@haverstack/core 0.29.0 → 0.30.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/dist/adapter-entry.d.ts +1 -1
- package/dist/adapter-entry.d.ts.map +1 -1
- package/dist/adapter-entry.js +1 -1
- package/dist/adapter-entry.js.map +1 -1
- package/dist/changes.d.ts +14 -0
- package/dist/changes.d.ts.map +1 -1
- package/dist/changes.js +35 -0
- package/dist/changes.js.map +1 -1
- package/dist/errors.d.ts +173 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +208 -0
- package/dist/errors.js.map +1 -0
- package/dist/grants.d.ts +84 -0
- package/dist/grants.d.ts.map +1 -0
- package/dist/grants.js +157 -0
- package/dist/grants.js.map +1 -0
- package/dist/id.d.ts +7 -5
- package/dist/id.d.ts.map +1 -1
- package/dist/id.js +17 -15
- package/dist/id.js.map +1 -1
- package/dist/identity-bindings.d.ts +13 -0
- package/dist/identity-bindings.d.ts.map +1 -0
- package/dist/identity-bindings.js +42 -0
- package/dist/identity-bindings.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +23 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +35 -0
- package/dist/limits.js.map +1 -0
- package/dist/query-validation.d.ts +80 -0
- package/dist/query-validation.d.ts.map +1 -0
- package/dist/query-validation.js +223 -0
- package/dist/query-validation.js.map +1 -0
- package/dist/record-changes.d.ts +89 -0
- package/dist/record-changes.d.ts.map +1 -0
- package/dist/record-changes.js +201 -0
- package/dist/record-changes.js.map +1 -0
- package/dist/record-id.d.ts +70 -0
- package/dist/record-id.d.ts.map +1 -0
- package/dist/record-id.js +127 -0
- package/dist/record-id.js.map +1 -0
- package/dist/scoped-stack.d.ts +460 -0
- package/dist/scoped-stack.d.ts.map +1 -0
- package/dist/scoped-stack.js +1163 -0
- package/dist/scoped-stack.js.map +1 -0
- package/dist/stack-reads.d.ts +38 -0
- package/dist/stack-reads.d.ts.map +1 -0
- package/dist/stack-reads.js +79 -0
- package/dist/stack-reads.js.map +1 -0
- package/dist/stack.d.ts +37 -643
- package/dist/stack.d.ts.map +1 -1
- package/dist/stack.js +102 -2254
- package/dist/stack.js.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -1
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +9 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -1
- package/dist/wire-entry.d.ts +2 -2
- package/dist/wire-entry.d.ts.map +1 -1
- package/dist/wire-entry.js +2 -2
- package/dist/wire-entry.js.map +1 -1
- package/dist/wire-record.js +1 -1
- package/dist/wire-record.js.map +1 -1
- package/dist/wire-request.d.ts.map +1 -1
- package/dist/wire-request.js +3 -2
- package/dist/wire-request.js.map +1 -1
- package/package.json +1 -1
package/dist/adapter-entry.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export type { StackRecordAdapter, StackBlobAdapter, AdapterCapabilities, ContentFilterReach, BlobFileInfo, ExpectedVersionOptions, SubscribeChangesOptions, } from './types.js';
|
|
10
10
|
export { combineAdapters } from './combine.js';
|
|
11
|
-
export { assertQueryCapabilities, assertSortCapability, assertValidSort, assertValidRelatedTo, parseContentFilterKey, } from './
|
|
11
|
+
export { assertQueryCapabilities, assertSortCapability, assertValidSort, assertValidRelatedTo, parseContentFilterKey, } from './query-validation.js';
|
|
12
12
|
export { contentSortEntry, contentSortKey, compareSortEntries } from './sort.js';
|
|
13
13
|
export type { SortEntry } from './sort.js';
|
|
14
14
|
//# sourceMappingURL=adapter-entry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-entry.d.ts","sourceRoot":"","sources":["../src/adapter-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"adapter-entry.d.ts","sourceRoot":"","sources":["../src/adapter-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjF,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/adapter-entry.js
CHANGED
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
* reads `stack.features` instead of these directly.
|
|
8
8
|
*/
|
|
9
9
|
export { combineAdapters } from './combine.js';
|
|
10
|
-
export { assertQueryCapabilities, assertSortCapability, assertValidSort, assertValidRelatedTo, parseContentFilterKey, } from './
|
|
10
|
+
export { assertQueryCapabilities, assertSortCapability, assertValidSort, assertValidRelatedTo, parseContentFilterKey, } from './query-validation.js';
|
|
11
11
|
export { contentSortEntry, contentSortKey, compareSortEntries } from './sort.js';
|
|
12
12
|
//# sourceMappingURL=adapter-entry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-entry.js","sourceRoot":"","sources":["../src/adapter-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"adapter-entry.js","sourceRoot":"","sources":["../src/adapter-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/changes.d.ts
CHANGED
|
@@ -146,4 +146,18 @@ export declare class ChangeEmitter {
|
|
|
146
146
|
closeAll(): void;
|
|
147
147
|
}
|
|
148
148
|
export declare const CHANGE_KINDS: Record<ChangeOp, ChangeKind>;
|
|
149
|
+
/**
|
|
150
|
+
* `since` only means something where a relay exists: a stack with no
|
|
151
|
+
* third party whose writes could have been missed has no cursor it could
|
|
152
|
+
* ever have minted. Silently starting from the present would let the
|
|
153
|
+
* caller believe it resumed when it did not, so a stack that cannot honor
|
|
154
|
+
* `since` refuses it rather than ignoring it.
|
|
155
|
+
*
|
|
156
|
+
* Its shape is checked here rather than left to the adapter, so that a
|
|
157
|
+
* malformed cursor is the same error whoever is underneath — the posture
|
|
158
|
+
* query() already takes with a filter no adapter declared. The value stays
|
|
159
|
+
* opaque: this asks whether it is framable, never what it means. See
|
|
160
|
+
* docs/spec/events.md § Subscribing.
|
|
161
|
+
*/
|
|
162
|
+
export declare function assertSinceUsable(since: string | undefined, relaysChanges: boolean): void;
|
|
149
163
|
//# sourceMappingURL=changes.d.ts.map
|
package/dist/changes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changes.d.ts","sourceRoot":"","sources":["../src/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,WAAW,EACZ,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"changes.d.ts","sourceRoot":"","sources":["../src/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,WAAW,EACZ,MAAM,YAAY,CAAC;AAGpB;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrC;;;;OAIG;IACH,MAAM,EAAE,WAAW,CAAC;IACpB;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAKF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CA0BpF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,EAAE,OAAO,GAAG,OAAO,CAIjG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,GAAG,YAAY,CAItF;AAED;;;;;GAKG;AACH,8BAAsB,YAAY;IAI9B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI;IAC1D,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,gB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Y,KAAK,IAAI,EAAE,IAAI,EAAE,gBAAgB,GAAG,WAAW;IAIvF,sEAAsE;IACtE,QAAQ,IAAI,IAAI;CAIjB;AAmBD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,CAcrD,CAAC;AAUF;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CAgBzF"}
|
package/dist/changes.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
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 { StackQueryError } from './errors.js';
|
|
16
17
|
/** The `baseId@version` split, as grants and query filters read it. */
|
|
17
18
|
const baseIdOf = (typeId) => typeId.split('@')[0];
|
|
18
19
|
/**
|
|
@@ -321,4 +322,38 @@ export const CHANGE_KINDS = {
|
|
|
321
322
|
unlist: 'deleted',
|
|
322
323
|
reparent: 'changed',
|
|
323
324
|
};
|
|
325
|
+
/**
|
|
326
|
+
* A resume cursor is opaque, but not arbitrary: it travels in an SSE `id:`
|
|
327
|
+
* field, so a value spanning a line would truncate the frame carrying it.
|
|
328
|
+
* Same charset and same reason as the auth nonce — see
|
|
329
|
+
* docs/spec/change-feed.md § Frames.
|
|
330
|
+
*/
|
|
331
|
+
const SEQ_FORMAT = /^[A-Za-z0-9_-]+$/;
|
|
332
|
+
/**
|
|
333
|
+
* `since` only means something where a relay exists: a stack with no
|
|
334
|
+
* third party whose writes could have been missed has no cursor it could
|
|
335
|
+
* ever have minted. Silently starting from the present would let the
|
|
336
|
+
* caller believe it resumed when it did not, so a stack that cannot honor
|
|
337
|
+
* `since` refuses it rather than ignoring it.
|
|
338
|
+
*
|
|
339
|
+
* Its shape is checked here rather than left to the adapter, so that a
|
|
340
|
+
* malformed cursor is the same error whoever is underneath — the posture
|
|
341
|
+
* query() already takes with a filter no adapter declared. The value stays
|
|
342
|
+
* opaque: this asks whether it is framable, never what it means. See
|
|
343
|
+
* docs/spec/events.md § Subscribing.
|
|
344
|
+
*/
|
|
345
|
+
export function assertSinceUsable(since, relaysChanges) {
|
|
346
|
+
if (since === undefined)
|
|
347
|
+
return;
|
|
348
|
+
if (!relaysChanges) {
|
|
349
|
+
throw new StackQueryError('subscribe() was passed `since`, but this stack relays no changes from elsewhere and so ' +
|
|
350
|
+
'has no cursor it could ever have minted. Omit `since` — or, for a stack that relays ' +
|
|
351
|
+
'from a server, use the seq off a previously delivered RecordChange.');
|
|
352
|
+
}
|
|
353
|
+
if (!SEQ_FORMAT.test(since)) {
|
|
354
|
+
throw new StackQueryError(`subscribe() was passed the resume cursor "${since}", which is not a valid seq: a cursor ` +
|
|
355
|
+
'carries unreserved base64url characters only, because it travels in a frame id. Use ' +
|
|
356
|
+
'the seq off a previously delivered RecordChange, unaltered.');
|
|
357
|
+
}
|
|
358
|
+
}
|
|
324
359
|
//# sourceMappingURL=changes.js.map
|
package/dist/changes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changes.js","sourceRoot":"","sources":["../src/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"changes.js","sourceRoot":"","sources":["../src/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2B9C,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,CAA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5B,MAAM,IAAI,eAAe,CACvB,6CAA6C,KAAK,wCAAwC;YACxF,sFAAsF;YACtF,6DAA6D,CAChE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack errors — the error taxonomy
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* Every error a Stack operation can raise, in one place. The hierarchy has
|
|
5
|
+
* a single root so a server's error middleware can ask one question —
|
|
6
|
+
* `instanceof StackError` — before serializing a wire body, and each
|
|
7
|
+
* subclass carries its wire discriminator as an instance `code`.
|
|
8
|
+
*
|
|
9
|
+
* Three errors sit deliberately outside that root (StackClosedError,
|
|
10
|
+
* StackRelayScopeError, and — in their own modules — IdGenerationError and
|
|
11
|
+
* InvalidDidError): they report a local programming error or an assembled
|
|
12
|
+
* topology, not a state a request can be in, so no server ever responds
|
|
13
|
+
* with one.
|
|
14
|
+
*/
|
|
15
|
+
import type { SchemaDriftViolation } from './schema.js';
|
|
16
|
+
import type { ValidationError } from './validate.js';
|
|
17
|
+
import type { TypeId } from './types.js';
|
|
18
|
+
/**
|
|
19
|
+
* The wire-protocol discriminator vocabulary, one code per Stack-domain
|
|
20
|
+
* error class. Lives here rather than in @haverstack/wire-types because the
|
|
21
|
+
* classes that carry these codes are defined here; wire-types re-exports it
|
|
22
|
+
* as WireErrorCode. See docs/spec/wire-format.md § Wire error body.
|
|
23
|
+
*/
|
|
24
|
+
export type StackErrorCode = 'bad_request' | 'permission' | 'not_found' | 'conflict' | 'version_conflict' | 'validation' | 'migration' | 'schema_drift' | 'payload_too_large' | 'timeout';
|
|
25
|
+
/**
|
|
26
|
+
* Root of the Stack error taxonomy. A single `instanceof StackError` answers
|
|
27
|
+
* "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 a nine-arm
|
|
29
|
+
* instanceof ladder answers only by exhaustion. Every subclass carries its
|
|
30
|
+
* discriminator as an instance `code`, so serialization is a lookup rather
|
|
31
|
+
* than a chain of class tests.
|
|
32
|
+
*
|
|
33
|
+
* Membership implies a wire mapping: every code has an entry in
|
|
34
|
+
* WIRE_ERROR_STATUS. Errors with no wire representation (IdGenerationError,
|
|
35
|
+
* InvalidDidError) deliberately stay outside this hierarchy.
|
|
36
|
+
*
|
|
37
|
+
* Subclassing adds no hierarchy beyond this root — notably
|
|
38
|
+
* StackVersionConflictError is a sibling of StackConflictError, not a
|
|
39
|
+
* subtype. See docs/spec/wire-format.md § Error responses.
|
|
40
|
+
*/
|
|
41
|
+
export declare abstract class StackError extends Error {
|
|
42
|
+
abstract readonly code: StackErrorCode;
|
|
43
|
+
}
|
|
44
|
+
export declare class StackValidationError extends StackError {
|
|
45
|
+
readonly errors: ValidationError[];
|
|
46
|
+
static readonly code: "validation";
|
|
47
|
+
readonly code: "validation";
|
|
48
|
+
constructor(errors: ValidationError[]);
|
|
49
|
+
}
|
|
50
|
+
export declare class StackMigrationError extends StackError {
|
|
51
|
+
static readonly code: "migration";
|
|
52
|
+
readonly code: "migration";
|
|
53
|
+
constructor(message: string);
|
|
54
|
+
}
|
|
55
|
+
/** Thrown by ScopedStack when a requester lacks permission for the operation. */
|
|
56
|
+
export declare class StackPermissionError extends StackError {
|
|
57
|
+
static readonly code: "permission";
|
|
58
|
+
readonly code: "permission";
|
|
59
|
+
constructor(message?: string);
|
|
60
|
+
}
|
|
61
|
+
/** Thrown when a record (or specific version) does not exist. */
|
|
62
|
+
export declare class StackNotFoundError extends StackError {
|
|
63
|
+
static readonly code: "not_found";
|
|
64
|
+
readonly code: "not_found";
|
|
65
|
+
constructor(message: string);
|
|
66
|
+
}
|
|
67
|
+
/** Thrown when an operation cannot proceed due to a constraint violation (e.g. deleting an attachment that is still referenced). */
|
|
68
|
+
export declare class StackConflictError extends StackError {
|
|
69
|
+
static readonly code: "conflict";
|
|
70
|
+
readonly code: "conflict";
|
|
71
|
+
constructor(message: string);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Thrown when an `ifVersion` precondition doesn't match a record's current
|
|
75
|
+
* version. Deliberately not a StackConflictError subtype — the two have
|
|
76
|
+
* different recovery stories and HTTP statuses (409 vs. 412). See
|
|
77
|
+
* docs/spec/versioning.md § Optimistic concurrency (`ifVersion`).
|
|
78
|
+
*/
|
|
79
|
+
export declare class StackVersionConflictError extends StackError {
|
|
80
|
+
readonly recordId: string;
|
|
81
|
+
readonly expectedVersion: number;
|
|
82
|
+
readonly actualVersion: number;
|
|
83
|
+
static readonly code: "version_conflict";
|
|
84
|
+
readonly code: "version_conflict";
|
|
85
|
+
constructor(message: string, recordId: string, expectedVersion: number, actualVersion: number);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Thrown when a request is structurally malformed — not a content-validation
|
|
89
|
+
* failure, but input the adapter/server can't even interpret (e.g. an
|
|
90
|
+
* undecodable pagination cursor, a malformed TypeId, search text the engine
|
|
91
|
+
* cannot parse, or a typeId no definition exists for). Distinct from
|
|
92
|
+
* StackValidationError, which means the request was well-formed but content
|
|
93
|
+
* failed schema validation.
|
|
94
|
+
*
|
|
95
|
+
* Naming something absent belongs here rather than under `not_found`: a
|
|
96
|
+
* request whose *type* is undefined never addressed a record, so answering
|
|
97
|
+
* 404 would say a record was missing when none was asked for.
|
|
98
|
+
*/
|
|
99
|
+
export declare class StackQueryError extends StackError {
|
|
100
|
+
static readonly code: "bad_request";
|
|
101
|
+
readonly code: "bad_request";
|
|
102
|
+
constructor(message: string);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Thrown when an attachment upload exceeds the adapter's declared
|
|
106
|
+
* `limits.attachmentBytes` ceiling — checked client-side before any bytes
|
|
107
|
+
* are sent; a server still enforces 413 authoritatively regardless. See
|
|
108
|
+
* docs/spec/wire-format.md § Attachments.
|
|
109
|
+
*/
|
|
110
|
+
export declare class StackPayloadTooLargeError extends StackError {
|
|
111
|
+
static readonly code: "payload_too_large";
|
|
112
|
+
readonly code: "payload_too_large";
|
|
113
|
+
constructor(message: string);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Thrown when a server abandons an operation for taking too long — in
|
|
117
|
+
* practice a full-text search, the one query whose cost the sanitizers
|
|
118
|
+
* bound the *grammar* of but not the execution of (see
|
|
119
|
+
* docs/spec/data-model.md § Capability-gated filters).
|
|
120
|
+
*
|
|
121
|
+
* Never produced in-process: both SQLite engines run synchronously, so
|
|
122
|
+
* there is nothing to interrupt from inside the call. It exists so a
|
|
123
|
+
* server that bounds query time has a class to serialize, and so the app
|
|
124
|
+
* catching it can tell "too expensive, narrow it and retry" from
|
|
125
|
+
* StackQueryError's "malformed, don't bother retrying" — the distinction
|
|
126
|
+
* that would be lost if a timeout reused `bad_request`.
|
|
127
|
+
*/
|
|
128
|
+
export declare class StackTimeoutError extends StackError {
|
|
129
|
+
static readonly code: "timeout";
|
|
130
|
+
readonly code: "timeout";
|
|
131
|
+
constructor(message: string);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Thrown by defineType() when redefining an existing typeId with a schema
|
|
135
|
+
* change beyond additive evolution. The remedy is a new version, never an
|
|
136
|
+
* in-place redefinition. See docs/spec/data-model.md § Schema drift
|
|
137
|
+
* detection.
|
|
138
|
+
*/
|
|
139
|
+
export declare class StackSchemaDriftError extends StackError {
|
|
140
|
+
readonly typeId: TypeId;
|
|
141
|
+
readonly violations: SchemaDriftViolation[];
|
|
142
|
+
static readonly code: "schema_drift";
|
|
143
|
+
readonly code: "schema_drift";
|
|
144
|
+
constructor(typeId: TypeId, violations: SchemaDriftViolation[]);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Thrown when a Stack or ScopedStack is used after close(). Deliberately
|
|
148
|
+
* outside the StackError taxonomy, alongside IdGenerationError and
|
|
149
|
+
* InvalidDidError: a caller holding a closed client is a local programming
|
|
150
|
+
* error with no wire representation — no server ever responds with it.
|
|
151
|
+
* See docs/spec/adapters.md § Lifecycle.
|
|
152
|
+
*/
|
|
153
|
+
export declare class StackClosedError extends Error {
|
|
154
|
+
constructor(message?: string);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Thrown when a scoped view is asked to observe a stack whose adapter
|
|
158
|
+
* relays a remote feed. Outside the StackError taxonomy for the same
|
|
159
|
+
* reason StackClosedError is: it reports a topology the caller assembled,
|
|
160
|
+
* not a state a request can be in.
|
|
161
|
+
*
|
|
162
|
+
* A relayed frame is scoped by the authority that opened the feed, and a
|
|
163
|
+
* narrower scope cannot re-derive that decision — a purge leaves no record
|
|
164
|
+
* to check `canRead` against. Delivering anyway would break the promise
|
|
165
|
+
* that a subscriber never sees what it may not read; delivering only local
|
|
166
|
+
* writes would silently drop every change made elsewhere, which is the
|
|
167
|
+
* failure that looks fine in testing. So it refuses.
|
|
168
|
+
* See docs/spec/events.md § Permission scoping.
|
|
169
|
+
*/
|
|
170
|
+
export declare class StackRelayScopeError extends Error {
|
|
171
|
+
constructor(message: string);
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB,aAAa,GACb,YAAY,GACZ,WAAW,GACX,UAAU,GACV,kBAAkB,GAClB,YAAY,GACZ,WAAW,GACX,cAAc,GACd,mBAAmB,GACnB,SAAS,CAAC;AAEd;;;;;;;;;;;;;;;GAeG;AACH,8BAAsB,UAAW,SAAQ,KAAK;IAC5C,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,c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AgB,SAAQ,UAAU;IAC7C,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAG,aAAa,CAAU;IAC9C,SAAkB,IAAI,gBAAwB;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,UAAU;IACvD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAG,mBAAmB,CAAU;IACpD,SAAkB,IAAI,sBAAkC;gBAC5C,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAkB,SAAQ,UAAU;IAC/C,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAG,SAAS,CAAU;IAC1C,SAAkB,IAAI,YAA0B;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,UAAU;aAIjC,MAAM,EAAE,MAAM;aACd,UAAU,EAAE,oBAAoB,EAAE;IAJpD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAG,cAAc,CAAU;IAC/C,SAAkB,IAAI,iBAA8B;gBAElC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,oBAAoB,EAAE;CAUrD;AAED;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,SAAgC;CAIpD;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack errors — the error taxonomy
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* Every error a Stack operation can raise, in one place. The hierarchy has
|
|
5
|
+
* a single root so a server's error middleware can ask one question —
|
|
6
|
+
* `instanceof StackError` — before serializing a wire body, and each
|
|
7
|
+
* subclass carries its wire discriminator as an instance `code`.
|
|
8
|
+
*
|
|
9
|
+
* Three errors sit deliberately outside that root (StackClosedError,
|
|
10
|
+
* StackRelayScopeError, and — in their own modules — IdGenerationError and
|
|
11
|
+
* InvalidDidError): they report a local programming error or an assembled
|
|
12
|
+
* topology, not a state a request can be in, so no server ever responds
|
|
13
|
+
* with one.
|
|
14
|
+
*/
|
|
15
|
+
import { baseIdOf, parseTypeId } from './schema.js';
|
|
16
|
+
/**
|
|
17
|
+
* Root of the Stack error taxonomy. A single `instanceof StackError` answers
|
|
18
|
+
* "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 a nine-arm
|
|
20
|
+
* instanceof ladder answers only by exhaustion. Every subclass carries its
|
|
21
|
+
* discriminator as an instance `code`, so serialization is a lookup rather
|
|
22
|
+
* than a chain of class tests.
|
|
23
|
+
*
|
|
24
|
+
* Membership implies a wire mapping: every code has an entry in
|
|
25
|
+
* WIRE_ERROR_STATUS. Errors with no wire representation (IdGenerationError,
|
|
26
|
+
* InvalidDidError) deliberately stay outside this hierarchy.
|
|
27
|
+
*
|
|
28
|
+
* Subclassing adds no hierarchy beyond this root — notably
|
|
29
|
+
* StackVersionConflictError is a sibling of StackConflictError, not a
|
|
30
|
+
* subtype. See docs/spec/wire-format.md § Error responses.
|
|
31
|
+
*/
|
|
32
|
+
export class StackError extends Error {
|
|
33
|
+
}
|
|
34
|
+
export class StackValidationError extends StackError {
|
|
35
|
+
errors;
|
|
36
|
+
static code = 'validation';
|
|
37
|
+
code = StackValidationError.code;
|
|
38
|
+
constructor(errors) {
|
|
39
|
+
super(`Content validation failed:\n` + errors.map((e) => ` ${e.path}: ${e.message}`).join('\n'));
|
|
40
|
+
this.errors = errors;
|
|
41
|
+
this.name = 'StackValidationError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class StackMigrationError extends StackError {
|
|
45
|
+
static code = 'migration';
|
|
46
|
+
code = StackMigrationError.code;
|
|
47
|
+
constructor(message) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = 'StackMigrationError';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Thrown by ScopedStack when a requester lacks permission for the operation. */
|
|
53
|
+
export class StackPermissionError extends StackError {
|
|
54
|
+
static code = 'permission';
|
|
55
|
+
code = StackPermissionError.code;
|
|
56
|
+
constructor(message = 'Permission denied') {
|
|
57
|
+
super(message);
|
|
58
|
+
this.name = 'StackPermissionError';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Thrown when a record (or specific version) does not exist. */
|
|
62
|
+
export class StackNotFoundError extends StackError {
|
|
63
|
+
static code = 'not_found';
|
|
64
|
+
code = StackNotFoundError.code;
|
|
65
|
+
constructor(message) {
|
|
66
|
+
super(message);
|
|
67
|
+
this.name = 'StackNotFoundError';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Thrown when an operation cannot proceed due to a constraint violation (e.g. deleting an attachment that is still referenced). */
|
|
71
|
+
export class StackConflictError extends StackError {
|
|
72
|
+
static code = 'conflict';
|
|
73
|
+
code = StackConflictError.code;
|
|
74
|
+
constructor(message) {
|
|
75
|
+
super(message);
|
|
76
|
+
this.name = 'StackConflictError';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Thrown when an `ifVersion` precondition doesn't match a record's current
|
|
81
|
+
* version. Deliberately not a StackConflictError subtype — the two have
|
|
82
|
+
* different recovery stories and HTTP statuses (409 vs. 412). See
|
|
83
|
+
* docs/spec/versioning.md § Optimistic concurrency (`ifVersion`).
|
|
84
|
+
*/
|
|
85
|
+
export class StackVersionConflictError extends StackError {
|
|
86
|
+
recordId;
|
|
87
|
+
expectedVersion;
|
|
88
|
+
actualVersion;
|
|
89
|
+
static code = 'version_conflict';
|
|
90
|
+
code = StackVersionConflictError.code;
|
|
91
|
+
constructor(message, recordId, expectedVersion, actualVersion) {
|
|
92
|
+
super(message);
|
|
93
|
+
this.recordId = recordId;
|
|
94
|
+
this.expectedVersion = expectedVersion;
|
|
95
|
+
this.actualVersion = actualVersion;
|
|
96
|
+
this.name = 'StackVersionConflictError';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Thrown when a request is structurally malformed — not a content-validation
|
|
101
|
+
* failure, but input the adapter/server can't even interpret (e.g. an
|
|
102
|
+
* undecodable pagination cursor, a malformed TypeId, search text the engine
|
|
103
|
+
* cannot parse, or a typeId no definition exists for). Distinct from
|
|
104
|
+
* StackValidationError, which means the request was well-formed but content
|
|
105
|
+
* failed schema validation.
|
|
106
|
+
*
|
|
107
|
+
* Naming something absent belongs here rather than under `not_found`: a
|
|
108
|
+
* request whose *type* is undefined never addressed a record, so answering
|
|
109
|
+
* 404 would say a record was missing when none was asked for.
|
|
110
|
+
*/
|
|
111
|
+
export class StackQueryError extends StackError {
|
|
112
|
+
static code = 'bad_request';
|
|
113
|
+
code = StackQueryError.code;
|
|
114
|
+
constructor(message) {
|
|
115
|
+
super(message);
|
|
116
|
+
this.name = 'StackQueryError';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Thrown when an attachment upload exceeds the adapter's declared
|
|
121
|
+
* `limits.attachmentBytes` ceiling — checked client-side before any bytes
|
|
122
|
+
* are sent; a server still enforces 413 authoritatively regardless. See
|
|
123
|
+
* docs/spec/wire-format.md § Attachments.
|
|
124
|
+
*/
|
|
125
|
+
export class StackPayloadTooLargeError extends StackError {
|
|
126
|
+
static code = 'payload_too_large';
|
|
127
|
+
code = StackPayloadTooLargeError.code;
|
|
128
|
+
constructor(message) {
|
|
129
|
+
super(message);
|
|
130
|
+
this.name = 'StackPayloadTooLargeError';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Thrown when a server abandons an operation for taking too long — in
|
|
135
|
+
* practice a full-text search, the one query whose cost the sanitizers
|
|
136
|
+
* bound the *grammar* of but not the execution of (see
|
|
137
|
+
* docs/spec/data-model.md § Capability-gated filters).
|
|
138
|
+
*
|
|
139
|
+
* Never produced in-process: both SQLite engines run synchronously, so
|
|
140
|
+
* there is nothing to interrupt from inside the call. It exists so a
|
|
141
|
+
* server that bounds query time has a class to serialize, and so the app
|
|
142
|
+
* catching it can tell "too expensive, narrow it and retry" from
|
|
143
|
+
* StackQueryError's "malformed, don't bother retrying" — the distinction
|
|
144
|
+
* that would be lost if a timeout reused `bad_request`.
|
|
145
|
+
*/
|
|
146
|
+
export class StackTimeoutError extends StackError {
|
|
147
|
+
static code = 'timeout';
|
|
148
|
+
code = StackTimeoutError.code;
|
|
149
|
+
constructor(message) {
|
|
150
|
+
super(message);
|
|
151
|
+
this.name = 'StackTimeoutError';
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Thrown by defineType() when redefining an existing typeId with a schema
|
|
156
|
+
* change beyond additive evolution. The remedy is a new version, never an
|
|
157
|
+
* in-place redefinition. See docs/spec/data-model.md § Schema drift
|
|
158
|
+
* detection.
|
|
159
|
+
*/
|
|
160
|
+
export class StackSchemaDriftError extends StackError {
|
|
161
|
+
typeId;
|
|
162
|
+
violations;
|
|
163
|
+
static code = 'schema_drift';
|
|
164
|
+
code = StackSchemaDriftError.code;
|
|
165
|
+
constructor(typeId, violations) {
|
|
166
|
+
super(`Schema drift detected for type "${typeId}": the stored schema and the new definition ` +
|
|
167
|
+
`differ beyond additive evolution (new optional fields only). Bump the version instead ` +
|
|
168
|
+
`of redefining "${typeId}" in place — e.g. defineType(\`${baseIdOf(typeId)}@${(parseTypeId(typeId)?.version ?? 0) + 1}\`, ...) plus registerMigration().\n` +
|
|
169
|
+
violations.map((v) => ` ${v.path || '(root)'}: ${v.message}`).join('\n'));
|
|
170
|
+
this.typeId = typeId;
|
|
171
|
+
this.violations = violations;
|
|
172
|
+
this.name = 'StackSchemaDriftError';
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Thrown when a Stack or ScopedStack is used after close(). Deliberately
|
|
177
|
+
* outside the StackError taxonomy, alongside IdGenerationError and
|
|
178
|
+
* InvalidDidError: a caller holding a closed client is a local programming
|
|
179
|
+
* error with no wire representation — no server ever responds with it.
|
|
180
|
+
* See docs/spec/adapters.md § Lifecycle.
|
|
181
|
+
*/
|
|
182
|
+
export class StackClosedError extends Error {
|
|
183
|
+
constructor(message = 'This Stack has been closed.') {
|
|
184
|
+
super(message);
|
|
185
|
+
this.name = 'StackClosedError';
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Thrown when a scoped view is asked to observe a stack whose adapter
|
|
190
|
+
* relays a remote feed. Outside the StackError taxonomy for the same
|
|
191
|
+
* reason StackClosedError is: it reports a topology the caller assembled,
|
|
192
|
+
* not a state a request can be in.
|
|
193
|
+
*
|
|
194
|
+
* A relayed frame is scoped by the authority that opened the feed, and a
|
|
195
|
+
* narrower scope cannot re-derive that decision — a purge leaves no record
|
|
196
|
+
* to check `canRead` against. Delivering anyway would break the promise
|
|
197
|
+
* that a subscriber never sees what it may not read; delivering only local
|
|
198
|
+
* writes would silently drop every change made elsewhere, which is the
|
|
199
|
+
* failure that looks fine in testing. So it refuses.
|
|
200
|
+
* See docs/spec/events.md § Permission scoping.
|
|
201
|
+
*/
|
|
202
|
+
export class StackRelayScopeError extends Error {
|
|
203
|
+
constructor(message) {
|
|
204
|
+
super(message);
|
|
205
|
+
this.name = 'StackRelayScopeError';
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;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,CA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2
|
+
* Grant vocabulary and coverage
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* What a `_grant` Record says, and who it says it about. The coverage
|
|
5
|
+
* question — does this grant reach this grantee — is answered here rather
|
|
6
|
+
* than at each call site so that the access checks and listGrants() cannot
|
|
7
|
+
* drift apart about it.
|
|
8
|
+
*
|
|
9
|
+
* See docs/spec/access-control.md § Type-level grants.
|
|
10
|
+
*/
|
|
11
|
+
import type { GroupRole } from './access.js';
|
|
12
|
+
import type { EntityId, GrantAction, GrantContent, QueryResult, RecordId, StackQuery, StackRecord } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Valid GrantAction values, for runtime validation in Stack.grant().
|
|
15
|
+
* Built from GRANT_ACTIONS (types.ts), the source of truth GrantAction is
|
|
16
|
+
* itself derived from — so this can't drift from the type.
|
|
17
|
+
*/
|
|
18
|
+
export declare const GRANT_ACTION_SET: ReadonlySet<GrantAction>;
|
|
19
|
+
/**
|
|
20
|
+
* The read actions that make a mutate action coherent, scope for scope: a
|
|
21
|
+
* `-any` verb needs read over the same reach it can mutate, a `-own` verb
|
|
22
|
+
* needs read over its author's own. A grant carrying neither conveys the
|
|
23
|
+
* verb to nobody. `create` has no companion — writing a Record you then
|
|
24
|
+
* cannot read is the drop-box, and it discloses nothing.
|
|
25
|
+
* See docs/spec/access-control.md § Write implies read.
|
|
26
|
+
*/
|
|
27
|
+
export declare const READ_COMPANIONS: ReadonlyMap<GrantAction, readonly GrantAction[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Whether one grant's action list conveys `action`. The companion has to
|
|
30
|
+
* sit in the same `_grant` Record, not merely somewhere in the grantee's
|
|
31
|
+
* set: a grant is revoked whole, so a rule satisfied across two records
|
|
32
|
+
* would let revoking the read one leave a mutate-without-read grant
|
|
33
|
+
* standing — the configuration this rule exists to refuse, arrived at
|
|
34
|
+
* without anyone writing it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function grantConveys(actions: readonly string[], action: GrantAction): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Who a grant() / revoke() / listGrants() call targets: a specific entity
|
|
39
|
+
* (DID), a `_group` Record's roster (by ID), or `null` for the default
|
|
40
|
+
* grant / default-only listing. See docs/spec/access-control.md § Type-level
|
|
41
|
+
* grants.
|
|
42
|
+
*/
|
|
43
|
+
export type GrantTarget = EntityId | {
|
|
44
|
+
groupId: RecordId;
|
|
45
|
+
} | null;
|
|
46
|
+
/** Direct (non-roster) match between a stored _grant's content and a GrantTarget. */
|
|
47
|
+
export declare function matchesGrantTarget(content: GrantContent, target: GrantTarget): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Reject a grant target that names nobody. An empty groupId or entityId is
|
|
50
|
+
* falsy, so a stored record carrying one reads as a *default* grant — every
|
|
51
|
+
* authenticated entity — instead of the target the caller meant. `null` is
|
|
52
|
+
* the only way to say "default".
|
|
53
|
+
*/
|
|
54
|
+
export declare function validateGrantTarget(target: GrantTarget): void;
|
|
55
|
+
/**
|
|
56
|
+
* Whether a stored _grant covers `grantee`: a direct DID match, roster
|
|
57
|
+
* membership when `allowGroup`, or a default when `allowDefault`. Presence
|
|
58
|
+
* decides the tier, never truthiness — an empty grantee field names nobody.
|
|
59
|
+
* Module-level so the access checks and listGrants() cannot drift apart.
|
|
60
|
+
* See docs/spec/access-control.md § Type-level grants.
|
|
61
|
+
*/
|
|
62
|
+
export declare function grantCoversGrantee(c: GrantContent, grantee: EntityId, opts: {
|
|
63
|
+
allowDefault: boolean;
|
|
64
|
+
allowGroup: boolean;
|
|
65
|
+
groupRoles: Map<string, GroupRole | null>;
|
|
66
|
+
resolveRecord: (id: RecordId) => Promise<StackRecord | null>;
|
|
67
|
+
}): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* System type families grant() refuses to target: a grant on any of them
|
|
70
|
+
* would let the grantee mint their own grants, touch stack config, or
|
|
71
|
+
* register an app card claiming a DID that isn't theirs — the last of
|
|
72
|
+
* which is what verified app attribution rests on. See
|
|
73
|
+
* docs/spec/access-control.md § Type-level grants.
|
|
74
|
+
*/
|
|
75
|
+
export declare const UNGRANTABLE_SYSTEM_TYPES: ReadonlySet<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Every `_grant` Record, cursor-walked. Read through an unscoped query at
|
|
78
|
+
* every call site: a grant is what decides who may read, so it can never
|
|
79
|
+
* itself sit behind a read check. No content prefilter — a stored grant's
|
|
80
|
+
* typeId may be a bare baseId or versioned, so exact matching would wrongly
|
|
81
|
+
* exclude family versions.
|
|
82
|
+
*/
|
|
83
|
+
export declare function loadGrantRecords(query: (q: StackQuery) => Promise<QueryResult>): Promise<StackRecord[]>;
|
|
84
|
+
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACZ,MAAM,YAAY,CAAC;AAGpB;;;;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;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAIrF;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,GAAG,IAAI,CAAC;AAElE,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO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