@picked/client 0.0.50 → 0.0.51-next.10
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/api-CHy9HcU7.cjs +1 -0
- package/dist/{api-DWBcrf98.js → api-mlYS-lDj.js} +1 -1
- package/dist/cjs/form/index.js +1 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/form/index.js +472 -0
- package/dist/esm/index.js +473 -383
- package/dist/esm/plugins/create-experience/index.js +198 -165
- package/dist/esm/plugins/dynamic-experiences/index.js +52 -30
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +7 -9
- package/dist/esm/plugins/responses-indexeddb/index.js +11 -11
- package/dist/esm/plugins/single-page-app/index.js +4 -4
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-DOcd8XI1.cjs +1 -0
- package/dist/experience-instance-NHU1moID.js +486 -0
- package/dist/{object-Clj5zVr1.js → object-C82v79xc.js} +2 -1
- package/dist/object-CUJOjanb.cjs +1 -0
- package/dist/rules-logic-CnVktz2l.js +240 -0
- package/dist/rules-logic-nMHNVLn7.cjs +1 -0
- package/dist/{storage-DyxpJ0pg.js → storage-6Xk0uAxB.js} +3 -1
- package/dist/storage-B6lQtc4-.cjs +1 -0
- package/dist/types/client.d.ts +47 -43
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/entities/action/action.d.ts +37 -5
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/condition/condition.d.ts +20 -0
- package/dist/types/entities/condition/condition.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +67 -51
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +22 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +24 -10
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/response/response-validation.d.ts +74 -0
- package/dist/types/entities/response/response-validation.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +24 -20
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +42 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- package/dist/types/exports.d.ts +0 -1
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/form/build-responses.d.ts +17 -0
- package/dist/types/form/build-responses.d.ts.map +1 -0
- package/dist/types/form/create-field-evaluator.d.ts +27 -0
- package/dist/types/form/create-field-evaluator.d.ts.map +1 -0
- package/dist/types/form/create-field-validation.d.ts +59 -0
- package/dist/types/form/create-field-validation.d.ts.map +1 -0
- package/dist/types/form/create-form.d.ts +97 -0
- package/dist/types/form/create-form.d.ts.map +1 -0
- package/dist/types/form/create-submit-pipeline.d.ts +70 -0
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -0
- package/dist/types/form/get-step-fields.d.ts +18 -0
- package/dist/types/form/get-step-fields.d.ts.map +1 -0
- package/dist/types/form/index.d.ts +10 -0
- package/dist/types/form/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +12 -10
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +99 -33
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +53 -31
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/index.d.ts +2 -2
- package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +21 -4
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +45 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -0
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +0 -3
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +2 -2
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/global-obj.d.ts +0 -1
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/indexed-db.d.ts +2 -1
- package/dist/types/utils/indexed-db.d.ts.map +1 -1
- package/dist/types/utils/logger.d.ts.map +1 -1
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +16 -0
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -0
- package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +2 -2
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/object.d.ts +0 -8
- package/dist/types/utils/object.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +1 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts +31 -0
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/dist/types/utils/search-params.d.ts.map +1 -1
- package/dist/types/utils/state-snaphot.d.ts +11 -1
- package/dist/types/utils/state-snaphot.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +43 -7
- package/dist/api-BwTaomem.cjs +0 -1
- package/dist/experience-instance-BRpI9I4s.js +0 -710
- package/dist/experience-instance-BUTnwbSJ.cjs +0 -1
- package/dist/object-BReQiaSS.cjs +0 -1
- package/dist/storage-BFjb8azI.cjs +0 -1
- package/dist/types/entities/project/project.d.ts +0 -9
- package/dist/types/entities/project/project.d.ts.map +0 -1
- package/dist/types/utils/get-step-fields.d.ts +0 -4
- package/dist/types/utils/get-step-fields.d.ts.map +0 -1
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +0 -3
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +0 -1
- /package/dist/{id-CIbS4P60.cjs → id-Bv44ilEo.cjs} +0 -0
- /package/dist/{id-BniPxOdF.js → id-CRqy981z.js} +0 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { t as e } from "./object-C82v79xc.js";
|
|
2
|
+
//#region src/logic-engine.ts
|
|
3
|
+
function t(e) {
|
|
4
|
+
return typeof e == "number" && !isNaN(e);
|
|
5
|
+
}
|
|
6
|
+
function n(e) {
|
|
7
|
+
return typeof e == "string";
|
|
8
|
+
}
|
|
9
|
+
function r(e) {
|
|
10
|
+
return Array.isArray(e);
|
|
11
|
+
}
|
|
12
|
+
function i(e) {
|
|
13
|
+
return e instanceof Promise;
|
|
14
|
+
}
|
|
15
|
+
function a(e) {
|
|
16
|
+
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
17
|
+
}
|
|
18
|
+
function o(e) {
|
|
19
|
+
if (t(e)) return e;
|
|
20
|
+
let n = parseFloat(`${e}`);
|
|
21
|
+
return isNaN(n) ? 0 : n;
|
|
22
|
+
}
|
|
23
|
+
function s(e) {
|
|
24
|
+
return `${e}`;
|
|
25
|
+
}
|
|
26
|
+
var c = {
|
|
27
|
+
"==": (e, t) => e == t,
|
|
28
|
+
"===": (e, t) => e === t,
|
|
29
|
+
"!=": (e, t) => e != t,
|
|
30
|
+
"!==": (e, t) => e !== t,
|
|
31
|
+
">": (e, t) => o(e) > o(t),
|
|
32
|
+
">=": (e, t) => o(e) >= o(t),
|
|
33
|
+
"<": (e, t, n) => {
|
|
34
|
+
let r = o(e), i = o(t);
|
|
35
|
+
if (n === void 0) return r < i;
|
|
36
|
+
let a = o(n);
|
|
37
|
+
return r < i && i < a;
|
|
38
|
+
},
|
|
39
|
+
"<=": (e, t, n) => {
|
|
40
|
+
let r = o(e), i = o(t);
|
|
41
|
+
if (n === void 0) return r <= i;
|
|
42
|
+
let a = o(n);
|
|
43
|
+
return r <= i && i <= a;
|
|
44
|
+
},
|
|
45
|
+
"!!": async (e) => await u(e),
|
|
46
|
+
"!": async (e) => !await u(e),
|
|
47
|
+
"%": (e, t) => o(e) % o(t),
|
|
48
|
+
log: (e) => (console.log(e), e),
|
|
49
|
+
in: (e, t) => t ? n(t) ? t.indexOf(s(e)) !== -1 : r(t) ? t.includes(e) : !1 : !1,
|
|
50
|
+
cat: (...e) => e.map(s).join(""),
|
|
51
|
+
substr: (e, t, n) => {
|
|
52
|
+
let r = s(e), i = o(t);
|
|
53
|
+
if (n === void 0) return r.substr(i);
|
|
54
|
+
let a = o(n);
|
|
55
|
+
if (a < 0) {
|
|
56
|
+
let e = r.substr(i);
|
|
57
|
+
return e.substr(0, e.length + a);
|
|
58
|
+
}
|
|
59
|
+
return r.substr(i, a);
|
|
60
|
+
},
|
|
61
|
+
"+": (...e) => e.reduce((e, t) => o(e) + o(t), 0),
|
|
62
|
+
"*": (...e) => e.reduce((e, t) => o(e) * o(t), 1),
|
|
63
|
+
"-": (e, t) => {
|
|
64
|
+
let n = o(e);
|
|
65
|
+
return t === void 0 ? -n : n - o(t);
|
|
66
|
+
},
|
|
67
|
+
"/": (e, t) => o(e) / o(t),
|
|
68
|
+
min: (...e) => Math.min(...e.map(o)),
|
|
69
|
+
max: (...e) => Math.max(...e.map(o)),
|
|
70
|
+
merge: (...e) => e.reduce((e, t) => r(t) ? e.concat(t) : e.concat([t]), []),
|
|
71
|
+
var(e, t) {
|
|
72
|
+
let n = arguments.length > 1 ? t : null;
|
|
73
|
+
if (e === "" || e === "." || e == null) return this;
|
|
74
|
+
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
75
|
+
let r = s(e);
|
|
76
|
+
if (r === "" || r === ".") return this;
|
|
77
|
+
let i = r.split("."), a = this;
|
|
78
|
+
for (let e of i) {
|
|
79
|
+
if (a == null) return n;
|
|
80
|
+
if (Array.isArray(a)) {
|
|
81
|
+
let t = parseInt(e, 10);
|
|
82
|
+
a = isNaN(t) ? a[e] : a[t];
|
|
83
|
+
} else a = a[e];
|
|
84
|
+
}
|
|
85
|
+
return a === void 0 ? n : a;
|
|
86
|
+
},
|
|
87
|
+
async missing(...e) {
|
|
88
|
+
let t = r(e[0]) ? e[0] : e, n = [];
|
|
89
|
+
for (let e of t) {
|
|
90
|
+
let t = await l({ var: e }, this);
|
|
91
|
+
(t === null || t === "") && n.push(`${e}`);
|
|
92
|
+
}
|
|
93
|
+
return n;
|
|
94
|
+
},
|
|
95
|
+
async missing_some(e, t) {
|
|
96
|
+
let i = await l({ missing: t }, this);
|
|
97
|
+
if (!r(i) || !r(t)) return [];
|
|
98
|
+
let a = i.filter(n);
|
|
99
|
+
return t.filter(n).length - a.length >= o(e) ? [] : a;
|
|
100
|
+
},
|
|
101
|
+
invoke(...e) {
|
|
102
|
+
let [t, ...n] = e;
|
|
103
|
+
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
104
|
+
},
|
|
105
|
+
startsWith: (e, t) => n(e) && n(t) && e.startsWith(t),
|
|
106
|
+
endsWith: (e, t) => n(e) && n(t) && e.endsWith(t),
|
|
107
|
+
regexp_matches(e, t) {
|
|
108
|
+
let i = e, a = "";
|
|
109
|
+
if (r(e)) {
|
|
110
|
+
let [t, n] = e;
|
|
111
|
+
i = t, a = n;
|
|
112
|
+
}
|
|
113
|
+
return !n(i) || !n(a) ? !1 : new RegExp(i, a).test(s(t));
|
|
114
|
+
},
|
|
115
|
+
throw(e) {
|
|
116
|
+
throw Error(s(e));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
async function l(e, t) {
|
|
120
|
+
if (!e) return e;
|
|
121
|
+
if (i(e)) return l(await e, t);
|
|
122
|
+
if (r(e)) return Promise.all(e.map((e) => l(e, t)));
|
|
123
|
+
if (!a(e)) return e;
|
|
124
|
+
let n = d(e), o = n ? e[n] ?? [] : [];
|
|
125
|
+
switch (r(o) || (o = [o]), n) {
|
|
126
|
+
case "if":
|
|
127
|
+
case "?:":
|
|
128
|
+
for (let e = 0; e < o.length - 1; e += 2) if (await u(await l(o[e], t))) return l(o[e + 1], t);
|
|
129
|
+
return o.length % 2 == 1 ? l(o[o.length - 1], t) : null;
|
|
130
|
+
case "and": {
|
|
131
|
+
let e = null;
|
|
132
|
+
for (let n of o) if (e = await l(n, t), !await u(e)) return e;
|
|
133
|
+
return e;
|
|
134
|
+
}
|
|
135
|
+
case "or": {
|
|
136
|
+
let e = null;
|
|
137
|
+
for (let n of o) if (e = await l(n, t), await u(e)) return e;
|
|
138
|
+
return e;
|
|
139
|
+
}
|
|
140
|
+
case "map": {
|
|
141
|
+
let e = await l(o[0], t);
|
|
142
|
+
return r(e) ? await Promise.all(e.map((e) => l(o[1], e))) : [];
|
|
143
|
+
}
|
|
144
|
+
case "filter": {
|
|
145
|
+
let e = await l(o[0], t);
|
|
146
|
+
return r(e) ? (await Promise.all(e.map(async (e) => ({
|
|
147
|
+
item: e,
|
|
148
|
+
shouldInclude: await u(await l(o[1], e))
|
|
149
|
+
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
150
|
+
}
|
|
151
|
+
case "reduce": {
|
|
152
|
+
let e = await l(o[0], t);
|
|
153
|
+
if (!r(e)) return o.length > 2 ? await l(o[2], t) : null;
|
|
154
|
+
let n = o[1], i = o.length > 2 ? await l(o[2], t) : null;
|
|
155
|
+
for (let t of e) i = await l(n, {
|
|
156
|
+
current: t,
|
|
157
|
+
accumulator: i
|
|
158
|
+
});
|
|
159
|
+
return i;
|
|
160
|
+
}
|
|
161
|
+
case "all": {
|
|
162
|
+
let e = await l(o[0], t);
|
|
163
|
+
if (!r(e) || e.length === 0) return !1;
|
|
164
|
+
for (let t of e) if (!await u(await l(o[1], t))) return !1;
|
|
165
|
+
return !0;
|
|
166
|
+
}
|
|
167
|
+
case "some": {
|
|
168
|
+
let e = await l(o[0], t);
|
|
169
|
+
if (!r(e)) return !1;
|
|
170
|
+
for (let t of e) if (await u(await l(o[1], t))) return !0;
|
|
171
|
+
return !1;
|
|
172
|
+
}
|
|
173
|
+
case "none": {
|
|
174
|
+
let e = await l(o[0], t);
|
|
175
|
+
if (!r(e)) return !0;
|
|
176
|
+
for (let t of e) if (await u(await l(o[1], t))) return !1;
|
|
177
|
+
return !0;
|
|
178
|
+
}
|
|
179
|
+
case "catch": try {
|
|
180
|
+
return await l(o[0], t);
|
|
181
|
+
} catch (e) {
|
|
182
|
+
return a(e) ? await l(e, t) : o[1] ? await l(o[1], e) : e instanceof Error ? e.message : e;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
let s = await Promise.all(o.map((e) => l(e, t))), f = n ? c[n] : void 0;
|
|
186
|
+
if (!f) throw Error(`Unrecognized operation ${n}`);
|
|
187
|
+
return f.apply(t, s);
|
|
188
|
+
}
|
|
189
|
+
async function u(e) {
|
|
190
|
+
return i(e) ? u(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
191
|
+
}
|
|
192
|
+
function d(e) {
|
|
193
|
+
return Object.keys(e)[0];
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/utils/rules-logic.ts
|
|
197
|
+
function f(t) {
|
|
198
|
+
return !e(t);
|
|
199
|
+
}
|
|
200
|
+
async function p(e, t, n) {
|
|
201
|
+
let r = e.getStateSnapshot(), i = e.predicates.listStore.getState().reduce((e, t) => ({
|
|
202
|
+
...e,
|
|
203
|
+
[t.name]: (...e) => t.predicate({
|
|
204
|
+
...r,
|
|
205
|
+
args: e
|
|
206
|
+
})
|
|
207
|
+
}), {}), a = e.actions.listStore.getState().reduce((e, t) => ({
|
|
208
|
+
...e,
|
|
209
|
+
[t.name]: (...e) => t.action({
|
|
210
|
+
...r,
|
|
211
|
+
args: e
|
|
212
|
+
})
|
|
213
|
+
}), {}), o = e.features.listStore.getState().reduce((e, t) => ({
|
|
214
|
+
...e,
|
|
215
|
+
[t.id]: async () => {
|
|
216
|
+
let { bucket: e } = await t.getBucket();
|
|
217
|
+
return e;
|
|
218
|
+
}
|
|
219
|
+
}), {});
|
|
220
|
+
return await l(t, {
|
|
221
|
+
responses: e.responses.getAllStore.getState(),
|
|
222
|
+
location: typeof r.location == "object" ? {
|
|
223
|
+
hash: r.location.hash,
|
|
224
|
+
host: r.location.host,
|
|
225
|
+
hostname: r.location.hostname,
|
|
226
|
+
href: r.location.href,
|
|
227
|
+
origin: r.location.origin,
|
|
228
|
+
pathname: r.location.pathname,
|
|
229
|
+
port: r.location.port,
|
|
230
|
+
protocol: r.location.protocol,
|
|
231
|
+
search: r.location.search
|
|
232
|
+
} : void 0,
|
|
233
|
+
predicates: i,
|
|
234
|
+
actions: a,
|
|
235
|
+
features: o,
|
|
236
|
+
...n
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
export { f as n, p as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./object-CUJOjanb.cjs`);function t(e){return typeof e==`number`&&!isNaN(e)}function n(e){return typeof e==`string`}function r(e){return Array.isArray(e)}function i(e){return e instanceof Promise}function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===1}function o(e){if(t(e))return e;let n=parseFloat(`${e}`);return isNaN(n)?0:n}function s(e){return`${e}`}var c={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>o(e)>o(t),">=":(e,t)=>o(e)>=o(t),"<":(e,t,n)=>{let r=o(e),i=o(t);if(n===void 0)return r<i;let a=o(n);return r<i&&i<a},"<=":(e,t,n)=>{let r=o(e),i=o(t);if(n===void 0)return r<=i;let a=o(n);return r<=i&&i<=a},"!!":async e=>await u(e),"!":async e=>!await u(e),"%":(e,t)=>o(e)%o(t),log:e=>(console.log(e),e),in:(e,t)=>t?n(t)?t.indexOf(s(e))!==-1:r(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(s).join(``),substr:(e,t,n)=>{let r=s(e),i=o(t);if(n===void 0)return r.substr(i);let a=o(n);if(a<0){let e=r.substr(i);return e.substr(0,e.length+a)}return r.substr(i,a)},"+":(...e)=>e.reduce((e,t)=>o(e)+o(t),0),"*":(...e)=>e.reduce((e,t)=>o(e)*o(t),1),"-":(e,t)=>{let n=o(e);return t===void 0?-n:n-o(t)},"/":(e,t)=>o(e)/o(t),min:(...e)=>Math.min(...e.map(o)),max:(...e)=>Math.max(...e.map(o)),merge:(...e)=>e.reduce((e,t)=>r(t)?e.concat(t):e.concat([t]),[]),var(e,t){let n=arguments.length>1?t:null;if(e===``||e===`.`||e==null)return this;if(typeof e==`number`&&Array.isArray(this))return e>=0&&e<this.length?this[e]:n;let r=s(e);if(r===``||r===`.`)return this;let i=r.split(`.`),a=this;for(let e of i){if(a==null)return n;if(Array.isArray(a)){let t=parseInt(e,10);a=isNaN(t)?a[e]:a[t]}else a=a[e]}return a===void 0?n:a},async missing(...e){let t=r(e[0])?e[0]:e,n=[];for(let e of t){let t=await l({var:e},this);(t===null||t===``)&&n.push(`${e}`)}return n},async missing_some(e,t){let i=await l({missing:t},this);if(!r(i)||!r(t))return[];let a=i.filter(n);return t.filter(n).length-a.length>=o(e)?[]:a},invoke(...e){let[t,...n]=e;return typeof t==`function`?Reflect.apply(t,null,n):null},startsWith:(e,t)=>n(e)&&n(t)&&e.startsWith(t),endsWith:(e,t)=>n(e)&&n(t)&&e.endsWith(t),regexp_matches(e,t){let i=e,a=``;if(r(e)){let[t,n]=e;i=t,a=n}return!n(i)||!n(a)?!1:new RegExp(i,a).test(s(t))},throw(e){throw Error(s(e))}};async function l(e,t){if(!e)return e;if(i(e))return l(await e,t);if(r(e))return Promise.all(e.map(e=>l(e,t)));if(!a(e))return e;let n=d(e),o=n?e[n]??[]:[];switch(r(o)||(o=[o]),n){case`if`:case`?:`:for(let e=0;e<o.length-1;e+=2)if(await u(await l(o[e],t)))return l(o[e+1],t);return o.length%2==1?l(o[o.length-1],t):null;case`and`:{let e=null;for(let n of o)if(e=await l(n,t),!await u(e))return e;return e}case`or`:{let e=null;for(let n of o)if(e=await l(n,t),await u(e))return e;return e}case`map`:{let e=await l(o[0],t);return r(e)?await Promise.all(e.map(e=>l(o[1],e))):[]}case`filter`:{let e=await l(o[0],t);return r(e)?(await Promise.all(e.map(async e=>({item:e,shouldInclude:await u(await l(o[1],e))})))).filter(({shouldInclude:e})=>e).map(({item:e})=>e):[]}case`reduce`:{let e=await l(o[0],t);if(!r(e))return o.length>2?await l(o[2],t):null;let n=o[1],i=o.length>2?await l(o[2],t):null;for(let t of e)i=await l(n,{current:t,accumulator:i});return i}case`all`:{let e=await l(o[0],t);if(!r(e)||e.length===0)return!1;for(let t of e)if(!await u(await l(o[1],t)))return!1;return!0}case`some`:{let e=await l(o[0],t);if(!r(e))return!1;for(let t of e)if(await u(await l(o[1],t)))return!0;return!1}case`none`:{let e=await l(o[0],t);if(!r(e))return!0;for(let t of e)if(await u(await l(o[1],t)))return!1;return!0}case`catch`:try{return await l(o[0],t)}catch(e){return a(e)?await l(e,t):o[1]?await l(o[1],e):e instanceof Error?e.message:e}}let s=await Promise.all(o.map(e=>l(e,t))),f=n?c[n]:void 0;if(!f)throw Error(`Unrecognized operation ${n}`);return f.apply(t,s)}async function u(e){return i(e)?u(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function d(e){return Object.keys(e)[0]}function f(t){return!e.t(t)}async function p(e,t,n){let r=e.getStateSnapshot(),i=e.predicates.listStore.getState().reduce((e,t)=>({...e,[t.name]:(...e)=>t.predicate({...r,args:e})}),{}),a=e.actions.listStore.getState().reduce((e,t)=>({...e,[t.name]:(...e)=>t.action({...r,args:e})}),{}),o=e.features.listStore.getState().reduce((e,t)=>({...e,[t.id]:async()=>{let{bucket:e}=await t.getBucket();return e}}),{});return await l(t,{responses:e.responses.getAllStore.getState(),location:typeof r.location==`object`?{hash:r.location.hash,host:r.location.host,hostname:r.location.hostname,href:r.location.href,origin:r.location.origin,pathname:r.location.pathname,port:r.location.port,protocol:r.location.protocol,search:r.location.search}:void 0,predicates:i,actions:a,features:o,...n})}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return p}});
|
|
@@ -36,7 +36,9 @@ function o(e, t, r, i) {
|
|
|
36
36
|
function s(e, n) {
|
|
37
37
|
n === t && i(r(e));
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
window.addEventListener("storage", o), n.has(e._) || n.set(e._, /* @__PURE__ */ new Set());
|
|
40
|
+
let c = n.get(e._);
|
|
41
|
+
return c && c.add(s), function() {
|
|
40
42
|
window.removeEventListener("storage", o);
|
|
41
43
|
let t = n.get(e._);
|
|
42
44
|
t && (t.delete(s), t.size === 0 && n.delete(e._));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=e=>btoa([...e].map(e=>String.fromCharCode(e.charCodeAt(0)^7)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);function t(t,n=`global`,r){let i=`pckd`;if(n===`experience`){if(!r)throw Error(`Experience instance is required to scope storage to an experience`);i=`${i}:${r.experienceId}`}return{_:`${i}:${e(t)}`,scope:n}}var n=new Map;function r(e,t){let r=n.get(e._);r&&r.forEach(n=>n(e,t))}function i(e,t,n,i){let a=n===`local`?localStorage:sessionStorage,o=typeof t==`string`?t:JSON.stringify(t);if(a.setItem(e._,o),typeof i==`number`){let t=new Date(Date.now()+i).toISOString();a.setItem(`${e._}:expires-at`,t)}r(e,n)}function a(e,t){let n=t===`local`?localStorage:sessionStorage;n.removeItem(e._),n.removeItem(`${e._}:expires-at`),r(e,t)}function o(e,t,r,i){let a=t===`local`?localStorage:sessionStorage;function o(t){t.storageArea===a&&t.key===e._&&i(r(e))}function s(e,n){n===t&&i(r(e))}window.addEventListener(`storage`,o),n.has(e._)||n.set(e._,new Set);let c=n.get(e._);return c&&c.add(s),function(){window.removeEventListener(`storage`,o);let t=n.get(e._);t&&(t.delete(s),t.size===0&&n.delete(e._))}}function s(e,t){let n=t===`local`?localStorage:sessionStorage,r=n.getItem(e._),c=n.getItem(`${e._}:expires-at`),l=(n,r)=>i(e,n,t,r),u=()=>a(e,t),d=n=>o(e,t,e=>s(e,t),n);return c&&new Date>new Date(c)?(a(e,t),{isSet:()=>!1,text:()=>null,json:()=>null,boolean:()=>null,set:l,remove:u,subscribe:d}):{isSet(){return r!==null},text(){return r},json(){return r?JSON.parse(r):null},boolean(){return r?r===`true`:null},set:l,remove:u,subscribe:d}}var c={get(e){return s(e,`session`)},set(e,t,n){i(e,t,`session`,n)},remove(e){a(e,`session`)},subscribe(e,t){return o(e,`session`,this.get,t)}},l={get(e){return s(e,`local`)},set(e,t,n){i(e,t,`local`,n)},remove(e){a(e,`local`)},subscribe(e,t){return o(e,`local`,this.get,t)}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
package/dist/types/client.d.ts
CHANGED
|
@@ -7,34 +7,36 @@ import { LogicRule } from './logic-engine';
|
|
|
7
7
|
export interface CreateClientOptions {
|
|
8
8
|
/**
|
|
9
9
|
* Your organizations unique identifier.
|
|
10
|
-
* If not provided the organizationId will be read from
|
|
10
|
+
* If not provided the organizationId will be read from window.pickedConfig.organizationId or data-organizationid on the script tag.
|
|
11
11
|
*/
|
|
12
12
|
organizationId?: string;
|
|
13
13
|
/**
|
|
14
14
|
* Your projects unique identifier.
|
|
15
|
-
* If not provided the projectId will be read from
|
|
15
|
+
* If not provided the projectId will be read from window.pickedConfig.projectId or data-projectid on the script tag.
|
|
16
16
|
*/
|
|
17
17
|
projectId?: string;
|
|
18
18
|
/**
|
|
19
|
-
* Authentication token for previewing unpublished experiences
|
|
19
|
+
* Authentication token for previewing unpublished experiences.
|
|
20
20
|
*/
|
|
21
21
|
previewToken?: string;
|
|
22
22
|
/**
|
|
23
|
-
* Base URL for the Picked API service
|
|
23
|
+
* Base URL for the Picked API service.
|
|
24
24
|
*/
|
|
25
25
|
apiUrl?: string;
|
|
26
26
|
/**
|
|
27
|
-
* Base URL for the Picked Dashboard
|
|
27
|
+
* Base URL for the Picked Dashboard.
|
|
28
|
+
*
|
|
28
29
|
* @default 'https://dashboard.picked.app'
|
|
29
30
|
*/
|
|
30
31
|
dashboardUrl?: string;
|
|
31
32
|
/**
|
|
32
|
-
* Base URL for the documentation site shown in devtools
|
|
33
|
+
* Base URL for the documentation site shown in devtools.
|
|
34
|
+
*
|
|
33
35
|
* @default 'https://docs.picked.app'
|
|
34
36
|
*/
|
|
35
37
|
documentationSiteUrl?: string;
|
|
36
38
|
/**
|
|
37
|
-
* Register predicates to determine when experiences should be rendered
|
|
39
|
+
* Register predicates to determine when experiences should be rendered.
|
|
38
40
|
*
|
|
39
41
|
* @example
|
|
40
42
|
* ```typescript
|
|
@@ -47,20 +49,24 @@ export interface CreateClientOptions {
|
|
|
47
49
|
*/
|
|
48
50
|
predicates?: Record<string, Predicate>;
|
|
49
51
|
/**
|
|
50
|
-
* Register actions to be invoked in experience trees
|
|
52
|
+
* Register actions to be invoked in experience trees and JSON Logic conditions.
|
|
53
|
+
* Actions receive a state snapshot with full client context.
|
|
51
54
|
*
|
|
52
55
|
* @example
|
|
53
56
|
* ```typescript
|
|
54
57
|
* actions: {
|
|
55
|
-
* logEvent({
|
|
56
|
-
* // custom logic
|
|
58
|
+
* logEvent({ client, responses, location, args }) {
|
|
59
|
+
* // custom logic with access to full state
|
|
60
|
+
* },
|
|
61
|
+
* isLoggedIn({ responses }) {
|
|
62
|
+
* return responses.some(r => r.fieldKey === 'userId' && r.value)
|
|
57
63
|
* }
|
|
58
64
|
* }
|
|
59
65
|
* ```
|
|
60
66
|
*/
|
|
61
67
|
actions?: Record<string, Action>;
|
|
62
68
|
/**
|
|
63
|
-
* Plugins to extend client functionality
|
|
69
|
+
* Plugins to extend client functionality.
|
|
64
70
|
*
|
|
65
71
|
* @example
|
|
66
72
|
* ```typescript
|
|
@@ -73,24 +79,26 @@ export interface CreateClientOptions {
|
|
|
73
79
|
*/
|
|
74
80
|
plugins?: (Plugin | (() => Plugin) | Plugin[] | (() => Plugin[]))[];
|
|
75
81
|
/**
|
|
76
|
-
*
|
|
82
|
+
* Calculate AB test results to decide which experience to show.
|
|
77
83
|
*
|
|
78
84
|
* @example
|
|
79
|
-
```typescript
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
* ```typescript
|
|
86
|
+
* features: {
|
|
87
|
+
* 'summer-sales-experiment': {
|
|
88
|
+
* key: 'summer-sales-experiment-1',
|
|
89
|
+
* name: 'Summer Sales Experiment',
|
|
90
|
+
* decide: async () => {
|
|
91
|
+
* await new Promise((resolve) => setTimeout(resolve, 800))
|
|
92
|
+
* return false
|
|
93
|
+
* },
|
|
94
|
+
* weight: 0.2,
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
90
98
|
*/
|
|
91
99
|
features?: Record<string, Feature | (() => Feature)>;
|
|
92
100
|
/**
|
|
93
|
-
* Register components for use in dynamic experiences
|
|
101
|
+
* Register components for use in dynamic experiences.
|
|
94
102
|
*
|
|
95
103
|
* @example
|
|
96
104
|
* ```typescript
|
|
@@ -102,33 +110,29 @@ export interface CreateClientOptions {
|
|
|
102
110
|
*/
|
|
103
111
|
components?: Record<string, AdaptedComponent>;
|
|
104
112
|
/**
|
|
105
|
-
* Evaluate a condition or boolean expression before initializing the client
|
|
113
|
+
* Evaluate a condition or boolean expression before initializing the client.
|
|
106
114
|
*
|
|
107
115
|
* @example
|
|
108
116
|
* ```typescript
|
|
109
|
-
*
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
+
* precondition: {
|
|
118
|
+
* invoke: {
|
|
119
|
+
* var: 'predicates.shopify-is-product-page',
|
|
120
|
+
* },
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
117
123
|
*/
|
|
118
124
|
precondition?: LogicRule;
|
|
119
125
|
/**
|
|
120
|
-
* Evaluate a condition or boolean expression to determine the user state at initialization
|
|
126
|
+
* Evaluate a condition or boolean expression to determine the user state at initialization.
|
|
121
127
|
*
|
|
122
|
-
*
|
|
128
|
+
* @example
|
|
123
129
|
* ```typescript
|
|
124
|
-
*
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
*
|
|
131
|
-
*
|
|
130
|
+
* condition: {
|
|
131
|
+
* invoke: {
|
|
132
|
+
* var: 'features.convincely-enabled',
|
|
133
|
+
* },
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
132
136
|
*/
|
|
133
137
|
condition?: LogicRule;
|
|
134
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAE7B;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAEtC;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEhC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,EAAE,CAAA;IAEnE;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAA;IAEpD;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAE7C;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,SAAS,CAAA;IAExB;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB"}
|
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
import { Store } from 'effector';
|
|
2
|
-
|
|
2
|
+
import { StateSnapshot } from '../../utils/state-snaphot';
|
|
3
|
+
import { Picked } from '../../picked';
|
|
4
|
+
/**
|
|
5
|
+
* A named callable function that receives a state snapshot and optional arguments.
|
|
6
|
+
* Actions can return values (boolean, string, string[]) or execute side effects (void).
|
|
7
|
+
*/
|
|
8
|
+
export type Action = (snapshot: StateSnapshot & {
|
|
9
|
+
args: unknown[];
|
|
10
|
+
}) => boolean | Promise<boolean> | string | Promise<string> | string[] | Promise<string[]> | void | Promise<void> | undefined;
|
|
3
11
|
export type ActionsStore = ReturnType<typeof createActionIndexFactory>;
|
|
4
12
|
export interface ActionIndexItem {
|
|
5
13
|
name: string;
|
|
6
14
|
action: Action;
|
|
7
15
|
}
|
|
8
|
-
declare const createActionIndexFactory: (
|
|
16
|
+
declare const createActionIndexFactory: ({ client }: {
|
|
17
|
+
client: Picked;
|
|
18
|
+
}) => {
|
|
9
19
|
register: (name: string, action: Action) => void;
|
|
10
|
-
getByName: (name: string) => Store<
|
|
20
|
+
getByName: (name: string) => Store<Action | undefined>;
|
|
11
21
|
listStore: Store<ActionIndexItem[]>;
|
|
12
|
-
getEvokableAction: (actionName: string) => Store<(
|
|
22
|
+
getEvokableAction: (actionName: string) => Store<() => ReturnType<Action>>;
|
|
13
23
|
};
|
|
14
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Creates an action index with lifecycle stores and registration logic.
|
|
26
|
+
*
|
|
27
|
+
* @param {object} params - Factory parameters including the client.
|
|
28
|
+
* @returns {ReturnType<typeof createActionIndexFactory>} The action index with register, getByName, listStore, and getEvokableAction methods.
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const actions = createActionIndex({ client })
|
|
32
|
+
* actions.register('logEvent', ({ responses }) => { console.log(responses) })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function createActionIndex<T extends Parameters<typeof createActionIndexFactory>[0]>(params: T): ReturnType<typeof createActionIndexFactory>;
|
|
36
|
+
/**
|
|
37
|
+
* Convenience helper that registers a single action on the given store.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} name - Unique name for the action.
|
|
40
|
+
* @param {Action} action - The action function to register.
|
|
41
|
+
* @param {ActionsStore} actions - The actions store to register into.
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* setupAction('logEvent', ({ responses }) => { console.log(responses) }, actionsStore)
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
15
47
|
export declare const setupAction: (name: string, action: Action, actions: ActionsStore) => void;
|
|
16
48
|
export {};
|
|
17
49
|
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/entities/action/action.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/entities/action/action.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAA8D,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAGjG,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,CACnB,QAAQ,EAAE,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,KAE3C,OAAO,GACP,OAAO,CAAC,OAAO,CAAC,GAChB,MAAM,GACN,OAAO,CAAC,MAAM,CAAC,GACf,MAAM,EAAE,GACR,OAAO,CAAC,MAAM,EAAE,CAAC,GACjB,IAAI,GACJ,OAAO,CAAC,IAAI,CAAC,GACb,SAAS,CAAA;AAEb,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEtE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAKD,QAAA,MAAM,wBAAwB,eAA8B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;qBA2BpD,MAAM,UAAU,MAAM,KAAG,IAAI;sBA2B5B,MAAM;;oCAiBQ,MAAM,KAAG,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;CAuC/E,CAAA;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,EACxF,MAAM,EAAE,CAAC,GACR,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAE7C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,YAAY,KAAG,IAEjF,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LogicRule } from '../../logic-engine';
|
|
2
|
+
export type ConditionsStore = ReturnType<typeof createConditionIndex>;
|
|
3
|
+
export interface Condition {
|
|
4
|
+
id: string;
|
|
5
|
+
key: string;
|
|
6
|
+
name: string;
|
|
7
|
+
logic: LogicRule;
|
|
8
|
+
}
|
|
9
|
+
declare const createConditionIndexFactory: () => {
|
|
10
|
+
register: (condition: Condition) => void;
|
|
11
|
+
getById: (id: Condition["id"]) => import('effector').Store<Condition | null>;
|
|
12
|
+
getByKey: (key: Condition["key"]) => import('effector').Store<Condition | null>;
|
|
13
|
+
listStore: import('effector').Store<Condition[]>;
|
|
14
|
+
indexStore: import('effector').StoreWritable<{
|
|
15
|
+
[id: string]: Condition;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
export declare function createConditionIndex(): ReturnType<typeof createConditionIndexFactory>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=condition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../../../../src/entities/condition/condition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAIrE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,CAAA;CACjB;AAGD,QAAA,MAAM,2BAA2B;0BAcF,SAAS,KAAG,IAAI;kBAcxB,SAAS,CAAC,IAAI,CAAC;oBAUb,SAAS,CAAC,KAAK,CAAC;;;;;CAgBvC,CAAA;AAEF,wBAAgB,oBAAoB,IAAI,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAErF"}
|