@plitzi/sdk-interactions 0.39.14 → 0.39.16
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/CHANGELOG.md +22 -0
- package/dist/InteractionsHelper.mjs +62 -52
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @plitzi/sdk-interactions
|
|
2
2
|
|
|
3
|
+
## 0.39.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0389dd0: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [0389dd0]
|
|
10
|
+
- @plitzi/sdk-auth@0.39.16
|
|
11
|
+
- @plitzi/sdk-event-bridge@0.39.16
|
|
12
|
+
- @plitzi/sdk-shared@0.39.16
|
|
13
|
+
|
|
14
|
+
## 0.39.15
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 359fd04: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
19
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
20
|
+
- Updated dependencies [359fd04]
|
|
21
|
+
- @plitzi/sdk-auth@0.39.15
|
|
22
|
+
- @plitzi/sdk-event-bridge@0.39.15
|
|
23
|
+
- @plitzi/sdk-shared@0.39.15
|
|
24
|
+
|
|
3
25
|
## 0.39.14
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -3,43 +3,44 @@ import t from "./utility/index.mjs";
|
|
|
3
3
|
import { get as n, omit as r } from "@plitzi/plitzi-ui/helpers";
|
|
4
4
|
import { pConsole as i } from "@plitzi/sdk-shared/devTools";
|
|
5
5
|
import { evaluateRuleGroup as a, ruleValuesOf as o } from "@plitzi/sdk-shared/conditions";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { flowStarted as s } from "@plitzi/sdk-shared/devTools/running";
|
|
7
|
+
import { MAX_PARAM_PASSES as c, resolveStepParam as l } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
8
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
9
|
// src/InteractionsHelper.tsx
|
|
9
|
-
var
|
|
10
|
+
var p = 5, m = (e, t, n, r, a) => {
|
|
10
11
|
if (e === "utility" && a === "twigTemplate") return t;
|
|
11
12
|
let o = {
|
|
12
13
|
...n,
|
|
13
14
|
...r
|
|
14
|
-
},
|
|
15
|
+
}, s = (e, t, n) => {
|
|
15
16
|
if (typeof e == "string") {
|
|
16
|
-
let { value: n, unresolved: r } =
|
|
17
|
-
return r && i.warning("interactions", /* @__PURE__ */
|
|
17
|
+
let { value: n, unresolved: r } = l(e, o);
|
|
18
|
+
return r && i.warning("interactions", /* @__PURE__ */ f("span", { children: [
|
|
18
19
|
"Twig token resolution exceeded ",
|
|
19
|
-
|
|
20
|
+
c,
|
|
20
21
|
" passes for ",
|
|
21
|
-
/* @__PURE__ */
|
|
22
|
+
/* @__PURE__ */ d("b", { children: t }),
|
|
22
23
|
", leaving unresolved tokens"
|
|
23
24
|
] }), {
|
|
24
25
|
param: t,
|
|
25
26
|
value: n
|
|
26
27
|
}), n;
|
|
27
28
|
}
|
|
28
|
-
return n >=
|
|
29
|
+
return n >= p || typeof e != "object" || !e ? e : Array.isArray(e) ? e.map((e) => s(e, t, n + 1)) : Object.fromEntries(Object.entries(e).map(([e, r]) => [e, s(r, t, n + 1)]));
|
|
29
30
|
};
|
|
30
31
|
return Object.keys(t).reduce((n, r) => {
|
|
31
|
-
let i = e === "trigger" ? t[r] :
|
|
32
|
+
let i = e === "trigger" ? t[r] : s(t[r], r, 0);
|
|
32
33
|
return {
|
|
33
34
|
...n,
|
|
34
35
|
[r]: i
|
|
35
36
|
};
|
|
36
37
|
}, {});
|
|
37
|
-
},
|
|
38
|
-
let
|
|
38
|
+
}, h = (e) => typeof e == "object" && !!e && "then" in e && typeof e.then == "function", g = (r, s = {}, c = {}, l = {}, u = {}) => {
|
|
39
|
+
let p = [], { id: g, action: _, enabled: v, params: y, elementId: b, type: x, when: S } = r;
|
|
39
40
|
if (!_ || !v) return {
|
|
40
41
|
status: "disabled",
|
|
41
42
|
result: {},
|
|
42
|
-
postCallbacks:
|
|
43
|
+
postCallbacks: p
|
|
43
44
|
};
|
|
44
45
|
let C = o({
|
|
45
46
|
...l,
|
|
@@ -49,34 +50,34 @@ var f = 5, p = (e, t, n, r, a) => {
|
|
|
49
50
|
if (S && !a(S, C)) return {
|
|
50
51
|
status: "skipped",
|
|
51
52
|
result: {},
|
|
52
|
-
postCallbacks:
|
|
53
|
+
postCallbacks: p,
|
|
53
54
|
whenParams: C
|
|
54
55
|
};
|
|
55
|
-
let w = (e) => (i.danger("interactions", /* @__PURE__ */
|
|
56
|
+
let w = (e) => (i.danger("interactions", /* @__PURE__ */ f("span", { children: ["Interaction node failed ", /* @__PURE__ */ d("b", { children: _ })] }), {
|
|
56
57
|
error: e instanceof Error ? e.message : String(e),
|
|
57
58
|
node: r
|
|
58
59
|
}), {
|
|
59
60
|
status: "failed",
|
|
60
61
|
result: {},
|
|
61
|
-
postCallbacks:
|
|
62
|
+
postCallbacks: p,
|
|
62
63
|
whenParams: C
|
|
63
64
|
}), T;
|
|
64
65
|
switch (x) {
|
|
65
66
|
case "callback":
|
|
66
67
|
case "globalCallback":
|
|
67
|
-
if (!b) return i.warning("interactions", /* @__PURE__ */
|
|
68
|
+
if (!b) return i.warning("interactions", /* @__PURE__ */ f("span", { children: [
|
|
68
69
|
"Step ",
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ d("b", { children: _ }),
|
|
70
71
|
" names no element, so there is nothing to run it on"
|
|
71
72
|
] }), { node: r }), {
|
|
72
73
|
status: "failed",
|
|
73
74
|
result: {},
|
|
74
|
-
postCallbacks:
|
|
75
|
+
postCallbacks: p,
|
|
75
76
|
whenParams: C
|
|
76
77
|
};
|
|
77
|
-
if (T = n(s, `${b}.${_}`), !T) return i.warning("interactions", /* @__PURE__ */
|
|
78
|
+
if (T = n(s, `${b}.${_}`), !T) return i.warning("interactions", /* @__PURE__ */ f("span", { children: [
|
|
78
79
|
"Nothing is registered as ",
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
+
/* @__PURE__ */ d("b", { children: `${b}.${_}` }),
|
|
80
81
|
", so this step did nothing"
|
|
81
82
|
] }), {
|
|
82
83
|
node: r,
|
|
@@ -84,7 +85,7 @@ var f = 5, p = (e, t, n, r, a) => {
|
|
|
84
85
|
}), {
|
|
85
86
|
status: "failed",
|
|
86
87
|
result: {},
|
|
87
|
-
postCallbacks:
|
|
88
|
+
postCallbacks: p,
|
|
88
89
|
whenParams: C
|
|
89
90
|
};
|
|
90
91
|
break;
|
|
@@ -94,7 +95,7 @@ var f = 5, p = (e, t, n, r, a) => {
|
|
|
94
95
|
default: return {
|
|
95
96
|
status: "success",
|
|
96
97
|
result: {},
|
|
97
|
-
postCallbacks:
|
|
98
|
+
postCallbacks: p,
|
|
98
99
|
whenParams: C
|
|
99
100
|
};
|
|
100
101
|
}
|
|
@@ -102,8 +103,8 @@ var f = 5, p = (e, t, n, r, a) => {
|
|
|
102
103
|
let t = {
|
|
103
104
|
...c,
|
|
104
105
|
...l,
|
|
105
|
-
...e(T.params,
|
|
106
|
-
}, { callback: n, postCallback: r } = T, i = (e) => (r &&
|
|
106
|
+
...e(T.params, m(x, y, c, l, _))
|
|
107
|
+
}, { callback: n, postCallback: r } = T, i = (e) => (r && p.push({
|
|
107
108
|
id: g,
|
|
108
109
|
callback: r,
|
|
109
110
|
params: {
|
|
@@ -113,45 +114,45 @@ var f = 5, p = (e, t, n, r, a) => {
|
|
|
113
114
|
}), {
|
|
114
115
|
status: "success",
|
|
115
116
|
result: e,
|
|
116
|
-
postCallbacks:
|
|
117
|
+
postCallbacks: p,
|
|
117
118
|
whenParams: C
|
|
118
|
-
}), a = n ? n(t,
|
|
119
|
-
return
|
|
119
|
+
}), a = n ? n(t, u) : {};
|
|
120
|
+
return h(a) ? Promise.resolve(a).then(i, w) : i(a);
|
|
120
121
|
} catch (e) {
|
|
121
122
|
return w(e);
|
|
122
123
|
}
|
|
123
|
-
},
|
|
124
|
+
}, _ = async (e = []) => {
|
|
124
125
|
let t = {};
|
|
125
126
|
return await Promise.all(e.reverse().map(async ({ id: e, callback: n, params: i }) => {
|
|
126
127
|
t[e] = await n?.(r(i, [e]), i[e]);
|
|
127
128
|
})), t;
|
|
128
|
-
},
|
|
129
|
+
}, v = () => ({}), y = async (e, t = {}, r = {}, a = {}, o = v, s = [], c = {}, l = {}) => {
|
|
129
130
|
let u = e, d = a;
|
|
130
131
|
for (; u;) {
|
|
131
132
|
if (l.signal?.aborted) return c;
|
|
132
133
|
let e = n(t, u.afterNode);
|
|
133
|
-
if (!e) return s.length > 0 && await
|
|
134
|
-
let a = i.getTime().valueOf(), f =
|
|
134
|
+
if (!e) return s.length > 0 && await _(s), c;
|
|
135
|
+
let a = i.getTime().valueOf(), f = g(e, r, d, o(), l), p = h(f) ? await f : f, { result: m, postCallbacks: v, whenParams: y } = p, b = p.status === "failed" && l.signal?.aborted ? "skipped" : p.status;
|
|
135
136
|
c[e.id] = {
|
|
136
137
|
node: e,
|
|
137
138
|
status: b,
|
|
138
|
-
result:
|
|
139
|
+
result: m,
|
|
139
140
|
postCallbacks: v,
|
|
140
141
|
whenParams: y,
|
|
141
142
|
startTime: a,
|
|
142
143
|
endTime: i.getTime().valueOf()
|
|
143
144
|
}, s.push(...v), d = {
|
|
144
145
|
...d,
|
|
145
|
-
[e.id]:
|
|
146
|
+
[e.id]: m
|
|
146
147
|
}, u = e;
|
|
147
148
|
}
|
|
148
149
|
return c;
|
|
149
|
-
},
|
|
150
|
-
let o = i.getTime().valueOf(), s = r === "skipped" ? "skipped" : "success", c = /* @__PURE__ */
|
|
150
|
+
}, b = (e, t, n = {}, r, a) => {
|
|
151
|
+
let o = i.getTime().valueOf(), s = r === "skipped" ? "skipped" : "success", c = /* @__PURE__ */ f("span", { children: [
|
|
151
152
|
"Interaction triggered ",
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
a ? /* @__PURE__ */
|
|
154
|
-
] }),
|
|
153
|
+
/* @__PURE__ */ d("b", { children: `${e.title} [${e.action}]` }),
|
|
154
|
+
a ? /* @__PURE__ */ f(u, { children: [" on ", /* @__PURE__ */ d("b", { children: a })] }) : null
|
|
155
|
+
] }), l = {
|
|
155
156
|
status: r,
|
|
156
157
|
node: e,
|
|
157
158
|
elementId: e.elementId,
|
|
@@ -170,20 +171,29 @@ var f = 5, p = (e, t, n, r, a) => {
|
|
|
170
171
|
startTime: t,
|
|
171
172
|
endTime: o
|
|
172
173
|
};
|
|
173
|
-
r === "failed" ? i.danger("interactions", c,
|
|
174
|
-
},
|
|
175
|
-
let
|
|
176
|
-
if (!
|
|
177
|
-
...
|
|
174
|
+
r === "failed" ? i.danger("interactions", c, l) : i.info("interactions", c, l);
|
|
175
|
+
}, x = (e) => Object.values(e).some(({ status: e }) => e === "failed") ? "failed" : "completed", S = async (e, t = {}, n = {}, r = {}, c = v, l, u, d = []) => {
|
|
176
|
+
let f = i.getTime().valueOf(), { action: p, enabled: m, when: h } = e;
|
|
177
|
+
if (!p || !m || h && !a(h, o({
|
|
178
|
+
...c(),
|
|
178
179
|
...r
|
|
179
180
|
}))) {
|
|
180
|
-
|
|
181
|
+
b(e, f, {}, "skipped", l);
|
|
181
182
|
return;
|
|
182
183
|
}
|
|
183
|
-
let
|
|
184
|
-
|
|
185
|
-
...l ? {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
184
|
+
let g = s({
|
|
185
|
+
trigger: `${e.title} [${e.action}]`,
|
|
186
|
+
...l ? { on: l } : {},
|
|
187
|
+
since: f
|
|
188
|
+
}), _;
|
|
189
|
+
try {
|
|
190
|
+
_ = await y(e, t, n, r, c, d, {}, {
|
|
191
|
+
hostElementId: l,
|
|
192
|
+
...u ? { signal: u } : {}
|
|
193
|
+
});
|
|
194
|
+
} finally {
|
|
195
|
+
g();
|
|
196
|
+
}
|
|
197
|
+
b(e, f, _, x(_), l);
|
|
198
|
+
}, C = { flowTrigger: S };
|
|
199
|
+
export { C as default, S as flowTrigger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-interactions",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.16",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@plitzi/nexus": "^1.5.1",
|
|
42
42
|
"@plitzi/plitzi-ui": "^1.6.41",
|
|
43
|
-
"@plitzi/sdk-auth": "0.39.
|
|
44
|
-
"@plitzi/sdk-event-bridge": "0.39.
|
|
45
|
-
"@plitzi/sdk-shared": "0.39.
|
|
43
|
+
"@plitzi/sdk-auth": "0.39.16",
|
|
44
|
+
"@plitzi/sdk-event-bridge": "0.39.16",
|
|
45
|
+
"@plitzi/sdk-shared": "0.39.16"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "^19"
|