@plitzi/sdk-interactions 0.30.19 → 0.31.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/CHANGELOG.md +14 -0
- package/dist/InteractionsHelper.mjs +97 -75
- package/dist/InteractionsManager.mjs +14 -9
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @plitzi/sdk-interactions
|
|
2
2
|
|
|
3
|
+
## 0.31.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- v0.31.0
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @plitzi/sdk-auth@0.31.0
|
|
13
|
+
- @plitzi/sdk-dev-tools@0.31.0
|
|
14
|
+
- @plitzi/sdk-event-bridge@0.31.0
|
|
15
|
+
- @plitzi/sdk-shared@0.31.0
|
|
16
|
+
|
|
3
17
|
## 0.30.19
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -5,112 +5,134 @@ import { pConsole as i } from "@plitzi/sdk-shared/devTools/utils/PlitziConsole";
|
|
|
5
5
|
import { hasValidToken as a, processTwig as o } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
6
6
|
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
7
|
//#region src/InteractionsHelper.tsx
|
|
8
|
-
var l = (e, t, n, r,
|
|
9
|
-
let
|
|
8
|
+
var l = 5, u = (e, t, n, r, u) => e === "utility" && u === "twigTemplate" ? t : Object.keys(t).reduce((u, d) => {
|
|
9
|
+
let f = t[d];
|
|
10
10
|
if (e !== "trigger") {
|
|
11
|
-
let e =
|
|
12
|
-
for (; typeof
|
|
11
|
+
let e = l;
|
|
12
|
+
for (; typeof f == "string" && a(f) && e > 0;) f = o(f, {
|
|
13
13
|
...n,
|
|
14
14
|
...r
|
|
15
15
|
}, !1, !0), e--;
|
|
16
|
+
typeof f == "string" && a(f) && i.warning("interactions", /* @__PURE__ */ c("span", { children: [
|
|
17
|
+
"Twig token resolution exceeded ",
|
|
18
|
+
l,
|
|
19
|
+
" passes for ",
|
|
20
|
+
/* @__PURE__ */ s("b", { children: d }),
|
|
21
|
+
", leaving unresolved tokens"
|
|
22
|
+
] }), {
|
|
23
|
+
param: d,
|
|
24
|
+
value: f
|
|
25
|
+
});
|
|
16
26
|
}
|
|
17
27
|
return {
|
|
18
|
-
...
|
|
19
|
-
[
|
|
28
|
+
...u,
|
|
29
|
+
[d]: f
|
|
20
30
|
};
|
|
21
|
-
}, {}),
|
|
22
|
-
let
|
|
23
|
-
if (!
|
|
31
|
+
}, {}), d = async (n, a = {}, o = {}, l = {}) => {
|
|
32
|
+
let d = {}, f = [], { id: p, action: m, enabled: h, params: g, elementId: _, type: v, when: y } = n;
|
|
33
|
+
if (!m || !h) return {
|
|
24
34
|
status: "disabled",
|
|
25
|
-
result:
|
|
26
|
-
postCallbacks:
|
|
35
|
+
result: d,
|
|
36
|
+
postCallbacks: f
|
|
27
37
|
};
|
|
28
|
-
let
|
|
38
|
+
let b = {
|
|
39
|
+
...l,
|
|
29
40
|
...o,
|
|
30
|
-
|
|
31
|
-
[u]: p
|
|
41
|
+
[p]: g
|
|
32
42
|
};
|
|
33
|
-
if (
|
|
43
|
+
if (y && !r(y, b)) return {
|
|
34
44
|
status: "skipped",
|
|
35
|
-
result:
|
|
36
|
-
postCallbacks:
|
|
37
|
-
whenParams:
|
|
45
|
+
result: d,
|
|
46
|
+
postCallbacks: f,
|
|
47
|
+
whenParams: b
|
|
38
48
|
};
|
|
39
|
-
let
|
|
40
|
-
...a,
|
|
49
|
+
let x = {
|
|
41
50
|
...o,
|
|
42
|
-
...l
|
|
51
|
+
...l,
|
|
52
|
+
...u(v, g, o, l, m)
|
|
43
53
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
54
|
+
try {
|
|
55
|
+
switch (v) {
|
|
56
|
+
case "callback":
|
|
57
|
+
case "globalCallback": {
|
|
58
|
+
if (!_) return {
|
|
59
|
+
status: "failed",
|
|
60
|
+
result: d,
|
|
61
|
+
postCallbacks: f,
|
|
62
|
+
whenParams: b
|
|
63
|
+
};
|
|
64
|
+
let e = t(a, `${_}.${m}`);
|
|
65
|
+
if (!e) return {
|
|
66
|
+
status: "failed",
|
|
67
|
+
result: d,
|
|
68
|
+
postCallbacks: f,
|
|
69
|
+
whenParams: b
|
|
70
|
+
};
|
|
71
|
+
let { callback: n, postCallback: r } = e;
|
|
72
|
+
n && (d = await n(x)), r && f.push({
|
|
73
|
+
id: p,
|
|
74
|
+
callback: r,
|
|
75
|
+
params: {
|
|
76
|
+
...x,
|
|
77
|
+
[p]: d
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "utility": {
|
|
83
|
+
let { callback: n, postCallback: r } = t(e, m, {});
|
|
84
|
+
n && (d = await n(x)), r && f.push({
|
|
85
|
+
id: p,
|
|
86
|
+
callback: r,
|
|
87
|
+
params: {
|
|
88
|
+
...x,
|
|
89
|
+
[p]: d
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
default:
|
|
82
95
|
}
|
|
83
|
-
|
|
96
|
+
} catch (e) {
|
|
97
|
+
return i.danger("interactions", /* @__PURE__ */ c("span", { children: ["Interaction node failed ", /* @__PURE__ */ s("b", { children: m })] }), {
|
|
98
|
+
error: e instanceof Error ? e.message : String(e),
|
|
99
|
+
node: n
|
|
100
|
+
}), {
|
|
101
|
+
status: "failed",
|
|
102
|
+
result: d,
|
|
103
|
+
postCallbacks: f,
|
|
104
|
+
whenParams: b
|
|
105
|
+
};
|
|
84
106
|
}
|
|
85
107
|
return {
|
|
86
108
|
status: "success",
|
|
87
|
-
result:
|
|
88
|
-
postCallbacks:
|
|
89
|
-
whenParams:
|
|
109
|
+
result: d,
|
|
110
|
+
postCallbacks: f,
|
|
111
|
+
whenParams: b
|
|
90
112
|
};
|
|
91
|
-
},
|
|
113
|
+
}, f = async (e = []) => {
|
|
92
114
|
let t = {};
|
|
93
115
|
return await Promise.all(e.reverse().map(async ({ id: e, callback: r, params: i }) => {
|
|
94
116
|
t[e] = await r?.(n(i, [e]), i[e]);
|
|
95
117
|
})), t;
|
|
96
|
-
},
|
|
118
|
+
}, p = async (e, n = {}, r = {}, a = {}, o = {}, s = [], c = {}) => {
|
|
97
119
|
if (!e) return c;
|
|
98
120
|
let l = t(n, e.afterNode);
|
|
99
|
-
if (!l && s.length > 0 && await
|
|
100
|
-
let
|
|
121
|
+
if (!l && s.length > 0 && await f(s), !l) return c;
|
|
122
|
+
let u = i.getTime().valueOf(), { status: m, result: h, postCallbacks: g, whenParams: _ } = await d(l, r, a, o);
|
|
101
123
|
return c[l.id] = {
|
|
102
124
|
node: l,
|
|
103
125
|
status: m,
|
|
104
126
|
result: h,
|
|
105
127
|
postCallbacks: g,
|
|
106
128
|
whenParams: _,
|
|
107
|
-
startTime:
|
|
129
|
+
startTime: u,
|
|
108
130
|
endTime: i.getTime().valueOf()
|
|
109
|
-
}, s.push(...g),
|
|
131
|
+
}, s.push(...g), p(l, n, r, {
|
|
110
132
|
...a,
|
|
111
133
|
[l.id]: h
|
|
112
134
|
}, o, s, c);
|
|
113
|
-
},
|
|
135
|
+
}, m = (e, t, n = {}, r) => {
|
|
114
136
|
let a = i.getTime().valueOf(), o = "skipped";
|
|
115
137
|
r === "completed" && (o = "success"), i.info("interactions", /* @__PURE__ */ c("span", { children: ["Interaction triggered ", /* @__PURE__ */ s("b", { children: `${e.title} [${e.action}]` })] }), {
|
|
116
138
|
status: r,
|
|
@@ -130,16 +152,16 @@ var l = (e, t, n, r, i) => e === "utility" && i === "twigTemplate" ? t : Object.
|
|
|
130
152
|
startTime: t,
|
|
131
153
|
endTime: a
|
|
132
154
|
});
|
|
133
|
-
},
|
|
155
|
+
}, h = async (e, t = {}, n = {}, a = {}, o = {}, s = []) => {
|
|
134
156
|
let c = i.getTime().valueOf(), { action: l, enabled: u, when: d } = e;
|
|
135
157
|
if (!l || !u || d && !r(d, {
|
|
136
158
|
...o,
|
|
137
159
|
...a
|
|
138
160
|
})) {
|
|
139
|
-
|
|
161
|
+
m(e, c, {}, "skipped");
|
|
140
162
|
return;
|
|
141
163
|
}
|
|
142
|
-
|
|
143
|
-
},
|
|
164
|
+
m(e, c, await p(e, t, n, a, o, s), "completed");
|
|
165
|
+
}, g = { flowTrigger: h };
|
|
144
166
|
//#endregion
|
|
145
|
-
export {
|
|
167
|
+
export { g as default, h as flowTrigger };
|
|
@@ -20,15 +20,20 @@ var i = class i {
|
|
|
20
20
|
}, this.lastUpdate = Date.now();
|
|
21
21
|
}
|
|
22
22
|
eventBridgeCallback = (r) => async (i, a, o) => {
|
|
23
|
-
if (!r || !a || !i || t(this.interactionsRunning, `${i}.${a}`))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
if (!(!r || !a || !i || t(this.interactionsRunning, `${i}.${a}`))) {
|
|
24
|
+
n(this.interactionsRunning, `${i}.${a}`, !0);
|
|
25
|
+
try {
|
|
26
|
+
let n = t(this.subscriptors, `${i}.getAdditionalParams`, void 0), s;
|
|
27
|
+
typeof n == "function" && ({dataSource: s} = n());
|
|
28
|
+
let c = Object.values(r).filter((e) => e.type === "trigger" && e.action === a && e.enabled);
|
|
29
|
+
await Promise.all(c.map((t) => e(t, r, this.getCallbacksAvailables(), { [t.id]: o }, {
|
|
30
|
+
...this.interactionsData,
|
|
31
|
+
...s
|
|
32
|
+
})));
|
|
33
|
+
} finally {
|
|
34
|
+
n(this.interactionsRunning, `${i}.${a}`, !1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
32
37
|
};
|
|
33
38
|
subscribe(e, t = {}, r = {}, i = {}, a) {
|
|
34
39
|
if (this.subscriptors[e]) return !1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-interactions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -78,6 +78,8 @@
|
|
|
78
78
|
"scripts": {
|
|
79
79
|
"lint": "eslint ./src",
|
|
80
80
|
"typecheck": "tsc -p tsconfig.app.json --noEmit",
|
|
81
|
+
"test": "vitest run",
|
|
82
|
+
"test:watch": "vitest",
|
|
81
83
|
"build:dev": "vite build --mode development --minify false && node ../sdk-shared/scripts/generate-exports.mjs",
|
|
82
84
|
"build:dev-watch": "vite build --mode development --watch --minify false",
|
|
83
85
|
"build:prod": "vite build && node ../sdk-shared/scripts/generate-exports.mjs"
|
|
@@ -87,13 +89,14 @@
|
|
|
87
89
|
"devDependencies": {
|
|
88
90
|
"eslint": "^9.39.4",
|
|
89
91
|
"typescript": "^6.0.3",
|
|
90
|
-
"vite": "^8.0.
|
|
92
|
+
"vite": "^8.0.14",
|
|
93
|
+
"vitest": "^4.1.7"
|
|
91
94
|
},
|
|
92
95
|
"dependencies": {
|
|
93
|
-
"@plitzi/plitzi-ui": "^1.6.
|
|
94
|
-
"@plitzi/sdk-auth": "0.
|
|
95
|
-
"@plitzi/sdk-dev-tools": "0.
|
|
96
|
-
"@plitzi/sdk-event-bridge": "0.
|
|
97
|
-
"@plitzi/sdk-shared": "0.
|
|
96
|
+
"@plitzi/plitzi-ui": "^1.6.9",
|
|
97
|
+
"@plitzi/sdk-auth": "0.31.0",
|
|
98
|
+
"@plitzi/sdk-dev-tools": "0.31.0",
|
|
99
|
+
"@plitzi/sdk-event-bridge": "0.31.0",
|
|
100
|
+
"@plitzi/sdk-shared": "0.31.0"
|
|
98
101
|
}
|
|
99
102
|
}
|