@powerhousedao/reactor 6.2.2-dev.50 → 6.2.2-dev.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-worker-executor-CkuJGUlJ.js → build-worker-executor-NT9b3rNm.js} +2 -2
- package/dist/{build-worker-executor-CkuJGUlJ.js.map → build-worker-executor-NT9b3rNm.js.map} +1 -1
- package/dist/{drive-container-types-BoY5t12r.js → drive-container-types-RZa1wukO.js} +193 -167
- package/dist/drive-container-types-RZa1wukO.js.map +1 -0
- package/dist/entry.js +2 -2
- package/dist/index.d.ts +274 -101
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +135 -11
- package/dist/index.js.map +1 -1
- package/dist/projection-entry.js +2 -2
- package/dist/{worker-BCMw-hBw.js → worker-sw2vjrd3.js} +2 -2
- package/dist/{worker-BCMw-hBw.js.map → worker-sw2vjrd3.js.map} +1 -1
- package/package.json +4 -4
- package/dist/drive-container-types-BoY5t12r.js.map +0 -1
package/dist/entry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as instrumentPgPool } from "./drive-container-types-
|
|
1
|
+
import { o as instrumentPgPool } from "./drive-container-types-RZa1wukO.js";
|
|
2
2
|
import { n as errorToInfo, t as createForwardingLogger } from "./forwarding-logger-BBkMSxuJ.js";
|
|
3
|
-
import { n as defaultLoadFactory, t as buildWorkerExecutor } from "./build-worker-executor-
|
|
3
|
+
import { n as defaultLoadFactory, t as buildWorkerExecutor } from "./build-worker-executor-NT9b3rNm.js";
|
|
4
4
|
import { ConsoleLogger } from "document-model";
|
|
5
5
|
import { isMainThread, parentPort } from "node:worker_threads";
|
|
6
6
|
//#region src/executor/worker/run-worker.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1659,6 +1659,104 @@ interface IReactorSubscriptionManager {
|
|
|
1659
1659
|
onRelationshipChanged(callback: (parentId: string, childId: string, changeType: RelationshipChangeType) => void, search?: SearchFilter): () => void;
|
|
1660
1660
|
}
|
|
1661
1661
|
//#endregion
|
|
1662
|
+
//#region src/decision/types.d.ts
|
|
1663
|
+
/** One operation stream. */
|
|
1664
|
+
type StreamQuery = {
|
|
1665
|
+
documentId: string;
|
|
1666
|
+
branch: string;
|
|
1667
|
+
scope: string;
|
|
1668
|
+
};
|
|
1669
|
+
/**
|
|
1670
|
+
* What building a decision model reads a stream's state through.
|
|
1671
|
+
*
|
|
1672
|
+
* `IWriteCache` satisfies this and is what the write paths pass. The read path
|
|
1673
|
+
* cannot: the write cache is a write-side projection invalidated by the process
|
|
1674
|
+
* that runs the executor, so a reactor whose executors live in worker processes
|
|
1675
|
+
* holds state in its parent that no commit ever invalidates. A read there would
|
|
1676
|
+
* decide against a policy arbitrarily far behind the one the write paths
|
|
1677
|
+
* enforce. Reads therefore pass a reader backed by the read side.
|
|
1678
|
+
*/
|
|
1679
|
+
interface IStreamStateReader {
|
|
1680
|
+
getState(documentId: string, scope: string, branch: string, targetRevision?: number, signal?: AbortSignal): Promise<PHDocument>;
|
|
1681
|
+
}
|
|
1682
|
+
/** The document and branch a decision model is built for. */
|
|
1683
|
+
type DecisionTarget = {
|
|
1684
|
+
documentId: string;
|
|
1685
|
+
branch: string;
|
|
1686
|
+
};
|
|
1687
|
+
/**
|
|
1688
|
+
* What a decision's conditions may read beyond the projections: the executing
|
|
1689
|
+
* scope's own state and the attempted action's input. Populated only while
|
|
1690
|
+
* authConditions is on; otherwise both stay undefined and conditional grants
|
|
1691
|
+
* never apply.
|
|
1692
|
+
*/
|
|
1693
|
+
type DecisionContext = {
|
|
1694
|
+
scopeState: unknown;
|
|
1695
|
+
actionInput?: unknown;
|
|
1696
|
+
};
|
|
1697
|
+
/** A statically-queried stream's operations, named after its projection. */
|
|
1698
|
+
type StreamHistory = {
|
|
1699
|
+
name: string;
|
|
1700
|
+
operations: Operation[];
|
|
1701
|
+
};
|
|
1702
|
+
/**
|
|
1703
|
+
* A named stream whose value in the model is that scope's state from the
|
|
1704
|
+
* document rebuild the reactor already performs. A derived query may read
|
|
1705
|
+
* only statically-queried projections, so composition is one layer deep.
|
|
1706
|
+
*/
|
|
1707
|
+
type Projection<M> = {
|
|
1708
|
+
query: StreamQuery | ((model: Partial<M>) => StreamQuery[]);
|
|
1709
|
+
/**
|
|
1710
|
+
* For a derived projection, the streams it may read anywhere in an
|
|
1711
|
+
* evaluated range, derived from the statically-queried streams' operations
|
|
1712
|
+
* (including the operations under evaluation). A positional walk cannot use
|
|
1713
|
+
* `query`, because the folded state it depends on changes over the range;
|
|
1714
|
+
* this over-approximates by design, since a stream referenced at any
|
|
1715
|
+
* position stays readable when the earlier range is re-evaluated even if a
|
|
1716
|
+
* later operation removes the reference. Ignored on static projections.
|
|
1717
|
+
*/
|
|
1718
|
+
queryOverHistory?: (reads: StreamHistory[]) => StreamQuery[];
|
|
1719
|
+
/**
|
|
1720
|
+
* Action types in this stream that can change an evaluation. Reads of the stream
|
|
1721
|
+
* are filtered to these, so anything left out is invisible to a decision.
|
|
1722
|
+
*/
|
|
1723
|
+
decidingActions: string[]; /** Applies one of this stream's operations while deciding. */
|
|
1724
|
+
apply: (document: PHDocument, operation: Operation) => PHDocument;
|
|
1725
|
+
};
|
|
1726
|
+
/**
|
|
1727
|
+
* The outcome of evaluating one operation. A refusal carries the reason it is
|
|
1728
|
+
* recorded with, because a model has more than one way to refuse.
|
|
1729
|
+
*/
|
|
1730
|
+
type Evaluation = {
|
|
1731
|
+
decision: "allow";
|
|
1732
|
+
} | {
|
|
1733
|
+
decision: "deny";
|
|
1734
|
+
reason: string;
|
|
1735
|
+
};
|
|
1736
|
+
/** Projections plus a decision function over the built model. */
|
|
1737
|
+
type DecisionModel<M> = {
|
|
1738
|
+
projections: { [K in keyof M]: Projection<M> };
|
|
1739
|
+
/**
|
|
1740
|
+
* Present when decide reads the executing scope's state through the
|
|
1741
|
+
* decision context. A positional walk then folds the evaluated stream with
|
|
1742
|
+
* this, from its base state through every effective operation, so
|
|
1743
|
+
* conditions read the state as it stood at each operation's position
|
|
1744
|
+
* rather than at the head.
|
|
1745
|
+
*/
|
|
1746
|
+
foldEvaluatedScope?: (document: PHDocument, operation: Operation) => PHDocument;
|
|
1747
|
+
/**
|
|
1748
|
+
* Whether or not this model decides about operations in a given scope. That
|
|
1749
|
+
* is, a scope it reads is not necessarily one it evaluates, and vise-versa.
|
|
1750
|
+
*/
|
|
1751
|
+
evaluatesScope(scope: string): boolean;
|
|
1752
|
+
decide(model: M, subject: AuthSubject, request: AuthRequest, ctx: DecisionContext): Evaluation;
|
|
1753
|
+
};
|
|
1754
|
+
/** A built model plus the read-set condition recording what the build read. */
|
|
1755
|
+
type BuiltDecisionModel<M> = {
|
|
1756
|
+
model: M;
|
|
1757
|
+
appendCondition: AppendCondition;
|
|
1758
|
+
};
|
|
1759
|
+
//#endregion
|
|
1662
1760
|
//#region src/client/types.d.ts
|
|
1663
1761
|
/**
|
|
1664
1762
|
* Describes the types of document changes that can occur.
|
|
@@ -1766,6 +1864,33 @@ interface IDriveClient {
|
|
|
1766
1864
|
*/
|
|
1767
1865
|
listNodes(driveIdentifier: string, parentFolder?: string | null, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Node>>;
|
|
1768
1866
|
}
|
|
1867
|
+
/**
|
|
1868
|
+
* One operation an authorization preflight predicts a verdict for. The input is
|
|
1869
|
+
* what a conditional grant reads, so a candidate standing for a filled-in form
|
|
1870
|
+
* carries that form's input.
|
|
1871
|
+
*/
|
|
1872
|
+
type ActionCandidate = {
|
|
1873
|
+
scope: string;
|
|
1874
|
+
type: string;
|
|
1875
|
+
input?: unknown;
|
|
1876
|
+
};
|
|
1877
|
+
/**
|
|
1878
|
+
* The predicted verdicts for a set of candidates, in the order they were given,
|
|
1879
|
+
* with the aggregates a UI branches on.
|
|
1880
|
+
*
|
|
1881
|
+
* The aggregates are redundant -- a verdict is binary, so `allDenied` is
|
|
1882
|
+
* `!anyAllowed` and `anyDenied` is `!allAllowed` -- and all four are returned
|
|
1883
|
+
* so that a caller reads the one its question is phrased in rather than
|
|
1884
|
+
* negating another. Over no candidates every aggregate is false: nothing is
|
|
1885
|
+
* allowed and nothing is denied.
|
|
1886
|
+
*/
|
|
1887
|
+
type ActionEvaluations = {
|
|
1888
|
+
evaluations: Evaluation[];
|
|
1889
|
+
allAllowed: boolean;
|
|
1890
|
+
anyAllowed: boolean;
|
|
1891
|
+
allDenied: boolean;
|
|
1892
|
+
anyDenied: boolean;
|
|
1893
|
+
};
|
|
1769
1894
|
/**
|
|
1770
1895
|
* The ReactorClient interface that wraps lower-level APIs to provide
|
|
1771
1896
|
* a simpler interface for document operations.
|
|
@@ -1860,6 +1985,44 @@ interface IReactorClient {
|
|
|
1860
1985
|
* @returns List of documents matching criteria and pagination cursor
|
|
1861
1986
|
*/
|
|
1862
1987
|
find(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
1988
|
+
/**
|
|
1989
|
+
* Predicts whether the subject would be admitted to execute each of a set of
|
|
1990
|
+
* candidate operations, without submitting any of them. A UI asks this to
|
|
1991
|
+
* disable a control rather than offer an action that fails on submit.
|
|
1992
|
+
*
|
|
1993
|
+
* The answer is a prediction, not a promise. Three caveats hold:
|
|
1994
|
+
*
|
|
1995
|
+
* - Real admission compiles an append condition over everything it read and
|
|
1996
|
+
* the store enforces it at write time. A preflight reads no future, so a
|
|
1997
|
+
* policy change landing between this answer and the submit changes the
|
|
1998
|
+
* verdict. The submit path stays the only authority.
|
|
1999
|
+
* - The verdict is evaluated at the stream heads. It is therefore correct for
|
|
2000
|
+
* a candidate that will be stamped at or after every timestamp the
|
|
2001
|
+
* evaluation read, which is the normal case for a control the user is about
|
|
2002
|
+
* to click. A backdated submission is out of contract: the reactor decides
|
|
2003
|
+
* that one by position, against the policy as it stood there.
|
|
2004
|
+
* - A candidate whose input decides the verdict needs that input supplied.
|
|
2005
|
+
* With `authConditions` on, a conditional grant reads `action.input`, so
|
|
2006
|
+
* omitting the input predicts the denial an empty input would earn rather
|
|
2007
|
+
* than the verdict the filled-in form will get.
|
|
2008
|
+
*
|
|
2009
|
+
* Document-scope candidates are decided against the policy of the document
|
|
2010
|
+
* their input names, not the one passed here: delete and upgrade name it in
|
|
2011
|
+
* `input.documentId`, and the relationship actions in `input.sourceId`. This
|
|
2012
|
+
* follows the executor's own gate, which decides against the document
|
|
2013
|
+
* guarding the write. `CREATE_DOCUMENT` follows the gate's exemption: it runs
|
|
2014
|
+
* before its document exists, so the executor never decides it against a
|
|
2015
|
+
* policy and the preflight predicts allow.
|
|
2016
|
+
*
|
|
2017
|
+
* @param documentIdentifier - Document "id" or "slug" the candidates target
|
|
2018
|
+
* @param branch - Branch to evaluate against
|
|
2019
|
+
* @param candidates - Operations to predict a verdict for, each with the scope it would execute in
|
|
2020
|
+
* @param subject - Optional subject to decide for, defaulting to the client's own signer. A plain subject rather than a ViewFilter: the evaluation reads no view, so a filter's branch or scopes would be silently ignored here
|
|
2021
|
+
* @param signal - Optional abort signal to cancel the request
|
|
2022
|
+
* @returns One evaluation per candidate, in the order given, with the aggregates over them
|
|
2023
|
+
* @throws AuthEnforcementDisabledError if the reactor's authEnforcement flag is off, in which case it holds no decision model and the legacy host-table permission system cannot answer for one
|
|
2024
|
+
*/
|
|
2025
|
+
evaluateActions(documentIdentifier: string, branch: string, candidates: ActionCandidate[], subject?: AuthSubject, signal?: AbortSignal): Promise<ActionEvaluations>;
|
|
1863
2026
|
/**
|
|
1864
2027
|
* Creates a document and waits for completion
|
|
1865
2028
|
*
|
|
@@ -3220,104 +3383,6 @@ type ExecutorManagerStatus = {
|
|
|
3220
3383
|
totalJobsProcessed: number;
|
|
3221
3384
|
};
|
|
3222
3385
|
//#endregion
|
|
3223
|
-
//#region src/decision/types.d.ts
|
|
3224
|
-
/** One operation stream. */
|
|
3225
|
-
type StreamQuery = {
|
|
3226
|
-
documentId: string;
|
|
3227
|
-
branch: string;
|
|
3228
|
-
scope: string;
|
|
3229
|
-
};
|
|
3230
|
-
/**
|
|
3231
|
-
* What building a decision model reads a stream's state through.
|
|
3232
|
-
*
|
|
3233
|
-
* `IWriteCache` satisfies this and is what the write paths pass. The read path
|
|
3234
|
-
* cannot: the write cache is a write-side projection invalidated by the process
|
|
3235
|
-
* that runs the executor, so a reactor whose executors live in worker processes
|
|
3236
|
-
* holds state in its parent that no commit ever invalidates. A read there would
|
|
3237
|
-
* decide against a policy arbitrarily far behind the one the write paths
|
|
3238
|
-
* enforce. Reads therefore pass a reader backed by the read side.
|
|
3239
|
-
*/
|
|
3240
|
-
interface IStreamStateReader {
|
|
3241
|
-
getState(documentId: string, scope: string, branch: string, targetRevision?: number, signal?: AbortSignal): Promise<PHDocument>;
|
|
3242
|
-
}
|
|
3243
|
-
/** The document and branch a decision model is built for. */
|
|
3244
|
-
type DecisionTarget = {
|
|
3245
|
-
documentId: string;
|
|
3246
|
-
branch: string;
|
|
3247
|
-
};
|
|
3248
|
-
/**
|
|
3249
|
-
* What a decision's conditions may read beyond the projections: the executing
|
|
3250
|
-
* scope's own state and the attempted action's input. Populated only while
|
|
3251
|
-
* authConditions is on; otherwise both stay undefined and conditional grants
|
|
3252
|
-
* never apply.
|
|
3253
|
-
*/
|
|
3254
|
-
type DecisionContext = {
|
|
3255
|
-
scopeState: unknown;
|
|
3256
|
-
actionInput?: unknown;
|
|
3257
|
-
};
|
|
3258
|
-
/** A statically-queried stream's operations, named after its projection. */
|
|
3259
|
-
type StreamHistory = {
|
|
3260
|
-
name: string;
|
|
3261
|
-
operations: Operation[];
|
|
3262
|
-
};
|
|
3263
|
-
/**
|
|
3264
|
-
* A named stream whose value in the model is that scope's state from the
|
|
3265
|
-
* document rebuild the reactor already performs. A derived query may read
|
|
3266
|
-
* only statically-queried projections, so composition is one layer deep.
|
|
3267
|
-
*/
|
|
3268
|
-
type Projection<M> = {
|
|
3269
|
-
query: StreamQuery | ((model: Partial<M>) => StreamQuery[]);
|
|
3270
|
-
/**
|
|
3271
|
-
* For a derived projection, the streams it may read anywhere in an
|
|
3272
|
-
* evaluated range, derived from the statically-queried streams' operations
|
|
3273
|
-
* (including the operations under evaluation). A positional walk cannot use
|
|
3274
|
-
* `query`, because the folded state it depends on changes over the range;
|
|
3275
|
-
* this over-approximates by design, since a stream referenced at any
|
|
3276
|
-
* position stays readable when the earlier range is re-evaluated even if a
|
|
3277
|
-
* later operation removes the reference. Ignored on static projections.
|
|
3278
|
-
*/
|
|
3279
|
-
queryOverHistory?: (reads: StreamHistory[]) => StreamQuery[];
|
|
3280
|
-
/**
|
|
3281
|
-
* Action types in this stream that can change an evaluation. Reads of the stream
|
|
3282
|
-
* are filtered to these, so anything left out is invisible to a decision.
|
|
3283
|
-
*/
|
|
3284
|
-
decidingActions: string[]; /** Applies one of this stream's operations while deciding. */
|
|
3285
|
-
apply: (document: PHDocument, operation: Operation) => PHDocument;
|
|
3286
|
-
};
|
|
3287
|
-
/**
|
|
3288
|
-
* The outcome of evaluating one operation. A refusal carries the reason it is
|
|
3289
|
-
* recorded with, because a model has more than one way to refuse.
|
|
3290
|
-
*/
|
|
3291
|
-
type Evaluation = {
|
|
3292
|
-
decision: "allow";
|
|
3293
|
-
} | {
|
|
3294
|
-
decision: "deny";
|
|
3295
|
-
reason: string;
|
|
3296
|
-
};
|
|
3297
|
-
/** Projections plus a decision function over the built model. */
|
|
3298
|
-
type DecisionModel<M> = {
|
|
3299
|
-
projections: { [K in keyof M]: Projection<M> };
|
|
3300
|
-
/**
|
|
3301
|
-
* Present when decide reads the executing scope's state through the
|
|
3302
|
-
* decision context. A positional walk then folds the evaluated stream with
|
|
3303
|
-
* this, from its base state through every effective operation, so
|
|
3304
|
-
* conditions read the state as it stood at each operation's position
|
|
3305
|
-
* rather than at the head.
|
|
3306
|
-
*/
|
|
3307
|
-
foldEvaluatedScope?: (document: PHDocument, operation: Operation) => PHDocument;
|
|
3308
|
-
/**
|
|
3309
|
-
* Whether or not this model decides about operations in a given scope. That
|
|
3310
|
-
* is, a scope it reads is not necessarily one it evaluates, and vise-versa.
|
|
3311
|
-
*/
|
|
3312
|
-
evaluatesScope(scope: string): boolean;
|
|
3313
|
-
decide(model: M, subject: AuthSubject, request: AuthRequest, ctx: DecisionContext): Evaluation;
|
|
3314
|
-
};
|
|
3315
|
-
/** A built model plus the read-set condition recording what the build read. */
|
|
3316
|
-
type BuiltDecisionModel<M> = {
|
|
3317
|
-
model: M;
|
|
3318
|
-
appendCondition: AppendCondition;
|
|
3319
|
-
};
|
|
3320
|
-
//#endregion
|
|
3321
3386
|
//#region src/decision/document-decision-model.d.ts
|
|
3322
3387
|
/** What the document decision model reads: the target's document scope. */
|
|
3323
3388
|
type DocumentDecisionModel = {
|
|
@@ -3406,6 +3471,31 @@ declare function readDecisionModel(flags: ReactorFeatureFlags, registry: IDocume
|
|
|
3406
3471
|
declare class BareReadGate implements IReadGate {
|
|
3407
3472
|
scopePredicate(document: PHDocument, subject: AuthSubject): Promise<(scope: string) => boolean>;
|
|
3408
3473
|
}
|
|
3474
|
+
/**
|
|
3475
|
+
* Answers a stream read from the document already fetched, and anything else
|
|
3476
|
+
* through the read side.
|
|
3477
|
+
*
|
|
3478
|
+
* The seed is why routing reads through a decision model costs no extra I/O for
|
|
3479
|
+
* the document being read: its `document` and `auth` scopes are the two static
|
|
3480
|
+
* projections, and the caller has both in hand. Only a group stream the grant
|
|
3481
|
+
* list names is fetched.
|
|
3482
|
+
*/
|
|
3483
|
+
declare class SeededStateReader implements IStreamStateReader {
|
|
3484
|
+
private readonly documentView;
|
|
3485
|
+
private readonly seed;
|
|
3486
|
+
private readonly branch;
|
|
3487
|
+
constructor(documentView: IDocumentView, seed: PHDocument, branch: string);
|
|
3488
|
+
/**
|
|
3489
|
+
* A stream this replica does not hold has to reach buildDecisionModel as the
|
|
3490
|
+
* absence it recognises, or the whole read fails instead of leaving the group
|
|
3491
|
+
* out of the model, where its principal does not match and the policy fails
|
|
3492
|
+
* closed. The read side reports absence as a plain Error, so the absence is
|
|
3493
|
+
* confirmed rather than inferred from the message: a transient failure must
|
|
3494
|
+
* surface, not silently deny.
|
|
3495
|
+
*/
|
|
3496
|
+
getState(documentId: string, scope: string, branch: string, targetRevision?: number, signal?: AbortSignal): Promise<PHDocument>;
|
|
3497
|
+
private assertAbsent;
|
|
3498
|
+
}
|
|
3409
3499
|
/**
|
|
3410
3500
|
* Evaluates a read against the registered decision model, built at the stream
|
|
3411
3501
|
* heads. This is what makes `{ group }` principals and conditional grants apply
|
|
@@ -3499,6 +3589,21 @@ declare class ModelReadGate implements IReadGate {
|
|
|
3499
3589
|
}
|
|
3500
3590
|
//#endregion
|
|
3501
3591
|
//#region src/client/reactor-client.d.ts
|
|
3592
|
+
/**
|
|
3593
|
+
* What {@link IReactorClient.evaluateActions} decides against: the decision
|
|
3594
|
+
* model this reactor enforces, and the flags that selected it.
|
|
3595
|
+
*
|
|
3596
|
+
* Both, because neither alone is enough. The flags say which of the model's
|
|
3597
|
+
* inputs a decision may read, and the model itself cannot be derived from them
|
|
3598
|
+
* here: selecting one needs the document model registry, which a client does not
|
|
3599
|
+
* hold. Absent, this client answers no preflight at all -- which is the whole of
|
|
3600
|
+
* the non-coexistence guarantee, since a client built without a reactor holding
|
|
3601
|
+
* a decision model has nothing to answer from.
|
|
3602
|
+
*/
|
|
3603
|
+
type ActionEvaluationConfig = {
|
|
3604
|
+
model: RegisteredDecisionModel;
|
|
3605
|
+
flags: ReactorFeatureFlags;
|
|
3606
|
+
};
|
|
3502
3607
|
/**
|
|
3503
3608
|
* ReactorClient implementation that wraps lower-level APIs to provide
|
|
3504
3609
|
* a simpler interface for document operations.
|
|
@@ -3518,8 +3623,9 @@ declare class ReactorClient implements IReactorClient {
|
|
|
3518
3623
|
private documentIndexer;
|
|
3519
3624
|
private documentView;
|
|
3520
3625
|
private readGate;
|
|
3626
|
+
private actionEvaluation;
|
|
3521
3627
|
readonly drives: IDriveClient;
|
|
3522
|
-
constructor(logger: ILogger, reactor: IReactor, signer: ISigner, subscriptionManager: IReactorSubscriptionManager, jobAwaiter: IJobAwaiter, documentIndexer: IDocumentIndexer, documentView: IDocumentView, readGate?: IReadGate);
|
|
3628
|
+
constructor(logger: ILogger, reactor: IReactor, signer: ISigner, subscriptionManager: IReactorSubscriptionManager, jobAwaiter: IJobAwaiter, documentIndexer: IDocumentIndexer, documentView: IDocumentView, readGate?: IReadGate, actionEvaluation?: ActionEvaluationConfig);
|
|
3523
3629
|
private readSubject;
|
|
3524
3630
|
/**
|
|
3525
3631
|
* Which scopes of one document the subject may read. Resolved once per
|
|
@@ -3580,6 +3686,37 @@ declare class ReactorClient implements IReactorClient {
|
|
|
3580
3686
|
* Filters documents by criteria and returns a list of them
|
|
3581
3687
|
*/
|
|
3582
3688
|
find(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
3689
|
+
/**
|
|
3690
|
+
* Predicts the admission verdict for each candidate. See
|
|
3691
|
+
* {@link IReactorClient.evaluateActions} for the contract and its caveats.
|
|
3692
|
+
*
|
|
3693
|
+
* Read-only throughout, and never through the write cache: that cache is
|
|
3694
|
+
* invalidated by whichever process runs the executor, so a reactor running
|
|
3695
|
+
* its executors in worker processes would answer here from state no commit
|
|
3696
|
+
* ever invalidates.
|
|
3697
|
+
*/
|
|
3698
|
+
evaluateActions(documentIdentifier: string, branch: string, candidates: ActionCandidate[], subject?: AuthSubject, signal?: AbortSignal): Promise<ActionEvaluations>;
|
|
3699
|
+
/**
|
|
3700
|
+
* The decision model for one target document, built at its stream heads.
|
|
3701
|
+
*
|
|
3702
|
+
* The document is fetched unfiltered, because the policy is what decides:
|
|
3703
|
+
* reading it through the read gate would withhold the very scopes the
|
|
3704
|
+
* decision is about. A deleted document is served at its deletion boundary,
|
|
3705
|
+
* which is what lets the model refuse an execute against it -- authEnforcement
|
|
3706
|
+
* requires documentDecisions, so that read is available whenever this runs.
|
|
3707
|
+
*
|
|
3708
|
+
* Reading past the gate discloses nothing a submit does not. The `auth` and
|
|
3709
|
+
* `document` scopes are readable by every holder, so a verdict resting on the
|
|
3710
|
+
* policy alone is one the caller could compute unaided; and a verdict resting
|
|
3711
|
+
* on a conditional grant reads the executing scope's state exactly as
|
|
3712
|
+
* admission reads it, so the answer here is what submitting and being refused
|
|
3713
|
+
* would have revealed anyway.
|
|
3714
|
+
*
|
|
3715
|
+
* The append condition the build records is dropped. It guards a write, and
|
|
3716
|
+
* this makes none; reproducing it is also what the preflight cannot do, which
|
|
3717
|
+
* is why the answer is a prediction.
|
|
3718
|
+
*/
|
|
3719
|
+
private buildEvaluationTarget;
|
|
3583
3720
|
/**
|
|
3584
3721
|
* Creates a document and waits for completion
|
|
3585
3722
|
*/
|
|
@@ -5385,7 +5522,7 @@ declare class ReactorClientBuilder {
|
|
|
5385
5522
|
*/
|
|
5386
5523
|
withReadGate(readGate: IReadGate): this;
|
|
5387
5524
|
/**
|
|
5388
|
-
* The gate
|
|
5525
|
+
* The gate the resolved model calls for. Below authEnforcement there is no
|
|
5389
5526
|
* model to enforce -- the registered one ignores the auth scope -- so the
|
|
5390
5527
|
* policy is evaluated on its own, which is what reads did before the model
|
|
5391
5528
|
* existed. Group serving turns on with authGroups, because below it a
|
|
@@ -5393,6 +5530,20 @@ declare class ReactorClientBuilder {
|
|
|
5393
5530
|
* use.
|
|
5394
5531
|
*/
|
|
5395
5532
|
private resolveReadGate;
|
|
5533
|
+
/**
|
|
5534
|
+
* What the client answers an authorization preflight from, or undefined when
|
|
5535
|
+
* it answers none.
|
|
5536
|
+
*
|
|
5537
|
+
* Resolved from the same model reads enforce, so a preflight and a read can
|
|
5538
|
+
* never decide against different models. Undefined below authEnforcement, and
|
|
5539
|
+
* undefined on the `withReactor` path, where there are no flags and no
|
|
5540
|
+
* registry to select a model with -- a client with no model refuses the
|
|
5541
|
+
* preflight rather than answering it from the legacy host-side permission
|
|
5542
|
+
* tables. Deliberately not derived from the read gate: `withReadGate`
|
|
5543
|
+
* overrides that, so sniffing the gate's type would report enforcement from a
|
|
5544
|
+
* caller's substitution.
|
|
5545
|
+
*/
|
|
5546
|
+
private resolveActionEvaluation;
|
|
5396
5547
|
build(): Promise<ReactorClient>;
|
|
5397
5548
|
buildModule(): Promise<InProcessReactorClientModule>;
|
|
5398
5549
|
}
|
|
@@ -5465,6 +5616,28 @@ declare function parseDriveUrl(url: string): ParsedDriveUrl;
|
|
|
5465
5616
|
*/
|
|
5466
5617
|
declare function driveIdFromUrl(url: string): string;
|
|
5467
5618
|
//#endregion
|
|
5619
|
+
//#region src/shared/errors.d.ts
|
|
5620
|
+
/**
|
|
5621
|
+
* An authorization preflight was asked for while the reactor's decision model
|
|
5622
|
+
* is off, so there is no model to answer from.
|
|
5623
|
+
*
|
|
5624
|
+
* Thrown rather than answered from the legacy host-side permission tables. The
|
|
5625
|
+
* two systems do not compose: the tables record which addresses a host lets
|
|
5626
|
+
* near a drive, the policy records what a document's own grants permit, and an
|
|
5627
|
+
* answer stitched from both would report an admission verdict neither system
|
|
5628
|
+
* would reach. A caller that cannot get a prediction disables nothing, which
|
|
5629
|
+
* leaves the submit path -- and its real gate -- as the only authority.
|
|
5630
|
+
*
|
|
5631
|
+
* Detection is by `name`, not `instanceof`: the SharedWorker RPC boundary
|
|
5632
|
+
* rebuilds a thrown error from `{ name, message, stack, cause }` alone
|
|
5633
|
+
* (`reactor-browser/src/rpc/error-info.ts`), so the class identity and any
|
|
5634
|
+
* custom field are lost in transit. This error therefore carries no fields.
|
|
5635
|
+
*/
|
|
5636
|
+
declare class AuthEnforcementDisabledError extends Error {
|
|
5637
|
+
constructor();
|
|
5638
|
+
static isError(error: unknown): error is AuthEnforcementDisabledError;
|
|
5639
|
+
}
|
|
5640
|
+
//#endregion
|
|
5468
5641
|
//#region src/shared/factories.d.ts
|
|
5469
5642
|
/**
|
|
5470
5643
|
* Factory method to create a ShutdownStatus that can be updated
|
|
@@ -6523,5 +6696,5 @@ declare class ProcessorManager extends BaseReadModel implements IProcessorManage
|
|
|
6523
6696
|
private deleteProcessorCursors;
|
|
6524
6697
|
}
|
|
6525
6698
|
//#endregion
|
|
6526
|
-
export { ALWAYS_READABLE_SCOPES, APPEND_CONDITION_FAILED_PREFIX, type AbortMessage, type AdmissionDecision, type AppendCondition, AppendConditionFailedError, type AppendConditionStream, type AtomicTxn, type AttachmentHash, type AttachmentRef, type AuthDecisionModel, BareReadGate, BaseReadModel, type BatchExecutionRequest, type BatchExecutionResult, type BatchLoadRequest, type BatchLoadResult, type BuiltDecisionModel, type BuiltInReadModelKind, type CachedSnapshot, type ChannelConfig, ChannelError, ChannelErrorSource, type ChannelHealth, type ChannelMeta, ChannelScheme, type ConnectionState, type ConnectionStateChangeCallback, type ConnectionStateChangedEvent, type ConnectionStateSnapshot, type ConsistencyCoordinate, type ConsistencyKey, type ConsistencyToken, ConsistencyTracker, DEFAULT_DRIVE_CONTAINER_TYPES, DRIVE_AUTH_ERROR_MESSAGES, type Database, type DbConfig, type DeadLetterAddedEvent, type DecisionContext, type DecisionModel, type DecisionTarget, DefaultSubscriptionErrorHandler, type DocumentChangeEvent, DocumentChangeType, type DocumentDecisionModel, type DocumentGraphEdge, type DocumentIndexerDatabase, DocumentIntegrityService, DocumentModelRegistry, DocumentModelResolver, type DocumentModelSource, type DocumentModelSpec, type DocumentRelationship, type DocumentRevisions, type DocumentStreamKey, type DocumentViewDatabase, DriveClient, DriveCollectionId, DuplicateManifestError, DuplicateModuleError, DuplicateOperationError, type Evaluation, EventBus, EventBusAggregateError, type ExecuteMessage, type ExecutionJobPlan, type ExecutorStartedEvent, type ExecutorStoppedEvent, type FactorySpec, type FileModelSource, type GqlChannelConfig, GqlRequestChannel, GqlRequestChannelFactory, GqlResponseChannel, GqlResponseChannelFactory, type HeartbeatMessage, type IChannel, type IChannelFactory, type IConsistencyTracker, type IDocumentGraph, type IDocumentIndexer, type IDocumentIntegrityService, type IDocumentModelLoader, type IDocumentModelRegistry, type IDocumentModelResolver, type IDocumentView, type IDriveClient, type IEventBus, type IJobAwaiter, type IJobExecutor, type IJobExecutorManager, type IJobTracker, type IKeyframeStore, type ILiveReadModelCoordinator, type IMailbox, type IOperationIndex, type IOperationStore, type IPollTimer, type IProcessor, type IProcessorHostModule, type IProcessorManager, type IProjectionTransport, type IQueue, type IReactor, type IReactorClient, type IReactorSubscriptionManager, type IReadGate, type IReadModel, type IReadModelCoordinator, type IRelationalDb, type IStreamStateReader, type ISubscriptionErrorHandler, type ISyncCursorStorage, type ISyncManager, type ISyncRemoteStorage, type ISyncStatusTracker, type IWriteCache, SimpleJobExecutor as InMemoryJobExecutor, SimpleJobExecutor, InMemoryJobTracker, InMemoryQueue, type InProcessReactorClientModule, type InProcessReactorModule, type InProcessSyncModule, type InitMessage, type InsertableDocumentSnapshot, IntervalPollTimer, InvalidModuleError, type Job, type JobAvailableEvent, JobAwaiter, type JobCompletedEvent, type JobExecutorConfig, JobExecutorEventTypes, type JobExecutorFactory, type JobFailedEvent, type JobInfo, type JobPendingEvent, type JobReadReadyEvent, type JobResult, type JobRunningEvent, type JobStartedEvent, JobStatus, type JobWriteReadyEvent, type JobWriteReadyPayload, type JwtHandler, type KeyframeSnapshot, type KeyframeValidationIssue, KyselyDocumentIndexer, KyselyDocumentView, KyselyKeyframeStore, KyselyOperationStore, KyselySyncCursorStorage, KyselySyncRemoteStorage, KyselyWriteCache, type LoadJobPlan, type LoadModelMessage, type LogMessage, Mailbox, type MetricsMessage, type ModelLoadFailedMessage, type ModelLoadedEvent, type ModelLoadedMessage, type ModelManifestEntry, ModelReadGate, ModuleNotFoundError, type ModuleRef, NullDocumentModelResolver, type OperationBatch, type OperationContext, type OperationFilter, type OperationIndexEntry, type OperationTable, type OperationWithContext, OptimisticLockError, type OutOfOrderPair, type PackageModelSource, type PagedResults, type PagingOptions, type ParentMessage, type ParsedDriveUrl, type ParsedPaging, PollBehavior, PollingChannelError, type PoolInstrumentation, type PoolStats, type ProcessorApp, type ProcessorFactory, type ProcessorFactoryBuilder, type ProcessorFilter, ProcessorManager, type ProcessorRecord, type ProcessorStatus, type Projection, type ProjectionShardBuilderConfig, type ProjectionShardManagerConfig, type ProjectionWorkerFactory, PropagationMode, QueueEventTypes, REACTOR_SCHEMA, Reactor, ReactorBuilder, ReactorClient, ReactorClientBuilder, type ReactorClientModule, ReactorEventTypes, type ReactorFeatureFlags, type ReactorFeatures, type JobFailedEvent$1 as ReactorJobFailedEvent, type ReactorModule, ReactorSubscriptionManager, type ReadModelBatchCompletedEvent, ReadModelCoordinator, type ReadModelFactory, type ReadModelFactoryDeps, type ReadModelIndexedEvent, type ReadModelIndexingStage, type ReadModelRegistrationStage, type ReadModelStage, type ReadyMessage, type RebuildResult, type RegisteredDecisionModel, RelationalDbProcessor, RelationshipChangeType, type Remote, type RemoteCursor, type RemoteFilter, type RemoteMeta, type RemoteOptions, type RemoteRecord, type RemoteStatus, type ResultMessage, RetryAccounting, RevisionMismatchError, type SanitizedArg, type SearchFilter, type ShutdownMessage, type ShutdownStatus, type SignatureVerificationHandler, type SignatureVerifierSpec, type SignerConfig, SimpleJobExecutorManager, type SnapshotValidationIssue, type Database$1 as StorageDatabase, type StreamOrderIssue, type StreamQuery, type SubscriptionErrorContext, SyncBuilder, type SyncEnvelope, type SyncEnvelopeType, SyncEventTypes, type SyncFailedEvent, type SyncModule, SyncOperation, SyncOperationAggregateError, type SyncOperationErrorType, SyncOperationStatus, type SyncPendingEvent, SyncStatus, type SyncStatusChangeCallback, SyncStatusTracker, type SyncSucceededEvent, type TrackedProcessor, type Unsubscribe, type ValidationResult, type ViewFilter, type ErrorInfo as WorkerErrorInfo, type WorkerMessage, type WorkerPoolConfig, type WorkerPoolOptions, type WriteCacheConfig, addRelationshipAction, authDecisionModel, batchOperationsByDocument, buildDecisionModel, classifyJobFailure, consolidateSyncOperations, createDocumentAction, createForwardingLogger, createMutableShutdownStatus, createRelationalDb, decideAtHead, deleteDocumentAction, documentActions, documentDecisionModel, driveIdFromUrl, envelopesToSyncOperations, errorToInfo, firstOutOfOrderPair, getMigrationStatus, instrumentPgPool, isDriveAuthError, makeConsistencyKey, parseDriveUrl, parsePagingOptions, quarantinesDocument, readDecisionModel, removeRelationshipAction, runMigrations, sanitizeArg, selectDecisionModel, supportsLiveReadModelRegistration, syncOperationErrorType, trimMailboxFromAckOrdinal, updateRelationshipAction, upgradeDocumentAction, workerEntryPath };
|
|
6699
|
+
export { ALWAYS_READABLE_SCOPES, APPEND_CONDITION_FAILED_PREFIX, type AbortMessage, type ActionCandidate, type ActionEvaluationConfig, type ActionEvaluations, type AdmissionDecision, type AppendCondition, AppendConditionFailedError, type AppendConditionStream, type AtomicTxn, type AttachmentHash, type AttachmentRef, type AuthDecisionModel, AuthEnforcementDisabledError, BareReadGate, BaseReadModel, type BatchExecutionRequest, type BatchExecutionResult, type BatchLoadRequest, type BatchLoadResult, type BuiltDecisionModel, type BuiltInReadModelKind, type CachedSnapshot, type ChannelConfig, ChannelError, ChannelErrorSource, type ChannelHealth, type ChannelMeta, ChannelScheme, type ConnectionState, type ConnectionStateChangeCallback, type ConnectionStateChangedEvent, type ConnectionStateSnapshot, type ConsistencyCoordinate, type ConsistencyKey, type ConsistencyToken, ConsistencyTracker, DEFAULT_DRIVE_CONTAINER_TYPES, DRIVE_AUTH_ERROR_MESSAGES, type Database, type DbConfig, type DeadLetterAddedEvent, type DecisionContext, type DecisionModel, type DecisionTarget, DefaultSubscriptionErrorHandler, type DocumentChangeEvent, DocumentChangeType, type DocumentDecisionModel, type DocumentGraphEdge, type DocumentIndexerDatabase, DocumentIntegrityService, DocumentModelRegistry, DocumentModelResolver, type DocumentModelSource, type DocumentModelSpec, type DocumentRelationship, type DocumentRevisions, type DocumentStreamKey, type DocumentViewDatabase, DriveClient, DriveCollectionId, DuplicateManifestError, DuplicateModuleError, DuplicateOperationError, type Evaluation, EventBus, EventBusAggregateError, type ExecuteMessage, type ExecutionJobPlan, type ExecutorStartedEvent, type ExecutorStoppedEvent, type FactorySpec, type FileModelSource, type GqlChannelConfig, GqlRequestChannel, GqlRequestChannelFactory, GqlResponseChannel, GqlResponseChannelFactory, type HeartbeatMessage, type IChannel, type IChannelFactory, type IConsistencyTracker, type IDocumentGraph, type IDocumentIndexer, type IDocumentIntegrityService, type IDocumentModelLoader, type IDocumentModelRegistry, type IDocumentModelResolver, type IDocumentView, type IDriveClient, type IEventBus, type IJobAwaiter, type IJobExecutor, type IJobExecutorManager, type IJobTracker, type IKeyframeStore, type ILiveReadModelCoordinator, type IMailbox, type IOperationIndex, type IOperationStore, type IPollTimer, type IProcessor, type IProcessorHostModule, type IProcessorManager, type IProjectionTransport, type IQueue, type IReactor, type IReactorClient, type IReactorSubscriptionManager, type IReadGate, type IReadModel, type IReadModelCoordinator, type IRelationalDb, type IStreamStateReader, type ISubscriptionErrorHandler, type ISyncCursorStorage, type ISyncManager, type ISyncRemoteStorage, type ISyncStatusTracker, type IWriteCache, SimpleJobExecutor as InMemoryJobExecutor, SimpleJobExecutor, InMemoryJobTracker, InMemoryQueue, type InProcessReactorClientModule, type InProcessReactorModule, type InProcessSyncModule, type InitMessage, type InsertableDocumentSnapshot, IntervalPollTimer, InvalidModuleError, type Job, type JobAvailableEvent, JobAwaiter, type JobCompletedEvent, type JobExecutorConfig, JobExecutorEventTypes, type JobExecutorFactory, type JobFailedEvent, type JobInfo, type JobPendingEvent, type JobReadReadyEvent, type JobResult, type JobRunningEvent, type JobStartedEvent, JobStatus, type JobWriteReadyEvent, type JobWriteReadyPayload, type JwtHandler, type KeyframeSnapshot, type KeyframeValidationIssue, KyselyDocumentIndexer, KyselyDocumentView, KyselyKeyframeStore, KyselyOperationStore, KyselySyncCursorStorage, KyselySyncRemoteStorage, KyselyWriteCache, type LoadJobPlan, type LoadModelMessage, type LogMessage, Mailbox, type MetricsMessage, type ModelLoadFailedMessage, type ModelLoadedEvent, type ModelLoadedMessage, type ModelManifestEntry, ModelReadGate, ModuleNotFoundError, type ModuleRef, NullDocumentModelResolver, type OperationBatch, type OperationContext, type OperationFilter, type OperationIndexEntry, type OperationTable, type OperationWithContext, OptimisticLockError, type OutOfOrderPair, type PackageModelSource, type PagedResults, type PagingOptions, type ParentMessage, type ParsedDriveUrl, type ParsedPaging, PollBehavior, PollingChannelError, type PoolInstrumentation, type PoolStats, type ProcessorApp, type ProcessorFactory, type ProcessorFactoryBuilder, type ProcessorFilter, ProcessorManager, type ProcessorRecord, type ProcessorStatus, type Projection, type ProjectionShardBuilderConfig, type ProjectionShardManagerConfig, type ProjectionWorkerFactory, PropagationMode, QueueEventTypes, REACTOR_SCHEMA, Reactor, ReactorBuilder, ReactorClient, ReactorClientBuilder, type ReactorClientModule, ReactorEventTypes, type ReactorFeatureFlags, type ReactorFeatures, type JobFailedEvent$1 as ReactorJobFailedEvent, type ReactorModule, ReactorSubscriptionManager, type ReadModelBatchCompletedEvent, ReadModelCoordinator, type ReadModelFactory, type ReadModelFactoryDeps, type ReadModelIndexedEvent, type ReadModelIndexingStage, type ReadModelRegistrationStage, type ReadModelStage, type ReadyMessage, type RebuildResult, type RegisteredDecisionModel, RelationalDbProcessor, RelationshipChangeType, type Remote, type RemoteCursor, type RemoteFilter, type RemoteMeta, type RemoteOptions, type RemoteRecord, type RemoteStatus, type ResultMessage, RetryAccounting, RevisionMismatchError, type SanitizedArg, type SearchFilter, SeededStateReader, type ShutdownMessage, type ShutdownStatus, type SignatureVerificationHandler, type SignatureVerifierSpec, type SignerConfig, SimpleJobExecutorManager, type SnapshotValidationIssue, type Database$1 as StorageDatabase, type StreamOrderIssue, type StreamQuery, type SubscriptionErrorContext, SyncBuilder, type SyncEnvelope, type SyncEnvelopeType, SyncEventTypes, type SyncFailedEvent, type SyncModule, SyncOperation, SyncOperationAggregateError, type SyncOperationErrorType, SyncOperationStatus, type SyncPendingEvent, SyncStatus, type SyncStatusChangeCallback, SyncStatusTracker, type SyncSucceededEvent, type TrackedProcessor, type Unsubscribe, type ValidationResult, type ViewFilter, type ErrorInfo as WorkerErrorInfo, type WorkerMessage, type WorkerPoolConfig, type WorkerPoolOptions, type WriteCacheConfig, addRelationshipAction, authDecisionModel, batchOperationsByDocument, buildDecisionModel, classifyJobFailure, consolidateSyncOperations, createDocumentAction, createForwardingLogger, createMutableShutdownStatus, createRelationalDb, decideAtHead, deleteDocumentAction, documentActions, documentDecisionModel, driveIdFromUrl, envelopesToSyncOperations, errorToInfo, firstOutOfOrderPair, getMigrationStatus, instrumentPgPool, isDriveAuthError, makeConsistencyKey, parseDriveUrl, parsePagingOptions, quarantinesDocument, readDecisionModel, removeRelationshipAction, runMigrations, sanitizeArg, selectDecisionModel, supportsLiveReadModelRegistration, syncOperationErrorType, trimMailboxFromAckOrdinal, updateRelationshipAction, upgradeDocumentAction, workerEntryPath };
|
|
6527
6700
|
//# sourceMappingURL=index.d.ts.map
|