@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 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
- }, {}) : delete this.callbacksAvailables[e], Object.keys(n).length > 0 ? this.eventBridge.on("interaction", e, this.eventBridgeCallback(t), { override: !0 }) : this.eventBridge.off("interaction", e);
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), delete this.subscriptors[e], this.dropParked(e), this.callbacksAvailables[e] && delete this.callbacksAvailables[e], this.touch(), !0) : !1;
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;
@@ -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 { invalidateAfterWrite as n, queryCache as r, requestKey as i } from "@plitzi/sdk-shared/queries";
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 a = /* @__PURE__ */ new Set(["GET", "HEAD"]), o = /* @__PURE__ */ new Set([
6
+ var o = /* @__PURE__ */ new Set(["GET", "HEAD"]), s = /* @__PURE__ */ new Set([
6
7
  "GET",
7
8
  "HEAD",
8
9
  "DELETE"
9
- ]), s = (t) => {
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
- }, c = (e) => e ? { Authorization: `Bearer ${e}` } : {}, l = (e) => typeof e == "object" && e ? e : {}, u = /* @__PURE__ */ new Set(["authorization", "content-type"]), d = (e) => typeof e == "object" && e ? Object.fromEntries(Object.entries(e).flatMap(([e, t]) => (typeof t == "string" || typeof t == "number") && t !== "" && !u.has(e.toLowerCase()) ? [[e, String(t)]] : [])) : {}, f = async ({ url: e, authorizationToken: t, headers: n, body: r, credentials: i }, a, s) => {
13
- let u = l(r), f = Object.values(u).some((e) => e instanceof Blob), p = {
14
- method: a,
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
- ...d(n),
17
- ...f ? {} : { "Content-Type": "application/json" },
18
- ...c(t)
17
+ ...f(r),
18
+ ...p ? {} : { "Content-Type": "application/json" },
19
+ ...l(t)
19
20
  },
20
- credentials: i,
21
- ...s ? { signal: s } : {}
21
+ credentials: a,
22
+ ...c ? { signal: c } : {}
22
23
  };
23
- if (!o.has(a)) {
24
- if (!f) p.body = JSON.stringify(u);
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(u).forEach(([t, n]) => {
28
+ Object.entries(d).forEach(([t, n]) => {
28
29
  e.append(t, n);
29
- }), p.body = e;
30
+ }), m.body = e;
30
31
  }
31
32
  }
32
- let m = await fetch(e, p).catch((t) => {
33
- throw Error(`${a} ${e} got no answer: ${t instanceof Error ? t.message : String(t)}`);
34
- }), h = "";
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
- h = await m.json();
37
+ g = await h.json();
37
38
  } catch {}
38
39
  return {
39
- status: m.status,
40
- data: h
40
+ status: h.status,
41
+ data: g
41
42
  };
42
- }, p = t("webHook", e, async (e, t) => {
43
- let o = (e.method || "get").toUpperCase();
44
- if (a.has(o)) {
45
- if (e.cache !== !0 && e.cache !== "true") return { response: await f(e, o, t?.signal) };
46
- let n = i({
47
- method: o,
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
- ...d(e.headers),
52
- ...c(e.authorizationToken)
52
+ ...f(e.headers),
53
+ ...l(e.authorizationToken)
53
54
  }
54
55
  });
55
- return { response: await r.fetchQuery(n, {
56
+ return { response: await i.fetchQuery(r, {
56
57
  meta: { url: e.url },
57
- fetcher: () => f(e, o),
58
- staleTime: s(e.staleTime),
58
+ fetcher: () => p(e, n),
59
+ staleTime: c(e.staleTime),
59
60
  isCacheable: (e) => e.status < 400
60
61
  }) };
61
62
  }
62
- let l = await f(e, o, t?.signal);
63
- return l.status >= 200 && l.status < 300 && n({
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: l };
69
+ }), { response: s };
69
70
  });
70
- export { p as default };
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",
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.38",
43
- "@plitzi/sdk-auth": "0.39.3",
44
- "@plitzi/sdk-event-bridge": "0.39.3",
45
- "@plitzi/sdk-shared": "0.39.3"
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"