@active-reach/web-sdk 1.19.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/cdn.d.ts.map +1 -1
- package/dist/chat/AegisChat.d.ts +24 -0
- package/dist/chat/AegisChat.d.ts.map +1 -1
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/inapp/AegisInAppManager.d.ts +17 -1
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/renderPreview.d.ts +16 -1
- package/dist/inapp/renderPreview.d.ts.map +1 -1
- package/dist/inapp/renderers/active-web-chat.d.ts +7 -0
- package/dist/inapp/renderers/active-web-chat.d.ts.map +1 -1
- package/dist/inapp/renderers/hero.d.ts +23 -0
- package/dist/inapp/renderers/hero.d.ts.map +1 -0
- package/dist/inapp/renderers/index.d.ts +1 -0
- package/dist/inapp/renderers/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +766 -160
- package/dist/index.js.map +1 -1
- package/dist/runtime/AegisMessageRuntime.d.ts +37 -20
- package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
- package/dist/triggers/ContactScoresFetcher.d.ts +6 -0
- package/dist/triggers/ContactScoresFetcher.d.ts.map +1 -1
- package/dist/triggers/IntentRuleEvaluator.d.ts +29 -4
- package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -52,7 +52,7 @@ export interface AegisMessageRuntimeConfig extends AegisInAppConfig {
|
|
|
52
52
|
/** Presentation overrides for the chat launcher (title / greeting / accent),
|
|
53
53
|
* plus proactive auto-open. writeKey / apiHost / org / contact are inherited
|
|
54
54
|
* from the runtime. */
|
|
55
|
-
chat?: Pick<AegisChatConfig, 'title' | 'greeting' | 'accentColor' | 'channel' | 'icon' | 'logoUrl' | 'position'> & {
|
|
55
|
+
chat?: Pick<AegisChatConfig, 'title' | 'greeting' | 'accentColor' | 'channel' | 'icon' | 'logoUrl' | 'position' | 'displayMode'> & {
|
|
56
56
|
/** Client-side TriggerEngine events that auto-open the launcher (e.g.
|
|
57
57
|
* ['exit_intent', 'inactivity_90']). The trigger ONLY opens the panel —
|
|
58
58
|
* it never creates an offer. The proactive *opener* is owned server-side
|
|
@@ -94,10 +94,6 @@ export declare class AegisMessageRuntime {
|
|
|
94
94
|
private initialized;
|
|
95
95
|
/** apiHost captured for the device-pairing entry (`?aegis_pair=CODE`). */
|
|
96
96
|
private readonly pairingApiHost;
|
|
97
|
-
/** Live cart snapshot, set imperatively via setCartState(). Held in
|
|
98
|
-
* private state (NOT a window global) and surfaced to the InAppManager's
|
|
99
|
-
* renderers via the getCartState reader passed into its constructor. */
|
|
100
|
-
private cartState?;
|
|
101
97
|
constructor(config: AegisMessageRuntimeConfig);
|
|
102
98
|
/**
|
|
103
99
|
* Boots both managers in parallel. Safe to call multiple times — the
|
|
@@ -122,23 +118,44 @@ export declare class AegisMessageRuntime {
|
|
|
122
118
|
*/
|
|
123
119
|
onClientEvent(eventName: string, eventData?: Record<string, unknown>): void;
|
|
124
120
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
121
|
+
* Unified reactive context — the GENERAL imperative state API (Plotline-style
|
|
122
|
+
* "global context state engine"). The host app feeds named namespaces:
|
|
123
|
+
* runtime.updateContext('cart', { total: 540, items: 3, currency: 'INR' })
|
|
124
|
+
* runtime.updateContext('user', { tier: 'gold', lifecycle: 'active' })
|
|
125
|
+
* runtime.updateContext('session', { idle_s: 60 })
|
|
129
126
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* via the getCartState reader passed into the InAppManager;
|
|
134
|
-
* 2. feeds the `cart_value` micro-intent signal so `CART_VALUE`-gated
|
|
135
|
-
* campaigns (e.g. a cart-idle nudge) can evaluate — this signal was
|
|
136
|
-
* previously never populated client-side;
|
|
137
|
-
* 3. taps a debounced in-app refresh so a newly eligible cart-gated
|
|
138
|
-
* campaign arms without waiting for the next identity flip.
|
|
127
|
+
* Held in PRIVATE runtime state (no `window` pollution). Merged shallowly per
|
|
128
|
+
* namespace and evaluated entirely client-side — no round-trip. This supersedes
|
|
129
|
+
* the single-purpose `setCartState` (kept as a thin wrapper for back-compat).
|
|
139
130
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
131
|
+
* Design note (vs the proposed rewrite): we DELIBERATELY do NOT introduce a
|
|
132
|
+
* parallel rule schema. Our canonical `IntentRule` (shared with the cell-plane
|
|
133
|
+
* Pydantic schema + the editor + seeded campaigns) stays the source of truth.
|
|
134
|
+
* `updateContext` BRIDGES known paths into the existing enum-keyed
|
|
135
|
+
* `IntentSnapshot` (e.g. cart.total → the `cart_value` signal) so today's rules
|
|
136
|
+
* keep firing — fed by the generic API. Arbitrary dot-path leaves
|
|
137
|
+
* (`cart.foo`) are a forward-compatible follow-up that adds an optional `path`
|
|
138
|
+
* to the canonical `IntentLeaf` (schema-mirrored + drift-guarded), NOT a second
|
|
139
|
+
* evaluator. Tri-state (null = unprovable) evaluation is preserved — we do not
|
|
140
|
+
* regress missing paths to `false`.
|
|
141
|
+
*/
|
|
142
|
+
updateContext(namespace: string, data: Record<string, unknown>): void;
|
|
143
|
+
/** Read the current client-side context snapshot (for the editor scrubber /
|
|
144
|
+
* preview bridge to mirror live values). Read-only view of the ONE store. */
|
|
145
|
+
getContext(): Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
146
|
+
/**
|
|
147
|
+
* Bridge well-known context paths into the canonical enum-keyed IntentSnapshot,
|
|
148
|
+
* so existing signal-based rules (cart_value) keep firing off the generic
|
|
149
|
+
* `updateContext`. Reads from the ONE store (the evaluator). Extend here as new
|
|
150
|
+
* signals map to context paths — no parallel engine.
|
|
151
|
+
*/
|
|
152
|
+
private bridgeContextToSignals;
|
|
153
|
+
/** Derive the typed cart snapshot for the progress-bar renderer reader from
|
|
154
|
+
* the ONE context store (the `cart` namespace). No separate cart field. */
|
|
155
|
+
private deriveCartState;
|
|
156
|
+
/**
|
|
157
|
+
* Back-compat wrapper over `updateContext('cart', …)`. The single-purpose cart
|
|
158
|
+
* feed for headless storefronts; prefer `updateContext` for new code.
|
|
142
159
|
*/
|
|
143
160
|
setCartState(state: CartState): void;
|
|
144
161
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AegisMessageRuntime.d.ts","sourceRoot":"","sources":["../../src/runtime/AegisMessageRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,iBAAiB,EAAqB,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAC3H,OAAO,EAAE,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IACjE;;kEAE8D;IAC9D,aAAa,CAAC,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAC;IACnD;;sDAEkD;IAClD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;0EACsE;IACtE,cAAc,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACrD;;;mDAG+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;yCAEqC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;4BAEwB;IACxB,IAAI,CAAC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C,KAAK,EAAE,SAAS,GAAG,IAAI;IAsBpC;;;;;;;OAOG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAK9B;;;;;OAKG;IACH,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAOzB;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAO1B;;;;;;;;;;;;;;;;OAgBG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIxC;;;;;OAKG;IACH,OAAO,IAAI,IAAI;IAOf;;;;;OAKG;IACH,YAAY,IAAI,aAAa,EAAE;CAMhC"}
|
|
@@ -48,6 +48,12 @@ export interface ContactScoresResponse {
|
|
|
48
48
|
price_sensitivity_score?: number;
|
|
49
49
|
scoring_tier?: string;
|
|
50
50
|
scores_updated_at?: string | null;
|
|
51
|
+
/** Governed contact context — namespaced { user: { custom: {…} }, loyalty:
|
|
52
|
+
* { points, tier } } from contacts.attributes + the loyalty record (the SAME
|
|
53
|
+
* source segments + {{custom.x}} merge fields use). Pushed into the rule
|
|
54
|
+
* engine's namespaces so `user.custom.<attr>` / `loyalty.points` path-leaves
|
|
55
|
+
* resolve client-side off one catalog. */
|
|
56
|
+
context?: Record<string, Record<string, unknown>>;
|
|
51
57
|
}
|
|
52
58
|
export interface ContactScoresFetcherConfig {
|
|
53
59
|
apiHost: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactScoresFetcher.d.ts","sourceRoot":"","sources":["../../src/triggers/ContactScoresFetcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEjF,uEAAuE;AACvE,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM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q' | 'in' | 'nin';
|
|
31
31
|
export type IntentLeafValue = number | string | boolean | ReadonlyArray<number | string | boolean>;
|
|
32
32
|
export interface IntentLeaf {
|
|
33
|
-
signal
|
|
33
|
+
/** Canonical enum signal (Layer-1/2). Mutually exclusive with `path`. */
|
|
34
|
+
signal?: IntentSignal;
|
|
35
|
+
/** Dot-path into the updateContext namespaces (cart.total / user.tier /
|
|
36
|
+
* session.idle_s). Mutually exclusive with `signal`. */
|
|
37
|
+
path?: string;
|
|
34
38
|
op: Comparator;
|
|
35
39
|
value: IntentLeafValue;
|
|
36
40
|
}
|
|
41
|
+
/** A value/node in the generic reactive context (fed via updateContext). */
|
|
42
|
+
export type ContextValue = string | number | boolean | null | ContextNode | ReadonlyArray<ContextValue>;
|
|
43
|
+
export interface ContextNode {
|
|
44
|
+
[key: string]: ContextValue;
|
|
45
|
+
}
|
|
46
|
+
/** Named namespaces: { cart: {...}, user: {...}, session: {...}, custom: {...} }. */
|
|
47
|
+
export type ContextNamespaces = Record<string, ContextNode>;
|
|
37
48
|
export interface IntentNode {
|
|
38
49
|
op: 'AND' | 'OR' | 'NOT';
|
|
39
50
|
operands: ReadonlyArray<IntentExpr>;
|
|
@@ -53,6 +64,10 @@ export type SignalValue = number | string | boolean | null;
|
|
|
53
64
|
* same as `null`. */
|
|
54
65
|
export type IntentSnapshot = Partial<Record<IntentSignal, SignalValue>>;
|
|
55
66
|
export declare function isIntentLeaf(expr: IntentExpr): expr is IntentLeaf;
|
|
67
|
+
/** Resolve a dot-path (`cart.total`) against the context namespaces.
|
|
68
|
+
* Returns undefined on any miss → tri-state null in evaluateLeaf (same as a
|
|
69
|
+
* missing signal). Never throws. */
|
|
70
|
+
export declare function getValueByPath(namespaces: ContextNamespaces | undefined, path: string): ContextValue | undefined;
|
|
56
71
|
export declare function isIntentNode(expr: IntentExpr): expr is IntentNode;
|
|
57
72
|
/**
|
|
58
73
|
* Evaluate a single leaf comparison against a snapshot.
|
|
@@ -71,7 +86,7 @@ export declare function isIntentNode(expr: IntentExpr): expr is IntentNode;
|
|
|
71
86
|
* contact's RFM segment is "not in" the forbidden list if we don't
|
|
72
87
|
* know it yet — conservative).
|
|
73
88
|
*/
|
|
74
|
-
export declare function evaluateLeaf(leaf: IntentLeaf, snapshot: IntentSnapshot): boolean | null;
|
|
89
|
+
export declare function evaluateLeaf(leaf: IntentLeaf, snapshot: IntentSnapshot, namespaces?: ContextNamespaces): boolean | null;
|
|
75
90
|
/**
|
|
76
91
|
* Evaluate the full predicate tree.
|
|
77
92
|
*
|
|
@@ -93,11 +108,11 @@ export declare function evaluateLeaf(leaf: IntentLeaf, snapshot: IntentSnapshot)
|
|
|
93
108
|
* Top-level: a null result from the root expression means the rule
|
|
94
109
|
* cannot be evaluated yet — do NOT fire.
|
|
95
110
|
*/
|
|
96
|
-
export declare function evaluateExpr(expr: IntentExpr, snapshot: IntentSnapshot): boolean | null;
|
|
111
|
+
export declare function evaluateExpr(expr: IntentExpr, snapshot: IntentSnapshot, namespaces?: ContextNamespaces): boolean | null;
|
|
97
112
|
/** Top-level "does the rule fire right now?" check. Treats a null
|
|
98
113
|
* evaluation result as "do not fire" (we can't prove the rule's
|
|
99
114
|
* conditions are met). */
|
|
100
|
-
export declare function evaluateRule(rule: IntentRule, snapshot: IntentSnapshot): boolean;
|
|
115
|
+
export declare function evaluateRule(rule: IntentRule, snapshot: IntentSnapshot, namespaces?: ContextNamespaces): boolean;
|
|
101
116
|
/** A campaign carrying a compound rule, in the SDK's runtime shape.
|
|
102
117
|
* Mirrors the cell-plane payload at /v1/in-app/active when
|
|
103
118
|
* client_trigger.type === 'micro_intent'. */
|
|
@@ -126,6 +141,9 @@ export declare class IntentRuleEvaluator {
|
|
|
126
141
|
* updateSnapshot whenever TriggerEngine emits a state change or
|
|
127
142
|
* contact-scores fetch completes. */
|
|
128
143
|
private snapshot;
|
|
144
|
+
/** Generic reactive context namespaces fed via updateContext() — the SINGLE
|
|
145
|
+
* store path-leaves resolve against (no parallel state elsewhere). */
|
|
146
|
+
private namespaces;
|
|
129
147
|
/** Campaigns that have already fired this session — never re-fire. */
|
|
130
148
|
private firedThisSession;
|
|
131
149
|
/** Campaigns silenced by a prior `suppress_competing` win. The set
|
|
@@ -136,6 +154,13 @@ export declare class IntentRuleEvaluator {
|
|
|
136
154
|
updateSignal(signal: IntentSignal, value: SignalValue): void;
|
|
137
155
|
updateSnapshot(partial: IntentSnapshot): void;
|
|
138
156
|
getSnapshot(): Readonly<IntentSnapshot>;
|
|
157
|
+
/** Merge a namespace's data (shallow). Path-leaves (`cart.total`) resolve
|
|
158
|
+
* against this. The runtime's updateContext() delegates here so there is ONE
|
|
159
|
+
* context store, then bridges well-known paths to enum signals. */
|
|
160
|
+
updateContext(namespace: string, data: ContextNode): void;
|
|
161
|
+
getNamespaces(): Readonly<ContextNamespaces>;
|
|
162
|
+
/** Resolve a dot-path against the live context (for previews / debugging). */
|
|
163
|
+
getValueByPath(path: string): ContextValue | undefined;
|
|
139
164
|
setArmed(campaigns: ArmedCampaign[]): void;
|
|
140
165
|
getArmed(): ReadonlyArray<ArmedCampaign>;
|
|
141
166
|
markFired(campaignId: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntentRuleEvaluator.d.ts","sourceRoot":"","sources":["../../src/triggers/IntentRuleEvaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,MAAM,MAAM,YAAY,GAEpB,cAAc,GACd,cAAc,GACd,aAAa,GACb,aAAa,GACb,iBAAiB,GACjB,YAAY,GACZ,mBAAmB,GACnB,YAAY,GACZ,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,mBAAmB,GACnB,YAAY,GACZ,sBAAsB,GAEtB,aAAa,GACb,WAAW,GACX,iBAAiB,GACjB,uBAAuB,GACvB,sBAAsB,GACtB,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,GACf,oBAAoB,GACpB,qBAAqB,GACrB,kBAAkB,GAClB,YAAY,GACZ,yBAAyB,GACzB,cAAc,GACd,gBAAgB,GAChB,cAAc,CAAC;AAEnB,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AAEnF,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,MAAM,GACN,OAAO,GACP,aAAa,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAE7C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"IntentRuleEvaluator.d.ts","sourceRoot":"","sources":["../../src/triggers/IntentRuleEvaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,MAAM,MAAM,YAAY,GAEpB,cAAc,GACd,cAAc,GACd,aAAa,GACb,aAAa,GACb,iBAAiB,GACjB,YAAY,GACZ,mBAAmB,GACnB,YAAY,GACZ,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,mBAAmB,GACnB,YAAY,GACZ,sBAAsB,GAEtB,aAAa,GACb,WAAW,GACX,iBAAiB,GACjB,uBAAuB,GACvB,sBAAsB,GACtB,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,GACf,oBAAoB,GACpB,qBAAqB,GACrB,kBAAkB,GAClB,YAAY,GACZ,yBAAyB,GACzB,cAAc,GACd,gBAAgB,GAChB,cAAc,CAAC;AAEnB,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AAEnF,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,MAAM,GACN,OAAO,GACP,aAAa,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAE7C,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACzE,MAAM,CAAC,E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CAAC,cAAc,CAAC;IAMvC;;wEAEoE;IACpE,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI;IAKzD,aAAa,IAAI,QAAQ,CAAC,iBAAiB,CAAC;IAI5C,8EAA8E;IAC9E,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAMtD,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI;IAI1C,QAAQ,IAAI,aAAa,CAAC,aAAa,CAAC;IAIxC,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAInC;yBACqB;IACrB,KAAK,IAAI,IAAI;IAOb;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,kBAAkB;CAuC1D;AAID,eAAO,MAAM,cAAc,GAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@active-reach/web-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"description": "Web SDK for Active Reach Intelligence — event tracking, identity resolution, in-app messaging, web push, and placements",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
],
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "vite build && node scripts/build-cdn.js && npm run build:snippet && npm run build:types",
|
|
47
|
+
"build": "vite build && node scripts/build-cdn.js && npm run build:snippet && npm run build:types && npm run sync:web",
|
|
48
|
+
"sync:web": "if [ -d ../../apps/web/public ]; then mkdir -p ../../apps/web/public/sdk && cp dist/aegis.min.js dist/aegis.min.js.map ../../apps/web/public/sdk/; else echo 'sync:web: apps/web not in build context (e.g. turbo-pruned cashier-portal build) — skipped; committed bundle is source of truth'; fi",
|
|
48
49
|
"build:snippet": "node scripts/minify-snippet.js",
|
|
49
50
|
"build:types": "tsc --project tsconfig.build.json",
|
|
50
51
|
"test": "vitest run",
|