@haverstack/core 0.41.0 → 0.43.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 +124 -64
- package/dist/access.d.ts +43 -47
- package/dist/access.d.ts.map +1 -1
- package/dist/access.js +66 -101
- 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} +18 -3
- package/dist/adapter/combine.js.map +1 -0
- package/dist/adapter/index.d.ts +19 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +16 -0
- package/dist/adapter/index.js.map +1 -0
- package/dist/adapter/reach.d.ts +14 -0
- package/dist/adapter/reach.d.ts.map +1 -0
- package/dist/adapter/reach.js +31 -0
- package/dist/adapter/reach.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 +69 -0
- package/dist/associations/identity.d.ts.map +1 -0
- package/dist/associations/identity.js +174 -0
- package/dist/associations/identity.js.map +1 -0
- package/dist/associations/validation.d.ts +83 -0
- package/dist/associations/validation.d.ts.map +1 -0
- package/dist/associations/validation.js +312 -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 +178 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +397 -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 +54 -66
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +58 -62
- package/dist/errors.js.map +1 -1
- package/dist/grants.d.ts +20 -44
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +69 -151
- 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 +13 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +3 -6
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +6 -10
- package/dist/install.js.map +1 -1
- package/dist/lazy.d.ts +13 -0
- package/dist/lazy.d.ts.map +1 -0
- package/dist/lazy.js +27 -0
- package/dist/lazy.js.map +1 -0
- package/dist/merge.d.ts +1 -1
- package/dist/merge.d.ts.map +1 -1
- package/dist/merge.js +6 -12
- 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 +68 -121
- package/dist/query-validation.d.ts.map +1 -1
- package/dist/query-validation.js +214 -380
- package/dist/query-validation.js.map +1 -1
- package/dist/record-changes.d.ts +11 -150
- package/dist/record-changes.d.ts.map +1 -1
- package/dist/record-changes.js +14 -305
- 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-snapshot.d.ts +37 -0
- package/dist/scoped-stack/authority-snapshot.d.ts.map +1 -0
- package/dist/scoped-stack/authority-snapshot.js +49 -0
- package/dist/scoped-stack/authority-snapshot.js.map +1 -0
- package/dist/scoped-stack/authority.d.ts +169 -0
- package/dist/scoped-stack/authority.d.ts.map +1 -0
- package/dist/scoped-stack/authority.js +408 -0
- package/dist/scoped-stack/authority.js.map +1 -0
- package/dist/scoped-stack/family-policy.d.ts +59 -0
- package/dist/scoped-stack/family-policy.d.ts.map +1 -0
- package/dist/scoped-stack/family-policy.js +68 -0
- package/dist/scoped-stack/family-policy.js.map +1 -0
- package/dist/scoped-stack/scoped-stack.d.ts +318 -0
- package/dist/scoped-stack/scoped-stack.d.ts.map +1 -0
- package/dist/scoped-stack/scoped-stack.js +695 -0
- package/dist/scoped-stack/scoped-stack.js.map +1 -0
- package/dist/scoped-stack/subscription.d.ts +36 -0
- package/dist/scoped-stack/subscription.d.ts.map +1 -0
- package/dist/scoped-stack/subscription.js +69 -0
- package/dist/scoped-stack/subscription.js.map +1 -0
- package/dist/stack/arguments.d.ts +27 -0
- package/dist/stack/arguments.d.ts.map +1 -0
- package/dist/stack/arguments.js +53 -0
- package/dist/stack/arguments.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} +30 -72
- package/dist/stack/changes.d.ts.map +1 -0
- package/dist/{changes.js → stack/changes.js} +40 -74
- package/dist/stack/changes.js.map +1 -0
- package/dist/stack/client.d.ts +247 -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} +5 -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 +262 -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 +69 -0
- package/dist/stack/reads.d.ts.map +1 -0
- package/dist/stack/reads.js +141 -0
- 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 +444 -0
- package/dist/stack/stack.d.ts.map +1 -0
- package/dist/stack/stack.js +1339 -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 +79 -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/stack/write-gate.d.ts +23 -0
- package/dist/stack/write-gate.d.ts.map +1 -0
- package/dist/stack/write-gate.js +17 -0
- package/dist/stack/write-gate.js.map +1 -0
- package/dist/testing.d.ts +44 -33
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +180 -176
- 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 +282 -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 +140 -0
- package/dist/types/associations.d.ts.map +1 -0
- package/dist/types/associations.js +6 -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 +150 -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 +31 -70
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +52 -92
- 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} +35 -12
- package/dist/wire/body.d.ts.map +1 -0
- package/dist/{wire-body.js → wire/body.js} +74 -13
- 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 +31 -0
- package/dist/wire/record.d.ts.map +1 -0
- package/dist/{wire-record.js → wire/record.js} +7 -67
- package/dist/wire/record.js.map +1 -0
- package/dist/{wire-request.d.ts → wire/request.d.ts} +32 -49
- package/dist/wire/request.d.ts.map +1 -0
- package/dist/{wire-request.js → wire/request.js} +113 -83
- package/dist/wire/request.js.map +1 -0
- package/package.json +7 -7
- package/dist/adapter-entry.d.ts +0 -16
- package/dist/adapter-entry.d.ts.map +0 -1
- package/dist/adapter-entry.js +0 -14
- 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 -549
- package/dist/scoped-stack.d.ts.map +0 -1
- package/dist/scoped-stack.js +0 -1301
- 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 +0 -38
- package/dist/stack-reads.d.ts.map +0 -1
- package/dist/stack-reads.js +0 -79
- package/dist/stack-reads.js.map +0 -1
- package/dist/stack.d.ts +0 -1032
- package/dist/stack.d.ts.map +0 -1
- package/dist/stack.js +0 -2337
- package/dist/stack.js.map +0 -1
- package/dist/types.d.ts +0 -1278
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -51
- 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 +0 -50
- 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,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change events: what `subscribe()` delivers and the options it takes.
|
|
3
|
+
*/
|
|
4
|
+
import type { DataAssociation } from './associations.js';
|
|
5
|
+
import type { RecordId, TypeId, AppId, Actor } from './ids.js';
|
|
6
|
+
import type { RecordFilter } from './query.js';
|
|
7
|
+
import type { StackRecord } from './records.js';
|
|
8
|
+
/**
|
|
9
|
+
* The coarse branch every subscriber makes, closed at four values. A
|
|
10
|
+
* handler covering exactly these is complete, not merely adequate:
|
|
11
|
+
* `changed` is an upsert signal carrying nine distinct verbs.
|
|
12
|
+
* See docs/spec/events.md § The event shape.
|
|
13
|
+
*/
|
|
14
|
+
export type ChangeKind = 'created' | 'changed' | 'removed' | 'purged';
|
|
15
|
+
/**
|
|
16
|
+
* The precise verb behind a ChangeKind, for consumers that distinguish a
|
|
17
|
+
* reshare from an edit. Each is named after the call that produced it; see
|
|
18
|
+
* docs/spec/events.md § The event shape for the three that aren't a method
|
|
19
|
+
* name. `associate`, `dissociate`, `reshare`, `reparent`, `unlist` and
|
|
20
|
+
* `list` don't bump; see docs/spec/versioning.md § Version history.
|
|
21
|
+
*/
|
|
22
|
+
export type ChangeOp = 'create' | 'patch' | 'associate' | 'dissociate' | 'reshare' | 'migrate' | 'restore' | 'delete' | 'undelete' | 'purge'
|
|
23
|
+
/**
|
|
24
|
+
* Emitted even though the record's post-change state (`unlistedAt` now
|
|
25
|
+
* set) would otherwise be excluded by the same filter it announces —
|
|
26
|
+
* subscribers who already know the record need telling to drop it. See
|
|
27
|
+
* docs/spec/events.md § The unlisted transition.
|
|
28
|
+
*/
|
|
29
|
+
| 'unlist'
|
|
30
|
+
/** The publish moment — mechanically an upsert, like `undelete`. */
|
|
31
|
+
| 'list'
|
|
32
|
+
/**
|
|
33
|
+
* A move between containers. Matched by a `parentId` filter naming
|
|
34
|
+
* *either* side of the move, so a subscriber watching the old container
|
|
35
|
+
* learns the record left it — the record's post-change state alone
|
|
36
|
+
* would answer only for the destination. See docs/spec/events.md
|
|
37
|
+
* § The reparent transition.
|
|
38
|
+
*/
|
|
39
|
+
| 'reparent';
|
|
40
|
+
/**
|
|
41
|
+
* Who performed a change — never who authored the record. Absent from a
|
|
42
|
+
* RecordChange entirely when unknown, which means a write by an unscoped
|
|
43
|
+
* `Stack`: absence is a fact of its own and never stands in for the
|
|
44
|
+
* author. See docs/spec/events.md § Attribution.
|
|
45
|
+
*/
|
|
46
|
+
export type ChangeActor = Actor & {
|
|
47
|
+
/** Self-reported at create, never a trust input. See AppId. */
|
|
48
|
+
appId?: AppId;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* One change to one record. The envelope describes the change; the record
|
|
52
|
+
* describes the record, so nothing of the record's own provenance appears
|
|
53
|
+
* here — a consumer that wants it asks for `record`.
|
|
54
|
+
* See docs/spec/events.md § The event shape.
|
|
55
|
+
*/
|
|
56
|
+
export type RecordChange = {
|
|
57
|
+
kind: ChangeKind;
|
|
58
|
+
/**
|
|
59
|
+
* Every aspect this version moved, diffed against prior state rather
|
|
60
|
+
* than read off the request. Never empty; multi-entry only for an
|
|
61
|
+
* association write that both adds and removes.
|
|
62
|
+
* See docs/spec/events.md § The event shape.
|
|
63
|
+
*/
|
|
64
|
+
ops: ChangeOp[];
|
|
65
|
+
recordId: RecordId;
|
|
66
|
+
/** As stored at the moment of the change. */
|
|
67
|
+
typeId: TypeId;
|
|
68
|
+
/**
|
|
69
|
+
* The version this change produced; on `purged`, the version destroyed.
|
|
70
|
+
* Unchanged from the record's prior version on every op that doesn't
|
|
71
|
+
* bump — see ChangeOp.
|
|
72
|
+
*/
|
|
73
|
+
version: number;
|
|
74
|
+
/**
|
|
75
|
+
* As persisted by this change; on `purged`, when the delete ran.
|
|
76
|
+
* Unchanged from the record's prior `updatedAt` on every op that
|
|
77
|
+
* doesn't bump.
|
|
78
|
+
*/
|
|
79
|
+
updatedAt: Date;
|
|
80
|
+
parentId?: RecordId;
|
|
81
|
+
actor?: ChangeActor;
|
|
82
|
+
/**
|
|
83
|
+
* Associations now present that weren't before — current annotation
|
|
84
|
+
* included, so a re-point appears here under its new
|
|
85
|
+
* `attachmentRecordId`. Present whenever `ops` includes `associate`, on
|
|
86
|
+
* the same "as of this change" convention as every other field here.
|
|
87
|
+
*/
|
|
88
|
+
associationsAdded?: DataAssociation[];
|
|
89
|
+
/**
|
|
90
|
+
* Associations no longer present, identity only — kind and label, plus
|
|
91
|
+
* `fileId` for an attachment — present whenever `ops` includes
|
|
92
|
+
* `dissociate`. An attachment's `attachmentRecordId` is never repeated
|
|
93
|
+
* here, the same way a `purged` frame never carries what it destroyed.
|
|
94
|
+
*/
|
|
95
|
+
associationsRemoved?: DataAssociation[];
|
|
96
|
+
/**
|
|
97
|
+
* The record as of this change — present only when asked for and
|
|
98
|
+
* available, never on `purged`. Shared with every other subscriber on
|
|
99
|
+
* this emission, so a handler that needs to alter it copies first.
|
|
100
|
+
*/
|
|
101
|
+
record?: StackRecord;
|
|
102
|
+
/**
|
|
103
|
+
* Resume cursor, minted by a server. Local changes carry none, this
|
|
104
|
+
* stack's own writes included — so a consumer holding a cursor keeps
|
|
105
|
+
* the last one that was present rather than the last change's.
|
|
106
|
+
*/
|
|
107
|
+
cursor?: string;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Applied by the emitter, exactly: a filtered subscription never receives
|
|
111
|
+
* an event outside its filter, so filtering again is redundant rather than
|
|
112
|
+
* defensive. Every key means what it means on `RecordFilter`, so one value
|
|
113
|
+
* can drive both `query()` and `subscribe()`. See docs/spec/events.md
|
|
114
|
+
* § Subscribing.
|
|
115
|
+
*/
|
|
116
|
+
export type ChangeFilter = Pick<RecordFilter, 'typeId' | 'baseId' | 'parentId' | 'createdBy' | 'includeUnlisted'> & {
|
|
117
|
+
kinds?: ChangeKind[];
|
|
118
|
+
};
|
|
119
|
+
/** Ends a subscription. Safe to call more than once. */
|
|
120
|
+
export type Unsubscribe = () => void;
|
|
121
|
+
/**
|
|
122
|
+
* What a subscriber asks for, and what `Stack` forwards unchanged to an
|
|
123
|
+
* adapter's `subscribeChanges()` relay — the relay honors every key.
|
|
124
|
+
* See docs/spec/events.md § Subscribing and § Where events come from.
|
|
125
|
+
*/
|
|
126
|
+
export type SubscribeOptions = {
|
|
127
|
+
filter?: ChangeFilter;
|
|
128
|
+
/** Ask the emitter to include `record`. Honored when it can; never assume it. */
|
|
129
|
+
includeRecords?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Resume from this cursor — the last `cursor` that was *present* on a
|
|
132
|
+
* delivered `RecordChange`. Refused with `StackBadRequestError` on a
|
|
133
|
+
* stack with no relay, which has no cursor it could have minted.
|
|
134
|
+
* See docs/spec/events.md § Subscribing.
|
|
135
|
+
*/
|
|
136
|
+
since?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Where a throwing handler's error goes, and on a relaying stack a
|
|
139
|
+
* connection the relay could not restore. Without one a handler error is
|
|
140
|
+
* rethrown asynchronously; it never reaches the mutation's caller.
|
|
141
|
+
*/
|
|
142
|
+
onError?: (err: unknown) => void;
|
|
143
|
+
/**
|
|
144
|
+
* A gap opened that resumption could not close: reconcile by query.
|
|
145
|
+
* Never fires on a local stack. Can fire on the first connection when
|
|
146
|
+
* the far end will not honor `since`.
|
|
147
|
+
*/
|
|
148
|
+
onReset?: () => void;
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,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gB,GAAG;IAC7B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,iFAAiF;IACjF,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifiers, and the Actor that pairs two of them.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Crockford base-32 encoded ID — time-sortable, unique within a stack.
|
|
6
|
+
* Format: 9-char timestamp prefix + 3-char random suffix = 12 chars total.
|
|
7
|
+
* Human-readable and URL-safe. Uniqueness is within-stack only;
|
|
8
|
+
* cross-stack references must include a stackUrl to disambiguate.
|
|
9
|
+
*/
|
|
10
|
+
export type RecordId = string;
|
|
11
|
+
/** Namespaced, versioned type identifier e.g. "com.example.myapp/note@2" */
|
|
12
|
+
export type TypeId = string;
|
|
13
|
+
/** A type family: a TypeId without its version, e.g. "com.example.myapp/note" */
|
|
14
|
+
export type BaseId = string;
|
|
15
|
+
/** Opaque file identifier returned by putBlob() */
|
|
16
|
+
export type FileId = string;
|
|
17
|
+
/**
|
|
18
|
+
* Reverse-DNS identifier for the software that wrote a Record, e.g.
|
|
19
|
+
* "com.example.myapp" — not a RecordId. Self-reported and never a
|
|
20
|
+
* permission input; `StackRecord.createdBy.principalId` is the verified
|
|
21
|
+
* counterpart.
|
|
22
|
+
* See docs/spec/identity.md § App.
|
|
23
|
+
*/
|
|
24
|
+
export type AppId = string;
|
|
25
|
+
/**
|
|
26
|
+
* Identifies a "who" — a DID string, e.g. "did:key:z6Mk...". A
|
|
27
|
+
* self-certifying identifier that means the same thing in every stack,
|
|
28
|
+
* unlike a RecordId. did:key is the mandatory floor method (see did/did.ts).
|
|
29
|
+
* See docs/spec/identity.md.
|
|
30
|
+
*/
|
|
31
|
+
export type EntityId = string;
|
|
32
|
+
/**
|
|
33
|
+
* Who did something, and through which principal. `subjectId` is who the
|
|
34
|
+
* act is attributed to; `principalId` is who authenticated, present only
|
|
35
|
+
* when it differs — a delegated app acting for its user. `Stack` stores
|
|
36
|
+
* a `principalId` equal to `subjectId` as absent, so the two spellings of
|
|
37
|
+
* "acted as itself" never diverge. See docs/spec/data-model.md § Actor.
|
|
38
|
+
*/
|
|
39
|
+
export type Actor = {
|
|
40
|
+
subjectId: EntityId;
|
|
41
|
+
principalId?: EntityId;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/types/ids.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,4EAA4E;AAC5E,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,iFAAiF;AACjF,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,mDAAmD;AACnD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,QAAQ,CAAC;IACpB,WAAW,CAAC,EAAE,QAAQ,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/types/ids.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack — Core Type Definitions
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* The source of truth for all types in the Stack library, one module per
|
|
5
|
+
* concern. No logic lives here — just shapes. Import from this barrel
|
|
6
|
+
* rather than from a module, so a type can move without touching callers.
|
|
7
|
+
*/
|
|
8
|
+
export * from './ids.js';
|
|
9
|
+
export * from './associations.js';
|
|
10
|
+
export * from './records.js';
|
|
11
|
+
export * from './schema.js';
|
|
12
|
+
export * from './system.js';
|
|
13
|
+
export * from './query.js';
|
|
14
|
+
export * from './capabilities.js';
|
|
15
|
+
export * from './journal.js';
|
|
16
|
+
export * from './events.js';
|
|
17
|
+
export * from './adapter.js';
|
|
18
|
+
export * from './tokens.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack — Core Type Definitions
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* The source of truth for all types in the Stack library, one module per
|
|
5
|
+
* concern. No logic lives here — just shapes. Import from this barrel
|
|
6
|
+
* rather than from a module, so a type can move without touching callers.
|
|
7
|
+
*/
|
|
8
|
+
export * from './ids.js';
|
|
9
|
+
export * from './associations.js';
|
|
10
|
+
export * from './records.js';
|
|
11
|
+
export * from './schema.js';
|
|
12
|
+
export * from './system.js';
|
|
13
|
+
export * from './query.js';
|
|
14
|
+
export * from './capabilities.js';
|
|
15
|
+
export * from './journal.js';
|
|
16
|
+
export * from './events.js';
|
|
17
|
+
export * from './adapter.js';
|
|
18
|
+
export * from './tokens.js';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The change journal: the per-record log of what each write moved.
|
|
3
|
+
*/
|
|
4
|
+
import type { AssociationChange } from './associations.js';
|
|
5
|
+
import type { ChangeKind, ChangeOp, ChangeActor } from './events.js';
|
|
6
|
+
import type { RecordId, TypeId } from './ids.js';
|
|
7
|
+
/**
|
|
8
|
+
* The part of a change the record cannot report once the write has
|
|
9
|
+
* landed: which aspects moved, who moved them, and what an association
|
|
10
|
+
* mutation displaced. The adapter stamps the rest of the entry from the
|
|
11
|
+
* row it just wrote, so the two never drift. See docs/spec/journal.md.
|
|
12
|
+
*/
|
|
13
|
+
export type JournalEntryInput = {
|
|
14
|
+
ops: ChangeOp[];
|
|
15
|
+
kind: ChangeKind;
|
|
16
|
+
actor?: ChangeActor;
|
|
17
|
+
/** The container a move took the record out of, `null` for the root. */
|
|
18
|
+
previousParentId?: RecordId | null;
|
|
19
|
+
/**
|
|
20
|
+
* What an association mutation moved, one tagged edit per association,
|
|
21
|
+
* with `previous` beside whatever displaced it.
|
|
22
|
+
* See docs/spec/journal.md § The entry.
|
|
23
|
+
*/
|
|
24
|
+
associations?: AssociationChange[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One durable entry in a record's change journal. Envelope only — content
|
|
28
|
+
* lives on a RecordVersion. See docs/spec/journal.md § Ordering for why
|
|
29
|
+
* `seq` is the only ordering.
|
|
30
|
+
*/
|
|
31
|
+
export type RecordJournalEntry = JournalEntryInput & {
|
|
32
|
+
seq: number;
|
|
33
|
+
/** When the entry was appended — not the record's `updatedAt`, which an association change leaves alone. */
|
|
34
|
+
at: Date;
|
|
35
|
+
/** The version this change produced — unchanged on an op that doesn't bump; see ChangeOp. */
|
|
36
|
+
version: number;
|
|
37
|
+
typeId: TypeId;
|
|
38
|
+
/** Where the record sat after the change, absent for the root. */
|
|
39
|
+
parentId?: RecordId;
|
|
40
|
+
};
|
|
41
|
+
/** Window into a record's journal. Omitting both reads the whole log, oldest first. */
|
|
42
|
+
export type JournalQuery = {
|
|
43
|
+
/** Entries after this seq, exclusive. */
|
|
44
|
+
afterSeq?: number;
|
|
45
|
+
limit?: number;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=journal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../src/types/journal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,QAAQ,EAAE,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,4GAA4G;IAC5G,EAAE,EAAE,IAAI,CAAC;IACT,6FAA6F;IAC7F,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG;IACzB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal.js","sourceRoot":"","sources":["../../src/types/journal.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query filters, sorting, and the page a query returns.
|
|
3
|
+
*/
|
|
4
|
+
import type { RecordId, TypeId, BaseId, FileId, AppId, EntityId } from './ids.js';
|
|
5
|
+
import type { StackRecord } from './records.js';
|
|
6
|
+
/**
|
|
7
|
+
* A target pattern in `RecordFilter.relatedTo` — the association shape with
|
|
8
|
+
* the parts a query may leave open: an `external` target without `id`
|
|
9
|
+
* matches its whole namespace.
|
|
10
|
+
*/
|
|
11
|
+
export type RelationshipTargetPattern = {
|
|
12
|
+
kind: 'record';
|
|
13
|
+
recordId: RecordId;
|
|
14
|
+
stackUrl?: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'entity';
|
|
17
|
+
entityId: EntityId;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'external';
|
|
20
|
+
ns: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A relationship query names a label, a target, or both — never neither.
|
|
25
|
+
* "Carries any relationship at all" is deliberately not expressible, in
|
|
26
|
+
* line with `tags` and `attachment`, which likewise have no match-any
|
|
27
|
+
* form. See docs/spec/data-model.md § Filter.
|
|
28
|
+
*/
|
|
29
|
+
export type RelatedToFilter = {
|
|
30
|
+
label: string;
|
|
31
|
+
target?: RelationshipTargetPattern;
|
|
32
|
+
} | {
|
|
33
|
+
label?: string;
|
|
34
|
+
target: RelationshipTargetPattern;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* An attachment query names a label, a file, or both — never neither —
|
|
38
|
+
* and both halves together match one association. See
|
|
39
|
+
* docs/spec/data-model.md § Filter.
|
|
40
|
+
*/
|
|
41
|
+
export type AttachmentFilter = {
|
|
42
|
+
label: string;
|
|
43
|
+
fileId?: FileId;
|
|
44
|
+
} | {
|
|
45
|
+
label?: string;
|
|
46
|
+
fileId: FileId;
|
|
47
|
+
};
|
|
48
|
+
export type DateRange = {
|
|
49
|
+
before?: Date;
|
|
50
|
+
after?: Date;
|
|
51
|
+
};
|
|
52
|
+
/** One Type's arm of `RecordFilter.contentByType`, flat by design. */
|
|
53
|
+
export type ContentArm = {
|
|
54
|
+
content?: Record<string, unknown>;
|
|
55
|
+
contentPresent?: string[];
|
|
56
|
+
};
|
|
57
|
+
export type RecordFilter = {
|
|
58
|
+
typeId?: TypeId | TypeId[];
|
|
59
|
+
/**
|
|
60
|
+
* Match every version of a type family: a record whose typeId, without
|
|
61
|
+
* its `@version` suffix, is one of these. Intersects with `typeId` when
|
|
62
|
+
* both are given. A value carrying an `@version` suffix is refused with
|
|
63
|
+
* StackValidationError. See docs/spec/data-model.md § Filter.
|
|
64
|
+
*/
|
|
65
|
+
baseId?: BaseId | BaseId[];
|
|
66
|
+
parentId?: RecordId | null;
|
|
67
|
+
appId?: AppId | AppId[];
|
|
68
|
+
/** Matches the record's author — never the latest actor, which isn't filterable. */
|
|
69
|
+
createdBy?: {
|
|
70
|
+
subjectId?: EntityId | EntityId[];
|
|
71
|
+
principalId?: EntityId | EntityId[];
|
|
72
|
+
};
|
|
73
|
+
createdAt?: DateRange;
|
|
74
|
+
updatedAt?: DateRange;
|
|
75
|
+
tags?: string[];
|
|
76
|
+
/** Records carrying a matching attachment association. See docs/spec/data-model.md § Filter. */
|
|
77
|
+
attachment?: AttachmentFilter;
|
|
78
|
+
/**
|
|
79
|
+
* Records carrying a matching relationship association. Either half may
|
|
80
|
+
* be given alone and each is a pattern: a bare `label` matches every
|
|
81
|
+
* target under it, and an `external` target with no `id` matches the
|
|
82
|
+
* whole namespace. An absent `stackUrl` on a `record` target matches
|
|
83
|
+
* only local targets. See docs/spec/data-model.md § Filter.
|
|
84
|
+
*/
|
|
85
|
+
relatedTo?: RelatedToFilter;
|
|
86
|
+
/**
|
|
87
|
+
* Records that reference this file, through an attachment association
|
|
88
|
+
* or a top-level `file-ref` content field — the question GC and
|
|
89
|
+
* `deleteAttachment()` ask. See docs/spec/attachments.md § Deleting attachments.
|
|
90
|
+
*/
|
|
91
|
+
referencesFileId?: FileId;
|
|
92
|
+
/**
|
|
93
|
+
* Exact match on content fields, keyed by a dot-separated path
|
|
94
|
+
* (`'emails.value'`); an array along the path matches element-wise. A
|
|
95
|
+
* multi-segment key needs `filter.content: 'path'`. POST /records/query
|
|
96
|
+
* only. See docs/spec/data-model.md § Filter.
|
|
97
|
+
*/
|
|
98
|
+
content?: Record<string, unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* Paths that must hold a non-null value — the question `content` cannot
|
|
101
|
+
* ask. Element-wise like `content`. Needs `filter.contentPresent`.
|
|
102
|
+
* POST /records/query only. See docs/spec/data-model.md § Filter.
|
|
103
|
+
*/
|
|
104
|
+
contentPresent?: string[];
|
|
105
|
+
/**
|
|
106
|
+
* A content predicate per Type: a record matches when its `typeId` is a
|
|
107
|
+
* key and its content satisfies that arm. Generated by a collection from
|
|
108
|
+
* a migration chain; never beside `content` or `contentPresent`. Needs
|
|
109
|
+
* `filter.contentByType`. POST /records/query only. See
|
|
110
|
+
* docs/spec/data-model.md § Content by type.
|
|
111
|
+
*/
|
|
112
|
+
contentByType?: Record<TypeId, ContentArm>;
|
|
113
|
+
search?: string;
|
|
114
|
+
includeDeleted?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Unlisted records are excluded by default, like soft-deleted ones.
|
|
117
|
+
* Owner-only under `ScopedStack` — enumeration standing rests on nothing
|
|
118
|
+
* but ownership, so a grant or delegation never carries it. See
|
|
119
|
+
* docs/spec/unlisted.md.
|
|
120
|
+
*/
|
|
121
|
+
includeUnlisted?: boolean;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* The Record columns every adapter stores natively, and can order by. The
|
|
125
|
+
* array is the source of truth, so the runtime checks that narrow a wire
|
|
126
|
+
* value or a cursor to this set can't drift from NativeSortField.
|
|
127
|
+
*/
|
|
128
|
+
export declare const NATIVE_SORT_FIELDS: readonly ["createdAt", "updatedAt", "version"];
|
|
129
|
+
export type NativeSortField = (typeof NATIVE_SORT_FIELDS)[number];
|
|
130
|
+
/**
|
|
131
|
+
* What a record at one Type orders by under `contentFieldByType`: a
|
|
132
|
+
* top-level field of its own, or a constant already reduced to what it
|
|
133
|
+
* orders as — a number, text, or `null` for no value.
|
|
134
|
+
*/
|
|
135
|
+
export type ContentSortKey = {
|
|
136
|
+
field: string;
|
|
137
|
+
value?: never;
|
|
138
|
+
} | {
|
|
139
|
+
field?: never;
|
|
140
|
+
value: string | number | null;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Order by a native column, a top-level content field, or a content field
|
|
144
|
+
* per Type — separate members, so a content field named `version` stays
|
|
145
|
+
* distinct from the native column. `direction` defaults to `asc`; a query
|
|
146
|
+
* with no sort is `createdAt`, newest first. See docs/spec/data-model.md
|
|
147
|
+
* § Sorting by a content field.
|
|
148
|
+
*/
|
|
149
|
+
export type QuerySort = {
|
|
150
|
+
field: NativeSortField;
|
|
151
|
+
contentField?: never;
|
|
152
|
+
contentFieldByType?: never;
|
|
153
|
+
direction?: 'asc' | 'desc';
|
|
154
|
+
} | {
|
|
155
|
+
field?: never;
|
|
156
|
+
contentField: string;
|
|
157
|
+
contentFieldByType?: never;
|
|
158
|
+
direction?: 'asc' | 'desc';
|
|
159
|
+
} | {
|
|
160
|
+
field?: never;
|
|
161
|
+
contentField?: never;
|
|
162
|
+
contentFieldByType: Record<TypeId, ContentSortKey>;
|
|
163
|
+
direction?: 'asc' | 'desc';
|
|
164
|
+
};
|
|
165
|
+
export type StackQuery = {
|
|
166
|
+
filter?: RecordFilter;
|
|
167
|
+
sort?: QuerySort;
|
|
168
|
+
limit?: number;
|
|
169
|
+
cursor?: string;
|
|
170
|
+
/**
|
|
171
|
+
* "stored" (the default) returns records as stored; "latest" applies the
|
|
172
|
+
* migration chain in memory, never written back. Throws
|
|
173
|
+
* StackMigrationError if a matched record has no path to the latest.
|
|
174
|
+
*/
|
|
175
|
+
presentAt?: 'stored' | 'latest';
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* A page of results and where the next one resumes. There is no count of
|
|
179
|
+
* the whole match: see docs/spec/data-model.md § Sorting and pagination.
|
|
180
|
+
*/
|
|
181
|
+
export type QueryResult = {
|
|
182
|
+
records: StackRecord[];
|
|
183
|
+
cursor: string | null;
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/types/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAA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I,CAAA;CAAE,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GACjB;IACE,KAAK,EAAE,eAAe,CAAC;IACvB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,kBAAkB,CAAC,EAAE,KAAK,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC5B,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,KAAK,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC5B,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACnD,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC5B,CAAC;AAEN,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query filters, sorting, and the page a query returns.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The Record columns every adapter stores natively, and can order by. The
|
|
6
|
+
* array is the source of truth, so the runtime checks that narrow a wire
|
|
7
|
+
* value or a cursor to this set can't drift from NativeSortField.
|
|
8
|
+
*/
|
|
9
|
+
export const NATIVE_SORT_FIELDS = ['createdAt', 'updatedAt', 'version'];
|
|
10
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/types/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AA2HH;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,CAAU,CAAC"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"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