@brightsideoy/kama 1.0.0-alpha.10 → 1.0.0-alpha.12

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.
@@ -0,0 +1,486 @@
1
+ import e from "node:fs";
2
+ import t from "node:path";
3
+ //#region scripts/build-seed.ts
4
+ var n = [
5
+ {
6
+ city: "Tallinn",
7
+ area: "Harju County",
8
+ country: "Estonia",
9
+ zip: "10111",
10
+ lat: 59.437,
11
+ lng: 24.7535,
12
+ tz: "Europe/Tallinn"
13
+ },
14
+ {
15
+ city: "London",
16
+ area: "Greater London",
17
+ country: "United Kingdom",
18
+ zip: "EC1A 1BB",
19
+ lat: 51.5074,
20
+ lng: -.1278,
21
+ tz: "Europe/London"
22
+ },
23
+ {
24
+ city: "New York",
25
+ area: "NY",
26
+ country: "United States",
27
+ zip: "10001",
28
+ lat: 40.7128,
29
+ lng: -74.006,
30
+ tz: "America/New_York"
31
+ },
32
+ {
33
+ city: "Berlin",
34
+ area: "Berlin State",
35
+ country: "Germany",
36
+ zip: "10115",
37
+ lat: 52.52,
38
+ lng: 13.405,
39
+ tz: "Europe/Berlin"
40
+ },
41
+ {
42
+ city: "Tokyo",
43
+ area: "Kanto",
44
+ country: "Japan",
45
+ zip: "100-0001",
46
+ lat: 35.6762,
47
+ lng: 139.6503,
48
+ tz: "Asia/Tokyo"
49
+ }
50
+ ], r = [
51
+ "Main St",
52
+ "Oak Ave",
53
+ "Narva mnt",
54
+ "Broadway",
55
+ "High St",
56
+ "Pärnu mnt",
57
+ "Sunset Blvd",
58
+ "Park Ave"
59
+ ], i = [
60
+ "Emma",
61
+ "Liam",
62
+ "Olivia",
63
+ "Noah",
64
+ "Ava",
65
+ "Oliver",
66
+ "Isabella",
67
+ "Elijah",
68
+ "Sophia",
69
+ "William",
70
+ "Mia",
71
+ "James",
72
+ "Charlotte",
73
+ "Benjamin",
74
+ "Amelia",
75
+ "Lucas",
76
+ "Harper",
77
+ "Henry",
78
+ "Evelyn",
79
+ "Alexander"
80
+ ], a = [
81
+ "Smith",
82
+ "Johnson",
83
+ "Williams",
84
+ "Brown",
85
+ "Jones",
86
+ "Garcia",
87
+ "Miller",
88
+ "Davis",
89
+ "Rodriguez",
90
+ "Martinez",
91
+ "Hernandez",
92
+ "Lopez",
93
+ "Gonzalez",
94
+ "Wilson",
95
+ "Anderson",
96
+ "Thomas",
97
+ "Taylor",
98
+ "Moore",
99
+ "Jackson",
100
+ "Martin"
101
+ ], o = [
102
+ "Senior Engineer",
103
+ "Product Manager",
104
+ "Lead Designer",
105
+ "Content Strategist",
106
+ "DevOps Specialist",
107
+ "Marketing Director",
108
+ "Data Scientist",
109
+ "System Architect"
110
+ ], s = [
111
+ "Corporate Tech Summit",
112
+ "Developer Conference",
113
+ "Design System Workshop",
114
+ "API Masterclass",
115
+ "AI & Edge Computing Expo",
116
+ "Product Design Forum",
117
+ "Vue & TypeScript Meetup"
118
+ ], c = [
119
+ "Future of Web Development",
120
+ "Mastering Vue 3 and TypeScript",
121
+ "SQLite Performance Strategies",
122
+ "Design Systems at Scale",
123
+ "Building Scalable Architecture",
124
+ "Optimizing CMS Workflows",
125
+ "Tailwind CSS Tricks",
126
+ "Modern API Security Patterns",
127
+ "Edge Computing Explained",
128
+ "Micro-Frontends in 2026",
129
+ "State Management Patterns",
130
+ "Headless CMS Tradeoffs"
131
+ ], l = [
132
+ "Comprehensive Guide to",
133
+ "Deep Dive into",
134
+ "Secrets of",
135
+ "Practical Intro to",
136
+ "Advanced Tips for",
137
+ "The Complete Handbook of",
138
+ "Understanding",
139
+ "Future Outlook of"
140
+ ], u = [
141
+ {
142
+ id: 1,
143
+ title: "Home",
144
+ slug: "home",
145
+ parentId: "NULL"
146
+ },
147
+ {
148
+ id: 2,
149
+ title: "About Us",
150
+ slug: "about-us",
151
+ parentId: 1
152
+ },
153
+ {
154
+ id: 3,
155
+ title: "Leadership & Team",
156
+ slug: "leadership",
157
+ parentId: 2
158
+ },
159
+ {
160
+ id: 4,
161
+ title: "Our Mission & Values",
162
+ slug: "mission",
163
+ parentId: 2
164
+ },
165
+ {
166
+ id: 5,
167
+ title: "Services",
168
+ slug: "services",
169
+ parentId: 1
170
+ },
171
+ {
172
+ id: 6,
173
+ title: "Enterprise Consulting",
174
+ slug: "enterprise-consulting",
175
+ parentId: 5
176
+ },
177
+ {
178
+ id: 7,
179
+ title: "Cloud Architecture",
180
+ slug: "cloud-architecture",
181
+ parentId: 5
182
+ },
183
+ {
184
+ id: 8,
185
+ title: "Solutions",
186
+ slug: "solutions",
187
+ parentId: 1
188
+ },
189
+ {
190
+ id: 9,
191
+ title: "Digital Transformation",
192
+ slug: "digital-transformation",
193
+ parentId: 8
194
+ },
195
+ {
196
+ id: 10,
197
+ title: "Careers",
198
+ slug: "careers",
199
+ parentId: 1
200
+ },
201
+ {
202
+ id: 11,
203
+ title: "Open Positions",
204
+ slug: "open-positions",
205
+ parentId: 10
206
+ },
207
+ {
208
+ id: 12,
209
+ title: "News & Press",
210
+ slug: "news",
211
+ parentId: 1
212
+ },
213
+ {
214
+ id: 13,
215
+ title: "Investor Relations",
216
+ slug: "investors",
217
+ parentId: 1
218
+ },
219
+ {
220
+ id: 14,
221
+ title: "Contact",
222
+ slug: "contact",
223
+ parentId: 1
224
+ },
225
+ {
226
+ id: 15,
227
+ title: "Global Offices",
228
+ slug: "offices",
229
+ parentId: 1
230
+ },
231
+ {
232
+ id: 16,
233
+ title: "Sustainability",
234
+ slug: "sustainability",
235
+ parentId: 2
236
+ },
237
+ {
238
+ id: 17,
239
+ title: "Partners",
240
+ slug: "partners",
241
+ parentId: 1
242
+ }
243
+ ], d = [
244
+ {
245
+ id: 20,
246
+ title: "Store Home",
247
+ slug: "home",
248
+ parentId: "NULL"
249
+ },
250
+ {
251
+ id: 21,
252
+ title: "Product Catalog",
253
+ slug: "catalog",
254
+ parentId: 20
255
+ },
256
+ {
257
+ id: 22,
258
+ title: "Bulk Ordering",
259
+ slug: "bulk-orders",
260
+ parentId: 20
261
+ },
262
+ {
263
+ id: 23,
264
+ title: "My Account",
265
+ slug: "account",
266
+ parentId: 20
267
+ },
268
+ {
269
+ id: 24,
270
+ title: "Support & Docs",
271
+ slug: "support",
272
+ parentId: 20
273
+ },
274
+ {
275
+ id: 25,
276
+ title: "API Documentation",
277
+ slug: "api",
278
+ parentId: 24
279
+ },
280
+ {
281
+ id: 26,
282
+ title: "Pricing",
283
+ slug: "pricing",
284
+ parentId: 20
285
+ },
286
+ {
287
+ id: 27,
288
+ title: "Enterprise Licensing",
289
+ slug: "enterprise-licensing",
290
+ parentId: 26
291
+ }
292
+ ], f = [
293
+ {
294
+ id: 30,
295
+ title: "Privacy Policy",
296
+ slug: "privacy-policy",
297
+ parentId: "NULL"
298
+ },
299
+ {
300
+ id: 31,
301
+ title: "Terms of Service",
302
+ slug: "terms-of-service",
303
+ parentId: "NULL"
304
+ },
305
+ {
306
+ id: 32,
307
+ title: "Cookie Policy",
308
+ slug: "cookie-policy",
309
+ parentId: "NULL"
310
+ },
311
+ {
312
+ id: 33,
313
+ title: "Refund Policy",
314
+ slug: "refund-policy",
315
+ parentId: "NULL"
316
+ },
317
+ {
318
+ id: 34,
319
+ title: "Security Hub",
320
+ slug: "security",
321
+ parentId: "NULL"
322
+ }
323
+ ];
324
+ function p(e) {
325
+ return `${l[e % l.length]} ${c[e * 7 % c.length]} #${e}`;
326
+ }
327
+ function m(e = 2024) {
328
+ let t = new Date(e, 0, 1).getTime(), n = t + Math.random() * (Date.now() - t);
329
+ return new Date(n).toISOString();
330
+ }
331
+ function h(e = 2024, t = 2026) {
332
+ let n = new Date(e, 0, 1).getTime(), r = new Date(t, 11, 31, 23, 59, 59).getTime(), i = n + Math.random() * (r - n);
333
+ return new Date(i).toISOString();
334
+ }
335
+ function g(e) {
336
+ return e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
337
+ }
338
+ function _(e) {
339
+ return e.replace(/\\/g, "\\\\").replace(/'/g, "''");
340
+ }
341
+ function v(e, t, n, r, i = 100) {
342
+ for (let a = 0; a < r.length; a += i) {
343
+ let o = r.slice(a, a + i);
344
+ e.push(`INSERT INTO ${t} (${n.join(", ")}) VALUES\n ${o.join(",\n ")};`);
345
+ }
346
+ }
347
+ function y() {
348
+ console.log("⚡ Generating Massive Cloudflare D1-optimized seed.sql file...");
349
+ let c = [];
350
+ c.push("PRAGMA foreign_keys = OFF;"), [
351
+ "sessions",
352
+ "user_accounts",
353
+ "node_revisions",
354
+ "content_blocks",
355
+ "tree_nodes",
356
+ "node_channels",
357
+ "node_relations",
358
+ "channel_trees",
359
+ "content_nodes",
360
+ "trees",
361
+ "channels",
362
+ "users"
363
+ ].forEach((e) => c.push(`DELETE FROM ${e};`));
364
+ let l = "usr_admin_01";
365
+ c.push(`INSERT INTO users (id, email, name, globalRole) VALUES ('${l}', 'admin@example.com', 'Superadmin User', 'superadmin');`), c.push(`INSERT INTO user_accounts (id, userId, provider, providerAccountId, passwordHash) VALUES ('acc_admin_01', '${l}', 'credentials', 'admin@example.com', '\$2a\$10\$w82H/kG7k8bW8Vq5i4.D/.7n0s8s2h2X3f0j1k2l3m4n5o6p7q8r9');`), c.push(`INSERT INTO channels (id, key, label, channelType, defaultLanguage, isHidden, createdById) VALUES (1, 'corporate', 'Corporate Website', 'website', 'en', 0, '${l}');`), c.push(`INSERT INTO channels (id, key, label, channelType, defaultLanguage, isHidden, createdById) VALUES (2, 'campaigns', 'Campaigns', 'website', 'en', 0, '${l}');`), c.push(`INSERT INTO channels (id, key, label, channelType, defaultLanguage, isHidden, createdById) VALUES (3, 'store', 'Storefront', 'ecommerce', 'en', 0, '${l}');`), c.push(`INSERT INTO trees (id, key, label, treeType, channelId, createdById) VALUES (1, 'main-nav', 'Corporate Nav', 'navigation', 1, '${l}');`), c.push(`INSERT INTO trees (id, key, label, treeType, channelId, createdById) VALUES (2, 'legal-nav', 'Legal Nav', 'navigation', 1, '${l}');`), c.push(`INSERT INTO trees (id, key, label, treeType, channelId, createdById) VALUES (3, 'b2b-nav', 'Store Nav', 'navigation', 3, '${l}');`), c.push("INSERT INTO channel_trees (channelId, treeId, key) VALUES (1, 1, 'main');"), c.push("INSERT INTO channel_trees (channelId, treeId, key) VALUES (1, 2, 'footer');"), c.push("INSERT INTO channel_trees (channelId, treeId, key) VALUES (3, 3, 'main');");
366
+ let y = [], b = [], x = [], S = [], C = [];
367
+ function w(e, t) {
368
+ let n = `<h1>${t}</h1><p>Detailed overview regarding ${t}. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>`, r = _(JSON.stringify({
369
+ content: n,
370
+ html: n,
371
+ body: n,
372
+ text: n
373
+ }));
374
+ S.push(`(${e}, 'content', 'text', '${r}', 0, 1)`), S.push(`(${e}, 'content', 'text', '${r}', 0, 0)`);
375
+ }
376
+ [
377
+ ...u.map((e) => ({
378
+ ...e,
379
+ cId: 1,
380
+ tId: 1
381
+ })),
382
+ ...d.map((e) => ({
383
+ ...e,
384
+ cId: 3,
385
+ tId: 3
386
+ })),
387
+ ...f.map((e) => ({
388
+ ...e,
389
+ cId: 1,
390
+ tId: 2
391
+ }))
392
+ ].forEach((e, t) => {
393
+ let n = m(2024), r = e.parentId === "NULL", i = JSON.stringify({
394
+ channelId: e.cId,
395
+ channels: [e.cId],
396
+ menuTitle: e.title,
397
+ layoutId: r ? "single-column" : "inherit"
398
+ });
399
+ y.push(`(${e.id}, 'page', '${_(e.title)}', '${e.slug}', 0, 'published', '{}', '${_(i)}', '${_(i)}', '${_(i)}', '${n}', '${l}', '${l}', '${n}', '${n}')`), b.push(`(${e.id}, ${e.cId})`), x.push(`(${e.tId}, ${e.id}, ${e.parentId}, ${t + 1})`), w(e.id, e.title);
400
+ });
401
+ let T = 100, E = [];
402
+ console.log("Generating 500 People...");
403
+ for (let e = 1; e <= 500; e++) {
404
+ let t = i[e % i.length], n = a[e % a.length], r = o[e % o.length], s = `${t} ${n}`, c = g(s) + `-${e}`, u = m(2024), d = JSON.stringify({
405
+ firstName: t,
406
+ lastName: n,
407
+ position: r,
408
+ channels: [1]
409
+ });
410
+ y.push(`(${T}, 'person', '${_(s)}', '${c}', 0, 'published', '{}', '${_(d)}', '${_(d)}', '${_(d)}', '${u}', '${l}', '${l}', '${u}', '${u}')`), b.push(`(${T}, 1)`), E.push(T), T++;
411
+ }
412
+ console.log("Generating 500 Addresses...");
413
+ for (let e = 1; e <= 500; e++) {
414
+ let t = n[e % n.length], i = `${e * 12 % 199 + 1} ${r[e % r.length]}`, a = `${t.city} Hub #${e}`, o = `address-${t.city.toLowerCase()}-${e}`, s = m(2024), c = JSON.stringify({
415
+ street: i,
416
+ city: t.city,
417
+ country: t.country,
418
+ zip: t.zip,
419
+ channels: [1]
420
+ });
421
+ y.push(`(${T}, 'address', '${_(a)}', '${o}', 0, 'published', '{}', '${_(c)}', '${_(c)}', '${_(c)}', '${s}', '${l}', '${l}', '${s}', '${s}')`), b.push(`(${T}, 1)`), T++;
422
+ }
423
+ console.log("Generating 4,000 Events...");
424
+ for (let e = 1; e <= 4e3; e++) {
425
+ let t = s[e % s.length], n = `${t} 2026 #${e}`, r = `event-${g(t)}-${e}`, i = m(2024), a = h(2024, 2027), o = JSON.stringify({
426
+ startTime: a,
427
+ channels: [1],
428
+ layoutId: "single-column"
429
+ });
430
+ y.push(`(${T}, 'event', '${_(n)}', '${r}', 0, 'published', '{}', '${_(o)}', '${_(o)}', '${_(o)}', '${i}', '${l}', '${l}', '${i}', '${i}')`), b.push(`(${T}, 1)`), w(T, n), T++;
431
+ }
432
+ console.log("Generating 4,000 Articles (and linking relations)...");
433
+ for (let e = 1; e <= 4e3; e++) {
434
+ let t = p(e), n = `${g(t)}-${e}`, r = m(2024), i = r.split("T")[0], a = e % 2 + 1, o = [];
435
+ for (let t = 0; t < a; t++) {
436
+ let n = E[(e + t * 7) % E.length];
437
+ C.push(`(${T}, ${n}, 'authors', ${t})`), o.push(n);
438
+ }
439
+ let s = JSON.stringify({
440
+ articleDate: i,
441
+ authors: o,
442
+ channels: [1],
443
+ layoutId: "single-column"
444
+ });
445
+ y.push(`(${T}, 'article', '${_(t)}', '${n}', 0, 'published', '{}', '${_(s)}', '${_(s)}', '${_(s)}', '${r}', '${l}', '${l}', '${r}', '${r}')`), b.push(`(${T}, 1)`), w(T, t), T++;
446
+ }
447
+ console.log("Writing Batches..."), v(c, "content_nodes", [
448
+ "id",
449
+ "contentType",
450
+ "title",
451
+ "slug",
452
+ "isHidden",
453
+ "status",
454
+ "disabledRegionsJson",
455
+ "dataJson",
456
+ "draftDataJson",
457
+ "publishedDataJson",
458
+ "publishedAt",
459
+ "createdById",
460
+ "updatedById",
461
+ "createdAt",
462
+ "updatedAt"
463
+ ], y, 100), v(c, "node_channels", ["nodeId", "channelId"], b, 200), v(c, "tree_nodes", [
464
+ "treeId",
465
+ "contentId",
466
+ "parentId",
467
+ "sortOrder"
468
+ ], x, 50), v(c, "content_blocks", [
469
+ "contentId",
470
+ "region",
471
+ "elementType",
472
+ "dataJson",
473
+ "sortOrder",
474
+ "isDraft"
475
+ ], S, 200), v(c, "node_relations", [
476
+ "sourceNodeId",
477
+ "targetNodeId",
478
+ "fieldKey",
479
+ "sortOrder"
480
+ ], C, 200), c.push("PRAGMA foreign_keys = ON;");
481
+ let D = t.resolve(process.cwd(), "./seed.sql");
482
+ e.writeFileSync(D, c.join("\n"), "utf-8"), console.log(`✅ Success! Scaled Seed SQL generated to ${D}.`);
483
+ }
484
+ y();
485
+ //#endregion
486
+ export { y as generateSqlFile };
@@ -23914,7 +23914,7 @@ gx.get("/", async (e) => {
23914
23914
  status: "LOWER(cn.status)",
23915
23915
  isHidden: "cn.isHidden"
23916
23916
  };
23917
- b[c] && (y = b[c]);
23917
+ b[c] ? y = b[c] : c && c.length > 0 && (y = `json_extract(CASE WHEN cn.draftDataJson IS NOT NULL AND cn.draftDataJson != '' THEN cn.draftDataJson WHEN cn.dataJson IS NOT NULL AND cn.dataJson != '' THEN cn.dataJson ELSE '{}' END, '$.${c.replace(/[^a-zA-Z0-9_]/g, "")}')`);
23918
23918
  let x = `
23919
23919
  WITH filtered_nodes AS (
23920
23920
  SELECT cn.* FROM content_nodes cn ${g} ORDER BY ${y} ${l} LIMIT ? OFFSET ?
@@ -23941,7 +23941,7 @@ gx.get("/", async (e) => {
23941
23941
  (SELECT path FROM node_routes nr WHERE nr.nodeId = fn.id AND isCanonical = 1 LIMIT 1) as routePath
23942
23942
  FROM filtered_nodes fn
23943
23943
  LEFT JOIN node_asset_counts nac ON fn.id = nac.nodeId
23944
- ORDER BY ${y.replace("cn.", "fn.")} ${l}
23944
+ ORDER BY ${y.replace(/cn\./g, "fn.")} ${l}
23945
23945
  `, S = [
23946
23946
  ...m,
23947
23947
  f,
@@ -24299,7 +24299,7 @@ gx.get("/", async (e) => {
24299
24299
  } catch {}
24300
24300
  return {
24301
24301
  version: e.version,
24302
- publishedAt: t || (/* @__PURE__ */ new Date()).toISOString(),
24302
+ publishedAt: t || new DatetoISOString(),
24303
24303
  createdById: e.createdById
24304
24304
  };
24305
24305
  });
@@ -24335,6 +24335,32 @@ gx.get("/", async (e) => {
24335
24335
  success: !0,
24336
24336
  restoredVersion: r
24337
24337
  });
24338
+ }), gx.post("/:id/toggle-visibility", async (e) => {
24339
+ let t = e.get("db"), n = Number(e.req.param("id")), r = await e.req.json();
24340
+ if (isNaN(n)) return e.json({ error: "Invalid Node ID" }, 400);
24341
+ let i = +(r.isHidden === !0 || r.isHidden === 1 || r.isHidden === "true"), a = e.get("user")?.id || null, o = await t.prepare("SELECT draftDataJson, dataJson, publishedDataJson, isHidden, status FROM content_nodes WHERE id = ?").get(n);
24342
+ if (!o) return e.json({ error: "Node not found" }, 404);
24343
+ if (Number(o.isHidden) === i) return e.json({
24344
+ success: !0,
24345
+ isHidden: i
24346
+ });
24347
+ let s = "UPDATE content_nodes SET isHidden = ?, updatedById = ?, updatedAt = CURRENT_TIMESTAMP", c = [i, a], l = {};
24348
+ try {
24349
+ l = typeof o.draftDataJson == "string" ? JSON.parse(o.draftDataJson) : o.draftDataJson || {};
24350
+ } catch {}
24351
+ if (l.isHidden !== i && (l.isHidden = i, s += ", draftDataJson = ?", c.push(JSON.stringify(l))), o.status === "published" && o.dataJson) {
24352
+ let e = {};
24353
+ try {
24354
+ e = typeof o.dataJson == "string" ? JSON.parse(o.dataJson) : o.dataJson;
24355
+ } catch {}
24356
+ e.isHidden = i;
24357
+ let t = JSON.stringify(e);
24358
+ s += ", dataJson = ?, publishedDataJson = ?", c.push(t, t);
24359
+ }
24360
+ return s += " WHERE id = ?", c.push(n), await t.prepare(s).run(...c), await $b(e).clear(), await hx(t), new mx(e.env).purgeNode(e, t, n, !0), e.json({
24361
+ success: !0,
24362
+ isHidden: i
24363
+ });
24338
24364
  });
24339
24365
  var Dx = new e();
24340
24366
  function Ox(e, t = null) {
package/dist/index.html CHANGED
@@ -6,8 +6,8 @@
6
6
  <title>KAMA</title>
7
7
  <link rel="icon" href="/favicon.png">
8
8
  <link rel="apple-touch-icon" sizes="180x180" href="/favicon.png">
9
- <script type="module" crossorigin src="/assets/index-DX98CiK-.js"></script>
10
- <link rel="stylesheet" crossorigin href="/assets/index-Bzbme3Ob.css">
9
+ <script type="module" crossorigin src="/assets/index-De9O-dAG.js"></script>
10
+ <link rel="stylesheet" crossorigin href="/assets/index-CGLx9oqF.css">
11
11
  </head>
12
12
  <body>
13
13
  <div id="app"></div>
package/dist/index.js CHANGED
@@ -24102,7 +24102,7 @@ gx.get("/", async (e) => {
24102
24102
  status: "LOWER(cn.status)",
24103
24103
  isHidden: "cn.isHidden"
24104
24104
  };
24105
- b[c] && (y = b[c]);
24105
+ b[c] ? y = b[c] : c && c.length > 0 && (y = `json_extract(CASE WHEN cn.draftDataJson IS NOT NULL AND cn.draftDataJson != '' THEN cn.draftDataJson WHEN cn.dataJson IS NOT NULL AND cn.dataJson != '' THEN cn.dataJson ELSE '{}' END, '$.${c.replace(/[^a-zA-Z0-9_]/g, "")}')`);
24106
24106
  let x = `
24107
24107
  WITH filtered_nodes AS (
24108
24108
  SELECT cn.* FROM content_nodes cn ${g} ORDER BY ${y} ${l} LIMIT ? OFFSET ?
@@ -24129,7 +24129,7 @@ gx.get("/", async (e) => {
24129
24129
  (SELECT path FROM node_routes nr WHERE nr.nodeId = fn.id AND isCanonical = 1 LIMIT 1) as routePath
24130
24130
  FROM filtered_nodes fn
24131
24131
  LEFT JOIN node_asset_counts nac ON fn.id = nac.nodeId
24132
- ORDER BY ${y.replace("cn.", "fn.")} ${l}
24132
+ ORDER BY ${y.replace(/cn\./g, "fn.")} ${l}
24133
24133
  `, S = [
24134
24134
  ...m,
24135
24135
  f,
@@ -24487,7 +24487,7 @@ gx.get("/", async (e) => {
24487
24487
  } catch {}
24488
24488
  return {
24489
24489
  version: e.version,
24490
- publishedAt: t || (/* @__PURE__ */ new Date()).toISOString(),
24490
+ publishedAt: t || new DatetoISOString(),
24491
24491
  createdById: e.createdById
24492
24492
  };
24493
24493
  });
@@ -24523,6 +24523,32 @@ gx.get("/", async (e) => {
24523
24523
  success: !0,
24524
24524
  restoredVersion: r
24525
24525
  });
24526
+ }), gx.post("/:id/toggle-visibility", async (e) => {
24527
+ let t = e.get("db"), n = Number(e.req.param("id")), r = await e.req.json();
24528
+ if (isNaN(n)) return e.json({ error: "Invalid Node ID" }, 400);
24529
+ let i = +(r.isHidden === !0 || r.isHidden === 1 || r.isHidden === "true"), a = e.get("user")?.id || null, o = await t.prepare("SELECT draftDataJson, dataJson, publishedDataJson, isHidden, status FROM content_nodes WHERE id = ?").get(n);
24530
+ if (!o) return e.json({ error: "Node not found" }, 404);
24531
+ if (Number(o.isHidden) === i) return e.json({
24532
+ success: !0,
24533
+ isHidden: i
24534
+ });
24535
+ let s = "UPDATE content_nodes SET isHidden = ?, updatedById = ?, updatedAt = CURRENT_TIMESTAMP", c = [i, a], l = {};
24536
+ try {
24537
+ l = typeof o.draftDataJson == "string" ? JSON.parse(o.draftDataJson) : o.draftDataJson || {};
24538
+ } catch {}
24539
+ if (l.isHidden !== i && (l.isHidden = i, s += ", draftDataJson = ?", c.push(JSON.stringify(l))), o.status === "published" && o.dataJson) {
24540
+ let e = {};
24541
+ try {
24542
+ e = typeof o.dataJson == "string" ? JSON.parse(o.dataJson) : o.dataJson;
24543
+ } catch {}
24544
+ e.isHidden = i;
24545
+ let t = JSON.stringify(e);
24546
+ s += ", dataJson = ?, publishedDataJson = ?", c.push(t, t);
24547
+ }
24548
+ return s += " WHERE id = ?", c.push(n), await t.prepare(s).run(...c), await $b(e).clear(), await hx(t), new mx(e.env).purgeNode(e, t, n, !0), e.json({
24549
+ success: !0,
24550
+ isHidden: i
24551
+ });
24526
24552
  });
24527
24553
  //#endregion
24528
24554
  //#region server/routes/admin/trees.ts
@@ -30,7 +30,7 @@ async function f() {
30
30
  if (n(f)) l = (await import(t(f).href)).compileDefinitions;
31
31
  else if (n(p)) l = (await import(t(p).href)).compileDefinitions;
32
32
  else try {
33
- l = (await import("./dist-CErcWOwp.js")).compileDefinitions;
33
+ l = (await import("./dist-kIJlDMvm.js")).compileDefinitions;
34
34
  } catch (e) {
35
35
  console.error("\x1B[31m ✖\x1B[0m \x1B[31mCould not resolve Kama Schema Engine:\x1B[0m", e), process.exit(1);
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightsideoy/kama",
3
- "version": "1.0.0-alpha.10",
3
+ "version": "1.0.0-alpha.12",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -24,6 +24,8 @@
24
24
  "bundle:definitions": "node bin/cli.js bundle",
25
25
  "build:schema": "tsx scripts/build-schema.ts",
26
26
  "build:seed": "tsx scripts/build-seed.ts",
27
+ "seed": "npm run seed:local",
28
+ "seed:local": "tsx scripts/build-seed.ts && sqlite3 kama.db < seed.sql",
27
29
  "build:server": "vite build",
28
30
  "build:ui": "vite build --config vite.config.ui.ts",
29
31
  "build": "npm run bundle:definitions && npm run build:schema && npm run build:server && npm run build:ui",