@cullet/erp-core 1.1.0 → 1.3.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/KIT_CONTEXT.md +1 -67
- package/dist/app-error.d.cts +108 -0
- package/dist/application/index.cjs +26 -0
- package/dist/application/index.d.cts +2 -0
- package/dist/application/index.d.ts +1 -1
- package/dist/application/index.js +2 -1
- package/dist/domain/index.cjs +16 -0
- package/dist/domain/index.d.cts +3 -0
- package/dist/domain/index.d.ts +3 -0
- package/dist/domain/index.js +3 -0
- package/dist/domain-event-contracts.cjs +33 -0
- package/dist/domain-event-contracts.cjs.map +1 -0
- package/dist/domain-event-contracts.d.cts +27 -0
- package/dist/domain-event-contracts.d.ts +27 -0
- package/dist/domain-event-contracts.js +22 -0
- package/dist/domain-event-contracts.js.map +1 -0
- package/dist/domain-exception.cjs +17 -0
- package/dist/domain-exception.cjs.map +1 -0
- package/dist/domain-exception.d.cts +7 -0
- package/dist/domain-exception.d.ts +7 -0
- package/dist/domain-exception.js +12 -0
- package/dist/domain-exception.js.map +1 -0
- package/dist/errors/index.cjs +41 -0
- package/dist/errors/index.d.cts +3 -0
- package/dist/errors/index.js +1 -1
- package/dist/exceptions/index.cjs +17 -0
- package/dist/exceptions/index.d.cts +5 -0
- package/dist/exceptions/index.d.ts +5 -0
- package/dist/exceptions/index.js +7 -0
- package/dist/exceptions/validation-field.cjs +3 -0
- package/dist/exceptions/validation-field.d.cts +2 -0
- package/dist/gate-engine-registry.cjs +308 -0
- package/dist/gate-engine-registry.cjs.map +1 -0
- package/dist/gate-engine-registry.d.cts +81 -0
- package/dist/gate-engine-registry.d.ts +2 -1
- package/dist/gate-engine-registry.js +2 -1
- package/dist/gate-engine-registry.js.map +1 -1
- package/dist/gate-types.d.cts +171 -0
- package/dist/gate-types.d.ts +3 -139
- package/dist/gate-v1-payload.schema.cjs +638 -0
- package/dist/gate-v1-payload.schema.cjs.map +1 -0
- package/dist/gate-v1-payload.schema.js +2 -116
- package/dist/gate-v1-payload.schema.js.map +1 -1
- package/dist/hashing.cjs +66 -0
- package/dist/hashing.cjs.map +1 -0
- package/dist/immutable.cjs +77 -0
- package/dist/immutable.cjs.map +1 -0
- package/dist/immutable.d.cts +6 -0
- package/dist/immutable.d.ts +6 -0
- package/dist/immutable.js +54 -0
- package/dist/immutable.js.map +1 -0
- package/dist/index.cjs +163 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +30 -0
- package/dist/index.d.ts +15 -160
- package/dist/index.js +19 -176
- package/dist/index.js.map +1 -1
- package/dist/invalid-state-transition-exception.cjs +47 -0
- package/dist/invalid-state-transition-exception.cjs.map +1 -0
- package/dist/invalid-state-transition-exception.js +30 -0
- package/dist/invalid-state-transition-exception.js.map +1 -0
- package/dist/invariant-violation-exception.cjs +16 -0
- package/dist/invariant-violation-exception.cjs.map +1 -0
- package/dist/invariant-violation-exception.js +11 -0
- package/dist/invariant-violation-exception.js.map +1 -0
- package/dist/not-found-error.cjs +65 -0
- package/dist/not-found-error.cjs.map +1 -0
- package/dist/not-found-error.js +1 -1
- package/dist/outcome.cjs +97 -0
- package/dist/outcome.cjs.map +1 -0
- package/dist/outcome.d.cts +140 -0
- package/dist/outcome.d.ts +140 -0
- package/dist/outcome.js +1 -1
- package/dist/parse-gate-payload.d.cts +62 -0
- package/dist/parse-gate-payload.d.ts +2 -1
- package/dist/path.d.cts +90 -0
- package/dist/path.d.ts +2 -1
- package/dist/plugin.cjs +79 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +85 -0
- package/dist/plugin.d.ts +85 -0
- package/dist/plugin.js +74 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/index.cjs +3 -0
- package/dist/plugins/index.d.cts +2 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +2 -0
- package/dist/policies/engines/index.cjs +10 -0
- package/dist/policies/engines/index.d.cts +4 -0
- package/dist/policies/engines/index.d.ts +1 -1
- package/dist/policies/engines/v1/gate/index.cjs +91 -0
- package/dist/policies/engines/v1/gate/index.cjs.map +1 -0
- package/dist/policies/engines/v1/gate/index.d.cts +121 -0
- package/dist/policies/engines/v1/gate/index.d.ts +2 -1
- package/dist/policies/engines/v1/gate/index.js +2 -1
- package/dist/policies/engines/v1/gate/index.js.map +1 -1
- package/dist/policies/index.cjs +41 -0
- package/dist/policies/index.d.cts +7 -0
- package/dist/policies/index.d.ts +2 -1
- package/dist/policies/index.js +2 -1
- package/dist/policy-service.cjs +1190 -0
- package/dist/policy-service.cjs.map +1 -0
- package/dist/policy-service.d.cts +559 -0
- package/dist/policy-service.d.ts +2 -1
- package/dist/policy-service.js +6 -3
- package/dist/policy-service.js.map +1 -1
- package/dist/result/index.cjs +7 -0
- package/dist/result/index.d.cts +2 -0
- package/dist/result/index.d.ts +2 -0
- package/dist/result/index.js +3 -0
- package/dist/result.cjs +135 -0
- package/dist/result.cjs.map +1 -0
- package/dist/result.js +118 -0
- package/dist/result.js.map +1 -0
- package/dist/ruleset-registry.cjs +47 -0
- package/dist/ruleset-registry.cjs.map +1 -0
- package/dist/ruleset-registry.js +42 -0
- package/dist/ruleset-registry.js.map +1 -0
- package/dist/rulesets/index.cjs +3 -0
- package/dist/rulesets/index.d.cts +2 -0
- package/dist/rulesets/index.d.ts +2 -0
- package/dist/rulesets/index.js +2 -0
- package/dist/temporal-guards.cjs +32 -0
- package/dist/temporal-guards.cjs.map +1 -0
- package/dist/temporal-guards.js +2 -17
- package/dist/temporal-guards.js.map +1 -1
- package/dist/temporal-use-case.cjs +191 -0
- package/dist/temporal-use-case.cjs.map +1 -0
- package/dist/temporal-use-case.d.cts +304 -0
- package/dist/temporal-use-case.d.ts +4 -9
- package/dist/temporal-use-case.js +6 -140
- package/dist/temporal-use-case.js.map +1 -1
- package/dist/unexpected-error.cjs +208 -0
- package/dist/unexpected-error.cjs.map +1 -0
- package/dist/unexpected-error.js +179 -0
- package/dist/unexpected-error.js.map +1 -0
- package/dist/use-case.cjs +96 -0
- package/dist/use-case.cjs.map +1 -0
- package/dist/use-case.js +91 -0
- package/dist/use-case.js.map +1 -0
- package/dist/uuid-identifier.cjs +65 -0
- package/dist/uuid-identifier.cjs.map +1 -0
- package/dist/uuid-identifier.d.cts +230 -0
- package/dist/uuid-identifier.d.ts +230 -0
- package/dist/uuid-identifier.js +60 -0
- package/dist/uuid-identifier.js.map +1 -0
- package/dist/validation-code.cjs +60 -0
- package/dist/validation-code.cjs.map +1 -0
- package/dist/validation-code.d.cts +23 -0
- package/dist/validation-code.d.ts +23 -0
- package/dist/validation-code.js +1 -177
- package/dist/validation-code.js.map +1 -1
- package/dist/validation-error.cjs +1020 -0
- package/dist/validation-error.cjs.map +1 -0
- package/dist/validation-error.d.cts +777 -0
- package/dist/validation-error.d.ts +1 -21
- package/dist/validation-error.js +1 -1
- package/dist/validation-exception.cjs +41 -0
- package/dist/validation-exception.cjs.map +1 -0
- package/dist/validation-exception.d.cts +50 -0
- package/dist/validation-exception.d.ts +50 -0
- package/dist/validation-exception.js +8 -2
- package/dist/validation-exception.js.map +1 -1
- package/dist/validation-field.cjs +28 -0
- package/dist/validation-field.cjs.map +1 -0
- package/dist/validation-field.d.cts +12 -0
- package/dist/value-object-ruleset.contracts.d.cts +36 -0
- package/dist/value-object-ruleset.contracts.d.ts +36 -0
- package/dist/value-object.cjs +208 -0
- package/dist/value-object.cjs.map +1 -0
- package/dist/value-object.js +191 -0
- package/dist/value-object.js.map +1 -0
- package/dist/version.d.cts +10 -0
- package/dist/version.d.ts +10 -0
- package/dist/versioning/index.cjs +7 -0
- package/dist/versioning/index.d.cts +3 -0
- package/dist/versioning/index.d.ts +3 -0
- package/dist/versioning/index.js +3 -0
- package/meta.json +18 -3
- package/package.json +165 -17
- package/src/core/domain/rulesets/index.ts +7 -0
- package/src/core/domain/uuid-identifier.ts +72 -0
- package/src/core/domain/value-object.ts +37 -5
- package/src/core/exceptions/index.ts +13 -0
- package/src/core/index.ts +14 -2
- package/src/core/plugins/index.ts +7 -0
- package/src/core/plugins/plugin.ts +99 -0
- package/src/core/plugins/types.ts +53 -0
- package/src/core/versioning/index.ts +14 -0
- package/src/domain/index.ts +7 -0
- package/src/exceptions/index.ts +1 -0
- package/src/plugins/index.ts +1 -0
- package/src/result/index.ts +2 -0
- package/src/rulesets/index.ts +1 -0
- package/src/version.ts +1 -1
- package/src/versioning/index.ts +1 -0
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//#region src/core/plugins/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Common shape every plugin shares, regardless of the contract it implements.
|
|
4
|
+
* Carries the metadata the {@link PluginManager} uses to identify, order and
|
|
5
|
+
* toggle plugins.
|
|
6
|
+
*/
|
|
7
|
+
interface BasePlugin {
|
|
8
|
+
/** Unique identifier, used for logs / debugging and for enable/disable. */
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/** Weight; the highest priority wins (default = 0). */
|
|
11
|
+
readonly priority?: number;
|
|
12
|
+
/** Shortcut to disable a plugin without removing it. */
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A plugin contract is a record whose values are the methods plugins may
|
|
17
|
+
* implement for a given extension point.
|
|
18
|
+
*
|
|
19
|
+
* `any` here is intentional: it is the only way to express the constraint
|
|
20
|
+
* "a record whose values are arbitrary functions". Using `unknown` for the
|
|
21
|
+
* parameters breaks assignment of concrete contracts by contravariance —
|
|
22
|
+
* TypeScript rejects functions with specific parameters as a subtype of
|
|
23
|
+
* `(...args: unknown[]) => unknown`.
|
|
24
|
+
*/
|
|
25
|
+
type PluginContract = Record<string, (...args: any[]) => any>;
|
|
26
|
+
/**
|
|
27
|
+
* Reducer used in `pipeline` mode to combine the result of each plugin into a
|
|
28
|
+
* single accumulated value.
|
|
29
|
+
*/
|
|
30
|
+
type PipelineReducer<R, P extends PluginContract> = (accumulated: R, current: R, plugin: P & BasePlugin, index: number) => R;
|
|
31
|
+
/** Options accepted by {@link PluginManager.invoke}. */
|
|
32
|
+
interface InvokeOptions<P extends PluginContract, K extends keyof P> {
|
|
33
|
+
/**
|
|
34
|
+
* `'first'` → returns the first enabled plugin with the highest priority.
|
|
35
|
+
* `'pipeline'` → runs every enabled plugin, combining results via `reducer`.
|
|
36
|
+
* default = `'first'`.
|
|
37
|
+
*/
|
|
38
|
+
mode?: "first" | "pipeline";
|
|
39
|
+
/** Executed when no plugin is enabled for the method. */
|
|
40
|
+
fallback: P[K];
|
|
41
|
+
/** Reducer used only when `mode = "pipeline"`. */
|
|
42
|
+
reducer?: PipelineReducer<ReturnType<P[K]>, P>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/core/plugins/plugin.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* Registry that holds a set of plugins implementing a shared {@link PluginContract}
|
|
48
|
+
* and resolves which of them answer a given extension point.
|
|
49
|
+
*
|
|
50
|
+
* Plugins are kept sorted by priority (descending). For a given method,
|
|
51
|
+
* {@link invoke} either delegates to the highest-priority enabled plugin
|
|
52
|
+
* (`'first'`) or folds every enabled plugin into a single value (`'pipeline'`).
|
|
53
|
+
* When no plugin is enabled, the supplied `fallback` runs instead, so the host
|
|
54
|
+
* always has defined behaviour even with an empty registry.
|
|
55
|
+
*
|
|
56
|
+
* @typeParam P - The plugin contract this manager coordinates.
|
|
57
|
+
*/
|
|
58
|
+
declare class PluginManager<P extends PluginContract> {
|
|
59
|
+
/** Internal list, kept sorted by priority (desc). */
|
|
60
|
+
private plugins;
|
|
61
|
+
/** Registers one or more plugins and re-sorts by priority. */
|
|
62
|
+
register(...plugins: (P & BasePlugin)[]): void;
|
|
63
|
+
/** Removes a previously registered plugin by name. */
|
|
64
|
+
unregister(name: string): void;
|
|
65
|
+
/** Enables a registered plugin by name. */
|
|
66
|
+
enable(name: string): void;
|
|
67
|
+
/** Disables a registered plugin by name (without removing it). */
|
|
68
|
+
disable(name: string): void;
|
|
69
|
+
/** Lists enabled plugins only, already in priority order. */
|
|
70
|
+
list(): readonly (P & BasePlugin)[];
|
|
71
|
+
/**
|
|
72
|
+
* Resolves `method` against the registered plugins.
|
|
73
|
+
*
|
|
74
|
+
* In `'first'` mode the highest-priority enabled plugin that implements
|
|
75
|
+
* `method` answers. In `'pipeline'` mode every enabled plugin runs and the
|
|
76
|
+
* results are folded with `reducer` (defaults to "keep the last result").
|
|
77
|
+
* When no enabled plugin implements `method`, `fallback` is called.
|
|
78
|
+
*/
|
|
79
|
+
invoke<K extends keyof P>(method: K, args: Parameters<P[K]>, opts: InvokeOptions<P, K>): ReturnType<P[K]>;
|
|
80
|
+
/** Re-sorts the internal list by priority (desc; default priority = 0). */
|
|
81
|
+
private reorder;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { PluginContract as a, PipelineReducer as i, BasePlugin as n, InvokeOptions as r, PluginManager as t };
|
|
85
|
+
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region src/core/plugins/plugin.ts
|
|
2
|
+
/**
|
|
3
|
+
* Registry that holds a set of plugins implementing a shared {@link PluginContract}
|
|
4
|
+
* and resolves which of them answer a given extension point.
|
|
5
|
+
*
|
|
6
|
+
* Plugins are kept sorted by priority (descending). For a given method,
|
|
7
|
+
* {@link invoke} either delegates to the highest-priority enabled plugin
|
|
8
|
+
* (`'first'`) or folds every enabled plugin into a single value (`'pipeline'`).
|
|
9
|
+
* When no plugin is enabled, the supplied `fallback` runs instead, so the host
|
|
10
|
+
* always has defined behaviour even with an empty registry.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam P - The plugin contract this manager coordinates.
|
|
13
|
+
*/
|
|
14
|
+
var PluginManager = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.plugins = [];
|
|
17
|
+
}
|
|
18
|
+
/** Registers one or more plugins and re-sorts by priority. */
|
|
19
|
+
register(...plugins) {
|
|
20
|
+
this.plugins.push(...plugins);
|
|
21
|
+
this.reorder();
|
|
22
|
+
}
|
|
23
|
+
/** Removes a previously registered plugin by name. */
|
|
24
|
+
unregister(name) {
|
|
25
|
+
this.plugins = this.plugins.filter((p) => p.name !== name);
|
|
26
|
+
}
|
|
27
|
+
/** Enables a registered plugin by name. */
|
|
28
|
+
enable(name) {
|
|
29
|
+
const plugin = this.plugins.find((p) => p.name === name);
|
|
30
|
+
if (plugin) plugin.enabled = true;
|
|
31
|
+
}
|
|
32
|
+
/** Disables a registered plugin by name (without removing it). */
|
|
33
|
+
disable(name) {
|
|
34
|
+
const plugin = this.plugins.find((p) => p.name === name);
|
|
35
|
+
if (plugin) plugin.enabled = false;
|
|
36
|
+
}
|
|
37
|
+
/** Lists enabled plugins only, already in priority order. */
|
|
38
|
+
list() {
|
|
39
|
+
return this.plugins.filter((p) => p.enabled !== false);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolves `method` against the registered plugins.
|
|
43
|
+
*
|
|
44
|
+
* In `'first'` mode the highest-priority enabled plugin that implements
|
|
45
|
+
* `method` answers. In `'pipeline'` mode every enabled plugin runs and the
|
|
46
|
+
* results are folded with `reducer` (defaults to "keep the last result").
|
|
47
|
+
* When no enabled plugin implements `method`, `fallback` is called.
|
|
48
|
+
*/
|
|
49
|
+
invoke(method, args, opts) {
|
|
50
|
+
const { mode = "first", fallback, reducer } = opts;
|
|
51
|
+
const enabled = this.list().filter((p) => method in p);
|
|
52
|
+
if (enabled.length === 0) return fallback(...args);
|
|
53
|
+
if (mode === "first") {
|
|
54
|
+
const fn = enabled[0][method];
|
|
55
|
+
return fn(...args);
|
|
56
|
+
}
|
|
57
|
+
const defaultReducer = (_, curr) => curr;
|
|
58
|
+
const red = reducer ?? defaultReducer;
|
|
59
|
+
let acc = enabled[0][method](...args);
|
|
60
|
+
enabled.slice(1).forEach((plugin, idx) => {
|
|
61
|
+
const res = plugin[method](...args);
|
|
62
|
+
acc = red(acc, res, plugin, idx + 1);
|
|
63
|
+
});
|
|
64
|
+
return acc;
|
|
65
|
+
}
|
|
66
|
+
/** Re-sorts the internal list by priority (desc; default priority = 0). */
|
|
67
|
+
reorder() {
|
|
68
|
+
this.plugins.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { PluginManager as t };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../src/core/plugins/plugin.ts"],"sourcesContent":["import {\n type BasePlugin,\n type InvokeOptions,\n type PipelineReducer,\n type PluginContract,\n} from \"./types.js\";\n\n/**\n * Registry that holds a set of plugins implementing a shared {@link PluginContract}\n * and resolves which of them answer a given extension point.\n *\n * Plugins are kept sorted by priority (descending). For a given method,\n * {@link invoke} either delegates to the highest-priority enabled plugin\n * (`'first'`) or folds every enabled plugin into a single value (`'pipeline'`).\n * When no plugin is enabled, the supplied `fallback` runs instead, so the host\n * always has defined behaviour even with an empty registry.\n *\n * @typeParam P - The plugin contract this manager coordinates.\n */\nclass PluginManager<P extends PluginContract> {\n /** Internal list, kept sorted by priority (desc). */\n private plugins: (P & BasePlugin)[] = [];\n\n /** Registers one or more plugins and re-sorts by priority. */\n public register(...plugins: (P & BasePlugin)[]): void {\n this.plugins.push(...plugins);\n this.reorder();\n }\n\n /** Removes a previously registered plugin by name. */\n public unregister(name: string): void {\n this.plugins = this.plugins.filter((p) => p.name !== name);\n }\n\n /** Enables a registered plugin by name. */\n public enable(name: string): void {\n const plugin = this.plugins.find((p) => p.name === name);\n if (plugin) plugin.enabled = true;\n }\n\n /** Disables a registered plugin by name (without removing it). */\n public disable(name: string): void {\n const plugin = this.plugins.find((p) => p.name === name);\n if (plugin) plugin.enabled = false;\n }\n\n /** Lists enabled plugins only, already in priority order. */\n public list(): readonly (P & BasePlugin)[] {\n return this.plugins.filter((p) => p.enabled !== false);\n }\n\n /**\n * Resolves `method` against the registered plugins.\n *\n * In `'first'` mode the highest-priority enabled plugin that implements\n * `method` answers. In `'pipeline'` mode every enabled plugin runs and the\n * results are folded with `reducer` (defaults to \"keep the last result\").\n * When no enabled plugin implements `method`, `fallback` is called.\n */\n public invoke<K extends keyof P>(\n method: K,\n args: Parameters<P[K]>,\n opts: InvokeOptions<P, K>,\n ): ReturnType<P[K]> {\n const { mode = \"first\", fallback, reducer } = opts;\n const enabled = this.list().filter((p) => method in p) as Array<\n P & BasePlugin\n >;\n\n if (enabled.length === 0) {\n return (fallback as P[K])(...args);\n }\n\n if (mode === \"first\") {\n const fn = enabled[0][method] as P[K];\n return fn(...args);\n }\n\n const defaultReducer: PipelineReducer<ReturnType<P[K]>, P> = (\n _,\n curr,\n ) => curr;\n const red = reducer ?? defaultReducer;\n\n let acc: ReturnType<P[K]> = enabled[0][method]!(...args);\n enabled.slice(1).forEach((plugin, idx) => {\n const res = plugin[method]!(...args);\n acc = red(acc, res, plugin, idx + 1);\n });\n return acc;\n }\n\n /** Re-sorts the internal list by priority (desc; default priority = 0). */\n private reorder(): void {\n this.plugins.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }\n}\n\nexport { PluginManager };\n"],"mappings":";;;;;;;;;;;;;AAmBA,IAAM,gBAAN,MAA8C;;iBAEJ,CAAC;;;CAGvC,SAAgB,GAAG,SAAmC;EAClD,KAAK,QAAQ,KAAK,GAAG,OAAO;EAC5B,KAAK,QAAQ;CACjB;;CAGA,WAAkB,MAAoB;EAClC,KAAK,UAAU,KAAK,QAAQ,QAAQ,MAAM,EAAE,SAAS,IAAI;CAC7D;;CAGA,OAAc,MAAoB;EAC9B,MAAM,SAAS,KAAK,QAAQ,MAAM,MAAM,EAAE,SAAS,IAAI;EACvD,IAAI,QAAQ,OAAO,UAAU;CACjC;;CAGA,QAAe,MAAoB;EAC/B,MAAM,SAAS,KAAK,QAAQ,MAAM,MAAM,EAAE,SAAS,IAAI;EACvD,IAAI,QAAQ,OAAO,UAAU;CACjC;;CAGA,OAA2C;EACvC,OAAO,KAAK,QAAQ,QAAQ,MAAM,EAAE,YAAY,KAAK;CACzD;;;;;;;;;CAUA,OACI,QACA,MACA,MACgB;EAChB,MAAM,EAAE,OAAO,SAAS,UAAU,YAAY;EAC9C,MAAM,UAAU,KAAK,KAAK,EAAE,QAAQ,MAAM,UAAU,CAAC;EAIrD,IAAI,QAAQ,WAAW,GACnB,OAAQ,SAAkB,GAAG,IAAI;EAGrC,IAAI,SAAS,SAAS;GAClB,MAAM,KAAK,QAAQ,GAAG;GACtB,OAAO,GAAG,GAAG,IAAI;EACrB;EAEA,MAAM,kBACF,GACA,SACC;EACL,MAAM,MAAM,WAAW;EAEvB,IAAI,MAAwB,QAAQ,GAAG,QAAS,GAAG,IAAI;EACvD,QAAQ,MAAM,CAAC,EAAE,SAAS,QAAQ,QAAQ;GACtC,MAAM,MAAM,OAAO,QAAS,GAAG,IAAI;GACnC,MAAM,IAAI,KAAK,KAAK,QAAQ,MAAM,CAAC;EACvC,CAAC;EACD,OAAO;CACX;;CAGA,UAAwB;EACpB,KAAK,QAAQ,MAAM,GAAG,OAAO,EAAE,YAAY,MAAM,EAAE,YAAY,EAAE;CACrE;AACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_gate_engine_registry = require("../../gate-engine-registry.cjs");
|
|
3
|
+
exports.ComputeEngineRegistry = require_gate_engine_registry.ComputeEngineRegistry;
|
|
4
|
+
exports.ComputeEvaluatorRegistry = require_gate_engine_registry.ComputeEvaluatorRegistry;
|
|
5
|
+
exports.ComputePayloadParserRegistry = require_gate_engine_registry.ComputePayloadParserRegistry;
|
|
6
|
+
exports.ComputePayloadParsers = require_gate_engine_registry.ComputePayloadParsers;
|
|
7
|
+
exports.ComputeRegistry = require_gate_engine_registry.ComputeRegistry;
|
|
8
|
+
exports.GateEngineRegistry = require_gate_engine_registry.GateEngineRegistry;
|
|
9
|
+
exports.GatePayloadParserRegistry = require_gate_engine_registry.GatePayloadParserRegistry;
|
|
10
|
+
exports.GatePayloadParsers = require_gate_engine_registry.GatePayloadParsers;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { A as ConditionEvaluationReportTag, D as ConditionEvaluationOptions, E as ConditionEvaluationCause, O as ConditionEvaluationReport, a as GateTraceNodeSnapshot, c as PolicyViolation, d as GatePayloadV1, i as GateTraceLeafSnapshot, j as ConditionEvaluatorReporter, k as ConditionEvaluationReportLevel, l as VersionedGateEngine, n as GateOutcomeData, o as GateViolationTrace, r as GateStatus, s as PolicyContext, t as GateOutcome, u as GatePayload } from "../../gate-types.cjs";
|
|
2
|
+
import { a as ComputeOutcome, c as VersionedComputeEngine, d as ComputeDecisionTableRule, f as ComputeParamsPayload, i as ComputeEvaluatorRegistration, l as ComputePayload, n as ComputeRegistry, o as ComputeOutcomeData, p as ComputePayloadV1, r as ComputeEvaluator, s as ComputeStatus, t as GateEngineRegistry, u as ComputeDecisionTablePayload } from "../../gate-engine-registry.cjs";
|
|
3
|
+
import { a as ComputePayloadParserRegistry, c as ComputeEvaluatorRegistry, i as ComputePayloadParser, n as GatePayloadParserRegistry, o as ComputePayloadParsers, r as GatePayloadParsers, s as ComputeEngineRegistry, t as GatePayloadParser } from "../../parse-gate-payload.cjs";
|
|
4
|
+
export { ComputeDecisionTablePayload, ComputeDecisionTableRule, ComputeEngineRegistry, ComputeEvaluator, ComputeEvaluatorRegistration, ComputeEvaluatorRegistry, ComputeOutcome, ComputeOutcomeData, ComputeParamsPayload, ComputePayload, ComputePayloadParser, ComputePayloadParserRegistry, ComputePayloadParsers, ComputePayloadV1, ComputeRegistry, ComputeStatus, ConditionEvaluationCause, ConditionEvaluationOptions, ConditionEvaluationReport, ConditionEvaluationReportLevel, ConditionEvaluationReportTag, ConditionEvaluatorReporter, GateEngineRegistry, GateOutcome, GateOutcomeData, GatePayload, GatePayloadParser, GatePayloadParserRegistry, GatePayloadParsers, GatePayloadV1, GateStatus, GateTraceLeafSnapshot, GateTraceNodeSnapshot, GateViolationTrace, PolicyContext, PolicyViolation, VersionedComputeEngine, VersionedGateEngine };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as ConditionEvaluationReportTag, D as ConditionEvaluationOptions, E as ConditionEvaluationCause, O as ConditionEvaluationReport, a as GateTraceNodeSnapshot, c as PolicyViolation, d as GatePayloadV1, i as GateTraceLeafSnapshot, j as ConditionEvaluatorReporter, k as ConditionEvaluationReportLevel, l as VersionedGateEngine, n as GateOutcomeData, o as GateViolationTrace, r as GateStatus, s as PolicyContext, t as GateOutcome, u as GatePayload } from "../../gate-types.js";
|
|
2
2
|
import { a as ComputeOutcome, c as VersionedComputeEngine, d as ComputeDecisionTableRule, f as ComputeParamsPayload, i as ComputeEvaluatorRegistration, l as ComputePayload, n as ComputeRegistry, o as ComputeOutcomeData, p as ComputePayloadV1, r as ComputeEvaluator, s as ComputeStatus, t as GateEngineRegistry, u as ComputeDecisionTablePayload } from "../../gate-engine-registry.js";
|
|
3
3
|
import { a as ComputePayloadParserRegistry, c as ComputeEvaluatorRegistry, i as ComputePayloadParser, n as GatePayloadParserRegistry, o as ComputePayloadParsers, r as GatePayloadParsers, s as ComputeEngineRegistry, t as GatePayloadParser } from "../../parse-gate-payload.js";
|
|
4
4
|
export { ComputeDecisionTablePayload, ComputeDecisionTableRule, ComputeEngineRegistry, ComputeEvaluator, ComputeEvaluatorRegistration, ComputeEvaluatorRegistry, ComputeOutcome, ComputeOutcomeData, ComputeParamsPayload, ComputePayload, ComputePayloadParser, ComputePayloadParserRegistry, ComputePayloadParsers, ComputePayloadV1, ComputeRegistry, ComputeStatus, ConditionEvaluationCause, ConditionEvaluationOptions, ConditionEvaluationReport, ConditionEvaluationReportLevel, ConditionEvaluationReportTag, ConditionEvaluatorReporter, GateEngineRegistry, GateOutcome, GateOutcomeData, GatePayload, GatePayloadParser, GatePayloadParserRegistry, GatePayloadParsers, GatePayloadV1, GateStatus, GateTraceLeafSnapshot, GateTraceNodeSnapshot, GateViolationTrace, PolicyContext, PolicyViolation, VersionedComputeEngine, VersionedGateEngine };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_gate_v1_payload_schema = require("../../../../gate-v1-payload.schema.cjs");
|
|
3
|
+
const require_result = require("../../../../result.cjs");
|
|
4
|
+
const require_outcome = require("../../../../outcome.cjs");
|
|
5
|
+
//#region src/core/policies/engines/v1/gate/gate-engine-v1.ts
|
|
6
|
+
var GateEngineV1 = class {
|
|
7
|
+
constructor(params = {}) {
|
|
8
|
+
this.version = 1;
|
|
9
|
+
this.coreConfig = params.coreConfig ?? require_gate_v1_payload_schema.coreConfig;
|
|
10
|
+
}
|
|
11
|
+
allow() {
|
|
12
|
+
return require_result.Result.ok(require_outcome.Outcome.of("ALLOW", { violations: [] }));
|
|
13
|
+
}
|
|
14
|
+
deny(violation) {
|
|
15
|
+
return require_result.Result.ok(require_outcome.Outcome.of("DENY", { violations: [violation] }));
|
|
16
|
+
}
|
|
17
|
+
outcomeFromStatus(status, violation) {
|
|
18
|
+
return status === "ALLOW" ? this.allow() : this.deny(violation);
|
|
19
|
+
}
|
|
20
|
+
isLeafNode(node) {
|
|
21
|
+
return "field" in node && "op" in node;
|
|
22
|
+
}
|
|
23
|
+
toLeafSnapshot(node) {
|
|
24
|
+
return {
|
|
25
|
+
kind: "LEAF",
|
|
26
|
+
field: node.field,
|
|
27
|
+
op: node.op,
|
|
28
|
+
...node.allowNull === true ? { allowNull: true } : {}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
toNodeSnapshot(node) {
|
|
32
|
+
if (this.isLeafNode(node)) return this.toLeafSnapshot(node);
|
|
33
|
+
if ("and" in node) return {
|
|
34
|
+
kind: "AND",
|
|
35
|
+
childCount: node.and.length
|
|
36
|
+
};
|
|
37
|
+
if ("or" in node) return {
|
|
38
|
+
kind: "OR",
|
|
39
|
+
childCount: node.or.length
|
|
40
|
+
};
|
|
41
|
+
return { kind: "NOT" };
|
|
42
|
+
}
|
|
43
|
+
buildDenyViolation(conditionResult) {
|
|
44
|
+
return {
|
|
45
|
+
code: "DENY_CONDITION_MET",
|
|
46
|
+
message: `Gate denied at ${conditionResult.trace.conditionPath}`,
|
|
47
|
+
trace: {
|
|
48
|
+
conditionPath: conditionResult.trace.conditionPath,
|
|
49
|
+
decisiveNode: this.toNodeSnapshot(conditionResult.trace.decisiveNode),
|
|
50
|
+
lastEvaluatedLeaf: this.toLeafSnapshot(conditionResult.trace.lastEvaluatedLeaf),
|
|
51
|
+
lastEvaluatedLeafPath: conditionResult.trace.lastEvaluatedLeafPath,
|
|
52
|
+
lastEvaluatedLeafResult: conditionResult.trace.lastEvaluatedLeafResult,
|
|
53
|
+
field: conditionResult.trace.lastEvaluatedLeaf.field,
|
|
54
|
+
op: conditionResult.trace.lastEvaluatedLeaf.op
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
normalizePayload(payload) {
|
|
59
|
+
if ("condition" in payload) return {
|
|
60
|
+
allowIf: payload.condition,
|
|
61
|
+
defaultOutcome: "DENY"
|
|
62
|
+
};
|
|
63
|
+
return payload;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Evaluates a GATE payload against a context object.
|
|
67
|
+
* Pure function — no side effects.
|
|
68
|
+
*
|
|
69
|
+
* Receives an already-parsed `GatePayload`; the registry is responsible
|
|
70
|
+
* for parsing from raw `unknown` before calling this method.
|
|
71
|
+
* Returns Result for technical failures (condition evaluation errors).
|
|
72
|
+
* The Outcome inside carries the business decision (ALLOW/DENY).
|
|
73
|
+
*/
|
|
74
|
+
evaluate(payload, context) {
|
|
75
|
+
const gatePayload = this.normalizePayload(payload);
|
|
76
|
+
const isAllowedResult = new require_gate_v1_payload_schema.ConditionEvaluatorV1(context, this.coreConfig.getConditionEvaluationOptions(this.version)).evaluateWithTrace(gatePayload.allowIf);
|
|
77
|
+
if (isAllowedResult.isErr()) return require_result.Result.err(isAllowedResult.errorOrNull());
|
|
78
|
+
const isAllowed = isAllowedResult.getOrNull();
|
|
79
|
+
if (isAllowed.matched) return this.allow();
|
|
80
|
+
return this.outcomeFromStatus(gatePayload.defaultOutcome, this.buildDenyViolation(isAllowed));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
exports.ConditionEvaluatorV1 = require_gate_v1_payload_schema.ConditionEvaluatorV1;
|
|
85
|
+
exports.GateEngineV1 = GateEngineV1;
|
|
86
|
+
exports.GatePayloadSchemaV1 = require_gate_v1_payload_schema.GatePayloadSchemaV1;
|
|
87
|
+
exports.conditionLeafNodeSchema = require_gate_v1_payload_schema.conditionLeafNodeSchema;
|
|
88
|
+
exports.conditionNodeSchema = require_gate_v1_payload_schema.conditionNodeSchema;
|
|
89
|
+
exports.gatePayloadSchema = require_gate_v1_payload_schema.gatePayloadSchema;
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["coreConfig","Result","Outcome","ConditionEvaluatorV1"],"sources":["../../../../../src/core/policies/engines/v1/gate/gate-engine-v1.ts"],"sourcesContent":["import { type CoreConfig, coreConfig } from \"../../../../config/index.js\";\nimport { Outcome } from \"../../../../result/outcome.js\";\nimport { Result } from \"../../../../result/result.js\";\n\nimport {\n ConditionEvaluatorV1,\n type TracedConditionEvaluation,\n} from \"../condition-evaluator.js\";\nimport type { ConditionLeafNode, ConditionNode } from \"../condition-types.js\";\nimport type { GatePayload } from \"../../gate-payload.js\";\nimport type {\n GateOutcome,\n GateStatus,\n GateTraceLeafSnapshot,\n GateTraceNodeSnapshot,\n PolicyContext,\n PolicyViolation,\n VersionedGateEngine,\n} from \"../../gate-types.js\";\n\n// ─── Gate engine v1 ─────────────────────────────────────────────────────────\n\nexport class GateEngineV1 implements VersionedGateEngine {\n public readonly version = 1;\n private readonly coreConfig: CoreConfig;\n\n constructor(params: { readonly coreConfig?: CoreConfig } = {}) {\n this.coreConfig = params.coreConfig ?? coreConfig;\n }\n\n private allow(): Result<GateOutcome, string> {\n return Result.ok(Outcome.of(\"ALLOW\", { violations: [] }));\n }\n\n private deny(violation: PolicyViolation): Result<GateOutcome, string> {\n return Result.ok(\n Outcome.of(\"DENY\", {\n violations: [violation],\n }),\n );\n }\n\n private outcomeFromStatus(\n status: GateStatus,\n violation: PolicyViolation,\n ): Result<GateOutcome, string> {\n return status === \"ALLOW\" ? this.allow() : this.deny(violation);\n }\n\n private isLeafNode(node: ConditionNode): node is ConditionLeafNode {\n return \"field\" in node && \"op\" in node;\n }\n\n private toLeafSnapshot(node: ConditionLeafNode): GateTraceLeafSnapshot {\n return {\n kind: \"LEAF\",\n field: node.field,\n op: node.op,\n ...(node.allowNull === true ? { allowNull: true } : {}),\n };\n }\n\n private toNodeSnapshot(node: ConditionNode): GateTraceNodeSnapshot {\n if (this.isLeafNode(node)) {\n return this.toLeafSnapshot(node);\n }\n\n if (\"and\" in node) {\n return {\n kind: \"AND\",\n childCount: node.and.length,\n };\n }\n\n if (\"or\" in node) {\n return {\n kind: \"OR\",\n childCount: node.or.length,\n };\n }\n\n return {\n kind: \"NOT\",\n };\n }\n\n private buildDenyViolation(\n conditionResult: TracedConditionEvaluation,\n ): PolicyViolation {\n return {\n code: \"DENY_CONDITION_MET\",\n message: `Gate denied at ${conditionResult.trace.conditionPath}`,\n trace: {\n conditionPath: conditionResult.trace.conditionPath,\n decisiveNode: this.toNodeSnapshot(\n conditionResult.trace.decisiveNode,\n ),\n lastEvaluatedLeaf: this.toLeafSnapshot(\n conditionResult.trace.lastEvaluatedLeaf,\n ),\n lastEvaluatedLeafPath:\n conditionResult.trace.lastEvaluatedLeafPath,\n lastEvaluatedLeafResult:\n conditionResult.trace.lastEvaluatedLeafResult,\n field: conditionResult.trace.lastEvaluatedLeaf.field,\n op: conditionResult.trace.lastEvaluatedLeaf.op,\n },\n };\n }\n\n private normalizePayload(payload: GatePayload): {\n readonly allowIf: ConditionNode;\n readonly defaultOutcome: \"ALLOW\" | \"DENY\";\n } {\n if (\"condition\" in payload) {\n return {\n allowIf: payload.condition,\n defaultOutcome: \"DENY\",\n };\n }\n\n return payload;\n }\n\n /**\n * Evaluates a GATE payload against a context object.\n * Pure function — no side effects.\n *\n * Receives an already-parsed `GatePayload`; the registry is responsible\n * for parsing from raw `unknown` before calling this method.\n * Returns Result for technical failures (condition evaluation errors).\n * The Outcome inside carries the business decision (ALLOW/DENY).\n */\n evaluate(\n payload: GatePayload,\n context: PolicyContext,\n ): Result<GateOutcome, string> {\n const gatePayload = this.normalizePayload(payload);\n const conditionEvaluator = new ConditionEvaluatorV1(\n context,\n this.coreConfig.getConditionEvaluationOptions(this.version),\n );\n\n const isAllowedResult = conditionEvaluator.evaluateWithTrace(\n gatePayload.allowIf,\n );\n if (isAllowedResult.isErr()) {\n return Result.err(isAllowedResult.errorOrNull()!);\n }\n\n const isAllowed = isAllowedResult.getOrNull()!;\n if (isAllowed.matched) {\n return this.allow();\n }\n\n return this.outcomeFromStatus(\n gatePayload.defaultOutcome,\n this.buildDenyViolation(isAllowed),\n );\n }\n}\n"],"mappings":";;;;;AAsBA,IAAa,eAAb,MAAyD;CAIrD,YAAY,SAA+C,CAAC,GAAG;iBAHrC;EAItB,KAAK,aAAa,OAAO,cAAcA,+BAAAA;CAC3C;CAEA,QAA6C;EACzC,OAAOC,eAAAA,OAAO,GAAGC,gBAAAA,QAAQ,GAAG,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;CAC5D;CAEA,KAAa,WAAyD;EAClE,OAAOD,eAAAA,OAAO,GACVC,gBAAAA,QAAQ,GAAG,QAAQ,EACf,YAAY,CAAC,SAAS,EAC1B,CAAC,CACL;CACJ;CAEA,kBACI,QACA,WAC2B;EAC3B,OAAO,WAAW,UAAU,KAAK,MAAM,IAAI,KAAK,KAAK,SAAS;CAClE;CAEA,WAAmB,MAAgD;EAC/D,OAAO,WAAW,QAAQ,QAAQ;CACtC;CAEA,eAAuB,MAAgD;EACnE,OAAO;GACH,MAAM;GACN,OAAO,KAAK;GACZ,IAAI,KAAK;GACT,GAAI,KAAK,cAAc,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;EACzD;CACJ;CAEA,eAAuB,MAA4C;EAC/D,IAAI,KAAK,WAAW,IAAI,GACpB,OAAO,KAAK,eAAe,IAAI;EAGnC,IAAI,SAAS,MACT,OAAO;GACH,MAAM;GACN,YAAY,KAAK,IAAI;EACzB;EAGJ,IAAI,QAAQ,MACR,OAAO;GACH,MAAM;GACN,YAAY,KAAK,GAAG;EACxB;EAGJ,OAAO,EACH,MAAM,MACV;CACJ;CAEA,mBACI,iBACe;EACf,OAAO;GACH,MAAM;GACN,SAAS,kBAAkB,gBAAgB,MAAM;GACjD,OAAO;IACH,eAAe,gBAAgB,MAAM;IACrC,cAAc,KAAK,eACf,gBAAgB,MAAM,YAC1B;IACA,mBAAmB,KAAK,eACpB,gBAAgB,MAAM,iBAC1B;IACA,uBACI,gBAAgB,MAAM;IAC1B,yBACI,gBAAgB,MAAM;IAC1B,OAAO,gBAAgB,MAAM,kBAAkB;IAC/C,IAAI,gBAAgB,MAAM,kBAAkB;GAChD;EACJ;CACJ;CAEA,iBAAyB,SAGvB;EACE,IAAI,eAAe,SACf,OAAO;GACH,SAAS,QAAQ;GACjB,gBAAgB;EACpB;EAGJ,OAAO;CACX;;;;;;;;;;CAWA,SACI,SACA,SAC2B;EAC3B,MAAM,cAAc,KAAK,iBAAiB,OAAO;EAMjD,MAAM,kBAAkB,IALOC,+BAAAA,qBAC3B,SACA,KAAK,WAAW,8BAA8B,KAAK,OAAO,CAGrB,EAAE,kBACvC,YAAY,OAChB;EACA,IAAI,gBAAgB,MAAM,GACtB,OAAOF,eAAAA,OAAO,IAAI,gBAAgB,YAAY,CAAE;EAGpD,MAAM,YAAY,gBAAgB,UAAU;EAC5C,IAAI,UAAU,SACV,OAAO,KAAK,MAAM;EAGtB,OAAO,KAAK,kBACR,YAAY,gBACZ,KAAK,mBAAmB,SAAS,CACrC;CACJ;AACJ"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { a as Result } from "../../../../outcome.cjs";
|
|
2
|
+
import { D as ConditionEvaluationOptions, d as GatePayloadV1, f as ConditionLeafNode, l as VersionedGateEngine, m as CoreConfig, p as ConditionNode, s as PolicyContext, t as GateOutcome, u as GatePayload } from "../../../../gate-types.cjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/core/policies/engines/v1/condition-evaluator.d.ts
|
|
6
|
+
interface ConditionEvaluationTrace {
|
|
7
|
+
readonly conditionPath: string;
|
|
8
|
+
readonly decisiveNode: ConditionNode;
|
|
9
|
+
readonly lastEvaluatedLeaf: ConditionLeafNode;
|
|
10
|
+
readonly lastEvaluatedLeafPath: string;
|
|
11
|
+
readonly lastEvaluatedLeafResult: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface TracedConditionEvaluation {
|
|
14
|
+
readonly matched: boolean;
|
|
15
|
+
readonly trace: ConditionEvaluationTrace;
|
|
16
|
+
}
|
|
17
|
+
declare class ConditionEvaluatorV1 {
|
|
18
|
+
private readonly context;
|
|
19
|
+
private readonly options;
|
|
20
|
+
constructor(context: PolicyContext, options: ConditionEvaluationOptions);
|
|
21
|
+
private static isLeafNode;
|
|
22
|
+
private static isAndNode;
|
|
23
|
+
private static isOrNode;
|
|
24
|
+
private static isNotNode;
|
|
25
|
+
private static isRelationalOperator;
|
|
26
|
+
private static describeError;
|
|
27
|
+
private static buildNullishNumericOperandMessage;
|
|
28
|
+
private static buildNullishDateOperandMessage;
|
|
29
|
+
private static buildInvalidDateOperandMessage;
|
|
30
|
+
private static buildInvalidNumericOperandMessage;
|
|
31
|
+
private static buildInvalidSetOperandMessage;
|
|
32
|
+
private static buildEmptyOrConditionMessage;
|
|
33
|
+
private static buildEmptyAndConditionMessage;
|
|
34
|
+
private static parseComparableDate;
|
|
35
|
+
private static evaluateRelationalNumbers;
|
|
36
|
+
private buildReport;
|
|
37
|
+
private conditionEvalErr;
|
|
38
|
+
private reportDateOperandError;
|
|
39
|
+
private reportInvalidNumericOperand;
|
|
40
|
+
private reportInvalidSetOperand;
|
|
41
|
+
private evaluateDateRelationalNode;
|
|
42
|
+
private evaluateOperator;
|
|
43
|
+
private evaluateNumericRelationalNode;
|
|
44
|
+
private evaluateLeafNode;
|
|
45
|
+
private buildTrace;
|
|
46
|
+
private evaluateWithTraceInternal;
|
|
47
|
+
evaluate(node: ConditionNode): Result<boolean, string>;
|
|
48
|
+
evaluateWithTrace(node: ConditionNode): Result<TracedConditionEvaluation, string>;
|
|
49
|
+
static extractFields(node: ConditionNode): string[];
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/core/policies/engines/v1/gate/gate-engine-v1.d.ts
|
|
53
|
+
declare class GateEngineV1 implements VersionedGateEngine {
|
|
54
|
+
readonly version = 1;
|
|
55
|
+
private readonly coreConfig;
|
|
56
|
+
constructor(params?: {
|
|
57
|
+
readonly coreConfig?: CoreConfig;
|
|
58
|
+
});
|
|
59
|
+
private allow;
|
|
60
|
+
private deny;
|
|
61
|
+
private outcomeFromStatus;
|
|
62
|
+
private isLeafNode;
|
|
63
|
+
private toLeafSnapshot;
|
|
64
|
+
private toNodeSnapshot;
|
|
65
|
+
private buildDenyViolation;
|
|
66
|
+
private normalizePayload;
|
|
67
|
+
/**
|
|
68
|
+
* Evaluates a GATE payload against a context object.
|
|
69
|
+
* Pure function — no side effects.
|
|
70
|
+
*
|
|
71
|
+
* Receives an already-parsed `GatePayload`; the registry is responsible
|
|
72
|
+
* for parsing from raw `unknown` before calling this method.
|
|
73
|
+
* Returns Result for technical failures (condition evaluation errors).
|
|
74
|
+
* The Outcome inside carries the business decision (ALLOW/DENY).
|
|
75
|
+
*/
|
|
76
|
+
evaluate(payload: GatePayload, context: PolicyContext): Result<GateOutcome, string>;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/core/policies/engines/v1/condition-schema.d.ts
|
|
80
|
+
declare const conditionLeafNodeSchema: z.ZodType<ConditionLeafNode>;
|
|
81
|
+
declare const conditionNodeSchema: z.ZodType<ConditionNode>;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/core/policies/engines/v1/gate/gate-v1-payload.schema.d.ts
|
|
84
|
+
declare class GatePayloadSchemaV1 {
|
|
85
|
+
static readonly schema: z.ZodUnion<[z.ZodObject<{
|
|
86
|
+
condition: z.ZodType<ConditionNode, z.ZodTypeDef, ConditionNode>;
|
|
87
|
+
}, "strict", z.ZodTypeAny, {
|
|
88
|
+
condition: ConditionNode;
|
|
89
|
+
}, {
|
|
90
|
+
condition: ConditionNode;
|
|
91
|
+
}>, z.ZodObject<{
|
|
92
|
+
allowIf: z.ZodType<ConditionNode, z.ZodTypeDef, ConditionNode>;
|
|
93
|
+
defaultOutcome: z.ZodEnum<["ALLOW", "DENY"]>;
|
|
94
|
+
}, "strict", z.ZodTypeAny, {
|
|
95
|
+
allowIf: ConditionNode;
|
|
96
|
+
defaultOutcome: "ALLOW" | "DENY";
|
|
97
|
+
}, {
|
|
98
|
+
allowIf: ConditionNode;
|
|
99
|
+
defaultOutcome: "ALLOW" | "DENY";
|
|
100
|
+
}>]>;
|
|
101
|
+
static parse(payload: unknown): Result<GatePayloadV1, string>;
|
|
102
|
+
}
|
|
103
|
+
declare const gatePayloadSchema: z.ZodUnion<[z.ZodObject<{
|
|
104
|
+
condition: z.ZodType<ConditionNode, z.ZodTypeDef, ConditionNode>;
|
|
105
|
+
}, "strict", z.ZodTypeAny, {
|
|
106
|
+
condition: ConditionNode;
|
|
107
|
+
}, {
|
|
108
|
+
condition: ConditionNode;
|
|
109
|
+
}>, z.ZodObject<{
|
|
110
|
+
allowIf: z.ZodType<ConditionNode, z.ZodTypeDef, ConditionNode>;
|
|
111
|
+
defaultOutcome: z.ZodEnum<["ALLOW", "DENY"]>;
|
|
112
|
+
}, "strict", z.ZodTypeAny, {
|
|
113
|
+
allowIf: ConditionNode;
|
|
114
|
+
defaultOutcome: "ALLOW" | "DENY";
|
|
115
|
+
}, {
|
|
116
|
+
allowIf: ConditionNode;
|
|
117
|
+
defaultOutcome: "ALLOW" | "DENY";
|
|
118
|
+
}>]>;
|
|
119
|
+
//#endregion
|
|
120
|
+
export { ConditionEvaluatorV1, GateEngineV1, GatePayloadSchemaV1, GatePayloadV1, conditionLeafNodeSchema, conditionNodeSchema, gatePayloadSchema };
|
|
121
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Result } from "../../../../outcome.js";
|
|
2
|
+
import { D as ConditionEvaluationOptions, d as GatePayloadV1, f as ConditionLeafNode, l as VersionedGateEngine, m as CoreConfig, p as ConditionNode, s as PolicyContext, t as GateOutcome, u as GatePayload } from "../../../../gate-types.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
|
|
4
5
|
//#region src/core/policies/engines/v1/condition-evaluator.d.ts
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as conditionNodeSchema, i as conditionLeafNodeSchema,
|
|
1
|
+
import { a as conditionNodeSchema, i as conditionLeafNodeSchema, n as gatePayloadSchema, r as ConditionEvaluatorV1, s as coreConfig, t as GatePayloadSchemaV1 } from "../../../../gate-v1-payload.schema.js";
|
|
2
|
+
import { r as Result } from "../../../../result.js";
|
|
2
3
|
import { t as Outcome } from "../../../../outcome.js";
|
|
3
4
|
//#region src/core/policies/engines/v1/gate/gate-engine-v1.ts
|
|
4
5
|
var GateEngineV1 = class {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/core/policies/engines/v1/gate/gate-engine-v1.ts"],"sourcesContent":["import { type CoreConfig, coreConfig } from \"../../../../config/index.js\";\nimport { Outcome } from \"../../../../result/outcome.js\";\nimport { Result } from \"../../../../result/result.js\";\n\nimport {\n ConditionEvaluatorV1,\n type TracedConditionEvaluation,\n} from \"../condition-evaluator.js\";\nimport type { ConditionLeafNode, ConditionNode } from \"../condition-types.js\";\nimport type { GatePayload } from \"../../gate-payload.js\";\nimport type {\n GateOutcome,\n GateStatus,\n GateTraceLeafSnapshot,\n GateTraceNodeSnapshot,\n PolicyContext,\n PolicyViolation,\n VersionedGateEngine,\n} from \"../../gate-types.js\";\n\n// ─── Gate engine v1 ─────────────────────────────────────────────────────────\n\nexport class GateEngineV1 implements VersionedGateEngine {\n public readonly version = 1;\n private readonly coreConfig: CoreConfig;\n\n constructor(params: { readonly coreConfig?: CoreConfig } = {}) {\n this.coreConfig = params.coreConfig ?? coreConfig;\n }\n\n private allow(): Result<GateOutcome, string> {\n return Result.ok(Outcome.of(\"ALLOW\", { violations: [] }));\n }\n\n private deny(violation: PolicyViolation): Result<GateOutcome, string> {\n return Result.ok(\n Outcome.of(\"DENY\", {\n violations: [violation],\n }),\n );\n }\n\n private outcomeFromStatus(\n status: GateStatus,\n violation: PolicyViolation,\n ): Result<GateOutcome, string> {\n return status === \"ALLOW\" ? this.allow() : this.deny(violation);\n }\n\n private isLeafNode(node: ConditionNode): node is ConditionLeafNode {\n return \"field\" in node && \"op\" in node;\n }\n\n private toLeafSnapshot(node: ConditionLeafNode): GateTraceLeafSnapshot {\n return {\n kind: \"LEAF\",\n field: node.field,\n op: node.op,\n ...(node.allowNull === true ? { allowNull: true } : {}),\n };\n }\n\n private toNodeSnapshot(node: ConditionNode): GateTraceNodeSnapshot {\n if (this.isLeafNode(node)) {\n return this.toLeafSnapshot(node);\n }\n\n if (\"and\" in node) {\n return {\n kind: \"AND\",\n childCount: node.and.length,\n };\n }\n\n if (\"or\" in node) {\n return {\n kind: \"OR\",\n childCount: node.or.length,\n };\n }\n\n return {\n kind: \"NOT\",\n };\n }\n\n private buildDenyViolation(\n conditionResult: TracedConditionEvaluation,\n ): PolicyViolation {\n return {\n code: \"DENY_CONDITION_MET\",\n message: `Gate denied at ${conditionResult.trace.conditionPath}`,\n trace: {\n conditionPath: conditionResult.trace.conditionPath,\n decisiveNode: this.toNodeSnapshot(\n conditionResult.trace.decisiveNode,\n ),\n lastEvaluatedLeaf: this.toLeafSnapshot(\n conditionResult.trace.lastEvaluatedLeaf,\n ),\n lastEvaluatedLeafPath:\n conditionResult.trace.lastEvaluatedLeafPath,\n lastEvaluatedLeafResult:\n conditionResult.trace.lastEvaluatedLeafResult,\n field: conditionResult.trace.lastEvaluatedLeaf.field,\n op: conditionResult.trace.lastEvaluatedLeaf.op,\n },\n };\n }\n\n private normalizePayload(payload: GatePayload): {\n readonly allowIf: ConditionNode;\n readonly defaultOutcome: \"ALLOW\" | \"DENY\";\n } {\n if (\"condition\" in payload) {\n return {\n allowIf: payload.condition,\n defaultOutcome: \"DENY\",\n };\n }\n\n return payload;\n }\n\n /**\n * Evaluates a GATE payload against a context object.\n * Pure function — no side effects.\n *\n * Receives an already-parsed `GatePayload`; the registry is responsible\n * for parsing from raw `unknown` before calling this method.\n * Returns Result for technical failures (condition evaluation errors).\n * The Outcome inside carries the business decision (ALLOW/DENY).\n */\n evaluate(\n payload: GatePayload,\n context: PolicyContext,\n ): Result<GateOutcome, string> {\n const gatePayload = this.normalizePayload(payload);\n const conditionEvaluator = new ConditionEvaluatorV1(\n context,\n this.coreConfig.getConditionEvaluationOptions(this.version),\n );\n\n const isAllowedResult = conditionEvaluator.evaluateWithTrace(\n gatePayload.allowIf,\n );\n if (isAllowedResult.isErr()) {\n return Result.err(isAllowedResult.errorOrNull()!);\n }\n\n const isAllowed = isAllowedResult.getOrNull()!;\n if (isAllowed.matched) {\n return this.allow();\n }\n\n return this.outcomeFromStatus(\n gatePayload.defaultOutcome,\n this.buildDenyViolation(isAllowed),\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/core/policies/engines/v1/gate/gate-engine-v1.ts"],"sourcesContent":["import { type CoreConfig, coreConfig } from \"../../../../config/index.js\";\nimport { Outcome } from \"../../../../result/outcome.js\";\nimport { Result } from \"../../../../result/result.js\";\n\nimport {\n ConditionEvaluatorV1,\n type TracedConditionEvaluation,\n} from \"../condition-evaluator.js\";\nimport type { ConditionLeafNode, ConditionNode } from \"../condition-types.js\";\nimport type { GatePayload } from \"../../gate-payload.js\";\nimport type {\n GateOutcome,\n GateStatus,\n GateTraceLeafSnapshot,\n GateTraceNodeSnapshot,\n PolicyContext,\n PolicyViolation,\n VersionedGateEngine,\n} from \"../../gate-types.js\";\n\n// ─── Gate engine v1 ─────────────────────────────────────────────────────────\n\nexport class GateEngineV1 implements VersionedGateEngine {\n public readonly version = 1;\n private readonly coreConfig: CoreConfig;\n\n constructor(params: { readonly coreConfig?: CoreConfig } = {}) {\n this.coreConfig = params.coreConfig ?? coreConfig;\n }\n\n private allow(): Result<GateOutcome, string> {\n return Result.ok(Outcome.of(\"ALLOW\", { violations: [] }));\n }\n\n private deny(violation: PolicyViolation): Result<GateOutcome, string> {\n return Result.ok(\n Outcome.of(\"DENY\", {\n violations: [violation],\n }),\n );\n }\n\n private outcomeFromStatus(\n status: GateStatus,\n violation: PolicyViolation,\n ): Result<GateOutcome, string> {\n return status === \"ALLOW\" ? this.allow() : this.deny(violation);\n }\n\n private isLeafNode(node: ConditionNode): node is ConditionLeafNode {\n return \"field\" in node && \"op\" in node;\n }\n\n private toLeafSnapshot(node: ConditionLeafNode): GateTraceLeafSnapshot {\n return {\n kind: \"LEAF\",\n field: node.field,\n op: node.op,\n ...(node.allowNull === true ? { allowNull: true } : {}),\n };\n }\n\n private toNodeSnapshot(node: ConditionNode): GateTraceNodeSnapshot {\n if (this.isLeafNode(node)) {\n return this.toLeafSnapshot(node);\n }\n\n if (\"and\" in node) {\n return {\n kind: \"AND\",\n childCount: node.and.length,\n };\n }\n\n if (\"or\" in node) {\n return {\n kind: \"OR\",\n childCount: node.or.length,\n };\n }\n\n return {\n kind: \"NOT\",\n };\n }\n\n private buildDenyViolation(\n conditionResult: TracedConditionEvaluation,\n ): PolicyViolation {\n return {\n code: \"DENY_CONDITION_MET\",\n message: `Gate denied at ${conditionResult.trace.conditionPath}`,\n trace: {\n conditionPath: conditionResult.trace.conditionPath,\n decisiveNode: this.toNodeSnapshot(\n conditionResult.trace.decisiveNode,\n ),\n lastEvaluatedLeaf: this.toLeafSnapshot(\n conditionResult.trace.lastEvaluatedLeaf,\n ),\n lastEvaluatedLeafPath:\n conditionResult.trace.lastEvaluatedLeafPath,\n lastEvaluatedLeafResult:\n conditionResult.trace.lastEvaluatedLeafResult,\n field: conditionResult.trace.lastEvaluatedLeaf.field,\n op: conditionResult.trace.lastEvaluatedLeaf.op,\n },\n };\n }\n\n private normalizePayload(payload: GatePayload): {\n readonly allowIf: ConditionNode;\n readonly defaultOutcome: \"ALLOW\" | \"DENY\";\n } {\n if (\"condition\" in payload) {\n return {\n allowIf: payload.condition,\n defaultOutcome: \"DENY\",\n };\n }\n\n return payload;\n }\n\n /**\n * Evaluates a GATE payload against a context object.\n * Pure function — no side effects.\n *\n * Receives an already-parsed `GatePayload`; the registry is responsible\n * for parsing from raw `unknown` before calling this method.\n * Returns Result for technical failures (condition evaluation errors).\n * The Outcome inside carries the business decision (ALLOW/DENY).\n */\n evaluate(\n payload: GatePayload,\n context: PolicyContext,\n ): Result<GateOutcome, string> {\n const gatePayload = this.normalizePayload(payload);\n const conditionEvaluator = new ConditionEvaluatorV1(\n context,\n this.coreConfig.getConditionEvaluationOptions(this.version),\n );\n\n const isAllowedResult = conditionEvaluator.evaluateWithTrace(\n gatePayload.allowIf,\n );\n if (isAllowedResult.isErr()) {\n return Result.err(isAllowedResult.errorOrNull()!);\n }\n\n const isAllowed = isAllowedResult.getOrNull()!;\n if (isAllowed.matched) {\n return this.allow();\n }\n\n return this.outcomeFromStatus(\n gatePayload.defaultOutcome,\n this.buildDenyViolation(isAllowed),\n );\n }\n}\n"],"mappings":";;;;AAsBA,IAAa,eAAb,MAAyD;CAIrD,YAAY,SAA+C,CAAC,GAAG;iBAHrC;EAItB,KAAK,aAAa,OAAO,cAAc;CAC3C;CAEA,QAA6C;EACzC,OAAO,OAAO,GAAG,QAAQ,GAAG,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;CAC5D;CAEA,KAAa,WAAyD;EAClE,OAAO,OAAO,GACV,QAAQ,GAAG,QAAQ,EACf,YAAY,CAAC,SAAS,EAC1B,CAAC,CACL;CACJ;CAEA,kBACI,QACA,WAC2B;EAC3B,OAAO,WAAW,UAAU,KAAK,MAAM,IAAI,KAAK,KAAK,SAAS;CAClE;CAEA,WAAmB,MAAgD;EAC/D,OAAO,WAAW,QAAQ,QAAQ;CACtC;CAEA,eAAuB,MAAgD;EACnE,OAAO;GACH,MAAM;GACN,OAAO,KAAK;GACZ,IAAI,KAAK;GACT,GAAI,KAAK,cAAc,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;EACzD;CACJ;CAEA,eAAuB,MAA4C;EAC/D,IAAI,KAAK,WAAW,IAAI,GACpB,OAAO,KAAK,eAAe,IAAI;EAGnC,IAAI,SAAS,MACT,OAAO;GACH,MAAM;GACN,YAAY,KAAK,IAAI;EACzB;EAGJ,IAAI,QAAQ,MACR,OAAO;GACH,MAAM;GACN,YAAY,KAAK,GAAG;EACxB;EAGJ,OAAO,EACH,MAAM,MACV;CACJ;CAEA,mBACI,iBACe;EACf,OAAO;GACH,MAAM;GACN,SAAS,kBAAkB,gBAAgB,MAAM;GACjD,OAAO;IACH,eAAe,gBAAgB,MAAM;IACrC,cAAc,KAAK,eACf,gBAAgB,MAAM,YAC1B;IACA,mBAAmB,KAAK,eACpB,gBAAgB,MAAM,iBAC1B;IACA,uBACI,gBAAgB,MAAM;IAC1B,yBACI,gBAAgB,MAAM;IAC1B,OAAO,gBAAgB,MAAM,kBAAkB;IAC/C,IAAI,gBAAgB,MAAM,kBAAkB;GAChD;EACJ;CACJ;CAEA,iBAAyB,SAGvB;EACE,IAAI,eAAe,SACf,OAAO;GACH,SAAS,QAAQ;GACjB,gBAAgB;EACpB;EAGJ,OAAO;CACX;;;;;;;;;;CAWA,SACI,SACA,SAC2B;EAC3B,MAAM,cAAc,KAAK,iBAAiB,OAAO;EAMjD,MAAM,kBAAkB,IALO,qBAC3B,SACA,KAAK,WAAW,8BAA8B,KAAK,OAAO,CAGrB,EAAE,kBACvC,YAAY,OAChB;EACA,IAAI,gBAAgB,MAAM,GACtB,OAAO,OAAO,IAAI,gBAAgB,YAAY,CAAE;EAGpD,MAAM,YAAY,gBAAgB,UAAU;EAC5C,IAAI,UAAU,SACV,OAAO,KAAK,MAAM;EAGtB,OAAO,KAAK,kBACR,YAAY,gBACZ,KAAK,mBAAmB,SAAS,CACrC;CACJ;AACJ"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_gate_v1_payload_schema = require("../gate-v1-payload.schema.cjs");
|
|
3
|
+
const require_result = require("../result.cjs");
|
|
4
|
+
const require_outcome = require("../outcome.cjs");
|
|
5
|
+
const require_policy_service = require("../policy-service.cjs");
|
|
6
|
+
const require_gate_engine_registry = require("../gate-engine-registry.cjs");
|
|
7
|
+
exports.ComputeEngineRegistry = require_gate_engine_registry.ComputeEngineRegistry;
|
|
8
|
+
exports.ComputeEvaluatorRegistry = require_gate_engine_registry.ComputeEvaluatorRegistry;
|
|
9
|
+
exports.ComputePayloadParserRegistry = require_gate_engine_registry.ComputePayloadParserRegistry;
|
|
10
|
+
exports.ComputePayloadParsers = require_gate_engine_registry.ComputePayloadParsers;
|
|
11
|
+
exports.ComputeRegistry = require_gate_engine_registry.ComputeRegistry;
|
|
12
|
+
exports.ContextResolverRegistry = require_policy_service.ContextResolverRegistry;
|
|
13
|
+
exports.ContextSeedValidator = require_policy_service.ContextSeedValidator;
|
|
14
|
+
exports.CoreConfig = require_gate_v1_payload_schema.CoreConfig;
|
|
15
|
+
exports.Err = require_result.Err;
|
|
16
|
+
exports.GateEngineRegistry = require_gate_engine_registry.GateEngineRegistry;
|
|
17
|
+
exports.GatePayloadParsers = require_gate_engine_registry.GatePayloadParsers;
|
|
18
|
+
exports.InMemoryPolicyDefinitionRepository = require_policy_service.InMemoryPolicyDefinitionRepository;
|
|
19
|
+
exports.Ok = require_result.Ok;
|
|
20
|
+
exports.Outcome = require_outcome.Outcome;
|
|
21
|
+
exports.PolicyAsOfResolver = require_policy_service.PolicyAsOfResolver;
|
|
22
|
+
exports.PolicyCatalog = require_policy_service.PolicyCatalog;
|
|
23
|
+
exports.PolicyCatalogFactory = require_policy_service.PolicyCatalogFactory;
|
|
24
|
+
exports.PolicyContextBuilder = require_policy_service.PolicyContextBuilder;
|
|
25
|
+
exports.PolicyContextPath = require_gate_v1_payload_schema.PolicyContextPath;
|
|
26
|
+
exports.PolicyDefinition = require_policy_service.PolicyDefinition;
|
|
27
|
+
exports.PolicyEvaluationErrors = require_policy_service.PolicyEvaluationErrors;
|
|
28
|
+
exports.PolicyHashing = require_policy_service.PolicyHashing;
|
|
29
|
+
exports.PolicyKey = require_policy_service.PolicyKey;
|
|
30
|
+
exports.PolicyResolver = require_policy_service.PolicyResolver;
|
|
31
|
+
exports.PolicyScopeMatcher = require_policy_service.PolicyScopeMatcher;
|
|
32
|
+
exports.PolicyService = require_policy_service.PolicyService;
|
|
33
|
+
exports.Result = require_result.Result;
|
|
34
|
+
exports.asPolicyDecisionId = require_policy_service.asPolicyDecisionId;
|
|
35
|
+
exports.asPolicyDefinitionId = require_policy_service.asPolicyDefinitionId;
|
|
36
|
+
exports.asSchoolId = require_policy_service.asSchoolId;
|
|
37
|
+
exports.asTenantId = require_policy_service.asTenantId;
|
|
38
|
+
exports.contextResolverRegistry = require_policy_service.contextResolverRegistry;
|
|
39
|
+
exports.coreConfig = require_gate_v1_payload_schema.coreConfig;
|
|
40
|
+
exports.registerNamespacedContextResolvers = require_policy_service.registerNamespacedContextResolvers;
|
|
41
|
+
exports.registerNamespacedContextResolversIn = require_policy_service.registerNamespacedContextResolversIn;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { a as Result, i as Ok, n as Outcome, r as Err, t as CommonOutcomeStatus } from "../outcome.cjs";
|
|
2
|
+
import { A as ConditionEvaluationReportTag, C as asPolicyDefinitionId, D as ConditionEvaluationOptions, E as ConditionEvaluationCause, O as ConditionEvaluationReport, S as asPolicyDecisionId, T as asTenantId, a as GateTraceNodeSnapshot, b as SchoolId, c as PolicyViolation, g as CoreObservabilityConfig, h as CoreConfigOptions, i as GateTraceLeafSnapshot, j as ConditionEvaluatorReporter, k as ConditionEvaluationReportLevel, l as VersionedGateEngine, m as CoreConfig, n as GateOutcomeData, o as GateViolationTrace, r as GateStatus, s as PolicyContext, t as GateOutcome, u as GatePayload, v as PolicyDecisionId, w as asSchoolId, x as TenantId, y as PolicyDefinitionId } from "../gate-types.cjs";
|
|
3
|
+
import { a as PolicyPackage, c as coreConfig, i as PolicyCatalogFactory, n as contextResolverRegistry, o as InMemoryPolicyDefinitionRepository, r as registerNamespacedContextResolvers, s as PolicyHashing, t as PolicyContextPath } from "../path.cjs";
|
|
4
|
+
import { A as PolicyScope, C as BasePolicyDefinitionProps, D as PolicyDefinition, E as GatePolicyDefinitionProps, F as PolicyKey, I as AsOfSource, L as PolicyKind, M as ScopeChain, N as PolicyCatalog, O as PolicyDefinitionProps, P as PolicyCatalogEntryProps, R as PolicyOwner, T as FindCandidatesParams, _ as ContextResolverResilienceOptions, a as PolicyServiceOptions, b as ContextSeed, c as PolicyEvaluationErrors, d as PolicyAsOfResolver, f as PolicyContextBuilder, g as ContextResolverCircuitBreakerOptions, h as registerNamespacedContextResolversIn, i as PolicyService, j as PolicyScopeMatcher, k as PolicyDefinitionStatus, l as PolicyResolver, m as ContextResolverRegistry, n as PolicyDecision, o as PolicyServiceParams, p as PolicyContextBuilderOptions, r as PolicyEvaluationResult, s as PolicyEvaluationError, t as EvaluateInput, u as DeriveAsOfOptions, v as ContextResolverRetryOptions, w as ComputePolicyDefinitionProps, x as ContextSeedValidator, y as ContextValueResolver, z as PolicyScopeLevel } from "../policy-service.cjs";
|
|
5
|
+
import { a as ComputeOutcome, c as VersionedComputeEngine, i as ComputeEvaluatorRegistration, n as ComputeRegistry, o as ComputeOutcomeData, r as ComputeEvaluator, s as ComputeStatus, t as GateEngineRegistry } from "../gate-engine-registry.cjs";
|
|
6
|
+
import { a as ComputePayloadParserRegistry, c as ComputeEvaluatorRegistry, o as ComputePayloadParsers, r as GatePayloadParsers, s as ComputeEngineRegistry } from "../parse-gate-payload.cjs";
|
|
7
|
+
export { AsOfSource, BasePolicyDefinitionProps, CommonOutcomeStatus, ComputeEngineRegistry, ComputeEvaluator, ComputeEvaluatorRegistration, ComputeEvaluatorRegistry, ComputeOutcome, ComputeOutcomeData, ComputePayloadParserRegistry, ComputePayloadParsers, ComputePolicyDefinitionProps, ComputeRegistry, ComputeStatus, ConditionEvaluationCause, ConditionEvaluationOptions, ConditionEvaluationReport, ConditionEvaluationReportLevel, ConditionEvaluationReportTag, ConditionEvaluatorReporter, ContextResolverCircuitBreakerOptions, ContextResolverRegistry, ContextResolverResilienceOptions, ContextResolverRetryOptions, ContextSeed, ContextSeedValidator, ContextValueResolver, CoreConfig, CoreConfigOptions, CoreObservabilityConfig, DeriveAsOfOptions, Err, EvaluateInput, FindCandidatesParams, GateEngineRegistry, GateOutcome, GateOutcomeData, GatePayload, GatePayloadParsers, GatePolicyDefinitionProps, GateStatus, GateTraceLeafSnapshot, GateTraceNodeSnapshot, GateViolationTrace, InMemoryPolicyDefinitionRepository, Ok, Outcome, PolicyAsOfResolver, PolicyCatalog, PolicyCatalogEntryProps, PolicyCatalogFactory, PolicyContext, PolicyContextBuilder, PolicyContextBuilderOptions, PolicyContextPath, PolicyDecision, PolicyDecisionId, PolicyDefinition, PolicyDefinitionId, PolicyDefinitionProps, PolicyDefinitionStatus, PolicyEvaluationError, PolicyEvaluationErrors, PolicyEvaluationResult, PolicyHashing, PolicyKey, PolicyKind, PolicyOwner, PolicyPackage, PolicyResolver, PolicyScope, PolicyScopeLevel, PolicyScopeMatcher, PolicyService, PolicyServiceOptions, PolicyServiceParams, PolicyViolation, Result, SchoolId, ScopeChain, TenantId, VersionedComputeEngine, VersionedGateEngine, asPolicyDecisionId, asPolicyDefinitionId, asSchoolId, asTenantId, contextResolverRegistry, coreConfig, registerNamespacedContextResolvers, registerNamespacedContextResolversIn };
|
package/dist/policies/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Result, i as Ok, n as Outcome, r as Err, t as CommonOutcomeStatus } from "../outcome.js";
|
|
2
|
+
import { A as ConditionEvaluationReportTag, C as asPolicyDefinitionId, D as ConditionEvaluationOptions, E as ConditionEvaluationCause, O as ConditionEvaluationReport, S as asPolicyDecisionId, T as asTenantId, a as GateTraceNodeSnapshot, b as SchoolId, c as PolicyViolation, g as CoreObservabilityConfig, h as CoreConfigOptions, i as GateTraceLeafSnapshot, j as ConditionEvaluatorReporter, k as ConditionEvaluationReportLevel, l as VersionedGateEngine, m as CoreConfig, n as GateOutcomeData, o as GateViolationTrace, r as GateStatus, s as PolicyContext, t as GateOutcome, u as GatePayload, v as PolicyDecisionId, w as asSchoolId, x as TenantId, y as PolicyDefinitionId } from "../gate-types.js";
|
|
2
3
|
import { a as PolicyPackage, c as coreConfig, i as PolicyCatalogFactory, n as contextResolverRegistry, o as InMemoryPolicyDefinitionRepository, r as registerNamespacedContextResolvers, s as PolicyHashing, t as PolicyContextPath } from "../path.js";
|
|
3
4
|
import { A as PolicyScope, C as BasePolicyDefinitionProps, D as PolicyDefinition, E as GatePolicyDefinitionProps, F as PolicyKey, I as AsOfSource, L as PolicyKind, M as ScopeChain, N as PolicyCatalog, O as PolicyDefinitionProps, P as PolicyCatalogEntryProps, R as PolicyOwner, T as FindCandidatesParams, _ as ContextResolverResilienceOptions, a as PolicyServiceOptions, b as ContextSeed, c as PolicyEvaluationErrors, d as PolicyAsOfResolver, f as PolicyContextBuilder, g as ContextResolverCircuitBreakerOptions, h as registerNamespacedContextResolversIn, i as PolicyService, j as PolicyScopeMatcher, k as PolicyDefinitionStatus, l as PolicyResolver, m as ContextResolverRegistry, n as PolicyDecision, o as PolicyServiceParams, p as PolicyContextBuilderOptions, r as PolicyEvaluationResult, s as PolicyEvaluationError, t as EvaluateInput, u as DeriveAsOfOptions, v as ContextResolverRetryOptions, w as ComputePolicyDefinitionProps, x as ContextSeedValidator, y as ContextValueResolver, z as PolicyScopeLevel } from "../policy-service.js";
|
|
4
5
|
import { a as ComputeOutcome, c as VersionedComputeEngine, i as ComputeEvaluatorRegistration, n as ComputeRegistry, o as ComputeOutcomeData, r as ComputeEvaluator, s as ComputeStatus, t as GateEngineRegistry } from "../gate-engine-registry.js";
|
package/dist/policies/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as CoreConfig, o as PolicyContextPath, s as coreConfig } from "../gate-v1-payload.schema.js";
|
|
2
|
+
import { n as Ok, r as Result, t as Err } from "../result.js";
|
|
2
3
|
import { t as Outcome } from "../outcome.js";
|
|
3
4
|
import { _ as asPolicyDecisionId, a as ContextSeedValidator, b as asTenantId, c as ContextResolverRegistry, d as PolicyDefinition, f as InMemoryPolicyDefinitionRepository, g as PolicyCatalog, h as PolicyCatalogFactory, i as PolicyAsOfResolver, l as registerNamespacedContextResolversIn, m as PolicyKey, n as PolicyEvaluationErrors, o as contextResolverRegistry, p as PolicyScopeMatcher, r as PolicyResolver, s as registerNamespacedContextResolvers, t as PolicyService, u as PolicyContextBuilder, v as asPolicyDefinitionId, x as PolicyHashing, y as asSchoolId } from "../policy-service.js";
|
|
4
5
|
import { a as ComputeEvaluatorRegistry, c as ComputePayloadParsers, i as ComputeRegistry, o as ComputeEngineRegistry, r as GatePayloadParsers, s as ComputePayloadParserRegistry, t as GateEngineRegistry } from "../gate-engine-registry.js";
|