@haverstack/core 0.40.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -59
- package/dist/access.d.ts +34 -36
- package/dist/access.d.ts.map +1 -1
- package/dist/access.js +65 -42
- package/dist/access.js.map +1 -1
- package/dist/{combine.d.ts → adapter/combine.d.ts} +8 -1
- package/dist/adapter/combine.d.ts.map +1 -0
- package/dist/{combine.js → adapter/combine.js} +7 -0
- package/dist/adapter/combine.js.map +1 -0
- package/dist/{adapter-entry.d.ts → adapter/index.d.ts} +6 -5
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/{adapter-entry.js → adapter/index.js} +5 -4
- package/dist/adapter/index.js.map +1 -0
- package/dist/{sort.d.ts → adapter/sort.d.ts} +20 -20
- package/dist/adapter/sort.d.ts.map +1 -0
- package/dist/{sort.js → adapter/sort.js} +37 -27
- package/dist/adapter/sort.js.map +1 -0
- package/dist/associations/identity.d.ts +93 -0
- package/dist/associations/identity.d.ts.map +1 -0
- package/dist/associations/identity.js +198 -0
- package/dist/associations/identity.js.map +1 -0
- package/dist/associations/validation.d.ts +90 -0
- package/dist/associations/validation.d.ts.map +1 -0
- package/dist/associations/validation.js +339 -0
- package/dist/associations/validation.js.map +1 -0
- package/dist/attachment-records.d.ts +48 -0
- package/dist/attachment-records.d.ts.map +1 -0
- package/dist/attachment-records.js +52 -0
- package/dist/attachment-records.js.map +1 -0
- package/dist/collection.d.ts +182 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +407 -0
- package/dist/collection.js.map +1 -0
- package/dist/content-match.d.ts +25 -0
- package/dist/content-match.d.ts.map +1 -0
- package/dist/content-match.js +51 -0
- package/dist/content-match.js.map +1 -0
- package/dist/content-translation.d.ts +42 -0
- package/dist/content-translation.d.ts.map +1 -0
- package/dist/content-translation.js +108 -0
- package/dist/content-translation.js.map +1 -0
- package/dist/did/did.d.ts.map +1 -0
- package/dist/{did.js → did/did.js} +3 -4
- package/dist/did/did.js.map +1 -0
- package/dist/{did-entry.d.ts → did/index.d.ts} +1 -1
- package/dist/did/index.d.ts.map +1 -0
- package/dist/{did-entry.js → did/index.js} +3 -3
- package/dist/did/index.js.map +1 -0
- package/dist/errors.d.ts +36 -63
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +35 -58
- package/dist/errors.js.map +1 -1
- package/dist/grants.d.ts +20 -43
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +71 -134
- package/dist/grants.js.map +1 -1
- package/dist/id.d.ts +13 -31
- package/dist/id.d.ts.map +1 -1
- package/dist/id.js +13 -31
- package/dist/id.js.map +1 -1
- package/dist/index.d.ts +14 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +141 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +219 -0
- package/dist/install.js.map +1 -0
- package/dist/merge.d.ts.map +1 -1
- package/dist/merge.js +5 -11
- package/dist/merge.js.map +1 -1
- package/dist/migration-steps.d.ts +102 -0
- package/dist/migration-steps.d.ts.map +1 -0
- package/dist/migration-steps.js +293 -0
- package/dist/migration-steps.js.map +1 -0
- package/dist/query-validation.d.ts +28 -94
- package/dist/query-validation.d.ts.map +1 -1
- package/dist/query-validation.js +156 -336
- package/dist/query-validation.js.map +1 -1
- package/dist/record-changes.d.ts +2 -117
- package/dist/record-changes.d.ts.map +1 -1
- package/dist/record-changes.js +10 -212
- package/dist/record-changes.js.map +1 -1
- package/dist/schema.d.ts +18 -7
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +59 -30
- package/dist/schema.js.map +1 -1
- package/dist/scoped-stack/authority.d.ts +156 -0
- package/dist/scoped-stack/authority.d.ts.map +1 -0
- package/dist/scoped-stack/authority.js +384 -0
- package/dist/scoped-stack/authority.js.map +1 -0
- package/dist/scoped-stack/scoped-stack.d.ts +338 -0
- package/dist/scoped-stack/scoped-stack.d.ts.map +1 -0
- package/dist/scoped-stack/scoped-stack.js +776 -0
- package/dist/scoped-stack/scoped-stack.js.map +1 -0
- package/dist/scoped-stack/subscription.d.ts +55 -0
- package/dist/scoped-stack/subscription.d.ts.map +1 -0
- package/dist/scoped-stack/subscription.js +110 -0
- package/dist/scoped-stack/subscription.js.map +1 -0
- package/dist/stack/attachments.d.ts +24 -0
- package/dist/stack/attachments.d.ts.map +1 -0
- package/dist/stack/attachments.js +113 -0
- package/dist/stack/attachments.js.map +1 -0
- package/dist/{changes.d.ts → stack/changes.d.ts} +29 -65
- package/dist/stack/changes.d.ts.map +1 -0
- package/dist/{changes.js → stack/changes.js} +32 -66
- package/dist/stack/changes.js.map +1 -0
- package/dist/stack/client.d.ts +271 -0
- package/dist/stack/client.d.ts.map +1 -0
- package/dist/stack/client.js +9 -0
- package/dist/stack/client.js.map +1 -0
- package/dist/stack/identity-bindings.d.ts.map +1 -0
- package/dist/{identity-bindings.js → stack/identity-bindings.js} +8 -14
- package/dist/stack/identity-bindings.js.map +1 -0
- package/dist/stack/install-app.d.ts +22 -0
- package/dist/stack/install-app.d.ts.map +1 -0
- package/dist/stack/install-app.js +260 -0
- package/dist/stack/install-app.js.map +1 -0
- package/dist/stack/integrity.d.ts +94 -0
- package/dist/stack/integrity.d.ts.map +1 -0
- package/dist/stack/integrity.js +268 -0
- package/dist/stack/integrity.js.map +1 -0
- package/dist/{limits.d.ts → stack/limits.d.ts} +2 -5
- package/dist/stack/limits.d.ts.map +1 -0
- package/dist/{limits.js → stack/limits.js} +3 -6
- package/dist/stack/limits.js.map +1 -0
- package/dist/stack/migrations.d.ts +59 -0
- package/dist/stack/migrations.d.ts.map +1 -0
- package/dist/stack/migrations.js +141 -0
- package/dist/stack/migrations.js.map +1 -0
- package/dist/{stack-reads.d.ts → stack/reads.d.ts} +33 -6
- package/dist/stack/reads.d.ts.map +1 -0
- package/dist/{stack-reads.js → stack/reads.js} +49 -7
- package/dist/stack/reads.js.map +1 -0
- package/dist/stack/record-id.d.ts +35 -0
- package/dist/stack/record-id.d.ts.map +1 -0
- package/dist/stack/record-id.js +82 -0
- package/dist/stack/record-id.js.map +1 -0
- package/dist/stack/stack.d.ts +438 -0
- package/dist/stack/stack.d.ts.map +1 -0
- package/dist/stack/stack.js +1366 -0
- package/dist/stack/stack.js.map +1 -0
- package/dist/stack/system-types.d.ts +16 -0
- package/dist/stack/system-types.d.ts.map +1 -0
- package/dist/stack/system-types.js +111 -0
- package/dist/stack/system-types.js.map +1 -0
- package/dist/stack/type-grants.d.ts +20 -0
- package/dist/stack/type-grants.d.ts.map +1 -0
- package/dist/stack/type-grants.js +69 -0
- package/dist/stack/type-grants.js.map +1 -0
- package/dist/stack/write-expectation.d.ts +78 -0
- package/dist/stack/write-expectation.d.ts.map +1 -0
- package/dist/stack/write-expectation.js +71 -0
- package/dist/stack/write-expectation.js.map +1 -0
- package/dist/testing.d.ts +21 -26
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +50 -70
- package/dist/testing.js.map +1 -1
- package/dist/type-handle.d.ts +67 -78
- package/dist/type-handle.d.ts.map +1 -1
- package/dist/type-handle.js +44 -111
- package/dist/type-handle.js.map +1 -1
- package/dist/types/adapter.d.ts +223 -0
- package/dist/types/adapter.d.ts.map +1 -0
- package/dist/types/adapter.js +5 -0
- package/dist/types/adapter.js.map +1 -0
- package/dist/types/associations.d.ts +156 -0
- package/dist/types/associations.d.ts.map +1 -0
- package/dist/types/associations.js +13 -0
- package/dist/types/associations.js.map +1 -0
- package/dist/types/capabilities.d.ts +89 -0
- package/dist/types/capabilities.d.ts.map +1 -0
- package/dist/types/capabilities.js +5 -0
- package/dist/types/capabilities.js.map +1 -0
- package/dist/types/events.d.ts +155 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +5 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/ids.d.ts +43 -0
- package/dist/types/ids.d.ts.map +1 -0
- package/dist/types/ids.js +5 -0
- package/dist/types/ids.js.map +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/journal.d.ts +47 -0
- package/dist/types/journal.d.ts.map +1 -0
- package/dist/types/journal.js +5 -0
- package/dist/types/journal.js.map +1 -0
- package/dist/types/query.d.ts +185 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/query.js +10 -0
- package/dist/types/query.js.map +1 -0
- package/dist/types/records.d.ts +76 -0
- package/dist/types/records.d.ts.map +1 -0
- package/dist/types/records.js +5 -0
- package/dist/types/records.js.map +1 -0
- package/dist/types/schema.d.ts +74 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +5 -0
- package/dist/types/schema.js.map +1 -0
- package/dist/types/system.d.ts +161 -0
- package/dist/types/system.d.ts.map +1 -0
- package/dist/types/system.js +32 -0
- package/dist/types/system.js.map +1 -0
- package/dist/types/tokens.d.ts +39 -0
- package/dist/types/tokens.d.ts.map +1 -0
- package/dist/types/tokens.js +5 -0
- package/dist/types/tokens.js.map +1 -0
- package/dist/validate.d.ts +29 -70
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +65 -97
- package/dist/validate.js.map +1 -1
- package/dist/{attachment-download.d.ts → wire/attachment-download.d.ts} +0 -57
- package/dist/wire/attachment-download.d.ts.map +1 -0
- package/dist/{attachment-download.js → wire/attachment-download.js} +0 -61
- package/dist/wire/attachment-download.js.map +1 -0
- package/dist/{auth.d.ts → wire/auth.d.ts} +5 -8
- package/dist/wire/auth.d.ts.map +1 -0
- package/dist/{auth.js → wire/auth.js} +5 -8
- package/dist/wire/auth.js.map +1 -0
- package/dist/{wire-body.d.ts → wire/body.d.ts} +13 -5
- package/dist/wire/body.d.ts.map +1 -0
- package/dist/{wire-body.js → wire/body.js} +65 -7
- package/dist/wire/body.js.map +1 -0
- package/dist/{wire-entry.d.ts → wire/index.d.ts} +12 -12
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/{wire-entry.js → wire/index.js} +13 -17
- package/dist/wire/index.js.map +1 -0
- package/dist/{wire-record.d.ts → wire/record.d.ts} +10 -22
- package/dist/wire/record.d.ts.map +1 -0
- package/dist/{wire-record.js → wire/record.js} +12 -24
- package/dist/wire/record.js.map +1 -0
- package/dist/{wire-request.d.ts → wire/request.d.ts} +20 -37
- package/dist/wire/request.d.ts.map +1 -0
- package/dist/{wire-request.js → wire/request.js} +79 -54
- package/dist/wire/request.js.map +1 -0
- package/package.json +7 -7
- package/dist/adapter-entry.d.ts.map +0 -1
- package/dist/adapter-entry.js.map +0 -1
- package/dist/attachment-download.d.ts.map +0 -1
- package/dist/attachment-download.js.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/changes.d.ts.map +0 -1
- package/dist/changes.js.map +0 -1
- package/dist/combine.d.ts.map +0 -1
- package/dist/combine.js.map +0 -1
- package/dist/did-entry.d.ts.map +0 -1
- package/dist/did-entry.js.map +0 -1
- package/dist/did.d.ts.map +0 -1
- package/dist/did.js.map +0 -1
- package/dist/identity-bindings.d.ts.map +0 -1
- package/dist/identity-bindings.js.map +0 -1
- package/dist/limits.d.ts.map +0 -1
- package/dist/limits.js.map +0 -1
- package/dist/record-id.d.ts +0 -70
- package/dist/record-id.d.ts.map +0 -1
- package/dist/record-id.js +0 -127
- package/dist/record-id.js.map +0 -1
- package/dist/scoped-stack.d.ts +0 -532
- package/dist/scoped-stack.d.ts.map +0 -1
- package/dist/scoped-stack.js +0 -1219
- package/dist/scoped-stack.js.map +0 -1
- package/dist/sort.d.ts.map +0 -1
- package/dist/sort.js.map +0 -1
- package/dist/stack-reads.d.ts.map +0 -1
- package/dist/stack-reads.js.map +0 -1
- package/dist/stack.d.ts +0 -971
- package/dist/stack.d.ts.map +0 -1
- package/dist/stack.js +0 -2012
- package/dist/stack.js.map +0 -1
- package/dist/types.d.ts +0 -1250
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -49
- package/dist/types.js.map +0 -1
- package/dist/wire-body.d.ts.map +0 -1
- package/dist/wire-body.js.map +0 -1
- package/dist/wire-entry.d.ts.map +0 -1
- package/dist/wire-entry.js.map +0 -1
- package/dist/wire-record.d.ts.map +0 -1
- package/dist/wire-record.js.map +0 -1
- package/dist/wire-request.d.ts.map +0 -1
- package/dist/wire-request.js.map +0 -1
- /package/dist/{did.d.ts → did/did.d.ts} +0 -0
- /package/dist/{identity-bindings.d.ts → stack/identity-bindings.d.ts} +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Record itself and its version snapshots.
|
|
3
|
+
*/
|
|
4
|
+
import type { AuthorityAssociation, DataAssociation } from './associations.js';
|
|
5
|
+
import type { RecordId, TypeId, AppId, Actor } from './ids.js';
|
|
6
|
+
export type StackRecord = {
|
|
7
|
+
id: RecordId;
|
|
8
|
+
typeId: TypeId;
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
updatedAt: Date;
|
|
11
|
+
content: Record<string, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Ordinal of the snapshot history, not a count of changes: associations,
|
|
14
|
+
* permissions, parent and listing moves leave it alone. See
|
|
15
|
+
* docs/spec/versioning.md § Version history.
|
|
16
|
+
*/
|
|
17
|
+
version: number;
|
|
18
|
+
parentId?: RecordId;
|
|
19
|
+
appId?: AppId;
|
|
20
|
+
/**
|
|
21
|
+
* The record's author, stamped once by the create. A `principalId` here
|
|
22
|
+
* is what lets `appId` be checked against the `_app` record naming that
|
|
23
|
+
* DID; without one, `appId` is an unverifiable self-report.
|
|
24
|
+
* See docs/spec/data-model.md § Authorship and attribution.
|
|
25
|
+
*/
|
|
26
|
+
createdBy?: Actor;
|
|
27
|
+
/**
|
|
28
|
+
* Who performed the mutation this version records — unlike `createdBy`,
|
|
29
|
+
* it moves with every write. Absent means an unscoped `Stack` wrote it,
|
|
30
|
+
* which names no requester.
|
|
31
|
+
* See docs/spec/data-model.md § Authorship and attribution.
|
|
32
|
+
*/
|
|
33
|
+
updatedBy?: Actor;
|
|
34
|
+
deletedAt?: Date;
|
|
35
|
+
/**
|
|
36
|
+
* Present when the record is withheld from enumeration: absent from
|
|
37
|
+
* `query()` and the change feed by default, but reachable by `get()` for
|
|
38
|
+
* anyone who may read it. Says nothing about who that is.
|
|
39
|
+
* See docs/spec/unlisted.md.
|
|
40
|
+
*/
|
|
41
|
+
unlistedAt?: Date;
|
|
42
|
+
/**
|
|
43
|
+
* Who reaches this Record, projected from the association table's
|
|
44
|
+
* authority kinds. Absent or empty means private — readable only by the
|
|
45
|
+
* stack owner. Declarative intent; enforcement is `ScopedStack`'s.
|
|
46
|
+
* See docs/spec/access-control.md § Record-level permissions.
|
|
47
|
+
*/
|
|
48
|
+
permissions?: AuthorityAssociation[];
|
|
49
|
+
associations?: DataAssociation[];
|
|
50
|
+
};
|
|
51
|
+
export type RecordVersion = {
|
|
52
|
+
version: number;
|
|
53
|
+
/** The record's typeId at the moment this version was snapshotted. */
|
|
54
|
+
typeId: TypeId;
|
|
55
|
+
content: Record<string, unknown>;
|
|
56
|
+
updatedAt: Date;
|
|
57
|
+
/**
|
|
58
|
+
* The record's author, carried through from `record.createdBy` — not the
|
|
59
|
+
* actor of the change this version records.
|
|
60
|
+
* See docs/spec/versioning.md § Version history.
|
|
61
|
+
*/
|
|
62
|
+
createdBy?: Actor;
|
|
63
|
+
/** Who performed the mutation that produced this version. */
|
|
64
|
+
updatedBy?: Actor;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Window into a record's version history. Newest first, the reverse of
|
|
68
|
+
* JournalQuery; omitting both reads every version.
|
|
69
|
+
* See docs/spec/versioning.md § Version history.
|
|
70
|
+
*/
|
|
71
|
+
export type VersionsQuery = {
|
|
72
|
+
/** Versions strictly older than this, exclusive. */
|
|
73
|
+
beforeVersion?: number;
|
|
74
|
+
limit?: number;
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|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GAAG;IAC1B,oDAAoD;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/types/records.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type schemas: field definitions and the registered StackType.
|
|
3
|
+
*/
|
|
4
|
+
import type { TypeId, BaseId } from './ids.js';
|
|
5
|
+
export type ScalarFieldKind = 'string' | 'number' | 'boolean' | 'date' | 'text' | 'record-ref' | 'file-ref' | 'enum';
|
|
6
|
+
/**
|
|
7
|
+
* `values` is a non-empty, duplicate-free list of the strings the field may
|
|
8
|
+
* hold. See docs/spec/data-model.md § Types.
|
|
9
|
+
*/
|
|
10
|
+
export type EnumFieldDef = {
|
|
11
|
+
kind: 'enum';
|
|
12
|
+
values: string[];
|
|
13
|
+
required?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type ScalarFieldDef = EnumFieldDef | {
|
|
16
|
+
kind: Exclude<ScalarFieldKind, 'enum'>;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A list. `open: true` leaves its elements unvalidated,
|
|
21
|
+
* which is how a heterogeneous or null-bearing list is spelled. Opacity is
|
|
22
|
+
* declared rather than inferred from a missing `items`, so a schema that
|
|
23
|
+
* forgets to describe its elements is a type error rather than a silently
|
|
24
|
+
* unchecked field. See docs/spec/data-model.md § Undeclared content fields.
|
|
25
|
+
*/
|
|
26
|
+
export type ArrayFieldDef = {
|
|
27
|
+
kind: 'array';
|
|
28
|
+
items: FieldDef;
|
|
29
|
+
open?: false;
|
|
30
|
+
required?: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'array';
|
|
33
|
+
open: true;
|
|
34
|
+
items?: undefined;
|
|
35
|
+
required?: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* An object. `open: true` leaves its keys unvalidated,
|
|
39
|
+
* which is the one way to store a shape a schema does not describe. Same
|
|
40
|
+
* reason as ArrayFieldDef for making it a declaration rather than an
|
|
41
|
+
* omission. See docs/spec/data-model.md § Undeclared content fields.
|
|
42
|
+
*/
|
|
43
|
+
export type ObjectFieldDef = {
|
|
44
|
+
kind: 'object';
|
|
45
|
+
properties: TypeSchema;
|
|
46
|
+
open?: false;
|
|
47
|
+
required?: boolean;
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'object';
|
|
50
|
+
open: true;
|
|
51
|
+
properties?: undefined;
|
|
52
|
+
required?: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* A field definition in a Type schema. Supports scalars, arrays, and nested
|
|
56
|
+
* objects. Arrays and nested objects are schema-validated on write but are
|
|
57
|
+
* opaque to the query engine in v1 — only top-level scalar fields support
|
|
58
|
+
* exact-match content filtering in queries.
|
|
59
|
+
*/
|
|
60
|
+
export type FieldDef = ScalarFieldDef | ArrayFieldDef | ObjectFieldDef;
|
|
61
|
+
export type TypeSchema = {
|
|
62
|
+
[fieldName: string]: FieldDef;
|
|
63
|
+
};
|
|
64
|
+
export type StackType = {
|
|
65
|
+
id: TypeId;
|
|
66
|
+
baseId: BaseId;
|
|
67
|
+
version: number;
|
|
68
|
+
name: string;
|
|
69
|
+
schema: TypeSchema;
|
|
70
|
+
schemaHash: string;
|
|
71
|
+
migratesFrom?: TypeId;
|
|
72
|
+
createdAt: Date;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,MAAM,eAAe,GACvB,QAAQ,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,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content shapes for the reserved `_`-prefixed system types.
|
|
3
|
+
*/
|
|
4
|
+
import type { Grantee } from './associations.js';
|
|
5
|
+
import type { TypeId, BaseId, FileId, AppId, EntityId } from './ids.js';
|
|
6
|
+
/**
|
|
7
|
+
* Content for _entity records: a stack-local profile card *about* a DID,
|
|
8
|
+
* not the identity itself. `name`/`handle` are this owner's local labels
|
|
9
|
+
* for that DID (the petname pattern), so two stacks holding different
|
|
10
|
+
* names for the same DID is correct. See docs/spec/identity.md § Entity.
|
|
11
|
+
*/
|
|
12
|
+
export type EntityContent = {
|
|
13
|
+
/**
|
|
14
|
+
* The identity this profile is about. e.g. "did:key:z6Mk...". A binding,
|
|
15
|
+
* not a value — an Actor's `subjectId` resolves through it to the name
|
|
16
|
+
* this card carries, so it is unique per stack and immutable once set.
|
|
17
|
+
* See docs/spec/identity.md § DID bindings.
|
|
18
|
+
*/
|
|
19
|
+
did: string;
|
|
20
|
+
/** Display name — human-friendly, not necessarily unique. May contain spaces and punctuation. e.g. "Jane Smith" */
|
|
21
|
+
name: string;
|
|
22
|
+
/**
|
|
23
|
+
* Short, conventionally URL-safe label. e.g. "janesmith". A label, not a
|
|
24
|
+
* key: duplicates are legitimate and `did` is what identifies this
|
|
25
|
+
* profile. See docs/spec/identity.md § Entity.
|
|
26
|
+
*/
|
|
27
|
+
handle?: string;
|
|
28
|
+
};
|
|
29
|
+
/** Content for _app records */
|
|
30
|
+
export type AppContent = {
|
|
31
|
+
/**
|
|
32
|
+
* The software this card is about, in reverse-DNS form — the value a
|
|
33
|
+
* Record's `appId` is checked against. Distinct from the card Record's
|
|
34
|
+
* own `appId`, which names whatever wrote the card (an admin console
|
|
35
|
+
* registering a third-party app is the ordinary case, and the two differ
|
|
36
|
+
* there). See docs/spec/identity.md § App.
|
|
37
|
+
*/
|
|
38
|
+
appId: AppId;
|
|
39
|
+
/** Display name of the app e.g. "My Notes App" */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Semver string e.g. "1.0.0". `appId` is the machine-readable identity, so no handle is needed here. */
|
|
42
|
+
version?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The DID this app authenticates with, when it holds a key of its own —
|
|
45
|
+
* what an Actor's `principalId` resolves to, and what a self-reported
|
|
46
|
+
* `appId` is checked against. Absent for apps that ride their user's
|
|
47
|
+
* identity. Unique and immutable: docs/spec/identity.md § DID bindings.
|
|
48
|
+
*/
|
|
49
|
+
did?: string;
|
|
50
|
+
};
|
|
51
|
+
/** Content for _group records */
|
|
52
|
+
export type GroupContent = {
|
|
53
|
+
/** Display name — human-friendly, not necessarily unique. May contain spaces and punctuation. e.g. "Jane's Book Club" */
|
|
54
|
+
name: string;
|
|
55
|
+
/**
|
|
56
|
+
* Short, conventionally URL-safe label. e.g. "janes-book-club". A label,
|
|
57
|
+
* not a key: duplicates are legitimate, and a group is addressed by
|
|
58
|
+
* `stackUrl` when it has one and by its record id otherwise. See
|
|
59
|
+
* docs/spec/identity.md § Group.
|
|
60
|
+
*/
|
|
61
|
+
handle?: string;
|
|
62
|
+
/** If present, this group owns a shared collaborative stack at this URL. Absent = permission-only group. */
|
|
63
|
+
stackUrl?: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Actions that can be granted via a _grant record. The array is the source
|
|
67
|
+
* of truth — GrantAction is derived from it so runtime validation (see
|
|
68
|
+
* Stack.grantType()) can't drift from the type.
|
|
69
|
+
*/
|
|
70
|
+
export declare const GRANT_ACTIONS: readonly ["create", "read-own", "read-any", "update-own", "update-any", "delete-own", "delete-any"];
|
|
71
|
+
export type GrantAction = (typeof GRANT_ACTIONS)[number];
|
|
72
|
+
/**
|
|
73
|
+
* Who a Grant reaches. `authenticated` is any authenticated entity —
|
|
74
|
+
* narrower than a Record permission's `anyone`, which reaches anonymous
|
|
75
|
+
* requesters too, so the two tiers deliberately share no word.
|
|
76
|
+
* See docs/spec/access-control.md § Type-level grants.
|
|
77
|
+
*/
|
|
78
|
+
export type GrantGrantee = Grantee | {
|
|
79
|
+
kind: 'authenticated';
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* What `Stack.grantType()` and `Stack.revokeType()` take beside the type they act
|
|
83
|
+
* on — the type-level counterpart of the `AuthorityAssociation`
|
|
84
|
+
* `grantAccess()` takes beside a record id.
|
|
85
|
+
*/
|
|
86
|
+
export type TypeGrant = {
|
|
87
|
+
actions: GrantAction[];
|
|
88
|
+
grantee: GrantGrantee;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Content for _grant records: a TypeGrant pinned to the type family it
|
|
92
|
+
* applies to — a bare baseId, never a versioned TypeId.
|
|
93
|
+
*/
|
|
94
|
+
export type GrantContent = TypeGrant & {
|
|
95
|
+
baseId: BaseId;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* One type-level grant an app's manifest asks for. No grantee: the app's
|
|
99
|
+
* own keys are who it reaches. See docs/spec/apps.md.
|
|
100
|
+
*/
|
|
101
|
+
export type InstallRequest = Omit<GrantContent, 'grantee'>;
|
|
102
|
+
/**
|
|
103
|
+
* Content for _install records: what the owner approved of an app's
|
|
104
|
+
* manifest, one live record per `appId`. See docs/spec/apps.md.
|
|
105
|
+
*/
|
|
106
|
+
export type InstallContent = {
|
|
107
|
+
/**
|
|
108
|
+
* The software this install is for. A binding: immutable, and unique
|
|
109
|
+
* among installs, so one install answers for each app.
|
|
110
|
+
*/
|
|
111
|
+
appId: AppId;
|
|
112
|
+
name: string;
|
|
113
|
+
version?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Every type version the owner has approved for this app. The families
|
|
116
|
+
* they name are claimed by this install and by no other.
|
|
117
|
+
*/
|
|
118
|
+
defines: TypeId[];
|
|
119
|
+
/** The grants each of the app's keys holds. */
|
|
120
|
+
requests: InstallRequest[];
|
|
121
|
+
};
|
|
122
|
+
/** Content for _attachment records — one per upload, tracks file metadata. */
|
|
123
|
+
export type AttachmentContent = {
|
|
124
|
+
/** Content-addressed file identifier (SHA-256 hex). */
|
|
125
|
+
fileId: FileId;
|
|
126
|
+
/** MIME type of the file. */
|
|
127
|
+
mimeType: string;
|
|
128
|
+
/** File size in bytes. */
|
|
129
|
+
size: number;
|
|
130
|
+
/** Original filename, if provided at upload time. */
|
|
131
|
+
filename?: string;
|
|
132
|
+
};
|
|
133
|
+
/** Content for _config records — one singleton per stack, created on initialization. */
|
|
134
|
+
export type ConfigContent = {
|
|
135
|
+
/**
|
|
136
|
+
* DID of the stack owner. Immutable — see docs/spec.md § The `_config`
|
|
137
|
+
* record for why ownership transfer isn't a field write.
|
|
138
|
+
*/
|
|
139
|
+
entityId: EntityId;
|
|
140
|
+
/**
|
|
141
|
+
* IANA timezone string e.g. "America/New_York". Optional passthrough app
|
|
142
|
+
* metadata — nothing in core reads it for behavior, and there is no
|
|
143
|
+
* default. See docs/spec.md § The `_config` record.
|
|
144
|
+
*/
|
|
145
|
+
timezone?: string;
|
|
146
|
+
};
|
|
147
|
+
/** Reserved system type IDs */
|
|
148
|
+
export declare const SYSTEM_TYPES: {
|
|
149
|
+
readonly ENTITY: "_entity";
|
|
150
|
+
readonly APP: "_app";
|
|
151
|
+
readonly GROUP: "_group";
|
|
152
|
+
/** Creation-permission grants. See GrantContent. */
|
|
153
|
+
readonly GRANT: "_grant";
|
|
154
|
+
/** Attachment metadata records. See AttachmentContent. */
|
|
155
|
+
readonly ATTACHMENT: "_attachment";
|
|
156
|
+
/** Stack-level configuration singleton. See ConfigContent. */
|
|
157
|
+
readonly CONFIG: "_config";
|
|
158
|
+
/** An owner's approval of an app's manifest. See InstallContent. */
|
|
159
|
+
readonly INSTALL: "_install";
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/types/system.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,mHAAmH;IACnH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,+BAA+B;AAC/B,MAAM,MAAM,UAAU,GAAG;IACvB;;;;;;OAMG;IACH,KAAK,EAAE,KAAK,CAAC;IACb,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,yGAAyG;IACzG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG;IACzB,yHAAyH;IACzH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MA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oDAAoD;;IAEpD,0DAA0D;;IAE1D,8DAA8D;;IAE9D,oEAAoE;;CAE5D,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content shapes for the reserved `_`-prefixed system types.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Actions that can be granted via a _grant record. The array is the source
|
|
6
|
+
* of truth — GrantAction is derived from it so runtime validation (see
|
|
7
|
+
* Stack.grantType()) can't drift from the type.
|
|
8
|
+
*/
|
|
9
|
+
export const GRANT_ACTIONS = [
|
|
10
|
+
'create',
|
|
11
|
+
'read-own',
|
|
12
|
+
'read-any',
|
|
13
|
+
'update-own',
|
|
14
|
+
'update-any',
|
|
15
|
+
'delete-own',
|
|
16
|
+
'delete-any',
|
|
17
|
+
];
|
|
18
|
+
/** Reserved system type IDs */
|
|
19
|
+
export const SYSTEM_TYPES = {
|
|
20
|
+
ENTITY: '_entity',
|
|
21
|
+
APP: '_app',
|
|
22
|
+
GROUP: '_group',
|
|
23
|
+
/** Creation-permission grants. See GrantContent. */
|
|
24
|
+
GRANT: '_grant',
|
|
25
|
+
/** Attachment metadata records. See AttachmentContent. */
|
|
26
|
+
ATTACHMENT: '_attachment',
|
|
27
|
+
/** Stack-level configuration singleton. See ConfigContent. */
|
|
28
|
+
CONFIG: '_config',
|
|
29
|
+
/** An owner's approval of an app's manifest. See InstallContent. */
|
|
30
|
+
INSTALL: '_install',
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/types/system.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,QAAQ;IACR,UAAU;IACV,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;CACJ,CAAC;AAoFX,+BAA+B;AAC/B,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,QAAQ;IACf,oDAAoD;IACpD,KAAK,EAAE,QAAQ;IACf,0DAA0D;IAC1D,UAAU,EAAE,aAAa;IACzB,8DAA8D;IAC9D,MAAM,EAAE,SAAS;IACjB,oEAAoE;IACpE,OAAO,EAAE,UAAU;CACX,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bearer-token issuance and lookup for server implementations.
|
|
3
|
+
*/
|
|
4
|
+
import type { EntityId, Actor } from './ids.js';
|
|
5
|
+
/**
|
|
6
|
+
* The two identities a token establishes — an Actor whose `principalId` is
|
|
7
|
+
* always populated, equal to `subjectId` on an undelegated token, so a
|
|
8
|
+
* server reading one never has to default it. Passes to `Stack.asActor()`
|
|
9
|
+
* as is. See docs/spec/access-control.md § Delegation: principal and subject.
|
|
10
|
+
*/
|
|
11
|
+
export type TokenSession = Actor & {
|
|
12
|
+
principalId: EntityId;
|
|
13
|
+
};
|
|
14
|
+
export type TokenInfo = TokenSession & {
|
|
15
|
+
id: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
expiresAt?: Date;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Bearer-token issuance and lookup for servers — standalone, not a slot on
|
|
22
|
+
* StackAdapter. createToken() trusts its caller: the handshake verifies the
|
|
23
|
+
* principal's DID first, and a differing `subjectId` is asserted by the
|
|
24
|
+
* owner out of band. Store tokens outside the portable stack file.
|
|
25
|
+
* See docs/spec/wire-format.md § Authentication.
|
|
26
|
+
*/
|
|
27
|
+
export interface StackTokenStore {
|
|
28
|
+
createToken(actor: Actor, opts?: {
|
|
29
|
+
label?: string;
|
|
30
|
+
expiresAt?: Date;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
id: string;
|
|
33
|
+
token: string;
|
|
34
|
+
}>;
|
|
35
|
+
lookupToken(token: string): Promise<TokenSession | null>;
|
|
36
|
+
listTokens(): Promise<TokenInfo[]>;
|
|
37
|
+
revokeToken(id: string): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/types/tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IACjC,WAAW,EAAE,QAAQ,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,WAAW,CACT,KAAK,EAAE,KAAK,EACZ,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,IAAI,CAAA;KAAE,GAC1C,OAAO,CAAC;QACT,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACzD,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/types/tokens.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/validate.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stack — Content Validation
|
|
2
|
+
* Stack — Content and Schema Validation
|
|
3
3
|
* -------------------------------------------------------
|
|
4
|
-
* Validates a Record's content object against a TypeSchema
|
|
5
|
-
*
|
|
4
|
+
* Validates a Record's content object against a TypeSchema, and a
|
|
5
|
+
* TypeSchema itself before it is defined — including the field-name rules
|
|
6
|
+
* both share, so no stored name is one a content filter cannot address.
|
|
7
|
+
* Every check returns a list of validation errors — empty means valid.
|
|
6
8
|
*
|
|
7
9
|
* Validates recursively for array and object field kinds.
|
|
8
10
|
* Coercion is never performed — types must match exactly.
|
|
9
11
|
*/
|
|
10
|
-
import type { TypeSchema } from './types.js';
|
|
12
|
+
import type { TypeSchema } from './types/index.js';
|
|
11
13
|
export type ValidationError = {
|
|
12
14
|
path: string;
|
|
13
15
|
message: string;
|
|
14
16
|
};
|
|
17
|
+
/** Shared by the 422 for a value outside the list and the 409 for removed values. */
|
|
18
|
+
export declare const formatEnumValues: (values: readonly string[]) => string;
|
|
15
19
|
/**
|
|
16
20
|
* Validate content against a schema, collecting all errors.
|
|
17
21
|
* @param content - The record's content object
|
|
@@ -28,23 +32,11 @@ export declare const validateContent: (content: Record<string, unknown>, schema:
|
|
|
28
32
|
*/
|
|
29
33
|
export declare const dropAbsentFields: (content: Record<string, unknown>, schema: TypeSchema) => Record<string, unknown>;
|
|
30
34
|
/**
|
|
31
|
-
* Content keys
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* That is not a prototype-pollution gadget today: JSON.stringify writes
|
|
37
|
-
* only own-enumerable properties, so a reassigned prototype never reaches
|
|
38
|
-
* storage, and JSON.parse recreates `__proto__` as an own property rather
|
|
39
|
-
* than invoking the setter, so a stored one round-trips inertly. The
|
|
40
|
-
* defect is that the two write paths disagree — a merge patch to
|
|
41
|
-
* `__proto__` silently vanishes, while the same key through create()
|
|
42
|
-
* stores as an ordinary field — and that a future refactor deepening the
|
|
43
|
-
* shallow merge would turn a quiet inconsistency into a real one.
|
|
44
|
-
*
|
|
45
|
-
* Rejecting is more honest than skipping: a caller who sends one of these
|
|
46
|
-
* finds out, rather than watching a write appear to succeed and do
|
|
47
|
-
* nothing. See docs/spec/data-model.md § Reserved content keys.
|
|
35
|
+
* Content keys naming JavaScript's object machinery rather than a field.
|
|
36
|
+
* Whether one survives a write would depend on how the code setting it was
|
|
37
|
+
* written — assignment drops `__proto__`, JSON.parse keeps it — so all
|
|
38
|
+
* three are refused at the write, and the caller finds out.
|
|
39
|
+
* See docs/spec/data-model.md § Reserved content keys.
|
|
48
40
|
*/
|
|
49
41
|
export declare const RESERVED_CONTENT_KEYS: readonly string[];
|
|
50
42
|
/**
|
|
@@ -52,61 +44,33 @@ export declare const RESERVED_CONTENT_KEYS: readonly string[];
|
|
|
52
44
|
* property, so it reaches none of the machinery above.
|
|
53
45
|
*/
|
|
54
46
|
export declare const validateReservedKeys: (content: Record<string, unknown>) => ValidationError[];
|
|
47
|
+
export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
55
48
|
/**
|
|
56
|
-
* Check that a schema is
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* out of hashSchema() rather than reporting anything, and a definition with
|
|
61
|
-
* an unknown `kind` — or none — defines a field whose every write fails
|
|
62
|
-
* against an expectation the schema never actually stated, sending the
|
|
63
|
-
* caller looking through their content for a bug that is in their type.
|
|
64
|
-
*
|
|
65
|
-
* Refused at definition time for the reason a field name no filter could
|
|
66
|
-
* address is: a schema is a promise, and one nothing can satisfy is worth
|
|
67
|
-
* catching where it is written. See docs/spec/data-model.md § Types.
|
|
49
|
+
* Check that a schema is a schema before anything reads it as one: off the
|
|
50
|
+
* wire it is JSON TypeScript never saw. A container declaring neither its
|
|
51
|
+
* interior nor `open` would throw out of hashSchema(), and an unknown `kind`
|
|
52
|
+
* would define a field every write fails. See docs/spec/data-model.md § Types.
|
|
68
53
|
*/
|
|
69
54
|
export declare const validateSchemaShape: (schema: unknown, prefix?: string, errors?: ValidationError[], depth?: number) => ValidationError[];
|
|
70
55
|
/**
|
|
71
|
-
* The same
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* A declaration cannot license what the content rule refuses, so accepting
|
|
77
|
-
* one would define a field no record could ever hold — and, where the
|
|
78
|
-
* declaration is `required`, a type no record could satisfy at all: supply
|
|
79
|
-
* the field and the write is refused as a reserved key, omit it and the
|
|
80
|
-
* write is refused as a missing required field. Refused at definition time
|
|
81
|
-
* for the reason a field name no filter could address is
|
|
82
|
-
* (validateSchemaFieldNames): a schema is a promise that a field is
|
|
83
|
-
* meaningful. See docs/spec/data-model.md § Reserved content keys.
|
|
56
|
+
* The same names, refused where a schema declares them, top-level only like
|
|
57
|
+
* the content rule. A declaration cannot license what that rule refuses, so
|
|
58
|
+
* it would define a field no record could hold — and if `required`, a type
|
|
59
|
+
* no record could satisfy. See docs/spec/data-model.md § Reserved content keys.
|
|
84
60
|
*/
|
|
85
61
|
export declare const validateSchemaReservedNames: (schema: TypeSchema) => ValidationError[];
|
|
86
62
|
/**
|
|
87
|
-
* `undefined` is not a value a merge patch can carry: `null`
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* field it names. Top-level only, matching the shallow merge — a nested
|
|
91
|
-
* one is part of a value being replaced wholesale.
|
|
63
|
+
* `undefined` is not a value a merge patch can carry: `null` deletes, JSON
|
|
64
|
+
* drops the key, and the presence checks read the key as a claim on its
|
|
65
|
+
* field. Top-level only, matching the shallow merge.
|
|
92
66
|
* See docs/spec/data-model.md § Undefined values in a patch.
|
|
93
67
|
*/
|
|
94
68
|
export declare const validatePatchValues: (patch: Record<string, unknown>) => ValidationError[];
|
|
95
69
|
/**
|
|
96
|
-
* Characters a
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* removed from the write side — where it is a validation error a caller
|
|
101
|
-
* can act on — rather than from the query side, where it would need an
|
|
102
|
-
* escape convention that silently misreads when a caller forgets it.
|
|
103
|
-
*
|
|
104
|
-
* Wider than what SQLite's JSON path grammar treats as syntax today (`.`,
|
|
105
|
-
* `[`, `]`, `$`, `"`): `*` and `#` are reserved against a path grammar
|
|
106
|
-
* that grows a wildcard or a last-element form. Narrowing a legal charset
|
|
107
|
-
* is a one-way door, so the cost of reserving a character now is nothing
|
|
108
|
-
* and the cost of reserving it later is every stored record.
|
|
109
|
-
*
|
|
70
|
+
* Characters a field name may not contain: a filter key is a dot-separated
|
|
71
|
+
* path, so a field named `emails.value` would make one filter mean two
|
|
72
|
+
* things. `*` and `#` are reserved ahead of the path grammar, as narrowing
|
|
73
|
+
* a legal charset later costs every stored record.
|
|
110
74
|
* See docs/spec/data-model.md § Content field names.
|
|
111
75
|
*/
|
|
112
76
|
export declare const CONTENT_KEY_PATH_METACHARACTERS: readonly [".", "[", "]", "$", "\"", "*", "#"];
|
|
@@ -124,9 +88,4 @@ export declare const validateContentKeys: (content: Record<string, unknown>) =>
|
|
|
124
88
|
* their own beyond the object properties nested under them.
|
|
125
89
|
*/
|
|
126
90
|
export declare const validateSchemaFieldNames: (schema: TypeSchema, prefix?: string, errors?: ValidationError[], depth?: number) => ValidationError[];
|
|
127
|
-
/**
|
|
128
|
-
* Returns true if the content is valid against the schema.
|
|
129
|
-
* Use validateContent() directly to get error details.
|
|
130
|
-
*/
|
|
131
|
-
export declare const isValid: (content: Record<string, unknown>, schema: TypeSchema) => boolean;
|
|
132
91
|
//# sourceMappingURL=validate.d.ts.map
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAU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