@codecks/fetch 0.1.5 → 0.1.7
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 +317 -10
- package/dist/_exploration/api-requester.d.ts +4 -4
- package/dist/_exploration/api-requester.js +5 -4
- package/dist/_exploration/create-hooks.d.ts +47 -5
- package/dist/_exploration/create-hooks.js +193 -88
- package/dist/_exploration/loader.d.ts +2 -2
- package/dist/_exploration/loader.js +7 -2
- package/dist/_exploration/store.d.ts +4 -4
- package/dist/_exploration/store.js +76 -73
- package/dist/{_root-D1Faf8cg.d.ts → _root-BW9uzB79.d.ts} +1 -1
- package/dist/immediate-cache-DiH8tpJM.js +237 -0
- package/dist/{index-DUBsesYl.d.ts → index-k-KPWV9R.d.ts} +8 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -5
- package/dist/{loader-types-Dp0CSVTf.d.ts → loader-types-fd5tV0FD.d.ts} +4 -8
- package/dist/{loader-utils-Du-CTKH-.d.ts → loader-utils-BqZKAn_v.d.ts} +2 -2
- package/dist/{query-helpers-DsMMOtSO.js → query-helpers-iX1fiqLv.js} +41 -16
- package/dist/{query-type-Dx5ZCv5N.d.ts → query-type-BqQ9oX_U.d.ts} +55 -10
- package/dist/{store-B6JWZnAO.d.ts → store-BvEJzUVp.d.ts} +104 -6
- package/package.json +4 -3
- package/schema/models/account.md +104 -0
- package/schema/models/accountOnboarding.md +15 -0
- package/schema/models/accountOnboardingStep.md +14 -0
- package/schema/models/accountRole.md +19 -0
- package/schema/models/accountUserAchievement.md +17 -0
- package/schema/models/accountUserSetting.md +20 -0
- package/schema/models/activeTimeTracker.md +19 -0
- package/schema/models/activity.md +30 -0
- package/schema/models/affiliateCode.md +30 -0
- package/schema/models/affiliateCodeStat.md +19 -0
- package/schema/models/app.md +10 -0
- package/schema/models/appInstallation.md +19 -0
- package/schema/models/assigneeAssignment.md +18 -0
- package/schema/models/assigneeDeckAssignment.md +20 -0
- package/schema/models/attachment.md +23 -0
- package/schema/models/autoFinishedTimeTrackingSegment.md +20 -0
- package/schema/models/card.md +82 -0
- package/schema/models/cardDiffNotification.md +22 -0
- package/schema/models/cardHistory.md +20 -0
- package/schema/models/cardOrder.md +17 -0
- package/schema/models/cardOrderInDeck.md +18 -0
- package/schema/models/cardPreset.md +19 -0
- package/schema/models/cardSubscription.md +19 -0
- package/schema/models/cardUpvote.md +21 -0
- package/schema/models/cardsEffortHistory.md +9 -0
- package/schema/models/cardsFinishedHistory.md +16 -0
- package/schema/models/cardsStatusHistory.md +9 -0
- package/schema/models/cardsTimeToFinished.md +18 -0
- package/schema/models/dailyDiscordGuildVoteMembership.md +15 -0
- package/schema/models/dailyPublicProjectMembership.md +15 -0
- package/schema/models/deck.md +53 -0
- package/schema/models/deckAssignment.md +18 -0
- package/schema/models/deckGuardian.md +17 -0
- package/schema/models/deckSubscription.md +18 -0
- package/schema/models/discordGuild.md +30 -0
- package/schema/models/discordMember.md +21 -0
- package/schema/models/discordProjectNotification.md +19 -0
- package/schema/models/discordSlashCommand.md +28 -0
- package/schema/models/dueCard.md +18 -0
- package/schema/models/file.md +26 -0
- package/schema/models/handCard.md +18 -0
- package/schema/models/integration.md +23 -0
- package/schema/models/invoice.md +21 -0
- package/schema/models/lastSeenCardUpvote.md +17 -0
- package/schema/models/milestone.md +39 -0
- package/schema/models/milestoneProgress.md +14 -0
- package/schema/models/milestoneProject.md +17 -0
- package/schema/models/pinnedMilestone.md +22 -0
- package/schema/models/project.md +58 -0
- package/schema/models/projectOrder.md +18 -0
- package/schema/models/projectSelection.md +18 -0
- package/schema/models/projectTag.md +19 -0
- package/schema/models/projectUser.md +18 -0
- package/schema/models/projectUserSetting.md +15 -0
- package/schema/models/publicProjectInfo.md +20 -0
- package/schema/models/publicProjectMembership.md +17 -0
- package/schema/models/publicProjectVisit.md +16 -0
- package/schema/models/queueEntry.md +21 -0
- package/schema/models/queueSelection.md +19 -0
- package/schema/models/release.md +12 -0
- package/schema/models/resolvable.md +32 -0
- package/schema/models/resolvableEntry.md +28 -0
- package/schema/models/resolvableEntryHistory.md +20 -0
- package/schema/models/resolvableEntryReaction.md +23 -0
- package/schema/models/resolvableNotification.md +30 -0
- package/schema/models/resolvableParticipant.md +25 -0
- package/schema/models/resolvableParticipantHistory.md +23 -0
- package/schema/models/savedSearch.md +18 -0
- package/schema/models/sprint.md +42 -0
- package/schema/models/sprintConfig.md +38 -0
- package/schema/models/sprintConfigProgress.md +14 -0
- package/schema/models/sprintProgress.md +14 -0
- package/schema/models/sprintProject.md +17 -0
- package/schema/models/stripeAccountSync.md +29 -0
- package/schema/models/timeTrackingSegment.md +24 -0
- package/schema/models/timeTrackingSum.md +18 -0
- package/schema/models/user.md +67 -0
- package/schema/models/userDismissedHint.md +16 -0
- package/schema/models/userEmail.md +18 -0
- package/schema/models/userInvitation.md +20 -0
- package/schema/models/userInviteCode.md +23 -0
- package/schema/models/userOnboarding.md +14 -0
- package/schema/models/userProjectAccess.md +17 -0
- package/schema/models/userReportEmail.md +19 -0
- package/schema/models/userReportSetting.md +23 -0
- package/schema/models/userReportToken.md +18 -0
- package/schema/models/userTag.md +18 -0
- package/schema/models/visionBoard.md +21 -0
- package/schema/models/visionBoardQuery.md +22 -0
- package/schema/models/wizard.md +19 -0
- package/schema/models/workflowItem.md +45 -0
- package/schema/models/workflowItemHistory.md +18 -0
- package/schema/overview.md +110 -0
- package/schema/query-syntax.md +184 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Query Syntax Reference
|
|
2
|
+
|
|
3
|
+
## Basic Query
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
const {fetchFromRoot, fetchInstance} = buildFetchersWithSimpleLoader({
|
|
7
|
+
token: "your-api-token",
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// Fetch from root entry points
|
|
11
|
+
const result = await fetchFromRoot({
|
|
12
|
+
account: {fields: ["name", "subdomain"]},
|
|
13
|
+
});
|
|
14
|
+
// result.account.name, result.account.subdomain
|
|
15
|
+
|
|
16
|
+
// Fetch a specific instance by model + ID
|
|
17
|
+
const card = await fetchInstance("card", cardId, {
|
|
18
|
+
fields: ["title", "status", "effort"],
|
|
19
|
+
});
|
|
20
|
+
// card.title, card.status, card.effort
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Field Selection
|
|
24
|
+
|
|
25
|
+
`fields` is an array of field names to include in the response.
|
|
26
|
+
Key fields (like `cardId` for card, `id` for most models) are always returned.
|
|
27
|
+
The meta fields `~model` and `~key` are always included.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
{fields: ["title", "status", "createdAt"]}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Nested Relations
|
|
34
|
+
|
|
35
|
+
Use `relations` to traverse the object graph:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const result = await fetchFromRoot({
|
|
39
|
+
account: {
|
|
40
|
+
fields: ["name"],
|
|
41
|
+
relations: {
|
|
42
|
+
cards: {
|
|
43
|
+
fields: ["title", "status"],
|
|
44
|
+
relations: {
|
|
45
|
+
assignee: {fields: ["name"]},
|
|
46
|
+
deck: {fields: ["title"]},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## hasMany Variants
|
|
55
|
+
|
|
56
|
+
hasMany relations support different query types:
|
|
57
|
+
|
|
58
|
+
### Default (array)
|
|
59
|
+
```ts
|
|
60
|
+
{cards: {fields: ["title", "status"]}}
|
|
61
|
+
// returns: cards: Array<{title, status, ...}>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### count
|
|
65
|
+
```ts
|
|
66
|
+
{cards: {type: "count", as: "cardCount"}}
|
|
67
|
+
// returns: cardCount: number
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### exists
|
|
71
|
+
```ts
|
|
72
|
+
{cards: {type: "exists", as: "hasCards"}}
|
|
73
|
+
// returns: hasCards: boolean
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### first
|
|
77
|
+
```ts
|
|
78
|
+
{cards: {type: "first", as: "latestCard", orderBy: "-createdAt", fields: ["title"]}}
|
|
79
|
+
// returns: latestCard: {title, ...} | null
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Multiple variants of the same relation
|
|
83
|
+
Pass an array of queries with `as` aliases:
|
|
84
|
+
```ts
|
|
85
|
+
{
|
|
86
|
+
cards: [
|
|
87
|
+
{as: "openCards", filter: {status: "started"}, fields: ["title"]},
|
|
88
|
+
{as: "cardCount", type: "count"},
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
// returns: openCards: Array<...>, cardCount: number
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Filtering (hasMany only)
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
{
|
|
98
|
+
cards: {
|
|
99
|
+
fields: ["title"],
|
|
100
|
+
filter: {
|
|
101
|
+
status: "started", // exact match
|
|
102
|
+
effort: {op: "gte", value: 3}, // comparison: lt, lte, gt, gte
|
|
103
|
+
assigneeId: {op: "eq", value: userId}, // equality: eq, neq (supports null)
|
|
104
|
+
tags: {op: "has", value: "bug"}, // array contains
|
|
105
|
+
title: {op: "contains", value: "search"}, // string contains
|
|
106
|
+
priority: {op: "in", value: ["high", "critical"]}, // in set
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Logical operators
|
|
113
|
+
```ts
|
|
114
|
+
{
|
|
115
|
+
cards: {
|
|
116
|
+
fields: ["title"],
|
|
117
|
+
filter: {
|
|
118
|
+
$or: [
|
|
119
|
+
{status: "started"},
|
|
120
|
+
{status: "done"},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Filter by relation
|
|
128
|
+
```ts
|
|
129
|
+
{
|
|
130
|
+
cards: {
|
|
131
|
+
fields: ["title"],
|
|
132
|
+
filter: {
|
|
133
|
+
assignee: {name: "Alice"}, // cards where assignee.name = "Alice"
|
|
134
|
+
"!deck": {isDeleted: "true"}, // negated: cards NOT in deleted decks
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Ordering (hasMany only)
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
// Simple: field name, prefix with - for descending
|
|
144
|
+
{cards: {fields: ["title"], orderBy: "createdAt"}}
|
|
145
|
+
{cards: {fields: ["title"], orderBy: "-createdAt"}}
|
|
146
|
+
|
|
147
|
+
// Multiple
|
|
148
|
+
{cards: {fields: ["title"], orderBy: ["status", "-createdAt"]}}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Pagination (hasMany only)
|
|
152
|
+
|
|
153
|
+
A subset (`limit`/`offset`) requires an `orderBy` — the API rejects a subset
|
|
154
|
+
without an order. `offset` is only meaningful together with `limit`. The types
|
|
155
|
+
enforce this, so `limit` on its own is a compile error.
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
{cards: {fields: ["title"], orderBy: "-createdAt", limit: 10, offset: 20}}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## `fkAsArray` relations (limited capabilities)
|
|
162
|
+
|
|
163
|
+
A handful of hasMany relations are stored server-side as a plain id-array column
|
|
164
|
+
rather than a joined table. These are flagged as `fkAsArray` on their model
|
|
165
|
+
pages and currently are:
|
|
166
|
+
|
|
167
|
+
- `card`: `childCards`, `inDeps`, `outDeps`, `cardReferences`, `attachments`
|
|
168
|
+
- `workflowItem`: `inDeps`, `outDeps`
|
|
169
|
+
|
|
170
|
+
They support **only** plain selection (`fields` + nested `relations`) and the
|
|
171
|
+
`count`/`exists` aggregates. `filter`, `orderBy`, `limit`, `offset`, and
|
|
172
|
+
`type: "first"` are not supported (the API rejects them), and the types reflect
|
|
173
|
+
that.
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
{childCards: {fields: ["cardId"]}} // OK → array
|
|
177
|
+
{childCards: {type: "count", as: "n"}} // OK → number
|
|
178
|
+
{childCards: {type: "exists", as: "hasChildren"}} // OK → boolean
|
|
179
|
+
|
|
180
|
+
// compile errors:
|
|
181
|
+
{childCards: {fields: ["cardId"], orderBy: "accountSeq"}}
|
|
182
|
+
{childCards: {fields: ["cardId"], limit: 50, orderBy: "accountSeq"}}
|
|
183
|
+
{childCards: {fields: ["cardId"], filter: {status: "started"}}}
|
|
184
|
+
```
|