@memberjunction/core 6.2.0 → 6.3.0-edge.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generic/BaseEntitySaveQueue.d.ts +11 -0
- package/dist/generic/BaseEntitySaveQueue.d.ts.map +1 -1
- package/dist/generic/BaseEntitySaveQueue.js +17 -1
- package/dist/generic/BaseEntitySaveQueue.js.map +1 -1
- package/dist/generic/JSONType-interfaces/IEntityConfiguration.d.ts +94 -0
- package/dist/generic/JSONType-interfaces/IEntityConfiguration.d.ts.map +1 -1
- package/dist/generic/JSONType-interfaces/IEntitySubtypeSelectorConfig.d.ts +77 -4
- package/dist/generic/JSONType-interfaces/IEntitySubtypeSelectorConfig.d.ts.map +1 -1
- package/dist/generic/appCapabilityRegistry.d.ts +106 -0
- package/dist/generic/appCapabilityRegistry.d.ts.map +1 -0
- package/dist/generic/appCapabilityRegistry.js +212 -0
- package/dist/generic/appCapabilityRegistry.js.map +1 -0
- package/dist/generic/baseEngine.d.ts +108 -3
- package/dist/generic/baseEngine.d.ts.map +1 -1
- package/dist/generic/baseEngine.js +891 -122
- package/dist/generic/baseEngine.js.map +1 -1
- package/dist/generic/baseEngineRegistry.d.ts.map +1 -1
- package/dist/generic/baseEngineRegistry.js +8 -1
- package/dist/generic/baseEngineRegistry.js.map +1 -1
- package/dist/generic/baseEntity.d.ts +147 -3
- package/dist/generic/baseEntity.d.ts.map +1 -1
- package/dist/generic/baseEntity.js +1063 -25
- package/dist/generic/baseEntity.js.map +1 -1
- package/dist/generic/baseRemotableOperation.d.ts +15 -0
- package/dist/generic/baseRemotableOperation.d.ts.map +1 -1
- package/dist/generic/baseRemotableOperation.js +11 -0
- package/dist/generic/baseRemotableOperation.js.map +1 -1
- package/dist/generic/compositeKey.d.ts.map +1 -1
- package/dist/generic/compositeKey.js +3 -1
- package/dist/generic/compositeKey.js.map +1 -1
- package/dist/generic/crossEntityPolicyEngine.d.ts +172 -0
- package/dist/generic/crossEntityPolicyEngine.d.ts.map +1 -0
- package/dist/generic/crossEntityPolicyEngine.js +667 -0
- package/dist/generic/crossEntityPolicyEngine.js.map +1 -0
- package/dist/generic/dataHooks.d.ts +14 -1
- package/dist/generic/dataHooks.d.ts.map +1 -1
- package/dist/generic/dataHooks.js.map +1 -1
- package/dist/generic/databaseProviderBase.d.ts +37 -0
- package/dist/generic/databaseProviderBase.d.ts.map +1 -1
- package/dist/generic/databaseProviderBase.js +220 -24
- package/dist/generic/databaseProviderBase.js.map +1 -1
- package/dist/generic/documentNumberingEngine.d.ts +190 -0
- package/dist/generic/documentNumberingEngine.d.ts.map +1 -0
- package/dist/generic/documentNumberingEngine.js +739 -0
- package/dist/generic/documentNumberingEngine.js.map +1 -0
- package/dist/generic/entityInfo.d.ts +104 -3
- package/dist/generic/entityInfo.d.ts.map +1 -1
- package/dist/generic/entityInfo.js +326 -22
- package/dist/generic/entityInfo.js.map +1 -1
- package/dist/generic/entityLifecyclePolicy.d.ts +214 -0
- package/dist/generic/entityLifecyclePolicy.d.ts.map +1 -0
- package/dist/generic/entityLifecyclePolicy.js +708 -0
- package/dist/generic/entityLifecyclePolicy.js.map +1 -0
- package/dist/generic/entitySubtypeDriver.d.ts +49 -0
- package/dist/generic/entitySubtypeDriver.d.ts.map +1 -0
- package/dist/generic/entitySubtypeDriver.js +26 -0
- package/dist/generic/entitySubtypeDriver.js.map +1 -0
- package/dist/generic/fieldSecuritySQLGate.d.ts +17 -0
- package/dist/generic/fieldSecuritySQLGate.d.ts.map +1 -1
- package/dist/generic/fieldSecuritySQLGate.js +41 -1
- package/dist/generic/fieldSecuritySQLGate.js.map +1 -1
- package/dist/generic/filters/compositeFilter.d.ts +5 -1
- package/dist/generic/filters/compositeFilter.d.ts.map +1 -1
- package/dist/generic/filters/compositeFilter.js +127 -12
- package/dist/generic/filters/compositeFilter.js.map +1 -1
- package/dist/generic/filters/compositeFilterSQL.d.ts +121 -0
- package/dist/generic/filters/compositeFilterSQL.d.ts.map +1 -0
- package/dist/generic/filters/compositeFilterSQL.js +489 -0
- package/dist/generic/filters/compositeFilterSQL.js.map +1 -0
- package/dist/generic/filters/filter.types.d.ts +5 -2
- package/dist/generic/filters/filter.types.d.ts.map +1 -1
- package/dist/generic/filters/filter.types.js +4 -1
- package/dist/generic/filters/filter.types.js.map +1 -1
- package/dist/generic/filters/filterBuilder.d.ts +75 -0
- package/dist/generic/filters/filterBuilder.d.ts.map +1 -0
- package/dist/generic/filters/filterBuilder.js +104 -0
- package/dist/generic/filters/filterBuilder.js.map +1 -0
- package/dist/generic/filters/index.d.ts +2 -0
- package/dist/generic/filters/index.d.ts.map +1 -1
- package/dist/generic/filters/index.js +2 -0
- package/dist/generic/filters/index.js.map +1 -1
- package/dist/generic/interfaces.d.ts +74 -1
- package/dist/generic/interfaces.d.ts.map +1 -1
- package/dist/generic/interfaces.js +0 -1
- package/dist/generic/interfaces.js.map +1 -1
- package/dist/generic/localCacheManager.d.ts +46 -3
- package/dist/generic/localCacheManager.d.ts.map +1 -1
- package/dist/generic/localCacheManager.js +267 -45
- package/dist/generic/localCacheManager.js.map +1 -1
- package/dist/generic/metadata.d.ts +3 -1
- package/dist/generic/metadata.d.ts.map +1 -1
- package/dist/generic/metadata.js +25 -6
- package/dist/generic/metadata.js.map +1 -1
- package/dist/generic/providerBase.d.ts +212 -33
- package/dist/generic/providerBase.d.ts.map +1 -1
- package/dist/generic/providerBase.js +543 -117
- package/dist/generic/providerBase.js.map +1 -1
- package/dist/generic/queryInfo.d.ts +5 -0
- package/dist/generic/queryInfo.d.ts.map +1 -1
- package/dist/generic/queryInfo.js +5 -0
- package/dist/generic/queryInfo.js.map +1 -1
- package/dist/generic/queryInfoInterfaces.d.ts +5 -0
- package/dist/generic/queryInfoInterfaces.d.ts.map +1 -1
- package/dist/generic/remoteOperationDispatch.d.ts.map +1 -1
- package/dist/generic/remoteOperationDispatch.js +13 -1
- package/dist/generic/remoteOperationDispatch.js.map +1 -1
- package/dist/generic/saveEntityGraphOperation.d.ts +6 -0
- package/dist/generic/saveEntityGraphOperation.d.ts.map +1 -1
- package/dist/generic/saveEntityGraphOperation.js +8 -0
- package/dist/generic/saveEntityGraphOperation.js.map +1 -1
- package/dist/generic/transactionGroup.d.ts +25 -0
- package/dist/generic/transactionGroup.d.ts.map +1 -1
- package/dist/generic/transactionGroup.js +105 -0
- package/dist/generic/transactionGroup.js.map +1 -1
- package/dist/generic/typedQuery.d.ts +151 -0
- package/dist/generic/typedQuery.d.ts.map +1 -0
- package/dist/generic/typedQuery.js +286 -0
- package/dist/generic/typedQuery.js.map +1 -0
- package/dist/generic/util.d.ts.map +1 -1
- package/dist/generic/util.js +9 -3
- package/dist/generic/util.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/views/runView.d.ts +53 -0
- package/dist/views/runView.d.ts.map +1 -1
- package/dist/views/runView.js +134 -0
- package/dist/views/runView.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Declarative Entity Lifecycle Policy Engine — State Machines, Field-Freeze, and WriteAuthority.
|
|
3
|
+
*
|
|
4
|
+
* Centralizes entity lifecycle invariants across both client (`BaseEntity.Validate()`) and server
|
|
5
|
+
* (`BaseEntity._innerSave` / `_innerDelete`, `DatabaseProviderBase.Save` / `Delete`, `ResolverBase`):
|
|
6
|
+
*
|
|
7
|
+
* 1. **Declarative State Machine**: initial states on create, directed state transitions (with role gates,
|
|
8
|
+
* required-server-operation gates, required fields on enter, cleared fields on transition), and terminal states.
|
|
9
|
+
* 2. **Field-Freeze & Post-Create Immutability**: `immutableAfterCreateFields`, `editableFieldsByState`,
|
|
10
|
+
* `frozenFieldsByState` (keyed by stored pre-save state or `'*'`), and `fieldFreezeExemptOperations`.
|
|
11
|
+
* 3. **WriteAuthority (`'Standard' | 'AppendOnly' | 'ServerOperationOnly'`)**:
|
|
12
|
+
* - `'AppendOnly'` permits initial creation (`!entity.IsSaved`) and unconditionally refuses updates and deletes.
|
|
13
|
+
* - `'ServerOperationOnly'` blocks direct client CRUD (`ResolverBase`, `TransactionGroupResolver`,
|
|
14
|
+
* `EntityCRUDHandler`, `MJ.SaveEntityGraph`) and unscoped saves, succeeding only inside an authorized
|
|
15
|
+
* {@link ServerOperationScopeManager} frame (automatically established for domain `BaseRemotableOperation`
|
|
16
|
+
* executions where `GrantsServerWriteAuthority === true`).
|
|
17
|
+
*
|
|
18
|
+
* Policies may be authored declaratively in `EntityInfo.Settings` (`'LifecyclePolicy'`, `'StateMachinePolicy'`,
|
|
19
|
+
* `'WriteAuthorityPolicy'`), in `IEntityConfiguration.Lifecycle` (`MJ: Entities.Configuration`), or registered
|
|
20
|
+
* programmatically via {@link EntityLifecyclePolicyEngine.RegisterPolicy}.
|
|
21
|
+
*
|
|
22
|
+
* @module @memberjunction/core
|
|
23
|
+
*/
|
|
24
|
+
import { BaseSingleton, ValidationResult } from '@memberjunction/global';
|
|
25
|
+
import type { BaseEntity } from './baseEntity.js';
|
|
26
|
+
import type { EntityInfo } from './entityInfo.js';
|
|
27
|
+
import type { UserInfo } from './securityInfo.js';
|
|
28
|
+
export type WriteAuthorityMode = 'Standard' | 'AppendOnly' | 'ServerOperationOnly';
|
|
29
|
+
export type EntityWriteOperation = 'Create' | 'Update' | 'Delete';
|
|
30
|
+
export interface IStateTransitionRule {
|
|
31
|
+
/** Source state value, or `'*'` to match any non-terminal stored state. */
|
|
32
|
+
from: string | '*';
|
|
33
|
+
/** Target state value. */
|
|
34
|
+
to: string;
|
|
35
|
+
/** Optional role names or Role IDs permitted to perform this transition (matched against `UserInfo.UserRoles`). */
|
|
36
|
+
allowedRoles?: string[];
|
|
37
|
+
/** When true, this transition may only occur inside an active authorized {@link ServerOperationScopeFrame}. */
|
|
38
|
+
requireServerOperation?: boolean;
|
|
39
|
+
/** Specific server operation keys (e.g. `['Accounting.PostBatch']`) allowed to perform this transition. */
|
|
40
|
+
allowedOperations?: string[];
|
|
41
|
+
/** Entity fields that must be non-null and non-blank when entering `to`. */
|
|
42
|
+
requiredFieldsOnEnter?: string[];
|
|
43
|
+
/** Entity fields that must be null or empty string when taking this transition. */
|
|
44
|
+
clearedFieldsOnTransition?: string[];
|
|
45
|
+
/** Custom human-readable refusal message when this rule rejects a transition. */
|
|
46
|
+
errorMessage?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface IEntityStateMachinePolicy {
|
|
49
|
+
/** Exact field name on the entity holding the lifecycle status (e.g. `'Status'`). */
|
|
50
|
+
statusField: string;
|
|
51
|
+
/** Allowed status values when creating a new record (`!entity.IsSaved`). */
|
|
52
|
+
initialStates?: string[];
|
|
53
|
+
/** Directed transition edges. Keeping the same status (`prior === next`) is always treated as a non-transition. */
|
|
54
|
+
transitions: IStateTransitionRule[];
|
|
55
|
+
/** Terminal states: outbound transitions are blocked, and field edits / deletes are locked by default. */
|
|
56
|
+
terminalStates?: string[];
|
|
57
|
+
/** Default `true`: records stored in a terminal state freeze all non-virtual fields and refuse `Delete()`. */
|
|
58
|
+
freezeAllFieldsInTerminalStates?: boolean;
|
|
59
|
+
/** Fields that may be populated on `Create` (`!entity.IsSaved`) and never modified once saved. */
|
|
60
|
+
immutableAfterCreateFields?: string[];
|
|
61
|
+
/** Allow-list of fields editable while the record's stored (pre-save) state equals key `S`. */
|
|
62
|
+
editableFieldsByState?: Record<string, string[]>;
|
|
63
|
+
/** Deny-list of fields frozen while the record's stored (pre-save) state equals key `S` (or `'*'` for all states). */
|
|
64
|
+
frozenFieldsByState?: Record<string, string[]>;
|
|
65
|
+
/** If provided, `Delete()` is only permitted when the record's stored status is in this list. */
|
|
66
|
+
deletableInStates?: string[];
|
|
67
|
+
/** Stored statuses in which `Delete()` is explicitly forbidden. */
|
|
68
|
+
nonDeletableStates?: string[];
|
|
69
|
+
/** Server operation keys exempted from field-freeze checks (e.g. controlled server amendment operations). */
|
|
70
|
+
fieldFreezeExemptOperations?: string[];
|
|
71
|
+
}
|
|
72
|
+
export interface IEntityWriteAuthorityPolicy {
|
|
73
|
+
/** Default write authority mode across `Create`, `Update`, and `Delete`. */
|
|
74
|
+
mode: WriteAuthorityMode;
|
|
75
|
+
/** Optional per-operation override (e.g. `Create: 'Standard'`, `Update: 'ServerOperationOnly'`). */
|
|
76
|
+
perOperationMode?: Partial<Record<EntityWriteOperation, WriteAuthorityMode>>;
|
|
77
|
+
/** Optional allow-list of operation keys permitted to write when effective mode is `'ServerOperationOnly'`. */
|
|
78
|
+
allowedOperations?: string[];
|
|
79
|
+
/** Custom refusal message surfaced when a write is denied. */
|
|
80
|
+
errorMessage?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface IEntityLifecyclePolicy {
|
|
83
|
+
stateMachine?: IEntityStateMachinePolicy;
|
|
84
|
+
writeAuthority?: IEntityWriteAuthorityPolicy;
|
|
85
|
+
}
|
|
86
|
+
export declare const CLIENT_DIRECT_CRUD_BOUNDARY_KEY = "__MJ_CLIENT_DIRECT_CRUD__";
|
|
87
|
+
/**
|
|
88
|
+
* The frame {@link ServerOperationScopeManager.RunAsServerWork} enters. It names no entities and no
|
|
89
|
+
* policy allows its key, so it grants no write authority; it only ends the client CRUD boundary
|
|
90
|
+
* around it, so the work inside does not read as the client's own request.
|
|
91
|
+
*/
|
|
92
|
+
export declare const SERVER_WORK_OPERATION_KEY = "__MJ_SERVER_WORK__";
|
|
93
|
+
export declare const DOCUMENT_SEQUENCE_SQL_STORE_OPERATION_KEY = "__MJ_INTERNAL_DOCUMENT_SEQUENCE_SQL_STORE__";
|
|
94
|
+
export interface ServerOperationScopeFrame {
|
|
95
|
+
readonly operationKey: string;
|
|
96
|
+
readonly source: 'RemotableOperation' | 'ServerEngine' | 'ServerAction' | 'ClientCrudBoundary';
|
|
97
|
+
/** Optional entity names this scope covers. Pass `['*']` to cover all entities. */
|
|
98
|
+
readonly allowedEntities?: ReadonlyArray<string>;
|
|
99
|
+
/** Optional acting User ID bound to this scope frame. When set, must match the entity's acting user. */
|
|
100
|
+
readonly userId?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface IServerOperationScopeTracker {
|
|
103
|
+
readonly IsAsyncSafe?: boolean;
|
|
104
|
+
RunInScope<T>(frame: ServerOperationScopeFrame, fn: () => T): T;
|
|
105
|
+
RunWithoutAuthority?<T>(fn: () => T): T;
|
|
106
|
+
GetActiveFrames(): ReadonlyArray<ServerOperationScopeFrame>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Browser-safe default synchronous/single-chain stack tracker used when Node's `AsyncLocalStorage`
|
|
110
|
+
* tracker has not been installed (e.g. Angular browser runtime or lightweight MJCore unit tests).
|
|
111
|
+
* On Node servers, `@memberjunction/generic-database-provider` installs `NodeAsyncServerOperationScopeTracker`.
|
|
112
|
+
*/
|
|
113
|
+
export declare class StackServerOperationScopeTracker implements IServerOperationScopeTracker {
|
|
114
|
+
readonly IsAsyncSafe = false;
|
|
115
|
+
private readonly _stack;
|
|
116
|
+
RunInScope<T>(frame: ServerOperationScopeFrame, fn: () => T): T;
|
|
117
|
+
RunWithoutAuthority<T>(fn: () => T): T;
|
|
118
|
+
GetActiveFrames(): ReadonlyArray<ServerOperationScopeFrame>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Process-wide singleton managing active server operation authority frames.
|
|
122
|
+
* Domain `BaseRemotableOperation` executions (`GrantsServerWriteAuthority === true`) and trusted server
|
|
123
|
+
* engines wrap their mutations in {@link RunWithAuthority}, while client CRUD entry points (`ResolverBase`,
|
|
124
|
+
* `TransactionGroupResolver`, `EntityCRUDHandler`, `SaveEntityGraphOperation`) wrap theirs in
|
|
125
|
+
* {@link RunInClientCrudBoundary} so outer ambient authority can never leak into direct client CRUD.
|
|
126
|
+
*/
|
|
127
|
+
export declare class ServerOperationScopeManager extends BaseSingleton<ServerOperationScopeManager> {
|
|
128
|
+
private _tracker;
|
|
129
|
+
protected constructor();
|
|
130
|
+
static get Instance(): ServerOperationScopeManager;
|
|
131
|
+
SetTracker(tracker: IServerOperationScopeTracker): void;
|
|
132
|
+
GetTracker(): IServerOperationScopeTracker;
|
|
133
|
+
RunWithAuthority<T>(frame: ServerOperationScopeFrame, fn: () => T): T;
|
|
134
|
+
/**
|
|
135
|
+
* Marks `fn` as executing inside a direct client-originated CRUD boundary. Any outer server-operation
|
|
136
|
+
* authority frame above this boundary is masked until a nested domain {@link RunWithAuthority} is entered.
|
|
137
|
+
*/
|
|
138
|
+
RunInClientCrudBoundary<T>(fn: () => T): T;
|
|
139
|
+
/**
|
|
140
|
+
* Executes `fn` with all outer authority frames cleared/masked (using `AsyncLocalStorage.run([], fn)`
|
|
141
|
+
* when `NodeAsyncServerOperationScopeTracker` is installed).
|
|
142
|
+
*/
|
|
143
|
+
RunWithoutAuthority<T>(fn: () => T): T;
|
|
144
|
+
/**
|
|
145
|
+
* Returns the effective active authority frames since the innermost {@link RunInClientCrudBoundary}
|
|
146
|
+
* (if any). Frames outside a client CRUD boundary are masked.
|
|
147
|
+
*/
|
|
148
|
+
GetEffectiveAuthorityFrames(): ReadonlyArray<ServerOperationScopeFrame>;
|
|
149
|
+
/**
|
|
150
|
+
* Whether the code running now is a client's own CRUD request: inside a {@link RunInClientCrudBoundary}
|
|
151
|
+
* with no frame entered since, neither server authority nor {@link RunAsServerWork}. A save made here
|
|
152
|
+
* is the requesting user's own act; any other save is server code acting as that user.
|
|
153
|
+
*/
|
|
154
|
+
IsInDirectClientCrud(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Runs `fn` as server work: when called inside a client's own CRUD request ({@link IsInDirectClientCrud}),
|
|
157
|
+
* `fn` runs under a frame that grants nothing ({@link SERVER_WORK_OPERATION_KEY}), so saves it makes,
|
|
158
|
+
* and work it starts and leaves running, never read as the client's own. Agent runs and the task-graph
|
|
159
|
+
* dispatcher's passes run this way: the async scope follows them out of the request that started them.
|
|
160
|
+
* Elsewhere `fn` runs as is.
|
|
161
|
+
*/
|
|
162
|
+
RunAsServerWork<T>(fn: () => T): T;
|
|
163
|
+
IsOperationActive(allowedOperations?: ReadonlyArray<string>, entityName?: string, actingUser?: UserInfo): boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Evaluates declarative and programmatic entity lifecycle policies (state machines, field-freeze rules,
|
|
167
|
+
* post-create immutability, and `WriteAuthority` gates).
|
|
168
|
+
*/
|
|
169
|
+
export declare class EntityLifecyclePolicyEngine extends BaseSingleton<EntityLifecyclePolicyEngine> {
|
|
170
|
+
static readonly LIFECYCLE_SETTING_NAME = "LifecyclePolicy";
|
|
171
|
+
static readonly STATE_MACHINE_SETTING_NAME = "StateMachinePolicy";
|
|
172
|
+
static readonly WRITE_AUTHORITY_SETTING_NAME = "WriteAuthorityPolicy";
|
|
173
|
+
static readonly DOCUMENT_SEQUENCE_COUNTERS_ENTITY_NAME = "MJ: Document Sequence Counters";
|
|
174
|
+
private readonly _programmaticPolicies;
|
|
175
|
+
private readonly _metadataCache;
|
|
176
|
+
protected constructor();
|
|
177
|
+
static get Instance(): EntityLifecyclePolicyEngine;
|
|
178
|
+
RegisterPolicy(entityName: string, policy: IEntityLifecyclePolicy): void;
|
|
179
|
+
UnregisterPolicy(entityName: string): void;
|
|
180
|
+
ClearProgrammaticPolicies(): void;
|
|
181
|
+
private seedBuiltInPolicies;
|
|
182
|
+
ResolvePolicy(entityInfo: EntityInfo | null | undefined): IEntityLifecyclePolicy | null;
|
|
183
|
+
/**
|
|
184
|
+
* Whether `ResolverBase.UpdateRecord` MUST load the authoritative stored row from the database
|
|
185
|
+
* rather than hydrating from client-supplied `OldValues___` (preventing status/frozen-field spoofing
|
|
186
|
+
* on entities where `TrackRecordChanges === false`).
|
|
187
|
+
*/
|
|
188
|
+
RequiresStoredTruthOnUpdate(entityInfo: EntityInfo | null | undefined): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Checks coarse write-authority and delete-state gates before saving or deleting `entity`.
|
|
191
|
+
* Returns `null` when permitted, or a human-readable refusal message when denied.
|
|
192
|
+
*/
|
|
193
|
+
CheckWritePermissionGate(entity: BaseEntity, operation: EntityWriteOperation, user: UserInfo | undefined, isServerProvider: boolean): string | null;
|
|
194
|
+
/**
|
|
195
|
+
* Evaluates synchronous lifecycle invariants (append-only update guard, initial state on create,
|
|
196
|
+
* state transitions, role/operation transition gates, post-create field immutability, and per-state
|
|
197
|
+
* field-freeze rules) and appends any violations to `result`.
|
|
198
|
+
*/
|
|
199
|
+
ValidateLifecycleOnEntity(entity: BaseEntity, user: UserInfo | undefined, result: ValidationResult): void;
|
|
200
|
+
private validateStateTransition;
|
|
201
|
+
private evaluateTransitionRuleGuards;
|
|
202
|
+
private validateFieldFreezeForState;
|
|
203
|
+
private isUserMutatedDataField;
|
|
204
|
+
private resolveWriteAuthorityMode;
|
|
205
|
+
private resolveMetadataPolicy;
|
|
206
|
+
private normalizeStateMachinePolicy;
|
|
207
|
+
private normalizeWriteAuthorityPolicy;
|
|
208
|
+
private userHasAnyRole;
|
|
209
|
+
private stringifyStatusValue;
|
|
210
|
+
private valuesEqual;
|
|
211
|
+
private toDiagnosticScalar;
|
|
212
|
+
private failValidation;
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=entityLifecyclePolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityLifecyclePolicy.d.ts","sourceRoot":"","sources":["../../src/generic/entityLifecyclePolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACH,aAAa,EAMb,gBAAgB,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,YAAY,GAAG,qBAA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