@plitzi/sdk-interactions 0.37.1 → 0.37.3
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 +1304 -0
- package/dist/InteractionsContextProvider.d.ts +1 -1
- package/dist/InteractionsHelper.d.ts +11 -2
- package/dist/InteractionsHelper.mjs +116 -120
- package/dist/InteractionsManager.d.ts +16 -1
- package/dist/InteractionsManager.mjs +40 -27
- package/dist/InteractionsSourcesProvider.d.ts +1 -1
- package/dist/hooks/useInteractions.mjs +3 -1
- package/dist/sources/ActionsSource/ActionInteractions.mjs +8 -3
- package/dist/sources/ActionsSource/callbacks.mjs +4 -3
- package/dist/sources/AuthSource/callbacks.mjs +20 -2
- package/dist/sources/StateSource/StateInteractions.mjs +46 -33
- package/dist/sources/StateSource/callbacks.mjs +7 -5
- package/dist/utility/index.d.ts +2 -1
- package/dist/utility/webHook.d.ts +4 -1
- package/dist/utility/webHook.mjs +26 -23
- package/dist/utility/webHookSpec.mjs +10 -3
- package/package.json +9 -9
- package/dist/utility/transformer.d.ts +0 -1
- package/dist/utility/transformer.mjs +0 -0
|
@@ -6,5 +6,5 @@ export type InteractionsContextProviderProps = {
|
|
|
6
6
|
routeParams: RouteParams;
|
|
7
7
|
queryParams: QueryParams;
|
|
8
8
|
};
|
|
9
|
-
declare const InteractionsContextProvider: ({ children, currentPageId, routeParams, queryParams }: InteractionsContextProviderProps) => import(
|
|
9
|
+
declare const InteractionsContextProvider: ({ children, currentPageId, routeParams, queryParams }: InteractionsContextProviderProps) => import('react').JSX.Element;
|
|
10
10
|
export default InteractionsContextProvider;
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { ElementInteraction } from '@plitzi/sdk-shared';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The page's sources, as a step reads them.
|
|
4
|
+
*
|
|
5
|
+
* A function rather than a value because it is called before EVERY step: a step sees what the steps before it wrote,
|
|
6
|
+
* and whatever else changed while the flow waited — a `delay`, a request, a person clicking. Read once when the
|
|
7
|
+
* trigger fired, every step saw the page as it was then: a condition after a `delay` could not tell that the reader
|
|
8
|
+
* had moved on, and a step after `setState` read the value from before it.
|
|
9
|
+
*/
|
|
10
|
+
export type ReadGlobals = () => Record<string, unknown>;
|
|
11
|
+
declare const flowTrigger: (triggerNode: ElementInteraction, nodes?: {}, callbacksAvailables?: {}, flowParams?: Record<string, unknown>, readGlobals?: ReadGlobals,
|
|
3
12
|
/** The id of the element this fired on, carried through purely so the log can name it. */
|
|
4
13
|
hostElementId?: string, postCallbacksTotal?: never[]) => Promise<void>;
|
|
5
14
|
export { flowTrigger };
|
|
6
15
|
declare const InteractionsHelper: {
|
|
7
|
-
flowTrigger: (triggerNode: ElementInteraction, nodes?: {}, callbacksAvailables?: {}, flowParams?: Record<string, unknown>,
|
|
16
|
+
flowTrigger: (triggerNode: ElementInteraction, nodes?: {}, callbacksAvailables?: {}, flowParams?: Record<string, unknown>, readGlobals?: ReadGlobals, hostElementId?: string, postCallbacksTotal?: never[]) => Promise<void>;
|
|
8
17
|
};
|
|
9
18
|
export default InteractionsHelper;
|
|
@@ -2,21 +2,20 @@ import e from "./utility/index.mjs";
|
|
|
2
2
|
import { get as t, omit as n } from "@plitzi/plitzi-ui/helpers";
|
|
3
3
|
import { QueryBuilderEvaluator as r } from "@plitzi/plitzi-ui/QueryBuilder";
|
|
4
4
|
import { pConsole as i } from "@plitzi/sdk-shared/devTools/utils/PlitziConsole";
|
|
5
|
-
import {
|
|
5
|
+
import { MAX_PARAM_PASSES as a, resolveStepParam as o } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
6
6
|
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
7
|
//#region src/InteractionsHelper.tsx
|
|
8
|
-
var u = 5, d =
|
|
8
|
+
var u = 5, d = (e, t, n, r, s) => {
|
|
9
9
|
if (e === "utility" && s === "twigTemplate") return t;
|
|
10
|
-
let
|
|
10
|
+
let d = {
|
|
11
11
|
...n,
|
|
12
12
|
...r
|
|
13
|
-
},
|
|
13
|
+
}, f = (e, t, n) => {
|
|
14
14
|
if (typeof e == "string") {
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
return typeof n == "string" && a(n) && i.warning("interactions", /* @__PURE__ */ l("span", { children: [
|
|
15
|
+
let { value: n, unresolved: r } = o(e, d);
|
|
16
|
+
return r && i.warning("interactions", /* @__PURE__ */ l("span", { children: [
|
|
18
17
|
"Twig token resolution exceeded ",
|
|
19
|
-
|
|
18
|
+
a,
|
|
20
19
|
" passes for ",
|
|
21
20
|
/* @__PURE__ */ c("b", { children: t }),
|
|
22
21
|
", leaving unresolved tokens"
|
|
@@ -25,130 +24,127 @@ var u = 5, d = 5, f = (e, t, n, r, s) => {
|
|
|
25
24
|
value: n
|
|
26
25
|
}), n;
|
|
27
26
|
}
|
|
28
|
-
return n >=
|
|
27
|
+
return n >= u || typeof e != "object" || !e ? e : Array.isArray(e) ? e.map((e) => f(e, t, n + 1)) : Object.fromEntries(Object.entries(e).map(([e, r]) => [e, f(r, t, n + 1)]));
|
|
29
28
|
};
|
|
30
29
|
return Object.keys(t).reduce((n, r) => {
|
|
31
|
-
let i = e === "trigger" ? t[r] :
|
|
30
|
+
let i = e === "trigger" ? t[r] : f(t[r], r, 0);
|
|
32
31
|
return {
|
|
33
32
|
...n,
|
|
34
33
|
[r]: i
|
|
35
34
|
};
|
|
36
35
|
}, {});
|
|
37
|
-
}, p =
|
|
38
|
-
let
|
|
39
|
-
if (!
|
|
36
|
+
}, f = (e) => typeof e != "function" && typeof e != "symbol" && typeof e != "bigint", p = (e) => Object.fromEntries(Object.entries(e).filter((e) => f(e[1]))), m = (e) => typeof e == "object" && !!e && "then" in e && typeof e.then == "function", h = (n, a = {}, o = {}, s = {}, u = {}) => {
|
|
37
|
+
let f = [], { id: h, action: g, enabled: _, params: v, elementId: y, type: b, when: x } = n;
|
|
38
|
+
if (!g || !_) return {
|
|
40
39
|
status: "disabled",
|
|
41
|
-
result:
|
|
42
|
-
postCallbacks:
|
|
40
|
+
result: {},
|
|
41
|
+
postCallbacks: f
|
|
43
42
|
};
|
|
44
|
-
let
|
|
43
|
+
let S = p({
|
|
45
44
|
...s,
|
|
46
45
|
...o,
|
|
47
|
-
[
|
|
48
|
-
};
|
|
49
|
-
if (
|
|
46
|
+
[h]: v
|
|
47
|
+
});
|
|
48
|
+
if (x && !r(x, S)) return {
|
|
50
49
|
status: "skipped",
|
|
51
|
-
result:
|
|
52
|
-
postCallbacks:
|
|
53
|
-
whenParams:
|
|
54
|
-
};
|
|
55
|
-
let S = {
|
|
56
|
-
...o,
|
|
57
|
-
...s,
|
|
58
|
-
...f(y, _, o, s, h)
|
|
50
|
+
result: {},
|
|
51
|
+
postCallbacks: f,
|
|
52
|
+
whenParams: S
|
|
59
53
|
};
|
|
54
|
+
let C = (e) => (i.danger("interactions", /* @__PURE__ */ l("span", { children: ["Interaction node failed ", /* @__PURE__ */ c("b", { children: g })] }), {
|
|
55
|
+
error: e instanceof Error ? e.message : String(e),
|
|
56
|
+
node: n
|
|
57
|
+
}), {
|
|
58
|
+
status: "failed",
|
|
59
|
+
result: {},
|
|
60
|
+
postCallbacks: f,
|
|
61
|
+
whenParams: S
|
|
62
|
+
}), w;
|
|
63
|
+
switch (b) {
|
|
64
|
+
case "callback":
|
|
65
|
+
case "globalCallback":
|
|
66
|
+
if (!y) return i.warning("interactions", /* @__PURE__ */ l("span", { children: [
|
|
67
|
+
"Step ",
|
|
68
|
+
/* @__PURE__ */ c("b", { children: g }),
|
|
69
|
+
" names no element, so there is nothing to run it on"
|
|
70
|
+
] }), { node: n }), {
|
|
71
|
+
status: "failed",
|
|
72
|
+
result: {},
|
|
73
|
+
postCallbacks: f,
|
|
74
|
+
whenParams: S
|
|
75
|
+
};
|
|
76
|
+
if (w = t(a, `${y}.${g}`), !w) return i.warning("interactions", /* @__PURE__ */ l("span", { children: [
|
|
77
|
+
"Nothing is registered as ",
|
|
78
|
+
/* @__PURE__ */ c("b", { children: `${y}.${g}` }),
|
|
79
|
+
", so this step did nothing"
|
|
80
|
+
] }), {
|
|
81
|
+
node: n,
|
|
82
|
+
available: Object.keys(t(a, y, {}))
|
|
83
|
+
}), {
|
|
84
|
+
status: "failed",
|
|
85
|
+
result: {},
|
|
86
|
+
postCallbacks: f,
|
|
87
|
+
whenParams: S
|
|
88
|
+
};
|
|
89
|
+
break;
|
|
90
|
+
case "utility":
|
|
91
|
+
w = t(e, g, {});
|
|
92
|
+
break;
|
|
93
|
+
default: return {
|
|
94
|
+
status: "success",
|
|
95
|
+
result: {},
|
|
96
|
+
postCallbacks: f,
|
|
97
|
+
whenParams: S
|
|
98
|
+
};
|
|
99
|
+
}
|
|
60
100
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
postCallbacks: p,
|
|
72
|
-
whenParams: x
|
|
73
|
-
};
|
|
74
|
-
let e = t(a, `${v}.${h}`);
|
|
75
|
-
if (!e) return i.warning("interactions", /* @__PURE__ */ l("span", { children: [
|
|
76
|
-
"Nothing is registered as ",
|
|
77
|
-
/* @__PURE__ */ c("b", { children: `${v}.${h}` }),
|
|
78
|
-
", so this step did nothing"
|
|
79
|
-
] }), {
|
|
80
|
-
node: n,
|
|
81
|
-
available: Object.keys(t(a, v, {}))
|
|
82
|
-
}), {
|
|
83
|
-
status: "failed",
|
|
84
|
-
result: d,
|
|
85
|
-
postCallbacks: p,
|
|
86
|
-
whenParams: x
|
|
87
|
-
};
|
|
88
|
-
let { callback: r, postCallback: o } = e;
|
|
89
|
-
r && (d = await r(S, u)), o && p.push({
|
|
90
|
-
id: m,
|
|
91
|
-
callback: o,
|
|
92
|
-
params: {
|
|
93
|
-
...S,
|
|
94
|
-
[m]: d
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case "utility": {
|
|
100
|
-
let { callback: n, postCallback: r } = t(e, h, {});
|
|
101
|
-
n && (d = await n(S, u)), r && p.push({
|
|
102
|
-
id: m,
|
|
103
|
-
callback: r,
|
|
104
|
-
params: {
|
|
105
|
-
...S,
|
|
106
|
-
[m]: d
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
break;
|
|
101
|
+
let e = {
|
|
102
|
+
...o,
|
|
103
|
+
...s,
|
|
104
|
+
...d(b, v, o, s, g)
|
|
105
|
+
}, { callback: t, postCallback: n } = w, r = (t) => (n && f.push({
|
|
106
|
+
id: h,
|
|
107
|
+
callback: n,
|
|
108
|
+
params: {
|
|
109
|
+
...e,
|
|
110
|
+
[h]: t
|
|
110
111
|
}
|
|
111
|
-
}
|
|
112
|
-
} catch (e) {
|
|
113
|
-
return i.danger("interactions", /* @__PURE__ */ l("span", { children: ["Interaction node failed ", /* @__PURE__ */ c("b", { children: h })] }), {
|
|
114
|
-
error: e instanceof Error ? e.message : String(e),
|
|
115
|
-
node: n
|
|
116
112
|
}), {
|
|
117
|
-
status: "
|
|
118
|
-
result:
|
|
119
|
-
postCallbacks:
|
|
120
|
-
whenParams:
|
|
121
|
-
};
|
|
113
|
+
status: "success",
|
|
114
|
+
result: t,
|
|
115
|
+
postCallbacks: f,
|
|
116
|
+
whenParams: S
|
|
117
|
+
}), i = t ? t(e, u) : {};
|
|
118
|
+
return m(i) ? Promise.resolve(i).then(r, C) : r(i);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
return C(e);
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
status: "success",
|
|
125
|
-
result: d,
|
|
126
|
-
postCallbacks: p,
|
|
127
|
-
whenParams: x
|
|
128
|
-
};
|
|
129
|
-
}, m = async (e = []) => {
|
|
122
|
+
}, g = async (e = []) => {
|
|
130
123
|
let t = {};
|
|
131
124
|
return await Promise.all(e.reverse().map(async ({ id: e, callback: r, params: i }) => {
|
|
132
125
|
t[e] = await r?.(n(i, [e]), i[e]);
|
|
133
126
|
})), t;
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
127
|
+
}, _ = () => ({}), v = async (e, n = {}, r = {}, a = {}, o = _, s = [], c = {}, l = {}) => {
|
|
128
|
+
let u = e, d = a;
|
|
129
|
+
for (; u;) {
|
|
130
|
+
let e = t(n, u.afterNode);
|
|
131
|
+
if (!e) return s.length > 0 && await g(s), c;
|
|
132
|
+
let a = i.getTime().valueOf(), f = h(e, r, d, o(), l), { status: p, result: _, postCallbacks: v, whenParams: y } = m(f) ? await f : f;
|
|
133
|
+
c[e.id] = {
|
|
134
|
+
node: e,
|
|
135
|
+
status: p,
|
|
136
|
+
result: _,
|
|
137
|
+
postCallbacks: v,
|
|
138
|
+
whenParams: y,
|
|
139
|
+
startTime: a,
|
|
140
|
+
endTime: i.getTime().valueOf()
|
|
141
|
+
}, s.push(...v), d = {
|
|
142
|
+
...d,
|
|
143
|
+
[e.id]: _
|
|
144
|
+
}, u = e;
|
|
145
|
+
}
|
|
146
|
+
return c;
|
|
147
|
+
}, y = (e, t, n = {}, r, a) => {
|
|
152
148
|
let o = i.getTime().valueOf(), u = r === "skipped" ? "skipped" : "success", d = /* @__PURE__ */ l("span", { children: [
|
|
153
149
|
"Interaction triggered ",
|
|
154
150
|
/* @__PURE__ */ c("b", { children: `${e.title} [${e.action}]` }),
|
|
@@ -177,17 +173,17 @@ var u = 5, d = 5, f = (e, t, n, r, s) => {
|
|
|
177
173
|
return;
|
|
178
174
|
}
|
|
179
175
|
i.info("interactions", d, f);
|
|
180
|
-
},
|
|
176
|
+
}, b = (e) => Object.values(e).some(({ status: e }) => e === "failed") ? "failed" : "completed", x = async (e, t = {}, n = {}, a = {}, o = _, s, c = []) => {
|
|
181
177
|
let l = i.getTime().valueOf(), { action: u, enabled: d, when: f } = e;
|
|
182
|
-
if (!u || !d || f && !r(f, {
|
|
183
|
-
...o,
|
|
178
|
+
if (!u || !d || f && !r(f, p({
|
|
179
|
+
...o(),
|
|
184
180
|
...a
|
|
185
|
-
})) {
|
|
186
|
-
|
|
181
|
+
}))) {
|
|
182
|
+
y(e, l, {}, "skipped", s);
|
|
187
183
|
return;
|
|
188
184
|
}
|
|
189
|
-
let
|
|
190
|
-
|
|
191
|
-
},
|
|
185
|
+
let m = await v(e, t, n, a, o, c, {}, { hostElementId: s });
|
|
186
|
+
y(e, l, m, b(m), s);
|
|
187
|
+
}, S = { flowTrigger: x };
|
|
192
188
|
//#endregion
|
|
193
|
-
export {
|
|
189
|
+
export { S as default, x as flowTrigger };
|
|
@@ -8,12 +8,27 @@ declare class InteractionsManager {
|
|
|
8
8
|
interactionsData: Record<string, string | number | boolean>;
|
|
9
9
|
subscriptors: Record<string, Subscriptor>;
|
|
10
10
|
callbacksAvailables: Record<string, Record<string, InteractionCallback<any>>>;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The flows running now, by element and trigger node — what `whileRunning` decides against. Per FLOW rather than per
|
|
13
|
+
* event: two flows on one click are two things, and one still running says nothing about the other.
|
|
14
|
+
*/
|
|
15
|
+
private flowsRunning;
|
|
12
16
|
lastUpdate: number;
|
|
13
17
|
private listeners;
|
|
14
18
|
constructor(currentPageId?: string, routeParams?: RouteParams, queryParams?: QueryParams);
|
|
15
19
|
eventBridgeCallback: (interactions?: Record<string, ElementInteraction>) => (subscriptorId: string, eventName: string, params: Record<string, unknown>) => Promise<void>;
|
|
20
|
+
/** One firing of one flow, as its trigger's `whileRunning` says — see {@link WhileRunning}. */
|
|
21
|
+
private runFlow;
|
|
16
22
|
subscribe<TParams extends Record<string, unknown> = Record<string, unknown>>(id: string, interactions?: Record<string, ElementInteraction>, triggers?: Record<string, InteractionCallback<TParams>>, callbacks?: Record<string, InteractionCallback<TParams>>, getAdditionalParams?: Subscriptor<TParams>['getAdditionalParams']): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* What a subscribed element wires, replaced — its subscription kept.
|
|
25
|
+
*
|
|
26
|
+
* An element re-renders with new callbacks all the time, often right after firing a trigger (a form marks itself
|
|
27
|
+
* submitted). Its subscription is the same one for as long as it is mounted, so a flow that trigger started still
|
|
28
|
+
* runs: only an element unmounted meanwhile loses it (see `eventBridgeCallback`).
|
|
29
|
+
*/
|
|
30
|
+
update<TParams extends Record<string, unknown> = Record<string, unknown>>(id: string, interactions?: Record<string, ElementInteraction>, triggers?: Record<string, InteractionCallback<TParams>>, callbacks?: Record<string, InteractionCallback<TParams>>, getAdditionalParams?: Subscriptor<TParams>['getAdditionalParams']): boolean;
|
|
31
|
+
private wire;
|
|
17
32
|
unsubscribe(id: string): boolean;
|
|
18
33
|
getRootManager(): this | undefined;
|
|
19
34
|
private getSubscriptorInternal;
|
|
@@ -1,55 +1,68 @@
|
|
|
1
1
|
import { flowTrigger as e } from "./InteractionsHelper.mjs";
|
|
2
2
|
import { get as t, set as n } from "@plitzi/plitzi-ui/helpers";
|
|
3
3
|
import r from "@plitzi/sdk-event-bridge";
|
|
4
|
+
import { KEY_TRIGGER as i } from "@plitzi/sdk-shared/helpers/keys";
|
|
4
5
|
//#region src/InteractionsManager.ts
|
|
5
|
-
var
|
|
6
|
+
var a = (e, t) => {
|
|
7
|
+
if (e.action !== i) return !0;
|
|
8
|
+
let { shortcuts: n } = t;
|
|
9
|
+
return Array.isArray(n) && n.includes(e.params.keys);
|
|
10
|
+
}, o = class i {
|
|
6
11
|
eventBridge;
|
|
7
12
|
parentManager;
|
|
8
13
|
childManagers;
|
|
9
14
|
interactionsData;
|
|
10
15
|
subscriptors;
|
|
11
16
|
callbacksAvailables;
|
|
12
|
-
|
|
17
|
+
flowsRunning = /* @__PURE__ */ new Map();
|
|
13
18
|
lastUpdate;
|
|
14
19
|
listeners = /* @__PURE__ */ new Set();
|
|
15
20
|
constructor(e = "", t = {}, n = {}) {
|
|
16
|
-
this.eventBridge = new r(), this.parentManager = void 0, this.childManagers = [], this.subscriptors = {}, this.callbacksAvailables = {}, this.
|
|
21
|
+
this.eventBridge = new r(), this.parentManager = void 0, this.childManagers = [], this.subscriptors = {}, this.callbacksAvailables = {}, this.interactionsData = {
|
|
17
22
|
currentPageId: e,
|
|
18
23
|
...t,
|
|
19
24
|
...n
|
|
20
25
|
}, this.lastUpdate = Date.now();
|
|
21
26
|
}
|
|
22
|
-
eventBridgeCallback = (
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
...s
|
|
32
|
-
}, i)));
|
|
33
|
-
} finally {
|
|
34
|
-
n(this.interactionsRunning, `${i}.${a}`, !1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
27
|
+
eventBridgeCallback = (n) => async (r, i, o) => {
|
|
28
|
+
if (!n || !i || !r) return;
|
|
29
|
+
let s = this.subscriptors[r];
|
|
30
|
+
if (await Promise.resolve(), !s || this.subscriptors[r] !== s) return;
|
|
31
|
+
let c = t(this.subscriptors, `${r}.getAdditionalParams`, void 0), l = () => ({
|
|
32
|
+
...this.interactionsData,
|
|
33
|
+
...typeof c == "function" ? c().dataSource : void 0
|
|
34
|
+
}), u = Object.values(n).filter((e) => e.type === "trigger" && e.action === i && e.enabled && a(e, o));
|
|
35
|
+
await Promise.all(u.map((t) => this.runFlow(`${r}.${t.id}`, t.whileRunning ?? "skip", () => e(t, n, this.getCallbacksAvailables(), { [t.id]: o }, l, r))));
|
|
37
36
|
};
|
|
37
|
+
runFlow(e, t, n) {
|
|
38
|
+
let r = this.flowsRunning.get(e);
|
|
39
|
+
if (t === "parallel") return n();
|
|
40
|
+
if (r && t === "skip") return Promise.resolve();
|
|
41
|
+
let i = (r ? r.then(n, n) : n()).finally(() => {
|
|
42
|
+
this.flowsRunning.get(e) === i && this.flowsRunning.delete(e);
|
|
43
|
+
});
|
|
44
|
+
return this.flowsRunning.set(e, i), i;
|
|
45
|
+
}
|
|
38
46
|
subscribe(e, t = {}, r = {}, i = {}, a) {
|
|
39
|
-
|
|
40
|
-
n(this.subscriptors, e, {
|
|
47
|
+
return !e || this.subscriptors[e] ? !1 : (n(this.subscriptors, e, {
|
|
41
48
|
id: e,
|
|
42
49
|
triggers: r,
|
|
43
50
|
getAdditionalParams: a
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
}), this.wire(e, t, r, i), this.touch(), !0);
|
|
52
|
+
}
|
|
53
|
+
update(e, t = {}, n = {}, r = {}, i) {
|
|
54
|
+
let a = this.subscriptors[e];
|
|
55
|
+
return a ? (a.triggers = n, a.getAdditionalParams = i, this.wire(e, t, n, r), this.touch(), !0) : !1;
|
|
56
|
+
}
|
|
57
|
+
wire(e, t, n, r) {
|
|
58
|
+
let i = Object.keys(r);
|
|
59
|
+
i.length > 0 ? this.callbacksAvailables[e] = i.reduce((t, n) => {
|
|
60
|
+
let { title: i, callback: a, postCallback: o, params: s, preview: c, type: l } = r[n];
|
|
48
61
|
return typeof a == "function" ? {
|
|
49
62
|
...t,
|
|
50
63
|
[n]: {
|
|
51
64
|
elementId: e,
|
|
52
|
-
title:
|
|
65
|
+
title: i,
|
|
53
66
|
action: n,
|
|
54
67
|
type: l,
|
|
55
68
|
callback: a,
|
|
@@ -58,7 +71,7 @@ var i = class i {
|
|
|
58
71
|
preview: c
|
|
59
72
|
}
|
|
60
73
|
} : t;
|
|
61
|
-
}, {})
|
|
74
|
+
}, {}) : delete this.callbacksAvailables[e], Object.keys(n).length > 0 ? this.eventBridge.on("interaction", e, this.eventBridgeCallback(t), { override: !0 }) : this.eventBridge.off("interaction", e);
|
|
62
75
|
}
|
|
63
76
|
unsubscribe(e) {
|
|
64
77
|
return this.subscriptors[e] ? (this.eventBridge.off("interaction", e), delete this.subscriptors[e], this.callbacksAvailables[e] && delete this.callbacksAvailables[e], this.touch(), !0) : !1;
|
|
@@ -112,4 +125,4 @@ var i = class i {
|
|
|
112
125
|
}
|
|
113
126
|
};
|
|
114
127
|
//#endregion
|
|
115
|
-
export {
|
|
128
|
+
export { o as default };
|
|
@@ -5,5 +5,5 @@ export type InteractionsSourcesProviderProps = {
|
|
|
5
5
|
/** What the embedding application is willing to be asked to do — see {@link HostActions}. */
|
|
6
6
|
hostActions?: HostActions;
|
|
7
7
|
};
|
|
8
|
-
declare const InteractionsSourcesProvider: ({ children, hostActions }: InteractionsSourcesProviderProps) => import(
|
|
8
|
+
declare const InteractionsSourcesProvider: ({ children, hostActions }: InteractionsSourcesProviderProps) => import('react').JSX.Element;
|
|
9
9
|
export default InteractionsSourcesProvider;
|
|
@@ -4,9 +4,11 @@ import { use as t, useEffect as n } from "react";
|
|
|
4
4
|
var r = ({ id: r, interactions: i, triggers: a, callbacks: o, getAdditionalParams: s }) => {
|
|
5
5
|
let { interactionsManager: c } = t(e);
|
|
6
6
|
n(() => {
|
|
7
|
-
if (r) return c.subscribe(r
|
|
7
|
+
if (r) return c.subscribe(r), () => {
|
|
8
8
|
c.unsubscribe(r);
|
|
9
9
|
};
|
|
10
|
+
}, [r, c]), n(() => {
|
|
11
|
+
r && c.update(r, i, a, o, s);
|
|
10
12
|
}, [
|
|
11
13
|
r,
|
|
12
14
|
i,
|
|
@@ -237,7 +237,8 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
237
237
|
status: "failed",
|
|
238
238
|
reason: r.reason ?? "failed",
|
|
239
239
|
runId: "",
|
|
240
|
-
output: {}
|
|
240
|
+
output: {},
|
|
241
|
+
...r.error ? { error: r.error } : {}
|
|
241
242
|
};
|
|
242
243
|
}
|
|
243
244
|
let i = e.headers.get("X-Plitzi-Run-Id") ?? "";
|
|
@@ -272,6 +273,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
272
273
|
T({
|
|
273
274
|
status: e.data.status === "completed" ? "completed" : "failed",
|
|
274
275
|
...e.data.output ? { output: e.data.output } : {},
|
|
276
|
+
...typeof e.data.error == "string" ? { error: e.data.error } : {},
|
|
275
277
|
...r ? { steps: r } : {}
|
|
276
278
|
}), k(t?.hostElementId, "onFlowEnd", {
|
|
277
279
|
actionId: n,
|
|
@@ -336,12 +338,14 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
336
338
|
status: O.status === "completed" ? "completed" : "failed",
|
|
337
339
|
...O.runId ? { runId: O.runId } : {},
|
|
338
340
|
...O.output ? { output: O.output } : {},
|
|
341
|
+
...O.error ? { error: O.error } : {},
|
|
339
342
|
...O.steps ? { steps: O.steps } : {},
|
|
340
343
|
...O.trace ? { trace: O.trace } : {}
|
|
341
344
|
}), {
|
|
342
345
|
status: O.status ?? "completed",
|
|
343
346
|
runId: O.runId ?? "",
|
|
344
|
-
output: O.output ?? {}
|
|
347
|
+
output: O.output ?? {},
|
|
348
|
+
...O.error ? { error: O.error } : {}
|
|
345
349
|
}) : (w(D.status, O, E), T({
|
|
346
350
|
status: "failed",
|
|
347
351
|
...O.runId ? { runId: O.runId } : {},
|
|
@@ -363,7 +367,8 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
363
367
|
status: "failed",
|
|
364
368
|
reason: O.reason ?? "failed",
|
|
365
369
|
runId: O.runId ?? "",
|
|
366
|
-
output: {}
|
|
370
|
+
output: {},
|
|
371
|
+
...O.error ? { error: O.error } : {}
|
|
367
372
|
});
|
|
368
373
|
}, [E, k]), j = r(async (e) => {
|
|
369
374
|
if (!E || !e.runId) return { cancelled: !1 };
|
|
@@ -14,10 +14,9 @@ var t = {
|
|
|
14
14
|
label: "Action"
|
|
15
15
|
},
|
|
16
16
|
input: {
|
|
17
|
-
type: "
|
|
17
|
+
type: "json",
|
|
18
18
|
description: "The values passed to the action, as a JSON object. The server drops every key the action did not declare. Authoring in code, pass a real object rather than a line of JSON text — an interpolated value containing a quote or a newline makes the text unparseable, and unparseable input posts nothing.",
|
|
19
19
|
default: "{}",
|
|
20
|
-
builderType: "codemirror-json",
|
|
21
20
|
label: "Input"
|
|
22
21
|
},
|
|
23
22
|
mode: {
|
|
@@ -50,7 +49,9 @@ var t = {
|
|
|
50
49
|
preview: {
|
|
51
50
|
runId: "",
|
|
52
51
|
status: "",
|
|
53
|
-
output: {}
|
|
52
|
+
output: {},
|
|
53
|
+
reason: "",
|
|
54
|
+
error: ""
|
|
54
55
|
}
|
|
55
56
|
},
|
|
56
57
|
cancelServerAction: {
|
|
@@ -9,10 +9,15 @@ var e = {
|
|
|
9
9
|
type: "select",
|
|
10
10
|
description: "Credentials to sign in with: a username and password, or a token obtained elsewhere.",
|
|
11
11
|
default: "normal",
|
|
12
|
-
options: [
|
|
12
|
+
options: [
|
|
13
|
+
"normal",
|
|
14
|
+
"token",
|
|
15
|
+
"mfa"
|
|
16
|
+
],
|
|
13
17
|
optionLabels: {
|
|
14
18
|
normal: "User and Password",
|
|
15
|
-
token: "Token"
|
|
19
|
+
token: "Token",
|
|
20
|
+
mfa: "Second factor"
|
|
16
21
|
},
|
|
17
22
|
canBind: !1
|
|
18
23
|
},
|
|
@@ -33,11 +38,24 @@ var e = {
|
|
|
33
38
|
description: "A token to exchange for a session.",
|
|
34
39
|
default: "",
|
|
35
40
|
when: (e) => e.mode === "token"
|
|
41
|
+
},
|
|
42
|
+
mfaToken: {
|
|
43
|
+
type: "text",
|
|
44
|
+
description: "The challenge a sign-in answered with when it owed a second factor: `{{ login.mfaToken }}`.",
|
|
45
|
+
default: "",
|
|
46
|
+
when: (e) => e.mode === "mfa"
|
|
47
|
+
},
|
|
48
|
+
code: {
|
|
49
|
+
type: "text",
|
|
50
|
+
description: "The code from the authenticator app, or a recovery code.",
|
|
51
|
+
default: "",
|
|
52
|
+
when: (e) => e.mode === "mfa"
|
|
36
53
|
}
|
|
37
54
|
},
|
|
38
55
|
preview: {
|
|
39
56
|
ok: "",
|
|
40
57
|
reason: "",
|
|
58
|
+
mfaToken: "",
|
|
41
59
|
errors: {
|
|
42
60
|
username: "",
|
|
43
61
|
password: "",
|