Skip to content

Commit 5c848be

Browse files
committed
Initialize package
1 parent 1027f6d commit 5c848be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+12063
-0
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../node_modules/@changesets/config/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "restricted",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": ["what-the-fetch-docs"]
11+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
28+
- OS: [e.g. iOS]
29+
- Browser [e.g. chrome, safari]
30+
- Version [e.g. 22]
31+
32+
**Smartphone (please complete the following information):**
33+
34+
- Device: [e.g. iPhone6]
35+
- OS: [e.g. iOS8.1]
36+
- Browser [e.g. stock browser, safari]
37+
- Version [e.g. 22]
38+
39+
**Additional context**
40+
Add any other context about the problem here.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
**Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
12+
**Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**Additional context**
19+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!--
2+
Thanks for submitting a pull request!
3+
We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request.
4+
5+
Before submitting a pull request, please make sure the following is done:
6+
7+
1. Fork [the repository](https://github.com/hckhanh/what-the-fetch) and create your branch from `main`.
8+
2. Run `npm install` in the repository root.
9+
3. If you've fixed a bug or added code that should be tested, add tests!
10+
4. Ensure the test suite passes (`npm test`).
11+
5. Format your code with `npm run format`.
12+
6. Build the package with `npm run build`.
13+
-->
14+
15+
## Summary
16+
17+
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
18+
19+
## Details
20+
21+
<!-- Please provide any further details necessary to review and test your code. -->

.github/copilot-instructions.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Copilot Instructions for what-the-fetch
2+
3+
## Project Overview
4+
5+
This is **what-the-fetch**, a type-safe API client library with schema validation using Standard Schema. The project provides end-to-end type inference for API requests and responses, integrating with popular schema validation libraries like Zod, Valibot, and ArkType.
6+
7+
## Installation & Setup
8+
9+
```bash
10+
# Install dependencies
11+
npm install
12+
13+
# Build the project
14+
npm run build
15+
16+
# Run tests
17+
npm test
18+
19+
# Format code
20+
npm run format
21+
```
22+
23+
## Code Style & Standards
24+
25+
### Formatter & Linter
26+
- **Biome** is used for both formatting and linting
27+
- Single quotes for strings
28+
- Semicolons only when needed (ASI style)
29+
- Arrow function parentheses always included
30+
- 2-space indentation
31+
- Run `npm run format` to auto-fix style issues
32+
33+
### TypeScript Guidelines
34+
- Use strict TypeScript with full type safety
35+
- Leverage type inference wherever possible
36+
- Use `type` for type aliases (not `interface`) for consistency
37+
- Include JSDoc comments for public APIs
38+
- Use `.ts` extension in imports (e.g., `from './types.ts'`)
39+
- Prefer `const` over `let`
40+
- Use `unknown` instead of `any` where possible
41+
42+
### Testing
43+
- Tests are located in the `test/` directory
44+
- Use Vitest as the test framework
45+
- Mock external dependencies (e.g., `global.fetch`)
46+
- Test file naming: `*.test.ts`
47+
- Include tests for:
48+
- Happy paths
49+
- Error cases
50+
- Edge cases
51+
- Type safety validations
52+
53+
## Project Structure
54+
55+
```
56+
src/
57+
├── index.ts # Main export and createFetch function
58+
├── types.ts # Type definitions
59+
└── utils.ts # Utility functions (e.g., validation)
60+
test/
61+
└── createFetch.test.ts # Test suite
62+
```
63+
64+
## Key Dependencies
65+
66+
- **@standard-schema/spec**: Standard Schema specification for validation
67+
- **fast-url**: URL building and parameter substitution
68+
- **vitest**: Testing framework
69+
- **biome**: Linting and formatting
70+
- **tsdown**: TypeScript bundler powered by rolldown
71+
72+
## Development Workflow
73+
74+
1. Make code changes in `src/`
75+
2. Add tests in `test/`
76+
3. Run `npm run format` to auto-format
77+
4. Run `npm test` to verify tests pass
78+
5. Run `npm run build` to ensure the build succeeds
79+
6. Add a changeset for release tracking (see below)
80+
81+
## Changesets
82+
83+
This project uses [Changesets](https://github.com/changesets/changesets) for version management and changelog generation.
84+
85+
### When to Add a Changeset
86+
87+
Add a changeset when you make changes that affect the public API or user-facing behavior:
88+
- Adding new features (minor version bump)
89+
- Fixing bugs (patch version bump)
90+
- Breaking changes (major version bump)
91+
- Performance improvements
92+
- Documentation changes that affect usage
93+
94+
### How to Add a Changeset
95+
96+
Run the following command and follow the interactive prompts:
97+
98+
```bash
99+
npx changeset add
100+
```
101+
102+
The CLI will ask you:
103+
1. **What type of change**: Select `patch`, `minor`, or `major`
104+
- **patch**: Bug fixes, documentation updates, internal improvements
105+
- **minor**: New features, backward-compatible changes
106+
- **major**: Breaking changes that require user code changes
107+
2. **Summary**: Provide a clear, concise summary of the change
108+
109+
### Changeset Best Practices
110+
111+
- **Be descriptive**: Write summaries that explain what changed and why
112+
- **Include examples**: For new features, include code examples in the changeset
113+
- **One changeset per PR**: Generally, create one changeset per pull request
114+
- **Edit the changeset file**: After creation, you can manually edit `.changeset/*.md` to add more details, examples, or formatting
115+
116+
### Changeset File Format
117+
118+
Changesets are stored in `.changeset/*.md` files with the following format:
119+
120+
```markdown
121+
---
122+
"what-the-fetch": minor
123+
---
124+
125+
Brief summary of the change
126+
127+
### Optional: Detailed Description
128+
129+
More details, code examples, migration guides, etc.
130+
```
131+
132+
## API Design Principles
133+
134+
- **Type Safety First**: All APIs must provide full type inference
135+
- **Standard Schema Compatible**: Work with any schema library implementing Standard Schema
136+
- **Minimal Surface Area**: Keep the API simple and focused
137+
- **Zero Breaking Changes**: Maintain backward compatibility
138+
- **Bundle Size**: Keep dependencies minimal and bundle size small
139+
140+
## Common Tasks
141+
142+
### Adding a New Feature
143+
1. Define types in `types.ts` if needed
144+
2. Implement functionality in `index.ts` or `utils.ts`
145+
3. Add JSDoc comments with examples
146+
4. Write comprehensive tests
147+
5. Update README.md if adding public APIs
148+
6. Add a changeset with `npx changeset add` (select "minor")
149+
150+
### Fixing a Bug
151+
1. Write a failing test that reproduces the bug
152+
2. Fix the bug in the source code
153+
3. Verify the test passes
154+
4. Add regression tests if needed
155+
5. Add a changeset with `npx changeset add` (select "patch")
156+
157+
### Refactoring
158+
1. Ensure all tests pass before starting
159+
2. Make incremental changes
160+
3. Run tests frequently
161+
4. Do not change public API signatures without careful consideration
162+
163+
## Important Notes
164+
165+
- This project uses **Bun** in CI but supports all package managers
166+
- The package is published to both npm and JSR (Deno)
167+
- The library must remain framework-agnostic
168+
- Response validation happens automatically when schemas are provided
169+
- Default method is GET; POST is used when body is present
170+
- Custom headers merge with default headers (Content-Type: application/json)

.github/workflows/autofix.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: autofix.ci
2+
3+
on:
4+
pull_request:
5+
branches-ignore:
6+
- 'renovate/**'
7+
push:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
apply:
16+
name: Apply automated fixes
17+
runs-on: ubuntu-latest
18+
if: ${{ github.actor != 'renovate[bot]' && ! contains(github.event.head_commit.author.name , 'renovate[bot]') && ! contains(github.event.head_commit.message , 'chore(release)') }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
22+
- name: Setup toolchains
23+
uses: jdx/mise-action@146a28175021df8ca24f8ee1828cc2a60f980bd5 # v3.5.1
24+
- name: Setup Socket Firewall
25+
uses: SocketDev/action@4337a545deecc20f19a909e52db7a2f6ba292f42 # v1.2.0
26+
with:
27+
mode: firewall
28+
- name: Optimize dependencies with @socketregistry overrides
29+
run: socket optimize
30+
- name: Format code
31+
run: bun biome check --write
32+
- name: Fix package.json
33+
run: bun syncpack fix
34+
- name: Format package.json
35+
run: bun syncpack format
36+
- name: Update package lock file
37+
run: sfw bun install
38+
- name: Submit autofix
39+
uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # v1.3.2
40+
with:
41+
fail-fast: false

.github/workflows/codeql.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: 'CodeQL'
13+
14+
on:
15+
push:
16+
branches: ['main']
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: ['main']
20+
schedule:
21+
- cron: '0 0 * * 1'
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
analyze:
28+
name: Analyze
29+
runs-on: ubuntu-latest
30+
permissions:
31+
actions: read
32+
contents: read
33+
security-events: write
34+
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
language: ['typescript']
39+
# CodeQL supports [ $supported-codeql-languages ]
40+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
41+
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
45+
46+
# Initializes the CodeQL tools for scanning.
47+
- name: Initialize CodeQL
48+
uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
49+
with:
50+
languages: ${{ matrix.language }}
51+
# If you wish to specify custom queries, you can do so here or in a config file.
52+
# By default, queries listed here will override any specified in a config file.
53+
# Prefix the list here with "+" to use these queries and those in the config file.
54+
55+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
56+
# If this step fails, then you should remove it and run the build manually (see below)
57+
- name: Autobuild
58+
uses: github/codeql-action/autobuild@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
59+
60+
# ℹ️ Command-line programs to run using the OS shell.
61+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
62+
63+
# If the Autobuild fails above, remove it and uncomment the following three lines.
64+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
65+
66+
# - run: |
67+
# echo "Run, Build Application using script"
68+
# ./location_of_script_within_repo/buildscript.sh
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
72+
with:
73+
category: '/language:${{matrix.language}}'

0 commit comments

Comments
 (0)