@plitzi/sdk-interactions 0.39.3 → 0.39.4
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 +11 -0
- package/dist/InteractionsManager.mjs +2 -2
- package/dist/utility/webHook.mjs +37 -36
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @plitzi/sdk-interactions
|
|
2
2
|
|
|
3
|
+
## 0.39.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 35415a1: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [35415a1]
|
|
10
|
+
- @plitzi/sdk-auth@0.39.4
|
|
11
|
+
- @plitzi/sdk-event-bridge@0.39.4
|
|
12
|
+
- @plitzi/sdk-shared@0.39.4
|
|
13
|
+
|
|
3
14
|
## 0.39.3
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -83,10 +83,10 @@ var c = (e, t) => {
|
|
|
83
83
|
preview: c
|
|
84
84
|
}
|
|
85
85
|
} : t;
|
|
86
|
-
}, {}) :
|
|
86
|
+
}, {}) : Reflect.deleteProperty(this.callbacksAvailables, e), Object.keys(n).length > 0 ? this.eventBridge.on("interaction", e, this.eventBridgeCallback(t), { override: !0 }) : this.eventBridge.off("interaction", e);
|
|
87
87
|
}
|
|
88
88
|
unsubscribe(e) {
|
|
89
|
-
return this.subscriptors[e] ? (this.eventBridge.off("interaction", e),
|
|
89
|
+
return this.subscriptors[e] ? (this.eventBridge.off("interaction", e), Reflect.deleteProperty(this.subscriptors, e), this.dropParked(e), this.callbacksAvailables[e] && Reflect.deleteProperty(this.callbacksAvailables, e), this.touch(), !0) : !1;
|
|
90
90
|
}
|
|
91
91
|
getRootManager() {
|
|
92
92
|
return this.parentManager ? this.parentManager.getRootManager() : this;
|
package/dist/utility/webHook.mjs
CHANGED
|
@@ -1,70 +1,71 @@
|
|
|
1
1
|
import { webHookSpec as e } from "./webHookSpec.mjs";
|
|
2
2
|
import { toInteractionCallback as t } from "@plitzi/sdk-shared/authoring";
|
|
3
|
-
import {
|
|
3
|
+
import { csrfFetch as n } from "@plitzi/sdk-shared/csrf";
|
|
4
|
+
import { invalidateAfterWrite as r, queryCache as i, requestKey as a } from "@plitzi/sdk-shared/queries";
|
|
4
5
|
// src/utility/webHook.ts
|
|
5
|
-
var
|
|
6
|
+
var o = /* @__PURE__ */ new Set(["GET", "HEAD"]), s = /* @__PURE__ */ new Set([
|
|
6
7
|
"GET",
|
|
7
8
|
"HEAD",
|
|
8
9
|
"DELETE"
|
|
9
|
-
]),
|
|
10
|
+
]), c = (t) => {
|
|
10
11
|
let n = Number(t);
|
|
11
12
|
return (Number.isFinite(n) && n >= 0 ? n : Number(e.params.staleTime.default)) * 1e3;
|
|
12
|
-
},
|
|
13
|
-
let
|
|
14
|
-
method:
|
|
13
|
+
}, l = (e) => e ? { Authorization: `Bearer ${e}` } : {}, u = (e) => typeof e == "object" && e ? e : {}, d = /* @__PURE__ */ new Set(["authorization", "content-type"]), f = (e) => typeof e == "object" && e ? Object.fromEntries(Object.entries(e).flatMap(([e, t]) => (typeof t == "string" || typeof t == "number") && t !== "" && !d.has(e.toLowerCase()) ? [[e, String(t)]] : [])) : {}, p = async ({ url: e, authorizationToken: t, headers: r, body: i, credentials: a }, o, c) => {
|
|
14
|
+
let d = u(i), p = Object.values(d).some((e) => e instanceof Blob), m = {
|
|
15
|
+
method: o,
|
|
15
16
|
headers: {
|
|
16
|
-
...
|
|
17
|
-
...
|
|
18
|
-
...
|
|
17
|
+
...f(r),
|
|
18
|
+
...p ? {} : { "Content-Type": "application/json" },
|
|
19
|
+
...l(t)
|
|
19
20
|
},
|
|
20
|
-
credentials:
|
|
21
|
-
...
|
|
21
|
+
credentials: a,
|
|
22
|
+
...c ? { signal: c } : {}
|
|
22
23
|
};
|
|
23
|
-
if (!
|
|
24
|
-
if (!
|
|
24
|
+
if (!s.has(o)) {
|
|
25
|
+
if (!p) m.body = JSON.stringify(d);
|
|
25
26
|
else {
|
|
26
27
|
let e = new FormData();
|
|
27
|
-
Object.entries(
|
|
28
|
+
Object.entries(d).forEach(([t, n]) => {
|
|
28
29
|
e.append(t, n);
|
|
29
|
-
}),
|
|
30
|
+
}), m.body = e;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
let
|
|
33
|
-
throw Error(`${
|
|
34
|
-
}),
|
|
33
|
+
let h = await n(e, m).catch((t) => {
|
|
34
|
+
throw Error(`${o} ${e} got no answer: ${t instanceof Error ? t.message : String(t)}`);
|
|
35
|
+
}), g = "";
|
|
35
36
|
try {
|
|
36
|
-
|
|
37
|
+
g = await h.json();
|
|
37
38
|
} catch {}
|
|
38
39
|
return {
|
|
39
|
-
status:
|
|
40
|
-
data:
|
|
40
|
+
status: h.status,
|
|
41
|
+
data: g
|
|
41
42
|
};
|
|
42
|
-
},
|
|
43
|
-
let
|
|
44
|
-
if (
|
|
45
|
-
if (e.cache !== !0 && e.cache !== "true") return { response: await
|
|
46
|
-
let
|
|
47
|
-
method:
|
|
43
|
+
}, m = t("webHook", e, async (e, t) => {
|
|
44
|
+
let n = (e.method || "get").toUpperCase();
|
|
45
|
+
if (o.has(n)) {
|
|
46
|
+
if (e.cache !== !0 && e.cache !== "true") return { response: await p(e, n, t?.signal) };
|
|
47
|
+
let r = a({
|
|
48
|
+
method: n,
|
|
48
49
|
url: e.url,
|
|
49
50
|
credentials: e.credentials,
|
|
50
51
|
headers: {
|
|
51
|
-
...
|
|
52
|
-
...
|
|
52
|
+
...f(e.headers),
|
|
53
|
+
...l(e.authorizationToken)
|
|
53
54
|
}
|
|
54
55
|
});
|
|
55
|
-
return { response: await
|
|
56
|
+
return { response: await i.fetchQuery(r, {
|
|
56
57
|
meta: { url: e.url },
|
|
57
|
-
fetcher: () =>
|
|
58
|
-
staleTime:
|
|
58
|
+
fetcher: () => p(e, n),
|
|
59
|
+
staleTime: c(e.staleTime),
|
|
59
60
|
isCacheable: (e) => e.status < 400
|
|
60
61
|
}) };
|
|
61
62
|
}
|
|
62
|
-
let
|
|
63
|
-
return
|
|
63
|
+
let s = await p(e, n, t?.signal);
|
|
64
|
+
return s.status >= 200 && s.status < 300 && r({
|
|
64
65
|
mode: e.invalidateQueries,
|
|
65
66
|
fallback: "origin",
|
|
66
67
|
elements: e.invalidateElements,
|
|
67
68
|
url: e.url
|
|
68
|
-
}), { response:
|
|
69
|
+
}), { response: s };
|
|
69
70
|
});
|
|
70
|
-
export {
|
|
71
|
+
export { m as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-interactions",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.4",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@plitzi/nexus": "^1.4.0",
|
|
42
|
-
"@plitzi/plitzi-ui": "^1.6.
|
|
43
|
-
"@plitzi/sdk-auth": "0.39.
|
|
44
|
-
"@plitzi/sdk-event-bridge": "0.39.
|
|
45
|
-
"@plitzi/sdk-shared": "0.39.
|
|
42
|
+
"@plitzi/plitzi-ui": "^1.6.39",
|
|
43
|
+
"@plitzi/sdk-auth": "0.39.4",
|
|
44
|
+
"@plitzi/sdk-event-bridge": "0.39.4",
|
|
45
|
+
"@plitzi/sdk-shared": "0.39.4"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "^19"
|