@syntrologie/runtime-sdk 0.2.20 → 0.2.21
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/CAPABILITIES.md +211 -0
- package/dist/api.js +7 -6
- package/dist/api.js.map +1 -1
- package/dist/bootstrap.d.ts +16 -2
- package/dist/bootstrap.js +63 -14
- package/dist/bootstrap.js.map +1 -1
- package/dist/context/ContextManager.d.ts +66 -0
- package/dist/context/ContextManager.js +268 -0
- package/dist/context/ContextManager.js.map +1 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/index.js +7 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/schema.d.ts +360 -0
- package/dist/context/schema.js +50 -0
- package/dist/context/schema.js.map +1 -0
- package/dist/context/types.d.ts +101 -0
- package/dist/context/types.js +8 -0
- package/dist/context/types.js.map +1 -0
- package/dist/decisions/engine.d.ts +43 -0
- package/dist/decisions/engine.js +112 -0
- package/dist/decisions/engine.js.map +1 -0
- package/dist/decisions/index.d.ts +9 -0
- package/dist/decisions/index.js +10 -0
- package/dist/decisions/index.js.map +1 -0
- package/dist/decisions/schema.d.ts +2166 -0
- package/dist/decisions/schema.js +143 -0
- package/dist/decisions/schema.js.map +1 -0
- package/dist/decisions/strategies/rules.d.ts +24 -0
- package/dist/decisions/strategies/rules.js +152 -0
- package/dist/decisions/strategies/rules.js.map +1 -0
- package/dist/decisions/strategies/score.d.ts +10 -0
- package/dist/decisions/strategies/score.js +29 -0
- package/dist/decisions/strategies/score.js.map +1 -0
- package/dist/decisions/types.d.ts +242 -0
- package/dist/decisions/types.js +2 -0
- package/dist/decisions/types.js.map +1 -0
- package/dist/editorLoader.d.ts +10 -0
- package/dist/editorLoader.js +38 -0
- package/dist/editorLoader.js.map +1 -1
- package/dist/events/EventBus.d.ts +59 -0
- package/dist/events/EventBus.js +154 -0
- package/dist/events/EventBus.js.map +1 -0
- package/dist/events/index.d.ts +9 -0
- package/dist/events/index.js +10 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/normalizers/canvas.d.ts +67 -0
- package/dist/events/normalizers/canvas.js +116 -0
- package/dist/events/normalizers/canvas.js.map +1 -0
- package/dist/events/normalizers/posthog.d.ts +29 -0
- package/dist/events/normalizers/posthog.js +155 -0
- package/dist/events/normalizers/posthog.js.map +1 -0
- package/dist/events/schema.d.ts +70 -0
- package/dist/events/schema.js +30 -0
- package/dist/events/schema.js.map +1 -0
- package/dist/events/types.d.ts +73 -0
- package/dist/events/types.js +41 -0
- package/dist/events/types.js.map +1 -0
- package/dist/hooks/useShadowCanvasConfig.d.ts +5 -1
- package/dist/hooks/useShadowCanvasConfig.js +17 -3
- package/dist/hooks/useShadowCanvasConfig.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/overlays/schema.d.ts +48 -48
- package/dist/runtime.d.ts +86 -0
- package/dist/runtime.js +132 -0
- package/dist/runtime.js.map +1 -0
- package/dist/smart-canvas.esm.js +11 -11
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +1504 -17
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +11 -11
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/state/StateStore.d.ts +41 -0
- package/dist/state/StateStore.js +170 -0
- package/dist/state/StateStore.js.map +1 -0
- package/dist/state/helpers/cooldowns.d.ts +7 -0
- package/dist/state/helpers/cooldowns.js +31 -0
- package/dist/state/helpers/cooldowns.js.map +1 -0
- package/dist/state/helpers/dismissals.d.ts +7 -0
- package/dist/state/helpers/dismissals.js +34 -0
- package/dist/state/helpers/dismissals.js.map +1 -0
- package/dist/state/helpers/frequency.d.ts +8 -0
- package/dist/state/helpers/frequency.js +43 -0
- package/dist/state/helpers/frequency.js.map +1 -0
- package/dist/state/index.d.ts +7 -0
- package/dist/state/index.js +7 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/schema.d.ts +49 -0
- package/dist/state/schema.js +25 -0
- package/dist/state/schema.js.map +1 -0
- package/dist/state/types.d.ts +137 -0
- package/dist/state/types.js +9 -0
- package/dist/state/types.js.map +1 -0
- package/dist/telemetry/adapters/posthog.d.ts +1 -1
- package/dist/telemetry/adapters/posthog.js +1 -1
- package/dist/telemetry/adapters/posthog.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/package.json +2 -2
- package/schema/canvas-config.schema.json +205 -0
- package/schema/runtime-context.schema.json +131 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for RuntimeContext validation.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
export const PageContextZ = z.object({
|
|
6
|
+
url: z.string(),
|
|
7
|
+
routeId: z.string().optional(),
|
|
8
|
+
title: z.string().optional(),
|
|
9
|
+
locale: z.string().optional(),
|
|
10
|
+
});
|
|
11
|
+
export const PageHistoryEntryZ = z.object({
|
|
12
|
+
url: z.string(),
|
|
13
|
+
ts: z.number(),
|
|
14
|
+
});
|
|
15
|
+
export const SessionContextZ = z.object({
|
|
16
|
+
sessionId: z.string(),
|
|
17
|
+
startTs: z.number(),
|
|
18
|
+
pageHistory: z.array(PageHistoryEntryZ).optional(),
|
|
19
|
+
});
|
|
20
|
+
export const ViewportContextZ = z.object({
|
|
21
|
+
width: z.number(),
|
|
22
|
+
height: z.number(),
|
|
23
|
+
});
|
|
24
|
+
export const BoundingBoxZ = z.object({
|
|
25
|
+
x: z.number(),
|
|
26
|
+
y: z.number(),
|
|
27
|
+
w: z.number(),
|
|
28
|
+
h: z.number(),
|
|
29
|
+
});
|
|
30
|
+
export const AnchorStateZ = z.object({
|
|
31
|
+
anchorId: z.string(),
|
|
32
|
+
present: z.boolean(),
|
|
33
|
+
visible: z.boolean().optional(),
|
|
34
|
+
boundingBox: BoundingBoxZ.optional(),
|
|
35
|
+
});
|
|
36
|
+
export const AugmentationZ = z.record(z.union([z.number(), z.string(), z.boolean(), z.undefined()]));
|
|
37
|
+
export const RuntimeContextZ = z.object({
|
|
38
|
+
page: PageContextZ,
|
|
39
|
+
session: SessionContextZ,
|
|
40
|
+
viewport: ViewportContextZ,
|
|
41
|
+
anchors: z.array(AnchorStateZ).optional(),
|
|
42
|
+
augmented: AugmentationZ.optional(),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Validate a RuntimeContext object.
|
|
46
|
+
*/
|
|
47
|
+
export function validateRuntimeContext(data) {
|
|
48
|
+
return RuntimeContextZ.safeParse(data);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/context/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;CACf,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;CACnD,CAAC,C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;IAClD,OAAO,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Context Types
|
|
3
|
+
*
|
|
4
|
+
* The RuntimeContext represents the current state of the page, session, viewport,
|
|
5
|
+
* and other environmental factors that can be used for adaptive decision-making.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Page context - information about the current page.
|
|
9
|
+
*/
|
|
10
|
+
export interface PageContext {
|
|
11
|
+
/** Current page URL */
|
|
12
|
+
url: string;
|
|
13
|
+
/** Matched route pattern from RoutesConfig (e.g., "/products/:id") */
|
|
14
|
+
routeId?: string;
|
|
15
|
+
/** Document title */
|
|
16
|
+
title?: string;
|
|
17
|
+
/** Page locale (e.g., "en-US") */
|
|
18
|
+
locale?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Page history entry for session tracking.
|
|
22
|
+
*/
|
|
23
|
+
export interface PageHistoryEntry {
|
|
24
|
+
/** Page URL */
|
|
25
|
+
url: string;
|
|
26
|
+
/** Timestamp when page was visited */
|
|
27
|
+
ts: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Session context - information about the current session.
|
|
31
|
+
*/
|
|
32
|
+
export interface SessionContext {
|
|
33
|
+
/** Unique session ID (from PostHog) */
|
|
34
|
+
sessionId: string;
|
|
35
|
+
/** Session start timestamp */
|
|
36
|
+
startTs: number;
|
|
37
|
+
/** Page history within this session */
|
|
38
|
+
pageHistory?: PageHistoryEntry[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Viewport context - information about the viewport size.
|
|
42
|
+
*/
|
|
43
|
+
export interface ViewportContext {
|
|
44
|
+
/** Viewport width in pixels */
|
|
45
|
+
width: number;
|
|
46
|
+
/** Viewport height in pixels */
|
|
47
|
+
height: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Bounding box for anchor elements.
|
|
51
|
+
*/
|
|
52
|
+
export interface BoundingBox {
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
w: number;
|
|
56
|
+
h: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Anchor state - tracks visibility and position of anchored elements.
|
|
60
|
+
*/
|
|
61
|
+
export interface AnchorState {
|
|
62
|
+
/** Anchor element ID */
|
|
63
|
+
anchorId: string;
|
|
64
|
+
/** Whether the element is present in the DOM */
|
|
65
|
+
present: boolean;
|
|
66
|
+
/** Whether the element is visible in the viewport */
|
|
67
|
+
visible?: boolean;
|
|
68
|
+
/** Element's bounding box (when visible) */
|
|
69
|
+
boundingBox?: BoundingBox;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Augmentation data from ML models (Phase 3).
|
|
73
|
+
* Placeholder for future implementation.
|
|
74
|
+
*/
|
|
75
|
+
export interface Augmentation {
|
|
76
|
+
/** Augmentation confidence scores by field name */
|
|
77
|
+
[field: string]: number | string | boolean | undefined;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The complete runtime context available to adaptives.
|
|
81
|
+
*/
|
|
82
|
+
export interface RuntimeContext {
|
|
83
|
+
/** Current page information */
|
|
84
|
+
page: PageContext;
|
|
85
|
+
/** Current session information */
|
|
86
|
+
session: SessionContext;
|
|
87
|
+
/** Current viewport size */
|
|
88
|
+
viewport: ViewportContext;
|
|
89
|
+
/** Tracked anchor element states (optional) */
|
|
90
|
+
anchors?: AnchorState[];
|
|
91
|
+
/** ML-derived augmentation data (Phase 3) */
|
|
92
|
+
augmented?: Augmentation;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Callback for context changes.
|
|
96
|
+
*/
|
|
97
|
+
export type ContextChangeCallback = (context: RuntimeContext, previousContext: RuntimeContext) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Unsubscribe function returned by subscribe().
|
|
100
|
+
*/
|
|
101
|
+
export type Unsubscribe = () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision Engine
|
|
3
|
+
*
|
|
4
|
+
* The central evaluation engine for DecisionStrategy objects.
|
|
5
|
+
* Routes strategies to their appropriate evaluators.
|
|
6
|
+
*/
|
|
7
|
+
import type { DecisionStrategy, DecisionResult } from "./types";
|
|
8
|
+
import type { RuntimeContext } from "../context/types";
|
|
9
|
+
import type { StateStore } from "../state/StateStore";
|
|
10
|
+
import type { EventBus } from "../events/EventBus";
|
|
11
|
+
import type { SessionMetricTracker } from "../metrics/sessionMetrics";
|
|
12
|
+
/**
|
|
13
|
+
* Options for the decision engine evaluate function.
|
|
14
|
+
*/
|
|
15
|
+
export interface EvaluateOptions {
|
|
16
|
+
/** State store for dismissal/cooldown/frequency checks */
|
|
17
|
+
state?: StateStore;
|
|
18
|
+
/** Event bus for event_occurred checks */
|
|
19
|
+
events?: EventBus;
|
|
20
|
+
/** Session metric tracker for session_metric checks */
|
|
21
|
+
sessionMetrics?: SessionMetricTracker;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Evaluate a DecisionStrategy against the current context.
|
|
25
|
+
*
|
|
26
|
+
* @param strategy - The decision strategy to evaluate
|
|
27
|
+
* @param context - The runtime context
|
|
28
|
+
* @param options - Additional evaluation options
|
|
29
|
+
* @returns The decision result
|
|
30
|
+
*/
|
|
31
|
+
export declare function evaluate<T>(strategy: DecisionStrategy<T>, context: RuntimeContext, options?: EvaluateOptions): Promise<DecisionResult<T>>;
|
|
32
|
+
/**
|
|
33
|
+
* Synchronous version of evaluate for simple strategies.
|
|
34
|
+
* Use this when you know the strategy doesn't require async operations.
|
|
35
|
+
*/
|
|
36
|
+
export declare function evaluateSync<T>(strategy: DecisionStrategy<T>, context: RuntimeContext, options?: EvaluateOptions): DecisionResult<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Create a decision engine with pre-bound options.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createDecisionEngine(options: EvaluateOptions): {
|
|
41
|
+
evaluate: <T>(strategy: DecisionStrategy<T>, context: RuntimeContext) => Promise<DecisionResult<T>>;
|
|
42
|
+
evaluateSync: <T>(strategy: DecisionStrategy<T>, context: RuntimeContext) => DecisionResult<T>;
|
|
43
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { evaluateRuleStrategy } from "./strategies/rules";
|
|
2
|
+
import { evaluateScoreStrategy } from "./strategies/score";
|
|
3
|
+
/**
|
|
4
|
+
* Create an EvaluationContext from runtime components.
|
|
5
|
+
*/
|
|
6
|
+
function createEvaluationContext(context, options) {
|
|
7
|
+
const { state, events, sessionMetrics } = options;
|
|
8
|
+
return {
|
|
9
|
+
context,
|
|
10
|
+
state: state
|
|
11
|
+
? {
|
|
12
|
+
isDismissed: (key) => state.dismissals.isDismissed(key),
|
|
13
|
+
isCooldownActive: (key) => state.cooldowns.isActive(key),
|
|
14
|
+
getFrequencyCount: (key) => state.frequency.count(key),
|
|
15
|
+
getSessionMetric: (key) => { var _a; return (_a = sessionMetrics === null || sessionMetrics === void 0 ? void 0 : sessionMetrics.get(key)) !== null && _a !== void 0 ? _a : 0; },
|
|
16
|
+
}
|
|
17
|
+
: undefined,
|
|
18
|
+
events: events
|
|
19
|
+
? {
|
|
20
|
+
hasRecentEvent: (eventName, withinMs) => events.hasRecentEvent(eventName, withinMs),
|
|
21
|
+
}
|
|
22
|
+
: undefined,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Evaluate a DecisionStrategy against the current context.
|
|
27
|
+
*
|
|
28
|
+
* @param strategy - The decision strategy to evaluate
|
|
29
|
+
* @param context - The runtime context
|
|
30
|
+
* @param options - Additional evaluation options
|
|
31
|
+
* @returns The decision result
|
|
32
|
+
*/
|
|
33
|
+
export async function evaluate(strategy, context, options = {}) {
|
|
34
|
+
const evalContext = createEvaluationContext(context, options);
|
|
35
|
+
switch (strategy.type) {
|
|
36
|
+
case "rules":
|
|
37
|
+
return evaluateRuleStrategy(strategy, evalContext);
|
|
38
|
+
case "score":
|
|
39
|
+
return evaluateScoreStrategy(strategy, evalContext);
|
|
40
|
+
case "model":
|
|
41
|
+
// Phase 3: Model-based strategy
|
|
42
|
+
// For now, return default
|
|
43
|
+
return {
|
|
44
|
+
value: strategy.default,
|
|
45
|
+
isFallback: true,
|
|
46
|
+
matchInfo: {
|
|
47
|
+
strategyType: "model",
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
case "external":
|
|
51
|
+
// Phase 3: External strategy
|
|
52
|
+
// For now, return default
|
|
53
|
+
return {
|
|
54
|
+
value: strategy.default,
|
|
55
|
+
isFallback: true,
|
|
56
|
+
matchInfo: {
|
|
57
|
+
strategyType: "external",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
default:
|
|
61
|
+
// Unknown strategy type
|
|
62
|
+
console.warn("[DecisionEngine] Unknown strategy type:", strategy.type);
|
|
63
|
+
return {
|
|
64
|
+
value: undefined,
|
|
65
|
+
isFallback: true,
|
|
66
|
+
matchInfo: {
|
|
67
|
+
strategyType: strategy.type,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Synchronous version of evaluate for simple strategies.
|
|
74
|
+
* Use this when you know the strategy doesn't require async operations.
|
|
75
|
+
*/
|
|
76
|
+
export function evaluateSync(strategy, context, options = {}) {
|
|
77
|
+
const evalContext = createEvaluationContext(context, options);
|
|
78
|
+
switch (strategy.type) {
|
|
79
|
+
case "rules":
|
|
80
|
+
return evaluateRuleStrategy(strategy, evalContext);
|
|
81
|
+
case "score":
|
|
82
|
+
return evaluateScoreStrategy(strategy, evalContext);
|
|
83
|
+
case "model":
|
|
84
|
+
case "external":
|
|
85
|
+
// These require async, return default
|
|
86
|
+
return {
|
|
87
|
+
value: strategy.default,
|
|
88
|
+
isFallback: true,
|
|
89
|
+
matchInfo: {
|
|
90
|
+
strategyType: strategy.type,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
default:
|
|
94
|
+
return {
|
|
95
|
+
value: undefined,
|
|
96
|
+
isFallback: true,
|
|
97
|
+
matchInfo: {
|
|
98
|
+
strategyType: strategy.type,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Create a decision engine with pre-bound options.
|
|
105
|
+
*/
|
|
106
|
+
export function createDecisionEngine(options) {
|
|
107
|
+
return {
|
|
108
|
+
evaluate: (strategy, context) => evaluate(strategy, context, options),
|
|
109
|
+
evaluateSync: (strategy, context) => evaluateSync(strategy, context, options),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/decisions/engine.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAc3D;;GAEG;AACH,SAAS,uBAAuB,CAC9B,OAAuB,EACvB,OAAwB;IAExB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAElD,OAAO;QACL,OAAO;QACP,KAAK,EAAE,KAAK;YACV,CAAC,CAAC;gBACE,WAAW,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC;gBAC/D,gBAAgB,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAChE,iBAAiB,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,K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@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decisions module exports.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./schema";
|
|
6
|
+
export { evaluate, evaluateSync, createDecisionEngine } from "./engine";
|
|
7
|
+
export type { EvaluateOptions } from "./engine";
|
|
8
|
+
export { evaluateCondition, evaluateRule, evaluateRuleStrategy } from "./strategies/rules";
|
|
9
|
+
export { evaluateScoreStrategy } from "./strategies/score";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decisions module exports.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./schema";
|
|
6
|
+
export { evaluate, evaluateSync, createDecisionEngine } from "./engine";
|
|
7
|
+
// Strategy evaluators (for advanced use)
|
|
8
|
+
export { evaluateCondition, evaluateRule, evaluateRuleStrategy } from "./strategies/rules";
|
|
9
|
+
export { evaluateScoreStrategy } from "./strategies/score";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decisions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGxE,yCAAyC;AACzC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|