@declarion/react 0.189.0 → 0.196.0

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.
@@ -83,9 +83,12 @@ export declare function actionResults(map: Record<string, ActionResult>): Record
83
83
  export declare function actionEnvelope(env: Partial<ActionExecuteResponse> & {
84
84
  status: string;
85
85
  }): ActionResult;
86
- /** Clear every harness seam + the seeded auth state. Auto-registered as an
87
- * afterEach when the test runner exposes one (vitest/jest globals); exported
88
- * so a runner without globals can call it explicitly. */
86
+ /** Unmount the rendered screens, then clear every harness seam + the seeded auth
87
+ * state. Auto-registered as an afterEach when the test runner exposes one
88
+ * (vitest/jest globals); exported so a runner without globals can call it
89
+ * explicitly. Unmounting first matters: the runner calls this hook before
90
+ * testing-library's own cleanup, and an auth reset under a mounted screen
91
+ * renders it again and re-reads the session after the test. */
89
92
  export declare function cleanupDeclarion(): void;
90
93
  /**
91
94
  * Render a consumer screen under the SDK's real providers with fixtures seeded
@@ -11,14 +11,14 @@ import { QueryClient as f, QueryClientProvider as p } from "@tanstack/react-quer
11
11
  import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
12
  import { MemoryRouter as g, useLocation as _ } from "react-router";
13
13
  import { Toaster as v } from "sonner";
14
- import { render as y } from "@testing-library/react";
14
+ import { cleanup as y, render as b } from "@testing-library/react";
15
15
  // src/testing.tsx
16
- function b(e = "en", t) {
16
+ function x(e = "en", t) {
17
17
  return u(t, e, "en");
18
18
  }
19
- function x(e = "en", t) {
19
+ function S(e = "en", t) {
20
20
  let n = new f({ defaultOptions: { queries: { retry: !1 } } });
21
- return a(n, S({
21
+ return a(n, C({
22
22
  language: e,
23
23
  messages: t
24
24
  })), function({ children: e }) {
@@ -28,7 +28,7 @@ function x(e = "en", t) {
28
28
  });
29
29
  };
30
30
  }
31
- function S(e = {}) {
31
+ function C(e = {}) {
32
32
  return {
33
33
  languages: [],
34
34
  language: "en",
@@ -43,7 +43,7 @@ function S(e = {}) {
43
43
  ...e
44
44
  };
45
45
  }
46
- function C(e, t = {}, n) {
46
+ function w(e, t = {}, n) {
47
47
  return {
48
48
  data: e,
49
49
  meta: {
@@ -57,31 +57,31 @@ function C(e, t = {}, n) {
57
57
  ...n === void 0 ? {} : { $refs: n }
58
58
  };
59
59
  }
60
- function w(e) {
60
+ function T(e) {
61
61
  return e;
62
62
  }
63
- var T = Symbol("declarion.testing.actionEnvelope");
64
- function E(e) {
63
+ var E = Symbol("declarion.testing.actionEnvelope");
64
+ function D(e) {
65
65
  return {
66
66
  ...e,
67
- [T]: !0
67
+ [E]: !0
68
68
  };
69
69
  }
70
- function D(e) {
71
- if (e && typeof e == "object" && e[T]) {
70
+ function O(e) {
71
+ if (e && typeof e == "object" && e[E]) {
72
72
  let t = { ...e };
73
- return delete t[T], t;
73
+ return delete t[E], t;
74
74
  }
75
75
  return {
76
76
  status: "success",
77
77
  result: e
78
78
  };
79
79
  }
80
- function O({ into: e }) {
80
+ function k({ into: e }) {
81
81
  let t = _();
82
82
  return e.current = `${t.pathname}${t.search}${t.hash}`, null;
83
83
  }
84
- function k() {
84
+ function A() {
85
85
  let e = {
86
86
  id: "test-tenant",
87
87
  code: "test",
@@ -98,7 +98,7 @@ function k() {
98
98
  };
99
99
  i.getState().setUser(t, e);
100
100
  }
101
- function A(e) {
101
+ function j(e) {
102
102
  if (e === void 0) return { rows: [] };
103
103
  if (Array.isArray(e)) return { rows: e };
104
104
  if (Array.isArray(e.data)) {
@@ -111,14 +111,14 @@ function A(e) {
111
111
  }
112
112
  return e;
113
113
  }
114
- function j(e) {
114
+ function M(e) {
115
115
  let t = e.entityData ?? {};
116
116
  l((n, r) => {
117
117
  let i = r;
118
118
  e.onListRequest?.(n, i);
119
119
  let a = t[n], o = typeof a == "function" ? a(i) : a;
120
120
  if (o instanceof Error) throw o;
121
- let s = A(o), c = s.meta?.per_page ?? 50, l = s.meta?.total ?? s.rows.length;
121
+ let s = j(o), c = s.meta?.per_page ?? 50, l = s.meta?.total ?? s.rows.length;
122
122
  return r.count === "only" ? {
123
123
  data: [],
124
124
  meta: {
@@ -151,23 +151,23 @@ function j(e) {
151
151
  s(async (e, t) => {
152
152
  if (!(e in i)) throw Error(`renderWithDeclarion: no action result registered for "${e}" (seed it via actionResults)`);
153
153
  let n = i[e];
154
- return D(typeof n == "function" ? await n(t) : n);
154
+ return O(typeof n == "function" ? await n(t) : n);
155
155
  });
156
156
  }
157
- function M() {
158
- l(null), c(null), s(null), i.setState({
157
+ function N() {
158
+ y(), l(null), c(null), s(null), i.setState({
159
159
  user: null,
160
160
  isAuthenticated: !1,
161
161
  activeTenant: null,
162
162
  tenants: []
163
163
  });
164
164
  }
165
- function N(i, o = {}) {
165
+ function P(i, o = {}) {
166
166
  let s = new f({ defaultOptions: { queries: {
167
167
  retry: !1,
168
168
  gcTime: Infinity
169
169
  } } });
170
- k(), a(s, o.schema ?? S()), j(o);
170
+ A(), a(s, o.schema ?? C()), M(o);
171
171
  let c = o.screenCode ? /* @__PURE__ */ m(t, {
172
172
  code: o.screenCode,
173
173
  children: i
@@ -175,12 +175,12 @@ function N(i, o = {}) {
175
175
  client: s,
176
176
  children: [/* @__PURE__ */ h(g, {
177
177
  initialEntries: [o.route ?? "/"],
178
- children: [/* @__PURE__ */ m(O, { into: l }), /* @__PURE__ */ m(r, { children: c })]
178
+ children: [/* @__PURE__ */ m(k, { into: l }), /* @__PURE__ */ m(r, { children: c })]
179
179
  }), /* @__PURE__ */ m(v, {})]
180
180
  }), d = o.embedQuery ? /* @__PURE__ */ m(n, {
181
181
  query: o.embedQuery,
182
182
  children: u
183
- }) : u, _ = y(o.viewport ? /* @__PURE__ */ m(e, {
183
+ }) : u, _ = b(o.viewport ? /* @__PURE__ */ m(e, {
184
184
  viewportOverride: o.viewport,
185
185
  children: d
186
186
  }) : d);
@@ -189,19 +189,19 @@ function N(i, o = {}) {
189
189
  location: () => l.current
190
190
  });
191
191
  }
192
- function P({ children: e, authenticated: t = !0, ...n }) {
192
+ function F({ children: e, authenticated: t = !0, ...n }) {
193
193
  let [o] = d(() => {
194
194
  let e = new f({ defaultOptions: { queries: {
195
195
  retry: !1,
196
196
  gcTime: Infinity
197
197
  } } });
198
- return t ? (k(), a(e, n.schema ?? S())) : (i.setState({
198
+ return t ? (A(), a(e, n.schema ?? C())) : (i.setState({
199
199
  user: null,
200
200
  isAuthenticated: !1,
201
201
  isLoading: !1,
202
202
  activeTenant: null,
203
203
  tenants: []
204
- }), a(e, n.schema ?? S())), j(n), e;
204
+ }), a(e, n.schema ?? C())), M(n), e;
205
205
  });
206
206
  return /* @__PURE__ */ h(p, {
207
207
  client: o,
@@ -211,5 +211,5 @@ function P({ children: e, authenticated: t = !0, ...n }) {
211
211
  }), /* @__PURE__ */ m(v, {})]
212
212
  });
213
213
  }
214
- typeof afterEach == "function" && afterEach(() => M());
215
- export { P as PreviewHarness, E as actionEnvelope, w as actionResults, M as cleanupDeclarion, C as entityDataFixture, x as languageWrapper, N as renderWithDeclarion, S as schemaFixture, b as textFixture };
214
+ typeof afterEach == "function" && afterEach(() => N());
215
+ export { F as PreviewHarness, D as actionEnvelope, T as actionResults, N as cleanupDeclarion, w as entityDataFixture, S as languageWrapper, P as renderWithDeclarion, C as schemaFixture, x as textFixture };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.189.0",
3
+ "version": "0.196.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",