@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,76 @@
1
+ /**
2
+ * The Record itself and its version snapshots.
3
+ */
4
+ import type { AuthorityAssociation, DataAssociation } from './associations.js';
5
+ import type { RecordId, TypeId, AppId, Actor } from './ids.js';
6
+ export type StackRecord = {
7
+ id: RecordId;
8
+ typeId: TypeId;
9
+ createdAt: Date;
10
+ updatedAt: Date;
11
+ content: Record<string, unknown>;
12
+ /**
13
+ * Ordinal of the snapshot history, not a count of changes: associations,
14
+ * permissions, parent and listing moves leave it alone. See
15
+ * docs/spec/versioning.md § Version history.
16
+ */
17
+ version: number;
18
+ parentId?: RecordId;
19
+ appId?: AppId;
20
+ /**
21
+ * The record's author, stamped once by the create. A `principalId` here
22
+ * is what lets `appId` be checked against the `_app` record naming that
23
+ * DID; without one, `appId` is an unverifiable self-report.
24
+ * See docs/spec/data-model.md § Authorship and attribution.
25
+ */
26
+ createdBy?: Actor;
27
+ /**
28
+ * Who performed the mutation this version records — unlike `createdBy`,
29
+ * it moves with every write. Absent means an unscoped `Stack` wrote it,
30
+ * which names no requester.
31
+ * See docs/spec/data-model.md § Authorship and attribution.
32
+ */
33
+ updatedBy?: Actor;
34
+ deletedAt?: Date;
35
+ /**
36
+ * Present when the record is withheld from enumeration: absent from
37
+ * `query()` and the change feed by default, but reachable by `get()` for
38
+ * anyone who may read it. Says nothing about who that is.
39
+ * See docs/spec/unlisted.md.
40
+ */
41
+ unlistedAt?: Date;
42
+ /**
43
+ * Who reaches this Record, projected from the association table's
44
+ * authority kinds. Absent or empty means private — readable only by the
45
+ * stack owner. Declarative intent; enforcement is `ScopedStack`'s.
46
+ * See docs/spec/access-control.md § Record-level permissions.
47
+ */
48
+ permissions?: AuthorityAssociation[];
49
+ associations?: DataAssociation[];
50
+ };
51
+ export type RecordVersion = {
52
+ version: number;
53
+ /** The record's typeId at the moment this version was snapshotted. */
54
+ typeId: TypeId;
55
+ content: Record<string, unknown>;
56
+ updatedAt: Date;
57
+ /**
58
+ * The record's author, carried through from `record.createdBy` — not the
59
+ * actor of the change this version records.
60
+ * See docs/spec/versioning.md § Version history.
61
+ */
62
+ createdBy?: Actor;
63
+ /** Who performed the mutation that produced this version. */
64
+ updatedBy?: Actor;
65
+ };
66
+ /**
67
+ * Window into a record's version history. Newest first, the reverse of
68
+ * JournalQuery; omitting both reads every version.
69
+ * See docs/spec/versioning.md § Version history.
70
+ */
71
+ export type VersionsQuery = {
72
+ /** Versions strictly older than this, exclusive. */
73
+ beforeVersion?: number;
74
+ limit?: number;
75
+ };
76
+ //# sourceMappingURL=records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/types/records.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE/D,MAAM,MAAM,WAAW,GAAG;IAExB,EAAE,EAAE,QAAQ,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAGhB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,EAAE,IAAI,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,oDAAoD;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The Record itself and its version snapshots.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=records.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/types/records.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Type schemas: field definitions and the registered StackType.
3
+ */
4
+ import type { TypeId, BaseId } from './ids.js';
5
+ export type ScalarFieldKind = 'string' | 'number' | 'boolean' | 'date' | 'text' | 'record-ref' | 'file-ref' | 'enum';
6
+ /**
7
+ * `values` is a non-empty, duplicate-free list of the strings the field may
8
+ * hold. See docs/spec/data-model.md § Types.
9
+ */
10
+ export type EnumFieldDef = {
11
+ kind: 'enum';
12
+ values: string[];
13
+ required?: boolean;
14
+ };
15
+ export type ScalarFieldDef = EnumFieldDef | {
16
+ kind: Exclude<ScalarFieldKind, 'enum'>;
17
+ required?: boolean;
18
+ };
19
+ /**
20
+ * A list. `open: true` leaves its elements unvalidated,
21
+ * which is how a heterogeneous or null-bearing list is spelled. Opacity is
22
+ * declared rather than inferred from a missing `items`, so a schema that
23
+ * forgets to describe its elements is a type error rather than a silently
24
+ * unchecked field. See docs/spec/data-model.md § Undeclared content fields.
25
+ */
26
+ export type ArrayFieldDef = {
27
+ kind: 'array';
28
+ items: FieldDef;
29
+ open?: false;
30
+ required?: boolean;
31
+ } | {
32
+ kind: 'array';
33
+ open: true;
34
+ items?: undefined;
35
+ required?: boolean;
36
+ };
37
+ /**
38
+ * An object. `open: true` leaves its keys unvalidated,
39
+ * which is the one way to store a shape a schema does not describe. Same
40
+ * reason as ArrayFieldDef for making it a declaration rather than an
41
+ * omission. See docs/spec/data-model.md § Undeclared content fields.
42
+ */
43
+ export type ObjectFieldDef = {
44
+ kind: 'object';
45
+ properties: TypeSchema;
46
+ open?: false;
47
+ required?: boolean;
48
+ } | {
49
+ kind: 'object';
50
+ open: true;
51
+ properties?: undefined;
52
+ required?: boolean;
53
+ };
54
+ /**
55
+ * A field definition in a Type schema. Supports scalars, arrays, and nested
56
+ * objects. Arrays and nested objects are schema-validated on write but are
57
+ * opaque to the query engine in v1 — only top-level scalar fields support
58
+ * exact-match content filtering in queries.
59
+ */
60
+ export type FieldDef = ScalarFieldDef | ArrayFieldDef | ObjectFieldDef;
61
+ export type TypeSchema = {
62
+ [fieldName: string]: FieldDef;
63
+ };
64
+ export type StackType = {
65
+ id: TypeId;
66
+ baseId: BaseId;
67
+ version: number;
68
+ name: string;
69
+ schema: TypeSchema;
70
+ schemaHash: string;
71
+ migratesFrom?: TypeId;
72
+ createdAt: Date;
73
+ };
74
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,MAAM,GACN,MAAM,GACN,YAAY,GACZ,UAAU,GACV,MAAM,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB,YAAY,GACZ;IAAE,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,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registered StackType.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Content shapes for the reserved `_`-prefixed system types.
3
+ */
4
+ import type { Grantee } from './associations.js';
5
+ import type { TypeId, BaseId, FileId, AppId, EntityId } from './ids.js';
6
+ /**
7
+ * Content for _entity records: a stack-local profile card *about* a DID,
8
+ * not the identity itself. `name`/`handle` are this owner's local labels
9
+ * for that DID (the petname pattern), so two stacks holding different
10
+ * names for the same DID is correct. See docs/spec/identity.md § Entity.
11
+ */
12
+ export type EntityContent = {
13
+ /**
14
+ * The identity this profile is about. e.g. "did:key:z6Mk...". A binding,
15
+ * not a value — an Actor's `subjectId` resolves through it to the name
16
+ * this card carries, so it is unique per stack and immutable once set.
17
+ * See docs/spec/identity.md § DID bindings.
18
+ */
19
+ did: string;
20
+ /** Display name — human-friendly, not necessarily unique. May contain spaces and punctuation. e.g. "Jane Smith" */
21
+ name: string;
22
+ /**
23
+ * Short, conventionally URL-safe label. e.g. "janesmith". A label, not a
24
+ * key: duplicates are legitimate and `did` is what identifies this
25
+ * profile. See docs/spec/identity.md § Entity.
26
+ */
27
+ handle?: string;
28
+ };
29
+ /** Content for _app records */
30
+ export type AppContent = {
31
+ /**
32
+ * The software this card is about, in reverse-DNS form — the value a
33
+ * Record's `appId` is checked against. Distinct from the card Record's
34
+ * own `appId`, which names whatever wrote the card (an admin console
35
+ * registering a third-party app is the ordinary case, and the two differ
36
+ * there). See docs/spec/identity.md § App.
37
+ */
38
+ appId: AppId;
39
+ /** Display name of the app e.g. "My Notes App" */
40
+ name: string;
41
+ /** Semver string e.g. "1.0.0". `appId` is the machine-readable identity, so no handle is needed here. */
42
+ version?: string;
43
+ /**
44
+ * The DID this app authenticates with, when it holds a key of its own —
45
+ * what an Actor's `principalId` resolves to, and what a self-reported
46
+ * `appId` is checked against. Absent for apps that ride their user's
47
+ * identity. Unique and immutable: docs/spec/identity.md § DID bindings.
48
+ */
49
+ did?: string;
50
+ };
51
+ /** Content for _group records */
52
+ export type GroupContent = {
53
+ /** Display name — human-friendly, not necessarily unique. May contain spaces and punctuation. e.g. "Jane's Book Club" */
54
+ name: string;
55
+ /**
56
+ * Short, conventionally URL-safe label. e.g. "janes-book-club". A label,
57
+ * not a key: duplicates are legitimate, and a group is addressed by
58
+ * `stackUrl` when it has one and by its record id otherwise. See
59
+ * docs/spec/identity.md § Group.
60
+ */
61
+ handle?: string;
62
+ /** If present, this group owns a shared collaborative stack at this URL. Absent = permission-only group. */
63
+ stackUrl?: string;
64
+ };
65
+ /**
66
+ * Actions that can be granted via a _grant record. The array is the source
67
+ * of truth — GrantAction is derived from it so runtime validation (see
68
+ * Stack.grantType()) can't drift from the type.
69
+ */
70
+ export declare const GRANT_ACTIONS: readonly ["create", "read-own", "read-any", "update-own", "update-any", "delete-own", "delete-any"];
71
+ export type GrantAction = (typeof GRANT_ACTIONS)[number];
72
+ /**
73
+ * Who a Grant reaches. `authenticated` is any authenticated entity —
74
+ * narrower than a Record permission's `anyone`, which reaches anonymous
75
+ * requesters too, so the two tiers deliberately share no word.
76
+ * See docs/spec/access-control.md § Type-level grants.
77
+ */
78
+ export type GrantGrantee = Grantee | {
79
+ kind: 'authenticated';
80
+ };
81
+ /**
82
+ * What `Stack.grantType()` and `Stack.revokeType()` take beside the type they act
83
+ * on — the type-level counterpart of the `AuthorityAssociation`
84
+ * `grantAccess()` takes beside a record id.
85
+ */
86
+ export type TypeGrant = {
87
+ actions: GrantAction[];
88
+ grantee: GrantGrantee;
89
+ };
90
+ /**
91
+ * Content for _grant records: a TypeGrant pinned to the type family it
92
+ * applies to — a bare baseId, never a versioned TypeId.
93
+ */
94
+ export type GrantContent = TypeGrant & {
95
+ baseId: BaseId;
96
+ };
97
+ /**
98
+ * One type-level grant an app's manifest asks for. No grantee: the app's
99
+ * own keys are who it reaches. See docs/spec/apps.md.
100
+ */
101
+ export type InstallRequest = Omit<GrantContent, 'grantee'>;
102
+ /**
103
+ * Content for _install records: what the owner approved of an app's
104
+ * manifest, one live record per `appId`. See docs/spec/apps.md.
105
+ */
106
+ export type InstallContent = {
107
+ /**
108
+ * The software this install is for. A binding: immutable, and unique
109
+ * among installs, so one install answers for each app.
110
+ */
111
+ appId: AppId;
112
+ name: string;
113
+ version?: string;
114
+ /**
115
+ * Every type version the owner has approved for this app. The families
116
+ * they name are claimed by this install and by no other.
117
+ */
118
+ defines: TypeId[];
119
+ /** The grants each of the app's keys holds. */
120
+ requests: InstallRequest[];
121
+ };
122
+ /** Content for _attachment records — one per upload, tracks file metadata. */
123
+ export type AttachmentContent = {
124
+ /** Content-addressed file identifier (SHA-256 hex). */
125
+ fileId: FileId;
126
+ /** MIME type of the file. */
127
+ mimeType: string;
128
+ /** File size in bytes. */
129
+ size: number;
130
+ /** Original filename, if provided at upload time. */
131
+ filename?: string;
132
+ };
133
+ /** Content for _config records — one singleton per stack, created on initialization. */
134
+ export type ConfigContent = {
135
+ /**
136
+ * DID of the stack owner. Immutable — see docs/spec.md § The `_config`
137
+ * record for why ownership transfer isn't a field write.
138
+ */
139
+ entityId: EntityId;
140
+ /**
141
+ * IANA timezone string e.g. "America/New_York". Optional passthrough app
142
+ * metadata — nothing in core reads it for behavior, and there is no
143
+ * default. See docs/spec.md § The `_config` record.
144
+ */
145
+ timezone?: string;
146
+ };
147
+ /** Reserved system type IDs */
148
+ export declare const SYSTEM_TYPES: {
149
+ readonly ENTITY: "_entity";
150
+ readonly APP: "_app";
151
+ readonly GROUP: "_group";
152
+ /** Creation-permission grants. See GrantContent. */
153
+ readonly GRANT: "_grant";
154
+ /** Attachment metadata records. See AttachmentContent. */
155
+ readonly ATTACHMENT: "_attachment";
156
+ /** Stack-level configuration singleton. See ConfigContent. */
157
+ readonly CONFIG: "_config";
158
+ /** An owner's approval of an app's manifest. See InstallContent. */
159
+ readonly INSTALL: "_install";
160
+ };
161
+ //# sourceMappingURL=system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/types/system.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,mHAAmH;IACnH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,+BAA+B;AAC/B,MAAM,MAAM,UAAU,GAAG;IACvB;;;;;;OAMG;IACH,KAAK,EAAE,KAAK,CAAC;IACb,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,yGAAyG;IACzG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG;IACzB,yHAAyH;IACzH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,qGAQhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,+CAA+C;IAC/C,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wFAAwF;AACxF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,+BAA+B;AAC/B,eAAO,MAAM,YAAY;;;;IAIvB,oDAAoD;;IAEpD,0DAA0D;;IAE1D,8DAA8D;;IAE9D,oEAAoE;;CAE5D,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Content shapes for the reserved `_`-prefixed system types.
3
+ */
4
+ /**
5
+ * Actions that can be granted via a _grant record. The array is the source
6
+ * of truth — GrantAction is derived from it so runtime validation (see
7
+ * Stack.grantType()) can't drift from the type.
8
+ */
9
+ export const GRANT_ACTIONS = [
10
+ 'create',
11
+ 'read-own',
12
+ 'read-any',
13
+ 'update-own',
14
+ 'update-any',
15
+ 'delete-own',
16
+ 'delete-any',
17
+ ];
18
+ /** Reserved system type IDs */
19
+ export const SYSTEM_TYPES = {
20
+ ENTITY: '_entity',
21
+ APP: '_app',
22
+ GROUP: '_group',
23
+ /** Creation-permission grants. See GrantContent. */
24
+ GRANT: '_grant',
25
+ /** Attachment metadata records. See AttachmentContent. */
26
+ ATTACHMENT: '_attachment',
27
+ /** Stack-level configuration singleton. See ConfigContent. */
28
+ CONFIG: '_config',
29
+ /** An owner's approval of an app's manifest. See InstallContent. */
30
+ INSTALL: '_install',
31
+ };
32
+ //# sourceMappingURL=system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/types/system.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,QAAQ;IACR,UAAU;IACV,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;CACJ,CAAC;AAoFX,+BAA+B;AAC/B,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,QAAQ;IACf,oDAAoD;IACpD,KAAK,EAAE,QAAQ;IACf,0DAA0D;IAC1D,UAAU,EAAE,aAAa;IACzB,8DAA8D;IAC9D,MAAM,EAAE,SAAS;IACjB,oEAAoE;IACpE,OAAO,EAAE,UAAU;CACX,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Bearer-token issuance and lookup for server implementations.
3
+ */
4
+ import type { EntityId, Actor } from './ids.js';
5
+ /**
6
+ * The two identities a token establishes — an Actor whose `principalId` is
7
+ * always populated, equal to `subjectId` on an undelegated token, so a
8
+ * server reading one never has to default it. Passes to `Stack.asActor()`
9
+ * as is. See docs/spec/access-control.md § Delegation: principal and subject.
10
+ */
11
+ export type TokenSession = Actor & {
12
+ principalId: EntityId;
13
+ };
14
+ export type TokenInfo = TokenSession & {
15
+ id: string;
16
+ label?: string;
17
+ createdAt: Date;
18
+ expiresAt?: Date;
19
+ };
20
+ /**
21
+ * Bearer-token issuance and lookup for servers — standalone, not a slot on
22
+ * StackAdapter. createToken() trusts its caller: the handshake verifies the
23
+ * principal's DID first, and a differing `subjectId` is asserted by the
24
+ * owner out of band. Store tokens outside the portable stack file.
25
+ * See docs/spec/wire-format.md § Authentication.
26
+ */
27
+ export interface StackTokenStore {
28
+ createToken(actor: Actor, opts?: {
29
+ label?: string;
30
+ expiresAt?: Date;
31
+ }): Promise<{
32
+ id: string;
33
+ token: string;
34
+ }>;
35
+ lookupToken(token: string): Promise<TokenSession | null>;
36
+ listTokens(): Promise<TokenInfo[]>;
37
+ revokeToken(id: string): Promise<void>;
38
+ }
39
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/types/tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IACjC,WAAW,EAAE,QAAQ,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,WAAW,CACT,KAAK,EAAE,KAAK,EACZ,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,IAAI,CAAA;KAAE,GAC1C,OAAO,CAAC;QACT,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACzD,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Bearer-token issuance and lookup for server implementations.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/types/tokens.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,17 +1,21 @@
1
1
  /**
2
- * Stack — Content Validation
2
+ * Stack — Content and Schema Validation
3
3
  * -------------------------------------------------------
4
- * Validates a Record's content object against a TypeSchema.
5
- * Returns a list of validation errors — empty means valid.
4
+ * Validates a Record's content object against a TypeSchema, and a
5
+ * TypeSchema itself before it is defined — including the field-name rules
6
+ * both share, so no stored name is one a content filter cannot address.
7
+ * Every check returns a list of validation errors — empty means valid.
6
8
  *
7
9
  * Validates recursively for array and object field kinds.
8
10
  * Coercion is never performed — types must match exactly.
9
11
  */
10
- import type { TypeSchema } from './types.js';
12
+ import type { TypeSchema } from './types/index.js';
11
13
  export type ValidationError = {
12
14
  path: string;
13
15
  message: string;
14
16
  };
17
+ /** Shared by the 422 for a value outside the list and the 409 for removed values. */
18
+ export declare const formatEnumValues: (values: readonly string[]) => string;
15
19
  /**
16
20
  * Validate content against a schema, collecting all errors.
17
21
  * @param content - The record's content object
@@ -28,23 +32,11 @@ export declare const validateContent: (content: Record<string, unknown>, schema:
28
32
  */
29
33
  export declare const dropAbsentFields: (content: Record<string, unknown>, schema: TypeSchema) => Record<string, unknown>;
30
34
  /**
31
- * Content keys that name JavaScript's object machinery rather than a
32
- * field. Undeclared content fields are allowed by design, so without this
33
- * they reach `merged[key] = value` in applyMergePatch — where `__proto__`
34
- * invokes the prototype setter instead of setting a field.
35
- *
36
- * That is not a prototype-pollution gadget today: JSON.stringify writes
37
- * only own-enumerable properties, so a reassigned prototype never reaches
38
- * storage, and JSON.parse recreates `__proto__` as an own property rather
39
- * than invoking the setter, so a stored one round-trips inertly. The
40
- * defect is that the two write paths disagree — a merge patch to
41
- * `__proto__` silently vanishes, while the same key through create()
42
- * stores as an ordinary field — and that a future refactor deepening the
43
- * shallow merge would turn a quiet inconsistency into a real one.
44
- *
45
- * Rejecting is more honest than skipping: a caller who sends one of these
46
- * finds out, rather than watching a write appear to succeed and do
47
- * nothing. See docs/spec/data-model.md § Reserved content keys.
35
+ * Content keys naming JavaScript's object machinery rather than a field.
36
+ * Whether one survives a write would depend on how the code setting it was
37
+ * written — assignment drops `__proto__`, JSON.parse keeps it — so all
38
+ * three are refused at the write, and the caller finds out.
39
+ * See docs/spec/data-model.md § Reserved content keys.
48
40
  */
49
41
  export declare const RESERVED_CONTENT_KEYS: readonly string[];
50
42
  /**
@@ -52,61 +44,33 @@ export declare const RESERVED_CONTENT_KEYS: readonly string[];
52
44
  * property, so it reaches none of the machinery above.
53
45
  */
54
46
  export declare const validateReservedKeys: (content: Record<string, unknown>) => ValidationError[];
47
+ export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
55
48
  /**
56
- * Check that a schema is actually a schema, before anything reads it as
57
- * one. `defineType()` takes a TypeSchema, but a schema off the wire is
58
- * parsed JSON that TypeScript never saw, so every shape below is reachable
59
- * at runtime: a container declaring neither its interior nor `open` throws
60
- * out of hashSchema() rather than reporting anything, and a definition with
61
- * an unknown `kind` — or none — defines a field whose every write fails
62
- * against an expectation the schema never actually stated, sending the
63
- * caller looking through their content for a bug that is in their type.
64
- *
65
- * Refused at definition time for the reason a field name no filter could
66
- * address is: a schema is a promise, and one nothing can satisfy is worth
67
- * catching where it is written. See docs/spec/data-model.md § Types.
49
+ * Check that a schema is a schema before anything reads it as one: off the
50
+ * wire it is JSON TypeScript never saw. A container declaring neither its
51
+ * interior nor `open` would throw out of hashSchema(), and an unknown `kind`
52
+ * would define a field every write fails. See docs/spec/data-model.md § Types.
68
53
  */
69
54
  export declare const validateSchemaShape: (schema: unknown, prefix?: string, errors?: ValidationError[], depth?: number) => ValidationError[];
70
55
  /**
71
- * The same three names, refused where a schema declares them. Top-level
72
- * only, exactly matching the content rule's scope above: a nested
73
- * declaration names a field a record can actually carry, so refusing one
74
- * would deny a writable shape.
75
- *
76
- * A declaration cannot license what the content rule refuses, so accepting
77
- * one would define a field no record could ever hold — and, where the
78
- * declaration is `required`, a type no record could satisfy at all: supply
79
- * the field and the write is refused as a reserved key, omit it and the
80
- * write is refused as a missing required field. Refused at definition time
81
- * for the reason a field name no filter could address is
82
- * (validateSchemaFieldNames): a schema is a promise that a field is
83
- * meaningful. See docs/spec/data-model.md § Reserved content keys.
56
+ * The same names, refused where a schema declares them, top-level only like
57
+ * the content rule. A declaration cannot license what that rule refuses, so
58
+ * it would define a field no record could hold — and if `required`, a type
59
+ * no record could satisfy. See docs/spec/data-model.md § Reserved content keys.
84
60
  */
85
61
  export declare const validateSchemaReservedNames: (schema: TypeSchema) => ValidationError[];
86
62
  /**
87
- * `undefined` is not a value a merge patch can carry: `null` is the
88
- * deletion sentinel, JSON drops the key on the way to storage, and the
89
- * presence checks a patch runs through read the key as a claim on the
90
- * field it names. Top-level only, matching the shallow merge — a nested
91
- * one is part of a value being replaced wholesale.
63
+ * `undefined` is not a value a merge patch can carry: `null` deletes, JSON
64
+ * drops the key, and the presence checks read the key as a claim on its
65
+ * field. Top-level only, matching the shallow merge.
92
66
  * See docs/spec/data-model.md § Undefined values in a patch.
93
67
  */
94
68
  export declare const validatePatchValues: (patch: Record<string, unknown>) => ValidationError[];
95
69
  /**
96
- * Characters a content field name may not contain, because a content
97
- * filter key is a dot-separated path: `{ content: { 'emails.value': x } }`
98
- * addresses `value` inside `emails`. A field literally named `emails.value`
99
- * would make that filter mean two things at once, so the ambiguity is
100
- * removed from the write side — where it is a validation error a caller
101
- * can act on — rather than from the query side, where it would need an
102
- * escape convention that silently misreads when a caller forgets it.
103
- *
104
- * Wider than what SQLite's JSON path grammar treats as syntax today (`.`,
105
- * `[`, `]`, `$`, `"`): `*` and `#` are reserved against a path grammar
106
- * that grows a wildcard or a last-element form. Narrowing a legal charset
107
- * is a one-way door, so the cost of reserving a character now is nothing
108
- * and the cost of reserving it later is every stored record.
109
- *
70
+ * Characters a field name may not contain: a filter key is a dot-separated
71
+ * path, so a field named `emails.value` would make one filter mean two
72
+ * things. `*` and `#` are reserved ahead of the path grammar, as narrowing
73
+ * a legal charset later costs every stored record.
110
74
  * See docs/spec/data-model.md § Content field names.
111
75
  */
112
76
  export declare const CONTENT_KEY_PATH_METACHARACTERS: readonly [".", "[", "]", "$", "\"", "*", "#"];
@@ -124,9 +88,4 @@ export declare const validateContentKeys: (content: Record<string, unknown>) =>
124
88
  * their own beyond the object properties nested under them.
125
89
  */
126
90
  export declare const validateSchemaFieldNames: (schema: TypeSchema, prefix?: string, errors?: ValidationError[], depth?: number) => ValidationError[];
127
- /**
128
- * Returns true if the content is valid against the schema.
129
- * Use validateContent() directly to get error details.
130
- */
131
- export declare const isValid: (content: Record<string, unknown>, schema: TypeSchema) => boolean;
132
91
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAA6B,MAAM,YAAY,CAAC;AAmBxE,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAyKF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,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