@powerhousedao/shared 6.2.3-dev.101 → 6.2.3-dev.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/clis/args/migrate.d.mts +9 -0
  2. package/dist/clis/args/migrate.d.mts.map +1 -1
  3. package/dist/clis/args/migrate.mjs +17 -1
  4. package/dist/clis/args/migrate.mjs.map +1 -1
  5. package/dist/clis/args/service-CLCvH3kf.d.mts.map +1 -1
  6. package/dist/clis/build-pieces.d.mts +1 -1
  7. package/dist/clis/constants.d.mts +1 -1
  8. package/dist/clis/definition-sources.d.mts +11 -42
  9. package/dist/clis/definition-sources.d.mts.map +1 -1
  10. package/dist/clis/definition-sources.mjs +12 -83
  11. package/dist/clis/definition-sources.mjs.map +1 -1
  12. package/dist/clis/index.d.mts +14 -76
  13. package/dist/clis/index.d.mts.map +1 -1
  14. package/dist/clis/index.mjs +17 -67
  15. package/dist/clis/index.mjs.map +1 -1
  16. package/dist/clis/{types-Qy1GBoTY.d.mts → types-AG9WBhp7.d.mts} +6 -5
  17. package/dist/clis/types-AG9WBhp7.d.mts.map +1 -0
  18. package/dist/connect/config-loader.d.ts +1 -1
  19. package/dist/connect/index.d.ts +1 -1
  20. package/dist/document-drive/index.d.ts +3 -3
  21. package/dist/document-drive/index.js +1 -1
  22. package/dist/document-model/dispatch.d.ts +1 -1
  23. package/dist/document-model/errors.d.ts +1 -1
  24. package/dist/document-model/index.d.ts +2 -2
  25. package/dist/document-model/index.js +1 -1
  26. package/dist/document-model/utils.d.ts +1 -1
  27. package/dist/{document-model-TCCW8aMC.js → document-model-CqySIaKV.js} +12 -2
  28. package/dist/document-model-CqySIaKV.js.map +1 -0
  29. package/dist/{index-C_lizUqn.d.ts → index-CUZ8eWun.d.ts} +2 -2
  30. package/dist/{index-C_lizUqn.d.ts.map → index-CUZ8eWun.d.ts.map} +1 -1
  31. package/dist/index.d.ts +3 -3
  32. package/dist/processors/index.d.ts +1 -1
  33. package/dist/processors/testing.d.ts +1 -1
  34. package/dist/registry/index.d.ts +2 -2
  35. package/dist/registry/manifest-slim.d.ts +2 -2
  36. package/dist/{types-cIIv_Rsg.d.ts → types-CV2j3BvH.d.ts} +2060 -2061
  37. package/dist/types-CV2j3BvH.d.ts.map +1 -0
  38. package/dist/{types-BuEzD0jp.d.ts → types-D_6ZcaJj.d.ts} +2 -2
  39. package/dist/{types-BuEzD0jp.d.ts.map → types-D_6ZcaJj.d.ts.map} +1 -1
  40. package/package.json +1 -1
  41. package/dist/clis/definition-types-CiUH8dqg.d.mts +0 -18
  42. package/dist/clis/definition-types-CiUH8dqg.d.mts.map +0 -1
  43. package/dist/clis/types-Qy1GBoTY.d.mts.map +0 -1
  44. package/dist/document-model-TCCW8aMC.js.map +0 -1
  45. package/dist/types-cIIv_Rsg.d.ts.map +0 -1
@@ -9,1931 +9,1378 @@ import { DispatchOutcome, DocumentDispatch, DocumentDispatch as DocumentDispatch
9
9
  import { OperationWithContext } from "@powerhousedao/shared/document-model";
10
10
  import { IncomingMessage, ServerResponse } from "node:http";
11
11
  import { FC, ReactNode } from "react";
12
- //#region document-model/definition-types.d.ts
13
- type JsonPrimitive = string | number | boolean | null;
14
- type JsonValue = JsonPrimitive | readonly JsonValue[] | {
15
- readonly [key: string]: JsonValue;
12
+ //#region clis/args/common.d.ts
13
+ declare const getPackageManagerCommand: Partial<import("cmd-ts/dist/cjs/argparser.js").Register> & {
14
+ parse(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<{
15
+ packageManager: Agent | undefined;
16
+ npm: boolean | undefined;
17
+ pnpm: boolean | undefined;
18
+ yarn: boolean | undefined;
19
+ bun: boolean | undefined;
20
+ }>>;
21
+ } & import("cmd-ts/dist/cjs/helpdoc.js").PrintHelp & import("cmd-ts/dist/cjs/helpdoc.js").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc.js").Named & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned> & import("cmd-ts/dist/cjs/argparser.js").Register & import("cmd-ts/dist/cjs/runner.js").Handling<{
22
+ packageManager: Agent | undefined;
23
+ npm: boolean | undefined;
24
+ pnpm: boolean | undefined;
25
+ yarn: boolean | undefined;
26
+ bun: boolean | undefined;
27
+ }, {
28
+ packageManager: Agent | undefined;
29
+ npm: boolean | undefined;
30
+ pnpm: boolean | undefined;
31
+ yarn: boolean | undefined;
32
+ bun: boolean | undefined;
33
+ }> & {
34
+ run(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<{
35
+ packageManager: Agent | undefined;
36
+ npm: boolean | undefined;
37
+ pnpm: boolean | undefined;
38
+ yarn: boolean | undefined;
39
+ bun: boolean | undefined;
40
+ }>>;
41
+ } & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned & import("cmd-ts/dist/cjs/helpdoc.js").Descriptive & import("cmd-ts/dist/cjs/helpdoc.js").Aliased>;
42
+ //#endregion
43
+ //#region processors/constants.d.ts
44
+ declare const PROCESSOR_APPS: readonly ["connect", "switchboard"];
45
+ declare const DEFAULT_RELATIONAL_PROCESSOR_DB_NAME = "relational-db";
46
+ declare const DEFAULT_ANALYTICS_PROCESSOR_DB_NAME = "analytics-db";
47
+ //#endregion
48
+ //#region document-model/signatures.d.ts
49
+ type Signature = [string, string, string, string, string];
50
+ /**
51
+ * A user action signer.
52
+ */
53
+ type UserActionSigner = {
54
+ address: string;
55
+ networkId: string;
56
+ chainId: number;
16
57
  };
17
- type Sha256Digest = `sha256:${string}`;
18
- type DefinitionSource = {
19
- readonly specifier: `./${string}`;
20
- readonly exportPath?: readonly string[];
58
+ /**
59
+ * An app action signer.
60
+ */
61
+ type AppActionSigner = {
62
+ name: string;
63
+ key: string;
21
64
  };
22
- type DefinitionDiagnosticSeverity = "error" | "warning";
23
- type DefinitionDiagnosticPhase = "configuration" | "import" | "definition" | "composition" | "authorization" | "typecheck" | "package" | "replay";
24
- type DefinitionKind = "document-model" | "subgraph" | "scalar" | "package";
25
- type DefinitionRef = {
26
- readonly kind: DefinitionKind;
27
- readonly key: string;
28
- readonly version?: number;
65
+ /**
66
+ * An action signer.
67
+ */
68
+ type ActionSigner = {
69
+ user: UserActionSigner;
70
+ app: AppActionSigner;
71
+ signatures: Signature[];
29
72
  };
30
- type DefinitionPath = readonly (string | number)[];
31
- type DefinitionRelatedLocation = {
32
- readonly source?: DefinitionSource;
33
- readonly path: DefinitionPath;
34
- readonly message: string;
73
+ /**
74
+ * Information to verify the document creator.
75
+ */
76
+ type PHDocumentSignatureInfo = {
77
+ /**
78
+ * The public key of the document creator.
79
+ **/
80
+ publicKey: JsonWebKey;
81
+ /** The nonce that was appended to the message to create the signature. */
82
+ nonce: string;
35
83
  };
36
- type DefinitionDiagnostic = {
37
- readonly code: `PH-${string}`;
38
- readonly severity: DefinitionDiagnosticSeverity;
39
- readonly phase: DefinitionDiagnosticPhase;
40
- readonly source?: DefinitionSource;
41
- readonly definition?: DefinitionRef;
42
- readonly path: DefinitionPath;
43
- readonly message: string;
44
- readonly expected?: string;
45
- readonly received?: string;
46
- readonly repair: string;
47
- readonly related?: readonly DefinitionRelatedLocation[];
84
+ /** Joins a signature's params for transport. Already-joined input passes through. */
85
+ declare function serializeSignature(signature: Signature | string): string;
86
+ /**
87
+ * Splits a transported signature back into its params. A tuple passes through.
88
+ *
89
+ * Short input is padded rather than refused: verification reads the params by
90
+ * position and fails on a wrong one, which says more than a length complaint
91
+ * raised here would.
92
+ */
93
+ declare function deserializeSignature(signature: Signature | string): Signature;
94
+ /**
95
+ * Configuration for hashing document state in operations.
96
+ */
97
+ type HashConfig = {
98
+ /** The hashing algorithm to use (e.g., "sha1", "sha256") */
99
+ algorithm: string;
100
+ /** The encoding format for the hash output (e.g., "base64", "hex") */
101
+ encoding: string;
102
+ /** Optional algorithm-specific parameters */
103
+ params?: Record<string, unknown>;
48
104
  };
49
- type GraphQLNameNode = {
50
- readonly kind: "Name";
51
- readonly value: string;
105
+ //#endregion
106
+ //#region document-model/operations.d.ts
107
+ declare function setNameOperation<TDocument extends PHDocument$1>(document: TDocument, input: {
108
+ name: string;
109
+ }): TDocument & {
110
+ header: {
111
+ name: string;
112
+ id: string;
113
+ sig: PHDocumentSignatureInfo;
114
+ documentType: string;
115
+ createdAtUtcIso: string;
116
+ slug: string;
117
+ branch: string;
118
+ revision: {
119
+ [scope: string]: number;
120
+ };
121
+ lastModifiedAtUtcIso: string;
122
+ protocolVersions?: {
123
+ [key: string]: number;
124
+ };
125
+ meta?: PHDocumentMeta;
126
+ };
52
127
  };
53
- type GraphQLNamedTypeNode = {
54
- readonly kind: "NamedType";
55
- readonly name: GraphQLNameNode;
128
+ declare function setPreferredEditorOperation<TDocument extends PHDocument$1>(document: TDocument, input: {
129
+ preferredEditor: string | null;
130
+ }): TDocument;
131
+ declare function setSlugOperation<TDocument extends PHDocument$1>(document: TDocument, input: {
132
+ slug: string;
133
+ }): TDocument;
134
+ declare function undoOperation<TDocument extends PHDocument$1>(document: TDocument, action: Action, skip: number): {
135
+ document: TDocument;
136
+ action: Action;
137
+ skip: number;
138
+ reuseLastOperationIndex: boolean;
56
139
  };
57
- type GraphQLListTypeNode = {
58
- readonly kind: "ListType";
59
- readonly type: GraphQLTypeNode;
140
+ /**
141
+ * V2 of undoOperation for protocol version 2+.
142
+ * Key differences from undoOperation:
143
+ * - Never reuses operation index (always increments)
144
+ * - Always sets skip=1 (consecutive NOOPs are handled during rebuild/GC)
145
+ * - No complex skip calculation - simpler model where each UNDO is independent
146
+ */
147
+ declare function undoOperationV2<TDocument extends PHDocument$1>(document: TDocument, action: Action, skip: number): {
148
+ document: TDocument;
149
+ action: Action;
150
+ skip: number;
151
+ reuseLastOperationIndex: false;
60
152
  };
61
- type GraphQLNonNullTypeNode = {
62
- readonly kind: "NonNullType";
63
- readonly type: GraphQLNamedTypeNode | GraphQLListTypeNode;
153
+ declare function redoOperation<TDocument extends PHDocument$1>(document: TDocument, action: Action, skip: number): {
154
+ document: TDocument;
155
+ action: Action;
156
+ skip: number;
157
+ reuseLastOperationIndex: boolean;
64
158
  };
65
- type GraphQLTypeNode = GraphQLNamedTypeNode | GraphQLListTypeNode | GraphQLNonNullTypeNode;
66
- type GraphQLStringValueNode = {
67
- readonly kind: "StringValue";
68
- readonly value: string;
69
- readonly block?: boolean;
159
+ /**
160
+ * An operation that was applied to a {@link BaseDocument}.
161
+ *
162
+ * @remarks
163
+ * Wraps an action with an index, to be added to the operations history of a Document.
164
+ * The `index` field is used to keep all operations in order and enable replaying the
165
+ * document's history from the beginning. Note that indices and skips are relative to
166
+ * a specific reactor. Example below:
167
+ *
168
+ * For (index, skip, ts, action)
169
+ * A - [(0, 0, 1, "A0"), (1, 0, 2, "A1")]
170
+ * B - [(0, 0, 0, "B0"), (1, 0, 3, "B1")]
171
+ * ...
172
+ * B gets A's Operations Scenario:
173
+ * B' - [(0, 0, 0, "B0"), (1, 0, 3, "B1"), (2, 1, 1, "A0"), (3, 0, 2, "A1"), (4, 0, 3, "B1")]
174
+ * Then A needs to end up with:
175
+ * A' - [(0, 0, 1, "A0"), (1, 0, 2, "A1"), (2, 2, 0, "B0"), (3, 0, 1, "A0"), (4, 0, 2, "A1"), (5, 0, 3, "B1")]
176
+ * So that both A and B end up with the stream of actions (action):
177
+ * [("B0"), ("A0"), ("A1"), ("B1")]
178
+ *
179
+ * @typeParam A - The type of the action.
180
+ */
181
+ type Operation = {
182
+ /**
183
+ * This is a stable id, derived from various document and action properties
184
+ * in deriveOperationId().
185
+ *
186
+ * It _cannot_ be an arbitrary string.
187
+ *
188
+ * It it also not unique per operation, as reshuffled operations will keep'
189
+ * the same id they had before they were reshuffled. This means that the
190
+ * IOperationStore may have multiple operations with the same operation id.
191
+ **/
192
+ id: string;
193
+ /** Position of the operation in the history. This is relative to a specific reactor -- they may not all agree on this value. */
194
+ index: number;
195
+ /** The number of operations skipped with this Operation. This is relative to a specific reactor -- they may not all agree on this value. */
196
+ skip: number;
197
+ /** Timestamp of when the operation was added */
198
+ timestampUtcMs: string;
199
+ /** Hash of the resulting document data after the operation */
200
+ hash: string;
201
+ /** Error message for a failed action */
202
+ error?: string;
203
+ /** The name of the error a reducer threw, e.g. "BookNotStartedError"; not stored. */
204
+ errorName?: string;
205
+ /** The `errorCode` of the error a reducer threw, e.g. "BOOK_NOT_STARTED"; not stored. */
206
+ errorCode?: string;
207
+ /**
208
+ * If authorization rejected the action, this records the reason why.
209
+ */
210
+ deniedReason?: string;
211
+ /** The resulting state after the operation */
212
+ resultingState?: string;
213
+ /**
214
+ * The action that was applied to the document to produce this operation.
215
+ */
216
+ action: Action;
70
217
  };
71
- type GraphQLConstValueNode = {
72
- readonly kind: "IntValue";
73
- readonly value: string;
74
- } | {
75
- readonly kind: "FloatValue";
76
- readonly value: string;
77
- } | GraphQLStringValueNode | {
78
- readonly kind: "BooleanValue";
79
- readonly value: boolean;
80
- } | {
81
- readonly kind: "NullValue";
82
- } | {
83
- readonly kind: "EnumValue";
84
- readonly value: string;
218
+ /**
219
+ * The operations history of the document by scope.
220
+ *
221
+ * This will be removed in a future release.
222
+ *
223
+ * TODO: Type should be Partial<Record<string, Operation[]>>,
224
+ * but that is a breaking change for codegen + external doc models.
225
+ */
226
+ type DocumentOperations = Record<string, Operation[]>;
227
+ /**
228
+ * What happened to an operation. An operation that is not `applied` still
229
+ * occupies its index but contributes nothing to the document's state.
230
+ */
231
+ type OperationOutcome = {
232
+ kind: "applied";
85
233
  } | {
86
- readonly kind: "ListValue";
87
- readonly values: readonly GraphQLConstValueNode[];
234
+ kind: "reducer-error";
235
+ message: string;
236
+ name?: string;
237
+ code?: string;
88
238
  } | {
89
- readonly kind: "ObjectValue";
90
- readonly fields: readonly GraphQLObjectFieldNode[];
91
- };
92
- type GraphQLObjectFieldNode = {
93
- readonly kind: "ObjectField";
94
- readonly name: GraphQLNameNode;
95
- readonly value: GraphQLConstValueNode;
96
- };
97
- type GraphQLArgumentNode = {
98
- readonly kind: "Argument";
99
- readonly name: GraphQLNameNode;
100
- readonly value: GraphQLConstValueNode;
101
- };
102
- type GraphQLDirectiveNode = {
103
- readonly kind: "Directive";
104
- readonly name: GraphQLNameNode;
105
- readonly arguments: readonly GraphQLArgumentNode[];
239
+ kind: "denied";
240
+ reason: string;
106
241
  };
107
- type GraphQLInputValueDefinitionNode = {
108
- readonly kind: "InputValueDefinition";
109
- readonly description?: GraphQLStringValueNode;
110
- readonly name: GraphQLNameNode;
111
- readonly type: GraphQLTypeNode;
112
- readonly defaultValue?: GraphQLConstValueNode;
113
- readonly directives: readonly GraphQLDirectiveNode[];
242
+ /**
243
+ * Reads an operation's outcome. A denial takes precedence over a reducer
244
+ * error, since a denied operation never reaches its reducer.
245
+ */
246
+ declare function operationOutcome(operation: Operation): OperationOutcome;
247
+ type OperationContext = {
248
+ documentId: string;
249
+ documentType: string;
250
+ scope: string;
251
+ branch: string;
252
+ resultingState?: string;
253
+ ordinal: number;
114
254
  };
115
- type GraphQLFieldDefinitionNode = {
116
- readonly kind: "FieldDefinition";
117
- readonly description?: GraphQLStringValueNode;
118
- readonly name: GraphQLNameNode;
119
- readonly arguments: readonly GraphQLInputValueDefinitionNode[];
120
- readonly type: GraphQLTypeNode;
121
- readonly directives: readonly GraphQLDirectiveNode[];
255
+ type OperationWithContext$1 = {
256
+ operation: Operation;
257
+ context: OperationContext;
122
258
  };
123
- type GraphQLEnumValueDefinitionNode = {
124
- readonly kind: "EnumValueDefinition";
125
- readonly description?: GraphQLStringValueNode;
126
- readonly name: GraphQLNameNode;
127
- readonly directives: readonly GraphQLDirectiveNode[];
259
+ //#endregion
260
+ //#region document-model/operation-order.d.ts
261
+ declare function isDocumentAction(action: Action): action is DocumentAction;
262
+ declare function garbageCollect<TOpIndex extends OperationIndex>(sortedOperations: TOpIndex[]): TOpIndex[];
263
+ declare function sortOperations<TOpIndex extends OperationIndex>(operations: TOpIndex[]): TOpIndex[];
264
+ declare function nextSkipNumber(sortedOperations: OperationIndex[]): number;
265
+ //#endregion
266
+ //#region document-model/signature-policy.d.ts
267
+ /** The `protocolVersions` key that fixes a document's signature requirement. */
268
+ declare const SIGNATURE_PROTOCOL = "signature";
269
+ /** `protocolVersions.signature` of a document that requires v2 tuples. */
270
+ declare const SIGNATURE_PROTOCOL_V2 = 2;
271
+ /** `v2-required`: v2 tuples only and a content-addressed id. */
272
+ type SignaturePolicy$1 = "legacy" | "v2-required";
273
+ /** What a new document is created as unless the caller or host says otherwise. */
274
+ declare const DEFAULT_SIGNATURE_POLICY: SignaturePolicy$1;
275
+ declare function isSignaturePolicy(value: unknown): value is SignaturePolicy$1;
276
+ type ProtocolVersions = {
277
+ [protocol: string]: number;
128
278
  };
129
- type GraphQLNamedDefinitionNode = {
130
- readonly description?: GraphQLStringValueNode;
131
- readonly name: GraphQLNameNode;
132
- readonly directives: readonly GraphQLDirectiveNode[];
279
+ /** Read from a header, a CREATE_DOCUMENT input or a bare map. */
280
+ declare function signaturePolicyOf(source: {
281
+ protocolVersions?: ProtocolVersions | null;
282
+ } | ProtocolVersions | null | undefined): SignaturePolicy$1;
283
+ /** `protocolVersions` for a new v2-required document, over `base`. */
284
+ declare function v2RequiredProtocolVersions(base?: ProtocolVersions): ProtocolVersions;
285
+ /**
286
+ * The policy a create call asks for: `signaturePolicy`, else the `signature`
287
+ * key of its `protocolVersions`, else `fallback`, the host's default.
288
+ */
289
+ declare function requestedSignaturePolicy(request: {
290
+ signaturePolicy?: SignaturePolicy$1;
291
+ protocolVersions?: ProtocolVersions;
292
+ } | undefined, fallback: SignaturePolicy$1): SignaturePolicy$1;
293
+ /** `protocolVersions` for a new document under `policy`, over `base`. */
294
+ declare function protocolVersionsFor(policy: SignaturePolicy$1, base?: ProtocolVersions): ProtocolVersions;
295
+ /** What the id of a v2-required document is a hash of. */
296
+ type DocumentIdParams = {
297
+ documentType: string;
298
+ createdAtUtcIso: string;
299
+ nonce: string;
300
+ protocolVersions: ProtocolVersions;
133
301
  };
134
- type GraphQLScalarTypeDefinitionNode = GraphQLNamedDefinitionNode & {
135
- readonly kind: "ScalarTypeDefinition";
302
+ /** `base64url(sha256(canonicalJson(params)))`, unpadded. */
303
+ declare function deriveDocumentId(params: DocumentIdParams): string;
304
+ /** Whether `id` has the shape `deriveDocumentId` produces. */
305
+ declare function isDerivedDocumentId(id: string): boolean;
306
+ //#endregion
307
+ //#region document-model/state.d.ts
308
+ /**
309
+ * Creates a default PHAuthState
310
+ */
311
+ declare function defaultAuthState(): PHAuthState;
312
+ /**
313
+ * Creates a default PHDocumentState
314
+ */
315
+ declare function defaultDocumentState(): PHDocumentState;
316
+ /**
317
+ * Creates a default PHBaseState with auth and document properties
318
+ */
319
+ declare function defaultBaseState(): PHBaseState;
320
+ /**
321
+ * Creates a PHAuthState with the given properties
322
+ */
323
+ declare function createAuthState(auth?: Partial<PHAuthState>): PHAuthState;
324
+ /**
325
+ * Creates a PHDocumentState with the given properties
326
+ */
327
+ declare function createDocumentState(document?: Partial<PHDocumentState>): PHDocumentState;
328
+ /**
329
+ * Creates a PHBaseState with the given auth and document properties
330
+ */
331
+ declare function createBaseState(auth?: Partial<PHAuthState>, document?: Partial<PHDocumentState>): PHBaseState;
332
+ /**
333
+ * Backfills the auth scope to the default for legacy documents serialized with
334
+ * an empty `auth`. Replaces only `state.auth`. Idempotent.
335
+ */
336
+ declare function backfillAuthState<TState extends PHBaseState>(state: TState): TState;
337
+ /**
338
+ * The document state of the document.
339
+ */
340
+ type PHDocumentState = {
341
+ /**
342
+ * The current document model schema version of the document. This is used
343
+ * with the UPGRADE_DOCUMENT operation to specify the DocumentModelModule
344
+ * version to use for reducer execution.
345
+ */
346
+ version: number;
347
+ /** Hash configuration for operation state verification */
348
+ hash: HashConfig;
349
+ /** True if and only if the document has been deleted */
350
+ isDeleted?: boolean;
351
+ /** The timestamp when the document was deleted, in UTC ISO format */
352
+ deletedAtUtcIso?: string;
353
+ /** Optional: who deleted the document */
354
+ deletedBy?: string;
355
+ /** Optional: reason for deletion */
356
+ deletionReason?: string;
136
357
  };
137
- type GraphQLObjectTypeDefinitionNode = GraphQLNamedDefinitionNode & {
138
- readonly kind: "ObjectTypeDefinition";
139
- readonly interfaces: readonly GraphQLNamedTypeNode[];
140
- readonly fields: readonly GraphQLFieldDefinitionNode[];
358
+ /**
359
+ * The document's authorization policy: an ordered, stacked list of grants,
360
+ * where the last matching grant wins. `{ version: 0, grants: [] }` is
361
+ * uninitialized and leaves the document open.
362
+ */
363
+ type PHAuthState = {
364
+ /**
365
+ * Policy language version. 0 is the uninitialized state; INITIALIZE_AUTH
366
+ * sets an integer >= 1.
367
+ */
368
+ version: number;
369
+ grants: Grant[];
370
+ /**
371
+ * The did:key of the auth-policy creator, captured from the INITIALIZE_AUTH
372
+ * signer. The creator may always administer the auth scope, so a grant policy
373
+ * can never lock administration out of itself. Absent for an unsigned genesis.
374
+ */
375
+ creator?: string;
141
376
  };
142
- type GraphQLInterfaceTypeDefinitionNode = GraphQLNamedDefinitionNode & {
143
- readonly kind: "InterfaceTypeDefinition";
144
- readonly interfaces: readonly GraphQLNamedTypeNode[];
145
- readonly fields: readonly GraphQLFieldDefinitionNode[];
377
+ type Grant = {
378
+ /** Stable id. */
379
+ id: string;
380
+ description: string;
381
+ effect: "allow" | "deny";
382
+ principal: Principal;
383
+ capability: Capability;
384
+ /**
385
+ * The grant applies only when this condition holds. Until conditions are
386
+ * evaluated, a grant carrying one never applies.
387
+ */
388
+ where?: Condition;
146
389
  };
147
- type GraphQLUnionTypeDefinitionNode = GraphQLNamedDefinitionNode & {
148
- readonly kind: "UnionTypeDefinition";
149
- readonly types: readonly GraphQLNamedTypeNode[];
390
+ type Principal = {
391
+ anyone: true;
392
+ } | {
393
+ address: string;
394
+ } | {
395
+ group: string;
396
+ } | {
397
+ match: Condition;
150
398
  };
151
- type GraphQLEnumTypeDefinitionNode = GraphQLNamedDefinitionNode & {
152
- readonly kind: "EnumTypeDefinition";
153
- readonly values: readonly GraphQLEnumValueDefinitionNode[];
399
+ /**
400
+ * The folded global state of a PHGroup (powerhouse/reactor-group) document,
401
+ * narrowed to what auth evaluation reads. Membership is matched
402
+ * case-insensitively against the subject's address.
403
+ */
404
+ type PHGroupState = {
405
+ members: string[];
154
406
  };
155
- type GraphQLInputObjectTypeDefinitionNode = GraphQLNamedDefinitionNode & {
156
- readonly kind: "InputObjectTypeDefinition";
157
- readonly fields: readonly GraphQLInputValueDefinitionNode[];
407
+ /**
408
+ * Folded group states keyed by group document id, as the groups projection
409
+ * provides them. A group id a policy names but the map does not hold fails
410
+ * closed: the principal does not match.
411
+ */
412
+ type AuthGroups = Record<string, PHGroupState>;
413
+ type Capability = {
414
+ can: "read";
415
+ scope?: string;
416
+ } | {
417
+ can: "execute";
418
+ scope?: string;
419
+ operation?: string[];
158
420
  };
159
- type GraphQLOperationTypeDefinitionNode = {
160
- readonly kind: "OperationTypeDefinition";
161
- readonly operation: "query" | "mutation" | "subscription";
162
- readonly type: GraphQLNamedTypeNode;
163
- };
164
- type GraphQLSchemaDefinitionNode = {
165
- readonly kind: "SchemaDefinition";
166
- readonly description?: GraphQLStringValueNode;
167
- readonly directives: readonly GraphQLDirectiveNode[];
168
- readonly operationTypes: readonly GraphQLOperationTypeDefinitionNode[];
421
+ /**
422
+ * Boolean condition language for grants: deterministic, total, and
423
+ * JSON-serializable, versioned by `PHAuthState.version`. Defined now but not
424
+ * yet evaluated or enforced.
425
+ */
426
+ type Condition = {
427
+ eq: [Operand, Operand];
428
+ } | {
429
+ ne: [Operand, Operand];
430
+ } | {
431
+ in: [Operand, Operand[]];
432
+ } | {
433
+ notIn: [Operand, Operand[]];
434
+ } | {
435
+ lt: [Operand, Operand];
436
+ } | {
437
+ lte: [Operand, Operand];
438
+ } | {
439
+ gt: [Operand, Operand];
440
+ } | {
441
+ gte: [Operand, Operand];
442
+ } | {
443
+ exists: Operand;
444
+ } | {
445
+ and: Condition[];
446
+ } | {
447
+ or: Condition[];
448
+ } | {
449
+ not: Condition;
169
450
  };
170
- type GraphQLDirectiveDefinitionNode = {
171
- readonly kind: "DirectiveDefinition";
172
- readonly description?: GraphQLStringValueNode;
173
- readonly name: GraphQLNameNode;
174
- readonly arguments: readonly GraphQLInputValueDefinitionNode[];
175
- readonly repeatable: boolean;
176
- readonly locations: readonly GraphQLNameNode[];
451
+ /**
452
+ * A condition operand: `attr` is a dotted path into the decision context
453
+ * (e.g. "doc.global.status", "subject.address"); `lit` is a constant value.
454
+ */
455
+ type Operand = {
456
+ attr: string;
457
+ } | {
458
+ lit: string | number | boolean | null;
177
459
  };
178
- type GraphQLTypeSystemDefinitionNode = GraphQLSchemaDefinitionNode | GraphQLScalarTypeDefinitionNode | GraphQLObjectTypeDefinitionNode | GraphQLInterfaceTypeDefinitionNode | GraphQLUnionTypeDefinitionNode | GraphQLEnumTypeDefinitionNode | GraphQLInputObjectTypeDefinitionNode | GraphQLDirectiveDefinitionNode;
179
- type GraphQLTypeSystemExtensionNode = (Omit<GraphQLSchemaDefinitionNode, "kind" | "description"> & {
180
- readonly kind: "SchemaExtension";
181
- }) | (Omit<GraphQLScalarTypeDefinitionNode, "kind" | "description"> & {
182
- readonly kind: "ScalarTypeExtension";
183
- }) | (Omit<GraphQLObjectTypeDefinitionNode, "kind" | "description"> & {
184
- readonly kind: "ObjectTypeExtension";
185
- }) | (Omit<GraphQLInterfaceTypeDefinitionNode, "kind" | "description"> & {
186
- readonly kind: "InterfaceTypeExtension";
187
- }) | (Omit<GraphQLUnionTypeDefinitionNode, "kind" | "description"> & {
188
- readonly kind: "UnionTypeExtension";
189
- }) | (Omit<GraphQLEnumTypeDefinitionNode, "kind" | "description"> & {
190
- readonly kind: "EnumTypeExtension";
191
- }) | (Omit<GraphQLInputObjectTypeDefinitionNode, "kind" | "description"> & {
192
- readonly kind: "InputObjectTypeExtension";
193
- });
194
- type LocationFreeGraphQLDocumentNode = {
195
- readonly kind: "Document";
196
- readonly definitions: readonly (GraphQLTypeSystemDefinitionNode | GraphQLTypeSystemExtensionNode)[];
460
+ /**
461
+ * The base state of the document.
462
+ */
463
+ type PHBaseState = {
464
+ /** Carries authentication information. */
465
+ auth: PHAuthState;
466
+ /** Carries information about the document. */
467
+ document: PHDocumentState;
197
468
  };
198
- type SchemaFirstGraphQLDocumentCompatibility = {
199
- readonly kind: "graphql-ast-v1";
200
- readonly document: LocationFreeGraphQLDocumentNode;
201
- readonly preserveDefinitionOrder: true;
469
+ declare function defaultGlobalState(): DocumentModelGlobalState;
470
+ declare function defaultLocalState(): DocumentModelLocalState;
471
+ declare function defaultPHState(): DocumentModelPHState;
472
+ declare function createGlobalState(state?: Partial<DocumentModelGlobalState>): DocumentModelGlobalState;
473
+ declare function createLocalState(state?: Partial<DocumentModelLocalState>): DocumentModelLocalState;
474
+ declare function createState(baseState?: Partial<PHBaseState>, globalState?: Partial<DocumentModelGlobalState>, localState?: Partial<DocumentModelLocalState>): DocumentModelPHState;
475
+ //#endregion
476
+ //#region document-model/documents.d.ts
477
+ /** Meta information about the document. */
478
+ type PHDocumentMeta = {
479
+ /** The preferred editor for the document. */
480
+ preferredEditor?: string;
202
481
  };
203
- type GraphQLBuiltInScalarName = "ID" | "String" | "Boolean" | "Int" | "Float";
204
- /** The catalog scalars a document model or subgraph may reference. */
205
- type PowerhouseScalarName = "PHID" | "OID" | "OLabel" | "Currency" | "EmailAddress" | "EthereumAddress" | "URL" | "Date" | "DateTime" | "Amount_Money" | "Amount_Percentage" | "Amount_Tokens" | "Amount" | "Amount_Fiat" | "Amount_Crypto" | "Amount_Currency" | "Address" | "AttachmentRef" | "Unknown" | "Upload";
206
- /** Catalog scalars only the reactor host declares. A subgraph can reference one; a document model cannot. */
207
- type InternalScalarName = "JSONObject";
208
- /** Every catalog scalar, author-facing and internal. */
209
- type CatalogScalarName = PowerhouseScalarName | InternalScalarName;
210
- type ScalarName = GraphQLBuiltInScalarName | PowerhouseScalarName;
211
- type ScalarRepresentation = "string" | "number" | "boolean" | "json-object" | "json" | "opaque";
212
- /** The validation and coercion rules of the `document-model/scalars` catalog. */
213
- type ScalarValidationProfile = "catalog-v1";
214
- type ScalarGraphQLProfile = "legacy-graphql-default-v1" | "catalog-v1";
215
482
  /**
216
- * A scalar as a stored definition records it. `document-model/scalars`'
217
- * `ScalarDefinition` is the runtime declaration it is made from.
483
+ * The header of a document.
218
484
  */
219
- type StoredScalarDefinition = {
220
- readonly kind: "powerhouse.scalar";
221
- readonly formatVersion: 1;
485
+ type PHDocumentHeader = {
222
486
  /**
223
- * Any GraphQL name. A catalog scalar uses a `PowerhouseScalarName`; a
224
- * package scalar uses any other name that is not a GraphQL built-in.
487
+ * The id of the document.
488
+ *
489
+ * This is a Ed25519 signature and is immutable.
490
+ **/
491
+ id: string;
492
+ /**
493
+ * Information to verify the document creator.
494
+ *
495
+ * This is immutable.
496
+ **/
497
+ sig: PHDocumentSignatureInfo;
498
+ /**
499
+ * The type of the document.
500
+ *
501
+ * This is used as part of the signature payload and thus, cannot be changed
502
+ * after the document header has been created.
503
+ **/
504
+ documentType: string;
505
+ /**
506
+ * The timestamp of the creation date of the document, in UTC ISO format.
507
+ *
508
+ * This is used as part of the signature payload and thus, cannot be changed
509
+ * after the document header has been created.
510
+ **/
511
+ createdAtUtcIso: string;
512
+ /** The slug of the document. */
513
+ slug: string;
514
+ /** The name of the document. */
515
+ name: string;
516
+ /** The branch of this document. */
517
+ branch: string;
518
+ /**
519
+ * The revision of each scope of the document. This object is updated every
520
+ * time any _other_ scope is updated.
225
521
  */
226
- readonly name: string;
227
- readonly representation: ScalarRepresentation;
228
- readonly description: string;
229
- readonly coercion: {
230
- readonly source: "derived" | "explicit";
522
+ revision: {
523
+ [scope: string]: number;
231
524
  };
232
- readonly coercionProfile: ScalarValidationProfile;
233
- };
234
- type ScalarTypeReferenceDefinition = {
235
- readonly kind: "scalar";
236
525
  /**
237
- * A `ScalarName`, or a package scalar that the enclosing definition's
238
- * `scalars` list declares.
526
+ * The timestamp of the last change in the document, in UTC ISO format.
527
+ **/
528
+ lastModifiedAtUtcIso: string;
529
+ /**
530
+ * This is a map from protocol name to version. A protocol can be any set of
531
+ * rules that are applied to the document.
532
+ *
533
+ * Examples of protocols include:
534
+ *
535
+ * - "base-reducer"
239
536
  */
240
- readonly name: string;
241
- readonly required: boolean;
242
- };
243
- type NamedTypeReferenceDefinition = {
244
- readonly kind: "named";
245
- readonly name: string;
246
- readonly required: boolean;
247
- };
248
- type ListTypeReferenceDefinition = {
249
- readonly kind: "list";
250
- readonly required: boolean;
251
- readonly item: TypeReferenceDefinition;
252
- };
253
- type TypeReferenceDefinition = ScalarTypeReferenceDefinition | NamedTypeReferenceDefinition | ListTypeReferenceDefinition;
254
- type DirectiveUseDefinition = {
255
- readonly name: string;
256
- readonly arguments: readonly {
257
- readonly name: string;
258
- readonly value: JsonValue;
259
- }[];
260
- };
261
- type FieldDefinition = {
262
- readonly key: string;
263
- readonly name: string;
264
- readonly description: string | null;
265
- readonly deprecated: string | null;
266
- readonly args?: readonly InputFieldDefinition[];
267
- readonly type: TypeReferenceDefinition;
268
- readonly directives?: readonly DirectiveUseDefinition[];
537
+ protocolVersions?: {
538
+ [key: string]: number;
539
+ };
540
+ /** Meta information about the document. */
541
+ meta?: PHDocumentMeta;
269
542
  };
270
- type InputFieldDefinition = Omit<FieldDefinition, "args"> & ({
271
- readonly defaultValue?: never;
272
- } | {
273
- readonly defaultValue: JsonValue;
274
- });
275
- type EnumValueDefinition = {
276
- readonly name: string;
277
- readonly description: string | null;
278
- readonly deprecated: string | null;
279
- readonly directives?: readonly DirectiveUseDefinition[];
280
- };
281
- type EnumTypeDefinition = {
282
- readonly kind: "enum";
283
- readonly name: string;
284
- readonly description: string | null;
285
- readonly values: readonly EnumValueDefinition[];
286
- };
287
- type ObjectTypeDefinition = {
288
- readonly kind: "object";
289
- readonly name: string;
290
- readonly description: string | null;
291
- readonly implements?: readonly string[];
292
- readonly fields: readonly FieldDefinition[];
293
- };
294
- type InterfaceTypeDefinition = {
295
- readonly kind: "interface";
296
- readonly name: string;
297
- readonly description: string | null;
298
- readonly implements?: readonly string[];
299
- readonly fields: readonly FieldDefinition[];
300
- };
301
- type InputTypeDefinition = {
302
- readonly kind: "input";
303
- readonly name: string;
304
- readonly description: string | null;
305
- readonly unknownKeys: "preserve" | "reject";
306
- readonly fields: readonly InputFieldDefinition[];
307
- };
308
- type UnionTypeDefinition = {
309
- readonly kind: "union";
310
- readonly name: string;
311
- readonly description: string | null;
312
- readonly members: readonly string[];
313
- };
314
- type NamedGraphQLTypeDefinition = EnumTypeDefinition | ObjectTypeDefinition | InterfaceTypeDefinition | InputTypeDefinition | UnionTypeDefinition;
315
- type CatalogScalarImplementationReference<TName extends CatalogScalarName> = { [Name in TName]: {
316
- readonly name: Name;
317
- readonly implementation: `powerhouse.catalog#${Name}`;
318
- }; }[TName];
319
- type CatalogScalarReferenceDefinition = CatalogScalarImplementationReference<PowerhouseScalarName> & {
320
- readonly coercionProfile: ScalarValidationProfile;
543
+ /**
544
+ * The base type of a document model.
545
+ *
546
+ * @remarks
547
+ * This type is extended by all Document models.
548
+ *
549
+ * @typeParam TState - The type of the document state.
550
+ */
551
+ type PHDocument$1<TState extends PHBaseState = PHBaseState> = {
552
+ /** The header of the document. */
553
+ header: PHDocumentHeader;
554
+ /** The document model specific state. */
555
+ state: TState;
556
+ /**
557
+ * The initial state of the document, enabling replaying operations.
558
+ *
559
+ * This will be removed in a future release.
560
+ */
561
+ initialState: TState;
562
+ /**
563
+ * The operations history of the document.
564
+ *
565
+ * Only documents built by reducers carry it. Documents read from a reactor,
566
+ * such as an editor's `document` in Connect, have an empty array per scope;
567
+ * read their history with `useDocumentOperations(document.header.id, scope)`
568
+ * and their operation count with `header.revision[scope]`.
569
+ *
570
+ * This will be removed in a future release.
571
+ */
572
+ operations: DocumentOperations;
573
+ /**
574
+ * A list of undone operations
575
+ *
576
+ * This will be removed in a future release.
577
+ */
578
+ clipboard: Operation[];
321
579
  };
580
+ declare function isNoopOperation<TOp extends {
581
+ type: string;
582
+ skip: number;
583
+ hash: string;
584
+ }>(op: Partial<TOp>): boolean;
585
+ declare function isUndoRedo(action: Action): action is UndoRedoAction;
586
+ declare function isUndo(action: Action): action is UndoAction;
322
587
  /**
323
- * The package that ships the definition declares this scalar with `defineScalar`.
588
+ * Creates a new document. When `documentType` is given the header is stamped
589
+ * with it and the document-scope operations are seeded. Without
590
+ * `protocolVersions` the document is v2-required and takes a derived id; with
591
+ * them it is v2-required only if they say so (see {@link protocolVersionsFor}).
324
592
  */
325
- type PackageScalarReferenceDefinition = {
326
- readonly name: string;
327
- readonly implementation: `package#${string}`;
328
- readonly coercionProfile: ScalarValidationProfile;
329
- readonly definition: StoredScalarDefinition;
330
- };
331
- type DocumentScalarReferenceDefinition = CatalogScalarReferenceDefinition | PackageScalarReferenceDefinition;
332
- type DefinitionExample = {
333
- readonly id: string;
334
- readonly key: string;
335
- readonly value: string;
336
- };
337
- type MaterializedStateDefinition = {
338
- readonly schema: string;
339
- readonly initialValue: string;
340
- readonly examples: readonly Omit<DefinitionExample, "key">[];
341
- };
342
- type NonEmptyStateDefinition = {
343
- readonly root: NamedTypeReferenceDefinition;
344
- readonly initialValue: JsonValue;
345
- readonly examples: readonly DefinitionExample[];
346
- readonly unknownKeys: "preserve";
347
- readonly materialized: MaterializedStateDefinition;
348
- };
349
- type EmptyLocalStateDefinition = {
350
- readonly root: null;
351
- readonly initialValue: Readonly<Record<string, never>>;
352
- readonly examples: readonly DefinitionExample[];
353
- readonly unknownKeys: "preserve";
354
- readonly materialized: MaterializedStateDefinition & {
355
- readonly schema: "";
356
- };
357
- };
358
- type StateDefinition = NonEmptyStateDefinition | EmptyLocalStateDefinition;
359
- type CompiledErrorDefinition = {
360
- readonly id: string;
361
- readonly key: string;
362
- readonly code: string | null;
363
- readonly name: string | null;
364
- readonly description: string | null;
365
- readonly template: string | null;
366
- };
367
- type DocumentModelOperationDefinition = {
368
- readonly id: string;
369
- readonly key: string;
370
- readonly name: string | null;
371
- readonly description: string | null;
372
- readonly actionType: string;
373
- readonly creatorKey: string;
374
- readonly scope: "global" | "local";
375
- readonly input: InputTypeDefinition | null;
376
- readonly errors: readonly CompiledErrorDefinition[];
377
- readonly examples: readonly DefinitionExample[];
378
- readonly template: string | null;
379
- readonly reducer: string | null;
380
- };
381
- type DocumentModelModuleDefinition = {
382
- readonly id: string;
383
- readonly key: string;
384
- readonly name: string;
385
- readonly description: string | null;
386
- readonly operations: readonly DocumentModelOperationDefinition[];
387
- };
388
- type DocumentModelSpecificationDefinition = {
389
- readonly version: number;
390
- readonly scalars: readonly DocumentScalarReferenceDefinition[];
391
- readonly graphQLCompatibility: SchemaFirstGraphQLDocumentCompatibility | null;
392
- readonly types: readonly NamedGraphQLTypeDefinition[];
393
- readonly state: {
394
- readonly global: NonEmptyStateDefinition;
395
- readonly local: StateDefinition;
396
- };
397
- readonly modules: readonly DocumentModelModuleDefinition[];
398
- readonly changeLog: readonly string[];
399
- };
400
- type DocumentModelDefinition = {
401
- readonly kind: "powerhouse.document-model";
402
- readonly formatVersion: 1;
403
- readonly compatibility: {
404
- readonly identity: "derived-v1" | "explicit-schema-first";
405
- readonly scalarCoercion: ScalarValidationProfile;
406
- readonly serialization: "canonical-v1" | "explicit-schema-first";
407
- };
408
- readonly model: {
409
- readonly documentType: string;
410
- readonly graphQLName: string;
411
- readonly name: string;
412
- readonly description: string;
413
- readonly extension: string;
414
- readonly author: {
415
- readonly name: string;
416
- readonly website: string | null;
417
- };
418
- };
419
- readonly specifications: readonly DocumentModelSpecificationDefinition[];
420
- };
421
- type DefinitionCheckProfile = "edit" | "release";
422
- type DefinitionSourcesConfig = {
423
- readonly formatVersion: 1;
424
- } & ({
425
- readonly mode: "code-first";
426
- readonly entries: readonly DefinitionSource[];
427
- } | {
428
- readonly mode: "schema-first";
429
- readonly entries?: never;
430
- });
431
- type DefinitionCheckRequest = {
432
- readonly formatVersion: 1;
433
- readonly profile: DefinitionCheckProfile;
434
- readonly warningsAsErrors?: boolean;
435
- } & ({
436
- readonly sourceMode: "code-first";
437
- readonly sourceOrigin: "config" | "cli" | "request";
438
- readonly sources: readonly [DefinitionSource, ...DefinitionSource[]];
439
- } | {
440
- readonly sourceMode: "schema-first";
441
- readonly sourceOrigin: "config";
442
- readonly sources?: never;
443
- });
444
- type DefinitionCompatibilitySelection = {
445
- readonly identity: "derived-v1" | "explicit-schema-first";
446
- readonly serialization: "canonical-v1" | "explicit-schema-first";
447
- readonly paths: {
448
- readonly ids: readonly string[];
449
- readonly names: readonly string[];
450
- readonly serialization: readonly string[];
451
- };
452
- };
453
- type DefinitionCheckReport = {
454
- readonly kind: "powerhouse.definition-check";
455
- readonly formatVersion: 1;
456
- readonly profile: DefinitionCheckProfile;
457
- readonly sourceSet: {
458
- readonly mode: "code-first" | "schema-first";
459
- readonly origin: "config" | "cli" | "request";
460
- readonly digest: Sha256Digest;
461
- readonly sources: readonly DefinitionSource[];
462
- };
463
- readonly definitions: readonly (DefinitionRef & {
464
- readonly digest?: Sha256Digest;
465
- readonly source: DefinitionSource;
466
- readonly compatibility?: DefinitionCompatibilitySelection;
467
- })[];
468
- readonly diagnostics: readonly DefinitionDiagnostic[];
469
- readonly summary: {
470
- readonly errors: number;
471
- readonly warnings: number;
593
+ declare function baseCreateDocument<TState extends PHBaseState = PHBaseState>(createState: CreateState<TState>, initialState?: Partial<TState>, documentType?: string, protocolVersions?: ProtocolVersions): PHDocument$1<TState>;
594
+ /**
595
+ * `document`, not yet created, under a fresh header for `policy`. A legacy
596
+ * header takes `id` when given; a v2-required one ignores `id` and derives its
597
+ * own, so a caller that needs a fixed id must ask for legacy.
598
+ * `protocolVersions` are merged over the document's. Name, slug, branch and
599
+ * meta carry over. A document already under `policy` is returned as is unless
600
+ * a legacy `id` or `protocolVersions` are given.
601
+ */
602
+ declare function withSignaturePolicy<TDocument extends PHDocument$1>(document: TDocument, policy: SignaturePolicy$1, options?: {
603
+ id?: string;
604
+ protocolVersions?: ProtocolVersions;
605
+ }): TDocument;
606
+ declare function hashDocumentStateForScope(document: {
607
+ state: {
608
+ [key: string]: unknown;
472
609
  };
473
- } & ({
474
- readonly status: "ok" | "invalid" | "failed";
475
- readonly skipReason?: never;
476
- } | {
477
- readonly status: "skipped";
478
- readonly skipReason: DefinitionCheckSkipReason;
479
- });
480
- type DefinitionCheckSkipReason = "explicit-schema-first-mode" | "definition-sources-absent" | "definition-sources-empty";
610
+ }, scope?: string): string;
611
+ declare function readOnly<T>(value: T): Readonly<T>;
481
612
  /**
482
- * `fieldName` is `null` for a resolver bound to a type rather than a field.
613
+ * Maps skipped operations in an array of operations.
614
+ * Skipped operations are operations that are ignored during processing.
615
+ * @param operations - The array of operations to map.
616
+ * @param skippedHeadOperations - The number of operations to skip at the head of the array of operations.
617
+ * @returns An array of mapped operations with ignore flag indicating if the operation is skipped.
618
+ * @throws Error if the operation index is invalid and there are missing operations.
483
619
  */
484
- type ResolverCoordinateDefinition = {
485
- readonly typeName: string;
486
- readonly fieldName: string | null;
487
- readonly resolverKind: "field" | "subscribe" | "resolve" | "resolveType" | "isTypeOf" | "enum" | "scalar";
488
- };
620
+ declare function mapSkippedOperations(operations: Operation[], skippedHeadOperations?: number): MappedOperation[];
489
621
  /**
490
- * The compiler supplies this marker. Resolvers perform their own authorization.
622
+ * V2 version of mapSkippedOperations for protocol version 2+.
623
+ * In V2, all NOOPs have skip=1 and consecutive NOOPs form chains.
624
+ * N consecutive NOOPs at any point skip N preceding content operations.
625
+ *
626
+ * Algorithm: Process from end to start
627
+ * - When hitting a NOOP: increment chain length, mark as ignored
628
+ * - When hitting a non-NOOP:
629
+ * - If chain > 0: decrement chain, mark as ignored (this op was undone)
630
+ * - If chain == 0: mark as not ignored (apply this op)
491
631
  */
492
- type SubgraphEntryAccess = {
493
- readonly kind: "manual";
494
- };
495
- type SubgraphRootEntryBase = {
496
- /** The author's key, which is stable across a GraphQL name change. */
497
- readonly key: string;
498
- readonly fieldName: string;
499
- readonly description: string | null;
500
- readonly deprecated: string | null;
501
- readonly args: readonly InputFieldDefinition[];
502
- readonly returns: TypeReferenceDefinition;
503
- readonly access: SubgraphEntryAccess;
504
- };
505
- type SubgraphEntryDefinition = ({
506
- readonly kind: "query";
507
- } & SubgraphRootEntryBase) | ({
508
- readonly kind: "mutation";
509
- } & SubgraphRootEntryBase) | ({
510
- readonly kind: "subscription";
511
- } & SubgraphRootEntryBase) | {
512
- readonly kind: "computed-field";
513
- readonly typeName: string;
514
- readonly fieldName: string;
515
- readonly access: SubgraphEntryAccess;
516
- } | {
517
- readonly kind: "resolve-type";
518
- readonly typeName: string;
519
- readonly access: SubgraphEntryAccess;
520
- } | {
521
- readonly kind: "is-type-of";
522
- readonly typeName: string;
523
- readonly access: SubgraphEntryAccess;
524
- };
525
- /** A subgraph may also reference the internal scalars the host declares. */
526
- type SubgraphScalarReferenceDefinition = (CatalogScalarImplementationReference<CatalogScalarName> & {
527
- readonly graphQLProfile: "legacy-graphql-default-v1";
528
- }) | {
529
- readonly name: string;
530
- readonly implementation: `package#${string}`;
531
- readonly graphQLProfile: "declared-coercion-v1";
532
- readonly definition: StoredScalarDefinition;
533
- };
534
- type SubgraphDefinitionBase = {
535
- readonly kind: "powerhouse.subgraph";
536
- readonly formatVersion: 1;
537
- /** The instance and route segment name, not a new global identity. */
538
- readonly name: string;
539
- readonly compositionPolicy: "host-current";
540
- readonly federationProfile: "host-current";
541
- };
542
- type SubgraphDefinition = SubgraphDefinitionBase & ({
543
- readonly schemaKind: "typed";
544
- readonly hasSubscriptions: boolean;
545
- readonly types: readonly NamedGraphQLTypeDefinition[];
546
- readonly entries: readonly SubgraphEntryDefinition[];
547
- readonly scalars: readonly SubgraphScalarReferenceDefinition[];
548
- /**
549
- * Every emitted definition name appears once, including roots and
550
- * scalars. This order preserves the authored schema's print order.
551
- */
552
- readonly definitionOrder: readonly string[];
553
- } | {
554
- readonly schemaKind: "graphql-ast-compat";
555
- /**
556
- * `null` records runtime `undefined`. Both `null` and `false` disable
557
- * subscriptions, but compatibility must preserve their distinct values.
558
- */
559
- readonly hasSubscriptions: boolean | null;
560
- readonly document: LocationFreeGraphQLDocumentNode;
561
- readonly resolverCoordinates: readonly ResolverCoordinateDefinition[];
562
- readonly access: "manual";
563
- });
564
- //#endregion
565
- //#region clis/args/common.d.ts
566
- declare const getPackageManagerCommand: Partial<import("cmd-ts/dist/cjs/argparser.js").Register> & {
567
- parse(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<{
568
- packageManager: Agent | undefined;
569
- npm: boolean | undefined;
570
- pnpm: boolean | undefined;
571
- yarn: boolean | undefined;
572
- bun: boolean | undefined;
573
- }>>;
574
- } & import("cmd-ts/dist/cjs/helpdoc.js").PrintHelp & import("cmd-ts/dist/cjs/helpdoc.js").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc.js").Named & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned> & import("cmd-ts/dist/cjs/argparser.js").Register & import("cmd-ts/dist/cjs/runner.js").Handling<{
575
- packageManager: Agent | undefined;
576
- npm: boolean | undefined;
577
- pnpm: boolean | undefined;
578
- yarn: boolean | undefined;
579
- bun: boolean | undefined;
580
- }, {
581
- packageManager: Agent | undefined;
582
- npm: boolean | undefined;
583
- pnpm: boolean | undefined;
584
- yarn: boolean | undefined;
585
- bun: boolean | undefined;
586
- }> & {
587
- run(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<{
588
- packageManager: Agent | undefined;
589
- npm: boolean | undefined;
590
- pnpm: boolean | undefined;
591
- yarn: boolean | undefined;
592
- bun: boolean | undefined;
593
- }>>;
594
- } & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned & import("cmd-ts/dist/cjs/helpdoc.js").Descriptive & import("cmd-ts/dist/cjs/helpdoc.js").Aliased>;
595
- //#endregion
596
- //#region processors/constants.d.ts
597
- declare const PROCESSOR_APPS: readonly ["connect", "switchboard"];
598
- declare const DEFAULT_RELATIONAL_PROCESSOR_DB_NAME = "relational-db";
599
- declare const DEFAULT_ANALYTICS_PROCESSOR_DB_NAME = "analytics-db";
600
- //#endregion
601
- //#region document-model/signatures.d.ts
602
- type Signature = [string, string, string, string, string];
632
+ declare function mapSkippedOperationsV2(operations: Operation[]): MappedOperation[];
603
633
  /**
604
- * A user action signer.
634
+ * V2 garbage collect that returns only operations that should be applied for state.
635
+ * Uses the V2 model where consecutive NOOPs form chains.
636
+ * Unlike V1 garbageCollect, this preserves ALL operations but marks which to apply.
605
637
  */
606
- type UserActionSigner = {
607
- address: string;
608
- networkId: string;
609
- chainId: number;
610
- };
638
+ declare function garbageCollectV2<TOpIndex extends OperationIndex>(sortedOperations: TOpIndex[]): TOpIndex[];
639
+ declare function sortMappedOperations(operations: DocumentOperationsIgnoreMap): MappedOperation[];
611
640
  /**
612
- * An app action signer.
641
+ * Records an operation in the history without applying it, which is what a
642
+ * denied operation needs: it occupies its index and contributes no state.
643
+ *
644
+ * The scope defaults to the action's own, and is passed explicitly by a rebuild
645
+ * that is walking one stream and does not want to trust the action's copy.
613
646
  */
614
- type AppActionSigner = {
615
- name: string;
616
- key: string;
647
+ declare function appendWithoutApplying<TState extends PHBaseState>(document: PHDocument$1<TState>, operation: Operation, scope?: string): PHDocument$1<TState>;
648
+ /** The state reducer base-reducer 3 derives with; throws when `reducer` wraps none. */
649
+ declare function requireStateReducer<TState extends PHBaseState = PHBaseState>(reducer: Reducer<TState>, documentType: string, version?: number): StateReducer<TState>;
650
+ /** Rejects the index gaps the reducer rejects when it appends a replayed row. */
651
+ declare function assertReplayIndices(operations: readonly Operation[]): void;
652
+ declare function appendRows<TState extends PHBaseState>(document: PHDocument$1<TState>, scope: string, rows: readonly Operation[]): PHDocument$1<TState>;
653
+ declare function replayDocument<TState extends PHBaseState = PHBaseState>(initialState: TState, operations: DocumentOperations, reducer: Reducer<TState>, header: PHDocumentHeader, dispatch?: SignalDispatch, skipHeaderOperations?: SkipHeaderOperations, options?: ReplayDocumentOptions): PHDocument$1<TState>;
654
+ declare function parseResultingState<TState>(state: string | null | undefined): TState;
655
+ declare enum IntegrityIssueType {
656
+ UNEXPECTED_INDEX = "UNEXPECTED_INDEX"
657
+ }
658
+ declare enum IntegrityIssueSubType {
659
+ DUPLICATED_INDEX = "DUPLICATED_INDEX",
660
+ MISSING_INDEX = "MISSING_INDEX"
661
+ }
662
+ type IntegrityIssue = {
663
+ operation: OperationIndex;
664
+ issue: IntegrityIssueType;
665
+ category: IntegrityIssueSubType;
666
+ message: string;
667
+ };
668
+ type Reshuffle = (startIndex: OperationIndex, opsA: Operation[], opsB: Operation[]) => Operation[];
669
+ declare function checkCleanedOperationsIntegrity(sortedOperations: OperationIndex[]): IntegrityIssue[];
670
+ declare function addUndo(sortedOperations: Operation[]): Operation[];
671
+ declare function reshuffleByTimestamp<TOp extends OperationIndex>(startIndex: OperationIndex, opsA: TOp[], opsB: TOp[]): TOp[];
672
+ declare function reshuffleByTimestampAndIndex<TOp extends OperationIndex>(startIndex: OperationIndex, opsA: TOp[], opsB: TOp[]): TOp[];
673
+ declare function operationsAreEqual<TOp extends {
674
+ index: number;
675
+ skip: number;
676
+ type?: string;
677
+ scope?: string;
678
+ input?: unknown;
679
+ }>(op1: TOp, op2: TOp): boolean;
680
+ declare function attachBranch(trunk: Operation[], newBranch: Operation[]): [Operation[], Operation[]];
681
+ declare function precedes(op1: OperationIndex, op2: OperationIndex): boolean;
682
+ declare function split(sortedTargetOperations: Operation[], sortedMergeOperations: Operation[]): [Operation[], Operation[], Operation[]];
683
+ declare function merge(sortedTargetOperations: Operation[], sortedMergeOperations: Operation[], reshuffle: Reshuffle): Operation[];
684
+ declare function checkOperationsIntegrity(operations: Operation[]): IntegrityIssue[];
685
+ declare function groupOperationsByScope(operations: Operation[]): Partial<Record<string, Operation[]>>;
686
+ type PrepareOperationsResult = {
687
+ validOperations: Operation[];
688
+ invalidOperations: Operation[];
689
+ duplicatedOperations: Operation[];
690
+ integrityIssues: IntegrityIssue[];
617
691
  };
692
+ declare function prepareOperations(operationsHistory: Operation[], newOperations: Operation[]): PrepareOperationsResult;
693
+ declare function removeExistingOperations(newOperations: Operation[], operationsHistory: Operation[]): Operation[];
618
694
  /**
619
- * An action signer.
695
+ * Skips header operations and returns the remaining operations.
696
+ *
697
+ * @param operations - The array of operations.
698
+ * @param skipHeaderOperation - The skip header operation index.
699
+ * @returns The remaining operations after skipping header operations.
620
700
  */
621
- type ActionSigner = {
622
- user: UserActionSigner;
623
- app: AppActionSigner;
624
- signatures: Signature[];
625
- };
701
+ declare function skipHeaderOperations(operations: Operation[], skipHeaderOperation: SkipHeaderOperationIndex): Operation[];
702
+ declare function garbageCollectDocumentOperations(documentOperations: DocumentOperations): DocumentOperations;
626
703
  /**
627
- * Information to verify the document creator.
704
+ * Filters out duplicated operations from the target operations array based on their IDs.
705
+ * If an operation has an ID, it is considered duplicated if there is another operation in the source operations array with the same ID.
706
+ * If an operation does not have an ID, it is considered unique and will not be filtered out.
707
+ * @param targetOperations - The array of target operations to filter.
708
+ * @param sourceOperations - The array of source operations to compare against.
709
+ * @returns An array of operations with duplicates filtered out.
628
710
  */
629
- type PHDocumentSignatureInfo = {
630
- /**
631
- * The public key of the document creator.
632
- **/
633
- publicKey: JsonWebKey;
634
- /** The nonce that was appended to the message to create the signature. */
635
- nonce: string;
711
+ declare function filterDuplicatedOperations<T extends {
712
+ id?: string | number;
713
+ }>(targetOperations: T[], sourceOperations: T[]): T[];
714
+ declare function filterDocumentOperationsResultingState(documentOperations?: DocumentOperations): {
715
+ [x: string]: Operation[] | {
716
+ id: string;
717
+ index: number;
718
+ skip: number;
719
+ timestampUtcMs: string;
720
+ hash: string;
721
+ error?: string;
722
+ errorName?: string;
723
+ errorCode?: string;
724
+ deniedReason?: string;
725
+ action: Action;
726
+ }[];
636
727
  };
637
- /** Joins a signature's params for transport. Already-joined input passes through. */
638
- declare function serializeSignature(signature: Signature | string): string;
639
728
  /**
640
- * Splits a transported signature back into its params. A tuple passes through.
729
+ * Calculates the difference between two arrays of operations.
730
+ * Returns an array of operations that are present in `clearedOperationsA` but not in `clearedOperationsB`.
641
731
  *
642
- * Short input is padded rather than refused: verification reads the params by
643
- * position and fails on a wrong one, which says more than a length complaint
644
- * raised here would.
732
+ * @template TOp - The type of the operations.
733
+ * @param {TOp[]} clearedOperationsA - The first array of operations.
734
+ * @param {TOp[]} clearedOperationsB - The second array of operations.
735
+ * @returns {TOp[]} - The difference between the two arrays of operations.
645
736
  */
646
- declare function deserializeSignature(signature: Signature | string): Signature;
737
+ declare function diffOperations<TOp extends OperationIndex>(clearedOperationsA: TOp[], clearedOperationsB: TOp[]): TOp[];
738
+ declare function getDocumentLastModified(document: PHDocument$1): string;
739
+ /** `revision` with a 0 for each scope of `state` it lacks; auth is not a model scope, so it is left out. */
740
+ declare function withScopeRevisions(revision: PHDocumentHeader["revision"], state: object): PHDocumentHeader["revision"];
647
741
  /**
648
- * Configuration for hashing document state in operations.
742
+ * Updates the document header with the latest revision number and
743
+ * date of last modification.
744
+ *
745
+ * @param document The current state of the document.
746
+ * @param scope The scope of the operation.
747
+ * @param lastModifiedTimestamp Optional timestamp to use directly, avoiding a scan of all operations.
748
+ * @returns The updated document state.
649
749
  */
650
- type HashConfig = {
651
- /** The hashing algorithm to use (e.g., "sha1", "sha256") */
652
- algorithm: string;
653
- /** The encoding format for the hash output (e.g., "base64", "hex") */
654
- encoding: string;
655
- /** Optional algorithm-specific parameters */
656
- params?: Record<string, unknown>;
657
- };
750
+ declare function updateHeaderRevision(document: PHDocument$1, scope: string, lastModifiedTimestamp?: string): PHDocument$1;
658
751
  //#endregion
659
- //#region document-model/operations.d.ts
660
- declare function setNameOperation<TDocument extends PHDocument$1>(document: TDocument, input: {
661
- name: string;
662
- }): TDocument & {
663
- header: {
664
- name: string;
665
- id: string;
666
- sig: PHDocumentSignatureInfo;
667
- documentType: string;
668
- createdAtUtcIso: string;
669
- slug: string;
670
- branch: string;
671
- revision: {
672
- [scope: string]: number;
673
- };
674
- lastModifiedAtUtcIso: string;
675
- protocolVersions?: {
676
- [key: string]: number;
677
- };
678
- meta?: PHDocumentMeta;
679
- };
680
- };
681
- declare function setPreferredEditorOperation<TDocument extends PHDocument$1>(document: TDocument, input: {
682
- preferredEditor: string | null;
683
- }): TDocument;
684
- declare function setSlugOperation<TDocument extends PHDocument$1>(document: TDocument, input: {
685
- slug: string;
686
- }): TDocument;
687
- declare function undoOperation<TDocument extends PHDocument$1>(document: TDocument, action: Action, skip: number): {
688
- document: TDocument;
689
- action: Action;
690
- skip: number;
691
- reuseLastOperationIndex: boolean;
692
- };
693
- /**
694
- * V2 of undoOperation for protocol version 2+.
695
- * Key differences from undoOperation:
696
- * - Never reuses operation index (always increments)
697
- * - Always sets skip=1 (consecutive NOOPs are handled during rebuild/GC)
698
- * - No complex skip calculation - simpler model where each UNDO is independent
699
- */
700
- declare function undoOperationV2<TDocument extends PHDocument$1>(document: TDocument, action: Action, skip: number): {
701
- document: TDocument;
702
- action: Action;
703
- skip: number;
704
- reuseLastOperationIndex: false;
705
- };
706
- declare function redoOperation<TDocument extends PHDocument$1>(document: TDocument, action: Action, skip: number): {
707
- document: TDocument;
708
- action: Action;
709
- skip: number;
710
- reuseLastOperationIndex: boolean;
711
- };
752
+ //#region document-model/actions.d.ts
712
753
  /**
713
- * An operation that was applied to a {@link BaseDocument}.
714
- *
715
- * @remarks
716
- * Wraps an action with an index, to be added to the operations history of a Document.
717
- * The `index` field is used to keep all operations in order and enable replaying the
718
- * document's history from the beginning. Note that indices and skips are relative to
719
- * a specific reactor. Example below:
720
- *
721
- * For (index, skip, ts, action)
722
- * A - [(0, 0, 1, "A0"), (1, 0, 2, "A1")]
723
- * B - [(0, 0, 0, "B0"), (1, 0, 3, "B1")]
724
- * ...
725
- * B gets A's Operations Scenario:
726
- * B' - [(0, 0, 0, "B0"), (1, 0, 3, "B1"), (2, 1, 1, "A0"), (3, 0, 2, "A1"), (4, 0, 3, "B1")]
727
- * Then A needs to end up with:
728
- * A' - [(0, 0, 1, "A0"), (1, 0, 2, "A1"), (2, 2, 0, "B0"), (3, 0, 1, "A0"), (4, 0, 2, "A1"), (5, 0, 3, "B1")]
729
- * So that both A and B end up with the stream of actions (action):
730
- * [("B0"), ("A0"), ("A1"), ("B1")]
754
+ * Cancels the last `count` operations.
731
755
  *
732
- * @typeParam A - The type of the action.
756
+ * @param count - Number of operations to cancel
757
+ * @category Actions
733
758
  */
734
- type Operation = {
735
- /**
736
- * This is a stable id, derived from various document and action properties
737
- * in deriveOperationId().
738
- *
739
- * It _cannot_ be an arbitrary string.
740
- *
741
- * It it also not unique per operation, as reshuffled operations will keep'
742
- * the same id they had before they were reshuffled. This means that the
743
- * IOperationStore may have multiple operations with the same operation id.
744
- **/
745
- id: string;
746
- /** Position of the operation in the history. This is relative to a specific reactor -- they may not all agree on this value. */
747
- index: number;
748
- /** The number of operations skipped with this Operation. This is relative to a specific reactor -- they may not all agree on this value. */
749
- skip: number;
750
- /** Timestamp of when the operation was added */
751
- timestampUtcMs: string;
752
- /** Hash of the resulting document data after the operation */
753
- hash: string;
754
- /** Error message for a failed action */
755
- error?: string;
756
- /** The name of the error a reducer threw, e.g. "BookNotStartedError"; not stored. */
757
- errorName?: string;
758
- /** The `errorCode` of the error a reducer threw, e.g. "BOOK_NOT_STARTED"; not stored. */
759
- errorCode?: string;
760
- /**
761
- * If authorization rejected the action, this records the reason why.
762
- */
763
- deniedReason?: string;
764
- /** The resulting state after the operation */
765
- resultingState?: string;
766
- /**
767
- * The action that was applied to the document to produce this operation.
768
- */
769
- action: Action;
770
- };
759
+ declare const undo: (count?: number, scope?: string) => UndoAction;
771
760
  /**
772
- * The operations history of the document by scope.
773
- *
774
- * This will be removed in a future release.
761
+ * Cancels the last `count` {@link undo | UNDO} operations.
775
762
  *
776
- * TODO: Type should be Partial<Record<string, Operation[]>>,
777
- * but that is a breaking change for codegen + external doc models.
778
- */
779
- type DocumentOperations = Record<string, Operation[]>;
780
- /**
781
- * What happened to an operation. An operation that is not `applied` still
782
- * occupies its index but contributes nothing to the document's state.
783
- */
784
- type OperationOutcome = {
785
- kind: "applied";
786
- } | {
787
- kind: "reducer-error";
788
- message: string;
789
- name?: string;
790
- code?: string;
791
- } | {
792
- kind: "denied";
793
- reason: string;
794
- };
795
- /**
796
- * Reads an operation's outcome. A denial takes precedence over a reducer
797
- * error, since a denied operation never reaches its reducer.
798
- */
799
- declare function operationOutcome(operation: Operation): OperationOutcome;
800
- type OperationContext = {
801
- documentId: string;
802
- documentType: string;
803
- scope: string;
804
- branch: string;
805
- resultingState?: string;
806
- ordinal: number;
807
- };
808
- type OperationWithContext$1 = {
809
- operation: Operation;
810
- context: OperationContext;
811
- };
812
- //#endregion
813
- //#region document-model/operation-order.d.ts
814
- declare function isDocumentAction(action: Action): action is DocumentAction;
815
- declare function garbageCollect<TOpIndex extends OperationIndex>(sortedOperations: TOpIndex[]): TOpIndex[];
816
- declare function sortOperations<TOpIndex extends OperationIndex>(operations: TOpIndex[]): TOpIndex[];
817
- declare function nextSkipNumber(sortedOperations: OperationIndex[]): number;
818
- //#endregion
819
- //#region document-model/signature-policy.d.ts
820
- /** The `protocolVersions` key that fixes a document's signature requirement. */
821
- declare const SIGNATURE_PROTOCOL = "signature";
822
- /** `protocolVersions.signature` of a document that requires v2 tuples. */
823
- declare const SIGNATURE_PROTOCOL_V2 = 2;
824
- /** `v2-required`: v2 tuples only and a content-addressed id. */
825
- type SignaturePolicy$1 = "legacy" | "v2-required";
826
- /** What a new document is created as unless the caller or host says otherwise. */
827
- declare const DEFAULT_SIGNATURE_POLICY: SignaturePolicy$1;
828
- declare function isSignaturePolicy(value: unknown): value is SignaturePolicy$1;
829
- type ProtocolVersions = {
830
- [protocol: string]: number;
831
- };
832
- /** Read from a header, a CREATE_DOCUMENT input or a bare map. */
833
- declare function signaturePolicyOf(source: {
834
- protocolVersions?: ProtocolVersions | null;
835
- } | ProtocolVersions | null | undefined): SignaturePolicy$1;
836
- /** `protocolVersions` for a new v2-required document, over `base`. */
837
- declare function v2RequiredProtocolVersions(base?: ProtocolVersions): ProtocolVersions;
838
- /**
839
- * The policy a create call asks for: `signaturePolicy`, else the `signature`
840
- * key of its `protocolVersions`, else `fallback`, the host's default.
841
- */
842
- declare function requestedSignaturePolicy(request: {
843
- signaturePolicy?: SignaturePolicy$1;
844
- protocolVersions?: ProtocolVersions;
845
- } | undefined, fallback: SignaturePolicy$1): SignaturePolicy$1;
846
- /** `protocolVersions` for a new document under `policy`, over `base`. */
847
- declare function protocolVersionsFor(policy: SignaturePolicy$1, base?: ProtocolVersions): ProtocolVersions;
848
- /** What the id of a v2-required document is a hash of. */
849
- type DocumentIdParams = {
850
- documentType: string;
851
- createdAtUtcIso: string;
852
- nonce: string;
853
- protocolVersions: ProtocolVersions;
854
- };
855
- /** `base64url(sha256(canonicalJson(params)))`, unpadded. */
856
- declare function deriveDocumentId(params: DocumentIdParams): string;
857
- /** Whether `id` has the shape `deriveDocumentId` produces. */
858
- declare function isDerivedDocumentId(id: string): boolean;
859
- //#endregion
860
- //#region document-model/state.d.ts
861
- /**
862
- * Creates a default PHAuthState
863
- */
864
- declare function defaultAuthState(): PHAuthState;
865
- /**
866
- * Creates a default PHDocumentState
763
+ * @param count - Number of UNDO operations to cancel
764
+ * @category Actions
867
765
  */
868
- declare function defaultDocumentState(): PHDocumentState;
766
+ declare const redo: (count?: number, scope?: string) => RedoAction;
767
+ declare const noop: (scope?: string) => NOOPAction;
869
768
  /**
870
- * Creates a default PHBaseState with auth and document properties
769
+ * Retracts the action with id `target` on base-reducer 3.
770
+ *
771
+ * @category Actions
871
772
  */
872
- declare function defaultBaseState(): PHBaseState;
773
+ declare const retract: (target: string, scope?: string) => RetractAction;
873
774
  /**
874
- * Creates a PHAuthState with the given properties
775
+ * Helper function to be used by action creators.
776
+ *
777
+ * @remarks
778
+ * Creates an action with the given type and input properties. The input
779
+ * properties default to an empty object.
780
+ *
781
+ * @typeParam A - Type of the action to be returned.
782
+ *
783
+ * @param type - The type of the action.
784
+ * @param input - The input properties of the action.
785
+ * @param _attachments - Deprecated and ignored. Retained so action creators
786
+ * generated before the attachment-system removal keep their 5-argument shape.
787
+ * @param validator - The validator to use for the input properties.
788
+ * @param scope - The scope of the action, can either be 'global' or 'local'.
789
+ *
790
+ * @throws Error if the type is empty or not a string.
791
+ *
792
+ * @returns The new action.
875
793
  */
876
- declare function createAuthState(auth?: Partial<PHAuthState>): PHAuthState;
794
+ declare function createAction<TAction extends Action>(type: TAction["type"], input?: TAction["input"], _attachments?: unknown, validator?: () => {
795
+ parse(v: unknown): TAction["input"];
796
+ }, scope?: Action["scope"]): TAction;
877
797
  /**
878
- * Creates a PHDocumentState with the given properties
798
+ * This function should be used instead of { ...action } to ensure
799
+ * that extra properties are not included in the action.
879
800
  */
880
- declare function createDocumentState(document?: Partial<PHDocumentState>): PHDocumentState;
801
+ declare const actionFromAction: (action: Action) => Action;
802
+ declare const operationFromAction: (action: Action, index: number, skip: number, context: OperationContext) => Operation;
803
+ declare const operationFromOperation: (operation: Operation, index: number, skip: number, context: OperationContext) => Operation;
804
+ declare const operationWithContext: (operation: Operation, context: ActionContext) => Operation;
805
+ declare const actionContext: () => ActionContext;
806
+ declare const actionSigner: (user: UserActionSigner, app: AppActionSigner, signatures?: Signature[]) => ActionSigner;
807
+ declare function buildOperationSignature(context: ActionSignatureContext, signMethod: ActionSigningHandler): Promise<Signature>;
808
+ /** @deprecated Emits a legacy SHA-1 tuple; sign through `ISigner.signAction`. */
809
+ declare function buildSignedAction<TState extends PHBaseState = PHBaseState>(action: Action, reducer: Reducer<TState>, document: PHDocument$1<TState>, signer: ActionSigner, signHandler: ActionSigningHandler): Promise<Operation>;
810
+ /** @deprecated Use `verifyActionSignature` from `@powerhousedao/reactor`. */
811
+ declare function verifyOperationSignature(signature: Signature, signer: Omit<ActionSigner, "signatures">, verifyHandler: ActionVerificationHandler): Promise<boolean>;
881
812
  /**
882
- * Creates a PHBaseState with the given auth and document properties
813
+ * Changes the name of the document.
814
+ *
815
+ * @param name - The name to be set in the document.
816
+ * @category Actions
883
817
  */
884
- declare function createBaseState(auth?: Partial<PHAuthState>, document?: Partial<PHDocumentState>): PHBaseState;
818
+ declare const setName: (name: string | {
819
+ name: string;
820
+ }) => SetNameAction;
885
821
  /**
886
- * Backfills the auth scope to the default for legacy documents serialized with
887
- * an empty `auth`. Replaces only `state.auth`. Idempotent.
822
+ * Changes the preferred editor recorded in the document header meta.
823
+ *
824
+ * Passing `null` clears the preferred editor.
825
+ *
826
+ * @category Actions
888
827
  */
889
- declare function backfillAuthState<TState extends PHBaseState>(state: TState): TState;
828
+ declare const setPreferredEditor: (input: string | null | {
829
+ preferredEditor: string | null;
830
+ }) => SetPreferredEditorAction;
890
831
  /**
891
- * The document state of the document.
832
+ * Gives the document a slug, its name on the reactor that serves it. The last
833
+ * document to claim a slug holds it.
834
+ *
835
+ * @category Actions
892
836
  */
893
- type PHDocumentState = {
894
- /**
895
- * The current document model schema version of the document. This is used
896
- * with the UPGRADE_DOCUMENT operation to specify the DocumentModelModule
897
- * version to use for reducer execution.
898
- */
899
- version: number;
900
- /** Hash configuration for operation state verification */
901
- hash: HashConfig;
902
- /** True if and only if the document has been deleted */
903
- isDeleted?: boolean;
904
- /** The timestamp when the document was deleted, in UTC ISO format */
905
- deletedAtUtcIso?: string;
906
- /** Optional: who deleted the document */
907
- deletedBy?: string;
908
- /** Optional: reason for deletion */
909
- deletionReason?: string;
837
+ declare const setSlug: (slug: string) => SetSlugAction;
838
+ declare const setModelName: (input: SetModelNameInput) => SetModelNameAction;
839
+ declare const setModelId: (input: SetModelIdInput) => SetModelIdAction;
840
+ declare const setModelExtension: (input: SetModelExtensionInput) => SetModelExtensionAction;
841
+ declare const setModelDescription: (input: SetModelDescriptionInput) => SetModelDescriptionAction;
842
+ declare const setAuthorName: (input: SetAuthorNameInput) => SetAuthorNameAction;
843
+ declare const setAuthorWebsite: (input: SetAuthorWebsiteInput) => SetAuthorWebsiteAction;
844
+ declare const addModule: (input: AddModuleInput) => AddModuleAction;
845
+ declare const setModuleName: (input: SetModuleNameInput) => SetModuleNameAction;
846
+ declare const setModuleDescription: (input: SetModuleDescriptionInput) => SetModuleDescriptionAction;
847
+ declare const deleteModule: (input: DeleteModuleInput) => DeleteModuleAction;
848
+ declare const reorderModules: (input: ReorderModulesInput) => ReorderModulesAction;
849
+ declare const addOperation: (input: AddOperationInput) => AddOperationAction;
850
+ declare const setOperationName: (input: SetOperationNameInput) => SetOperationNameAction;
851
+ declare const setOperationScope: (input: SetOperationScopeInput) => SetOperationScopeAction;
852
+ declare const setOperationSchema: (input: SetOperationSchemaInput) => SetOperationSchemaAction;
853
+ declare const setOperationDescription: (input: SetOperationDescriptionInput) => SetOperationDescriptionAction;
854
+ declare const setOperationTemplate: (input: SetOperationTemplateInput) => SetOperationTemplateAction;
855
+ declare const setOperationReducer: (input: SetOperationReducerInput) => SetOperationReducerAction;
856
+ declare const moveOperation: (input: MoveOperationInput) => MoveOperationAction;
857
+ declare const deleteOperation: (input: DeleteOperationInput) => DeleteOperationAction;
858
+ declare const reorderModuleOperations: (input: ReorderModuleOperationsInput) => ReorderModuleOperationsAction;
859
+ declare const addOperationError: (input: AddOperationErrorInput) => AddOperationErrorAction;
860
+ declare const setOperationErrorCode: (input: SetOperationErrorCodeInput) => SetOperationErrorCodeAction;
861
+ declare const setOperationErrorName: (input: SetOperationErrorNameInput) => SetOperationErrorNameAction;
862
+ declare const setOperationErrorDescription: (input: SetOperationErrorDescriptionInput) => SetOperationErrorDescriptionAction;
863
+ declare const setOperationErrorTemplate: (input: SetOperationErrorTemplateInput) => SetOperationErrorTemplateAction;
864
+ declare const deleteOperationError: (input: DeleteOperationErrorInput) => DeleteOperationErrorAction;
865
+ declare const reorderOperationErrors: (input: ReorderOperationErrorsInput) => ReorderOperationErrorsAction;
866
+ declare const addOperationExample: (input: AddOperationExampleInput) => AddOperationExampleAction;
867
+ declare const updateOperationExample: (input: UpdateOperationExampleInput) => UpdateOperationExampleAction;
868
+ declare const deleteOperationExample: (input: DeleteOperationExampleInput) => DeleteOperationExampleAction;
869
+ declare const reorderOperationExamples: (input: ReorderOperationExamplesInput) => ReorderOperationExamplesAction;
870
+ declare const operationExampleCreators: {
871
+ addOperationExample: typeof addOperationExample;
872
+ updateOperationExample: typeof updateOperationExample;
873
+ deleteOperationExample: typeof deleteOperationExample;
874
+ reorderOperationExamples: typeof reorderOperationExamples;
910
875
  };
911
- /**
912
- * The document's authorization policy: an ordered, stacked list of grants,
913
- * where the last matching grant wins. `{ version: 0, grants: [] }` is
914
- * uninitialized and leaves the document open.
915
- */
916
- type PHAuthState = {
917
- /**
918
- * Policy language version. 0 is the uninitialized state; INITIALIZE_AUTH
919
- * sets an integer >= 1.
920
- */
921
- version: number;
922
- grants: Grant[];
923
- /**
924
- * The did:key of the auth-policy creator, captured from the INITIALIZE_AUTH
925
- * signer. The creator may always administer the auth scope, so a grant policy
926
- * can never lock administration out of itself. Absent for an unsigned genesis.
927
- */
928
- creator?: string;
876
+ declare const setStateSchema: (input: SetStateSchemaInput) => SetStateSchemaAction;
877
+ declare const setInitialState: (input: SetInitialStateInput) => SetInitialStateAction;
878
+ declare const addStateExample: (input: AddStateExampleInput) => AddStateExampleAction;
879
+ declare const updateStateExample: (input: UpdateStateExampleInput) => UpdateStateExampleAction;
880
+ declare const deleteStateExample: (input: DeleteStateExampleInput) => DeleteStateExampleAction;
881
+ declare const reorderStateExamples: (input: ReorderStateExamplesInput) => ReorderStateExamplesAction;
882
+ declare const addChangeLogItem: (input: AddChangeLogItemInput) => AddChangeLogItemAction;
883
+ declare const updateChangeLogItem: (input: UpdateChangeLogItemInput) => UpdateChangeLogItemAction;
884
+ declare const deleteChangeLogItem: (input: DeleteChangeLogItemInput) => DeleteChangeLogItemAction;
885
+ declare const reorderChangeLogItems: (input: ReorderChangeLogItemsInput) => ReorderChangeLogItemsAction;
886
+ declare const releaseNewVersion: () => ReleaseNewVersionAction;
887
+ declare const baseActions: {
888
+ setName: typeof setName;
889
+ setPreferredEditor: typeof setPreferredEditor;
890
+ setSlug: typeof setSlug;
891
+ undo: typeof undo;
892
+ redo: typeof redo;
893
+ noop: typeof noop;
929
894
  };
930
- type Grant = {
931
- /** Stable id. */
932
- id: string;
933
- description: string;
934
- effect: "allow" | "deny";
935
- principal: Principal;
936
- capability: Capability;
937
- /**
938
- * The grant applies only when this condition holds. Until conditions are
939
- * evaluated, a grant carrying one never applies.
940
- */
941
- where?: Condition;
895
+ declare const documentModelActions: {
896
+ setModelName: typeof setModelName;
897
+ setModelId: typeof setModelId;
898
+ setModelExtension: typeof setModelExtension;
899
+ setModelDescription: typeof setModelDescription;
900
+ setAuthorName: typeof setAuthorName;
901
+ setAuthorWebsite: typeof setAuthorWebsite;
902
+ addModule: typeof addModule;
903
+ setModuleName: typeof setModuleName;
904
+ setModuleDescription: typeof setModuleDescription;
905
+ deleteModule: typeof deleteModule;
906
+ reorderModules: typeof reorderModules;
907
+ addOperation: typeof addOperation;
908
+ setOperationName: typeof setOperationName;
909
+ setOperationScope: typeof setOperationScope;
910
+ setOperationSchema: typeof setOperationSchema;
911
+ setOperationDescription: typeof setOperationDescription;
912
+ setOperationTemplate: typeof setOperationTemplate;
913
+ setOperationReducer: typeof setOperationReducer;
914
+ moveOperation: typeof moveOperation;
915
+ deleteOperation: typeof deleteOperation;
916
+ reorderModuleOperations: typeof reorderModuleOperations;
917
+ addOperationError: typeof addOperationError;
918
+ setOperationErrorCode: typeof setOperationErrorCode;
919
+ setOperationErrorName: typeof setOperationErrorName;
920
+ setOperationErrorDescription: typeof setOperationErrorDescription;
921
+ setOperationErrorTemplate: typeof setOperationErrorTemplate;
922
+ deleteOperationError: typeof deleteOperationError;
923
+ reorderOperationErrors: typeof reorderOperationErrors;
924
+ addOperationExample: typeof addOperationExample;
925
+ updateOperationExample: typeof updateOperationExample;
926
+ deleteOperationExample: typeof deleteOperationExample;
927
+ reorderOperationExamples: typeof reorderOperationExamples;
928
+ setStateSchema: typeof setStateSchema;
929
+ setInitialState: typeof setInitialState;
930
+ addStateExample: typeof addStateExample;
931
+ updateStateExample: typeof updateStateExample;
932
+ deleteStateExample: typeof deleteStateExample;
933
+ reorderStateExamples: typeof reorderStateExamples;
934
+ addChangeLogItem: typeof addChangeLogItem;
935
+ updateChangeLogItem: typeof updateChangeLogItem;
936
+ deleteChangeLogItem: typeof deleteChangeLogItem;
937
+ reorderChangeLogItems: typeof reorderChangeLogItems;
938
+ releaseNewVersion: typeof releaseNewVersion;
942
939
  };
943
- type Principal = {
944
- anyone: true;
945
- } | {
946
- address: string;
947
- } | {
948
- group: string;
949
- } | {
950
- match: Condition;
940
+ declare const actions: {
941
+ setName: typeof setName;
942
+ setPreferredEditor: typeof setPreferredEditor;
943
+ setSlug: typeof setSlug;
944
+ undo: typeof undo;
945
+ redo: typeof redo;
946
+ noop: typeof noop;
947
+ setModelName: typeof setModelName;
948
+ setModelId: typeof setModelId;
949
+ setModelExtension: typeof setModelExtension;
950
+ setModelDescription: typeof setModelDescription;
951
+ setAuthorName: typeof setAuthorName;
952
+ setAuthorWebsite: typeof setAuthorWebsite;
953
+ addModule: typeof addModule;
954
+ setModuleName: typeof setModuleName;
955
+ setModuleDescription: typeof setModuleDescription;
956
+ deleteModule: typeof deleteModule;
957
+ reorderModules: typeof reorderModules;
958
+ addOperation: typeof addOperation;
959
+ setOperationName: typeof setOperationName;
960
+ setOperationScope: typeof setOperationScope;
961
+ setOperationSchema: typeof setOperationSchema;
962
+ setOperationDescription: typeof setOperationDescription;
963
+ setOperationTemplate: typeof setOperationTemplate;
964
+ setOperationReducer: typeof setOperationReducer;
965
+ moveOperation: typeof moveOperation;
966
+ deleteOperation: typeof deleteOperation;
967
+ reorderModuleOperations: typeof reorderModuleOperations;
968
+ addOperationError: typeof addOperationError;
969
+ setOperationErrorCode: typeof setOperationErrorCode;
970
+ setOperationErrorName: typeof setOperationErrorName;
971
+ setOperationErrorDescription: typeof setOperationErrorDescription;
972
+ setOperationErrorTemplate: typeof setOperationErrorTemplate;
973
+ deleteOperationError: typeof deleteOperationError;
974
+ reorderOperationErrors: typeof reorderOperationErrors;
975
+ addOperationExample: typeof addOperationExample;
976
+ updateOperationExample: typeof updateOperationExample;
977
+ deleteOperationExample: typeof deleteOperationExample;
978
+ reorderOperationExamples: typeof reorderOperationExamples;
979
+ setStateSchema: typeof setStateSchema;
980
+ setInitialState: typeof setInitialState;
981
+ addStateExample: typeof addStateExample;
982
+ updateStateExample: typeof updateStateExample;
983
+ deleteStateExample: typeof deleteStateExample;
984
+ reorderStateExamples: typeof reorderStateExamples;
985
+ addChangeLogItem: typeof addChangeLogItem;
986
+ updateChangeLogItem: typeof updateChangeLogItem;
987
+ deleteChangeLogItem: typeof deleteChangeLogItem;
988
+ reorderChangeLogItems: typeof reorderChangeLogItems;
989
+ releaseNewVersion: typeof releaseNewVersion;
951
990
  };
952
991
  /**
953
- * The folded global state of a PHGroup (powerhouse/reactor-group) document,
954
- * narrowed to what auth evaluation reads. Membership is matched
955
- * case-insensitively against the subject's address.
992
+ * The context of an action.
956
993
  */
957
- type PHGroupState = {
958
- members: string[];
994
+ type ActionContext = {
995
+ /** The index of the previous operation, showing intended ordering. */
996
+ prevOpIndex?: number;
997
+ /** The hash of the previous operation, showing intended state. */
998
+ prevOpHash?: string;
999
+ /** A nonce, to cover specific signing attacks and to prevent replay attacks from no-ops. */
1000
+ nonce?: string;
1001
+ /** The signer of the action. */
1002
+ signer?: ActionSigner;
959
1003
  };
960
1004
  /**
961
- * Folded group states keyed by group document id, as the groups projection
962
- * provides them. A group id a policy names but the map does not hold fails
963
- * closed: the principal does not match.
1005
+ * Defines the basic structure of an action.
964
1006
  */
965
- type AuthGroups = Record<string, PHGroupState>;
966
- type Capability = {
967
- can: "read";
968
- scope?: string;
969
- } | {
970
- can: "execute";
971
- scope?: string;
972
- operation?: string[];
1007
+ type Action = {
1008
+ /** The id of the action. This is distinct from the operation id. */
1009
+ id: string;
1010
+ /** The name of the action. */
1011
+ type: string;
1012
+ /** The timestamp of the action. */
1013
+ timestampUtcMs: string;
1014
+ /** The payload of the action. */
1015
+ input: unknown;
1016
+ /** The scope of the action */
1017
+ scope: string;
1018
+ /** The context of the action. */
1019
+ context?: ActionContext;
973
1020
  };
974
- /**
975
- * Boolean condition language for grants: deterministic, total, and
976
- * JSON-serializable, versioned by `PHAuthState.version`. Defined now but not
977
- * yet evaluated or enforced.
978
- */
979
- type Condition = {
980
- eq: [Operand, Operand];
981
- } | {
982
- ne: [Operand, Operand];
983
- } | {
984
- in: [Operand, Operand[]];
985
- } | {
986
- notIn: [Operand, Operand[]];
987
- } | {
988
- lt: [Operand, Operand];
989
- } | {
990
- lte: [Operand, Operand];
991
- } | {
992
- gt: [Operand, Operand];
993
- } | {
994
- gte: [Operand, Operand];
995
- } | {
996
- exists: Operand;
997
- } | {
998
- and: Condition[];
999
- } | {
1000
- or: Condition[];
1001
- } | {
1002
- not: Condition;
1021
+ //#endregion
1022
+ //#region document-model/action-signature.d.ts
1023
+ declare const ACTION_SIGNATURE_V2_PREFIX = "v2:";
1024
+ /** The log an operation is stored in, which a v2 tuple is bound to. */
1025
+ type ActionSigningTarget = {
1026
+ documentId: string;
1027
+ branch: string;
1003
1028
  };
1004
- /**
1005
- * A condition operand: `attr` is a dotted path into the decision context
1006
- * (e.g. "doc.global.status", "subject.address"); `lit` is a constant value.
1007
- */
1008
- type Operand = {
1009
- attr: string;
1010
- } | {
1011
- lit: string | number | boolean | null;
1029
+ /** Who a v2 tuple attributes the action to; both halves are in the preimage. */
1030
+ type ActionSignerIdentity = {
1031
+ user: UserActionSigner;
1032
+ app: AppActionSigner;
1012
1033
  };
1034
+ /** A value that would not survive a JSON store round trip unchanged. */
1035
+ declare class CanonicalJsonError extends Error {
1036
+ constructor(path: string, detail: string);
1037
+ }
1038
+ /** Sorted-key JSON, as the state hash encodes; drops `undefined` properties. */
1039
+ declare function canonicalJson(value: unknown, label?: string): string;
1040
+ /** Actions the reactor reduces itself, onto the document scope. */
1041
+ declare const DOCUMENT_SCOPE_ACTION_TYPES: ReadonlySet<string>;
1042
+ /** Where a document-scope action writes: `sourceId` or `documentId`. */
1043
+ declare function targetDocumentId(action: {
1044
+ type: string;
1045
+ input: unknown;
1046
+ }, fallback: string): string;
1047
+ /** The log an action submitted to a job on `documentId` is stored in. */
1048
+ declare function actionSigningTarget(action: {
1049
+ type: string;
1050
+ input: unknown;
1051
+ }, documentId: string, branch: string): ActionSigningTarget;
1052
+ /** The identity a signer writes into `context.signer`, and signs over. */
1053
+ declare function actionSignerIdentity(signer: {
1054
+ user?: UserActionSigner;
1055
+ app?: AppActionSigner;
1056
+ }): ActionSignerIdentity;
1057
+ /** The v2 preimage; throws `CanonicalJsonError` on an unsignable action. */
1058
+ declare function actionPreimageV2(action: Action, target: ActionSigningTarget, signer: ActionSignerIdentity): string;
1059
+ /** `"v2:" + base64url(sha256(preimage))`, unpadded. */
1060
+ declare function hashActionV2(action: Action, target: ActionSigningTarget, signer: ActionSignerIdentity): Promise<string>;
1061
+ /** Signs `action` as a v2 tuple; the message layout is the legacy one. */
1062
+ declare function signActionV2(params: {
1063
+ action: Action;
1064
+ target: ActionSigningTarget;
1065
+ signer: ActionSignerIdentity;
1066
+ sign: ActionSigningHandler;
1067
+ previousStateHash?: string;
1068
+ }): Promise<Signature>;
1069
+ /** Element [2] carries the v2 prefix, whether or not it is well formed. */
1070
+ declare function isV2ActionHash(hash: string): boolean;
1071
+ /** The strict shape of a v2 tuple, apart from what its hash covers. */
1072
+ declare function v2TupleProblem(tuple: Signature): string | undefined;
1073
+ //#endregion
1074
+ //#region document-model/action-transport.d.ts
1013
1075
  /**
1014
- * The base state of the document.
1076
+ * An action's signer, as the wire declares it: signatures joined into strings,
1077
+ * because GraphQL declares them as a list of strings rather than of lists.
1015
1078
  */
1016
- type PHBaseState = {
1017
- /** Carries authentication information. */
1018
- auth: PHAuthState;
1019
- /** Carries information about the document. */
1020
- document: PHDocumentState;
1079
+ type TransportSigner = {
1080
+ user?: {
1081
+ address: string;
1082
+ networkId: string;
1083
+ chainId: number;
1084
+ };
1085
+ app?: {
1086
+ name: string;
1087
+ key: string;
1088
+ };
1089
+ signatures: string[];
1021
1090
  };
1022
- declare function defaultGlobalState(): DocumentModelGlobalState;
1023
- declare function defaultLocalState(): DocumentModelLocalState;
1024
- declare function defaultPHState(): DocumentModelPHState;
1025
- declare function createGlobalState(state?: Partial<DocumentModelGlobalState>): DocumentModelGlobalState;
1026
- declare function createLocalState(state?: Partial<DocumentModelLocalState>): DocumentModelLocalState;
1027
- declare function createState(baseState?: Partial<PHBaseState>, globalState?: Partial<DocumentModelGlobalState>, localState?: Partial<DocumentModelLocalState>): DocumentModelPHState;
1028
- //#endregion
1029
- //#region document-model/documents.d.ts
1030
- /** Meta information about the document. */
1031
- type PHDocumentMeta = {
1032
- /** The preferred editor for the document. */
1033
- preferredEditor?: string;
1091
+ /** An action's context, as the wire declares it. */
1092
+ type TransportActionContext = {
1093
+ prevOpIndex?: number;
1094
+ prevOpHash?: string;
1095
+ nonce?: string;
1096
+ signer?: TransportSigner;
1034
1097
  };
1035
- /**
1036
- * The header of a document.
1037
- */
1038
- type PHDocumentHeader = {
1039
- /**
1040
- * The id of the document.
1041
- *
1042
- * This is a Ed25519 signature and is immutable.
1043
- **/
1098
+ /** An action projected onto exactly the fields the wire declares. */
1099
+ type TransportAction = {
1044
1100
  id: string;
1101
+ type: string;
1102
+ timestampUtcMs: string;
1045
1103
  /**
1046
- * Information to verify the document creator.
1047
- *
1048
- * This is immutable.
1049
- **/
1050
- sig: PHDocumentSignatureInfo;
1051
- /**
1052
- * The type of the document.
1053
- *
1054
- * This is used as part of the signature payload and thus, cannot be changed
1055
- * after the document header has been created.
1056
- **/
1057
- documentType: string;
1058
- /**
1059
- * The timestamp of the creation date of the document, in UTC ISO format.
1060
- *
1061
- * This is used as part of the signature payload and thus, cannot be changed
1062
- * after the document header has been created.
1063
- **/
1064
- createdAtUtcIso: string;
1065
- /** The slug of the document. */
1066
- slug: string;
1067
- /** The name of the document. */
1068
- name: string;
1069
- /** The branch of this document. */
1070
- branch: string;
1071
- /**
1072
- * The revision of each scope of the document. This object is updated every
1073
- * time any _other_ scope is updated.
1074
- */
1075
- revision: {
1076
- [scope: string]: number;
1077
- };
1078
- /**
1079
- * The timestamp of the last change in the document, in UTC ISO format.
1080
- **/
1081
- lastModifiedAtUtcIso: string;
1082
- /**
1083
- * This is a map from protocol name to version. A protocol can be any set of
1084
- * rules that are applied to the document.
1085
- *
1086
- * Examples of protocols include:
1087
- *
1088
- * - "base-reducer"
1104
+ * Non-nullable, because the wire declares it so. An action's own type says
1105
+ * `unknown`, which admits the absent input an action creator called without
1106
+ * one produces - {@link toTransportAction} refuses that rather than passing
1107
+ * it on.
1089
1108
  */
1090
- protocolVersions?: {
1091
- [key: string]: number;
1092
- };
1093
- /** Meta information about the document. */
1094
- meta?: PHDocumentMeta;
1109
+ input: NonNullable<unknown>;
1110
+ scope: string;
1111
+ context?: TransportActionContext;
1095
1112
  };
1096
1113
  /**
1097
- * The base type of a document model.
1114
+ * Projects an action onto the fields the GraphQL `ActionInput` declares.
1098
1115
  *
1099
- * @remarks
1100
- * This type is extended by all Document models.
1116
+ * A projection rather than a spread, because an input object rejects a field it
1117
+ * does not declare, and that refusal takes the whole request with it. An action
1118
+ * read back out of storage can carry fields the type no longer has - a legacy
1119
+ * `attachments` array, or the operation fields left behind by a signing helper
1120
+ * that returns an operation - and any one of them would sink an otherwise valid
1121
+ * submission.
1101
1122
  *
1102
- * @typeParam TState - The type of the document state.
1123
+ * Only fields the action actually carries are emitted, so an unsigned action
1124
+ * sends no context at all rather than a context full of nulls.
1103
1125
  */
1104
- type PHDocument$1<TState extends PHBaseState = PHBaseState> = {
1105
- /** The header of the document. */
1106
- header: PHDocumentHeader;
1107
- /** The document model specific state. */
1108
- state: TState;
1109
- /**
1110
- * The initial state of the document, enabling replaying operations.
1111
- *
1112
- * This will be removed in a future release.
1113
- */
1114
- initialState: TState;
1115
- /**
1116
- * The operations history of the document.
1117
- *
1118
- * Only documents built by reducers carry it. Documents read from a reactor,
1119
- * such as an editor's `document` in Connect, have an empty array per scope;
1120
- * read their history with `useDocumentOperations(document.header.id, scope)`
1121
- * and their operation count with `header.revision[scope]`.
1122
- *
1123
- * This will be removed in a future release.
1124
- */
1125
- operations: DocumentOperations;
1126
- /**
1127
- * A list of undone operations
1128
- *
1129
- * This will be removed in a future release.
1130
- */
1131
- clipboard: Operation[];
1126
+ declare function toTransportAction(action: Action): TransportAction;
1127
+ //#endregion
1128
+ //#region document-model/auth.d.ts
1129
+ type InitializeAuthActionInput = {
1130
+ version: number;
1131
+ grants: Grant[];
1132
1132
  };
1133
- declare function isNoopOperation<TOp extends {
1134
- type: string;
1135
- skip: number;
1136
- hash: string;
1137
- }>(op: Partial<TOp>): boolean;
1138
- declare function isUndoRedo(action: Action): action is UndoRedoAction;
1139
- declare function isUndo(action: Action): action is UndoAction;
1140
- /**
1141
- * Creates a new document. When `documentType` is given the header is stamped
1142
- * with it and the document-scope operations are seeded. Without
1143
- * `protocolVersions` the document is v2-required and takes a derived id; with
1144
- * them it is v2-required only if they say so (see {@link protocolVersionsFor}).
1145
- */
1146
- declare function baseCreateDocument<TState extends PHBaseState = PHBaseState>(createState: CreateState<TState>, initialState?: Partial<TState>, documentType?: string, protocolVersions?: ProtocolVersions): PHDocument$1<TState>;
1147
- /**
1148
- * `document`, not yet created, under a fresh header for `policy`. A legacy
1149
- * header takes `id` when given; a v2-required one ignores `id` and derives its
1150
- * own, so a caller that needs a fixed id must ask for legacy.
1151
- * `protocolVersions` are merged over the document's. Name, slug, branch and
1152
- * meta carry over. A document already under `policy` is returned as is unless
1153
- * a legacy `id` or `protocolVersions` are given.
1154
- */
1155
- declare function withSignaturePolicy<TDocument extends PHDocument$1>(document: TDocument, policy: SignaturePolicy$1, options?: {
1156
- id?: string;
1157
- protocolVersions?: ProtocolVersions;
1158
- }): TDocument;
1159
- declare function hashDocumentStateForScope(document: {
1160
- state: {
1161
- [key: string]: unknown;
1162
- };
1163
- }, scope?: string): string;
1164
- declare function readOnly<T>(value: T): Readonly<T>;
1165
- /**
1166
- * Maps skipped operations in an array of operations.
1167
- * Skipped operations are operations that are ignored during processing.
1168
- * @param operations - The array of operations to map.
1169
- * @param skippedHeadOperations - The number of operations to skip at the head of the array of operations.
1170
- * @returns An array of mapped operations with ignore flag indicating if the operation is skipped.
1171
- * @throws Error if the operation index is invalid and there are missing operations.
1172
- */
1173
- declare function mapSkippedOperations(operations: Operation[], skippedHeadOperations?: number): MappedOperation[];
1174
- /**
1175
- * V2 version of mapSkippedOperations for protocol version 2+.
1176
- * In V2, all NOOPs have skip=1 and consecutive NOOPs form chains.
1177
- * N consecutive NOOPs at any point skip N preceding content operations.
1178
- *
1179
- * Algorithm: Process from end to start
1180
- * - When hitting a NOOP: increment chain length, mark as ignored
1181
- * - When hitting a non-NOOP:
1182
- * - If chain > 0: decrement chain, mark as ignored (this op was undone)
1183
- * - If chain == 0: mark as not ignored (apply this op)
1184
- */
1185
- declare function mapSkippedOperationsV2(operations: Operation[]): MappedOperation[];
1186
- /**
1187
- * V2 garbage collect that returns only operations that should be applied for state.
1188
- * Uses the V2 model where consecutive NOOPs form chains.
1189
- * Unlike V1 garbageCollect, this preserves ALL operations but marks which to apply.
1190
- */
1191
- declare function garbageCollectV2<TOpIndex extends OperationIndex>(sortedOperations: TOpIndex[]): TOpIndex[];
1192
- declare function sortMappedOperations(operations: DocumentOperationsIgnoreMap): MappedOperation[];
1193
- /**
1194
- * Records an operation in the history without applying it, which is what a
1195
- * denied operation needs: it occupies its index and contributes no state.
1196
- *
1197
- * The scope defaults to the action's own, and is passed explicitly by a rebuild
1198
- * that is walking one stream and does not want to trust the action's copy.
1199
- */
1200
- declare function appendWithoutApplying<TState extends PHBaseState>(document: PHDocument$1<TState>, operation: Operation, scope?: string): PHDocument$1<TState>;
1201
- /** The state reducer base-reducer 3 derives with; throws when `reducer` wraps none. */
1202
- declare function requireStateReducer<TState extends PHBaseState = PHBaseState>(reducer: Reducer<TState>, documentType: string, version?: number): StateReducer<TState>;
1203
- /** Rejects the index gaps the reducer rejects when it appends a replayed row. */
1204
- declare function assertReplayIndices(operations: readonly Operation[]): void;
1205
- declare function appendRows<TState extends PHBaseState>(document: PHDocument$1<TState>, scope: string, rows: readonly Operation[]): PHDocument$1<TState>;
1206
- declare function replayDocument<TState extends PHBaseState = PHBaseState>(initialState: TState, operations: DocumentOperations, reducer: Reducer<TState>, header: PHDocumentHeader, dispatch?: SignalDispatch, skipHeaderOperations?: SkipHeaderOperations, options?: ReplayDocumentOptions): PHDocument$1<TState>;
1207
- declare function parseResultingState<TState>(state: string | null | undefined): TState;
1208
- declare enum IntegrityIssueType {
1209
- UNEXPECTED_INDEX = "UNEXPECTED_INDEX"
1210
- }
1211
- declare enum IntegrityIssueSubType {
1212
- DUPLICATED_INDEX = "DUPLICATED_INDEX",
1213
- MISSING_INDEX = "MISSING_INDEX"
1214
- }
1215
- type IntegrityIssue = {
1216
- operation: OperationIndex;
1217
- issue: IntegrityIssueType;
1218
- category: IntegrityIssueSubType;
1219
- message: string;
1133
+ type SetGrantActionInput = {
1134
+ grant: Grant;
1220
1135
  };
1221
- type Reshuffle = (startIndex: OperationIndex, opsA: Operation[], opsB: Operation[]) => Operation[];
1222
- declare function checkCleanedOperationsIntegrity(sortedOperations: OperationIndex[]): IntegrityIssue[];
1223
- declare function addUndo(sortedOperations: Operation[]): Operation[];
1224
- declare function reshuffleByTimestamp<TOp extends OperationIndex>(startIndex: OperationIndex, opsA: TOp[], opsB: TOp[]): TOp[];
1225
- declare function reshuffleByTimestampAndIndex<TOp extends OperationIndex>(startIndex: OperationIndex, opsA: TOp[], opsB: TOp[]): TOp[];
1226
- declare function operationsAreEqual<TOp extends {
1136
+ type RemoveGrantActionInput = {
1137
+ id: string;
1138
+ };
1139
+ type MoveGrantActionInput = {
1140
+ id: string;
1141
+ /** Target index in the grant list; clamped to the valid range. */
1227
1142
  index: number;
1228
- skip: number;
1229
- type?: string;
1230
- scope?: string;
1231
- input?: unknown;
1232
- }>(op1: TOp, op2: TOp): boolean;
1233
- declare function attachBranch(trunk: Operation[], newBranch: Operation[]): [Operation[], Operation[]];
1234
- declare function precedes(op1: OperationIndex, op2: OperationIndex): boolean;
1235
- declare function split(sortedTargetOperations: Operation[], sortedMergeOperations: Operation[]): [Operation[], Operation[], Operation[]];
1236
- declare function merge(sortedTargetOperations: Operation[], sortedMergeOperations: Operation[], reshuffle: Reshuffle): Operation[];
1237
- declare function checkOperationsIntegrity(operations: Operation[]): IntegrityIssue[];
1238
- declare function groupOperationsByScope(operations: Operation[]): Partial<Record<string, Operation[]>>;
1239
- type PrepareOperationsResult = {
1240
- validOperations: Operation[];
1241
- invalidOperations: Operation[];
1242
- duplicatedOperations: Operation[];
1243
- integrityIssues: IntegrityIssue[];
1244
1143
  };
1245
- declare function prepareOperations(operationsHistory: Operation[], newOperations: Operation[]): PrepareOperationsResult;
1246
- declare function removeExistingOperations(newOperations: Operation[], operationsHistory: Operation[]): Operation[];
1247
- /**
1248
- * Skips header operations and returns the remaining operations.
1249
- *
1250
- * @param operations - The array of operations.
1251
- * @param skipHeaderOperation - The skip header operation index.
1252
- * @returns The remaining operations after skipping header operations.
1253
- */
1254
- declare function skipHeaderOperations(operations: Operation[], skipHeaderOperation: SkipHeaderOperationIndex): Operation[];
1255
- declare function garbageCollectDocumentOperations(documentOperations: DocumentOperations): DocumentOperations;
1144
+ type InitializeAuthAction = Action & {
1145
+ type: "INITIALIZE_AUTH";
1146
+ input: InitializeAuthActionInput;
1147
+ };
1148
+ type SetGrantAction = Action & {
1149
+ type: "SET_GRANT";
1150
+ input: SetGrantActionInput;
1151
+ };
1152
+ type RemoveGrantAction = Action & {
1153
+ type: "REMOVE_GRANT";
1154
+ input: RemoveGrantActionInput;
1155
+ };
1156
+ type MoveGrantAction = Action & {
1157
+ type: "MOVE_GRANT";
1158
+ input: MoveGrantActionInput;
1159
+ };
1160
+ type AuthAction = InitializeAuthAction | SetGrantAction | RemoveGrantAction | MoveGrantAction;
1161
+ declare const AUTH_ACTION_TYPES: readonly ["INITIALIZE_AUTH", "SET_GRANT", "REMOVE_GRANT", "MOVE_GRANT"];
1162
+ declare function isAuthAction(action: Action): action is AuthAction;
1163
+ /** Highest known policy version; decide() fails closed above it. */
1164
+ declare const MAX_SUPPORTED_AUTH_VERSION = 1;
1165
+ declare const InitializeAuthActionInputSchema: () => z.ZodObject<{
1166
+ version: z.ZodNumber;
1167
+ grants: z.ZodArray<z.ZodCustom<Grant, Grant>>;
1168
+ }, z.core.$strip>;
1169
+ declare const SetGrantActionInputSchema: () => z.ZodObject<{
1170
+ grant: z.ZodCustom<Grant, Grant>;
1171
+ }, z.core.$strip>;
1172
+ declare const RemoveGrantActionInputSchema: () => z.ZodObject<{
1173
+ id: z.ZodString;
1174
+ }, z.core.$strip>;
1175
+ declare const MoveGrantActionInputSchema: () => z.ZodObject<{
1176
+ id: z.ZodString;
1177
+ index: z.ZodNumber;
1178
+ }, z.core.$strip>;
1179
+ declare const initializeAuth: (input: InitializeAuthActionInput) => InitializeAuthAction;
1180
+ declare const setGrant: (input: SetGrantActionInput) => SetGrantAction;
1181
+ declare const removeGrant: (input: RemoveGrantActionInput) => RemoveGrantAction;
1182
+ declare const moveGrant: (input: MoveGrantActionInput) => MoveGrantAction;
1256
1183
  /**
1257
- * Filters out duplicated operations from the target operations array based on their IDs.
1258
- * If an operation has an ID, it is considered duplicated if there is another operation in the source operations array with the same ID.
1259
- * If an operation does not have an ID, it is considered unique and will not be filtered out.
1260
- * @param targetOperations - The array of target operations to filter.
1261
- * @param sourceOperations - The array of source operations to compare against.
1262
- * @returns An array of operations with duplicates filtered out.
1184
+ * True when `signerKey` (an ActionSigner app key, a did:key) identifies the same
1185
+ * key recorded as the document creator. Returns false
1186
+ * when there is no creator (empty JWK) or no signer key.
1263
1187
  */
1264
- declare function filterDuplicatedOperations<T extends {
1265
- id?: string | number;
1266
- }>(targetOperations: T[], sourceOperations: T[]): T[];
1267
- declare function filterDocumentOperationsResultingState(documentOperations?: DocumentOperations): {
1268
- [x: string]: Operation[] | {
1269
- id: string;
1270
- index: number;
1271
- skip: number;
1272
- timestampUtcMs: string;
1273
- hash: string;
1274
- error?: string;
1275
- errorName?: string;
1276
- errorCode?: string;
1277
- deniedReason?: string;
1278
- action: Action;
1279
- }[];
1280
- };
1188
+ declare function isDocumentCreator(creatorKey: JsonWebKey | undefined, signerKey: string | undefined): boolean;
1281
1189
  /**
1282
- * Calculates the difference between two arrays of operations.
1283
- * Returns an array of operations that are present in `clearedOperationsA` but not in `clearedOperationsB`.
1284
- *
1285
- * @template TOp - The type of the operations.
1286
- * @param {TOp[]} clearedOperationsA - The first array of operations.
1287
- * @param {TOp[]} clearedOperationsB - The second array of operations.
1288
- * @returns {TOp[]} - The difference between the two arrays of operations.
1190
+ * Sets the initial policy. Valid only while the auth scope is uninitialized
1191
+ * (version 0). The input version is the policy language version and must be an
1192
+ * integer >= 1; 0 is reserved for the uninitialized state. On a signed-header
1193
+ * document it must be signed by the document creator (`header.sig.publicKey`).
1194
+ * A creator-less policy must include a grant permitting execute on the auth
1195
+ * scope, or it would be born locked out.
1289
1196
  */
1290
- declare function diffOperations<TOp extends OperationIndex>(clearedOperationsA: TOp[], clearedOperationsB: TOp[]): TOp[];
1291
- declare function getDocumentLastModified(document: PHDocument$1): string;
1292
- /** `revision` with a 0 for each scope of `state` it lacks; auth is not a model scope, so it is left out. */
1293
- declare function withScopeRevisions(revision: PHDocumentHeader["revision"], state: object): PHDocumentHeader["revision"];
1197
+ declare function applyInitializeAuthAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: InitializeAuthAction): PHDocument$1<TState>;
1198
+ /** Upserts a grant by id: replaces in place if present, otherwise appends. */
1199
+ declare function applySetGrantAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: SetGrantAction): PHDocument$1<TState>;
1294
1200
  /**
1295
- * Updates the document header with the latest revision number and
1296
- * date of last modification.
1297
- *
1298
- * @param document The current state of the document.
1299
- * @param scope The scope of the operation.
1300
- * @param lastModifiedTimestamp Optional timestamp to use directly, avoiding a scan of all operations.
1301
- * @returns The updated document state.
1201
+ * Removes a grant by id; throws if the id is not present or if the removal
1202
+ * would leave a creator-less policy with no auth-administration grant.
1302
1203
  */
1303
- declare function updateHeaderRevision(document: PHDocument$1, scope: string, lastModifiedTimestamp?: string): PHDocument$1;
1304
- //#endregion
1305
- //#region document-model/actions.d.ts
1204
+ declare function applyRemoveGrantAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: RemoveGrantAction): PHDocument$1<TState>;
1306
1205
  /**
1307
- * Cancels the last `count` operations.
1206
+ * Moves a grant by id to a new index. Order is load-bearing (the last
1207
+ * applicable grant wins), so the relative order of the other grants is kept.
1208
+ * The target index is clamped to the valid range; an unknown id throws.
1308
1209
  *
1309
- * @param count - Number of operations to cancel
1310
- * @category Actions
1210
+ * Order alone decides which grant wins, so a move can take administration away
1211
+ * without changing the list's contents. It carries the same retention rule as
1212
+ * the two mutation paths.
1311
1213
  */
1312
- declare const undo: (count?: number, scope?: string) => UndoAction;
1214
+ declare function applyMoveGrantAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: MoveGrantAction): PHDocument$1<TState>;
1313
1215
  /**
1314
- * Cancels the last `count` {@link undo | UNDO} operations.
1315
- *
1316
- * @param count - Number of UNDO operations to cancel
1317
- * @category Actions
1216
+ * Dispatches an auth-scope action to its handler. This is the auth scope's
1217
+ * dedicated reducer: it is applied by the base reducer instead of the model
1218
+ * reducer, mirroring the document-scope platform handlers. Unknown types are a
1219
+ * no-op, matching the model-reducer default.
1318
1220
  */
1319
- declare const redo: (count?: number, scope?: string) => RedoAction;
1320
- declare const noop: (scope?: string) => NOOPAction;
1221
+ declare function applyAuthAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: Action): PHDocument$1<TState>;
1321
1222
  /**
1322
- * Retracts the action with id `target` on base-reducer 3.
1323
- *
1324
- * @category Actions
1223
+ * Because only creators can initialize auth scopes, we must verify that either
1224
+ * the document has no auth or the version and creator match.
1325
1225
  */
1326
- declare const retract: (target: string, scope?: string) => RetractAction;
1226
+ declare function assertAuthPreservedOnDuplicate(documentId: string, source: PHAuthState | undefined, duplicated: PHAuthState | undefined): void;
1327
1227
  /**
1328
- * Helper function to be used by action creators.
1329
- *
1330
- * @remarks
1331
- * Creates an action with the given type and input properties. The input
1332
- * properties default to an empty object.
1333
- *
1334
- * @typeParam A - Type of the action to be returned.
1228
+ * The auth scope a state snapshot may install, given the policy already there.
1335
1229
  *
1336
- * @param type - The type of the action.
1337
- * @param input - The input properties of the action.
1338
- * @param _attachments - Deprecated and ignored. Retained so action creators
1339
- * generated before the attachment-system removal keep their 5-argument shape.
1340
- * @param validator - The validator to use for the input properties.
1341
- * @param scope - The scope of the action, can either be 'global' or 'local'.
1230
+ * `applyAuthAction` is the validated door onto `state.auth`, but a whole-state
1231
+ * snapshot (UPGRADE_DOCUMENT's `initialState`) replaces the scope wholesale and
1232
+ * is authorized as a `document`-scope write. Without this, a subject holding
1233
+ * `execute` on `document` and no auth grant at all can install a policy of its
1234
+ * choosing, name itself `creator` (which exempts the policy from the retention
1235
+ * rule for good), or wipe an existing policy by carrying the default
1236
+ * uninitialized one.
1342
1237
  *
1343
- * @throws Error if the type is empty or not a string.
1238
+ * Three cases:
1344
1239
  *
1345
- * @returns The new action.
1346
- */
1347
- declare function createAction<TAction extends Action>(type: TAction["type"], input?: TAction["input"], _attachments?: unknown, validator?: () => {
1348
- parse(v: unknown): TAction["input"];
1349
- }, scope?: Action["scope"]): TAction;
1350
- /**
1351
- * This function should be used instead of { ...action } to ensure
1352
- * that extra properties are not included in the action.
1240
+ * - the snapshot carries no policy, or an uninitialized one: the document
1241
+ * keeps the policy it has, so a default-state upgrade cannot reset it;
1242
+ * - the document is uninitialized and the snapshot carries a policy: the
1243
+ * policy is installed after the same validation genesis applies, so it
1244
+ * cannot be born locked out;
1245
+ * - both carry a policy: they must agree. A duplicate preserves its source's
1246
+ * policy (see {@link assertAuthPreservedOnDuplicate}), and anything else is
1247
+ * an attempt to replace one policy with another.
1353
1248
  */
1354
- declare const actionFromAction: (action: Action) => Action;
1355
- declare const operationFromAction: (action: Action, index: number, skip: number, context: OperationContext) => Operation;
1356
- declare const operationFromOperation: (operation: Operation, index: number, skip: number, context: OperationContext) => Operation;
1357
- declare const operationWithContext: (operation: Operation, context: ActionContext) => Operation;
1358
- declare const actionContext: () => ActionContext;
1359
- declare const actionSigner: (user: UserActionSigner, app: AppActionSigner, signatures?: Signature[]) => ActionSigner;
1360
- declare function buildOperationSignature(context: ActionSignatureContext, signMethod: ActionSigningHandler): Promise<Signature>;
1361
- /** @deprecated Emits a legacy SHA-1 tuple; sign through `ISigner.signAction`. */
1362
- declare function buildSignedAction<TState extends PHBaseState = PHBaseState>(action: Action, reducer: Reducer<TState>, document: PHDocument$1<TState>, signer: ActionSigner, signHandler: ActionSigningHandler): Promise<Operation>;
1363
- /** @deprecated Use `verifyActionSignature` from `@powerhousedao/reactor`. */
1364
- declare function verifyOperationSignature(signature: Signature, signer: Omit<ActionSigner, "signatures">, verifyHandler: ActionVerificationHandler): Promise<boolean>;
1249
+ declare function resolveSnapshotAuth(documentId: string, documentType: string, current: PHAuthState | undefined, incoming: PHAuthState | undefined): PHAuthState;
1250
+ /** UNDO and REDO are rejected on the auth scope. */
1251
+ declare function assertAuthScopeActionAllowed(action: Action): void;
1252
+ type AuthVerb = "read" | "execute";
1253
+ type AuthRequest = {
1254
+ verb: AuthVerb;
1255
+ scope: string;
1256
+ /** For execute: the operation (action type) being attempted. Omitted for reads. */
1257
+ operation?: string;
1258
+ };
1259
+ type AuthSubject = {
1260
+ /** Verified signer address; undefined for an anonymous subject. */
1261
+ address?: string;
1262
+ /** The signer's app key (a did:key), used to match the document creator. */
1263
+ key?: string;
1264
+ };
1365
1265
  /**
1366
- * Changes the name of the document.
1367
- *
1368
- * @param name - The name to be set in the document.
1369
- * @category Actions
1266
+ * What condition attr paths resolve against, beyond the subject. Supplied
1267
+ * only while authConditions enforcement is on: with no context a grant
1268
+ * carrying `where` or a { match } principal never applies.
1370
1269
  */
1371
- declare const setName: (name: string | {
1372
- name: string;
1373
- }) => SetNameAction;
1270
+ type ConditionContext = {
1271
+ /** The executing scope's own state, for `doc.<scope>.*` paths. */
1272
+ scopeState: unknown;
1273
+ /** The action's input, for `action.input.*` paths. Absent for reads. */
1274
+ actionInput?: unknown;
1275
+ };
1276
+ type AuthDecision = "allow" | "deny";
1277
+ /** Why the policy refused a request. */
1278
+ type AuthRefusal = "version-unsupported" | "no-applicable-grant" | "denied-by-grant";
1374
1279
  /**
1375
- * Changes the preferred editor recorded in the document header meta.
1376
- *
1377
- * Passing `null` clears the preferred editor.
1378
- *
1379
- * @category Actions
1280
+ * A decision together with why it refused. A refusal names which of the
1281
+ * policy's rules produced it, so an operation records the reason it was refused
1282
+ * rather than one reason standing for every refusal.
1380
1283
  */
1381
- declare const setPreferredEditor: (input: string | null | {
1382
- preferredEditor: string | null;
1383
- }) => SetPreferredEditorAction;
1284
+ type AuthEvaluation = {
1285
+ decision: "allow";
1286
+ } | {
1287
+ decision: "deny";
1288
+ refusal: AuthRefusal;
1289
+ grantId?: string;
1290
+ };
1384
1291
  /**
1385
- * Gives the document a slug, its name on the reactor that serves it. The last
1386
- * document to claim a slug holds it.
1292
+ * Evaluates the auth policy for a single request and reports why it refused.
1293
+ * Pure and deterministic.
1387
1294
  *
1388
- * @category Actions
1295
+ * An uninitialized policy (version 0, absent auth state, or a legacy `{}`
1296
+ * auth scope serialized before PHAuthState had a version) leaves the document
1297
+ * open. Once a policy exists the default is deny, and grants stack in order.
1298
+ *
1299
+ * Group principals match only against a supplied groups map (the groups
1300
+ * projection, present when authGroups is on); with no map they never apply.
1301
+ * `where` clauses and { match } principals likewise evaluate only against a
1302
+ * supplied condition context (present when authConditions is on).
1389
1303
  */
1390
- declare const setSlug: (slug: string) => SetSlugAction;
1391
- declare const setModelName: (input: SetModelNameInput) => SetModelNameAction;
1392
- declare const setModelId: (input: SetModelIdInput) => SetModelIdAction;
1393
- declare const setModelExtension: (input: SetModelExtensionInput) => SetModelExtensionAction;
1394
- declare const setModelDescription: (input: SetModelDescriptionInput) => SetModelDescriptionAction;
1395
- declare const setAuthorName: (input: SetAuthorNameInput) => SetAuthorNameAction;
1396
- declare const setAuthorWebsite: (input: SetAuthorWebsiteInput) => SetAuthorWebsiteAction;
1397
- declare const addModule: (input: AddModuleInput) => AddModuleAction;
1398
- declare const setModuleName: (input: SetModuleNameInput) => SetModuleNameAction;
1399
- declare const setModuleDescription: (input: SetModuleDescriptionInput) => SetModuleDescriptionAction;
1400
- declare const deleteModule: (input: DeleteModuleInput) => DeleteModuleAction;
1401
- declare const reorderModules: (input: ReorderModulesInput) => ReorderModulesAction;
1402
- declare const addOperation: (input: AddOperationInput) => AddOperationAction;
1403
- declare const setOperationName: (input: SetOperationNameInput) => SetOperationNameAction;
1404
- declare const setOperationScope: (input: SetOperationScopeInput) => SetOperationScopeAction;
1405
- declare const setOperationSchema: (input: SetOperationSchemaInput) => SetOperationSchemaAction;
1406
- declare const setOperationDescription: (input: SetOperationDescriptionInput) => SetOperationDescriptionAction;
1407
- declare const setOperationTemplate: (input: SetOperationTemplateInput) => SetOperationTemplateAction;
1408
- declare const setOperationReducer: (input: SetOperationReducerInput) => SetOperationReducerAction;
1409
- declare const moveOperation: (input: MoveOperationInput) => MoveOperationAction;
1410
- declare const deleteOperation: (input: DeleteOperationInput) => DeleteOperationAction;
1411
- declare const reorderModuleOperations: (input: ReorderModuleOperationsInput) => ReorderModuleOperationsAction;
1412
- declare const addOperationError: (input: AddOperationErrorInput) => AddOperationErrorAction;
1413
- declare const setOperationErrorCode: (input: SetOperationErrorCodeInput) => SetOperationErrorCodeAction;
1414
- declare const setOperationErrorName: (input: SetOperationErrorNameInput) => SetOperationErrorNameAction;
1415
- declare const setOperationErrorDescription: (input: SetOperationErrorDescriptionInput) => SetOperationErrorDescriptionAction;
1416
- declare const setOperationErrorTemplate: (input: SetOperationErrorTemplateInput) => SetOperationErrorTemplateAction;
1417
- declare const deleteOperationError: (input: DeleteOperationErrorInput) => DeleteOperationErrorAction;
1418
- declare const reorderOperationErrors: (input: ReorderOperationErrorsInput) => ReorderOperationErrorsAction;
1419
- declare const addOperationExample: (input: AddOperationExampleInput) => AddOperationExampleAction;
1420
- declare const updateOperationExample: (input: UpdateOperationExampleInput) => UpdateOperationExampleAction;
1421
- declare const deleteOperationExample: (input: DeleteOperationExampleInput) => DeleteOperationExampleAction;
1422
- declare const reorderOperationExamples: (input: ReorderOperationExamplesInput) => ReorderOperationExamplesAction;
1423
- declare const operationExampleCreators: {
1424
- addOperationExample: typeof addOperationExample;
1425
- updateOperationExample: typeof updateOperationExample;
1426
- deleteOperationExample: typeof deleteOperationExample;
1427
- reorderOperationExamples: typeof reorderOperationExamples;
1428
- };
1429
- declare const setStateSchema: (input: SetStateSchemaInput) => SetStateSchemaAction;
1430
- declare const setInitialState: (input: SetInitialStateInput) => SetInitialStateAction;
1431
- declare const addStateExample: (input: AddStateExampleInput) => AddStateExampleAction;
1432
- declare const updateStateExample: (input: UpdateStateExampleInput) => UpdateStateExampleAction;
1433
- declare const deleteStateExample: (input: DeleteStateExampleInput) => DeleteStateExampleAction;
1434
- declare const reorderStateExamples: (input: ReorderStateExamplesInput) => ReorderStateExamplesAction;
1435
- declare const addChangeLogItem: (input: AddChangeLogItemInput) => AddChangeLogItemAction;
1436
- declare const updateChangeLogItem: (input: UpdateChangeLogItemInput) => UpdateChangeLogItemAction;
1437
- declare const deleteChangeLogItem: (input: DeleteChangeLogItemInput) => DeleteChangeLogItemAction;
1438
- declare const reorderChangeLogItems: (input: ReorderChangeLogItemsInput) => ReorderChangeLogItemsAction;
1439
- declare const releaseNewVersion: () => ReleaseNewVersionAction;
1440
- declare const baseActions: {
1441
- setName: typeof setName;
1442
- setPreferredEditor: typeof setPreferredEditor;
1443
- setSlug: typeof setSlug;
1444
- undo: typeof undo;
1445
- redo: typeof redo;
1446
- noop: typeof noop;
1447
- };
1448
- declare const documentModelActions: {
1449
- setModelName: typeof setModelName;
1450
- setModelId: typeof setModelId;
1451
- setModelExtension: typeof setModelExtension;
1452
- setModelDescription: typeof setModelDescription;
1453
- setAuthorName: typeof setAuthorName;
1454
- setAuthorWebsite: typeof setAuthorWebsite;
1455
- addModule: typeof addModule;
1456
- setModuleName: typeof setModuleName;
1457
- setModuleDescription: typeof setModuleDescription;
1458
- deleteModule: typeof deleteModule;
1459
- reorderModules: typeof reorderModules;
1460
- addOperation: typeof addOperation;
1461
- setOperationName: typeof setOperationName;
1462
- setOperationScope: typeof setOperationScope;
1463
- setOperationSchema: typeof setOperationSchema;
1464
- setOperationDescription: typeof setOperationDescription;
1465
- setOperationTemplate: typeof setOperationTemplate;
1466
- setOperationReducer: typeof setOperationReducer;
1467
- moveOperation: typeof moveOperation;
1468
- deleteOperation: typeof deleteOperation;
1469
- reorderModuleOperations: typeof reorderModuleOperations;
1470
- addOperationError: typeof addOperationError;
1471
- setOperationErrorCode: typeof setOperationErrorCode;
1472
- setOperationErrorName: typeof setOperationErrorName;
1473
- setOperationErrorDescription: typeof setOperationErrorDescription;
1474
- setOperationErrorTemplate: typeof setOperationErrorTemplate;
1475
- deleteOperationError: typeof deleteOperationError;
1476
- reorderOperationErrors: typeof reorderOperationErrors;
1477
- addOperationExample: typeof addOperationExample;
1478
- updateOperationExample: typeof updateOperationExample;
1479
- deleteOperationExample: typeof deleteOperationExample;
1480
- reorderOperationExamples: typeof reorderOperationExamples;
1481
- setStateSchema: typeof setStateSchema;
1482
- setInitialState: typeof setInitialState;
1483
- addStateExample: typeof addStateExample;
1484
- updateStateExample: typeof updateStateExample;
1485
- deleteStateExample: typeof deleteStateExample;
1486
- reorderStateExamples: typeof reorderStateExamples;
1487
- addChangeLogItem: typeof addChangeLogItem;
1488
- updateChangeLogItem: typeof updateChangeLogItem;
1489
- deleteChangeLogItem: typeof deleteChangeLogItem;
1490
- reorderChangeLogItems: typeof reorderChangeLogItems;
1491
- releaseNewVersion: typeof releaseNewVersion;
1492
- };
1493
- declare const actions: {
1494
- setName: typeof setName;
1495
- setPreferredEditor: typeof setPreferredEditor;
1496
- setSlug: typeof setSlug;
1497
- undo: typeof undo;
1498
- redo: typeof redo;
1499
- noop: typeof noop;
1500
- setModelName: typeof setModelName;
1501
- setModelId: typeof setModelId;
1502
- setModelExtension: typeof setModelExtension;
1503
- setModelDescription: typeof setModelDescription;
1504
- setAuthorName: typeof setAuthorName;
1505
- setAuthorWebsite: typeof setAuthorWebsite;
1506
- addModule: typeof addModule;
1507
- setModuleName: typeof setModuleName;
1508
- setModuleDescription: typeof setModuleDescription;
1509
- deleteModule: typeof deleteModule;
1510
- reorderModules: typeof reorderModules;
1511
- addOperation: typeof addOperation;
1512
- setOperationName: typeof setOperationName;
1513
- setOperationScope: typeof setOperationScope;
1514
- setOperationSchema: typeof setOperationSchema;
1515
- setOperationDescription: typeof setOperationDescription;
1516
- setOperationTemplate: typeof setOperationTemplate;
1517
- setOperationReducer: typeof setOperationReducer;
1518
- moveOperation: typeof moveOperation;
1519
- deleteOperation: typeof deleteOperation;
1520
- reorderModuleOperations: typeof reorderModuleOperations;
1521
- addOperationError: typeof addOperationError;
1522
- setOperationErrorCode: typeof setOperationErrorCode;
1523
- setOperationErrorName: typeof setOperationErrorName;
1524
- setOperationErrorDescription: typeof setOperationErrorDescription;
1525
- setOperationErrorTemplate: typeof setOperationErrorTemplate;
1526
- deleteOperationError: typeof deleteOperationError;
1527
- reorderOperationErrors: typeof reorderOperationErrors;
1528
- addOperationExample: typeof addOperationExample;
1529
- updateOperationExample: typeof updateOperationExample;
1530
- deleteOperationExample: typeof deleteOperationExample;
1531
- reorderOperationExamples: typeof reorderOperationExamples;
1532
- setStateSchema: typeof setStateSchema;
1533
- setInitialState: typeof setInitialState;
1534
- addStateExample: typeof addStateExample;
1535
- updateStateExample: typeof updateStateExample;
1536
- deleteStateExample: typeof deleteStateExample;
1537
- reorderStateExamples: typeof reorderStateExamples;
1538
- addChangeLogItem: typeof addChangeLogItem;
1539
- updateChangeLogItem: typeof updateChangeLogItem;
1540
- deleteChangeLogItem: typeof deleteChangeLogItem;
1541
- reorderChangeLogItems: typeof reorderChangeLogItems;
1542
- releaseNewVersion: typeof releaseNewVersion;
1543
- };
1304
+ declare function evaluate(auth: PHAuthState | undefined, subject: AuthSubject, request: AuthRequest, groups?: AuthGroups, conditions?: ConditionContext): AuthEvaluation;
1544
1305
  /**
1545
- * The context of an action.
1306
+ * Evaluates the auth policy for a single request. Pure and deterministic. This
1307
+ * is {@link evaluate} with the reason dropped.
1546
1308
  */
1547
- type ActionContext = {
1548
- /** The index of the previous operation, showing intended ordering. */
1549
- prevOpIndex?: number;
1550
- /** The hash of the previous operation, showing intended state. */
1551
- prevOpHash?: string;
1552
- /** A nonce, to cover specific signing attacks and to prevent replay attacks from no-ops. */
1553
- nonce?: string;
1554
- /** The signer of the action. */
1555
- signer?: ActionSigner;
1556
- };
1309
+ declare function decide(auth: PHAuthState | undefined, subject: AuthSubject, request: AuthRequest, groups?: AuthGroups, conditions?: ConditionContext): AuthDecision;
1557
1310
  /**
1558
- * Defines the basic structure of an action.
1311
+ * The group document ids a single auth action's input names with `{ group }`
1312
+ * principals. INITIALIZE_AUTH contributes the groups named across its grants,
1313
+ * SET_GRANT the groups named by its one grant; REMOVE_GRANT and MOVE_GRANT
1314
+ * contribute nothing. Total over any input shape, because references are read
1315
+ * from the input as it arrived, including inputs later stored as errors.
1559
1316
  */
1560
- type Action = {
1561
- /** The id of the action. This is distinct from the operation id. */
1562
- id: string;
1563
- /** The name of the action. */
1564
- type: string;
1565
- /** The timestamp of the action. */
1566
- timestampUtcMs: string;
1567
- /** The payload of the action. */
1568
- input: unknown;
1569
- /** The scope of the action */
1570
- scope: string;
1571
- /** The context of the action. */
1572
- context?: ActionContext;
1573
- };
1574
- //#endregion
1575
- //#region document-model/action-signature.d.ts
1576
- declare const ACTION_SIGNATURE_V2_PREFIX = "v2:";
1577
- /** The log an operation is stored in, which a v2 tuple is bound to. */
1578
- type ActionSigningTarget = {
1579
- documentId: string;
1580
- branch: string;
1581
- };
1582
- /** Who a v2 tuple attributes the action to; both halves are in the preimage. */
1583
- type ActionSignerIdentity = {
1584
- user: UserActionSigner;
1585
- app: AppActionSigner;
1586
- };
1587
- /** A value that would not survive a JSON store round trip unchanged. */
1588
- declare class CanonicalJsonError extends Error {
1589
- constructor(path: string, detail: string);
1590
- }
1591
- /** Sorted-key JSON, as the state hash encodes; drops `undefined` properties. */
1592
- declare function canonicalJson(value: unknown, label?: string): string;
1593
- /** Actions the reactor reduces itself, onto the document scope. */
1594
- declare const DOCUMENT_SCOPE_ACTION_TYPES: ReadonlySet<string>;
1595
- /** Where a document-scope action writes: `sourceId` or `documentId`. */
1596
- declare function targetDocumentId(action: {
1597
- type: string;
1598
- input: unknown;
1599
- }, fallback: string): string;
1600
- /** The log an action submitted to a job on `documentId` is stored in. */
1601
- declare function actionSigningTarget(action: {
1602
- type: string;
1603
- input: unknown;
1604
- }, documentId: string, branch: string): ActionSigningTarget;
1605
- /** The identity a signer writes into `context.signer`, and signs over. */
1606
- declare function actionSignerIdentity(signer: {
1607
- user?: UserActionSigner;
1608
- app?: AppActionSigner;
1609
- }): ActionSignerIdentity;
1610
- /** The v2 preimage; throws `CanonicalJsonError` on an unsignable action. */
1611
- declare function actionPreimageV2(action: Action, target: ActionSigningTarget, signer: ActionSignerIdentity): string;
1612
- /** `"v2:" + base64url(sha256(preimage))`, unpadded. */
1613
- declare function hashActionV2(action: Action, target: ActionSigningTarget, signer: ActionSignerIdentity): Promise<string>;
1614
- /** Signs `action` as a v2 tuple; the message layout is the legacy one. */
1615
- declare function signActionV2(params: {
1616
- action: Action;
1617
- target: ActionSigningTarget;
1618
- signer: ActionSignerIdentity;
1619
- sign: ActionSigningHandler;
1620
- previousStateHash?: string;
1621
- }): Promise<Signature>;
1622
- /** Element [2] carries the v2 prefix, whether or not it is well formed. */
1623
- declare function isV2ActionHash(hash: string): boolean;
1624
- /** The strict shape of a v2 tuple, apart from what its hash covers. */
1625
- declare function v2TupleProblem(tuple: Signature): string | undefined;
1317
+ declare function mentionedGroupIds(action: Action): string[];
1626
1318
  //#endregion
1627
- //#region document-model/action-transport.d.ts
1319
+ //#region document-model/auth-v1.d.ts
1320
+ /** Maximum number of grants in a policy. */
1321
+ declare const MAX_AUTH_GRANTS = 100;
1322
+ /** Maximum nesting depth of a condition tree. */
1323
+ declare const MAX_CONDITION_DEPTH = 10;
1324
+ /** Maximum node count (conditions plus operands) of a condition tree. */
1325
+ declare const MAX_CONDITION_NODES = 100;
1326
+ /** Maximum entries in an execute capability's operation list. */
1327
+ declare const MAX_CAPABILITY_OPERATIONS = 100;
1628
1328
  /**
1629
- * An action's signer, as the wire declares it: signatures joined into strings,
1630
- * because GraphQL declares them as a list of strings rather than of lists.
1329
+ * Thrown when a grant violates the v1 validation rules. The message is stored
1330
+ * on error operations, so it must be a pure function of the input.
1631
1331
  */
1632
- type TransportSigner = {
1633
- user?: {
1634
- address: string;
1635
- networkId: string;
1636
- chainId: number;
1637
- };
1638
- app?: {
1639
- name: string;
1640
- key: string;
1641
- };
1642
- signatures: string[];
1643
- };
1644
- /** An action's context, as the wire declares it. */
1645
- type TransportActionContext = {
1646
- prevOpIndex?: number;
1647
- prevOpHash?: string;
1648
- nonce?: string;
1649
- signer?: TransportSigner;
1650
- };
1651
- /** An action projected onto exactly the fields the wire declares. */
1652
- type TransportAction = {
1653
- id: string;
1654
- type: string;
1655
- timestampUtcMs: string;
1656
- /**
1657
- * Non-nullable, because the wire declares it so. An action's own type says
1658
- * `unknown`, which admits the absent input an action creator called without
1659
- * one produces - {@link toTransportAction} refuses that rather than passing
1660
- * it on.
1661
- */
1662
- input: NonNullable<unknown>;
1663
- scope: string;
1664
- context?: TransportActionContext;
1665
- };
1332
+ declare class InvalidGrantError extends Error {
1333
+ readonly grantId: string;
1334
+ constructor(grantId: string, problem: string);
1335
+ }
1336
+ /** Thrown for a `{ group }` principal on a group document: references never chain. */
1337
+ declare class GroupPrincipalNotAllowedError extends Error {
1338
+ readonly grantId: string;
1339
+ constructor(grantId: string);
1340
+ }
1666
1341
  /**
1667
- * Projects an action onto the fields the GraphQL `ActionInput` declares.
1668
- *
1669
- * A projection rather than a spread, because an input object rejects a field it
1670
- * does not declare, and that refusal takes the whole request with it. An action
1671
- * read back out of storage can carry fields the type no longer has - a legacy
1672
- * `attachments` array, or the operation fields left behind by a signing helper
1673
- * that returns an operation - and any one of them would sink an otherwise valid
1674
- * submission.
1675
- *
1676
- * Only fields the action actually carries are emitted, so an unsigned action
1677
- * sends no context at all rather than a context full of nulls.
1342
+ * Thrown when a change would leave a creator-less policy with no grant
1343
+ * permitting execute on the auth scope. Without the creator carve-out no
1344
+ * subject could ever administer such a policy again.
1678
1345
  */
1679
- declare function toTransportAction(action: Action): TransportAction;
1680
- //#endregion
1681
- //#region document-model/auth.d.ts
1682
- type InitializeAuthActionInput = {
1683
- version: number;
1684
- grants: Grant[];
1685
- };
1686
- type SetGrantActionInput = {
1687
- grant: Grant;
1688
- };
1689
- type RemoveGrantActionInput = {
1690
- id: string;
1691
- };
1692
- type MoveGrantActionInput = {
1693
- id: string;
1694
- /** Target index in the grant list; clamped to the valid range. */
1695
- index: number;
1696
- };
1697
- type InitializeAuthAction = Action & {
1698
- type: "INITIALIZE_AUTH";
1699
- input: InitializeAuthActionInput;
1700
- };
1701
- type SetGrantAction = Action & {
1702
- type: "SET_GRANT";
1703
- input: SetGrantActionInput;
1704
- };
1705
- type RemoveGrantAction = Action & {
1706
- type: "REMOVE_GRANT";
1707
- input: RemoveGrantActionInput;
1708
- };
1709
- type MoveGrantAction = Action & {
1710
- type: "MOVE_GRANT";
1711
- input: MoveGrantActionInput;
1712
- };
1713
- type AuthAction = InitializeAuthAction | SetGrantAction | RemoveGrantAction | MoveGrantAction;
1714
- declare const AUTH_ACTION_TYPES: readonly ["INITIALIZE_AUTH", "SET_GRANT", "REMOVE_GRANT", "MOVE_GRANT"];
1715
- declare function isAuthAction(action: Action): action is AuthAction;
1716
- /** Highest known policy version; decide() fails closed above it. */
1717
- declare const MAX_SUPPORTED_AUTH_VERSION = 1;
1718
- declare const InitializeAuthActionInputSchema: () => z.ZodObject<{
1719
- version: z.ZodNumber;
1720
- grants: z.ZodArray<z.ZodCustom<Grant, Grant>>;
1721
- }, z.core.$strip>;
1722
- declare const SetGrantActionInputSchema: () => z.ZodObject<{
1723
- grant: z.ZodCustom<Grant, Grant>;
1724
- }, z.core.$strip>;
1725
- declare const RemoveGrantActionInputSchema: () => z.ZodObject<{
1726
- id: z.ZodString;
1727
- }, z.core.$strip>;
1728
- declare const MoveGrantActionInputSchema: () => z.ZodObject<{
1729
- id: z.ZodString;
1730
- index: z.ZodNumber;
1731
- }, z.core.$strip>;
1732
- declare const initializeAuth: (input: InitializeAuthActionInput) => InitializeAuthAction;
1733
- declare const setGrant: (input: SetGrantActionInput) => SetGrantAction;
1734
- declare const removeGrant: (input: RemoveGrantActionInput) => RemoveGrantAction;
1735
- declare const moveGrant: (input: MoveGrantActionInput) => MoveGrantAction;
1346
+ declare class AuthAdministrationLockoutError extends Error {
1347
+ readonly grantId: string;
1348
+ constructor(grantId: string);
1349
+ }
1736
1350
  /**
1737
- * True when `signerKey` (an ActionSigner app key, a did:key) identifies the same
1738
- * key recorded as the document creator. Returns false
1739
- * when there is no creator (empty JWK) or no signer key.
1351
+ * Thrown when INITIALIZE_AUTH would create a creator-less policy with no grant
1352
+ * permitting execute on the auth scope. Such a policy would be born with no
1353
+ * subject able to administer it.
1740
1354
  */
1741
- declare function isDocumentCreator(creatorKey: JsonWebKey | undefined, signerKey: string | undefined): boolean;
1355
+ declare class AuthAdministrationMissingError extends Error {
1356
+ constructor();
1357
+ }
1358
+ declare function isPlainValue(value: unknown): value is Record<string, unknown>;
1359
+ /** Returns the first v1-rule violation, or null. Pure, total, deterministic. */
1360
+ declare function grantProblem(value: unknown): string | null;
1361
+ declare const GrantSchema: () => z.ZodCustom<Grant, Grant>;
1362
+ /** V1 shape rules plus the group-document group-principal ban. */
1363
+ declare function assertValidGrant(grant: unknown, documentType: string): void;
1742
1364
  /**
1743
- * Sets the initial policy. Valid only while the auth scope is uninitialized
1744
- * (version 0). The input version is the policy language version and must be an
1745
- * integer >= 1; 0 is reserved for the uninitialized state. On a signed-header
1746
- * document it must be signed by the document creator (`header.sig.publicKey`).
1747
- * A creator-less policy must include a grant permitting execute on the auth
1748
- * scope, or it would be born locked out.
1365
+ * Validates an initial grant list: the count cap, every grant, and — on a
1366
+ * creator-less policy — that some grant keeps the auth scope administrable.
1749
1367
  */
1750
- declare function applyInitializeAuthAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: InitializeAuthAction): PHDocument$1<TState>;
1751
- /** Upserts a grant by id: replaces in place if present, otherwise appends. */
1752
- declare function applySetGrantAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: SetGrantAction): PHDocument$1<TState>;
1368
+ declare function assertValidInitialGrants(grants: Grant[], documentType: string, creator: string | undefined): void;
1753
1369
  /**
1754
- * Removes a grant by id; throws if the id is not present or if the removal
1755
- * would leave a creator-less policy with no auth-administration grant.
1370
+ * Validates a grant upsert: the grant itself, the count cap on append, and
1371
+ * administration retention. Retention is checked on an append as well as an
1372
+ * in-place replace, because a grant appended after the administration grant can
1373
+ * shadow it (evaluation is last-applicable-grant-wins) and so take
1374
+ * administration away without removing anything.
1756
1375
  */
1757
- declare function applyRemoveGrantAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: RemoveGrantAction): PHDocument$1<TState>;
1376
+ declare function assertValidGrantUpsert(grant: Grant, existing: Grant[], documentType: string, creator: string | undefined): void;
1758
1377
  /**
1759
- * Moves a grant by id to a new index. Order is load-bearing (the last
1760
- * applicable grant wins), so the relative order of the other grants is kept.
1761
- * The target index is clamped to the valid range; an unknown id throws.
1762
- *
1763
- * Order alone decides which grant wins, so a move can take administration away
1764
- * without changing the list's contents. It carries the same retention rule as
1765
- * the two mutation paths.
1378
+ * A creator-less policy must always retain a grant permitting execute on the
1379
+ * auth scope; on a signed document the creator carve-out keeps administration
1380
+ * reachable instead. Rejects a change that takes the last such grant away. A
1381
+ * policy already without one is left alone: the change is not what locks it.
1766
1382
  */
1767
- declare function applyMoveGrantAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: MoveGrantAction): PHDocument$1<TState>;
1768
- /**
1769
- * Dispatches an auth-scope action to its handler. This is the auth scope's
1770
- * dedicated reducer: it is applied by the base reducer instead of the model
1771
- * reducer, mirroring the document-scope platform handlers. Unknown types are a
1772
- * no-op, matching the model-reducer default.
1773
- */
1774
- declare function applyAuthAction<TState extends PHBaseState>(document: PHDocument$1<TState>, action: Action): PHDocument$1<TState>;
1775
- /**
1776
- * Because only creators can initialize auth scopes, we must verify that either
1777
- * the document has no auth or the version and creator match.
1778
- */
1779
- declare function assertAuthPreservedOnDuplicate(documentId: string, source: PHAuthState | undefined, duplicated: PHAuthState | undefined): void;
1780
- /**
1781
- * The auth scope a state snapshot may install, given the policy already there.
1782
- *
1783
- * `applyAuthAction` is the validated door onto `state.auth`, but a whole-state
1784
- * snapshot (UPGRADE_DOCUMENT's `initialState`) replaces the scope wholesale and
1785
- * is authorized as a `document`-scope write. Without this, a subject holding
1786
- * `execute` on `document` and no auth grant at all can install a policy of its
1787
- * choosing, name itself `creator` (which exempts the policy from the retention
1788
- * rule for good), or wipe an existing policy by carrying the default
1789
- * uninitialized one.
1790
- *
1791
- * Three cases:
1792
- *
1793
- * - the snapshot carries no policy, or an uninitialized one: the document
1794
- * keeps the policy it has, so a default-state upgrade cannot reset it;
1795
- * - the document is uninitialized and the snapshot carries a policy: the
1796
- * policy is installed after the same validation genesis applies, so it
1797
- * cannot be born locked out;
1798
- * - both carry a policy: they must agree. A duplicate preserves its source's
1799
- * policy (see {@link assertAuthPreservedOnDuplicate}), and anything else is
1800
- * an attempt to replace one policy with another.
1801
- */
1802
- declare function resolveSnapshotAuth(documentId: string, documentType: string, current: PHAuthState | undefined, incoming: PHAuthState | undefined): PHAuthState;
1803
- /** UNDO and REDO are rejected on the auth scope. */
1804
- declare function assertAuthScopeActionAllowed(action: Action): void;
1805
- type AuthVerb = "read" | "execute";
1806
- type AuthRequest = {
1807
- verb: AuthVerb;
1808
- scope: string;
1809
- /** For execute: the operation (action type) being attempted. Omitted for reads. */
1810
- operation?: string;
1811
- };
1812
- type AuthSubject = {
1813
- /** Verified signer address; undefined for an anonymous subject. */
1814
- address?: string;
1815
- /** The signer's app key (a did:key), used to match the document creator. */
1816
- key?: string;
1817
- };
1818
- /**
1819
- * What condition attr paths resolve against, beyond the subject. Supplied
1820
- * only while authConditions enforcement is on: with no context a grant
1821
- * carrying `where` or a { match } principal never applies.
1822
- */
1823
- type ConditionContext = {
1824
- /** The executing scope's own state, for `doc.<scope>.*` paths. */
1825
- scopeState: unknown;
1826
- /** The action's input, for `action.input.*` paths. Absent for reads. */
1827
- actionInput?: unknown;
1828
- };
1829
- type AuthDecision = "allow" | "deny";
1830
- /** Why the policy refused a request. */
1831
- type AuthRefusal = "version-unsupported" | "no-applicable-grant" | "denied-by-grant";
1832
- /**
1833
- * A decision together with why it refused. A refusal names which of the
1834
- * policy's rules produced it, so an operation records the reason it was refused
1835
- * rather than one reason standing for every refusal.
1836
- */
1837
- type AuthEvaluation = {
1838
- decision: "allow";
1839
- } | {
1840
- decision: "deny";
1841
- refusal: AuthRefusal;
1842
- grantId?: string;
1843
- };
1844
- /**
1845
- * Evaluates the auth policy for a single request and reports why it refused.
1846
- * Pure and deterministic.
1847
- *
1848
- * An uninitialized policy (version 0, absent auth state, or a legacy `{}`
1849
- * auth scope serialized before PHAuthState had a version) leaves the document
1850
- * open. Once a policy exists the default is deny, and grants stack in order.
1851
- *
1852
- * Group principals match only against a supplied groups map (the groups
1853
- * projection, present when authGroups is on); with no map they never apply.
1854
- * `where` clauses and { match } principals likewise evaluate only against a
1855
- * supplied condition context (present when authConditions is on).
1856
- */
1857
- declare function evaluate(auth: PHAuthState | undefined, subject: AuthSubject, request: AuthRequest, groups?: AuthGroups, conditions?: ConditionContext): AuthEvaluation;
1858
- /**
1859
- * Evaluates the auth policy for a single request. Pure and deterministic. This
1860
- * is {@link evaluate} with the reason dropped.
1861
- */
1862
- declare function decide(auth: PHAuthState | undefined, subject: AuthSubject, request: AuthRequest, groups?: AuthGroups, conditions?: ConditionContext): AuthDecision;
1863
- /**
1864
- * The group document ids a single auth action's input names with `{ group }`
1865
- * principals. INITIALIZE_AUTH contributes the groups named across its grants,
1866
- * SET_GRANT the groups named by its one grant; REMOVE_GRANT and MOVE_GRANT
1867
- * contribute nothing. Total over any input shape, because references are read
1868
- * from the input as it arrived, including inputs later stored as errors.
1869
- */
1870
- declare function mentionedGroupIds(action: Action): string[];
1871
- //#endregion
1872
- //#region document-model/auth-v1.d.ts
1873
- /** Maximum number of grants in a policy. */
1874
- declare const MAX_AUTH_GRANTS = 100;
1875
- /** Maximum nesting depth of a condition tree. */
1876
- declare const MAX_CONDITION_DEPTH = 10;
1877
- /** Maximum node count (conditions plus operands) of a condition tree. */
1878
- declare const MAX_CONDITION_NODES = 100;
1879
- /** Maximum entries in an execute capability's operation list. */
1880
- declare const MAX_CAPABILITY_OPERATIONS = 100;
1881
- /**
1882
- * Thrown when a grant violates the v1 validation rules. The message is stored
1883
- * on error operations, so it must be a pure function of the input.
1884
- */
1885
- declare class InvalidGrantError extends Error {
1886
- readonly grantId: string;
1887
- constructor(grantId: string, problem: string);
1888
- }
1889
- /** Thrown for a `{ group }` principal on a group document: references never chain. */
1890
- declare class GroupPrincipalNotAllowedError extends Error {
1891
- readonly grantId: string;
1892
- constructor(grantId: string);
1893
- }
1894
- /**
1895
- * Thrown when a change would leave a creator-less policy with no grant
1896
- * permitting execute on the auth scope. Without the creator carve-out no
1897
- * subject could ever administer such a policy again.
1898
- */
1899
- declare class AuthAdministrationLockoutError extends Error {
1900
- readonly grantId: string;
1901
- constructor(grantId: string);
1902
- }
1903
- /**
1904
- * Thrown when INITIALIZE_AUTH would create a creator-less policy with no grant
1905
- * permitting execute on the auth scope. Such a policy would be born with no
1906
- * subject able to administer it.
1907
- */
1908
- declare class AuthAdministrationMissingError extends Error {
1909
- constructor();
1910
- }
1911
- declare function isPlainValue(value: unknown): value is Record<string, unknown>;
1912
- /** Returns the first v1-rule violation, or null. Pure, total, deterministic. */
1913
- declare function grantProblem(value: unknown): string | null;
1914
- declare const GrantSchema: () => z.ZodCustom<Grant, Grant>;
1915
- /** V1 shape rules plus the group-document group-principal ban. */
1916
- declare function assertValidGrant(grant: unknown, documentType: string): void;
1917
- /**
1918
- * Validates an initial grant list: the count cap, every grant, and — on a
1919
- * creator-less policy — that some grant keeps the auth scope administrable.
1920
- */
1921
- declare function assertValidInitialGrants(grants: Grant[], documentType: string, creator: string | undefined): void;
1922
- /**
1923
- * Validates a grant upsert: the grant itself, the count cap on append, and
1924
- * administration retention. Retention is checked on an append as well as an
1925
- * in-place replace, because a grant appended after the administration grant can
1926
- * shadow it (evaluation is last-applicable-grant-wins) and so take
1927
- * administration away without removing anything.
1928
- */
1929
- declare function assertValidGrantUpsert(grant: Grant, existing: Grant[], documentType: string, creator: string | undefined): void;
1930
- /**
1931
- * A creator-less policy must always retain a grant permitting execute on the
1932
- * auth scope; on a signed document the creator carve-out keeps administration
1933
- * reachable instead. Rejects a change that takes the last such grant away. A
1934
- * policy already without one is left alone: the change is not what locks it.
1935
- */
1936
- declare function assertAuthAdministrationRetained(creator: string | undefined, previous: Grant[], next: Grant[], grantId: string): void;
1383
+ declare function assertAuthAdministrationRetained(creator: string | undefined, previous: Grant[], next: Grant[], grantId: string): void;
1937
1384
  /**
1938
1385
  * Evaluates a version-1 condition. Deterministic, total, and pure: any input
1939
1386
  * shape yields a boolean and never throws, and a malformed condition is
@@ -1966,303 +1413,845 @@ type PeerCapabilityFlags = {
1966
1413
  readonly undoV3?: boolean;
1967
1414
  readonly [flag: string]: boolean | undefined;
1968
1415
  };
1969
- /** A document protocol, named by its `protocolVersions` key. */
1970
- type ProtocolCapability = {
1971
- kind: "protocol";
1972
- name: string;
1973
- /** What a peer that announces nothing is assumed to support. */
1974
- baseline: readonly number[];
1975
- supported(flags: PeerCapabilityFlags): readonly number[];
1976
- /** The version new documents take when peers agree. Absent: not negotiated. */
1977
- preferred?(flags: PeerCapabilityFlags): number;
1978
- /** Who chooses a new document's version, given the creator's preference; absent: "agreed". */
1979
- selection?: ProtocolSelectionRule | ((preferred: number) => ProtocolSelectionRule);
1980
- /** A header may omit the key. */
1981
- optional: boolean;
1416
+ /** A document protocol, named by its `protocolVersions` key. */
1417
+ type ProtocolCapability = {
1418
+ kind: "protocol";
1419
+ name: string;
1420
+ /** What a peer that announces nothing is assumed to support. */
1421
+ baseline: readonly number[];
1422
+ supported(flags: PeerCapabilityFlags): readonly number[];
1423
+ /** The version new documents take when peers agree. Absent: not negotiated. */
1424
+ preferred?(flags: PeerCapabilityFlags): number;
1425
+ /** Who chooses a new document's version, given the creator's preference; absent: "agreed". */
1426
+ selection?: ProtocolSelectionRule | ((preferred: number) => ProtocolSelectionRule);
1427
+ /** A header may omit the key. */
1428
+ optional: boolean;
1429
+ };
1430
+ /**
1431
+ * "agreed": the creator's preference narrowed to what every member supports.
1432
+ * "creator": the creator's preference; a member that cannot run it is held.
1433
+ */
1434
+ type ProtocolSelectionRule = "agreed" | "creator";
1435
+ /** A feature that changes what a peer sends or expects on the wire. */
1436
+ type FeatureCapability = {
1437
+ kind: "feature";
1438
+ name: string;
1439
+ baseline: readonly number[];
1440
+ supported(flags: PeerCapabilityFlags): readonly number[];
1441
+ };
1442
+ type PeerCapability = ProtocolCapability | FeatureCapability;
1443
+ /** A purged document's protocol; never preferred, so creation never selects it. */
1444
+ declare const DOCUMENT_PURGE_PROTOCOL = "document-purge";
1445
+ /** A peer that takes refusals of polled purge markers on the poll. */
1446
+ declare const MARKER_REFUSAL_FEATURE = "marker-refusal";
1447
+ declare const PEER_CAPABILITIES: readonly PeerCapability[];
1448
+ /** `base-reducer`'s preference with no reactor flags, which shared never holds. */
1449
+ declare const FLAGLESS_BASE_REDUCER_VERSION: number;
1450
+ /** `base` plus `extra`; an extra replaces a base entry of the same name. */
1451
+ declare function mergePeerCapabilities(base: readonly PeerCapability[], extra: readonly PeerCapability[]): PeerCapability[];
1452
+ declare const PEER_MANIFEST_FORMAT = 1;
1453
+ type Supports = {
1454
+ protocols: {
1455
+ [protocol: string]: readonly number[];
1456
+ };
1457
+ features: {
1458
+ [feature: string]: readonly number[];
1459
+ };
1460
+ };
1461
+ type PeerManifest = Supports & {
1462
+ format: 1;
1463
+ /** The signer's did:key, when configured; informational. */
1464
+ appKey?: string;
1465
+ /** Grows with every start of the reactor; a peer ignores an older one. */
1466
+ sequence: number;
1467
+ /** base64url(sha256(canonicalJson(Supports & { sequence }))) */
1468
+ revision: string;
1469
+ };
1470
+ /** What this reactor supports, for every capability it registers. */
1471
+ declare function localSupports(capabilities: readonly PeerCapability[], flags: PeerCapabilityFlags): Supports;
1472
+ /** What a peer that announces nothing supports. */
1473
+ declare function legacySupports(capabilities: readonly PeerCapability[]): Supports;
1474
+ declare function manifestRevision(supports: Supports, sequence?: number): string;
1475
+ declare function localPeerManifest(capabilities: readonly PeerCapability[], flags: PeerCapabilityFlags, appKey?: string, sequence?: number): PeerManifest;
1476
+ /** A manifest sent before the one already held; silence carries no sequence. */
1477
+ declare function isOlderManifest(next: PeerManifest | null, held: PeerManifest | null | undefined): boolean;
1478
+ /** A peer's manifest, or the baselines for a peer that announced none. */
1479
+ declare function peerSupports(manifest: PeerManifest | null, capabilities: readonly PeerCapability[]): Supports;
1480
+ /**
1481
+ * A manifest as received from a peer, or null when it is not one. Formats only
1482
+ * add fields, so one of an unknown format is read as its two maps.
1483
+ */
1484
+ declare function readPeerManifest(value: unknown): PeerManifest | null;
1485
+ /** Why a document may not go to a peer. */
1486
+ type HoldReason = {
1487
+ protocol: string;
1488
+ version: number;
1489
+ peerSupports: readonly number[];
1490
+ };
1491
+ /** Only keys this reactor registers are judged; an absent key agrees. */
1492
+ declare function holdReason(peer: Supports, versions: {
1493
+ readonly [protocol: string]: number;
1494
+ }, capabilities: readonly PeerCapability[]): HoldReason | undefined;
1495
+ /** Whether a peer runs every version this reactor does, so nothing is held. */
1496
+ declare function coversLocal(peer: Supports, local: Supports, capabilities: readonly PeerCapability[]): boolean;
1497
+ /**
1498
+ * protocolVersions for a new document: per negotiated protocol, the highest
1499
+ * version up to the local preference that every member supports, else the
1500
+ * lowest local one. `requested` wins over what is selected.
1501
+ */
1502
+ declare function selectProtocolVersions(input: {
1503
+ capabilities: readonly PeerCapability[];
1504
+ flags: PeerCapabilityFlags;
1505
+ members: Iterable<Supports>;
1506
+ requested?: {
1507
+ readonly [protocol: string]: number;
1508
+ };
1509
+ }): {
1510
+ [protocol: string]: number;
1511
+ };
1512
+ /**
1513
+ * Another reactor's selection for a new document, within `supports`: a
1514
+ * negotiated protocol drops to the highest supported version at or below it,
1515
+ * or takes its baseline when absent; another known protocol must be
1516
+ * supported; an unknown one passes, as refusalFor admits it.
1517
+ */
1518
+ declare function capSelection(selected: {
1519
+ readonly [protocol: string]: number;
1520
+ } | undefined, capabilities: readonly PeerCapability[], supports: Supports): {
1521
+ [protocol: string]: number;
1522
+ };
1523
+ //#endregion
1524
+ //#region document-model/base-reducer-protocol.d.ts
1525
+ declare const BASE_REDUCER_VERSIONS: readonly [1, 2, 3];
1526
+ type BaseReducerVersion = (typeof BASE_REDUCER_VERSIONS)[number];
1527
+ interface UndoModelValues {
1528
+ skip: true;
1529
+ "noop-chain": true;
1530
+ retraction: true;
1531
+ }
1532
+ /** What UNDO and REDO become. */
1533
+ type UndoModel = keyof UndoModelValues;
1534
+ interface SkipMeaningValues {
1535
+ "undo-or-rewind": true;
1536
+ rewind: true;
1537
+ }
1538
+ /** Whether a stored skip can be an undo, or is only a replica's rewind. */
1539
+ type SkipMeaning = keyof SkipMeaningValues;
1540
+ interface TieOrderValues {
1541
+ "rank-locale": true;
1542
+ canonical: true;
1543
+ }
1544
+ /** How same-timestamp actions are ordered. */
1545
+ type TieOrder = keyof TieOrderValues;
1546
+ interface SynthesizedIdFormValues {
1547
+ hashed: true;
1548
+ none: true;
1549
+ }
1550
+ /** How a synthesized row's action id derives from its source's; "none" synthesizes nothing. */
1551
+ type SynthesizedIdForm = keyof SynthesizedIdFormValues;
1552
+ interface ReplayHashValues {
1553
+ sender: true;
1554
+ receiver: true;
1555
+ }
1556
+ /** Whose state hash a received row keeps. */
1557
+ type ReplayHash = keyof ReplayHashValues;
1558
+ interface DerivationModelValues {
1559
+ replay: true;
1560
+ "retraction-rule": true;
1561
+ }
1562
+ /** How a scope's state derives from its rows. */
1563
+ type DerivationModel = keyof DerivationModelValues;
1564
+ interface ReducerContractValues {
1565
+ any: true;
1566
+ "state-reducer": true;
1567
+ }
1568
+ /** Which registered reducers a version runs. */
1569
+ type ReducerContract = keyof ReducerContractValues;
1570
+ interface GatingFlagValues {
1571
+ undoV3: true;
1572
+ }
1573
+ /** A reactor feature flag a version runs only under. */
1574
+ type GatingFlag = keyof GatingFlagValues;
1575
+ type BaseReducerCapabilities = {
1576
+ readonly version: BaseReducerVersion;
1577
+ readonly undo: UndoModel;
1578
+ /** "retraction-rule" derives every scope outside RULE_EXEMPT_SCOPES by the rule. */
1579
+ readonly derivation: DerivationModel;
1580
+ readonly skip: SkipMeaning;
1581
+ readonly tieOrder: TieOrder;
1582
+ readonly synthesizedId: SynthesizedIdForm;
1583
+ readonly replayHash: ReplayHash;
1584
+ /** "state-reducer" runs only models whose every registered reducer createReducer tagged. */
1585
+ readonly reducerContract: ReducerContract;
1586
+ /** The flag this version runs only under; null runs always. */
1587
+ readonly gatedBy: GatingFlag | null;
1588
+ };
1589
+ /** The versions a reactor running `flags` supports. */
1590
+ declare function baseReducerVersionsFor(flags: PeerCapabilityFlags): BaseReducerVersion[];
1591
+ /** Flags under which this build runs every version it knows. */
1592
+ declare const FLAGS_FOR_EVERY_VERSION: { readonly [F in GatingFlag]: true; };
1593
+ /** Scopes the retraction rule never derives. */
1594
+ declare const RULE_EXEMPT_SCOPES: ReadonlySet<string>;
1595
+ declare function assertNever(value: never, what: string): never;
1596
+ declare function isBaseReducerVersion(value: unknown): value is BaseReducerVersion;
1597
+ declare function capabilitiesOf(version: BaseReducerVersion): BaseReducerCapabilities;
1598
+ /**
1599
+ * The version `versions` runs as: a known number as itself, a number this
1600
+ * build does not know as `highest`, undefined without a number.
1601
+ */
1602
+ declare function resolveBaseReducerVersion(versions: ProtocolVersions | undefined, highest?: BaseReducerVersion): BaseReducerVersion | undefined;
1603
+ /** Throws on a missing version: defaulting one would replay through the wrong reducer. */
1604
+ declare function baseReducerVersion(header: PHDocumentHeader): BaseReducerVersion;
1605
+ /** Throws on a missing or unknown version. */
1606
+ declare function baseReducerCapabilities(header: PHDocumentHeader): BaseReducerCapabilities;
1607
+ /** Undefined only for a header without a version; throws on an unknown one. */
1608
+ declare function optionalBaseReducerCapabilities(header: PHDocumentHeader): BaseReducerCapabilities | undefined;
1609
+ /** Undefined when `versions` names no known base-reducer version. */
1610
+ declare function capabilitiesFor(versions: ProtocolVersions | undefined): BaseReducerCapabilities | undefined;
1611
+ /** From CREATE_DOCUMENT input; undefined when it names no known version. */
1612
+ declare function createdCapabilities(input: Partial<CreateDocumentActionInput> | undefined): BaseReducerCapabilities | undefined;
1613
+ /**
1614
+ * Every decision a consumer may take on a capability axis. Outside this module
1615
+ * and the other protocol owners, an axis is read only through these or through
1616
+ * an exhaustive switch.
1617
+ */
1618
+ declare const CAPABILITY_DECISIONS: {
1619
+ readonly usesRetractionRule: {
1620
+ replay: false;
1621
+ "retraction-rule": true;
1622
+ };
1623
+ readonly needsTaggedModel: {
1624
+ any: false;
1625
+ "state-reducer": true;
1626
+ };
1627
+ readonly sortsJobsCanonically: {
1628
+ "rank-locale": false;
1629
+ canonical: true;
1630
+ };
1631
+ readonly conflictWindowMovesEveryRow: {
1632
+ "rank-locale": false;
1633
+ canonical: true;
1634
+ };
1635
+ readonly skipMayUndo: {
1636
+ "undo-or-rewind": true;
1637
+ rewind: false;
1638
+ };
1639
+ };
1640
+ /** Whether the version derives scopes by the retraction rule; a versionless header does not. */
1641
+ declare function usesRetractionRule(caps: BaseReducerCapabilities | undefined): boolean;
1642
+ /** Whether the retraction rule derives `scope`. */
1643
+ declare function derivesByRule(caps: BaseReducerCapabilities | undefined, scope: string): boolean;
1644
+ /** Whether the retraction rule derives `scope` of the document `header` heads. */
1645
+ declare function documentDerivesByRule(header: PHDocumentHeader, scope: string): boolean;
1646
+ /** Whether the version runs only models whose every reducer is tagged. */
1647
+ declare function needsTaggedModel(caps: BaseReducerCapabilities | undefined): boolean;
1648
+ /** How same-timestamp actions are ordered; a versionless header ranks and compares by locale. */
1649
+ declare function tieOrderOf(caps: BaseReducerCapabilities | undefined): TieOrder;
1650
+ /** Whether a job's actions are stored in canonical order rather than as submitted. */
1651
+ declare function sortsJobsCanonically(caps: BaseReducerCapabilities | undefined): boolean;
1652
+ /** Whether every conflicting row of a load moves, rather than only those past the predecessor bound. */
1653
+ declare function conflictWindowMovesEveryRow(caps: BaseReducerCapabilities | undefined): boolean;
1654
+ /** Whether a stored skip may be an undo, not only a replica's rewind. */
1655
+ declare function skipMayUndo(caps: BaseReducerCapabilities | undefined): boolean;
1656
+ /** Whether a stored skip in `scope` is a rewind the reducer applies. */
1657
+ declare function appliesRewind(caps: BaseReducerCapabilities, scope: string): boolean;
1658
+ /** Whether a submitted RETRACT is this version's undo. */
1659
+ declare function acceptsSubmittedRetract(caps: BaseReducerCapabilities): boolean;
1660
+ /** Whether a submitted UNDO or REDO is this version's undo; on retraction a client submits RETRACT. */
1661
+ declare function acceptsSubmittedUndoRedo(caps: BaseReducerCapabilities): boolean;
1662
+ /** Whether every registered version of `documentType` runs under `caps`; undefined when none is. */
1663
+ declare function modelRunsBaseReducer(caps: BaseReducerCapabilities, documentType: string, modules: readonly DocumentModelModule[]): boolean | undefined;
1664
+ type ProtocolSupport = Supports["protocols"];
1665
+ type ProtocolRefusal = {
1666
+ protocol: string;
1667
+ version: number;
1668
+ /** Set when the version is supported but this model cannot run it. */
1669
+ documentType?: string;
1670
+ };
1671
+ /** Why `versions` cannot run here; unregistered protocols and types are admitted. */
1672
+ declare function refusalFor(documentType: string | undefined, versions: ProtocolVersions | undefined, support: ProtocolSupport, modules: readonly DocumentModelModule[]): ProtocolRefusal | undefined;
1673
+ //#endregion
1674
+ //#region document-model/constants.d.ts
1675
+ declare const documentModelFileExtension: "phdm";
1676
+ declare const documentModelInitialLocalState: DocumentModelLocalState;
1677
+ declare const documentModelInitialGlobalState: DocumentModelGlobalState;
1678
+ declare const documentModelGlobalState: DocumentModelGlobalState;
1679
+ declare const HASH_ALGORITHM_SHA1 = "sha1";
1680
+ declare const HASH_ALGORITHM_SHA256 = "sha256";
1681
+ declare const HASH_ALGORITHM_SHA512 = "sha512";
1682
+ declare const HASH_ENCODING_BASE64 = "base64";
1683
+ declare const HASH_ENCODING_HEX = "hex";
1684
+ //#endregion
1685
+ //#region document-model/create-base-reducer.d.ts
1686
+ type CreateBaseReducerLogger = {
1687
+ debug: (message: string, ...replacements: unknown[]) => void;
1688
+ warn: (message: string, ...replacements: unknown[]) => void;
1689
+ };
1690
+ /**
1691
+ * Steps a selected base-reducer down to the highest version the model runs.
1692
+ * An unregistered type cannot be checked, so it takes the highest version
1693
+ * that needs no tagged reducer.
1694
+ */
1695
+ declare function fitCreateBaseReducer(selected: ProtocolVersions, documentType: string | undefined, modules: readonly DocumentModelModule[], logger: CreateBaseReducerLogger): ProtocolVersions;
1696
+ //#endregion
1697
+ //#region document-model/crypto.d.ts
1698
+ declare const hashBrowser: (data: string | Uint8Array | ArrayBufferView | DataView, algorithm?: string, encoding?: string, _params?: Record<string, unknown>) => string;
1699
+ declare function getUnixTimestamp(date: Date | string): string;
1700
+ declare function buildOperationSignatureParams({ documentId, signer, action, previousStateHash }: ActionSignatureContext): [string, string, string, string];
1701
+ declare function buildOperationSignatureMessage(params: [string, string, string, string]): Uint8Array;
1702
+ declare function ab2hex(ab: ArrayBuffer | ArrayBufferView): string;
1703
+ declare function hex2ab(hex: string): Uint8Array<ArrayBuffer>;
1704
+ /**
1705
+ * Decodes a base58btc (Bitcoin/IPFS alphabet) string to bytes. Returns null on
1706
+ * any character outside the alphabet.
1707
+ */
1708
+ declare function base58Decode(input: string): Uint8Array | null;
1709
+ /** Encodes bytes as unpadded base64url. */
1710
+ declare function bytesToBase64Url(bytes: Uint8Array): string;
1711
+ /** Decodes a base64url string to bytes (portable across node, browsers, workers). */
1712
+ declare function base64UrlToBytes(input: string): Uint8Array;
1713
+ //#endregion
1714
+ //#region document-model/definition-types.d.ts
1715
+ type JsonPrimitive = string | number | boolean | null;
1716
+ type JsonValue = JsonPrimitive | readonly JsonValue[] | {
1717
+ readonly [key: string]: JsonValue;
1718
+ };
1719
+ type Sha256Digest = `sha256:${string}`;
1720
+ type DefinitionSource = {
1721
+ readonly specifier: `./${string}`;
1722
+ readonly exportPath?: readonly string[];
1723
+ };
1724
+ type DefinitionDiagnosticSeverity = "error" | "warning";
1725
+ type DefinitionDiagnosticPhase = "configuration" | "import" | "definition" | "composition" | "authorization" | "typecheck" | "package" | "replay";
1726
+ type DefinitionKind = "document-model" | "subgraph" | "scalar" | "package";
1727
+ type DefinitionRef = {
1728
+ readonly kind: DefinitionKind;
1729
+ readonly key: string;
1730
+ readonly version?: number;
1731
+ };
1732
+ type DefinitionPath = readonly (string | number)[];
1733
+ type DefinitionRelatedLocation = {
1734
+ readonly source?: DefinitionSource;
1735
+ readonly path: DefinitionPath;
1736
+ readonly message: string;
1737
+ };
1738
+ type DefinitionDiagnostic = {
1739
+ readonly code: `PH-${string}`;
1740
+ readonly severity: DefinitionDiagnosticSeverity;
1741
+ readonly phase: DefinitionDiagnosticPhase;
1742
+ readonly source?: DefinitionSource;
1743
+ readonly definition?: DefinitionRef;
1744
+ readonly path: DefinitionPath;
1745
+ readonly message: string;
1746
+ readonly expected?: string;
1747
+ readonly received?: string;
1748
+ readonly repair: string;
1749
+ readonly related?: readonly DefinitionRelatedLocation[];
1750
+ };
1751
+ type GraphQLNameNode = {
1752
+ readonly kind: "Name";
1753
+ readonly value: string;
1754
+ };
1755
+ type GraphQLNamedTypeNode = {
1756
+ readonly kind: "NamedType";
1757
+ readonly name: GraphQLNameNode;
1758
+ };
1759
+ type GraphQLListTypeNode = {
1760
+ readonly kind: "ListType";
1761
+ readonly type: GraphQLTypeNode;
1762
+ };
1763
+ type GraphQLNonNullTypeNode = {
1764
+ readonly kind: "NonNullType";
1765
+ readonly type: GraphQLNamedTypeNode | GraphQLListTypeNode;
1766
+ };
1767
+ type GraphQLTypeNode = GraphQLNamedTypeNode | GraphQLListTypeNode | GraphQLNonNullTypeNode;
1768
+ type GraphQLStringValueNode = {
1769
+ readonly kind: "StringValue";
1770
+ readonly value: string;
1771
+ readonly block?: boolean;
1772
+ };
1773
+ type GraphQLConstValueNode = {
1774
+ readonly kind: "IntValue";
1775
+ readonly value: string;
1776
+ } | {
1777
+ readonly kind: "FloatValue";
1778
+ readonly value: string;
1779
+ } | GraphQLStringValueNode | {
1780
+ readonly kind: "BooleanValue";
1781
+ readonly value: boolean;
1782
+ } | {
1783
+ readonly kind: "NullValue";
1784
+ } | {
1785
+ readonly kind: "EnumValue";
1786
+ readonly value: string;
1787
+ } | {
1788
+ readonly kind: "ListValue";
1789
+ readonly values: readonly GraphQLConstValueNode[];
1790
+ } | {
1791
+ readonly kind: "ObjectValue";
1792
+ readonly fields: readonly GraphQLObjectFieldNode[];
1793
+ };
1794
+ type GraphQLObjectFieldNode = {
1795
+ readonly kind: "ObjectField";
1796
+ readonly name: GraphQLNameNode;
1797
+ readonly value: GraphQLConstValueNode;
1798
+ };
1799
+ type GraphQLArgumentNode = {
1800
+ readonly kind: "Argument";
1801
+ readonly name: GraphQLNameNode;
1802
+ readonly value: GraphQLConstValueNode;
1803
+ };
1804
+ type GraphQLDirectiveNode = {
1805
+ readonly kind: "Directive";
1806
+ readonly name: GraphQLNameNode;
1807
+ readonly arguments: readonly GraphQLArgumentNode[];
1808
+ };
1809
+ type GraphQLInputValueDefinitionNode = {
1810
+ readonly kind: "InputValueDefinition";
1811
+ readonly description?: GraphQLStringValueNode;
1812
+ readonly name: GraphQLNameNode;
1813
+ readonly type: GraphQLTypeNode;
1814
+ readonly defaultValue?: GraphQLConstValueNode;
1815
+ readonly directives: readonly GraphQLDirectiveNode[];
1816
+ };
1817
+ type GraphQLFieldDefinitionNode = {
1818
+ readonly kind: "FieldDefinition";
1819
+ readonly description?: GraphQLStringValueNode;
1820
+ readonly name: GraphQLNameNode;
1821
+ readonly arguments: readonly GraphQLInputValueDefinitionNode[];
1822
+ readonly type: GraphQLTypeNode;
1823
+ readonly directives: readonly GraphQLDirectiveNode[];
1824
+ };
1825
+ type GraphQLEnumValueDefinitionNode = {
1826
+ readonly kind: "EnumValueDefinition";
1827
+ readonly description?: GraphQLStringValueNode;
1828
+ readonly name: GraphQLNameNode;
1829
+ readonly directives: readonly GraphQLDirectiveNode[];
1830
+ };
1831
+ type GraphQLNamedDefinitionNode = {
1832
+ readonly description?: GraphQLStringValueNode;
1833
+ readonly name: GraphQLNameNode;
1834
+ readonly directives: readonly GraphQLDirectiveNode[];
1835
+ };
1836
+ type GraphQLScalarTypeDefinitionNode = GraphQLNamedDefinitionNode & {
1837
+ readonly kind: "ScalarTypeDefinition";
1838
+ };
1839
+ type GraphQLObjectTypeDefinitionNode = GraphQLNamedDefinitionNode & {
1840
+ readonly kind: "ObjectTypeDefinition";
1841
+ readonly interfaces: readonly GraphQLNamedTypeNode[];
1842
+ readonly fields: readonly GraphQLFieldDefinitionNode[];
1843
+ };
1844
+ type GraphQLInterfaceTypeDefinitionNode = GraphQLNamedDefinitionNode & {
1845
+ readonly kind: "InterfaceTypeDefinition";
1846
+ readonly interfaces: readonly GraphQLNamedTypeNode[];
1847
+ readonly fields: readonly GraphQLFieldDefinitionNode[];
1848
+ };
1849
+ type GraphQLUnionTypeDefinitionNode = GraphQLNamedDefinitionNode & {
1850
+ readonly kind: "UnionTypeDefinition";
1851
+ readonly types: readonly GraphQLNamedTypeNode[];
1852
+ };
1853
+ type GraphQLEnumTypeDefinitionNode = GraphQLNamedDefinitionNode & {
1854
+ readonly kind: "EnumTypeDefinition";
1855
+ readonly values: readonly GraphQLEnumValueDefinitionNode[];
1856
+ };
1857
+ type GraphQLInputObjectTypeDefinitionNode = GraphQLNamedDefinitionNode & {
1858
+ readonly kind: "InputObjectTypeDefinition";
1859
+ readonly fields: readonly GraphQLInputValueDefinitionNode[];
1860
+ };
1861
+ type GraphQLOperationTypeDefinitionNode = {
1862
+ readonly kind: "OperationTypeDefinition";
1863
+ readonly operation: "query" | "mutation" | "subscription";
1864
+ readonly type: GraphQLNamedTypeNode;
1865
+ };
1866
+ type GraphQLSchemaDefinitionNode = {
1867
+ readonly kind: "SchemaDefinition";
1868
+ readonly description?: GraphQLStringValueNode;
1869
+ readonly directives: readonly GraphQLDirectiveNode[];
1870
+ readonly operationTypes: readonly GraphQLOperationTypeDefinitionNode[];
1871
+ };
1872
+ type GraphQLDirectiveDefinitionNode = {
1873
+ readonly kind: "DirectiveDefinition";
1874
+ readonly description?: GraphQLStringValueNode;
1875
+ readonly name: GraphQLNameNode;
1876
+ readonly arguments: readonly GraphQLInputValueDefinitionNode[];
1877
+ readonly repeatable: boolean;
1878
+ readonly locations: readonly GraphQLNameNode[];
1879
+ };
1880
+ type GraphQLTypeSystemDefinitionNode = GraphQLSchemaDefinitionNode | GraphQLScalarTypeDefinitionNode | GraphQLObjectTypeDefinitionNode | GraphQLInterfaceTypeDefinitionNode | GraphQLUnionTypeDefinitionNode | GraphQLEnumTypeDefinitionNode | GraphQLInputObjectTypeDefinitionNode | GraphQLDirectiveDefinitionNode;
1881
+ type GraphQLTypeSystemExtensionNode = (Omit<GraphQLSchemaDefinitionNode, "kind" | "description"> & {
1882
+ readonly kind: "SchemaExtension";
1883
+ }) | (Omit<GraphQLScalarTypeDefinitionNode, "kind" | "description"> & {
1884
+ readonly kind: "ScalarTypeExtension";
1885
+ }) | (Omit<GraphQLObjectTypeDefinitionNode, "kind" | "description"> & {
1886
+ readonly kind: "ObjectTypeExtension";
1887
+ }) | (Omit<GraphQLInterfaceTypeDefinitionNode, "kind" | "description"> & {
1888
+ readonly kind: "InterfaceTypeExtension";
1889
+ }) | (Omit<GraphQLUnionTypeDefinitionNode, "kind" | "description"> & {
1890
+ readonly kind: "UnionTypeExtension";
1891
+ }) | (Omit<GraphQLEnumTypeDefinitionNode, "kind" | "description"> & {
1892
+ readonly kind: "EnumTypeExtension";
1893
+ }) | (Omit<GraphQLInputObjectTypeDefinitionNode, "kind" | "description"> & {
1894
+ readonly kind: "InputObjectTypeExtension";
1895
+ });
1896
+ type LocationFreeGraphQLDocumentNode = {
1897
+ readonly kind: "Document";
1898
+ readonly definitions: readonly (GraphQLTypeSystemDefinitionNode | GraphQLTypeSystemExtensionNode)[];
1899
+ };
1900
+ type SchemaFirstGraphQLDocumentCompatibility = {
1901
+ readonly kind: "graphql-ast-v1";
1902
+ readonly document: LocationFreeGraphQLDocumentNode;
1903
+ readonly preserveDefinitionOrder: true;
1904
+ };
1905
+ type GraphQLBuiltInScalarName = "ID" | "String" | "Boolean" | "Int" | "Float";
1906
+ /** The catalog scalars a document model or subgraph may reference. */
1907
+ type PowerhouseScalarName = "PHID" | "OID" | "OLabel" | "Currency" | "EmailAddress" | "EthereumAddress" | "URL" | "Date" | "DateTime" | "Amount_Money" | "Amount_Percentage" | "Amount_Tokens" | "Amount" | "Amount_Fiat" | "Amount_Crypto" | "Amount_Currency" | "Address" | "AttachmentRef" | "Unknown" | "Upload";
1908
+ /** Catalog scalars only the reactor host declares. A subgraph can reference one; a document model cannot. */
1909
+ type InternalScalarName = "JSONObject";
1910
+ /** Every catalog scalar, author-facing and internal. */
1911
+ type CatalogScalarName = PowerhouseScalarName | InternalScalarName;
1912
+ type ScalarName = GraphQLBuiltInScalarName | PowerhouseScalarName;
1913
+ type ScalarRepresentation = "string" | "number" | "boolean" | "json-object" | "json" | "opaque";
1914
+ /** The validation and coercion rules of the `document-model/scalars` catalog. */
1915
+ type ScalarValidationProfile = "catalog-v1";
1916
+ type ScalarGraphQLProfile = "legacy-graphql-default-v1" | "catalog-v1";
1917
+ /**
1918
+ * A scalar as a stored definition records it. `document-model/scalars`'
1919
+ * `ScalarDefinition` is the runtime declaration it is made from.
1920
+ */
1921
+ type StoredScalarDefinition = {
1922
+ readonly kind: "powerhouse.scalar";
1923
+ readonly formatVersion: 1;
1924
+ /**
1925
+ * Any GraphQL name. A catalog scalar uses a `PowerhouseScalarName`; a
1926
+ * package scalar uses any other name that is not a GraphQL built-in.
1927
+ */
1928
+ readonly name: string;
1929
+ readonly representation: ScalarRepresentation;
1930
+ readonly description: string;
1931
+ readonly coercion: {
1932
+ readonly source: "derived" | "explicit";
1933
+ };
1934
+ readonly coercionProfile: ScalarValidationProfile;
1935
+ };
1936
+ type ScalarTypeReferenceDefinition = {
1937
+ readonly kind: "scalar";
1938
+ /**
1939
+ * A `ScalarName`, or a package scalar that the enclosing definition's
1940
+ * `scalars` list declares.
1941
+ */
1942
+ readonly name: string;
1943
+ readonly required: boolean;
1944
+ };
1945
+ type NamedTypeReferenceDefinition = {
1946
+ readonly kind: "named";
1947
+ readonly name: string;
1948
+ readonly required: boolean;
1949
+ };
1950
+ type ListTypeReferenceDefinition = {
1951
+ readonly kind: "list";
1952
+ readonly required: boolean;
1953
+ readonly item: TypeReferenceDefinition;
1954
+ };
1955
+ type TypeReferenceDefinition = ScalarTypeReferenceDefinition | NamedTypeReferenceDefinition | ListTypeReferenceDefinition;
1956
+ type DirectiveUseDefinition = {
1957
+ readonly name: string;
1958
+ readonly arguments: readonly {
1959
+ readonly name: string;
1960
+ readonly value: JsonValue;
1961
+ }[];
1962
+ };
1963
+ type FieldDefinition = {
1964
+ readonly key: string;
1965
+ readonly name: string;
1966
+ readonly description: string | null;
1967
+ readonly deprecated: string | null;
1968
+ readonly args?: readonly InputFieldDefinition[];
1969
+ readonly type: TypeReferenceDefinition;
1970
+ readonly directives?: readonly DirectiveUseDefinition[];
1971
+ };
1972
+ type InputFieldDefinition = Omit<FieldDefinition, "args"> & ({
1973
+ readonly defaultValue?: never;
1974
+ } | {
1975
+ readonly defaultValue: JsonValue;
1976
+ });
1977
+ type EnumValueDefinition = {
1978
+ readonly name: string;
1979
+ readonly description: string | null;
1980
+ readonly deprecated: string | null;
1981
+ readonly directives?: readonly DirectiveUseDefinition[];
1982
+ };
1983
+ type EnumTypeDefinition = {
1984
+ readonly kind: "enum";
1985
+ readonly name: string;
1986
+ readonly description: string | null;
1987
+ readonly values: readonly EnumValueDefinition[];
1982
1988
  };
1983
- /**
1984
- * "agreed": the creator's preference narrowed to what every member supports.
1985
- * "creator": the creator's preference; a member that cannot run it is held.
1986
- */
1987
- type ProtocolSelectionRule = "agreed" | "creator";
1988
- /** A feature that changes what a peer sends or expects on the wire. */
1989
- type FeatureCapability = {
1990
- kind: "feature";
1991
- name: string;
1992
- baseline: readonly number[];
1993
- supported(flags: PeerCapabilityFlags): readonly number[];
1989
+ type ObjectTypeDefinition = {
1990
+ readonly kind: "object";
1991
+ readonly name: string;
1992
+ readonly description: string | null;
1993
+ readonly implements?: readonly string[];
1994
+ readonly fields: readonly FieldDefinition[];
1994
1995
  };
1995
- type PeerCapability = ProtocolCapability | FeatureCapability;
1996
- /** A purged document's protocol; never preferred, so creation never selects it. */
1997
- declare const DOCUMENT_PURGE_PROTOCOL = "document-purge";
1998
- /** A peer that takes refusals of polled purge markers on the poll. */
1999
- declare const MARKER_REFUSAL_FEATURE = "marker-refusal";
2000
- declare const PEER_CAPABILITIES: readonly PeerCapability[];
2001
- /** `base-reducer`'s preference with no reactor flags, which shared never holds. */
2002
- declare const FLAGLESS_BASE_REDUCER_VERSION: number;
2003
- /** `base` plus `extra`; an extra replaces a base entry of the same name. */
2004
- declare function mergePeerCapabilities(base: readonly PeerCapability[], extra: readonly PeerCapability[]): PeerCapability[];
2005
- declare const PEER_MANIFEST_FORMAT = 1;
2006
- type Supports = {
2007
- protocols: {
2008
- [protocol: string]: readonly number[];
2009
- };
2010
- features: {
2011
- [feature: string]: readonly number[];
2012
- };
1996
+ type InterfaceTypeDefinition = {
1997
+ readonly kind: "interface";
1998
+ readonly name: string;
1999
+ readonly description: string | null;
2000
+ readonly implements?: readonly string[];
2001
+ readonly fields: readonly FieldDefinition[];
2013
2002
  };
2014
- type PeerManifest = Supports & {
2015
- format: 1;
2016
- /** The signer's did:key, when configured; informational. */
2017
- appKey?: string;
2018
- /** Grows with every start of the reactor; a peer ignores an older one. */
2019
- sequence: number;
2020
- /** base64url(sha256(canonicalJson(Supports & { sequence }))) */
2021
- revision: string;
2003
+ type InputTypeDefinition = {
2004
+ readonly kind: "input";
2005
+ readonly name: string;
2006
+ readonly description: string | null;
2007
+ readonly unknownKeys: "preserve" | "reject";
2008
+ readonly fields: readonly InputFieldDefinition[];
2022
2009
  };
2023
- /** What this reactor supports, for every capability it registers. */
2024
- declare function localSupports(capabilities: readonly PeerCapability[], flags: PeerCapabilityFlags): Supports;
2025
- /** What a peer that announces nothing supports. */
2026
- declare function legacySupports(capabilities: readonly PeerCapability[]): Supports;
2027
- declare function manifestRevision(supports: Supports, sequence?: number): string;
2028
- declare function localPeerManifest(capabilities: readonly PeerCapability[], flags: PeerCapabilityFlags, appKey?: string, sequence?: number): PeerManifest;
2029
- /** A manifest sent before the one already held; silence carries no sequence. */
2030
- declare function isOlderManifest(next: PeerManifest | null, held: PeerManifest | null | undefined): boolean;
2031
- /** A peer's manifest, or the baselines for a peer that announced none. */
2032
- declare function peerSupports(manifest: PeerManifest | null, capabilities: readonly PeerCapability[]): Supports;
2033
- /**
2034
- * A manifest as received from a peer, or null when it is not one. Formats only
2035
- * add fields, so one of an unknown format is read as its two maps.
2036
- */
2037
- declare function readPeerManifest(value: unknown): PeerManifest | null;
2038
- /** Why a document may not go to a peer. */
2039
- type HoldReason = {
2040
- protocol: string;
2041
- version: number;
2042
- peerSupports: readonly number[];
2010
+ type UnionTypeDefinition = {
2011
+ readonly kind: "union";
2012
+ readonly name: string;
2013
+ readonly description: string | null;
2014
+ readonly members: readonly string[];
2043
2015
  };
2044
- /** Only keys this reactor registers are judged; an absent key agrees. */
2045
- declare function holdReason(peer: Supports, versions: {
2046
- readonly [protocol: string]: number;
2047
- }, capabilities: readonly PeerCapability[]): HoldReason | undefined;
2048
- /** Whether a peer runs every version this reactor does, so nothing is held. */
2049
- declare function coversLocal(peer: Supports, local: Supports, capabilities: readonly PeerCapability[]): boolean;
2050
- /**
2051
- * protocolVersions for a new document: per negotiated protocol, the highest
2052
- * version up to the local preference that every member supports, else the
2053
- * lowest local one. `requested` wins over what is selected.
2054
- */
2055
- declare function selectProtocolVersions(input: {
2056
- capabilities: readonly PeerCapability[];
2057
- flags: PeerCapabilityFlags;
2058
- members: Iterable<Supports>;
2059
- requested?: {
2060
- readonly [protocol: string]: number;
2061
- };
2062
- }): {
2063
- [protocol: string]: number;
2016
+ type NamedGraphQLTypeDefinition = EnumTypeDefinition | ObjectTypeDefinition | InterfaceTypeDefinition | InputTypeDefinition | UnionTypeDefinition;
2017
+ type CatalogScalarImplementationReference<TName extends CatalogScalarName> = { [Name in TName]: {
2018
+ readonly name: Name;
2019
+ readonly implementation: `powerhouse.catalog#${Name}`;
2020
+ }; }[TName];
2021
+ type CatalogScalarReferenceDefinition = CatalogScalarImplementationReference<PowerhouseScalarName> & {
2022
+ readonly coercionProfile: ScalarValidationProfile;
2064
2023
  };
2065
2024
  /**
2066
- * Another reactor's selection for a new document, within `supports`: a
2067
- * negotiated protocol drops to the highest supported version at or below it,
2068
- * or takes its baseline when absent; another known protocol must be
2069
- * supported; an unknown one passes, as refusalFor admits it.
2025
+ * The package that ships the definition declares this scalar with `defineScalar`.
2070
2026
  */
2071
- declare function capSelection(selected: {
2072
- readonly [protocol: string]: number;
2073
- } | undefined, capabilities: readonly PeerCapability[], supports: Supports): {
2074
- [protocol: string]: number;
2027
+ type PackageScalarReferenceDefinition = {
2028
+ readonly name: string;
2029
+ readonly implementation: `package#${string}`;
2030
+ readonly coercionProfile: ScalarValidationProfile;
2031
+ readonly definition: StoredScalarDefinition;
2075
2032
  };
2076
- //#endregion
2077
- //#region document-model/base-reducer-protocol.d.ts
2078
- declare const BASE_REDUCER_VERSIONS: readonly [1, 2, 3];
2079
- type BaseReducerVersion = (typeof BASE_REDUCER_VERSIONS)[number];
2080
- interface UndoModelValues {
2081
- skip: true;
2082
- "noop-chain": true;
2083
- retraction: true;
2084
- }
2085
- /** What UNDO and REDO become. */
2086
- type UndoModel = keyof UndoModelValues;
2087
- interface SkipMeaningValues {
2088
- "undo-or-rewind": true;
2089
- rewind: true;
2090
- }
2091
- /** Whether a stored skip can be an undo, or is only a replica's rewind. */
2092
- type SkipMeaning = keyof SkipMeaningValues;
2093
- interface TieOrderValues {
2094
- "rank-locale": true;
2095
- canonical: true;
2096
- }
2097
- /** How same-timestamp actions are ordered. */
2098
- type TieOrder = keyof TieOrderValues;
2099
- interface SynthesizedIdFormValues {
2100
- hashed: true;
2101
- none: true;
2102
- }
2103
- /** How a synthesized row's action id derives from its source's; "none" synthesizes nothing. */
2104
- type SynthesizedIdForm = keyof SynthesizedIdFormValues;
2105
- interface ReplayHashValues {
2106
- sender: true;
2107
- receiver: true;
2108
- }
2109
- /** Whose state hash a received row keeps. */
2110
- type ReplayHash = keyof ReplayHashValues;
2111
- interface DerivationModelValues {
2112
- replay: true;
2113
- "retraction-rule": true;
2114
- }
2115
- /** How a scope's state derives from its rows. */
2116
- type DerivationModel = keyof DerivationModelValues;
2117
- interface ReducerContractValues {
2118
- any: true;
2119
- "state-reducer": true;
2120
- }
2121
- /** Which registered reducers a version runs. */
2122
- type ReducerContract = keyof ReducerContractValues;
2123
- interface GatingFlagValues {
2124
- undoV3: true;
2125
- }
2126
- /** A reactor feature flag a version runs only under. */
2127
- type GatingFlag = keyof GatingFlagValues;
2128
- type BaseReducerCapabilities = {
2129
- readonly version: BaseReducerVersion;
2130
- readonly undo: UndoModel;
2131
- /** "retraction-rule" derives every scope outside RULE_EXEMPT_SCOPES by the rule. */
2132
- readonly derivation: DerivationModel;
2133
- readonly skip: SkipMeaning;
2134
- readonly tieOrder: TieOrder;
2135
- readonly synthesizedId: SynthesizedIdForm;
2136
- readonly replayHash: ReplayHash;
2137
- /** "state-reducer" runs only models whose every registered reducer createReducer tagged. */
2138
- readonly reducerContract: ReducerContract;
2139
- /** The flag this version runs only under; null runs always. */
2140
- readonly gatedBy: GatingFlag | null;
2033
+ type DocumentScalarReferenceDefinition = CatalogScalarReferenceDefinition | PackageScalarReferenceDefinition;
2034
+ type DefinitionExample = {
2035
+ readonly id: string;
2036
+ readonly key: string;
2037
+ readonly value: string;
2141
2038
  };
2142
- /** The versions a reactor running `flags` supports. */
2143
- declare function baseReducerVersionsFor(flags: PeerCapabilityFlags): BaseReducerVersion[];
2144
- /** Flags under which this build runs every version it knows. */
2145
- declare const FLAGS_FOR_EVERY_VERSION: { readonly [F in GatingFlag]: true; };
2146
- /** Scopes the retraction rule never derives. */
2147
- declare const RULE_EXEMPT_SCOPES: ReadonlySet<string>;
2148
- declare function assertNever(value: never, what: string): never;
2149
- declare function isBaseReducerVersion(value: unknown): value is BaseReducerVersion;
2150
- declare function capabilitiesOf(version: BaseReducerVersion): BaseReducerCapabilities;
2151
- /**
2152
- * The version `versions` runs as: a known number as itself, a number this
2153
- * build does not know as `highest`, undefined without a number.
2154
- */
2155
- declare function resolveBaseReducerVersion(versions: ProtocolVersions | undefined, highest?: BaseReducerVersion): BaseReducerVersion | undefined;
2156
- /** Throws on a missing version: defaulting one would replay through the wrong reducer. */
2157
- declare function baseReducerVersion(header: PHDocumentHeader): BaseReducerVersion;
2158
- /** Throws on a missing or unknown version. */
2159
- declare function baseReducerCapabilities(header: PHDocumentHeader): BaseReducerCapabilities;
2160
- /** Undefined only for a header without a version; throws on an unknown one. */
2161
- declare function optionalBaseReducerCapabilities(header: PHDocumentHeader): BaseReducerCapabilities | undefined;
2162
- /** Undefined when `versions` names no known base-reducer version. */
2163
- declare function capabilitiesFor(versions: ProtocolVersions | undefined): BaseReducerCapabilities | undefined;
2164
- /** From CREATE_DOCUMENT input; undefined when it names no known version. */
2165
- declare function createdCapabilities(input: Partial<CreateDocumentActionInput> | undefined): BaseReducerCapabilities | undefined;
2166
- /**
2167
- * Every decision a consumer may take on a capability axis. Outside this module
2168
- * and the other protocol owners, an axis is read only through these or through
2169
- * an exhaustive switch.
2170
- */
2171
- declare const CAPABILITY_DECISIONS: {
2172
- readonly usesRetractionRule: {
2173
- replay: false;
2174
- "retraction-rule": true;
2175
- };
2176
- readonly needsTaggedModel: {
2177
- any: false;
2178
- "state-reducer": true;
2039
+ type MaterializedStateDefinition = {
2040
+ readonly schema: string;
2041
+ readonly initialValue: string;
2042
+ readonly examples: readonly Omit<DefinitionExample, "key">[];
2043
+ };
2044
+ type NonEmptyStateDefinition = {
2045
+ readonly root: NamedTypeReferenceDefinition;
2046
+ readonly initialValue: JsonValue;
2047
+ readonly examples: readonly DefinitionExample[];
2048
+ readonly unknownKeys: "preserve";
2049
+ readonly materialized: MaterializedStateDefinition;
2050
+ };
2051
+ type EmptyLocalStateDefinition = {
2052
+ readonly root: null;
2053
+ readonly initialValue: Readonly<Record<string, never>>;
2054
+ readonly examples: readonly DefinitionExample[];
2055
+ readonly unknownKeys: "preserve";
2056
+ readonly materialized: MaterializedStateDefinition & {
2057
+ readonly schema: "";
2179
2058
  };
2180
- readonly sortsJobsCanonically: {
2181
- "rank-locale": false;
2182
- canonical: true;
2059
+ };
2060
+ type StateDefinition = NonEmptyStateDefinition | EmptyLocalStateDefinition;
2061
+ type CompiledErrorDefinition = {
2062
+ readonly id: string;
2063
+ readonly key: string;
2064
+ readonly code: string | null;
2065
+ readonly name: string | null;
2066
+ readonly description: string | null;
2067
+ readonly template: string | null;
2068
+ };
2069
+ type DocumentModelOperationDefinition = {
2070
+ readonly id: string;
2071
+ readonly key: string;
2072
+ readonly name: string | null;
2073
+ readonly description: string | null;
2074
+ readonly actionType: string;
2075
+ readonly creatorKey: string;
2076
+ readonly scope: "global" | "local";
2077
+ readonly input: InputTypeDefinition | null;
2078
+ readonly errors: readonly CompiledErrorDefinition[];
2079
+ readonly examples: readonly DefinitionExample[];
2080
+ readonly template: string | null;
2081
+ readonly reducer: string | null;
2082
+ };
2083
+ type DocumentModelModuleDefinition = {
2084
+ readonly id: string;
2085
+ readonly key: string;
2086
+ readonly name: string;
2087
+ readonly description: string | null;
2088
+ readonly operations: readonly DocumentModelOperationDefinition[];
2089
+ };
2090
+ type DocumentModelSpecificationDefinition = {
2091
+ readonly version: number;
2092
+ readonly scalars: readonly DocumentScalarReferenceDefinition[];
2093
+ readonly graphQLCompatibility: SchemaFirstGraphQLDocumentCompatibility | null;
2094
+ readonly types: readonly NamedGraphQLTypeDefinition[];
2095
+ readonly state: {
2096
+ readonly global: NonEmptyStateDefinition;
2097
+ readonly local: StateDefinition;
2183
2098
  };
2184
- readonly conflictWindowMovesEveryRow: {
2185
- "rank-locale": false;
2186
- canonical: true;
2099
+ readonly modules: readonly DocumentModelModuleDefinition[];
2100
+ readonly changeLog: readonly string[];
2101
+ };
2102
+ type DocumentModelDefinition = {
2103
+ readonly kind: "powerhouse.document-model";
2104
+ readonly formatVersion: 1;
2105
+ readonly compatibility: {
2106
+ readonly identity: "derived-v1" | "explicit-schema-first";
2107
+ readonly scalarCoercion: ScalarValidationProfile;
2108
+ readonly serialization: "canonical-v1" | "explicit-schema-first";
2187
2109
  };
2188
- readonly skipMayUndo: {
2189
- "undo-or-rewind": true;
2190
- rewind: false;
2110
+ readonly model: {
2111
+ readonly documentType: string;
2112
+ readonly graphQLName: string;
2113
+ readonly name: string;
2114
+ readonly description: string;
2115
+ readonly extension: string;
2116
+ readonly author: {
2117
+ readonly name: string;
2118
+ readonly website: string | null;
2119
+ };
2191
2120
  };
2121
+ readonly specifications: readonly DocumentModelSpecificationDefinition[];
2192
2122
  };
2193
- /** Whether the version derives scopes by the retraction rule; a versionless header does not. */
2194
- declare function usesRetractionRule(caps: BaseReducerCapabilities | undefined): boolean;
2195
- /** Whether the retraction rule derives `scope`. */
2196
- declare function derivesByRule(caps: BaseReducerCapabilities | undefined, scope: string): boolean;
2197
- /** Whether the retraction rule derives `scope` of the document `header` heads. */
2198
- declare function documentDerivesByRule(header: PHDocumentHeader, scope: string): boolean;
2199
- /** Whether the version runs only models whose every reducer is tagged. */
2200
- declare function needsTaggedModel(caps: BaseReducerCapabilities | undefined): boolean;
2201
- /** How same-timestamp actions are ordered; a versionless header ranks and compares by locale. */
2202
- declare function tieOrderOf(caps: BaseReducerCapabilities | undefined): TieOrder;
2203
- /** Whether a job's actions are stored in canonical order rather than as submitted. */
2204
- declare function sortsJobsCanonically(caps: BaseReducerCapabilities | undefined): boolean;
2205
- /** Whether every conflicting row of a load moves, rather than only those past the predecessor bound. */
2206
- declare function conflictWindowMovesEveryRow(caps: BaseReducerCapabilities | undefined): boolean;
2207
- /** Whether a stored skip may be an undo, not only a replica's rewind. */
2208
- declare function skipMayUndo(caps: BaseReducerCapabilities | undefined): boolean;
2209
- /** Whether a stored skip in `scope` is a rewind the reducer applies. */
2210
- declare function appliesRewind(caps: BaseReducerCapabilities, scope: string): boolean;
2211
- /** Whether a submitted RETRACT is this version's undo. */
2212
- declare function acceptsSubmittedRetract(caps: BaseReducerCapabilities): boolean;
2213
- /** Whether a submitted UNDO or REDO is this version's undo; on retraction a client submits RETRACT. */
2214
- declare function acceptsSubmittedUndoRedo(caps: BaseReducerCapabilities): boolean;
2215
- /** Whether every registered version of `documentType` runs under `caps`; undefined when none is. */
2216
- declare function modelRunsBaseReducer(caps: BaseReducerCapabilities, documentType: string, modules: readonly DocumentModelModule[]): boolean | undefined;
2217
- type ProtocolSupport = Supports["protocols"];
2218
- type ProtocolRefusal = {
2219
- protocol: string;
2220
- version: number;
2221
- /** Set when the version is supported but this model cannot run it. */
2222
- documentType?: string;
2123
+ type DefinitionCheckProfile = "edit" | "release";
2124
+ /**
2125
+ * The document model sources a check or inspection read. Discovery lists
2126
+ * each model directory's entry module (code-first) and stored specification
2127
+ * (schema-first); `request` means a caller named the modules itself.
2128
+ */
2129
+ type DefinitionSourceSet = {
2130
+ readonly origin: "discovery" | "request";
2131
+ /** The package-relative directory discovery read. */
2132
+ readonly documentModelsDir: `./${string}`;
2133
+ readonly digest: Sha256Digest;
2134
+ /** Code-first entry modules, sorted. */
2135
+ readonly sources: readonly DefinitionSource[];
2136
+ /** Schema-first stored specifications, sorted. */
2137
+ readonly stored: readonly DefinitionSource[];
2223
2138
  };
2224
- /** Why `versions` cannot run here; unregistered protocols and types are admitted. */
2225
- declare function refusalFor(documentType: string | undefined, versions: ProtocolVersions | undefined, support: ProtocolSupport, modules: readonly DocumentModelModule[]): ProtocolRefusal | undefined;
2226
- //#endregion
2227
- //#region document-model/constants.d.ts
2228
- declare const documentModelFileExtension: "phdm";
2229
- declare const documentModelInitialLocalState: DocumentModelLocalState;
2230
- declare const documentModelInitialGlobalState: DocumentModelGlobalState;
2231
- declare const documentModelGlobalState: DocumentModelGlobalState;
2232
- declare const HASH_ALGORITHM_SHA1 = "sha1";
2233
- declare const HASH_ALGORITHM_SHA256 = "sha256";
2234
- declare const HASH_ALGORITHM_SHA512 = "sha512";
2235
- declare const HASH_ENCODING_BASE64 = "base64";
2236
- declare const HASH_ENCODING_HEX = "hex";
2237
- //#endregion
2238
- //#region document-model/create-base-reducer.d.ts
2239
- type CreateBaseReducerLogger = {
2240
- debug: (message: string, ...replacements: unknown[]) => void;
2241
- warn: (message: string, ...replacements: unknown[]) => void;
2139
+ type DefinitionCompatibilitySelection = {
2140
+ readonly identity: "derived-v1" | "explicit-schema-first";
2141
+ readonly serialization: "canonical-v1" | "explicit-schema-first";
2142
+ readonly paths: {
2143
+ readonly ids: readonly string[];
2144
+ readonly names: readonly string[];
2145
+ readonly serialization: readonly string[];
2146
+ };
2242
2147
  };
2148
+ type DefinitionCheckReport = {
2149
+ readonly kind: "powerhouse.definition-check";
2150
+ readonly formatVersion: 2;
2151
+ readonly profile: DefinitionCheckProfile;
2152
+ readonly sourceSet: DefinitionSourceSet;
2153
+ readonly definitions: readonly (DefinitionRef & {
2154
+ readonly digest?: Sha256Digest;
2155
+ readonly source: DefinitionSource;
2156
+ readonly compatibility?: DefinitionCompatibilitySelection;
2157
+ })[];
2158
+ readonly diagnostics: readonly DefinitionDiagnostic[];
2159
+ readonly summary: {
2160
+ readonly errors: number;
2161
+ readonly warnings: number;
2162
+ };
2163
+ } & ({
2164
+ readonly status: "ok" | "invalid" | "failed";
2165
+ readonly skipReason?: never;
2166
+ } | {
2167
+ readonly status: "skipped";
2168
+ readonly skipReason: DefinitionCheckSkipReason;
2169
+ });
2170
+ /** The package has no document model directory to check. */
2171
+ type DefinitionCheckSkipReason = "no-document-models";
2243
2172
  /**
2244
- * Steps a selected base-reducer down to the highest version the model runs.
2245
- * An unregistered type cannot be checked, so it takes the highest version
2246
- * that needs no tagged reducer.
2173
+ * `fieldName` is `null` for a resolver bound to a type rather than a field.
2247
2174
  */
2248
- declare function fitCreateBaseReducer(selected: ProtocolVersions, documentType: string | undefined, modules: readonly DocumentModelModule[], logger: CreateBaseReducerLogger): ProtocolVersions;
2249
- //#endregion
2250
- //#region document-model/crypto.d.ts
2251
- declare const hashBrowser: (data: string | Uint8Array | ArrayBufferView | DataView, algorithm?: string, encoding?: string, _params?: Record<string, unknown>) => string;
2252
- declare function getUnixTimestamp(date: Date | string): string;
2253
- declare function buildOperationSignatureParams({ documentId, signer, action, previousStateHash }: ActionSignatureContext): [string, string, string, string];
2254
- declare function buildOperationSignatureMessage(params: [string, string, string, string]): Uint8Array;
2255
- declare function ab2hex(ab: ArrayBuffer | ArrayBufferView): string;
2256
- declare function hex2ab(hex: string): Uint8Array<ArrayBuffer>;
2175
+ type ResolverCoordinateDefinition = {
2176
+ readonly typeName: string;
2177
+ readonly fieldName: string | null;
2178
+ readonly resolverKind: "field" | "subscribe" | "resolve" | "resolveType" | "isTypeOf" | "enum" | "scalar";
2179
+ };
2257
2180
  /**
2258
- * Decodes a base58btc (Bitcoin/IPFS alphabet) string to bytes. Returns null on
2259
- * any character outside the alphabet.
2181
+ * The compiler supplies this marker. Resolvers perform their own authorization.
2260
2182
  */
2261
- declare function base58Decode(input: string): Uint8Array | null;
2262
- /** Encodes bytes as unpadded base64url. */
2263
- declare function bytesToBase64Url(bytes: Uint8Array): string;
2264
- /** Decodes a base64url string to bytes (portable across node, browsers, workers). */
2265
- declare function base64UrlToBytes(input: string): Uint8Array;
2183
+ type SubgraphEntryAccess = {
2184
+ readonly kind: "manual";
2185
+ };
2186
+ type SubgraphRootEntryBase = {
2187
+ /** The author's key, which is stable across a GraphQL name change. */
2188
+ readonly key: string;
2189
+ readonly fieldName: string;
2190
+ readonly description: string | null;
2191
+ readonly deprecated: string | null;
2192
+ readonly args: readonly InputFieldDefinition[];
2193
+ readonly returns: TypeReferenceDefinition;
2194
+ readonly access: SubgraphEntryAccess;
2195
+ };
2196
+ type SubgraphEntryDefinition = ({
2197
+ readonly kind: "query";
2198
+ } & SubgraphRootEntryBase) | ({
2199
+ readonly kind: "mutation";
2200
+ } & SubgraphRootEntryBase) | ({
2201
+ readonly kind: "subscription";
2202
+ } & SubgraphRootEntryBase) | {
2203
+ readonly kind: "computed-field";
2204
+ readonly typeName: string;
2205
+ readonly fieldName: string;
2206
+ readonly access: SubgraphEntryAccess;
2207
+ } | {
2208
+ readonly kind: "resolve-type";
2209
+ readonly typeName: string;
2210
+ readonly access: SubgraphEntryAccess;
2211
+ } | {
2212
+ readonly kind: "is-type-of";
2213
+ readonly typeName: string;
2214
+ readonly access: SubgraphEntryAccess;
2215
+ };
2216
+ /** A subgraph may also reference the internal scalars the host declares. */
2217
+ type SubgraphScalarReferenceDefinition = (CatalogScalarImplementationReference<CatalogScalarName> & {
2218
+ readonly graphQLProfile: "legacy-graphql-default-v1";
2219
+ }) | {
2220
+ readonly name: string;
2221
+ readonly implementation: `package#${string}`;
2222
+ readonly graphQLProfile: "declared-coercion-v1";
2223
+ readonly definition: StoredScalarDefinition;
2224
+ };
2225
+ type SubgraphDefinitionBase = {
2226
+ readonly kind: "powerhouse.subgraph";
2227
+ readonly formatVersion: 1;
2228
+ /** The instance and route segment name, not a new global identity. */
2229
+ readonly name: string;
2230
+ readonly compositionPolicy: "host-current";
2231
+ readonly federationProfile: "host-current";
2232
+ };
2233
+ type SubgraphDefinition = SubgraphDefinitionBase & ({
2234
+ readonly schemaKind: "typed";
2235
+ readonly hasSubscriptions: boolean;
2236
+ readonly types: readonly NamedGraphQLTypeDefinition[];
2237
+ readonly entries: readonly SubgraphEntryDefinition[];
2238
+ readonly scalars: readonly SubgraphScalarReferenceDefinition[];
2239
+ /**
2240
+ * Every emitted definition name appears once, including roots and
2241
+ * scalars. This order preserves the authored schema's print order.
2242
+ */
2243
+ readonly definitionOrder: readonly string[];
2244
+ } | {
2245
+ readonly schemaKind: "graphql-ast-compat";
2246
+ /**
2247
+ * `null` records runtime `undefined`. Both `null` and `false` disable
2248
+ * subscriptions, but compatibility must preserve their distinct values.
2249
+ */
2250
+ readonly hasSubscriptions: boolean | null;
2251
+ readonly document: LocationFreeGraphQLDocumentNode;
2252
+ readonly resolverCoordinates: readonly ResolverCoordinateDefinition[];
2253
+ readonly access: "manual";
2254
+ });
2266
2255
  //#endregion
2267
2256
  //#region document-model/create-document.d.ts
2268
2257
  declare function createDocumentAction(input: CreateDocumentActionInput): Action;
@@ -3209,10 +3198,18 @@ declare const PublisherSchema: z.ZodObject<{
3209
3198
  name: z.ZodOptional<z.ZodString>;
3210
3199
  url: z.ZodOptional<z.ZodString>;
3211
3200
  }, z.core.$strip>;
3212
- declare const ConfigEntryTypeSchema: z.ZodUnion<readonly [z.ZodLiteral<"var">, z.ZodLiteral<"secret">]>;
3201
+ declare const ConfigEntryTypeSchema: z.ZodEnum<{
3202
+ boolean: "boolean";
3203
+ secret: "secret";
3204
+ var: "var";
3205
+ }>;
3213
3206
  declare const ConfigEntrySchema: z.ZodObject<{
3214
3207
  name: z.ZodString;
3215
- type: z.ZodUnion<readonly [z.ZodLiteral<"var">, z.ZodLiteral<"secret">]>;
3208
+ type: z.ZodEnum<{
3209
+ boolean: "boolean";
3210
+ secret: "secret";
3211
+ var: "var";
3212
+ }>;
3216
3213
  description: z.ZodOptional<z.ZodString>;
3217
3214
  required: z.ZodOptional<z.ZodBoolean>;
3218
3215
  default: z.ZodOptional<z.ZodString>;
@@ -3264,7 +3261,11 @@ declare const ManifestSchema: z.ZodObject<{
3264
3261
  externalDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
3265
3262
  config: z.ZodOptional<z.ZodArray<z.ZodObject<{
3266
3263
  name: z.ZodString;
3267
- type: z.ZodUnion<readonly [z.ZodLiteral<"var">, z.ZodLiteral<"secret">]>;
3264
+ type: z.ZodEnum<{
3265
+ boolean: "boolean";
3266
+ secret: "secret";
3267
+ var: "var";
3268
+ }>;
3268
3269
  description: z.ZodOptional<z.ZodString>;
3269
3270
  required: z.ZodOptional<z.ZodBoolean>;
3270
3271
  default: z.ZodOptional<z.ZodString>;
@@ -5701,10 +5702,8 @@ type PowerhouseConfig = {
5701
5702
  };
5702
5703
  packageRegistryUrl?: string;
5703
5704
  connect?: PHConnectRuntimeConfig;
5704
- /** @experimental The modules that declare code-first definitions, or an explicit schema-first selection. */
5705
- definitionSources?: DefinitionSourcesConfig;
5706
5705
  };
5707
5706
  //#endregion
5708
- export { PackageManagerArgs as $, DEFAULT_SIGNATURE_POLICY as $_, SignalType as $a, ModuleSchema as $c, UndoOperationRefusedError as $d, ProtocolSupport as $f, checkOperationsIntegrity as $g, noop as $h, SetAuthorNameInput as $i, UndoSchema as $l, assertAuthPreservedOnDuplicate as $m, MakeEmpty as $n, ProcessorDispatchCreateResult as $o, legacySupports as $p, MutationUpdateStateExampleArgs as $r, assertOperationErrorIdUnique as $s, DeleteOperationInput as $t, CreateProtocolVersionsOptions as $u, DefinitionRef as $v, ResolverCoordinateDefinition as $y, PHConnectPwaRuntimeCaching as A, AuthGroups as A_, SetOperationNameInput as Aa, UndoRedoBatch as Ac, replayDocumentVersioned as Ad, hashBrowser as Af, setOperationSchema as Ag, ActionContext as Ah, ReorderModulesAction as Ai, SetNameActionInputSchema as Al, AuthRefusal as Am, DocumentOperationsIgnoreMap as An, createNamespacedDb as Ao, refusalFor as Ap, MutationSetAuthorNameArgs as Ar, RouteContext as As, ConfigEntry as At, undoRedoActions as Au, HashConfig as Av, GraphQLOperationTypeDefinitionNode as Ay, PHConnectRuntimeDefaultDriveRemote as B, backfillAuthState as B_, SetPreferredEditorActionInput as Ba, ConfigEntrySchema as Bc, AuthAlreadyInitializedError as Bd, documentModelGlobalState as Bf, verifyOperationSignature as Bg, addStateExample as Bh, RetractActionInput as Bi, SetOperationScopeInputSchema as Bl, MoveGrantActionInput as Bm, IAction as Bn, IRelationalDb as Bo, MARKER_REFUSAL_FEATURE as Bp, MutationSetOperationDescriptionArgs as Br, WebhookHashAlgorithm as Bs, DeleteChangeLogItemAction as Bt, documentModelVersioningReducer as Bu, CatalogScalarReferenceDefinition as Bv, InterfaceTypeDefinition as By, PHConnectOpenPanel as C, reshuffleByTimestampAndIndex as C_, SetOperationErrorDescriptionAction as Ca, compareActionIds as Cc, isDocumentZip as Cd, ab2hex as Cf, setOperationDescription as Cg, canonicalJson as Ch, ReleaseNewVersionAction as Ci, SetInitialStateInputSchema as Cl, grantProblem as Cm, DocumentModelOperationOperations as Cn, CodegenState as Co, createdCapabilities as Cp, MutationRedoArgs as Cr, IWebhookEndpoints as Cs, AddRelationshipActionInput as Ct, undoTarget as Cu, setNameOperation as Cv, GraphQLInterfaceTypeDefinitionNode as Cy, PHConnectPwaFileHandler as D, updateHeaderRevision as D_, SetOperationErrorTemplateAction as Da, legacyIdOrder as Dc, zipEntries as Dd, buildOperationSignatureParams as Df, setOperationErrorTemplate as Dg, targetDocumentId as Dh, ReorderChangeLogItemsInput as Di, SetModelNameInputSchema as Dl, AuthAction as Dm, DocumentModelUtils as Dn, SETTLED_CODEGEN_STATES as Do, modelRunsBaseReducer as Dp, MutationReorderOperationErrorsArgs as Dr, RouteAuth as Ds, AssertIsStateOfType as Dt, serializeByKey as Du, undoOperationV2 as Dv, GraphQLNonNullTypeNode as Dy, PHConnectPwaCacheStrategy as E, split as E_, SetOperationErrorNameInput as Ea, idOrderFor as Ec, writeFileBrowser as Ed, buildOperationSignatureMessage as Ef, setOperationErrorName as Eg, signActionV2 as Eh, ReorderChangeLogItemsAction as Ei, SetModelIdInputSchema as El, AUTH_ACTION_TYPES as Em, DocumentModelStateOperations as En, PackageLoadFailure as Eo, isBaseReducerVersion as Ep, MutationReorderModulesArgs as Er, RouteActor as Es, AssertIsDocumentOfType as Et, UndoRedoTargets as Eu, undoOperation as Ev, GraphQLNamedTypeNode as Ey, PHConnectRenown as F, PHAuthState as F_, SetOperationScopeAction as Fa, AddOperationExampleInputSchema as Fc, applyUpgradeDocumentAction as Fd, HASH_ALGORITHM_SHA256 as Ff, setStateSchema as Fg, addChangeLogItem as Fh, ReorderOperationExamplesInput as Fi, SetOperationErrorNameInputSchema as Fl, InitializeAuthAction as Fm, EditorProps as Fn, relationalDbToQueryBuilder as Fo, usesRetractionRule as Fp, MutationSetModelIdArgs as Fr, RouteTransport as Fs, CreateChildDocumentSignal as Ft, documentModelOperationExampleReducer as Fu, serializeSignature as Fv, GraphQLTypeSystemDefinitionNode as Fy, PHLength as G, createLocalState as G_, SetStateSchemaInput as Ga, DeleteOperationExampleInputSchema as Gc, GrantNotFoundError as Gd, BaseReducerVersion as Gf, PHDocumentMeta as Gg, deleteChangeLogItem as Gh, SchemaNOOPAction as Gi, SetSlugActionSchema as Gl, SetGrantAction as Gm, ISignalResult as Gn, RelationalDbProcessorClass as Go, PeerManifest as Gp, MutationSetOperationNameArgs as Gr, WebhookSignatureEncoding as Gs, DeleteDocumentActionInput as Gt, updateDocument as Gu, DefinitionCheckSkipReason as Gv, LocationFreeGraphQLDocumentNode as Gy, PHEdges as H, createBaseState as H_, SetSlugAction as Ha, DeleteChangeLogItemInputSchema as Hc, AuthPolicyNotPreservedError as Hd, documentModelInitialLocalState as Hf, IntegrityIssueType as Hg, buildOperationSignature as Hh, SaveToFile as Hi, SetPreferredEditorActionInputSchema as Hl, RemoveGrantAction as Hm, IDocument as Hn, IRelationalQueryBuilder as Ho, PEER_MANIFEST_FORMAT as Hp, MutationSetOperationErrorDescriptionArgs as Hr, WebhookReply as Hs, DeleteChildDocumentInput as Ht, createReducer as Hu, DefinitionCheckProfile as Hv, JsonPrimitive as Hy, PHConnectRenownAdapters as I, PHBaseState as I_, SetOperationScopeInput as Ia, AddOperationInputSchema as Ic, computeUpgradeTransitions as Id, HASH_ALGORITHM_SHA512 as If, undo as Ig, addModule as Ih, ReorderStateExamplesAction as Ii, SetOperationErrorTemplateInputSchema as Il, InitializeAuthActionInput as Im, Exact as In, DOCUMENT_ID_COLUMNS as Io, DOCUMENT_PURGE_PROTOCOL as Ip, MutationSetModelNameArgs as Ir, RouteUser as Is, CreateDocument as It, documentModelOperationReducer as Iu, DEFAULT_ANALYTICS_PROCESSOR_DB_NAME as Iv, GraphQLTypeSystemExtensionNode as Iy, PHReactorRenown as J, defaultBaseState as J_, Set_Slug as Ja, DocumentActionSchema as Jc, InvalidActionInputZodError as Jd, DerivationModelValues as Jf, appendWithoutApplying as Jg, deleteOperationError as Jh, SchemaSetPreferredEditorAction as Ji, Set_PreferredEditorSchema as Jl, applyAuthAction as Jm, InputMaybe as Jn, IProcessorHostModuleBase as Jo, Supports as Jp, MutationSetOperationTemplateArgs as Jr, deletedDocumentId as Js, DeleteOperationAction as Jt, PurgeMarkerOperation as Ju, DefinitionDiagnosticPhase as Jv, NamedTypeReferenceDefinition as Jy, PHPackageProvider as K, createState as K_, Set_Name as Ka, DeleteOperationInputSchema as Kc, HashMismatchError as Kd, CAPABILITY_DECISIONS as Kf, addUndo as Kg, deleteModule as Kh, SchemaRedoAction as Ki, SetStateSchemaInputSchema as Kl, SetGrantActionInput as Km, ISigner as Kn, IProcessor as Ko, ProtocolCapability as Kp, MutationSetOperationReducerArgs as Kr, WebhookSpec as Ks, DeleteModuleAction as Kt, stateReducerOf as Ku, DefinitionCompatibilitySelection as Kv, MaterializedStateDefinition as Ky, PHConnectRouterSettings as L, PHDocumentState as L_, SetOperationTemplateAction as La, AddStateExampleInputSchema as Lc, latestVersionOf as Ld, HASH_ENCODING_BASE64 as Lf, updateChangeLogItem as Lg, addOperation as Lh, ReorderStateExamplesInput as Li, SetOperationNameInputSchema as Ll, InitializeAuthActionInputSchema as Lm, FileInput as Ln, ExtractProcessorSchemaOrSelf as Lo, FLAGLESS_BASE_REDUCER_VERSION as Lp, MutationSetModuleDescriptionArgs as Lr, ScopedRouteHandle as Ls, CreateDocumentAction as Lt, documentModelReducer as Lu, DEFAULT_RELATIONAL_PROCESSOR_DB_NAME as Lv, GraphQLUnionTypeDefinitionNode as Ly, PHConnectReactor as M, Condition as M_, SetOperationReducerInput as Ma, AddChangeLogItemInputSchema as Mc, UpgradeReducer as Md, CreateBaseReducerLogger as Mf, setOperationTemplate as Mg, actionFromAction as Mh, ReorderOperationErrorsAction as Mi, SetOperationDescriptionInputSchema as Ml, AuthSubject as Mm, ENSInfo as Mn, createRelationalDb as Mo, skipMayUndo as Mp, MutationSetInitialStateArgs as Mr, RouteMethod as Ms, CopyChildDocumentInput as Mt, documentModelHeaderReducer as Mu, Signature as Mv, GraphQLSchemaDefinitionNode as My, PHConnectReactorFeatureFlags as N, Grant as N_, SetOperationSchemaAction as Na, AddModuleInputSchema as Nc, UpgradeTransition as Nd, fitCreateBaseReducer as Nf, setPreferredEditor as Ng, actionSigner as Nh, ReorderOperationErrorsInput as Ni, SetOperationErrorCodeInputSchema as Nl, AuthVerb as Nm, EditorDispatch as Nn, hashNamespace as No, sortsJobsCanonically as Np, MutationSetModelDescriptionArgs as Nr, RouteOptions as Ns, CopyChildDocumentSignal as Nt, documentModelModuleReducer as Nu, UserActionSigner as Nv, GraphQLStringValueNode as Ny, PHConnectPwaIcon as O, withScopeRevisions as O_, SetOperationErrorTemplateInput as Oa, synthesizedActionId as Oc, VersionedReducers as Od, bytesToBase64Url as Of, setOperationName as Og, v2TupleProblem as Oh, ReorderModuleOperationsAction as Oi, SetModuleDescriptionInputSchema as Ol, AuthDecision as Om, DocumentModelVersioningAction as On, getCodegenStatusRegistry as Oo, needsTaggedModel as Op, MutationReorderOperationExamplesArgs as Or, RouteAuthorizer as Os, Author as Ot, undoCapabilitiesOf as Ou, ActionSigner as Ov, GraphQLObjectFieldNode as Oy, PHConnectRemoteBackend as P, Operand as P_, SetOperationSchemaInput as Pa, AddOperationErrorInputSchema as Pc, applyDeleteDocumentAction as Pd, HASH_ALGORITHM_SHA1 as Pf, setSlug as Pg, actions as Ph, ReorderOperationExamplesAction as Pi, SetOperationErrorDescriptionInputSchema as Pl, ConditionContext as Pm, EditorModule as Pn, namespaceSchemaOf as Po, tieOrderOf as Pp, MutationSetModelExtensionArgs as Pr, RouteSpec as Ps, CreateChildDocumentInput as Pt, documentModelOperationErrorReducer as Pu, deserializeSignature as Pv, GraphQLTypeNode as Py, PHSchemedImage as Q, defaultPHState as Q_, SignalResults as Qa, ManifestSchema as Qc, SubmittedUndoRefusedError as Qd, ProtocolRefusal as Qf, checkCleanedOperationsIntegrity as Qg, moveOperation as Qh, SetAuthorNameAction as Qi, UndoActionSchema as Ql, applySetGrantAction as Qm, LoadFromInput as Qn, ProcessorDeletePropagation as Qo, isOlderManifest as Qp, MutationUpdateOperationExampleArgs as Qr, assertModuleIdUnique as Qs, DeleteOperationExampleInput as Qt, purgedProtocolVersions as Qu, DefinitionPath as Qv, PowerhouseScalarName as Qy, PHConnectRuntimeConfig as R, PHGroupState as R_, SetOperationTemplateInput as Ra, AuthorSchema as Rc, withProtocolVersions as Rd, HASH_ENCODING_HEX as Rf, updateOperationExample as Rg, addOperationError as Rh, ReplayDocumentOptions as Ri, SetOperationReducerInputSchema as Rl, MAX_SUPPORTED_AUTH_VERSION as Rm, GetDocumentOptions as Rn, HashAlgorithms as Ro, FeatureCapability as Rp, MutationSetModuleNameArgs as Rr, WebhookEndpointInfo as Rs, CreateDocumentActionInput as Rt, documentModelStateReducer as Ru, PROCESSOR_APPS as Rv, InputFieldDefinition as Ry, PHConnectLoader as S, reshuffleByTimestamp as S_, SetOperationErrorCodeInput as Sa, UNDO_GROUP_MARK as Sc, getFileBrowser as Sd, upgradeDocumentAction as Sf, setName as Sg, actionSigningTarget as Sh, RejectedAction as Si, SetAuthorWebsiteInputSchema as Sl, evaluateGrants as Sm, DocumentModelOperationExampleOperations as Sn, ValidationError as So, conflictWindowMovesEveryRow as Sp, MutationMoveOperationArgs as Sr, IHttpScope as Ss, AddRelationshipAction as St, undoRedoTargetsOf as Su, redoOperation as Sv, GraphQLInputValueDefinitionNode as Sy, PHConnectPwa as T, sortMappedOperations as T_, SetOperationErrorNameAction as Ta, groupedActionId as Tc, readFileBrowser as Td, base64UrlToBytes as Tf, setOperationErrorDescription as Tg, isV2ActionHash as Th, RemoveRelationshipActionInput as Ti, SetModelExtensionInputSchema as Tl, referencedGroupIds as Tm, DocumentModelStateAction as Tn, CodegenStatusRegistry as To, documentDerivesByRule as Tp, MutationReorderModuleOperationsArgs as Tr, NodeRouteSpec as Ts, AddStateExampleInput as Tt, UndoRedoAvailability as Tu, setSlugOperation as Tv, GraphQLNameNode as Ty, PHImageRef as U, createDocumentState as U_, SetSlugActionInput as Ua, DeleteModuleInputSchema as Uc, DowngradeNotSupportedError as Ud, BASE_REDUCER_VERSIONS as Uf, PHDocument$1 as Ug, buildSignedAction as Uh, SaveToFileHandle as Ui, SetPreferredEditorActionSchema as Ul, RemoveGrantActionInput as Um, IOperation as Un, IRelationalQueryMethods as Uo, PeerCapability as Up, MutationSetOperationErrorNameArgs as Ur, WebhookRequest as Us, DeleteChildDocumentSignal as Ut, processUndoRedo as Uu, DefinitionCheckReport as Uv, JsonValue as Uy, PHConnectSentry as V, createAuthState as V_, SetPreferredEditorOperation as Va, ConfigEntryTypeSchema as Vc, AuthInitializerNotCreatorError as Vd, documentModelInitialGlobalState as Vf, IntegrityIssueSubType as Vg, baseActions as Vh, RevisionsFilter as Vi, SetOperationTemplateInputSchema as Vl, MoveGrantActionInputSchema as Vm, ID as Vn, IRelationalDbProcessor as Vo, PEER_CAPABILITIES as Vp, MutationSetOperationErrorCodeArgs as Vr, WebhookPolicy as Vs, DeleteChangeLogItemInput as Vt, baseReducer as Vu, CompiledErrorDefinition as Vv, InternalScalarName as Vy, PHKeyframeRule as W, createGlobalState as W_, SetStateSchemaAction as Wa, DeleteOperationErrorInputSchema as Wc, FileSystemError as Wd, BaseReducerCapabilities as Wf, PHDocumentHeader as Wg, createAction as Wh, Scalars as Wi, SetSlugActionInputSchema as Wl, RemoveGrantActionInputSchema as Wm, ISignal as Wn, RelationalDbProcessor as Wo, PeerCapabilityFlags as Wp, MutationSetOperationErrorTemplateArgs as Wr, WebhookScheme as Ws, DeleteDocumentAction as Wt, replayOperations as Wu, DefinitionCheckRequest as Wv, ListTypeReferenceDefinition as Wy, PHRenownRainbowAdapterConfig as X, defaultGlobalState as X_, SignalDispatch as Xa, DocumentModelInputSchema as Xc, MissingStateReducerError as Xd, GatingFlag as Xf, attachBranch as Xg, deleteStateExample as Xh, SchemaUndoAction as Xi, StateSchema as Xl, applyMoveGrantAction as Xm, IsStateOfType as Xn, ProcessorApp as Xo, coversLocal as Xp, MutationUndoArgs as Xr, RESERVED_OPERATION_NAMES as Xs, DeleteOperationErrorInput as Xt, purgeDocumentAction as Xu, DefinitionExample as Xv, ObjectTypeDefinition as Xy, PHRenownPrivyAdapterConfig as Y, defaultDocumentState as Y_, Signal as Ya, DocumentModelGlobalStateSchema as Yc, InvalidAuthVersionError as Yd, FLAGS_FOR_EVERY_VERSION as Yf, assertReplayIndices as Yg, deleteOperationExample as Yh, SchemaSetSlugAction as Yi, Set_SlugSchema as Yl, applyInitializeAuthAction as Ym, IsDocumentOfType as Yn, IProcessorManager as Yo, capSelection as Yp, MutationSetStateSchemaArgs as Yr, OPERATION_NAME_PATTERN as Ys, DeleteOperationErrorAction as Yt, isPurgeMarker as Yu, DefinitionDiagnosticSeverity as Yv, NonEmptyStateDefinition as Yy, PHSchemedColor as Z, defaultLocalState as Z_, SignalResult as Za, DocumentSpecificationSchema as Zc, NoUndoRedoTargetError as Zd, GatingFlagValues as Zf, baseCreateDocument as Zg, documentModelActions as Zh, ScopeState as Zi, UndoActionInputSchema as Zl, applyRemoveGrantAction as Zm, LoadFromFile as Zn, ProcessorApps as Zo, holdReason as Zp, MutationUpdateChangeLogItemInputArgs as Zr, ReservedOperationName as Zs, DeleteOperationExampleAction as Zt, purgeMarkerOperation as Zu, DefinitionKind as Zv, PackageScalarReferenceDefinition as Zy, PHConnectDriveSections as _, prepareOperations as __, SetNameActionInput as _a, generateId as _c, createMinimalZip as _d, isDenied as _f, setModelExtension as _g, ActionSigningTarget as _h, Redo as _i, ReorderOperationExamplesInputSchema as _l, assertValidGrant as _m, DocumentModelModuleOperations as _n, UpdateStateExampleAction as _o, baseReducerCapabilities as _p, MutationDeleteModuleArgs as _r, ProcessorTimingPath as _s, AddOperationErrorAction as _t, reduceOne as _u, Operation as _v, GraphQLDirectiveNode as _y, PHBackground as a, getDocumentLastModified as a_, SetModelDescriptionInput as aa, SchemaFirstGraphQLDocumentCompatibility as ab, findOperationOrThrow as ac, createPresignedHeader as ad, BaseDocumentStateSchema as af, releaseNewVersion as ag, isDocumentCreator as ah, PartialRecord as ai, PieceModulesSchema as al, readPeerManifest as am, DocumentDispatch$1 as an, StateReducer as ao, SkipMeaning as ap, MinimalBackupData as ar, ProcessorPhase as as, ServiceActions as at, OnThrow as au, deriveDocumentId as av, DocumentModelModuleDefinition as ay, PHConnectHome as b, replayDocument as b_, SetOperationDescriptionInput as ba, IdOrder as bc, documentModelSaveToFileHandle as bd, creationState as bf, setModuleDescription as bg, actionPreimageV2 as bh, Reducer as bi, ScopeStateSchema as bl, evaluateCondition as bm, DocumentModelOperationErrorOperations as bn, UpgradeDocumentActionInput as bo, capabilitiesFor as bp, MutationDeleteOperationExampleArgs as br, TrackedProcessor as bs, AddOperationExampleInput as bt, retractionTarget as bu, OperationWithContext$1 as bv, GraphQLFieldDefinitionNode as by, PHConnectAi as c, isNoopOperation as c_, SetModelIdAction as ca, StoredScalarDefinition as cb, isValidOperationNameFormat as cc, createVerificationSigner as cd, DocumentModelSchema as cf, reorderModules as cg, removeGrant as ch, PhAiToolAnnotations as ci, PublisherSchema as cl, AuthAdministrationMissingError as cm, DocumentModelDocumentModelModule as cn, UndoAction as co, SynthesizedIdFormValues as cp, MoveOperationInput as cr, ProcessorRerunOptions as cs, ActionSignatureContext as ct, TailBase as cu, protocolVersionsFor as cv, DocumentScalarReferenceDefinition as cy, PHConnectCollection as d, mapSkippedOperations as d_, SetModelNameInput as da, SubgraphEntryAccess as db, validateModuleOperation as dc, validateHeader as dd, isDocumentModelDocument as df, reorderStateExamples as dg, TransportAction as dh, PieceModule as di, RedoActionSchema as dl, InvalidGrantError as dm, DocumentModelHeaderOperations as dn, UpdateChangeLogItemAction as do, UndoModel as dp, MutationAddModuleArgs as dr, ProcessorTimingBatch as ds, Actions as dt, advanceUndoTargets as du, v2RequiredProtocolVersions as dv, EnumValueDefinition as dy, diffOperations as e_, SetAuthorWebsiteAction as ea, ScalarGraphQLProfile as eb, assertOperationExampleIdUnique as ec, NewDocumentHeaderOptions as ed, UnsupportedDocumentModelVersionError as ef, operationExampleCreators as eg, assertAuthScopeActionAllowed as eh, NOOPAction as ei, MoveOperationInputSchema as el, localPeerManifest as em, DeleteStateExampleAction as en, SignatureVerificationHandler as eo, RULE_EXEMPT_SCOPES as ep, MakeMaybe as er, ProcessorDispatchResult as es, ParsedCmdResult as et, UpdateChangeLogItemInputSchema as eu, DocumentIdParams as ev, DefinitionRelatedLocation as ey, PHConnectCompositionEntry as f, mapSkippedOperationsV2 as f_, SetModuleDescriptionAction as fa, SubgraphEntryDefinition as fb, validateModules as fc, verify as fd, isDocumentModelState as ff, retract as fg, TransportActionContext as fh, PowerhouseModule as fi, RedoSchema as fl, MAX_AUTH_GRANTS as fm, DocumentModelInput as fn, UpdateChangeLogItemInput as fo, UndoModelValues as fp, MutationAddOperationArgs as fr, ProcessorTimingCounters as fs, AddChangeLogItemAction as ft, appliedOperations as fu, garbageCollect as fv, FieldDefinition as fy, PHConnectDriveSection as g, precedes as g_, SetNameAction as ga, deriveOperationId as gc, baseSaveToFileHandle as gd, DOCUMENT_DELETED_REASON as gf, setModelDescription as gg, ActionSignerIdentity as gh, Query as gi, ReorderOperationErrorsInputSchema as gl, assertAuthAdministrationRetained as gm, DocumentModelModuleAction as gn, UpdateRelationshipActionInput as go, assertNever as gp, MutationDeleteChangeLogItemInputArgs as gr, ProcessorTimingLevel as gs, AddOperationAction as gt, redoTarget as gu, DocumentOperations as gv, GraphQLDirectiveDefinitionNode as gy, PHConnectDefaultDriveRemote as h, parseResultingState as h_, SetModuleNameInput as ha, UnionTypeDefinition as hb, validateStateSchemaName as hc, baseLoadFromInputVersioned as hd, AUTH_VERSION_UNSUPPORTED_REASON as hf, setInitialState as hg, ACTION_SIGNATURE_V2_PREFIX as hh, PurgeDocumentActionInput as hi, ReorderModulesInputSchema as hl, MAX_CONDITION_NODES as hm, DocumentModelModule as hn, UpdateRelationshipAction as ho, appliesRewind as hp, MutationAddStateExampleArgs as hr, ProcessorTimingLastRun as hs, AddModuleInput as ht, positionalOperations as hu, sortOperations as hv, GraphQLConstValueNode as hy, LogLevels as i, garbageCollectV2 as i_, SetModelDescriptionAction as ia, ScalarValidationProfile as ib, findOperationExampleOrThrow as ic, createCopyHeader as id, BaseDocumentHeaderSchema as if, redo as ig, isAuthAction as ih, OperationsByScope as ii, PieceModuleSchema as il, peerSupports as im, DocumentAction as in, State as io, ReplayHashValues as ip, Maybe as ir, ProcessorHostInfo as is, ServiceAction as it, isDefinedNonNullAny as iu, SignaturePolicy$1 as iv, DocumentModelDefinition as iy, PHConnectPwaUrlPattern as j, Capability as j_, SetOperationReducerAction as ja, undoRedoBatch as jc, UpgradeManifest as jd, hex2ab as jf, setOperationScope as jg, actionContext as jh, ReorderModulesInput as ji, SetNameActionSchema as jl, AuthRequest as jm, DocumentSpecification as jn, createNamespacedQueryBuilder as jo, resolveBaseReducerVersion as jp, MutationSetAuthorWebsiteArgs as jr, RouteHandler as js, ConfigEntryType as jt, undoRedoAvailabilityOf as ju, PHDocumentSignatureInfo as jv, GraphQLScalarTypeDefinitionNode as jy, PHConnectPwaManifest as k, withSignaturePolicy as k_, SetOperationNameAction as ka, undoGroupOfId as kc, VersionedReplayConfig as kd, getUnixTimestamp as kf, setOperationReducer as kg, Action as kh, ReorderModuleOperationsInput as ki, SetModuleNameInputSchema as kl, AuthEvaluation as km, DocumentModelVersioningOperations as kn, isSettledCodegenState as ko, optionalBaseReducerCapabilities as kp, MutationReorderStateExamplesArgs as kr, RouteBody as ks, CodeExample as kt, undoNeedsTargets as ku, AppActionSigner as kv, GraphQLObjectTypeDefinitionNode as ky, PHConnectApp as l, isUndo as l_, SetModelIdInput as la, SubgraphDefinition as lb, validateInitialState as lc, hasDerivedDocumentId as ld, assertIsDocumentModelDocument as lf, reorderOperationErrors as lg, resolveSnapshotAuth as lh, PhAiToolContext as li, PwaConfigSchema as ll, GrantSchema as lm, DocumentModelGlobalState as ln, UndoActionInput as lo, TieOrder as lp, Mutation as lr, ProcessorStatus as ls, ActionSigningHandler as lt, UndoTargetsBase as lu, requestedSignaturePolicy as lv, EmptyLocalStateDefinition as ly, PHConnectDefaultDriveLocal as m, operationsAreEqual as m_, SetModuleNameAction as ma, TypeReferenceDefinition as mb, validateOperations as mc, baseLoadFromInput as md, AUTH_NO_GRANT_REASON as mf, setAuthorWebsite as mg, toTransportAction as mh, PurgeDocumentAction as mi, ReorderModuleOperationsInputSchema as ml, MAX_CONDITION_DEPTH as mm, DocumentModelLocalState as mn, UpdateOperationExampleInput as mo, acceptsSubmittedUndoRedo as mp, MutationAddOperationExampleArgs as mr, ProcessorTimingHorizon as ms, AddModuleAction as mt, deriveScopeVersioned as mu, nextSkipNumber as mv, GraphQLBuiltInScalarName as my, DrivePreserveStrategy as n, filterDuplicatedOperations as n_, SetInitialStateAction as na, ScalarRepresentation as nb, findModuleOrThrow as nc, headNewDocument as nd, groupDocumentType as nf, operationFromOperation as ng, evaluate as nh, OperationIndex as ni, OperationScopeSchema as nl, manifestRevision as nm, DeriveScope as nn, SkipHeaderOperationIndex as no, ReducerContractValues as np, Manifest as nr, ProcessorFactoryBuilder as ns, PowerhouseConfig as nt, UpdateStateExampleInputSchema as nu, SIGNATURE_PROTOCOL as nv, DefinitionSourcesConfig as ny, PHBackgroundLayer as o, groupOperationsByScope as o_, SetModelExtensionAction as oa, Sha256Digest as ob, getAllOperationNames as oc, createSignedHeader as od, DocumentModelHeaderSchema as of, reorderChangeLogItems as og, mentionedGroupIds as oh, PartialState as oi, PowerhouseModuleSchema as ol, selectProtocolVersions as om, DocumentModelAction as on, SubgraphModule as oo, SkipMeaningValues as op, ModuleSpecification as or, ProcessorQueueDepth as os, DEFAULT_REGISTRY_URL as ot, ReducerFor as ou, isDerivedDocumentId as ov, DocumentModelOperationDefinition as oy, PHConnectDefaultDrive as p, merge as p_, SetModuleDescriptionInput as pa, SubgraphScalarReferenceDefinition as pb, validateOperationName as pc, BulkArchiveEntry as pd, AUTH_DENIED_BY_GRANT_REASON as pf, setAuthorName as pg, TransportSigner as ph, Publisher as pi, ReorderChangeLogItemsInputSchema as pl, MAX_CAPABILITY_OPERATIONS as pm, DocumentModelLib as pn, UpdateOperationExampleAction as po, acceptsSubmittedRetract as pp, MutationAddOperationErrorArgs as pr, ProcessorTimingDocumentType as ps, AddChangeLogItemInput as pt, deriveScope as pu, isDocumentAction as pv, GraphQLArgumentNode as py, PHReactorClientMode as q, defaultAuthState as q_, Set_PreferredEditor as qa, DeleteStateExampleInputSchema as qc, InvalidActionInputError as qd, DerivationModel as qf, appendRows as qg, deleteOperation as qh, SchemaSetNameAction as qi, Set_NameSchema as ql, SetGrantActionInputSchema as qm, Incremental as qn, IProcessorDispatch as qo, ProtocolSelectionRule as qp, MutationSetOperationSchemaArgs as qr, WebhookVerification as qs, DeleteModuleInput as qt, PURGE_DOCUMENT as qu, DefinitionDiagnostic as qv, NamedGraphQLTypeDefinition as qy, LogLevel as r, garbageCollectDocumentOperations as r_, SetInitialStateInput as ra, ScalarTypeReferenceDefinition as rb, findOperationErrorOrThrow as rc, selectDocumentModelModule as rd, groupMembershipActionTypes as rf, operationWithContext as rg, initializeAuth as rh, OperationSpecification as ri, OperationSpecificationSchema as rl, mergePeerCapabilities as rm, DispatchOutcome as rn, SkipHeaderOperations as ro, ReplayHash as rp, MappedOperation as rr, ProcessorFilter as rs, PowerhousePackage as rt, definedNonNullAnySchema as ru, SIGNATURE_PROTOCOL_V2 as rv, DirectiveUseDefinition as ry, PHBackgroundLayers as s, hashDocumentStateForScope as s_, SetModelExtensionInput as sa, StateDefinition as sb, isReservedOperationName as sc, createSignedHeaderForSigner as sd, DocumentModelPHStateSchema as sf, reorderModuleOperations as sg, moveGrant as sh, PhAiChatImage as si, PowerhouseModulesSchema as sl, AuthAdministrationLockoutError as sm, DocumentModelDocument as sn, Undo as so, SynthesizedIdForm as sp, MoveOperationAction as sr, ProcessorRecord as ss, ActionErrorCallback as st, ScopeVersions as su, isSignaturePolicy as sv, DocumentModelSpecificationDefinition as sy, DrivePreserveStrategies as t, filterDocumentOperationsResultingState as t_, SetAuthorWebsiteInput as ta, ScalarName as tb, assertOperationIdUnique as tc, createVersionsOf as td, documentModelDocumentType as tf, operationFromAction as tg, decide as th, OperationErrorSpecification as ti, OperationErrorSchema as tl, localSupports as tm, DeleteStateExampleInput as tn, SigningParameters as to, ReducerContract as tp, MakeOptional as tr, ProcessorFactory as ts, PathValidation as tt, UpdateOperationExampleInputSchema as tu, ProtocolVersions as tv, DefinitionSource as ty, PHConnectBranding as u, isUndoRedo as u_, SetModelNameAction as ua, SubgraphDefinitionBase as ub, validateModule as uc, sign as ud, assertIsDocumentModelState as uf, reorderOperationExamples as ug, setGrant as uh, PhAiToolDescriptor as ui, RedoActionInputSchema as ul, GroupPrincipalNotAllowedError as um, DocumentModelHeaderAction as un, UndoRedoAction as uo, TieOrderValues as up, MutationAddChangeLogItemInputArgs as ur, ProcessorTiming as us, ActionVerificationHandler as ut, actionReferences as uu, signaturePolicyOf as uv, EnumTypeDefinition as uy, PHConnectDrives as v, readOnly as v_, SetNameOperation as va, generateMock as vc, createZip as vd, createDocumentAction as vf, setModelId as vg, CanonicalJsonError as vh, RedoAction as vi, ReorderStateExamplesInputSchema as vl, assertValidGrantUpsert as vm, DocumentModelOperationAction as vn, UpdateStateExampleInput as vo, baseReducerVersion as vp, MutationDeleteOperationArgs as vr, ProcessorTimingRun as vs, AddOperationErrorInput as vt, retractedActionIds as vu, OperationContext as vv, GraphQLEnumTypeDefinitionNode as vy, PHConnectPackages as w, skipHeaderOperations as w_, SetOperationErrorDescriptionInput as wa, compareCanonical as wc, parseBulkArchive as wd, base58Decode as wf, setOperationErrorCode as wg, hashActionV2 as wh, RemoveRelationshipAction as wi, SetModelDescriptionInputSchema as wl, isPlainValue as wm, DocumentModelPHState as wn, CodegenStatus as wo, derivesByRule as wp, MutationReorderChangeLogItemsInputArgs as wr, IWebhookScope as ws, AddStateExampleAction as wt, undoTargetsBase as wu, setPreferredEditorOperation as wv, GraphQLListTypeNode as wy, PHConnectInstance as x, requireStateReducer as x_, SetOperationErrorCodeAction as xa, LEGACY_UNDO_GROUP_PREFIX as xc, fetchFileBrowser as xd, documentFromCreation as xf, setModuleName as xg, actionSignerIdentity as xh, ReducerOptions as xi, SetAuthorNameInputSchema as xl, evaluateGrantStack as xm, DocumentModelOperationExampleAction as xn, User as xo, capabilitiesOf as xp, MutationDeleteStateExampleArgs as xr, AuthorizerResult as xs, AddOperationInput as xt, tailAppliesIncrementally as xu, operationOutcome as xv, GraphQLInputObjectTypeDefinitionNode as xy, PHConnectExplorerIcons as y, removeExistingOperations as y_, SetOperationDescriptionAction as ya, CanonicalKey as yc, documentModelLoadFromInput as yd, creationActions as yf, setModelName as yg, DOCUMENT_SCOPE_ACTION_TYPES as yh, RedoActionInput as yi, RetractActionInputSchema as yl, assertValidInitialGrants as ym, DocumentModelOperationErrorAction as yn, UpgradeDocumentAction as yo, baseReducerVersionsFor as yp, MutationDeleteOperationErrorArgs as yr, ReplayStateMode as ys, AddOperationExampleAction as yt, retractionRewrites as yu, OperationOutcome as yv, GraphQLEnumValueDefinitionNode as yy, PHConnectRuntimeDefaultDrive as z, Principal as z_, SetPreferredEditorAction as za, CodeExampleSchema as zc, AuthActionNotAllowedError as zd, documentModelFileExtension as zf, updateStateExample as zg, addOperationExample as zh, RetractAction as zi, SetOperationSchemaInputSchema as zl, MoveGrantAction as zm, HostedEditorProps as zn, IBaseRelationalDb as zo, HoldReason as zp, MutationSetNameArgs as zr, WebhookField as zs, CreateState as zt, documentModelStateSchemaReducer as zu, CatalogScalarName as zv, InputTypeDefinition as zy };
5707
+ export { PackageManagerArgs as $, setOperationDescription as $_, SignalType as $a, ModuleSchema as $c, UndoOperationRefusedError as $d, GraphQLDirectiveDefinitionNode as $f, canonicalJson as $g, grantProblem as $h, SetAuthorNameInput as $i, UndoSchema as $l, createdCapabilities as $m, MakeEmpty as $n, ProcessorDispatchCreateResult as $o, ab2hex as $p, MutationUpdateStateExampleArgs as $r, assertOperationErrorIdUnique as $s, DeleteOperationInput as $t, CreateProtocolVersionsOptions as $u, reshuffleByTimestampAndIndex as $v, setNameOperation as $y, PHConnectPwaRuntimeCaching as A, operationExampleCreators as A_, SetOperationNameInput as Aa, UndoRedoBatch as Ac, replayDocumentVersioned as Ad, DefinitionDiagnostic as Af, assertAuthScopeActionAllowed as Ag, localPeerManifest as Ah, ReorderModulesAction as Ai, SetNameActionInputSchema as Al, RULE_EXEMPT_SCOPES as Am, DocumentOperationsIgnoreMap as An, createNamespacedDb as Ao, NamedGraphQLTypeDefinition as Ap, MutationSetAuthorNameArgs as Ar, RouteContext as As, ConfigEntry as At, undoRedoActions as Au, diffOperations as Av, DocumentIdParams as Ay, PHConnectRuntimeDefaultDriveRemote as B, reorderOperationExamples as B_, SetPreferredEditorActionInput as Ba, ConfigEntrySchema as Bc, AuthAlreadyInitializedError as Bd, DirectiveUseDefinition as Bf, setGrant as Bg, GroupPrincipalNotAllowedError as Bh, RetractActionInput as Bi, SetOperationScopeInputSchema as Bl, TieOrderValues as Bm, IAction as Bn, IRelationalDb as Bo, ScalarTypeReferenceDefinition as Bp, MutationSetOperationDescriptionArgs as Br, WebhookHashAlgorithm as Bs, DeleteChangeLogItemAction as Bt, documentModelVersioningReducer as Bu, isUndoRedo as Bv, signaturePolicyOf as By, PHConnectOpenPanel as C, deleteOperation as C_, SetOperationErrorDescriptionAction as Ca, compareActionIds as Cc, isDocumentZip as Cd, CatalogScalarName as Cf, SetGrantActionInputSchema as Cg, ProtocolSelectionRule as Ch, ReleaseNewVersionAction as Ci, SetInitialStateInputSchema as Cl, DerivationModel as Cm, DocumentModelOperationOperations as Cn, CodegenState as Co, InterfaceTypeDefinition as Cp, MutationRedoArgs as Cr, IWebhookEndpoints as Cs, AddRelationshipActionInput as Ct, undoTarget as Cu, appendRows as Cv, defaultAuthState as Cy, PHConnectPwaFileHandler as D, documentModelActions as D_, SetOperationErrorTemplateAction as Da, legacyIdOrder as Dc, zipEntries as Dd, DefinitionCheckReport as Df, applyRemoveGrantAction as Dg, holdReason as Dh, ReorderChangeLogItemsInput as Di, SetModelNameInputSchema as Dl, GatingFlagValues as Dm, DocumentModelUtils as Dn, SETTLED_CODEGEN_STATES as Do, ListTypeReferenceDefinition as Dp, MutationReorderOperationErrorsArgs as Dr, RouteAuth as Ds, AssertIsStateOfType as Dt, serializeByKey as Du, baseCreateDocument as Dv, defaultLocalState as Dy, PHConnectPwaCacheStrategy as E, deleteStateExample as E_, SetOperationErrorNameInput as Ea, idOrderFor as Ec, writeFileBrowser as Ed, DefinitionCheckProfile as Ef, applyMoveGrantAction as Eg, coversLocal as Eh, ReorderChangeLogItemsAction as Ei, SetModelIdInputSchema as El, GatingFlag as Em, DocumentModelStateOperations as En, PackageLoadFailure as Eo, JsonValue as Ep, MutationReorderModulesArgs as Er, RouteActor as Es, AssertIsDocumentOfType as Et, UndoRedoTargets as Eu, attachBranch as Ev, defaultGlobalState as Ey, PHConnectRenown as F, releaseNewVersion as F_, SetOperationScopeAction as Fa, AddOperationExampleInputSchema as Fc, applyUpgradeDocumentAction as Fd, DefinitionPath as Ff, isDocumentCreator as Fg, readPeerManifest as Fh, ReorderOperationExamplesInput as Fi, SetOperationErrorNameInputSchema as Fl, SkipMeaning as Fm, EditorProps as Fn, relationalDbToQueryBuilder as Fo, PowerhouseScalarName as Fp, MutationSetModelIdArgs as Fr, RouteTransport as Fs, CreateChildDocumentSignal as Ft, documentModelOperationExampleReducer as Fu, getDocumentLastModified as Fv, deriveDocumentId as Fy, PHLength as G, setInitialState as G_, SetStateSchemaInput as Ga, DeleteOperationExampleInputSchema as Gc, GrantNotFoundError as Gd, DocumentScalarReferenceDefinition as Gf, ACTION_SIGNATURE_V2_PREFIX as Gg, MAX_CONDITION_NODES as Gh, SchemaNOOPAction as Gi, SetSlugActionSchema as Gl, appliesRewind as Gm, ISignalResult as Gn, RelationalDbProcessorClass as Go, StoredScalarDefinition as Gp, MutationSetOperationNameArgs as Gr, WebhookSignatureEncoding as Gs, DeleteDocumentActionInput as Gt, updateDocument as Gu, parseResultingState as Gv, sortOperations as Gy, PHEdges as H, retract as H_, SetSlugAction as Ha, DeleteChangeLogItemInputSchema as Hc, AuthPolicyNotPreservedError as Hd, DocumentModelModuleDefinition as Hf, TransportActionContext as Hg, MAX_AUTH_GRANTS as Hh, SaveToFile as Hi, SetPreferredEditorActionInputSchema as Hl, UndoModelValues as Hm, IDocument as Hn, IRelationalQueryBuilder as Ho, SchemaFirstGraphQLDocumentCompatibility as Hp, MutationSetOperationErrorDescriptionArgs as Hr, WebhookReply as Hs, DeleteChildDocumentInput as Ht, createReducer as Hu, mapSkippedOperationsV2 as Hv, garbageCollect as Hy, PHConnectRenownAdapters as I, reorderChangeLogItems as I_, SetOperationScopeInput as Ia, AddOperationInputSchema as Ic, computeUpgradeTransitions as Id, DefinitionRef as If, mentionedGroupIds as Ig, selectProtocolVersions as Ih, ReorderStateExamplesAction as Ii, SetOperationErrorTemplateInputSchema as Il, SkipMeaningValues as Im, Exact as In, DOCUMENT_ID_COLUMNS as Io, ResolverCoordinateDefinition as Ip, MutationSetModelNameArgs as Ir, RouteUser as Is, CreateDocument as It, documentModelOperationReducer as Iu, groupOperationsByScope as Iv, isDerivedDocumentId as Iy, PHReactorRenown as J, setModelId as J_, Set_Slug as Ja, DocumentActionSchema as Jc, InvalidActionInputZodError as Jd, EnumValueDefinition as Jf, CanonicalJsonError as Jg, assertValidGrantUpsert as Jh, SchemaSetPreferredEditorAction as Ji, Set_PreferredEditorSchema as Jl, baseReducerVersion as Jm, InputMaybe as Jn, IProcessorHostModuleBase as Jo, SubgraphEntryAccess as Jp, MutationSetOperationTemplateArgs as Jr, deletedDocumentId as Js, DeleteOperationAction as Jt, PurgeMarkerOperation as Ju, readOnly as Jv, OperationContext as Jy, PHPackageProvider as K, setModelDescription as K_, Set_Name as Ka, DeleteOperationInputSchema as Kc, HashMismatchError as Kd, EmptyLocalStateDefinition as Kf, ActionSignerIdentity as Kg, assertAuthAdministrationRetained as Kh, SchemaRedoAction as Ki, SetStateSchemaInputSchema as Kl, assertNever as Km, ISigner as Kn, IProcessor as Ko, SubgraphDefinition as Kp, MutationSetOperationReducerArgs as Kr, WebhookSpec as Ks, DeleteModuleAction as Kt, stateReducerOf as Ku, precedes as Kv, DocumentOperations as Ky, PHConnectRouterSettings as L, reorderModuleOperations as L_, SetOperationTemplateAction as La, AddStateExampleInputSchema as Lc, latestVersionOf as Ld, DefinitionRelatedLocation as Lf, moveGrant as Lg, AuthAdministrationLockoutError as Lh, ReorderStateExamplesInput as Li, SetOperationNameInputSchema as Ll, SynthesizedIdForm as Lm, FileInput as Ln, ExtractProcessorSchemaOrSelf as Lo, ScalarGraphQLProfile as Lp, MutationSetModuleDescriptionArgs as Lr, ScopedRouteHandle as Ls, CreateDocumentAction as Lt, documentModelReducer as Lu, hashDocumentStateForScope as Lv, isSignaturePolicy as Ly, PHConnectReactor as M, operationFromOperation as M_, SetOperationReducerInput as Ma, AddChangeLogItemInputSchema as Mc, UpgradeReducer as Md, DefinitionDiagnosticSeverity as Mf, evaluate as Mg, manifestRevision as Mh, ReorderOperationErrorsAction as Mi, SetOperationDescriptionInputSchema as Ml, ReducerContractValues as Mm, ENSInfo as Mn, createRelationalDb as Mo, NonEmptyStateDefinition as Mp, MutationSetInitialStateArgs as Mr, RouteMethod as Ms, CopyChildDocumentInput as Mt, documentModelHeaderReducer as Mu, filterDuplicatedOperations as Mv, SIGNATURE_PROTOCOL as My, PHConnectReactorFeatureFlags as N, operationWithContext as N_, SetOperationSchemaAction as Na, AddModuleInputSchema as Nc, UpgradeTransition as Nd, DefinitionExample as Nf, initializeAuth as Ng, mergePeerCapabilities as Nh, ReorderOperationErrorsInput as Ni, SetOperationErrorCodeInputSchema as Nl, ReplayHash as Nm, EditorDispatch as Nn, hashNamespace as No, ObjectTypeDefinition as Np, MutationSetModelDescriptionArgs as Nr, RouteOptions as Ns, CopyChildDocumentSignal as Nt, documentModelModuleReducer as Nu, garbageCollectDocumentOperations as Nv, SIGNATURE_PROTOCOL_V2 as Ny, PHConnectPwaIcon as O, moveOperation as O_, SetOperationErrorTemplateInput as Oa, synthesizedActionId as Oc, VersionedReducers as Od, DefinitionCheckSkipReason as Of, applySetGrantAction as Og, isOlderManifest as Oh, ReorderModuleOperationsAction as Oi, SetModuleDescriptionInputSchema as Ol, ProtocolRefusal as Om, DocumentModelVersioningAction as On, getCodegenStatusRegistry as Oo, LocationFreeGraphQLDocumentNode as Op, MutationReorderOperationExamplesArgs as Or, RouteAuthorizer as Os, Author as Ot, undoCapabilitiesOf as Ou, checkCleanedOperationsIntegrity as Ov, defaultPHState as Oy, PHConnectRemoteBackend as P, redo as P_, SetOperationSchemaInput as Pa, AddOperationErrorInputSchema as Pc, applyDeleteDocumentAction as Pd, DefinitionKind as Pf, isAuthAction as Pg, peerSupports as Ph, ReorderOperationExamplesAction as Pi, SetOperationErrorDescriptionInputSchema as Pl, ReplayHashValues as Pm, EditorModule as Pn, namespaceSchemaOf as Po, PackageScalarReferenceDefinition as Pp, MutationSetModelExtensionArgs as Pr, RouteSpec as Ps, CreateChildDocumentInput as Pt, documentModelOperationErrorReducer as Pu, garbageCollectV2 as Pv, SignaturePolicy$1 as Py, PHSchemedImage as Q, setName as Q_, SignalResults as Qa, ManifestSchema as Qc, SubmittedUndoRefusedError as Qd, GraphQLConstValueNode as Qf, actionSigningTarget as Qg, evaluateGrants as Qh, SetAuthorNameAction as Qi, UndoActionSchema as Ql, conflictWindowMovesEveryRow as Qm, LoadFromInput as Qn, ProcessorDeletePropagation as Qo, UnionTypeDefinition as Qp, MutationUpdateOperationExampleArgs as Qr, assertModuleIdUnique as Qs, DeleteOperationExampleInput as Qt, purgedProtocolVersions as Qu, reshuffleByTimestamp as Qv, redoOperation as Qy, PHConnectRuntimeConfig as R, reorderModules as R_, SetOperationTemplateInput as Ra, AuthorSchema as Rc, withProtocolVersions as Rd, DefinitionSource as Rf, removeGrant as Rg, AuthAdministrationMissingError as Rh, ReplayDocumentOptions as Ri, SetOperationReducerInputSchema as Rl, SynthesizedIdFormValues as Rm, GetDocumentOptions as Rn, HashAlgorithms as Ro, ScalarName as Rp, MutationSetModuleNameArgs as Rr, WebhookEndpointInfo as Rs, CreateDocumentActionInput as Rt, documentModelStateReducer as Ru, isNoopOperation as Rv, protocolVersionsFor as Ry, PHConnectLoader as S, deleteModule as S_, SetOperationErrorCodeInput as Sa, UNDO_GROUP_MARK as Sc, getFileBrowser as Sd, upgradeDocumentAction as Sf, SetGrantActionInput as Sg, ProtocolCapability as Sh, RejectedAction as Si, SetAuthorWebsiteInputSchema as Sl, CAPABILITY_DECISIONS as Sm, DocumentModelOperationExampleOperations as Sn, ValidationError as So, InputTypeDefinition as Sp, MutationMoveOperationArgs as Sr, IHttpScope as Ss, AddRelationshipAction as St, undoRedoTargetsOf as Su, addUndo as Sv, createState as Sy, PHConnectPwa as T, deleteOperationExample as T_, SetOperationErrorNameAction as Ta, groupedActionId as Tc, readFileBrowser as Td, CompiledErrorDefinition as Tf, applyInitializeAuthAction as Tg, capSelection as Th, RemoveRelationshipActionInput as Ti, SetModelExtensionInputSchema as Tl, FLAGS_FOR_EVERY_VERSION as Tm, DocumentModelStateAction as Tn, CodegenStatusRegistry as To, JsonPrimitive as Tp, MutationReorderModuleOperationsArgs as Tr, NodeRouteSpec as Ts, AddStateExampleInput as Tt, UndoRedoAvailability as Tu, assertReplayIndices as Tv, defaultDocumentState as Ty, PHImageRef as U, setAuthorName as U_, SetSlugActionInput as Ua, DeleteModuleInputSchema as Uc, DowngradeNotSupportedError as Ud, DocumentModelOperationDefinition as Uf, TransportSigner as Ug, MAX_CAPABILITY_OPERATIONS as Uh, SaveToFileHandle as Ui, SetPreferredEditorActionSchema as Ul, acceptsSubmittedRetract as Um, IOperation as Un, IRelationalQueryMethods as Uo, Sha256Digest as Up, MutationSetOperationErrorNameArgs as Ur, WebhookRequest as Us, DeleteChildDocumentSignal as Ut, processUndoRedo as Uu, merge as Uv, isDocumentAction as Uy, PHConnectSentry as V, reorderStateExamples as V_, SetPreferredEditorOperation as Va, ConfigEntryTypeSchema as Vc, AuthInitializerNotCreatorError as Vd, DocumentModelDefinition as Vf, TransportAction as Vg, InvalidGrantError as Vh, RevisionsFilter as Vi, SetOperationTemplateInputSchema as Vl, UndoModel as Vm, ID as Vn, IRelationalDbProcessor as Vo, ScalarValidationProfile as Vp, MutationSetOperationErrorCodeArgs as Vr, WebhookPolicy as Vs, DeleteChangeLogItemInput as Vt, baseReducer as Vu, mapSkippedOperations as Vv, v2RequiredProtocolVersions as Vy, PHKeyframeRule as W, setAuthorWebsite as W_, SetStateSchemaAction as Wa, DeleteOperationErrorInputSchema as Wc, FileSystemError as Wd, DocumentModelSpecificationDefinition as Wf, toTransportAction as Wg, MAX_CONDITION_DEPTH as Wh, Scalars as Wi, SetSlugActionInputSchema as Wl, acceptsSubmittedUndoRedo as Wm, ISignal as Wn, RelationalDbProcessor as Wo, StateDefinition as Wp, MutationSetOperationErrorTemplateArgs as Wr, WebhookScheme as Ws, DeleteDocumentAction as Wt, replayOperations as Wu, operationsAreEqual as Wv, nextSkipNumber as Wy, PHRenownRainbowAdapterConfig as X, setModuleDescription as X_, SignalDispatch as Xa, DocumentModelInputSchema as Xc, MissingStateReducerError as Xd, GraphQLArgumentNode as Xf, actionPreimageV2 as Xg, evaluateCondition as Xh, SchemaUndoAction as Xi, StateSchema as Xl, capabilitiesFor as Xm, IsStateOfType as Xn, ProcessorApp as Xo, SubgraphScalarReferenceDefinition as Xp, MutationUndoArgs as Xr, RESERVED_OPERATION_NAMES as Xs, DeleteOperationErrorInput as Xt, purgeDocumentAction as Xu, replayDocument as Xv, OperationWithContext$1 as Xy, PHRenownPrivyAdapterConfig as Y, setModelName as Y_, Signal as Ya, DocumentModelGlobalStateSchema as Yc, InvalidAuthVersionError as Yd, FieldDefinition as Yf, DOCUMENT_SCOPE_ACTION_TYPES as Yg, assertValidInitialGrants as Yh, SchemaSetSlugAction as Yi, Set_SlugSchema as Yl, baseReducerVersionsFor as Ym, IsDocumentOfType as Yn, IProcessorManager as Yo, SubgraphEntryDefinition as Yp, MutationSetStateSchemaArgs as Yr, OPERATION_NAME_PATTERN as Ys, DeleteOperationErrorAction as Yt, isPurgeMarker as Yu, removeExistingOperations as Yv, OperationOutcome as Yy, PHSchemedColor as Z, setModuleName as Z_, SignalResult as Za, DocumentSpecificationSchema as Zc, NoUndoRedoTargetError as Zd, GraphQLBuiltInScalarName as Zf, actionSignerIdentity as Zg, evaluateGrantStack as Zh, ScopeState as Zi, UndoActionInputSchema as Zl, capabilitiesOf as Zm, LoadFromFile as Zn, ProcessorApps as Zo, TypeReferenceDefinition as Zp, MutationUpdateChangeLogItemInputArgs as Zr, ReservedOperationName as Zs, DeleteOperationExampleAction as Zt, purgeMarkerOperation as Zu, requireStateReducer as Zv, operationOutcome as Zy, PHConnectDriveSections as _, baseActions as __, SetNameActionInput as _a, generateId as _c, createMinimalZip as _d, isDenied as _f, MoveGrantActionInputSchema as _g, PEER_CAPABILITIES as _h, Redo as _i, ReorderOperationExamplesInputSchema as _l, documentModelInitialGlobalState as _m, DocumentModelModuleOperations as _n, UpdateStateExampleAction as _o, GraphQLTypeNode as _p, MutationDeleteModuleArgs as _r, ProcessorTimingPath as _s, AddOperationErrorAction as _t, reduceOne as _u, IntegrityIssueSubType as _v, createAuthState as _y, PHBackground as a, Action as a_, SetModelDescriptionInput as aa, AppActionSigner as ab, findOperationOrThrow as ac, createPresignedHeader as ad, BaseDocumentStateSchema as af, AuthEvaluation as ag, optionalBaseReducerCapabilities as ah, PartialRecord as ai, PieceModulesSchema as al, getUnixTimestamp as am, DocumentDispatch$1 as an, StateReducer as ao, GraphQLInputValueDefinitionNode as ap, MinimalBackupData as ar, ProcessorPhase as as, ServiceActions as at, OnThrow as au, setOperationReducer as av, withSignaturePolicy as ay, PHConnectHome as b, createAction as b_, SetOperationDescriptionInput as ba, IdOrder as bc, documentModelSaveToFileHandle as bd, creationState as bf, RemoveGrantActionInputSchema as bg, PeerCapabilityFlags as bh, Reducer as bi, ScopeStateSchema as bl, BaseReducerCapabilities as bm, DocumentModelOperationErrorOperations as bn, UpgradeDocumentActionInput as bo, GraphQLUnionTypeDefinitionNode as bp, MutationDeleteOperationExampleArgs as br, TrackedProcessor as bs, AddOperationExampleInput as bt, retractionTarget as bu, PHDocumentHeader as bv, createGlobalState as by, PHConnectAi as c, actionFromAction as c_, SetModelIdAction as ca, Signature as cb, isValidOperationNameFormat as cc, createVerificationSigner as cd, DocumentModelSchema as cf, AuthSubject as cg, skipMayUndo as ch, PhAiToolAnnotations as ci, PublisherSchema as cl, CreateBaseReducerLogger as cm, DocumentModelDocumentModelModule as cn, UndoAction as co, GraphQLNameNode as cp, MoveOperationInput as cr, ProcessorRerunOptions as cs, ActionSignatureContext as ct, TailBase as cu, setOperationTemplate as cv, Condition as cy, PHConnectCollection as d, addChangeLogItem as d_, SetModelNameInput as da, serializeSignature as db, validateModuleOperation as dc, validateHeader as dd, isDocumentModelDocument as df, InitializeAuthAction as dg, usesRetractionRule as dh, PieceModule as di, RedoActionSchema as dl, HASH_ALGORITHM_SHA256 as dm, DocumentModelHeaderOperations as dn, UpdateChangeLogItemAction as do, GraphQLObjectFieldNode as dp, MutationAddModuleArgs as dr, ProcessorTimingBatch as ds, Actions as dt, advanceUndoTargets as du, setStateSchema as dv, PHAuthState as dy, hashActionV2 as e_, SetAuthorWebsiteAction as ea, setPreferredEditorOperation as eb, assertOperationExampleIdUnique as ec, NewDocumentHeaderOptions as ed, UnsupportedDocumentModelVersionError as ef, isPlainValue as eg, derivesByRule as eh, NOOPAction as ei, MoveOperationInputSchema as el, base58Decode as em, DeleteStateExampleAction as en, SignatureVerificationHandler as eo, GraphQLDirectiveNode as ep, MakeMaybe as er, ProcessorDispatchResult as es, ParsedCmdResult as et, UpdateChangeLogItemInputSchema as eu, setOperationErrorCode as ev, skipHeaderOperations as ey, PHConnectCompositionEntry as f, addModule as f_, SetModuleDescriptionAction as fa, DEFAULT_ANALYTICS_PROCESSOR_DB_NAME as fb, validateModules as fc, verify as fd, isDocumentModelState as ff, InitializeAuthActionInput as fg, DOCUMENT_PURGE_PROTOCOL as fh, PowerhouseModule as fi, RedoSchema as fl, HASH_ALGORITHM_SHA512 as fm, DocumentModelInput as fn, UpdateChangeLogItemInput as fo, GraphQLObjectTypeDefinitionNode as fp, MutationAddOperationArgs as fr, ProcessorTimingCounters as fs, AddChangeLogItemAction as ft, appliedOperations as fu, undo as fv, PHBaseState as fy, PHConnectDriveSection as g, addStateExample as g_, SetNameAction as ga, deriveOperationId as gc, baseSaveToFileHandle as gd, DOCUMENT_DELETED_REASON as gf, MoveGrantActionInput as gg, MARKER_REFUSAL_FEATURE as gh, Query as gi, ReorderOperationErrorsInputSchema as gl, documentModelGlobalState as gm, DocumentModelModuleAction as gn, UpdateRelationshipActionInput as go, GraphQLStringValueNode as gp, MutationDeleteChangeLogItemInputArgs as gr, ProcessorTimingLevel as gs, AddOperationAction as gt, redoTarget as gu, verifyOperationSignature as gv, backfillAuthState as gy, PHConnectDefaultDriveRemote as h, addOperationExample as h_, SetModuleNameInput as ha, validateStateSchemaName as hc, baseLoadFromInputVersioned as hd, AUTH_VERSION_UNSUPPORTED_REASON as hf, MoveGrantAction as hg, HoldReason as hh, PurgeDocumentActionInput as hi, ReorderModulesInputSchema as hl, documentModelFileExtension as hm, DocumentModelModule as hn, UpdateRelationshipAction as ho, GraphQLSchemaDefinitionNode as hp, MutationAddStateExampleArgs as hr, ProcessorTimingLastRun as hs, AddModuleInput as ht, positionalOperations as hu, updateStateExample as hv, Principal as hy, LogLevels as i, v2TupleProblem as i_, SetModelDescriptionAction as ia, ActionSigner as ib, findOperationExampleOrThrow as ic, createCopyHeader as id, BaseDocumentHeaderSchema as if, AuthDecision as ig, needsTaggedModel as ih, OperationsByScope as ii, PieceModuleSchema as il, bytesToBase64Url as im, DocumentAction as in, State as io, GraphQLInputObjectTypeDefinitionNode as ip, Maybe as ir, ProcessorHostInfo as is, ServiceAction as it, isDefinedNonNullAny as iu, setOperationName as iv, withScopeRevisions as iy, PHConnectPwaUrlPattern as j, operationFromAction as j_, SetOperationReducerAction as ja, undoRedoBatch as jc, UpgradeManifest as jd, DefinitionDiagnosticPhase as jf, decide as jg, localSupports as jh, ReorderModulesInput as ji, SetNameActionSchema as jl, ReducerContract as jm, DocumentSpecification as jn, createNamespacedQueryBuilder as jo, NamedTypeReferenceDefinition as jp, MutationSetAuthorWebsiteArgs as jr, RouteHandler as js, ConfigEntryType as jt, undoRedoAvailabilityOf as ju, filterDocumentOperationsResultingState as jv, ProtocolVersions as jy, PHConnectPwaManifest as k, noop as k_, SetOperationNameAction as ka, undoGroupOfId as kc, VersionedReplayConfig as kd, DefinitionCompatibilitySelection as kf, assertAuthPreservedOnDuplicate as kg, legacySupports as kh, ReorderModuleOperationsInput as ki, SetModuleNameInputSchema as kl, ProtocolSupport as km, DocumentModelVersioningOperations as kn, isSettledCodegenState as ko, MaterializedStateDefinition as kp, MutationReorderStateExamplesArgs as kr, RouteBody as ks, CodeExample as kt, undoNeedsTargets as ku, checkOperationsIntegrity as kv, DEFAULT_SIGNATURE_POLICY as ky, PHConnectApp as l, actionSigner as l_, SetModelIdInput as la, UserActionSigner as lb, validateInitialState as lc, hasDerivedDocumentId as ld, assertIsDocumentModelDocument as lf, AuthVerb as lg, sortsJobsCanonically as lh, PhAiToolContext as li, PwaConfigSchema as ll, fitCreateBaseReducer as lm, DocumentModelGlobalState as ln, UndoActionInput as lo, GraphQLNamedTypeNode as lp, Mutation as lr, ProcessorStatus as ls, ActionSigningHandler as lt, UndoTargetsBase as lu, setPreferredEditor as lv, Grant as ly, PHConnectDefaultDriveLocal as m, addOperationError as m_, SetModuleNameAction as ma, PROCESSOR_APPS as mb, validateOperations as mc, baseLoadFromInput as md, AUTH_NO_GRANT_REASON as mf, MAX_SUPPORTED_AUTH_VERSION as mg, FeatureCapability as mh, PurgeDocumentAction as mi, ReorderModuleOperationsInputSchema as ml, HASH_ENCODING_HEX as mm, DocumentModelLocalState as mn, UpdateOperationExampleInput as mo, GraphQLScalarTypeDefinitionNode as mp, MutationAddOperationExampleArgs as mr, ProcessorTimingHorizon as ms, AddModuleAction as mt, deriveScopeVersioned as mu, updateOperationExample as mv, PHGroupState as my, DrivePreserveStrategy as n, signActionV2 as n_, SetInitialStateAction as na, undoOperation as nb, findModuleOrThrow as nc, headNewDocument as nd, groupDocumentType as nf, AUTH_ACTION_TYPES as ng, isBaseReducerVersion as nh, OperationIndex as ni, OperationScopeSchema as nl, buildOperationSignatureMessage as nm, DeriveScope as nn, SkipHeaderOperationIndex as no, GraphQLEnumValueDefinitionNode as np, Manifest as nr, ProcessorFactoryBuilder as ns, PowerhouseConfig as nt, UpdateStateExampleInputSchema as nu, setOperationErrorName as nv, split as ny, PHBackgroundLayer as o, ActionContext as o_, SetModelExtensionAction as oa, HashConfig as ob, getAllOperationNames as oc, createSignedHeader as od, DocumentModelHeaderSchema as of, AuthRefusal as og, refusalFor as oh, PartialState as oi, PowerhouseModuleSchema as ol, hashBrowser as om, DocumentModelAction as on, SubgraphModule as oo, GraphQLInterfaceTypeDefinitionNode as op, ModuleSpecification as or, ProcessorQueueDepth as os, DEFAULT_REGISTRY_URL as ot, ReducerFor as ou, setOperationSchema as ov, AuthGroups as oy, PHConnectDefaultDrive as p, addOperation as p_, SetModuleDescriptionInput as pa, DEFAULT_RELATIONAL_PROCESSOR_DB_NAME as pb, validateOperationName as pc, BulkArchiveEntry as pd, AUTH_DENIED_BY_GRANT_REASON as pf, InitializeAuthActionInputSchema as pg, FLAGLESS_BASE_REDUCER_VERSION as ph, Publisher as pi, ReorderChangeLogItemsInputSchema as pl, HASH_ENCODING_BASE64 as pm, DocumentModelLib as pn, UpdateOperationExampleAction as po, GraphQLOperationTypeDefinitionNode as pp, MutationAddOperationErrorArgs as pr, ProcessorTimingDocumentType as ps, AddChangeLogItemInput as pt, deriveScope as pu, updateChangeLogItem as pv, PHDocumentState as py, PHReactorClientMode as q, setModelExtension as q_, Set_PreferredEditor as qa, DeleteStateExampleInputSchema as qc, InvalidActionInputError as qd, EnumTypeDefinition as qf, ActionSigningTarget as qg, assertValidGrant as qh, SchemaSetNameAction as qi, Set_NameSchema as ql, baseReducerCapabilities as qm, Incremental as qn, IProcessorDispatch as qo, SubgraphDefinitionBase as qp, MutationSetOperationSchemaArgs as qr, WebhookVerification as qs, DeleteModuleInput as qt, PURGE_DOCUMENT as qu, prepareOperations as qv, Operation as qy, LogLevel as r, targetDocumentId as r_, SetInitialStateInput as ra, undoOperationV2 as rb, findOperationErrorOrThrow as rc, selectDocumentModelModule as rd, groupMembershipActionTypes as rf, AuthAction as rg, modelRunsBaseReducer as rh, OperationSpecification as ri, OperationSpecificationSchema as rl, buildOperationSignatureParams as rm, DispatchOutcome as rn, SkipHeaderOperations as ro, GraphQLFieldDefinitionNode as rp, MappedOperation as rr, ProcessorFilter as rs, PowerhousePackage as rt, definedNonNullAnySchema as ru, setOperationErrorTemplate as rv, updateHeaderRevision as ry, PHBackgroundLayers as s, actionContext as s_, SetModelExtensionInput as sa, PHDocumentSignatureInfo as sb, isReservedOperationName as sc, createSignedHeaderForSigner as sd, DocumentModelPHStateSchema as sf, AuthRequest as sg, resolveBaseReducerVersion as sh, PhAiChatImage as si, PowerhouseModulesSchema as sl, hex2ab as sm, DocumentModelDocument as sn, Undo as so, GraphQLListTypeNode as sp, MoveOperationAction as sr, ProcessorRecord as ss, ActionErrorCallback as st, ScopeVersions as su, setOperationScope as sv, Capability as sy, DrivePreserveStrategies as t, isV2ActionHash as t_, SetAuthorWebsiteInput as ta, setSlugOperation as tb, assertOperationIdUnique as tc, createVersionsOf as td, documentModelDocumentType as tf, referencedGroupIds as tg, documentDerivesByRule as th, OperationErrorSpecification as ti, OperationErrorSchema as tl, base64UrlToBytes as tm, DeleteStateExampleInput as tn, SigningParameters as to, GraphQLEnumTypeDefinitionNode as tp, MakeOptional as tr, ProcessorFactory as ts, PathValidation as tt, UpdateOperationExampleInputSchema as tu, setOperationErrorDescription as tv, sortMappedOperations as ty, PHConnectBranding as u, actions as u_, SetModelNameAction as ua, deserializeSignature as ub, validateModule as uc, sign as ud, assertIsDocumentModelState as uf, ConditionContext as ug, tieOrderOf as uh, PhAiToolDescriptor as ui, RedoActionInputSchema as ul, HASH_ALGORITHM_SHA1 as um, DocumentModelHeaderAction as un, UndoRedoAction as uo, GraphQLNonNullTypeNode as up, MutationAddChangeLogItemInputArgs as ur, ProcessorTiming as us, ActionVerificationHandler as ut, actionReferences as uu, setSlug as uv, Operand as uy, PHConnectDrives as v, buildOperationSignature as v_, SetNameOperation as va, generateMock as vc, createZip as vd, createDocumentAction as vf, RemoveGrantAction as vg, PEER_MANIFEST_FORMAT as vh, RedoAction as vi, ReorderStateExamplesInputSchema as vl, documentModelInitialLocalState as vm, DocumentModelOperationAction as vn, UpdateStateExampleInput as vo, GraphQLTypeSystemDefinitionNode as vp, MutationDeleteOperationArgs as vr, ProcessorTimingRun as vs, AddOperationErrorInput as vt, retractedActionIds as vu, IntegrityIssueType as vv, createBaseState as vy, PHConnectPackages as w, deleteOperationError as w_, SetOperationErrorDescriptionInput as wa, compareCanonical as wc, parseBulkArchive as wd, CatalogScalarReferenceDefinition as wf, applyAuthAction as wg, Supports as wh, RemoveRelationshipAction as wi, SetModelDescriptionInputSchema as wl, DerivationModelValues as wm, DocumentModelPHState as wn, CodegenStatus as wo, InternalScalarName as wp, MutationReorderChangeLogItemsInputArgs as wr, IWebhookScope as ws, AddStateExampleAction as wt, undoTargetsBase as wu, appendWithoutApplying as wv, defaultBaseState as wy, PHConnectInstance as x, deleteChangeLogItem as x_, SetOperationErrorCodeAction as xa, LEGACY_UNDO_GROUP_PREFIX as xc, fetchFileBrowser as xd, documentFromCreation as xf, SetGrantAction as xg, PeerManifest as xh, ReducerOptions as xi, SetAuthorNameInputSchema as xl, BaseReducerVersion as xm, DocumentModelOperationExampleAction as xn, User as xo, InputFieldDefinition as xp, MutationDeleteStateExampleArgs as xr, AuthorizerResult as xs, AddOperationInput as xt, tailAppliesIncrementally as xu, PHDocumentMeta as xv, createLocalState as xy, PHConnectExplorerIcons as y, buildSignedAction as y_, SetOperationDescriptionAction as ya, CanonicalKey as yc, documentModelLoadFromInput as yd, creationActions as yf, RemoveGrantActionInput as yg, PeerCapability as yh, RedoActionInput as yi, RetractActionInputSchema as yl, BASE_REDUCER_VERSIONS as ym, DocumentModelOperationErrorAction as yn, UpgradeDocumentAction as yo, GraphQLTypeSystemExtensionNode as yp, MutationDeleteOperationErrorArgs as yr, ReplayStateMode as ys, AddOperationExampleAction as yt, retractionRewrites as yu, PHDocument$1 as yv, createDocumentState as yy, PHConnectRuntimeDefaultDrive as z, reorderOperationErrors as z_, SetPreferredEditorAction as za, CodeExampleSchema as zc, AuthActionNotAllowedError as zd, DefinitionSourceSet as zf, resolveSnapshotAuth as zg, GrantSchema as zh, RetractAction as zi, SetOperationSchemaInputSchema as zl, TieOrder as zm, HostedEditorProps as zn, IBaseRelationalDb as zo, ScalarRepresentation as zp, MutationSetNameArgs as zr, WebhookField as zs, CreateState as zt, documentModelStateSchemaReducer as zu, isUndo as zv, requestedSignaturePolicy as zy };
5709
5708
  export {};
5710
- //# sourceMappingURL=types-cIIv_Rsg.d.ts.map
5709
+ //# sourceMappingURL=types-CV2j3BvH.d.ts.map