@haverstack/core 0.40.0 → 0.42.0

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 (287) hide show
  1. package/README.md +121 -59
  2. package/dist/access.d.ts +34 -36
  3. package/dist/access.d.ts.map +1 -1
  4. package/dist/access.js +65 -42
  5. package/dist/access.js.map +1 -1
  6. package/dist/{combine.d.ts → adapter/combine.d.ts} +8 -1
  7. package/dist/adapter/combine.d.ts.map +1 -0
  8. package/dist/{combine.js → adapter/combine.js} +7 -0
  9. package/dist/adapter/combine.js.map +1 -0
  10. package/dist/{adapter-entry.d.ts → adapter/index.d.ts} +6 -5
  11. package/dist/adapter/index.d.ts.map +1 -0
  12. package/dist/{adapter-entry.js → adapter/index.js} +5 -4
  13. package/dist/adapter/index.js.map +1 -0
  14. package/dist/{sort.d.ts → adapter/sort.d.ts} +20 -20
  15. package/dist/adapter/sort.d.ts.map +1 -0
  16. package/dist/{sort.js → adapter/sort.js} +37 -27
  17. package/dist/adapter/sort.js.map +1 -0
  18. package/dist/associations/identity.d.ts +93 -0
  19. package/dist/associations/identity.d.ts.map +1 -0
  20. package/dist/associations/identity.js +198 -0
  21. package/dist/associations/identity.js.map +1 -0
  22. package/dist/associations/validation.d.ts +90 -0
  23. package/dist/associations/validation.d.ts.map +1 -0
  24. package/dist/associations/validation.js +339 -0
  25. package/dist/associations/validation.js.map +1 -0
  26. package/dist/attachment-records.d.ts +48 -0
  27. package/dist/attachment-records.d.ts.map +1 -0
  28. package/dist/attachment-records.js +52 -0
  29. package/dist/attachment-records.js.map +1 -0
  30. package/dist/collection.d.ts +182 -0
  31. package/dist/collection.d.ts.map +1 -0
  32. package/dist/collection.js +407 -0
  33. package/dist/collection.js.map +1 -0
  34. package/dist/content-match.d.ts +25 -0
  35. package/dist/content-match.d.ts.map +1 -0
  36. package/dist/content-match.js +51 -0
  37. package/dist/content-match.js.map +1 -0
  38. package/dist/content-translation.d.ts +42 -0
  39. package/dist/content-translation.d.ts.map +1 -0
  40. package/dist/content-translation.js +108 -0
  41. package/dist/content-translation.js.map +1 -0
  42. package/dist/did/did.d.ts.map +1 -0
  43. package/dist/{did.js → did/did.js} +3 -4
  44. package/dist/did/did.js.map +1 -0
  45. package/dist/{did-entry.d.ts → did/index.d.ts} +1 -1
  46. package/dist/did/index.d.ts.map +1 -0
  47. package/dist/{did-entry.js → did/index.js} +3 -3
  48. package/dist/did/index.js.map +1 -0
  49. package/dist/errors.d.ts +36 -63
  50. package/dist/errors.d.ts.map +1 -1
  51. package/dist/errors.js +35 -58
  52. package/dist/errors.js.map +1 -1
  53. package/dist/grants.d.ts +20 -43
  54. package/dist/grants.d.ts.map +1 -1
  55. package/dist/grants.js +71 -134
  56. package/dist/grants.js.map +1 -1
  57. package/dist/id.d.ts +13 -31
  58. package/dist/id.d.ts.map +1 -1
  59. package/dist/id.js +13 -31
  60. package/dist/id.js.map +1 -1
  61. package/dist/index.d.ts +14 -8
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +9 -5
  64. package/dist/index.js.map +1 -1
  65. package/dist/install.d.ts +141 -0
  66. package/dist/install.d.ts.map +1 -0
  67. package/dist/install.js +219 -0
  68. package/dist/install.js.map +1 -0
  69. package/dist/merge.d.ts.map +1 -1
  70. package/dist/merge.js +5 -11
  71. package/dist/merge.js.map +1 -1
  72. package/dist/migration-steps.d.ts +102 -0
  73. package/dist/migration-steps.d.ts.map +1 -0
  74. package/dist/migration-steps.js +293 -0
  75. package/dist/migration-steps.js.map +1 -0
  76. package/dist/query-validation.d.ts +28 -94
  77. package/dist/query-validation.d.ts.map +1 -1
  78. package/dist/query-validation.js +156 -336
  79. package/dist/query-validation.js.map +1 -1
  80. package/dist/record-changes.d.ts +2 -117
  81. package/dist/record-changes.d.ts.map +1 -1
  82. package/dist/record-changes.js +10 -212
  83. package/dist/record-changes.js.map +1 -1
  84. package/dist/schema.d.ts +18 -7
  85. package/dist/schema.d.ts.map +1 -1
  86. package/dist/schema.js +59 -30
  87. package/dist/schema.js.map +1 -1
  88. package/dist/scoped-stack/authority.d.ts +156 -0
  89. package/dist/scoped-stack/authority.d.ts.map +1 -0
  90. package/dist/scoped-stack/authority.js +384 -0
  91. package/dist/scoped-stack/authority.js.map +1 -0
  92. package/dist/scoped-stack/scoped-stack.d.ts +338 -0
  93. package/dist/scoped-stack/scoped-stack.d.ts.map +1 -0
  94. package/dist/scoped-stack/scoped-stack.js +776 -0
  95. package/dist/scoped-stack/scoped-stack.js.map +1 -0
  96. package/dist/scoped-stack/subscription.d.ts +55 -0
  97. package/dist/scoped-stack/subscription.d.ts.map +1 -0
  98. package/dist/scoped-stack/subscription.js +110 -0
  99. package/dist/scoped-stack/subscription.js.map +1 -0
  100. package/dist/stack/attachments.d.ts +24 -0
  101. package/dist/stack/attachments.d.ts.map +1 -0
  102. package/dist/stack/attachments.js +113 -0
  103. package/dist/stack/attachments.js.map +1 -0
  104. package/dist/{changes.d.ts → stack/changes.d.ts} +29 -65
  105. package/dist/stack/changes.d.ts.map +1 -0
  106. package/dist/{changes.js → stack/changes.js} +32 -66
  107. package/dist/stack/changes.js.map +1 -0
  108. package/dist/stack/client.d.ts +271 -0
  109. package/dist/stack/client.d.ts.map +1 -0
  110. package/dist/stack/client.js +9 -0
  111. package/dist/stack/client.js.map +1 -0
  112. package/dist/stack/identity-bindings.d.ts.map +1 -0
  113. package/dist/{identity-bindings.js → stack/identity-bindings.js} +8 -14
  114. package/dist/stack/identity-bindings.js.map +1 -0
  115. package/dist/stack/install-app.d.ts +22 -0
  116. package/dist/stack/install-app.d.ts.map +1 -0
  117. package/dist/stack/install-app.js +260 -0
  118. package/dist/stack/install-app.js.map +1 -0
  119. package/dist/stack/integrity.d.ts +94 -0
  120. package/dist/stack/integrity.d.ts.map +1 -0
  121. package/dist/stack/integrity.js +268 -0
  122. package/dist/stack/integrity.js.map +1 -0
  123. package/dist/{limits.d.ts → stack/limits.d.ts} +2 -5
  124. package/dist/stack/limits.d.ts.map +1 -0
  125. package/dist/{limits.js → stack/limits.js} +3 -6
  126. package/dist/stack/limits.js.map +1 -0
  127. package/dist/stack/migrations.d.ts +59 -0
  128. package/dist/stack/migrations.d.ts.map +1 -0
  129. package/dist/stack/migrations.js +141 -0
  130. package/dist/stack/migrations.js.map +1 -0
  131. package/dist/{stack-reads.d.ts → stack/reads.d.ts} +33 -6
  132. package/dist/stack/reads.d.ts.map +1 -0
  133. package/dist/{stack-reads.js → stack/reads.js} +49 -7
  134. package/dist/stack/reads.js.map +1 -0
  135. package/dist/stack/record-id.d.ts +35 -0
  136. package/dist/stack/record-id.d.ts.map +1 -0
  137. package/dist/stack/record-id.js +82 -0
  138. package/dist/stack/record-id.js.map +1 -0
  139. package/dist/stack/stack.d.ts +438 -0
  140. package/dist/stack/stack.d.ts.map +1 -0
  141. package/dist/stack/stack.js +1366 -0
  142. package/dist/stack/stack.js.map +1 -0
  143. package/dist/stack/system-types.d.ts +16 -0
  144. package/dist/stack/system-types.d.ts.map +1 -0
  145. package/dist/stack/system-types.js +111 -0
  146. package/dist/stack/system-types.js.map +1 -0
  147. package/dist/stack/type-grants.d.ts +20 -0
  148. package/dist/stack/type-grants.d.ts.map +1 -0
  149. package/dist/stack/type-grants.js +69 -0
  150. package/dist/stack/type-grants.js.map +1 -0
  151. package/dist/stack/write-expectation.d.ts +78 -0
  152. package/dist/stack/write-expectation.d.ts.map +1 -0
  153. package/dist/stack/write-expectation.js +71 -0
  154. package/dist/stack/write-expectation.js.map +1 -0
  155. package/dist/testing.d.ts +21 -26
  156. package/dist/testing.d.ts.map +1 -1
  157. package/dist/testing.js +50 -70
  158. package/dist/testing.js.map +1 -1
  159. package/dist/type-handle.d.ts +67 -78
  160. package/dist/type-handle.d.ts.map +1 -1
  161. package/dist/type-handle.js +44 -111
  162. package/dist/type-handle.js.map +1 -1
  163. package/dist/types/adapter.d.ts +223 -0
  164. package/dist/types/adapter.d.ts.map +1 -0
  165. package/dist/types/adapter.js +5 -0
  166. package/dist/types/adapter.js.map +1 -0
  167. package/dist/types/associations.d.ts +156 -0
  168. package/dist/types/associations.d.ts.map +1 -0
  169. package/dist/types/associations.js +13 -0
  170. package/dist/types/associations.js.map +1 -0
  171. package/dist/types/capabilities.d.ts +89 -0
  172. package/dist/types/capabilities.d.ts.map +1 -0
  173. package/dist/types/capabilities.js +5 -0
  174. package/dist/types/capabilities.js.map +1 -0
  175. package/dist/types/events.d.ts +155 -0
  176. package/dist/types/events.d.ts.map +1 -0
  177. package/dist/types/events.js +5 -0
  178. package/dist/types/events.js.map +1 -0
  179. package/dist/types/ids.d.ts +43 -0
  180. package/dist/types/ids.d.ts.map +1 -0
  181. package/dist/types/ids.js +5 -0
  182. package/dist/types/ids.js.map +1 -0
  183. package/dist/types/index.d.ts +19 -0
  184. package/dist/types/index.d.ts.map +1 -0
  185. package/dist/types/index.js +19 -0
  186. package/dist/types/index.js.map +1 -0
  187. package/dist/types/journal.d.ts +47 -0
  188. package/dist/types/journal.d.ts.map +1 -0
  189. package/dist/types/journal.js +5 -0
  190. package/dist/types/journal.js.map +1 -0
  191. package/dist/types/query.d.ts +185 -0
  192. package/dist/types/query.d.ts.map +1 -0
  193. package/dist/types/query.js +10 -0
  194. package/dist/types/query.js.map +1 -0
  195. package/dist/types/records.d.ts +76 -0
  196. package/dist/types/records.d.ts.map +1 -0
  197. package/dist/types/records.js +5 -0
  198. package/dist/types/records.js.map +1 -0
  199. package/dist/types/schema.d.ts +74 -0
  200. package/dist/types/schema.d.ts.map +1 -0
  201. package/dist/types/schema.js +5 -0
  202. package/dist/types/schema.js.map +1 -0
  203. package/dist/types/system.d.ts +161 -0
  204. package/dist/types/system.d.ts.map +1 -0
  205. package/dist/types/system.js +32 -0
  206. package/dist/types/system.js.map +1 -0
  207. package/dist/types/tokens.d.ts +39 -0
  208. package/dist/types/tokens.d.ts.map +1 -0
  209. package/dist/types/tokens.js +5 -0
  210. package/dist/types/tokens.js.map +1 -0
  211. package/dist/validate.d.ts +29 -70
  212. package/dist/validate.d.ts.map +1 -1
  213. package/dist/validate.js +65 -97
  214. package/dist/validate.js.map +1 -1
  215. package/dist/{attachment-download.d.ts → wire/attachment-download.d.ts} +0 -57
  216. package/dist/wire/attachment-download.d.ts.map +1 -0
  217. package/dist/{attachment-download.js → wire/attachment-download.js} +0 -61
  218. package/dist/wire/attachment-download.js.map +1 -0
  219. package/dist/{auth.d.ts → wire/auth.d.ts} +5 -8
  220. package/dist/wire/auth.d.ts.map +1 -0
  221. package/dist/{auth.js → wire/auth.js} +5 -8
  222. package/dist/wire/auth.js.map +1 -0
  223. package/dist/{wire-body.d.ts → wire/body.d.ts} +13 -5
  224. package/dist/wire/body.d.ts.map +1 -0
  225. package/dist/{wire-body.js → wire/body.js} +65 -7
  226. package/dist/wire/body.js.map +1 -0
  227. package/dist/{wire-entry.d.ts → wire/index.d.ts} +12 -12
  228. package/dist/wire/index.d.ts.map +1 -0
  229. package/dist/{wire-entry.js → wire/index.js} +13 -17
  230. package/dist/wire/index.js.map +1 -0
  231. package/dist/{wire-record.d.ts → wire/record.d.ts} +10 -22
  232. package/dist/wire/record.d.ts.map +1 -0
  233. package/dist/{wire-record.js → wire/record.js} +12 -24
  234. package/dist/wire/record.js.map +1 -0
  235. package/dist/{wire-request.d.ts → wire/request.d.ts} +20 -37
  236. package/dist/wire/request.d.ts.map +1 -0
  237. package/dist/{wire-request.js → wire/request.js} +79 -54
  238. package/dist/wire/request.js.map +1 -0
  239. package/package.json +7 -7
  240. package/dist/adapter-entry.d.ts.map +0 -1
  241. package/dist/adapter-entry.js.map +0 -1
  242. package/dist/attachment-download.d.ts.map +0 -1
  243. package/dist/attachment-download.js.map +0 -1
  244. package/dist/auth.d.ts.map +0 -1
  245. package/dist/auth.js.map +0 -1
  246. package/dist/changes.d.ts.map +0 -1
  247. package/dist/changes.js.map +0 -1
  248. package/dist/combine.d.ts.map +0 -1
  249. package/dist/combine.js.map +0 -1
  250. package/dist/did-entry.d.ts.map +0 -1
  251. package/dist/did-entry.js.map +0 -1
  252. package/dist/did.d.ts.map +0 -1
  253. package/dist/did.js.map +0 -1
  254. package/dist/identity-bindings.d.ts.map +0 -1
  255. package/dist/identity-bindings.js.map +0 -1
  256. package/dist/limits.d.ts.map +0 -1
  257. package/dist/limits.js.map +0 -1
  258. package/dist/record-id.d.ts +0 -70
  259. package/dist/record-id.d.ts.map +0 -1
  260. package/dist/record-id.js +0 -127
  261. package/dist/record-id.js.map +0 -1
  262. package/dist/scoped-stack.d.ts +0 -532
  263. package/dist/scoped-stack.d.ts.map +0 -1
  264. package/dist/scoped-stack.js +0 -1219
  265. package/dist/scoped-stack.js.map +0 -1
  266. package/dist/sort.d.ts.map +0 -1
  267. package/dist/sort.js.map +0 -1
  268. package/dist/stack-reads.d.ts.map +0 -1
  269. package/dist/stack-reads.js.map +0 -1
  270. package/dist/stack.d.ts +0 -971
  271. package/dist/stack.d.ts.map +0 -1
  272. package/dist/stack.js +0 -2012
  273. package/dist/stack.js.map +0 -1
  274. package/dist/types.d.ts +0 -1250
  275. package/dist/types.d.ts.map +0 -1
  276. package/dist/types.js +0 -49
  277. package/dist/types.js.map +0 -1
  278. package/dist/wire-body.d.ts.map +0 -1
  279. package/dist/wire-body.js.map +0 -1
  280. package/dist/wire-entry.d.ts.map +0 -1
  281. package/dist/wire-entry.js.map +0 -1
  282. package/dist/wire-record.d.ts.map +0 -1
  283. package/dist/wire-record.js.map +0 -1
  284. package/dist/wire-request.d.ts.map +0 -1
  285. package/dist/wire-request.js.map +0 -1
  286. /package/dist/{did.d.ts → did/did.d.ts} +0 -0
  287. /package/dist/{identity-bindings.d.ts → stack/identity-bindings.d.ts} +0 -0
@@ -0,0 +1,89 @@
1
+ /**
2
+ * What a Stack and its adapter honor, and what a query can be refused for.
3
+ */
4
+ import type { NativeSortField } from './query.js';
5
+ /**
6
+ * How far into `content` a filter key may reach. The rungs nest, so they
7
+ * are one ordered value rather than booleans that can spell an impossible
8
+ * state. An unrecognized value reads as `'none'`: a refusal is recoverable,
9
+ * an unfiltered superset passed off as filtered is not.
10
+ * See docs/spec/adapters.md § Adapter capabilities.
11
+ */
12
+ export type ContentFilterReach =
13
+ /** No `filter.content` and no `filter.contentPresent` at all. */
14
+ 'none'
15
+ /** Single-segment field names only (`'did'`). */
16
+ | 'field'
17
+ /** Multi-segment paths too (`'emails.value'`). */
18
+ | 'path';
19
+ /**
20
+ * What a Stack — and the adapter under it — honors. Every `filter`/`sort`
21
+ * entry is named for the query key it gates, so the capability a query
22
+ * needs is derivable from the query. `limits` are numbers to pre-check
23
+ * against, not features. See docs/spec/adapters.md § Adapter capabilities.
24
+ */
25
+ export type StackCapabilities = {
26
+ filter: {
27
+ /**
28
+ * Required `'path'` for local/in-process adapters; a wire adapter may
29
+ * report a shallower rung, driven by the server's discovery response.
30
+ * Stack.query() throws StackBadRequestError rather than silently widening.
31
+ */
32
+ content: ContentFilterReach;
33
+ /**
34
+ * Whether `filter.contentPresent` is honored. Beside the reach ladder,
35
+ * not on it: matching a value promises nothing about answering whether
36
+ * one is there. Meaningful only where `content` is not `'none'`.
37
+ */
38
+ contentPresent: boolean;
39
+ /**
40
+ * The most arms `filter.contentByType` may hold; `0` declines it. A
41
+ * collection narrows the versions it cannot reach rather than failing.
42
+ * Local adapters must honor it. See docs/spec/adapters.md § Adapter
43
+ * capabilities.
44
+ */
45
+ contentByType: number;
46
+ /**
47
+ * Whether `filter.search` is honored. Not a rung on the ladder: a
48
+ * full-text index is a different mechanism from field matching, and
49
+ * neither implies the other. Local adapters may decline it.
50
+ */
51
+ search: boolean;
52
+ };
53
+ sort: {
54
+ /** Which native columns this adapter can order by; see NativeSortField. */
55
+ fields: NativeSortField[];
56
+ /**
57
+ * Whether `sort.contentField` is honored. A boolean rather than names
58
+ * in `fields`: an adapter that sorts by content indexes every top-level
59
+ * scalar. Independent of `filter.content`.
60
+ */
61
+ contentField: boolean;
62
+ /** The most keys `sort.contentFieldByType` may hold; `0` declines it. */
63
+ contentFieldByType: number;
64
+ };
65
+ /**
66
+ * Ceilings a client can check before spending a request; the server's
67
+ * own limit stays authoritative. `null` means this client cannot
68
+ * pre-check, not that nothing is enforced — local adapters declare it.
69
+ * See docs/spec/adapters.md § Adapter capabilities.
70
+ */
71
+ limits: {
72
+ /** Maximum attachment upload size in bytes. */
73
+ attachmentBytes: number | null;
74
+ /**
75
+ * Maximum serialized size in bytes of a Record's content — a create
76
+ * body or a merge patch. Stack.create()/Stack.mutate() pre-check
77
+ * against it and throw StackPayloadTooLargeError before sending.
78
+ */
79
+ contentBytes: number | null;
80
+ };
81
+ };
82
+ /**
83
+ * A capability a query can be refused for, as its path into
84
+ * StackCapabilities — the same name the spec and a discovery response
85
+ * use, so an error says which key to look at. `limits` never appears: a
86
+ * ceiling is not something a query can lack.
87
+ */
88
+ export type MissingCapability = 'filter.content' | 'filter.contentPresent' | 'filter.contentByType' | 'filter.search' | 'sort.fields' | 'sort.contentField' | 'sort.contentFieldByType';
89
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/types/capabilities.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB;AAC5B,iEAAiE;AAC/D,MAAM;AACR,iDAAiD;GAC/C,OAAO;AACT,kDAAkD;GAChD,MAAM,CAAC;AAEX;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE;QACN;;;;WAIG;QACH,OAAO,EAAE,kBAAkB,CAAC;QAC5B;;;;WAIG;QACH,cAAc,EAAE,OAAO,CAAC;QACxB;;;;;WAKG;QACH,aAAa,EAAE,MAAM,CAAC;QACtB;;;;WAIG;QACH,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,IAAI,EAAE;QACJ,2EAA2E;QAC3E,MAAM,EAAE,eAAe,EAAE,CAAC;QAC1B;;;;WAIG;QACH,YAAY,EAAE,OAAO,CAAC;QACtB,yEAAyE;QACzE,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF;;;;;OAKG;IACH,MAAM,EAAE;QACN,+CAA+C;QAC/C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B;;;;WAIG;QACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GACzB,gBAAgB,GAChB,uBAAuB,GACvB,sBAAsB,GACtB,eAAe,GACf,aAAa,GACb,mBAAmB,GACnB,yBAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * What a Stack and its adapter honor, and what a query can be refused for.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/types/capabilities.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Change events: what `subscribe()` delivers and the options it takes.
3
+ */
4
+ import type { DataAssociation } from './associations.js';
5
+ import type { RecordId, TypeId, AppId, Actor } from './ids.js';
6
+ import type { RecordFilter } from './query.js';
7
+ import type { StackRecord } from './records.js';
8
+ /**
9
+ * The coarse branch every subscriber makes, closed at four values. A
10
+ * handler covering exactly these is complete, not merely adequate:
11
+ * `changed` is an upsert signal carrying nine distinct verbs.
12
+ * See docs/spec/events.md § The event shape.
13
+ */
14
+ export type ChangeKind = 'created' | 'changed' | 'removed' | 'purged';
15
+ /**
16
+ * The precise verb behind a ChangeKind, for consumers that distinguish a
17
+ * reshare from an edit. Each is named after the call that produced it; see
18
+ * docs/spec/events.md § The event shape for the three that aren't a method
19
+ * name. `associate`, `dissociate`, `reshare`, `reparent`, `unlist` and
20
+ * `list` don't bump; see docs/spec/versioning.md § Version history.
21
+ */
22
+ export type ChangeOp = 'create' | 'patch' | 'associate' | 'dissociate' | 'reshare' | 'migrate' | 'restore' | 'delete' | 'undelete' | 'purge'
23
+ /**
24
+ * Emitted even though the record's post-change state (`unlistedAt` now
25
+ * set) would otherwise be excluded by the same filter it announces —
26
+ * subscribers who already know the record need telling to drop it. See
27
+ * docs/spec/events.md § The unlisted transition.
28
+ */
29
+ | 'unlist'
30
+ /** The publish moment — mechanically an upsert, like `undelete`. */
31
+ | 'list'
32
+ /**
33
+ * A move between containers. Matched by a `parentId` filter naming
34
+ * *either* side of the move, so a subscriber watching the old container
35
+ * learns the record left it — the record's post-change state alone
36
+ * would answer only for the destination. See docs/spec/events.md
37
+ * § The reparent transition.
38
+ */
39
+ | 'reparent';
40
+ /**
41
+ * Who performed a change — never who authored the record. Absent from a
42
+ * RecordChange entirely when unknown, which means a write by an unscoped
43
+ * `Stack`: absence is a fact of its own and never stands in for the
44
+ * author. See docs/spec/events.md § Attribution.
45
+ */
46
+ export type ChangeActor = Actor & {
47
+ /** Self-reported at create, never a trust input. See AppId. */
48
+ appId?: AppId;
49
+ };
50
+ /**
51
+ * One change to one record. The envelope describes the change; the record
52
+ * describes the record, so nothing of the record's own provenance appears
53
+ * here — a consumer that wants it asks for `record`.
54
+ * See docs/spec/events.md § The event shape.
55
+ */
56
+ export type RecordChange = {
57
+ kind: ChangeKind;
58
+ /**
59
+ * Every aspect this version moved, diffed against prior state rather
60
+ * than read off the request. Never empty; multi-entry only for mutate().
61
+ * See docs/spec/events.md § The event shape.
62
+ */
63
+ ops: ChangeOp[];
64
+ recordId: RecordId;
65
+ /** As stored at the moment of the change. */
66
+ typeId: TypeId;
67
+ /**
68
+ * The version this change produced; on `purged`, the version destroyed.
69
+ * Unchanged from the record's prior version on every op that doesn't
70
+ * bump — see ChangeOp.
71
+ */
72
+ version: number;
73
+ /**
74
+ * As persisted by this change; on `purged`, when the delete ran.
75
+ * Unchanged from the record's prior `updatedAt` on every op that
76
+ * doesn't bump.
77
+ */
78
+ updatedAt: Date;
79
+ parentId?: RecordId;
80
+ actor?: ChangeActor;
81
+ /**
82
+ * Associations now present that weren't before — current annotation
83
+ * included, so a re-point appears here under its new
84
+ * `attachmentRecordId`. Present whenever `ops` includes `associate`, on
85
+ * the same "as of this change" convention as every other field here.
86
+ */
87
+ associationsAdded?: DataAssociation[];
88
+ /**
89
+ * Associations no longer present, identity only — kind and label, plus
90
+ * `fileId` for an attachment — present whenever `ops` includes
91
+ * `dissociate`. An attachment's `attachmentRecordId` is never repeated
92
+ * here, the same way a `purged` frame never carries what it destroyed.
93
+ */
94
+ associationsRemoved?: DataAssociation[];
95
+ /**
96
+ * The record as of this change — present only when asked for and
97
+ * available, never on `purged`. Shared with every other subscriber on
98
+ * this emission, so a handler that needs to alter it copies first.
99
+ */
100
+ record?: StackRecord;
101
+ /**
102
+ * Resume cursor, minted by a server. Local changes carry none, this
103
+ * stack's own writes included — so a consumer holding a cursor keeps
104
+ * the last one that was present rather than the last change's.
105
+ */
106
+ cursor?: string;
107
+ };
108
+ /**
109
+ * Applied by the emitter, exactly: a filtered subscription never receives
110
+ * an event outside its filter, so filtering again is redundant rather than
111
+ * defensive. Every key means what it means on `RecordFilter`, so one value
112
+ * can drive both `query()` and `subscribe()`. See docs/spec/events.md
113
+ * § Subscribing.
114
+ */
115
+ export type ChangeFilter = Pick<RecordFilter, 'typeId' | 'baseId' | 'parentId' | 'createdBy'> & {
116
+ kinds?: ChangeKind[];
117
+ };
118
+ /** Ends a subscription. Safe to call more than once. */
119
+ export type Unsubscribe = () => void;
120
+ /**
121
+ * What a subscriber asks for, and what `Stack` forwards unchanged to an
122
+ * adapter's `subscribeChanges()` relay — the relay honors every key.
123
+ * See docs/spec/events.md § Subscribing and § Where events come from.
124
+ */
125
+ export type SubscribeOptions = {
126
+ filter?: ChangeFilter;
127
+ /** Ask the emitter to include `record`. Honored when it can; never assume it. */
128
+ includeRecords?: boolean;
129
+ /**
130
+ * Receive events for unlisted records too. Owner-only under
131
+ * `ScopedStack`, same authority as `RecordFilter.includeUnlisted`.
132
+ * See docs/spec/unlisted.md.
133
+ */
134
+ includeUnlisted?: boolean;
135
+ /**
136
+ * Resume from this cursor — the last `cursor` that was *present* on a
137
+ * delivered `RecordChange`. Refused with `StackBadRequestError` on a
138
+ * stack with no relay, which has no cursor it could have minted.
139
+ * See docs/spec/events.md § Subscribing.
140
+ */
141
+ since?: string;
142
+ /**
143
+ * Where a throwing handler's error goes, and on a relaying stack a
144
+ * connection the relay could not restore. Without one a handler error is
145
+ * rethrown asynchronously; it never reaches the mutation's caller.
146
+ */
147
+ onError?: (err: unknown) => void;
148
+ /**
149
+ * A gap opened that resumption could not close: reconcile by query.
150
+ * Never fires on a local stack. Can fire on the first connection when
151
+ * the far end will not honor `since`.
152
+ */
153
+ onReset?: () => void;
154
+ };
155
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAChB,QAAQ,GACR,OAAO,GACP,WAAW,GACX,YAAY,GACZ,SAAS,GACT,SAAS,GACT,SAAS,GACT,QAAQ,GACR,UAAU,GACV,OAAO;AACT;;;;;GAKG;GACD,QAAQ;AACV,oEAAoE;GAClE,MAAM;AACR;;;;;;GAMG;GACD,UAAU,CAAC;AAEf;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG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I,CAAC;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Change events: what `subscribe()` delivers and the options it takes.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Identifiers, and the Actor that pairs two of them.
3
+ */
4
+ /**
5
+ * Crockford base-32 encoded ID — time-sortable, unique within a stack.
6
+ * Format: 9-char timestamp prefix + 3-char random suffix = 12 chars total.
7
+ * Human-readable and URL-safe. Uniqueness is within-stack only;
8
+ * cross-stack references must include a stackUrl to disambiguate.
9
+ */
10
+ export type RecordId = string;
11
+ /** Namespaced, versioned type identifier e.g. "com.example.myapp/note@2" */
12
+ export type TypeId = string;
13
+ /** A type family: a TypeId without its version, e.g. "com.example.myapp/note" */
14
+ export type BaseId = string;
15
+ /** Opaque file identifier returned by putBlob() */
16
+ export type FileId = string;
17
+ /**
18
+ * Reverse-DNS identifier for the software that wrote a Record, e.g.
19
+ * "com.example.myapp" — not a RecordId. Self-reported and never a
20
+ * permission input; `StackRecord.createdBy.principalId` is the verified
21
+ * counterpart.
22
+ * See docs/spec/identity.md § App.
23
+ */
24
+ export type AppId = string;
25
+ /**
26
+ * Identifies a "who" — a DID string, e.g. "did:key:z6Mk...". A
27
+ * self-certifying identifier that means the same thing in every stack,
28
+ * unlike a RecordId. did:key is the mandatory floor method (see did/did.ts).
29
+ * See docs/spec/identity.md.
30
+ */
31
+ export type EntityId = string;
32
+ /**
33
+ * Who did something, and through which principal. `subjectId` is who the
34
+ * act is attributed to; `principalId` is who authenticated, present only
35
+ * when it differs — a delegated app acting for its user. `Stack` stores
36
+ * a `principalId` equal to `subjectId` as absent, so the two spellings of
37
+ * "acted as itself" never diverge. See docs/spec/data-model.md § Actor.
38
+ */
39
+ export type Actor = {
40
+ subjectId: EntityId;
41
+ principalId?: EntityId;
42
+ };
43
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/types/ids.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,4EAA4E;AAC5E,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,iFAAiF;AACjF,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,mDAAmD;AACnD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,QAAQ,CAAC;IACpB,WAAW,CAAC,EAAE,QAAQ,CAAC;CACxB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Identifiers, and the Actor that pairs two of them.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/types/ids.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Stack — Core Type Definitions
3
+ * -------------------------------------------------------
4
+ * The source of truth for all types in the Stack library, one module per
5
+ * concern. No logic lives here — just shapes. Import from this barrel
6
+ * rather than from a module, so a type can move without touching callers.
7
+ */
8
+ export * from './ids.js';
9
+ export * from './associations.js';
10
+ export * from './records.js';
11
+ export * from './schema.js';
12
+ export * from './system.js';
13
+ export * from './query.js';
14
+ export * from './capabilities.js';
15
+ export * from './journal.js';
16
+ export * from './events.js';
17
+ export * from './adapter.js';
18
+ export * from './tokens.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Stack — Core Type Definitions
3
+ * -------------------------------------------------------
4
+ * The source of truth for all types in the Stack library, one module per
5
+ * concern. No logic lives here — just shapes. Import from this barrel
6
+ * rather than from a module, so a type can move without touching callers.
7
+ */
8
+ export * from './ids.js';
9
+ export * from './associations.js';
10
+ export * from './records.js';
11
+ export * from './schema.js';
12
+ export * from './system.js';
13
+ export * from './query.js';
14
+ export * from './capabilities.js';
15
+ export * from './journal.js';
16
+ export * from './events.js';
17
+ export * from './adapter.js';
18
+ export * from './tokens.js';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The change journal: the per-record log of what each write moved.
3
+ */
4
+ import type { AssociationChange } from './associations.js';
5
+ import type { ChangeKind, ChangeOp, ChangeActor } from './events.js';
6
+ import type { RecordId, TypeId } from './ids.js';
7
+ /**
8
+ * The part of a change the record cannot report once the write has
9
+ * landed: which aspects moved, who moved them, and what an association
10
+ * mutation displaced. The adapter stamps the rest of the entry from the
11
+ * row it just wrote, so the two never drift. See docs/spec/journal.md.
12
+ */
13
+ export type JournalEntryInput = {
14
+ ops: ChangeOp[];
15
+ kind: ChangeKind;
16
+ actor?: ChangeActor;
17
+ /** The container a move took the record out of, `null` for the root. */
18
+ previousParentId?: RecordId | null;
19
+ /**
20
+ * What an association mutation moved, one tagged edit per association,
21
+ * with `previous` beside whatever displaced it.
22
+ * See docs/spec/journal.md § The entry.
23
+ */
24
+ associations?: AssociationChange[];
25
+ };
26
+ /**
27
+ * One durable entry in a record's change journal. Envelope only — content
28
+ * lives on a RecordVersion. See docs/spec/journal.md § Ordering for why
29
+ * `seq` is the only ordering.
30
+ */
31
+ export type RecordJournalEntry = JournalEntryInput & {
32
+ seq: number;
33
+ /** When the entry was appended — not the record's `updatedAt`, which an association change leaves alone. */
34
+ at: Date;
35
+ /** The version this change produced — unchanged on an op that doesn't bump; see ChangeOp. */
36
+ version: number;
37
+ typeId: TypeId;
38
+ /** Where the record sat after the change, absent for the root. */
39
+ parentId?: RecordId;
40
+ };
41
+ /** Window into a record's journal. Omitting both reads the whole log, oldest first. */
42
+ export type JournalQuery = {
43
+ /** Entries after this seq, exclusive. */
44
+ afterSeq?: number;
45
+ limit?: number;
46
+ };
47
+ //# sourceMappingURL=journal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../src/types/journal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,QAAQ,EAAE,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,4GAA4G;IAC5G,EAAE,EAAE,IAAI,CAAC;IACT,6FAA6F;IAC7F,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG;IACzB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The change journal: the per-record log of what each write moved.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=journal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal.js","sourceRoot":"","sources":["../../src/types/journal.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Query filters, sorting, and the page a query returns.
3
+ */
4
+ import type { RecordId, TypeId, BaseId, FileId, AppId, EntityId } from './ids.js';
5
+ import type { StackRecord } from './records.js';
6
+ /**
7
+ * A target pattern in `RecordFilter.relatedTo` — the association shape with
8
+ * the parts a query may leave open: an `external` target without `id`
9
+ * matches its whole namespace.
10
+ */
11
+ export type RelationshipTargetPattern = {
12
+ kind: 'record';
13
+ recordId: RecordId;
14
+ stackUrl?: string;
15
+ } | {
16
+ kind: 'entity';
17
+ entityId: EntityId;
18
+ } | {
19
+ kind: 'external';
20
+ ns: string;
21
+ id?: string;
22
+ };
23
+ /**
24
+ * A relationship query names a label, a target, or both — never neither.
25
+ * "Carries any relationship at all" is deliberately not expressible, in
26
+ * line with `tags` and `attachment`, which likewise have no match-any
27
+ * form. See docs/spec/data-model.md § Filter.
28
+ */
29
+ export type RelatedToFilter = {
30
+ label: string;
31
+ target?: RelationshipTargetPattern;
32
+ } | {
33
+ label?: string;
34
+ target: RelationshipTargetPattern;
35
+ };
36
+ /**
37
+ * An attachment query names a label, a file, or both — never neither —
38
+ * and both halves together match one association. See
39
+ * docs/spec/data-model.md § Filter.
40
+ */
41
+ export type AttachmentFilter = {
42
+ label: string;
43
+ fileId?: FileId;
44
+ } | {
45
+ label?: string;
46
+ fileId: FileId;
47
+ };
48
+ export type DateRange = {
49
+ before?: Date;
50
+ after?: Date;
51
+ };
52
+ /** One Type's arm of `RecordFilter.contentByType`, flat by design. */
53
+ export type ContentArm = {
54
+ content?: Record<string, unknown>;
55
+ contentPresent?: string[];
56
+ };
57
+ export type RecordFilter = {
58
+ typeId?: TypeId | TypeId[];
59
+ /**
60
+ * Match every version of a type family, resolved against registered
61
+ * Types rather than parsed from typeId strings. Intersects with `typeId`
62
+ * when both are given. A value carrying an `@version` suffix is refused
63
+ * with StackValidationError.
64
+ */
65
+ baseId?: BaseId | BaseId[];
66
+ parentId?: RecordId | null;
67
+ appId?: AppId | AppId[];
68
+ /** Matches the record's author — never the latest actor, which isn't filterable. */
69
+ createdBy?: {
70
+ subjectId?: EntityId | EntityId[];
71
+ principalId?: EntityId | EntityId[];
72
+ };
73
+ createdAt?: DateRange;
74
+ updatedAt?: DateRange;
75
+ tags?: string[];
76
+ /** Records carrying a matching attachment association. See docs/spec/data-model.md § Filter. */
77
+ attachment?: AttachmentFilter;
78
+ /**
79
+ * Records carrying a matching relationship association. Either half may
80
+ * be given alone and each is a pattern: a bare `label` matches every
81
+ * target under it, and an `external` target with no `id` matches the
82
+ * whole namespace. An absent `stackUrl` on a `record` target matches
83
+ * only local targets. See docs/spec/data-model.md § Filter.
84
+ */
85
+ relatedTo?: RelatedToFilter;
86
+ /**
87
+ * Records that reference this file, through an attachment association
88
+ * or a top-level `file-ref` content field — the question GC and
89
+ * `deleteAttachment()` ask. See docs/spec/attachments.md § Deleting attachments.
90
+ */
91
+ referencesFileId?: FileId;
92
+ /**
93
+ * Exact match on content fields, keyed by a dot-separated path
94
+ * (`'emails.value'`); an array along the path matches element-wise. A
95
+ * multi-segment key needs `filter.content: 'path'`. POST /records/query
96
+ * only. See docs/spec/data-model.md § Filter.
97
+ */
98
+ content?: Record<string, unknown>;
99
+ /**
100
+ * Paths that must hold a non-null value — the question `content` cannot
101
+ * ask. Element-wise like `content`. Needs `filter.contentPresent`.
102
+ * POST /records/query only. See docs/spec/data-model.md § Filter.
103
+ */
104
+ contentPresent?: string[];
105
+ /**
106
+ * A content predicate per Type: a record matches when its `typeId` is a
107
+ * key and its content satisfies that arm. Generated by a collection from
108
+ * a migration chain; never beside `content` or `contentPresent`. Needs
109
+ * `filter.contentByType`. POST /records/query only. See
110
+ * docs/spec/data-model.md § Content by type.
111
+ */
112
+ contentByType?: Record<TypeId, ContentArm>;
113
+ search?: string;
114
+ includeDeleted?: boolean;
115
+ /**
116
+ * Unlisted records are excluded by default, like soft-deleted ones.
117
+ * Owner-only under `ScopedStack` — enumeration standing rests on nothing
118
+ * but ownership, so a grant or delegation never carries it. See
119
+ * docs/spec/unlisted.md.
120
+ */
121
+ includeUnlisted?: boolean;
122
+ };
123
+ /**
124
+ * The Record columns every adapter stores natively, and can order by. The
125
+ * array is the source of truth, so the runtime checks that narrow a wire
126
+ * value or a cursor to this set can't drift from NativeSortField.
127
+ */
128
+ export declare const NATIVE_SORT_FIELDS: readonly ["createdAt", "updatedAt", "version"];
129
+ export type NativeSortField = (typeof NATIVE_SORT_FIELDS)[number];
130
+ /**
131
+ * What a record at one Type orders by under `contentFieldByType`: a
132
+ * top-level field of its own, or a constant already reduced to what it
133
+ * orders as — a number, text, or `null` for no value.
134
+ */
135
+ export type ContentSortKey = {
136
+ field: string;
137
+ value?: never;
138
+ } | {
139
+ field?: never;
140
+ value: string | number | null;
141
+ };
142
+ /**
143
+ * Order by a native column, a top-level content field, or a content field
144
+ * per Type — separate members, so a content field named `version` stays
145
+ * distinct from the native column. `direction` defaults to `asc`; a query
146
+ * with no sort is `createdAt`, newest first. See docs/spec/data-model.md
147
+ * § Sorting by a content field.
148
+ */
149
+ export type QuerySort = {
150
+ field: NativeSortField;
151
+ contentField?: never;
152
+ contentFieldByType?: never;
153
+ direction?: 'asc' | 'desc';
154
+ } | {
155
+ field?: never;
156
+ contentField: string;
157
+ contentFieldByType?: never;
158
+ direction?: 'asc' | 'desc';
159
+ } | {
160
+ field?: never;
161
+ contentField?: never;
162
+ contentFieldByType: Record<TypeId, ContentSortKey>;
163
+ direction?: 'asc' | 'desc';
164
+ };
165
+ export type StackQuery = {
166
+ filter?: RecordFilter;
167
+ sort?: QuerySort;
168
+ limit?: number;
169
+ cursor?: string;
170
+ /**
171
+ * "stored" (the default) returns records as stored; "latest" applies the
172
+ * migration chain in memory, never written back. Throws
173
+ * StackMigrationError if a matched record has no path to the latest.
174
+ */
175
+ presentAt?: 'stored' | 'latest';
176
+ };
177
+ /**
178
+ * A page of results and where the next one resumes. There is no count of
179
+ * the whole match: see docs/spec/data-model.md § Sorting and pagination.
180
+ */
181
+ export type QueryResult = {
182
+ records: StackRecord[];
183
+ cursor: string | null;
184
+ };
185
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/types/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EA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AAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GACjB;IACE,KAAK,EAAE,eAAe,CAAC;IACvB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,kBAAkB,CAAC,EAAE,KAAK,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC5B,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,KAAK,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC5B,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACnD,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC5B,CAAC;AAEN,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Query filters, sorting, and the page a query returns.
3
+ */
4
+ /**
5
+ * The Record columns every adapter stores natively, and can order by. The
6
+ * array is the source of truth, so the runtime checks that narrow a wire
7
+ * value or a cursor to this set can't drift from NativeSortField.
8
+ */
9
+ export const NATIVE_SORT_FIELDS = ['createdAt', 'updatedAt', 'version'];
10
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/types/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AA2HH;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,CAAU,CAAC"}