@haverstack/core 0.42.0 → 0.44.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 (185) hide show
  1. package/README.md +6 -9
  2. package/dist/access.d.ts +36 -34
  3. package/dist/access.d.ts.map +1 -1
  4. package/dist/access.js +51 -100
  5. package/dist/access.js.map +1 -1
  6. package/dist/adapter/combine.d.ts.map +1 -1
  7. package/dist/adapter/combine.js +14 -7
  8. package/dist/adapter/combine.js.map +1 -1
  9. package/dist/adapter/copy.d.ts +27 -0
  10. package/dist/adapter/copy.d.ts.map +1 -0
  11. package/dist/adapter/copy.js +105 -0
  12. package/dist/adapter/copy.js.map +1 -0
  13. package/dist/adapter/index.d.ts +9 -4
  14. package/dist/adapter/index.d.ts.map +1 -1
  15. package/dist/adapter/index.js +6 -3
  16. package/dist/adapter/index.js.map +1 -1
  17. package/dist/adapter/reach.d.ts +14 -0
  18. package/dist/adapter/reach.d.ts.map +1 -0
  19. package/dist/adapter/reach.js +31 -0
  20. package/dist/adapter/reach.js.map +1 -0
  21. package/dist/adapter/seed.d.ts +13 -0
  22. package/dist/adapter/seed.d.ts.map +1 -0
  23. package/dist/adapter/seed.js +26 -0
  24. package/dist/adapter/seed.js.map +1 -0
  25. package/dist/associations/identity.d.ts +18 -42
  26. package/dist/associations/identity.d.ts.map +1 -1
  27. package/dist/associations/identity.js +60 -84
  28. package/dist/associations/identity.js.map +1 -1
  29. package/dist/associations/validation.d.ts +1 -8
  30. package/dist/associations/validation.d.ts.map +1 -1
  31. package/dist/associations/validation.js +3 -30
  32. package/dist/associations/validation.js.map +1 -1
  33. package/dist/collection.d.ts +7 -11
  34. package/dist/collection.d.ts.map +1 -1
  35. package/dist/collection.js +24 -34
  36. package/dist/collection.js.map +1 -1
  37. package/dist/content-match.d.ts +2 -2
  38. package/dist/content-match.js +2 -2
  39. package/dist/errors.d.ts +41 -12
  40. package/dist/errors.d.ts.map +1 -1
  41. package/dist/errors.js +56 -15
  42. package/dist/errors.js.map +1 -1
  43. package/dist/grants.d.ts +18 -6
  44. package/dist/grants.d.ts.map +1 -1
  45. package/dist/grants.js +48 -37
  46. package/dist/grants.js.map +1 -1
  47. package/dist/hash.d.ts +8 -0
  48. package/dist/hash.d.ts.map +1 -0
  49. package/dist/hash.js +14 -0
  50. package/dist/hash.js.map +1 -0
  51. package/dist/index.d.ts +6 -6
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +2 -2
  54. package/dist/index.js.map +1 -1
  55. package/dist/install.d.ts +29 -5
  56. package/dist/install.d.ts.map +1 -1
  57. package/dist/install.js +69 -44
  58. package/dist/install.js.map +1 -1
  59. package/dist/lazy.d.ts +13 -0
  60. package/dist/lazy.d.ts.map +1 -0
  61. package/dist/lazy.js +27 -0
  62. package/dist/lazy.js.map +1 -0
  63. package/dist/merge.d.ts +1 -1
  64. package/dist/merge.js +1 -1
  65. package/dist/query-validation.d.ts +41 -28
  66. package/dist/query-validation.d.ts.map +1 -1
  67. package/dist/query-validation.js +85 -71
  68. package/dist/query-validation.js.map +1 -1
  69. package/dist/record-changes.d.ts +12 -36
  70. package/dist/record-changes.d.ts.map +1 -1
  71. package/dist/record-changes.js +9 -98
  72. package/dist/record-changes.js.map +1 -1
  73. package/dist/schema.d.ts.map +1 -1
  74. package/dist/schema.js +2 -5
  75. package/dist/schema.js.map +1 -1
  76. package/dist/scoped-stack/authority-snapshot.d.ts +37 -0
  77. package/dist/scoped-stack/authority-snapshot.d.ts.map +1 -0
  78. package/dist/scoped-stack/authority-snapshot.js +49 -0
  79. package/dist/scoped-stack/authority-snapshot.js.map +1 -0
  80. package/dist/scoped-stack/authority.d.ts +69 -51
  81. package/dist/scoped-stack/authority.d.ts.map +1 -1
  82. package/dist/scoped-stack/authority.js +189 -153
  83. package/dist/scoped-stack/authority.js.map +1 -1
  84. package/dist/scoped-stack/family-policy.d.ts +59 -0
  85. package/dist/scoped-stack/family-policy.d.ts.map +1 -0
  86. package/dist/scoped-stack/family-policy.js +68 -0
  87. package/dist/scoped-stack/family-policy.js.map +1 -0
  88. package/dist/scoped-stack/scoped-stack.d.ts +73 -86
  89. package/dist/scoped-stack/scoped-stack.d.ts.map +1 -1
  90. package/dist/scoped-stack/scoped-stack.js +279 -337
  91. package/dist/scoped-stack/scoped-stack.js.map +1 -1
  92. package/dist/scoped-stack/subscription.d.ts +14 -33
  93. package/dist/scoped-stack/subscription.d.ts.map +1 -1
  94. package/dist/scoped-stack/subscription.js +16 -57
  95. package/dist/scoped-stack/subscription.js.map +1 -1
  96. package/dist/stack/arguments.d.ts +27 -0
  97. package/dist/stack/arguments.d.ts.map +1 -0
  98. package/dist/stack/arguments.js +53 -0
  99. package/dist/stack/arguments.js.map +1 -0
  100. package/dist/stack/attachments.d.ts +1 -1
  101. package/dist/stack/attachments.js +1 -1
  102. package/dist/stack/changes.d.ts +4 -10
  103. package/dist/stack/changes.d.ts.map +1 -1
  104. package/dist/stack/changes.js +8 -8
  105. package/dist/stack/changes.js.map +1 -1
  106. package/dist/stack/client.d.ts +34 -58
  107. package/dist/stack/client.d.ts.map +1 -1
  108. package/dist/stack/field-rules.d.ts +27 -0
  109. package/dist/stack/field-rules.d.ts.map +1 -0
  110. package/dist/stack/field-rules.js +50 -0
  111. package/dist/stack/field-rules.js.map +1 -0
  112. package/dist/stack/install-app.d.ts +2 -2
  113. package/dist/stack/install-app.d.ts.map +1 -1
  114. package/dist/stack/install-app.js +16 -14
  115. package/dist/stack/install-app.js.map +1 -1
  116. package/dist/stack/integrity.d.ts +9 -53
  117. package/dist/stack/integrity.d.ts.map +1 -1
  118. package/dist/stack/integrity.js +47 -107
  119. package/dist/stack/integrity.js.map +1 -1
  120. package/dist/stack/limits.d.ts +1 -1
  121. package/dist/stack/limits.js +1 -1
  122. package/dist/stack/reads.d.ts +9 -5
  123. package/dist/stack/reads.d.ts.map +1 -1
  124. package/dist/stack/reads.js +24 -4
  125. package/dist/stack/reads.js.map +1 -1
  126. package/dist/stack/stack.d.ts +84 -79
  127. package/dist/stack/stack.d.ts.map +1 -1
  128. package/dist/stack/stack.js +236 -306
  129. package/dist/stack/stack.js.map +1 -1
  130. package/dist/stack/system-types.d.ts.map +1 -1
  131. package/dist/stack/system-types.js +1 -3
  132. package/dist/stack/system-types.js.map +1 -1
  133. package/dist/stack/type-grants.d.ts.map +1 -1
  134. package/dist/stack/type-grants.js +9 -6
  135. package/dist/stack/type-grants.js.map +1 -1
  136. package/dist/stack/write-expectation.d.ts +13 -12
  137. package/dist/stack/write-expectation.d.ts.map +1 -1
  138. package/dist/stack/write-expectation.js.map +1 -1
  139. package/dist/stack/write-gate.d.ts +23 -0
  140. package/dist/stack/write-gate.d.ts.map +1 -0
  141. package/dist/stack/write-gate.js +17 -0
  142. package/dist/stack/write-gate.js.map +1 -0
  143. package/dist/testing.d.ts +37 -24
  144. package/dist/testing.d.ts.map +1 -1
  145. package/dist/testing.js +176 -153
  146. package/dist/testing.js.map +1 -1
  147. package/dist/types/adapter.d.ts +115 -43
  148. package/dist/types/adapter.d.ts.map +1 -1
  149. package/dist/types/associations.d.ts +1 -17
  150. package/dist/types/associations.d.ts.map +1 -1
  151. package/dist/types/associations.js +1 -8
  152. package/dist/types/associations.js.map +1 -1
  153. package/dist/types/capabilities.d.ts +8 -8
  154. package/dist/types/capabilities.d.ts.map +1 -1
  155. package/dist/types/events.d.ts +3 -8
  156. package/dist/types/events.d.ts.map +1 -1
  157. package/dist/types/query.d.ts +4 -4
  158. package/dist/types/system.d.ts +2 -8
  159. package/dist/types/system.d.ts.map +1 -1
  160. package/dist/types/system.js.map +1 -1
  161. package/dist/validate.d.ts +2 -0
  162. package/dist/validate.d.ts.map +1 -1
  163. package/dist/validate.js +2 -1
  164. package/dist/validate.js.map +1 -1
  165. package/dist/wire/body.d.ts +32 -9
  166. package/dist/wire/body.d.ts.map +1 -1
  167. package/dist/wire/body.js +69 -8
  168. package/dist/wire/body.js.map +1 -1
  169. package/dist/wire/index.d.ts +4 -4
  170. package/dist/wire/index.d.ts.map +1 -1
  171. package/dist/wire/index.js +3 -3
  172. package/dist/wire/index.js.map +1 -1
  173. package/dist/wire/record.d.ts +1 -8
  174. package/dist/wire/record.d.ts.map +1 -1
  175. package/dist/wire/record.js +0 -48
  176. package/dist/wire/record.js.map +1 -1
  177. package/dist/wire/request.d.ts +18 -18
  178. package/dist/wire/request.d.ts.map +1 -1
  179. package/dist/wire/request.js +41 -36
  180. package/dist/wire/request.js.map +1 -1
  181. package/package.json +1 -1
  182. package/dist/stack/identity-bindings.d.ts +0 -13
  183. package/dist/stack/identity-bindings.d.ts.map +0 -1
  184. package/dist/stack/identity-bindings.js +0 -36
  185. package/dist/stack/identity-bindings.js.map +0 -1
@@ -7,11 +7,16 @@
7
7
  * adapters). Types an app reads too, such as StackCapabilities, live in
8
8
  * the root entry point instead: every export has exactly one home.
9
9
  */
10
- export type { StackAdapter, StackRecordAdapter, StackBlobAdapter, BlobInfo, BumpVersionOptions, SnapshotOptions, JournalEntryInput, JournalOptions, MutateOptions, } from '../types/index.js';
11
- export { OwnerMismatchError } from '../errors.js';
10
+ export type { AdapterQuery, PlainQuery, AdapterSort, StackAdapter, StackRecordAdapter, StackBlobAdapter, BlobInfo, SnapshotOptions, JournalEntryInput, JournalOptions, MutateOptions, AspectWriteOptions, ElementWriteOptions, Reach, RecordHistory, StoreSeed, } from '../types/index.js';
11
+ export { sameAssociationSet } from '../associations/identity.js';
12
+ export { ElementSetMovedError, FormatMismatchError, OwnerMismatchError, softDeletedRefusal, } from '../errors.js';
12
13
  export { combineAdapters } from './combine.js';
13
- export { assertQueryCapabilities, assertSortCapability, assertValidSort, assertValidAssociationFilters, assertValidJournalQuery, assertValidVersionsQuery, filtersContent, parseContentFilterKey, } from '../query-validation.js';
14
+ export { copyStack } from './copy.js';
15
+ export type { CreateStore } from './copy.js';
16
+ export { newStoreSeed } from './seed.js';
17
+ export { inReach } from './reach.js';
18
+ export type { ReachedRecord } from './reach.js';
19
+ export { assertQueryCapabilities, assertValidSort, resolveQuery, assertValidAssociationFilters, assertValidJournalQuery, assertValidVersionsQuery, filtersContent, parseContentFilterKey, } from '../query-validation.js';
14
20
  export { contentSortEntry, contentSortKey, compareSortEntries, constantSortEntry, sortConstant, } from './sort.js';
15
21
  export type { SortEntry } from './sort.js';
16
- export { AUTHORITY_ASSOCIATION_KINDS, partitionAssociations } from '../associations/identity.js';
17
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,EACL,aAAa,EACb,SAAS,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC"}
@@ -7,9 +7,12 @@
7
7
  * adapters). Types an app reads too, such as StackCapabilities, live in
8
8
  * the root entry point instead: every export has exactly one home.
9
9
  */
10
- export { OwnerMismatchError } from '../errors.js';
10
+ export { sameAssociationSet } from '../associations/identity.js';
11
+ export { ElementSetMovedError, FormatMismatchError, OwnerMismatchError, softDeletedRefusal, } from '../errors.js';
11
12
  export { combineAdapters } from './combine.js';
12
- export { assertQueryCapabilities, assertSortCapability, assertValidSort, assertValidAssociationFilters, assertValidJournalQuery, assertValidVersionsQuery, filtersContent, parseContentFilterKey, } from '../query-validation.js';
13
+ export { copyStack } from './copy.js';
14
+ export { newStoreSeed } from './seed.js';
15
+ export { inReach } from './reach.js';
16
+ export { assertQueryCapabilities, assertValidSort, resolveQuery, assertValidAssociationFilters, assertValidJournalQuery, assertValidVersionsQuery, filtersContent, parseContentFilterKey, } from '../query-validation.js';
13
17
  export { contentSortEntry, contentSortKey, compareSortEntries, constantSortEntry, sortConstant, } from './sort.js';
14
- export { AUTHORITY_ASSOCIATION_KINDS, partitionAssociations } from '../associations/identity.js';
15
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoBH,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,WAAW,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Matching a Reach in memory
3
+ * -------------------------------------------------------
4
+ * The one reading of a reach in JavaScript: MemoryAdapter matches a query
5
+ * with it, and ScopedStack asks it of each Record a verb would act on. A
6
+ * SQL adapter states the same conditions in its own query language. See
7
+ * docs/spec/access-control.md § Reach.
8
+ */
9
+ import type { Reach, StackRecord } from '../types/index.js';
10
+ /** What a reach asks of a Record — all a record yet to be created has to show. */
11
+ export type ReachedRecord = Pick<StackRecord, 'typeId' | 'createdBy' | 'permissions'>;
12
+ /** Whether `record` is inside the reach, matched by its family. */
13
+ export declare function inReach(record: ReachedRecord, reach: Reach): boolean;
14
+ //# sourceMappingURL=reach.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../../src/adapter/reach.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5D,kFAAkF;AAClF,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,WAAW,GAAG,aAAa,CAAC,CAAC;AAEtF,mEAAmE;AACnE,wBAAgB,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAmBpE"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Matching a Reach in memory
3
+ * -------------------------------------------------------
4
+ * The one reading of a reach in JavaScript: MemoryAdapter matches a query
5
+ * with it, and ScopedStack asks it of each Record a verb would act on. A
6
+ * SQL adapter states the same conditions in its own query language. See
7
+ * docs/spec/access-control.md § Reach.
8
+ */
9
+ import { associationKey } from '../associations/identity.js';
10
+ import { baseIdOf } from '../schema.js';
11
+ /** Whether `record` is inside the reach, matched by its family. */
12
+ export function inReach(record, reach) {
13
+ const family = baseIdOf(record.typeId);
14
+ if (reach.fence && !reach.fence.includes(family))
15
+ return false;
16
+ const within = reach.within;
17
+ if (!within)
18
+ return true;
19
+ if (within.baseIds.includes(family))
20
+ return true;
21
+ const authored = within.authored;
22
+ if (authored &&
23
+ authored.baseIds.includes(family) &&
24
+ record.createdBy?.subjectId === authored.subjectId) {
25
+ return true;
26
+ }
27
+ const held = new Set((record.permissions ?? []).map(associationKey));
28
+ held.delete(undefined);
29
+ return within.permissions.some((set) => set.length > 0 && set.every((element) => held.has(associationKey(element))));
30
+ }
31
+ //# sourceMappingURL=reach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reach.js","sourceRoot":"","sources":["../../src/adapter/reach.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAMxC,mEAAmE;AACnE,MAAM,UAAU,OAAO,CAAC,MAAqB,EAAE,KAAY;IACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/D,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,IACE,QAAQ;QACR,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QACjC,MAAM,CAAC,SAAS,EAAE,SAAS,KAAK,QAAQ,CAAC,SAAS,EAClD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;IACrE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvB,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAC5B,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CACrF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Store seeds
3
+ * -------------------------------------------------------
4
+ * A store is created holding one Record, `_config`, which says whose stack
5
+ * it is. A seed is that Record with its history: fresh for a new stack, the
6
+ * source's own for a copy, so the one Record every store starts with is
7
+ * written the way every other Record is. See docs/spec/adapters.md
8
+ * § Construction.
9
+ */
10
+ import type { ConfigContent, StoreSeed } from '../types/index.js';
11
+ /** The seed of a stack that has no past: `_config` at version 1, holding `config`. */
12
+ export declare function newStoreSeed(config: ConfigContent): StoreSeed;
13
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../src/adapter/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGlE,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CAa7D"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Store seeds
3
+ * -------------------------------------------------------
4
+ * A store is created holding one Record, `_config`, which says whose stack
5
+ * it is. A seed is that Record with its history: fresh for a new stack, the
6
+ * source's own for a copy, so the one Record every store starts with is
7
+ * written the way every other Record is. See docs/spec/adapters.md
8
+ * § Construction.
9
+ */
10
+ import { SYSTEM_TYPES } from '../types/index.js';
11
+ /** The seed of a stack that has no past: `_config` at version 1, holding `config`. */
12
+ export function newStoreSeed(config) {
13
+ const now = new Date();
14
+ return {
15
+ config: {
16
+ id: SYSTEM_TYPES.CONFIG,
17
+ typeId: `${SYSTEM_TYPES.CONFIG}@1`,
18
+ createdAt: now,
19
+ updatedAt: now,
20
+ content: { ...config },
21
+ version: 1,
22
+ },
23
+ history: { versions: [], journal: [] },
24
+ };
25
+ }
26
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.js","sourceRoot":"","sources":["../../src/adapter/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,MAAqB;IAChD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,OAAO;QACL,MAAM,EAAE;YACN,EAAE,EAAE,YAAY,CAAC,MAAM;YACvB,MAAM,EAAE,GAAG,YAAY,CAAC,MAAM,IAAI;YAClC,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,GAAG;YACd,OAAO,EAAE,EAAE,GAAG,MAAM,EAAE;YACtB,OAAO,EAAE,CAAC;SACX;QACD,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;KACvC,CAAC;AACJ,CAAC"}
@@ -9,19 +9,17 @@
9
9
  */
10
10
  import type { Association, AssociationChange, AssociationEdit, AuthorityAssociation, DataAssociation, Grantee, RelationshipTarget } from '../types/index.js';
11
11
  /**
12
- * Association identity — what dissociate() matches and a repeat associate()
12
+ * Association identity — what a remove edit matches and a repeat add
13
13
  * collides with; the SQLite adapter's primary key. An attachment's
14
14
  * `attachmentRecordId` annotates a reference rather than naming one, so it
15
15
  * is outside; a group grantee's `role` names a different set of people, so
16
16
  * it is inside. See docs/spec/data-model.md § Associations.
17
17
  */
18
+ export declare function associationKey(a: Association): string | undefined;
19
+ /** Whether two associations are the same one — see associationKey(). */
18
20
  export declare function associationEqual(a: Association, b: Association): boolean;
19
- /**
20
- * Structural equality per grantee arm. `role` is required, so there is no
21
- * absent-means-any spelling to normalize.
22
- */
23
21
  export declare function granteeEqual(a: Grantee, b: Grantee): boolean;
24
- /** Structural equality per target arm — what dissociate() matches on. */
22
+ /** Structural equality per target arm — what a remove edit matches on. */
25
23
  export declare function targetEqual(a: RelationshipTarget, b: RelationshipTarget): boolean;
26
24
  /**
27
25
  * Identity plus every annotation outside it, so a write that only re-points
@@ -30,35 +28,26 @@ export declare function targetEqual(a: RelationshipTarget, b: RelationshipTarget
30
28
  * this decides whether it says anything new.
31
29
  */
32
30
  export declare function associationIdentical(a: Association, b: Association): boolean;
33
- /**
34
- * The association kinds that carry authority. Every other kind is data.
35
- * Storage that partitions by kind in a query reads this list rather than
36
- * restating it, so a new authority kind can't fall into the data half.
37
- */
38
- export declare const AUTHORITY_ASSOCIATION_KINDS: readonly AuthorityAssociation['kind'][];
39
31
  /**
40
32
  * Whether an association carries authority rather than data — the partition
41
33
  * `StackRecord.permissions` and `StackRecord.associations` project, and the
42
- * line `associate()`/`dissociate()` refuse to cross.
34
+ * line the association verbs refuse to cross.
43
35
  * See docs/spec/access-control.md § Record-level permissions.
44
36
  */
45
37
  export declare function isAuthorityAssociation(a: Association): a is AuthorityAssociation;
46
38
  /**
47
- * One stored association set split into the two the record presents. An app
48
- * editing tags never sees the authority half, so it cannot drop it.
39
+ * What replacing a record's set with `after` moves, one tagged edit each.
40
+ * An entry matching an existing identity displaced it: a `repoint`,
41
+ * carrying the prior association in full as `previous` — the only place
42
+ * an overwritten `attachmentRecordId` survives.
43
+ * See docs/spec/journal.md § The entry.
49
44
  */
50
- export declare function partitionAssociations(associations: Association[]): {
51
- associations: DataAssociation[];
52
- permissions: AuthorityAssociation[];
53
- };
45
+ export declare function associationDelta(before: readonly Association[], after: readonly Association[]): AssociationChange[];
54
46
  /**
55
- * What a `changes.associations` list moves against a record's current set,
56
- * one tagged edit each. An entry matching an existing identity displaced it:
57
- * a `repoint`, carrying the prior association in full as `previous` — the
58
- * only place an overwritten `attachmentRecordId` survives.
59
- * See docs/spec/journal.md § The entry.
47
+ * Whether two sets hold the same elements, annotations included, in any
48
+ * order — what an element-set write's `expectSet` is compared by.
60
49
  */
61
- export declare function associationDelta(before: Association[], after: Association[]): AssociationChange[];
50
+ export declare function sameAssociationSet(a: readonly Association[], b: readonly Association[]): boolean;
62
51
  /**
63
52
  * The two flat lists a change frame carries, derived from the tagged list.
64
53
  * The feed reports what is true now, so a `repoint` appears only under its
@@ -70,24 +59,11 @@ export declare function feedAssociationDelta(changes: AssociationChange[]): {
70
59
  added: DataAssociation[];
71
60
  removed: DataAssociation[];
72
61
  };
62
+ /** The elements an edit list adds. */
63
+ export declare function addsOf(edits: readonly AssociationEdit[]): Association[];
73
64
  /**
74
- * An association edit list travels one surface: authority and data share
75
- * storage and a delta, and never share a call. Refused here so every
76
- * adapter inherits the same rule.
77
- * See docs/spec/access-control.md § Storage unifies; the API does not.
78
- */
79
- export declare function assertOneSurface(changes: readonly AssociationEdit[]): void;
80
- /**
81
- * The set a list of edits leaves behind: removes first, then adds, an add
82
- * landing on an identity already held in place. Adds naming one identity
83
- * collapse, last wins; an add outlives a remove of the same identity.
84
- * See docs/spec/adapters.md § Amending associations.
65
+ * The set a list of edits leaves behind, an add landing on an identity
66
+ * already held in place. See docs/spec/adapters.md § Editing associations.
85
67
  */
86
68
  export declare function applyAssociationEdits(current: Association[], changes: readonly AssociationEdit[]): Association[];
87
- /**
88
- * The same op over every element of a list — what associate(),
89
- * dissociate(), grantAccess() and revokeAccess() hand to the amend verb
90
- * each is one half of.
91
- */
92
- export declare function editsOf(op: 'add' | 'remove', associations: Association[]): AssociationEdit[];
93
69
  //# sourceMappingURL=identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/associations/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,OAAO,EACP,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAaxE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAQ5D;AAED,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAQjF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAM5E;AAcD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,SAAS,oBAAoB,CAAC,MAAM,CAAC,EAG9E,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,WAAW,GAAG,CAAC,IAAI,oBAAoB,CAEhF;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG;IAClE,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC,CAKA;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,WA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AAC,EAAE,WAAW,GAAG,OAAO,CAM5E;AAoBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,WAAW,GAAG,CAAC,IAAI,oBAAoB,CAEhF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,KAAK,EAAE,SAAS,WAAW,EAAE,GAC5B,iBAAiB,EAAE,CAcrB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,SAAS,WAAW,EAAE,EAAE,CAAC,EAAE,SAAS,WAAW,EAAE,GAAG,OAAO,CAEhG;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG;IAClE,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B,CAYA;AAED,sCAAsC;AACtC,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,GAAG,WAAW,EAAE,CAEvE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,EAAE,EACtB,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,WAAW,EAAE,CAWf"}
@@ -7,59 +7,61 @@
7
7
  * applying edits, the feed — so they answer it with one comparison and
8
8
  * can never disagree. See docs/spec/data-model.md § Associations.
9
9
  */
10
- import { StackBadRequestError } from '../errors.js';
11
10
  /**
12
- * Association identity — what dissociate() matches and a repeat associate()
11
+ * Association identity — what a remove edit matches and a repeat add
13
12
  * collides with; the SQLite adapter's primary key. An attachment's
14
13
  * `attachmentRecordId` annotates a reference rather than naming one, so it
15
14
  * is outside; a group grantee's `role` names a different set of people, so
16
15
  * it is inside. See docs/spec/data-model.md § Associations.
17
16
  */
18
- export function associationEqual(a, b) {
19
- // Never "the same one": naming a malformed association is
17
+ export function associationKey(a) {
18
+ // No key, so never "the same one": naming a malformed association is
20
19
  // validateAssociation()'s job, which this must reach without throwing.
21
- if (!a || !b)
22
- return false;
23
- if (a.kind !== b.kind || a.label !== b.label)
24
- return false;
25
- if (a.kind === 'attachment' && b.kind === 'attachment')
26
- return a.fileId === b.fileId;
27
- if (a.kind === 'relationship' && b.kind === 'relationship') {
28
- return targetEqual(a.target, b.target);
29
- }
30
- if (a.kind === 'permission' && b.kind === 'permission') {
31
- return granteeEqual(a.grantee, b.grantee);
32
- }
33
- return true;
20
+ if (!a)
21
+ return undefined;
22
+ const arm = a.kind === 'attachment'
23
+ ? [a.fileId]
24
+ : a.kind === 'relationship'
25
+ ? targetParts(a.target)
26
+ : a.kind === 'permission'
27
+ ? granteeParts(a.grantee)
28
+ : [];
29
+ return arm && JSON.stringify([a.kind, a.label, ...arm]);
30
+ }
31
+ /** Whether two associations are the same one — see associationKey(). */
32
+ export function associationEqual(a, b) {
33
+ const key = associationKey(a);
34
+ return key !== undefined && key === associationKey(b);
34
35
  }
35
36
  /**
36
- * Structural equality per grantee arm. `role` is required, so there is no
37
+ * A grantee's identity, per arm. `role` is required, so there is no
37
38
  * absent-means-any spelling to normalize.
38
39
  */
40
+ function granteeParts(g) {
41
+ if (g?.kind === 'entity')
42
+ return [g.kind, g.entityId];
43
+ if (g?.kind === 'group')
44
+ return [g.kind, g.groupId, g.role];
45
+ return undefined;
46
+ }
39
47
  export function granteeEqual(a, b) {
40
- if (!a || !b)
41
- return false;
42
- if (a.kind !== b.kind)
43
- return false;
44
- if (a.kind === 'entity' && b.kind === 'entity')
45
- return a.entityId === b.entityId;
46
- if (a.kind === 'group' && b.kind === 'group') {
47
- return a.groupId === b.groupId && a.role === b.role;
48
- }
49
- return false;
48
+ const parts = granteeParts(a);
49
+ return parts !== undefined && JSON.stringify(parts) === JSON.stringify(granteeParts(b));
50
+ }
51
+ /** A target's identity, per arm — an absent `stackUrl` is this stack, as an empty one is. */
52
+ function targetParts(t) {
53
+ if (t?.kind === 'record')
54
+ return [t.kind, t.recordId, t.stackUrl ?? ''];
55
+ if (t?.kind === 'entity')
56
+ return [t.kind, t.entityId];
57
+ if (t?.kind === 'external')
58
+ return [t.kind, t.ns, t.id];
59
+ return undefined;
50
60
  }
51
- /** Structural equality per target arm — what dissociate() matches on. */
61
+ /** Structural equality per target arm — what a remove edit matches on. */
52
62
  export function targetEqual(a, b) {
53
- if (a.kind !== b.kind)
54
- return false;
55
- if (a.kind === 'record' && b.kind === 'record') {
56
- return a.recordId === b.recordId && (a.stackUrl ?? '') === (b.stackUrl ?? '');
57
- }
58
- if (a.kind === 'entity' && b.kind === 'entity')
59
- return a.entityId === b.entityId;
60
- if (a.kind === 'external' && b.kind === 'external')
61
- return a.ns === b.ns && a.id === b.id;
62
- return false;
63
+ const parts = targetParts(a);
64
+ return parts !== undefined && JSON.stringify(parts) === JSON.stringify(targetParts(b));
63
65
  }
64
66
  /**
65
67
  * Identity plus every annotation outside it, so a write that only re-points
@@ -87,39 +89,25 @@ function stripAssociationAnnotation(association) {
87
89
  const { attachmentRecordId: _attachmentRecordId, ...identity } = association;
88
90
  return identity;
89
91
  }
90
- /**
91
- * The association kinds that carry authority. Every other kind is data.
92
- * Storage that partitions by kind in a query reads this list rather than
93
- * restating it, so a new authority kind can't fall into the data half.
94
- */
95
- export const AUTHORITY_ASSOCIATION_KINDS = [
92
+ /** The association kinds that carry authority. Every other kind is data. */
93
+ const AUTHORITY_ASSOCIATION_KINDS = [
96
94
  'permission',
97
95
  'anyone',
98
96
  ];
99
97
  /**
100
98
  * Whether an association carries authority rather than data — the partition
101
99
  * `StackRecord.permissions` and `StackRecord.associations` project, and the
102
- * line `associate()`/`dissociate()` refuse to cross.
100
+ * line the association verbs refuse to cross.
103
101
  * See docs/spec/access-control.md § Record-level permissions.
104
102
  */
105
103
  export function isAuthorityAssociation(a) {
106
104
  return AUTHORITY_ASSOCIATION_KINDS.includes(a.kind);
107
105
  }
108
106
  /**
109
- * One stored association set split into the two the record presents. An app
110
- * editing tags never sees the authority half, so it cannot drop it.
111
- */
112
- export function partitionAssociations(associations) {
113
- return {
114
- associations: associations.filter((a) => !isAuthorityAssociation(a)),
115
- permissions: associations.filter(isAuthorityAssociation),
116
- };
117
- }
118
- /**
119
- * What a `changes.associations` list moves against a record's current set,
120
- * one tagged edit each. An entry matching an existing identity displaced it:
121
- * a `repoint`, carrying the prior association in full as `previous` — the
122
- * only place an overwritten `attachmentRecordId` survives.
107
+ * What replacing a record's set with `after` moves, one tagged edit each.
108
+ * An entry matching an existing identity displaced it: a `repoint`,
109
+ * carrying the prior association in full as `previous` — the only place
110
+ * an overwritten `attachmentRecordId` survives.
123
111
  * See docs/spec/journal.md § The entry.
124
112
  */
125
113
  export function associationDelta(before, after) {
@@ -135,6 +123,13 @@ export function associationDelta(before, after) {
135
123
  .filter((b) => !after.some((a) => associationEqual(a, b)))
136
124
  .map((association) => ({ op: 'remove', association })));
137
125
  }
126
+ /**
127
+ * Whether two sets hold the same elements, annotations included, in any
128
+ * order — what an element-set write's `expectSet` is compared by.
129
+ */
130
+ export function sameAssociationSet(a, b) {
131
+ return associationDelta(a, b).length === 0;
132
+ }
138
133
  /**
139
134
  * The two flat lists a change frame carries, derived from the tagged list.
140
135
  * The feed reports what is true now, so a `repoint` appears only under its
@@ -157,24 +152,13 @@ export function feedAssociationDelta(changes) {
157
152
  }
158
153
  return { added, removed };
159
154
  }
160
- /**
161
- * An association edit list travels one surface: authority and data share
162
- * storage and a delta, and never share a call. Refused here so every
163
- * adapter inherits the same rule.
164
- * See docs/spec/access-control.md § Storage unifies; the API does not.
165
- */
166
- export function assertOneSurface(changes) {
167
- const authority = changes.filter((c) => isAuthorityAssociation(c.association)).length;
168
- if (authority === 0 || authority === changes.length)
169
- return;
170
- throw new StackBadRequestError('An association edit list carries authority or data, never both: permission and anyone ' +
171
- 'elements travel on the permissions surface.');
155
+ /** The elements an edit list adds. */
156
+ export function addsOf(edits) {
157
+ return edits.flatMap((e) => (e.op === 'add' ? [e.association] : []));
172
158
  }
173
159
  /**
174
- * The set a list of edits leaves behind: removes first, then adds, an add
175
- * landing on an identity already held in place. Adds naming one identity
176
- * collapse, last wins; an add outlives a remove of the same identity.
177
- * See docs/spec/adapters.md § Amending associations.
160
+ * The set a list of edits leaves behind, an add landing on an identity
161
+ * already held in place. See docs/spec/adapters.md § Editing associations.
178
162
  */
179
163
  export function applyAssociationEdits(current, changes) {
180
164
  let next = current.filter((a) => !changes.some((c) => c.op === 'remove' && associationEqual(c.association, a)));
@@ -187,12 +171,4 @@ export function applyAssociationEdits(current, changes) {
187
171
  }
188
172
  return next;
189
173
  }
190
- /**
191
- * The same op over every element of a list — what associate(),
192
- * dissociate(), grantAccess() and revokeAccess() hand to the amend verb
193
- * each is one half of.
194
- */
195
- export function editsOf(op, associations) {
196
- return associations.map((association) => ({ op, association }));
197
- }
198
174
  //# sourceMappingURL=identity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/associations/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAWpD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAc,EAAE,CAAc;IAC7D,0DAA0D;IAC1D,uEAAuE;IACvE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAC3D,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CAAC;IACrF,IAAI,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QAC3D,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,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IAAI,gBAAgB,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CACrF,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,EAAE,KAAK,KAAK;YAAE,SAAS;QAC7B,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;YACzD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3E,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -56,7 +56,7 @@ export declare function granteeErrors(grantee: unknown, path: string, opts: {
56
56
  * Refuse an authority element on the data surface. The two halves share
57
57
  * storage but never a call, or an app editing tags could replace an ACL it
58
58
  * was never shown. Thrown, not collected: the caller named the wrong
59
- * surface, and wanted grantAccess()/revokeAccess().
59
+ * surface, and wanted editAccess()/setAccess().
60
60
  * See docs/spec/access-control.md § Record-level permissions.
61
61
  */
62
62
  export declare function assertDataAssociations(associations: readonly Association[], surface: string): asserts associations is DataAssociation[];
@@ -80,11 +80,4 @@ export declare function validateAssociations(associations: Association[] | undef
80
80
  * the journal's word, never a request. See docs/spec/data-model.md § Mutations.
81
81
  */
82
82
  export declare function assertAssociationEdits(changes: unknown, surface: string, half: 'data' | 'authority'): asserts changes is AssociationEdit[];
83
- /**
84
- * assertAssociationEdits() for the verbs taking a bare list — associate(),
85
- * grantAccess() and their inverses — asked before wrapping, so problems are
86
- * reported under `param`, the name the caller used. Same order of checks,
87
- * so a wrong-surface element is refused as such before duplicates count.
88
- */
89
- export declare function assertAssociationList(associations: unknown, surface: string, param: string, half: 'data' | 'authority'): asserts associations is Association[];
90
83
  //# sourceMappingURL=validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/associations/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAEV,WAAW,EACX,eAAe,EAEf,oBAAoB,EACpB,eAAe,EAGf,YAAY,EAKZ,kBAAkB,EAClB,yBAAyB,EAE1B,MAAM,mBAAmB,CAAC;AAY3B,sDAAsD;AACtD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAI7E,CAAC;AAgBF,qEAAqE;AACrE,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAIxE,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAE5E;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAM1F;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GAAG,yBAAyB,EACtD,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC1C,eAAe,EAAE,CAyBnB;AAmBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,IAAI,SAAgB,GACnB,eAAe,EAAE,CAoBnB;AAmCD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IAAE,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GACrF,eAAe,EAAE,CA+CnB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,SAAS,WAAW,EAAE,EACpC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,IAAI,eAAe,EAAE,CAO3C;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,SAAS,WAAW,EAAE,EACnC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,IAAI,oBAAoB,EAAE,CAO/C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,WAAW,EAAE,GAAG,SAAS,EACvC,IAAI,SAAiB,GACpB,eAAe,EAAE,CAMnB;AAgBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAAG,WAAW,GACzB,OAAO,CAAC,OAAO,IAAI,eAAe,EAAE,CAoCtC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,OAAO,EACrB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GAAG,WAAW,GACzB,OAAO,CAAC,YAAY,IAAI,WAAW,EAAE,CAoBvC"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/associations/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAEV,WAAW,EACX,eAAe,EAE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,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,IAAI,eAAe,EAAE,CAO3C;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,SAAS,WAAW,EAAE,EACnC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,IAAI,oBAAoB,EAAE,CAO/C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,WAAW,EAAE,GAAG,SAAS,EACvC,IAAI,SAAiB,GACpB,eAAe,EAAE,CAMnB;AAgBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAAG,WAAW,GACzB,OAAO,CAAC,OAAO,IAAI,eAAe,EAAE,CAoCtC"}
@@ -220,7 +220,7 @@ export function granteeErrors(grantee, path, opts) {
220
220
  * Refuse an authority element on the data surface. The two halves share
221
221
  * storage but never a call, or an app editing tags could replace an ACL it
222
222
  * was never shown. Thrown, not collected: the caller named the wrong
223
- * surface, and wanted grantAccess()/revokeAccess().
223
+ * surface, and wanted editAccess()/setAccess().
224
224
  * See docs/spec/access-control.md § Record-level permissions.
225
225
  */
226
226
  export function assertDataAssociations(associations, surface) {
@@ -228,7 +228,7 @@ export function assertDataAssociations(associations, surface) {
228
228
  if (!authority)
229
229
  return;
230
230
  throw new StackBadRequestError(`${surface} does not carry authority: a "${authority.kind}" association belongs to the ` +
231
- '`permissions` surface — use grantAccess()/revokeAccess(), or the `permissions` change-set key.');
231
+ '`permissions` surface — use editAccess() or setAccess().');
232
232
  }
233
233
  /**
234
234
  * The mirror of assertDataAssociations(): the `permissions` surface takes
@@ -240,7 +240,7 @@ export function assertAuthorityAssociations(permissions, surface) {
240
240
  if (!data)
241
241
  return;
242
242
  throw new StackBadRequestError(`${surface} carries authority alone: a "${data.kind}" association belongs to the ` +
243
- '`associations` surface — use associate()/dissociate(), or the `associations` change-set key.');
243
+ '`associations` surface — use editAssociations() or setAssociations().');
244
244
  }
245
245
  /**
246
246
  * Every association in a list, plus the list's own rule: identities are
@@ -309,31 +309,4 @@ export function assertAssociationEdits(changes, surface, half) {
309
309
  if (duplicates.length > 0)
310
310
  throw new StackValidationError(duplicates, ARGUMENTS_INVALID);
311
311
  }
312
- /**
313
- * assertAssociationEdits() for the verbs taking a bare list — associate(),
314
- * grantAccess() and their inverses — asked before wrapping, so problems are
315
- * reported under `param`, the name the caller used. Same order of checks,
316
- * so a wrong-surface element is refused as such before duplicates count.
317
- */
318
- export function assertAssociationList(associations, surface, param, half) {
319
- if (!Array.isArray(associations) || associations.length === 0) {
320
- throw new StackValidationError([{ path: param, message: `${surface} names at least one association.` }], ARGUMENTS_INVALID);
321
- }
322
- const errors = associations.flatMap((raw, i) => typeof raw === 'object' && raw !== null && !Array.isArray(raw)
323
- ? []
324
- : [{ path: `${param}[${i}]`, message: `${param}[${i}] must be an object.` }]);
325
- if (errors.length > 0)
326
- throw new StackValidationError(errors, ARGUMENTS_INVALID);
327
- const list = associations;
328
- const shapeErrors = list.flatMap((a, i) => validateAssociation(a, `${param}[${i}]`));
329
- if (shapeErrors.length > 0)
330
- throw new StackValidationError(shapeErrors, ARGUMENTS_INVALID);
331
- if (half === 'data')
332
- assertDataAssociations(list, surface);
333
- else
334
- assertAuthorityAssociations(list, surface);
335
- const listErrors = validateAssociations(list, param);
336
- if (listErrors.length > 0)
337
- throw new StackValidationError(listErrors, ARGUMENTS_INVALID);
338
- }
339
312
  //# sourceMappingURL=validation.js.map