@kyro-cms/core 0.9.5 → 0.9.6

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.
Files changed (53) hide show
  1. package/dist/api-handler-graphql.cjs +10 -10
  2. package/dist/api-handler-graphql.js +6 -6
  3. package/dist/api-handler-trpc.cjs +8 -8
  4. package/dist/api-handler-trpc.js +6 -6
  5. package/dist/api-handler.cjs +9 -9
  6. package/dist/api-handler.js +6 -6
  7. package/dist/{chunk-YFAVQQTU.js → chunk-AX2TZRQJ.js} +3 -3
  8. package/dist/{chunk-YFAVQQTU.js.map → chunk-AX2TZRQJ.js.map} +1 -1
  9. package/dist/{chunk-5H3MWQJS.js → chunk-CMXVTUYV.js} +12 -12
  10. package/dist/chunk-CMXVTUYV.js.map +1 -0
  11. package/dist/{chunk-E2763JUP.cjs → chunk-DRVOUQMT.cjs} +27 -27
  12. package/dist/chunk-DRVOUQMT.cjs.map +1 -0
  13. package/dist/{chunk-4M7X5HAB.cjs → chunk-FKKQUMXR.cjs} +109 -3
  14. package/dist/chunk-FKKQUMXR.cjs.map +1 -0
  15. package/dist/{chunk-PV2I2KMI.cjs → chunk-HVCUIII2.cjs} +21 -75
  16. package/dist/chunk-HVCUIII2.cjs.map +1 -0
  17. package/dist/{chunk-CJONKRHJ.js → chunk-NZEUU7QB.js} +108 -3
  18. package/dist/chunk-NZEUU7QB.js.map +1 -0
  19. package/dist/{chunk-NWUEVLQT.cjs → chunk-OZ3CCTTA.cjs} +5 -5
  20. package/dist/{chunk-NWUEVLQT.cjs.map → chunk-OZ3CCTTA.cjs.map} +1 -1
  21. package/dist/chunk-PONTBXR5.js +842 -0
  22. package/dist/chunk-PONTBXR5.js.map +1 -0
  23. package/dist/{chunk-CNKT4PME.cjs → chunk-QVJNSAQL.cjs} +71 -149
  24. package/dist/chunk-QVJNSAQL.cjs.map +1 -0
  25. package/dist/{chunk-OHC6UHFY.js → chunk-QX3WNQ7V.js} +18 -72
  26. package/dist/chunk-QX3WNQ7V.js.map +1 -0
  27. package/dist/chunk-RRKCIAPU.cjs +848 -0
  28. package/dist/chunk-RRKCIAPU.cjs.map +1 -0
  29. package/dist/{chunk-IPTZM3VE.js → chunk-VLK5SJRI.js} +56 -134
  30. package/dist/chunk-VLK5SJRI.js.map +1 -0
  31. package/dist/graphql/index.cjs +8 -4
  32. package/dist/graphql/index.d.cts +4 -1
  33. package/dist/graphql/index.d.ts +4 -1
  34. package/dist/graphql/index.js +2 -2
  35. package/dist/index.cjs +57 -57
  36. package/dist/index.js +6 -6
  37. package/dist/rest/index.cjs +4 -4
  38. package/dist/rest/index.js +2 -2
  39. package/dist/trpc/index.cjs +11 -11
  40. package/dist/trpc/index.js +2 -2
  41. package/package.json +2 -2
  42. package/dist/chunk-3HR772HI.cjs +0 -555
  43. package/dist/chunk-3HR772HI.cjs.map +0 -1
  44. package/dist/chunk-4M7X5HAB.cjs.map +0 -1
  45. package/dist/chunk-5H3MWQJS.js.map +0 -1
  46. package/dist/chunk-CJONKRHJ.js.map +0 -1
  47. package/dist/chunk-CNKT4PME.cjs.map +0 -1
  48. package/dist/chunk-E2763JUP.cjs.map +0 -1
  49. package/dist/chunk-IPTZM3VE.js.map +0 -1
  50. package/dist/chunk-L5UKKZQN.js +0 -552
  51. package/dist/chunk-L5UKKZQN.js.map +0 -1
  52. package/dist/chunk-OHC6UHFY.js.map +0 -1
  53. package/dist/chunk-PV2I2KMI.cjs.map +0 -1
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk3KTWGODI_cjs = require('./chunk-3KTWGODI.cjs');
4
- var chunkPV2I2KMI_cjs = require('./chunk-PV2I2KMI.cjs');
5
- var chunk3HR772HI_cjs = require('./chunk-3HR772HI.cjs');
6
- var chunkCNKT4PME_cjs = require('./chunk-CNKT4PME.cjs');
4
+ var chunkHVCUIII2_cjs = require('./chunk-HVCUIII2.cjs');
5
+ var chunkRRKCIAPU_cjs = require('./chunk-RRKCIAPU.cjs');
6
+ var chunkQVJNSAQL_cjs = require('./chunk-QVJNSAQL.cjs');
7
7
  var chunkQFLB4EIJ_cjs = require('./chunk-QFLB4EIJ.cjs');
8
- var chunk4M7X5HAB_cjs = require('./chunk-4M7X5HAB.cjs');
8
+ var chunkFKKQUMXR_cjs = require('./chunk-FKKQUMXR.cjs');
9
9
  var chunkEEJUFDMF_cjs = require('./chunk-EEJUFDMF.cjs');
10
10
  var chunkGUUB5EAG_cjs = require('./chunk-GUUB5EAG.cjs');
11
11
  var zod = require('zod');
@@ -778,7 +778,7 @@ function globalToUpdateZod(global) {
778
778
 
779
779
  // src/registry/index.ts
780
780
  var Registry = class {
781
- storageProviders = chunkCNKT4PME_cjs.getDefaultRegistry();
781
+ storageProviders = chunkQVJNSAQL_cjs.getDefaultRegistry();
782
782
  collections = /* @__PURE__ */ new Map();
783
783
  globals = /* @__PURE__ */ new Map();
784
784
  plugins = [];
@@ -1319,7 +1319,7 @@ var s3StoragePlugin = {
1319
1319
  configFields: v.configFields,
1320
1320
  extractConfig: (sc) => buildS3ConfigFromStorageConfig(v.type, v, sc),
1321
1321
  extractRawConfig: (raw) => buildS3ConfigFromRaw(v.type, v, raw),
1322
- factory: (c) => chunkCNKT4PME_cjs.createS3Storage(c)
1322
+ factory: (c) => chunkQVJNSAQL_cjs.createS3Storage(c)
1323
1323
  });
1324
1324
  }
1325
1325
  }
@@ -1367,7 +1367,7 @@ var cloudinaryStoragePlugin = {
1367
1367
  uploadPreset: cl?.uploadPreset
1368
1368
  };
1369
1369
  },
1370
- factory: (c) => chunkCNKT4PME_cjs.createCloudinaryStorage(c)
1370
+ factory: (c) => chunkQVJNSAQL_cjs.createCloudinaryStorage(c)
1371
1371
  });
1372
1372
  }
1373
1373
  };
@@ -1417,7 +1417,7 @@ var ftpStoragePlugin = {
1417
1417
  type: "ftp"
1418
1418
  };
1419
1419
  },
1420
- factory: (c) => chunkCNKT4PME_cjs.createFtpStorage(c)
1420
+ factory: (c) => chunkQVJNSAQL_cjs.createFtpStorage(c)
1421
1421
  });
1422
1422
  }
1423
1423
  };
@@ -1515,7 +1515,7 @@ var Kyro = class {
1515
1515
  );
1516
1516
  }
1517
1517
  const systemCollection = {
1518
- slug: chunk4M7X5HAB_cjs.API_KEY_COLLECTION,
1518
+ slug: chunkFKKQUMXR_cjs.API_KEY_COLLECTION,
1519
1519
  fields: [
1520
1520
  { name: "userId", type: "text", required: true },
1521
1521
  { name: "name", type: "text", required: true },
@@ -1614,7 +1614,7 @@ var Kyro = class {
1614
1614
  const authObj = typeof this.config.auth === "object" ? this.config.auth : null;
1615
1615
  const authSecret = authObj?.secret;
1616
1616
  const checkSession = authObj?.checkSession !== false;
1617
- return chunkCNKT4PME_cjs.createHonoApp({
1617
+ return chunkQVJNSAQL_cjs.createHonoApp({
1618
1618
  registry: this.registry,
1619
1619
  db: this.db,
1620
1620
  authSecret,
@@ -1627,7 +1627,7 @@ var Kyro = class {
1627
1627
  });
1628
1628
  }
1629
1629
  getGraphQL(options) {
1630
- const defaultSchema = chunk3HR772HI_cjs.buildGraphQLSchema({
1630
+ const defaultSchema = chunkRRKCIAPU_cjs.buildGraphQLSchema({
1631
1631
  registry: this.registry,
1632
1632
  db: this.db,
1633
1633
  settings: this.settings,
@@ -1637,11 +1637,11 @@ var Kyro = class {
1637
1637
  });
1638
1638
  return {
1639
1639
  fetch: async (request, _locals) => {
1640
- const apiKeyRaw = chunk4M7X5HAB_cjs.extractApiKeyFromRequest(request);
1640
+ const apiKeyRaw = chunkFKKQUMXR_cjs.extractApiKeyFromRequest(request);
1641
1641
  let gqlUser;
1642
1642
  let apiKeyCtx;
1643
1643
  if (apiKeyRaw && this.db) {
1644
- const apiKeyResult = await chunk4M7X5HAB_cjs.validateApiKey(apiKeyRaw, this.db);
1644
+ const apiKeyResult = await chunkFKKQUMXR_cjs.validateApiKey(apiKeyRaw, this.db);
1645
1645
  if (!apiKeyResult.valid) {
1646
1646
  return new Response(
1647
1647
  JSON.stringify({ errors: [{ message: apiKeyResult.error || "Invalid API key" }] }),
@@ -1650,11 +1650,11 @@ var Kyro = class {
1650
1650
  }
1651
1651
  if (apiKeyResult.user) {
1652
1652
  gqlUser = apiKeyResult.user;
1653
- apiKeyCtx = chunk4M7X5HAB_cjs.createApiKeyContext(apiKeyResult);
1653
+ apiKeyCtx = chunkFKKQUMXR_cjs.createApiKeyContext(apiKeyResult);
1654
1654
  }
1655
1655
  }
1656
1656
  const mustRebuild = gqlUser !== options?.user || apiKeyCtx !== void 0;
1657
- const schema = mustRebuild ? chunk3HR772HI_cjs.buildGraphQLSchema({
1657
+ const schema = mustRebuild ? chunkRRKCIAPU_cjs.buildGraphQLSchema({
1658
1658
  registry: this.registry,
1659
1659
  db: this.db,
1660
1660
  settings: this.settings,
@@ -1721,7 +1721,7 @@ var Kyro = class {
1721
1721
  { status: 400, headers: { "Content-Type": "application/json" } }
1722
1722
  );
1723
1723
  }
1724
- const ctx = await chunkPV2I2KMI_cjs.createContext({
1724
+ const ctx = await chunkHVCUIII2_cjs.createContext({
1725
1725
  db: this.db,
1726
1726
  registry: this.registry,
1727
1727
  req: request,
@@ -1729,7 +1729,7 @@ var Kyro = class {
1729
1729
  tenantID: options?.tenantID,
1730
1730
  settings: this.settings
1731
1731
  });
1732
- const kyroRouter = chunkPV2I2KMI_cjs.createKyroServer(ctx);
1732
+ const kyroRouter = chunkHVCUIII2_cjs.createKyroServer(ctx);
1733
1733
  const collectionRouter = kyroRouter[slug];
1734
1734
  if (!collectionRouter) {
1735
1735
  return new Response(
@@ -1807,7 +1807,7 @@ var Kyro = class {
1807
1807
  return null;
1808
1808
  }
1809
1809
  const defaultVerifyToken = async (token) => {
1810
- const result = await chunk4M7X5HAB_cjs.validateApiKey(token, this.db);
1810
+ const result = await chunkFKKQUMXR_cjs.validateApiKey(token, this.db);
1811
1811
  if (!result.valid) throw new Error(result.error || "Invalid API key");
1812
1812
  if (!result.user) throw new Error("API key has no associated user");
1813
1813
  return result.user;
@@ -1835,7 +1835,7 @@ var Kyro = class {
1835
1835
  function createKyro(config) {
1836
1836
  return new Kyro(config);
1837
1837
  }
1838
- var _require = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-E2763JUP.cjs', document.baseURI).href)));
1838
+ var _require = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-DRVOUQMT.cjs', document.baseURI).href)));
1839
1839
  var modPath = "node:sqlite";
1840
1840
  var { DatabaseSync } = _require(modPath);
1841
1841
  function flattenFields(fields) {
@@ -2068,6 +2068,10 @@ var LocalAdapter = class extends chunkGUUB5EAG_cjs.AbstractBaseAdapter {
2068
2068
  updated_at TEXT DEFAULT (datetime('now'))
2069
2069
  )
2070
2070
  `);
2071
+ try {
2072
+ this.db.exec(`ALTER TABLE ${this.versionsTableName} ADD COLUMN autosave INTEGER NOT NULL DEFAULT 0`);
2073
+ } catch {
2074
+ }
2071
2075
  this.db.exec(
2072
2076
  `CREATE INDEX IF NOT EXISTS idx_${this.versionsTableName}_doc ON ${this.versionsTableName}(collection_slug, document_id)`
2073
2077
  );
@@ -2077,10 +2081,6 @@ var LocalAdapter = class extends chunkGUUB5EAG_cjs.AbstractBaseAdapter {
2077
2081
  this.db.exec(
2078
2082
  `CREATE INDEX IF NOT EXISTS idx_${this.versionsTableName}_autosave ON ${this.versionsTableName}(autosave)`
2079
2083
  );
2080
- try {
2081
- this.db.exec(`ALTER TABLE ${this.versionsTableName} ADD COLUMN autosave INTEGER NOT NULL DEFAULT 0`);
2082
- } catch {
2083
- }
2084
2084
  }
2085
2085
  // ========================================================================
2086
2086
  // SQL Quoting
@@ -2293,7 +2293,7 @@ var LocalAdapter = class extends chunkGUUB5EAG_cjs.AbstractBaseAdapter {
2293
2293
  this.db.prepare(
2294
2294
  `INSERT OR REPLACE INTO ${tableName} (${quotedColumns.join(", ")}) VALUES (${placeholders})`
2295
2295
  ).run(...values);
2296
- return this.findByID({ collection: slug, id, tenantID });
2296
+ return this.findByID({ collection: slug, id, tenantID, draft: true });
2297
2297
  }
2298
2298
  async update(args) {
2299
2299
  const { collection: slug, id, data, tenantID } = args;
@@ -2329,7 +2329,7 @@ var LocalAdapter = class extends chunkGUUB5EAG_cjs.AbstractBaseAdapter {
2329
2329
  const parsed = this.parseGlobalsSlug(slug);
2330
2330
  const config = parsed.isGlobal ? this.globals.get(parsed.globalSlug) : this.getCollection(slug);
2331
2331
  this.ensureTable(config, parsed.tableName);
2332
- const doc = await this.findByID({ collection: slug, id, tenantID });
2332
+ const doc = await this.findByID({ collection: slug, id, tenantID, draft: true });
2333
2333
  if (!doc) throw new Error(`Document not found: ${slug}/${id}`);
2334
2334
  const tableName = parsed.tableName;
2335
2335
  let sql = `DELETE FROM ${tableName} WHERE id = ?`;
@@ -2783,5 +2783,5 @@ exports.validateCollection = validateCollection;
2783
2783
  exports.validateConfig = validateConfig;
2784
2784
  exports.validateFields = validateFields;
2785
2785
  exports.validateGlobal = validateGlobal;
2786
- //# sourceMappingURL=chunk-E2763JUP.cjs.map
2787
- //# sourceMappingURL=chunk-E2763JUP.cjs.map
2786
+ //# sourceMappingURL=chunk-DRVOUQMT.cjs.map
2787
+ //# sourceMappingURL=chunk-DRVOUQMT.cjs.map