@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.
Files changed (114) hide show
  1. package/README.md +317 -10
  2. package/dist/_exploration/api-requester.d.ts +4 -4
  3. package/dist/_exploration/api-requester.js +5 -4
  4. package/dist/_exploration/create-hooks.d.ts +47 -5
  5. package/dist/_exploration/create-hooks.js +193 -88
  6. package/dist/_exploration/loader.d.ts +2 -2
  7. package/dist/_exploration/loader.js +7 -2
  8. package/dist/_exploration/store.d.ts +4 -4
  9. package/dist/_exploration/store.js +76 -73
  10. package/dist/{_root-D1Faf8cg.d.ts → _root-BW9uzB79.d.ts} +1 -1
  11. package/dist/immediate-cache-DiH8tpJM.js +237 -0
  12. package/dist/{index-DUBsesYl.d.ts → index-k-KPWV9R.d.ts} +8 -1
  13. package/dist/index.d.ts +4 -4
  14. package/dist/index.js +6 -5
  15. package/dist/{loader-types-Dp0CSVTf.d.ts → loader-types-fd5tV0FD.d.ts} +4 -8
  16. package/dist/{loader-utils-Du-CTKH-.d.ts → loader-utils-BqZKAn_v.d.ts} +2 -2
  17. package/dist/{query-helpers-DsMMOtSO.js → query-helpers-iX1fiqLv.js} +41 -16
  18. package/dist/{query-type-Dx5ZCv5N.d.ts → query-type-BqQ9oX_U.d.ts} +55 -10
  19. package/dist/{store-B6JWZnAO.d.ts → store-BvEJzUVp.d.ts} +104 -6
  20. package/package.json +4 -3
  21. package/schema/models/account.md +104 -0
  22. package/schema/models/accountOnboarding.md +15 -0
  23. package/schema/models/accountOnboardingStep.md +14 -0
  24. package/schema/models/accountRole.md +19 -0
  25. package/schema/models/accountUserAchievement.md +17 -0
  26. package/schema/models/accountUserSetting.md +20 -0
  27. package/schema/models/activeTimeTracker.md +19 -0
  28. package/schema/models/activity.md +30 -0
  29. package/schema/models/affiliateCode.md +30 -0
  30. package/schema/models/affiliateCodeStat.md +19 -0
  31. package/schema/models/app.md +10 -0
  32. package/schema/models/appInstallation.md +19 -0
  33. package/schema/models/assigneeAssignment.md +18 -0
  34. package/schema/models/assigneeDeckAssignment.md +20 -0
  35. package/schema/models/attachment.md +23 -0
  36. package/schema/models/autoFinishedTimeTrackingSegment.md +20 -0
  37. package/schema/models/card.md +82 -0
  38. package/schema/models/cardDiffNotification.md +22 -0
  39. package/schema/models/cardHistory.md +20 -0
  40. package/schema/models/cardOrder.md +17 -0
  41. package/schema/models/cardOrderInDeck.md +18 -0
  42. package/schema/models/cardPreset.md +19 -0
  43. package/schema/models/cardSubscription.md +19 -0
  44. package/schema/models/cardUpvote.md +21 -0
  45. package/schema/models/cardsEffortHistory.md +9 -0
  46. package/schema/models/cardsFinishedHistory.md +16 -0
  47. package/schema/models/cardsStatusHistory.md +9 -0
  48. package/schema/models/cardsTimeToFinished.md +18 -0
  49. package/schema/models/dailyDiscordGuildVoteMembership.md +15 -0
  50. package/schema/models/dailyPublicProjectMembership.md +15 -0
  51. package/schema/models/deck.md +53 -0
  52. package/schema/models/deckAssignment.md +18 -0
  53. package/schema/models/deckGuardian.md +17 -0
  54. package/schema/models/deckSubscription.md +18 -0
  55. package/schema/models/discordGuild.md +30 -0
  56. package/schema/models/discordMember.md +21 -0
  57. package/schema/models/discordProjectNotification.md +19 -0
  58. package/schema/models/discordSlashCommand.md +28 -0
  59. package/schema/models/dueCard.md +18 -0
  60. package/schema/models/file.md +26 -0
  61. package/schema/models/handCard.md +18 -0
  62. package/schema/models/integration.md +23 -0
  63. package/schema/models/invoice.md +21 -0
  64. package/schema/models/lastSeenCardUpvote.md +17 -0
  65. package/schema/models/milestone.md +39 -0
  66. package/schema/models/milestoneProgress.md +14 -0
  67. package/schema/models/milestoneProject.md +17 -0
  68. package/schema/models/pinnedMilestone.md +22 -0
  69. package/schema/models/project.md +58 -0
  70. package/schema/models/projectOrder.md +18 -0
  71. package/schema/models/projectSelection.md +18 -0
  72. package/schema/models/projectTag.md +19 -0
  73. package/schema/models/projectUser.md +18 -0
  74. package/schema/models/projectUserSetting.md +15 -0
  75. package/schema/models/publicProjectInfo.md +20 -0
  76. package/schema/models/publicProjectMembership.md +17 -0
  77. package/schema/models/publicProjectVisit.md +16 -0
  78. package/schema/models/queueEntry.md +21 -0
  79. package/schema/models/queueSelection.md +19 -0
  80. package/schema/models/release.md +12 -0
  81. package/schema/models/resolvable.md +32 -0
  82. package/schema/models/resolvableEntry.md +28 -0
  83. package/schema/models/resolvableEntryHistory.md +20 -0
  84. package/schema/models/resolvableEntryReaction.md +23 -0
  85. package/schema/models/resolvableNotification.md +30 -0
  86. package/schema/models/resolvableParticipant.md +25 -0
  87. package/schema/models/resolvableParticipantHistory.md +23 -0
  88. package/schema/models/savedSearch.md +18 -0
  89. package/schema/models/sprint.md +42 -0
  90. package/schema/models/sprintConfig.md +38 -0
  91. package/schema/models/sprintConfigProgress.md +14 -0
  92. package/schema/models/sprintProgress.md +14 -0
  93. package/schema/models/sprintProject.md +17 -0
  94. package/schema/models/stripeAccountSync.md +29 -0
  95. package/schema/models/timeTrackingSegment.md +24 -0
  96. package/schema/models/timeTrackingSum.md +18 -0
  97. package/schema/models/user.md +67 -0
  98. package/schema/models/userDismissedHint.md +16 -0
  99. package/schema/models/userEmail.md +18 -0
  100. package/schema/models/userInvitation.md +20 -0
  101. package/schema/models/userInviteCode.md +23 -0
  102. package/schema/models/userOnboarding.md +14 -0
  103. package/schema/models/userProjectAccess.md +17 -0
  104. package/schema/models/userReportEmail.md +19 -0
  105. package/schema/models/userReportSetting.md +23 -0
  106. package/schema/models/userReportToken.md +18 -0
  107. package/schema/models/userTag.md +18 -0
  108. package/schema/models/visionBoard.md +21 -0
  109. package/schema/models/visionBoardQuery.md +22 -0
  110. package/schema/models/wizard.md +19 -0
  111. package/schema/models/workflowItem.md +45 -0
  112. package/schema/models/workflowItemHistory.md +18 -0
  113. package/schema/overview.md +110 -0
  114. 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
+ ```