@brightsideoy/kama 1.0.0-alpha.11 → 1.0.0-alpha.13
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/bin/cli.js +51 -32
- package/dist/assets/{index-BVkEzCNs.js → index-B1ogCRCg.js} +1 -1
- package/dist/build-seed.js +37 -28
- package/dist/index.html +1 -1
- package/package.json +3 -2
package/dist/build-seed.js
CHANGED
|
@@ -325,12 +325,12 @@ function p(e) {
|
|
|
325
325
|
return `${l[e % l.length]} ${c[e * 7 % c.length]} #${e}`;
|
|
326
326
|
}
|
|
327
327
|
function m(e = 2024) {
|
|
328
|
-
let t = new Date(e, 0, 1).getTime()
|
|
329
|
-
return new Date(
|
|
328
|
+
let t = new Date(e, 0, 1).getTime();
|
|
329
|
+
return new Date(t + Math.random() * (Date.now() - t)).toISOString();
|
|
330
330
|
}
|
|
331
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()
|
|
333
|
-
return new Date(
|
|
332
|
+
let n = new Date(e, 0, 1).getTime(), r = new Date(t, 11, 31, 23, 59, 59).getTime();
|
|
333
|
+
return new Date(n + Math.random() * (r - n)).toISOString();
|
|
334
334
|
}
|
|
335
335
|
function g(e) {
|
|
336
336
|
return e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
@@ -338,14 +338,14 @@ function g(e) {
|
|
|
338
338
|
function _(e) {
|
|
339
339
|
return e.replace(/\\/g, "\\\\").replace(/'/g, "''");
|
|
340
340
|
}
|
|
341
|
-
function v(e, t, n, r, i =
|
|
341
|
+
function v(e, t, n, r, i = 50) {
|
|
342
342
|
for (let a = 0; a < r.length; a += i) {
|
|
343
343
|
let o = r.slice(a, a + i);
|
|
344
344
|
e.push(`INSERT INTO ${t} (${n.join(", ")}) VALUES\n ${o.join(",\n ")};`);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
function y() {
|
|
348
|
-
console.log("⚡ Generating Massive Cloudflare D1-optimized seed
|
|
348
|
+
console.log("⚡ Generating Massive Cloudflare D1-optimized seed chunks...");
|
|
349
349
|
let c = [];
|
|
350
350
|
c.push("PRAGMA foreign_keys = OFF;"), [
|
|
351
351
|
"sessions",
|
|
@@ -365,7 +365,7 @@ function y() {
|
|
|
365
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
366
|
let y = [], b = [], x = [], S = [], C = [];
|
|
367
367
|
function w(e, t) {
|
|
368
|
-
let n = `<h1>${t}</h1><p>Detailed overview regarding ${t}. Lorem ipsum dolor sit amet
|
|
368
|
+
let n = `<h1>${t}</h1><p>Detailed overview regarding ${t}. Lorem ipsum dolor sit amet.</p>`, r = _(JSON.stringify({
|
|
369
369
|
content: n,
|
|
370
370
|
html: n,
|
|
371
371
|
body: n,
|
|
@@ -401,48 +401,50 @@ function y() {
|
|
|
401
401
|
let T = 100, E = [];
|
|
402
402
|
console.log("Generating 500 People...");
|
|
403
403
|
for (let e = 1; e <= 500; e++) {
|
|
404
|
-
let t = i[e % i.length], n = a[e % a.length], r =
|
|
404
|
+
let t = i[e % i.length], n = a[e % a.length], r = `${t} ${n}`, s = m(2024), c = JSON.stringify({
|
|
405
405
|
firstName: t,
|
|
406
406
|
lastName: n,
|
|
407
|
-
position:
|
|
407
|
+
position: o[e % o.length],
|
|
408
408
|
channels: [1]
|
|
409
409
|
});
|
|
410
|
-
y.push(`(${T}, 'person', '${_(
|
|
410
|
+
y.push(`(${T}, 'person', '${_(r)}', '${g(r) + `-${e}`}', 0, 'published', '{}', '${_(c)}', '${_(c)}', '${_(c)}', '${s}', '${l}', '${l}', '${s}', '${s}')`), b.push(`(${T}, 1)`), E.push(T), T++;
|
|
411
411
|
}
|
|
412
412
|
console.log("Generating 500 Addresses...");
|
|
413
413
|
for (let e = 1; e <= 500; e++) {
|
|
414
|
-
let t = n[e % n.length], i = `${e * 12 % 199 + 1} ${r[e % r.length]}`,
|
|
415
|
-
street:
|
|
414
|
+
let t = n[e % n.length], i = t.lat + (Math.random() - .5) * .15, a = t.lng + (Math.random() - .5) * .15, o = `${e * 12 % 199 + 1} ${r[e % r.length]}`, s = m(2024), c = JSON.stringify({
|
|
415
|
+
street: o,
|
|
416
416
|
city: t.city,
|
|
417
417
|
country: t.country,
|
|
418
418
|
zip: t.zip,
|
|
419
|
+
lat: i,
|
|
420
|
+
lng: a,
|
|
419
421
|
channels: [1]
|
|
420
422
|
});
|
|
421
|
-
y.push(`(${T}, 'address', '${_(
|
|
423
|
+
y.push(`(${T}, 'address', '${_(`${t.city} Hub #${e}`)}', 'address-${t.city.toLowerCase()}-${e}', 0, 'published', '{}', '${_(c)}', '${_(c)}', '${_(c)}', '${s}', '${l}', '${l}', '${s}', '${s}')`), b.push(`(${T}, 1)`), T++;
|
|
422
424
|
}
|
|
423
425
|
console.log("Generating 4,000 Events...");
|
|
424
426
|
for (let e = 1; e <= 4e3; e++) {
|
|
425
|
-
let t = s[e % s.length], n = `${t} 2026 #${e}`, r =
|
|
426
|
-
startTime:
|
|
427
|
+
let t = s[e % s.length], n = `${t} 2026 #${e}`, r = m(2024), i = JSON.stringify({
|
|
428
|
+
startTime: h(2024, 2027),
|
|
427
429
|
channels: [1],
|
|
428
430
|
layoutId: "single-column"
|
|
429
431
|
});
|
|
430
|
-
y.push(`(${T}, 'event', '${_(n)}', '
|
|
432
|
+
y.push(`(${T}, 'event', '${_(n)}', 'event-${g(t)}-${e}', 0, 'published', '{}', '${_(i)}', '${_(i)}', '${_(i)}', '${r}', '${l}', '${l}', '${r}', '${r}')`), b.push(`(${T}, 1)`), w(T, n), T++;
|
|
431
433
|
}
|
|
432
434
|
console.log("Generating 4,000 Articles (and linking relations)...");
|
|
433
435
|
for (let e = 1; e <= 4e3; e++) {
|
|
434
|
-
let t = p(e), n =
|
|
435
|
-
for (let t = 0; t <
|
|
436
|
+
let t = p(e), n = m(2024), r = [];
|
|
437
|
+
for (let t = 0; t < e % 2 + 1; t++) {
|
|
436
438
|
let n = E[(e + t * 7) % E.length];
|
|
437
|
-
C.push(`(${T}, ${n}, 'authors', ${t})`),
|
|
439
|
+
C.push(`(${T}, ${n}, 'authors', ${t})`), r.push(n);
|
|
438
440
|
}
|
|
439
|
-
let
|
|
440
|
-
articleDate:
|
|
441
|
-
authors:
|
|
441
|
+
let i = JSON.stringify({
|
|
442
|
+
articleDate: n.split("T")[0],
|
|
443
|
+
authors: r,
|
|
442
444
|
channels: [1],
|
|
443
445
|
layoutId: "single-column"
|
|
444
446
|
});
|
|
445
|
-
y.push(`(${T}, 'article', '${_(t)}', '${
|
|
447
|
+
y.push(`(${T}, 'article', '${_(t)}', '${g(t)}-${e}', 0, 'published', '{}', '${_(i)}', '${_(i)}', '${_(i)}', '${n}', '${l}', '${l}', '${n}', '${n}')`), b.push(`(${T}, 1)`), w(T, t), T++;
|
|
446
448
|
}
|
|
447
449
|
console.log("Writing Batches..."), v(c, "content_nodes", [
|
|
448
450
|
"id",
|
|
@@ -460,7 +462,7 @@ function y() {
|
|
|
460
462
|
"updatedById",
|
|
461
463
|
"createdAt",
|
|
462
464
|
"updatedAt"
|
|
463
|
-
], y,
|
|
465
|
+
], y, 50), v(c, "node_channels", ["nodeId", "channelId"], b, 100), v(c, "tree_nodes", [
|
|
464
466
|
"treeId",
|
|
465
467
|
"contentId",
|
|
466
468
|
"parentId",
|
|
@@ -472,14 +474,21 @@ function y() {
|
|
|
472
474
|
"dataJson",
|
|
473
475
|
"sortOrder",
|
|
474
476
|
"isDraft"
|
|
475
|
-
], S,
|
|
477
|
+
], S, 100), v(c, "node_relations", [
|
|
476
478
|
"sourceNodeId",
|
|
477
479
|
"targetNodeId",
|
|
478
480
|
"fieldKey",
|
|
479
481
|
"sortOrder"
|
|
480
|
-
], C,
|
|
481
|
-
let D = t.resolve(process.cwd(), "./seed.sql");
|
|
482
|
-
e.
|
|
482
|
+
], C, 100), c.push("PRAGMA foreign_keys = ON;");
|
|
483
|
+
let D = 0, O = t.resolve(process.cwd(), "./seed.sql");
|
|
484
|
+
e.existsSync(O) && e.unlinkSync(O);
|
|
485
|
+
for (let n = 0; n < c.length; n += 50) {
|
|
486
|
+
let r = c.slice(n, n + 50);
|
|
487
|
+
D++;
|
|
488
|
+
let i = String(D).padStart(3, "0"), a = t.resolve(process.cwd(), `./seed-${i}.sql`);
|
|
489
|
+
e.writeFileSync(a, r.join("\n\n"), "utf-8");
|
|
490
|
+
}
|
|
491
|
+
console.log(`✅ Success! Data split across ${D} files (seed-001.sql to seed-${String(D).padStart(3, "0")}.sql) for safe remote processing.`);
|
|
483
492
|
}
|
|
484
493
|
y();
|
|
485
494
|
//#endregion
|
package/dist/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
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-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-B1ogCRCg.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-CGLx9oqF.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightsideoy/kama",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -24,7 +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": "
|
|
27
|
+
"seed": "npm run seed:local",
|
|
28
|
+
"seed:local": "tsx scripts/build-seed.ts && sqlite3 kama.db < seed.sql",
|
|
28
29
|
"build:server": "vite build",
|
|
29
30
|
"build:ui": "vite build --config vite.config.ui.ts",
|
|
30
31
|
"build": "npm run bundle:definitions && npm run build:schema && npm run build:server && npm run build:ui",
|