@syntrologie/runtime-sdk 2.8.0-canary.7 → 2.8.0-canary.71
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 +299 -167
- package/README.md +2 -0
- package/dist/actions/schema.d.ts +783 -783
- package/dist/actions/schema.js +3 -3
- package/dist/actions/types.d.ts +1 -1
- package/dist/actions/validation-core.d.ts +24 -0
- package/dist/actions/validation-rules.d.ts +74 -0
- package/dist/actions/validation.d.ts +5 -11
- package/dist/bootstrap-init.d.ts +33 -0
- package/dist/bootstrap-runtime.d.ts +7 -0
- package/dist/bootstrap-types.d.ts +90 -0
- package/dist/bootstrap.d.ts +19 -83
- package/dist/{chunk-R5DNAIRI.js → chunk-77TNZ66J.js} +4 -4
- package/dist/{chunk-R5DNAIRI.js.map → chunk-77TNZ66J.js.map} +2 -2
- package/dist/{chunk-XDYJ64IN.js → chunk-IR6UOR63.js} +4 -4
- package/dist/chunk-IR6UOR63.js.map +7 -0
- package/dist/{chunk-GWF5BTST.js → chunk-WX32GVSP.js} +1855 -783
- package/dist/chunk-WX32GVSP.js.map +7 -0
- package/dist/chunk-YLLWLUQX.js +241 -0
- package/dist/chunk-YLLWLUQX.js.map +7 -0
- package/dist/components/ShadowCanvasOverlay.d.ts +1 -2
- package/dist/components/TileIcon.d.ts +2 -2
- package/dist/components/emojiToIcon.d.ts +24 -0
- package/dist/config/schema.d.ts +147 -136
- package/dist/config/schema.js +2 -2
- package/dist/decisions/schema.d.ts +47 -47
- package/dist/decisions/schema.js +1 -1
- package/dist/events/EventBus.d.ts +27 -1
- package/dist/events/history.d.ts +9 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/normalizers/posthog.d.ts +4 -50
- package/dist/events/types.d.ts +30 -23
- package/dist/events/validation.d.ts +7 -0
- package/dist/fetchers/experimentsFetcher.d.ts +3 -3
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1529 -212
- package/dist/index.js.map +4 -4
- package/dist/overlays/runtime/overlay/overlay-runner.d.ts +4 -0
- package/dist/overlays/runtime/overlay/overlay-state.d.ts +21 -0
- package/dist/overlays/types.d.ts +3 -1
- package/dist/react.js +6 -4
- package/dist/react.js.map +2 -2
- package/dist/smart-canvas.esm.js +115 -65
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +5901 -3064
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +115 -65
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/telemetry/InterventionTracker.d.ts +23 -0
- package/dist/telemetry/adapters/posthog.d.ts +30 -4
- package/dist/telemetry/index.d.ts +1 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/token.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/package.json +23 -28
- package/schema/canvas-config.schema.json +1974 -10925
- package/scripts/syntroReactPlugin.mjs +3 -0
- package/scripts/validate-config.mjs +42 -0
- package/dist/chunk-BU4Z6PD7.js +0 -218
- package/dist/chunk-BU4Z6PD7.js.map +0 -7
- package/dist/chunk-GWF5BTST.js.map +0 -7
- package/dist/chunk-XDYJ64IN.js.map +0 -7
|
@@ -71,6 +71,9 @@ export const syntroReactPlugin = {
|
|
|
71
71
|
export function useReducer() { return _R().useReducer.apply(null, arguments); }
|
|
72
72
|
export function useLayoutEffect() { return _R().useLayoutEffect.apply(null, arguments); }
|
|
73
73
|
export function useId() { return _R().useId.apply(null, arguments); }
|
|
74
|
+
export function useSyncExternalStore() { return _R().useSyncExternalStore.apply(null, arguments); }
|
|
75
|
+
export function useDebugValue() { return _R().useDebugValue.apply(null, arguments); }
|
|
76
|
+
export function useInsertionEffect() { return _R().useInsertionEffect.apply(null, arguments); }
|
|
74
77
|
|
|
75
78
|
// Creation APIs — lazy function wrappers
|
|
76
79
|
export function createElement() { return _R().createElement.apply(null, arguments); }
|
|
@@ -119,6 +119,29 @@ if (semanticErrors.length > 0) {
|
|
|
119
119
|
process.exit(1);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
// --- Semantic check: tiles with notifications must have actions ---
|
|
123
|
+
// Notifications reference content (FAQ items, nav tips) that lives in
|
|
124
|
+
// tile.props.actions. Without actions, notifications have nothing to show.
|
|
125
|
+
for (const tile of config.tiles ?? []) {
|
|
126
|
+
const notifications = tile.notifications ?? [];
|
|
127
|
+
if (notifications.length === 0) continue;
|
|
128
|
+
|
|
129
|
+
const actions = tile.props?.actions ?? [];
|
|
130
|
+
if (actions.length === 0) {
|
|
131
|
+
semanticErrors.push(
|
|
132
|
+
`Tile "${tile.id}": has ${notifications.length} notification(s) but no actions.\n` +
|
|
133
|
+
` Notifications reference tile content (FAQ items, nav tips) defined in tile.props.actions.\n` +
|
|
134
|
+
` Add actions to the tile, or remove the notifications.`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (semanticErrors.length > 0) {
|
|
140
|
+
console.error(`\n\u274C ${semanticErrors.length} semantic error(s):`);
|
|
141
|
+
for (const e of semanticErrors) console.error(` - ${e}`);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
|
|
122
145
|
// --- Semantic check: anchorId.route must include at least one concrete route ---
|
|
123
146
|
// Wildcards allowed by canvas-config.schema.json anchorId.route;
|
|
124
147
|
// update here if the schema adds new glob patterns.
|
|
@@ -241,6 +264,25 @@ for (const { path, url } of pageUrlHits) {
|
|
|
241
264
|
}
|
|
242
265
|
}
|
|
243
266
|
|
|
267
|
+
// Hidden insertHtml without a triggerWhen is dead HTML — the SDK has no way to show it.
|
|
268
|
+
// The LLM sometimes generates `display:none` elements expecting a trigger type (e.g.,
|
|
269
|
+
// exit-intent) that doesn't exist in the SDK. Without triggerWhen, the element is
|
|
270
|
+
// injected hidden and stays hidden forever.
|
|
271
|
+
for (const [i, action] of (config.actions ?? []).entries()) {
|
|
272
|
+
if (action.kind !== 'content:insertHtml') continue;
|
|
273
|
+
if (action.triggerWhen) continue;
|
|
274
|
+
const html = action.html ?? '';
|
|
275
|
+
if (!/display\s*:\s*none/i.test(html)) continue;
|
|
276
|
+
|
|
277
|
+
const label = action.label ? ` (label: "${action.label}")` : '';
|
|
278
|
+
warnings.push(
|
|
279
|
+
`actions[${i}]${label}: content:insertHtml injects hidden HTML (display:none) with no triggerWhen.\n` +
|
|
280
|
+
` This element will be inserted into the DOM but never shown — the SDK has no mechanism to reveal it.\n` +
|
|
281
|
+
` Either add a triggerWhen with a valid condition (e.g., event_count, session_metric) to control visibility,\n` +
|
|
282
|
+
` or remove display:none to show it immediately.`
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
244
286
|
if (warnings.length > 0) {
|
|
245
287
|
console.warn(`\n\u26A0\uFE0F ${warnings.length} design warning(s):`);
|
|
246
288
|
for (const w of warnings) console.warn(` - ${w}`);
|
package/dist/chunk-BU4Z6PD7.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __typeError = (msg) => {
|
|
3
|
-
throw TypeError(msg);
|
|
4
|
-
};
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
|
|
12
|
-
// src/decisions/schema.ts
|
|
13
|
-
import { z as z2 } from "zod";
|
|
14
|
-
|
|
15
|
-
// ../sdk-contracts/dist/schemas.js
|
|
16
|
-
import { z } from "zod";
|
|
17
|
-
var AnchorIdZ = z.object({
|
|
18
|
-
selector: z.string(),
|
|
19
|
-
route: z.union([z.string(), z.array(z.string())])
|
|
20
|
-
}).strict();
|
|
21
|
-
var PageUrlConditionZ = z.object({
|
|
22
|
-
type: z.literal("page_url"),
|
|
23
|
-
url: z.string()
|
|
24
|
-
});
|
|
25
|
-
var RouteConditionZ = z.object({
|
|
26
|
-
type: z.literal("route"),
|
|
27
|
-
routeId: z.string()
|
|
28
|
-
});
|
|
29
|
-
var AnchorVisibleConditionZ = z.object({
|
|
30
|
-
type: z.literal("anchor_visible"),
|
|
31
|
-
anchorId: z.string(),
|
|
32
|
-
state: z.enum(["visible", "present", "absent"])
|
|
33
|
-
});
|
|
34
|
-
var EventOccurredConditionZ = z.object({
|
|
35
|
-
type: z.literal("event_occurred"),
|
|
36
|
-
eventName: z.string(),
|
|
37
|
-
withinMs: z.number().optional()
|
|
38
|
-
});
|
|
39
|
-
var StateEqualsConditionZ = z.object({
|
|
40
|
-
type: z.literal("state_equals"),
|
|
41
|
-
key: z.string(),
|
|
42
|
-
value: z.unknown()
|
|
43
|
-
});
|
|
44
|
-
var ViewportConditionZ = z.object({
|
|
45
|
-
type: z.literal("viewport"),
|
|
46
|
-
minWidth: z.number().optional(),
|
|
47
|
-
maxWidth: z.number().optional(),
|
|
48
|
-
minHeight: z.number().optional(),
|
|
49
|
-
maxHeight: z.number().optional()
|
|
50
|
-
});
|
|
51
|
-
var SessionMetricConditionZ = z.object({
|
|
52
|
-
type: z.literal("session_metric"),
|
|
53
|
-
key: z.string(),
|
|
54
|
-
operator: z.enum(["gte", "lte", "eq", "gt", "lt"]),
|
|
55
|
-
threshold: z.number()
|
|
56
|
-
});
|
|
57
|
-
var DismissedConditionZ = z.object({
|
|
58
|
-
type: z.literal("dismissed"),
|
|
59
|
-
key: z.string(),
|
|
60
|
-
inverted: z.boolean().optional()
|
|
61
|
-
});
|
|
62
|
-
var CooldownActiveConditionZ = z.object({
|
|
63
|
-
type: z.literal("cooldown_active"),
|
|
64
|
-
key: z.string(),
|
|
65
|
-
inverted: z.boolean().optional()
|
|
66
|
-
});
|
|
67
|
-
var FrequencyLimitConditionZ = z.object({
|
|
68
|
-
type: z.literal("frequency_limit"),
|
|
69
|
-
key: z.string(),
|
|
70
|
-
limit: z.number(),
|
|
71
|
-
inverted: z.boolean().optional()
|
|
72
|
-
});
|
|
73
|
-
var MatchOpZ = z.object({
|
|
74
|
-
equals: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
75
|
-
contains: z.string().optional()
|
|
76
|
-
});
|
|
77
|
-
var CounterDefZ = z.object({
|
|
78
|
-
events: z.array(z.string()).min(1),
|
|
79
|
-
match: z.record(z.string(), MatchOpZ).optional()
|
|
80
|
-
});
|
|
81
|
-
var EventCountConditionZ = z.object({
|
|
82
|
-
type: z.literal("event_count"),
|
|
83
|
-
key: z.string(),
|
|
84
|
-
operator: z.enum(["gte", "lte", "eq", "gt", "lt"]),
|
|
85
|
-
count: z.number().int().min(0),
|
|
86
|
-
withinMs: z.number().positive().optional(),
|
|
87
|
-
counter: CounterDefZ.optional()
|
|
88
|
-
});
|
|
89
|
-
var ConditionZ = z.discriminatedUnion("type", [
|
|
90
|
-
PageUrlConditionZ,
|
|
91
|
-
RouteConditionZ,
|
|
92
|
-
AnchorVisibleConditionZ,
|
|
93
|
-
EventOccurredConditionZ,
|
|
94
|
-
StateEqualsConditionZ,
|
|
95
|
-
ViewportConditionZ,
|
|
96
|
-
SessionMetricConditionZ,
|
|
97
|
-
DismissedConditionZ,
|
|
98
|
-
CooldownActiveConditionZ,
|
|
99
|
-
FrequencyLimitConditionZ,
|
|
100
|
-
EventCountConditionZ
|
|
101
|
-
]);
|
|
102
|
-
var RuleZ = z.object({
|
|
103
|
-
conditions: z.array(ConditionZ),
|
|
104
|
-
value: z.unknown()
|
|
105
|
-
});
|
|
106
|
-
var RuleStrategyZ = z.object({
|
|
107
|
-
type: z.literal("rules"),
|
|
108
|
-
rules: z.array(RuleZ),
|
|
109
|
-
default: z.unknown()
|
|
110
|
-
});
|
|
111
|
-
var ScoreStrategyZ = z.object({
|
|
112
|
-
type: z.literal("score"),
|
|
113
|
-
field: z.string(),
|
|
114
|
-
threshold: z.number(),
|
|
115
|
-
above: z.unknown(),
|
|
116
|
-
below: z.unknown()
|
|
117
|
-
});
|
|
118
|
-
var ModelStrategyZ = z.object({
|
|
119
|
-
type: z.literal("model"),
|
|
120
|
-
modelId: z.string(),
|
|
121
|
-
inputs: z.array(z.string()),
|
|
122
|
-
outputMapping: z.record(z.string(), z.unknown()),
|
|
123
|
-
default: z.unknown()
|
|
124
|
-
});
|
|
125
|
-
var ExternalStrategyZ = z.object({
|
|
126
|
-
type: z.literal("external"),
|
|
127
|
-
endpoint: z.string(),
|
|
128
|
-
method: z.enum(["GET", "POST"]).optional(),
|
|
129
|
-
default: z.unknown(),
|
|
130
|
-
timeoutMs: z.number().optional()
|
|
131
|
-
});
|
|
132
|
-
var DecisionStrategyZ = z.discriminatedUnion("type", [
|
|
133
|
-
RuleStrategyZ,
|
|
134
|
-
ScoreStrategyZ,
|
|
135
|
-
ModelStrategyZ,
|
|
136
|
-
ExternalStrategyZ
|
|
137
|
-
]);
|
|
138
|
-
var TriggerWhenZ = DecisionStrategyZ.nullable().optional();
|
|
139
|
-
var EventScopeZ = z.object({
|
|
140
|
-
events: z.array(z.string()),
|
|
141
|
-
urlContains: z.string().optional(),
|
|
142
|
-
props: z.record(z.union([z.string(), z.number(), z.boolean()])).optional()
|
|
143
|
-
});
|
|
144
|
-
var NotifyZ = z.object({
|
|
145
|
-
title: z.string().optional(),
|
|
146
|
-
body: z.string().optional(),
|
|
147
|
-
icon: z.string().optional()
|
|
148
|
-
}).nullable().optional();
|
|
149
|
-
|
|
150
|
-
// src/decisions/schema.ts
|
|
151
|
-
var RouteFilterZ = z2.object({
|
|
152
|
-
include: z2.array(z2.string()).optional().describe(
|
|
153
|
-
"URL patterns where this tile appears. Supports *, **, :param wildcards. Use sparingly \u2014 mostly to isolate to specific webapp functionality. Omit to appear on all routes."
|
|
154
|
-
),
|
|
155
|
-
exclude: z2.array(z2.string()).optional().describe("URL patterns where this tile should NOT appear. Evaluated before include.")
|
|
156
|
-
});
|
|
157
|
-
var ActivationConfigZ = z2.object({
|
|
158
|
-
routes: RouteFilterZ,
|
|
159
|
-
onlyIfPopulated: z2.boolean().optional().describe(
|
|
160
|
-
"When true, tile is hidden if none of its props.actions[] have an active triggerWhen. Useful for tiles with all-deferred FAQ questions or nav tips. Default: false."
|
|
161
|
-
)
|
|
162
|
-
});
|
|
163
|
-
function validateCondition(data) {
|
|
164
|
-
return ConditionZ.safeParse(data);
|
|
165
|
-
}
|
|
166
|
-
function validateStrategy(data) {
|
|
167
|
-
return DecisionStrategyZ.safeParse(data);
|
|
168
|
-
}
|
|
169
|
-
function validateActivationConfig(data) {
|
|
170
|
-
return ActivationConfigZ.safeParse(data);
|
|
171
|
-
}
|
|
172
|
-
var decisionSchemas = [
|
|
173
|
-
{ defName: "matchOp", schema: MatchOpZ },
|
|
174
|
-
{ defName: "counterDef", schema: CounterDefZ },
|
|
175
|
-
{ defName: "activationConfig", schema: ActivationConfigZ },
|
|
176
|
-
{ defName: "routeFilter", schema: RouteFilterZ },
|
|
177
|
-
{ defName: "ruleStrategy", schema: RuleStrategyZ },
|
|
178
|
-
{ defName: "scoreStrategy", schema: ScoreStrategyZ },
|
|
179
|
-
{ defName: "modelStrategy", schema: ModelStrategyZ },
|
|
180
|
-
{ defName: "externalStrategy", schema: ExternalStrategyZ },
|
|
181
|
-
{ defName: "rule", schema: RuleZ },
|
|
182
|
-
{ defName: "condition", schema: ConditionZ }
|
|
183
|
-
];
|
|
184
|
-
|
|
185
|
-
export {
|
|
186
|
-
__publicField,
|
|
187
|
-
__privateGet,
|
|
188
|
-
__privateAdd,
|
|
189
|
-
__privateSet,
|
|
190
|
-
PageUrlConditionZ,
|
|
191
|
-
RouteConditionZ,
|
|
192
|
-
AnchorVisibleConditionZ,
|
|
193
|
-
EventOccurredConditionZ,
|
|
194
|
-
StateEqualsConditionZ,
|
|
195
|
-
ViewportConditionZ,
|
|
196
|
-
SessionMetricConditionZ,
|
|
197
|
-
DismissedConditionZ,
|
|
198
|
-
CooldownActiveConditionZ,
|
|
199
|
-
FrequencyLimitConditionZ,
|
|
200
|
-
MatchOpZ,
|
|
201
|
-
CounterDefZ,
|
|
202
|
-
EventCountConditionZ,
|
|
203
|
-
ConditionZ,
|
|
204
|
-
RuleZ,
|
|
205
|
-
RuleStrategyZ,
|
|
206
|
-
ScoreStrategyZ,
|
|
207
|
-
ModelStrategyZ,
|
|
208
|
-
ExternalStrategyZ,
|
|
209
|
-
DecisionStrategyZ,
|
|
210
|
-
TriggerWhenZ,
|
|
211
|
-
RouteFilterZ,
|
|
212
|
-
ActivationConfigZ,
|
|
213
|
-
validateCondition,
|
|
214
|
-
validateStrategy,
|
|
215
|
-
validateActivationConfig,
|
|
216
|
-
decisionSchemas
|
|
217
|
-
};
|
|
218
|
-
//# sourceMappingURL=chunk-BU4Z6PD7.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/decisions/schema.ts", "../../sdk-contracts/dist/schemas.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Zod schemas for decision strategy validation.\n *\n * Condition and strategy schemas are canonical in @syntrologie/sdk-contracts.\n * This module re-exports them and adds runtime-specific schemas\n * (ActivationConfig, RouteFilter) plus the decisionSchemas array for\n * unified JSON Schema generation.\n */\nimport { z } from 'zod';\n\n// Re-export all condition + strategy schemas from the single source of truth\nexport {\n AnchorVisibleConditionZ,\n type ConditionSchema,\n ConditionZ,\n CooldownActiveConditionZ,\n CounterDefZ,\n type DecisionStrategySchema,\n DecisionStrategyZ,\n DismissedConditionZ,\n EventCountConditionZ,\n EventOccurredConditionZ,\n ExternalStrategyZ,\n FrequencyLimitConditionZ,\n MatchOpZ,\n ModelStrategyZ,\n PageUrlConditionZ,\n RouteConditionZ,\n type RuleSchema,\n RuleStrategyZ,\n RuleZ,\n ScoreStrategyZ,\n SessionMetricConditionZ,\n StateEqualsConditionZ,\n TriggerWhenZ,\n ViewportConditionZ,\n} from '@syntrologie/sdk-contracts';\n\nimport {\n ConditionZ,\n CounterDefZ,\n DecisionStrategyZ,\n ExternalStrategyZ,\n MatchOpZ,\n ModelStrategyZ,\n RuleStrategyZ,\n RuleZ,\n ScoreStrategyZ,\n} from '@syntrologie/sdk-contracts';\n\n// =============================================================================\n// ACTIVATION CONFIG SCHEMA (runtime-specific)\n// =============================================================================\n\nexport const RouteFilterZ = z.object({\n include: z\n .array(z.string())\n .optional()\n .describe(\n 'URL patterns where this tile appears. Supports *, **, :param wildcards. ' +\n 'Use sparingly \u2014 mostly to isolate to specific webapp functionality. ' +\n 'Omit to appear on all routes.'\n ),\n exclude: z\n .array(z.string())\n .optional()\n .describe('URL patterns where this tile should NOT appear. Evaluated before include.'),\n});\n\nexport const ActivationConfigZ = z.object({\n routes: RouteFilterZ,\n onlyIfPopulated: z\n .boolean()\n .optional()\n .describe(\n 'When true, tile is hidden if none of its props.actions[] have an active triggerWhen. ' +\n 'Useful for tiles with all-deferred FAQ questions or nav tips. Default: false.'\n ),\n});\n\n// =============================================================================\n// VALIDATION FUNCTIONS\n// =============================================================================\n\n/**\n * Validate a Condition object.\n */\nexport function validateCondition(data: unknown) {\n return ConditionZ.safeParse(data);\n}\n\n/**\n * Validate a DecisionStrategy object.\n */\nexport function validateStrategy(data: unknown) {\n return DecisionStrategyZ.safeParse(data);\n}\n\n/**\n * Validate an ActivationConfig object.\n */\nexport function validateActivationConfig(data: unknown) {\n return ActivationConfigZ.safeParse(data);\n}\n\n// =============================================================================\n// Export: Array for unified schema generation\n// =============================================================================\n\n/**\n * Decision schemas for unified JSON Schema generation.\n * The generator imports this array and converts each to a JSON Schema $def.\n *\n * Note: `decisionStrategy` is NOT included here \u2014 it's a oneOf wrapper that\n * the generator builds from $refs to the four strategy defs.\n */\nexport const decisionSchemas = [\n { defName: 'matchOp', schema: MatchOpZ },\n { defName: 'counterDef', schema: CounterDefZ },\n { defName: 'activationConfig', schema: ActivationConfigZ },\n { defName: 'routeFilter', schema: RouteFilterZ },\n { defName: 'ruleStrategy', schema: RuleStrategyZ },\n { defName: 'scoreStrategy', schema: ScoreStrategyZ },\n { defName: 'modelStrategy', schema: ModelStrategyZ },\n { defName: 'externalStrategy', schema: ExternalStrategyZ },\n { defName: 'rule', schema: RuleZ },\n { defName: 'condition', schema: ConditionZ },\n];\n\n// =============================================================================\n// TYPE INFERENCE\n// =============================================================================\n\nexport type ActivationConfigSchema = z.infer<typeof ActivationConfigZ>;\n", "/**\n * Shared Zod schemas for decision strategies, conditions, and event scoping.\n *\n * These are the canonical definitions \u2014 runtime-sdk and all adaptive packages\n * should import from here instead of duplicating.\n */\nimport { z } from 'zod';\n// =============================================================================\n// ANCHOR ID SCHEMA\n// =============================================================================\nexport const AnchorIdZ = z\n .object({\n selector: z.string(),\n route: z.union([z.string(), z.array(z.string())]),\n})\n .strict();\n// =============================================================================\n// CONDITION SCHEMAS\n// =============================================================================\nexport const PageUrlConditionZ = z.object({\n type: z.literal('page_url'),\n url: z.string(),\n});\nexport const RouteConditionZ = z.object({\n type: z.literal('route'),\n routeId: z.string(),\n});\nexport const AnchorVisibleConditionZ = z.object({\n type: z.literal('anchor_visible'),\n anchorId: z.string(),\n state: z.enum(['visible', 'present', 'absent']),\n});\nexport const EventOccurredConditionZ = z.object({\n type: z.literal('event_occurred'),\n eventName: z.string(),\n withinMs: z.number().optional(),\n});\nexport const StateEqualsConditionZ = z.object({\n type: z.literal('state_equals'),\n key: z.string(),\n value: z.unknown(),\n});\nexport const ViewportConditionZ = z.object({\n type: z.literal('viewport'),\n minWidth: z.number().optional(),\n maxWidth: z.number().optional(),\n minHeight: z.number().optional(),\n maxHeight: z.number().optional(),\n});\nexport const SessionMetricConditionZ = z.object({\n type: z.literal('session_metric'),\n key: z.string(),\n operator: z.enum(['gte', 'lte', 'eq', 'gt', 'lt']),\n threshold: z.number(),\n});\nexport const DismissedConditionZ = z.object({\n type: z.literal('dismissed'),\n key: z.string(),\n inverted: z.boolean().optional(),\n});\nexport const CooldownActiveConditionZ = z.object({\n type: z.literal('cooldown_active'),\n key: z.string(),\n inverted: z.boolean().optional(),\n});\nexport const FrequencyLimitConditionZ = z.object({\n type: z.literal('frequency_limit'),\n key: z.string(),\n limit: z.number(),\n inverted: z.boolean().optional(),\n});\nexport const MatchOpZ = z.object({\n equals: z.union([z.string(), z.number(), z.boolean()]).optional(),\n contains: z.string().optional(),\n});\nexport const CounterDefZ = z.object({\n events: z.array(z.string()).min(1),\n match: z.record(z.string(), MatchOpZ).optional(),\n});\nexport const EventCountConditionZ = z.object({\n type: z.literal('event_count'),\n key: z.string(),\n operator: z.enum(['gte', 'lte', 'eq', 'gt', 'lt']),\n count: z.number().int().min(0),\n withinMs: z.number().positive().optional(),\n counter: CounterDefZ.optional(),\n});\nexport const ConditionZ = z.discriminatedUnion('type', [\n PageUrlConditionZ,\n RouteConditionZ,\n AnchorVisibleConditionZ,\n EventOccurredConditionZ,\n StateEqualsConditionZ,\n ViewportConditionZ,\n SessionMetricConditionZ,\n DismissedConditionZ,\n CooldownActiveConditionZ,\n FrequencyLimitConditionZ,\n EventCountConditionZ,\n]);\n// =============================================================================\n// STRATEGY SCHEMAS\n// =============================================================================\nexport const RuleZ = z.object({\n conditions: z.array(ConditionZ),\n value: z.unknown(),\n});\nexport const RuleStrategyZ = z.object({\n type: z.literal('rules'),\n rules: z.array(RuleZ),\n default: z.unknown(),\n});\nexport const ScoreStrategyZ = z.object({\n type: z.literal('score'),\n field: z.string(),\n threshold: z.number(),\n above: z.unknown(),\n below: z.unknown(),\n});\nexport const ModelStrategyZ = z.object({\n type: z.literal('model'),\n modelId: z.string(),\n inputs: z.array(z.string()),\n outputMapping: z.record(z.string(), z.unknown()),\n default: z.unknown(),\n});\nexport const ExternalStrategyZ = z.object({\n type: z.literal('external'),\n endpoint: z.string(),\n method: z.enum(['GET', 'POST']).optional(),\n default: z.unknown(),\n timeoutMs: z.number().optional(),\n});\nexport const DecisionStrategyZ = z.discriminatedUnion('type', [\n RuleStrategyZ,\n ScoreStrategyZ,\n ModelStrategyZ,\n ExternalStrategyZ,\n]);\n/** Canonical Zod schema for the optional triggerWhen field on actions and adaptive items. */\nexport const TriggerWhenZ = DecisionStrategyZ.nullable().optional();\n// =============================================================================\n// EVENT SCOPE SCHEMA\n// =============================================================================\n/** Scopes a widget to specific events/URLs. */\nexport const EventScopeZ = z.object({\n events: z.array(z.string()),\n urlContains: z.string().optional(),\n props: z.record(z.union([z.string(), z.number(), z.boolean()])).optional(),\n});\n// =============================================================================\n// NOTIFY SCHEMA\n// =============================================================================\n/** Toast notification config for triggerWhen transitions. */\nexport const NotifyZ = z\n .object({\n title: z.string().optional(),\n body: z.string().optional(),\n icon: z.string().optional(),\n})\n .nullable()\n .optional();\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;AAQA,SAAS,KAAAA,UAAS;;;ACFlB,SAAS,SAAS;AAIX,IAAM,YAAY,EACpB,OAAO;AAAA,EACR,UAAU,EAAE,OAAO;AAAA,EACnB,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACpD,CAAC,EACI,OAAO;AAIL,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACtC,MAAM,EAAE,QAAQ,UAAU;AAAA,EAC1B,KAAK,EAAE,OAAO;AAClB,CAAC;AACM,IAAM,kBAAkB,EAAE,OAAO;AAAA,EACpC,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,SAAS,EAAE,OAAO;AACtB,CAAC;AACM,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC5C,MAAM,EAAE,QAAQ,gBAAgB;AAAA,EAChC,UAAU,E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