@codecks/fetch 1.0.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -32
- package/dist/_exploration/api-requester.d.ts +3 -4
- package/dist/_exploration/api-requester.js +2 -2
- package/dist/_exploration/create-hooks.d.ts +4313 -13097
- package/dist/_exploration/create-hooks.js +1 -1
- package/dist/_exploration/loader.d.ts +2 -2
- package/dist/_exploration/loader.js +1 -1
- package/dist/_exploration/store.d.ts +5 -4
- package/dist/_exploration/store.js +1 -1
- package/dist/{collection-utils-KmtGUuXm.js → collection-utils-y85xawyq.js} +4 -2
- package/dist/index-iEtXFnkY.d.ts +39 -0
- package/dist/index.d.ts +4 -19
- package/dist/index.js +26 -15
- package/dist/{loader-types-fd5tV0FD.d.ts → loader-types-CIO8hJAv.d.ts} +1 -1
- package/dist/loader-utils-DdrmVo0F.d.ts +2218 -0
- package/dist/query-helpers-DndWBcMF.js +1203 -0
- package/dist/{query-type-BqQ9oX_U.d.ts → query-type-CwrwqxUP.d.ts} +30 -15
- package/dist/store-Dpx1yvWU.d.ts +1203 -0
- package/package.json +2 -1
- package/schema/actions.md +789 -0
- package/schema/models/account.md +57 -90
- package/schema/models/attachment.md +15 -11
- package/schema/models/card.md +91 -65
- package/schema/models/cardHistory.md +15 -9
- package/schema/models/deck.md +41 -36
- package/schema/models/file.md +13 -15
- package/schema/models/handCard.md +8 -5
- package/schema/models/milestone.md +27 -22
- package/schema/models/milestoneProgress.md +9 -3
- package/schema/models/milestoneProject.md +6 -4
- package/schema/models/project.md +15 -39
- package/schema/models/projectTag.md +12 -7
- package/schema/models/queueEntry.md +12 -8
- package/schema/models/release.md +8 -6
- package/schema/models/resolvable.md +19 -15
- package/schema/models/resolvableEntry.md +16 -13
- package/schema/models/resolvableEntryReaction.md +16 -12
- package/schema/models/sprint.md +35 -25
- package/schema/models/sprintConfig.md +24 -20
- package/schema/models/sprintConfigProgress.md +9 -3
- package/schema/models/sprintProgress.md +9 -3
- package/schema/models/sprintProject.md +7 -5
- package/schema/models/user.md +15 -56
- package/schema/models/workflowItem.md +47 -31
- package/schema/overview.md +40 -93
- package/schema/query-syntax.md +1 -1
- package/schema/types.md +103 -0
- package/dist/_root-BW9uzB79.d.ts +0 -34
- package/dist/index-k-KPWV9R.d.ts +0 -2680
- package/dist/loader-utils-hvdC-xsQ.d.ts +0 -42
- package/dist/query-helpers-iX1fiqLv.js +0 -3062
- package/dist/store-BvEJzUVp.d.ts +0 -2667
- package/schema/models/accountOnboarding.md +0 -15
- package/schema/models/accountOnboardingStep.md +0 -14
- package/schema/models/accountRole.md +0 -19
- package/schema/models/accountUserAchievement.md +0 -17
- package/schema/models/accountUserSetting.md +0 -20
- package/schema/models/activeTimeTracker.md +0 -19
- package/schema/models/activity.md +0 -30
- package/schema/models/affiliateCode.md +0 -30
- package/schema/models/affiliateCodeStat.md +0 -19
- package/schema/models/app.md +0 -10
- package/schema/models/appInstallation.md +0 -19
- package/schema/models/assigneeAssignment.md +0 -18
- package/schema/models/assigneeDeckAssignment.md +0 -20
- package/schema/models/autoFinishedTimeTrackingSegment.md +0 -20
- package/schema/models/cardDiffNotification.md +0 -22
- package/schema/models/cardOrder.md +0 -17
- package/schema/models/cardOrderInDeck.md +0 -18
- package/schema/models/cardPreset.md +0 -19
- package/schema/models/cardSubscription.md +0 -19
- package/schema/models/cardUpvote.md +0 -21
- package/schema/models/cardsEffortHistory.md +0 -9
- package/schema/models/cardsFinishedHistory.md +0 -16
- package/schema/models/cardsStatusHistory.md +0 -9
- package/schema/models/cardsTimeToFinished.md +0 -18
- package/schema/models/dailyDiscordGuildVoteMembership.md +0 -15
- package/schema/models/dailyPublicProjectMembership.md +0 -15
- package/schema/models/deckAssignment.md +0 -18
- package/schema/models/deckGuardian.md +0 -17
- package/schema/models/deckSubscription.md +0 -18
- package/schema/models/discordGuild.md +0 -30
- package/schema/models/discordMember.md +0 -21
- package/schema/models/discordProjectNotification.md +0 -19
- package/schema/models/discordSlashCommand.md +0 -28
- package/schema/models/dueCard.md +0 -18
- package/schema/models/integration.md +0 -23
- package/schema/models/invoice.md +0 -21
- package/schema/models/lastSeenCardUpvote.md +0 -17
- package/schema/models/pinnedMilestone.md +0 -22
- package/schema/models/projectOrder.md +0 -18
- package/schema/models/projectSelection.md +0 -18
- package/schema/models/projectUser.md +0 -18
- package/schema/models/projectUserSetting.md +0 -15
- package/schema/models/publicProjectInfo.md +0 -20
- package/schema/models/publicProjectMembership.md +0 -17
- package/schema/models/publicProjectVisit.md +0 -16
- package/schema/models/queueSelection.md +0 -19
- package/schema/models/resolvableEntryHistory.md +0 -20
- package/schema/models/resolvableNotification.md +0 -30
- package/schema/models/resolvableParticipant.md +0 -25
- package/schema/models/resolvableParticipantHistory.md +0 -23
- package/schema/models/savedSearch.md +0 -18
- package/schema/models/stripeAccountSync.md +0 -29
- package/schema/models/timeTrackingSegment.md +0 -24
- package/schema/models/timeTrackingSum.md +0 -18
- package/schema/models/userDismissedHint.md +0 -16
- package/schema/models/userEmail.md +0 -18
- package/schema/models/userInvitation.md +0 -20
- package/schema/models/userInviteCode.md +0 -23
- package/schema/models/userOnboarding.md +0 -14
- package/schema/models/userProjectAccess.md +0 -17
- package/schema/models/userReportEmail.md +0 -19
- package/schema/models/userReportSetting.md +0 -23
- package/schema/models/userReportToken.md +0 -18
- package/schema/models/userTag.md +0 -18
- package/schema/models/visionBoard.md +0 -21
- package/schema/models/visionBoardQuery.md +0 -22
- package/schema/models/wizard.md +0 -19
- package/schema/models/workflowItemHistory.md +0 -18
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @codecks/fetch
|
|
|
13
13
|
```ts
|
|
14
14
|
import {buildFetchers} from "@codecks/fetch";
|
|
15
15
|
|
|
16
|
-
const {fetchFromRoot, fetchInstance, fetchInstances, fetchFromInstance} = buildFetchers({
|
|
16
|
+
const {fetchFromRoot, fetchInstance, fetchInstances, fetchFromInstance, dispatch} = buildFetchers({
|
|
17
17
|
token: "cdxat_…",
|
|
18
18
|
});
|
|
19
19
|
```
|
|
@@ -61,7 +61,7 @@ before then.
|
|
|
61
61
|
|
|
62
62
|
### `fetchFromRoot` — query top-level relations
|
|
63
63
|
|
|
64
|
-
Use this to query entry points
|
|
64
|
+
Use this to query the entry points `account`, `loggedInUser` and `releases`.
|
|
65
65
|
|
|
66
66
|
```ts
|
|
67
67
|
const result = await fetchFromRoot({
|
|
@@ -105,9 +105,8 @@ const account = result.account;
|
|
|
105
105
|
// account has { ~model: "account", ~key: "1" }
|
|
106
106
|
|
|
107
107
|
const details = await fetchFromInstance(account, {
|
|
108
|
-
fields: ["seats", "activeProjectCount"],
|
|
109
108
|
relations: {
|
|
110
|
-
|
|
109
|
+
projects: {fields: ["name"]},
|
|
111
110
|
},
|
|
112
111
|
});
|
|
113
112
|
```
|
|
@@ -121,22 +120,19 @@ const result = await fetchFromRoot({
|
|
|
121
120
|
account: {
|
|
122
121
|
fields: ["name"],
|
|
123
122
|
relations: {
|
|
124
|
-
// belongsTo — returns a single object (or null if optional)
|
|
125
|
-
disabledBy: {fields: ["name"]},
|
|
126
|
-
|
|
127
123
|
// hasMany — returns an array
|
|
128
|
-
|
|
129
|
-
fields: ["
|
|
124
|
+
cards: {
|
|
125
|
+
fields: ["title"],
|
|
130
126
|
relations: {
|
|
131
|
-
|
|
127
|
+
// belongsTo — returns a single object (or null if optional)
|
|
128
|
+
assignee: {fields: ["name", "fullName"]},
|
|
132
129
|
},
|
|
133
130
|
},
|
|
134
131
|
},
|
|
135
132
|
},
|
|
136
133
|
});
|
|
137
134
|
|
|
138
|
-
// result.account.
|
|
139
|
-
// result.account.roles[0].user.name
|
|
135
|
+
// result.account.cards[0].assignee?.name
|
|
140
136
|
```
|
|
141
137
|
|
|
142
138
|
## hasMany variants
|
|
@@ -147,32 +143,32 @@ hasMany relations support several query modes. Non-default variants require an `
|
|
|
147
143
|
|
|
148
144
|
```ts
|
|
149
145
|
relations: {
|
|
150
|
-
|
|
151
|
-
fields: ["
|
|
152
|
-
orderBy: "-
|
|
146
|
+
cards: {
|
|
147
|
+
fields: ["title"],
|
|
148
|
+
orderBy: "-createdAt",
|
|
153
149
|
limit: 10,
|
|
154
150
|
offset: 0,
|
|
155
151
|
},
|
|
156
152
|
}
|
|
157
|
-
// result.
|
|
153
|
+
// result.cards: Array<{title: string, ...}>
|
|
158
154
|
```
|
|
159
155
|
|
|
160
156
|
### Count
|
|
161
157
|
|
|
162
158
|
```ts
|
|
163
159
|
relations: {
|
|
164
|
-
|
|
160
|
+
cards: {type: "count", as: "cardCount"},
|
|
165
161
|
}
|
|
166
|
-
// result.
|
|
162
|
+
// result.cardCount: number
|
|
167
163
|
```
|
|
168
164
|
|
|
169
165
|
### Exists
|
|
170
166
|
|
|
171
167
|
```ts
|
|
172
168
|
relations: {
|
|
173
|
-
|
|
169
|
+
cards: {type: "exists", as: "hasCards"},
|
|
174
170
|
}
|
|
175
|
-
// result.
|
|
171
|
+
// result.hasCards: boolean
|
|
176
172
|
```
|
|
177
173
|
|
|
178
174
|
### First
|
|
@@ -181,14 +177,14 @@ Returns a single result or `null`. Requires `orderBy`.
|
|
|
181
177
|
|
|
182
178
|
```ts
|
|
183
179
|
relations: {
|
|
184
|
-
|
|
180
|
+
cards: {
|
|
185
181
|
type: "first",
|
|
186
|
-
as: "
|
|
187
|
-
orderBy: "-
|
|
188
|
-
fields: ["
|
|
182
|
+
as: "newestCard",
|
|
183
|
+
orderBy: "-createdAt",
|
|
184
|
+
fields: ["title"],
|
|
189
185
|
},
|
|
190
186
|
}
|
|
191
|
-
// result.
|
|
187
|
+
// result.newestCard: {title: string, ...} | null
|
|
192
188
|
```
|
|
193
189
|
|
|
194
190
|
### Multiple queries on the same relation
|
|
@@ -197,13 +193,13 @@ Pass an array of aliased queries to query the same relation in different ways:
|
|
|
197
193
|
|
|
198
194
|
```ts
|
|
199
195
|
relations: {
|
|
200
|
-
|
|
201
|
-
{as: "
|
|
202
|
-
{as: "
|
|
196
|
+
cards: [
|
|
197
|
+
{as: "startedCards", fields: ["title"], filter: {status: "started"}},
|
|
198
|
+
{as: "cardCount", type: "count"},
|
|
203
199
|
],
|
|
204
200
|
}
|
|
205
|
-
// result.
|
|
206
|
-
// result.
|
|
201
|
+
// result.startedCards: Array<...>
|
|
202
|
+
// result.cardCount: number
|
|
207
203
|
```
|
|
208
204
|
|
|
209
205
|
## Filtering
|
|
@@ -231,7 +227,7 @@ filter: {
|
|
|
231
227
|
|
|
232
228
|
```ts
|
|
233
229
|
filter: {
|
|
234
|
-
createdAt: {op: "gt", value: "2025-01-01"},
|
|
230
|
+
createdAt: {op: "gt", value: new Date("2025-01-01")},
|
|
235
231
|
effort: {op: "lte", value: 5},
|
|
236
232
|
}
|
|
237
233
|
```
|
|
@@ -328,14 +324,62 @@ const card = await fetchInstance("card", "card-123", {
|
|
|
328
324
|
|
|
329
325
|
All response types are fully inferred from your query — TypeScript knows exactly which fields and relations are present.
|
|
330
326
|
|
|
327
|
+
## Writing data
|
|
328
|
+
|
|
329
|
+
Every change is an action of the API, called with `dispatch(name, params)`. The name is the one
|
|
330
|
+
the [API Reference](https://manual.codecks.io/api-reference/#actions) lists, and the params and the
|
|
331
|
+
response are typed from it.
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
const {id, accountSeq} = await dispatch("cards/create", {content: "Fix login\nDetails…", deckId});
|
|
335
|
+
await dispatch("cards/update", {id, status: "done", assigneeId: null});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
- **Optional and nullable params**: left out, a value stays as it is; `null` clears it.
|
|
339
|
+
- **Enums in params are closed**: `status: "snoozing"` is a type error, since the API only accepts
|
|
340
|
+
the listed values. Enums the API answers stay open, see [Field types](#field-types).
|
|
341
|
+
- **Response**: an action without one resolves to `undefined`.
|
|
342
|
+
- **Errors**: a refused action throws a `CodecksApiError` with the reason as its message, e.g.
|
|
343
|
+
`[403] requires card:write` for a read-only token. A missing scope has the `code`
|
|
344
|
+
`missing_scope` and the scope in `body.requiredScope`.
|
|
345
|
+
|
|
346
|
+
Each action's JSDoc holds its description and the token scopes it needs. `ActionMap`,
|
|
347
|
+
`ActionName`, `ActionParams<N>` and `ActionResponse<N>` are exported for wrapping `dispatch`.
|
|
348
|
+
|
|
349
|
+
`dispatch` doesn't change what the `fetch*` functions return: they always ask the API again.
|
|
350
|
+
|
|
351
|
+
## Stability
|
|
352
|
+
|
|
353
|
+
The models and fields in this package are the ones the [API Reference](https://manual.codecks.io/api-reference/) documents. The API answers more than that, but anything undocumented is internal and can change without notice, so this package leaves it out.
|
|
354
|
+
|
|
355
|
+
- **stable** — changes only after a deprecation and 6 months' notice, see [Stability](https://manual.codecks.io/api/#stability).
|
|
356
|
+
- **preview** — may change in any release, listed in the [API changelog](https://manual.codecks.io/api-changelog/). The types mark these `@experimental`.
|
|
357
|
+
- **deprecated** — the types mark these `@deprecated`, with the removal date and what to use instead, so editors strike them through.
|
|
358
|
+
|
|
359
|
+
## Field types
|
|
360
|
+
|
|
361
|
+
Field types come from the API Reference's schemas.
|
|
362
|
+
|
|
363
|
+
- **Enums are open unions**: `card.status` is `"not_started" | "started" | "snoozing" | "done" | (string & {})`. The values autocomplete, but the API may add new ones, so a `switch` over one isn't exhaustive. Keep a `default` branch.
|
|
364
|
+
- **Ids are nominal**: `CardId`, `UserId`, … can't be mixed up, also inside arrays and maps (`card.mentionedUsers: UserId[]`, `milestone.userCapacities: {[userId: UserId]: number}`).
|
|
365
|
+
- **Dates**: a top-level timestamp is a `Date`, a day is `{year, month, day}`, except a day that is part of a key (`milestoneProgress.date`), which stays a string. Inside a json value (e.g. an entry of an array field) they stay ISO strings.
|
|
366
|
+
|
|
367
|
+
The reference's named types and every id type are exported, so you can use them in your own code:
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
import type {CardId, Checkbox, Priority, UserId} from "@codecks/fetch";
|
|
371
|
+
```
|
|
372
|
+
|
|
331
373
|
## Schema reference for LLMs
|
|
332
374
|
|
|
333
|
-
This package ships with generated markdown files describing every API model, its fields, and relations. These are designed for LLM-based tools (Claude Code, Cursor, Copilot, etc.) that need to discover the API schema without relying on TypeScript autocomplete.
|
|
375
|
+
This package ships with generated markdown files describing every documented API model, its fields, and relations, with the same stability markers. These are designed for LLM-based tools (Claude Code, Cursor, Copilot, etc.) that need to discover the API schema without relying on TypeScript autocomplete.
|
|
334
376
|
|
|
335
377
|
```
|
|
336
378
|
node_modules/@codecks/fetch/schema/
|
|
337
379
|
overview.md # Root entry points + index of all models
|
|
338
380
|
query-syntax.md # Query DSL reference with examples
|
|
381
|
+
types.md # Named types (Priority, Checkbox, ...) the model files link to
|
|
382
|
+
actions.md # Every action with its params, response and required scopes
|
|
339
383
|
models/
|
|
340
384
|
card.md # Fields + relations for the card model
|
|
341
385
|
account.md # Fields + relations for the account model
|
|
@@ -356,5 +400,9 @@ const {fetchFromRoot} = buildFetchersFromLoader({
|
|
|
356
400
|
// your custom loading logic
|
|
357
401
|
return recordOfResults;
|
|
358
402
|
},
|
|
403
|
+
dispatch: async (name, params) => {
|
|
404
|
+
// POST params to `dispatch/${name}`, return the answer's `payload`
|
|
405
|
+
return payload;
|
|
406
|
+
},
|
|
359
407
|
});
|
|
360
408
|
```
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "../query-type-
|
|
2
|
-
import "../
|
|
3
|
-
import {
|
|
4
|
-
import { BaseRequester, MissingDataRequest } from "../loader-types-fd5tV0FD.js";
|
|
1
|
+
import "../query-type-CwrwqxUP.js";
|
|
2
|
+
import { FetchOptions } from "../loader-utils-DdrmVo0F.js";
|
|
3
|
+
import { BaseRequester, MissingDataRequest } from "../loader-types-CIO8hJAv.js";
|
|
5
4
|
|
|
6
5
|
//#region src/_exploration/api-requester.d.ts
|
|
7
6
|
declare class ApiRequester implements BaseRequester {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bearerTransport, configuredFetch, ensureMapValue } from "../collection-utils-
|
|
2
|
-
import { serializeModel } from "../query-helpers-
|
|
1
|
+
import { bearerTransport, configuredFetch, ensureMapValue } from "../collection-utils-y85xawyq.js";
|
|
2
|
+
import { serializeModel } from "../query-helpers-DndWBcMF.js";
|
|
3
3
|
|
|
4
4
|
//#region src/_exploration/utils/concurrency-limiter.ts
|
|
5
5
|
var ConcurrencyLimiter = class {
|