@haverstack/core 0.37.0 → 0.39.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.
- package/README.md +19 -15
- package/dist/access.d.ts +4 -6
- package/dist/access.d.ts.map +1 -1
- package/dist/access.js +7 -8
- package/dist/access.js.map +1 -1
- package/dist/adapter-entry.d.ts +7 -6
- package/dist/adapter-entry.d.ts.map +1 -1
- package/dist/adapter-entry.js +6 -5
- package/dist/adapter-entry.js.map +1 -1
- package/dist/attachment-download.d.ts +3 -1
- package/dist/attachment-download.d.ts.map +1 -1
- package/dist/attachment-download.js +1 -1
- package/dist/attachment-download.js.map +1 -1
- package/dist/changes.d.ts +22 -16
- package/dist/changes.d.ts.map +1 -1
- package/dist/changes.js +43 -32
- package/dist/changes.js.map +1 -1
- package/dist/combine.d.ts +1 -1
- package/dist/combine.js +6 -6
- package/dist/combine.js.map +1 -1
- package/dist/errors.d.ts +24 -12
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +32 -17
- package/dist/errors.js.map +1 -1
- package/dist/grants.d.ts +17 -25
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +27 -14
- package/dist/grants.js.map +1 -1
- package/dist/identity-bindings.js +2 -2
- package/dist/index.d.ts +12 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/query-validation.d.ts +28 -11
- package/dist/query-validation.d.ts.map +1 -1
- package/dist/query-validation.js +95 -36
- package/dist/query-validation.js.map +1 -1
- package/dist/record-changes.d.ts +11 -10
- package/dist/record-changes.d.ts.map +1 -1
- package/dist/record-changes.js +33 -25
- package/dist/record-changes.js.map +1 -1
- package/dist/record-id.d.ts +3 -3
- package/dist/record-id.js +8 -8
- package/dist/record-id.js.map +1 -1
- package/dist/scoped-stack.d.ts +71 -34
- package/dist/scoped-stack.d.ts.map +1 -1
- package/dist/scoped-stack.js +107 -88
- package/dist/scoped-stack.js.map +1 -1
- package/dist/stack-reads.d.ts +2 -2
- package/dist/stack-reads.js +5 -5
- package/dist/stack-reads.js.map +1 -1
- package/dist/stack.d.ts +132 -161
- package/dist/stack.d.ts.map +1 -1
- package/dist/stack.js +287 -288
- package/dist/stack.js.map +1 -1
- package/dist/testing.d.ts +17 -17
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +46 -42
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +169 -143
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/dist/wire-body.d.ts +71 -0
- package/dist/wire-body.d.ts.map +1 -0
- package/dist/wire-body.js +138 -0
- package/dist/wire-body.js.map +1 -0
- package/dist/wire-entry.d.ts +9 -8
- package/dist/wire-entry.d.ts.map +1 -1
- package/dist/wire-entry.js +13 -14
- package/dist/wire-entry.js.map +1 -1
- package/dist/wire-record.d.ts +4 -4
- package/dist/wire-record.d.ts.map +1 -1
- package/dist/wire-record.js +35 -22
- package/dist/wire-record.js.map +1 -1
- package/dist/wire-request.d.ts +37 -4
- package/dist/wire-request.d.ts.map +1 -1
- package/dist/wire-request.js +288 -79
- package/dist/wire-request.js.map +1 -1
- package/package.json +1 -1
package/dist/combine.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Use this when you want different backends for records and blobs, e.g.:
|
|
4
4
|
*
|
|
5
5
|
* const adapter = combineAdapters({ record: sqliteAdapter, blob: s3Adapter });
|
|
6
|
-
* const stack = await Stack.
|
|
6
|
+
* const stack = await Stack.open(adapter);
|
|
7
7
|
*/
|
|
8
8
|
export function combineAdapters(parts) {
|
|
9
9
|
return {
|
|
@@ -50,11 +50,11 @@ export function combineAdapters(parts) {
|
|
|
50
50
|
// synthesized here: glued backends have no shared transaction to honor
|
|
51
51
|
// its atomicity promise (docs/spec/adapters.md § Interface split).
|
|
52
52
|
// Stack.putAttachment() falls back to bytes-then-create().
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
...(parts.blob.
|
|
57
|
-
|
|
53
|
+
putBlob: (data) => parts.blob.putBlob(data),
|
|
54
|
+
getBlob: (id) => parts.blob.getBlob(id),
|
|
55
|
+
deleteBlob: (id) => parts.blob.deleteBlob(id),
|
|
56
|
+
...(parts.blob.listBlobs && {
|
|
57
|
+
listBlobs: () => parts.blob.listBlobs(),
|
|
58
58
|
}),
|
|
59
59
|
async flush() {
|
|
60
60
|
await parts.record.flush?.();
|
package/dist/combine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combine.js","sourceRoot":"","sources":["../src/combine.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAG/B;IACC,OAAO;QACL,IAAI,YAAY;YACd,OAAO,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;QACnC,CAAC;QACD,IAAI,aAAa;YACf,OAAO,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;QACpC,CAAC;QACD,IAAI,QAAQ;YACV,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC/B,CAAC;QAED,YAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC;QAC7D,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7C,YAAY,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC;QACjF,YAAY,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC;QAC/D,cAAc,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,C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I,EAAE,OAAO,CAAC;SAChD,CAAC;QAEF,+DAA+D;QAC/D,uEAAuE;QACvE,mEAAmE;QACnE,2DAA2D;QAC3D,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAC3C,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7C,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI;YAC1B,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAU,EAAE;SACzC,CAAC;QAEF,KAAK,CAAC,KAAK;YACT,MAAM,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;YAC7B,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QAC7B,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;YAC7B,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
* `instanceof StackError` — before serializing a wire body, and each
|
|
7
7
|
* subclass carries its wire discriminator as an instance `code`.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* InvalidDidError): they report a local
|
|
12
|
-
* topology, not a state a request can be
|
|
13
|
-
* with one.
|
|
9
|
+
* Several errors sit deliberately outside that root (UseAfterCloseError,
|
|
10
|
+
* InvalidAdapterError, RelayScopeError, and — in their own
|
|
11
|
+
* modules — IdGenerationError and InvalidDidError): they report a local
|
|
12
|
+
* programming error or an assembled topology, not a state a request can be
|
|
13
|
+
* in, so no server ever responds with one.
|
|
14
|
+
*
|
|
15
|
+
* The `Stack` prefix is reserved for the taxonomy: a class named
|
|
16
|
+
* `Stack…Error` extends StackError, and nothing else carries the prefix.
|
|
14
17
|
*/
|
|
15
18
|
import type { SchemaDriftViolation } from './schema.js';
|
|
16
19
|
import type { ValidationError } from './validate.js';
|
|
@@ -25,8 +28,8 @@ export type StackErrorCode = 'bad_request' | 'permission' | 'not_found' | 'confl
|
|
|
25
28
|
/**
|
|
26
29
|
* Root of the Stack error taxonomy. A single `instanceof StackError` answers
|
|
27
30
|
* "is this a Stack-domain error or a bug?" — the question a server's error
|
|
28
|
-
* middleware asks before serializing a wire body, and one
|
|
29
|
-
*
|
|
31
|
+
* middleware asks before serializing a wire body, and one an instanceof
|
|
32
|
+
* ladder answers only by exhaustion. Every subclass carries its
|
|
30
33
|
* discriminator as an instance `code`, so serialization is a lookup rather
|
|
31
34
|
* than a chain of class tests.
|
|
32
35
|
*
|
|
@@ -96,7 +99,7 @@ export declare class StackVersionConflictError extends StackError {
|
|
|
96
99
|
* request whose *type* is undefined never addressed a record, so answering
|
|
97
100
|
* 404 would say a record was missing when none was asked for.
|
|
98
101
|
*/
|
|
99
|
-
export declare class
|
|
102
|
+
export declare class StackBadRequestError extends StackError {
|
|
100
103
|
/**
|
|
101
104
|
* Which declared capability the query asked for and the adapter lacks,
|
|
102
105
|
* or undefined when the query's own shape is what was wrong — a
|
|
@@ -140,7 +143,7 @@ export declare class StackPayloadTooLargeError extends StackError {
|
|
|
140
143
|
* there is nothing to interrupt from inside the call. It exists so a
|
|
141
144
|
* server that bounds query time has a class to serialize, and so the app
|
|
142
145
|
* catching it can tell "too expensive, narrow it and retry" from
|
|
143
|
-
*
|
|
146
|
+
* StackBadRequestError's "malformed, don't bother retrying" — the distinction
|
|
144
147
|
* that would be lost if a timeout reused `bad_request`.
|
|
145
148
|
*/
|
|
146
149
|
export declare class StackTimeoutError extends StackError {
|
|
@@ -168,13 +171,22 @@ export declare class StackSchemaDriftError extends StackError {
|
|
|
168
171
|
* error with no wire representation — no server ever responds with it.
|
|
169
172
|
* See docs/spec/adapters.md § Lifecycle.
|
|
170
173
|
*/
|
|
171
|
-
export declare class
|
|
174
|
+
export declare class UseAfterCloseError extends Error {
|
|
172
175
|
constructor(message?: string);
|
|
173
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Thrown when Stack.open() is handed an adapter that cannot back a stack.
|
|
179
|
+
* Outside the StackError taxonomy for the same reason UseAfterCloseError is:
|
|
180
|
+
* it reports a local setup mistake, not a state a request can be in.
|
|
181
|
+
* See docs/spec.md § Stack initialization.
|
|
182
|
+
*/
|
|
183
|
+
export declare class InvalidAdapterError extends Error {
|
|
184
|
+
constructor(message: string);
|
|
185
|
+
}
|
|
174
186
|
/**
|
|
175
187
|
* Thrown when a scoped view is asked to observe a stack whose adapter
|
|
176
188
|
* relays a remote feed. Outside the StackError taxonomy for the same
|
|
177
|
-
* reason
|
|
189
|
+
* reason UseAfterCloseError is: it reports a topology the caller assembled,
|
|
178
190
|
* not a state a request can be in.
|
|
179
191
|
*
|
|
180
192
|
* A relayed frame is scoped by the authority that opened the feed, and a
|
|
@@ -185,7 +197,7 @@ export declare class StackClosedError extends Error {
|
|
|
185
197
|
* failure that looks fine in testing. So it refuses.
|
|
186
198
|
* See docs/spec/events.md § Permission scoping.
|
|
187
199
|
*/
|
|
188
|
-
export declare class
|
|
200
|
+
export declare class RelayScopeError extends Error {
|
|
189
201
|
constructor(message: string);
|
|
190
202
|
}
|
|
191
203
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;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C,SAAkB,IAAI,iBAA8B;gBAElC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,oBAAoB,EAAE;CAUrD;AAED;;;;;;GAMG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,SAAgC;CAIpD;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
CHANGED
|
@@ -6,18 +6,21 @@
|
|
|
6
6
|
* `instanceof StackError` — before serializing a wire body, and each
|
|
7
7
|
* subclass carries its wire discriminator as an instance `code`.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* InvalidDidError): they report a local
|
|
12
|
-
* topology, not a state a request can be
|
|
13
|
-
* with one.
|
|
9
|
+
* Several errors sit deliberately outside that root (UseAfterCloseError,
|
|
10
|
+
* InvalidAdapterError, RelayScopeError, and — in their own
|
|
11
|
+
* modules — IdGenerationError and InvalidDidError): they report a local
|
|
12
|
+
* programming error or an assembled topology, not a state a request can be
|
|
13
|
+
* in, so no server ever responds with one.
|
|
14
|
+
*
|
|
15
|
+
* The `Stack` prefix is reserved for the taxonomy: a class named
|
|
16
|
+
* `Stack…Error` extends StackError, and nothing else carries the prefix.
|
|
14
17
|
*/
|
|
15
18
|
import { baseIdOf, parseTypeId } from './schema.js';
|
|
16
19
|
/**
|
|
17
20
|
* Root of the Stack error taxonomy. A single `instanceof StackError` answers
|
|
18
21
|
* "is this a Stack-domain error or a bug?" — the question a server's error
|
|
19
|
-
* middleware asks before serializing a wire body, and one
|
|
20
|
-
*
|
|
22
|
+
* middleware asks before serializing a wire body, and one an instanceof
|
|
23
|
+
* ladder answers only by exhaustion. Every subclass carries its
|
|
21
24
|
* discriminator as an instance `code`, so serialization is a lookup rather
|
|
22
25
|
* than a chain of class tests.
|
|
23
26
|
*
|
|
@@ -108,10 +111,10 @@ export class StackVersionConflictError extends StackError {
|
|
|
108
111
|
* request whose *type* is undefined never addressed a record, so answering
|
|
109
112
|
* 404 would say a record was missing when none was asked for.
|
|
110
113
|
*/
|
|
111
|
-
export class
|
|
114
|
+
export class StackBadRequestError extends StackError {
|
|
112
115
|
capability;
|
|
113
116
|
static code = 'bad_request';
|
|
114
|
-
code =
|
|
117
|
+
code = StackBadRequestError.code;
|
|
115
118
|
constructor(message,
|
|
116
119
|
/**
|
|
117
120
|
* Which declared capability the query asked for and the adapter lacks,
|
|
@@ -124,7 +127,7 @@ export class StackQueryError extends StackError {
|
|
|
124
127
|
capability) {
|
|
125
128
|
super(message);
|
|
126
129
|
this.capability = capability;
|
|
127
|
-
this.name = '
|
|
130
|
+
this.name = 'StackBadRequestError';
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
/**
|
|
@@ -151,7 +154,7 @@ export class StackPayloadTooLargeError extends StackError {
|
|
|
151
154
|
* there is nothing to interrupt from inside the call. It exists so a
|
|
152
155
|
* server that bounds query time has a class to serialize, and so the app
|
|
153
156
|
* catching it can tell "too expensive, narrow it and retry" from
|
|
154
|
-
*
|
|
157
|
+
* StackBadRequestError's "malformed, don't bother retrying" — the distinction
|
|
155
158
|
* that would be lost if a timeout reused `bad_request`.
|
|
156
159
|
*/
|
|
157
160
|
export class StackTimeoutError extends StackError {
|
|
@@ -176,7 +179,7 @@ export class StackSchemaDriftError extends StackError {
|
|
|
176
179
|
constructor(typeId, violations) {
|
|
177
180
|
super(`Schema drift detected for type "${typeId}": the stored schema and the new definition ` +
|
|
178
181
|
`differ beyond additive evolution (new optional fields only). Bump the version instead ` +
|
|
179
|
-
`of redefining "${typeId}" in place — e.g. defineType(\`${baseIdOf(typeId)}@${(parseTypeId(typeId)?.version ?? 0) + 1}\`, ...) plus registerMigration().\n` +
|
|
182
|
+
`of redefining "${typeId}" in place — e.g. defineType({ id: \`${baseIdOf(typeId)}@${(parseTypeId(typeId)?.version ?? 0) + 1}\`, ... }) plus registerMigration().\n` +
|
|
180
183
|
violations.map((v) => ` ${v.path || '(root)'}: ${v.message}`).join('\n'));
|
|
181
184
|
this.typeId = typeId;
|
|
182
185
|
this.violations = violations;
|
|
@@ -190,16 +193,28 @@ export class StackSchemaDriftError extends StackError {
|
|
|
190
193
|
* error with no wire representation — no server ever responds with it.
|
|
191
194
|
* See docs/spec/adapters.md § Lifecycle.
|
|
192
195
|
*/
|
|
193
|
-
export class
|
|
196
|
+
export class UseAfterCloseError extends Error {
|
|
194
197
|
constructor(message = 'This Stack has been closed.') {
|
|
195
198
|
super(message);
|
|
196
|
-
this.name = '
|
|
199
|
+
this.name = 'UseAfterCloseError';
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Thrown when Stack.open() is handed an adapter that cannot back a stack.
|
|
204
|
+
* Outside the StackError taxonomy for the same reason UseAfterCloseError is:
|
|
205
|
+
* it reports a local setup mistake, not a state a request can be in.
|
|
206
|
+
* See docs/spec.md § Stack initialization.
|
|
207
|
+
*/
|
|
208
|
+
export class InvalidAdapterError extends Error {
|
|
209
|
+
constructor(message) {
|
|
210
|
+
super(message);
|
|
211
|
+
this.name = 'InvalidAdapterError';
|
|
197
212
|
}
|
|
198
213
|
}
|
|
199
214
|
/**
|
|
200
215
|
* Thrown when a scoped view is asked to observe a stack whose adapter
|
|
201
216
|
* relays a remote feed. Outside the StackError taxonomy for the same
|
|
202
|
-
* reason
|
|
217
|
+
* reason UseAfterCloseError is: it reports a topology the caller assembled,
|
|
203
218
|
* not a state a request can be in.
|
|
204
219
|
*
|
|
205
220
|
* A relayed frame is scoped by the authority that opened the feed, and a
|
|
@@ -210,10 +225,10 @@ export class StackClosedError extends Error {
|
|
|
210
225
|
* failure that looks fine in testing. So it refuses.
|
|
211
226
|
* See docs/spec/events.md § Permission scoping.
|
|
212
227
|
*/
|
|
213
|
-
export class
|
|
228
|
+
export class RelayScopeError extends Error {
|
|
214
229
|
constructor(message) {
|
|
215
230
|
super(message);
|
|
216
|
-
this.name = '
|
|
231
|
+
this.name = 'RelayScopeError';
|
|
217
232
|
}
|
|
218
233
|
}
|
|
219
234
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAuBpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAgB,UAAW,SAAQ,KAAK;CAE7C;AAED,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAGtB;IAF5B,MAAM,CAAU,IAAI,GAAG,YAAqB,CAAC;IAC3B,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC;IACnD,YAA4B,MAAyB;QACnD,KAAK,CACH,8BAA8B,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAC3F,CAAC;QAHwB,WAAM,GAAN,MAAM,CAAmB;QAInD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;;AAGH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IACjD,MAAM,CAAU,IAAI,GAAG,WAAoB,CAAC;IAC1B,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;;AAGH,iFAAiF;AACjF,MAAM,OAAO,oBAAqB,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,IAAI,QAAQ,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAC5E,CAAC;QARc,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAwB;QAQlD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;;AAGH;;;;;;GAMG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAO,GAAG,6BAA6B;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
|
package/dist/grants.d.ts
CHANGED
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
* -------------------------------------------------------
|
|
4
4
|
* What a `_grant` Record says, and who it says it about. The coverage
|
|
5
5
|
* question — does this grant reach this grantee — is answered here rather
|
|
6
|
-
* than at each call site so that the access checks and
|
|
6
|
+
* than at each call site so that the access checks and listTypeGrants() cannot
|
|
7
7
|
* drift apart about it.
|
|
8
8
|
*
|
|
9
9
|
* See docs/spec/access-control.md § Type-level grants.
|
|
10
10
|
*/
|
|
11
|
-
import type { GroupRole } from './
|
|
12
|
-
import type { EntityId, GrantAction, GrantContent, GrantGrantee, QueryResult, RecordId, StackQuery, StackRecord, TypeId } from './types.js';
|
|
11
|
+
import type { EntityId, GrantAction, GrantContent, GrantGrantee, GroupRole, QueryResult, RecordId, StackQuery, StackRecord, TypeId } from './types.js';
|
|
13
12
|
import type { ValidationError } from './validate.js';
|
|
14
13
|
/**
|
|
15
|
-
* Valid GrantAction values, for runtime validation in Stack.
|
|
14
|
+
* Valid GrantAction values, for runtime validation in Stack.grantType(). Built
|
|
16
15
|
* from GRANT_ACTIONS, which GrantAction itself derives from, so the set and
|
|
17
16
|
* the type cannot drift.
|
|
18
17
|
*/
|
|
@@ -51,30 +50,20 @@ export declare function grantReach(content: unknown): {
|
|
|
51
50
|
actions: GrantAction[];
|
|
52
51
|
} | null;
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
55
|
-
* stored grant carries, so a target is the grantee it writes.
|
|
56
|
-
* `{ kind: 'authenticated' }` is the default grant, and the default-only
|
|
57
|
-
* listing.
|
|
58
|
-
*/
|
|
59
|
-
export type GrantTarget = GrantGrantee;
|
|
60
|
-
/**
|
|
61
|
-
* What listGrants() accepts: a GrantTarget, widened so a group listing can
|
|
53
|
+
* What listTypeGrants() accepts: a GrantGrantee, widened so a group listing can
|
|
62
54
|
* ask for every role at once. `role: 'any'` is not a role an entity can
|
|
63
55
|
* hold and never reaches storage — a query can say it, a grantee cannot.
|
|
64
56
|
*/
|
|
65
|
-
export type GrantQuery = {
|
|
66
|
-
kind: '
|
|
67
|
-
|
|
68
|
-
} | {
|
|
57
|
+
export type GrantQuery = Exclude<GrantGrantee, {
|
|
58
|
+
kind: 'group';
|
|
59
|
+
}> | {
|
|
69
60
|
kind: 'group';
|
|
70
61
|
groupId: RecordId;
|
|
71
|
-
role:
|
|
72
|
-
} | {
|
|
73
|
-
kind: 'authenticated';
|
|
62
|
+
role: GroupRole | 'any';
|
|
74
63
|
};
|
|
75
64
|
/**
|
|
76
65
|
* Direct (non-roster) match between a stored _grant's content and a target:
|
|
77
|
-
* the whole grantee, `role` included. A target is the identity
|
|
66
|
+
* the whole grantee, `role` included. A target is the identity grantType()
|
|
78
67
|
* wrote, so a revoke aimed at a group's admins leaves the members' grant
|
|
79
68
|
* standing. A query's `role: 'any'` is the one widening, and it is spelled.
|
|
80
69
|
*/
|
|
@@ -84,8 +73,9 @@ export declare function matchesGrantTarget(content: GrantContent, target: GrantQ
|
|
|
84
73
|
* empty groupId or entityId reaches no one, so storing it would leave a
|
|
85
74
|
* grant that can only ever deny while looking like a share that worked.
|
|
86
75
|
* Read as data, not as the type: a target reaching Stack from a request
|
|
87
|
-
* body or an import has whatever shape it arrived with
|
|
88
|
-
*
|
|
76
|
+
* body or an import has whatever shape it arrived with, so a key its tier
|
|
77
|
+
* does not define is refused too. `allowAny` admits
|
|
78
|
+
* the listing-only `role: 'any'`, which grantType() and revokeType() refuse.
|
|
89
79
|
*/
|
|
90
80
|
export declare function validateGrantTarget(target: GrantQuery, allowAny?: boolean): void;
|
|
91
81
|
/**
|
|
@@ -109,7 +99,7 @@ export declare function grantCoversGrantee(c: GrantContent, grantee: EntityId, o
|
|
|
109
99
|
resolveRecord: (id: RecordId) => Promise<StackRecord | null>;
|
|
110
100
|
}): Promise<boolean>;
|
|
111
101
|
/**
|
|
112
|
-
* System type families
|
|
102
|
+
* System type families grantType() refuses to target: a grant on any of them
|
|
113
103
|
* would let the grantee mint their own grants, touch stack config, or
|
|
114
104
|
* register an app card claiming a DID that isn't theirs — the last of which
|
|
115
105
|
* is what verified app attribution rests on.
|
|
@@ -122,8 +112,10 @@ export declare const UNGRANTABLE_SYSTEM_TYPES: ReadonlySet<string>;
|
|
|
122
112
|
*
|
|
123
113
|
* `includeUnlisted`, because withholding a Record from enumeration decides
|
|
124
114
|
* nothing about what it confers. Deleted grants are excluded on the
|
|
125
|
-
* opposite grounds — a soft delete is how
|
|
115
|
+
* opposite grounds — a soft delete is how revokeType() withdraws one.
|
|
126
116
|
* See docs/spec/unlisted.md.
|
|
127
117
|
*/
|
|
128
|
-
export declare function loadGrantRecords(query: (q: StackQuery) => Promise<QueryResult>): Promise<StackRecord
|
|
118
|
+
export declare function loadGrantRecords(query: (q: StackQuery) => Promise<QueryResult>): Promise<(StackRecord & {
|
|
119
|
+
content: GrantContent;
|
|
120
|
+
})[]>;
|
|
129
121
|
//# sourceMappingURL=grants.d.ts.map
|
package/dist/grants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,MAAM,EACP,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,WAAW,CAA0B,CAAC;AAEjF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,WAAW,EAAE,SAAS,WAAW,EAAE,CAK3E,CAAC;AAEH;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAI1F;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,GAAG,IAAI,CAShG;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,GACxC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,SAAS,GAAG,KAAK,CAAA;CAAE,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CASrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,UAAQ,GAAG,IAAI,CA+B9E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe,EAAE,CAkDnF;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,CAAC,EAAE,YAAY,EACf,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE;IACJ,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC;IAC1C,aAAa,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC9D,GACA,OAAO,CAAC,OAAO,CAAC,CAuBlB;AAwBD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,MAAM,CAIvD,CAAC;AAEH;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO,CAAC,WAAW,CAAC,GAC7C,OAAO,CAAC,CAAC,WAAW,GAAG;IAAE,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC,EAAE,CAAC,CAKtD"}
|
package/dist/grants.js
CHANGED
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
* -------------------------------------------------------
|
|
4
4
|
* What a `_grant` Record says, and who it says it about. The coverage
|
|
5
5
|
* question — does this grant reach this grantee — is answered here rather
|
|
6
|
-
* than at each call site so that the access checks and
|
|
6
|
+
* than at each call site so that the access checks and listTypeGrants() cannot
|
|
7
7
|
* drift apart about it.
|
|
8
8
|
*
|
|
9
9
|
* See docs/spec/access-control.md § Type-level grants.
|
|
10
10
|
*/
|
|
11
11
|
import { baseIdOf } from './schema.js';
|
|
12
|
-
import {
|
|
12
|
+
import { StackBadRequestError } from './errors.js';
|
|
13
|
+
import { assertKnownKeys, GRANTEE_KEYS, unknownKeys } from './query-validation.js';
|
|
13
14
|
import { SYSTEM_TYPES, GRANT_ACTIONS } from './types.js';
|
|
14
15
|
import { carriesRoster, groupRoleFromAssociations } from './access.js';
|
|
15
16
|
import { queryAllPages } from './stack-reads.js';
|
|
16
17
|
/**
|
|
17
|
-
* Valid GrantAction values, for runtime validation in Stack.
|
|
18
|
+
* Valid GrantAction values, for runtime validation in Stack.grantType(). Built
|
|
18
19
|
* from GRANT_ACTIONS, which GrantAction itself derives from, so the set and
|
|
19
20
|
* the type cannot drift.
|
|
20
21
|
*/
|
|
@@ -73,7 +74,7 @@ export function grantReach(content) {
|
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
76
|
* Direct (non-roster) match between a stored _grant's content and a target:
|
|
76
|
-
* the whole grantee, `role` included. A target is the identity
|
|
77
|
+
* the whole grantee, `role` included. A target is the identity grantType()
|
|
77
78
|
* wrote, so a revoke aimed at a group's admins leaves the members' grant
|
|
78
79
|
* standing. A query's `role: 'any'` is the one widening, and it is spelled.
|
|
79
80
|
*/
|
|
@@ -94,25 +95,28 @@ export function matchesGrantTarget(content, target) {
|
|
|
94
95
|
* empty groupId or entityId reaches no one, so storing it would leave a
|
|
95
96
|
* grant that can only ever deny while looking like a share that worked.
|
|
96
97
|
* Read as data, not as the type: a target reaching Stack from a request
|
|
97
|
-
* body or an import has whatever shape it arrived with
|
|
98
|
-
*
|
|
98
|
+
* body or an import has whatever shape it arrived with, so a key its tier
|
|
99
|
+
* does not define is refused too. `allowAny` admits
|
|
100
|
+
* the listing-only `role: 'any'`, which grantType() and revokeType() refuse.
|
|
99
101
|
*/
|
|
100
102
|
export function validateGrantTarget(target, allowAny = false) {
|
|
101
103
|
const t = target;
|
|
104
|
+
if (t?.kind === 'authenticated' || t?.kind === 'entity' || t?.kind === 'group')
|
|
105
|
+
assertKnownKeys(t, GRANTEE_KEYS[t.kind], 'grant target');
|
|
102
106
|
switch (t?.kind) {
|
|
103
107
|
case 'authenticated':
|
|
104
108
|
return;
|
|
105
109
|
case 'entity':
|
|
106
110
|
if (typeof t.entityId !== 'string' || t.entityId.length === 0) {
|
|
107
|
-
throw new
|
|
111
|
+
throw new StackBadRequestError('An entity grant target requires a non-empty entityId.');
|
|
108
112
|
}
|
|
109
113
|
return;
|
|
110
114
|
case 'group':
|
|
111
115
|
if (typeof t.groupId !== 'string' || t.groupId.length === 0) {
|
|
112
|
-
throw new
|
|
116
|
+
throw new StackBadRequestError('A group grant target requires a non-empty groupId.');
|
|
113
117
|
}
|
|
114
118
|
if (t.role !== 'member' && t.role !== 'admin' && !(allowAny && t.role === 'any')) {
|
|
115
|
-
throw new
|
|
119
|
+
throw new StackBadRequestError(allowAny
|
|
116
120
|
? "A group grant target requires role 'member', 'admin' or 'any'."
|
|
117
121
|
: "A group grant target requires role 'member' or 'admin'.");
|
|
118
122
|
}
|
|
@@ -120,7 +124,7 @@ export function validateGrantTarget(target, allowAny = false) {
|
|
|
120
124
|
// association's recordId. One that resolves to nothing simply denies.
|
|
121
125
|
return;
|
|
122
126
|
default:
|
|
123
|
-
throw new
|
|
127
|
+
throw new StackBadRequestError("A grant target must name its tier: { kind: 'entity' }, { kind: 'group' } or { kind: 'authenticated' }.");
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
/**
|
|
@@ -137,6 +141,14 @@ export function validateGrantee(typeId, content) {
|
|
|
137
141
|
// An absent or non-object grantee is the schema's to refuse, and it does.
|
|
138
142
|
if (!g || typeof g !== 'object')
|
|
139
143
|
return [];
|
|
144
|
+
if (g.kind === 'authenticated' || g.kind === 'entity' || g.kind === 'group') {
|
|
145
|
+
const unknown = unknownKeys(g, GRANTEE_KEYS[g.kind]);
|
|
146
|
+
if (unknown.length > 0)
|
|
147
|
+
return unknown.map((key) => ({
|
|
148
|
+
path: `grantee.${key}`,
|
|
149
|
+
message: `A ${String(g.kind)} grantee does not carry ${key}`,
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
140
152
|
switch (g.kind) {
|
|
141
153
|
case 'authenticated':
|
|
142
154
|
return [];
|
|
@@ -221,7 +233,7 @@ async function resolveGroupRoleMemoized(groupId, entityId, groupRoles, resolveRe
|
|
|
221
233
|
return role;
|
|
222
234
|
}
|
|
223
235
|
/**
|
|
224
|
-
* System type families
|
|
236
|
+
* System type families grantType() refuses to target: a grant on any of them
|
|
225
237
|
* would let the grantee mint their own grants, touch stack config, or
|
|
226
238
|
* register an app card claiming a DID that isn't theirs — the last of which
|
|
227
239
|
* is what verified app attribution rests on.
|
|
@@ -238,12 +250,13 @@ export const UNGRANTABLE_SYSTEM_TYPES = new Set([
|
|
|
238
250
|
*
|
|
239
251
|
* `includeUnlisted`, because withholding a Record from enumeration decides
|
|
240
252
|
* nothing about what it confers. Deleted grants are excluded on the
|
|
241
|
-
* opposite grounds — a soft delete is how
|
|
253
|
+
* opposite grounds — a soft delete is how revokeType() withdraws one.
|
|
242
254
|
* See docs/spec/unlisted.md.
|
|
243
255
|
*/
|
|
244
|
-
export function loadGrantRecords(query) {
|
|
245
|
-
|
|
256
|
+
export async function loadGrantRecords(query) {
|
|
257
|
+
const records = await queryAllPages(query, {
|
|
246
258
|
filter: { typeId: `${SYSTEM_TYPES.GRANT}@1`, includeUnlisted: true },
|
|
247
259
|
});
|
|
260
|
+
return records;
|
|
248
261
|
}
|
|
249
262
|
//# sourceMappingURL=grants.js.map
|
package/dist/grants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE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,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE;KACrE,CAAC,CAAC;IACH,OAAO,OAAsD,CAAC;AAChE,CAAC"}
|
|
@@ -20,8 +20,8 @@ const BINDING_FIELDS = new Map([
|
|
|
20
20
|
]);
|
|
21
21
|
/**
|
|
22
22
|
* The subset that is additionally unique per stack: the fields something
|
|
23
|
-
* resolves *by*.
|
|
24
|
-
* its `
|
|
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
25
|
* that lookup without a single answer — and ambiguity is all an
|
|
26
26
|
* impersonating card needs.
|
|
27
27
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -5,21 +5,25 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Exports the Stack class, the app/plugin-facing data types, and the
|
|
7
7
|
* general-purpose utilities every caller needs. Audience-specific surfaces
|
|
8
|
-
* live behind their own subpaths,
|
|
8
|
+
* live behind their own subpaths, and every export has exactly one home —
|
|
9
|
+
* nothing here is repeated in a subpath, or the reverse:
|
|
9
10
|
* ./did — key generation, custody and signing (did:key)
|
|
10
|
-
* ./wire — the auth handshake
|
|
11
|
-
* by both sides of a
|
|
11
|
+
* ./wire — the request encoding, auth handshake, token store and
|
|
12
|
+
* attachment-download policy shared by both sides of a
|
|
13
|
+
* client/server connection
|
|
12
14
|
* ./adapter — the interfaces a storage adapter implements
|
|
13
15
|
* ./testing — the in-memory MemoryAdapter for tests
|
|
14
|
-
* Storage adapters are published as separate packages
|
|
15
|
-
*
|
|
16
|
+
* Storage adapters are published as separate packages — adapter-local,
|
|
17
|
+
* adapter-api, record-adapter-sqlite, record-adapter-do-sqlite,
|
|
18
|
+
* blob-adapter-disk and blob-adapter-s3, all under @haverstack/.
|
|
16
19
|
*/
|
|
17
20
|
export { Stack } from './stack.js';
|
|
18
21
|
export { ScopedStack } from './scoped-stack.js';
|
|
19
|
-
export type { StackClient, CreateRecordOptions, BackdatableCreateRecordOptions, StackOptions, GetRecordOptions, DeleteRecordOptions, DeleteResult, DeleteAndReturnResult,
|
|
20
|
-
export { StackError, StackValidationError, StackMigrationError, StackPermissionError, StackNotFoundError, StackConflictError, StackVersionConflictError,
|
|
22
|
+
export type { StackClient, CreateRecordOptions, BackdatableCreateRecordOptions, StackOptions, DefineTypeOptions, GetRecordOptions, DeleteRecordOptions, DeleteResult, DeleteAndReturnResult, CollectAttachmentGarbageOptions, CollectAttachmentGarbageResult, } from './stack.js';
|
|
23
|
+
export { StackError, StackValidationError, StackMigrationError, StackPermissionError, StackNotFoundError, StackConflictError, StackVersionConflictError, StackBadRequestError, StackSchemaDriftError, StackPayloadTooLargeError, StackTimeoutError, } from './errors.js';
|
|
24
|
+
export { UseAfterCloseError, InvalidAdapterError, RelayScopeError } from './errors.js';
|
|
21
25
|
export type { StackErrorCode } from './errors.js';
|
|
22
|
-
export type { RecordId, TypeId, FileId, EntityId, AttachmentContent, StackRecord,
|
|
26
|
+
export type { RecordId, TypeId, BaseId, FileId, EntityId, AppId, AttachmentContent, StackRecord, RecordChangeSet, RecordVersion, RecordJournalEntry, JournalQuery, Actor, ActorOptions, ChangeKind, ChangeOp, ChangeActor, RecordChange, ChangeFilter, SubscribeOptions, Unsubscribe, StackType, TypeSchema, FieldDef, ScalarFieldDef, ArrayFieldDef, ObjectFieldDef, ScalarFieldKind, Association, TagAssociation, AttachmentAssociation, RelationshipAssociation, PermissionAssociation, Grantee, GroupRole, AnyoneAssociation, AuthorityAssociation, DataAssociation, AssociationChange, RelationshipTarget, RecordTarget, EntityTarget, ExternalTarget, StackQuery, RecordFilter, RelatedToFilter, AttachmentFilter, RelationshipTargetPattern, QuerySort, NativeSortField, QueryResult, DateRange, Migration, MigrationFn, StackCapabilities, ContentFilterReach, MissingCapability, IfVersionOptions, EntityContent, AppContent, GroupContent, GrantAction, GrantContent, GrantGrantee, TypeGrant, PutAttachmentOptions, ConfigContent, } from './types.js';
|
|
23
27
|
export type { GrantQuery } from './grants.js';
|
|
24
28
|
export { SYSTEM_TYPES, NATIVE_SORT_FIELDS } from './types.js';
|
|
25
29
|
export { generateId } from './id.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,8BAA8B,EAC9B,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,EACrB,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvF,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,YAAY,EACV,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,KAAK,EACL,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,UAAU,EACV,QAAQ,EACR,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,EACf,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,SAAS,EACT,eAAe,EACf,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAM9D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,20 +5,26 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Exports the Stack class, the app/plugin-facing data types, and the
|
|
7
7
|
* general-purpose utilities every caller needs. Audience-specific surfaces
|
|
8
|
-
* live behind their own subpaths,
|
|
8
|
+
* live behind their own subpaths, and every export has exactly one home —
|
|
9
|
+
* nothing here is repeated in a subpath, or the reverse:
|
|
9
10
|
* ./did — key generation, custody and signing (did:key)
|
|
10
|
-
* ./wire — the auth handshake
|
|
11
|
-
* by both sides of a
|
|
11
|
+
* ./wire — the request encoding, auth handshake, token store and
|
|
12
|
+
* attachment-download policy shared by both sides of a
|
|
13
|
+
* client/server connection
|
|
12
14
|
* ./adapter — the interfaces a storage adapter implements
|
|
13
15
|
* ./testing — the in-memory MemoryAdapter for tests
|
|
14
|
-
* Storage adapters are published as separate packages
|
|
15
|
-
*
|
|
16
|
+
* Storage adapters are published as separate packages — adapter-local,
|
|
17
|
+
* adapter-api, record-adapter-sqlite, record-adapter-do-sqlite,
|
|
18
|
+
* blob-adapter-disk and blob-adapter-s3, all under @haverstack/.
|
|
16
19
|
*/
|
|
17
20
|
// Core class and client interface
|
|
18
21
|
export { Stack } from './stack.js';
|
|
19
22
|
export { ScopedStack } from './scoped-stack.js';
|
|
20
23
|
// The error taxonomy
|
|
21
|
-
export { StackError, StackValidationError, StackMigrationError, StackPermissionError, StackNotFoundError, StackConflictError, StackVersionConflictError,
|
|
24
|
+
export { StackError, StackValidationError, StackMigrationError, StackPermissionError, StackNotFoundError, StackConflictError, StackVersionConflictError, StackBadRequestError, StackSchemaDriftError, StackPayloadTooLargeError, StackTimeoutError, } from './errors.js';
|
|
25
|
+
// Local errors outside the taxonomy — no wire representation, and no
|
|
26
|
+
// `Stack` prefix. See docs/spec/wire-format.md § The taxonomy root.
|
|
27
|
+
export { UseAfterCloseError, InvalidAdapterError, RelayScopeError } from './errors.js';
|
|
22
28
|
export { SYSTEM_TYPES, NATIVE_SORT_FIELDS } from './types.js';
|
|
23
29
|
// Utilities
|
|
24
30
|
// No in-repo caller: client-minted IDs are the default per spec, and an app
|