@velastack/patterns 0.3.1 → 0.3.3
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/README.md +42 -3
- package/dist/chunks/_layout-B7ujvjnA.js +55 -0
- package/dist/chunks/_layout-B7ujvjnA.js.map +1 -0
- package/dist/chunks/{collections-CgdvZXmh.js → collections-CrOvS2E7.js} +3 -3
- package/dist/chunks/{collections-CgdvZXmh.js.map → collections-CrOvS2E7.js.map} +1 -1
- package/dist/chunks/{compose-handle-Cg9jnCsS.js → compose-handle-B-CkDcQD.js} +23 -23
- package/dist/chunks/{compose-handle-Cg9jnCsS.js.map → compose-handle-B-CkDcQD.js.map} +1 -1
- package/dist/chunks/config-target-Bln26FJe.js +164 -0
- package/dist/chunks/config-target-Bln26FJe.js.map +1 -0
- package/dist/chunks/{constants-DSFKQwtP.js → constants-BYkd9jeJ.js} +2 -2
- package/dist/chunks/constants-BYkd9jeJ.js.map +1 -0
- package/dist/chunks/errors-DR3gF_7a.js +18 -0
- package/dist/chunks/errors-DR3gF_7a.js.map +1 -0
- package/dist/chunks/{format-result-Cb2hWsb8.js → format-result-DZ8De8KY.js} +19 -11
- package/dist/chunks/format-result-DZ8De8KY.js.map +1 -0
- package/dist/chunks/{generate-DRA63W0r.js → generate-6snrlnpA.js} +2 -2
- package/dist/chunks/{generate-DRA63W0r.js.map → generate-6snrlnpA.js.map} +1 -1
- package/dist/chunks/{generate-iQP31-m1.js → generate-Ca_6FlPi.js} +5 -5
- package/dist/chunks/{generate-iQP31-m1.js.map → generate-Ca_6FlPi.js.map} +1 -1
- package/dist/chunks/{generate-tOkjJFUf.js → generate-CyuY2Ci7.js} +4 -3
- package/dist/chunks/generate-CyuY2Ci7.js.map +1 -0
- package/dist/chunks/{generate-BkQ1xMDp.js → generate-DQeWOEPY.js} +4 -4
- package/dist/chunks/{generate-BkQ1xMDp.js.map → generate-DQeWOEPY.js.map} +1 -1
- package/dist/chunks/{generate-_LvrYK6i.js → generate-DwADTUob.js} +4 -4
- package/dist/chunks/{generate-_LvrYK6i.js.map → generate-DwADTUob.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BbIN0tUZ.js → generate.runtime-4FDxnvCl.js} +67 -66
- package/dist/chunks/generate.runtime-4FDxnvCl.js.map +1 -0
- package/dist/chunks/{generate.runtime-B0hhtyAL.js → generate.runtime-AYQVW1S-.js} +27 -26
- package/dist/chunks/generate.runtime-AYQVW1S-.js.map +1 -0
- package/dist/chunks/{generate.runtime-wA1G3tQ4.js → generate.runtime-B2aFFaac.js} +38 -37
- package/dist/chunks/generate.runtime-B2aFFaac.js.map +1 -0
- package/dist/chunks/{generate.runtime-DhkaXTq3.js → generate.runtime-B45MvtYm.js} +61 -59
- package/dist/chunks/generate.runtime-B45MvtYm.js.map +1 -0
- package/dist/chunks/{generate.runtime-S5RIgbQx.js → generate.runtime-BFOXm2DD.js} +98 -92
- package/dist/chunks/generate.runtime-BFOXm2DD.js.map +1 -0
- package/dist/chunks/{generate.runtime-BnWE4qsu.js → generate.runtime-BHkFmI2Y.js} +55 -54
- package/dist/chunks/generate.runtime-BHkFmI2Y.js.map +1 -0
- package/dist/chunks/{generate.runtime-DNaQxed-.js → generate.runtime-BKiJvE8I.js} +84 -83
- package/dist/chunks/generate.runtime-BKiJvE8I.js.map +1 -0
- package/dist/chunks/{generate.runtime-DoZdSh9W.js → generate.runtime-BSRFv4cJ.js} +58 -57
- package/dist/chunks/generate.runtime-BSRFv4cJ.js.map +1 -0
- package/dist/chunks/{generate.runtime-B49wetSx.js → generate.runtime-BUqsF3AF.js} +43 -42
- package/dist/chunks/generate.runtime-BUqsF3AF.js.map +1 -0
- package/dist/chunks/{generate.runtime-acRmiU7e.js → generate.runtime-BsaSyTnU.js} +9 -8
- package/dist/chunks/{generate.runtime-acRmiU7e.js.map → generate.runtime-BsaSyTnU.js.map} +1 -1
- package/dist/chunks/generate.runtime-CMnvmeVt.js +111 -0
- package/dist/chunks/generate.runtime-CMnvmeVt.js.map +1 -0
- package/dist/chunks/{generate.runtime-BORbegw_.js → generate.runtime-CN5c2xH8.js} +123 -122
- package/dist/chunks/generate.runtime-CN5c2xH8.js.map +1 -0
- package/dist/chunks/{generate.runtime-flFRYzpi.js → generate.runtime-CgoSrP55.js} +62 -61
- package/dist/chunks/generate.runtime-CgoSrP55.js.map +1 -0
- package/dist/chunks/{generate.runtime-D0icLb5j.js → generate.runtime-D1DNAY6k.js} +12 -11
- package/dist/chunks/{generate.runtime-D0icLb5j.js.map → generate.runtime-D1DNAY6k.js.map} +1 -1
- package/dist/chunks/generate.runtime-DG-3G00z.js +87 -0
- package/dist/chunks/generate.runtime-DG-3G00z.js.map +1 -0
- package/dist/chunks/{generate.runtime-BKo-Nidn.js → generate.runtime-DQwSY6Nc.js} +6 -6
- package/dist/chunks/{generate.runtime-BKo-Nidn.js.map → generate.runtime-DQwSY6Nc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DSqkXvps.js → generate.runtime-D_yqWLcI.js} +15 -14
- package/dist/chunks/{generate.runtime-DSqkXvps.js.map → generate.runtime-D_yqWLcI.js.map} +1 -1
- package/dist/chunks/generate.runtime-Drmahmdl.js +313 -0
- package/dist/chunks/generate.runtime-Drmahmdl.js.map +1 -0
- package/dist/chunks/{generate.runtime-D8vgh5MH.js → generate.runtime-FdZw277n.js} +156 -76
- package/dist/chunks/generate.runtime-FdZw277n.js.map +1 -0
- package/dist/chunks/generate.runtime-Lh1cW9Tz.js +94 -0
- package/dist/chunks/generate.runtime-Lh1cW9Tz.js.map +1 -0
- package/dist/chunks/{generate.runtime-DAmYsIvF.js → generate.runtime-QGHToXRY.js} +5 -5
- package/dist/chunks/{generate.runtime-DAmYsIvF.js.map → generate.runtime-QGHToXRY.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CRYjWJRe.js → generate.runtime-Um77JfwC.js} +89 -88
- package/dist/chunks/generate.runtime-Um77JfwC.js.map +1 -0
- package/dist/chunks/{generate.runtime-BwhGDnGu.js → generate.runtime-VgVwRiiN.js} +151 -150
- package/dist/chunks/generate.runtime-VgVwRiiN.js.map +1 -0
- package/dist/chunks/{generate.runtime-CcuAXuV2.js → generate.runtime-YyIVd4oy.js} +15 -14
- package/dist/chunks/{generate.runtime-CcuAXuV2.js.map → generate.runtime-YyIVd4oy.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DOuufRLr.js → generate.runtime-cQGLxuZM.js} +82 -81
- package/dist/chunks/generate.runtime-cQGLxuZM.js.map +1 -0
- package/dist/chunks/generate.runtime-n9AFWtPp.js +94 -0
- package/dist/chunks/generate.runtime-n9AFWtPp.js.map +1 -0
- package/dist/chunks/generate.runtime-ofdnLtxS.js +57 -0
- package/dist/chunks/generate.runtime-ofdnLtxS.js.map +1 -0
- package/dist/chunks/generate.runtime-onBnOiS7.js +328 -0
- package/dist/chunks/generate.runtime-onBnOiS7.js.map +1 -0
- package/dist/chunks/modify-file-Dwfv0dCI.js +46 -0
- package/dist/chunks/modify-file-Dwfv0dCI.js.map +1 -0
- package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js → modify-svelte-config-remote-BUU_EaDf.js} +2 -2
- package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js.map → modify-svelte-config-remote-BUU_EaDf.js.map} +1 -1
- package/dist/chunks/{pocketbase-CeG5BMN2.js → pocketbase-BkhUywtb.js} +2 -2
- package/dist/chunks/{pocketbase-CeG5BMN2.js.map → pocketbase-BkhUywtb.js.map} +1 -1
- package/dist/chunks/{providers-DO9kMyzB.js → providers-BL9vJP_9.js} +2 -2
- package/dist/chunks/{providers-DO9kMyzB.js.map → providers-BL9vJP_9.js.map} +1 -1
- package/dist/chunks/{shared-BwHQM-a9.js → shared-C8GtNxpm.js} +2 -2
- package/dist/chunks/{shared-BwHQM-a9.js.map → shared-C8GtNxpm.js.map} +1 -1
- package/dist/chunks/{site-D027dpBm.js → site-BdMX8qrH.js} +2 -2
- package/dist/chunks/{site-D027dpBm.js.map → site-BdMX8qrH.js.map} +1 -1
- package/dist/chunks/table-core-G9Shld4F.js +126 -0
- package/dist/chunks/table-core-G9Shld4F.js.map +1 -0
- package/dist/chunks/{test-setup-B2hd8I-s.js → test-setup-DHEFKEHE.js} +23 -10
- package/dist/chunks/test-setup-DHEFKEHE.js.map +1 -0
- package/dist/chunks/ts-morph-helpers-CeduA--o.js +253 -0
- package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +1 -0
- package/dist/chunks/{ui-jhXrsw4T.js → ui-DD4NltyN.js} +2 -2
- package/dist/chunks/{ui-jhXrsw4T.js.map → ui-DD4NltyN.js.map} +1 -1
- package/dist/chunks/{ui-B4Tuit-7.js → ui-TlEuI2Sz.js} +50 -49
- package/dist/chunks/{ui-B4Tuit-7.js.map → ui-TlEuI2Sz.js.map} +1 -1
- package/dist/chunks/unmodify-load-jfdcVZ_a.js +81 -0
- package/dist/chunks/unmodify-load-jfdcVZ_a.js.map +1 -0
- package/dist/chunks/write-result-Djy0SZXX.js +376 -0
- package/dist/chunks/write-result-Djy0SZXX.js.map +1 -0
- package/dist/index.d.ts +33 -1
- package/dist/index.js +2240 -2020
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/_layout-DqH4lA_r.js +0 -47
- package/dist/chunks/_layout-DqH4lA_r.js.map +0 -1
- package/dist/chunks/config-target-Co-ij8p3.js +0 -163
- package/dist/chunks/config-target-Co-ij8p3.js.map +0 -1
- package/dist/chunks/constants-DSFKQwtP.js.map +0 -1
- package/dist/chunks/errors-D6gyegUK.js +0 -14
- package/dist/chunks/errors-D6gyegUK.js.map +0 -1
- package/dist/chunks/format-result-Cb2hWsb8.js.map +0 -1
- package/dist/chunks/generate-tOkjJFUf.js.map +0 -1
- package/dist/chunks/generate.runtime-B0hhtyAL.js.map +0 -1
- package/dist/chunks/generate.runtime-B49wetSx.js.map +0 -1
- package/dist/chunks/generate.runtime-B7LRx-BU.js +0 -86
- package/dist/chunks/generate.runtime-B7LRx-BU.js.map +0 -1
- package/dist/chunks/generate.runtime-BORbegw_.js.map +0 -1
- package/dist/chunks/generate.runtime-BbIN0tUZ.js.map +0 -1
- package/dist/chunks/generate.runtime-BnWE4qsu.js.map +0 -1
- package/dist/chunks/generate.runtime-BwhGDnGu.js.map +0 -1
- package/dist/chunks/generate.runtime-CCg2Pjcv.js +0 -257
- package/dist/chunks/generate.runtime-CCg2Pjcv.js.map +0 -1
- package/dist/chunks/generate.runtime-CRYjWJRe.js.map +0 -1
- package/dist/chunks/generate.runtime-D2e_KRj0.js +0 -56
- package/dist/chunks/generate.runtime-D2e_KRj0.js.map +0 -1
- package/dist/chunks/generate.runtime-D44gjxRA.js +0 -332
- package/dist/chunks/generate.runtime-D44gjxRA.js.map +0 -1
- package/dist/chunks/generate.runtime-D8vgh5MH.js.map +0 -1
- package/dist/chunks/generate.runtime-DNaQxed-.js.map +0 -1
- package/dist/chunks/generate.runtime-DOuufRLr.js.map +0 -1
- package/dist/chunks/generate.runtime-DhkaXTq3.js.map +0 -1
- package/dist/chunks/generate.runtime-DoZdSh9W.js.map +0 -1
- package/dist/chunks/generate.runtime-S5RIgbQx.js.map +0 -1
- package/dist/chunks/generate.runtime-WmSMWL15.js +0 -82
- package/dist/chunks/generate.runtime-WmSMWL15.js.map +0 -1
- package/dist/chunks/generate.runtime-flFRYzpi.js.map +0 -1
- package/dist/chunks/generate.runtime-gtpOuLNO.js +0 -110
- package/dist/chunks/generate.runtime-gtpOuLNO.js.map +0 -1
- package/dist/chunks/generate.runtime-kLxeDGnS.js +0 -93
- package/dist/chunks/generate.runtime-kLxeDGnS.js.map +0 -1
- package/dist/chunks/generate.runtime-wA1G3tQ4.js.map +0 -1
- package/dist/chunks/modify-file-GQD6uNgI.js +0 -254
- package/dist/chunks/modify-file-GQD6uNgI.js.map +0 -1
- package/dist/chunks/test-setup-B2hd8I-s.js.map +0 -1
- package/dist/chunks/unmodify-load-W1ePZQHr.js +0 -80
- package/dist/chunks/unmodify-load-W1ePZQHr.js.map +0 -1
- package/dist/chunks/write-result-DewHCNhM.js +0 -451
- package/dist/chunks/write-result-DewHCNhM.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { o as e } from "./generate-
|
|
1
|
+
import { o as e } from "./generate-Ca_6FlPi.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { n } from "./shared-
|
|
4
|
-
import { n as r, t as i } from "./generate-
|
|
3
|
+
import { n } from "./shared-C8GtNxpm.js";
|
|
4
|
+
import { n as r, t as i } from "./generate-DwADTUob.js";
|
|
5
5
|
import { n as a } from "./env-BPfk1VAw.js";
|
|
6
|
-
import { envRevertOutcomeToFile as o } from "./modify-file-
|
|
6
|
+
import { envRevertOutcomeToFile as o } from "./modify-file-Dwfv0dCI.js";
|
|
7
7
|
import s from "node:fs";
|
|
8
8
|
import c from "node:path";
|
|
9
9
|
//#region src/patterns/disable/ai/generate.runtime.ts
|
|
@@ -29,4 +29,4 @@ async function l(l) {
|
|
|
29
29
|
//#endregion
|
|
30
30
|
export { l as generate };
|
|
31
31
|
|
|
32
|
-
//# sourceMappingURL=generate.runtime-
|
|
32
|
+
//# sourceMappingURL=generate.runtime-QGHToXRY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-QGHToXRY.js","names":[],"sources":["../../src/patterns/disable/ai/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyEnvRemove } from \"../../../runtime/env\";\nimport { envRevertOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { demoDir } from \"../../enable/ai/generate\";\nimport { allEnvEdits, demoDirs } from \"./generate\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n // The base result names the page in the current default group; a page\n // generated before auth was enabled sits in the other one.\n const current = demoDir(options);\n for (const dir of demoDirs(options)) {\n const page = `${dir}/+page.svelte`;\n if (dir !== current && fs.existsSync(path.join(options.root, page))) {\n deletes.push(toDeleteEntry(page));\n }\n }\n\n logger.info(\"Removing the AI provider's API key from .env\");\n const envPath = path.join(options.root, \".env\");\n const env = envRevertOutcomeToFile(\n envPath,\n modifyEnvRemove(envPath, allEnvEdits()),\n );\n if (env.modify) modifies.push(env.modify);\n if (env.delete) deletes.push(env.delete);\n\n return {\n creates: [],\n modifies,\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAUA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC,GACpB,IAAkB,CAAC,GAInB,IAAU,EAAQ,CAAO;CAC/B,KAAK,IAAM,KAAO,EAAS,CAAO,GAAG;EACnC,IAAM,IAAO,GAAG,EAAI;EACpB,AAAI,MAAQ,KAAW,EAAG,WAAW,EAAK,KAAK,EAAQ,MAAM,CAAI,CAAC,KAChE,EAAQ,KAAK,EAAc,CAAI,CAAC;CAEpC;CAEA,EAAO,KAAK,8CAA8C;CAC1D,IAAM,IAAU,EAAK,KAAK,EAAQ,MAAM,MAAM,GACxC,IAAM,EACV,GACA,EAAgB,GAAS,EAAY,CAAC,CACxC;CAIA,OAHI,EAAI,UAAQ,EAAS,KAAK,EAAI,MAAM,GACpC,EAAI,UAAQ,EAAQ,KAAK,EAAI,MAAM,GAEhC;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -2,42 +2,43 @@ import { a as e } from "./util-BLYliuUK.js";
|
|
|
2
2
|
import { t } from "./dedent-Gq6Krl4n.js";
|
|
3
3
|
import { n } from "./logger-CQONztPm.js";
|
|
4
4
|
import { t as r } from "./pocketbase-DpudAAmd.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { t as d } from "./
|
|
9
|
-
import {
|
|
10
|
-
import m from "
|
|
11
|
-
import h from "node:
|
|
12
|
-
import
|
|
5
|
+
import { _ as i, o as a, r as o } from "./ts-morph-helpers-CeduA--o.js";
|
|
6
|
+
import { modifyOutcomeToFile as s } from "./modify-file-Dwfv0dCI.js";
|
|
7
|
+
import { t as c } from "./svelte-file-B3RfgVdt.js";
|
|
8
|
+
import { i as l, n as u, t as d } from "./pocketbase-BkhUywtb.js";
|
|
9
|
+
import { t as f } from "./modify-utils-Cw-on_cL.js";
|
|
10
|
+
import { applyCollectionRulePatches as p, createCollectionIdempotent as m } from "./collections-CrOvS2E7.js";
|
|
11
|
+
import h from "node:fs";
|
|
12
|
+
import g from "node:path";
|
|
13
|
+
import { Project as _, SyntaxKind as v } from "ts-morph";
|
|
13
14
|
//#region src/patterns/enable/notifications/modifies/modify-app-layout.ts
|
|
14
|
-
var
|
|
15
|
+
var y = "\n <div class=\"ml-auto px-4\">\n <NotificationsBell />\n </div>\n ", b = t`
|
|
15
16
|
import NotificationsBell from '$lib/components/notifications-bell.svelte';
|
|
16
|
-
`,
|
|
17
|
+
`, x = [
|
|
17
18
|
"Add the notifications bell inside the (app) layout's <header>.",
|
|
18
19
|
"",
|
|
19
20
|
"Imports to add to the <script> tag:",
|
|
20
21
|
"",
|
|
21
|
-
|
|
22
|
+
b,
|
|
22
23
|
"",
|
|
23
24
|
"Markup to add inside <header>:",
|
|
24
|
-
|
|
25
|
-
].join("\n"),
|
|
25
|
+
y
|
|
26
|
+
].join("\n"), S = [
|
|
26
27
|
"Create src/routes/(app)/+layout.svelte with a <header> that includes the bell.",
|
|
27
28
|
"",
|
|
28
29
|
"Imports for the <script> tag:",
|
|
29
30
|
"",
|
|
30
|
-
|
|
31
|
+
b,
|
|
31
32
|
"",
|
|
32
33
|
"Markup inside <header>:",
|
|
33
|
-
|
|
34
|
+
y
|
|
34
35
|
].join("\n");
|
|
35
|
-
function
|
|
36
|
-
if (!
|
|
36
|
+
function C(e) {
|
|
37
|
+
if (!h.existsSync(e)) return {
|
|
37
38
|
status: "not-found",
|
|
38
|
-
message:
|
|
39
|
+
message: S
|
|
39
40
|
};
|
|
40
|
-
let t =
|
|
41
|
+
let t = c.fromPath(e);
|
|
41
42
|
return t.hasElement("header") ? t.hasElement("NotificationsBell") ? {
|
|
42
43
|
status: "success",
|
|
43
44
|
changed: !1
|
|
@@ -49,84 +50,84 @@ function S(e) {
|
|
|
49
50
|
}]);
|
|
50
51
|
});
|
|
51
52
|
return t;
|
|
52
|
-
}), t.insertBeforeClosingTag("header",
|
|
53
|
+
}), t.insertBeforeClosingTag("header", y), t.writeTo(e), {
|
|
53
54
|
status: "success",
|
|
54
55
|
changed: t.hasChanged()
|
|
55
56
|
}) : {
|
|
56
57
|
status: "failed",
|
|
57
|
-
message:
|
|
58
|
+
message: x
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
//#endregion
|
|
61
62
|
//#region src/patterns/enable/notifications/modifies/+layout.server.ts
|
|
62
|
-
var
|
|
63
|
+
var w = t`
|
|
63
64
|
const notificationsList = await locals.pb
|
|
64
65
|
.collection("notifications")
|
|
65
66
|
.getList(1, 5, {
|
|
66
67
|
filter: \`user = "\${locals.pb.authStore.record!.id}" && read = false\`,
|
|
67
68
|
sort: "-created",
|
|
68
69
|
});
|
|
69
|
-
`,
|
|
70
|
-
function
|
|
71
|
-
if (!
|
|
70
|
+
`, T = "const notifications = { count: notificationsList.totalItems, items: notificationsList.items };", E = "depends(\"app:notifications\");";
|
|
71
|
+
function D(e) {
|
|
72
|
+
if (!h.existsSync(e)) {
|
|
72
73
|
let n = t`
|
|
73
74
|
export const load = async ({ locals, depends }) => {
|
|
74
|
-
${C}
|
|
75
75
|
${w}
|
|
76
76
|
${T}
|
|
77
|
+
${E}
|
|
77
78
|
return { notifications };
|
|
78
79
|
};
|
|
79
80
|
`;
|
|
80
|
-
return
|
|
81
|
+
return h.writeFileSync(e, n), {
|
|
81
82
|
status: "success",
|
|
82
83
|
changed: !0
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
|
-
let n =
|
|
86
|
+
let n = h.readFileSync(e, "utf8"), r = new _().addSourceFileAtPath(e), i = (e, t, n) => {
|
|
86
87
|
e.getProperty(t) || (t === n ? e.addShorthandPropertyAssignment({ name: t }) : e.addPropertyAssignment({
|
|
87
88
|
name: t,
|
|
88
89
|
initializer: n
|
|
89
90
|
}));
|
|
90
|
-
},
|
|
91
|
-
if (
|
|
92
|
-
let e =
|
|
93
|
-
if (e)
|
|
91
|
+
}, o, s, c = r.getVariableDeclaration("load");
|
|
92
|
+
if (c && c.getFirstAncestorByKind(v.VariableStatement)?.hasExportKeyword()) {
|
|
93
|
+
let e = c.getInitializerIfKind(v.ArrowFunction);
|
|
94
|
+
if (e) o = e;
|
|
94
95
|
else {
|
|
95
|
-
let e =
|
|
96
|
+
let e = c.getInitializer();
|
|
96
97
|
if (e) {
|
|
97
|
-
let t = e.getFirstDescendantByKind(
|
|
98
|
-
if (t)
|
|
98
|
+
let t = e.getFirstDescendantByKind(v.ArrowFunction);
|
|
99
|
+
if (t) o = t;
|
|
99
100
|
else {
|
|
100
|
-
let t = e.getFirstDescendantByKind(
|
|
101
|
-
t && (
|
|
101
|
+
let t = e.getFirstDescendantByKind(v.FunctionExpression);
|
|
102
|
+
t && (s = t);
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
|
-
if (!
|
|
107
|
+
if (!o && !s) {
|
|
107
108
|
let e = r.getFunction("load");
|
|
108
|
-
e && e.isExported() && (
|
|
109
|
+
e && e.isExported() && (s = e);
|
|
109
110
|
}
|
|
110
|
-
if (!
|
|
111
|
+
if (!o && !s) return r.addFunction({
|
|
111
112
|
isExported: !0,
|
|
112
113
|
isAsync: !0,
|
|
113
114
|
name: "load",
|
|
114
115
|
parameters: [{ name: "{ locals, depends }" }],
|
|
115
116
|
statements: [
|
|
116
|
-
C,
|
|
117
117
|
w,
|
|
118
118
|
T,
|
|
119
|
+
E,
|
|
119
120
|
"return { notifications };"
|
|
120
121
|
]
|
|
121
|
-
}), r
|
|
122
|
+
}), a(r), r.saveSync(), {
|
|
122
123
|
status: "success",
|
|
123
124
|
changed: !0
|
|
124
125
|
};
|
|
125
|
-
let
|
|
126
|
-
if (
|
|
126
|
+
let l = o ?? s, u = l.getParameters();
|
|
127
|
+
if (u.length === 0) l.insertParameter(0, { name: "{ locals, depends }" });
|
|
127
128
|
else {
|
|
128
|
-
let e =
|
|
129
|
-
if (n.getKind() ===
|
|
129
|
+
let e = u[0], t = e.getStructure(), n = e.getNameNode();
|
|
130
|
+
if (n.getKind() === v.ObjectBindingPattern) {
|
|
130
131
|
let r = n, i = r.getElements().map((e) => e.getName()), a = i.includes("depends"), o = i.includes("locals");
|
|
131
132
|
if (!a || !o) {
|
|
132
133
|
let n = r.getElements().map((e) => e.getText()).filter(Boolean), i = o ? [] : ["locals"];
|
|
@@ -149,66 +150,66 @@ function E(e) {
|
|
|
149
150
|
});
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
|
-
|
|
153
|
-
let
|
|
154
|
-
if (
|
|
155
|
-
let e =
|
|
153
|
+
o && !o.isAsync() ? o.setIsAsync(!0) : s && !s.isAsync() && s.setIsAsync(!0);
|
|
154
|
+
let d = l.getBody();
|
|
155
|
+
if (d && d.getKind() === v.Block) {
|
|
156
|
+
let e = d, t = e.getStatements(), n = (e) => t.some((t) => t.getKind() === v.VariableStatement && t.getDeclarations().some((t) => t.getName() === e)), r = t.some((e) => e.getKind() === v.ExpressionStatement && e.getDescendantsOfKind(v.CallExpression).some((e) => {
|
|
156
157
|
if (e.getExpression().getText() !== "depends") return !1;
|
|
157
158
|
let t = e.getArguments(), n = t[0]?.getText() ?? "";
|
|
158
159
|
return t.length === 1 && (n === "'app:notifications'" || n === "\"app:notifications\"");
|
|
159
|
-
})), i = n("notificationsList"), a = n("notifications"), o = t.findIndex((e) => e.getKind() ===
|
|
160
|
-
i || (e.insertStatements(s,
|
|
160
|
+
})), i = n("notificationsList"), a = n("notifications"), o = t.findIndex((e) => e.getKind() === v.ReturnStatement), s = o >= 0 ? o : t.length;
|
|
161
|
+
i || (e.insertStatements(s, w), s++), a || (e.insertStatements(s, T), s++), r || e.insertStatements(s, E);
|
|
161
162
|
}
|
|
162
|
-
let
|
|
163
|
+
let f = (e) => {
|
|
163
164
|
i(e, "notifications", "notifications");
|
|
164
|
-
},
|
|
165
|
-
e.getDescendantsOfKind(
|
|
165
|
+
}, p = (e) => {
|
|
166
|
+
e.getDescendantsOfKind(v.ReturnStatement).forEach((e) => {
|
|
166
167
|
let t = e.getExpression();
|
|
167
168
|
if (t) {
|
|
168
|
-
if (t.getKind() ===
|
|
169
|
-
else if (t.getKind() ===
|
|
169
|
+
if (t.getKind() === v.ObjectLiteralExpression) f(t);
|
|
170
|
+
else if (t.getKind() === v.ParenthesizedExpression) {
|
|
170
171
|
let e = t.getExpression();
|
|
171
|
-
e.getKind() ===
|
|
172
|
+
e.getKind() === v.ObjectLiteralExpression && f(e);
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
});
|
|
175
176
|
};
|
|
176
|
-
if (
|
|
177
|
-
let e =
|
|
178
|
-
if (e.getKind() ===
|
|
177
|
+
if (o) {
|
|
178
|
+
let e = o.getBody();
|
|
179
|
+
if (e.getKind() === v.Block) p(e);
|
|
179
180
|
else {
|
|
180
181
|
let t = e;
|
|
181
|
-
if (t.getKind() ===
|
|
182
|
+
if (t.getKind() === v.ParenthesizedExpression) {
|
|
182
183
|
let e = t.getExpression();
|
|
183
|
-
e.getKind() ===
|
|
184
|
-
} else t.getKind() ===
|
|
184
|
+
e.getKind() === v.ObjectLiteralExpression && f(e);
|
|
185
|
+
} else t.getKind() === v.ObjectLiteralExpression && f(t);
|
|
185
186
|
}
|
|
186
|
-
} else if (
|
|
187
|
-
let e =
|
|
188
|
-
e &&
|
|
187
|
+
} else if (s) {
|
|
188
|
+
let e = s.getBody();
|
|
189
|
+
e && p(e);
|
|
189
190
|
}
|
|
190
|
-
return r
|
|
191
|
+
return a(r), r.saveSync(), {
|
|
191
192
|
status: "success",
|
|
192
193
|
changed: r.getFullText() !== n
|
|
193
194
|
};
|
|
194
195
|
}
|
|
195
196
|
//#endregion
|
|
196
197
|
//#region src/patterns/enable/notifications/generate.runtime.ts
|
|
197
|
-
async function
|
|
198
|
+
async function O(t, n, r, i = !0) {
|
|
198
199
|
if (!i) return;
|
|
199
|
-
await
|
|
200
|
-
let a =
|
|
200
|
+
await u();
|
|
201
|
+
let a = d(n, "created", r);
|
|
201
202
|
a && t.push({
|
|
202
203
|
path: a,
|
|
203
204
|
language: e(a),
|
|
204
|
-
content:
|
|
205
|
+
content: h.readFileSync(a, "utf8"),
|
|
205
206
|
status: "success"
|
|
206
207
|
});
|
|
207
208
|
}
|
|
208
|
-
async function
|
|
209
|
+
async function k(e) {
|
|
209
210
|
let t = n(e), i = [];
|
|
210
|
-
await
|
|
211
|
-
let a = await n.collections.getOne("users"), o = (e) =>
|
|
211
|
+
await l(e.root, async (n) => {
|
|
212
|
+
let a = await n.collections.getOne("users"), o = (e) => m(n, e, t);
|
|
212
213
|
t.info("Creating notifications collection");
|
|
213
214
|
let s = await o({
|
|
214
215
|
name: "notifications",
|
|
@@ -261,22 +262,22 @@ async function O(e) {
|
|
|
261
262
|
],
|
|
262
263
|
indexes: ["CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)"]
|
|
263
264
|
});
|
|
264
|
-
await
|
|
265
|
-
let c = await
|
|
265
|
+
await O(i, "notifications", e, s.created), t.info("Applying notifications rule patches");
|
|
266
|
+
let c = await p(n, r, e, t);
|
|
266
267
|
i.push(...c);
|
|
267
268
|
});
|
|
268
|
-
let
|
|
269
|
-
e &&
|
|
269
|
+
let a = [], o = (e) => {
|
|
270
|
+
e && a.push(e);
|
|
270
271
|
};
|
|
271
272
|
t.info("Modifying (app) +layout.svelte");
|
|
272
|
-
let
|
|
273
|
-
s(
|
|
274
|
-
let u =
|
|
275
|
-
s(
|
|
276
|
-
let
|
|
277
|
-
return s(
|
|
273
|
+
let c = g.join(e.root, "src", "routes", "(app)", "+layout.svelte");
|
|
274
|
+
o(s(c, C(c))), t.info("Modifying (app) +layout.server.ts");
|
|
275
|
+
let u = g.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
276
|
+
o(s(u, D(u))), t.info("Modifying utils.ts");
|
|
277
|
+
let d = g.join(e.root, "src", "lib", "utils.ts");
|
|
278
|
+
return o(s(d, f(d))), {
|
|
278
279
|
creates: i,
|
|
279
|
-
modifies:
|
|
280
|
+
modifies: a,
|
|
280
281
|
deletes: [],
|
|
281
282
|
components: [],
|
|
282
283
|
packages: [],
|
|
@@ -286,6 +287,6 @@ async function O(e) {
|
|
|
286
287
|
};
|
|
287
288
|
}
|
|
288
289
|
//#endregion
|
|
289
|
-
export {
|
|
290
|
+
export { k as generate };
|
|
290
291
|
|
|
291
|
-
//# sourceMappingURL=generate.runtime-
|
|
292
|
+
//# sourceMappingURL=generate.runtime-Um77JfwC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-Um77JfwC.js","names":[],"sources":["../../src/patterns/enable/notifications/modifies/modify-app-layout.ts","../../src/patterns/enable/notifications/modifies/+layout.server.ts","../../src/patterns/enable/notifications/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BELL_SNIPPET = `\n\t\t<div class=\"ml-auto px-4\">\n\t\t\t<NotificationsBell />\n\t\t</div>\n\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import NotificationsBell from '$lib/components/notifications-bell.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the notifications bell inside the (app) layout's <header>.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add inside <header>:\",\n BELL_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with a <header> that includes the bell.\",\n \"\",\n \"Imports for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup inside <header>:\",\n BELL_SNIPPET,\n].join(\"\\n\");\n\nexport function modifyAppLayout(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"header\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"NotificationsBell\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"NotificationsBell\",\n moduleSpecifier: \"$lib/components/notifications-bell.svelte\",\n },\n ]);\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"header\", BELL_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FETCH_STATEMENT = dedent`\n const notificationsList = await locals.pb\n .collection(\"notifications\")\n .getList(1, 5, {\n filter: \\`user = \"\\${locals.pb.authStore.record!.id}\" && read = false\\`,\n sort: \"-created\",\n });\n`;\n\nconst NOTIFICATIONS_STATEMENT =\n \"const notifications = { count: notificationsList.totalItems, items: notificationsList.items };\";\n\nconst DEPENDS_STATEMENT = 'depends(\"app:notifications\");';\n\nexport function modifyLayoutServer(layoutServerPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n const snippet = dedent`\n export const load = async ({ locals, depends }) => {\n ${FETCH_STATEMENT}\n ${NOTIFICATIONS_STATEMENT}\n ${DEPENDS_STATEMENT}\n return { notifications };\n };\n `;\n fs.writeFileSync(layoutServerPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutServerPath);\n\n const addProperty = (\n obj: import(\"ts-morph\").ObjectLiteralExpression,\n name: string,\n initializer: string,\n ) => {\n if (obj.getProperty(name)) return;\n if (name === initializer) {\n obj.addShorthandPropertyAssignment({ name });\n } else {\n obj.addPropertyAssignment({ name, initializer });\n }\n };\n\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n if (vs?.hasExportKeyword()) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n\n if (!loadArrow && !loadFn) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) loadFn = maybeFn;\n }\n\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals, depends }\" }],\n statements: [\n FETCH_STATEMENT,\n NOTIFICATIONS_STATEMENT,\n DEPENDS_STATEMENT,\n \"return { notifications };\",\n ],\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const fnLike = (loadArrow ?? loadFn!) as\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression;\n\n // Ensure first param destructures { locals, depends }\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals, depends }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const elementNames = obp.getElements().map((el) => el.getName());\n const hasDepends = elementNames.includes(\"depends\");\n const hasLocals = elementNames.includes(\"locals\");\n\n if (!hasDepends || !hasLocals) {\n const existingParts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const parts: string[] = hasLocals ? [] : [\"locals\"];\n parts.push(...existingParts);\n if (!hasDepends) parts.push(\"depends\");\n first.set({\n name: `{ ${parts.join(\", \")} }`,\n type: original.type,\n initializer: (original as { initializer?: string }).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, depends, ...${currentName} }`,\n type: original.type,\n initializer: (original as { initializer?: string }).initializer,\n });\n } else {\n first.set({\n name: `{ locals, depends }`,\n type: original.type,\n initializer: (original as { initializer?: string }).initializer,\n });\n }\n }\n }\n\n if (loadArrow && !loadArrow.isAsync()) loadArrow.setIsAsync(true);\n else if (loadFn && !loadFn.isAsync()) loadFn.setIsAsync(true);\n\n const body = fnLike.getBody();\n if (body && body.getKind() === SyntaxKind.Block) {\n const blockBody = body as import(\"ts-morph\").Block;\n const statements = blockBody.getStatements();\n\n const declaresVar = (name: string) =>\n statements.some((stmt) => {\n if (stmt.getKind() !== SyntaxKind.VariableStatement) return false;\n return (stmt as import(\"ts-morph\").VariableStatement)\n .getDeclarations()\n .some((d) => d.getName() === name);\n });\n\n const hasDependsCall = statements.some(\n (stmt) =>\n stmt.getKind() === SyntaxKind.ExpressionStatement &&\n stmt.getDescendantsOfKind(SyntaxKind.CallExpression).some((ce) => {\n if (ce.getExpression().getText() !== \"depends\") return false;\n const args = ce.getArguments();\n const argText = args[0]?.getText() ?? \"\";\n return (\n args.length === 1 &&\n (argText === \"'app:notifications'\" ||\n argText === '\"app:notifications\"')\n );\n }),\n );\n\n const hasNotificationsList = declaresVar(\"notificationsList\");\n const hasNotifications = declaresVar(\"notifications\");\n\n const returnIdx = statements.findIndex(\n (s) => s.getKind() === SyntaxKind.ReturnStatement,\n );\n let insertAt = returnIdx >= 0 ? returnIdx : statements.length;\n\n if (!hasNotificationsList) {\n blockBody.insertStatements(insertAt, FETCH_STATEMENT);\n insertAt++;\n }\n if (!hasNotifications) {\n blockBody.insertStatements(insertAt, NOTIFICATIONS_STATEMENT);\n insertAt++;\n }\n if (!hasDependsCall) {\n blockBody.insertStatements(insertAt, DEPENDS_STATEMENT);\n }\n }\n\n const augmentReturnObject = (\n obj: import(\"ts-morph\").ObjectLiteralExpression,\n ) => {\n addProperty(obj, \"notifications\", \"notifications\");\n };\n\n const augmentReturns = (target: import(\"ts-morph\").Node) => {\n const returns = target.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(\n inner as import(\"ts-morph\").ObjectLiteralExpression,\n );\n }\n }\n });\n };\n\n if (loadArrow) {\n const arrowBody = loadArrow.getBody();\n if (arrowBody.getKind() === SyntaxKind.Block) {\n augmentReturns(arrowBody);\n } else {\n const bodyExpr = arrowBody as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(\n inner as import(\"ts-morph\").ObjectLiteralExpression,\n );\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(\n bodyExpr as import(\"ts-morph\").ObjectLiteralExpression,\n );\n }\n }\n } else if (loadFn) {\n const fnBody = loadFn.getBody();\n if (fnBody) augmentReturns(fnBody);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n applyCollectionRulePatches,\n createCollectionIdempotent,\n} from \"../../../runtime/collections\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyUtils } from \"../../../runtime/modify-utils\";\nimport { modifyAppLayout } from \"./modifies/modify-app-layout\";\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { NOTIFICATION_RULE_PATCHES } from \"./runtime/pocketbase\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n options: Options,\n created = true,\n) {\n if (!created) return;\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, \"created\", options);\n if (!migrationFile) return;\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n const userCollection = await pb.collections.getOne(\"users\");\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n logger.info(\"Creating notifications collection\");\n const result = await create({\n name: \"notifications\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"user\",\n type: \"relation\",\n cascadeDelete: true,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"title\",\n type: \"text\",\n required: true,\n },\n {\n name: \"body\",\n type: \"text\",\n },\n {\n name: \"read\",\n type: \"bool\",\n },\n {\n name: \"created\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: false,\n },\n {\n name: \"updated\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: true,\n },\n ],\n indexes: [\n \"CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)\",\n ],\n });\n await pushMigrationCreates(\n creates,\n \"notifications\",\n options,\n result.created,\n );\n\n logger.info(\"Applying notifications rule patches\");\n const ruleMigrations = await applyCollectionRulePatches(\n pb,\n NOTIFICATION_RULE_PATCHES,\n options,\n logger,\n );\n creates.push(...ruleMigrations);\n });\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying (app) +layout.svelte\");\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, modifyAppLayout(appLayoutPath)),\n );\n\n logger.info(\"Modifying (app) +layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n modifyLayoutServer(appLayoutServerPath),\n ),\n );\n\n logger.info(\"Modifying utils.ts\");\n const utilsPath = path.join(options.root, \"src\", \"lib\", \"utils.ts\");\n pushResult(modifyOutcomeToFile(utilsPath, modifyUtils(utilsPath)));\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,IAAM,IAAe,2EAMf,IAAiB,CAAM;;GAIvB,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAEL,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgB,EAAgB,GAAmC;CACjE,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAa,SAAS;CAAe;CAGxD,IAAM,IAAO,EAAW,SAAS,CAAU;CAsB3C,OArBK,EAAK,WAAW,QAAQ,IAGzB,EAAK,WAAW,mBAAmB,IAC9B;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQ,MAAQ,EAAmB,IAAS,MAAO;GACzD,EAAc,GAAI,CAChB;IACE,eAAe;IACf,iBAAiB;GACnB,CACF,CAAC;EACH,CAAC;EACD,OAAO;CACT,CAAC,GAED,EAAK,uBAAuB,UAAU,CAAY,GAClD,EAAK,QAAQ,CAAU,GAChB;EAAE,QAAQ;EAAW,SAAS,EAAK,WAAW;CAAE,KApB9C;EAAE,QAAQ;EAAU,SAAS;CAAa;AAqBrD;;;AC/DA,IAAM,IAAkB,CAAM;;;;;;;GASxB,IACJ,kGAEI,IAAoB;AAE1B,SAAgB,EAAm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