@haverstack/core 0.40.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/README.md +121 -59
  2. package/dist/access.d.ts +34 -36
  3. package/dist/access.d.ts.map +1 -1
  4. package/dist/access.js +65 -42
  5. package/dist/access.js.map +1 -1
  6. package/dist/{combine.d.ts → adapter/combine.d.ts} +8 -1
  7. package/dist/adapter/combine.d.ts.map +1 -0
  8. package/dist/{combine.js → adapter/combine.js} +7 -0
  9. package/dist/adapter/combine.js.map +1 -0
  10. package/dist/{adapter-entry.d.ts → adapter/index.d.ts} +6 -5
  11. package/dist/adapter/index.d.ts.map +1 -0
  12. package/dist/{adapter-entry.js → adapter/index.js} +5 -4
  13. package/dist/adapter/index.js.map +1 -0
  14. package/dist/{sort.d.ts → adapter/sort.d.ts} +20 -20
  15. package/dist/adapter/sort.d.ts.map +1 -0
  16. package/dist/{sort.js → adapter/sort.js} +37 -27
  17. package/dist/adapter/sort.js.map +1 -0
  18. package/dist/associations/identity.d.ts +93 -0
  19. package/dist/associations/identity.d.ts.map +1 -0
  20. package/dist/associations/identity.js +198 -0
  21. package/dist/associations/identity.js.map +1 -0
  22. package/dist/associations/validation.d.ts +90 -0
  23. package/dist/associations/validation.d.ts.map +1 -0
  24. package/dist/associations/validation.js +339 -0
  25. package/dist/associations/validation.js.map +1 -0
  26. package/dist/attachment-records.d.ts +48 -0
  27. package/dist/attachment-records.d.ts.map +1 -0
  28. package/dist/attachment-records.js +52 -0
  29. package/dist/attachment-records.js.map +1 -0
  30. package/dist/collection.d.ts +182 -0
  31. package/dist/collection.d.ts.map +1 -0
  32. package/dist/collection.js +407 -0
  33. package/dist/collection.js.map +1 -0
  34. package/dist/content-match.d.ts +25 -0
  35. package/dist/content-match.d.ts.map +1 -0
  36. package/dist/content-match.js +51 -0
  37. package/dist/content-match.js.map +1 -0
  38. package/dist/content-translation.d.ts +42 -0
  39. package/dist/content-translation.d.ts.map +1 -0
  40. package/dist/content-translation.js +108 -0
  41. package/dist/content-translation.js.map +1 -0
  42. package/dist/did/did.d.ts.map +1 -0
  43. package/dist/{did.js → did/did.js} +3 -4
  44. package/dist/did/did.js.map +1 -0
  45. package/dist/{did-entry.d.ts → did/index.d.ts} +1 -1
  46. package/dist/did/index.d.ts.map +1 -0
  47. package/dist/{did-entry.js → did/index.js} +3 -3
  48. package/dist/did/index.js.map +1 -0
  49. package/dist/errors.d.ts +36 -63
  50. package/dist/errors.d.ts.map +1 -1
  51. package/dist/errors.js +35 -58
  52. package/dist/errors.js.map +1 -1
  53. package/dist/grants.d.ts +20 -43
  54. package/dist/grants.d.ts.map +1 -1
  55. package/dist/grants.js +71 -134
  56. package/dist/grants.js.map +1 -1
  57. package/dist/id.d.ts +13 -31
  58. package/dist/id.d.ts.map +1 -1
  59. package/dist/id.js +13 -31
  60. package/dist/id.js.map +1 -1
  61. package/dist/index.d.ts +14 -8
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +9 -5
  64. package/dist/index.js.map +1 -1
  65. package/dist/install.d.ts +141 -0
  66. package/dist/install.d.ts.map +1 -0
  67. package/dist/install.js +219 -0
  68. package/dist/install.js.map +1 -0
  69. package/dist/merge.d.ts.map +1 -1
  70. package/dist/merge.js +5 -11
  71. package/dist/merge.js.map +1 -1
  72. package/dist/migration-steps.d.ts +102 -0
  73. package/dist/migration-steps.d.ts.map +1 -0
  74. package/dist/migration-steps.js +293 -0
  75. package/dist/migration-steps.js.map +1 -0
  76. package/dist/query-validation.d.ts +28 -94
  77. package/dist/query-validation.d.ts.map +1 -1
  78. package/dist/query-validation.js +156 -336
  79. package/dist/query-validation.js.map +1 -1
  80. package/dist/record-changes.d.ts +2 -117
  81. package/dist/record-changes.d.ts.map +1 -1
  82. package/dist/record-changes.js +10 -212
  83. package/dist/record-changes.js.map +1 -1
  84. package/dist/schema.d.ts +18 -7
  85. package/dist/schema.d.ts.map +1 -1
  86. package/dist/schema.js +59 -30
  87. package/dist/schema.js.map +1 -1
  88. package/dist/scoped-stack/authority.d.ts +156 -0
  89. package/dist/scoped-stack/authority.d.ts.map +1 -0
  90. package/dist/scoped-stack/authority.js +384 -0
  91. package/dist/scoped-stack/authority.js.map +1 -0
  92. package/dist/scoped-stack/scoped-stack.d.ts +338 -0
  93. package/dist/scoped-stack/scoped-stack.d.ts.map +1 -0
  94. package/dist/scoped-stack/scoped-stack.js +776 -0
  95. package/dist/scoped-stack/scoped-stack.js.map +1 -0
  96. package/dist/scoped-stack/subscription.d.ts +55 -0
  97. package/dist/scoped-stack/subscription.d.ts.map +1 -0
  98. package/dist/scoped-stack/subscription.js +110 -0
  99. package/dist/scoped-stack/subscription.js.map +1 -0
  100. package/dist/stack/attachments.d.ts +24 -0
  101. package/dist/stack/attachments.d.ts.map +1 -0
  102. package/dist/stack/attachments.js +113 -0
  103. package/dist/stack/attachments.js.map +1 -0
  104. package/dist/{changes.d.ts → stack/changes.d.ts} +29 -65
  105. package/dist/stack/changes.d.ts.map +1 -0
  106. package/dist/{changes.js → stack/changes.js} +32 -66
  107. package/dist/stack/changes.js.map +1 -0
  108. package/dist/stack/client.d.ts +271 -0
  109. package/dist/stack/client.d.ts.map +1 -0
  110. package/dist/stack/client.js +9 -0
  111. package/dist/stack/client.js.map +1 -0
  112. package/dist/stack/identity-bindings.d.ts.map +1 -0
  113. package/dist/{identity-bindings.js → stack/identity-bindings.js} +8 -14
  114. package/dist/stack/identity-bindings.js.map +1 -0
  115. package/dist/stack/install-app.d.ts +22 -0
  116. package/dist/stack/install-app.d.ts.map +1 -0
  117. package/dist/stack/install-app.js +260 -0
  118. package/dist/stack/install-app.js.map +1 -0
  119. package/dist/stack/integrity.d.ts +94 -0
  120. package/dist/stack/integrity.d.ts.map +1 -0
  121. package/dist/stack/integrity.js +268 -0
  122. package/dist/stack/integrity.js.map +1 -0
  123. package/dist/{limits.d.ts → stack/limits.d.ts} +2 -5
  124. package/dist/stack/limits.d.ts.map +1 -0
  125. package/dist/{limits.js → stack/limits.js} +3 -6
  126. package/dist/stack/limits.js.map +1 -0
  127. package/dist/stack/migrations.d.ts +59 -0
  128. package/dist/stack/migrations.d.ts.map +1 -0
  129. package/dist/stack/migrations.js +141 -0
  130. package/dist/stack/migrations.js.map +1 -0
  131. package/dist/{stack-reads.d.ts → stack/reads.d.ts} +33 -6
  132. package/dist/stack/reads.d.ts.map +1 -0
  133. package/dist/{stack-reads.js → stack/reads.js} +49 -7
  134. package/dist/stack/reads.js.map +1 -0
  135. package/dist/stack/record-id.d.ts +35 -0
  136. package/dist/stack/record-id.d.ts.map +1 -0
  137. package/dist/stack/record-id.js +82 -0
  138. package/dist/stack/record-id.js.map +1 -0
  139. package/dist/stack/stack.d.ts +438 -0
  140. package/dist/stack/stack.d.ts.map +1 -0
  141. package/dist/stack/stack.js +1366 -0
  142. package/dist/stack/stack.js.map +1 -0
  143. package/dist/stack/system-types.d.ts +16 -0
  144. package/dist/stack/system-types.d.ts.map +1 -0
  145. package/dist/stack/system-types.js +111 -0
  146. package/dist/stack/system-types.js.map +1 -0
  147. package/dist/stack/type-grants.d.ts +20 -0
  148. package/dist/stack/type-grants.d.ts.map +1 -0
  149. package/dist/stack/type-grants.js +69 -0
  150. package/dist/stack/type-grants.js.map +1 -0
  151. package/dist/stack/write-expectation.d.ts +78 -0
  152. package/dist/stack/write-expectation.d.ts.map +1 -0
  153. package/dist/stack/write-expectation.js +71 -0
  154. package/dist/stack/write-expectation.js.map +1 -0
  155. package/dist/testing.d.ts +21 -26
  156. package/dist/testing.d.ts.map +1 -1
  157. package/dist/testing.js +50 -70
  158. package/dist/testing.js.map +1 -1
  159. package/dist/type-handle.d.ts +67 -78
  160. package/dist/type-handle.d.ts.map +1 -1
  161. package/dist/type-handle.js +44 -111
  162. package/dist/type-handle.js.map +1 -1
  163. package/dist/types/adapter.d.ts +223 -0
  164. package/dist/types/adapter.d.ts.map +1 -0
  165. package/dist/types/adapter.js +5 -0
  166. package/dist/types/adapter.js.map +1 -0
  167. package/dist/types/associations.d.ts +156 -0
  168. package/dist/types/associations.d.ts.map +1 -0
  169. package/dist/types/associations.js +13 -0
  170. package/dist/types/associations.js.map +1 -0
  171. package/dist/types/capabilities.d.ts +89 -0
  172. package/dist/types/capabilities.d.ts.map +1 -0
  173. package/dist/types/capabilities.js +5 -0
  174. package/dist/types/capabilities.js.map +1 -0
  175. package/dist/types/events.d.ts +155 -0
  176. package/dist/types/events.d.ts.map +1 -0
  177. package/dist/types/events.js +5 -0
  178. package/dist/types/events.js.map +1 -0
  179. package/dist/types/ids.d.ts +43 -0
  180. package/dist/types/ids.d.ts.map +1 -0
  181. package/dist/types/ids.js +5 -0
  182. package/dist/types/ids.js.map +1 -0
  183. package/dist/types/index.d.ts +19 -0
  184. package/dist/types/index.d.ts.map +1 -0
  185. package/dist/types/index.js +19 -0
  186. package/dist/types/index.js.map +1 -0
  187. package/dist/types/journal.d.ts +47 -0
  188. package/dist/types/journal.d.ts.map +1 -0
  189. package/dist/types/journal.js +5 -0
  190. package/dist/types/journal.js.map +1 -0
  191. package/dist/types/query.d.ts +185 -0
  192. package/dist/types/query.d.ts.map +1 -0
  193. package/dist/types/query.js +10 -0
  194. package/dist/types/query.js.map +1 -0
  195. package/dist/types/records.d.ts +76 -0
  196. package/dist/types/records.d.ts.map +1 -0
  197. package/dist/types/records.js +5 -0
  198. package/dist/types/records.js.map +1 -0
  199. package/dist/types/schema.d.ts +74 -0
  200. package/dist/types/schema.d.ts.map +1 -0
  201. package/dist/types/schema.js +5 -0
  202. package/dist/types/schema.js.map +1 -0
  203. package/dist/types/system.d.ts +161 -0
  204. package/dist/types/system.d.ts.map +1 -0
  205. package/dist/types/system.js +32 -0
  206. package/dist/types/system.js.map +1 -0
  207. package/dist/types/tokens.d.ts +39 -0
  208. package/dist/types/tokens.d.ts.map +1 -0
  209. package/dist/types/tokens.js +5 -0
  210. package/dist/types/tokens.js.map +1 -0
  211. package/dist/validate.d.ts +29 -70
  212. package/dist/validate.d.ts.map +1 -1
  213. package/dist/validate.js +65 -97
  214. package/dist/validate.js.map +1 -1
  215. package/dist/{attachment-download.d.ts → wire/attachment-download.d.ts} +0 -57
  216. package/dist/wire/attachment-download.d.ts.map +1 -0
  217. package/dist/{attachment-download.js → wire/attachment-download.js} +0 -61
  218. package/dist/wire/attachment-download.js.map +1 -0
  219. package/dist/{auth.d.ts → wire/auth.d.ts} +5 -8
  220. package/dist/wire/auth.d.ts.map +1 -0
  221. package/dist/{auth.js → wire/auth.js} +5 -8
  222. package/dist/wire/auth.js.map +1 -0
  223. package/dist/{wire-body.d.ts → wire/body.d.ts} +13 -5
  224. package/dist/wire/body.d.ts.map +1 -0
  225. package/dist/{wire-body.js → wire/body.js} +65 -7
  226. package/dist/wire/body.js.map +1 -0
  227. package/dist/{wire-entry.d.ts → wire/index.d.ts} +12 -12
  228. package/dist/wire/index.d.ts.map +1 -0
  229. package/dist/{wire-entry.js → wire/index.js} +13 -17
  230. package/dist/wire/index.js.map +1 -0
  231. package/dist/{wire-record.d.ts → wire/record.d.ts} +10 -22
  232. package/dist/wire/record.d.ts.map +1 -0
  233. package/dist/{wire-record.js → wire/record.js} +12 -24
  234. package/dist/wire/record.js.map +1 -0
  235. package/dist/{wire-request.d.ts → wire/request.d.ts} +20 -37
  236. package/dist/wire/request.d.ts.map +1 -0
  237. package/dist/{wire-request.js → wire/request.js} +79 -54
  238. package/dist/wire/request.js.map +1 -0
  239. package/package.json +7 -7
  240. package/dist/adapter-entry.d.ts.map +0 -1
  241. package/dist/adapter-entry.js.map +0 -1
  242. package/dist/attachment-download.d.ts.map +0 -1
  243. package/dist/attachment-download.js.map +0 -1
  244. package/dist/auth.d.ts.map +0 -1
  245. package/dist/auth.js.map +0 -1
  246. package/dist/changes.d.ts.map +0 -1
  247. package/dist/changes.js.map +0 -1
  248. package/dist/combine.d.ts.map +0 -1
  249. package/dist/combine.js.map +0 -1
  250. package/dist/did-entry.d.ts.map +0 -1
  251. package/dist/did-entry.js.map +0 -1
  252. package/dist/did.d.ts.map +0 -1
  253. package/dist/did.js.map +0 -1
  254. package/dist/identity-bindings.d.ts.map +0 -1
  255. package/dist/identity-bindings.js.map +0 -1
  256. package/dist/limits.d.ts.map +0 -1
  257. package/dist/limits.js.map +0 -1
  258. package/dist/record-id.d.ts +0 -70
  259. package/dist/record-id.d.ts.map +0 -1
  260. package/dist/record-id.js +0 -127
  261. package/dist/record-id.js.map +0 -1
  262. package/dist/scoped-stack.d.ts +0 -532
  263. package/dist/scoped-stack.d.ts.map +0 -1
  264. package/dist/scoped-stack.js +0 -1219
  265. package/dist/scoped-stack.js.map +0 -1
  266. package/dist/sort.d.ts.map +0 -1
  267. package/dist/sort.js.map +0 -1
  268. package/dist/stack-reads.d.ts.map +0 -1
  269. package/dist/stack-reads.js.map +0 -1
  270. package/dist/stack.d.ts +0 -971
  271. package/dist/stack.d.ts.map +0 -1
  272. package/dist/stack.js +0 -2012
  273. package/dist/stack.js.map +0 -1
  274. package/dist/types.d.ts +0 -1250
  275. package/dist/types.d.ts.map +0 -1
  276. package/dist/types.js +0 -49
  277. package/dist/types.js.map +0 -1
  278. package/dist/wire-body.d.ts.map +0 -1
  279. package/dist/wire-body.js.map +0 -1
  280. package/dist/wire-entry.d.ts.map +0 -1
  281. package/dist/wire-entry.js.map +0 -1
  282. package/dist/wire-record.d.ts.map +0 -1
  283. package/dist/wire-record.js.map +0 -1
  284. package/dist/wire-request.d.ts.map +0 -1
  285. package/dist/wire-request.js.map +0 -1
  286. /package/dist/{did.d.ts → did/did.d.ts} +0 -0
  287. /package/dist/{identity-bindings.d.ts → stack/identity-bindings.d.ts} +0 -0
@@ -13,8 +13,9 @@
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';
16
+ import { StackBadRequestError } from '../errors.js';
17
+ import { bumpsVersion } from '../record-changes.js';
18
+ import { feedAssociationDelta } from '../associations/identity.js';
18
19
  /** The `baseId@version` split, as grants and query filters read it. */
19
20
  const baseIdOf = (typeId) => typeId.split('@')[0];
20
21
  /**
@@ -67,11 +68,9 @@ export function matchesFilter(emitted, filter) {
67
68
  const asArray = (value) => (Array.isArray(value) ? value : [value]);
68
69
  /**
69
70
  * 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.
71
+ * subscription. `unlist` is the one exception to the default exclusion:
72
+ * without it a subscriber who already holds the record would never be told
73
+ * to drop it. See docs/spec/events.md § The unlisted transition.
75
74
  */
76
75
  export function passesUnlistedBoundary(emitted, includeUnlisted) {
77
76
  if (includeUnlisted)
@@ -82,14 +81,9 @@ export function passesUnlistedBoundary(emitted, includeUnlisted) {
82
81
  }
83
82
  /**
84
83
  * 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.
84
+ * record, whatever was asked for — see docs/spec/events.md § Purged records
85
+ * carry nothing. The record rides by reference, shared across every frame
86
+ * from one emission: handlers are contractually read-only over it.
93
87
  */
94
88
  export function emitted(emission, includeRecords) {
95
89
  const { change, record } = emission;
@@ -154,16 +148,10 @@ function reportError(err, opts) {
154
148
  });
155
149
  }
156
150
  /**
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.
151
+ * Delivery for frames that originate elsewhere, already projected and
152
+ * scoped by the authority that opened the feed, so nothing here filters
153
+ * them again. One subscriber's, not the registry's: a relay carries its own
154
+ * subscription's filter. See docs/spec/events.md § Where events come from.
167
155
  */
168
156
  export class RelayDelivery {
169
157
  handler;
@@ -201,16 +189,10 @@ class UnscopedSubscription extends Subscription {
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,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAgCnE,uEAAuE;AACvE,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;AAEnE;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAsB,EAAE,MAAqB;IACzE,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;QAChC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;I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C,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,271 @@
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, RecordChangeSet, 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. Information, not action: a purge never
121
+ * touches the blob store, and nothing here is deleted by having been
122
+ * named. See docs/spec/attachments.md § A purge strands the bytes it
123
+ * referenced.
124
+ */
125
+ export type DeleteResult = {
126
+ /**
127
+ * The files the purged record referenced — its attachment associations
128
+ * and its `file-ref` content fields, deduplicated. The purge removes the
129
+ * only rows naming them, so this is the caller's one chance to hold the
130
+ * argument `deleteAttachment()` takes. Empty on a soft delete, which
131
+ * strands nothing: a tombstone's references stand.
132
+ */
133
+ referencedFileIds: FileId[];
134
+ };
135
+ /**
136
+ * What deleteAndReturn() reports back — DeleteResult plus the record itself,
137
+ * captured inside the same atomic operation as the destroy rather than a
138
+ * read beforehand. See Stack.deleteAndReturn().
139
+ */
140
+ export type DeleteAndReturnResult = DeleteResult & {
141
+ /**
142
+ * The record as it stood at the moment of deletion: immediately before
143
+ * destruction for a purge, or the resulting tombstone for a soft
144
+ * delete. Null only for the purge no-op — there was nothing to
145
+ * delete, and nothing to report; every other outcome throws instead of
146
+ * returning null (see Stack.delete()'s own no-op cases).
147
+ */
148
+ record: StackRecord | null;
149
+ };
150
+ /** Options for Stack.migrateAll(). */
151
+ export type MigrateAllOptions = {
152
+ /**
153
+ * `'all'` (the default) sweeps every record of the family, deleted and
154
+ * unlisted included. `'listed'` sweeps only what a non-owner can
155
+ * enumerate and read whole. See docs/spec/apps.md § Migrating an
156
+ * installed app's types.
157
+ */
158
+ sweep?: 'all' | 'listed';
159
+ };
160
+ /** The argument to Stack.defineType(). */
161
+ export type DefineTypeOptions = {
162
+ id: TypeId;
163
+ name: string;
164
+ /** A handle's `schema` is accepted as written, readonly members and all. */
165
+ schema: ReadonlyTypeSchema;
166
+ migratesFrom?: TypeId;
167
+ };
168
+ /**
169
+ * The app-facing record API, implemented by both Stack and ScopedStack.
170
+ * Accept this type in plugin or extension code to remain adapter-agnostic
171
+ * and work equally well with a full Stack or a permission-scoped view.
172
+ */
173
+ export interface StackClient {
174
+ readonly capabilities: StackCapabilities;
175
+ /**
176
+ * Typed access to `handle`'s whole family, every record migrated in
177
+ * memory to the handle's version. Throws `StackMigrationError` when the
178
+ * handle's `migratesFrom` has no migration passed to `Stack.open()`.
179
+ * See docs/spec/data-model.md § Type handles.
180
+ */
181
+ collection<S extends ReadonlyTypeSchema>(handle: TypeHandle<S>): Collection<ContentOf<S>>;
182
+ create<T extends Record<string, unknown> = Record<string, unknown>>(typeId: TypeId, content: T, opts?: CreateRecordOptions): Promise<StackRecord & {
183
+ content: T;
184
+ }>;
185
+ get(id: RecordId, opts?: GetRecordOptions): Promise<StackRecord | null>;
186
+ query(query?: StackQuery): Promise<QueryResult>;
187
+ /**
188
+ * Resolve a DID to its `_entity` card — family-wide and soft-deleted
189
+ * inclusive, per docs/spec/identity.md § DID bindings. No caching.
190
+ *
191
+ * Under `ScopedStack`, `null` covers missing, unreadable, and (unless the
192
+ * owner is acting alone) unlisted — never evidence the card is absent.
193
+ */
194
+ getEntityByDid(did: EntityId): Promise<StackRecord | null>;
195
+ /** getEntityByDid() for the one DID every stack reserves: its own owner. */
196
+ getOwnerEntity(): Promise<StackRecord | null>;
197
+ /**
198
+ * Apply a change set — any of `contentPatch`, `parentId`, `permissions`,
199
+ * `associations` and `unlisted` — as one atomic write, versioned only when
200
+ * it names `contentPatch`. Keys are read for presence; under ScopedStack
201
+ * one refused key refuses the call. See docs/spec/data-model.md § Mutations.
202
+ */
203
+ mutate(id: RecordId, changes: RecordChangeSet, opts?: IfVersionOptions): Promise<StackRecord>;
204
+ /** mutate() with `contentPatch` alone — the common case, named for it. */
205
+ patchContent(id: RecordId, patch: Record<string, unknown | null>, opts?: IfVersionOptions): Promise<StackRecord>;
206
+ /**
207
+ * Add associations in one atomic write and one journal entry. Never bumps
208
+ * `version`/`updatedAt` and takes no `ifVersion` — a set-add composes
209
+ * regardless of write order. See docs/spec/data-model.md § Mutations and
210
+ * docs/spec/versioning.md § Version history.
211
+ */
212
+ associate(id: RecordId, associations: DataAssociation[]): Promise<StackRecord>;
213
+ /** Remove associations, matched by identity — see associate(). */
214
+ dissociate(id: RecordId, associations: DataAssociation[]): Promise<StackRecord>;
215
+ /**
216
+ * Apply a list of adds and removes to a record's data associations as one
217
+ * atomic write — the cover swap. associate() and dissociate() are this with
218
+ * one half each; `mutate({ associations })` is the only whole-set write.
219
+ * `repoint` is not a request: an add naming an attachment the record
220
+ * already holds re-points it. See docs/spec/data-model.md § Mutations.
221
+ */
222
+ amendAssociations(id: RecordId, changes: AssociationEdit[]): Promise<StackRecord>;
223
+ /**
224
+ * Extend who reaches a record — the record-level mirror of the type-level
225
+ * `grantType()`, and the amending spelling of the `permissions` key, which
226
+ * replaces the whole set. `write` never implies `read`: grant both,
227
+ * `grantAccess(id, [read, write])`. No-bump, like associate().
228
+ * See docs/spec/access-control.md § Write implies read.
229
+ */
230
+ grantAccess(id: RecordId, permissions: AuthorityAssociation[]): Promise<StackRecord>;
231
+ /** Withdraw elements of who reaches a record — see grantAccess(). */
232
+ revokeAccess(id: RecordId, permissions: AuthorityAssociation[]): Promise<StackRecord>;
233
+ /**
234
+ * amendAssociations() for permissions: adds and removes in one atomic
235
+ * write, so a downgrade (remove `write`, keep `read`) is one change.
236
+ * See docs/spec/access-control.md § Record-level permissions.
237
+ */
238
+ amendAccess(id: RecordId, changes: AssociationEdit[]): Promise<StackRecord>;
239
+ delete(id: RecordId, opts?: DeleteRecordOptions): Promise<DeleteResult>;
240
+ /**
241
+ * delete(), plus the record it acted on — read and destroyed as one
242
+ * atomic operation, so a caller that needs the record for its own
243
+ * response (e.g. a server building a purge's body) never opens a
244
+ * gap between reading it and destroying it. See Stack.deleteAndReturn().
245
+ */
246
+ deleteAndReturn(id: RecordId, opts?: DeleteRecordOptions): Promise<DeleteAndReturnResult>;
247
+ undelete(id: RecordId, opts?: IfVersionOptions): Promise<StackRecord>;
248
+ getVersions(id: RecordId, query?: VersionsQuery): Promise<RecordVersion[]>;
249
+ getVersion(id: RecordId, version: number): Promise<RecordVersion | null>;
250
+ restoreVersion(id: RecordId, version: number, opts?: IfVersionOptions): Promise<StackRecord>;
251
+ /**
252
+ * A record's change journal, oldest first, gated like getVersions().
253
+ * Required of every adapter, so an empty log always means "nothing
254
+ * changed". See docs/spec/journal.md § Reading it.
255
+ */
256
+ getJournal(id: RecordId, query?: JournalQuery): Promise<RecordJournalEntry[]>;
257
+ /**
258
+ * Commit a per-record migration: `typeId` and `content` together,
259
+ * validated against `toTypeId`'s schema — the only way a record's typeId
260
+ * changes after creation. See docs/spec/wire-format.md § Migration commit.
261
+ */
262
+ commitMigration(id: RecordId, toTypeId: TypeId, content: Record<string, unknown>, opts?: IfVersionOptions): Promise<StackRecord>;
263
+ getAttachment(fileId: FileId): Promise<Uint8Array>;
264
+ putAttachment(data: Uint8Array, opts: PutAttachmentOptions): Promise<StackRecord & {
265
+ content: AttachmentContent;
266
+ }>;
267
+ deleteAttachment(fileId: FileId): Promise<void>;
268
+ collectAttachmentGarbage(opts?: CollectAttachmentGarbageOptions): Promise<CollectAttachmentGarbageResult>;
269
+ subscribe(handler: (change: RecordChange) => void, opts?: SubscribeOptions): Promise<Unsubscribe>;
270
+ }
271
+ //# 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,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,MAAM,EACN,WAAW,EACX,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;;OAKG;IACH,EAAE,CAAC,EAAE,QAAQ,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,kEAAkE;IAClE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AACF;;;;;GAKG;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,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
@@ -17,25 +17,19 @@ import { SYSTEM_TYPES } from './types.js';
17
17
  const BINDING_FIELDS = new Map([
18
18
  [SYSTEM_TYPES.APP, ['did', 'appId']],
19
19
  [SYSTEM_TYPES.ENTITY, ['did']],
20
+ [SYSTEM_TYPES.INSTALL, ['appId']],
20
21
  ]);
21
22
  /**
22
- * The subset that is additionally unique per stack: the fields something
23
- * resolves *by*. An Actor's `principalId` finds its card by `_app.did` and
24
- * its `subjectId` by `_entity.did`, so a second card claiming either leaves
25
- * that lookup without a single answer — and ambiguity is all an
26
- * impersonating card needs.
27
- *
28
- * `_app.appId` is deliberately absent. Nothing resolves a card by it — the
29
- * cross-check reaches the card by `did` and only compares `appId` — so
30
- * uniqueness would buy no disambiguation, while forbidding the second card
31
- * key rotation is supposed to produce: `appId` is required, so a
32
- * replacement card for the same software necessarily repeats it. Moving one
33
- * card onto another's `appId` is what immutability already refuses.
34
- * 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.
35
27
  */
36
28
  const UNIQUE_BINDING_FIELDS = new Map([
37
29
  [SYSTEM_TYPES.APP, ['did']],
38
30
  [SYSTEM_TYPES.ENTITY, ['did']],
31
+ // One install answers for each app; see docs/spec/apps.md § The `_install` record.
32
+ [SYSTEM_TYPES.INSTALL, ['appId']],
39
33
  ]);
40
34
  export const bindingFieldsOf = (family) => BINDING_FIELDS.get(family) ?? [];
41
35
  export const uniqueBindingFieldsOf = (family) => UNIQUE_BINDING_FIELDS.get(family) ?? [];
@@ -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,CA6CpD;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,WAAW,GAAG;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC,CAapD"}