@plitzi/sdk-interactions 0.35.10 → 0.36.1

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 CHANGED
@@ -1,5 +1,72 @@
1
1
  # @plitzi/sdk-interactions
2
2
 
3
+ ## 0.36.1
4
+
5
+ ### Patch Changes
6
+
7
+ - v0.36.1
8
+ - Updated dependencies
9
+ - @plitzi/sdk-auth@0.36.1
10
+ - @plitzi/sdk-dev-tools@0.36.1
11
+ - @plitzi/sdk-event-bridge@0.36.1
12
+ - @plitzi/sdk-navigation@0.36.1
13
+ - @plitzi/sdk-schema@0.36.1
14
+ - @plitzi/sdk-shared@0.36.1
15
+
16
+ ## 0.36.0
17
+
18
+ ### Minor Changes
19
+
20
+ - - **An `apiContainer` can keep its browser requests in a query cache, the way react-query does.** Moving between
21
+ sections or pages used to ask the API again every time a provider was shown: a provider in a hidden section is
22
+ mounted but disabled, so showing it fired a fresh request, and a page navigation remounted it and did the same.
23
+ With the new `cache: true` an answer is kept for `staleTime` seconds (30 by default) and shared by every cached
24
+ provider asking the same thing — same method, URL, credentials and headers, the token included, so two visitors
25
+ never share one. Past its time the answer is still drawn at once and a fresh one is fetched behind it; an answer
26
+ nobody shows is forgotten after `gcTime` seconds (300 by default). A refused request (`4xx`/`5xx`) is shown but
27
+ never kept. **The cache is off unless an element asks for it**: an uncached provider behaves as before, asking on
28
+ every mount and sharing nothing.
29
+
30
+ The cache is `@plitzi/sdk-shared/queries` (`queryCache`, `useQuery`, `invalidateQueries`,
31
+ `invalidateQueriesForWrite`), a nexus store written with the per-path `ttl` of `@plitzi/nexus` 1.2.0, which every
32
+ consumer now requires. It reacts to the store's own freshness events, so anything that expires a query's path
33
+ makes the providers on screen ask again.
34
+
35
+ An answer stops counting as current before its time when the element's `performQuery` runs (it always asks
36
+ again), when a flow runs the new global `invalidateQueries` step (source `queries`: `elements`, api container ids
37
+ — a container's requests are tagged with its own id — and/or a `url` prefix), and after a write. Both write steps
38
+ gained `invalidateQueries` / `invalidateElements`: a `webHook` sent with anything but `GET`/`HEAD` refreshes the
39
+ requests to its own site by default, a completed `runServerAction` refreshes all of them by default, and either
40
+ can name containers instead or refresh nothing. A `writeRecord` refreshes all. Providers on screen ask again at
41
+ once; the rest when they are next shown. A sign-in, sign-out or change of account drops everything held. Server-driven
42
+ providers and RSC are untouched.
43
+
44
+ - **A `webHook` that reads can be cached** (`cache`, `staleTime`), in the same cache and under the same key as an api
45
+ container asking the same thing. Its declaration now lives beside it (`utility/webHookSpec`) and the authoring
46
+ catalog gathers it instead of keeping a copy. A `HEAD` is no longer sent with a body, which `fetch` refused.
47
+
48
+ - **Step params can pick several elements.** A new param type, `elementIds` (with an `elementType` filter), is drawn
49
+ in the flow editor as a picker: the matching elements of the space to add, and the picked ones as chips to remove —
50
+ an id no element answers to any more is kept and flagged. The value is a list of ids, so nobody types a
51
+ comma-separated list; `invalidateQueries.elements` and the write steps' `invalidateElements` use it, and the MCP
52
+ catalog says which element type each such param takes.
53
+
54
+ - The dev-tools' Store tab lists the paths a store holds with a TTL — how long ago each was written, what is left
55
+ of it, and a button to expire one or all of them. The query cache appears there as "Queries".
56
+
57
+ - `useApi` no longer takes `params`: nothing passed them, and a GET cannot carry a body anyway. A mock now answers
58
+ synchronously, without a loading frame, and a provider whose URL has not resolved asks for nothing.
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies
63
+ - @plitzi/sdk-auth@0.36.0
64
+ - @plitzi/sdk-dev-tools@0.36.0
65
+ - @plitzi/sdk-event-bridge@0.36.0
66
+ - @plitzi/sdk-navigation@0.36.0
67
+ - @plitzi/sdk-schema@0.36.0
68
+ - @plitzi/sdk-shared@0.36.0
69
+
3
70
  ## 0.35.10
4
71
 
5
72
  ### Patch Changes
@@ -3,32 +3,33 @@ import t from "./sources/ActionsSource/ActionInteractions.mjs";
3
3
  import n from "./sources/AuthSource/AuthInteractions.mjs";
4
4
  import r from "./sources/HostSource/HostInteractions.mjs";
5
5
  import i from "./sources/NavigationSource/NavigationInteractions.mjs";
6
- import a from "./sources/StateSource/StateInteractions.mjs";
7
- import { jsx as o } from "react/jsx-runtime";
8
- import { useRenderSettings as s, useSdkStore as c } from "@plitzi/sdk-shared/store";
6
+ import a from "./sources/QueriesSource/QueriesInteractions.mjs";
7
+ import o from "./sources/StateSource/StateInteractions.mjs";
8
+ import { jsx as s } from "react/jsx-runtime";
9
+ import { useRenderSettings as c, useSdkStore as l } from "@plitzi/sdk-shared/store";
9
10
  //#region src/InteractionsSourcesProvider.tsx
10
- var l = ({ children: l, hostActions: u }) => {
11
- let [[d = "basic", f, p, m]] = c([
11
+ var u = ({ children: u, hostActions: d }) => {
12
+ let [[f = "basic", p, m, h]] = l([
12
13
  "schema.settings.userProvider",
13
14
  "navigation.routeParams",
14
15
  "navigation.queryParams",
15
16
  "navigation.currentPageId"
16
- ]), { previewMode: h } = s();
17
- return /* @__PURE__ */ o(e, {
18
- currentPageId: m,
19
- routeParams: f,
20
- queryParams: p,
21
- children: /* @__PURE__ */ o(n, {
22
- authProvider: d,
23
- children: /* @__PURE__ */ o(a, { children: /* @__PURE__ */ o(t, { children: /* @__PURE__ */ o(i, {
24
- previewMode: h,
25
- children: /* @__PURE__ */ o(r, {
26
- actions: u,
27
- children: l
17
+ ]), { previewMode: g } = c();
18
+ return /* @__PURE__ */ s(e, {
19
+ currentPageId: h,
20
+ routeParams: p,
21
+ queryParams: m,
22
+ children: /* @__PURE__ */ s(n, {
23
+ authProvider: f,
24
+ children: /* @__PURE__ */ s(o, { children: /* @__PURE__ */ s(t, { children: /* @__PURE__ */ s(a, { children: /* @__PURE__ */ s(i, {
25
+ previewMode: g,
26
+ children: /* @__PURE__ */ s(r, {
27
+ actions: d,
28
+ children: u
28
29
  })
29
- }) }) })
30
+ }) }) }) })
30
31
  })
31
32
  });
32
33
  };
33
34
  //#endregion
34
- export { l as default };
35
+ export { u as default };
package/dist/index.mjs CHANGED
@@ -9,6 +9,7 @@ import c from "./sources/AuthSource/AuthInteractions.mjs";
9
9
  import l from "./sources/HostSource/callbacks.mjs";
10
10
  import u from "./sources/HostSource/HostInteractions.mjs";
11
11
  import d from "./sources/NavigationSource/NavigationInteractions.mjs";
12
- import f from "./sources/StateSource/StateInteractions.mjs";
13
- import p from "./InteractionsSourcesProvider.mjs";
14
- export { s as ActionInteractions, c as AuthInteractions, u as HostInteractions, e as InteractionsContext, o as InteractionsContextProvider, r as InteractionsHelper, a as InteractionsManager, p as InteractionsSourcesProvider, d as NavigationInteractions, f as StateInteractions, i as flowTrigger, l as hostCallbacks, t as useInteractions, n as utility };
12
+ import f from "./sources/QueriesSource/QueriesInteractions.mjs";
13
+ import p from "./sources/StateSource/StateInteractions.mjs";
14
+ import m from "./InteractionsSourcesProvider.mjs";
15
+ export { s as ActionInteractions, c as AuthInteractions, u as HostInteractions, e as InteractionsContext, o as InteractionsContextProvider, r as InteractionsHelper, a as InteractionsManager, m as InteractionsSourcesProvider, d as NavigationInteractions, f as QueriesInteractions, p as StateInteractions, i as flowTrigger, l as hostCallbacks, t as useInteractions, n as utility };
@@ -2,12 +2,13 @@ import e from "../../InteractionsContext.mjs";
2
2
  import { actionsCallbacks as t } from "./callbacks.mjs";
3
3
  import { use as n, useCallback as r, useMemo as i } from "react";
4
4
  import { pConsole as a } from "@plitzi/sdk-shared/devTools/utils/PlitziConsole";
5
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
- import { recordActionProgress as c, recordActionRun as l, registerActionCanceller as u, releaseActionCanceller as d, updateActionRun as f, useCommonStore as p } from "@plitzi/sdk-shared/store";
7
- import { authFailureFromResponse as m, reportAuthFailure as h } from "@plitzi/sdk-shared/auth";
8
- import { toBuilderParams as g, toInteractionCallbacks as _ } from "@plitzi/sdk-shared/authoring/builder";
5
+ import { toBuilderParams as o, toInteractionCallbacks as s } from "@plitzi/sdk-shared/authoring/builder";
6
+ import { invalidateAfterWrite as c } from "@plitzi/sdk-shared/queries";
7
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
8
+ import { recordActionProgress as d, recordActionRun as f, registerActionCanceller as p, releaseActionCanceller as m, updateActionRun as h, useCommonStore as g } from "@plitzi/sdk-shared/store";
9
+ import { authFailureFromResponse as _, reportAuthFailure as v } from "@plitzi/sdk-shared/auth";
9
10
  //#region src/sources/ActionsSource/ActionInteractions.tsx
10
- var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
11
+ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
11
12
  let n = e.getReader(), r = new TextDecoder(), i = "";
12
13
  for (;;) {
13
14
  let { done: e, value: a } = await n.read();
@@ -27,7 +28,7 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
27
28
  } catch {}
28
29
  }
29
30
  }
30
- }, b = (e) => {
31
+ }, x = (e) => {
31
32
  if (!e) return {};
32
33
  if (typeof e == "object") return e;
33
34
  try {
@@ -36,32 +37,32 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
36
37
  } catch {
37
38
  return {};
38
39
  }
39
- }, x = {
40
+ }, S = {
40
41
  status: "failed",
41
42
  reason: "failed",
42
43
  runId: "",
43
44
  output: {}
44
- }, S = (e, t) => e.signal.aborted ? {
45
+ }, C = (e, t) => e.signal.aborted ? {
45
46
  status: "aborted",
46
47
  error: "Cancelled"
47
48
  } : {
48
49
  status: "failed",
49
50
  error: t instanceof Error ? t.message : String(t)
50
- }, C = (e, t, n) => {
51
+ }, w = (e, t, n) => {
51
52
  if (e !== 401) return;
52
- let r = m(e, t);
53
- r && h({
53
+ let r = _(e, t);
54
+ r && v({
54
55
  reason: r,
55
56
  url: n
56
57
  });
57
- }, w = ({ children: m }) => {
58
- let { useInteractions: h, interactionsManager: w } = n(e), [T] = p("actions.endpoint"), [[E, D]] = p(["actions.catalog", "actions.available"]), O = r((e, t, n) => {
59
- e && w.interactionTrigger(e, t, n);
60
- }, [w]), k = r(async (e, t) => {
58
+ }, T = ({ children: _ }) => {
59
+ let { useInteractions: v, interactionsManager: T } = n(e), [E] = g("actions.endpoint"), [[D, O]] = g(["actions.catalog", "actions.available"]), k = r((e, t, n) => {
60
+ e && T.interactionTrigger(e, t, n);
61
+ }, [T]), A = r(async (e, t) => {
61
62
  let { actionId: n, mode: r = "await", idempotencyKey: i } = e;
62
- if (!T) return a.warning("actions", /* @__PURE__ */ s("span", { children: [
63
+ if (!E) return a.warning("actions", /* @__PURE__ */ u("span", { children: [
63
64
  "Server action ",
64
- /* @__PURE__ */ o("b", { children: n }),
65
+ /* @__PURE__ */ l("b", { children: n }),
65
66
  " was skipped: this page is served without a Plitzi server"
66
67
  ] }), {
67
68
  actionId: n,
@@ -76,57 +77,61 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
76
77
  runId: "",
77
78
  output: {}
78
79
  };
79
- let p = b(e.input), m = JSON.stringify({
80
+ let o = x(e.input), s = JSON.stringify({
80
81
  actionId: n,
81
- input: p,
82
+ input: o,
82
83
  ...i ? { idempotencyKey: i } : {}
83
- }), h = l({
84
+ }), g = f({
84
85
  actionId: n,
85
86
  mode: r,
86
- input: p
87
- }), g = new AbortController(), _ = "";
88
- u(h, () => {
89
- g.abort(), f(h, {
87
+ input: o
88
+ }), _ = new AbortController(), v = "";
89
+ p(g, () => {
90
+ _.abort(), h(g, {
90
91
  status: "aborted",
91
92
  endedAt: Date.now(),
92
93
  cancellable: !1
93
- }), _ && fetch(`${T}/run/${_}`, {
94
+ }), v && fetch(`${E}/run/${v}`, {
94
95
  method: "DELETE",
95
96
  credentials: "same-origin"
96
97
  }).catch(() => void 0);
97
98
  });
98
- let w = (e) => {
99
- d(h), f(h, {
99
+ let T = (t) => {
100
+ m(g), h(g, {
100
101
  endedAt: Date.now(),
101
102
  cancellable: !1,
102
- ...e
103
+ ...t
104
+ }), t.status === "completed" && c({
105
+ mode: e.invalidateQueries,
106
+ fallback: "all",
107
+ elements: e.invalidateElements
103
108
  });
104
109
  };
105
- if (r === "detached") return a.info("actions", /* @__PURE__ */ s("span", { children: [
110
+ if (r === "detached") return a.info("actions", /* @__PURE__ */ u("span", { children: [
106
111
  "Server action ",
107
- /* @__PURE__ */ o("b", { children: n }),
112
+ /* @__PURE__ */ l("b", { children: n }),
108
113
  " sent"
109
114
  ] }), {
110
115
  actionId: n,
111
116
  mode: r,
112
117
  status: "accepted"
113
- }), fetch(T, {
118
+ }), fetch(E, {
114
119
  method: "POST",
115
120
  headers: { "Content-Type": "application/json" },
116
121
  credentials: "same-origin",
117
122
  keepalive: !0,
118
- signal: g.signal,
119
- body: m
123
+ signal: _.signal,
124
+ body: s
120
125
  }).then(async (e) => {
121
126
  let i = await e.json().catch(() => ({}));
122
127
  if (!e.ok) {
123
- C(e.status, i, T), w({
128
+ w(e.status, i, E), T({
124
129
  status: "failed",
125
130
  ...i.runId ? { runId: i.runId } : {},
126
131
  ...i.reason ? { reason: i.reason } : {},
127
132
  ...i.error ? { error: i.error } : {},
128
133
  ...i.steps ? { steps: i.steps } : {}
129
- }), O(t?.hostElementId, "onFlowError", {
134
+ }), k(t?.hostElementId, "onFlowError", {
130
135
  actionId: n,
131
136
  runId: i.runId ?? "",
132
137
  error: i.error ?? "",
@@ -134,15 +139,15 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
134
139
  });
135
140
  return;
136
141
  }
137
- w({
142
+ T({
138
143
  status: i.status === "completed" ? "completed" : "accepted",
139
144
  ...i.runId ? { runId: i.runId } : {},
140
145
  ...i.output ? { output: i.output } : {},
141
146
  ...i.steps ? { steps: i.steps } : {},
142
147
  ...i.trace ? { trace: i.trace } : {}
143
- }), a.success("actions", /* @__PURE__ */ s("span", { children: [
148
+ }), a.success("actions", /* @__PURE__ */ u("span", { children: [
144
149
  "Server action ",
145
- /* @__PURE__ */ o("b", { children: n }),
150
+ /* @__PURE__ */ l("b", { children: n }),
146
151
  " finished"
147
152
  ] }), {
148
153
  actionId: n,
@@ -150,22 +155,22 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
150
155
  runId: i.runId,
151
156
  status: i.status,
152
157
  output: i.output
153
- }), O(t?.hostElementId, "onFlowEnd", {
158
+ }), k(t?.hostElementId, "onFlowEnd", {
154
159
  actionId: n,
155
160
  runId: i.runId ?? "",
156
161
  status: i.status ?? "completed",
157
162
  output: i.output ?? {}
158
163
  });
159
164
  }).catch((e) => {
160
- w(S(g, e)), a.warning("actions", /* @__PURE__ */ s("span", { children: [
165
+ T(C(_, e)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
161
166
  "Server action ",
162
- /* @__PURE__ */ o("b", { children: n }),
167
+ /* @__PURE__ */ l("b", { children: n }),
163
168
  " could not be sent"
164
169
  ] }), {
165
170
  actionId: n,
166
171
  mode: r,
167
172
  error: e instanceof Error ? e.message : String(e)
168
- }), O(t?.hostElementId, "onFlowError", {
173
+ }), k(t?.hostElementId, "onFlowError", {
169
174
  actionId: n,
170
175
  runId: "",
171
176
  error: "",
@@ -178,9 +183,9 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
178
183
  output: {}
179
184
  };
180
185
  if (r === "stream") {
181
- a.info("actions", /* @__PURE__ */ s("span", { children: [
186
+ a.info("actions", /* @__PURE__ */ u("span", { children: [
182
187
  "Server action ",
183
- /* @__PURE__ */ o("b", { children: n }),
188
+ /* @__PURE__ */ l("b", { children: n }),
184
189
  " streaming"
185
190
  ] }), {
186
191
  actionId: n,
@@ -189,41 +194,41 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
189
194
  });
190
195
  let e;
191
196
  try {
192
- e = await fetch(T, {
197
+ e = await fetch(E, {
193
198
  method: "POST",
194
199
  headers: {
195
200
  "Content-Type": "application/json",
196
201
  Accept: "text/event-stream"
197
202
  },
198
203
  credentials: "same-origin",
199
- signal: g.signal,
200
- body: m
204
+ signal: _.signal,
205
+ body: s
201
206
  });
202
207
  } catch (e) {
203
- return w(S(g, e)), a.warning("actions", /* @__PURE__ */ s("span", { children: [
208
+ return T(C(_, e)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
204
209
  "Server action ",
205
- /* @__PURE__ */ o("b", { children: n }),
210
+ /* @__PURE__ */ l("b", { children: n }),
206
211
  " could not be reached"
207
212
  ] }), {
208
213
  actionId: n,
209
214
  mode: r,
210
215
  error: e instanceof Error ? e.message : String(e)
211
- }), O(t?.hostElementId, "onFlowError", {
216
+ }), k(t?.hostElementId, "onFlowError", {
212
217
  actionId: n,
213
218
  runId: "",
214
219
  error: "",
215
220
  reason: "failed"
216
- }), x;
221
+ }), S;
217
222
  }
218
223
  if (!e.ok || !e.body) {
219
224
  let r = await e.json().catch(() => ({}));
220
- return C(e.status, r, T), w({
225
+ return w(e.status, r, E), T({
221
226
  status: "failed",
222
227
  ...r.runId ? { runId: r.runId } : {},
223
228
  ...r.reason ? { reason: r.reason } : {},
224
229
  ...r.error ? { error: r.error } : {},
225
230
  ...r.steps ? { steps: r.steps } : {}
226
- }), O(t?.hostElementId, "onFlowError", {
231
+ }), k(t?.hostElementId, "onFlowError", {
227
232
  actionId: n,
228
233
  runId: r.runId ?? "",
229
234
  error: r.error ?? "",
@@ -236,12 +241,12 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
236
241
  };
237
242
  }
238
243
  let i = e.headers.get("X-Plitzi-Run-Id") ?? "";
239
- return _ = i, f(h, {
244
+ return v = i, h(g, {
240
245
  status: "streaming",
241
246
  ...i ? { runId: i } : {}
242
- }), y(e.body, (e) => {
247
+ }), b(e.body, (e) => {
243
248
  if (e.event === "data") {
244
- c(h, e.data.chunk ?? e.data), O(t?.hostElementId, "onFlowProgress", {
249
+ d(g, e.data.chunk ?? e.data), k(t?.hostElementId, "onFlowProgress", {
245
250
  actionId: n,
246
251
  runId: i,
247
252
  ...e.data
@@ -249,13 +254,13 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
249
254
  return;
250
255
  }
251
256
  if (e.event === "error") {
252
- let r = v(e.data.steps);
253
- w({
257
+ let r = y(e.data.steps);
258
+ T({
254
259
  status: "failed",
255
260
  ...typeof e.data.reason == "string" ? { reason: e.data.reason } : {},
256
261
  ...typeof e.data.error == "string" ? { error: e.data.error } : {},
257
262
  ...r ? { steps: r } : {}
258
- }), O(t?.hostElementId, "onFlowError", {
263
+ }), k(t?.hostElementId, "onFlowError", {
259
264
  actionId: n,
260
265
  runId: i,
261
266
  ...e.data
@@ -263,36 +268,36 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
263
268
  return;
264
269
  }
265
270
  if (e.event === "done") {
266
- let r = v(e.data.steps);
267
- w({
271
+ let r = y(e.data.steps);
272
+ T({
268
273
  status: e.data.status === "completed" ? "completed" : "failed",
269
274
  ...e.data.output ? { output: e.data.output } : {},
270
275
  ...r ? { steps: r } : {}
271
- }), O(t?.hostElementId, "onFlowEnd", {
276
+ }), k(t?.hostElementId, "onFlowEnd", {
272
277
  actionId: n,
273
278
  runId: i,
274
279
  ...e.data
275
280
  });
276
281
  }
277
282
  }).catch((e) => {
278
- if (g.signal.aborted) return;
279
- let c = e instanceof Error ? e.message : String(e);
280
- w({
283
+ if (_.signal.aborted) return;
284
+ let o = e instanceof Error ? e.message : String(e);
285
+ T({
281
286
  status: "failed",
282
- error: c
283
- }), a.warning("actions", /* @__PURE__ */ s("span", { children: [
287
+ error: o
288
+ }), a.warning("actions", /* @__PURE__ */ u("span", { children: [
284
289
  "Server action ",
285
- /* @__PURE__ */ o("b", { children: n }),
290
+ /* @__PURE__ */ l("b", { children: n }),
286
291
  " stopped mid-stream"
287
292
  ] }), {
288
293
  actionId: n,
289
294
  mode: r,
290
295
  runId: i,
291
- error: c
292
- }), O(t?.hostElementId, "onFlowError", {
296
+ error: o
297
+ }), k(t?.hostElementId, "onFlowError", {
293
298
  actionId: n,
294
299
  runId: i,
295
- error: c,
300
+ error: o,
296
301
  reason: "failed"
297
302
  });
298
303
  }), {
@@ -302,74 +307,74 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
302
307
  output: {}
303
308
  };
304
309
  }
305
- let E;
310
+ let D;
306
311
  try {
307
- E = await fetch(T, {
312
+ D = await fetch(E, {
308
313
  method: "POST",
309
314
  headers: { "Content-Type": "application/json" },
310
315
  credentials: "same-origin",
311
- signal: g.signal,
312
- body: m
316
+ signal: _.signal,
317
+ body: s
313
318
  });
314
319
  } catch (e) {
315
- return w(S(g, e)), a.warning("interactions", /* @__PURE__ */ s("span", { children: [
320
+ return T(C(_, e)), a.warning("interactions", /* @__PURE__ */ u("span", { children: [
316
321
  "Server action ",
317
- /* @__PURE__ */ o("b", { children: n }),
322
+ /* @__PURE__ */ l("b", { children: n }),
318
323
  " could not be reached"
319
324
  ] }), {
320
325
  actionId: n,
321
326
  error: e instanceof Error ? e.message : String(e)
322
- }), O(t?.hostElementId, "onFlowError", {
327
+ }), k(t?.hostElementId, "onFlowError", {
323
328
  actionId: n,
324
329
  runId: "",
325
330
  error: "",
326
331
  reason: "failed"
327
- }), x;
332
+ }), S;
328
333
  }
329
- let D = await E.json().catch(() => ({}));
330
- return E.ok ? (w({
331
- status: D.status === "completed" ? "completed" : "failed",
332
- ...D.runId ? { runId: D.runId } : {},
333
- ...D.output ? { output: D.output } : {},
334
- ...D.steps ? { steps: D.steps } : {},
335
- ...D.trace ? { trace: D.trace } : {}
334
+ let O = await D.json().catch(() => ({}));
335
+ return D.ok ? (T({
336
+ status: O.status === "completed" ? "completed" : "failed",
337
+ ...O.runId ? { runId: O.runId } : {},
338
+ ...O.output ? { output: O.output } : {},
339
+ ...O.steps ? { steps: O.steps } : {},
340
+ ...O.trace ? { trace: O.trace } : {}
336
341
  }), {
337
- status: D.status ?? "completed",
338
- runId: D.runId ?? "",
339
- output: D.output ?? {}
340
- }) : (C(E.status, D, T), w({
342
+ status: O.status ?? "completed",
343
+ runId: O.runId ?? "",
344
+ output: O.output ?? {}
345
+ }) : (w(D.status, O, E), T({
341
346
  status: "failed",
342
- ...D.runId ? { runId: D.runId } : {},
343
- ...D.reason ? { reason: D.reason } : {},
344
- ...D.error ? { error: D.error } : {},
345
- ...D.steps ? { steps: D.steps } : {}
346
- }), a.warning("actions", /* @__PURE__ */ s("span", { children: [
347
+ ...O.runId ? { runId: O.runId } : {},
348
+ ...O.reason ? { reason: O.reason } : {},
349
+ ...O.error ? { error: O.error } : {},
350
+ ...O.steps ? { steps: O.steps } : {}
351
+ }), a.warning("actions", /* @__PURE__ */ u("span", { children: [
347
352
  "Server action ",
348
- /* @__PURE__ */ o("b", { children: n }),
353
+ /* @__PURE__ */ l("b", { children: n }),
349
354
  " was refused"
350
355
  ] }), {
351
356
  actionId: n,
352
357
  mode: r,
353
- runId: D.runId,
354
- reason: D.reason,
355
- error: D.error,
356
- status: String(E.status)
358
+ runId: O.runId,
359
+ reason: O.reason,
360
+ error: O.error,
361
+ status: String(D.status)
357
362
  }), {
358
363
  status: "failed",
359
- reason: D.reason ?? "failed",
360
- runId: D.runId ?? "",
364
+ reason: O.reason ?? "failed",
365
+ runId: O.runId ?? "",
361
366
  output: {}
362
367
  });
363
- }, [T, O]), A = r(async (e) => {
364
- if (!T || !e.runId) return { cancelled: !1 };
368
+ }, [E, k]), j = r(async (e) => {
369
+ if (!E || !e.runId) return { cancelled: !1 };
365
370
  try {
366
- let t = (await fetch(`${T}/run/${e.runId}`, {
371
+ let t = (await fetch(`${E}/run/${e.runId}`, {
367
372
  method: "DELETE",
368
373
  credentials: "same-origin"
369
374
  })).status === 204;
370
- return a.info("actions", /* @__PURE__ */ s("span", { children: [
375
+ return a.info("actions", /* @__PURE__ */ u("span", { children: [
371
376
  "Server action run ",
372
- /* @__PURE__ */ o("b", { children: e.runId }),
377
+ /* @__PURE__ */ l("b", { children: e.runId }),
373
378
  " ",
374
379
  t ? "cancelled" : "was not cancelled"
375
380
  ] }), {
@@ -381,25 +386,25 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
381
386
  } catch {
382
387
  return { cancelled: !1 };
383
388
  }
384
- }, [T]), j = i(() => (E ?? []).map((e) => ({
389
+ }, [E]), M = i(() => (D ?? []).map((e) => ({
385
390
  label: `${e.name} (${e.identifier})`,
386
391
  value: e.identifier
387
- })), [E]);
388
- return h({
392
+ })), [D]);
393
+ return v({
389
394
  id: "actions",
390
- callbacks: i(() => _(t, {
391
- cancelServerAction: A,
392
- runServerAction: k
395
+ callbacks: i(() => s(t, {
396
+ cancelServerAction: j,
397
+ runServerAction: A
393
398
  }, { runServerAction: { params: (e) => {
394
- let n = g(t.runServerAction.params), r = (E ?? []).find((t) => t.identifier === e.actionId), i = Object.entries(r?.input ?? {});
399
+ let n = o(t.runServerAction.params), r = (D ?? []).find((t) => t.identifier === e.actionId), i = Object.entries(r?.input ?? {});
395
400
  return {
396
401
  ...n,
397
402
  actionId: {
398
403
  ...n.actionId,
399
- type: () => j.length > 0 ? "select" : "text",
404
+ type: () => M.length > 0 ? "select" : "text",
400
405
  canBind: !0,
401
- label: D === !1 ? "Action — this space has no server to run it" : "Action",
402
- options: j
406
+ label: O === !1 ? "Action — this space has no server to run it" : "Action",
407
+ options: M
403
408
  },
404
409
  input: {
405
410
  ...n.input,
@@ -408,13 +413,13 @@ var v = (e) => Array.isArray(e) ? e : void 0, y = async (e, t) => {
408
413
  }
409
414
  };
410
415
  } } }), [
411
- k,
412
416
  A,
413
417
  j,
414
- E,
415
- D
418
+ M,
419
+ D,
420
+ O
416
421
  ])
417
- }), m;
422
+ }), _;
418
423
  };
419
424
  //#endregion
420
- export { w as default };
425
+ export { T as default };
@@ -1,5 +1,6 @@
1
+ import { writeInvalidationParams as e } from "../QueriesSource/writeParams.mjs";
1
2
  //#region src/sources/ActionsSource/callbacks.ts
2
- var e = {
3
+ var t = {
3
4
  runServerAction: {
4
5
  source: "actions",
5
6
  title: "Run Server Action",
@@ -39,7 +40,12 @@ var e = {
39
40
  description: "Makes a repeat of the same intent answer with the first run instead of running again.",
40
41
  default: "",
41
42
  when: (e) => e.mode !== "detached"
42
- }
43
+ },
44
+ ...e([
45
+ "all",
46
+ "elements",
47
+ "none"
48
+ ])
43
49
  },
44
50
  preview: {
45
51
  runId: "",
@@ -60,4 +66,4 @@ var e = {
60
66
  }
61
67
  };
62
68
  //#endregion
63
- export { e as actionsCallbacks };
69
+ export { t as actionsCallbacks };
@@ -2,11 +2,11 @@ import e from "../../InteractionsContext.mjs";
2
2
  import { navigationCallbacks as t } from "./callbacks.mjs";
3
3
  import { use as n, useCallback as r, useMemo as i } from "react";
4
4
  import { get as a, pick as o } from "@plitzi/plitzi-ui/helpers";
5
- import { useSdkStore as s } from "@plitzi/sdk-shared/store";
6
- import { toBuilderParams as c, toInteractionCallbacks as l } from "@plitzi/sdk-shared/authoring/builder";
5
+ import { toBuilderParams as s, toInteractionCallbacks as c } from "@plitzi/sdk-shared/authoring/builder";
6
+ import { useSdkStore as l } from "@plitzi/sdk-shared/store";
7
7
  //#region src/sources/NavigationSource/NavigationInteractions.tsx
8
8
  var u = ({ children: u, previewMode: d = !1 }) => {
9
- let { useInteractions: f } = n(e), [[p, m, h]] = s([
9
+ let { useInteractions: f } = n(e), [[p, m, h]] = l([
10
10
  "schema.pages",
11
11
  "pageDefinitions",
12
12
  "navigation.navigate"
@@ -28,8 +28,8 @@ var u = ({ children: u, previewMode: d = !1 }) => {
28
28
  return f({
29
29
  id: "navigation",
30
30
  callbacks: i(() => {
31
- let { urlType: e, url: n } = c(t.navigate.params);
32
- return l(t, { navigate: _ }, { navigate: { params: {
31
+ let { urlType: e, url: n } = s(t.navigate.params);
32
+ return c(t, { navigate: _ }, { navigate: { params: {
33
33
  urlType: e,
34
34
  url: {
35
35
  ...n,
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ export type QueriesInteractionsProps = {
3
+ children?: ReactNode;
4
+ };
5
+ declare const QueriesInteractions: ({ children }: QueriesInteractionsProps) => ReactNode;
6
+ export default QueriesInteractions;
@@ -0,0 +1,18 @@
1
+ import e from "../../InteractionsContext.mjs";
2
+ import { queriesCallbacks as t } from "./callbacks.mjs";
3
+ import { use as n, useCallback as r, useMemo as i } from "react";
4
+ import { toInteractionCallbacks as a } from "@plitzi/sdk-shared/authoring/builder";
5
+ import { invalidateQueries as o, parseIds as s } from "@plitzi/sdk-shared/queries";
6
+ //#region src/sources/QueriesSource/QueriesInteractions.tsx
7
+ var c = ({ children: c }) => {
8
+ let { useInteractions: l } = n(e), u = r((e) => o({
9
+ url: e.url ?? "",
10
+ elements: s(e.elements)
11
+ }), []);
12
+ return l({
13
+ id: "queries",
14
+ callbacks: i(() => a(t, { invalidateQueries: u }), [u])
15
+ }), c;
16
+ };
17
+ //#endregion
18
+ export { c as default };
@@ -0,0 +1,10 @@
1
+ import { BuiltinGlobalCallback } from '@plitzi/sdk-shared/authoring/builder';
2
+ /**
3
+ * The step that tells the page's cached requests the data behind them changed.
4
+ *
5
+ * A browser request made by an api container is served from memory until its cache time runs out, so a flow that
6
+ * changed something the page reads — through a route of its own, a third-party form, anything the page cannot see
7
+ * — says so here. The providers on screen ask again at once; the ones on a tab nobody is looking at ask when they
8
+ * are shown.
9
+ */
10
+ export declare const queriesCallbacks: Record<string, BuiltinGlobalCallback>;
@@ -0,0 +1,24 @@
1
+ //#region src/sources/QueriesSource/callbacks.ts
2
+ var e = { invalidateQueries: {
3
+ source: "queries",
4
+ title: "Invalidate Queries",
5
+ strictParams: !0,
6
+ params: {
7
+ elements: {
8
+ type: "elementIds",
9
+ elementType: "apiContainer",
10
+ description: "The api containers to refresh, by element id — the way to name a request whose URL is a template. Leave both this and `url` empty to refresh every cached request on the page.",
11
+ default: [],
12
+ label: "Containers (ids)"
13
+ },
14
+ url: {
15
+ type: "text",
16
+ description: "Only the requests whose URL starts with this — `/api/orders` covers `/api/orders?page=2`. With `elements` too, a request must match both.",
17
+ default: "",
18
+ label: "URL prefix"
19
+ }
20
+ },
21
+ preview: {}
22
+ } };
23
+ //#endregion
24
+ export { e as queriesCallbacks };
@@ -0,0 +1,3 @@
1
+ import { default as QueriesInteractions } from './QueriesInteractions';
2
+ export * from './QueriesInteractions';
3
+ export { QueriesInteractions };
@@ -0,0 +1,2 @@
1
+ import e from "./QueriesInteractions.mjs";
2
+ export { e as QueriesInteractions };
@@ -0,0 +1,10 @@
1
+ import { ParamSpec } from '@plitzi/sdk-shared/authoring/paramSpec';
2
+ import { WriteInvalidation } from '@plitzi/sdk-shared/queries';
3
+ /**
4
+ * The two params a step that writes carries: what to refresh once it succeeded, and — when it is a list — which
5
+ * containers, by id. Declared once for every such step, so a webhook and a server action offer the same choice.
6
+ *
7
+ * @param modes What this step can offer, its default first. `origin` needs a URL the step knows.
8
+ * @param applies When the step writes at all; a webhook that only reads shows neither param.
9
+ */
10
+ export declare const writeInvalidationParams: (modes: readonly WriteInvalidation[], applies?: (params: Record<string, unknown>) => boolean) => ParamSpec;
@@ -0,0 +1,28 @@
1
+ //#region src/sources/QueriesSource/writeParams.ts
2
+ var e = {
3
+ origin: "Requests to the same site",
4
+ all: "All cached requests",
5
+ elements: "Only these containers",
6
+ none: "None — this only reads"
7
+ }, t = (t, n = () => !0) => ({
8
+ invalidateQueries: {
9
+ type: "select",
10
+ description: "What to refresh once the write succeeded, so the page shows the new data: the cached requests to the same site, all of them, only the api containers named in `invalidateElements`, or none for a step that only reads. Containers on screen ask again at once; the rest when they are shown.",
11
+ default: t[0],
12
+ options: [...t],
13
+ optionLabels: Object.fromEntries(t.map((t) => [t, e[t]])),
14
+ label: "Refresh cached requests",
15
+ canBind: !1,
16
+ when: n
17
+ },
18
+ invalidateElements: {
19
+ type: "elementIds",
20
+ elementType: "apiContainer",
21
+ description: "The api containers to refresh, by element id.",
22
+ default: [],
23
+ label: "Containers (ids)",
24
+ when: (e) => n(e) && e.invalidateQueries === "elements"
25
+ }
26
+ });
27
+ //#endregion
28
+ export { t as writeInvalidationParams };
@@ -1,11 +1,11 @@
1
1
  import e from "../../InteractionsContext.mjs";
2
2
  import { stateCallbacks as t } from "./callbacks.mjs";
3
3
  import { use as n, useCallback as r, useMemo as i } from "react";
4
- import { useCommonStoreSetter as a } from "@plitzi/sdk-shared/store";
5
- import { toInteractionCallbacks as o } from "@plitzi/sdk-shared/authoring/builder";
4
+ import { toInteractionCallbacks as a } from "@plitzi/sdk-shared/authoring/builder";
5
+ import { useCommonStoreSetter as o } from "@plitzi/sdk-shared/store";
6
6
  //#region src/sources/StateSource/StateInteractions.tsx
7
7
  var s = 0, c = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `e${++s}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`, l = ({ children: s }) => {
8
- let { useInteractions: l } = n(e), u = a(), d = r((e) => {
8
+ let { useInteractions: l } = n(e), u = o(), d = r((e) => {
9
9
  let { key: t, type: n } = e, { value: r } = e;
10
10
  n === "boolean" ? r = r === !0 || r === "true" : n === "number" && (r = parseInt(r, 10)), u(`runtime.state.${t}`, r);
11
11
  }, [u]), f = r((e) => {
@@ -52,7 +52,7 @@ var s = 0, c = () => typeof crypto < "u" && typeof crypto.randomUUID == "functio
52
52
  }, [u]);
53
53
  return l({
54
54
  id: "state",
55
- callbacks: i(() => o(t, {
55
+ callbacks: i(() => a(t, {
56
56
  setState: d,
57
57
  toggleState: f,
58
58
  appendState: m,
@@ -2,10 +2,12 @@ import { ActionInteractions } from './ActionsSource';
2
2
  import { AuthInteractions } from './AuthSource';
3
3
  import { HostInteractions } from './HostSource';
4
4
  import { NavigationInteractions } from './NavigationSource';
5
+ import { QueriesInteractions } from './QueriesSource';
5
6
  import { StateInteractions } from './StateSource';
6
7
  export * from './ActionsSource';
7
8
  export * from './AuthSource';
8
9
  export * from './HostSource';
9
10
  export * from './NavigationSource';
11
+ export * from './QueriesSource';
10
12
  export * from './StateSource';
11
- export { ActionInteractions, AuthInteractions, HostInteractions, NavigationInteractions, StateInteractions };
13
+ export { ActionInteractions, AuthInteractions, HostInteractions, NavigationInteractions, QueriesInteractions, StateInteractions };
@@ -3,5 +3,6 @@ import t from "./AuthSource/AuthInteractions.mjs";
3
3
  import n from "./HostSource/callbacks.mjs";
4
4
  import r from "./HostSource/HostInteractions.mjs";
5
5
  import i from "./NavigationSource/NavigationInteractions.mjs";
6
- import a from "./StateSource/StateInteractions.mjs";
7
- export { e as ActionInteractions, t as AuthInteractions, r as HostInteractions, i as NavigationInteractions, a as StateInteractions, n as hostCallbacks };
6
+ import a from "./QueriesSource/QueriesInteractions.mjs";
7
+ import o from "./StateSource/StateInteractions.mjs";
8
+ export { e as ActionInteractions, t as AuthInteractions, r as HostInteractions, i as NavigationInteractions, a as QueriesInteractions, o as StateInteractions, n as hostCallbacks };
@@ -12,6 +12,10 @@ declare const _default: {
12
12
  body: Record<string, string | Blob>;
13
13
  authorizationToken: string;
14
14
  credentials: RequestCredentials;
15
+ cache?: boolean | string;
16
+ staleTime?: number | string;
17
+ invalidateQueries?: string;
18
+ invalidateElements?: string[];
15
19
  }>;
16
20
  };
17
21
  export default _default;
@@ -1,9 +1,14 @@
1
1
  import { InteractionCallback } from '@plitzi/sdk-shared';
2
- declare const delayTime: InteractionCallback<{
2
+ type WebHookParams = {
3
3
  url: string;
4
4
  method: string;
5
5
  body: Record<string, string | Blob>;
6
6
  authorizationToken: string;
7
7
  credentials: RequestCredentials;
8
- }>;
9
- export default delayTime;
8
+ cache?: boolean | string;
9
+ staleTime?: number | string;
10
+ invalidateQueries?: string;
11
+ invalidateElements?: string[];
12
+ };
13
+ declare const webHook: InteractionCallback<WebHookParams>;
14
+ export default webHook;
@@ -1,121 +1,70 @@
1
+ import { webHookSpec as e } from "./webHookSpec.mjs";
2
+ import { toInteractionCallback as t } from "@plitzi/sdk-shared/authoring/builder";
3
+ import { invalidateAfterWrite as n, queryCache as r, requestKey as i } from "@plitzi/sdk-shared/queries";
1
4
  //#region src/utility/webHook.ts
2
- var e = {
3
- action: "webHook",
4
- title: "Webhook",
5
- type: "utility",
6
- params: {
7
- url: {
8
- canBind: !0,
9
- defaultValue: "",
10
- type: "text",
11
- label: "Url"
12
- },
13
- method: {
14
- label: "Method",
15
- type: "select",
16
- defaultValue: "get",
17
- options: [
18
- {
19
- label: "Get",
20
- value: "get"
21
- },
22
- {
23
- label: "Post",
24
- value: "post"
25
- },
26
- {
27
- label: "Put",
28
- value: "put"
29
- },
30
- {
31
- label: "Delete",
32
- value: "delete"
33
- },
34
- {
35
- label: "Patch",
36
- value: "patch"
37
- },
38
- {
39
- label: "Head",
40
- value: "head"
41
- }
42
- ]
43
- },
44
- body: {
45
- canBind: !0,
46
- defaultValue: "",
47
- type: "textarea",
48
- label: "Body"
49
- },
50
- authorizationToken: {
51
- canBind: !0,
52
- defaultValue: "",
53
- type: "text",
54
- label: "Authorization Token"
55
- },
56
- credentials: {
57
- canBind: !0,
58
- defaultValue: "same-origin",
59
- type: "select",
60
- options: [
61
- {
62
- label: "Include",
63
- value: "include"
64
- },
65
- {
66
- label: "Omit",
67
- value: "omit"
68
- },
69
- {
70
- label: "Same Origin",
71
- value: "same-origin"
72
- }
73
- ],
74
- label: "Credentials"
75
- }
76
- },
77
- preview: { response: {
78
- status: "",
79
- data: ""
80
- } },
81
- callback: async (e) => {
82
- let { url: t, authorizationToken: n, body: r, credentials: i } = e, { method: a } = e, o = {};
83
- try {
84
- a = a.toUpperCase();
85
- let e = { "Content-Type": "application/json" };
86
- n && (e.Authorization = `Bearer ${n}`), Object.values(r).forEach((t) => {
87
- if (t instanceof Blob && e["Content-Type"] !== "multipart/form-data") {
88
- e["Content-Type"] = "multipart/form-data";
89
- return;
90
- }
91
- });
92
- let s = {
93
- method: a,
94
- headers: e,
95
- credentials: i
96
- };
97
- if (a && !["get", "delete"].includes(a.toLowerCase())) {
98
- if (e["Content-Type"] === "application/json") s.body = JSON.stringify(r);
99
- else if (e["Content-Type"] === "multipart/form-data") {
100
- let e = new FormData();
101
- Object.entries(r).forEach(([t, n]) => {
102
- e?.append(t, n);
103
- }), s.body = e;
104
- }
5
+ var a = /* @__PURE__ */ new Set(["GET", "HEAD"]), o = /* @__PURE__ */ new Set([
6
+ "GET",
7
+ "HEAD",
8
+ "DELETE"
9
+ ]), s = (t) => {
10
+ let n = Number(t);
11
+ return (Number.isFinite(n) && n >= 0 ? n : Number(e.params.staleTime.default)) * 1e3;
12
+ }, c = (e) => e ? { Authorization: `Bearer ${e}` } : {}, l = async ({ url: e, authorizationToken: t, body: n, credentials: r }, i) => {
13
+ try {
14
+ let a = {
15
+ "Content-Type": "application/json",
16
+ ...c(t)
17
+ };
18
+ Object.values(n).some((e) => e instanceof Blob) && (a["Content-Type"] = "multipart/form-data");
19
+ let s = {
20
+ method: i,
21
+ headers: a,
22
+ credentials: r
23
+ };
24
+ if (!o.has(i)) {
25
+ if (a["Content-Type"] === "application/json") s.body = JSON.stringify(n);
26
+ else {
27
+ let e = new FormData();
28
+ Object.entries(n).forEach(([t, n]) => {
29
+ e.append(t, n);
30
+ }), s.body = e;
105
31
  }
106
- let c = await fetch(t, s), l = "";
107
- try {
108
- l = await c.json();
109
- } catch {}
110
- o = {
111
- status: c.status,
112
- data: l
113
- };
114
- } catch (e) {
115
- console.error(e);
116
32
  }
117
- return { response: o };
33
+ let l = await fetch(e, s), u = "";
34
+ try {
35
+ u = await l.json();
36
+ } catch {}
37
+ return {
38
+ status: l.status,
39
+ data: u
40
+ };
41
+ } catch (e) {
42
+ return console.error(e), {};
43
+ }
44
+ }, u = t("webHook", e, async (e) => {
45
+ let t = (e.method || "get").toUpperCase();
46
+ if (a.has(t)) {
47
+ if (e.cache !== !0 && e.cache !== "true") return { response: await l(e, t) };
48
+ let n = i({
49
+ method: t,
50
+ url: e.url,
51
+ credentials: e.credentials,
52
+ headers: c(e.authorizationToken)
53
+ });
54
+ return { response: await r.fetchQuery(n, {
55
+ meta: { url: e.url },
56
+ fetcher: () => l(e, t),
57
+ staleTime: s(e.staleTime),
58
+ isCacheable: (e) => e.status !== void 0 && e.status < 400
59
+ }) ?? {} };
118
60
  }
119
- };
61
+ let o = await l(e, t);
62
+ return o.status !== void 0 && o.status >= 200 && o.status < 300 && n({
63
+ mode: e.invalidateQueries,
64
+ fallback: "origin",
65
+ elements: e.invalidateElements,
66
+ url: e.url
67
+ }), { response: o };
68
+ });
120
69
  //#endregion
121
- export { e as default };
70
+ export { u as default };
@@ -0,0 +1,9 @@
1
+ import { BuiltinActionSpec } from '@plitzi/sdk-shared/authoring/builder';
2
+ /**
3
+ * The webhook step, as the editor and anything authoring one offline read it.
4
+ *
5
+ * A read may be served from the page's query cache — the same one api containers use, under the same key, so a
6
+ * flow reading a URL a container already loaded does not ask again. A write says what it refreshes once it
7
+ * succeeded, which by default is every cached request to the site it wrote to.
8
+ */
9
+ export declare const webHookSpec: BuiltinActionSpec;
@@ -0,0 +1,79 @@
1
+ import { writeInvalidationParams as e } from "../sources/QueriesSource/writeParams.mjs";
2
+ //#region src/utility/webHookSpec.ts
3
+ var t = (e) => {
4
+ let t = typeof e.method == "string" ? e.method.toLowerCase() : "get";
5
+ return t === "get" || t === "head";
6
+ }, n = {
7
+ title: "Webhook",
8
+ type: "utility",
9
+ strictParams: !0,
10
+ params: {
11
+ url: {
12
+ type: "text",
13
+ description: "The URL to call.",
14
+ default: "",
15
+ label: "Url"
16
+ },
17
+ method: {
18
+ type: "select",
19
+ description: "HTTP method.",
20
+ default: "get",
21
+ options: [
22
+ "get",
23
+ "post",
24
+ "put",
25
+ "delete",
26
+ "patch",
27
+ "head"
28
+ ],
29
+ canBind: !1
30
+ },
31
+ body: {
32
+ type: "textarea",
33
+ description: "Request body.",
34
+ default: ""
35
+ },
36
+ authorizationToken: {
37
+ type: "text",
38
+ description: "Value sent as the Authorization header.",
39
+ default: ""
40
+ },
41
+ credentials: {
42
+ type: "select",
43
+ description: "fetch credentials mode.",
44
+ default: "same-origin",
45
+ options: [
46
+ "include",
47
+ "omit",
48
+ "same-origin"
49
+ ],
50
+ optionLabels: { "same-origin": "Same Origin" }
51
+ },
52
+ cache: {
53
+ type: "boolean",
54
+ description: "Serve a GET from the page’s query cache while it is fresh, and keep the answer there — shared with any api container asking the same thing.",
55
+ default: !1,
56
+ label: "Cache response",
57
+ when: t
58
+ },
59
+ staleTime: {
60
+ type: "number",
61
+ description: "With `cache`: seconds the answer is served without asking again.",
62
+ default: 30,
63
+ label: "Fresh for (s)",
64
+ when: (e) => t(e) && (e.cache === !0 || e.cache === "true")
65
+ },
66
+ ...e([
67
+ "origin",
68
+ "all",
69
+ "elements",
70
+ "none"
71
+ ], (e) => !t(e))
72
+ },
73
+ preview: { response: {
74
+ status: "",
75
+ data: ""
76
+ } }
77
+ };
78
+ //#endregion
79
+ export { n as webHookSpec };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-interactions",
3
- "version": "0.35.10",
3
+ "version": "0.36.1",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist"
@@ -106,6 +106,26 @@
106
106
  "types": "./dist/sources/NavigationSource/index.d.ts",
107
107
  "import": "./dist/sources/NavigationSource/index.mjs"
108
108
  },
109
+ "./sources/QueriesSource": {
110
+ "types": "./dist/sources/QueriesSource/index.d.ts",
111
+ "import": "./dist/sources/QueriesSource/index.mjs"
112
+ },
113
+ "./sources/QueriesSource/QueriesInteractions": {
114
+ "types": "./dist/sources/QueriesSource/QueriesInteractions.d.ts",
115
+ "import": "./dist/sources/QueriesSource/QueriesInteractions.mjs"
116
+ },
117
+ "./sources/QueriesSource/callbacks": {
118
+ "types": "./dist/sources/QueriesSource/callbacks.d.ts",
119
+ "import": "./dist/sources/QueriesSource/callbacks.mjs"
120
+ },
121
+ "./sources/QueriesSource/index": {
122
+ "types": "./dist/sources/QueriesSource/index.d.ts",
123
+ "import": "./dist/sources/QueriesSource/index.mjs"
124
+ },
125
+ "./sources/QueriesSource/writeParams": {
126
+ "types": "./dist/sources/QueriesSource/writeParams.d.ts",
127
+ "import": "./dist/sources/QueriesSource/writeParams.mjs"
128
+ },
109
129
  "./sources/StateSource": {
110
130
  "types": "./dist/sources/StateSource/index.d.ts",
111
131
  "import": "./dist/sources/StateSource/index.mjs"
@@ -145,6 +165,10 @@
145
165
  "./utility/webHook": {
146
166
  "types": "./dist/utility/webHook.d.ts",
147
167
  "import": "./dist/utility/webHook.mjs"
168
+ },
169
+ "./utility/webHookSpec": {
170
+ "types": "./dist/utility/webHookSpec.d.ts",
171
+ "import": "./dist/utility/webHookSpec.mjs"
148
172
  }
149
173
  },
150
174
  "scripts": {
@@ -166,11 +190,11 @@
166
190
  },
167
191
  "dependencies": {
168
192
  "@plitzi/plitzi-ui": "^1.6.21",
169
- "@plitzi/sdk-auth": "0.35.10",
170
- "@plitzi/sdk-dev-tools": "0.35.10",
171
- "@plitzi/sdk-event-bridge": "0.35.10",
172
- "@plitzi/sdk-navigation": "0.35.10",
173
- "@plitzi/sdk-schema": "0.35.10",
174
- "@plitzi/sdk-shared": "0.35.10"
193
+ "@plitzi/sdk-auth": "0.36.1",
194
+ "@plitzi/sdk-dev-tools": "0.36.1",
195
+ "@plitzi/sdk-event-bridge": "0.36.1",
196
+ "@plitzi/sdk-navigation": "0.36.1",
197
+ "@plitzi/sdk-schema": "0.36.1",
198
+ "@plitzi/sdk-shared": "0.36.1"
175
199
  }
176
200
  }