@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
@@ -13,16 +13,19 @@
13
13
  * property of one function here, not a convention every emission site has
14
14
  * to remember. See docs/spec/events.md.
15
15
  */
16
- import { StackBadRequestError } from './errors.js';
17
- import { bumpsVersion, feedAssociationDelta } from './record-changes.js';
18
- /** The `baseId@version` split, as grants and query filters read it. */
19
- const baseIdOf = (typeId) => typeId.split('@')[0];
16
+ import { StackBadRequestError } from '../errors.js';
17
+ import { baseIdOf } from '../schema.js';
18
+ import { bumpsVersion } from '../record-changes.js';
19
+ import { feedAssociationDelta } from '../associations/identity.js';
20
20
  /**
21
- * Whether an emission matches a subscription's filter. Reads the record
22
- * for the fields the envelope deliberately omits, so `createdBy` filters on
23
- * the author and `purged` frames stay filterable without carrying either.
21
+ * Whether an emission matches a subscription's filter, every key of it.
22
+ * Reads the record for the fields the envelope deliberately omits, so
23
+ * `createdBy` filters on the author and `purged` frames stay filterable
24
+ * without carrying either.
24
25
  */
25
26
  export function matchesFilter(emitted, filter) {
27
+ if (!passesUnlistedBoundary(emitted, filter?.includeUnlisted))
28
+ return false;
26
29
  if (!filter)
27
30
  return true;
28
31
  const { change, record } = emitted;
@@ -67,13 +70,11 @@ export function matchesFilter(emitted, filter) {
67
70
  const asArray = (value) => (Array.isArray(value) ? value : [value]);
68
71
  /**
69
72
  * Whether an emission passes the unlisted-enumeration boundary for one
70
- * subscription. The `unlist` transition is the one exception to the
71
- * default exclusion: without it a subscriber who already knows the record
72
- * would never be told to drop it. Every other transition falls out of
73
- * checking the record's current state.
74
- * See docs/spec/events.md § The unlisted transition.
73
+ * subscription. `unlist` is the one exception to the default exclusion:
74
+ * without it a subscriber who already holds the record would never be told
75
+ * to drop it. See docs/spec/events.md § The unlisted transition.
75
76
  */
76
- export function passesUnlistedBoundary(emitted, includeUnlisted) {
77
+ function passesUnlistedBoundary(emitted, includeUnlisted) {
77
78
  if (includeUnlisted)
78
79
  return true;
79
80
  if (emitted.change.ops.includes('unlist'))
@@ -82,14 +83,9 @@ export function passesUnlistedBoundary(emitted, includeUnlisted) {
82
83
  }
83
84
  /**
84
85
  * The frame a subscriber receives. A `purged` frame never carries the
85
- * record, whatever was asked for: purge is the erasure primitive,
86
- * and a frame that shipped the body — or the author — of a record the
87
- * stack has just destroyed would hand every subscriber a permanent copy of
88
- * the thing being erased. See docs/spec/events.md § Purged records carry
89
- * nothing.
90
- *
91
- * The record rides by reference, shared across every frame projected from
92
- * one emission: handlers are contractually read-only over it.
86
+ * record, whatever was asked for — see docs/spec/events.md § Purged records
87
+ * carry nothing. The record rides by reference, shared across every frame
88
+ * from one emission: handlers are contractually read-only over it.
93
89
  */
94
90
  export function emitted(emission, includeRecords) {
95
91
  const { change, record } = emission;
@@ -154,16 +150,10 @@ function reportError(err, opts) {
154
150
  });
155
151
  }
156
152
  /**
157
- * Delivery for frames that originate elsewhere. A relayed frame arrives
158
- * already projected and already scoped by the authority that opened the
159
- * feed, so nothing here filters it again: the emitter that produced it saw
160
- * the record, and this one never will — a purge in particular leaves
161
- * nothing to decide with. See docs/spec/events.md § Where events come from.
162
- *
163
- * It is delivered to one subscriber rather than through the emitter,
164
- * because a relay is opened per subscription and carries that
165
- * subscription's filter. Handing it to the registry would give every other
166
- * subscriber a copy of a stream it did not ask for.
153
+ * Delivery for frames that originate elsewhere, already projected and
154
+ * scoped by the authority that opened the feed, so nothing here filters
155
+ * them again. One subscriber's, not the registry's: a relay carries its own
156
+ * subscription's filter. See docs/spec/events.md § Where events come from.
167
157
  */
168
158
  export class RelayDelivery {
169
159
  handler;
@@ -195,22 +185,14 @@ class UnscopedSubscription extends Subscription {
195
185
  accept(emission) {
196
186
  if (!matchesFilter(emission, this.opts.filter))
197
187
  return;
198
- if (!passesUnlistedBoundary(emission, this.opts.includeUnlisted))
199
- return;
200
188
  this.deliver(emission);
201
189
  }
202
190
  }
203
191
  /**
204
- * One change, held between the two halves it is written in.
205
- *
206
- * A change lands twice: the durable half travels into the adapter's
207
- * transaction ahead of the write, and the live half is built from the
208
- * record that write produced. Naming the change once — its ops, its kind,
209
- * its actor, what it moved — is what makes "the entry set is the event
210
- * set" true by construction rather than by convention. No verb can journal
211
- * one thing and announce another, and a verb that writes only one half has
212
- * to say so where it does it. See docs/spec/journal.md § The entry set is
213
- * the event set.
192
+ * One change, held between the journal entry that travels into the
193
+ * adapter's write and the event built from the record it produced. Naming
194
+ * it once is what keeps a verb from journaling one thing and announcing
195
+ * another. See docs/spec/journal.md § The entry set is the event set.
214
196
  */
215
197
  export class PendingChange {
216
198
  moved;
@@ -226,13 +208,10 @@ export class PendingChange {
226
208
  this.kind = resolveKind(list);
227
209
  }
228
210
  /**
229
- * The durable half, handed to the adapter as `journal` so that it lands
230
- * in the same write as the mutation it describes.
231
- *
232
- * Absent for a purge, which destroys the log an entry would be appended
233
- * to. The rule lives here rather than at each call site that would
234
- * otherwise have to remember it. See docs/spec/journal.md § A purge
235
- * destroys the journal.
211
+ * The durable half, handed to the adapter as `journal` so it lands in the
212
+ * same write as the mutation it describes. Absent for a purge, which
213
+ * destroys the log it would be appended to — see docs/spec/journal.md
214
+ * § A purge destroys the journal.
236
215
  */
237
216
  get journal() {
238
217
  if (this.kind === 'purged')
@@ -247,15 +226,10 @@ export class PendingChange {
247
226
  };
248
227
  }
249
228
  /**
250
- * The live half, built from the record the write produced — for a purge,
251
- * from the record as it stood immediately before destruction.
252
- *
253
- * The actor is read off the record for every version-bumping op, so it
254
- * agrees with what was persisted by construction. A no-bump op stamps
255
- * nothing, so the requester travels here instead — reading the record
256
- * would report whoever's last version-bumping write this is. A purged
257
- * frame drops `parentId` and the create-time `appId` too: it says a
258
- * record of some type was destroyed and nothing about whose it was.
229
+ * The live half, built from the record the write produced (for a purge,
230
+ * as it stood before destruction). A version-bumping op's actor is read
231
+ * off that record; a no-bump op stamps none, so the requester travels
232
+ * here instead. See docs/spec/events.md § Attribution.
259
233
  */
260
234
  emission(record, at) {
261
235
  if (this.kind === 'purged') {
@@ -351,12 +325,10 @@ export class ChangeEmitter {
351
325
  }
352
326
  }
353
327
  /**
354
- * The kind a set of ops resolves to: the most conservative entry wins.
355
- * `unlist` beats everything a change set can carry beside it, because a
356
- * subscriber holding the record still has to drop it — announcing an edit
357
- * bundled with an unlist as an upsert would leave a stale copy behind.
358
- * Nothing else competes: `created` and `purged` name whole-record
359
- * transitions that are always emitted alone.
328
+ * The kind a set of ops resolves to: the most conservative wins. `unlist`
329
+ * beats anything beside it, since announcing an edit bundled with an
330
+ * unlist as an upsert would leave subscribers holding a stale copy.
331
+ * `created` and `purged` are always emitted alone.
360
332
  */
361
333
  function resolveKind(ops) {
362
334
  if (ops.includes('unlist'))
@@ -389,15 +361,9 @@ export const CHANGE_KINDS = {
389
361
  */
390
362
  const CURSOR_FORMAT = /^[A-Za-z0-9_-]+$/;
391
363
  /**
392
- * `since` only means something where a relay exists: a stack with no
393
- * third party whose writes could have been missed has no cursor it could
394
- * ever have minted. Silently starting from the present would let the
395
- * caller believe it resumed when it did not, so a stack that cannot honor
396
- * `since` refuses it rather than ignoring it.
397
- *
398
- * Its shape is checked here rather than left to the adapter, so a malformed
399
- * cursor is the same error whoever is underneath. The value stays opaque:
400
- * this asks whether it is framable, never what it means.
364
+ * Refuse a `since` this stack cannot honor rather than silently starting
365
+ * from the present, and a malformed one here rather than in the adapter, so
366
+ * it is the same error whoever is underneath. The value stays opaque.
401
367
  * See docs/spec/events.md § Subscribing.
402
368
  */
403
369
  export function assertSinceUsable(since, relaysChanges) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changes.js","sourceRoot":"","sources":["../../src/stack/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAgCnE;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,OAAsB,EAAE,MAAqB;IACzE,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5E,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEnC,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAEtE,wEAAwE;IACxE,yEAAyE;IACzE,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS;QAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAE/E,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACh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AC;AAEF;;;;;GAKG;AACH,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAyB,EAAE,aAAsB;IACjF,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO;IAChC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,oBAAoB,CAC5B,yFAAyF;YACvF,sFAAsF;YACtF,wEAAwE,CAC3E,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,oBAAoB,CAC5B,6CAA6C,KAAK,sCAAsC;YACtF,sFAAsF;YACtF,gEAAgE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,247 @@
1
+ /**
2
+ * StackClient and the option types around it
3
+ * -------------------------------------------------------
4
+ * The app-facing record API that both `Stack` and `ScopedStack` implement,
5
+ * with the option and result shapes its verbs take. Shapes only: the
6
+ * behaviour behind them lives in stack.ts and scoped-stack.ts.
7
+ */
8
+ import type { Actor, AppId, AssociationEdit, AttachmentContent, AuthorityAssociation, DataAssociation, EntityId, FileId, IfVersionOptions, JournalQuery, PutAttachmentOptions, QueryResult, RecordChange, RecordId, RecordJournalEntry, RecordVersion, StackCapabilities, StackQuery, StackRecord, SubscribeOptions, TypeId, Unsubscribe, VersionsQuery } from '../types/index.js';
9
+ import type { ContentOf, Migration, ReadonlyTypeSchema, TypeHandle } from '../type-handle.js';
10
+ import type { Collection } from '../collection.js';
11
+ export type CreateRecordOptions = {
12
+ /**
13
+ * Client-minted record ID. Must be 12 lowercase Crockford base-32
14
+ * characters and may not use the reserved `_` prefix. Omit to let the
15
+ * library generate one. See Stack.create() and ScopedStack.create()
16
+ * for the validation each applies.
17
+ */
18
+ id?: RecordId;
19
+ parentId?: RecordId;
20
+ /**
21
+ * The author. ScopedStack sets this from its own identities; callers of
22
+ * plain Stack supply it only when reconstructing an attributed write.
23
+ * See StackRecord.createdBy.
24
+ */
25
+ createdBy?: Actor;
26
+ /** Reverse-DNS identifier of the writing software — see AppId. */
27
+ appId?: AppId;
28
+ permissions?: AuthorityAssociation[];
29
+ associations?: DataAssociation[];
30
+ /**
31
+ * Create the record already unlisted, so the create event itself is
32
+ * withheld from the feed — there is no window where the record exists
33
+ * and is listed before a mutation catches up. See
34
+ * docs/spec/unlisted.md.
35
+ */
36
+ unlisted?: boolean;
37
+ };
38
+ /**
39
+ * CreateRecordOptions plus createdAt/updatedAt, for backdating on import.
40
+ * ScopedStack.create() takes them only from the owner acting alone: anyone
41
+ * else could forge a sort position with them, as with a raw `id`.
42
+ * See docs/spec/data-model.md § Backdating on import.
43
+ */
44
+ export type BackdatableCreateRecordOptions = CreateRecordOptions & {
45
+ /**
46
+ * The record's creation time. When `id` is also supplied, its embedded
47
+ * timestamp must agree with this within `idTimestampSkewMs` (default 24h;
48
+ * see StackOptions.idTimestampSkewMs) or the create throws
49
+ * StackValidationError. Omit `id` to have it derived from this timestamp
50
+ * instead. Defaults to now.
51
+ */
52
+ createdAt?: Date;
53
+ /**
54
+ * The record's last-modified time. Defaults to `createdAt` (or now, if
55
+ * `createdAt` is omitted too) — never to the actual current time — so a
56
+ * plain import doesn't fabricate a fake edit. Must not precede
57
+ * `createdAt`.
58
+ */
59
+ updatedAt?: Date;
60
+ };
61
+ export type StackOptions = {
62
+ /**
63
+ * Ensures the owner's own `_entity` profile record exists, creating it on
64
+ * first run. Idempotent — safe to pass on every open. See
65
+ * docs/spec/identity.md § Entity.
66
+ */
67
+ ownerProfile?: {
68
+ name: string;
69
+ handle?: string;
70
+ };
71
+ /**
72
+ * Clock-skew tolerance (ms) between a client-supplied `id`'s timestamp
73
+ * and the current time (a live scoped create) or an explicit `createdAt`
74
+ * (a backdated one). Default: 24 hours; null disables both checks.
75
+ * See docs/spec/data-model.md § Record IDs.
76
+ */
77
+ idTimestampSkewMs?: number | null;
78
+ /**
79
+ * Every migration this app knows, built with `migration()`. The chain is
80
+ * complete before the first read, and one that cannot be walked — two
81
+ * steps from one TypeId, or a cycle — is refused here. See
82
+ * docs/spec/data-model.md § Type migrations.
83
+ */
84
+ migrations?: readonly Migration[];
85
+ };
86
+ export type CollectAttachmentGarbageOptions = {
87
+ /**
88
+ * How recent an unreferenced file must be to survive collection, covering
89
+ * the upload-then-associate window. Default: 24 hours. Pass 0 to collect
90
+ * anything unreferenced right now.
91
+ */
92
+ graceMs?: number;
93
+ /** Compute what would be deleted without deleting anything. Default: false. */
94
+ dryRun?: boolean;
95
+ };
96
+ export type CollectAttachmentGarbageResult = {
97
+ /** The files collected — or, on a dry run, the ones that would be. */
98
+ deletedFileIds: FileId[];
99
+ reclaimedBytes: number;
100
+ };
101
+ export type GetRecordOptions = {
102
+ /**
103
+ * Records are returned exactly as stored by default. Pass "latest" to
104
+ * apply the registered migration chain in memory — never written back.
105
+ * See docs/spec/data-model.md § Type migrations.
106
+ */
107
+ presentAt?: 'stored' | 'latest';
108
+ /**
109
+ * Soft-deleted records are hidden by default, as query() hides them: a
110
+ * tombstone reads as `null`. Pass true to read it back.
111
+ * See docs/spec/versioning.md § Deletion.
112
+ */
113
+ includeDeleted?: boolean;
114
+ };
115
+ export type DeleteRecordOptions = IfVersionOptions & {
116
+ /** If true, permanently remove the record and all its history. Default: false */
117
+ purge?: boolean;
118
+ };
119
+ /**
120
+ * What a delete reports back. The record is captured inside the same
121
+ * atomic write as the delete, never read beforehand. `referencedFileIds`
122
+ * is information, not action: a purge never touches the blob store. See
123
+ * docs/spec/attachments.md § A purge strands the bytes it referenced.
124
+ */
125
+ export type DeleteResult = {
126
+ /**
127
+ * The record as a soft delete left it — under ScopedStack, presented as
128
+ * its tombstone — or as it stood immediately before destruction for a
129
+ * purge, and `null` when there was nothing at `id` to purge.
130
+ * See docs/spec/versioning.md § The tombstone is literal.
131
+ */
132
+ record: StackRecord | null;
133
+ /**
134
+ * The files the purged record referenced — its attachment associations
135
+ * and its `file-ref` content fields, deduplicated. The purge removes the
136
+ * only rows naming them, so this is the caller's one chance to hold the
137
+ * argument `deleteAttachment()` takes. Empty on a soft delete, which
138
+ * strands nothing: a tombstone's references stand.
139
+ */
140
+ referencedFileIds: FileId[];
141
+ };
142
+ /** Options for Stack.migrateAll(). */
143
+ export type MigrateAllOptions = {
144
+ /**
145
+ * `'all'` (the default) sweeps every record of the family, deleted and
146
+ * unlisted included. `'listed'` sweeps only what a non-owner can
147
+ * enumerate and read whole. See docs/spec/apps.md § Migrating an
148
+ * installed app's types.
149
+ */
150
+ sweep?: 'all' | 'listed';
151
+ };
152
+ /** The argument to Stack.defineType(). */
153
+ export type DefineTypeOptions = {
154
+ id: TypeId;
155
+ name: string;
156
+ /** A handle's `schema` is accepted as written, readonly members and all. */
157
+ schema: ReadonlyTypeSchema;
158
+ migratesFrom?: TypeId;
159
+ };
160
+ /**
161
+ * The app-facing record API, implemented by both Stack and ScopedStack.
162
+ * Accept this type in plugin or extension code to remain adapter-agnostic
163
+ * and work equally well with a full Stack or a permission-scoped view.
164
+ */
165
+ export interface StackClient {
166
+ readonly capabilities: StackCapabilities;
167
+ /**
168
+ * Typed access to `handle`'s whole family, every record migrated in
169
+ * memory to the handle's version. Throws `StackMigrationError` when the
170
+ * handle's `migratesFrom` has no migration passed to `Stack.open()`.
171
+ * See docs/spec/data-model.md § Type handles.
172
+ */
173
+ collection<S extends ReadonlyTypeSchema>(handle: TypeHandle<S>): Collection<ContentOf<S>>;
174
+ create<T extends Record<string, unknown> = Record<string, unknown>>(typeId: TypeId, content: T, opts?: CreateRecordOptions): Promise<StackRecord & {
175
+ content: T;
176
+ }>;
177
+ get(id: RecordId, opts?: GetRecordOptions): Promise<StackRecord | null>;
178
+ query(query?: StackQuery): Promise<QueryResult>;
179
+ /**
180
+ * Resolve a DID to its `_entity` card — family-wide and soft-deleted
181
+ * inclusive, per docs/spec/identity.md § DID bindings. No caching.
182
+ *
183
+ * Under `ScopedStack`, `null` covers missing, unreadable, and (unless the
184
+ * owner is acting alone) unlisted — never evidence the card is absent.
185
+ */
186
+ getEntityByDid(did: EntityId): Promise<StackRecord | null>;
187
+ /** getEntityByDid() for the one DID every stack reserves: its own owner. */
188
+ getOwnerEntity(): Promise<StackRecord | null>;
189
+ /**
190
+ * Merge a patch into a record's content, one level deep (`null` removes a
191
+ * key). The only content edit, and the one write besides the lifecycle
192
+ * verbs that bumps `version`. See docs/spec/data-model.md § Mutations.
193
+ */
194
+ patchContent(id: RecordId, patch: Record<string, unknown | null>, opts?: IfVersionOptions): Promise<StackRecord>;
195
+ /**
196
+ * Move a record under `parentId`, or to the root with `null`. See
197
+ * docs/spec/data-model.md § Reparenting.
198
+ */
199
+ setParent(id: RecordId, parentId: RecordId | null, opts?: IfVersionOptions): Promise<StackRecord>;
200
+ /** Withhold a record from enumeration, or restore it. See docs/spec/unlisted.md. */
201
+ setUnlisted(id: RecordId, unlisted: boolean, opts?: IfVersionOptions): Promise<StackRecord>;
202
+ /**
203
+ * Apply adds and removes to a record's data associations as one write,
204
+ * changing only what the list names. An add naming an attachment the
205
+ * record already holds re-points it. See docs/spec/data-model.md § Mutations.
206
+ */
207
+ editAssociations(id: RecordId, edits: AssociationEdit[], opts?: IfVersionOptions): Promise<StackRecord>;
208
+ /** Make a record's data associations exactly `associations`. */
209
+ setAssociations(id: RecordId, associations: DataAssociation[], opts?: IfVersionOptions): Promise<StackRecord>;
210
+ /**
211
+ * editAssociations() for who reaches a record, so a downgrade (remove
212
+ * `write`, keep `read`) is one change. `write` never implies `read`:
213
+ * grant both. See docs/spec/access-control.md § Record-level permissions.
214
+ */
215
+ editAccess(id: RecordId, edits: AssociationEdit[], opts?: IfVersionOptions): Promise<StackRecord>;
216
+ /** Make who reaches a record exactly `permissions`; `[]` is private. */
217
+ setAccess(id: RecordId, permissions: AuthorityAssociation[], opts?: IfVersionOptions): Promise<StackRecord>;
218
+ /**
219
+ * Soft-delete a record, or purge it with its history, reporting the
220
+ * record it acted on. See docs/spec/versioning.md § Deletion.
221
+ */
222
+ delete(id: RecordId, opts?: DeleteRecordOptions): Promise<DeleteResult>;
223
+ undelete(id: RecordId, opts?: IfVersionOptions): Promise<StackRecord>;
224
+ getVersions(id: RecordId, query?: VersionsQuery): Promise<RecordVersion[]>;
225
+ getVersion(id: RecordId, version: number): Promise<RecordVersion | null>;
226
+ restoreVersion(id: RecordId, version: number, opts?: IfVersionOptions): Promise<StackRecord>;
227
+ /**
228
+ * A record's change journal, oldest first, gated like getVersions().
229
+ * Required of every adapter, so an empty log always means "nothing
230
+ * changed". See docs/spec/journal.md § Reading it.
231
+ */
232
+ getJournal(id: RecordId, query?: JournalQuery): Promise<RecordJournalEntry[]>;
233
+ /**
234
+ * Commit a per-record migration: `typeId` and `content` together,
235
+ * validated against `toTypeId`'s schema — the only way a record's typeId
236
+ * changes after creation. See docs/spec/wire-format.md § Migration commit.
237
+ */
238
+ commitMigration(id: RecordId, toTypeId: TypeId, content: Record<string, unknown>, opts?: IfVersionOptions): Promise<StackRecord>;
239
+ getAttachment(fileId: FileId): Promise<Uint8Array>;
240
+ putAttachment(data: Uint8Array, opts: PutAttachmentOptions): Promise<StackRecord & {
241
+ content: AttachmentContent;
242
+ }>;
243
+ deleteAttachment(fileId: FileId): Promise<void>;
244
+ collectAttachmentGarbage(opts?: CollectAttachmentGarbageOptions): Promise<CollectAttachmentGarbageResult>;
245
+ subscribe(handler: (change: RecordChange) => void, opts?: SubscribeOptions): Promise<Unsubscribe>;
246
+ }
247
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/stack/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,KAAK,EACL,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,k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AChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,WAAW,CAAC,CAAC;IACxB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACnD,aAAa,CACX,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,WAAW,GAAG;QAAE,OAAO,EAAE,iBAAiB,CAAA;KAAE,CAAC,CAAC;IACzD,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,wBAAwB,CACtB,IAAI,CAAC,EAAE,+BAA+B,GACrC,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAC3C,SAAS,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACnG"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * StackClient and the option types around it
3
+ * -------------------------------------------------------
4
+ * The app-facing record API that both `Stack` and `ScopedStack` implement,
5
+ * with the option and result shapes its verbs take. Shapes only: the
6
+ * behaviour behind them lives in stack.ts and scoped-stack.ts.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/stack/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-bindings.d.ts","sourceRoot":"","sources":["../../src/stack/identity-bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA4BH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,EACzC,CAAC;AAEnC,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,KAAG,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,EACxC,CAAC"}
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * See docs/spec/identity.md § DID bindings.
10
10
  */
11
- import { SYSTEM_TYPES } from './types.js';
11
+ import { SYSTEM_TYPES } from '../types/index.js';
12
12
  /**
13
13
  * Content fields that are lookup keys rather than display values: a card
14
14
  * claims one, and something later resolves through it. Every one of them is
@@ -20,19 +20,10 @@ const BINDING_FIELDS = new Map([
20
20
  [SYSTEM_TYPES.INSTALL, ['appId']],
21
21
  ]);
22
22
  /**
23
- * The subset that is additionally unique per stack: the fields something
24
- * resolves *by*. An Actor's `principalId` finds its card by `_app.did` and
25
- * its `subjectId` by `_entity.did`, so a second card claiming either leaves
26
- * that lookup without a single answer — and ambiguity is all an
27
- * impersonating card needs.
28
- *
29
- * `_app.appId` is deliberately absent. Nothing resolves a card by it — the
30
- * cross-check reaches the card by `did` and only compares `appId` — so
31
- * uniqueness would buy no disambiguation, while forbidding the second card
32
- * key rotation is supposed to produce: `appId` is required, so a
33
- * replacement card for the same software necessarily repeats it. Moving one
34
- * card onto another's `appId` is what immutability already refuses.
35
- * See docs/spec/identity.md § DID bindings.
23
+ * The subset that is additionally unique per stack: the fields an Actor is
24
+ * resolved *by*, where a second claimant leaves the lookup ambiguous.
25
+ * `_app.appId` is deliberately absent — nothing resolves by it, and a new
26
+ * key's card must repeat it. See docs/spec/identity.md § DID bindings.
36
27
  */
37
28
  const UNIQUE_BINDING_FIELDS = new Map([
38
29
  [SYSTEM_TYPES.APP, ['did']],
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-bindings.js","sourceRoot":"","sources":["../../src/stack/identity-bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,cAAc,GAAsD,IAAI,GAAG,CAAC;IAChF,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,CAAU,CAAC;IAC7C,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,KAAK,CAAU,CAAC;IACvC,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,OAAO,CAAU,CAAC;CAC3C,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,qBAAqB,GAAsD,IAAI,GAAG,CAAC;IACvF,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,KAAK,CAAU,CAAC;IACpC,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,KAAK,CAAU,CAAC;IACvC,mFAAmF;IACnF,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,OAAO,CAAU,CAAC;CAC3C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAgC,EAAE,CAC9E,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAEnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAgC,EAAE,CACpF,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * App install verbs
3
+ * -------------------------------------------------------
4
+ * Planning, applying and withdrawing an app's install over an unscoped
5
+ * Stack: the bodies of Stack.planInstall(), installApp() and
6
+ * uninstallApp(), whose doc comments describe the contract. Written
7
+ * against Stack's public API alone, so every write here passes the same
8
+ * checks any other caller's would. See docs/spec/apps.md.
9
+ */
10
+ import type { AppManifest, InstallPlan } from '../install.js';
11
+ import type { AppId, EntityId, InstallContent, StackRecord } from '../types/index.js';
12
+ import type { Stack } from './stack.js';
13
+ export declare function planInstall(stack: Stack, submitted: AppManifest, opts: {
14
+ did: EntityId;
15
+ }): Promise<InstallPlan>;
16
+ export declare function installApp(stack: Stack, plan: InstallPlan): Promise<StackRecord & {
17
+ content: InstallContent;
18
+ }>;
19
+ export declare function uninstallApp(stack: Stack, appId: AppId): Promise<StackRecord & {
20
+ content: InstallContent;
21
+ }>;
22
+ //# sourceMappingURL=install-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-app.d.ts","sourceRoot":"","sources":["../../src/stack/install-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkCH,OAAO,KAAK,EAAE,WAAW,EAAkB,WAAW,EAAc,MAAM,eAAe,CAAC;AAC1F,OAAO,KAAK,EAEV,KAAK,EAIL,QAAQ,EAER,cAAc,EAEd,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAsB,WAAW,CAC/B,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,WAAW,EACtB,IAAI,EAAE;IAAE,GAAG,EAAE,QAAQ,CAAA;CAAE,GACtB,OAAO,CAAC,WAAW,CAAC,CAqEtB;AAED,wBAAsB,UAAU,CAC9B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,WAAW,GAAG;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC,CA+CpD;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,WAAW,GAAG;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC,CAapD"}