@kyro-cms/core 0.12.44 → 0.12.46
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/{WebhookService-C19xR8qE.d.ts → WebhookService-CZf_na-J.d.ts} +1 -1
- package/dist/{WebhookService-BBcCHBo8.d.cts → WebhookService-DgIx21X-.d.cts} +1 -1
- package/dist/api-handler-graphql.cjs +1 -1
- package/dist/api-handler-graphql.js +2 -1
- package/dist/api-handler-trpc.cjs +1 -1
- package/dist/api-handler-trpc.js +2 -1
- package/dist/api-handler.cjs +1 -1
- package/dist/api-handler.js +1 -1
- package/dist/{base-yXdYZxFK.d.ts → base-7vJMzr4V.d.ts} +1 -1
- package/dist/{base-C2iwjdJQ.d.cts → base-DDEmdRqV.d.cts} +1 -1
- package/dist/bcryptjs-AZA6WEN2.js +2 -0
- package/dist/bcryptjs-WIQSWJGK.cjs +1 -0
- package/dist/better-sqlite3-42Q3FG3E.js +2 -0
- package/dist/better-sqlite3-5IISPX34.cjs +1 -0
- package/dist/bootstrap-7CI3NVSY.js +1 -0
- package/dist/bootstrap-DOOM2CNQ.cjs +1 -0
- package/dist/bowser-FI5JQGKZ.js +11 -0
- package/dist/bowser-VX6B6ZSE.cjs +10 -0
- package/dist/chokidar-24HVS6XD.cjs +5 -0
- package/dist/chokidar-43DT7CVN.js +6 -0
- package/dist/chunk-227MEHYX.cjs +269 -0
- package/dist/chunk-26Q7JXM4.cjs +3 -0
- package/dist/chunk-2BUODBE2.js +2 -0
- package/dist/chunk-2WFTETFB.js +2 -0
- package/dist/chunk-35PGCW3S.cjs +1 -0
- package/dist/chunk-3VXEK5ZW.cjs +1 -0
- package/dist/chunk-45TJAB5X.js +301 -0
- package/dist/chunk-5DWYVUQR.cjs +1 -0
- package/dist/chunk-5LPNEYK5.cjs +1 -0
- package/dist/chunk-66BJXVFJ.js +2 -0
- package/dist/chunk-6KRR7YHA.js +2 -0
- package/dist/chunk-6KUL2BSA.cjs +133 -0
- package/dist/chunk-6MSS5X77.js +2 -0
- package/dist/chunk-6QWLXJ7L.js +2 -0
- package/dist/chunk-73D2PNHD.cjs +7 -0
- package/dist/chunk-7ACHOBWY.cjs +13 -0
- package/dist/chunk-7AQSH3KR.js +2 -0
- package/dist/chunk-7GGZA5YU.cjs +2 -0
- package/dist/chunk-7I6URA6F.js +4 -0
- package/dist/chunk-7JWQ2PZP.cjs +1 -0
- package/dist/chunk-7T35572E.js +75 -0
- package/dist/chunk-7V67ONUD.js +4 -0
- package/dist/chunk-7WMMKGEO.cjs +1 -0
- package/dist/chunk-A73AVVFR.js +11 -0
- package/dist/chunk-AK754S3T.cjs +2 -0
- package/dist/chunk-AMGJ5AFH.cjs +1 -0
- package/dist/chunk-ATBH763U.js +2 -0
- package/dist/chunk-B3GDQ7UI.cjs +114 -0
- package/dist/chunk-BAVN7VDR.cjs +1 -0
- package/dist/chunk-BCEE4NBZ.cjs +2 -0
- package/dist/{chunk-J4252I5B.cjs → chunk-BHR7OAU4.cjs} +4 -4
- package/dist/chunk-BLH2MRK4.js +2 -0
- package/dist/chunk-BPMA2ECA.js +10 -0
- package/dist/chunk-BUNLC3II.cjs +1 -0
- package/dist/chunk-C2PXMVR5.js +2 -0
- package/dist/chunk-CAJ4ZJO6.cjs +1 -0
- package/dist/chunk-CGPAS4U5.js +4 -0
- package/dist/chunk-DS5DE5BU.js +2 -0
- package/dist/chunk-DT3LHRQT.js +57 -0
- package/dist/chunk-DUO523BH.cjs +1 -0
- package/dist/chunk-DVWYO3KK.cjs +1 -0
- package/dist/chunk-E27KEZPT.js +2 -0
- package/dist/chunk-EHWUALGH.cjs +1 -0
- package/dist/chunk-EN65ZEK2.cjs +2 -0
- package/dist/chunk-EOOZDOL7.js +3 -0
- package/dist/chunk-EZIDQBXI.cjs +1 -0
- package/dist/chunk-F4ITQ6XQ.cjs +3 -0
- package/dist/chunk-GIS6X43A.cjs +3 -0
- package/dist/chunk-GNEVCEJU.cjs +3 -0
- package/dist/chunk-GNOSG3PK.cjs +1 -0
- package/dist/chunk-HLAEJB5R.js +384 -0
- package/dist/chunk-HPYH7GTS.cjs +1 -0
- package/dist/chunk-HT44I66C.js +24 -0
- package/dist/chunk-HTYVI2HK.cjs +9 -0
- package/dist/chunk-ICVQWR2A.js +2 -0
- package/dist/chunk-IP6JUEH3.js +3 -0
- package/dist/chunk-IPXOY4RI.js +2 -0
- package/dist/chunk-IUAWDAUD.cjs +56 -0
- package/dist/chunk-J6U5LWZ7.js +11 -0
- package/dist/{chunk-UHFDH3PG.js → chunk-JT36FTHY.cjs} +4 -4
- package/dist/chunk-JUJZOG6P.js +2 -0
- package/dist/{chunk-2BTRHVT3.cjs → chunk-K7YNEKVE.js} +5 -4
- package/dist/chunk-KCHPADCH.cjs +7 -0
- package/dist/chunk-KH7LM52S.js +3 -0
- package/dist/chunk-LEBM6ZSZ.cjs +10 -0
- package/dist/chunk-LQ3YZTPU.cjs +15 -0
- package/dist/chunk-LY7N3UHH.cjs +23 -0
- package/dist/chunk-MCZ3YZ2L.js +2 -0
- package/dist/chunk-MP5VC5ER.cjs +1 -0
- package/dist/chunk-MVX2PYJJ.cjs +1 -0
- package/dist/chunk-MY42EWZP.js +2 -0
- package/dist/chunk-MZOWPV4D.js +20 -0
- package/dist/chunk-NGNJSUGL.cjs +1 -0
- package/dist/chunk-NWCREF47.js +3 -0
- package/dist/chunk-OMWQVPV7.js +14 -0
- package/dist/chunk-ORG67NXX.js +3 -0
- package/dist/chunk-OSAVAYJZ.js +16 -0
- package/dist/chunk-P7XYIKL6.cjs +300 -0
- package/dist/chunk-PBOZJOKN.js +2 -0
- package/dist/chunk-PITMDQYN.cjs +18 -0
- package/dist/chunk-PL5AIE6F.js +2 -0
- package/dist/chunk-PTWQQMWW.js +270 -0
- package/dist/chunk-QC4YXUBT.cjs +383 -0
- package/dist/chunk-QDHP5E4P.cjs +2 -0
- package/dist/chunk-QVDY6S4B.js +2 -0
- package/dist/chunk-QYI3GOHF.cjs +1 -0
- package/dist/chunk-R3NEPC4I.js +3 -0
- package/dist/chunk-R4LXRAMX.js +2 -0
- package/dist/chunk-S5HTTLN7.cjs +2 -0
- package/dist/chunk-STX5V7HG.cjs +20 -0
- package/dist/chunk-SVYUTQVE.js +115 -0
- package/dist/chunk-SYEP5QLG.js +19 -0
- package/dist/chunk-TR3ZS3T3.js +3 -0
- package/dist/chunk-UB5TJHQR.js +2 -0
- package/dist/chunk-UD6ZPO7T.js +2 -0
- package/dist/chunk-UNYXWPLZ.cjs +2 -0
- package/dist/chunk-VBPAAQEF.js +2 -0
- package/dist/chunk-VIUU4D5I.js +2 -0
- package/dist/chunk-VJ2WMKPK.js +21 -0
- package/dist/chunk-VOQUO2EZ.cjs +74 -0
- package/dist/chunk-VQ53TFYA.cjs +1 -0
- package/dist/chunk-VRZC4TTF.cjs +1 -0
- package/dist/chunk-W46LZ4MY.js +2 -0
- package/dist/chunk-WCFHS7EZ.cjs +1 -0
- package/dist/chunk-WGESLAWV.js +8 -0
- package/dist/chunk-WSP7PSXC.js +8 -0
- package/dist/chunk-X54XZACS.cjs +10 -0
- package/dist/{chunk-Q2UYCYKV.js → chunk-XBH4YMC7.js} +5 -4
- package/dist/chunk-XDE7CFV6.cjs +19 -0
- package/dist/chunk-XOACKBG7.js +4 -0
- package/dist/chunk-XPPVX4GQ.cjs +1 -0
- package/dist/chunk-ZJE3VAAW.js +134 -0
- package/dist/chunk-ZO3YB5DK.cjs +1 -0
- package/dist/chunk-ZOVH6QT5.cjs +1 -0
- package/dist/cli/index.cjs +197 -78
- package/dist/cli/index.js +198 -78
- package/dist/client.cjs +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +2 -1
- package/dist/d1-5ZQJOFDX.cjs +1 -0
- package/dist/d1-VPH75GI2.js +2 -0
- package/dist/dist-es-3SSNUZST.cjs +1 -0
- package/dist/dist-es-6SVFVYN3.js +1 -0
- package/dist/dist-es-6TQTDPE7.js +2 -0
- package/dist/dist-es-A5OF2STN.cjs +2 -0
- package/dist/dist-es-BOW5V247.cjs +6 -0
- package/dist/dist-es-CRIMATLL.cjs +2 -0
- package/dist/dist-es-DL3VLVP6.cjs +1 -0
- package/dist/dist-es-EMUQ6ZNZ.js +3 -0
- package/dist/dist-es-MNIQZC4U.js +2 -0
- package/dist/dist-es-P25IKLBI.cjs +1 -0
- package/dist/dist-es-SJ76GYCI.js +2 -0
- package/dist/dist-es-SRPWSAF4.cjs +1 -0
- package/dist/dist-es-T2H2W5BX.cjs +3 -0
- package/dist/dist-es-TX4DBXEW.js +3 -0
- package/dist/dist-es-U4ZB3ZDA.js +7 -0
- package/dist/dist-es-XZBHIIKY.js +4 -0
- package/dist/drizzle/index.cjs +1 -1
- package/dist/drizzle/index.d.cts +2 -2
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +1 -1
- package/dist/drizzle-orm-47ELDEM6.cjs +1 -0
- package/dist/drizzle-orm-7YTX5NTT.js +1 -0
- package/dist/event-streams-25YJ2Z6R.js +1 -0
- package/dist/event-streams-JBMWCI2O.cjs +1 -0
- package/dist/fields/index.cjs +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/fs-DGKZLRM6.cjs +1 -0
- package/dist/fs-YZJ5FM6J.js +2 -0
- package/dist/graphql/index.cjs +1 -1
- package/dist/graphql/index.d.cts +2 -2
- package/dist/graphql/index.d.ts +2 -2
- package/dist/graphql/index.js +1 -1
- package/dist/{index-DTz6u7w9.d.cts → index-BJ1rwHxk.d.cts} +1 -1
- package/dist/{index-BeQtbl3z.d.ts → index-BTjlptCL.d.ts} +1 -1
- package/dist/index.cjs +28 -46
- package/dist/index.d.cts +23 -9
- package/dist/index.d.ts +23 -9
- package/dist/index.js +29 -46
- package/dist/integration.cjs +1 -1
- package/dist/integration.js +1 -1
- package/dist/jsonwebtoken-DFB6ZBZA.cjs +8 -0
- package/dist/jsonwebtoken-S7BG2YWK.js +9 -0
- package/dist/lib-5QYYN6ML.cjs +12 -0
- package/dist/lib-IYW32OER.js +13 -0
- package/dist/loadSso-JY4WDQPS.cjs +2 -0
- package/dist/loadSso-YTG2GQGW.js +3 -0
- package/dist/local-VDCSEMC2.js +1 -0
- package/dist/local-YCWBUF3R.cjs +1 -0
- package/dist/media-3Z6YW5J4.cjs +1 -0
- package/dist/media-HK2IZMUZ.js +1 -0
- package/dist/mongo-auth-adapter-7K64Y2QM.cjs +1 -0
- package/dist/mongo-auth-adapter-BUKINEZL.js +1 -0
- package/dist/mongodb/index.cjs +1 -1
- package/dist/mongodb/index.d.cts +2 -2
- package/dist/mongodb/index.d.ts +2 -2
- package/dist/mongodb/index.js +1 -1
- package/dist/nodemailer-AXROO37D.js +54 -0
- package/dist/nodemailer-IDML4L6W.cjs +53 -0
- package/dist/postgres-auth-adapter-2M4RNEY3.cjs +1 -0
- package/dist/postgres-auth-adapter-MKSHIJDL.js +1 -0
- package/dist/postgres-js-3Y54EXVQ.cjs +1 -0
- package/dist/postgres-js-INQPBHJP.js +1 -0
- package/dist/redis-adapter-EGMUN65D.cjs +1 -0
- package/dist/redis-adapter-SXOXLHNH.js +1 -0
- package/dist/rest/index.cjs +1 -1
- package/dist/rest/index.d.cts +5 -5
- package/dist/rest/index.d.ts +5 -5
- package/dist/rest/index.js +1 -1
- package/dist/schema-RT6WSUYC.cjs +1 -0
- package/dist/schema-XC5ISGNR.js +2 -0
- package/dist/signin-KZBIAHGS.js +3 -0
- package/dist/signin-VFBLX7EL.cjs +2 -0
- package/dist/sqlite-adapter-DV7ZX2EJ.js +1 -0
- package/dist/sqlite-adapter-ZTABLT2X.cjs +1 -0
- package/dist/src-6LAUXXDM.cjs +1 -0
- package/dist/src-GZRZ4VAO.js +1 -0
- package/dist/sso-oidc-54BIRYR6.cjs +2 -0
- package/dist/sso-oidc-SX5OIQGG.js +3 -0
- package/dist/sts-HVGDJYIF.js +3 -0
- package/dist/sts-YLXXIB3X.cjs +2 -0
- package/dist/templates/index.cjs +1 -1
- package/dist/templates/index.d.cts +1 -1
- package/dist/templates/index.d.ts +1 -1
- package/dist/templates/index.js +1 -1
- package/dist/trpc/index.cjs +1 -1
- package/dist/trpc/index.d.cts +7 -7
- package/dist/trpc/index.d.ts +7 -7
- package/dist/trpc/index.js +1 -1
- package/dist/{types-CaXXmV9h.d.ts → types-CYGXsNcJ.d.ts} +5 -5
- package/dist/{types-BjivdGbU.d.cts → types-DOKMyC3y.d.cts} +5 -5
- package/dist/ws/index.cjs +1 -1
- package/dist/ws/index.js +1 -1
- package/package.json +2 -2
- package/dist/bootstrap-ROSTPMVL.js +0 -1
- package/dist/bootstrap-WW5NJ6EB.cjs +0 -1
- package/dist/chunk-3CVLI5C5.cjs +0 -3
- package/dist/chunk-3Q2WUG63.cjs +0 -2
- package/dist/chunk-3RSMK4DA.cjs +0 -2
- package/dist/chunk-4IGWJMBY.cjs +0 -2
- package/dist/chunk-4ORJMSJU.cjs +0 -1
- package/dist/chunk-4RMFCTWH.js +0 -1
- package/dist/chunk-5B6X2GBJ.js +0 -2
- package/dist/chunk-5J6HXUF6.js +0 -1
- package/dist/chunk-5KOQYQEE.js +0 -1
- package/dist/chunk-5SEHX7ON.js +0 -1
- package/dist/chunk-6ROHVUXF.js +0 -1
- package/dist/chunk-6SPPR5JZ.js +0 -3
- package/dist/chunk-7IVN6TTY.js +0 -133
- package/dist/chunk-AHSFSERC.cjs +0 -1
- package/dist/chunk-B5XWYVWK.js +0 -1
- package/dist/chunk-BGX27ZRG.cjs +0 -300
- package/dist/chunk-C2W5PSHC.js +0 -300
- package/dist/chunk-CCUQZ66T.cjs +0 -133
- package/dist/chunk-D5P2IPGX.cjs +0 -3
- package/dist/chunk-EPMGPNBE.js +0 -1
- package/dist/chunk-FHJJKFAU.cjs +0 -1
- package/dist/chunk-FVZ5RFLO.js +0 -2
- package/dist/chunk-FZ6Q2EBJ.cjs +0 -20
- package/dist/chunk-G3J2EU5D.cjs +0 -1
- package/dist/chunk-G7SSHELM.cjs +0 -1
- package/dist/chunk-GKYEJ2UF.js +0 -1
- package/dist/chunk-GO34AOBZ.cjs +0 -1
- package/dist/chunk-GYQMNXXW.cjs +0 -114
- package/dist/chunk-HLSB2MCK.js +0 -1
- package/dist/chunk-HQP2Y7QQ.js +0 -251
- package/dist/chunk-HS2KNFAB.cjs +0 -2
- package/dist/chunk-HVXO3OFB.cjs +0 -1
- package/dist/chunk-IETGL7WJ.js +0 -1
- package/dist/chunk-IFJ73O3A.cjs +0 -1
- package/dist/chunk-ILEZ3NYX.cjs +0 -2
- package/dist/chunk-INB4LNA6.js +0 -90
- package/dist/chunk-K6WUOU6P.js +0 -1
- package/dist/chunk-KD7LUCFY.cjs +0 -1
- package/dist/chunk-KDNYHLD2.js +0 -1
- package/dist/chunk-LHW4R367.js +0 -1
- package/dist/chunk-MIOMMB23.cjs +0 -1
- package/dist/chunk-N5VNHUJS.cjs +0 -4
- package/dist/chunk-NRLIGDYF.js +0 -1
- package/dist/chunk-NY47CFVP.cjs +0 -1
- package/dist/chunk-NZJAGASC.cjs +0 -251
- package/dist/chunk-OG7CNQGU.js +0 -1
- package/dist/chunk-PP5S2UBV.js +0 -0
- package/dist/chunk-PP7W5UKL.js +0 -2
- package/dist/chunk-Q3Q7BJVQ.cjs +0 -1
- package/dist/chunk-QCA3AP3M.cjs +0 -1
- package/dist/chunk-QOCHBPMK.js +0 -2
- package/dist/chunk-QYFU5Y7S.js +0 -3
- package/dist/chunk-RHCWCG3O.js +0 -114
- package/dist/chunk-SK2Q4PRV.cjs +0 -90
- package/dist/chunk-TFBHE5FF.cjs +0 -1
- package/dist/chunk-UBRYJP2G.js +0 -1
- package/dist/chunk-V65NPSR5.cjs +0 -1
- package/dist/chunk-VGQ4VUG6.js +0 -2
- package/dist/chunk-W7C6SJXZ.js +0 -20
- package/dist/chunk-WIZ6C5QZ.cjs +0 -1
- package/dist/chunk-ZIWJJRWQ.js +0 -4
- package/dist/chunk-ZUVP4UK7.cjs +0 -1
- package/dist/media-L5XDD47D.js +0 -1
- package/dist/media-OUBQTIQP.cjs +0 -1
- package/dist/mongo-auth-adapter-5TJO5J5U.js +0 -1
- package/dist/mongo-auth-adapter-JVE5M3S4.cjs +0 -1
- package/dist/postgres-auth-adapter-33QOIRXT.js +0 -1
- package/dist/postgres-auth-adapter-JKDYYULH.cjs +0 -1
- package/dist/redis-adapter-NN3H4GRX.js +0 -1
- package/dist/redis-adapter-OUKQGYCH.cjs +0 -1
- package/dist/schema-HIUSHSUI.cjs +0 -1
- package/dist/schema-KFYUM674.js +0 -1
- package/dist/sqlite-adapter-GTTVSXRV.cjs +0 -1
- package/dist/sqlite-adapter-UPANATIW.js +0 -1
package/dist/chunk-C2W5PSHC.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-K6WUOU6P.js';function l(i){let{title:e,previewText:t=e,badgeText:r="Security Notification",badgeType:s="info",bodyHtml:o,ctaText:a,ctaUrl:n,secondaryCtaText:c,secondaryCtaUrl:g}=i,d="#eff6ff",p="#bfdbfe",m="#1d4ed8";return s==="success"?(d="#ecfdf5",p="#a7f3d0",m="#047857"):s==="warning"?(d="#fffbeb",p="#fde68a",m="#b45309"):s==="error"&&(d="#fef2f2",p="#fecaca",m="#b91c1c"),`<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<meta name="color-scheme" content="light dark">
|
|
7
|
-
<meta name="supported-color-schemes" content="light dark">
|
|
8
|
-
<title>${e}</title>
|
|
9
|
-
<style>
|
|
10
|
-
:root {
|
|
11
|
-
color-scheme: light dark;
|
|
12
|
-
supported-color-schemes: light dark;
|
|
13
|
-
}
|
|
14
|
-
@media (prefers-color-scheme: dark) {
|
|
15
|
-
.email-body { background-color: #09090b !important; color: #f4f4f5 !important; }
|
|
16
|
-
.email-card { background-color: #121215 !important; border-color: #27272a !important; box-shadow: none !important; }
|
|
17
|
-
.email-header { background-color: #18181b !important; border-color: #27272a !important; }
|
|
18
|
-
.email-brand-text { color: #ffffff !important; }
|
|
19
|
-
.email-title { color: #ffffff !important; }
|
|
20
|
-
.email-text { color: #a1a1aa !important; }
|
|
21
|
-
.email-strong { color: #ffffff !important; }
|
|
22
|
-
.email-table { background-color: #18181b !important; border-color: #27272a !important; }
|
|
23
|
-
.email-td-border { border-color: #27272a !important; }
|
|
24
|
-
.email-label { color: #a1a1aa !important; }
|
|
25
|
-
.email-value { color: #f4f4f5 !important; }
|
|
26
|
-
.email-code-box { background-color: #18181b !important; border-color: #27272a !important; color: #ffffff !important; }
|
|
27
|
-
.email-btn-primary { background-color: #ffffff !important; color: #09090b !important; }
|
|
28
|
-
.email-btn-secondary { background-color: #18181b !important; border-color: #27272a !important; color: #f4f4f5 !important; }
|
|
29
|
-
.email-footer { background-color: #09090b !important; border-color: #27272a !important; }
|
|
30
|
-
.email-footer-text { color: #71717a !important; }
|
|
31
|
-
.email-footer-link { color: #a1a1aa !important; }
|
|
32
|
-
.logo-light { display: none !important; }
|
|
33
|
-
.logo-dark { display: inline-block !important; }
|
|
34
|
-
}
|
|
35
|
-
</style>
|
|
36
|
-
</head>
|
|
37
|
-
<body class="email-body" style="margin: 0; padding: 36px 16px; background-color: #f4f4f5; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; color: #09090b; -webkit-font-smoothing: antialiased;">
|
|
38
|
-
<!-- Preview Text -->
|
|
39
|
-
<div style="display: none; max-height: 0; overflow: hidden;">${t}</div>
|
|
40
|
-
|
|
41
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" class="email-card" style="max-width: 540px; margin: 0 auto; background-color: #ffffff; border: 1px solid #e4e4e7; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);">
|
|
42
|
-
<!-- Header Bar -->
|
|
43
|
-
<tr>
|
|
44
|
-
<td class="email-header" style="padding: 22px 28px; border-bottom: 1px solid #f4f4f5; background-color: #ffffff;">
|
|
45
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
46
|
-
<tr>
|
|
47
|
-
<td align="left" valign="middle">
|
|
48
|
-
<a href="https://kyro-cms.com" target="_blank" style="text-decoration: none; display: inline-flex; align-items: center; gap: 10px;">
|
|
49
|
-
<!-- Light Mode Logo -->
|
|
50
|
-
<img src="https://kyro-cms.com/logo.svg" alt="Kyro Logo" class="logo-light" height="24" style="display: inline-block; border: 0; max-height: 24px; vertical-align: middle;" />
|
|
51
|
-
<!-- Dark Mode Logo -->
|
|
52
|
-
<img src="https://kyro-cms.com/logo-white.svg" alt="Kyro Logo" class="logo-dark" height="24" style="display: none; border: 0; max-height: 24px; vertical-align: middle;" />
|
|
53
|
-
<span class="email-brand-text" style="font-size: 16px; font-weight: 700; color: #09090b; letter-spacing: -0.3px; vertical-align: middle;">Kyro CMS</span>
|
|
54
|
-
</a>
|
|
55
|
-
</td>
|
|
56
|
-
<td align="right" valign="middle">
|
|
57
|
-
<span class="badge-status" style="display: inline-block; padding: 4px 10px; background-color: ${d}; border: 1px solid ${p}; border-radius: 9999px; font-size: 11px; font-weight: 500; color: ${m};">
|
|
58
|
-
${r}
|
|
59
|
-
</span>
|
|
60
|
-
</td>
|
|
61
|
-
</tr>
|
|
62
|
-
</table>
|
|
63
|
-
</td>
|
|
64
|
-
</tr>
|
|
65
|
-
|
|
66
|
-
<!-- Body Section -->
|
|
67
|
-
<tr>
|
|
68
|
-
<td style="padding: 28px;">
|
|
69
|
-
<h1 class="email-title" style="margin: 0 0 12px; font-size: 20px; font-weight: 600; color: #09090b; letter-spacing: -0.3px;">
|
|
70
|
-
${e}
|
|
71
|
-
</h1>
|
|
72
|
-
|
|
73
|
-
${o}
|
|
74
|
-
|
|
75
|
-
${a&&n?`
|
|
76
|
-
<!-- Action Buttons -->
|
|
77
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top: 24px;">
|
|
78
|
-
<tr>
|
|
79
|
-
<td align="left">
|
|
80
|
-
<a href="${n}" target="_blank" class="email-btn-primary" style="display: inline-block; padding: 11px 20px; background-color: #09090b; color: #ffffff; font-size: 13px; font-weight: 500; text-decoration: none; border-radius: 6px;">
|
|
81
|
-
${a} \u2192
|
|
82
|
-
</a>
|
|
83
|
-
${c&&g?`<a href="${g}" target="_blank" class="email-btn-secondary" style="display: inline-block; padding: 11px 16px; margin-left: 8px; background-color: #ffffff; border: 1px solid #e4e4e7; color: #09090b; font-size: 13px; font-weight: 500; text-decoration: none; border-radius: 6px;">
|
|
84
|
-
${c}
|
|
85
|
-
</a>`:""}
|
|
86
|
-
</td>
|
|
87
|
-
</tr>
|
|
88
|
-
</table>`:""}
|
|
89
|
-
</td>
|
|
90
|
-
</tr>
|
|
91
|
-
|
|
92
|
-
<!-- Footer -->
|
|
93
|
-
<tr>
|
|
94
|
-
<td class="email-footer" style="padding: 18px 28px; border-top: 1px solid #f4f4f5; background-color: #fafafa; text-align: center;">
|
|
95
|
-
<p class="email-footer-text" style="margin: 0 0 8px; font-size: 12px; color: #71717a;">
|
|
96
|
-
Sent securely via <strong>Kyro CMS Authentication Engine</strong>.
|
|
97
|
-
</p>
|
|
98
|
-
<p style="margin: 0; font-size: 12px; color: #71717a;">
|
|
99
|
-
<a href="https://kyro-cms.com" target="_blank" class="email-footer-link" style="color: #09090b; text-decoration: none; font-weight: 500;">kyro-cms.com</a> \u2022
|
|
100
|
-
<a href="https://kyro-cms.com/docs" target="_blank" class="email-footer-link" style="color: #09090b; text-decoration: none; font-weight: 500;">Docs</a> \u2022
|
|
101
|
-
<a href="https://github.com/danielDozie/kyro-cms" target="_blank" class="email-footer-link" style="color: #09090b; text-decoration: none; font-weight: 500;">GitHub</a>
|
|
102
|
-
</p>
|
|
103
|
-
</td>
|
|
104
|
-
</tr>
|
|
105
|
-
</table>
|
|
106
|
-
</body>
|
|
107
|
-
</html>`}function h(i,e="User"){let t="Confirm your email address \u2014 Kyro CMS",r=`
|
|
108
|
-
<p class="email-text" style="margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
109
|
-
Hello <strong class="email-strong" style="color: #09090b;">${e}</strong>,
|
|
110
|
-
</p>
|
|
111
|
-
<p class="email-text" style="margin: 0 0 20px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
112
|
-
Thank you for registering. Please confirm your email address by clicking the verification button below to activate your account.
|
|
113
|
-
</p>
|
|
114
|
-
|
|
115
|
-
<!-- Verification Token Link Card -->
|
|
116
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" class="email-table" style="background-color: #fafafa; border: 1px solid #e4e4e7; border-radius: 8px; margin-bottom: 20px; padding: 14px; border-collapse: separate;">
|
|
117
|
-
<tr>
|
|
118
|
-
<td style="font-size: 12px; color: #71717a; line-height: 1.5; word-break: break-all;">
|
|
119
|
-
<strong>Direct link:</strong><br />
|
|
120
|
-
<a href="${i}" style="color: #09090b; text-decoration: underline;" class="email-value">${i}</a>
|
|
121
|
-
</td>
|
|
122
|
-
</tr>
|
|
123
|
-
</table>
|
|
124
|
-
|
|
125
|
-
<p class="email-text" style="margin: 0 0 8px; font-size: 12px; color: #71717a;">
|
|
126
|
-
This verification link will expire in 24 hours. If you did not create an account, you can safely ignore this email.
|
|
127
|
-
</p>
|
|
128
|
-
`,s=l({title:"Confirm Your Email Address",previewText:"Please confirm your email address to activate your Kyro CMS account.",badgeText:"Action Required",badgeType:"warning",bodyHtml:r,ctaText:"Confirm Email Address",ctaUrl:i,secondaryCtaText:"Documentation",secondaryCtaUrl:"https://kyro-cms.com/docs"}),o=`Welcome, ${e}!
|
|
129
|
-
|
|
130
|
-
Please verify your email address by visiting:
|
|
131
|
-
${i}
|
|
132
|
-
|
|
133
|
-
This link expires in 24 hours.
|
|
134
|
-
|
|
135
|
-
Kyro CMS \u2014 https://kyro-cms.com`;return {subject:t,html:s,text:o}}function y(i,e="User"){let t="Reset your password \u2014 Kyro CMS",r=`
|
|
136
|
-
<p class="email-text" style="margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
137
|
-
Hello <strong class="email-strong" style="color: #09090b;">${e}</strong>,
|
|
138
|
-
</p>
|
|
139
|
-
<p class="email-text" style="margin: 0 0 20px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
140
|
-
We received a request to reset the password for your account. Click the button below to choose a new password.
|
|
141
|
-
</p>
|
|
142
|
-
|
|
143
|
-
<!-- Reset Link Box -->
|
|
144
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" class="email-table" style="background-color: #fafafa; border: 1px solid #e4e4e7; border-radius: 8px; margin-bottom: 20px; padding: 14px; border-collapse: separate;">
|
|
145
|
-
<tr>
|
|
146
|
-
<td style="font-size: 12px; color: #71717a; line-height: 1.5; word-break: break-all;">
|
|
147
|
-
<strong>Reset URL:</strong><br />
|
|
148
|
-
<a href="${i}" style="color: #09090b; text-decoration: underline;" class="email-value">${i}</a>
|
|
149
|
-
</td>
|
|
150
|
-
</tr>
|
|
151
|
-
</table>
|
|
152
|
-
|
|
153
|
-
<p class="email-text" style="margin: 0 0 8px; font-size: 12px; color: #71717a;">
|
|
154
|
-
For security reasons, this link will expire in 1 hour. If you did not request a password reset, no further action is required.
|
|
155
|
-
</p>
|
|
156
|
-
`,s=l({title:"Reset Your Password",previewText:"Use this secure link to reset your Kyro CMS password.",badgeText:"Security Action",badgeType:"warning",bodyHtml:r,ctaText:"Reset Password",ctaUrl:i}),o=`Hello ${e},
|
|
157
|
-
|
|
158
|
-
Reset your password using the following link:
|
|
159
|
-
${i}
|
|
160
|
-
|
|
161
|
-
This link will expire in 1 hour.
|
|
162
|
-
|
|
163
|
-
Kyro CMS \u2014 https://kyro-cms.com`;return {subject:t,html:s,text:o}}function b(i="User",e="https://kyro-cms.com"){let t="Welcome to Kyro CMS!",r=`
|
|
164
|
-
<p class="email-text" style="margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
165
|
-
Welcome <strong class="email-strong" style="color: #09090b;">${i}</strong>,
|
|
166
|
-
</p>
|
|
167
|
-
<p class="email-text" style="margin: 0 0 20px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
168
|
-
Your Kyro CMS account is now set up and ready to go. You can access your admin dashboard, build content collections, and manage schema endpoints.
|
|
169
|
-
</p>
|
|
170
|
-
|
|
171
|
-
<!-- Key Capabilities List -->
|
|
172
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" class="email-table" style="background-color: #fafafa; border: 1px solid #e4e4e7; border-radius: 8px; margin-bottom: 24px; padding: 16px; border-collapse: separate;">
|
|
173
|
-
<tr>
|
|
174
|
-
<td style="font-size: 13px; color: #09090b; line-height: 1.6;" class="email-value">
|
|
175
|
-
\u{1F680} <strong>What you can do next:</strong>
|
|
176
|
-
<ul style="margin: 8px 0 0; padding-left: 20px; color: #52525b;">
|
|
177
|
-
<li>Define collections & custom field schemas in <code style="font-family: monospace;">kyro.config.ts</code></li>
|
|
178
|
-
<li>Explore auto-generated REST, GraphQL, tRPC & WebSocket endpoints</li>
|
|
179
|
-
<li>Customize your visual Admin dashboard & branding settings</li>
|
|
180
|
-
</ul>
|
|
181
|
-
</td>
|
|
182
|
-
</tr>
|
|
183
|
-
</table>
|
|
184
|
-
`,s=l({title:"Welcome to Kyro CMS",previewText:"Your account is verified and ready. Start building content applications.",badgeText:"Account Ready",badgeType:"success",bodyHtml:r,ctaText:"Open Dashboard",ctaUrl:e,secondaryCtaText:"Documentation",secondaryCtaUrl:"https://kyro-cms.com/docs"}),o=`Welcome to Kyro CMS, ${i}!
|
|
185
|
-
|
|
186
|
-
Your account is active. Log in at ${e} to start building.
|
|
187
|
-
|
|
188
|
-
Documentation: https://kyro-cms.com/docs`;return {subject:t,html:s,text:o}}function x(i="User"){let e="Security Alert: Password Changed \u2014 Kyro CMS",t=new Date().toUTCString(),r=`
|
|
189
|
-
<p class="email-text" style="margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
190
|
-
Hello <strong class="email-strong" style="color: #09090b;">${i}</strong>,
|
|
191
|
-
</p>
|
|
192
|
-
<p class="email-text" style="margin: 0 0 20px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
193
|
-
This email confirms that the password for your Kyro CMS account was successfully updated on <strong>${t}</strong>.
|
|
194
|
-
</p>
|
|
195
|
-
|
|
196
|
-
<!-- Security Warning Card -->
|
|
197
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" class="email-table" style="background-color: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; margin-bottom: 20px; padding: 14px; border-collapse: separate;">
|
|
198
|
-
<tr>
|
|
199
|
-
<td style="font-size: 13px; color: #991b1b; line-height: 1.5;">
|
|
200
|
-
\u26A0\uFE0F <strong>Did not request this change?</strong><br />
|
|
201
|
-
If you did not initiate this change, your account may be compromised. Reset your password immediately and contact an administrator.
|
|
202
|
-
</td>
|
|
203
|
-
</tr>
|
|
204
|
-
</table>
|
|
205
|
-
`,s=l({title:"Password Updated",previewText:"Your Kyro CMS account password was updated.",badgeText:"Security Alert",badgeType:"warning",bodyHtml:r,ctaText:"Account Security",ctaUrl:"https://kyro-cms.com"}),o=`Security Alert: Your Kyro CMS password was updated at ${t}.
|
|
206
|
-
|
|
207
|
-
If you did not make this change, please reset your password immediately.
|
|
208
|
-
|
|
209
|
-
Kyro CMS \u2014 https://kyro-cms.com`;return {subject:e,html:s,text:o}}function _(i,e,t="User"){let r="Your one-time login link \u2014 Kyro CMS",s=`
|
|
210
|
-
<p class="email-text" style="margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
211
|
-
Hello <strong class="email-strong" style="color: #09090b;">${t}</strong>,
|
|
212
|
-
</p>
|
|
213
|
-
<p class="email-text" style="margin: 0 0 20px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
214
|
-
Click the button below to sign in to your Kyro CMS account without entering a password.
|
|
215
|
-
</p>
|
|
216
|
-
|
|
217
|
-
${e?`
|
|
218
|
-
<!-- One-Time Passcode Box -->
|
|
219
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" class="email-table" style="background-color: #fafafa; border: 1px solid #e4e4e7; border-radius: 8px; margin-bottom: 20px; padding: 16px; text-align: center;">
|
|
220
|
-
<tr>
|
|
221
|
-
<td style="font-size: 12px; color: #71717a; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;">
|
|
222
|
-
One-Time Passcode
|
|
223
|
-
</td>
|
|
224
|
-
</tr>
|
|
225
|
-
<tr>
|
|
226
|
-
<td style="font-size: 28px; font-weight: 800; font-family: monospace; color: #09090b; letter-spacing: 4px;" class="email-code-box">
|
|
227
|
-
${e}
|
|
228
|
-
</td>
|
|
229
|
-
</tr>
|
|
230
|
-
</table>`:""}
|
|
231
|
-
|
|
232
|
-
<p class="email-text" style="margin: 0 0 8px; font-size: 12px; color: #71717a;">
|
|
233
|
-
This single-use link will expire in 10 minutes. Never share authentication links with anyone.
|
|
234
|
-
</p>
|
|
235
|
-
`,o=l({title:"Sign in to Kyro CMS",previewText:"Your secure magic login link for Kyro CMS.",badgeText:"Instant Login",badgeType:"info",bodyHtml:s,ctaText:"Sign In Now",ctaUrl:i}),a=`Hello ${t},
|
|
236
|
-
|
|
237
|
-
Sign in to Kyro CMS using the link below:
|
|
238
|
-
${i}${e?`
|
|
239
|
-
|
|
240
|
-
Or enter code: ${e}`:""}
|
|
241
|
-
|
|
242
|
-
This link expires in 10 minutes.
|
|
243
|
-
|
|
244
|
-
Kyro CMS \u2014 https://kyro-cms.com`;return {subject:r,html:o,text:a}}function S(i,e,t="User"){let r="Security Alert: Account Temporarily Locked \u2014 Kyro CMS",s=`
|
|
245
|
-
<p class="email-text" style="margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
246
|
-
Hello <strong class="email-strong" style="color: #09090b;">${t}</strong>,
|
|
247
|
-
</p>
|
|
248
|
-
<p class="email-text" style="margin: 0 0 20px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
249
|
-
Your Kyro CMS account was temporarily locked after <strong>${i} failed login attempts</strong>.
|
|
250
|
-
</p>
|
|
251
|
-
|
|
252
|
-
<!-- Lockout Notice Card -->
|
|
253
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" class="email-table" style="background-color: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; margin-bottom: 20px; padding: 14px; border-collapse: separate;">
|
|
254
|
-
<tr>
|
|
255
|
-
<td style="font-size: 13px; color: #b45309; line-height: 1.5;">
|
|
256
|
-
\u{1F512} <strong>Lockout duration:</strong> ${e} minutes.<br />
|
|
257
|
-
You may try logging in again after the cooling-off period expires.
|
|
258
|
-
</td>
|
|
259
|
-
</tr>
|
|
260
|
-
</table>
|
|
261
|
-
`,o=l({title:"Account Temporarily Locked",previewText:"Your Kyro CMS account was locked due to multiple failed login attempts.",badgeText:"Security Lockout",badgeType:"warning",bodyHtml:s,ctaText:"Unlock Instructions",ctaUrl:"https://kyro-cms.com/docs"}),a=`Security Alert: Account temporarily locked for ${t} after ${i} failed login attempts. Unlocks in ${e} minutes.
|
|
262
|
-
|
|
263
|
-
Kyro CMS \u2014 https://kyro-cms.com`;return {subject:r,html:o,text:a}}function T(i,e="Editor",t="An Administrator"){let r="You're invited to join Kyro CMS",s=`
|
|
264
|
-
<p class="email-text" style="margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
265
|
-
Hello,
|
|
266
|
-
</p>
|
|
267
|
-
<p class="email-text" style="margin: 0 0 20px; font-size: 14px; line-height: 1.6; color: #52525b;">
|
|
268
|
-
<strong class="email-strong" style="color: #09090b;">${t}</strong> has invited you to join their team workspace as an <strong>${e}</strong> in Kyro CMS.
|
|
269
|
-
</p>
|
|
270
|
-
|
|
271
|
-
<!-- Invite Details Card -->
|
|
272
|
-
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" class="email-table" style="background-color: #fafafa; border: 1px solid #e4e4e7; border-radius: 8px; margin-bottom: 20px; padding: 14px; border-collapse: separate;">
|
|
273
|
-
<tr>
|
|
274
|
-
<td style="font-size: 13px; color: #09090b; line-height: 1.6;" class="email-value">
|
|
275
|
-
<strong>Assigned Role:</strong> ${e}<br />
|
|
276
|
-
<strong>Invited By:</strong> ${t}
|
|
277
|
-
</td>
|
|
278
|
-
</tr>
|
|
279
|
-
</table>
|
|
280
|
-
`,o=l({title:"Workspace Invitation",previewText:`You have been invited to join Kyro CMS as an ${e}.`,badgeText:"Team Invite",badgeType:"info",bodyHtml:s,ctaText:"Accept Invitation",ctaUrl:i,secondaryCtaText:"Documentation",secondaryCtaUrl:"https://kyro-cms.com/docs"}),a=`You're invited to join Kyro CMS as an ${e} by ${t}.
|
|
281
|
-
|
|
282
|
-
Accept your invitation here:
|
|
283
|
-
${i}
|
|
284
|
-
|
|
285
|
-
Kyro CMS \u2014 https://kyro-cms.com`;return {subject:r,html:o,text:a}}function w(){return {verifyEmail:(i,e)=>h(i,e),resetPassword:(i,e)=>y(i,e),welcome:(i,e)=>b(i,e),passwordChanged:i=>x(i),magicLink:(i,e,t)=>_(i,e,t),accountLocked:(i,e,t)=>S(i,e,t),newLogin:(i,e,t="User")=>{let r="Security Alert: New Sign-in to Kyro CMS",s=`New login detected for ${t} at ${e} from ${i}.`,o=`<p>${s}</p>`;return {subject:r,html:o,text:s}},userInvite:(i,e,t)=>T(i,e,t)}}var C=false,u=class i{db;cache={};loaded=false;static SENSITIVE_KEYS=["storage.s3.secret_access_key","storage.r2.secret_access_key","storage.gcs.private_key","storage.backblaze.application_key","storage.wasabi.secret_access_key","storage.ftp.password","storage.bunny.api_key","storage.cloudinary.api_secret","storage.imgix.sign_key","email.smtp.pass","auth.jwt_secret","auth.github_secret","auth.google_secret","auth.app_secret","database.url","redis.url","auth.admin_password"];constructor(e){this.db=e;}async load(){if(!this.loaded){await this.ensureSettingsTable();try{if(typeof this.db?.select=="function"){let e=await this.db.select().from(a);this.cache=e.reduce((t,r)=>(t[r.key]=r.value,t),{});}await this.loadFromGlobals();}catch{console.warn("ConfigService: Could not load settings from database, using environment fallbacks.");}this.loaded=true;}}async ensureSettingsTable(){if(!C)try{if(typeof this.db?.execute=="function"){let{sql:e}=await import('drizzle-orm');await this.db.execute(e`
|
|
286
|
-
CREATE TABLE IF NOT EXISTS "settings" (
|
|
287
|
-
"key" VARCHAR(255) PRIMARY KEY,
|
|
288
|
-
"value" TEXT NOT NULL,
|
|
289
|
-
"description" TEXT,
|
|
290
|
-
"updated_at" TIMESTAMP DEFAULT NOW()
|
|
291
|
-
)
|
|
292
|
-
`),C=!0;}else typeof this.db?.exec=="function"&&(this.db.exec(`
|
|
293
|
-
CREATE TABLE IF NOT EXISTS settings (
|
|
294
|
-
key TEXT PRIMARY KEY,
|
|
295
|
-
value TEXT NOT NULL,
|
|
296
|
-
description TEXT,
|
|
297
|
-
updated_at TEXT
|
|
298
|
-
)
|
|
299
|
-
`),C=!0);}catch{}}async loadFromGlobals(){try{let e=null;if(typeof this.db?.findOne=="function")try{let s=await this.db.findOne({collection:"_globals_storage-settings",where:{},draft:!0});s&&(e=s);}catch{}if(!e&&typeof this.db?.execute=="function"){let{sql:s}=await import('drizzle-orm'),o=['"_globals_storage-settings"','"_globals_storage_settings"','"global_storage_settings"'];for(let a of o)try{let n=await this.db.execute(s`SELECT * FROM ${s.raw(a)} LIMIT 1`);if(e=Array.isArray(n)?n[0]:n?.rows?n.rows[0]:null,e)break}catch{}}else if(!e&&typeof this.db?.prepare=="function"){let s=['"_globals_storage-settings"','"_globals_storage_settings"','"global_storage_settings"'];for(let o of s)try{if(e=this.db.prepare(`SELECT * FROM ${o} LIMIT 1`).get(),e)break}catch{}}if(!e)return;let t=s=>{if(!s)return null;if(typeof s=="string")try{return JSON.parse(s)}catch{return null}return s},r=e.provider||"local";if(this.cache["storage.type"]=r,r==="local"){let s=t(e.local);this.cache["storage.local.dir"]=s?.uploadDir||"./public/uploads",this.cache["storage.local.url"]=s?.baseUrl||"/uploads";}if(r==="aws"){let s=t(e.aws);this.cache["storage.s3.bucket"]=s?.bucket||"",this.cache["storage.s3.region"]=s?.region||"us-east-1",this.cache["storage.s3.access_key_id"]=s?.accessKeyId||"",this.cache["storage.s3.secret_access_key"]=s?.secretAccessKey||"",this.cache["storage.s3.endpoint"]=s?.endpoint||"",this.cache["storage.s3.cdn_url"]=s?.cdnUrl||"",this.cache["storage.s3.prefix"]=s?.prefix||"";}if(r==="r2"){let s=t(e.r2);this.cache["storage.r2.account_id"]=s?.accountId||"",this.cache["storage.r2.access_key_id"]=s?.accessKeyId||"",this.cache["storage.r2.secret_access_key"]=s?.secretAccessKey||"",this.cache["storage.r2.bucket"]=s?.bucket||"",this.cache["storage.r2.cdn_url"]=s?.cdnUrl||"",this.cache["storage.r2.prefix"]=s?.prefix||"";}if(r==="cloudinary"){let s=t(e.cloudinary);this.cache["storage.cloudinary.cloud_name"]=s?.cloudName||"",this.cache["storage.cloudinary.api_key"]=s?.apiKey||"",this.cache["storage.cloudinary.api_secret"]=s?.apiSecret||"",this.cache["storage.cloudinary.folder"]=s?.folder||"";}if(r==="ftp"){let s=t(e.ftp);this.cache["storage.ftp.host"]=s?.host||"",this.cache["storage.ftp.port"]=String(s?.port||"21"),this.cache["storage.ftp.user"]=s?.user||"",this.cache["storage.ftp.password"]=s?.password||"",this.cache["storage.ftp.secure"]=s?.secure?"true":"false",this.cache["storage.ftp.base_url"]=s?.baseUrl||"",this.cache["storage.ftp.prefix"]=s?.prefix||"";}}catch(e){console.warn("ConfigService: Could not load storage settings from globals table:",e);}try{let e=null;if(typeof this.db?.findOne=="function")try{let t=await this.db.findOne({collection:"_globals_email-settings",where:{},draft:!0});t&&(e=t);}catch{}if(!e&&typeof this.db?.execute=="function"){let{sql:t}=await import('drizzle-orm'),r=['"_globals_email-settings"','"_globals_email_settings"','"global_email_settings"'];for(let s of r)try{let o=await this.db.execute(t`SELECT * FROM ${t.raw(s)} LIMIT 1`);if(e=Array.isArray(o)?o[0]:o?.rows?o.rows[0]:null,e)break}catch{}}else if(!e&&typeof this.db?.prepare=="function"){let t=['"_globals_email-settings"','"_globals_email_settings"','"global_email_settings"'];for(let r of t)try{if(e=this.db.prepare(`SELECT * FROM ${r} LIMIT 1`).get(),e)break}catch{}}if(e){let t=r=>{if(!r)return null;if(typeof r=="string")try{return JSON.parse(r)}catch{return null}return r};if(this.cache["email.provider"]=e.provider||"smtp",this.cache["email.smtp.from"]=e.fromEmail||"",this.cache["email.smtp.from_name"]=e.fromName||"",this.cache["email.smtp.reply_to"]=e.replyTo||"",e.provider==="smtp"){let r=t(e.smtp);this.cache["email.smtp.host"]=r?.host||"",this.cache["email.smtp.port"]=String(r?.port||"587"),this.cache["email.smtp.user"]=r?.username||"",this.cache["email.smtp.pass"]=r?.password||"",this.cache["email.smtp.secure"]=r?.secure?"true":"false";}else if(e.provider==="resend"){let r=t(e.resend);this.cache["email.smtp.pass"]=r?.apiKey||"";}else if(e.provider==="sendgrid"){let r=t(e.sendgrid);this.cache["email.smtp.pass"]=r?.apiKey||"";}else if(e.provider==="mailgun"){let r=t(e.mailgun);this.cache["email.smtp.pass"]=r?.apiKey||"";}else if(e.provider==="ses"){let r=t(e.ses);this.cache["email.smtp.user"]=r?.accessKeyId||"",this.cache["email.smtp.pass"]=r?.secretAccessKey||"";}}}catch(e){console.warn("ConfigService: Could not load email settings from globals table:",e);}}get(e,t,r){return this.cache[e]?this.cache[e]:t&&process.env[t]?process.env[t]:r}getStorageConfig(){let e="local";return typeof globalThis.STORAGE_BUCKET<"u"&&(e="cloudflare_r2"),{type:this.get("storage.type","STORAGE_TYPE",e),s3:{bucket:this.get("storage.s3.bucket","STORAGE_BUCKET"),region:this.get("storage.s3.region","STORAGE_REGION","us-east-1"),accessKeyId:this.get("storage.s3.access_key_id","STORAGE_ACCESS_KEY_ID"),secretAccessKey:this.get("storage.s3.secret_access_key","STORAGE_SECRET_ACCESS_KEY"),endpoint:this.get("storage.s3.endpoint","STORAGE_ENDPOINT"),cdnUrl:this.get("storage.s3.cdn_url","STORAGE_CDN_URL"),prefix:this.get("storage.s3.prefix","STORAGE_PREFIX")},r2:{accountId:this.get("storage.r2.account_id","R2_ACCOUNT_ID"),accessKeyId:this.get("storage.r2.access_key_id","R2_ACCESS_KEY_ID"),secretAccessKey:this.get("storage.r2.secret_access_key","R2_SECRET_ACCESS_KEY"),bucket:this.get("storage.r2.bucket","R2_BUCKET"),cdnUrl:this.get("storage.r2.cdn_url","R2_CDN_URL"),prefix:this.get("storage.r2.prefix","R2_PREFIX")},gcs:{bucket:this.get("storage.gcs.bucket","GCS_BUCKET"),projectId:this.get("storage.gcs.project_id","GCS_PROJECT_ID"),clientEmail:this.get("storage.gcs.client_email","GCS_CLIENT_EMAIL"),privateKey:this.get("storage.gcs.private_key","GCS_PRIVATE_KEY"),cdnUrl:this.get("storage.gcs.cdn_url","GCS_CDN_URL"),prefix:this.get("storage.gcs.prefix","GCS_PREFIX")},digitalocean:{bucket:this.get("storage.digitalocean.bucket","DO_BUCKET"),region:this.get("storage.digitalocean.region","DO_REGION","nyc3"),accessKeyId:this.get("storage.digitalocean.access_key_id","DO_ACCESS_KEY_ID"),secretAccessKey:this.get("storage.digitalocean.secret_access_key","DO_SECRET_ACCESS_KEY"),cdnUrl:this.get("storage.digitalocean.cdn_url","DO_CDN_URL"),prefix:this.get("storage.digitalocean.prefix","DO_PREFIX")},backblaze:{bucket:this.get("storage.backblaze.bucket","BB_BUCKET"),accountId:this.get("storage.backblaze.account_id","BB_ACCOUNT_ID"),applicationKeyId:this.get("storage.backblaze.application_key_id","BB_APPLICATION_KEY_ID"),applicationKey:this.get("storage.backblaze.application_key","BB_APPLICATION_KEY"),cdnUrl:this.get("storage.backblaze.cdn_url","BB_CDN_URL"),prefix:this.get("storage.backblaze.prefix","BB_PREFIX")},wasabi:{bucket:this.get("storage.wasabi.bucket","WASABI_BUCKET"),region:this.get("storage.wasabi.region","WASABI_REGION","us-east-1"),accessKeyId:this.get("storage.wasabi.access_key_id","WASABI_ACCESS_KEY_ID"),secretAccessKey:this.get("storage.wasabi.secret_access_key","WASABI_SECRET_ACCESS_KEY"),cdnUrl:this.get("storage.wasabi.cdn_url","WASABI_CDN_URL"),prefix:this.get("storage.wasabi.prefix","WASABI_PREFIX")},bunny:{storageZone:this.get("storage.bunny.storage_zone","BUNNY_STORAGE_ZONE"),apiKey:this.get("storage.bunny.api_key","BUNNY_API_KEY"),cdnUrl:this.get("storage.bunny.cdn_url","BUNNY_CDN_URL"),prefix:this.get("storage.bunny.prefix","BUNNY_PREFIX")},ftp:{host:this.get("storage.ftp.host","FTP_HOST"),port:parseInt(this.get("storage.ftp.port","FTP_PORT","21"),10),user:this.get("storage.ftp.user","FTP_USER"),password:this.get("storage.ftp.password","FTP_PASSWORD"),secure:this.get("storage.ftp.secure","FTP_SECURE")==="true",baseUrl:this.get("storage.ftp.base_url","FTP_BASE_URL"),prefix:this.get("storage.ftp.prefix","FTP_PREFIX")},cloudinary:{cloudName:this.get("storage.cloudinary.cloud_name","CLOUDINARY_CLOUD_NAME"),apiKey:this.get("storage.cloudinary.api_key","CLOUDINARY_API_KEY"),apiSecret:this.get("storage.cloudinary.api_secret","CLOUDINARY_API_SECRET"),folder:this.get("storage.cloudinary.folder","CLOUDINARY_FOLDER")},imgix:{domain:this.get("storage.imgix.domain","IMGIX_DOMAIN"),signKey:this.get("storage.imgix.sign_key","IMGIX_SIGN_KEY")},local:{uploadDir:this.get("storage.local.dir","STORAGE_LOCAL_DIR","./public/uploads"),baseUrl:this.get("storage.local.url","STORAGE_LOCAL_URL","/uploads")}}}getEmailConfig(){return {provider:this.get("email.provider","EMAIL_PROVIDER","smtp"),host:this.get("email.smtp.host","SMTP_HOST"),port:parseInt(this.get("email.smtp.port","SMTP_PORT","587"),10),secure:this.get("email.smtp.secure","SMTP_SECURE")==="true",user:this.get("email.smtp.user","SMTP_USER"),pass:this.get("email.smtp.pass","SMTP_PASS"),from:this.get("email.smtp.from","SMTP_FROM","noreply@example.com"),fromName:this.get("email.smtp.from_name","SMTP_FROM_NAME","Kyro CMS"),replyTo:this.get("email.smtp.reply_to","SMTP_REPLY_TO")}}maskSensitive(e,t){return t&&(i.SENSITIVE_KEYS.includes(e)?"********":t)}async set(e,t,r){await this.db.insert(a).values({key:e,value:t,description:r,updatedAt:new Date}).onConflictDoUpdate({target:[a.key],set:{value:t,description:r,updatedAt:new Date}}),this.cache[e]=t;}};var E=class i{transporter;config;templates;transporterInitialized=false;constructor(e,t){this.config=e,this.templates={...w(),...t};}async ensureTransporter(){if(this.transporterInitialized)return this.transporter;let{default:e}=await import('nodemailer');return this.config.provider==="smtp"&&this.config.smtp?this.transporter=e.createTransport({host:this.config.smtp.host,port:this.config.smtp.port,secure:this.config.smtp.secure,auth:this.config.smtp.auth}):this.config.provider==="ses"&&this.config.ses&&(this.transporter=e.createTransport({host:`email-smtp.${this.config.ses.region}.amazonaws.com`,port:587,secure:false,auth:{user:this.config.ses.accessKeyId,pass:this.config.ses.secretAccessKey}})),this.transporterInitialized=true,this.transporter}async send(e){let{provider:t,from:r,fromName:s,replyTo:o}=this.config,a=`"${s||"Kyro CMS"}" <${r}>`,n=e.replyTo||o;try{let c;switch(t){case "smtp":case "ses":{let g=await this.ensureTransporter();if(!g)throw new Error(`${t} transporter not initialized`);c=await g.sendMail({from:a,to:Array.isArray(e.to)?e.to.join(", "):e.to,subject:e.subject,html:e.html,text:e.text,replyTo:n});}break;case "resend":c=await this.sendViaResend(a,e,n);break;case "sendgrid":c=await this.sendViaSendGrid(a,e,n);break;case "mailgun":c=await this.sendViaMailgun(a,e,n);break;default:throw new Error(`Unsupported email provider: ${t}`)}return c}catch(c){throw console.error("[EmailTransport] FAILED to send email:",c.message),c.response&&console.error("[EmailTransport] Provider Error Detail:",JSON.stringify(c.response,null,2)),c}}async sendViaResend(e,t,r){let s=this.config.resend?.apiKey;if(!s)throw new Error("Resend API Key missing");let o={from:e,to:t.to,subject:t.subject,html:t.html,text:t.text,reply_to:r},a=await fetch("https://api.resend.com/emails",{method:"POST",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok){let n=await a.json();throw new Error(`Resend Error: ${JSON.stringify(n)}`)}return a.json()}async sendViaSendGrid(e,t,r){let s=this.config.sendgrid?.apiKey;if(!s)throw new Error("SendGrid API Key missing");let o={personalizations:[{to:Array.isArray(t.to)?t.to.map(n=>({email:n})):[{email:t.to}]}],from:{email:e.match(/<(.+)>/)?.[1]||e,name:e.match(/"(.+)"/)?.[1]},subject:t.subject,content:[{type:"text/plain",value:t.text||""},{type:"text/html",value:t.html}],reply_to:r?{email:r}:void 0},a=await fetch("https://api.sendgrid.com/v3/mail/send",{method:"POST",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok){let n=await a.json();throw new Error(`SendGrid Error: ${JSON.stringify(n)}`)}return {success:true}}async sendViaMailgun(e,t,r){let{apiKey:s,domain:o,region:a}=this.config.mailgun||{};if(!s||!o)throw new Error("Mailgun config missing");let n=a==="eu"?"api.eu.mailgun.net":"api.mailgun.net",c=btoa(`api:${s}`),g=new URLSearchParams;g.append("from",e);let d=Array.isArray(t.to)?t.to.join(", "):t.to;g.append("to",d),g.append("subject",t.subject),g.append("html",t.html),t.text&&g.append("text",t.text),r&&g.append("h:Reply-To",r);let p=await fetch(`https://${n}/v3/${o}/messages`,{method:"POST",headers:{Authorization:`Basic ${c}`,"Content-Type":"application/x-www-form-urlencoded"},body:g});if(!p.ok){let m=await p.json();throw new Error(`Mailgun Error: ${JSON.stringify(m)}`)}return p.json()}getTemplates(){return this.templates}async verifyConnection(){if(this.config.provider==="smtp"||this.config.provider==="ses")try{let e=await this.ensureTransporter();if(e)return await e.verify(),!0}catch{return false}return !!(this.config.resend?.apiKey||this.config.sendgrid?.apiKey||this.config.mailgun?.apiKey)}static async fromConfig(e){let t=new u(e);await t.load();let r=t.getEmailConfig();if(!r.provider)return this.fromEnv();let s={provider:r.provider||"smtp",from:r.from||"noreply@example.com",fromName:r.fromName,replyTo:r.replyTo,smtp:r.provider==="smtp"?{host:r.host||"",port:r.port||587,secure:r.secure||false,auth:{user:r.user||"",pass:r.pass||""}}:void 0,resend:r.provider==="resend"?{apiKey:r.pass||""}:void 0,sendgrid:r.provider==="sendgrid"?{apiKey:r.pass||""}:void 0,mailgun:r.provider==="mailgun"?{apiKey:r.pass||"",domain:r.host||"",region:r.secure?"eu":"us"}:void 0,ses:r.provider==="ses"?{accessKeyId:r.user||"",secretAccessKey:r.pass||"",region:r.host||"us-east-1"}:void 0};return new i(s)}static fromEnv(){let e=process.env.EMAIL_PROVIDER||"smtp",t=process.env.SMTP_FROM||process.env.DEFAULT_FROM||"noreply@example.com",r=process.env.SMTP_FROM_NAME||"Kyro CMS",s=process.env.SMTP_REPLY_TO;if(e==="smtp"){let o=process.env.SMTP_HOST,a=process.env.SMTP_USER,n=process.env.SMTP_PASS;return !o||!a||!n?null:new i({provider:"smtp",from:t,fromName:r,replyTo:s,smtp:{host:o,port:parseInt(process.env.SMTP_PORT||"587",10),secure:process.env.SMTP_SECURE==="true",auth:{user:a,pass:n}}})}if(e==="resend"){let o=process.env.RESEND_API_KEY||process.env.SMTP_PASS;return o?new i({provider:"resend",from:t,fromName:r,replyTo:s,resend:{apiKey:o}}):null}if(e==="sendgrid"){let o=process.env.SENDGRID_API_KEY||process.env.SMTP_PASS;return o?new i({provider:"sendgrid",from:t,fromName:r,replyTo:s,sendgrid:{apiKey:o}}):null}if(e==="mailgun"){let o=process.env.MAILGUN_API_KEY||process.env.SMTP_PASS,a=process.env.MAILGUN_DOMAIN||process.env.SMTP_HOST;return !o||!a?null:new i({provider:"mailgun",from:t,fromName:r,replyTo:s,mailgun:{apiKey:o,domain:a,region:process.env.MAILGUN_REGION||(process.env.SMTP_SECURE==="true"?"eu":"us")}})}if(e==="ses"){let o=process.env.AWS_ACCESS_KEY_ID||process.env.SMTP_USER,a=process.env.AWS_SECRET_ACCESS_KEY||process.env.SMTP_PASS,n=process.env.AWS_REGION||process.env.SMTP_HOST||"us-east-1";return !o||!a?null:new i({provider:"ses",from:t,fromName:r,replyTo:s,ses:{accessKeyId:o,secretAccessKey:a,region:n}})}return null}};var v={minLength:12,requireUppercase:true,requireLowercase:true,requireNumbers:true,requireSpecialChars:true,preventReuse:5,maxLength:128},k=class{config;constructor(e={}){this.config={...v,...e};}validate(e){let t=[];return this.config.maxLength&&e.length>this.config.maxLength&&t.push(`Password must not exceed ${this.config.maxLength} characters`),e.length<this.config.minLength&&t.push(`Password must be at least ${this.config.minLength} characters`),this.config.requireUppercase&&!/[A-Z]/.test(e)&&t.push("Password must contain at least one uppercase letter"),this.config.requireLowercase&&!/[a-z]/.test(e)&&t.push("Password must contain at least one lowercase letter"),this.config.requireNumbers&&!/[0-9]/.test(e)&&t.push("Password must contain at least one number"),this.config.requireSpecialChars&&!/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(e)&&t.push("Password must contain at least one special character"),["password","123456","12345678","qwerty","abc123","monkey","1234567","letmein","trustno1","dragon","baseball","iloveyou","master","sunshine","ashley","football","password1","shadow","123123","654321"].includes(e.toLowerCase())&&t.push("This password is too common. Please choose a more secure password"),(/^[a-zA-Z]+$/.test(e)||/^[0-9]+$/.test(e))&&t.push("Password must contain a mix of letters, numbers, and/or special characters"),/(.)\1{2,}/.test(e)&&t.push("Password must not contain more than 2 consecutive identical characters"),/^(012|123|234|345|456|567|678|789|890|098|987|876|765|654|543|432|321|210)+$/i.test(e)&&t.push("Password must not contain sequential numbers or letters"),{valid:t.length===0,errors:t}}async checkReuse(e,t,r){return {valid:true,errors:[]}}async isInHistory(e,t,r){for(let s of t)if(await r(e,s))return true;return false}generatePassword(e=16){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",r="abcdefghijklmnopqrstuvwxyz",s="0123456789",o="!@#$%^&*()_+-=[]{}|;:,.<>?",a="";a+=t[Math.floor(Math.random()*t.length)],a+=r[Math.floor(Math.random()*r.length)],a+=s[Math.floor(Math.random()*s.length)],a+=o[Math.floor(Math.random()*o.length)];let n=t+r+s+o;for(let c=a.length;c<e;c++)a+=n[Math.floor(Math.random()*n.length)];return a.split("").sort(()=>Math.random()-.5).join("")}getStrength(e){let t=0,r=[];e.length>=8&&(t+=1),e.length>=12&&(t+=1),e.length>=16&&(t+=1),/[a-z]/.test(e)&&(t+=1),/[A-Z]/.test(e)&&(t+=1),/[0-9]/.test(e)&&(t+=1),/[!@#$%^&*()_+\-=\[\]{}|;:,.<>?]/.test(e)&&(t+=1),e.length>8&&(t+=1),e.length>12&&(t+=1);let s=new Set(e).size;s>6&&(t+=1),s>10&&(t+=1);let o;return t<=3?(o="Weak",r.push("Add more characters"),r.push("Include uppercase and lowercase letters")):t<=5?(o="Fair",r.push("Add special characters"),r.push("Consider making it longer")):t<=7?(o="Good",r.push("Consider making it longer for extra security")):o="Strong",{score:t,label:o,feedback:r}}setConfig(e){this.config={...this.config,...e};}getConfig(){return {...this.config}}};
|
|
300
|
-
export{l as a,h as b,y as c,b as d,x as e,_ as f,S as g,T as h,w as i,u as j,E as k,k as l};
|
package/dist/chunk-CCUQZ66T.cjs
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkFHJJKFAU_cjs=require('./chunk-FHJJKFAU.cjs'),chunkD5P2IPGX_cjs=require('./chunk-D5P2IPGX.cjs'),chunkG7SSHELM_cjs=require('./chunk-G7SSHELM.cjs'),drizzleOrm=require('drizzle-orm'),pgCore=require('drizzle-orm/pg-core'),sqliteCore=require('drizzle-orm/sqlite-core'),postgresJs=require('drizzle-orm/postgres-js'),fe=require('postgres'),crypto=require('crypto'),promises=require('fs/promises'),path=require('path'),module$1=require('module');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var fe__default=/*#__PURE__*/_interopDefault(fe);function D(f){if(typeof f!="string")return f;let t=f.replace(/-/g,"").toLowerCase();return t.length===32?`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`:f}function w(f,t="postgres"){switch(f.type){case "text":case "email":case "password":case "color":case "icon":return t==="sqlite"?"text":"varchar";case "textarea":case "code":case "markdown":case "secret":return "text";case "number":return f.integer?"integer":"decimal";case "checkbox":return "boolean";case "date":return "timestamp";case "select":case "radio":return t==="sqlite"?"text":"varchar";case "richtext":case "json":case "array":case "group":case "blocks":case "row":case "collapsible":case "tabs":return "jsonb";case "relationship":return t==="sqlite"?"text":"varchar";case "upload":return "jsonb";default:return "jsonb"}}function Re(f,t="postgres"){let i=f.slug.replace(/-/g,"_"),e=[];e.push(`export const ${i} = pgTable('${i}', {`),e.push(" id: uuid('id').primaryKey().defaultRandom(),");for(let s of f.fields){if(s.name==="id"||s.type==="password")continue;let a=w(s,t),r=s.required,n=` ${s.name}: pg.${a}('${s.name}')`;s.unique&&(n+=".unique()"),r||(n+=".nullable()"),s.defaultValue!==void 0&&(typeof s.defaultValue=="string"?n+=`.default('${s.defaultValue}')`:typeof s.defaultValue=="boolean"?n+=`.default(${s.defaultValue})`:n+=`.default(sql\`${JSON.stringify(s.defaultValue)}\`)`),n+=",",e.push(n);}return f.timestamps&&(e.push(" createdAt: pg.timestamp('created_at').defaultNow(),"),e.push(" updatedAt: pg.timestamp('updated_at').defaultNow(),")),e.push(` status: ${t==="sqlite"?"sqlite":"pg"}.varchar('status').default('draft'),`),e.push(` hasDraft: ${t==="sqlite"?"sqlite":"pg"}.boolean('hasDraft').default(false),`),e.push("});"),e.join(`
|
|
2
|
-
`)}function z(f,t){return Array.isArray(f)?f.map(i=>{if(!i||typeof i!="object")return i;let e=i.data?{...i.data}:void 0;if(!e)return i;let s=t.find(a=>a.slug===i.type||a.slug===i.slug);if(!s||!Array.isArray(s.fields))return i;for(let a of s.fields){if(a.name&&(a.type==="upload"||a.type==="image")&&e[a.name]){let r=e[a.name];Array.isArray(r)?e[a.name]=r.map(n=>typeof n=="string"?{id:n}:n):typeof r=="string"&&(e[a.name]={id:r});}if(a.type==="blocks"&&a.name&&e[a.name]){let r=a.blocks||[];e[a.name]=z(e[a.name],r);}}return {...i,data:e}}):f}var O=class extends chunkFHJJKFAU_cjs.a{client;schema;_schemaEnsured=false;dialect;connectionString;versionsTableReady=false;rawClient;constructor(t){if(super(),this.schema=t.schema||{},t.connectionString){this.connectionString=t.connectionString;let i=t.connectionString.toLowerCase();i.startsWith("postgres://")||i.startsWith("postgresql://")?this.dialect="postgres":i.includes(".db")||i.includes("sqlite")||i.includes("file:")?this.dialect="sqlite":this.dialect=t.type||"postgres";}else this.rawClient=t.client,this.client=t.client,this.dialect=t.type||"sqlite";}prepareData(t,i){let e=super.prepareData(t,i);e.createdAt&&typeof e.createdAt=="string"&&(e.createdAt=new Date(e.createdAt)),e.updatedAt&&typeof e.updatedAt=="string"&&(e.updatedAt=new Date(e.updatedAt));for(let s of i.fields)if(s.type==="date"&&s.name){let a=e[s.name];a&&typeof a=="string"&&(e[s.name]=new Date(a));}for(let s of i.fields){let r=w(s,this.dialect)==="jsonb";if(s.type==="tabs"&&"tabs"in s&&s.name){let n=t[s.name];if(n&&typeof n=="object"){let o={};for(let[c,d]of Object.entries(n)){let u=s.tabs.flatMap(g=>g.fields).find(g=>g.name===c);(u?.type==="upload"||u?.type==="image"||u?.type==="list"||u?.type==="relationship-block")&&d?o[c]=Array.isArray(d)||typeof d=="object"?JSON.stringify(d):d:o[c]=d;}e[s.name]=this.dialect==="sqlite"||!r?JSON.stringify(o):o;}}else if(r&&s.name&&t[s.name]!==void 0&&t[s.name]!==null)e[s.name]=this.dialect==="sqlite"?JSON.stringify(t[s.name]):t[s.name];else if((s.type==="upload"||s.type==="image"||s.type==="list"||s.type==="relationship-block")&&s.name){let n=t[s.name];n!=null&&(e[s.name]=this.dialect==="sqlite"||!r?typeof n=="string"?n:JSON.stringify(n):n);}}for(let s of i.fields)if(s.name&&e[s.name]===""){let a=w(s,this.dialect);(a==="timestamp"||a==="jsonb"||a==="decimal"||a==="integer"||a==="numeric"||a==="boolean")&&(e[s.name]=null);}return e}async connect(){if(this.connectionString&&!this.client){if(this.dialect==="postgres"){let t,i;try{t=(await import('postgres')).default,i=(await import('drizzle-orm/postgres-js')).drizzle;}catch{chunkD5P2IPGX_cjs.a(["postgres","drizzle-orm"]),t=(await import('postgres')).default,i=(await import('drizzle-orm/postgres-js')).drizzle;}let e=t(this.connectionString,{onnotice:()=>{}});this.client=i(e,{schema:this.schema});}else if(this.dialect==="sqlite"){let t,i,e="better-sqlite3",s="drizzle-orm/better-sqlite3";try{t=(await import(e)).default,i=(await import(s)).drizzle;}catch{chunkD5P2IPGX_cjs.a(["better-sqlite3","drizzle-orm"]),t=(await import(e)).default,i=(await import(s)).drizzle;}let a=new t(this.connectionString.replace("file:",""));this.client=i(a,{schema:this.schema});}}if(this.rawClient&&typeof this.rawClient.prepare=="function"&&typeof this.client?.select!="function"){let{drizzle:t}=await import('drizzle-orm/d1');this.client=t(this.rawClient,{schema:this.schema});}this.connected=true;}async init(t,i=[]){if(await super.init(t,i),(this.connectionString&&!this.client||this.rawClient&&typeof this.client?.select!="function")&&await this.connect(),this.client&&!this._schemaEnsured){for(let s of t){let a=this.getTableName(s.slug);this.schema[a]||(this.schema[a]=this.createTableFromConfig(s));}await this.ensureCollectionTables(t);let e=i.map(s=>({slug:`_globals_${s.slug}`,fields:s.fields,label:s.label}));for(let s of e){let a=this.getTableName(s.slug);this.schema[a]||(this.schema[a]=this.createTableFromConfig(s,true)),this.collections.has(s.slug)||this.collections.set(s.slug,s);}await this.ensureCollectionTables(e),this._schemaEnsured=true;}}createTableFromConfig(t,i=false){let e=this.getTableName(t.slug),s={id:i?pgCore.text("id").primaryKey():pgCore.uuid("id").primaryKey().defaultRandom()};for(let a of t.fields){if(!a.name||a.name==="id"||a.type==="password")continue;let r=w(a,this.dialect),n=a.name.replace(/-/g,"_"),o=n.replace(/([A-Z])/g,"_$1").toLowerCase(),c;if(this.dialect==="sqlite")switch(r){case "varchar":case "text":c=sqliteCore.text(o);break;case "integer":c=sqliteCore.integer(o);break;case "decimal":case "numeric":c=sqliteCore.numeric(o);break;case "boolean":c=sqliteCore.integer(o,{mode:"boolean"});break;case "timestamp":c=sqliteCore.text(o);break;case "jsonb":c=sqliteCore.text(o);break;default:c=sqliteCore.text(o);}else switch(r){case "varchar":c=pgCore.varchar(o,{length:255});break;case "integer":c=pgCore.integer(o);break;case "decimal":c=pgCore.decimal(o);break;case "boolean":c=pgCore.boolean(o);break;case "timestamp":c=pgCore.timestamp(o);break;case "jsonb":c=pgCore.jsonb(o);break;default:c=pgCore.text(o);}a.required||(c=c.default(null)),s[n]=c;}return s.createdAt||(s.createdAt=this.dialect==="sqlite"?sqliteCore.text("created_at").default(new Date().toISOString()):pgCore.timestamp("created_at").defaultNow()),s.updatedAt||(s.updatedAt=this.dialect==="sqlite"?sqliteCore.text("updated_at").default(new Date().toISOString()):pgCore.timestamp("updated_at").defaultNow()),e!=="users"&&e!=="audit_logs"&&(s.status||(s.status=this.dialect==="sqlite"?sqliteCore.text("status").default("draft"):pgCore.varchar("status",{length:20}).default("draft")),s.hasDraft||(s.hasDraft=this.dialect==="sqlite"?sqliteCore.integer("hasDraft",{mode:"boolean"}).default(false):pgCore.boolean("hasDraft").default(false))),this.dialect==="sqlite"?sqliteCore.sqliteTable(e,s):pgCore.pgTable(e,s)}async ensureCollectionTables(t){let i=[];for(let e of t){let s=e.slug.startsWith("_globals_"),a=this.getTableName(e.slug),r=this.generateCreateColumns(e),n=e.fields.some(u=>u.name==="createdAt"),o=e.fields.some(u=>u.name==="updatedAt"),c=e.fields.some(u=>u.name==="status"),d=e.fields.some(u=>u.name==="hasDraft");if(this.dialect==="postgres"){let u=s?'"id" TEXT PRIMARY KEY':'"id" UUID PRIMARY KEY DEFAULT gen_random_uuid()';i.push(`
|
|
3
|
-
CREATE TABLE IF NOT EXISTS "${a}" (
|
|
4
|
-
${u},
|
|
5
|
-
${r}
|
|
6
|
-
${n?"":'"created_at" TIMESTAMP NOT NULL DEFAULT NOW(),'}
|
|
7
|
-
${o?"":'"updated_at" TIMESTAMP NOT NULL DEFAULT NOW(),'}
|
|
8
|
-
${c?"":`"status" VARCHAR(20) DEFAULT 'draft',`}
|
|
9
|
-
${d?"":'"hasDraft" BOOLEAN DEFAULT false'}
|
|
10
|
-
)
|
|
11
|
-
`);}else i.push(`
|
|
12
|
-
CREATE TABLE IF NOT EXISTS "${a}" (
|
|
13
|
-
"id" TEXT PRIMARY KEY,
|
|
14
|
-
${r}
|
|
15
|
-
${n?"":`"created_at" TEXT NOT NULL DEFAULT (datetime('now')),`}
|
|
16
|
-
${o?"":`"updated_at" TEXT NOT NULL DEFAULT (datetime('now')),`}
|
|
17
|
-
${c?"":`"status" TEXT DEFAULT 'draft',`}
|
|
18
|
-
${d?"":'"hasDraft" INTEGER DEFAULT 0'}
|
|
19
|
-
)
|
|
20
|
-
`);}if(i.length>0)if(this.dialect==="postgres")await this.executeRaw(drizzleOrm.sql.raw(i.join(`;
|
|
21
|
-
`)));else for(let e of i)await this.executeRaw(drizzleOrm.sql.raw(e));for(let e of t){let s=this.getTableName(e.slug);s==="users"||s==="audit_logs"||await this.syncTableColumns(e,s);}}getColumnSqlDefinition(t,i){let e=w(t,i),s=t.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase(),a=this.columnSqlType(e,i);return `"${s}" ${a} DEFAULT NULL`}columnSqlType(t,i){if(i==="sqlite")switch(t){case "varchar":return "TEXT";case "text":return "TEXT";case "integer":return "INTEGER";case "decimal":case "numeric":return "NUMERIC";case "boolean":return "INTEGER";case "timestamp":return "TEXT";case "jsonb":return "TEXT";default:return "TEXT"}switch(t){case "varchar":return "VARCHAR(255)";case "text":return "TEXT";case "integer":return "INTEGER";case "decimal":case "numeric":return "DECIMAL";case "boolean":return "BOOLEAN";case "timestamp":return "TIMESTAMP";case "jsonb":return "JSONB";default:return "TEXT"}}getExpectedColumnDefs(t,i){let e={},s=t.slug.startsWith("_globals_"),a=t.fields.some(c=>c.name==="createdAt"),r=t.fields.some(c=>c.name==="updatedAt"),n=t.fields.some(c=>c.name==="status"),o=t.fields.some(c=>c.name==="hasDraft");this.dialect==="postgres"?(e.id=s?'"id" TEXT PRIMARY KEY':'"id" UUID PRIMARY KEY DEFAULT gen_random_uuid()',a||(e.created_at='"created_at" TIMESTAMP DEFAULT NULL'),r||(e.updated_at='"updated_at" TIMESTAMP DEFAULT NULL'),n||(e.status='"status" VARCHAR(20) DEFAULT NULL'),o||(e.hasDraft='"hasDraft" BOOLEAN DEFAULT NULL')):(e.id='"id" TEXT PRIMARY KEY',a||(e.created_at='"created_at" TEXT DEFAULT NULL'),r||(e.updated_at='"updated_at" TEXT DEFAULT NULL'),n||(e.status='"status" TEXT DEFAULT NULL'),o||(e.hasDraft='"hasDraft" INTEGER DEFAULT NULL'));for(let c of t.fields){if(!c.name||c.name==="id")continue;let d=this.getColumnSqlDefinition(c,this.dialect),u=c.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase();e[u]=d;}return e}async syncTableColumns(t,i){let e;try{if(this.dialect==="postgres"){let r=await this.executeRaw(drizzleOrm.sql`SELECT column_name, data_type, character_maximum_length FROM information_schema.columns WHERE table_name = ${i}`);e=new Map(r.map(n=>[n.column_name,{type:n.data_type,maxLen:n.character_maximum_length}]));}else {let r=await this.executeRaw(drizzleOrm.sql`PRAGMA table_info("${drizzleOrm.sql.raw(i)}")`);e=new Map(r.map(n=>[n.name,{type:n.type,maxLen:null}]));}}catch{return}let s=this.getExpectedColumnDefs(t,i),a=Object.keys(s).filter(r=>!e.has(r));if(a.length>0){let r=a.map(n=>`ALTER TABLE "${i}" ADD COLUMN ${s[n]}`);await this.executeRaw(drizzleOrm.sql.raw(r.join(`;
|
|
22
|
-
`)));}if(this.dialect==="postgres")for(let r of t.fields){if(!r.name||r.name==="id")continue;let n=w(r,this.dialect),o=r.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase(),c=e.get(o);!c||c.type!=="character varying"||(n==="text"?await this.executeRaw(drizzleOrm.sql.raw(`ALTER TABLE "${i}" ALTER COLUMN "${o}" TYPE TEXT`)):n==="jsonb"&&(await this.executeRaw(drizzleOrm.sql.raw(`ALTER TABLE "${i}" ALTER COLUMN "${o}" DROP DEFAULT`)),await this.executeRaw(drizzleOrm.sql.raw(`ALTER TABLE "${i}" ALTER COLUMN "${o}" TYPE JSONB USING (CASE WHEN "${o}" IS NULL THEN NULL WHEN "${o}"::text ~ '^\\s*\\{' THEN "${o}"::jsonb ELSE jsonb_build_object('id', "${o}"::text) END)`))));}}generateCreateColumns(t){let i=[];for(let e of t.fields){if(!e.name||e.name==="id")continue;let s=w(e,this.dialect),a=e.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase(),r=e.required?"NOT NULL":"DEFAULT NULL",n;if(this.dialect==="sqlite")switch(s){case "varchar":case "text":n=`TEXT ${r}`;break;case "integer":n=`INTEGER ${r}`;break;case "decimal":case "numeric":n=`NUMERIC ${r}`;break;case "boolean":n=`INTEGER ${r}`;break;case "timestamp":n=`TEXT ${r}`;break;case "jsonb":n=`TEXT ${r}`;break;default:n=`TEXT ${r}`;}else switch(s){case "varchar":n=`VARCHAR(255) ${r}`;break;case "integer":n=`INTEGER ${r}`;break;case "decimal":n=`DECIMAL ${r}`;break;case "boolean":n=`BOOLEAN ${r}`;break;case "timestamp":n=`TIMESTAMP ${r}`;break;case "jsonb":n=`JSONB ${r}`;break;default:n=`TEXT ${r}`;}i.push(`"${a}" ${n}`);}return i.join(`,
|
|
23
|
-
`)+(i.length>0?",":"")}async disconnect(){this.connected=false;}async find(t){let{collection:i,where:e={},sort:s,limit:a=10,page:r=1,tenantId:n,select:o,draft:c}=t,d=this.getCollection(i),u=this.getTable(i),m={...e};this.tenantContext&&d.tenantScoped&&(m=chunkFHJJKFAU_cjs.c({where:m},i,this.tenantContext,chunkFHJJKFAU_cjs.b).where||{});let g=this.buildWhereClause(m,d,u,n),y=d.fields.find(h=>h.name==="status"),p=y?.type==="select"&&Array.isArray(y.options)&&y.options.some(h=>h.value==="published");!c&&u.status&&p&&g.push(drizzleOrm.eq(u.status,"published"));let b=this.parseSort(s),_=!c&&u.status&&p?{...m,status:"published"}:m,W=await this.count({collection:i,where:_,tenantId:n}),V=(r-1)*a,U=[];try{let h=u[b.field]||u.createdAt||u.id,R=b.direction==="asc"?h:drizzleOrm.desc(h),A=this.client.select().from(u);g.length>0&&(A=A.where(drizzleOrm.and(...g))),U=await A.orderBy(R).limit(a).offset(V);}catch(h){console.error("[DrizzleAdapter] Query error:",h);}let N=U.map(h=>this.processResult(h,d));return this.tenantContext&&!this.tenantContext.isSuperAdmin&&(N=N.filter(h=>chunkFHJJKFAU_cjs.d(h,i,this.tenantContext,chunkFHJJKFAU_cjs.b))),c&&(N=await Promise.all(N.map(async h=>{let R=await this.executeRaw(drizzleOrm.sql`
|
|
24
|
-
SELECT * FROM kyro_versions
|
|
25
|
-
WHERE collection_slug = ${i}
|
|
26
|
-
AND document_id = ${h.id}
|
|
27
|
-
ORDER BY created_at DESC
|
|
28
|
-
LIMIT 1
|
|
29
|
-
`);if(R.length>0){let A=R[0],Y=typeof A.data=="string"?JSON.parse(A.data):A.data;return {...h,...Y,status:h.status}}return h}))),{docs:N,...this.calculatePagination(r,a,W)}}async findByID(t){let{collection:i,id:e,tenantId:s,draft:a}=t,r=this.getCollection(i),n=this.getTable(i),o=this.dialect==="postgres"&&typeof e=="string"?D(e):e;if(this.tenantContext&&r.tenantScoped){let p={id:o,tenantId:this.tenantContext.tenantId};if(!chunkFHJJKFAU_cjs.d(p,i,this.tenantContext,chunkFHJJKFAU_cjs.b))return null}let c=[drizzleOrm.eq(n.id,o)];s&&n.tenantId&&c.push(drizzleOrm.eq(n.tenantId,s));let d=r.fields.find(p=>p.name==="status"),u=d?.type==="select"&&Array.isArray(d.options)&&d.options.some(p=>p.value==="published");!a&&n.status&&u&&c.push(drizzleOrm.eq(n.status,"published"));let m=c.length>1?drizzleOrm.and(...c):c[0],g=await this.client.select().from(n).where(m);if(g.length===0)return null;let y=this.processResult(g[0],r);if(a){let p=await this.executeRaw(drizzleOrm.sql`
|
|
30
|
-
SELECT * FROM kyro_versions
|
|
31
|
-
WHERE collection_slug = ${i}
|
|
32
|
-
AND document_id = ${y.id}
|
|
33
|
-
ORDER BY created_at DESC
|
|
34
|
-
LIMIT 1
|
|
35
|
-
`);if(p.length>0){let b=p[0],_=typeof b.data=="string"?JSON.parse(b.data):b.data;y={...y,..._,status:y.status};}}return y}async create(t){let{collection:i,data:e,tenantId:s}=t,a=this.getCollection(i),r=this.getTable(i),n=this.prepareData(e,a);s&&a.tenantScoped&&(n.tenantId=s);let o=await this.client.insert(r).values(n).returning();return this.processResult(o[0],a)}async update(t){let{collection:i,id:e,data:s,tenantId:a}=t,r=this.getCollection(i),n=this.getTable(i),o=this.prepareData(s,r),c=this.dialect==="postgres"&&typeof e=="string"?D(e):e,d=[drizzleOrm.eq(n.id,c)];a&&n.tenantId&&d.push(drizzleOrm.eq(n.tenantId,a));let u=await this.client.update(n).set(o).where(drizzleOrm.and(...d)).returning();if(u.length===0)throw new Error(`Document not found: ${i}/${e}`);return this.processResult(u[0],r)}async delete(t){let{collection:i,id:e,tenantId:s}=t,a=this.getCollection(i),r=this.getTable(i),n=this.dialect==="postgres"&&typeof e=="string"?D(e):e,o=[drizzleOrm.eq(r.id,n)];s&&r.tenantId&&o.push(drizzleOrm.eq(r.tenantId,s));let c=await this.client.delete(r).where(drizzleOrm.and(...o)).returning();if(c.length===0)throw new Error(`Document not found: ${i}/${e}`);return this.processResult(c[0],a)}async count(t){let{collection:i,where:e={},tenantId:s}=t,a=this.getCollection(i),r=this.getTable(i),n=this.buildWhereClause(e,a,r,s);try{let o=this.client.select({count:drizzleOrm.sql`count(*)`}).from(r);n.length>0&&(o=o.where(drizzleOrm.and(...n)));let c=await o;return Number(c[0]?.count||0)}catch{return 0}}async findOne(t){let{collection:i,where:e={},tenantId:s,draft:a}=t;if(i.startsWith("_globals_")){let n=i.replace("_globals_",""),o=this.globals.get(n);if(!o)throw new Error(`Global "${n}" not found`);let c=this.getTable(i),d=this.client.select().from(c),u=o.fields.find(p=>p.name==="status"),m=u?.type==="select"&&Array.isArray(u.options)&&u.options.some(p=>p.value==="published");!a&&c.status&&m&&(d=d.where(drizzleOrm.eq(c.status,"published")));let g=await d.limit(1);if(g.length===0)return null;let y=this.processResult(g[0],o);if(a){let p=await this.executeRaw(drizzleOrm.sql`
|
|
36
|
-
SELECT * FROM kyro_versions
|
|
37
|
-
WHERE collection_slug = ${i}
|
|
38
|
-
AND document_id = ${n}
|
|
39
|
-
ORDER BY created_at DESC
|
|
40
|
-
LIMIT 1
|
|
41
|
-
`);if(p.length>0){let b=p[0],_=typeof b.data=="string"?JSON.parse(b.data):b.data;y={...y,..._,status:y.status};}}return y}return (await this.find({...t,limit:1})).docs[0]||null}async findVersions(t){await this.ensureVersionsTable();let{collection:i,documentId:e,limit:s=10,page:a=1,tenantId:r}=t,n=(a-1)*s,o=this.getCollection(i),c=await this.executeRaw(drizzleOrm.sql`
|
|
42
|
-
SELECT count(*) as count
|
|
43
|
-
FROM kyro_versions
|
|
44
|
-
WHERE collection_slug = ${i}
|
|
45
|
-
AND document_id = ${e}
|
|
46
|
-
AND autosave = 0
|
|
47
|
-
${r&&o.tenantScoped?drizzleOrm.sql`AND tenant_id = ${r}`:drizzleOrm.sql``}
|
|
48
|
-
`),d=parseInt(c[0]?.count||"0");return {docs:(await this.executeRaw(drizzleOrm.sql`
|
|
49
|
-
SELECT *
|
|
50
|
-
FROM kyro_versions
|
|
51
|
-
WHERE collection_slug = ${i}
|
|
52
|
-
AND document_id = ${e}
|
|
53
|
-
AND autosave = 0
|
|
54
|
-
${r&&o.tenantScoped?drizzleOrm.sql`AND tenant_id = ${r}`:drizzleOrm.sql``}
|
|
55
|
-
ORDER BY created_at DESC
|
|
56
|
-
LIMIT ${s}
|
|
57
|
-
OFFSET ${n}
|
|
58
|
-
`)).map(m=>({...m,data:typeof m.data=="string"?JSON.parse(m.data):m.data})),...this.calculatePagination(a,s,d)}}async findVersionByID(t){await this.ensureVersionsTable();let i=this.getCollection(t.collection),e=await this.executeRaw(drizzleOrm.sql`
|
|
59
|
-
SELECT * FROM kyro_versions
|
|
60
|
-
WHERE id = ${t.versionId}
|
|
61
|
-
AND collection_slug = ${t.collection}
|
|
62
|
-
${t.tenantId&&i.tenantScoped?drizzleOrm.sql`AND tenant_id = ${t.tenantId}`:drizzleOrm.sql``}
|
|
63
|
-
LIMIT 1
|
|
64
|
-
`);if(e.length===0)return null;let s=e[0];return {...s,data:typeof s.data=="string"?JSON.parse(s.data):s.data}}async createVersion(t){await this.ensureVersionsTable();let i=this.getCollection(t.collection),e=new Date().toISOString();if(t.autosave){let a=await this.executeRaw(drizzleOrm.sql`
|
|
65
|
-
SELECT * FROM kyro_versions
|
|
66
|
-
WHERE collection_slug = ${t.collection}
|
|
67
|
-
AND document_id = ${t.documentId}
|
|
68
|
-
AND autosave = 1
|
|
69
|
-
${t.tenantId&&i.tenantScoped?drizzleOrm.sql`AND tenant_id = ${t.tenantId}`:drizzleOrm.sql``}
|
|
70
|
-
LIMIT 1
|
|
71
|
-
`);if(a.length>0)return await this.executeRaw(drizzleOrm.sql`
|
|
72
|
-
UPDATE kyro_versions
|
|
73
|
-
SET data = ${JSON.stringify(t.data)},
|
|
74
|
-
status = ${t.status},
|
|
75
|
-
updated_at = ${e}
|
|
76
|
-
WHERE id = ${a[0].id}
|
|
77
|
-
`),this.findVersionByID({collection:t.collection,versionId:a[0].id,tenantId:t.tenantId})}let s=Math.random().toString(36).substring(2,15);if(await this.executeRaw(drizzleOrm.sql`
|
|
78
|
-
INSERT INTO kyro_versions (
|
|
79
|
-
id, collection_slug, document_id, tenant_id, data, status, autosave, created_by, change_description, created_at, updated_at
|
|
80
|
-
) VALUES (
|
|
81
|
-
${s}, ${t.collection}, ${t.documentId}, ${t.tenantId&&i.tenantScoped?t.tenantId:null},
|
|
82
|
-
${JSON.stringify(t.data)}, ${t.status}, ${t.autosave?1:0}, ${t.createdBy||null},
|
|
83
|
-
${t.changeDescription||null}, ${e}, ${e}
|
|
84
|
-
)
|
|
85
|
-
`),!t.autosave){let a=this.getCollection(t.collection);a.versions?.maxPerDoc&&await this.deleteVersions({collection:t.collection,documentId:t.documentId,keepLatest:a.versions.maxPerDoc,tenantId:t.tenantId});}return this.findVersionByID({collection:t.collection,versionId:s,tenantId:t.tenantId})}async updateLatestVersion(t){return this.createVersion({...t,autosave:true})}async deleteVersions(t){await this.ensureVersionsTable();let i=this.getCollection(t.collection);if(t.keepLatest){let s=(await this.executeRaw(drizzleOrm.sql`
|
|
86
|
-
SELECT id FROM kyro_versions
|
|
87
|
-
WHERE collection_slug = ${t.collection}
|
|
88
|
-
AND document_id = ${t.documentId}
|
|
89
|
-
AND autosave = 0
|
|
90
|
-
${t.tenantId&&i.tenantScoped?drizzleOrm.sql`AND tenant_id = ${t.tenantId}`:drizzleOrm.sql``}
|
|
91
|
-
ORDER BY created_at DESC
|
|
92
|
-
LIMIT ${t.keepLatest}
|
|
93
|
-
`)).map(a=>a.id);s.length>0&&await this.executeRaw(drizzleOrm.sql`
|
|
94
|
-
DELETE FROM kyro_versions
|
|
95
|
-
WHERE collection_slug = ${t.collection}
|
|
96
|
-
AND document_id = ${t.documentId}
|
|
97
|
-
AND autosave = 0
|
|
98
|
-
AND id NOT IN (${drizzleOrm.sql.join(s.map(a=>drizzleOrm.sql`${a}`),drizzleOrm.sql`, `)})
|
|
99
|
-
`);}else await this.executeRaw(drizzleOrm.sql`
|
|
100
|
-
DELETE FROM kyro_versions
|
|
101
|
-
WHERE collection_slug = ${t.collection}
|
|
102
|
-
AND document_id = ${t.documentId}
|
|
103
|
-
${t.tenantId&&i.tenantScoped?drizzleOrm.sql`AND tenant_id = ${t.tenantId}`:drizzleOrm.sql``}
|
|
104
|
-
`);}getTable(t){let i=this.getTableName(t),e=this.schema[i];if(!e)throw new Error(`Table "${i}" not found in schema`);return e}buildWhereClause(t,i,e,s){let a=[];s&&i.tenantScoped&&e.tenantId&&a.push(drizzleOrm.eq(e.tenantId,s));for(let[r,n]of Object.entries(t))if(r==="id"&&this.dialect==="postgres"&&(typeof n=="string"?n=D(n):n&&typeof n=="object"&&(n.equals!==void 0&&typeof n.equals=="string"&&(n={...n,equals:D(n.equals)}),n.in&&Array.isArray(n.in)&&(n={...n,in:n.in.map(o=>typeof o=="string"?D(o):o)}))),r==="AND"&&Array.isArray(n)){let o=n.map(c=>this.buildWhereClause(c,i,e)).flat().filter(Boolean);o.length>0&&a.push(drizzleOrm.and(...o));}else if(r==="OR"&&Array.isArray(n)){let o=n.map(c=>this.buildWhereClause(c,i,e)).flat().filter(Boolean);o.length>0&&a.push(drizzleOrm.or(...o));}else if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let o=e[r];if(!o)continue;n.equals!==void 0&&a.push(drizzleOrm.eq(o,n.equals)),n.not_equals!==void 0&&a.push(drizzleOrm.ne(o,n.not_equals)),n.in&&Array.isArray(n.in)&&a.push(drizzleOrm.inArray(o,n.in)),n.like!==void 0&&a.push(drizzleOrm.like(o,n.like)),n.contains!==void 0&&a.push(drizzleOrm.like(o,`%${n.contains}%`)),n.greater_than!==void 0&&a.push(drizzleOrm.gt(o,n.greater_than)),n.greater_than_equal!==void 0&&a.push(drizzleOrm.gte(o,n.greater_than_equal)),n.less_than!==void 0&&a.push(drizzleOrm.lt(o,n.less_than)),n.less_than_equal!==void 0&&a.push(drizzleOrm.lte(o,n.less_than_equal));}else {let o=e[r];o&&a.push(drizzleOrm.eq(o,n));}return a}processResult(t,i){if(!t)return null;let e={...t};for(let s of Object.keys(e))/^\d+$/.test(s)&&delete e[s];t.id&&(e.id=String(t.id));for(let s of i.fields){if(!s.name)continue;let a=s.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase();a!==s.name&&e[a]!==void 0&&e[s.name]===void 0&&(e[s.name]=e[a],delete e[a]);}for(let s of i.fields){if(["json","richtext","array","group","blocks","upload","image","list","relationship-block"].includes(s.type)){let a=s;if(e[a.name]&&typeof e[a.name]=="string")try{let r=JSON.parse(e[a.name]);e[a.name]=r;}catch{}if(s.type==="blocks"&&e[a.name]&&Array.isArray(e[a.name])){let r=a.blocks||[];e[a.name]=z(e[a.name],r);}}if(s.type==="tabs"&&"tabs"in s&&s.name){if(typeof e[s.name]=="object"&&e[s.name]!==null&&!Array.isArray(e[s.name])){for(let r of s.tabs)for(let n of r.fields)if((n.type==="upload"||n.type==="image")&&n.name){let o=e[s.name][n.name];if(typeof o=="string")try{let c=JSON.parse(o);e[s.name][n.name]=Array.isArray(c)?c.map(d=>d&&typeof d=="object"&&typeof d.id=="string"?d.id:String(d||"")):typeof c.id=="string"?c.id:String(c.id||"");}catch{}else o&&typeof o=="object"&&(e[s.name][n.name]=Array.isArray(o)?o.map(c=>c&&typeof c=="object"&&typeof c.id=="string"?c.id:String(c||"")):typeof o.id=="string"?o.id:String(o.id||""));}continue}if(typeof e[s.name]=="string")try{let r=JSON.parse(e[s.name]);if(typeof r=="object"&&r!==null){e[s.name]=r;continue}}catch{}let a={};for(let r of s.tabs)for(let n of r.fields)if(n.name&&e[n.name]!==void 0){let o=e[n.name];if(["json","richtext","array","group","blocks","upload","image","list","relationship-block"].includes(n.type)){if(o&&typeof o=="string")try{o=JSON.parse(o);}catch{}(n.type==="upload"||n.type==="image")&&o&&typeof o=="object"&&(o=Array.isArray(o)?o.map(c=>c&&typeof c=="object"&&typeof c.id=="string"?c.id:String(c||"")):typeof o.id=="string"?o.id:String(o.id||""));}a[n.name]=o,delete e[n.name];}e[s.name]=a;}}return e.createdAt&&(e.createdAt=new Date(e.createdAt).toISOString()),e.updatedAt&&(e.updatedAt=new Date(e.updatedAt).toISOString()),chunkG7SSHELM_cjs.a(e)}async ensureVersionsTable(){if(this.versionsTableReady)return;let t;this.dialect==="sqlite"?t=`
|
|
105
|
-
CREATE TABLE IF NOT EXISTS kyro_versions (
|
|
106
|
-
id text PRIMARY KEY,
|
|
107
|
-
collection_slug text NOT NULL,
|
|
108
|
-
document_id text NOT NULL,
|
|
109
|
-
tenant_id text,
|
|
110
|
-
data text NOT NULL,
|
|
111
|
-
status text NOT NULL DEFAULT 'draft',
|
|
112
|
-
autosave integer NOT NULL DEFAULT 0,
|
|
113
|
-
created_by text,
|
|
114
|
-
change_description text,
|
|
115
|
-
created_at text DEFAULT (datetime('now')),
|
|
116
|
-
updated_at text DEFAULT (datetime('now'))
|
|
117
|
-
)
|
|
118
|
-
`:t=`
|
|
119
|
-
CREATE TABLE IF NOT EXISTS kyro_versions (
|
|
120
|
-
id text PRIMARY KEY,
|
|
121
|
-
collection_slug text NOT NULL,
|
|
122
|
-
document_id text NOT NULL,
|
|
123
|
-
tenant_id text,
|
|
124
|
-
data text NOT NULL,
|
|
125
|
-
status text NOT NULL,
|
|
126
|
-
autosave integer NOT NULL DEFAULT 0,
|
|
127
|
-
created_by text,
|
|
128
|
-
change_description text,
|
|
129
|
-
created_at text NOT NULL,
|
|
130
|
-
updated_at text NOT NULL
|
|
131
|
-
)
|
|
132
|
-
`,await this.executeRaw(drizzleOrm.sql.raw(t));try{this.dialect==="postgres"?await this.executeRaw(drizzleOrm.sql.raw("ALTER TABLE kyro_versions ADD COLUMN IF NOT EXISTS autosave integer NOT NULL DEFAULT 0")):await this.executeRaw(drizzleOrm.sql.raw("ALTER TABLE kyro_versions ADD COLUMN autosave integer NOT NULL DEFAULT 0"));}catch{}this.versionsTableReady=true;}async execute(t){return this.executeRaw(t)}async executeRaw(t){let i="",e=[];if(typeof t=="string")i=t;else if(t&&(t.queryChunks||t.decoder))if(this.dialect==="postgres"){let a=new pgCore.PgDialect().sqlToQuery(t);i=a.sql,e=a.params;}else {let a=new sqliteCore.SQLiteSyncDialect().sqlToQuery(t);i=a.sql,e=a.params;}else if(t&&typeof t.toSQL=="function"){let a=t.toSQL();i=a.sql,e=a.params||[];}else i=String(t);let s=this.rawClient||this.client;if(s?.prepare&&typeof s.prepare=="function"){let a=s.prepare(i);return (e.length>0?await a.bind(...e).all():await a.all()).results||[]}if(typeof this.client?.execute=="function"){let a=await this.client.execute(t);return Array.isArray(a)?a:Array.isArray(a?.rows)?a.rows:Array.isArray(a?.[0])?a[0]:[]}return []}};function Ce(f){return new O(f)}var S;function Te(){return S||(S=module$1.createRequire("file:///")("node:sqlite").DatabaseSync,S)}function be(){return process.env.DB_TYPE==="postgres"?"postgres":"sqlite"}function X(){return crypto.randomBytes(16).toString("hex")}async function qe(){let f=be();if(f==="sqlite"){let r=path.resolve(process.cwd(),"data","kyro.db");await promises.mkdir(path.dirname(r),{recursive:true});let n=new(Te())(r);return n.exec("PRAGMA journal_mode = WAL"),{db:n,dialect:f,genId:X}}let t=process.env.DATABASE_URL||"postgresql://postgres:postgres@localhost:5432/kyro_cms",i=parseInt(process.env.DB_POOL_MAX||"10",10),e=process.env.DB_SSL==="true",s=fe__default.default(t,{max:i,ssl:e?"require":false,onnotice:()=>{}});return {db:postgresJs.drizzle(s),dialect:f,genId:X}}async function Fe(f,t){}async function ke(f){let{roles:t}=await import('./schema-HIUSHSUI.cjs');await f.insert(t).values({name:"super_admin",level:100,inherits:[],description:"Full system access across all tenants",isSystem:true}).onConflictDoNothing();}
|
|
133
|
-
exports.a=w;exports.b=Re;exports.c=O;exports.d=Ce;exports.e=X;exports.f=qe;exports.g=Fe;exports.h=ke;
|
package/dist/chunk-D5P2IPGX.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
'use strict';var child_process=require('child_process'),fs=require('fs'),path=require('path');function e(){let n=process.cwd();return fs.existsSync(path.join(n,"pnpm-lock.yaml"))?"pnpm":fs.existsSync(path.join(n,"yarn.lock"))?"yarn":fs.existsSync(path.join(n,"bun.lockb"))||fs.existsSync(path.join(n,"bun.lock"))?"bun":"npm"}function m(n){let o=e();console.log(`
|
|
2
|
-
\u{1F4E6} [Kyro CMS] Auto-installing missing database drivers: ${n.join(", ")}...`);try{let i=o==="npm"?"npm install":`${o} add`;child_process.execSync(`${i} ${n.join(" ")}`,{stdio:"inherit"}),console.log(`\u2705 [Kyro CMS] Successfully installed drivers!
|
|
3
|
-
`);}catch(i){throw console.error(`\u274C [Kyro CMS] Failed to auto-install drivers. Please run manually: ${o==="npm"?"npm install":`${o} add`} ${n.join(" ")}`),i}}exports.a=m;
|
package/dist/chunk-EPMGPNBE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {z}from'./chunk-ZIWJJRWQ.js';import {d}from'./chunk-B5XWYVWK.js';import {r}from'./chunk-HQP2Y7QQ.js';import {a as a$1}from'./chunk-Q2UYCYKV.js';import {c}from'./chunk-7IVN6TTY.js';import {a}from'./chunk-RHCWCG3O.js';import {a as a$2}from'./chunk-6ROHVUXF.js';import g from'kyro:config';var n=null,l=null;async function _(){if(!n){if(globalThis.__KYRO_INSTANCE__)try{await globalThis.__KYRO_INSTANCE__.shutdown();}catch{}try{let t=g.default||g,r$1=t.adapter,i=r$1&&!r$1.dialect&&typeof r$1.connect=="function";if(i&&globalThis.DB){let o=globalThis.DB;t.adapter=new c({type:"sqlite",client:o}),console.log("[Kyro API] Hot-swapped LocalAdapter for D1 DrizzleAdapter");}n=z(t);let a$3=t.adapter,c$1=a$3&&a$3.dialect&&(a$3.dialect==="postgres"||a$3.dialect==="sqlite"),s=a$3&&a$3.dialect==="mongodb",e;if(c$1)a$3.dialect==="postgres"?e=new a({db:a$3.client}):a$3.dialect==="sqlite"&&(e=new r({db:a$3.rawClient||a$3.client}));else if(i&&!globalThis.DB){let o=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";e=new a$1({path:o});}else s&&(e=new a$2({db:a$3.client}));if(e?.connect)try{await e.connect();}catch(o){console.warn("[Kyro API] Auth connect warning:",o);}await n.init();try{await n.loadSettings();}catch(o){console.warn("[Kyro API] loadSettings warning:",o);}try{await d(e);}catch(o){console.warn("[Kyro API] autoBootstrap warning:",o);}globalThis.__KYRO_INSTANCE__=n;}catch(t){throw n=null,l=null,console.error("[Kyro API] Init failed, will retry:",t),t}}}async function b(t){let r=globalThis.DB?globalThis:null;if(t)try{r=t.locals?.runtime?.env||t.locals?.cfContext?.env||t?.env||r;}catch{}if(!r)try{r=process.env;}catch{}r?.DB&&(globalThis.DB=r.DB),r?.STORAGE_BUCKET&&(globalThis.STORAGE_BUCKET=r.STORAGE_BUCKET),l||(l=_()),await l;}var m={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function w(t){if(!n)return m[t]??true;try{return (await n.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.[t]??m[t]??!0}catch{return true}}var K=async t=>{if(!n)try{await Promise.race([b(t),new Promise((s,e)=>setTimeout(()=>e(new Error("Initialization timeout")),3e4))]);}catch(s){return console.error("[Kyro API] Warm error:",s?.stack||s?.message||s),new Response(JSON.stringify({error:"Service Unavailable",message:"Kyro CMS is still starting up. Please try again in a moment."}),{status:503,headers:{"Content-Type":"application/json","Retry-After":"5"}})}let i=new URL(t.request.url).pathname,a=__KYRO_API_PATH__;if(i===`${a}/graphql`&&typeof n.getGraphQL=="function"){if(!await w("graphqlEnabled"))return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let e=await n.getGraphQL().fetch(t.request,t.locals);return new Response(e.body,e)}if(i.startsWith(`${a}/trpc/`)&&typeof n.getTRPC=="function"){if(!await w("trpcEnabled"))return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let e=await n.getTRPC().fetch(t.request,t.locals);return new Response(e.body,e)}return n.getREST().fetch(t.request,t.locals)};export{n as a,b,K as c};
|
package/dist/chunk-FHJJKFAU.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkQ3Q7BJVQ_cjs=require('./chunk-Q3Q7BJVQ.cjs');var a=class{collections=new Map;globals=new Map;connected=false;tenantContext;setTenantContext(e){this.tenantContext=e;}getTenantContext(){return this.tenantContext}async init(e,n=[]){for(let t of e)this.collections.set(t.slug,t);for(let t of n)this.globals.set(t.slug,t);await this.connect();}getCollection(e){let n=this.collections.get(e);if(!n)throw console.error(`[Adapter] Missing collection "${e}". Available collections:`,Array.from(this.collections.keys())),new Error(`Collection "${e}" not found in adapter`);return n}applyTenantFilter(e={},n){return n?{...e,tenantId:{equals:n}}:e}getTableName(e){return e.replace(/-/g,"_")}prepareData(e,n){let t={...e};return n.timestamps&&(t.updatedAt=new Date().toISOString(),t.createdAt||(t.createdAt=new Date().toISOString())),n.auth&&t.password,t}processRelationships(e,n,t){return e}parseSort(e){return e?e.startsWith("-")?{field:e.slice(1),direction:"desc"}:{field:e,direction:"asc"}:{field:"createdAt",direction:"desc"}}calculatePagination(e,n,t){let r=Math.ceil(t/n);return {totalDocs:t,limit:n,totalPages:r,page:e,pagingCounter:(e-1)*n+1,hasPrevPage:e>1,hasNextPage:e<r,prevPage:e>1?e-1:null,nextPage:e<r?e+1:null}}selectFields(e,n){if(!n||n.length===0)return e;let t={};for(let r of n)r in e&&(t[r]=e[r]);return t.id=e.id,t}isRelationshipField(e){return e.type==="relationship"}isUploadField(e){return e.type==="upload"}getRelationshipFields(e){let n=[];for(let t of e)t.type==="relationship"?n.push(t):"fields"in t&&t.fields&&n.push(...this.getRelationshipFields(t.fields));return n}getUploadFields(e){let n=[];for(let t of e)t.type==="upload"?n.push(t):"fields"in t&&t.fields&&n.push(...this.getUploadFields(t.fields));return n}};var s={tenantEnabled:true,tenantField:"tenantId",ownershipRules:{posts:{ownerField:"authorId",bypassRoles:["super_admin","admin","editor"]},pages:{ownerField:"authorId",bypassRoles:["super_admin","admin","editor"]},media:{ownerField:"uploadedBy",bypassRoles:["super_admin","admin","editor"]},orders:{ownerField:"customerId",bypassRoles:["super_admin","admin","editor"]},customers:{ownerField:"id",bypassRoles:["super_admin","admin"]},navigation:{ownerField:"id",bypassRoles:["super_admin","admin"]}}};function d(i,e,n=s){return !n.tenantEnabled||e.isSuperAdmin?i:{...i,where:{...i.where,[n.tenantField]:e.tenantId}}}function l(i,e,n,t=s){let r=t.ownershipRules[e];return !r||r.bypassRoles&&chunkQ3Q7BJVQ_cjs.b({role:n.role},r.bypassRoles)?i:r.ownerField==="id"&&n.userId?{...i,where:{...i.where,id:n.userId}}:r.ownerField&&n.userId?{...i,where:{...i.where,[r.ownerField]:n.userId}}:i}function p(i,e,n,t=s){let r=i;return r=d(r,n,t),r=l(r,e,n,t),r}function u(i,e,n,t=s){if(n.isSuperAdmin)return true;if(t.tenantEnabled&&i[t.tenantField]!==n.tenantId)return false;let r=t.ownershipRules[e];return !r||r.bypassRoles&&chunkQ3Q7BJVQ_cjs.b({role:n.role},r.bypassRoles)?true:r.ownerField==="id"?i.id===n.userId:r.ownerField?i[r.ownerField]===n.userId:true}exports.a=a;exports.b=s;exports.c=p;exports.d=u;
|
package/dist/chunk-FVZ5RFLO.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a as a$1,h as h$1}from'./chunk-HLSB2MCK.js';import {a}from'./chunk-4RMFCTWH.js';import {a as a$2}from'./chunk-KDNYHLD2.js';import {createHmac,randomBytes,randomUUID}from'crypto';var x={COLLECTION_CREATE:"collection.create",COLLECTION_UPDATE:"collection.update",COLLECTION_DELETE:"collection.delete",MEDIA_UPLOAD:"media.upload",MEDIA_DELETE:"media.delete",AUTH_LOGIN:"auth.login",AUTH_REGISTER:"auth.register",AUTH_LOGOUT:"auth.logout",ORDER_CREATED:"order.created",ORDER_PAID:"order.paid",ORDER_SHIPPED:"order.shipped",ORDER_DELIVERED:"order.delivered"},K=Object.values(x);var h="_webhooks",k="_webhook_deliveries";async function I(r,o,n,e={}){let t=e.timeout||3e4,a=Date.now(),l=new AbortController,i=setTimeout(()=>l.abort(),t);try{let s=await fetch(r,{method:"POST",headers:o,body:n,signal:l.signal});clearTimeout(i);let c=Date.now()-a,u;try{u=(await s.text()).slice(0,1e3);}catch{}let d={success:s.ok,status:s.status,statusText:s.statusText,body:u,duration:c};return d.success&&e.onSuccess?e.onSuccess(d):!d.success&&e.onFailure&&e.onFailure(`HTTP ${s.status}: ${s.statusText}`),d}catch(s){clearTimeout(i);let c=Date.now()-a,u=s.name==="AbortError"?`Request timed out after ${t}ms`:s.message||"Unknown error";return e.onFailure&&e.onFailure(u),{success:false,status:0,duration:c,error:u}}}async function H(r,o,n={}){let e=JSON.stringify(o),t={"Content-Type":"application/json","User-Agent":"Kyro-CMS-Webhook/1.0","X-Webhook-Event":o.event,"X-Webhook-Delivery":o.id,"X-Webhook-Timestamp":o.timestamp,...r.headers||{}};return r.secret&&(t["X-Webhook-Signature"]=O(e,r.secret)),I(r.url,t,e,n)}async function B(r,o,n={}){let e=r.config||{},t=process.env.GITHUB_TOKEN;if(!t)return {success:false,status:0,duration:0,error:"GITHUB_TOKEN environment variable is not set"};if(!e.githubOwner||!e.githubRepo)return {success:false,status:0,duration:0,error:"GitHub owner and repo are required"};let a=e.githubBranch||"main",l=Date.now(),i=async(s,c,u)=>{let d=await fetch(s,{method:c,headers:{"Content-Type":"application/json",Accept:"application/vnd.github+json",Authorization:`Bearer ${t}`,"X-GitHub-Api-Version":"2022-11-28","User-Agent":"Kyro-CMS-Webhook/1.0"},body:u?JSON.stringify(u):void 0});if(!d.ok){let y=await d.text();throw new Error(`GitHub API HTTP ${d.status}: ${y}`)}return d.json()};try{let s=`https://api.github.com/repos/${e.githubOwner}/${e.githubRepo}/git/refs/heads/${a}`,u=(await i(s,"GET")).object.sha,d=`https://api.github.com/repos/${e.githubOwner}/${e.githubRepo}/git/commits/${u}`,g=(await i(d,"GET")).tree.sha,f=`https://api.github.com/repos/${e.githubOwner}/${e.githubRepo}/git/commits`,p=(await i(f,"POST",{message:`Content updated via Kyro CMS (${o.event})`,tree:g,parents:[u]})).sha;return await i(s,"PATCH",{sha:p,force:!1}),{success:!0,status:201,duration:Date.now()-l,body:`Successfully pushed empty commit ${p} to branch ${a}`}}catch(s){return {success:false,status:0,duration:Date.now()-l,error:s.message||"Failed to push empty commit to GitHub"}}}var _={generic:H,"github-push":B};function R(r){return _[r||"generic"]||_.generic}function O(r,o){return `sha256=${createHmac("sha256",o).update(r).digest("hex")}`}function E(){return randomBytes(32).toString("hex")}async function L(r,o,n={}){return R(r.action)(r,o,n)}async function C(r,o,n,e={}){let t=e.maxRetries??5,a=e.retryDelay??1e3,l=null;for(let i=0;i<=t;i++){if(i>0){let s=Math.min(a*Math.pow(2,i-1),3e4);e.onRetry&&e.onRetry(i,`Retrying in ${s}ms...`),await M(s);}if(e.onRetry&&i>0&&e.onRetry(i,`Attempt ${i+1}/${t+1}`),l=await L(r,o,{...e,onRetry:void 0,onSuccess:void 0,onFailure:void 0}),l.success)return l;if(!(l.error?.includes("timed out")&&i<t)&&l.status>=400&&l.status<500)return l}return l||{success:false,status:0,duration:0,error:"All delivery attempts failed"}}function P(r,o,n,e,t,a){return {id:r,webhookId:o,event:n,payload:e,attempt:t,status:a.success?"success":"failed",responseStatus:a.status||void 0,responseBody:a.body,duration:a.duration,error:a.error,createdAt:new Date().toISOString(),deliveredAt:a.success?new Date().toISOString():void 0}}function M(r){return new Promise(o=>setTimeout(o,r))}function G(){return {id:`test_${Date.now()}`,event:"collection.create",timestamp:new Date().toISOString(),collection:"test",operation:"create",data:{message:"This is a test webhook delivery"},user:{id:"system",email:"system@kyro.dev",role:"super_admin"}}}function $(r){let o=new Set,n=[];for(let e of r){let t=e==="create"||e==="update"||e==="delete"?`collection.${e}`:e;o.has(t)||(o.add(t),n.push(t));}return n}var D=class{db;constructor(o){this.db=o;}async getWebhooks(o){let e=(await this.db.find({collection:h,where:o?.status?{status:{equals:o.status}}:{},limit:100,page:1,draft:true})).docs;return o?.event?e.filter(t=>t.events.includes(o.event)):e}async getWebhookById(o){return this.db.findByID({collection:h,id:o,draft:true})}async createWebhook(o){let n=new Date().toISOString(),e=o.secret||E(),t={id:randomUUID(),name:o.name,url:o.url,events:$(o.events),collections:o.collections||[],status:o.status||"active",secret:e,headers:o.headers||{},action:o.action||"generic",config:o.config||{},createdAt:n,updatedAt:n};return await this.db.create({collection:h,data:t}),t}async updateWebhook(o,n){let e=await this.getWebhookById(o);if(!e)return null;let t={...e,...n,events:n.events?$(n.events):e.events,collections:n.collections!==void 0?n.collections:e.collections,action:n.action!==void 0?n.action:e.action,config:n.config!==void 0?{...e.config,...n.config}:e.config,updatedAt:new Date().toISOString()};return n.secret===""&&"secret"in n&&delete t.secret,await this.db.update({collection:h,id:o,data:t}),t}async deleteWebhook(o){await this.db.delete({collection:h,id:o});}async trigger(o,n){let e=await this.getWebhooks({status:"active",event:o}),t=n.collection,a=e.filter(s=>!s.collections||s.collections.length===0||!t?true:s.collections.includes(t));if(a.length===0)return [];let l={id:randomUUID(),event:o,timestamp:new Date().toISOString(),...n},i=[];for(let s of a){let c=await this.triggerWebhook(s,l);i.push(c);}return i}async triggerWebhook(o,n){let e=randomUUID();try{let t=await C(o,n,e,{maxRetries:5,retryDelay:1e3}),a=P(e,o.id,o.events[0],n,1,t);try{await this.db.create({collection:k,data:a});}catch{console.warn("[WebhookService] Failed to save delivery record:",e);}return t.success?await this.updateWebhook(o.id,{lastTriggered:new Date().toISOString(),lastError:null}).catch(()=>{}):await this.updateWebhook(o.id,{lastError:t.error||`HTTP ${t.status}`}).catch(()=>{}),{deliveryId:e,webhookId:o.id,event:o.events[0],status:t.success?"success":"failed",responseStatus:t.status,duration:t.duration,error:t.error}}catch(t){return {deliveryId:e,webhookId:o.id,event:o.events[0],status:"failed",error:t.message}}}async testWebhook(o){let n=await this.getWebhookById(o);if(!n)return null;let e={id:randomUUID(),event:n.events[0]||"collection.create",timestamp:new Date().toISOString(),collection:"test",operation:"create",data:{message:"This is a test webhook delivery from Kyro CMS"},user:{id:"system",email:"system@kyro.dev",role:"super_admin"}};return this.triggerWebhook(n,e)}async getDeliveryHistory(o,n=50){return (await this.db.find({collection:k,where:{webhookId:{equals:o}},sort:"-createdAt",limit:n,page:1})).docs}async retryDelivery(o){let n=await this.db.findByID({collection:k,id:o});if(!n)return null;let e=await this.getWebhookById(n.webhookId);return e?this.triggerWebhook(e,n.payload):null}};function q(r){return new D(r)}function V(r){if(!r)return [];if(typeof r=="string")return [{id:r}];if(Array.isArray(r))return r.map(o=>typeof o=="object"?{id:o.value??o.id??o,relationTo:o.relationTo}:{id:o});if(typeof r=="object"){let o=r.value??r.id??r;if(typeof o=="string")return [{id:o,relationTo:r.relationTo}];if(Array.isArray(o))return o.map(n=>({id:n,relationTo:r.relationTo}))}return []}function W(r,o,n){if(!(!r||typeof r!="object")){for(let e of o)if(!(!e.name&&e.type!=="row"&&e.type!=="collapsible"&&e.type!=="tabs")){if(e.type==="relationship"||e.type==="upload"){let t=r[e.name];if(!t)continue;let a=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],l=V(t);for(let i of l){if(!i.id)continue;let s=i.relationTo?[i.relationTo]:a;for(let c of s)c!=="*"&&(n.has(c)||n.set(c,new Set),n.get(c).add(i.id));}}else if(e.type==="group"||e.type==="collapsible"||e.type==="row"){let t=e.name?r[e.name]:r;W(t,e.fields||[],n);}else if(e.type==="tabs"&&e.tabs){let t=e.name?r[e.name]:r;for(let a of e.tabs)W(t,a.fields||[],n);}else if(e.type==="array"&&e.name&&Array.isArray(r[e.name]))for(let t of r[e.name])W(t,e.fields||[],n);else if(e.type==="blocks"&&e.name&&Array.isArray(r[e.name]))for(let t of r[e.name]){if(!t||typeof t!="object")continue;let a=t.type||t.blockType;if(!a)continue;let l=e.blocks?.find(i=>i.slug===a);if(l&&Array.isArray(l.fields)){let i=t.data&&typeof t.data=="object"?t.data:t;W(i,l.fields,n);}}}}}function v(r,o,n){if(!(!r||typeof r!="object")){for(let e of o)if(!(!e.name&&e.type!=="row"&&e.type!=="collapsible"&&e.type!=="tabs")){if(e.type==="relationship"||e.type==="upload"){let t=r[e.name];if(!t)continue;let a=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],l=s=>{r[e.name]=s;},i=(s,c)=>{let u=c?[c]:a;for(let d of u){let y=n.get(d);if(y&&y.has(s))return y.get(s)}return null};if(typeof t=="string"){let s=i(t);l(s||{id:t});}else if(Array.isArray(t))l(t.map(s=>{let c=typeof s=="object"?s.value??s.id:s,u=typeof s=="object"?s.relationTo:void 0,d=i(c,u);return d||{id:c}}));else if(typeof t=="object"){let s=t.value??t.id,c=t.relationTo,u=i(s,c);l(u||{id:s});}}else if(e.type==="group"||e.type==="collapsible"||e.type==="row"){let t=e.name?r[e.name]:r;v(t,e.fields||[],n);}else if(e.type==="tabs"&&e.tabs){let t=e.name?r[e.name]:r;for(let a of e.tabs)v(t,a.fields||[],n);}else if(e.type==="array"&&e.name&&Array.isArray(r[e.name]))for(let t of r[e.name])v(t,e.fields||[],n);else if(e.type==="blocks"&&e.name&&Array.isArray(r[e.name]))for(let t of r[e.name]){if(!t||typeof t!="object")continue;let a=t.type||t.blockType;if(!a)continue;let l=e.blocks?.find(i=>i.slug===a);if(l&&Array.isArray(l.fields)){let i=t.data&&typeof t.data=="object"?t.data:t;v(i,l.fields,n);}}}}}async function F(r,o,n,e,t=1,a$1=0){if(!r||r.length===0||t>a$1)return;let l=new Map;for(let c of r)W(c,o,l);if(l.size===0)return;let i=new Map,s=new Map;for(let[c,u]of l.entries()){if(u.size===0||!e.getCollection(c))continue;let y=new Map,g=Array.from(u),f=[];for(let m of g)try{let p=await n.findByID({collection:c,id:m,draft:!0});p&&(y.set(m,p),f.push(p));}catch{}i.set(c,y),f.length>0&&s.set(c,f);}if(t<a$1)for(let[c,u]of s.entries()){let d=e.getCollection(c);d&&await F(u,d.fields,n,e,t+1,a$1);}for(let c=0;c<r.length;c++)v(r[c],o,i),r[c]=a(r[c]);}function j(r){return r==="read"?"read":r==="create"?"create":r==="update"?"update":"delete"}function z(r,o){return {none:false,read:r==="read",create:r==="read"||r==="create",update:r==="read"||r==="create"||r==="update",delete:r==="read"||r==="create"||r==="update"||r==="delete",admin:true}[o]||false}async function Ae(r,o,n,e={}){let{user:t,req:a,tenantId:l,apiKey:i}=n,{enablePublicAccess:s=true,defaultAccess:c="none"}=e,u=r.access?.[o];if(u){let y=await a$1(u,{req:a,user:t,tenantId:l});return y===false?{allowed:false,error:"Access denied",status:403}:typeof y=="object"?{allowed:true,extraWhere:y}:{allowed:true}}if(i?.permissions?.length>0){let y=r.slug,g=j(o),f=`${y}:${g}`;return !h$1(i.permissions,f)&&!h$1(i.permissions,`${y}:admin`)?{allowed:false,error:"Access denied: insufficient permissions",status:403}:{allowed:true}}if(t){let y=r.slug,g=j(o),f=`${y}:${g}`,m=a$2({id:t.id,email:t.email,role:t.role},f),p=a$2({id:t.id,email:t.email,role:t.role},`${y}:admin`);return m||p?{allowed:true}:{allowed:false,error:"Access denied: missing RBAC permission",status:403}}let d=z(o,c);return s&&d?{allowed:true}:{allowed:false,error:"Authentication required",status:401}}async function De(r,o,n,e={}){let{user:t,req:a,tenantId:l}=n,{enablePublicAccess:i=true}=e,s=r.access?.[o];if(s)return await a$1(s,{req:a,user:t,tenantId:l})===false?{allowed:false,error:"Access denied",status:403}:{allowed:true};if(t){let c=`globals:${o}`,u=a$2({id:t.id,email:t.email,role:t.role},c),d=a$2({id:t.id,email:t.email,role:t.role},"globals:admin");return u||d?{allowed:true}:{allowed:false,error:"Access denied: missing RBAC permission",status:403}}return i?{allowed:true}:{allowed:false,error:"Authentication required",status:401}}
|
|
2
|
-
export{F as a,Ae as b,De as c,x as d,K as e,h as f,k as g,O as h,E as i,L as j,C as k,P as l,G as m,D as n,q as o};
|