@haverstack/core 0.41.0 → 0.43.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 (317) hide show
  1. package/README.md +124 -64
  2. package/dist/access.d.ts +43 -47
  3. package/dist/access.d.ts.map +1 -1
  4. package/dist/access.js +66 -101
  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} +18 -3
  9. package/dist/adapter/combine.js.map +1 -0
  10. package/dist/adapter/index.d.ts +19 -0
  11. package/dist/adapter/index.d.ts.map +1 -0
  12. package/dist/adapter/index.js +16 -0
  13. package/dist/adapter/index.js.map +1 -0
  14. package/dist/adapter/reach.d.ts +14 -0
  15. package/dist/adapter/reach.d.ts.map +1 -0
  16. package/dist/adapter/reach.js +31 -0
  17. package/dist/adapter/reach.js.map +1 -0
  18. package/dist/{sort.d.ts → adapter/sort.d.ts} +20 -20
  19. package/dist/adapter/sort.d.ts.map +1 -0
  20. package/dist/{sort.js → adapter/sort.js} +37 -27
  21. package/dist/adapter/sort.js.map +1 -0
  22. package/dist/associations/identity.d.ts +69 -0
  23. package/dist/associations/identity.d.ts.map +1 -0
  24. package/dist/associations/identity.js +174 -0
  25. package/dist/associations/identity.js.map +1 -0
  26. package/dist/associations/validation.d.ts +83 -0
  27. package/dist/associations/validation.d.ts.map +1 -0
  28. package/dist/associations/validation.js +312 -0
  29. package/dist/associations/validation.js.map +1 -0
  30. package/dist/attachment-records.d.ts +48 -0
  31. package/dist/attachment-records.d.ts.map +1 -0
  32. package/dist/attachment-records.js +52 -0
  33. package/dist/attachment-records.js.map +1 -0
  34. package/dist/collection.d.ts +178 -0
  35. package/dist/collection.d.ts.map +1 -0
  36. package/dist/collection.js +397 -0
  37. package/dist/collection.js.map +1 -0
  38. package/dist/content-match.d.ts +25 -0
  39. package/dist/content-match.d.ts.map +1 -0
  40. package/dist/content-match.js +51 -0
  41. package/dist/content-match.js.map +1 -0
  42. package/dist/content-translation.d.ts +42 -0
  43. package/dist/content-translation.d.ts.map +1 -0
  44. package/dist/content-translation.js +108 -0
  45. package/dist/content-translation.js.map +1 -0
  46. package/dist/did/did.d.ts.map +1 -0
  47. package/dist/{did.js → did/did.js} +3 -4
  48. package/dist/did/did.js.map +1 -0
  49. package/dist/{did-entry.d.ts → did/index.d.ts} +1 -1
  50. package/dist/did/index.d.ts.map +1 -0
  51. package/dist/{did-entry.js → did/index.js} +3 -3
  52. package/dist/did/index.js.map +1 -0
  53. package/dist/errors.d.ts +54 -66
  54. package/dist/errors.d.ts.map +1 -1
  55. package/dist/errors.js +58 -62
  56. package/dist/errors.js.map +1 -1
  57. package/dist/grants.d.ts +20 -44
  58. package/dist/grants.d.ts.map +1 -1
  59. package/dist/grants.js +69 -151
  60. package/dist/grants.js.map +1 -1
  61. package/dist/id.d.ts +13 -31
  62. package/dist/id.d.ts.map +1 -1
  63. package/dist/id.js +13 -31
  64. package/dist/id.js.map +1 -1
  65. package/dist/index.d.ts +13 -9
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +9 -6
  68. package/dist/index.js.map +1 -1
  69. package/dist/install.d.ts +3 -6
  70. package/dist/install.d.ts.map +1 -1
  71. package/dist/install.js +6 -10
  72. package/dist/install.js.map +1 -1
  73. package/dist/lazy.d.ts +13 -0
  74. package/dist/lazy.d.ts.map +1 -0
  75. package/dist/lazy.js +27 -0
  76. package/dist/lazy.js.map +1 -0
  77. package/dist/merge.d.ts +1 -1
  78. package/dist/merge.d.ts.map +1 -1
  79. package/dist/merge.js +6 -12
  80. package/dist/merge.js.map +1 -1
  81. package/dist/migration-steps.d.ts +102 -0
  82. package/dist/migration-steps.d.ts.map +1 -0
  83. package/dist/migration-steps.js +293 -0
  84. package/dist/migration-steps.js.map +1 -0
  85. package/dist/query-validation.d.ts +68 -121
  86. package/dist/query-validation.d.ts.map +1 -1
  87. package/dist/query-validation.js +214 -380
  88. package/dist/query-validation.js.map +1 -1
  89. package/dist/record-changes.d.ts +11 -150
  90. package/dist/record-changes.d.ts.map +1 -1
  91. package/dist/record-changes.js +14 -305
  92. package/dist/record-changes.js.map +1 -1
  93. package/dist/schema.d.ts +18 -7
  94. package/dist/schema.d.ts.map +1 -1
  95. package/dist/schema.js +59 -30
  96. package/dist/schema.js.map +1 -1
  97. package/dist/scoped-stack/authority-snapshot.d.ts +37 -0
  98. package/dist/scoped-stack/authority-snapshot.d.ts.map +1 -0
  99. package/dist/scoped-stack/authority-snapshot.js +49 -0
  100. package/dist/scoped-stack/authority-snapshot.js.map +1 -0
  101. package/dist/scoped-stack/authority.d.ts +169 -0
  102. package/dist/scoped-stack/authority.d.ts.map +1 -0
  103. package/dist/scoped-stack/authority.js +408 -0
  104. package/dist/scoped-stack/authority.js.map +1 -0
  105. package/dist/scoped-stack/family-policy.d.ts +59 -0
  106. package/dist/scoped-stack/family-policy.d.ts.map +1 -0
  107. package/dist/scoped-stack/family-policy.js +68 -0
  108. package/dist/scoped-stack/family-policy.js.map +1 -0
  109. package/dist/scoped-stack/scoped-stack.d.ts +318 -0
  110. package/dist/scoped-stack/scoped-stack.d.ts.map +1 -0
  111. package/dist/scoped-stack/scoped-stack.js +695 -0
  112. package/dist/scoped-stack/scoped-stack.js.map +1 -0
  113. package/dist/scoped-stack/subscription.d.ts +36 -0
  114. package/dist/scoped-stack/subscription.d.ts.map +1 -0
  115. package/dist/scoped-stack/subscription.js +69 -0
  116. package/dist/scoped-stack/subscription.js.map +1 -0
  117. package/dist/stack/arguments.d.ts +27 -0
  118. package/dist/stack/arguments.d.ts.map +1 -0
  119. package/dist/stack/arguments.js +53 -0
  120. package/dist/stack/arguments.js.map +1 -0
  121. package/dist/stack/attachments.d.ts +24 -0
  122. package/dist/stack/attachments.d.ts.map +1 -0
  123. package/dist/stack/attachments.js +113 -0
  124. package/dist/stack/attachments.js.map +1 -0
  125. package/dist/{changes.d.ts → stack/changes.d.ts} +30 -72
  126. package/dist/stack/changes.d.ts.map +1 -0
  127. package/dist/{changes.js → stack/changes.js} +40 -74
  128. package/dist/stack/changes.js.map +1 -0
  129. package/dist/stack/client.d.ts +247 -0
  130. package/dist/stack/client.d.ts.map +1 -0
  131. package/dist/stack/client.js +9 -0
  132. package/dist/stack/client.js.map +1 -0
  133. package/dist/stack/identity-bindings.d.ts.map +1 -0
  134. package/dist/{identity-bindings.js → stack/identity-bindings.js} +5 -14
  135. package/dist/stack/identity-bindings.js.map +1 -0
  136. package/dist/stack/install-app.d.ts +22 -0
  137. package/dist/stack/install-app.d.ts.map +1 -0
  138. package/dist/stack/install-app.js +262 -0
  139. package/dist/stack/install-app.js.map +1 -0
  140. package/dist/stack/integrity.d.ts +94 -0
  141. package/dist/stack/integrity.d.ts.map +1 -0
  142. package/dist/stack/integrity.js +268 -0
  143. package/dist/stack/integrity.js.map +1 -0
  144. package/dist/{limits.d.ts → stack/limits.d.ts} +2 -5
  145. package/dist/stack/limits.d.ts.map +1 -0
  146. package/dist/{limits.js → stack/limits.js} +3 -6
  147. package/dist/stack/limits.js.map +1 -0
  148. package/dist/stack/migrations.d.ts +59 -0
  149. package/dist/stack/migrations.d.ts.map +1 -0
  150. package/dist/stack/migrations.js +141 -0
  151. package/dist/stack/migrations.js.map +1 -0
  152. package/dist/stack/reads.d.ts +69 -0
  153. package/dist/stack/reads.d.ts.map +1 -0
  154. package/dist/stack/reads.js +141 -0
  155. package/dist/stack/reads.js.map +1 -0
  156. package/dist/stack/record-id.d.ts +35 -0
  157. package/dist/stack/record-id.d.ts.map +1 -0
  158. package/dist/stack/record-id.js +82 -0
  159. package/dist/stack/record-id.js.map +1 -0
  160. package/dist/stack/stack.d.ts +444 -0
  161. package/dist/stack/stack.d.ts.map +1 -0
  162. package/dist/stack/stack.js +1339 -0
  163. package/dist/stack/stack.js.map +1 -0
  164. package/dist/stack/system-types.d.ts +16 -0
  165. package/dist/stack/system-types.d.ts.map +1 -0
  166. package/dist/stack/system-types.js +111 -0
  167. package/dist/stack/system-types.js.map +1 -0
  168. package/dist/stack/type-grants.d.ts +20 -0
  169. package/dist/stack/type-grants.d.ts.map +1 -0
  170. package/dist/stack/type-grants.js +69 -0
  171. package/dist/stack/type-grants.js.map +1 -0
  172. package/dist/stack/write-expectation.d.ts +79 -0
  173. package/dist/stack/write-expectation.d.ts.map +1 -0
  174. package/dist/stack/write-expectation.js +71 -0
  175. package/dist/stack/write-expectation.js.map +1 -0
  176. package/dist/stack/write-gate.d.ts +23 -0
  177. package/dist/stack/write-gate.d.ts.map +1 -0
  178. package/dist/stack/write-gate.js +17 -0
  179. package/dist/stack/write-gate.js.map +1 -0
  180. package/dist/testing.d.ts +44 -33
  181. package/dist/testing.d.ts.map +1 -1
  182. package/dist/testing.js +180 -176
  183. package/dist/testing.js.map +1 -1
  184. package/dist/type-handle.d.ts +67 -78
  185. package/dist/type-handle.d.ts.map +1 -1
  186. package/dist/type-handle.js +44 -111
  187. package/dist/type-handle.js.map +1 -1
  188. package/dist/types/adapter.d.ts +282 -0
  189. package/dist/types/adapter.d.ts.map +1 -0
  190. package/dist/types/adapter.js +5 -0
  191. package/dist/types/adapter.js.map +1 -0
  192. package/dist/types/associations.d.ts +140 -0
  193. package/dist/types/associations.d.ts.map +1 -0
  194. package/dist/types/associations.js +6 -0
  195. package/dist/types/associations.js.map +1 -0
  196. package/dist/types/capabilities.d.ts +89 -0
  197. package/dist/types/capabilities.d.ts.map +1 -0
  198. package/dist/types/capabilities.js +5 -0
  199. package/dist/types/capabilities.js.map +1 -0
  200. package/dist/types/events.d.ts +150 -0
  201. package/dist/types/events.d.ts.map +1 -0
  202. package/dist/types/events.js +5 -0
  203. package/dist/types/events.js.map +1 -0
  204. package/dist/types/ids.d.ts +43 -0
  205. package/dist/types/ids.d.ts.map +1 -0
  206. package/dist/types/ids.js +5 -0
  207. package/dist/types/ids.js.map +1 -0
  208. package/dist/types/index.d.ts +19 -0
  209. package/dist/types/index.d.ts.map +1 -0
  210. package/dist/types/index.js +19 -0
  211. package/dist/types/index.js.map +1 -0
  212. package/dist/types/journal.d.ts +47 -0
  213. package/dist/types/journal.d.ts.map +1 -0
  214. package/dist/types/journal.js +5 -0
  215. package/dist/types/journal.js.map +1 -0
  216. package/dist/types/query.d.ts +185 -0
  217. package/dist/types/query.d.ts.map +1 -0
  218. package/dist/types/query.js +10 -0
  219. package/dist/types/query.js.map +1 -0
  220. package/dist/types/records.d.ts +76 -0
  221. package/dist/types/records.d.ts.map +1 -0
  222. package/dist/types/records.js +5 -0
  223. package/dist/types/records.js.map +1 -0
  224. package/dist/types/schema.d.ts +74 -0
  225. package/dist/types/schema.d.ts.map +1 -0
  226. package/dist/types/schema.js +5 -0
  227. package/dist/types/schema.js.map +1 -0
  228. package/dist/types/system.d.ts +161 -0
  229. package/dist/types/system.d.ts.map +1 -0
  230. package/dist/types/system.js +32 -0
  231. package/dist/types/system.js.map +1 -0
  232. package/dist/types/tokens.d.ts +39 -0
  233. package/dist/types/tokens.d.ts.map +1 -0
  234. package/dist/types/tokens.js +5 -0
  235. package/dist/types/tokens.js.map +1 -0
  236. package/dist/validate.d.ts +31 -70
  237. package/dist/validate.d.ts.map +1 -1
  238. package/dist/validate.js +52 -92
  239. package/dist/validate.js.map +1 -1
  240. package/dist/{attachment-download.d.ts → wire/attachment-download.d.ts} +0 -57
  241. package/dist/wire/attachment-download.d.ts.map +1 -0
  242. package/dist/{attachment-download.js → wire/attachment-download.js} +0 -61
  243. package/dist/wire/attachment-download.js.map +1 -0
  244. package/dist/{auth.d.ts → wire/auth.d.ts} +5 -8
  245. package/dist/wire/auth.d.ts.map +1 -0
  246. package/dist/{auth.js → wire/auth.js} +5 -8
  247. package/dist/wire/auth.js.map +1 -0
  248. package/dist/{wire-body.d.ts → wire/body.d.ts} +35 -12
  249. package/dist/wire/body.d.ts.map +1 -0
  250. package/dist/{wire-body.js → wire/body.js} +74 -13
  251. package/dist/wire/body.js.map +1 -0
  252. package/dist/{wire-entry.d.ts → wire/index.d.ts} +12 -12
  253. package/dist/wire/index.d.ts.map +1 -0
  254. package/dist/{wire-entry.js → wire/index.js} +13 -17
  255. package/dist/wire/index.js.map +1 -0
  256. package/dist/wire/record.d.ts +31 -0
  257. package/dist/wire/record.d.ts.map +1 -0
  258. package/dist/{wire-record.js → wire/record.js} +7 -67
  259. package/dist/wire/record.js.map +1 -0
  260. package/dist/{wire-request.d.ts → wire/request.d.ts} +32 -49
  261. package/dist/wire/request.d.ts.map +1 -0
  262. package/dist/{wire-request.js → wire/request.js} +113 -83
  263. package/dist/wire/request.js.map +1 -0
  264. package/package.json +7 -7
  265. package/dist/adapter-entry.d.ts +0 -16
  266. package/dist/adapter-entry.d.ts.map +0 -1
  267. package/dist/adapter-entry.js +0 -14
  268. package/dist/adapter-entry.js.map +0 -1
  269. package/dist/attachment-download.d.ts.map +0 -1
  270. package/dist/attachment-download.js.map +0 -1
  271. package/dist/auth.d.ts.map +0 -1
  272. package/dist/auth.js.map +0 -1
  273. package/dist/changes.d.ts.map +0 -1
  274. package/dist/changes.js.map +0 -1
  275. package/dist/combine.d.ts.map +0 -1
  276. package/dist/combine.js.map +0 -1
  277. package/dist/did-entry.d.ts.map +0 -1
  278. package/dist/did-entry.js.map +0 -1
  279. package/dist/did.d.ts.map +0 -1
  280. package/dist/did.js.map +0 -1
  281. package/dist/identity-bindings.d.ts.map +0 -1
  282. package/dist/identity-bindings.js.map +0 -1
  283. package/dist/limits.d.ts.map +0 -1
  284. package/dist/limits.js.map +0 -1
  285. package/dist/record-id.d.ts +0 -70
  286. package/dist/record-id.d.ts.map +0 -1
  287. package/dist/record-id.js +0 -127
  288. package/dist/record-id.js.map +0 -1
  289. package/dist/scoped-stack.d.ts +0 -549
  290. package/dist/scoped-stack.d.ts.map +0 -1
  291. package/dist/scoped-stack.js +0 -1301
  292. package/dist/scoped-stack.js.map +0 -1
  293. package/dist/sort.d.ts.map +0 -1
  294. package/dist/sort.js.map +0 -1
  295. package/dist/stack-reads.d.ts +0 -38
  296. package/dist/stack-reads.d.ts.map +0 -1
  297. package/dist/stack-reads.js +0 -79
  298. package/dist/stack-reads.js.map +0 -1
  299. package/dist/stack.d.ts +0 -1032
  300. package/dist/stack.d.ts.map +0 -1
  301. package/dist/stack.js +0 -2337
  302. package/dist/stack.js.map +0 -1
  303. package/dist/types.d.ts +0 -1278
  304. package/dist/types.d.ts.map +0 -1
  305. package/dist/types.js +0 -51
  306. package/dist/types.js.map +0 -1
  307. package/dist/wire-body.d.ts.map +0 -1
  308. package/dist/wire-body.js.map +0 -1
  309. package/dist/wire-entry.d.ts.map +0 -1
  310. package/dist/wire-entry.js.map +0 -1
  311. package/dist/wire-record.d.ts +0 -50
  312. package/dist/wire-record.d.ts.map +0 -1
  313. package/dist/wire-record.js.map +0 -1
  314. package/dist/wire-request.d.ts.map +0 -1
  315. package/dist/wire-request.js.map +0 -1
  316. /package/dist/{did.d.ts → did/did.d.ts} +0 -0
  317. /package/dist/{identity-bindings.d.ts → stack/identity-bindings.d.ts} +0 -0
@@ -2,7 +2,7 @@
2
2
  * Stack — Wire Request Bodies
3
3
  * -------------------------------------------------------
4
4
  * The JSON bodies of the endpoints core specifies but runs no server for:
5
- * the auth handshake, `PATCH /entity`, `POST /types`,
5
+ * the auth handshake, the per-aspect record writes, `POST /types`,
6
6
  * `POST /records/:id/migrate` and `POST /installs`. Each parser names every key its endpoint
7
7
  * defines, so a server refuses the rest without keeping its own copy of
8
8
  * the list — a copy that drifts the first time core adds a field.
@@ -16,8 +16,8 @@
16
16
  * DID's form — so judging them here would let two answers drift.
17
17
  * See docs/spec/wire-format.md § Unrecognized input.
18
18
  */
19
- import { StackBadRequestError, StackValidationError } from './errors.js';
20
- import { assertKnownKeys, validateAssociation } from './query-validation.js';
19
+ import { ARGUMENTS_INVALID, StackBadRequestError, StackValidationError } from '../errors.js';
20
+ import { assertKnownKeys, validateAssociation } from '../associations/validation.js';
21
21
  export function requireBody(body, label) {
22
22
  if (typeof body !== 'object' || body === null || Array.isArray(body))
23
23
  throw new StackBadRequestError(`Invalid ${label}: expected an object`);
@@ -29,7 +29,7 @@ export function requireBody(body, label) {
29
29
  * class carries the path.
30
30
  */
31
31
  export function fieldError(path, message) {
32
- throw new StackValidationError([{ path, message }]);
32
+ throw new StackValidationError([{ path, message }], ARGUMENTS_INVALID);
33
33
  }
34
34
  /** A body carrying only `keys`; anything else is refused rather than ignored. */
35
35
  function requireKnownBody(body, keys, label) {
@@ -79,18 +79,79 @@ export function parseAuthTokenBody(body) {
79
79
  signature: requiredString(b, 'signature', label),
80
80
  };
81
81
  }
82
- /** Parse a `PATCH /entity` body. See docs/spec/wire-format.md § Entity. */
83
- export function parseEntityPatchBody(body) {
84
- const label = 'entity body';
85
- const b = requireKnownBody(body, ['contentPatch'], label);
86
- return { contentPatch: requiredObject(b, 'contentPatch', label) };
82
+ // -------------------------------------------------------
83
+ // PATCH /records/:id/content, PATCH /entity/content
84
+ // -------------------------------------------------------
85
+ /**
86
+ * Parse a content patch body: the bare patch, every key a content key.
87
+ * Which keys the record's type declares is `patchContent()`'s to judge, so
88
+ * an undeclared one is its 422 rather than a 400 here.
89
+ * See docs/spec/wire-format.md § Content.
90
+ */
91
+ export function parseContentPatchBody(body) {
92
+ return requireBody(body, 'content patch');
93
+ }
94
+ // -------------------------------------------------------
95
+ // PUT /records/:id/parent, PUT /records/:id/unlisted
96
+ // -------------------------------------------------------
97
+ /**
98
+ * Parse a `PUT /records/:id/parent` body. `null` is the root, not a
99
+ * removal spelling. See docs/spec/wire-format.md § Parent.
100
+ */
101
+ export function parseParentBody(body) {
102
+ const label = 'parent body';
103
+ const b = requireKnownBody(body, ['parentId'], label);
104
+ const { parentId } = b;
105
+ if (parentId === undefined)
106
+ throw new StackBadRequestError(`Invalid ${label}: parentId is required`);
107
+ if (parentId !== null && typeof parentId !== 'string')
108
+ fieldError('parentId', 'parentId must be a string or null');
109
+ return { parentId };
110
+ }
111
+ /** Parse a `PUT /records/:id/unlisted` body. See docs/spec/wire-format.md § Unlisted. */
112
+ export function parseUnlistedBody(body) {
113
+ const label = 'unlisted body';
114
+ const b = requireKnownBody(body, ['unlisted'], label);
115
+ const { unlisted } = b;
116
+ if (unlisted === undefined)
117
+ throw new StackBadRequestError(`Invalid ${label}: unlisted is required`);
118
+ if (typeof unlisted !== 'boolean')
119
+ fieldError('unlisted', 'unlisted must be a boolean');
120
+ return { unlisted };
121
+ }
122
+ // -------------------------------------------------------
123
+ // PUT /records/:id/associations, PUT /records/:id/permissions
124
+ // -------------------------------------------------------
125
+ /**
126
+ * Parse a `PUT /records/:id/associations` body into the set
127
+ * `setAssociations()` takes. Elements are `setAssociations()`'s to judge.
128
+ * See docs/spec/wire-format.md § Associations.
129
+ */
130
+ export function parseAssociationsBody(body) {
131
+ return requiredList(body, 'associations', 'associations body');
132
+ }
133
+ /**
134
+ * Parse a `PUT /records/:id/permissions` body into the set `setAccess()`
135
+ * takes; `[]` makes the record private. See docs/spec/wire-format.md § Permissions.
136
+ */
137
+ export function parsePermissionsBody(body) {
138
+ return requiredList(body, 'permissions', 'permissions body');
139
+ }
140
+ function requiredList(body, key, label) {
141
+ const b = requireKnownBody(body, [key], label);
142
+ const value = b[key];
143
+ if (value === undefined)
144
+ throw new StackBadRequestError(`Invalid ${label}: ${key} is required`);
145
+ if (!Array.isArray(value))
146
+ fieldError(key, `${key} must be an array`);
147
+ return value;
87
148
  }
88
149
  // -------------------------------------------------------
89
150
  // POST /records/:id/associations, POST /records/:id/permissions
90
151
  // -------------------------------------------------------
91
152
  /**
92
- * Parse an association or permission amend body into the edits
93
- * `amendAssociations()` takes. `repoint` is something the journal records,
153
+ * Parse an association or permission edit body into the edits
154
+ * `editAssociations()` and `editAccess()` take. `repoint` is something the journal records,
94
155
  * never something a caller sends, so it is refused with the other unknown
95
156
  * ops. Which surface an element belongs to is the endpoint's to judge.
96
157
  * See docs/spec/wire-format.md § Associations.
@@ -119,7 +180,7 @@ export function parseAssociationEditsBody(body) {
119
180
  const association = requiredObject(edit, 'association', `${label} ${path}`);
120
181
  const errors = validateAssociation(association, `${path}.association`);
121
182
  if (errors.length > 0)
122
- throw new StackValidationError(errors);
183
+ throw new StackValidationError(errors, ARGUMENTS_INVALID);
123
184
  return { op: edit.op, association };
124
185
  });
125
186
  }
@@ -232,4 +293,4 @@ function nestedArray(obj, at, key) {
232
293
  fieldError(`${at}.${key}`, `${key} must be an array`);
233
294
  return value;
234
295
  }
235
- //# sourceMappingURL=wire-body.js.map
296
+ //# sourceMappingURL=body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"body.js","sourceRoot":"","sources":["../../src/wire/body.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAYrF,MAAM,UAAU,WAAW,CAAC,IAAa,EAAE,KAAa;IACtD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAClE,MAAM,IAAI,oBAAoB,CAAC,WAAW,KAAK,sBAAsB,CAAC,CAAC;IACzE,OAAO,IAA+B,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,OAAe;IACtD,MAAM,IAAI,oBAAoB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,iBAAiB,CAAC,CAAC;AACzE,CAAC;AAED,iFAAiF;AACjF,SAAS,gBAAgB,CACvB,IAAa,EACb,IAAuB,EACvB,KAAa;IAEb,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,E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,OAAO,EAAE,OAAwB,EAAE,CAAC;QAC1F,CAAC,CAAC;KACH,CAAC;IACF,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ;YAAE,UAAU,CAAC,kBAAkB,EAAE,0BAA0B,CAAC,CAAC;QAC9F,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC;IAC/B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,8EAA8E;AAC9E,SAAS,YAAY,CAAC,GAA4B,EAAE,EAAU,EAAE,GAAW;IACzE,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,oBAAoB,CAAC,WAAW,EAAE,KAAK,GAAG,cAAc,CAAC,CAAC;IAC7F,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,UAAU,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,mBAAmB,CAAC,CAAC;IACrF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,6EAA6E;AAC7E,SAAS,WAAW,CAAC,GAA4B,EAAE,EAAU,EAAE,GAAW;IACxE,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,oBAAoB,CAAC,WAAW,EAAE,KAAK,GAAG,cAAc,CAAC,CAAC;IAC7F,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,UAAU,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,mBAAmB,CAAC,CAAC;IACjF,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -16,15 +16,15 @@ export { authOriginFromUrl } from './auth.js';
16
16
  export { InvalidAuthChallengeError } from './auth.js';
17
17
  export { isSafeAttachmentContentType, inferContentTypeFromFilename, resolveAttachmentDownloadContentType, NOSNIFF_HEADER_NAME, NOSNIFF_HEADER_VALUE, } from './attachment-download.js';
18
18
  export type { AttachmentDownloadContentType } from './attachment-download.js';
19
- export { firstRecordedAttachment, resolveReferencedAttachment } from './attachment-download.js';
20
- export type { StackTokenStore, TokenInfo, TokenSession } from './types.js';
21
- export { parseQueryParams, parseQueryBody, parseChangeParams, parseJournalParams, parseVersionsParams, parseGetRecordParams, parseDeleteParams, parseDownloadParams, parseAssociationParams, parseIfMatch, parseUploadFilename, parsePositiveInt, } from './wire-request.js';
22
- export { assertQueryTravels } from './wire-request.js';
23
- export type { ParsedChangeParams, ParsedDownloadParams, ParsedAssociationParams, } from './wire-request.js';
24
- export { parseDate } from './wire-request.js';
25
- export { createOptionsFromWireRecord, changesFromWireBody } from './wire-record.js';
26
- export type { WireCreateRequest } from './wire-record.js';
27
- export { parseAssociationEditsBody, parseAuthChallengeBody, parseAuthTokenBody, parseEntityPatchBody, parseTypeBody, parseMigrationBody, parseInstallBody, } from './wire-body.js';
28
- export type { WireAuthChallengeRequest, WireAuthTokenRequest, WireEntityPatch, WireMigrationRequest, } from './wire-body.js';
29
- export { isOwnerActingAlone } from './access.js';
30
- //# sourceMappingURL=wire-entry.d.ts.map
19
+ export { firstRecordedAttachment, resolveReferencedAttachment } from '../attachment-records.js';
20
+ export type { StackTokenStore, TokenInfo, TokenSession } from '../types/index.js';
21
+ export { parseQueryParams, parseQueryBody, parseChangeParams, parseJournalParams, parseVersionsParams, parseGetRecordParams, parseDeleteParams, parseDownloadParams, parseAssociationParams, parseIfMatch, parseUploadFilename, parseUnsignedInt, } from './request.js';
22
+ export { assertQueryTravels } from './request.js';
23
+ export type { ParsedChangeParams, ParsedDownloadParams, ParsedAssociationParams, } from './request.js';
24
+ export { parseDate } from './request.js';
25
+ export { createOptionsFromWireRecord } from './record.js';
26
+ export type { WireCreateRequest } from './record.js';
27
+ export { parseContentPatchBody, parseParentBody, parseUnlistedBody, parseAssociationEditsBody, parseAssociationsBody, parsePermissionsBody, parseAuthChallengeBody, parseAuthTokenBody, parseTypeBody, parseMigrationBody, parseInstallBody, } from './body.js';
28
+ export type { WireAuthChallengeRequest, WireAuthTokenRequest, WireMigrationRequest, } from './body.js';
29
+ export { isOwnerActingAlone } from '../access.js';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wire/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAM9E,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAIhG,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMlF,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAKzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKrD,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,WAAW,CAAC;AAKnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
@@ -12,8 +12,7 @@
12
12
  */
13
13
  export { buildAuthChallengePayload, signAuthChallenge, verifyAuthChallenge, didCredentialFromKeypair, base64urlEncode, base64urlDecode, } from './auth.js';
14
14
  // No in-repo caller: a server must derive the signing origin from its own
15
- // configured public origin (haverstack/server#53) — this is the primitive
16
- // it does that with.
15
+ // configured public origin — this is the primitive it does that with.
17
16
  export { authOriginFromUrl } from './auth.js';
18
17
  // Thrown by authOriginFromUrl, buildAuthChallengePayload and
19
18
  // base64urlDecode above — all public, so a caller needs this to
@@ -23,33 +22,30 @@ export { isSafeAttachmentContentType, inferContentTypeFromFilename, resolveAttac
23
22
  // No in-repo caller: resolveAttachmentDownloadContentType() takes
24
23
  // storedMimeType as an input rather than selecting the record itself — a
25
24
  // server must call these to pick the record a download describes and pass
26
- // the winner in. Contract, not internal. haverstack/server#37
27
- export { firstRecordedAttachment, resolveReferencedAttachment } from './attachment-download.js';
25
+ // the winner in. Contract, not internal.
26
+ export { firstRecordedAttachment, resolveReferencedAttachment } from '../attachment-records.js';
28
27
  // No in-repo caller: the parse half of the request encoding adapter-api
29
- // builds, so a server decodes GET /records, POST /records/query,
30
- // GET /changes, GET /records/:id/journal, GET /records/:id/versions, GET /records/:id,
31
- // DELETE /records/:id, GET /attachments/:fileId and GET /records/:id/associations with these
32
- // rather than transcribing the parameter table.
33
- // Contract, not internal — and the round trip against the builders is
34
- // pinned by a test, which is what having both halves here buys.
35
- export { parseQueryParams, parseQueryBody, parseChangeParams, parseJournalParams, parseVersionsParams, parseGetRecordParams, parseDeleteParams, parseDownloadParams, parseAssociationParams, parseIfMatch, parseUploadFilename, parsePositiveInt, } from './wire-request.js';
28
+ // builds, so a server decodes every query-bearing route with these rather
29
+ // than transcribing the parameter table. Contract, not internal — the
30
+ // round trip against the builders is pinned by a test.
31
+ export { parseQueryParams, parseQueryBody, parseChangeParams, parseJournalParams, parseVersionsParams, parseGetRecordParams, parseDeleteParams, parseDownloadParams, parseAssociationParams, parseIfMatch, parseUploadFilename, parseUnsignedInt, } from './request.js';
36
32
  // The build-side half of the fields that never travel: adapter-api refuses
37
33
  // them before encoding, so which encoding a server's content reach selects
38
34
  // never decides whether a family query widens or is refused.
39
- export { assertQueryTravels } from './wire-request.js';
35
+ export { assertQueryTravels } from './request.js';
40
36
  // Re-exported by @haverstack/wire-types for the response side: one wire
41
37
  // date decoding, used by both halves.
42
- export { parseDate } from './wire-request.js';
38
+ export { parseDate } from './request.js';
43
39
  // No in-repo caller: the create half of the same contract, so a server
44
40
  // inherits which half of a record body it may trust rather than deciding
45
41
  // field by field. See docs/spec/wire-format.md § Records.
46
- export { createOptionsFromWireRecord, changesFromWireBody } from './wire-record.js';
42
+ export { createOptionsFromWireRecord } from './record.js';
47
43
  // No in-repo caller: the bodies of the remaining endpoints core specifies,
48
44
  // so a server refuses a key they do not define without keeping its own
49
45
  // list of the ones they do. See docs/spec/wire-format.md § Unrecognized input.
50
- export { parseAssociationEditsBody, parseAuthChallengeBody, parseAuthTokenBody, parseEntityPatchBody, parseTypeBody, parseMigrationBody, parseInstallBody, } from './wire-body.js';
46
+ export { parseContentPatchBody, parseParentBody, parseUnlistedBody, parseAssociationEditsBody, parseAssociationsBody, parsePermissionsBody, parseAuthChallengeBody, parseAuthTokenBody, parseTypeBody, parseMigrationBody, parseInstallBody, } from './body.js';
51
47
  // The tier gating purge, commitMigration() and includeUnlisted, which
52
48
  // a server must decide for those routes itself. Computing it as "is the
53
49
  // owner" is a privilege bug with no symptom.
54
- export { isOwnerActingAlone } from './access.js';
55
- //# sourceMappingURL=wire-entry.js.map
50
+ export { isOwnerActingAlone } from '../access.js';
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wire/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,GAChB,MAAM,WAAW,CAAC;AAGnB,0EAA0E;AAC1E,sEAAsE;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,6DAA6D;AAC7D,gEAAgE;AAChE,oDAAoD;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAGlC,kEAAkE;AAClE,yEAAyE;AACzE,0EAA0E;AAC1E,yCAAyC;AACzC,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAMhG,wEAAwE;AACxE,0EAA0E;AAC1E,sEAAsE;AACtE,uDAAuD;AACvD,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,2EAA2E;AAC3E,2EAA2E;AAC3E,6DAA6D;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAOlD,wEAAwE;AACxE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,uEAAuE;AACvE,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAG1D,2EAA2E;AAC3E,uEAAuE;AACvE,+EAA+E;AAC/E,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAOnB,sEAAsE;AACtE,wEAAwE;AACxE,6CAA6C;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Stack — Wire Record Bodies
3
+ * -------------------------------------------------------
4
+ * `POST /records` is the one endpoint where a client sends a whole record
5
+ * and the server may trust only part of it. This module turns that body
6
+ * into the arguments `ScopedStack.create()` takes, so the disposition of
7
+ * each field — stamped, conditionally dropped, forwarded — is structural
8
+ * rather than a property of how carefully a route was written. Which field
9
+ * gets which is not derivable from its name, and the rules are normative
10
+ * for servers in other languages, so they live in the spec rather than
11
+ * here: docs/spec/wire-format.md § Records.
12
+ */
13
+ import type { BackdatableCreateRecordOptions } from '../stack/client.js';
14
+ import type { EntityId, TokenSession, TypeId } from '../types/index.js';
15
+ /**
16
+ * A `POST /records` body as the three arguments `ScopedStack.create()`
17
+ * takes. Not spread-ready, so a call site reads as three deliberate things.
18
+ */
19
+ export type WireCreateRequest = {
20
+ typeId: TypeId;
21
+ content: Record<string, unknown>;
22
+ /** Omitted, not optional: a caller cannot forward what the type lacks. */
23
+ options: Omit<BackdatableCreateRecordOptions, 'createdBy'>;
24
+ };
25
+ /**
26
+ * Read a `POST /records` body as a create. Takes the session, not a
27
+ * precomputed boolean, so the owner-acting-alone decision stays with its
28
+ * rule. Values beyond shape are `Stack`'s to judge, or two answers drift.
29
+ */
30
+ export declare function createOptionsFromWireRecord(body: unknown, session: TokenSession, ownerEntityId: EntityId): WireCreateRequest;
31
+ //# sourceMappingURL=record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/wire/record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EACV,QAAQ,EAIR,YAAY,EACZ,MAAM,EACP,MAAM,mBAAmB,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,0EAA0E;IAC1E,OAAO,EAAE,IAAI,CAAC,8BAA8B,EAAE,WAAW,CAAC,CAAC;CAC5D,CAAC;AAsDF;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,YAAY,EACrB,aAAa,EAAE,QAAQ,GACtB,iBAAiB,CAyCnB"}
@@ -10,10 +10,9 @@
10
10
  * for servers in other languages, so they live in the spec rather than
11
11
  * here: docs/spec/wire-format.md § Records.
12
12
  */
13
- import { isOwnerActingAlone } from './access.js';
14
- import { StackBadRequestError } from './errors.js';
15
- import { fieldError, requireBody } from './wire-body.js';
16
- import { RECORD_CHANGE_SET_KEYS } from './types.js';
13
+ import { isOwnerActingAlone } from '../access.js';
14
+ import { StackBadRequestError } from '../errors.js';
15
+ import { fieldError, requireBody } from './body.js';
17
16
  /**
18
17
  * Every top-level key a wire record carries — a `StackRecord`'s, so a new
19
18
  * field fails to compile here until it is listed. A create body is a whole
@@ -69,13 +68,9 @@ function ownerDate(body, key) {
69
68
  return date;
70
69
  }
71
70
  /**
72
- * Read a `POST /records` body as a create. Takes the session rather than a
73
- * pre-computed boolean so the owner-acting-alone determination stays with
74
- * the rule that needs it.
75
- *
76
- * Beyond shape, values are `Stack`'s to judge — an id's legality, a
77
- * permission's contents, the content's schema — since judging them twice
78
- * would let the two answers drift.
71
+ * Read a `POST /records` body as a create. Takes the session, not a
72
+ * precomputed boolean, so the owner-acting-alone decision stays with its
73
+ * rule. Values beyond shape are `Stack`'s to judge, or two answers drift.
79
74
  */
80
75
  export function createOptionsFromWireRecord(body, session, ownerEntityId) {
81
76
  const record = requireBody(body, 'record body');
@@ -118,59 +113,4 @@ export function createOptionsFromWireRecord(body, session, ownerEntityId) {
118
113
  }
119
114
  return { typeId, content: content, options };
120
115
  }
121
- /**
122
- * Read a `PATCH /records/:id` body as a change set. The envelope's keys
123
- * are native aspects, so an unrecognized one is a client reaching for
124
- * something this endpoint does not have — refused rather than ignored,
125
- * since a dropped `permissions` silently fails to share and a dropped
126
- * `unlisted` silently fails to publish.
127
- *
128
- * `StackBadRequestError` (400) for a key that addresses nothing and
129
- * `StackValidationError` (422) for one whose value is the wrong shape —
130
- * the same split every other write endpoint makes. Content keys are
131
- * `Stack`'s to judge, so `contentPatch` is checked for being an object and
132
- * nothing more.
133
- * See docs/spec/wire-format.md § Records.
134
- */
135
- export function changesFromWireBody(body) {
136
- const envelope = requireBody(body, 'record body');
137
- const unknown = Object.keys(envelope).filter((key) => !RECORD_CHANGE_SET_KEYS.includes(key));
138
- if (unknown.length > 0) {
139
- throw new StackBadRequestError(`Unknown change-set key${unknown.length > 1 ? 's' : ''}: ${unknown.join(', ')}. ` +
140
- `A change set names one or more of: ${RECORD_CHANGE_SET_KEYS.join(', ')}.`);
141
- }
142
- const changes = {};
143
- if (envelope.contentPatch !== undefined) {
144
- const patch = envelope.contentPatch;
145
- if (typeof patch !== 'object' || patch === null || Array.isArray(patch))
146
- fieldError('contentPatch', 'contentPatch must be an object');
147
- changes.contentPatch = patch;
148
- }
149
- // The one key `null` is a value for rather than a removal spelling: it
150
- // is the root, the same sentinel `?parentId=null` carries.
151
- if (envelope.parentId !== undefined) {
152
- const parentId = envelope.parentId;
153
- if (parentId !== null && typeof parentId !== 'string')
154
- fieldError('parentId', 'parentId must be a string or null');
155
- changes.parentId = parentId;
156
- }
157
- const permissions = optionalArray(envelope, 'permissions');
158
- if (permissions !== undefined)
159
- changes.permissions = permissions;
160
- const associations = optionalArray(envelope, 'associations');
161
- if (associations !== undefined)
162
- changes.associations = associations;
163
- if (envelope.unlisted !== undefined) {
164
- if (typeof envelope.unlisted !== 'boolean')
165
- fieldError('unlisted', 'unlisted must be a boolean');
166
- changes.unlisted = envelope.unlisted;
167
- }
168
- // Every key was absent. Refused here rather than left to mutate(), so a
169
- // server answers 400 without a storage round trip; mutate() refuses it
170
- // again for callers that never went through the wire.
171
- if (Object.keys(changes).length === 0) {
172
- throw new StackBadRequestError(`An empty change set addresses nothing. Name one or more of: ${RECORD_CHANGE_SET_KEYS.join(', ')}.`);
173
- }
174
- return changes;
175
- }
176
- //# sourceMappingURL=wire-record.js.map
116
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/wire/record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAsBpD;;;;;GAKG;AACH,MAAM,gBAAgB,GAAsB,MAAM,CAAC,IAAI,CAAC;IACtD,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,IAAI;IACX,SA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AQ,KAAK,SAAS;QAAE,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACxD,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IAE/C,MAAM,WAAW,GAAG,aAAa,CAAuB,MAAM,EAAE,aAAa,CAAC,CAAC;IAC/E,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;IACjE,MAAM,YAAY,GAAG,aAAa,CAAkB,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5E,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IAEpE,oEAAoE;IACpE,6DAA6D;IAC7D,IAAI,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAEhF,IAAI,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACjD,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3D,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACjD,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7D,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAkC,EAAE,OAAO,EAAE,CAAC;AAC1E,CAAC"}
@@ -24,56 +24,48 @@
24
24
  * servers already map to 400 — see docs/spec/wire-format.md § Error
25
25
  * responses.
26
26
  */
27
- import type { DataAssociation, ChangeFilter, JournalQuery, VersionsQuery, StackQuery } from './types.js';
27
+ import type { DataAssociation, ChangeFilter, JournalQuery, VersionsQuery, StackQuery, PlainQuery } from '../types/index.js';
28
28
  /** Parse an ISO date string from a wire body; undefined if absent or invalid. */
29
29
  export declare function parseDate(val: unknown): Date | undefined;
30
30
  /**
31
- * Strict positive-integer parse for a URL param — rejects "1abc", "2.7",
32
- * "-5". Also serves the `:version` path params, which share this
33
- * "malformed, don't silently coerce" requirement.
31
+ * Strict digits-only parse for a URL param — rejects "1abc", "2.7", "-5".
32
+ * Shape only: whether 0 is in range is `Stack`'s to judge. Also serves the
33
+ * `:version` path params, which share this "malformed, don't silently
34
+ * coerce" requirement.
34
35
  */
35
- export declare function parsePositiveInt(raw: string, label: string): number;
36
+ export declare function parseUnsignedInt(raw: string, label: string): number;
36
37
  /**
37
- * The client half of the same refusal, applied before a request is built
38
- * rather than after one arrives. `Stack.query()` resolves `filter.baseId`
39
- * against registered Types and applies `presentAt` itself, so neither
40
- * reaches an adapter through it — this catches the direct adapter call,
41
- * where the encoding would otherwise decide the answer: a query body
42
- * carries both fields to a server that refuses them, while search params
43
- * have nowhere to put them and would drop them into a wider result set.
44
- *
45
- * Absent and explicitly `undefined` are the same thing here, as they are
46
- * to `Stack.query()`. The parsers above test key presence instead, because
47
- * over the wire writing the key at all is a client that meant to send it.
38
+ * The client half of the same refusal, before a request is built.
39
+ * `Stack.query()` applies `presentAt` itself, so this catches the direct
40
+ * adapter call, where search params would drop it. Absent and `undefined`
41
+ * are one here; the parsers test presence, since over the wire a written
42
+ * key is one the client meant to send.
48
43
  */
49
44
  export declare function assertQueryTravels(query: StackQuery): void;
50
45
  /**
51
- * Build a `StackQuery` from `GET /records` search params — the inverse of
46
+ * Build a `PlainQuery` from `GET /records` search params — the inverse of
52
47
  * what `APIAdapter` encodes for a server that reaches no content.
53
48
  * `parentId=null` is the literal string, the sentinel for "top level":
54
49
  * Crockford base-32 excludes `u` and `l`, so no record ID can collide
55
50
  * with it. See docs/spec/wire-format.md § Records.
56
51
  */
57
- export declare function parseQueryParams(url: URL): StackQuery;
52
+ export declare function parseQueryParams(url: URL): PlainQuery;
58
53
  /**
59
- * Build a `StackQuery` from a `POST /records/query` JSON body — the
60
- * superset form, which additionally carries `filter.content`. Dates arrive
61
- * as the ISO strings `JSON.stringify` made of them and are decoded back to
62
- * `Date`. `undefined` is the absent body; `null` or any other non-object
63
- * is refused, so a server hands over no body as `undefined`.
54
+ * Build a `PlainQuery` from a `POST /records/query` body — the superset
55
+ * form, which also carries `filter.content`, with ISO date strings decoded.
56
+ * `undefined` is the absent body; any other non-object is refused.
64
57
  * See docs/spec/wire-format.md § Records.
65
58
  */
66
- export declare function parseQueryBody(raw: unknown): StackQuery;
59
+ export declare function parseQueryBody(raw: unknown): PlainQuery;
67
60
  /**
68
- * What `GET /changes`' query params carry. One object rather than three
69
- * exports because `includeUnlisted` sits on `SubscribeOptions` rather than
70
- * `ChangeFilter`, and a server needs it before the stream opens to answer
71
- * the owner-only 403. See docs/spec/change-feed.md.
61
+ * What `GET /changes`' query params carry: the filter, and `includeRecords`,
62
+ * which sits on `SubscribeOptions` beside it. A server reads
63
+ * `filter.includeUnlisted` before the stream opens to answer the
64
+ * owner-only 403. See docs/spec/change-feed.md.
72
65
  */
73
66
  export type ParsedChangeParams = {
74
67
  filter: ChangeFilter;
75
68
  includeRecords: boolean;
76
- includeUnlisted: boolean;
77
69
  };
78
70
  /**
79
71
  * Parse `GET /changes`' query params. The resume cursor is deliberately
@@ -82,21 +74,15 @@ export type ParsedChangeParams = {
82
74
  */
83
75
  export declare function parseChangeParams(url: URL): ParsedChangeParams;
84
76
  /**
85
- * Parse `GET /records/:id/journal`'s query params into the `JournalQuery`
86
- * `getJournal()` takes. Absent params stay absent rather than defaulting:
87
- * omitting `limit` reads the whole log by contract, so supplying a page
88
- * size here would truncate exactly the caller that omitted it.
89
- *
90
- * `afterSeq` is a journal `seq` — a dense per-record integer, never the
91
- * change feed's opaque cursor. See docs/spec/wire-format.md § Journal.
77
+ * Parse `GET /records/:id/journal`'s params into a `JournalQuery`. Absent
78
+ * stays absent: omitting `limit` reads the whole log, which a default page
79
+ * size would truncate. `afterSeq` is a journal `seq`, never a feed cursor.
80
+ * See docs/spec/wire-format.md § Journal.
92
81
  */
93
82
  export declare function parseJournalParams(url: URL): JournalQuery;
94
83
  /**
95
- * Parse `GET /records/:id/versions`'s query params into the `VersionsQuery`
96
- * `getVersions()` takes. Absent params stay absent, for the reason
97
- * parseJournalParams() leaves them so.
98
- *
99
- * `beforeVersion` is a snapshot's `version`, exclusive.
84
+ * Parse `GET /records/:id/versions`'s params into a `VersionsQuery`; absent
85
+ * stays absent, as in parseJournalParams(). `beforeVersion` is exclusive.
100
86
  * See docs/spec/wire-format.md § Versions.
101
87
  */
102
88
  export declare function parseVersionsParams(url: URL): VersionsQuery;
@@ -140,13 +126,10 @@ export type ParsedAssociationParams = {
140
126
  */
141
127
  export declare function parseAssociationParams(url: URL): ParsedAssociationParams;
142
128
  /**
143
- * Parse an `If-Match: "5"` header into the version for `ifVersion`.
144
- * A value that is not a bare, optionally quoted version is refused rather
145
- * than read as absent: the header exists to fence a write, so degrading a
146
- * malformed one to an unconditional last-writer-wins mutation defeats the
147
- * only thing it was sent to do. Weak comparators (`W/"5"`) are refused for
148
- * the same reason — a version match is exact or it is nothing.
149
- * See docs/spec/wire-format.md § Records.
129
+ * Parse `If-Match: "5"` into `ifVersion`. Anything but a bare, optionally
130
+ * quoted version — weak `W/"5"` included — is refused, not read as absent:
131
+ * degrading the fence to last-writer-wins defeats the one thing it was
132
+ * sent for. See docs/spec/wire-format.md § Records.
150
133
  */
151
134
  export declare function parseIfMatch(header: string | undefined): number | undefined;
152
135
  /**
@@ -156,4 +139,4 @@ export declare function parseIfMatch(header: string | undefined): number | undef
156
139
  * quoted form. See docs/spec/wire-format.md § Upload.
157
140
  */
158
141
  export declare function parseUploadFilename(header: string | undefined): string | undefined;
159
- //# sourceMappingURL=wire-request.d.ts.map
142
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","s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