@plitzi/sdk-interactions 0.32.25 → 0.33.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,32 @@
1
1
  # @plitzi/sdk-interactions
2
2
 
3
+ ## 0.33.1
4
+
5
+ ### Patch Changes
6
+
7
+ - v0.33.1
8
+ - Updated dependencies
9
+ - @plitzi/sdk-auth@0.33.1
10
+ - @plitzi/sdk-dev-tools@0.33.1
11
+ - @plitzi/sdk-event-bridge@0.33.1
12
+ - @plitzi/sdk-navigation@0.33.1
13
+ - @plitzi/sdk-shared@0.33.1
14
+
15
+ ## 0.33.0
16
+
17
+ ### Minor Changes
18
+
19
+ - v0.33.0
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+ - @plitzi/sdk-auth@0.33.0
25
+ - @plitzi/sdk-dev-tools@0.33.0
26
+ - @plitzi/sdk-event-bridge@0.33.0
27
+ - @plitzi/sdk-navigation@0.33.0
28
+ - @plitzi/sdk-shared@0.33.0
29
+
3
30
  ## 0.32.25
4
31
 
5
32
  ### Patch Changes
@@ -1,7 +1,9 @@
1
1
  import { ElementInteraction } from '@plitzi/sdk-shared';
2
- declare const flowTrigger: (triggerNode: ElementInteraction, nodes?: {}, callbacksAvailables?: {}, flowParams?: Record<string, unknown>, globalParams?: {}, postCallbacksTotal?: never[]) => Promise<void>;
2
+ declare const flowTrigger: (triggerNode: ElementInteraction, nodes?: {}, callbacksAvailables?: {}, flowParams?: Record<string, unknown>, globalParams?: {},
3
+ /** The idRef of the element this fired on, carried through purely so the log can name it. */
4
+ elementRef?: string, postCallbacksTotal?: never[]) => Promise<void>;
3
5
  export { flowTrigger };
4
6
  declare const InteractionsHelper: {
5
- flowTrigger: (triggerNode: ElementInteraction, nodes?: {}, callbacksAvailables?: {}, flowParams?: Record<string, unknown>, globalParams?: {}, postCallbacksTotal?: never[]) => Promise<void>;
7
+ flowTrigger: (triggerNode: ElementInteraction, nodes?: {}, callbacksAvailables?: {}, flowParams?: Record<string, unknown>, globalParams?: {}, elementRef?: string, postCallbacksTotal?: never[]) => Promise<void>;
6
8
  };
7
9
  export default InteractionsHelper;
@@ -3,21 +3,21 @@ 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
5
  import { hasValidToken as a, processTwig as o } from "@plitzi/sdk-shared/helpers/twigWrapper";
6
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
7
7
  //#region src/InteractionsHelper.tsx
8
- var l = 5, u = (e, t, n, r, u) => e === "utility" && u === "twigTemplate" ? t : Object.keys(t).reduce((u, d) => {
8
+ var u = 5, d = (e, t, n, r, s) => e === "utility" && s === "twigTemplate" ? t : Object.keys(t).reduce((s, d) => {
9
9
  let f = t[d];
10
10
  if (e !== "trigger") {
11
- let e = l;
11
+ let e = u;
12
12
  for (; typeof f == "string" && a(f) && e > 0;) f = o(f, {
13
13
  ...n,
14
14
  ...r
15
15
  }, !1, !0), e--;
16
- typeof f == "string" && a(f) && i.warning("interactions", /* @__PURE__ */ c("span", { children: [
16
+ typeof f == "string" && a(f) && i.warning("interactions", /* @__PURE__ */ l("span", { children: [
17
17
  "Twig token resolution exceeded ",
18
- l,
18
+ u,
19
19
  " passes for ",
20
- /* @__PURE__ */ s("b", { children: d }),
20
+ /* @__PURE__ */ c("b", { children: d }),
21
21
  ", leaving unresolved tokens"
22
22
  ] }), {
23
23
  param: d,
@@ -25,142 +25,163 @@ var l = 5, u = (e, t, n, r, u) => e === "utility" && u === "twigTemplate" ? t :
25
25
  });
26
26
  }
27
27
  return {
28
- ...u,
28
+ ...s,
29
29
  [d]: f
30
30
  };
31
- }, {}), d = async (n, a = {}, o = {}, l = {}) => {
32
- let d = {}, f = [], { id: p, action: m, enabled: h, params: g, elementId: _, type: v, when: y } = n;
31
+ }, {}), f = async (n, a = {}, o = {}, s = {}) => {
32
+ let u = {}, f = [], { id: p, action: m, enabled: h, params: g, elementId: _, type: v, when: y } = n;
33
33
  if (!m || !h) return {
34
34
  status: "disabled",
35
- result: d,
35
+ result: u,
36
36
  postCallbacks: f
37
37
  };
38
38
  let b = {
39
- ...l,
39
+ ...s,
40
40
  ...o,
41
41
  [p]: g
42
42
  };
43
43
  if (y && !r(y, b)) return {
44
44
  status: "skipped",
45
- result: d,
45
+ result: u,
46
46
  postCallbacks: f,
47
47
  whenParams: b
48
48
  };
49
49
  let x = {
50
50
  ...o,
51
- ...l,
52
- ...u(v, g, o, l, m)
51
+ ...s,
52
+ ...d(v, g, o, s, m)
53
53
  };
54
54
  try {
55
55
  switch (v) {
56
56
  case "callback":
57
57
  case "globalCallback": {
58
- if (!_) return {
58
+ if (!_) return i.warning("interactions", /* @__PURE__ */ l("span", { children: [
59
+ "Step ",
60
+ /* @__PURE__ */ c("b", { children: m }),
61
+ " names no element, so there is nothing to run it on"
62
+ ] }), { node: n }), {
59
63
  status: "failed",
60
- result: d,
64
+ result: u,
61
65
  postCallbacks: f,
62
66
  whenParams: b
63
67
  };
64
68
  let e = t(a, `${_}.${m}`);
65
- if (!e) return {
69
+ if (!e) return i.warning("interactions", /* @__PURE__ */ l("span", { children: [
70
+ "Nothing is registered as ",
71
+ /* @__PURE__ */ c("b", { children: `${_}.${m}` }),
72
+ ", so this step did nothing"
73
+ ] }), {
74
+ node: n,
75
+ available: Object.keys(t(a, _, {}))
76
+ }), {
66
77
  status: "failed",
67
- result: d,
78
+ result: u,
68
79
  postCallbacks: f,
69
80
  whenParams: b
70
81
  };
71
- let { callback: n, postCallback: r } = e;
72
- n && (d = await n(x)), r && f.push({
82
+ let { callback: r, postCallback: o } = e;
83
+ r && (u = await r(x)), o && f.push({
73
84
  id: p,
74
- callback: r,
85
+ callback: o,
75
86
  params: {
76
87
  ...x,
77
- [p]: d
88
+ [p]: u
78
89
  }
79
90
  });
80
91
  break;
81
92
  }
82
93
  case "utility": {
83
94
  let { callback: n, postCallback: r } = t(e, m, {});
84
- n && (d = await n(x)), r && f.push({
95
+ n && (u = await n(x)), r && f.push({
85
96
  id: p,
86
97
  callback: r,
87
98
  params: {
88
99
  ...x,
89
- [p]: d
100
+ [p]: u
90
101
  }
91
102
  });
92
103
  break;
93
104
  }
94
105
  }
95
106
  } catch (e) {
96
- return i.danger("interactions", /* @__PURE__ */ c("span", { children: ["Interaction node failed ", /* @__PURE__ */ s("b", { children: m })] }), {
107
+ return i.danger("interactions", /* @__PURE__ */ l("span", { children: ["Interaction node failed ", /* @__PURE__ */ c("b", { children: m })] }), {
97
108
  error: e instanceof Error ? e.message : String(e),
98
109
  node: n
99
110
  }), {
100
111
  status: "failed",
101
- result: d,
112
+ result: u,
102
113
  postCallbacks: f,
103
114
  whenParams: b
104
115
  };
105
116
  }
106
117
  return {
107
118
  status: "success",
108
- result: d,
119
+ result: u,
109
120
  postCallbacks: f,
110
121
  whenParams: b
111
122
  };
112
- }, f = async (e = []) => {
123
+ }, p = async (e = []) => {
113
124
  let t = {};
114
125
  return await Promise.all(e.reverse().map(async ({ id: e, callback: r, params: i }) => {
115
126
  t[e] = await r?.(n(i, [e]), i[e]);
116
127
  })), t;
117
- }, p = async (e, n = {}, r = {}, a = {}, o = {}, s = [], c = {}) => {
128
+ }, m = async (e, n = {}, r = {}, a = {}, o = {}, s = [], c = {}) => {
118
129
  if (!e) return c;
119
130
  let l = t(n, e.afterNode);
120
- if (!l && s.length > 0 && await f(s), !l) return c;
121
- let u = i.getTime().valueOf(), { status: m, result: h, postCallbacks: g, whenParams: _ } = await d(l, r, a, o);
131
+ if (!l && s.length > 0 && await p(s), !l) return c;
132
+ let u = i.getTime().valueOf(), { status: d, result: h, postCallbacks: g, whenParams: _ } = await f(l, r, a, o);
122
133
  return c[l.id] = {
123
134
  node: l,
124
- status: m,
135
+ status: d,
125
136
  result: h,
126
137
  postCallbacks: g,
127
138
  whenParams: _,
128
139
  startTime: u,
129
140
  endTime: i.getTime().valueOf()
130
- }, s.push(...g), p(l, n, r, {
141
+ }, s.push(...g), m(l, n, r, {
131
142
  ...a,
132
143
  [l.id]: h
133
144
  }, o, s, c);
134
- }, m = (e, t, n = {}, r) => {
135
- let a = i.getTime().valueOf(), o = "skipped";
136
- r === "completed" && (o = "success"), i.info("interactions", /* @__PURE__ */ c("span", { children: ["Interaction triggered ", /* @__PURE__ */ s("b", { children: `${e.title} [${e.action}]` })] }), {
145
+ }, h = (e, t, n = {}, r, a) => {
146
+ let o = i.getTime().valueOf(), u = r === "skipped" ? "skipped" : "success", d = /* @__PURE__ */ l("span", { children: [
147
+ "Interaction triggered ",
148
+ /* @__PURE__ */ c("b", { children: `${e.title} [${e.action}]` }),
149
+ a ? /* @__PURE__ */ l(s, { children: [" on ", /* @__PURE__ */ c("b", { children: a })] }) : null
150
+ ] }), f = {
137
151
  status: r,
138
152
  node: e,
139
153
  elementId: e.elementId,
154
+ elementRef: a,
140
155
  nodes: {
141
156
  ...n,
142
157
  [e.id]: {
143
158
  node: e,
144
- status: o,
159
+ status: u,
145
160
  result: void 0,
146
161
  postCallbacks: [],
147
162
  startTime: t,
148
- endTime: a
163
+ endTime: o
149
164
  }
150
165
  },
151
166
  startTime: t,
152
- endTime: a
153
- });
154
- }, h = async (e, t = {}, n = {}, a = {}, o = {}, s = []) => {
155
- let c = i.getTime().valueOf(), { action: l, enabled: u, when: d } = e;
156
- if (!l || !u || d && !r(d, {
167
+ endTime: o
168
+ };
169
+ if (r === "failed") {
170
+ i.danger("interactions", d, f);
171
+ return;
172
+ }
173
+ i.info("interactions", d, f);
174
+ }, g = (e) => Object.values(e).some(({ status: e }) => e === "failed") ? "failed" : "completed", _ = async (e, t = {}, n = {}, a = {}, o = {}, s, c = []) => {
175
+ let l = i.getTime().valueOf(), { action: u, enabled: d, when: f } = e;
176
+ if (!u || !d || f && !r(f, {
157
177
  ...o,
158
178
  ...a
159
179
  })) {
160
- m(e, c, {}, "skipped");
180
+ h(e, l, {}, "skipped", s);
161
181
  return;
162
182
  }
163
- m(e, c, await p(e, t, n, a, o, s), "completed");
164
- }, g = { flowTrigger: h };
183
+ let p = await m(e, t, n, a, o, c);
184
+ h(e, l, p, g(p), s);
185
+ }, v = { flowTrigger: _ };
165
186
  //#endregion
166
- export { g as default, h as flowTrigger };
187
+ export { v as default, _ as flowTrigger };
@@ -29,7 +29,7 @@ var i = class i {
29
29
  await Promise.all(c.map((t) => e(t, r, this.getCallbacksAvailables(), { [t.id]: o }, {
30
30
  ...this.interactionsData,
31
31
  ...s
32
- })));
32
+ }, i)));
33
33
  } finally {
34
34
  n(this.interactionsRunning, `${i}.${a}`, !1);
35
35
  }
@@ -1,7 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  export type InteractionsSourcesProviderProps = {
3
3
  children?: ReactNode;
4
- previewMode?: boolean;
5
4
  };
6
- declare const InteractionsSourcesProvider: ({ children, previewMode }: InteractionsSourcesProviderProps) => import("react").JSX.Element;
5
+ declare const InteractionsSourcesProvider: ({ children }: InteractionsSourcesProviderProps) => import("react").JSX.Element;
7
6
  export default InteractionsSourcesProvider;
@@ -1,27 +1,29 @@
1
1
  import e from "./InteractionsContextProvider.mjs";
2
2
  import t from "./sources/AuthSource/AuthInteractions.mjs";
3
- import n from "./sources/CollectionSource/CollectionInteractions.mjs";
4
- import r from "./sources/NavigationSource/NavigationInteractions.mjs";
5
- import i from "./sources/StateSource/StateInteractions.mjs";
6
- import { use as a } from "react";
7
- import { jsx as o } from "react/jsx-runtime";
8
- import s from "@plitzi/sdk-navigation/NavigationContext";
9
- import { useCommonStore as c } from "@plitzi/sdk-shared/store";
3
+ import n from "./sources/NavigationSource/NavigationInteractions.mjs";
4
+ import r from "./sources/StateSource/StateInteractions.mjs";
5
+ import { jsx as i } from "react/jsx-runtime";
6
+ import { useRenderSettings as a, useSdkStore as o } from "@plitzi/sdk-shared/store";
10
7
  //#region src/InteractionsSourcesProvider.tsx
11
- var l = ({ children: l, previewMode: u = !1 }) => {
12
- let { currentPageId: d, routeParams: f, queryParams: p } = a(s), [m = "basic"] = c("schema.settings.userProvider");
13
- return /* @__PURE__ */ o(e, {
8
+ var s = ({ children: s }) => {
9
+ let [[c = "basic", l, u, d]] = o([
10
+ "schema.settings.userProvider",
11
+ "navigation.routeParams",
12
+ "navigation.queryParams",
13
+ "navigation.currentPageId"
14
+ ]), { previewMode: f } = a();
15
+ return /* @__PURE__ */ i(e, {
14
16
  currentPageId: d,
15
- routeParams: f,
16
- queryParams: p,
17
- children: /* @__PURE__ */ o(t, {
18
- authProvider: m,
19
- children: /* @__PURE__ */ o(n, { children: /* @__PURE__ */ o(i, { children: /* @__PURE__ */ o(r, {
20
- previewMode: u,
21
- children: l
22
- }) }) })
17
+ routeParams: l,
18
+ queryParams: u,
19
+ children: /* @__PURE__ */ i(t, {
20
+ authProvider: c,
21
+ children: /* @__PURE__ */ i(r, { children: /* @__PURE__ */ i(n, {
22
+ previewMode: f,
23
+ children: s
24
+ }) })
23
25
  })
24
26
  });
25
27
  };
26
28
  //#endregion
27
- export { l as default };
29
+ export { s as default };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { default as InteractionsContextProvider } from './InteractionsContextPro
4
4
  import { default as InteractionsHelper } from './InteractionsHelper';
5
5
  import { default as InteractionsManager } from './InteractionsManager';
6
6
  import { default as InteractionsSourcesProvider } from './InteractionsSourcesProvider';
7
- import { AuthInteractions, CollectionInteractions, NavigationInteractions, StateInteractions } from './sources';
7
+ import { AuthInteractions, NavigationInteractions, StateInteractions } from './sources';
8
8
  import { default as utility } from './utility';
9
9
  export * from './utility';
10
10
  export * from './InteractionsContext';
@@ -14,4 +14,4 @@ export * from './InteractionsSourcesProvider';
14
14
  export * from './hooks/useInteractions';
15
15
  export * from './sources';
16
16
  export * from './InteractionsManager';
17
- export { InteractionsManager, utility, InteractionsContext, InteractionsContextProvider, InteractionsHelper, InteractionsSourcesProvider, useInteractions, AuthInteractions, CollectionInteractions, NavigationInteractions, StateInteractions };
17
+ export { InteractionsManager, utility, InteractionsContext, InteractionsContextProvider, InteractionsHelper, InteractionsSourcesProvider, useInteractions, AuthInteractions, NavigationInteractions, StateInteractions };
package/dist/index.mjs CHANGED
@@ -5,8 +5,7 @@ import r, { flowTrigger as i } from "./InteractionsHelper.mjs";
5
5
  import a from "./InteractionsManager.mjs";
6
6
  import o from "./InteractionsContextProvider.mjs";
7
7
  import s from "./sources/AuthSource/AuthInteractions.mjs";
8
- import c from "./sources/CollectionSource/CollectionInteractions.mjs";
9
- import l from "./sources/NavigationSource/NavigationInteractions.mjs";
10
- import u from "./sources/StateSource/StateInteractions.mjs";
11
- import d from "./InteractionsSourcesProvider.mjs";
12
- export { s as AuthInteractions, c as CollectionInteractions, e as InteractionsContext, o as InteractionsContextProvider, r as InteractionsHelper, a as InteractionsManager, d as InteractionsSourcesProvider, l as NavigationInteractions, u as StateInteractions, i as flowTrigger, t as useInteractions, n as utility };
8
+ import c from "./sources/NavigationSource/NavigationInteractions.mjs";
9
+ import l from "./sources/StateSource/StateInteractions.mjs";
10
+ import u from "./InteractionsSourcesProvider.mjs";
11
+ export { s as AuthInteractions, e as InteractionsContext, o as InteractionsContextProvider, r as InteractionsHelper, a as InteractionsManager, u as InteractionsSourcesProvider, c as NavigationInteractions, l as StateInteractions, i as flowTrigger, t as useInteractions, n as utility };
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  export type AuthInteractionsProps = {
3
3
  children?: ReactNode;
4
- authProvider?: '' | 'auth0' | 'basic' | 'custom';
4
+ authProvider?: string;
5
5
  };
6
6
  declare const AuthInteractions: ({ children, authProvider }: AuthInteractionsProps) => ReactNode;
7
7
  export default AuthInteractions;
@@ -6,107 +6,89 @@ var a = ({ children: a, authProvider: o = "basic" }) => {
6
6
  let { login: s, refresh: c, logout: l } = t(i), { useInteractions: u } = t(e), d = n((e) => s(e), [s]), f = n((e) => c(e), [c]), p = n(() => l(), [l]);
7
7
  return u({
8
8
  id: "auth",
9
- callbacks: r(() => {
10
- let e = {};
11
- return o === "auth0" ? e = {
12
- login: {
13
- action: "authLogin",
14
- title: "Auth Login",
15
- type: "globalCallback",
16
- callback: d,
17
- params: {}
18
- },
19
- logout: {
20
- action: "authLogout",
21
- title: "Auth Logout",
22
- type: "globalCallback",
23
- callback: p,
24
- params: {}
25
- }
26
- } : o === "basic" && (e = {
27
- login: {
28
- action: "authLogin",
29
- title: "Auth Login",
30
- type: "globalCallback",
31
- callback: d,
32
- params: {
33
- mode: {
34
- label: "Mode",
35
- canBind: !1,
36
- type: "select",
37
- defaultValue: "normal",
38
- options: [{
39
- label: "Token",
40
- value: "token"
41
- }, {
42
- label: "User and Password",
43
- value: "normal"
44
- }]
45
- },
46
- username: {
47
- type: "text",
48
- defaultValue: "",
49
- when: (e) => e.mode === "normal"
50
- },
51
- password: {
52
- type: "text",
53
- defaultValue: "",
54
- when: (e) => e.mode === "normal"
55
- },
56
- token: {
57
- type: "text",
58
- defaultValue: "",
59
- when: (e) => e.mode === "token"
60
- }
9
+ callbacks: r(() => o === "" ? {} : {
10
+ login: {
11
+ action: "authLogin",
12
+ title: "Auth Login",
13
+ type: "globalCallback",
14
+ callback: d,
15
+ params: {
16
+ mode: {
17
+ label: "Mode",
18
+ canBind: !1,
19
+ type: "select",
20
+ defaultValue: "normal",
21
+ options: [{
22
+ label: "Token",
23
+ value: "token"
24
+ }, {
25
+ label: "User and Password",
26
+ value: "normal"
27
+ }]
28
+ },
29
+ username: {
30
+ type: "text",
31
+ defaultValue: "",
32
+ when: (e) => e.mode === "normal"
33
+ },
34
+ password: {
35
+ type: "text",
36
+ defaultValue: "",
37
+ when: (e) => e.mode === "normal"
61
38
  },
62
- preview: {
63
- errors: {
64
- username: "",
65
- password: "",
66
- token: ""
67
- },
68
- success: "",
69
- access_token: "",
70
- expires_at: "",
71
- details: {
72
- id: "",
73
- username: "",
74
- email: "",
75
- verified: "",
76
- permissions: ""
77
- }
39
+ token: {
40
+ type: "text",
41
+ defaultValue: "",
42
+ when: (e) => e.mode === "token"
78
43
  }
79
44
  },
80
- refreshDetails: {
81
- action: "authRefreshDetails",
82
- title: "Auth Refresh Details",
83
- type: "globalCallback",
84
- callback: f,
85
- params: {},
86
- preview: {
87
- errors: "",
88
- success: "",
89
- access_token: "",
90
- expires_at: "",
91
- details: {
92
- id: "",
93
- username: "",
94
- email: "",
95
- roles: "",
96
- permissions: "",
97
- verified: ""
98
- }
45
+ preview: {
46
+ errors: {
47
+ username: "",
48
+ password: "",
49
+ token: ""
50
+ },
51
+ success: "",
52
+ access_token: "",
53
+ expires_at: "",
54
+ details: {
55
+ id: "",
56
+ username: "",
57
+ email: "",
58
+ verified: "",
59
+ permissions: ""
60
+ }
61
+ }
62
+ },
63
+ refreshDetails: {
64
+ action: "authRefreshDetails",
65
+ title: "Auth Refresh Details",
66
+ type: "globalCallback",
67
+ callback: f,
68
+ params: {},
69
+ preview: {
70
+ errors: "",
71
+ success: "",
72
+ access_token: "",
73
+ expires_at: "",
74
+ details: {
75
+ id: "",
76
+ username: "",
77
+ email: "",
78
+ roles: "",
79
+ permissions: "",
80
+ verified: ""
99
81
  }
100
- },
101
- logout: {
102
- action: "authLogout",
103
- title: "Auth Logout",
104
- type: "globalCallback",
105
- callback: p,
106
- preview: {},
107
- params: {}
108
82
  }
109
- }), e;
83
+ },
84
+ logout: {
85
+ action: "authLogout",
86
+ title: "Auth Logout",
87
+ type: "globalCallback",
88
+ callback: p,
89
+ preview: {},
90
+ params: {}
91
+ }
110
92
  }, [
111
93
  d,
112
94
  p,
@@ -1,12 +1,15 @@
1
1
  import e from "../../InteractionsContext.mjs";
2
2
  import { use as t, useCallback as n, useMemo as r } from "react";
3
3
  import { get as i, pick as a } from "@plitzi/plitzi-ui/helpers";
4
- import o from "@plitzi/sdk-navigation/NavigationContext";
5
- import { useCommonStore as s } from "@plitzi/sdk-shared/store";
4
+ import { useSdkStore as o } from "@plitzi/sdk-shared/store";
6
5
  //#region src/sources/NavigationSource/NavigationInteractions.tsx
7
- var c = ({ children: c, previewMode: l = !1 }) => {
8
- let { useInteractions: u } = t(e), { navigate: d } = t(o), [[f, p]] = s(["schema.pages", "pageDefinitions"]), m = r(() => {
9
- let e = a(p, f);
6
+ var s = ({ children: s, previewMode: c = !1 }) => {
7
+ let { useInteractions: l } = t(e), [[u, d, f]] = o([
8
+ "schema.pages",
9
+ "pageDefinitions",
10
+ "navigation.navigate"
11
+ ]), p = r(() => {
12
+ let e = a(d, u);
10
13
  return Object.keys(e).reduce((t, n) => {
11
14
  let r = e[n], a = i(r, "attributes.name", n), o = i(r, "attributes.default", !1);
12
15
  return [...t, {
@@ -15,18 +18,18 @@ var c = ({ children: c, previewMode: l = !1 }) => {
15
18
  defaultPage: o
16
19
  }];
17
20
  }, []);
18
- }, [p, f]), h = n((e) => {
19
- if (!l) return;
21
+ }, [d, u]), m = n((e) => {
22
+ if (!c) return;
20
23
  let { url: t, urlType: n } = e;
21
- n === "page" || n === "internal" ? d(t) : d(t, !0);
22
- }, [d, l]);
23
- return u({
24
+ n === "page" || n === "internal" ? f(t) : f(t, !0);
25
+ }, [f, c]);
26
+ return l({
24
27
  id: "navigation",
25
28
  callbacks: r(() => ({ navigate: {
26
29
  action: "navigate",
27
30
  title: "Navigate",
28
31
  type: "globalCallback",
29
- callback: h,
32
+ callback: m,
30
33
  preview: {},
31
34
  params: {
32
35
  urlType: {
@@ -49,17 +52,17 @@ var c = ({ children: c, previewMode: l = !1 }) => {
49
52
  ]
50
53
  },
51
54
  url: {
52
- defaultValue: m.find((e) => e.defaultPage)?.key ?? "",
55
+ defaultValue: p.find((e) => e.defaultPage)?.key ?? "",
53
56
  type: (e) => e.urlType === "page" ? "select" : "text",
54
57
  when: (e) => !!e.urlType,
55
- options: m.map((e) => ({
58
+ options: p.map((e) => ({
56
59
  value: e.key,
57
60
  label: e.label
58
61
  }))
59
62
  }
60
63
  }
61
- } }), [h, m])
62
- }), c;
64
+ } }), [m, p])
65
+ }), s;
63
66
  };
64
67
  //#endregion
65
- export { c as default };
68
+ export { s as default };
@@ -1,9 +1,7 @@
1
1
  import { AuthInteractions } from './AuthSource';
2
- import { CollectionInteractions } from './CollectionSource';
3
2
  import { NavigationInteractions } from './NavigationSource';
4
3
  import { StateInteractions } from './StateSource';
5
4
  export * from './AuthSource';
6
- export * from './CollectionSource';
7
5
  export * from './NavigationSource';
8
6
  export * from './StateSource';
9
- export { AuthInteractions, CollectionInteractions, NavigationInteractions, StateInteractions };
7
+ export { AuthInteractions, NavigationInteractions, StateInteractions };
@@ -1,5 +1,4 @@
1
1
  import e from "./AuthSource/AuthInteractions.mjs";
2
- import t from "./CollectionSource/CollectionInteractions.mjs";
3
- import n from "./NavigationSource/NavigationInteractions.mjs";
4
- import r from "./StateSource/StateInteractions.mjs";
5
- export { e as AuthInteractions, t as CollectionInteractions, n as NavigationInteractions, r as StateInteractions };
2
+ import t from "./NavigationSource/NavigationInteractions.mjs";
3
+ import n from "./StateSource/StateInteractions.mjs";
4
+ export { e as AuthInteractions, t as NavigationInteractions, n as StateInteractions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-interactions",
3
- "version": "0.32.25",
3
+ "version": "0.33.1",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist"
@@ -54,18 +54,6 @@
54
54
  "types": "./dist/sources/AuthSource/index.d.ts",
55
55
  "import": "./dist/sources/AuthSource/index.mjs"
56
56
  },
57
- "./sources/CollectionSource": {
58
- "types": "./dist/sources/CollectionSource/index.d.ts",
59
- "import": "./dist/sources/CollectionSource/index.mjs"
60
- },
61
- "./sources/CollectionSource/CollectionInteractions": {
62
- "types": "./dist/sources/CollectionSource/CollectionInteractions.d.ts",
63
- "import": "./dist/sources/CollectionSource/CollectionInteractions.mjs"
64
- },
65
- "./sources/CollectionSource/index": {
66
- "types": "./dist/sources/CollectionSource/index.d.ts",
67
- "import": "./dist/sources/CollectionSource/index.mjs"
68
- },
69
57
  "./sources/NavigationSource": {
70
58
  "types": "./dist/sources/NavigationSource/index.d.ts",
71
59
  "import": "./dist/sources/NavigationSource/index.mjs"
@@ -129,16 +117,15 @@
129
117
  "devDependencies": {
130
118
  "eslint": "^9.39.5",
131
119
  "typescript": "^6.0.3",
132
- "vite": "^8.2.0",
120
+ "vite": "^8.2.1",
133
121
  "vitest": "^4.1.10"
134
122
  },
135
123
  "dependencies": {
136
- "@plitzi/plitzi-ui": "^1.6.18",
137
- "@plitzi/sdk-auth": "0.32.25",
138
- "@plitzi/sdk-collections": "0.32.25",
139
- "@plitzi/sdk-dev-tools": "0.32.25",
140
- "@plitzi/sdk-event-bridge": "0.32.25",
141
- "@plitzi/sdk-navigation": "0.32.25",
142
- "@plitzi/sdk-shared": "0.32.25"
124
+ "@plitzi/plitzi-ui": "^1.6.19",
125
+ "@plitzi/sdk-auth": "0.33.1",
126
+ "@plitzi/sdk-dev-tools": "0.33.1",
127
+ "@plitzi/sdk-event-bridge": "0.33.1",
128
+ "@plitzi/sdk-navigation": "0.33.1",
129
+ "@plitzi/sdk-shared": "0.33.1"
143
130
  }
144
131
  }
@@ -1,6 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export type CollectionInteractionsProps = {
3
- children?: ReactNode;
4
- };
5
- declare const CollectionInteractions: ({ children }: CollectionInteractionsProps) => ReactNode;
6
- export default CollectionInteractions;
@@ -1,268 +0,0 @@
1
- import e from "../../InteractionsContext.mjs";
2
- import { use as t, useCallback as n, useMemo as r } from "react";
3
- import { get as i, pick as a } from "@plitzi/plitzi-ui/helpers";
4
- import { collectionFieldTypeToInteractions as o } from "@plitzi/sdk-collections/CollectionsHelper";
5
- import s from "@plitzi/sdk-shared/collections/CollectionContext";
6
- //#region src/sources/CollectionSource/CollectionInteractions.tsx
7
- var c = ({ children: c }) => {
8
- let { useInteractions: l } = t(e), { collections: u, addRecord: d, updateRecord: f, removeRecord: p } = t(s), m = n((e, t) => {
9
- if (!e) return !1;
10
- let { fields: n } = e;
11
- if (typeof n != "object") return !0;
12
- let r = Object.values(n).filter((e) => e.params.required);
13
- if (r.length === 0) return !0;
14
- let i = !0;
15
- return r.forEach((e) => {
16
- if (!t[e.machineName] && i) {
17
- i = !1;
18
- return;
19
- }
20
- }), i;
21
- }, []), h = n(async (e) => {
22
- let { collectionId: t, recordStatus: n = "draft" } = e, r = i(u, t, void 0);
23
- if (!r || !m(r, e)) return {
24
- success: !1,
25
- record: void 0
26
- };
27
- let { fields: o } = r, s = a(e, Object.keys(o));
28
- return {
29
- success: !0,
30
- collectionId: t,
31
- record: await d(t, n, s)
32
- };
33
- }, [
34
- d,
35
- u,
36
- m
37
- ]), g = n(async (e) => {
38
- let { collectionId: t, recordStatus: n = "draft", recordId: r } = e, o = i(u, t, void 0);
39
- if (!o || !r || !m(o, e)) return {
40
- success: !1,
41
- record: void 0
42
- };
43
- let { fields: s } = o, c = a(e, Object.keys(s));
44
- return {
45
- success: !0,
46
- collectionId: t,
47
- record: await f(t, r, n, c)
48
- };
49
- }, [
50
- u,
51
- f,
52
- m
53
- ]), _ = n(async (e) => {
54
- let { collectionId: t, recordId: n } = e;
55
- return !i(u, t, void 0) || !n ? {
56
- success: !1,
57
- record: void 0
58
- } : (await p(t, n), {
59
- success: !0,
60
- collectionId: t,
61
- recordId: n
62
- });
63
- }, [u, p]), v = r(() => !u || typeof u != "object" ? [] : Object.keys(u).reduce((e, t) => {
64
- let n = u[t], r = i(n, "name", t);
65
- return [...e, {
66
- value: t,
67
- label: r
68
- }];
69
- }, []), [u]);
70
- return l({
71
- id: "collection",
72
- callbacks: r(() => ({
73
- addCollectionRecord: {
74
- action: "addCollectionRecord",
75
- title: "Add Collection Record",
76
- type: "globalCallback",
77
- callback: h,
78
- preview: {
79
- success: "",
80
- collectionId: "",
81
- record: {
82
- id: "",
83
- status: "",
84
- values: {}
85
- }
86
- },
87
- params: (e) => {
88
- let t = i(u, `${e.collectionId}.fields`, {});
89
- return {
90
- collectionId: {
91
- label: "Collection",
92
- defaultValue: void 0,
93
- type: "select",
94
- options: v
95
- },
96
- recordStatus: {
97
- label: "Record Status",
98
- defaultValue: "draft",
99
- type: "select",
100
- options: [
101
- {
102
- value: "published",
103
- label: "Published"
104
- },
105
- {
106
- value: "draft",
107
- label: "Draft"
108
- },
109
- {
110
- value: "archived",
111
- label: "Archived"
112
- },
113
- {
114
- value: "deleted",
115
- label: "Deleted"
116
- },
117
- {
118
- value: "created",
119
- label: "Created"
120
- }
121
- ]
122
- },
123
- ...Object.values(t).reduce((e, t) => {
124
- let { machineName: n, name: r, type: i } = t;
125
- return {
126
- ...e,
127
- [n]: {
128
- label: r,
129
- defaultValue: void 0,
130
- when: (e) => !!e.collectionId,
131
- type: o(i)
132
- }
133
- };
134
- }, {})
135
- };
136
- }
137
- },
138
- updateCollectionRecord: {
139
- action: "updateCollectionRecord",
140
- title: "Update Collection Record",
141
- type: "globalCallback",
142
- callback: g,
143
- preview: {
144
- success: "",
145
- collectionId: "",
146
- record: {
147
- id: "",
148
- status: "",
149
- values: {}
150
- }
151
- },
152
- params: (e) => {
153
- let t = i(u, `${e.collectionId}.fields`, {});
154
- return {
155
- collectionId: {
156
- label: "Collection",
157
- defaultValue: void 0,
158
- type: "select",
159
- options: v
160
- },
161
- recordStatus: {
162
- label: "Record Status",
163
- defaultValue: "draft",
164
- type: "select",
165
- options: [
166
- {
167
- value: "published",
168
- label: "Published"
169
- },
170
- {
171
- value: "draft",
172
- label: "Draft"
173
- },
174
- {
175
- value: "archived",
176
- label: "Archived"
177
- },
178
- {
179
- value: "deleted",
180
- label: "Deleted"
181
- },
182
- {
183
- value: "created",
184
- label: "Created"
185
- }
186
- ]
187
- },
188
- recordId: {
189
- label: "Record",
190
- defaultValue: void 0,
191
- type: "select",
192
- when: (e) => !!e.collectionId,
193
- options: (e) => {
194
- let { collectionId: t } = e, n = u[t];
195
- if (!t || !n) return [];
196
- let r = Object.values(n.fields).find((e) => e.params.primary);
197
- return n.records.map((e) => {
198
- let t = "";
199
- return t = r ? e.values[r.machineName] : JSON.stringify(e.values), {
200
- value: e.id,
201
- label: t
202
- };
203
- });
204
- }
205
- },
206
- ...Object.values(t).reduce((e, t) => {
207
- let { machineName: n, name: r, type: i } = t;
208
- return {
209
- ...e,
210
- [n]: {
211
- label: r,
212
- defaultValue: void 0,
213
- when: (e) => !!e.collectionId,
214
- type: o(i)
215
- }
216
- };
217
- }, {})
218
- };
219
- }
220
- },
221
- removeCollectionRecord: {
222
- action: "removeCollectionRecord",
223
- title: "Remove Collection Record",
224
- type: "globalCallback",
225
- callback: _,
226
- preview: {
227
- success: "",
228
- collectionId: "",
229
- recordId: ""
230
- },
231
- params: {
232
- collectionId: {
233
- label: "Collection",
234
- defaultValue: void 0,
235
- type: "select",
236
- options: v
237
- },
238
- recordId: {
239
- label: "Record",
240
- defaultValue: void 0,
241
- type: "select",
242
- when: (e) => !!e.collectionId,
243
- options: (e) => {
244
- let { collectionId: t } = e, n = u[t];
245
- if (!t || !n) return [];
246
- let r = Object.values(n.fields).find((e) => e.params.primary);
247
- return n.records.map((e) => {
248
- let t = "";
249
- return t = r ? e.values[r.machineName] : JSON.stringify(e.values), {
250
- value: e.id,
251
- label: t
252
- };
253
- });
254
- }
255
- }
256
- }
257
- }
258
- }), [
259
- u,
260
- v,
261
- h,
262
- _,
263
- g
264
- ])
265
- }), c;
266
- };
267
- //#endregion
268
- export { c as default };
@@ -1,3 +0,0 @@
1
- import { default as CollectionInteractions } from './CollectionInteractions';
2
- export * from './CollectionInteractions';
3
- export { CollectionInteractions };
@@ -1,2 +0,0 @@
1
- import e from "./CollectionInteractions.mjs";
2
- export { e as CollectionInteractions };