@plitzi/sdk-interactions 0.38.11 → 0.38.13
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 +119 -0
- package/dist/InteractionsContext.d.ts +3 -3
- package/dist/InteractionsContextProvider.mjs +17 -17
- package/dist/InteractionsManager.d.ts +3 -3
- package/dist/sources/ActionsSource/ActionInteractions.mjs +95 -97
- package/dist/utility/twigTemplate.mjs +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,124 @@
|
|
|
1
1
|
# @plitzi/sdk-interactions
|
|
2
2
|
|
|
3
|
+
## 0.38.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- v0.38.13
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @plitzi/sdk-auth@0.38.13
|
|
10
|
+
- @plitzi/sdk-event-bridge@0.38.13
|
|
11
|
+
- @plitzi/sdk-shared@0.38.13
|
|
12
|
+
|
|
13
|
+
## 0.38.12
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 1301338: ## Builder
|
|
18
|
+
|
|
19
|
+
- **Icons in the canvas again** (`@plitzi/plitzi-builder`): the canvas inlined the SDK's Font Awesome sheet into its
|
|
20
|
+
`<style>`, where the sheet's `url(webfonts/…)` resolved against the editor's URL — a `srcdoc` frame takes it as its
|
|
21
|
+
base — so every icon was a 404 under `/spaces/<space>/webfonts/` and drew as an empty box. Only the Vite dev server,
|
|
22
|
+
which rewrites the URL, hid it. The canvas and the element preview now link the sheet from where the host serves it:
|
|
23
|
+
a new prop, `sdkIconsStylePath`, the one the host already gives the pages it renders
|
|
24
|
+
(`/sdk-assets/plitzi-sdk-icons.css` for sdk-server). Absent, the canvas links no icon sheet.
|
|
25
|
+
|
|
26
|
+
## Plugins
|
|
27
|
+
- **A plugin's other elements, hosted by `custom`** (`@plitzi/sdk-elements`): `custom({ renderType: 'jamDisc' })` on a
|
|
28
|
+
space with a plugin installed whose main element is another (`plitzi plugin pack` of several folders: the first is the
|
|
29
|
+
plugin, the rest go in it) rendered "Custom Component jamDisc Not Found" — the page registers only the plugin's main
|
|
30
|
+
element, and a `custom` host looked nowhere else. It now loads the type from the installed plugin that packs it, as
|
|
31
|
+
an element of the type itself always did, so the two ways the docs give to place a plugin's element are the same
|
|
32
|
+
everywhere: in a project `plitzi create` wrote, and once the project is on Plitzi.
|
|
33
|
+
- **One way to place a plugin's element** (`@plitzi/sdk-authoring`, `@plitzi/cli`, docs): from its declaration,
|
|
34
|
+
`const seatPicker = defineElement(declaration)` then `seatPicker({ id, … })` — typed by what it
|
|
35
|
+
declares, and the element the builder adds when somebody drops it. The welcome space `plitzi create` writes, the
|
|
36
|
+
plugin package's preview, `plitzi plugin add` and `plitzi explain` all write it so (the template's
|
|
37
|
+
`PluginHostOptions` now takes the plugin's `type` and `declaration: { from, attributes? }`; `custom`/`element` hosting
|
|
38
|
+
is gone). `pluginFolders(folder)` (`@plitzi/sdk-authoring/node`) reads each plugin with the folder it is in;
|
|
39
|
+
`pluginDeclarations` is built on it. A `custom({ renderType })` naming a plugin the space was handed the declaration
|
|
40
|
+
of is offered the declaration instead — suggestion `plugin-custom-host`. `custom` stays for a component registered
|
|
41
|
+
by name with no declaration. The skills, the CLI README, the MCP guide, `docs/en` and the website say the same.
|
|
42
|
+
- **`definePlugin`** (`@plitzi/sdk-authoring/plugin`, a new entry of 3 KB with nothing else in it): a plugin's
|
|
43
|
+
declaration written from what only it can say —
|
|
44
|
+
`definePlugin<SeatPickerAttributes>()({ type, label, attributes, triggers, callbacks })` — and every other field
|
|
45
|
+
at the default all plugins share (the builder's gestures, the catalogue entry, each attribute bindable, an empty
|
|
46
|
+
style). It answers the whole declaration, branded with its attributes, so `defineElement(declaration)` is typed
|
|
47
|
+
without a generic. `plitzi plugin add` and `create --plugin` write declarations with it (about a third of the lines).
|
|
48
|
+
- **`usePluginTrigger(declaration)`** (`@plitzi/plitzi-sdk`): fires a plugin's declared event on its element — the
|
|
49
|
+
event name and what each hands a flow typed off the declaration's `preview` — on a live page only. The hook every
|
|
50
|
+
plugin wrote for itself (and `plugin add` generated as `use<Name>Events`) is gone from the scaffold.
|
|
51
|
+
- **Attributes as the types their defaults are** (`@plitzi/sdk-elements`): a plugin's attribute bound from text — a
|
|
52
|
+
state, a row, a channel message — reaches its component as the number or the flag its declared default is (`'112'`
|
|
53
|
+
as 112, `'true'` as true). A plugin no longer types its props `number | string` and parses them.
|
|
54
|
+
|
|
55
|
+
## Server actions and functions
|
|
56
|
+
- **Task params with rules** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): a task declares `required`, a text's
|
|
57
|
+
`maxLength` and a number's `min`/`max`, and the runner refuses a call that breaks any of them — every rule broken at
|
|
58
|
+
once, in the words the page shows (`Title is required; Seconds is at most 300`) — before the code runs. A `text` param
|
|
59
|
+
bound to a number arrives as its digits. The manifest keeps the rules, so the platform's sandbox checks the same.
|
|
60
|
+
- **`taskAction(task, { trigger })`** (`@plitzi/sdk-authoring`): the action that runs one of the space's tasks and
|
|
61
|
+
answers its result, derived from the task — its id (`<namespace>-<action>`), name, description and input (the task's
|
|
62
|
+
params, once). An action of more than one step is still `defineAction`.
|
|
63
|
+
- **`ctx.rateLimit(bucket, { …, refuse })`**: past the limit the call is refused with those words instead of answering
|
|
64
|
+
`allowed: false` for the code to check — natively and in the sandbox.
|
|
65
|
+
|
|
66
|
+
## Authoring
|
|
67
|
+
- **`runServerActionOrNotify(id, params, fallback)`**: a server action run and the notice the visitor reads when it
|
|
68
|
+
fails — the action's own refusal, or the fallback — as two steps to spread into a flow.
|
|
69
|
+
- **`repeated-shape` reads what copies bind**: copies whose bindings read their data in different forms (a count, a
|
|
70
|
+
total of a quota) and copies holding a provider resolved on the server (found by its own id) are no longer offered
|
|
71
|
+
as one component.
|
|
72
|
+
- **`element-color-inherited`** (suggestion): `elements` giving a heading, a text, a link… `color: inherit` or the
|
|
73
|
+
page's own colour. **A link inherits the page's colour** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-elements`) rather than
|
|
74
|
+
holding the SDK's grey — the same by default, and the space's palette inside a card that is a link. The template
|
|
75
|
+
every space starts from writes its colours once, on the page.
|
|
76
|
+
|
|
77
|
+
## Fixes
|
|
78
|
+
- **A dialog opened with an id** (`@plitzi/sdk-elements`): `openDialog('dialog', '{{ row.id }}')` reads the id as its
|
|
79
|
+
`content`, as `openModal` already did — a numeric id parsed as the number and the dialog's bindings read nothing.
|
|
80
|
+
- **A select's chevron** (`@plitzi/plitzi-sdk`): a drawn chevron in the field's own colour, sized by its type, in place
|
|
81
|
+
of the `▼` glyph — and laid out in the box, so it ends where the box's padding begins whatever that padding is, and
|
|
82
|
+
the chosen option stops short of it instead of running under it. A disabled select's is faded.
|
|
83
|
+
- **Every element has its settings** (`@plitzi/plitzi-builder`, `@plitzi/sdk-elements`): the builder found none for
|
|
84
|
+
`tabContainerHeader` (registered under a misspelt type), `themeToggle`, `dropdownPopup`, `loading` and `notFound`.
|
|
85
|
+
The theme toggle's panel sets its mode, its labels and whether it offers "System"; the registry is typed by element
|
|
86
|
+
type and must hold one for each.
|
|
87
|
+
- **A plugin's panel** (`@plitzi/cli`): `plitzi doctor` warns of a plugin with no `Settings.tsx`, or one its entry never
|
|
88
|
+
passes as `pluginSettings` (`plugin-settings-missing`); the example `create` writes has its panel, as every element
|
|
89
|
+
`plugin add` writes does, and the panels it generates are laid out as the project's Prettier lays them out.
|
|
90
|
+
- **A refused or failed run reaches `onFlowError` in every mode** (`@plitzi/sdk-interactions`): an awaited server
|
|
91
|
+
action the server refused fired no `onFlowError` on the element that started it, as `detached` and `stream` ones do
|
|
92
|
+
— a board rolling its edits back on a refusal never did; and a run answered `status: 'failed'` fired `onFlowEnd`
|
|
93
|
+
(detached) or nothing (awaited) rather than `onFlowError`.
|
|
94
|
+
- **A source renamed** (`@plitzi/sdk-shared`): the binding picker lists a provider, a form or a modal by the name its
|
|
95
|
+
element has now, not the one it had when it mounted.
|
|
96
|
+
- **A text's words in the builder** (`@plitzi/sdk-elements`): a `paragraph`, `text` or `heading` whose `content` is
|
|
97
|
+
`0` shows `0` while editing too, not its placeholder; one bound to nothing shows nothing rather than `null`.
|
|
98
|
+
- **Built-in declarations** (`@plitzi/sdk-shared`): `elementDeclaration` fills in what every element shares — the
|
|
99
|
+
builder's gestures, Plitzi's catalogue entry, a visible element with no bindings, its style named by its label —
|
|
100
|
+
from the defaults `definePlugin` uses; each element's declaration says only what is its own (a third of the lines).
|
|
101
|
+
|
|
102
|
+
## Typed for plugins and hosts
|
|
103
|
+
- **`usePlitzi()` and `PlitziProvider`** (`@plitzi/sdk-shared/hooks/usePlitzi`, `@plitzi/plitzi-sdk`): what were
|
|
104
|
+
`usePlitziServiceContext()` and `PlitziServiceProvider` (and `PlitziServiceContextValue`, now `PlitziContextValue`),
|
|
105
|
+
holding only what the host rendering a space knows — `settings`, `root`, `utils`. Its `contexts` and
|
|
106
|
+
`customContexts` are gone: every context it carried is a shared one already, imported from its own module
|
|
107
|
+
(`@plitzi/sdk-interactions/InteractionsContext`, `@plitzi/sdk-shared/network/NetworkContext`…), and
|
|
108
|
+
`PluginsContext` moves to `@plitzi/sdk-shared/plugins/PluginsContext` beside the others.
|
|
109
|
+
- **`InteractionsManagerApi`** (`@plitzi/sdk-shared`): the interactions manager as everything outside
|
|
110
|
+
`@plitzi/sdk-interactions` reaches it, declared where every package can name it and implemented by
|
|
111
|
+
`InteractionsManager`, so `use(InteractionsContext)` is typed — `interactionTrigger`, `createChildManager`… — where it
|
|
112
|
+
was `any`.
|
|
113
|
+
- **`getPathsFromObject`** (`@plitzi/sdk-shared/helpers/utils`), spelt right; `getPathsFromObeject` is gone.
|
|
114
|
+
- **`ElementWords` places itself** (`@plitzi/sdk-elements`): `contentPlacement` and the element's children, so a button
|
|
115
|
+
and a link write their words once.
|
|
116
|
+
|
|
117
|
+
- Updated dependencies [1301338]
|
|
118
|
+
- @plitzi/sdk-auth@0.38.12
|
|
119
|
+
- @plitzi/sdk-event-bridge@0.38.12
|
|
120
|
+
- @plitzi/sdk-shared@0.38.12
|
|
121
|
+
|
|
3
122
|
## 0.38.11
|
|
4
123
|
|
|
5
124
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { default as InteractionsManager } from './InteractionsManager';
|
|
2
1
|
import { InteractionsContextValue as InteractionsContextValueShared } from '@plitzi/sdk-shared';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/** The manager as its context holds it: the interface sdk-shared declares, which `InteractionsManager` implements. */
|
|
3
|
+
export type InteractionsContextValue = InteractionsContextValueShared;
|
|
4
|
+
declare const InteractionsContext: import('react').Context<InteractionsContextValueShared>;
|
|
5
5
|
export default InteractionsContext;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import e from "./InteractionsContext.mjs";
|
|
2
2
|
import t from "./hooks/useInteractions.mjs";
|
|
3
3
|
import n from "./InteractionsManager.mjs";
|
|
4
|
-
import { useMemo as r } from "react";
|
|
5
|
-
import { jsx as
|
|
4
|
+
import { useMemo as r, useState as i } from "react";
|
|
5
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
6
6
|
//#region src/InteractionsContextProvider.tsx
|
|
7
|
-
var
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
currentPageId:
|
|
11
|
-
...
|
|
12
|
-
...
|
|
7
|
+
var o = ({ children: o, currentPageId: s, routeParams: c, queryParams: l }) => {
|
|
8
|
+
let [u] = i(() => new n(s, c, l));
|
|
9
|
+
u.interactionsData = r(() => ({
|
|
10
|
+
currentPageId: s,
|
|
11
|
+
...c,
|
|
12
|
+
...l
|
|
13
13
|
}), [
|
|
14
|
-
o,
|
|
15
14
|
s,
|
|
16
|
-
c
|
|
15
|
+
c,
|
|
16
|
+
l
|
|
17
17
|
]);
|
|
18
|
-
let
|
|
19
|
-
interactionsManager:
|
|
18
|
+
let d = r(() => ({
|
|
19
|
+
interactionsManager: u,
|
|
20
20
|
useInteractions: t
|
|
21
|
-
}), [
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
value:
|
|
24
|
-
children:
|
|
21
|
+
}), [u]);
|
|
22
|
+
return /* @__PURE__ */ a(e, {
|
|
23
|
+
value: d,
|
|
24
|
+
children: o
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
//#endregion
|
|
28
|
-
export {
|
|
28
|
+
export { o as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as EventBridge } from '@plitzi/sdk-event-bridge';
|
|
2
|
-
import { ElementInteraction, InteractionCallback, QueryParams, RouteParams, Subscriptor } from '@plitzi/sdk-shared';
|
|
2
|
+
import { ElementInteraction, InteractionCallback, InteractionsManagerApi, QueryParams, RouteParams, Subscriptor } from '@plitzi/sdk-shared';
|
|
3
3
|
type InteractionUpdateListener = (timestamp: number) => void;
|
|
4
|
-
declare class InteractionsManager {
|
|
4
|
+
declare class InteractionsManager implements InteractionsManagerApi {
|
|
5
5
|
eventBridge: InstanceType<typeof EventBridge>;
|
|
6
6
|
parentManager?: InteractionsManager;
|
|
7
7
|
childManagers: InteractionsManager[];
|
|
@@ -49,7 +49,7 @@ declare class InteractionsManager {
|
|
|
49
49
|
};
|
|
50
50
|
interactionTrigger(subscriptorId: string | undefined, eventName: string, params?: Record<string, unknown>): Promise<unknown[]> | undefined;
|
|
51
51
|
createChildManager: (routeParams?: Record<string, string>, queryParams?: Record<string, string>) => InteractionsManager;
|
|
52
|
-
removeChildManager: (childManager:
|
|
52
|
+
removeChildManager: (childManager: InteractionsManagerApi) => void;
|
|
53
53
|
onUpdate(listener: InteractionUpdateListener): () => void;
|
|
54
54
|
private touch;
|
|
55
55
|
}
|
|
@@ -55,12 +55,24 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
55
55
|
reason: r,
|
|
56
56
|
url: n
|
|
57
57
|
});
|
|
58
|
-
}, T = (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
}, T = (e) => ({
|
|
59
|
+
status: "failed",
|
|
60
|
+
...e.runId ? { runId: e.runId } : {},
|
|
61
|
+
...e.reason ? { reason: e.reason } : {},
|
|
62
|
+
...e.error ? { error: e.error } : {},
|
|
63
|
+
...e.steps ? { steps: e.steps } : {},
|
|
64
|
+
...e.trace ? { trace: e.trace } : {}
|
|
65
|
+
}), E = (e, t) => ({
|
|
66
|
+
actionId: e,
|
|
67
|
+
runId: t.runId ?? "",
|
|
68
|
+
error: t.error ?? "",
|
|
69
|
+
reason: t.reason ?? "failed"
|
|
70
|
+
}), D = ({ children: _ }) => {
|
|
71
|
+
let { useInteractions: v, interactionsManager: D } = n(e), [O] = g("actions.endpoint"), [[k, A]] = g(["actions.catalog", "actions.available"]), j = r((e, t, n) => {
|
|
72
|
+
e && D.interactionTrigger(e, t, n);
|
|
73
|
+
}, [D]), M = r(async (e, t) => {
|
|
62
74
|
let { actionId: n, mode: r = "await", idempotencyKey: i } = e;
|
|
63
|
-
if (!
|
|
75
|
+
if (!O) return a.warning("actions", /* @__PURE__ */ u("span", { children: [
|
|
64
76
|
"Server action ",
|
|
65
77
|
/* @__PURE__ */ l("b", { children: n }),
|
|
66
78
|
" was skipped: this page is served without a Plitzi server"
|
|
@@ -85,21 +97,21 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
85
97
|
actionId: n,
|
|
86
98
|
mode: r,
|
|
87
99
|
input: o
|
|
88
|
-
}), _ = new AbortController(), v = "",
|
|
100
|
+
}), _ = new AbortController(), v = "", D = () => {
|
|
89
101
|
_.abort(), h(g, {
|
|
90
102
|
status: "aborted",
|
|
91
103
|
endedAt: Date.now(),
|
|
92
104
|
cancellable: !1
|
|
93
|
-
}), v && fetch(`${
|
|
105
|
+
}), v && fetch(`${O}/run/${v}`, {
|
|
94
106
|
method: "DELETE",
|
|
95
107
|
credentials: "same-origin"
|
|
96
108
|
}).catch(() => void 0);
|
|
97
109
|
};
|
|
98
|
-
p(g,
|
|
99
|
-
let
|
|
100
|
-
|
|
101
|
-
let
|
|
102
|
-
|
|
110
|
+
p(g, D);
|
|
111
|
+
let k = t?.signal;
|
|
112
|
+
k?.addEventListener("abort", D, { once: !0 });
|
|
113
|
+
let A = (t) => {
|
|
114
|
+
k?.removeEventListener("abort", D), m(g), h(g, {
|
|
103
115
|
endedAt: Date.now(),
|
|
104
116
|
cancellable: !1,
|
|
105
117
|
...t
|
|
@@ -117,7 +129,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
117
129
|
actionId: n,
|
|
118
130
|
mode: r,
|
|
119
131
|
status: "accepted"
|
|
120
|
-
}), fetch(
|
|
132
|
+
}), fetch(O, {
|
|
121
133
|
method: "POST",
|
|
122
134
|
headers: { "Content-Type": "application/json" },
|
|
123
135
|
credentials: "same-origin",
|
|
@@ -127,21 +139,24 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
127
139
|
}).then(async (e) => {
|
|
128
140
|
let i = await e.json().catch(() => ({}));
|
|
129
141
|
if (!e.ok) {
|
|
130
|
-
w(e.status, i,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
w(e.status, i, O), A(T(i)), j(t?.hostElementId, "onFlowError", E(n, i));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (i.status === "failed") {
|
|
146
|
+
A(T(i)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
|
|
147
|
+
"Server action ",
|
|
148
|
+
/* @__PURE__ */ l("b", { children: n }),
|
|
149
|
+
" failed"
|
|
150
|
+
] }), {
|
|
137
151
|
actionId: n,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
reason: i.reason
|
|
141
|
-
|
|
152
|
+
mode: r,
|
|
153
|
+
runId: i.runId,
|
|
154
|
+
reason: i.reason,
|
|
155
|
+
error: i.error
|
|
156
|
+
}), j(t?.hostElementId, "onFlowError", E(n, i));
|
|
142
157
|
return;
|
|
143
158
|
}
|
|
144
|
-
|
|
159
|
+
A({
|
|
145
160
|
status: i.status === "completed" ? "completed" : "accepted",
|
|
146
161
|
...i.runId ? { runId: i.runId } : {},
|
|
147
162
|
...i.output ? { output: i.output } : {},
|
|
@@ -157,14 +172,14 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
157
172
|
runId: i.runId,
|
|
158
173
|
status: i.status,
|
|
159
174
|
output: i.output
|
|
160
|
-
}),
|
|
175
|
+
}), j(t?.hostElementId, "onFlowEnd", {
|
|
161
176
|
actionId: n,
|
|
162
177
|
runId: i.runId ?? "",
|
|
163
178
|
status: i.status ?? "completed",
|
|
164
179
|
output: i.output ?? {}
|
|
165
180
|
});
|
|
166
181
|
}).catch((e) => {
|
|
167
|
-
|
|
182
|
+
A(C(_, e)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
|
|
168
183
|
"Server action ",
|
|
169
184
|
/* @__PURE__ */ l("b", { children: n }),
|
|
170
185
|
" could not be sent"
|
|
@@ -172,7 +187,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
172
187
|
actionId: n,
|
|
173
188
|
mode: r,
|
|
174
189
|
error: e instanceof Error ? e.message : String(e)
|
|
175
|
-
}),
|
|
190
|
+
}), j(t?.hostElementId, "onFlowError", {
|
|
176
191
|
actionId: n,
|
|
177
192
|
runId: "",
|
|
178
193
|
error: "",
|
|
@@ -196,7 +211,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
196
211
|
});
|
|
197
212
|
let e;
|
|
198
213
|
try {
|
|
199
|
-
e = await fetch(
|
|
214
|
+
e = await fetch(O, {
|
|
200
215
|
method: "POST",
|
|
201
216
|
headers: {
|
|
202
217
|
"Content-Type": "application/json",
|
|
@@ -207,7 +222,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
207
222
|
body: s
|
|
208
223
|
});
|
|
209
224
|
} catch (e) {
|
|
210
|
-
return
|
|
225
|
+
return A(C(_, e)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
|
|
211
226
|
"Server action ",
|
|
212
227
|
/* @__PURE__ */ l("b", { children: n }),
|
|
213
228
|
" could not be reached"
|
|
@@ -215,7 +230,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
215
230
|
actionId: n,
|
|
216
231
|
mode: r,
|
|
217
232
|
error: e instanceof Error ? e.message : String(e)
|
|
218
|
-
}),
|
|
233
|
+
}), j(t?.hostElementId, "onFlowError", {
|
|
219
234
|
actionId: n,
|
|
220
235
|
runId: "",
|
|
221
236
|
error: "",
|
|
@@ -224,18 +239,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
224
239
|
}
|
|
225
240
|
if (!e.ok || !e.body) {
|
|
226
241
|
let r = await e.json().catch(() => ({}));
|
|
227
|
-
return w(e.status, r, E),
|
|
228
|
-
status: "failed",
|
|
229
|
-
...r.runId ? { runId: r.runId } : {},
|
|
230
|
-
...r.reason ? { reason: r.reason } : {},
|
|
231
|
-
...r.error ? { error: r.error } : {},
|
|
232
|
-
...r.steps ? { steps: r.steps } : {}
|
|
233
|
-
}), k(t?.hostElementId, "onFlowError", {
|
|
234
|
-
actionId: n,
|
|
235
|
-
runId: r.runId ?? "",
|
|
236
|
-
error: r.error ?? "",
|
|
237
|
-
reason: r.reason ?? "failed"
|
|
238
|
-
}), {
|
|
242
|
+
return w(e.status, r, O), A(T(r)), j(t?.hostElementId, "onFlowError", E(n, r)), {
|
|
239
243
|
status: "failed",
|
|
240
244
|
reason: r.reason ?? "failed",
|
|
241
245
|
runId: "",
|
|
@@ -249,7 +253,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
249
253
|
...i ? { runId: i } : {}
|
|
250
254
|
}), b(e.body, (e) => {
|
|
251
255
|
if (e.event === "data") {
|
|
252
|
-
d(g, e.data.chunk ?? e.data),
|
|
256
|
+
d(g, e.data.chunk ?? e.data), j(t?.hostElementId, "onFlowProgress", {
|
|
253
257
|
actionId: n,
|
|
254
258
|
runId: i,
|
|
255
259
|
...e.data
|
|
@@ -258,12 +262,12 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
258
262
|
}
|
|
259
263
|
if (e.event === "error") {
|
|
260
264
|
let r = y(e.data.steps);
|
|
261
|
-
|
|
265
|
+
A({
|
|
262
266
|
status: "failed",
|
|
263
267
|
...typeof e.data.reason == "string" ? { reason: e.data.reason } : {},
|
|
264
268
|
...typeof e.data.error == "string" ? { error: e.data.error } : {},
|
|
265
269
|
...r ? { steps: r } : {}
|
|
266
|
-
}),
|
|
270
|
+
}), j(t?.hostElementId, "onFlowError", {
|
|
267
271
|
actionId: n,
|
|
268
272
|
runId: i,
|
|
269
273
|
...e.data
|
|
@@ -272,12 +276,12 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
272
276
|
}
|
|
273
277
|
if (e.event === "done") {
|
|
274
278
|
let r = y(e.data.steps);
|
|
275
|
-
|
|
279
|
+
A({
|
|
276
280
|
status: e.data.status === "completed" ? "completed" : "failed",
|
|
277
281
|
...e.data.output ? { output: e.data.output } : {},
|
|
278
282
|
...typeof e.data.error == "string" ? { error: e.data.error } : {},
|
|
279
283
|
...r ? { steps: r } : {}
|
|
280
|
-
}),
|
|
284
|
+
}), j(t?.hostElementId, "onFlowEnd", {
|
|
281
285
|
actionId: n,
|
|
282
286
|
runId: i,
|
|
283
287
|
...e.data
|
|
@@ -286,7 +290,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
286
290
|
}).catch((e) => {
|
|
287
291
|
if (_.signal.aborted) return;
|
|
288
292
|
let o = e instanceof Error ? e.message : String(e);
|
|
289
|
-
|
|
293
|
+
A({
|
|
290
294
|
status: "failed",
|
|
291
295
|
error: o
|
|
292
296
|
}), a.warning("actions", /* @__PURE__ */ u("span", { children: [
|
|
@@ -298,7 +302,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
298
302
|
mode: r,
|
|
299
303
|
runId: i,
|
|
300
304
|
error: o
|
|
301
|
-
}),
|
|
305
|
+
}), j(t?.hostElementId, "onFlowError", {
|
|
302
306
|
actionId: n,
|
|
303
307
|
runId: i,
|
|
304
308
|
error: o,
|
|
@@ -311,9 +315,9 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
311
315
|
output: {}
|
|
312
316
|
};
|
|
313
317
|
}
|
|
314
|
-
let
|
|
318
|
+
let M;
|
|
315
319
|
try {
|
|
316
|
-
|
|
320
|
+
M = await fetch(O, {
|
|
317
321
|
method: "POST",
|
|
318
322
|
headers: { "Content-Type": "application/json" },
|
|
319
323
|
credentials: "same-origin",
|
|
@@ -321,61 +325,55 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
321
325
|
body: s
|
|
322
326
|
});
|
|
323
327
|
} catch (e) {
|
|
324
|
-
return
|
|
328
|
+
return A(C(_, e)), a.warning("interactions", /* @__PURE__ */ u("span", { children: [
|
|
325
329
|
"Server action ",
|
|
326
330
|
/* @__PURE__ */ l("b", { children: n }),
|
|
327
331
|
" could not be reached"
|
|
328
332
|
] }), {
|
|
329
333
|
actionId: n,
|
|
330
334
|
error: e instanceof Error ? e.message : String(e)
|
|
331
|
-
}),
|
|
335
|
+
}), j(t?.hostElementId, "onFlowError", {
|
|
332
336
|
actionId: n,
|
|
333
337
|
runId: "",
|
|
334
338
|
error: "",
|
|
335
339
|
reason: "failed"
|
|
336
340
|
}), S;
|
|
337
341
|
}
|
|
338
|
-
let
|
|
339
|
-
return
|
|
340
|
-
status:
|
|
341
|
-
...
|
|
342
|
-
...
|
|
343
|
-
...
|
|
344
|
-
...
|
|
345
|
-
...
|
|
346
|
-
}), {
|
|
347
|
-
status:
|
|
348
|
-
runId:
|
|
349
|
-
output:
|
|
350
|
-
...
|
|
351
|
-
}) : (w(
|
|
352
|
-
status: "failed",
|
|
353
|
-
...j.runId ? { runId: j.runId } : {},
|
|
354
|
-
...j.reason ? { reason: j.reason } : {},
|
|
355
|
-
...j.error ? { error: j.error } : {},
|
|
356
|
-
...j.steps ? { steps: j.steps } : {}
|
|
357
|
-
}), a.warning("actions", /* @__PURE__ */ u("span", { children: [
|
|
342
|
+
let N = await M.json().catch(() => ({}));
|
|
343
|
+
return M.ok ? (A({
|
|
344
|
+
status: N.status === "completed" ? "completed" : "failed",
|
|
345
|
+
...N.runId ? { runId: N.runId } : {},
|
|
346
|
+
...N.output ? { output: N.output } : {},
|
|
347
|
+
...N.error ? { error: N.error } : {},
|
|
348
|
+
...N.steps ? { steps: N.steps } : {},
|
|
349
|
+
...N.trace ? { trace: N.trace } : {}
|
|
350
|
+
}), N.status === "failed" && j(t?.hostElementId, "onFlowError", E(n, N)), {
|
|
351
|
+
status: N.status ?? "completed",
|
|
352
|
+
runId: N.runId ?? "",
|
|
353
|
+
output: N.output ?? {},
|
|
354
|
+
...N.error ? { error: N.error } : {}
|
|
355
|
+
}) : (w(M.status, N, O), A(T(N)), j(t?.hostElementId, "onFlowError", E(n, N)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
|
|
358
356
|
"Server action ",
|
|
359
357
|
/* @__PURE__ */ l("b", { children: n }),
|
|
360
358
|
" was refused"
|
|
361
359
|
] }), {
|
|
362
360
|
actionId: n,
|
|
363
361
|
mode: r,
|
|
364
|
-
runId:
|
|
365
|
-
reason:
|
|
366
|
-
error:
|
|
367
|
-
status: String(
|
|
362
|
+
runId: N.runId,
|
|
363
|
+
reason: N.reason,
|
|
364
|
+
error: N.error,
|
|
365
|
+
status: String(M.status)
|
|
368
366
|
}), {
|
|
369
367
|
status: "failed",
|
|
370
|
-
reason:
|
|
371
|
-
runId:
|
|
368
|
+
reason: N.reason ?? "failed",
|
|
369
|
+
runId: N.runId ?? "",
|
|
372
370
|
output: {},
|
|
373
|
-
...
|
|
371
|
+
...N.error ? { error: N.error } : {}
|
|
374
372
|
});
|
|
375
|
-
}, [
|
|
376
|
-
if (!
|
|
373
|
+
}, [O, j]), N = r(async (e) => {
|
|
374
|
+
if (!O || !e.runId) return { cancelled: !1 };
|
|
377
375
|
try {
|
|
378
|
-
let t = (await fetch(`${
|
|
376
|
+
let t = (await fetch(`${O}/run/${e.runId}`, {
|
|
379
377
|
method: "DELETE",
|
|
380
378
|
credentials: "same-origin"
|
|
381
379
|
})).status === 204;
|
|
@@ -393,25 +391,25 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
393
391
|
} catch {
|
|
394
392
|
return { cancelled: !1 };
|
|
395
393
|
}
|
|
396
|
-
}, [
|
|
394
|
+
}, [O]), P = i(() => (k ?? []).map((e) => ({
|
|
397
395
|
label: `${e.name} (${e.identifier})`,
|
|
398
396
|
value: e.identifier
|
|
399
|
-
})), [
|
|
397
|
+
})), [k]);
|
|
400
398
|
return v({
|
|
401
399
|
id: "actions",
|
|
402
400
|
callbacks: i(() => s(t, {
|
|
403
|
-
cancelServerAction:
|
|
404
|
-
runServerAction:
|
|
401
|
+
cancelServerAction: N,
|
|
402
|
+
runServerAction: M
|
|
405
403
|
}, { runServerAction: { params: (e) => {
|
|
406
|
-
let n = o(t.runServerAction.params), r = (
|
|
404
|
+
let n = o(t.runServerAction.params), r = (k ?? []).find((t) => t.identifier === e.actionId), i = Object.entries(r?.input ?? {});
|
|
407
405
|
return {
|
|
408
406
|
...n,
|
|
409
407
|
actionId: {
|
|
410
408
|
...n.actionId,
|
|
411
|
-
type: () =>
|
|
409
|
+
type: () => P.length > 0 ? "select" : "text",
|
|
412
410
|
canBind: !0,
|
|
413
|
-
label:
|
|
414
|
-
options:
|
|
411
|
+
label: A === !1 ? "Action — this space has no server to run it" : "Action",
|
|
412
|
+
options: P
|
|
415
413
|
},
|
|
416
414
|
input: {
|
|
417
415
|
...n.input,
|
|
@@ -420,13 +418,13 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
|
|
|
420
418
|
}
|
|
421
419
|
};
|
|
422
420
|
} } }), [
|
|
423
|
-
A,
|
|
424
|
-
j,
|
|
425
421
|
M,
|
|
426
|
-
|
|
427
|
-
|
|
422
|
+
N,
|
|
423
|
+
P,
|
|
424
|
+
k,
|
|
425
|
+
A
|
|
428
426
|
])
|
|
429
427
|
}), _;
|
|
430
428
|
};
|
|
431
429
|
//#endregion
|
|
432
|
-
export {
|
|
430
|
+
export { D as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { processTwig as e } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
2
|
-
import {
|
|
2
|
+
import { getPathsFromObject as t } from "@plitzi/sdk-shared/helpers/utils";
|
|
3
3
|
//#region src/utility/twigTemplate.ts
|
|
4
4
|
var n = {
|
|
5
5
|
action: "twigTemplate",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-interactions",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.13",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -203,9 +203,9 @@
|
|
|
203
203
|
},
|
|
204
204
|
"dependencies": {
|
|
205
205
|
"@plitzi/plitzi-ui": "^1.6.33",
|
|
206
|
-
"@plitzi/sdk-auth": "0.38.
|
|
207
|
-
"@plitzi/sdk-event-bridge": "0.38.
|
|
208
|
-
"@plitzi/sdk-shared": "0.38.
|
|
206
|
+
"@plitzi/sdk-auth": "0.38.13",
|
|
207
|
+
"@plitzi/sdk-event-bridge": "0.38.13",
|
|
208
|
+
"@plitzi/sdk-shared": "0.38.13"
|
|
209
209
|
},
|
|
210
210
|
"peerDependencies": {
|
|
211
211
|
"react": "^19"
|