@brightsideoy/kama 1.0.0-alpha.8 → 1.0.0-alpha.9

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.
@@ -26289,16 +26289,32 @@ function JS(e, t) {
26289
26289
  let n = e.toLowerCase();
26290
26290
  return n.endsWith(".jpg") || n.endsWith(".jpeg") ? "image/jpeg" : n.endsWith(".png") ? "image/png" : n.endsWith(".webp") ? "image/webp" : n.endsWith(".gif") ? "image/gif" : n.endsWith(".svg") ? "image/svg+xml" : n.endsWith(".pdf") ? "application/pdf" : n.endsWith(".mp4") ? "video/mp4" : "application/octet-stream";
26291
26291
  }
26292
- var YS = eb({
26292
+ var YS = [
26293
+ 320,
26294
+ 640,
26295
+ 768,
26296
+ 1024,
26297
+ 1352,
26298
+ 1920,
26299
+ 2560,
26300
+ 3840
26301
+ ];
26302
+ function XS(e) {
26303
+ if (!(!e || isNaN(e) || e <= 0)) return YS.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
26304
+ }
26305
+ var ZS = eb({
26293
26306
  method: "get",
26294
26307
  path: "/*",
26295
26308
  summary: "Serve & Optimize Media Assets",
26296
26309
  description: "Retrieves a media asset by its storage key. Optionally optimizes, resizes, and converts images on the fly via query parameters.",
26297
26310
  tags: ["Public Media API"],
26298
26311
  request: { query: X({
26299
- w: J().optional().openapi({ description: "Width in pixels for image optimization (e.g., \"800\")" }),
26300
- h: J().optional().openapi({ description: "Height in pixels for image optimization (e.g., \"600\")" }),
26301
- q: J().optional().openapi({ description: "Quality from 1-100 for image optimization (default: 80)" }),
26312
+ w: J().regex(/^\d+$/).refine((e) => parseInt(e, 10) <= 3840, { message: "Width cannot exceed 3840px" }).optional().openapi({ description: "Width in pixels (Snaps to nearest CDN breakpoint)" }),
26313
+ h: J().regex(/^\d+$/).refine((e) => parseInt(e, 10) <= 3840, { message: "Height cannot exceed 3840px" }).optional().openapi({ description: "Height in pixels (Max 3840)" }),
26314
+ q: J().regex(/^\d+$/).refine((e) => {
26315
+ let t = parseInt(e, 10);
26316
+ return t >= 1 && t <= 100;
26317
+ }, { message: "Quality must be between 1 and 100" }).optional().openapi({ description: "Quality from 1-100 (default: 80)" }),
26302
26318
  f: lv([
26303
26319
  "auto",
26304
26320
  "avif",
@@ -26333,7 +26349,7 @@ var YS = eb({
26333
26349
  }
26334
26350
  },
26335
26351
  400: {
26336
- description: "Asset key missing",
26352
+ description: "Bad Request (e.g. invalid query parameter values)",
26337
26353
  content: { "text/plain": { schema: { type: "string" } } }
26338
26354
  },
26339
26355
  404: {
@@ -26346,54 +26362,54 @@ var YS = eb({
26346
26362
  }
26347
26363
  }
26348
26364
  });
26349
- qS.openapi(YS, async (e) => {
26365
+ qS.openapi(ZS, async (e) => {
26350
26366
  try {
26351
26367
  let t = e.req.path.replace(/^\/media\//, "").replace(/^\//, "");
26352
26368
  if (!t) return e.text("Asset key missing", 400);
26353
- let { w: n, h: r, q: i, f: a } = e.req.valid("query"), o = !!(n || r || i || a), s = e.req.header("Accept") || "", c = "";
26369
+ let { w: n, h: r, q: i, f: a } = e.req.valid("query"), o = !!(n || r || i || a), s = XS(n ? parseInt(n, 10) : void 0), c = e.req.header("Accept") || "", l = "";
26354
26370
  if (o) {
26355
26371
  let e = !a || a === "auto";
26356
- a === "avif" || e && s.includes("image/avif") ? c = "avif" : a === "webp" || e && s.includes("image/webp") ? c = "webp" : a === "jpeg" || a === "jpg" ? c = "jpeg" : a === "png" && (c = "png");
26372
+ a === "avif" || e && c.includes("image/avif") ? l = "avif" : a === "webp" || e && c.includes("image/webp") ? l = "webp" : a === "jpeg" || a === "jpg" ? l = "jpeg" : a === "png" && (l = "png");
26357
26373
  }
26358
- let l = typeof caches < "u" && caches?.default ? caches.default : null, u = e.req.url;
26359
- if (o && c && !a) {
26360
- let e = new URL(u);
26361
- e.searchParams.set("_resolvedFormat", c), u = e.toString();
26374
+ let u = typeof caches < "u" && caches?.default ? caches.default : null, d = e.req.url;
26375
+ if (o) {
26376
+ let e = new URL(d);
26377
+ s && e.searchParams.set("w", String(s)), l && !a && e.searchParams.set("_resolvedFormat", l), d = e.toString();
26362
26378
  }
26363
- let d = l ? new Request(u, e.req.raw) : null;
26364
- if (l && d) {
26365
- let e = await l.match(d);
26379
+ let f = u ? new Request(d, e.req.raw) : null;
26380
+ if (u && f) {
26381
+ let e = await u.match(f);
26366
26382
  if (e) return e;
26367
26383
  }
26368
- let { storage: f, optimizer: p } = ix(e.env), m = await f.get(t);
26369
- if (!m) return e.text(`Asset not found: ${t}`, 404);
26384
+ let { storage: p, optimizer: m } = ix(e.env), h = await p.get(t);
26385
+ if (!h) return e.text(`Asset not found: ${t}`, 404);
26370
26386
  if (!o) {
26371
- let n = e.body(m, 200, {
26387
+ let n = e.body(h, 200, {
26372
26388
  "Content-Type": JS(t),
26373
26389
  "Cache-Control": "public, max-age=31536000, immutable"
26374
26390
  });
26375
- return l && d && e.executionCtx?.waitUntil && e.executionCtx.waitUntil(l.put(d, n.clone())), n;
26391
+ return u && f && e.executionCtx?.waitUntil && e.executionCtx.waitUntil(u.put(f, n.clone())), n;
26376
26392
  }
26377
- let h = {
26378
- width: n ? parseInt(n, 10) : void 0,
26393
+ let g = {
26394
+ width: s,
26379
26395
  height: r ? parseInt(r, 10) : void 0,
26380
26396
  quality: i ? parseInt(i, 10) : 80,
26381
- format: c
26382
- }, g = await p.process(m, h, {
26397
+ format: l
26398
+ }, _ = await m.process(h, g, {
26383
26399
  key: t,
26384
26400
  env: e.env,
26385
26401
  req: e.req.raw
26386
- }), _ = JS(t, c), v = e.body(g, 200, {
26387
- "Content-Type": _,
26402
+ }), v = JS(t, l), y = e.body(_, 200, {
26403
+ "Content-Type": v,
26388
26404
  "Cache-Control": "public, max-age=31536000, immutable"
26389
26405
  });
26390
- return l && d && e.executionCtx?.waitUntil && e.executionCtx.waitUntil(l.put(d, v.clone())), v;
26406
+ return u && f && e.executionCtx?.waitUntil && e.executionCtx.waitUntil(u.put(f, y.clone())), y;
26391
26407
  } catch (t) {
26392
26408
  return console.error("❌ [Public Assets Error]:", t), e.text("Internal Server Error", 500);
26393
26409
  }
26394
26410
  });
26395
- var XS = new $y();
26396
- function ZS(e, t) {
26411
+ var QS = new $y();
26412
+ function $S(e, t) {
26397
26413
  let n = /* @__PURE__ */ new Date();
26398
26414
  if (e && String(e).trim() !== "") {
26399
26415
  let t = new Date(e);
@@ -26405,31 +26421,31 @@ function ZS(e, t) {
26405
26421
  }
26406
26422
  return !0;
26407
26423
  }
26408
- var QS = X({
26424
+ var eC = X({
26409
26425
  channelId: J().optional().openapi({ description: "Optional channel ID/key to filter and resolve root paths for" }),
26410
26426
  channel: J().optional().openapi({ description: "Legacy alias for channelId" })
26411
- }), $S = z_(J()).openapi("PathsResponse"), eC = X({
26427
+ }), tC = z_(J()).openapi("PathsResponse"), nC = X({
26412
26428
  error: J(),
26413
26429
  details: J().optional()
26414
- }).openapi("ErrorResponse"), tC = eb({
26430
+ }).openapi("ErrorResponse"), rC = eb({
26415
26431
  method: "get",
26416
26432
  path: "/",
26417
26433
  summary: "Fetch All Public Paths",
26418
26434
  description: "Retrieves a deduplicated array of all active, published node paths leveraging the $O(1)$ node_routes table. Includes both tree-bound and standalone pages.",
26419
26435
  tags: ["Public Paths API"],
26420
- request: { query: QS },
26436
+ request: { query: eC },
26421
26437
  responses: {
26422
26438
  200: {
26423
26439
  description: "Array of valid public URL paths",
26424
- content: { "application/json": { schema: $S } }
26440
+ content: { "application/json": { schema: tC } }
26425
26441
  },
26426
26442
  500: {
26427
26443
  description: "Server error fetching paths",
26428
- content: { "application/json": { schema: eC } }
26444
+ content: { "application/json": { schema: nC } }
26429
26445
  }
26430
26446
  }
26431
26447
  });
26432
- XS.openapi(tC, async (e) => {
26448
+ QS.openapi(rC, async (e) => {
26433
26449
  try {
26434
26450
  let t = e.get("db"), n = e.req.valid("query"), r = n.channelId || n.channel, i = "", a = [];
26435
26451
  if (r && r !== "all") {
@@ -26454,7 +26470,7 @@ XS.openapi(tC, async (e) => {
26454
26470
  let t = !0;
26455
26471
  if (e.dataJson) try {
26456
26472
  let n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
26457
- t = ZS(n?.startShowingAt, n?.stopShowingAt);
26473
+ t = $S(n?.startShowingAt, n?.stopShowingAt);
26458
26474
  } catch {}
26459
26475
  t && c.push(e.path);
26460
26476
  }
@@ -26464,12 +26480,12 @@ XS.openapi(tC, async (e) => {
26464
26480
  return console.error("[CMS Paths API] Error:", t), e.json({ error: "Failed to fetch paths" }, 500);
26465
26481
  }
26466
26482
  });
26467
- var nC = new $y();
26468
- function rC(e) {
26483
+ var iC = new $y();
26484
+ function aC(e) {
26469
26485
  let t = (e || "").trim().toLowerCase(), n = dx()?.taxonomies || {};
26470
26486
  return n[t] ? t : n[`${t}s`] ? `${t}s` : t.endsWith("s") && n[t.slice(0, -1)] ? t.slice(0, -1) : t;
26471
26487
  }
26472
- var iC = X({
26488
+ var oC = X({
26473
26489
  id: c_(),
26474
26490
  taxonomy: J(),
26475
26491
  key: J(),
@@ -26479,14 +26495,14 @@ var iC = X({
26479
26495
  data: tv(k_()),
26480
26496
  createdAt: J(),
26481
26497
  updatedAt: J()
26482
- }), aC = X({
26498
+ }), sC = X({
26483
26499
  taxonomy: J(),
26484
- items: z_(iC),
26500
+ items: z_(oC),
26485
26501
  total: c_()
26486
- }).openapi("TaxonomyResponse"), oC = X({
26502
+ }).openapi("TaxonomyResponse"), cC = X({
26487
26503
  error: J(),
26488
26504
  details: J().optional()
26489
- }).openapi("ErrorResponse"), sC = eb({
26505
+ }).openapi("ErrorResponse"), lC = eb({
26490
26506
  method: "get",
26491
26507
  path: "/{taxonomy}",
26492
26508
  summary: "Fetch Public Taxonomy Terms",
@@ -26496,17 +26512,17 @@ var iC = X({
26496
26512
  responses: {
26497
26513
  200: {
26498
26514
  description: "List of taxonomy terms",
26499
- content: { "application/json": { schema: aC } }
26515
+ content: { "application/json": { schema: sC } }
26500
26516
  },
26501
26517
  500: {
26502
26518
  description: "Server error",
26503
- content: { "application/json": { schema: oC } }
26519
+ content: { "application/json": { schema: cC } }
26504
26520
  }
26505
26521
  }
26506
26522
  });
26507
- nC.openapi(sC, async (e) => {
26523
+ iC.openapi(lC, async (e) => {
26508
26524
  try {
26509
- let t = e.get("db"), n = $b(e), r = e.req.valid("param").taxonomy, i = rC(r), a = `taxonomy:public:${i}`, o = e.req.header("x-bypass-cache") === "true";
26525
+ let t = e.get("db"), n = $b(e), r = e.req.valid("param").taxonomy, i = aC(r), a = `taxonomy:public:${i}`, o = e.req.header("x-bypass-cache") === "true";
26510
26526
  if (!o) {
26511
26527
  let t = await n.get(a);
26512
26528
  if (t) return e.header("X-Cache", "HIT"), e.json(t);
@@ -26540,7 +26556,7 @@ nC.openapi(sC, async (e) => {
26540
26556
  return console.error("[Public Taxonomy API] Error fetching terms:", t), e.json({ error: "Failed to fetch taxonomy terms" }, 500);
26541
26557
  }
26542
26558
  });
26543
- var $ = new $y(), cC = !1;
26559
+ var $ = new $y(), uC = !1;
26544
26560
  $.use("*", t()), $.use("/media/*", t({
26545
26561
  origin: "*",
26546
26562
  allowMethods: [
@@ -26561,13 +26577,13 @@ $.use("*", t()), $.use("/media/*", t({
26561
26577
  let n = new URL(e.req.url), r = (e.req.header("host") || n.hostname).split(":")[0];
26562
26578
  e.set("currentDomain", r);
26563
26579
  let i = wb(e);
26564
- if (e.set("db", i), !cC) try {
26565
- await Mb(i), cC = !0;
26580
+ if (e.set("db", i), !uC) try {
26581
+ await Mb(i), uC = !0;
26566
26582
  } catch (e) {
26567
26583
  console.error("❌ [CMS Server] Failed to initialize system tables on cold start:", e);
26568
26584
  }
26569
26585
  await t();
26570
- }), $.route("/media", qS), $.use("/media/*", Pb()), $.route("/api/cms/nodes", mx), $.route("/api/cms/nodes.json", mx), $.route("/api/cms/formcsv", mx), $.route("/api/cms/formcsv.json", mx), $.route("/api/cms/stats", tS), $.route("/api/cms/stats.json", tS), $.route("/api/cms", Tx), $.route("/api/cms/trees.json", Tx), $.route("/api/cms/channels", kx), $.route("/api/cms/channels.json", kx), $.route("/api/cms/taxonomies", Ax), $.route("/api/cms/taxonomies.json", Ax), $.route("/api/cms/schemas", Xx), $.route("/api/cms/schemas.json", Xx), $.route("/api/cms", Qx), $.route("/api/admin/assets", nS), $.route("/api/v1/node", oS), $.route("/api/v1/tree", ES), $.route("/api/v1/channel", FS), $.route("/api/v1/all-paths", XS), $.route("/api/v1/taxonomies", nC), $.doc("/api/openapi.json", {
26586
+ }), $.route("/media", qS), $.use("/media/*", Pb()), $.route("/api/cms/nodes", mx), $.route("/api/cms/nodes.json", mx), $.route("/api/cms/formcsv", mx), $.route("/api/cms/formcsv.json", mx), $.route("/api/cms/stats", tS), $.route("/api/cms/stats.json", tS), $.route("/api/cms", Tx), $.route("/api/cms/trees.json", Tx), $.route("/api/cms/channels", kx), $.route("/api/cms/channels.json", kx), $.route("/api/cms/taxonomies", Ax), $.route("/api/cms/taxonomies.json", Ax), $.route("/api/cms/schemas", Xx), $.route("/api/cms/schemas.json", Xx), $.route("/api/cms", Qx), $.route("/api/admin/assets", nS), $.route("/api/v1/node", oS), $.route("/api/v1/tree", ES), $.route("/api/v1/channel", FS), $.route("/api/v1/all-paths", QS), $.route("/api/v1/taxonomies", iC), $.doc("/api/openapi.json", {
26571
26587
  openapi: "3.0.0",
26572
26588
  info: {
26573
26589
  title: "KAMA Engine Public API",
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-BoKRJcv3.js"></script>
10
- <link rel="stylesheet" crossorigin href="/assets/index-Cw7t4FzH.css">
9
+ <script type="module" crossorigin src="/assets/index-Dxb_fjpM.js"></script>
10
+ <link rel="stylesheet" crossorigin href="/assets/index-BP3z9TWM.css">
11
11
  </head>
12
12
  <body>
13
13
  <div id="app"></div>
package/dist/index.js CHANGED
@@ -26501,16 +26501,32 @@ function JS(e, t) {
26501
26501
  let n = e.toLowerCase();
26502
26502
  return n.endsWith(".jpg") || n.endsWith(".jpeg") ? "image/jpeg" : n.endsWith(".png") ? "image/png" : n.endsWith(".webp") ? "image/webp" : n.endsWith(".gif") ? "image/gif" : n.endsWith(".svg") ? "image/svg+xml" : n.endsWith(".pdf") ? "application/pdf" : n.endsWith(".mp4") ? "video/mp4" : "application/octet-stream";
26503
26503
  }
26504
- var YS = eb({
26504
+ var YS = [
26505
+ 320,
26506
+ 640,
26507
+ 768,
26508
+ 1024,
26509
+ 1352,
26510
+ 1920,
26511
+ 2560,
26512
+ 3840
26513
+ ];
26514
+ function XS(e) {
26515
+ if (!(!e || isNaN(e) || e <= 0)) return YS.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
26516
+ }
26517
+ var ZS = eb({
26505
26518
  method: "get",
26506
26519
  path: "/*",
26507
26520
  summary: "Serve & Optimize Media Assets",
26508
26521
  description: "Retrieves a media asset by its storage key. Optionally optimizes, resizes, and converts images on the fly via query parameters.",
26509
26522
  tags: ["Public Media API"],
26510
26523
  request: { query: X({
26511
- w: J().optional().openapi({ description: "Width in pixels for image optimization (e.g., \"800\")" }),
26512
- h: J().optional().openapi({ description: "Height in pixels for image optimization (e.g., \"600\")" }),
26513
- q: J().optional().openapi({ description: "Quality from 1-100 for image optimization (default: 80)" }),
26524
+ w: J().regex(/^\d+$/).refine((e) => parseInt(e, 10) <= 3840, { message: "Width cannot exceed 3840px" }).optional().openapi({ description: "Width in pixels (Snaps to nearest CDN breakpoint)" }),
26525
+ h: J().regex(/^\d+$/).refine((e) => parseInt(e, 10) <= 3840, { message: "Height cannot exceed 3840px" }).optional().openapi({ description: "Height in pixels (Max 3840)" }),
26526
+ q: J().regex(/^\d+$/).refine((e) => {
26527
+ let t = parseInt(e, 10);
26528
+ return t >= 1 && t <= 100;
26529
+ }, { message: "Quality must be between 1 and 100" }).optional().openapi({ description: "Quality from 1-100 (default: 80)" }),
26514
26530
  f: lv([
26515
26531
  "auto",
26516
26532
  "avif",
@@ -26545,7 +26561,7 @@ var YS = eb({
26545
26561
  }
26546
26562
  },
26547
26563
  400: {
26548
- description: "Asset key missing",
26564
+ description: "Bad Request (e.g. invalid query parameter values)",
26549
26565
  content: { "text/plain": { schema: { type: "string" } } }
26550
26566
  },
26551
26567
  404: {
@@ -26558,56 +26574,56 @@ var YS = eb({
26558
26574
  }
26559
26575
  }
26560
26576
  });
26561
- qS.openapi(YS, async (e) => {
26577
+ qS.openapi(ZS, async (e) => {
26562
26578
  try {
26563
26579
  let t = e.req.path.replace(/^\/media\//, "").replace(/^\//, "");
26564
26580
  if (!t) return e.text("Asset key missing", 400);
26565
- let { w: n, h: r, q: i, f: a } = e.req.valid("query"), o = !!(n || r || i || a), s = e.req.header("Accept") || "", c = "";
26581
+ let { w: n, h: r, q: i, f: a } = e.req.valid("query"), o = !!(n || r || i || a), s = XS(n ? parseInt(n, 10) : void 0), c = e.req.header("Accept") || "", l = "";
26566
26582
  if (o) {
26567
26583
  let e = !a || a === "auto";
26568
- a === "avif" || e && s.includes("image/avif") ? c = "avif" : a === "webp" || e && s.includes("image/webp") ? c = "webp" : a === "jpeg" || a === "jpg" ? c = "jpeg" : a === "png" && (c = "png");
26584
+ a === "avif" || e && c.includes("image/avif") ? l = "avif" : a === "webp" || e && c.includes("image/webp") ? l = "webp" : a === "jpeg" || a === "jpg" ? l = "jpeg" : a === "png" && (l = "png");
26569
26585
  }
26570
- let l = typeof caches < "u" && caches?.default ? caches.default : null, u = e.req.url;
26571
- if (o && c && !a) {
26572
- let e = new URL(u);
26573
- e.searchParams.set("_resolvedFormat", c), u = e.toString();
26586
+ let u = typeof caches < "u" && caches?.default ? caches.default : null, d = e.req.url;
26587
+ if (o) {
26588
+ let e = new URL(d);
26589
+ s && e.searchParams.set("w", String(s)), l && !a && e.searchParams.set("_resolvedFormat", l), d = e.toString();
26574
26590
  }
26575
- let d = l ? new Request(u, e.req.raw) : null;
26576
- if (l && d) {
26577
- let e = await l.match(d);
26591
+ let f = u ? new Request(d, e.req.raw) : null;
26592
+ if (u && f) {
26593
+ let e = await u.match(f);
26578
26594
  if (e) return e;
26579
26595
  }
26580
- let { storage: f, optimizer: p } = ix(e.env), m = await f.get(t);
26581
- if (!m) return e.text(`Asset not found: ${t}`, 404);
26596
+ let { storage: p, optimizer: m } = ix(e.env), h = await p.get(t);
26597
+ if (!h) return e.text(`Asset not found: ${t}`, 404);
26582
26598
  if (!o) {
26583
- let n = e.body(m, 200, {
26599
+ let n = e.body(h, 200, {
26584
26600
  "Content-Type": JS(t),
26585
26601
  "Cache-Control": "public, max-age=31536000, immutable"
26586
26602
  });
26587
- return l && d && e.executionCtx?.waitUntil && e.executionCtx.waitUntil(l.put(d, n.clone())), n;
26603
+ return u && f && e.executionCtx?.waitUntil && e.executionCtx.waitUntil(u.put(f, n.clone())), n;
26588
26604
  }
26589
- let h = {
26590
- width: n ? parseInt(n, 10) : void 0,
26605
+ let g = {
26606
+ width: s,
26591
26607
  height: r ? parseInt(r, 10) : void 0,
26592
26608
  quality: i ? parseInt(i, 10) : 80,
26593
- format: c
26594
- }, g = await p.process(m, h, {
26609
+ format: l
26610
+ }, _ = await m.process(h, g, {
26595
26611
  key: t,
26596
26612
  env: e.env,
26597
26613
  req: e.req.raw
26598
- }), _ = JS(t, c), v = e.body(g, 200, {
26599
- "Content-Type": _,
26614
+ }), v = JS(t, l), y = e.body(_, 200, {
26615
+ "Content-Type": v,
26600
26616
  "Cache-Control": "public, max-age=31536000, immutable"
26601
26617
  });
26602
- return l && d && e.executionCtx?.waitUntil && e.executionCtx.waitUntil(l.put(d, v.clone())), v;
26618
+ return u && f && e.executionCtx?.waitUntil && e.executionCtx.waitUntil(u.put(f, y.clone())), y;
26603
26619
  } catch (t) {
26604
26620
  return console.error("❌ [Public Assets Error]:", t), e.text("Internal Server Error", 500);
26605
26621
  }
26606
26622
  });
26607
26623
  //#endregion
26608
26624
  //#region server/routes/public/paths.ts
26609
- var XS = new $y();
26610
- function ZS(e, t) {
26625
+ var QS = new $y();
26626
+ function $S(e, t) {
26611
26627
  let n = /* @__PURE__ */ new Date();
26612
26628
  if (e && String(e).trim() !== "") {
26613
26629
  let t = new Date(e);
@@ -26619,31 +26635,31 @@ function ZS(e, t) {
26619
26635
  }
26620
26636
  return !0;
26621
26637
  }
26622
- var QS = X({
26638
+ var eC = X({
26623
26639
  channelId: J().optional().openapi({ description: "Optional channel ID/key to filter and resolve root paths for" }),
26624
26640
  channel: J().optional().openapi({ description: "Legacy alias for channelId" })
26625
- }), $S = z_(J()).openapi("PathsResponse"), eC = X({
26641
+ }), tC = z_(J()).openapi("PathsResponse"), nC = X({
26626
26642
  error: J(),
26627
26643
  details: J().optional()
26628
- }).openapi("ErrorResponse"), tC = eb({
26644
+ }).openapi("ErrorResponse"), rC = eb({
26629
26645
  method: "get",
26630
26646
  path: "/",
26631
26647
  summary: "Fetch All Public Paths",
26632
26648
  description: "Retrieves a deduplicated array of all active, published node paths leveraging the $O(1)$ node_routes table. Includes both tree-bound and standalone pages.",
26633
26649
  tags: ["Public Paths API"],
26634
- request: { query: QS },
26650
+ request: { query: eC },
26635
26651
  responses: {
26636
26652
  200: {
26637
26653
  description: "Array of valid public URL paths",
26638
- content: { "application/json": { schema: $S } }
26654
+ content: { "application/json": { schema: tC } }
26639
26655
  },
26640
26656
  500: {
26641
26657
  description: "Server error fetching paths",
26642
- content: { "application/json": { schema: eC } }
26658
+ content: { "application/json": { schema: nC } }
26643
26659
  }
26644
26660
  }
26645
26661
  });
26646
- XS.openapi(tC, async (e) => {
26662
+ QS.openapi(rC, async (e) => {
26647
26663
  try {
26648
26664
  let t = e.get("db"), n = e.req.valid("query"), r = n.channelId || n.channel, i = "", a = [];
26649
26665
  if (r && r !== "all") {
@@ -26668,7 +26684,7 @@ XS.openapi(tC, async (e) => {
26668
26684
  let t = !0;
26669
26685
  if (e.dataJson) try {
26670
26686
  let n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
26671
- t = ZS(n?.startShowingAt, n?.stopShowingAt);
26687
+ t = $S(n?.startShowingAt, n?.stopShowingAt);
26672
26688
  } catch {}
26673
26689
  t && c.push(e.path);
26674
26690
  }
@@ -26680,12 +26696,12 @@ XS.openapi(tC, async (e) => {
26680
26696
  });
26681
26697
  //#endregion
26682
26698
  //#region server/routes/public/taxonomies.ts
26683
- var nC = new $y();
26684
- function rC(e) {
26699
+ var iC = new $y();
26700
+ function aC(e) {
26685
26701
  let t = (e || "").trim().toLowerCase(), n = dx()?.taxonomies || {};
26686
26702
  return n[t] ? t : n[`${t}s`] ? `${t}s` : t.endsWith("s") && n[t.slice(0, -1)] ? t.slice(0, -1) : t;
26687
26703
  }
26688
- var iC = X({
26704
+ var oC = X({
26689
26705
  id: c_(),
26690
26706
  taxonomy: J(),
26691
26707
  key: J(),
@@ -26695,14 +26711,14 @@ var iC = X({
26695
26711
  data: tv(k_()),
26696
26712
  createdAt: J(),
26697
26713
  updatedAt: J()
26698
- }), aC = X({
26714
+ }), sC = X({
26699
26715
  taxonomy: J(),
26700
- items: z_(iC),
26716
+ items: z_(oC),
26701
26717
  total: c_()
26702
- }).openapi("TaxonomyResponse"), oC = X({
26718
+ }).openapi("TaxonomyResponse"), cC = X({
26703
26719
  error: J(),
26704
26720
  details: J().optional()
26705
- }).openapi("ErrorResponse"), sC = eb({
26721
+ }).openapi("ErrorResponse"), lC = eb({
26706
26722
  method: "get",
26707
26723
  path: "/{taxonomy}",
26708
26724
  summary: "Fetch Public Taxonomy Terms",
@@ -26712,17 +26728,17 @@ var iC = X({
26712
26728
  responses: {
26713
26729
  200: {
26714
26730
  description: "List of taxonomy terms",
26715
- content: { "application/json": { schema: aC } }
26731
+ content: { "application/json": { schema: sC } }
26716
26732
  },
26717
26733
  500: {
26718
26734
  description: "Server error",
26719
- content: { "application/json": { schema: oC } }
26735
+ content: { "application/json": { schema: cC } }
26720
26736
  }
26721
26737
  }
26722
26738
  });
26723
- nC.openapi(sC, async (e) => {
26739
+ iC.openapi(lC, async (e) => {
26724
26740
  try {
26725
- let t = e.get("db"), n = $b(e), r = e.req.valid("param").taxonomy, i = rC(r), a = `taxonomy:public:${i}`, o = e.req.header("x-bypass-cache") === "true";
26741
+ let t = e.get("db"), n = $b(e), r = e.req.valid("param").taxonomy, i = aC(r), a = `taxonomy:public:${i}`, o = e.req.header("x-bypass-cache") === "true";
26726
26742
  if (!o) {
26727
26743
  let t = await n.get(a);
26728
26744
  if (t) return e.header("X-Cache", "HIT"), e.json(t);
@@ -26758,7 +26774,7 @@ nC.openapi(sC, async (e) => {
26758
26774
  });
26759
26775
  //#endregion
26760
26776
  //#region server/index.ts
26761
- var $ = new $y(), cC = !1;
26777
+ var $ = new $y(), uC = !1;
26762
26778
  $.use("*", t()), $.use("/media/*", t({
26763
26779
  origin: "*",
26764
26780
  allowMethods: [
@@ -26779,13 +26795,13 @@ $.use("*", t()), $.use("/media/*", t({
26779
26795
  let n = new URL(e.req.url), r = (e.req.header("host") || n.hostname).split(":")[0];
26780
26796
  e.set("currentDomain", r);
26781
26797
  let i = wb(e);
26782
- if (e.set("db", i), !cC) try {
26783
- await Mb(i), cC = !0;
26798
+ if (e.set("db", i), !uC) try {
26799
+ await Mb(i), uC = !0;
26784
26800
  } catch (e) {
26785
26801
  console.error("❌ [CMS Server] Failed to initialize system tables on cold start:", e);
26786
26802
  }
26787
26803
  await t();
26788
- }), $.route("/media", qS), $.use("/media/*", Pb()), $.route("/api/cms/nodes", mx), $.route("/api/cms/nodes.json", mx), $.route("/api/cms/formcsv", mx), $.route("/api/cms/formcsv.json", mx), $.route("/api/cms/stats", tS), $.route("/api/cms/stats.json", tS), $.route("/api/cms", Tx), $.route("/api/cms/trees.json", Tx), $.route("/api/cms/channels", kx), $.route("/api/cms/channels.json", kx), $.route("/api/cms/taxonomies", Ax), $.route("/api/cms/taxonomies.json", Ax), $.route("/api/cms/schemas", Xx), $.route("/api/cms/schemas.json", Xx), $.route("/api/cms", Qx), $.route("/api/admin/assets", nS), $.route("/api/v1/node", oS), $.route("/api/v1/tree", ES), $.route("/api/v1/channel", FS), $.route("/api/v1/all-paths", XS), $.route("/api/v1/taxonomies", nC), $.doc("/api/openapi.json", {
26804
+ }), $.route("/media", qS), $.use("/media/*", Pb()), $.route("/api/cms/nodes", mx), $.route("/api/cms/nodes.json", mx), $.route("/api/cms/formcsv", mx), $.route("/api/cms/formcsv.json", mx), $.route("/api/cms/stats", tS), $.route("/api/cms/stats.json", tS), $.route("/api/cms", Tx), $.route("/api/cms/trees.json", Tx), $.route("/api/cms/channels", kx), $.route("/api/cms/channels.json", kx), $.route("/api/cms/taxonomies", Ax), $.route("/api/cms/taxonomies.json", Ax), $.route("/api/cms/schemas", Xx), $.route("/api/cms/schemas.json", Xx), $.route("/api/cms", Qx), $.route("/api/admin/assets", nS), $.route("/api/v1/node", oS), $.route("/api/v1/tree", ES), $.route("/api/v1/channel", FS), $.route("/api/v1/all-paths", QS), $.route("/api/v1/taxonomies", iC), $.doc("/api/openapi.json", {
26789
26805
  openapi: "3.0.0",
26790
26806
  info: {
26791
26807
  title: "KAMA Engine Public API",
@@ -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-KAwiRitk.js")).compileDefinitions;
33
+ l = (await import("./dist-CUiHkSO8.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.8",
3
+ "version": "1.0.0-alpha.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -45,13 +45,13 @@ if (region.includes("_")) {
45
45
  }
46
46
 
47
47
  /**
48
- * Default single-column layout.
48
+ * Default single-column layout (aligned to backend CDN buckets).
49
49
  */
50
50
  let maxWidth = "1352";
51
51
  let targetColumnWidth = 1352;
52
52
 
53
- // 1-col: Base mobile (~400), 2x mobile/tablet (~800), 1x desktop (1352), 2x desktop (2704)
54
- let optimizedWidths = [400, 800, 1352, 2048, 2704];
53
+ // 1-col: 1x/2x desktop and retina buckets
54
+ let optimizedWidths = [768, 1352, 1920, 2560];
55
55
  let sizes = "(max-width: 1399px) calc(100vw - 48px), 1352px";
56
56
 
57
57
  /**
@@ -61,8 +61,7 @@ if (columnCount === 2) {
61
61
  maxWidth = "660";
62
62
  targetColumnWidth = 660;
63
63
 
64
- // 2-col: 1x desktop (660), 2x mobile stacked (~800), 2x desktop (1320)
65
- optimizedWidths = [400, 660, 800, 1320];
64
+ optimizedWidths = [640, 768, 1024, 1352];
66
65
  sizes =
67
66
  "(max-width: 767px) calc(100vw - 48px), " +
68
67
  "(max-width: 1399px) calc((100vw - 80px) / 2), " +
@@ -76,8 +75,7 @@ else if (columnCount === 3) {
76
75
  maxWidth = "429";
77
76
  targetColumnWidth = 429;
78
77
 
79
- // 3-col: 1x desktop (429), 2x desktop/tablet (~858), 2x/3x mobile stacked (~1000)
80
- optimizedWidths = [300, 429, 858, 1024];
78
+ optimizedWidths = [320, 640, 768, 1024];
81
79
  sizes =
82
80
  "(max-width: 767px) calc(100vw - 48px), " +
83
81
  "(max-width: 1399px) calc((100vw - 112px) / 3), " +
@@ -91,8 +89,7 @@ else if (columnCount === 4) {
91
89
  maxWidth = "314";
92
90
  targetColumnWidth = 314;
93
91
 
94
- // 4-col: 1x desktop (314), 2x desktop (628), 2x/3x mobile stacked (~1000)
95
- optimizedWidths = [264, 314, 628, 1024];
92
+ optimizedWidths = [320, 640, 768];
96
93
  sizes =
97
94
  "(max-width: 767px) calc(100vw - 48px), " +
98
95
  "(max-width: 1399px) calc((100vw - 144px) / 4), " +
@@ -106,12 +103,9 @@ else if (columnCount === 4) {
106
103
  sizes={sizes}
107
104
  desktopWidths={optimizedWidths}
108
105
  idealWidth={targetColumnWidth}
109
- width={data.width || data.image_meta?.width}
110
- height={data.height || data.image_meta?.height}
111
106
  class="responsive-header-image"
112
107
  loading={isLcp ? "eager" : "lazy"}
113
108
  fetchpriority={isLcp ? "high" : "auto"}
114
- decoding={isLcp ? "sync" : "async"}
115
109
  />
116
110
  </div>
117
111
 
@@ -26,31 +26,31 @@ if (region.includes("_")) {
26
26
  if (region.includes("_col4")) columnCount = 4;
27
27
  }
28
28
 
29
- // 🎯 Column Config Lookup (Max width, breakpoint widths, sizes)
29
+ // 🎯 Column Config Lookup (Target width, aligned CDN breakpoint widths, sizes)
30
30
  const COLUMN_CONFIGS: Record<
31
31
  number,
32
32
  { targetWidth: number; widths: number[]; sizes: string }
33
33
  > = {
34
34
  1: {
35
35
  targetWidth: 1352,
36
- widths: [768, 1352],
36
+ widths: [768, 1352, 1920, 2560],
37
37
  sizes: "(max-width: 1399px) calc(100vw - 48px), 1352px",
38
38
  },
39
39
  2: {
40
40
  targetWidth: 660,
41
- widths: [400, 660],
41
+ widths: [640, 768, 1024, 1352],
42
42
  sizes:
43
43
  "(max-width: 767px) calc(100vw - 48px), (max-width: 1399px) calc((100vw - 80px) / 2), 660px",
44
44
  },
45
45
  3: {
46
46
  targetWidth: 429,
47
- widths: [300, 429],
47
+ widths: [320, 640, 768, 1024],
48
48
  sizes:
49
49
  "(max-width: 767px) calc(100vw - 48px), (max-width: 1399px) calc((100vw - 112px) / 3), 429px",
50
50
  },
51
51
  4: {
52
52
  targetWidth: 314,
53
- widths: [264, 314],
53
+ widths: [320, 640, 768],
54
54
  sizes:
55
55
  "(max-width: 767px) calc(100vw - 48px), (max-width: 1399px) calc((100vw - 144px) / 4), 314px",
56
56
  },
@@ -67,7 +67,6 @@ const layout = COLUMN_CONFIGS[columnCount] || COLUMN_CONFIGS[1];
67
67
  sizes={layout.sizes}
68
68
  desktopWidths={layout.widths}
69
69
  idealWidth={layout.targetWidth}
70
- maxWidth={layout.targetWidth}
71
70
  class="free-crop-image"
72
71
  loading={isLcp ? "eager" : "lazy"}
73
72
  fetchpriority={isLcp ? "high" : "auto"}