@nestledjs/data-browser 0.1.4 → 0.1.5

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.
@@ -9,18 +9,18 @@ import { useState as U, useMemo as y, useEffect as _ } from "react";
9
9
  import { useParams as w, Link as g, useNavigate as k } from "react-router";
10
10
  import { getAdminDocuments as T, buildFormFields as E, cleanFormInput as $ } from "../utils/graphql-utils.js";
11
11
  function N(a) {
12
- return a.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/^./, (d) => d.toUpperCase());
12
+ return a.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/^./, (n) => n.toUpperCase());
13
13
  }
14
14
  function B(a) {
15
15
  return !a || typeof a != "string" ? "" : a.replace(/[<>"'%;()&+]/g, "").replace(/javascript:/gi, "").replace(/on\w+\s*=/gi, "").trim().substring(0, 100);
16
16
  }
17
17
  const j = (a) => a.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
18
18
  function O() {
19
- const { dataType: a } = w(), { databaseModels: d, basePath: o = "/admin/data", formTheme: f } = P(), u = (b) => d.find((m) => m.name === b), s = ((b) => {
19
+ const { dataType: a } = w(), { databaseModels: n, basePath: o = "/admin/data", formTheme: f } = P(), u = (b) => n.find((m) => m.name === b), s = ((b) => {
20
20
  const m = B(b);
21
21
  if (!m) return null;
22
- const i = m.split("-").map((l) => l.charAt(0).toUpperCase() + l.slice(1).toLowerCase()).join("");
23
- return d.find((l) => l.name === i) ? i : null;
22
+ const l = m.split("-").map((i) => i.charAt(0).toUpperCase() + i.slice(1).toLowerCase()).join("");
23
+ return n.find((i) => i.name === l) ? l : null;
24
24
  })(a), r = !s, c = s ? u(s) : null, p = s && !0 && !c;
25
25
  return r ? /* @__PURE__ */ e("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ e("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ e("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ e("div", { className: "text-center", children: [
26
26
  /* @__PURE__ */ e(h, { className: "mx-auto h-12 w-12 text-red-400" }, void 0, !1, {
@@ -136,20 +136,20 @@ function O() {
136
136
  columnNumber: 10
137
137
  }, this);
138
138
  }
139
- function L({ model: a, basePath: d, formTheme: o }) {
139
+ function L({ model: a, basePath: n, formTheme: o }) {
140
140
  const f = k(), { sdk: u } = P(), [t, s] = U({ status: "idle" }), r = y(() => {
141
141
  try {
142
142
  return T(u, a);
143
- } catch (i) {
144
- return console.error("[AdminDataCreatePage] Error getting documents:", i), null;
143
+ } catch (l) {
144
+ return console.error("[AdminDataCreatePage] Error getting documents:", l), null;
145
145
  }
146
146
  }, [u, a]), c = y(() => {
147
- var i, n;
147
+ var l, d;
148
148
  if (!(r != null && r.create)) return null;
149
149
  try {
150
- return (i = r.create) != null && i.definitions && ((n = r.create) != null && n.loc) ? r.create : x(r.create);
151
- } catch (l) {
152
- return console.error("[AdminDataCreatePage] Error parsing CREATE mutation:", l), null;
150
+ return (l = r.create) != null && l.definitions && ((d = r.create) != null && d.loc) ? r.create : x(r.create);
151
+ } catch (i) {
152
+ return console.error("[AdminDataCreatePage] Error parsing CREATE mutation:", i), null;
153
153
  }
154
154
  }, [r]), [p] = C(
155
155
  c || x`
@@ -178,7 +178,7 @@ function L({ model: a, basePath: d, formTheme: o }) {
178
178
  /* @__PURE__ */ e("div", { className: "mt-6", children: /* @__PURE__ */ e(
179
179
  g,
180
180
  {
181
- to: d,
181
+ to: n,
182
182
  className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
183
183
  children: "Return to Data Browser"
184
184
  },
@@ -212,18 +212,18 @@ function L({ model: a, basePath: d, formTheme: o }) {
212
212
  lineNumber: 222,
213
213
  columnNumber: 7
214
214
  }, this);
215
- const b = E(u, a, "create"), m = async (i) => {
215
+ const b = E(u, a, "create"), m = async (l) => {
216
216
  try {
217
217
  s({ status: "loading" });
218
- const n = $(i, a), l = await p({
218
+ const d = $(l, a), i = await p({
219
219
  variables: {
220
- input: n
220
+ input: d
221
221
  }
222
222
  });
223
- if (l.errors) {
224
- console.error("GraphQL errors:", l.errors), s({
223
+ if (i.errors) {
224
+ console.error("GraphQL errors:", i.errors), s({
225
225
  status: "error",
226
- message: l.errors.map((v) => v.message).join(", ")
226
+ message: i.errors.map((v) => v.message).join(", ")
227
227
  });
228
228
  return;
229
229
  }
@@ -231,26 +231,26 @@ function L({ model: a, basePath: d, formTheme: o }) {
231
231
  status: "success",
232
232
  message: `${N(a.name)} created successfully!`
233
233
  }), setTimeout(() => {
234
- f(`/admin/data/${j(a.pluralName)}`);
234
+ f(`${n}/${j(a.pluralName)}`);
235
235
  }, 1500);
236
- } catch (n) {
237
- console.error("Error creating record:", n), s({
236
+ } catch (d) {
237
+ console.error("Error creating record:", d), s({
238
238
  status: "error",
239
- message: n instanceof Error ? n.message : "An unexpected error occurred"
239
+ message: d instanceof Error ? d.message : "An unexpected error occurred"
240
240
  });
241
241
  }
242
242
  };
243
243
  return _(() => {
244
244
  if (t.status === "error") {
245
- const i = setTimeout(() => {
245
+ const l = setTimeout(() => {
246
246
  s({ status: "idle" });
247
247
  }, 5e3);
248
- return () => clearTimeout(i);
248
+ return () => clearTimeout(l);
249
249
  }
250
250
  }, [t.status]), /* @__PURE__ */ e("div", { className: "space-y-6", children: [
251
251
  /* @__PURE__ */ e("div", { className: "mb-8", children: [
252
252
  /* @__PURE__ */ e("nav", { className: "flex mb-6", "aria-label": "Breadcrumb", children: /* @__PURE__ */ e("ol", { className: "flex items-center space-x-4", children: [
253
- /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(g, { to: "/admin/data", className: "text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400", children: "Data Browser" }, void 0, !1, {
253
+ /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(g, { to: n, className: "text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400", children: "Data Browser" }, void 0, !1, {
254
254
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataCreatePage.tsx",
255
255
  lineNumber: 309,
256
256
  columnNumber: 17
@@ -295,7 +295,7 @@ function L({ model: a, basePath: d, formTheme: o }) {
295
295
  /* @__PURE__ */ e(
296
296
  g,
297
297
  {
298
- to: `/admin/data/${j(a.pluralName)}`,
298
+ to: `${n}/${j(a.pluralName)}`,
299
299
  className: "ml-4 text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400",
300
300
  children: N(a.pluralName)
301
301
  },
@@ -1,15 +1,15 @@
1
1
  import { jsxDEV as e } from "react/jsx-dev-runtime";
2
- import { gql as x } from "@apollo/client";
3
- import { useQuery as Z, useMutation as S } from "@apollo/client/react";
2
+ import { gql as y } from "@apollo/client";
3
+ import { useQuery as Z, useMutation as T } from "@apollo/client/react";
4
4
  import { loadDevMessages as Y, loadErrorMessages as K } from "@apollo/client/dev";
5
- import { ExclamationCircleIcon as h, CheckCircleIcon as H } from "@heroicons/react/24/outline";
5
+ import { ExclamationCircleIcon as p, CheckCircleIcon as H } from "@heroicons/react/24/outline";
6
6
  import { TrashIcon as J } from "@heroicons/react/24/solid";
7
7
  import { useAdminDataContext as F } from "../context/AdminDataContext.js";
8
8
  import { ErrorBoundary as W } from "@nestledjs/shared-components";
9
9
  import { Form as X } from "@nestledjs/forms";
10
- import { useState as C, useMemo as A, useEffect as $ } from "react";
11
- import { useParams as ee, Link as p, useNavigate as ae } from "react-router";
12
- import { getAdminDocuments as te, buildFormFields as se, cleanFormInput as ie } from "../utils/graphql-utils.js";
10
+ import { useState as C, useMemo as A, useEffect as S } from "react";
11
+ import { useParams as ee, Link as x, useNavigate as te } from "react-router";
12
+ import { getAdminDocuments as ae, buildFormFields as se, cleanFormInput as ie } from "../utils/graphql-utils.js";
13
13
  function M(s) {
14
14
  return s ? s.charAt(0).toLowerCase() + s.slice(1) : "";
15
15
  }
@@ -29,15 +29,15 @@ const B = (s) => !s || typeof s != "string" ? "" : s.replace(/[<>"'%;()&+]/g, ""
29
29
  return d ? /^[a-zA-Z0-9_-]+$/.test(d) ? d : (console.warn(`[Security] Invalid ID format attempted: ${s}`), null) : null;
30
30
  };
31
31
  function Pe() {
32
- const { dataType: s, id: d } = ee(), { databaseModels: v, basePath: y = "/admin/data", formTheme: U } = F(), j = (i) => v.find((b) => b.name === i), m = ((i) => {
32
+ const { dataType: s, id: d } = ee(), { databaseModels: c, basePath: j = "/admin/data", formTheme: U } = F(), P = (i) => c.find((g) => g.name === i), m = ((i) => {
33
33
  if (!i) return null;
34
- const b = B(i);
35
- if (!b) return null;
36
- const P = b.split("-").map((g) => g.charAt(0).toUpperCase() + g.slice(1).toLowerCase()).join("");
37
- return v.find((g) => g.name === P) ? P : (console.warn(`[Security] Invalid dataType attempted: ${i}`), null);
38
- })(s), r = ne(d), N = !m || !r, D = m ? j(m) : null, E = m && r && !D;
39
- return N ? /* @__PURE__ */ e("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ e("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ e("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ e("div", { className: "text-center", children: [
40
- /* @__PURE__ */ e(h, { className: "mx-auto h-12 w-12 text-red-400" }, void 0, !1, {
34
+ const g = B(i);
35
+ if (!g) return null;
36
+ const v = g.split("-").map((f) => f.charAt(0).toUpperCase() + f.slice(1).toLowerCase()).join("");
37
+ return c.find((f) => f.name === v) ? v : (console.warn(`[Security] Invalid dataType attempted: ${i}`), null);
38
+ })(s), r = ne(d), h = !m || !r, D = m ? P(m) : null, E = m && r && !D;
39
+ return h ? /* @__PURE__ */ e("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ e("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ e("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ e("div", { className: "text-center", children: [
40
+ /* @__PURE__ */ e(p, { className: "mx-auto h-12 w-12 text-red-400" }, void 0, !1, {
41
41
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
42
42
  lineNumber: 122,
43
43
  columnNumber: 15
@@ -53,9 +53,9 @@ function Pe() {
53
53
  columnNumber: 15
54
54
  }, this),
55
55
  /* @__PURE__ */ e("div", { className: "mt-6", children: /* @__PURE__ */ e(
56
- p,
56
+ x,
57
57
  {
58
- to: y,
58
+ to: j,
59
59
  className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
60
60
  children: "Return to Data Browser"
61
61
  },
@@ -89,7 +89,7 @@ function Pe() {
89
89
  lineNumber: 118,
90
90
  columnNumber: 7
91
91
  }, this) : E ? /* @__PURE__ */ e("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ e("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ e("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ e("div", { className: "text-center", children: [
92
- /* @__PURE__ */ e(h, { className: "mx-auto h-12 w-12 text-yellow-400" }, void 0, !1, {
92
+ /* @__PURE__ */ e(p, { className: "mx-auto h-12 w-12 text-yellow-400" }, void 0, !1, {
93
93
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
94
94
  lineNumber: 148,
95
95
  columnNumber: 15
@@ -109,9 +109,9 @@ function Pe() {
109
109
  columnNumber: 15
110
110
  }, this),
111
111
  /* @__PURE__ */ e("div", { className: "mt-6", children: /* @__PURE__ */ e(
112
- p,
112
+ x,
113
113
  {
114
- to: y,
114
+ to: j,
115
115
  className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
116
116
  children: "Return to Data Browser"
117
117
  },
@@ -144,84 +144,84 @@ function Pe() {
144
144
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
145
145
  lineNumber: 144,
146
146
  columnNumber: 7
147
- }, this) : /* @__PURE__ */ e(de, { model: D, id: r, basePath: y, formTheme: U }, void 0, !1, {
147
+ }, this) : /* @__PURE__ */ e(de, { model: D, id: r, basePath: j, formTheme: U }, void 0, !1, {
148
148
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
149
149
  lineNumber: 169,
150
150
  columnNumber: 10
151
151
  }, this);
152
152
  }
153
- function de({ model: s, id: d, basePath: v, formTheme: y }) {
154
- const U = ae(), { sdk: j } = F(), [n, m] = C({ status: "idle" }), [r, N] = C({ status: "idle" }), [D, E] = C(!1), i = A(() => {
153
+ function de({ model: s, id: d, basePath: c, formTheme: j }) {
154
+ const U = te(), { sdk: P } = F(), [n, m] = C({ status: "idle" }), [r, h] = C({ status: "idle" }), [D, E] = C(!1), i = A(() => {
155
155
  try {
156
- return te(j, s);
156
+ return ae(P, s);
157
157
  } catch (l) {
158
158
  return console.error("[AdminDataEditPage] Error getting documents:", l), null;
159
159
  }
160
- }, [j, s]), b = A(() => {
161
- var l, t;
160
+ }, [P, s]), g = A(() => {
161
+ var l, a;
162
162
  if (!(i != null && i.query)) return null;
163
163
  try {
164
- return (l = i.query) != null && l.definitions && ((t = i.query) != null && t.loc) ? i.query : x(i.query);
165
- } catch (a) {
166
- return console.error("[AdminDataEditPage] Error parsing QUERY:", a), null;
164
+ return (l = i.query) != null && l.definitions && ((a = i.query) != null && a.loc) ? i.query : y(i.query);
165
+ } catch (t) {
166
+ return console.error("[AdminDataEditPage] Error parsing QUERY:", t), null;
167
167
  }
168
- }, [i]), P = A(() => {
169
- var l, t;
168
+ }, [i]), v = A(() => {
169
+ var l, a;
170
170
  if (!(i != null && i.update)) return null;
171
171
  try {
172
- return (l = i.update) != null && l.definitions && ((t = i.update) != null && t.loc) ? i.update : x(i.update);
173
- } catch (a) {
174
- return console.error("[AdminDataEditPage] Error parsing UPDATE mutation:", a), null;
172
+ return (l = i.update) != null && l.definitions && ((a = i.update) != null && a.loc) ? i.update : y(i.update);
173
+ } catch (t) {
174
+ return console.error("[AdminDataEditPage] Error parsing UPDATE mutation:", t), null;
175
175
  }
176
176
  }, [i]), _ = A(() => {
177
- var l, t;
177
+ var l, a;
178
178
  if (!(i != null && i.delete)) return null;
179
179
  try {
180
- return (l = i.delete) != null && l.definitions && ((t = i.delete) != null && t.loc) ? i.delete : x(i.delete);
181
- } catch (a) {
182
- return console.error("[AdminDataEditPage] Error parsing DELETE mutation:", a), null;
180
+ return (l = i.delete) != null && l.definitions && ((a = i.delete) != null && a.loc) ? i.delete : y(i.delete);
181
+ } catch (t) {
182
+ return console.error("[AdminDataEditPage] Error parsing DELETE mutation:", t), null;
183
183
  }
184
- }, [i]), g = le(s.name), R = re(s.name), { data: k, loading: z, error: L, refetch: T } = Z(
185
- b || x`
184
+ }, [i]), f = le(s.name), R = re(s.name), { data: k, loading: z, error: L, refetch: $ } = Z(
185
+ g || y`
186
186
  query PlaceholderQuery {
187
187
  __typename
188
188
  }
189
189
  `,
190
190
  {
191
- variables: { [g]: d },
191
+ variables: { [f]: d },
192
192
  errorPolicy: "all",
193
- skip: !b || !d
193
+ skip: !g || !d
194
194
  }
195
- ), [O] = S(
196
- P || x`
195
+ ), [O] = T(
196
+ v || y`
197
197
  mutation PlaceholderUpdate {
198
198
  __typename
199
199
  }
200
200
  `
201
- ), [Q] = S(
202
- _ || x`
201
+ ), [Q] = T(
202
+ _ || y`
203
203
  mutation PlaceholderDelete {
204
204
  __typename
205
205
  }
206
206
  `
207
207
  );
208
- if ($(() => {
208
+ if (S(() => {
209
209
  if (n.status === "error") {
210
210
  const l = setTimeout(() => {
211
211
  m({ status: "idle" });
212
212
  }, 5e3);
213
213
  return () => clearTimeout(l);
214
214
  }
215
- }, [n.status]), $(() => {
215
+ }, [n.status]), S(() => {
216
216
  if (r.status === "error") {
217
217
  const l = setTimeout(() => {
218
- N({ status: "idle" });
218
+ h({ status: "idle" });
219
219
  }, 5e3);
220
220
  return () => clearTimeout(l);
221
221
  }
222
- }, [r.status]), !i || !b || !P || !_)
222
+ }, [r.status]), !i || !g || !v || !_)
223
223
  return /* @__PURE__ */ e("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ e("div", { className: "mt-8 mx-auto w-full max-w-2xl", children: /* @__PURE__ */ e("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ e("div", { className: "text-center", children: [
224
- /* @__PURE__ */ e(h, { className: "mx-auto h-12 w-12 text-red-400" }, void 0, !1, {
224
+ /* @__PURE__ */ e(p, { className: "mx-auto h-12 w-12 text-red-400" }, void 0, !1, {
225
225
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
226
226
  lineNumber: 309,
227
227
  columnNumber: 15
@@ -237,9 +237,9 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
237
237
  columnNumber: 15
238
238
  }, this),
239
239
  /* @__PURE__ */ e("div", { className: "mt-6", children: /* @__PURE__ */ e(
240
- p,
240
+ x,
241
241
  {
242
- to: v,
242
+ to: c,
243
243
  className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
244
244
  children: "Return to Data Browser"
245
245
  },
@@ -275,7 +275,7 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
275
275
  }, this);
276
276
  if (L)
277
277
  return /* @__PURE__ */ e("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ e("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ e("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ e("div", { className: "text-center", children: [
278
- /* @__PURE__ */ e(h, { className: "mx-auto h-12 w-12 text-red-400" }, void 0, !1, {
278
+ /* @__PURE__ */ e(p, { className: "mx-auto h-12 w-12 text-red-400" }, void 0, !1, {
279
279
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
280
280
  lineNumber: 337,
281
281
  columnNumber: 15
@@ -294,7 +294,7 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
294
294
  /* @__PURE__ */ e(
295
295
  "button",
296
296
  {
297
- onClick: () => T(),
297
+ onClick: () => $(),
298
298
  className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
299
299
  children: "Try Again"
300
300
  },
@@ -308,9 +308,9 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
308
308
  this
309
309
  ),
310
310
  /* @__PURE__ */ e(
311
- p,
311
+ x,
312
312
  {
313
- to: `/admin/data/${I(s.pluralName)}`,
313
+ to: `${c}/${I(s.pluralName)}`,
314
314
  className: "w-full flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
315
315
  children: "Back to List"
316
316
  },
@@ -386,7 +386,7 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
386
386
  const w = k == null ? void 0 : k[R];
387
387
  if (!w)
388
388
  return /* @__PURE__ */ e("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ e("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ e("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ e("div", { className: "text-center", children: [
389
- /* @__PURE__ */ e(h, { className: "mx-auto h-12 w-12 text-yellow-400" }, void 0, !1, {
389
+ /* @__PURE__ */ e(p, { className: "mx-auto h-12 w-12 text-yellow-400" }, void 0, !1, {
390
390
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
391
391
  lineNumber: 389,
392
392
  columnNumber: 15
@@ -406,9 +406,9 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
406
406
  columnNumber: 15
407
407
  }, this),
408
408
  /* @__PURE__ */ e("div", { className: "mt-6", children: /* @__PURE__ */ e(
409
- p,
409
+ x,
410
410
  {
411
- to: `/admin/data/${I(s.pluralName)}`,
411
+ to: `${c}/${I(s.pluralName)}`,
412
412
  className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
413
413
  children: "Back to List"
414
414
  },
@@ -442,98 +442,98 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
442
442
  lineNumber: 385,
443
443
  columnNumber: 7
444
444
  }, this);
445
- const V = se(j, s, "update"), o = {};
445
+ const V = se(P, s, "update"), o = {};
446
446
  if (w) {
447
- s.fields.filter((t) => (t.isId, !(t.isReadOnly || t.isGenerated || t.isUpdatedAt || t.name === "createdAt" || t.relationName && t.isList))).forEach((t) => {
448
- var f;
449
- let a = w[t.name];
450
- if (t.relationName && !t.isList) {
451
- const c = ((f = t.relationFromFields) == null ? void 0 : f[0]) || t.name;
452
- a = w[c], a && typeof a == "object" && (a = a.id || ""), o[c] = a || "";
447
+ s.fields.filter((a) => (a.isId, !(a.isReadOnly || a.isGenerated || a.isUpdatedAt || a.name === "createdAt" || a.relationName && a.isList))).forEach((a) => {
448
+ var N;
449
+ let t = w[a.name];
450
+ if (a.relationName && !a.isList) {
451
+ const b = ((N = a.relationFromFields) == null ? void 0 : N[0]) || a.name;
452
+ t = w[b], t && typeof t == "object" && (t = t.id || ""), o[b] = t || "";
453
453
  } else {
454
- if (t.type.toLowerCase() === "datetime" || t.type.toLowerCase() === "date")
455
- if (a != null && a !== "")
454
+ if (a.type.toLowerCase() === "datetime" || a.type.toLowerCase() === "date")
455
+ if (t != null && t !== "")
456
456
  try {
457
- const c = a instanceof Date ? a : new Date(a);
458
- t.type.toLowerCase() === "date" ? a = c.toISOString().split("T")[0] : a = c.toISOString().substring(0, 16);
459
- } catch (c) {
460
- console.warn(`Failed to convert date value for field ${t.name}:`, c), a = "";
457
+ const b = t instanceof Date ? t : new Date(t);
458
+ a.type.toLowerCase() === "date" ? t = b.toISOString().split("T")[0] : t = b.toISOString().substring(0, 16);
459
+ } catch (b) {
460
+ console.warn(`Failed to convert date value for field ${a.name}:`, b), t = "";
461
461
  }
462
462
  else
463
- a = "";
464
- a === null && t.type.toLowerCase() !== "boolean" && (a = ""), t.type.toLowerCase() === "boolean" && (a = !!a), a !== null && typeof a == "object" && (console.warn(`Field ${t.name} has object value, converting to string:`, a), typeof a == "object" && "id" in a ? a = a.id : a = ""), o[t.name] = a;
463
+ t = "";
464
+ t === null && a.type.toLowerCase() !== "boolean" && (t = ""), a.type.toLowerCase() === "boolean" && (t = !!t), t !== null && typeof t == "object" && (console.warn(`Field ${a.name} has object value, converting to string:`, t), typeof t == "object" && "id" in t ? t = t.id : t = ""), o[a.name] = t;
465
465
  }
466
466
  });
467
- for (const [t, a] of Object.entries(o)) {
468
- if (a === void 0) {
469
- console.warn(`[AdminDataEditPage] Found undefined value for field ${t}, converting to empty string`), o[t] = "";
467
+ for (const [a, t] of Object.entries(o)) {
468
+ if (t === void 0) {
469
+ console.warn(`[AdminDataEditPage] Found undefined value for field ${a}, converting to empty string`), o[a] = "";
470
470
  continue;
471
471
  }
472
- if (a !== null && typeof a == "object")
473
- if (console.warn(`[AdminDataEditPage] Found non-primitive value for field ${t}, converting:`, a), "id" in a && typeof a.id == "string")
474
- o[t] = a.id;
475
- else if (a instanceof Date) {
476
- const f = s.fields.find((c) => c.name === t);
477
- o[t] = (f == null ? void 0 : f.type.toLowerCase()) === "date" ? a.toISOString().split("T")[0] : a.toISOString();
472
+ if (t !== null && typeof t == "object")
473
+ if (console.warn(`[AdminDataEditPage] Found non-primitive value for field ${a}, converting:`, t), "id" in t && typeof t.id == "string")
474
+ o[a] = t.id;
475
+ else if (t instanceof Date) {
476
+ const N = s.fields.find((b) => b.name === a);
477
+ o[a] = (N == null ? void 0 : N.type.toLowerCase()) === "date" ? t.toISOString().split("T")[0] : t.toISOString();
478
478
  } else
479
- o[t] = "";
479
+ o[a] = "";
480
480
  }
481
- console.log("[AdminDataEditPage] Final initialValues:", o), console.log("[AdminDataEditPage] Value types:", Object.entries(o).map(([t, a]) => ({
482
- key: t,
483
- type: typeof a,
484
- isDate: a instanceof Date,
485
- value: a
481
+ console.log("[AdminDataEditPage] Final initialValues:", o), console.log("[AdminDataEditPage] Value types:", Object.entries(o).map(([a, t]) => ({
482
+ key: a,
483
+ type: typeof t,
484
+ isDate: t instanceof Date,
485
+ value: t
486
486
  })));
487
487
  }
488
488
  const q = async (l) => {
489
489
  try {
490
490
  m({ status: "loading" });
491
- const t = ie(l, s), a = await O({
491
+ const a = ie(l, s), t = await O({
492
492
  variables: {
493
- input: t,
494
- [g]: d
493
+ input: a,
494
+ [f]: d
495
495
  }
496
496
  });
497
- if (a.errors) {
498
- console.error("GraphQL errors:", a.errors), m({
497
+ if (t.errors) {
498
+ console.error("GraphQL errors:", t.errors), m({
499
499
  status: "error",
500
- message: a.errors.map((f) => f.message).join(", ")
500
+ message: t.errors.map((N) => N.message).join(", ")
501
501
  });
502
502
  return;
503
503
  }
504
504
  m({
505
505
  status: "success",
506
506
  message: `${u(s.name)} updated successfully!`
507
- }), await T();
508
- } catch (t) {
509
- console.error("Error updating record:", t), m({
507
+ }), await $();
508
+ } catch (a) {
509
+ console.error("Error updating record:", a), m({
510
510
  status: "error",
511
- message: t instanceof Error ? t.message : "An unexpected error occurred"
511
+ message: a instanceof Error ? a.message : "An unexpected error occurred"
512
512
  });
513
513
  }
514
514
  }, G = async () => {
515
515
  try {
516
- N({ status: "loading" });
516
+ h({ status: "loading" });
517
517
  const l = await Q({
518
518
  variables: {
519
- [g]: d
519
+ [f]: d
520
520
  }
521
521
  });
522
522
  if (l.errors) {
523
- console.error("GraphQL errors:", l.errors), N({
523
+ console.error("GraphQL errors:", l.errors), h({
524
524
  status: "error",
525
- message: l.errors.map((t) => t.message).join(", ")
525
+ message: l.errors.map((a) => a.message).join(", ")
526
526
  });
527
527
  return;
528
528
  }
529
- N({
529
+ h({
530
530
  status: "success",
531
531
  message: `${u(s.name)} deleted successfully!`
532
532
  }), setTimeout(() => {
533
- U(`/admin/data/${I(s.pluralName)}`);
533
+ U(`${c}/${I(s.pluralName)}`);
534
534
  }, 1500);
535
535
  } catch (l) {
536
- console.error("Error deleting record:", l), N({
536
+ console.error("Error deleting record:", l), h({
537
537
  status: "error",
538
538
  message: l instanceof Error ? l.message : "An unexpected error occurred"
539
539
  });
@@ -542,7 +542,7 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
542
542
  return /* @__PURE__ */ e("div", { className: "space-y-6", children: [
543
543
  /* @__PURE__ */ e("div", { className: "mb-8", children: [
544
544
  /* @__PURE__ */ e("nav", { className: "flex mb-6", "aria-label": "Breadcrumb", children: /* @__PURE__ */ e("ol", { className: "flex items-center space-x-4", children: [
545
- /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(p, { to: "/admin/data", className: "text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400", children: "Data Browser" }, void 0, !1, {
545
+ /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(x, { to: c, className: "text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400", children: "Data Browser" }, void 0, !1, {
546
546
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
547
547
  lineNumber: 620,
548
548
  columnNumber: 17
@@ -585,9 +585,9 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
585
585
  this
586
586
  ),
587
587
  /* @__PURE__ */ e(
588
- p,
588
+ x,
589
589
  {
590
- to: `/admin/data/${I(s.pluralName)}`,
590
+ to: `${c}/${I(s.pluralName)}`,
591
591
  className: "ml-4 text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400",
592
592
  children: u(s.pluralName)
593
593
  },
@@ -710,7 +710,7 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
710
710
  }, this),
711
711
  D && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-gray-600 dark:bg-gray-900 bg-opacity-50 dark:bg-opacity-75 overflow-y-auto h-full w-full z-50 flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "bg-white dark:bg-gray-800 p-6 rounded-lg shadow-xl max-w-md w-full mx-4", children: [
712
712
  /* @__PURE__ */ e("div", { className: "flex items-center", children: [
713
- /* @__PURE__ */ e("div", { className: "flex-shrink-0", children: /* @__PURE__ */ e(h, { className: "h-6 w-6 text-red-600" }, void 0, !1, {
713
+ /* @__PURE__ */ e("div", { className: "flex-shrink-0", children: /* @__PURE__ */ e(p, { className: "h-6 w-6 text-red-600" }, void 0, !1, {
714
714
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
715
715
  lineNumber: 682,
716
716
  columnNumber: 19
@@ -810,7 +810,7 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
810
810
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
811
811
  lineNumber: 730,
812
812
  columnNumber: 19
813
- }, this) : n.status === "error" || r.status === "error" ? /* @__PURE__ */ e(h, { className: "h-5 w-5 text-red-400" }, void 0, !1, {
813
+ }, this) : n.status === "error" || r.status === "error" ? /* @__PURE__ */ e(p, { className: "h-5 w-5 text-red-400" }, void 0, !1, {
814
814
  fileName: "/Users/justinhandley/IdeaProjects/nestled_template/libs/admin-data/src/lib/pages/AdminDataEditPage.tsx",
815
815
  lineNumber: 732,
816
816
  columnNumber: 19
@@ -865,7 +865,7 @@ function de({ model: s, id: d, basePath: v, formTheme: y }) {
865
865
  submit: q,
866
866
  disabled: n.status === "loading" || r.status === "loading",
867
867
  defaultValues: o,
868
- theme: y
868
+ theme: j
869
869
  },
870
870
  void 0,
871
871
  !1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestledjs/data-browser",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Universal admin data browser for Nestled framework projects with full CRUD operations",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -39,7 +39,7 @@
39
39
  "@heroicons/react": "^2.0.0",
40
40
  "@nestledjs/forms": "^0.5.0",
41
41
  "@nestledjs/helpers": "^0.1.0",
42
- "@nestledjs/shared-components": "^0.1.4",
42
+ "@nestledjs/shared-components": "^0.1.5",
43
43
  "react": "^19.0.0",
44
44
  "react-router": "^7.0.0"
45
45
  },