@kyro-cms/core 0.10.4 → 0.10.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.
- package/dist/api-handler-graphql.cjs +1 -49
- package/dist/api-handler-graphql.js +1 -46
- package/dist/api-handler-trpc.cjs +1 -38
- package/dist/api-handler-trpc.js +1 -36
- package/dist/api-handler.cjs +1 -44
- package/dist/api-handler.js +1 -27
- package/dist/bootstrap-HIAV5ZFT.cjs +1 -0
- package/dist/bootstrap-P7QPQYQP.js +1 -0
- package/dist/chunk-2BTRHVT3.cjs +20 -0
- package/dist/chunk-2W4FK6CJ.js +122 -0
- package/dist/chunk-4ORJMSJU.cjs +1 -0
- package/dist/chunk-65G73T7Z.cjs +2 -0
- package/dist/chunk-7N6NKCRT.js +1 -0
- package/dist/chunk-7WOX27LK.js +259 -0
- package/dist/chunk-AE6GXUT7.js +1 -0
- package/dist/chunk-AJAZ7D3W.cjs +259 -0
- package/dist/chunk-ATLSIYRH.cjs +1 -0
- package/dist/chunk-AU6IWTBO.js +2 -0
- package/dist/chunk-CDL7ARXT.js +133 -0
- package/dist/chunk-CUTFS6N2.cjs +1 -0
- package/dist/chunk-CVVW4LXZ.cjs +1 -0
- package/dist/chunk-DGJUBN33.js +1 -0
- package/dist/chunk-DV4LFLPL.cjs +1 -0
- package/dist/chunk-EEWCANFX.js +1 -0
- package/dist/chunk-ELICKLFM.cjs +3 -0
- package/dist/chunk-EQUQJBPP.cjs +2 -0
- package/dist/chunk-ET6NN2V2.cjs +122 -0
- package/dist/chunk-F7P36SLX.cjs +74 -0
- package/dist/chunk-F7SR5IDT.cjs +1 -0
- package/dist/chunk-FO3HLBC7.js +1 -0
- package/dist/chunk-FS7GL2BR.js +73 -0
- package/dist/chunk-G6A7OSIG.js +2 -0
- package/dist/chunk-GFU7AOI3.cjs +1 -0
- package/dist/chunk-GYQMNXXW.cjs +114 -0
- package/dist/chunk-HLSB2MCK.js +1 -0
- package/dist/chunk-HVXO3OFB.cjs +1 -0
- package/dist/chunk-IFJJ44OQ.cjs +133 -0
- package/dist/chunk-ISWMETHJ.cjs +1 -0
- package/dist/chunk-K6WUOU6P.js +1 -0
- package/dist/chunk-KDNYHLD2.js +1 -0
- package/dist/chunk-KIW36TG7.cjs +86 -0
- package/dist/chunk-L6CZYN3L.cjs +20 -0
- package/dist/chunk-LRGAPGG3.js +74 -0
- package/dist/chunk-LZ6YFYQM.js +20 -0
- package/dist/chunk-MIOMMB23.cjs +1 -0
- package/dist/chunk-NGBJKZMT.js +90 -0
- package/dist/chunk-NRLIGDYF.js +1 -0
- package/dist/chunk-NY47CFVP.cjs +1 -0
- package/dist/chunk-NZ35PV5R.js +2 -0
- package/dist/chunk-OG7CNQGU.js +1 -0
- package/dist/chunk-OQD3WG6Z.cjs +1 -0
- package/dist/chunk-P7CESLDJ.js +1 -0
- package/dist/chunk-PP5S2UBV.js +0 -0
- package/dist/chunk-Q3Q7BJVQ.cjs +1 -0
- package/dist/chunk-Q4CSLXCO.cjs +90 -0
- package/dist/chunk-QRXDCV6K.js +0 -0
- package/dist/chunk-R7DVVXXI.cjs +73 -0
- package/dist/chunk-RHCWCG3O.js +114 -0
- package/dist/chunk-SL3LZQCF.js +1 -0
- package/dist/chunk-UBHFUFD4.cjs +1 -0
- package/dist/chunk-UBRYJP2G.js +1 -0
- package/dist/chunk-UDSJGML2.cjs +2 -0
- package/dist/chunk-UHFDH3PG.js +20 -0
- package/dist/chunk-UJNSOOYZ.cjs +1 -0
- package/dist/chunk-URCLFIME.js +86 -0
- package/dist/chunk-UVTS2IWM.js +1 -0
- package/dist/chunk-V65NPSR5.cjs +1 -0
- package/dist/chunk-WIZ6C5QZ.cjs +1 -0
- package/dist/chunk-ZAQOSRP6.js +1 -0
- package/dist/chunk-ZELCS7IC.js +3 -0
- package/dist/cli/index.cjs +35 -405
- package/dist/cli/index.js +35 -402
- package/dist/client.cjs +1 -55
- package/dist/client.js +1 -6
- package/dist/drizzle/index.cjs +1 -50
- package/dist/drizzle/index.d.cts +1 -2
- package/dist/drizzle/index.d.ts +1 -2
- package/dist/drizzle/index.js +1 -9
- package/dist/fields/index.cjs +1 -89
- package/dist/fields/index.js +1 -4
- package/dist/graphql/index.cjs +1 -31
- package/dist/graphql/index.d.cts +1 -1
- package/dist/graphql/index.d.ts +1 -1
- package/dist/graphql/index.js +1 -6
- package/dist/{index-jLs0zlft.d.ts → index-DXr33e0x.d.ts} +1 -1
- package/dist/{index-DHbywDs-.d.cts → index-DuuUzWBq.d.cts} +1 -1
- package/dist/index.cjs +29 -2464
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +29 -1929
- package/dist/integration.cjs +1 -10
- package/dist/integration.js +1 -4
- package/dist/media-NSSMOB7N.cjs +1 -0
- package/dist/media-RNMCZYPZ.js +1 -0
- package/dist/mongo-auth-adapter-JYJ4GBZE.cjs +1 -0
- package/dist/mongo-auth-adapter-XI7EPURZ.js +1 -0
- package/dist/mongodb/index.cjs +1 -29
- package/dist/mongodb/index.d.cts +1 -2
- package/dist/mongodb/index.d.ts +1 -2
- package/dist/mongodb/index.js +1 -8
- package/dist/postgres-auth-adapter-E7OGMDD4.cjs +1 -0
- package/dist/postgres-auth-adapter-F4KLOGAG.js +1 -0
- package/dist/redis-adapter-AQJVABYT.cjs +1 -0
- package/dist/redis-adapter-AUKOV74G.js +1 -0
- package/dist/rest/index.cjs +1 -31
- package/dist/rest/index.d.cts +1 -1
- package/dist/rest/index.d.ts +1 -1
- package/dist/rest/index.js +1 -18
- package/dist/schema-5XNROI7I.js +1 -0
- package/dist/schema-6O4JTJRU.cjs +1 -0
- package/dist/sqlite-adapter-5XFLNJDH.js +1 -0
- package/dist/sqlite-adapter-W53Q32N5.cjs +1 -0
- package/dist/templates/index.cjs +1 -207
- package/dist/templates/index.js +1 -6
- package/dist/trpc/index.cjs +1 -48
- package/dist/trpc/index.js +1 -7
- package/dist/ws/index.cjs +1 -25
- package/dist/ws/index.js +1 -4
- package/package.json +44 -13
- package/dist/api-handler-graphql.cjs.map +0 -1
- package/dist/api-handler-graphql.js.map +0 -1
- package/dist/api-handler-trpc.cjs.map +0 -1
- package/dist/api-handler-trpc.js.map +0 -1
- package/dist/api-handler.cjs.map +0 -1
- package/dist/api-handler.js.map +0 -1
- package/dist/bootstrap-FUAPY2OF.cjs +0 -32
- package/dist/bootstrap-FUAPY2OF.cjs.map +0 -1
- package/dist/bootstrap-OXNVM7FP.js +0 -7
- package/dist/bootstrap-OXNVM7FP.js.map +0 -1
- package/dist/chunk-2HFJUUFZ.js +0 -250
- package/dist/chunk-2HFJUUFZ.js.map +0 -1
- package/dist/chunk-3AKCVYDB.js +0 -162
- package/dist/chunk-3AKCVYDB.js.map +0 -1
- package/dist/chunk-3KTWGODI.cjs +0 -178
- package/dist/chunk-3KTWGODI.cjs.map +0 -1
- package/dist/chunk-3YELQL7Z.cjs +0 -4
- package/dist/chunk-3YELQL7Z.cjs.map +0 -1
- package/dist/chunk-4CV4JOE5.js +0 -24
- package/dist/chunk-4CV4JOE5.js.map +0 -1
- package/dist/chunk-4OCMVGEY.cjs +0 -173
- package/dist/chunk-4OCMVGEY.cjs.map +0 -1
- package/dist/chunk-4PWRCMTQ.cjs +0 -15
- package/dist/chunk-4PWRCMTQ.cjs.map +0 -1
- package/dist/chunk-53NYVYVX.js +0 -3243
- package/dist/chunk-53NYVYVX.js.map +0 -1
- package/dist/chunk-5GFQPHGT.cjs +0 -156
- package/dist/chunk-5GFQPHGT.cjs.map +0 -1
- package/dist/chunk-5RPRLTTN.js +0 -861
- package/dist/chunk-5RPRLTTN.js.map +0 -1
- package/dist/chunk-74YSDAWE.cjs +0 -2749
- package/dist/chunk-74YSDAWE.cjs.map +0 -1
- package/dist/chunk-7OGPN7MP.js +0 -352
- package/dist/chunk-7OGPN7MP.js.map +0 -1
- package/dist/chunk-7OS7TX2Q.cjs +0 -495
- package/dist/chunk-7OS7TX2Q.cjs.map +0 -1
- package/dist/chunk-ADLJSJSN.cjs +0 -13
- package/dist/chunk-ADLJSJSN.cjs.map +0 -1
- package/dist/chunk-B6X3LN25.cjs +0 -6486
- package/dist/chunk-B6X3LN25.cjs.map +0 -1
- package/dist/chunk-BYBMTIMT.js +0 -419
- package/dist/chunk-BYBMTIMT.js.map +0 -1
- package/dist/chunk-CF7OL6HR.js +0 -355
- package/dist/chunk-CF7OL6HR.js.map +0 -1
- package/dist/chunk-CJX74IYK.js +0 -489
- package/dist/chunk-CJX74IYK.js.map +0 -1
- package/dist/chunk-CKVOU6MX.cjs +0 -52
- package/dist/chunk-CKVOU6MX.cjs.map +0 -1
- package/dist/chunk-CZLDE2OZ.cjs +0 -28
- package/dist/chunk-CZLDE2OZ.cjs.map +0 -1
- package/dist/chunk-DPA3KWPY.cjs +0 -205
- package/dist/chunk-DPA3KWPY.cjs.map +0 -1
- package/dist/chunk-EEJUFDMF.cjs +0 -424
- package/dist/chunk-EEJUFDMF.cjs.map +0 -1
- package/dist/chunk-FIAMXNTH.js +0 -220
- package/dist/chunk-FIAMXNTH.js.map +0 -1
- package/dist/chunk-GAOXD3XT.js +0 -175
- package/dist/chunk-GAOXD3XT.js.map +0 -1
- package/dist/chunk-GTGRLD4Y.js +0 -3
- package/dist/chunk-GTGRLD4Y.js.map +0 -1
- package/dist/chunk-GUUB5EAG.cjs +0 -223
- package/dist/chunk-GUUB5EAG.cjs.map +0 -1
- package/dist/chunk-GXFOGU7N.cjs +0 -359
- package/dist/chunk-GXFOGU7N.cjs.map +0 -1
- package/dist/chunk-GZS4LMR7.js +0 -422
- package/dist/chunk-GZS4LMR7.js.map +0 -1
- package/dist/chunk-HY6B7B5A.js +0 -150
- package/dist/chunk-HY6B7B5A.js.map +0 -1
- package/dist/chunk-HZOMOK5Y.js +0 -2728
- package/dist/chunk-HZOMOK5Y.js.map +0 -1
- package/dist/chunk-IDVRRRAK.cjs +0 -824
- package/dist/chunk-IDVRRRAK.cjs.map +0 -1
- package/dist/chunk-KC2GDBLS.cjs +0 -84
- package/dist/chunk-KC2GDBLS.cjs.map +0 -1
- package/dist/chunk-L4EZKIEX.js +0 -185
- package/dist/chunk-L4EZKIEX.js.map +0 -1
- package/dist/chunk-LNTFRAHF.cjs +0 -473
- package/dist/chunk-LNTFRAHF.cjs.map +0 -1
- package/dist/chunk-MTIRYI7F.cjs +0 -4
- package/dist/chunk-MTIRYI7F.cjs.map +0 -1
- package/dist/chunk-N4GN6Q3V.cjs +0 -869
- package/dist/chunk-N4GN6Q3V.cjs.map +0 -1
- package/dist/chunk-N4H37VN4.cjs +0 -259
- package/dist/chunk-N4H37VN4.cjs.map +0 -1
- package/dist/chunk-N5QSHUA6.js +0 -1135
- package/dist/chunk-N5QSHUA6.js.map +0 -1
- package/dist/chunk-NKPKR5BW.cjs +0 -188
- package/dist/chunk-NKPKR5BW.cjs.map +0 -1
- package/dist/chunk-OIRG6ZRV.cjs +0 -1073
- package/dist/chunk-OIRG6ZRV.cjs.map +0 -1
- package/dist/chunk-OJ2AM75W.cjs +0 -253
- package/dist/chunk-OJ2AM75W.cjs.map +0 -1
- package/dist/chunk-OLV7K22H.js +0 -6457
- package/dist/chunk-OLV7K22H.js.map +0 -1
- package/dist/chunk-OX6GOIPH.js +0 -516
- package/dist/chunk-OX6GOIPH.js.map +0 -1
- package/dist/chunk-P2YW545G.js +0 -11
- package/dist/chunk-P2YW545G.js.map +0 -1
- package/dist/chunk-PHJRNPHY.cjs +0 -3291
- package/dist/chunk-PHJRNPHY.cjs.map +0 -1
- package/dist/chunk-Q72BOAPK.js +0 -817
- package/dist/chunk-Q72BOAPK.js.map +0 -1
- package/dist/chunk-QU2RFFH4.js +0 -3
- package/dist/chunk-QU2RFFH4.js.map +0 -1
- package/dist/chunk-RP7VZUEL.js +0 -49
- package/dist/chunk-RP7VZUEL.js.map +0 -1
- package/dist/chunk-SHTTJMLT.cjs +0 -361
- package/dist/chunk-SHTTJMLT.cjs.map +0 -1
- package/dist/chunk-SX76DNOO.js +0 -103
- package/dist/chunk-SX76DNOO.js.map +0 -1
- package/dist/chunk-THBQG64D.cjs +0 -425
- package/dist/chunk-THBQG64D.cjs.map +0 -1
- package/dist/chunk-TQG7G7YI.cjs +0 -526
- package/dist/chunk-TQG7G7YI.cjs.map +0 -1
- package/dist/chunk-U3VVLYXG.cjs +0 -189
- package/dist/chunk-U3VVLYXG.cjs.map +0 -1
- package/dist/chunk-UUDTPZX6.js +0 -193
- package/dist/chunk-UUDTPZX6.js.map +0 -1
- package/dist/chunk-V5AWATUP.js +0 -1059
- package/dist/chunk-V5AWATUP.js.map +0 -1
- package/dist/chunk-VAXLFZCV.cjs +0 -110
- package/dist/chunk-VAXLFZCV.cjs.map +0 -1
- package/dist/chunk-VKREAIBA.cjs +0 -1139
- package/dist/chunk-VKREAIBA.cjs.map +0 -1
- package/dist/chunk-WDTTHKDS.js +0 -458
- package/dist/chunk-WDTTHKDS.js.map +0 -1
- package/dist/chunk-WXVB364T.js +0 -218
- package/dist/chunk-WXVB364T.js.map +0 -1
- package/dist/chunk-X4BPPD6K.js +0 -181
- package/dist/chunk-X4BPPD6K.js.map +0 -1
- package/dist/chunk-XEB7PH2E.js +0 -81
- package/dist/chunk-XEB7PH2E.js.map +0 -1
- package/dist/chunk-YT7HXXVN.js +0 -13
- package/dist/chunk-YT7HXXVN.js.map +0 -1
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/client.cjs.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/drizzle/index.cjs.map +0 -1
- package/dist/drizzle/index.js.map +0 -1
- package/dist/fields/index.cjs.map +0 -1
- package/dist/fields/index.js.map +0 -1
- package/dist/graphql/index.cjs.map +0 -1
- package/dist/graphql/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integration.cjs.map +0 -1
- package/dist/integration.js.map +0 -1
- package/dist/media-7WDX4BDJ.js +0 -4
- package/dist/media-7WDX4BDJ.js.map +0 -1
- package/dist/media-TUSLVRQ6.cjs +0 -17
- package/dist/media-TUSLVRQ6.cjs.map +0 -1
- package/dist/mongo-auth-adapter-GT4S7SCU.cjs +0 -17
- package/dist/mongo-auth-adapter-GT4S7SCU.cjs.map +0 -1
- package/dist/mongo-auth-adapter-M7VV4LNB.js +0 -4
- package/dist/mongo-auth-adapter-M7VV4LNB.js.map +0 -1
- package/dist/mongodb/index.cjs.map +0 -1
- package/dist/mongodb/index.js.map +0 -1
- package/dist/postgres-auth-adapter-AFAPISH7.js +0 -5
- package/dist/postgres-auth-adapter-AFAPISH7.js.map +0 -1
- package/dist/postgres-auth-adapter-SFDTLONT.cjs +0 -14
- package/dist/postgres-auth-adapter-SFDTLONT.cjs.map +0 -1
- package/dist/redis-adapter-UQX4EE3B.cjs +0 -13
- package/dist/redis-adapter-UQX4EE3B.cjs.map +0 -1
- package/dist/redis-adapter-XALOGWY3.js +0 -4
- package/dist/redis-adapter-XALOGWY3.js.map +0 -1
- package/dist/rest/index.cjs.map +0 -1
- package/dist/rest/index.js.map +0 -1
- package/dist/schema-6QL3USNB.cjs +0 -67
- package/dist/schema-6QL3USNB.cjs.map +0 -1
- package/dist/schema-FNNWEAAW.js +0 -6
- package/dist/schema-FNNWEAAW.js.map +0 -1
- package/dist/sqlite-adapter-AQB5TCGV.cjs +0 -13
- package/dist/sqlite-adapter-AQB5TCGV.cjs.map +0 -1
- package/dist/sqlite-adapter-N5H6IM2X.js +0 -4
- package/dist/sqlite-adapter-N5H6IM2X.js.map +0 -1
- package/dist/templates/index.cjs.map +0 -1
- package/dist/templates/index.js.map +0 -1
- package/dist/trpc/index.cjs.map +0 -1
- package/dist/trpc/index.js.map +0 -1
- package/dist/ws/index.cjs.map +0 -1
- package/dist/ws/index.js.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,94 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
case "email":
|
|
13
|
-
case "password":
|
|
14
|
-
case "textarea":
|
|
15
|
-
case "color":
|
|
16
|
-
case "code":
|
|
17
|
-
case "markdown":
|
|
18
|
-
case "date":
|
|
19
|
-
case "richtext":
|
|
20
|
-
case "json":
|
|
21
|
-
return field.hasMany ? "string[]" : "string";
|
|
22
|
-
case "number":
|
|
23
|
-
return field.hasMany ? "number[]" : "number";
|
|
24
|
-
case "checkbox":
|
|
25
|
-
return "boolean";
|
|
26
|
-
case "select":
|
|
27
|
-
case "radio":
|
|
28
|
-
if (field.options) {
|
|
29
|
-
const values = field.options.map((o) => `'${o.value}'`).join(" | ");
|
|
30
|
-
return field.hasMany ? `(${values})[]` : values;
|
|
31
|
-
}
|
|
32
|
-
return field.hasMany ? "string[]" : "string";
|
|
33
|
-
case "relationship":
|
|
34
|
-
if (Array.isArray(field.relationTo)) {
|
|
35
|
-
const types = field.relationTo.map((r) => `${capitalize(r)} | string`).join(" | ");
|
|
36
|
-
return field.hasMany ? `(${types})[]` : `(${types})`;
|
|
37
|
-
}
|
|
38
|
-
const relTo = field.relationTo || "unknown";
|
|
39
|
-
return field.hasMany ? `(${capitalize(relTo)} | string)[]` : `${capitalize(relTo)} | string`;
|
|
40
|
-
case "upload":
|
|
41
|
-
return field.hasMany ? "(Media | string)[]" : "Media | string";
|
|
42
|
-
case "array":
|
|
43
|
-
if (field.fields && field.fields.length > 0) {
|
|
44
|
-
const itemFields = field.fields.filter((f) => f.name).map((f) => {
|
|
45
|
-
const type = fieldToType(f);
|
|
46
|
-
return ` ${f.name}${f.required ? "" : "?"}: ${type};`;
|
|
47
|
-
}).join("\n");
|
|
48
|
-
return `Array<{
|
|
49
|
-
${itemFields}
|
|
50
|
-
}>`;
|
|
51
|
-
}
|
|
52
|
-
return "Record<string, any>[]";
|
|
53
|
-
case "group":
|
|
54
|
-
if (field.fields && field.fields.length > 0) {
|
|
55
|
-
const itemFields = field.fields.filter((f) => f.name).map((f) => {
|
|
56
|
-
const type = fieldToType(f);
|
|
57
|
-
return ` ${f.name}${f.required ? "" : "?"}: ${type};`;
|
|
58
|
-
}).join("\n");
|
|
59
|
-
return `{
|
|
60
|
-
${itemFields}
|
|
61
|
-
}`;
|
|
62
|
-
}
|
|
63
|
-
return "Record<string, any>";
|
|
64
|
-
case "blocks":
|
|
65
|
-
return "Block[]";
|
|
66
|
-
default:
|
|
67
|
-
return "any";
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function capitalize(str) {
|
|
71
|
-
return str.charAt(0).toUpperCase() + str.slice(1).replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
72
|
-
}
|
|
73
|
-
function toCamel(str) {
|
|
74
|
-
return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
75
|
-
}
|
|
76
|
-
function collectionToInterface(collection) {
|
|
77
|
-
const name = capitalize(collection.slug);
|
|
78
|
-
const fields = collection.fields.filter((f) => f.name).map((f) => {
|
|
79
|
-
const type = fieldToType(f);
|
|
80
|
-
return ` ${f.name}${f.required ? "" : "?"}: ${type};`;
|
|
81
|
-
});
|
|
82
|
-
fields.unshift(" id: string;");
|
|
83
|
-
fields.push(" createdAt: string;");
|
|
84
|
-
fields.push(" updatedAt: string;");
|
|
85
|
-
return `export interface ${name} {
|
|
86
|
-
${fields.join("\n")}
|
|
87
|
-
}`;
|
|
88
|
-
}
|
|
89
|
-
function generateTypes(collections) {
|
|
90
|
-
const interfaces = collections.map((c) => collectionToInterface(c));
|
|
91
|
-
const header = `// ============================================================================
|
|
2
|
+
import'../chunk-DGJUBN33.js';import {Command}from'commander';import {readFileSync,existsSync,mkdirSync,writeFileSync}from'fs';import {dirname,join,resolve}from'path';import {fileURLToPath}from'url';import {glob}from'glob';function y(e){switch(e.type){case "text":case "email":case "password":case "textarea":case "color":case "code":case "markdown":case "date":case "richtext":case "json":return e.hasMany?"string[]":"string";case "number":return e.hasMany?"number[]":"number";case "checkbox":return "boolean";case "select":case "radio":if(e.options){let t=e.options.map(r=>`'${r.value}'`).join(" | ");return e.hasMany?`(${t})[]`:t}return e.hasMany?"string[]":"string";case "relationship":if(Array.isArray(e.relationTo)){let t=e.relationTo.map(r=>`${m(r)} | string`).join(" | ");return e.hasMany?`(${t})[]`:`(${t})`}let n=e.relationTo||"unknown";return e.hasMany?`(${m(n)} | string)[]`:`${m(n)} | string`;case "upload":return e.hasMany?"(Media | string)[]":"Media | string";case "array":return e.fields&&e.fields.length>0?`Array<{
|
|
3
|
+
${e.fields.filter(r=>r.name).map(r=>{let o=y(r);return ` ${r.name}${r.required?"":"?"}: ${o};`}).join(`
|
|
4
|
+
`)}
|
|
5
|
+
}>`:"Record<string, any>[]";case "group":return e.fields&&e.fields.length>0?`{
|
|
6
|
+
${e.fields.filter(r=>r.name).map(r=>{let o=y(r);return ` ${r.name}${r.required?"":"?"}: ${o};`}).join(`
|
|
7
|
+
`)}
|
|
8
|
+
}`:"Record<string, any>";case "blocks":return "Block[]";default:return "any"}}function m(e){return e.charAt(0).toUpperCase()+e.slice(1).replace(/-([a-z])/g,(n,t)=>t.toUpperCase())}function C(e){return e.replace(/-([a-z])/g,(n,t)=>t.toUpperCase())}function M(e){let n=m(e.slug),t=e.fields.filter(r=>r.name).map(r=>{let o=y(r);return ` ${r.name}${r.required?"":"?"}: ${o};`});return t.unshift(" id: string;"),t.push(" createdAt: string;"),t.push(" updatedAt: string;"),`export interface ${n} {
|
|
9
|
+
${t.join(`
|
|
10
|
+
`)}
|
|
11
|
+
}`}function T(e){let n=e.map(s=>M(s)),t=`// ============================================================================
|
|
92
12
|
// Auto-generated by kyro generate
|
|
93
13
|
// ============================================================================
|
|
94
14
|
|
|
@@ -111,9 +31,9 @@ export interface Block {
|
|
|
111
31
|
[key: string]: any;
|
|
112
32
|
}
|
|
113
33
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
34
|
+
`,r=n.join(`
|
|
35
|
+
|
|
36
|
+
`),o=`
|
|
117
37
|
|
|
118
38
|
// ============================================================================
|
|
119
39
|
// Query Types
|
|
@@ -176,7 +96,8 @@ export interface KyroDeleteResult<T> {
|
|
|
176
96
|
// ============================================================================
|
|
177
97
|
|
|
178
98
|
export interface KyroCollections {
|
|
179
|
-
${
|
|
99
|
+
${e.map(s=>` ${C(s.slug)}: ${m(s.slug)};`).join(`
|
|
100
|
+
`)}
|
|
180
101
|
}
|
|
181
102
|
|
|
182
103
|
// ============================================================================
|
|
@@ -193,29 +114,15 @@ export interface KyroTypedClient<C extends keyof KyroCollections> {
|
|
|
193
114
|
}
|
|
194
115
|
|
|
195
116
|
export interface KyroClient {
|
|
196
|
-
${
|
|
117
|
+
${e.map(s=>` ${C(s.slug)}: KyroTypedClient<'${s.slug}'>;`).join(`
|
|
118
|
+
`)}
|
|
197
119
|
}
|
|
198
120
|
|
|
199
121
|
export function createClient(config: { url: string; token?: string }): KyroClient {
|
|
200
122
|
// Client implementation would be here
|
|
201
123
|
throw new Error('Not implemented');
|
|
202
124
|
}
|
|
203
|
-
`;
|
|
204
|
-
return header + body + footer;
|
|
205
|
-
}
|
|
206
|
-
async function fetchRemoteSchema(url, apiKey) {
|
|
207
|
-
const schemaUrl = `${url.replace(/\/+$/, "")}/api/__schema`;
|
|
208
|
-
const res = await fetch(schemaUrl, {
|
|
209
|
-
headers: { Authorization: `ApiKey ${apiKey}` }
|
|
210
|
-
});
|
|
211
|
-
if (!res.ok) {
|
|
212
|
-
const body = await res.text();
|
|
213
|
-
throw new Error(`Schema fetch failed (${res.status}): ${body}`);
|
|
214
|
-
}
|
|
215
|
-
return res.json();
|
|
216
|
-
}
|
|
217
|
-
function generateRemoteTypes(collections) {
|
|
218
|
-
let output = `// ============================================================================
|
|
125
|
+
`;return t+r+o}async function q(e,n){let t=`${e.replace(/\/+$/,"")}/api/__schema`,r=await fetch(t,{headers:{Authorization:`ApiKey ${n}`}});if(!r.ok){let o=await r.text();throw new Error(`Schema fetch failed (${r.status}): ${o}`)}return r.json()}function D(e){let n=`// ============================================================================
|
|
219
126
|
// Auto-generated by kyro generate --api
|
|
220
127
|
// ============================================================================
|
|
221
128
|
|
|
@@ -238,23 +145,12 @@ export interface Block {
|
|
|
238
145
|
[key: string]: any;
|
|
239
146
|
}
|
|
240
147
|
|
|
241
|
-
`;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const fields = col.fields.filter((f) => f.name).map((f) => {
|
|
245
|
-
const type = fieldToType(f);
|
|
246
|
-
return ` ${f.name}${f.required ? "" : "?"}: ${type};`;
|
|
247
|
-
});
|
|
248
|
-
fields.unshift(" id: string;");
|
|
249
|
-
fields.push(" createdAt: string;");
|
|
250
|
-
fields.push(" updatedAt: string;");
|
|
251
|
-
output += `export interface ${name} {
|
|
252
|
-
${fields.join("\n")}
|
|
148
|
+
`;for(let t of e){let r=m(t.slug),o=t.fields.filter(s=>s.name).map(s=>{let i=y(s);return ` ${s.name}${s.required?"":"?"}: ${i};`});o.unshift(" id: string;"),o.push(" createdAt: string;"),o.push(" updatedAt: string;"),n+=`export interface ${r} {
|
|
149
|
+
${o.join(`
|
|
150
|
+
`)}
|
|
253
151
|
}
|
|
254
152
|
|
|
255
|
-
`;
|
|
256
|
-
}
|
|
257
|
-
output += `// ============================================================================
|
|
153
|
+
`;}return n+=`// ============================================================================
|
|
258
154
|
// Typed REST Client
|
|
259
155
|
// ============================================================================
|
|
260
156
|
|
|
@@ -293,286 +189,23 @@ export function createKyroClient(opts: KyroClientOptions) {
|
|
|
293
189
|
}
|
|
294
190
|
|
|
295
191
|
return {
|
|
296
|
-
${
|
|
297
|
-
const name = capitalize(col.slug);
|
|
298
|
-
return ` ${toCamel(col.slug)}: {
|
|
192
|
+
${e.map(t=>{let r=m(t.slug);return ` ${C(t.slug)}: {
|
|
299
193
|
find: (args?: { where?: Record<string, any>; sort?: string; limit?: number; page?: number; draft?: boolean }) =>
|
|
300
|
-
request<{ docs: ${
|
|
194
|
+
request<{ docs: ${r}[]; totalDocs: number; page: number; totalPages: number; hasNextPage: boolean; hasPrevPage: boolean }>(\`/${t.slug}\${args ? "?" + qs(args) : ""}\`),
|
|
301
195
|
findByID: (id: string, args?: { draft?: boolean }) =>
|
|
302
|
-
request<${
|
|
196
|
+
request<${r}>(\`/${t.slug}/\${id}\${args ? "?" + qs(args) : ""}\`),
|
|
303
197
|
findBySlug: (slug: string, args?: { draft?: boolean }) =>
|
|
304
|
-
request<{ docs: ${
|
|
305
|
-
create: (data: Partial<${
|
|
306
|
-
request<{ doc: ${
|
|
307
|
-
update: (id: string, data: Partial<${
|
|
308
|
-
request<{ doc: ${
|
|
198
|
+
request<{ docs: ${r}[] }>(\`/${t.slug}?where=\${encodeURIComponent(JSON.stringify({ slug: { equals: slug } }))}\`),
|
|
199
|
+
create: (data: Partial<${r}>) =>
|
|
200
|
+
request<{ doc: ${r}; message?: string }>(\`/${t.slug}\`, { method: "POST", body: JSON.stringify(data) }),
|
|
201
|
+
update: (id: string, data: Partial<${r}>, args?: { baseUpdatedAt?: string }) =>
|
|
202
|
+
request<{ doc: ${r}; message?: string }>(\`/${t.slug}/\${id}\`, { method: "PATCH", body: JSON.stringify({ ...data, ...args }) }),
|
|
309
203
|
delete: (id: string) =>
|
|
310
|
-
request<{ doc: ${
|
|
204
|
+
request<{ doc: ${r}; message: string }>(\`/${t.slug}/\${id}\`, { method: "DELETE" }),
|
|
311
205
|
count: (args?: { where?: Record<string, any> }) =>
|
|
312
|
-
request<{ totalDocs: number }>(\`/${
|
|
313
|
-
}
|
|
314
|
-
|
|
206
|
+
request<{ totalDocs: number }>(\`/${t.slug}/count\${args ? "?" + qs(args) : ""}\`),
|
|
207
|
+
},`}).join(`
|
|
208
|
+
`)}
|
|
315
209
|
};
|
|
316
210
|
}
|
|
317
|
-
|
|
318
|
-
return output;
|
|
319
|
-
}
|
|
320
|
-
function createGenerateCommand() {
|
|
321
|
-
const generate = new Command("generate").description("Generate TypeScript types from collection configs").option("-c, --config <path>", "Path to config file or directory", "./src/kyro").option("-o, --output <path>", "Output file path", "./src/types/kyro.d.ts").option("-w, --watch", "Watch for changes and regenerate").option("--url <url>", "URL of a running Kyro CMS instance (enables remote mode)").option("--api-key <key>", "API key for authentication (required with --url)").action(async (options) => {
|
|
322
|
-
if (options.url) {
|
|
323
|
-
if (!options.url) {
|
|
324
|
-
console.error("\u274C --url is required when using --api");
|
|
325
|
-
process.exit(1);
|
|
326
|
-
}
|
|
327
|
-
if (!options.apiKey) {
|
|
328
|
-
console.error("\u274C --api-key is required when using --api");
|
|
329
|
-
process.exit(1);
|
|
330
|
-
}
|
|
331
|
-
const outputPath2 = resolve(options.output);
|
|
332
|
-
try {
|
|
333
|
-
const collections = await fetchRemoteSchema(options.url, options.apiKey);
|
|
334
|
-
const types = generateRemoteTypes(collections);
|
|
335
|
-
const outputDir = join(outputPath2, "..");
|
|
336
|
-
if (!existsSync(outputDir)) {
|
|
337
|
-
mkdirSync(outputDir, { recursive: true });
|
|
338
|
-
}
|
|
339
|
-
writeFileSync(outputPath2, types);
|
|
340
|
-
} catch (error) {
|
|
341
|
-
console.error("\u274C Error:", error.message);
|
|
342
|
-
process.exit(1);
|
|
343
|
-
}
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const configPath = resolve(options.config);
|
|
347
|
-
const outputPath = resolve(options.output);
|
|
348
|
-
try {
|
|
349
|
-
const configFiles = await glob(`${configPath}/**/*.{ts,js}`);
|
|
350
|
-
if (configFiles.length === 0) {
|
|
351
|
-
console.error("\u274C No config files found at:", configPath);
|
|
352
|
-
process.exit(1);
|
|
353
|
-
}
|
|
354
|
-
const collections = [];
|
|
355
|
-
for (const file of configFiles) {
|
|
356
|
-
try {
|
|
357
|
-
const mod = await import(file);
|
|
358
|
-
const configs = Object.values(mod).filter((v) => v && v.slug && v.fields);
|
|
359
|
-
collections.push(...configs);
|
|
360
|
-
} catch (error) {
|
|
361
|
-
console.warn(`\u26A0\uFE0F Could not parse: ${file}`);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
if (collections.length === 0) {
|
|
365
|
-
console.error("\u274C No valid collection configs found");
|
|
366
|
-
process.exit(1);
|
|
367
|
-
}
|
|
368
|
-
const types = generateTypes(collections);
|
|
369
|
-
const outputDir = join(outputPath, "..");
|
|
370
|
-
if (!existsSync(outputDir)) {
|
|
371
|
-
mkdirSync(outputDir, { recursive: true });
|
|
372
|
-
}
|
|
373
|
-
writeFileSync(outputPath, types);
|
|
374
|
-
if (options.watch) {
|
|
375
|
-
const { watch } = await import('fs');
|
|
376
|
-
watch(configPath, { recursive: true }, async (eventType, filename) => {
|
|
377
|
-
const newCollections = [];
|
|
378
|
-
for (const file of configFiles) {
|
|
379
|
-
try {
|
|
380
|
-
const mod = await import(file + `?t=${Date.now()}`);
|
|
381
|
-
const configs = Object.values(mod).filter((v) => v && v.slug && v.fields);
|
|
382
|
-
newCollections.push(...configs);
|
|
383
|
-
} catch {
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
const newTypes = generateTypes(newCollections);
|
|
387
|
-
writeFileSync(outputPath, newTypes);
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
} catch (error) {
|
|
391
|
-
console.error("\u274C Error:", error.message);
|
|
392
|
-
process.exit(1);
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
return generate;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// src/cli/index.ts
|
|
399
|
-
var __filename$1 = fileURLToPath(import.meta.url);
|
|
400
|
-
var __dirname$1 = dirname(__filename$1);
|
|
401
|
-
var version = "0.1.0";
|
|
402
|
-
try {
|
|
403
|
-
const pkg = JSON.parse(
|
|
404
|
-
readFileSync(join(__dirname$1, "../../package.json"), "utf-8")
|
|
405
|
-
);
|
|
406
|
-
version = pkg.version;
|
|
407
|
-
} catch {
|
|
408
|
-
}
|
|
409
|
-
var program = new Command();
|
|
410
|
-
program.name("kyro").description("Kyro CMS - Astro-native headless CMS").version(version);
|
|
411
|
-
program.command("dev").description("Start Kyro CMS development server").option("-p, --port <port>", "Port to run on", "4321").option("-h, --host <host>", "Host to bind to", "localhost").action(async (options) => {
|
|
412
|
-
const { exec } = await import('child_process');
|
|
413
|
-
const child = exec(`astro dev --port ${options.port} --host ${options.host}`, {
|
|
414
|
-
env: { ...process.env, NODE_NO_WARNINGS: "1" }
|
|
415
|
-
});
|
|
416
|
-
child.stdout?.on("data", (data) => process.stdout.write(data));
|
|
417
|
-
child.stderr?.on("data", (data) => process.stderr.write(data));
|
|
418
|
-
process.on("SIGINT", () => {
|
|
419
|
-
child.kill("SIGINT");
|
|
420
|
-
process.exit(0);
|
|
421
|
-
});
|
|
422
|
-
process.on("SIGTERM", () => {
|
|
423
|
-
child.kill("SIGTERM");
|
|
424
|
-
process.exit(0);
|
|
425
|
-
});
|
|
426
|
-
});
|
|
427
|
-
program.addCommand(createGenerateCommand());
|
|
428
|
-
var dbCommand = program.command("db").description("Database management commands");
|
|
429
|
-
dbCommand.command("generate").description("Generate migrations from schema").action(async () => {
|
|
430
|
-
const { exec } = await import('child_process');
|
|
431
|
-
exec("npx drizzle-kit generate", (error, stdout, stderr) => {
|
|
432
|
-
if (error) {
|
|
433
|
-
console.error("\u274C Generation failed:", error.message);
|
|
434
|
-
process.exit(1);
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
});
|
|
438
|
-
dbCommand.command("migrate").description("Run database migrations").action(async () => {
|
|
439
|
-
const { exec } = await import('child_process');
|
|
440
|
-
exec("npx drizzle-kit migrate", (error, stdout, stderr) => {
|
|
441
|
-
if (error) {
|
|
442
|
-
console.error("\u274C Migration failed:", error.message);
|
|
443
|
-
process.exit(1);
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
});
|
|
447
|
-
dbCommand.command("push").description("Push schema to database (development)").action(async () => {
|
|
448
|
-
const { exec } = await import('child_process');
|
|
449
|
-
exec("npx drizzle-kit push", (error, stdout, stderr) => {
|
|
450
|
-
if (error) {
|
|
451
|
-
console.error("\u274C Push failed:", error.message);
|
|
452
|
-
process.exit(1);
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
});
|
|
456
|
-
dbCommand.command("seed").description("Seed database with initial data").action(async () => {
|
|
457
|
-
const { exec } = await import('child_process');
|
|
458
|
-
exec("npx tsx src/database/drizzle/seed.ts", (error, stdout, stderr) => {
|
|
459
|
-
if (error) {
|
|
460
|
-
console.error("\u274C Seeding failed:", error.message);
|
|
461
|
-
process.exit(1);
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
});
|
|
465
|
-
dbCommand.command("studio").description("Open Drizzle Studio").action(async () => {
|
|
466
|
-
const { exec } = await import('child_process');
|
|
467
|
-
exec("npx drizzle-kit studio", (error, stdout, stderr) => {
|
|
468
|
-
if (error) {
|
|
469
|
-
console.error("\u274C Studio failed:", error.message);
|
|
470
|
-
process.exit(1);
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
var authCommand = program.command("auth").description("Authentication management commands");
|
|
475
|
-
authCommand.command("bootstrap").description("Create initial admin user").option("-e, --email <email>", "Admin email", process.env.KYRO_ADMIN_EMAIL).option(
|
|
476
|
-
"-p, --password <password>",
|
|
477
|
-
"Admin password",
|
|
478
|
-
process.env.KYRO_ADMIN_PASSWORD
|
|
479
|
-
).option(
|
|
480
|
-
"-r, --role <role>",
|
|
481
|
-
"Admin role",
|
|
482
|
-
process.env.KYRO_ADMIN_ROLE || "admin"
|
|
483
|
-
).action(async (options) => {
|
|
484
|
-
if (!options.email || !options.password) {
|
|
485
|
-
console.error(
|
|
486
|
-
"\u274C Email and password are required. Set KYRO_ADMIN_EMAIL and KYRO_ADMIN_PASSWORD env vars or use -e and -p options."
|
|
487
|
-
);
|
|
488
|
-
process.exit(1);
|
|
489
|
-
}
|
|
490
|
-
try {
|
|
491
|
-
const { bootstrapAdmin } = await import('../bootstrap-OXNVM7FP.js');
|
|
492
|
-
const databaseUrl = process.env.DATABASE_URL || "";
|
|
493
|
-
const isPostgres = databaseUrl.toLowerCase().startsWith("postgres://") || databaseUrl.toLowerCase().startsWith("postgresql://");
|
|
494
|
-
const isMongo = databaseUrl.toLowerCase().startsWith("mongodb://") || databaseUrl.toLowerCase().startsWith("mongodb+srv://");
|
|
495
|
-
const isSQLite = !databaseUrl || databaseUrl.includes(".db") || databaseUrl.includes("sqlite") || databaseUrl.includes("file:");
|
|
496
|
-
let adapter;
|
|
497
|
-
if (isPostgres) {
|
|
498
|
-
const { PostgresAuthAdapter } = await import('../postgres-auth-adapter-AFAPISH7.js');
|
|
499
|
-
const { drizzle } = await import('drizzle-orm/postgres-js');
|
|
500
|
-
const { default: postgres } = await import('postgres');
|
|
501
|
-
const client = postgres(databaseUrl, { max: 1, onnotice: () => {
|
|
502
|
-
} });
|
|
503
|
-
const db = drizzle(client);
|
|
504
|
-
adapter = new PostgresAuthAdapter({ db });
|
|
505
|
-
} else if (isMongo) {
|
|
506
|
-
const { MongoDBAuthAdapter } = await import('../mongo-auth-adapter-M7VV4LNB.js');
|
|
507
|
-
const { MongoClient } = await import('mongodb');
|
|
508
|
-
const client = new MongoClient(databaseUrl);
|
|
509
|
-
await client.connect();
|
|
510
|
-
const db = client.db();
|
|
511
|
-
adapter = new MongoDBAuthAdapter({ db });
|
|
512
|
-
} else {
|
|
513
|
-
const { SQLiteAuthAdapter } = await import('../sqlite-adapter-N5H6IM2X.js');
|
|
514
|
-
const authDbPath = process.env.KYRO_AUTH_DB_PATH || "./data/auth.db";
|
|
515
|
-
adapter = new SQLiteAuthAdapter({ path: authDbPath });
|
|
516
|
-
}
|
|
517
|
-
if (adapter.connect) {
|
|
518
|
-
await adapter.connect();
|
|
519
|
-
}
|
|
520
|
-
const result = await bootstrapAdmin({
|
|
521
|
-
authAdapter: adapter,
|
|
522
|
-
adminEmail: options.email,
|
|
523
|
-
adminPassword: options.password,
|
|
524
|
-
adminRole: options.role
|
|
525
|
-
});
|
|
526
|
-
if (adapter.disconnect) {
|
|
527
|
-
await adapter.disconnect();
|
|
528
|
-
}
|
|
529
|
-
if (result.success) {
|
|
530
|
-
} else {
|
|
531
|
-
console.error("\u274C Failed to create admin:", result.error);
|
|
532
|
-
process.exit(1);
|
|
533
|
-
}
|
|
534
|
-
} catch (error) {
|
|
535
|
-
console.error("\u274C Bootstrap failed:", error);
|
|
536
|
-
process.exit(1);
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
program.command("health").description("Check system health").action(async () => {
|
|
540
|
-
const databaseUrl = process.env.DATABASE_URL || "";
|
|
541
|
-
const isPostgres = databaseUrl.toLowerCase().startsWith("postgres://") || databaseUrl.toLowerCase().startsWith("postgresql://");
|
|
542
|
-
const isMongo = databaseUrl.toLowerCase().startsWith("mongodb://") || databaseUrl.toLowerCase().startsWith("mongodb+srv://");
|
|
543
|
-
const isSQLite = !databaseUrl || databaseUrl.includes(".db") || databaseUrl.includes("sqlite") || databaseUrl.includes("file:");
|
|
544
|
-
if (isPostgres) {
|
|
545
|
-
try {
|
|
546
|
-
const { default: postgres } = await import('postgres');
|
|
547
|
-
const client = postgres(databaseUrl, { max: 1, onnotice: () => {
|
|
548
|
-
} });
|
|
549
|
-
await client.unsafe("SELECT 1");
|
|
550
|
-
await client.end();
|
|
551
|
-
} catch {
|
|
552
|
-
}
|
|
553
|
-
} else if (isMongo) {
|
|
554
|
-
try {
|
|
555
|
-
const { MongoClient } = await import('mongodb');
|
|
556
|
-
const client = new MongoClient(databaseUrl);
|
|
557
|
-
await client.connect();
|
|
558
|
-
await client.db().admin().ping();
|
|
559
|
-
await client.close();
|
|
560
|
-
} catch {
|
|
561
|
-
}
|
|
562
|
-
} else if (isSQLite) {
|
|
563
|
-
try {
|
|
564
|
-
const authDbPath = process.env.KYRO_AUTH_DB_PATH || "./data/auth.db";
|
|
565
|
-
const { existsSync: existsSync2 } = await import('fs');
|
|
566
|
-
if (existsSync2(authDbPath)) {
|
|
567
|
-
} else {
|
|
568
|
-
}
|
|
569
|
-
} catch {
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
program.parse();
|
|
574
|
-
if (!process.argv.slice(2).length) {
|
|
575
|
-
program.outputHelp();
|
|
576
|
-
}
|
|
577
|
-
//# sourceMappingURL=index.js.map
|
|
578
|
-
//# sourceMappingURL=index.js.map
|
|
211
|
+
`,n}function K(){return new Command("generate").description("Generate TypeScript types from collection configs").option("-c, --config <path>","Path to config file or directory","./src/kyro").option("-o, --output <path>","Output file path","./src/types/kyro.d.ts").option("-w, --watch","Watch for changes and regenerate").option("--url <url>","URL of a running Kyro CMS instance (enables remote mode)").option("--api-key <key>","API key for authentication (required with --url)").action(async n=>{if(n.url){n.url||(console.error("\u274C --url is required when using --api"),process.exit(1)),n.apiKey||(console.error("\u274C --api-key is required when using --api"),process.exit(1));let o=resolve(n.output);try{let s=await q(n.url,n.apiKey),i=D(s),d=join(o,"..");existsSync(d)||mkdirSync(d,{recursive:!0}),writeFileSync(o,i);}catch(s){console.error("\u274C Error:",s.message),process.exit(1);}return}let t=resolve(n.config),r=resolve(n.output);try{let o=await glob(`${t}/**/*.{ts,js}`);o.length===0&&(console.error("\u274C No config files found at:",t),process.exit(1));let s=[];for(let a of o)try{let l=await import(a),u=Object.values(l).filter(c=>c&&c.slug&&c.fields);s.push(...u);}catch{console.warn(`\u26A0\uFE0F Could not parse: ${a}`);}s.length===0&&(console.error("\u274C No valid collection configs found"),process.exit(1));let i=T(s),d=join(r,"..");if(existsSync(d)||mkdirSync(d,{recursive:!0}),writeFileSync(r,i),n.watch){let{watch:a}=await import('fs');a(t,{recursive:!0},async(l,u)=>{let c=[];for(let S of o)try{let k=await import(S+`?t=${Date.now()}`),v=Object.values(k).filter(h=>h&&h.slug&&h.fields);c.push(...v);}catch{}let f=T(c);writeFileSync(r,f);});}}catch(o){console.error("\u274C Error:",o.message),process.exit(1);}})}var L=fileURLToPath(import.meta.url),N=dirname(L),P="0.1.0";try{P=JSON.parse(readFileSync(join(N,"../../package.json"),"utf-8")).version;}catch{}var p=new Command;p.name("kyro").description("Kyro CMS - Astro-native headless CMS").version(P);p.command("dev").description("Start Kyro CMS development server").option("-p, --port <port>","Port to run on","4321").option("-h, --host <host>","Host to bind to","localhost").action(async e=>{let{exec:n}=await import('child_process'),t=n(`astro dev --port ${e.port} --host ${e.host}`,{env:{...process.env,NODE_NO_WARNINGS:"1"}});t.stdout?.on("data",r=>process.stdout.write(r)),t.stderr?.on("data",r=>process.stderr.write(r)),process.on("SIGINT",()=>{t.kill("SIGINT"),process.exit(0);}),process.on("SIGTERM",()=>{t.kill("SIGTERM"),process.exit(0);});});p.addCommand(K());var g=p.command("db").description("Database management commands");g.command("generate").description("Generate migrations from schema").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit generate",(n,t,r)=>{n&&(console.error("\u274C Generation failed:",n.message),process.exit(1));});});g.command("migrate").description("Run database migrations").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit migrate",(n,t,r)=>{n&&(console.error("\u274C Migration failed:",n.message),process.exit(1));});});g.command("push").description("Push schema to database (development)").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit push",(n,t,r)=>{n&&(console.error("\u274C Push failed:",n.message),process.exit(1));});});g.command("seed").description("Seed database with initial data").action(async()=>{let{exec:e}=await import('child_process');e("npx tsx src/database/drizzle/seed.ts",(n,t,r)=>{n&&(console.error("\u274C Seeding failed:",n.message),process.exit(1));});});g.command("studio").description("Open Drizzle Studio").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit studio",(n,t,r)=>{n&&(console.error("\u274C Studio failed:",n.message),process.exit(1));});});var F=p.command("auth").description("Authentication management commands");F.command("bootstrap").description("Create initial admin user").option("-e, --email <email>","Admin email",process.env.KYRO_ADMIN_EMAIL).option("-p, --password <password>","Admin password",process.env.KYRO_ADMIN_PASSWORD).option("-r, --role <role>","Admin role",process.env.KYRO_ADMIN_ROLE||"admin").action(async e=>{(!e.email||!e.password)&&(console.error("\u274C Email and password are required. Set KYRO_ADMIN_EMAIL and KYRO_ADMIN_PASSWORD env vars or use -e and -p options."),process.exit(1));try{let{bootstrapAdmin:n}=await import('../bootstrap-P7QPQYQP.js'),t=process.env.DATABASE_URL||"",r=t.toLowerCase().startsWith("postgres://")||t.toLowerCase().startsWith("postgresql://"),o=t.toLowerCase().startsWith("mongodb://")||t.toLowerCase().startsWith("mongodb+srv://"),s=!t||t.includes(".db")||t.includes("sqlite")||t.includes("file:"),i;if(r){let{PostgresAuthAdapter:a}=await import('../postgres-auth-adapter-F4KLOGAG.js'),{drizzle:l}=await import('drizzle-orm/postgres-js'),{default:u}=await import('postgres'),c=u(t,{max:1,onnotice:()=>{}}),f=l(c);i=new a({db:f});}else if(o){let{MongoDBAuthAdapter:a}=await import('../mongo-auth-adapter-XI7EPURZ.js'),{MongoClient:l}=await import('mongodb'),u=new l(t);await u.connect();let c=u.db();i=new a({db:c});}else {let{SQLiteAuthAdapter:a}=await import('../sqlite-adapter-5XFLNJDH.js'),l=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";i=new a({path:l});}i.connect&&await i.connect();let d=await n({authAdapter:i,adminEmail:e.email,adminPassword:e.password,adminRole:e.role});i.disconnect&&await i.disconnect(),d.success||(console.error("\u274C Failed to create admin:",d.error),process.exit(1));}catch(n){console.error("\u274C Bootstrap failed:",n),process.exit(1);}});p.command("health").description("Check system health").action(async()=>{let e=process.env.DATABASE_URL||"",n=e.toLowerCase().startsWith("postgres://")||e.toLowerCase().startsWith("postgresql://"),t=e.toLowerCase().startsWith("mongodb://")||e.toLowerCase().startsWith("mongodb+srv://"),r=!e||e.includes(".db")||e.includes("sqlite")||e.includes("file:");if(n)try{let{default:o}=await import('postgres'),s=o(e,{max:1,onnotice:()=>{}});await s.unsafe("SELECT 1"),await s.end();}catch{}else if(t)try{let{MongoClient:o}=await import('mongodb'),s=new o(e);await s.connect(),await s.db().admin().ping(),await s.close();}catch{}else if(r)try{let o=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db",{existsSync:s}=await import('fs');s(o);}catch{}});p.parse();process.argv.slice(2).length||p.outputHelp();
|
package/dist/client.cjs
CHANGED
|
@@ -1,55 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkN4H37VN4_cjs = require('./chunk-N4H37VN4.cjs');
|
|
4
|
-
var chunkOJ2AM75W_cjs = require('./chunk-OJ2AM75W.cjs');
|
|
5
|
-
var chunkADLJSJSN_cjs = require('./chunk-ADLJSJSN.cjs');
|
|
6
|
-
require('./chunk-CZLDE2OZ.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, "CSSGenerator", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () { return chunkN4H37VN4_cjs.CSSGenerator; }
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(exports, "createAdminStyling", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return chunkN4H37VN4_cjs.createAdminStyling; }
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "defaultDarkTheme", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () { return chunkN4H37VN4_cjs.defaultDarkTheme; }
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(exports, "defaultFieldStyling", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return chunkN4H37VN4_cjs.defaultFieldStyling; }
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(exports, "defaultLightTheme", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () { return chunkN4H37VN4_cjs.defaultLightTheme; }
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "ecommerce2026Theme", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () { return chunkN4H37VN4_cjs.ecommerce2026Theme; }
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(exports, "generateCSSVariables", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function () { return chunkN4H37VN4_cjs.generateCSSVariables; }
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(exports, "generateTailwindConfig", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () { return chunkN4H37VN4_cjs.generateTailwindConfig; }
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, "renderRichText", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () { return chunkOJ2AM75W_cjs.renderRichText; }
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(exports, "richTextStyles", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
get: function () { return chunkOJ2AM75W_cjs.richTextStyles; }
|
|
49
|
-
});
|
|
50
|
-
Object.defineProperty(exports, "createAuditContext", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function () { return chunkADLJSJSN_cjs.createAuditContext; }
|
|
53
|
-
});
|
|
54
|
-
//# sourceMappingURL=client.cjs.map
|
|
55
|
-
//# sourceMappingURL=client.cjs.map
|
|
1
|
+
'use strict';var chunk2BTRHVT3_cjs=require('./chunk-2BTRHVT3.cjs'),chunkQ4CSLXCO_cjs=require('./chunk-Q4CSLXCO.cjs'),chunkHVXO3OFB_cjs=require('./chunk-HVXO3OFB.cjs');require('./chunk-OQD3WG6Z.cjs');Object.defineProperty(exports,"CSSGenerator",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.a}});Object.defineProperty(exports,"createAdminStyling",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.g}});Object.defineProperty(exports,"defaultDarkTheme",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.d}});Object.defineProperty(exports,"defaultFieldStyling",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.h}});Object.defineProperty(exports,"defaultLightTheme",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.c}});Object.defineProperty(exports,"ecommerce2026Theme",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.e}});Object.defineProperty(exports,"generateCSSVariables",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.f}});Object.defineProperty(exports,"generateTailwindConfig",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.b}});Object.defineProperty(exports,"renderRichText",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.t}});Object.defineProperty(exports,"richTextStyles",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.r}});Object.defineProperty(exports,"createAuditContext",{enumerable:true,get:function(){return chunkHVXO3OFB_cjs.a}});
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { renderRichText, richTextStyles } from './chunk-FIAMXNTH.js';
|
|
3
|
-
export { createAuditContext } from './chunk-P2YW545G.js';
|
|
4
|
-
import './chunk-4CV4JOE5.js';
|
|
5
|
-
//# sourceMappingURL=client.js.map
|
|
6
|
-
//# sourceMappingURL=client.js.map
|
|
1
|
+
export{a as CSSGenerator,g as createAdminStyling,d as defaultDarkTheme,h as defaultFieldStyling,c as defaultLightTheme,e as ecommerce2026Theme,f as generateCSSVariables,b as generateTailwindConfig}from'./chunk-UHFDH3PG.js';export{t as renderRichText,r as richTextStyles}from'./chunk-NGBJKZMT.js';export{a as createAuditContext}from'./chunk-NRLIGDYF.js';import'./chunk-DGJUBN33.js';
|
package/dist/drizzle/index.cjs
CHANGED
|
@@ -1,50 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('../chunk-3YELQL7Z.cjs');
|
|
4
|
-
var chunkOIRG6ZRV_cjs = require('../chunk-OIRG6ZRV.cjs');
|
|
5
|
-
var chunk7OS7TX2Q_cjs = require('../chunk-7OS7TX2Q.cjs');
|
|
6
|
-
require('../chunk-DPA3KWPY.cjs');
|
|
7
|
-
require('../chunk-GUUB5EAG.cjs');
|
|
8
|
-
require('../chunk-NKPKR5BW.cjs');
|
|
9
|
-
require('../chunk-CZLDE2OZ.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "DrizzleAdapter", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return chunkOIRG6ZRV_cjs.DrizzleAdapter; }
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "collectionToDrizzleSchema", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return chunkOIRG6ZRV_cjs.collectionToDrizzleSchema; }
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(exports, "createDatabase", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return chunkOIRG6ZRV_cjs.createDatabase; }
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "createDrizzleAdapter", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return chunkOIRG6ZRV_cjs.createDrizzleAdapter; }
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, "fieldToDrizzleType", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () { return chunkOIRG6ZRV_cjs.fieldToDrizzleType; }
|
|
32
|
-
});
|
|
33
|
-
Object.defineProperty(exports, "genId", {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () { return chunkOIRG6ZRV_cjs.genId; }
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, "runMigrations", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () { return chunkOIRG6ZRV_cjs.runMigrations; }
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(exports, "seedDefaultRoles", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () { return chunkOIRG6ZRV_cjs.seedDefaultRoles; }
|
|
44
|
-
});
|
|
45
|
-
Object.defineProperty(exports, "PostgresAuthAdapter", {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () { return chunk7OS7TX2Q_cjs.PostgresAuthAdapter; }
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=index.cjs.map
|
|
50
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';require('../chunk-4ORJMSJU.cjs');var chunkIFJJ44OQ_cjs=require('../chunk-IFJJ44OQ.cjs'),chunkGYQMNXXW_cjs=require('../chunk-GYQMNXXW.cjs');require('../chunk-MIOMMB23.cjs'),require('../chunk-DV4LFLPL.cjs'),require('../chunk-Q3Q7BJVQ.cjs'),require('../chunk-OQD3WG6Z.cjs');Object.defineProperty(exports,"DrizzleAdapter",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.c}});Object.defineProperty(exports,"collectionToDrizzleSchema",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.b}});Object.defineProperty(exports,"createDatabase",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.f}});Object.defineProperty(exports,"createDrizzleAdapter",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.d}});Object.defineProperty(exports,"fieldToDrizzleType",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.a}});Object.defineProperty(exports,"runMigrations",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.g}});Object.defineProperty(exports,"seedDefaultRoles",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.h}});Object.defineProperty(exports,"PostgresAuthAdapter",{enumerable:true,get:function(){return chunkGYQMNXXW_cjs.a}});
|
package/dist/drizzle/index.d.cts
CHANGED
|
@@ -156,7 +156,6 @@ declare class PostgresAuthAdapter implements AuthAdapter {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
type Dialect = "sqlite" | "postgres";
|
|
159
|
-
declare function genId(): string;
|
|
160
159
|
interface DatabaseResult {
|
|
161
160
|
db: any;
|
|
162
161
|
dialect: Dialect;
|
|
@@ -166,4 +165,4 @@ declare function createDatabase(): Promise<DatabaseResult>;
|
|
|
166
165
|
declare function runMigrations(_db: any, _dialect?: Dialect): Promise<void>;
|
|
167
166
|
declare function seedDefaultRoles(db: any): Promise<void>;
|
|
168
167
|
|
|
169
|
-
export { type Dialect, DrizzleAdapter, PostgresAuthAdapter, collectionToDrizzleSchema, createDatabase, createDrizzleAdapter, fieldToDrizzleType,
|
|
168
|
+
export { type Dialect, DrizzleAdapter, PostgresAuthAdapter, collectionToDrizzleSchema, createDatabase, createDrizzleAdapter, fieldToDrizzleType, runMigrations, seedDefaultRoles };
|
package/dist/drizzle/index.d.ts
CHANGED
|
@@ -156,7 +156,6 @@ declare class PostgresAuthAdapter implements AuthAdapter {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
type Dialect = "sqlite" | "postgres";
|
|
159
|
-
declare function genId(): string;
|
|
160
159
|
interface DatabaseResult {
|
|
161
160
|
db: any;
|
|
162
161
|
dialect: Dialect;
|
|
@@ -166,4 +165,4 @@ declare function createDatabase(): Promise<DatabaseResult>;
|
|
|
166
165
|
declare function runMigrations(_db: any, _dialect?: Dialect): Promise<void>;
|
|
167
166
|
declare function seedDefaultRoles(db: any): Promise<void>;
|
|
168
167
|
|
|
169
|
-
export { type Dialect, DrizzleAdapter, PostgresAuthAdapter, collectionToDrizzleSchema, createDatabase, createDrizzleAdapter, fieldToDrizzleType,
|
|
168
|
+
export { type Dialect, DrizzleAdapter, PostgresAuthAdapter, collectionToDrizzleSchema, createDatabase, createDrizzleAdapter, fieldToDrizzleType, runMigrations, seedDefaultRoles };
|