@kyro-cms/core 0.5.2 → 0.5.4

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,61 @@
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+
4
+ // src/integration.ts
5
+ function kyro(options = {}) {
6
+ const {
7
+ configPath = "./kyro.config.ts",
8
+ apiPath = "/api",
9
+ adminPath = "/admin",
10
+ admin = true
11
+ } = options;
12
+ return {
13
+ name: "@kyro-cms/core",
14
+ hooks: {
15
+ "astro:config:setup": async ({ config, updateConfig, injectRoute, logger }) => {
16
+ logger.info(`Setting up Kyro CMS (API: ${apiPath}, Admin: ${adminPath})`);
17
+ const resolvedConfigPath = path.resolve(config.root.pathname, configPath);
18
+ let finalConfigPath = resolvedConfigPath;
19
+ if (!fs.existsSync(resolvedConfigPath)) {
20
+ logger.warn(`Kyro config file not found at ${configPath}. The API will fail to boot if collections are needed.`);
21
+ }
22
+ updateConfig({
23
+ vite: {
24
+ resolve: {
25
+ alias: {
26
+ "kyro:config": finalConfigPath
27
+ }
28
+ },
29
+ define: {
30
+ __KYRO_API_PATH__: JSON.stringify(apiPath),
31
+ __KYRO_ADMIN_PATH__: JSON.stringify(adminPath)
32
+ }
33
+ }
34
+ });
35
+ injectRoute({
36
+ pattern: `${apiPath}/[...path]`,
37
+ entrypoint: "@kyro-cms/core/api-handler"
38
+ });
39
+ if (admin) {
40
+ try {
41
+ const { ADMIN_ROUTES } = await import('@kyro-cms/admin/routes');
42
+ for (const route of ADMIN_ROUTES) {
43
+ const pattern = adminPath + route.pattern;
44
+ injectRoute({
45
+ pattern,
46
+ entrypoint: route.entrypoint
47
+ });
48
+ }
49
+ logger.info(`Mounted ${ADMIN_ROUTES.length} admin routes at ${adminPath}`);
50
+ } catch (e) {
51
+ logger.warn("Could not find @kyro-cms/admin/routes. Admin UI will not be available.");
52
+ }
53
+ }
54
+ }
55
+ }
56
+ };
57
+ }
58
+
59
+ export { kyro };
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AAA,CAAY;AAAA,UACV,OAAA,EAAS,GAAG,OAAO,CAAA,UAAA,CAAA;AAAA,UACnB,UAAA,EAAY;AAAA,SACb,CAAA;AAGD,QAAA,IAAI,KAAA,EAAO;AACT,UAAA,IAAI;AAEF,YAAA,MAAM,EAAE,YAAA,EAAa,GAAI,MAAM,OAAO,wBAAwB,CAAA;AAE9D,YAAA,KAAA,MAAW,SAAS,YAAA,EAAc;AAChC,cAAA,MAAM,OAAA,GAAU,YAAY,KAAA,CAAM,OAAA;AAElC,cAAA,WAAA,CAAY;AAAA,gBACV,OAAA;AAAA,gBACA,YAAY,KAAA,CAAM;AAAA,eACnB,CAAA;AAAA,YACH;AACA,YAAA,MAAA,CAAO,KAAK,CAAA,QAAA,EAAW,YAAA,CAAa,MAAM,CAAA,iBAAA,EAAoB,SAAS,CAAA,CAAE,CAAA;AAAA,UAC3E,SAAS,CAAA,EAAG;AACV,YAAA,MAAA,CAAO,KAAK,wEAAwE,CAAA;AAAA,UACtF;AAAA,QACF;AAAA,MACF;AAAA;AACF,GACF;AACF","file":"chunk-ATVNYGRQ.js","sourcesContent":["import type { AstroIntegration } from \"astro\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport interface KyroIntegrationOptions {\n /**\n * Path to the kyro configuration file relative to the project root.\n * Default: './kyro.config.ts'\n */\n configPath?: string;\n /**\n * Base path where the API should be mounted.\n * Default: '/api/kyro'\n */\n apiPath?: string;\n /**\n * Base path where the admin UI should be mounted.\n * Default: '/admin'\n */\n adminPath?: string;\n /**\n * Whether to mount the admin UI.\n * Default: true\n */\n admin?: boolean;\n}\n\nexport default function kyro(options: KyroIntegrationOptions = {}): AstroIntegration {\n const {\n configPath = \"./kyro.config.ts\",\n apiPath = \"/api\",\n adminPath = \"/admin\",\n admin = true,\n } = options;\n\n return {\n name: \"@kyro-cms/core\",\n hooks: {\n \"astro:config:setup\": async ({ config, updateConfig, injectRoute, logger }) => {\n logger.info(`Setting up Kyro CMS (API: ${apiPath}, Admin: ${adminPath})`);\n \n // Resolve config path\n const resolvedConfigPath = path.resolve(config.root.pathname, configPath);\n \n let finalConfigPath = resolvedConfigPath;\n if (!fs.existsSync(resolvedConfigPath)) {\n logger.warn(`Kyro config file not found at ${configPath}. The API will fail to boot if collections are needed.`);\n // If we had a default fallback, we could set it here\n }\n \n // Add Vite configuration so the API handler can import the config\n updateConfig({\n vite: {\n resolve: {\n alias: {\n \"kyro:config\": finalConfigPath,\n },\n },\n define: {\n __KYRO_API_PATH__: JSON.stringify(apiPath),\n __KYRO_ADMIN_PATH__: JSON.stringify(adminPath),\n },\n },\n });\n \n // Inject the core API routes\n // This mounts our Hono app or Astro endpoints to handle backend requests\n injectRoute({\n pattern: `${apiPath}/[...path]`,\n entrypoint: \"@kyro-cms/core/api-handler\",\n });\n \n // Inject admin routes if enabled\n if (admin) {\n try {\n // @ts-ignore\n const { ADMIN_ROUTES } = await import(\"@kyro-cms/admin/routes\");\n \n for (const route of ADMIN_ROUTES) {\n const pattern = adminPath + route.pattern;\n \n injectRoute({\n pattern,\n entrypoint: route.entrypoint,\n });\n }\n logger.info(`Mounted ${ADMIN_ROUTES.length} admin routes at ${adminPath}`);\n } catch (e) {\n logger.warn(\"Could not find @kyro-cms/admin/routes. Admin UI will not be available.\");\n }\n }\n },\n },\n };\n}\n"]}
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+ var fs = require('fs');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var path__default = /*#__PURE__*/_interopDefault(path);
9
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
10
+
11
+ // src/integration.ts
12
+ function kyro(options = {}) {
13
+ const {
14
+ configPath = "./kyro.config.ts",
15
+ apiPath = "/api",
16
+ adminPath = "/admin",
17
+ admin = true
18
+ } = options;
19
+ return {
20
+ name: "@kyro-cms/core",
21
+ hooks: {
22
+ "astro:config:setup": async ({ config, updateConfig, injectRoute, logger }) => {
23
+ logger.info(`Setting up Kyro CMS (API: ${apiPath}, Admin: ${adminPath})`);
24
+ const resolvedConfigPath = path__default.default.resolve(config.root.pathname, configPath);
25
+ let finalConfigPath = resolvedConfigPath;
26
+ if (!fs__default.default.existsSync(resolvedConfigPath)) {
27
+ logger.warn(`Kyro config file not found at ${configPath}. The API will fail to boot if collections are needed.`);
28
+ }
29
+ updateConfig({
30
+ vite: {
31
+ resolve: {
32
+ alias: {
33
+ "kyro:config": finalConfigPath
34
+ }
35
+ },
36
+ define: {
37
+ __KYRO_API_PATH__: JSON.stringify(apiPath),
38
+ __KYRO_ADMIN_PATH__: JSON.stringify(adminPath)
39
+ }
40
+ }
41
+ });
42
+ injectRoute({
43
+ pattern: `${apiPath}/[...path]`,
44
+ entrypoint: "@kyro-cms/core/api-handler"
45
+ });
46
+ if (admin) {
47
+ try {
48
+ const { ADMIN_ROUTES } = await import('@kyro-cms/admin/routes');
49
+ for (const route of ADMIN_ROUTES) {
50
+ const pattern = adminPath + route.pattern;
51
+ injectRoute({
52
+ pattern,
53
+ entrypoint: route.entrypoint
54
+ });
55
+ }
56
+ logger.info(`Mounted ${ADMIN_ROUTES.length} admin routes at ${adminPath}`);
57
+ } catch (e) {
58
+ logger.warn("Could not find @kyro-cms/admin/routes. Admin UI will not be available.");
59
+ }
60
+ }
61
+ }
62
+ }
63
+ };
64
+ }
65
+
66
+ exports.kyro = kyro;
67
+ //# sourceMappingURL=chunk-GBH6DN5C.cjs.map
68
+ //# sourceMappingURL=chunk-GBH6DN5C.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/integration.ts"],"names":["path","fs"],"mappings":";;;;;;;;;;;AA2Be,SAAR,IAAA,CAAsB,OAAA,GAAkC,EAAC,EAAqB;AACnF,EAAA,MAAM;AAAA,IACJ,UAAA,GAAa,kBAAA;AAAA,IACb,OAAA,GAAU,MAAA;AAAA,IACV,SAAA,GAAY,QAAA;AAAA,IACZ,KAAA,GAAQ;AAAA,GACV,GAAI,OAAA;AAEJ,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AAA;AAAA,gBACA,YAAY,KAAA,CAAM;AAAA,eACnB,CAAA;AAAA,YACH;AACA,YAAA,MAAA,CAAO,KAAK,CAAA,QAAA,EAAW,YAAA,CAAa,MAAM,CAAA,iBAAA,EAAoB,SAAS,CAAA,CAAE,CAAA;AAAA,UAC3E,SAAS,CAAA,EAAG;AACV,YAAA,MAAA,CAAO,KAAK,wEAAwE,CAAA;AAAA,UACtF;AAAA,QACF;AAAA,MACF;AAAA;AACF,GACF;AACF","file":"chunk-GBH6DN5C.cjs","sourcesContent":["import type { AstroIntegration } from \"astro\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport interface KyroIntegrationOptions {\n /**\n * Path to the kyro configuration file relative to the project root.\n * Default: './kyro.config.ts'\n */\n configPath?: string;\n /**\n * Base path where the API should be mounted.\n * Default: '/api/kyro'\n */\n apiPath?: string;\n /**\n * Base path where the admin UI should be mounted.\n * Default: '/admin'\n */\n adminPath?: string;\n /**\n * Whether to mount the admin UI.\n * Default: true\n */\n admin?: boolean;\n}\n\nexport default function kyro(options: KyroIntegrationOptions = {}): AstroIntegration {\n const {\n configPath = \"./kyro.config.ts\",\n apiPath = \"/api\",\n adminPath = \"/admin\",\n admin = true,\n } = options;\n\n return {\n name: \"@kyro-cms/core\",\n hooks: {\n \"astro:config:setup\": async ({ config, updateConfig, injectRoute, logger }) => {\n logger.info(`Setting up Kyro CMS (API: ${apiPath}, Admin: ${adminPath})`);\n \n // Resolve config path\n const resolvedConfigPath = path.resolve(config.root.pathname, configPath);\n \n let finalConfigPath = resolvedConfigPath;\n if (!fs.existsSync(resolvedConfigPath)) {\n logger.warn(`Kyro config file not found at ${configPath}. The API will fail to boot if collections are needed.`);\n // If we had a default fallback, we could set it here\n }\n \n // Add Vite configuration so the API handler can import the config\n updateConfig({\n vite: {\n resolve: {\n alias: {\n \"kyro:config\": finalConfigPath,\n },\n },\n define: {\n __KYRO_API_PATH__: JSON.stringify(apiPath),\n __KYRO_ADMIN_PATH__: JSON.stringify(adminPath),\n },\n },\n });\n \n // Inject the core API routes\n // This mounts our Hono app or Astro endpoints to handle backend requests\n injectRoute({\n pattern: `${apiPath}/[...path]`,\n entrypoint: \"@kyro-cms/core/api-handler\",\n });\n \n // Inject admin routes if enabled\n if (admin) {\n try {\n // @ts-ignore\n const { ADMIN_ROUTES } = await import(\"@kyro-cms/admin/routes\");\n \n for (const route of ADMIN_ROUTES) {\n const pattern = adminPath + route.pattern;\n \n injectRoute({\n pattern,\n entrypoint: route.entrypoint,\n });\n }\n logger.info(`Mounted ${ADMIN_ROUTES.length} admin routes at ${adminPath}`);\n } catch (e) {\n logger.warn(\"Could not find @kyro-cms/admin/routes. Admin UI will not be available.\");\n }\n }\n },\n },\n };\n}\n"]}
package/dist/index.cjs CHANGED
@@ -3,6 +3,7 @@
3
3
  var chunkH4XCAPA6_cjs = require('./chunk-H4XCAPA6.cjs');
4
4
  var chunkXJ2VYR47_cjs = require('./chunk-XJ2VYR47.cjs');
5
5
  var chunkZ2OVHWHB_cjs = require('./chunk-Z2OVHWHB.cjs');
6
+ var chunkGBH6DN5C_cjs = require('./chunk-GBH6DN5C.cjs');
6
7
  var chunkAGAIUDAV_cjs = require('./chunk-AGAIUDAV.cjs');
7
8
  var chunkN4H37VN4_cjs = require('./chunk-N4H37VN4.cjs');
8
9
  var chunkATBOUGQP_cjs = require('./chunk-ATBOUGQP.cjs');
@@ -2722,6 +2723,10 @@ Object.defineProperty(exports, "minimalCollections", {
2722
2723
  enumerable: true,
2723
2724
  get: function () { return chunkZ2OVHWHB_cjs.minimalCollections; }
2724
2725
  });
2726
+ Object.defineProperty(exports, "kyro", {
2727
+ enumerable: true,
2728
+ get: function () { return chunkGBH6DN5C_cjs.kyro; }
2729
+ });
2725
2730
  Object.defineProperty(exports, "ConfigValidationError", {
2726
2731
  enumerable: true,
2727
2732
  get: function () { return chunkAGAIUDAV_cjs.ConfigValidationError; }