@velastack/patterns 0.15.2 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/_page-CFeYIl2d.js +5 -0
- package/dist/chunks/_page-CFeYIl2d.js.map +1 -0
- package/dist/chunks/_page-CiazQY4O.js +5 -0
- package/dist/chunks/{_page-BFUn0CG1.js.map → _page-CiazQY4O.js.map} +1 -1
- package/dist/chunks/{auth-pages-D8n8gfCL.js → auth-pages-B8H3kQPW.js} +2 -2
- package/dist/chunks/{auth-pages-D8n8gfCL.js.map → auth-pages-B8H3kQPW.js.map} +1 -1
- package/dist/chunks/{collections-Daxlnbm0.js → collections-CFTIAty-.js} +2 -2
- package/dist/chunks/{collections-Daxlnbm0.js.map → collections-CFTIAty-.js.map} +1 -1
- package/dist/chunks/{currency.server-BkzwY17R.js → currency.server-CHzEhyTx.js} +74 -74
- package/dist/chunks/currency.server-CHzEhyTx.js.map +1 -0
- package/dist/chunks/dispatch-DSkRrJFe.js +5 -0
- package/dist/chunks/{dispatch-BxlKS_5v.js.map → dispatch-DSkRrJFe.js.map} +1 -1
- package/dist/chunks/{env-vars-C3TSZc4f.js → env-vars--fyhY-ew.js} +3 -3
- package/dist/chunks/{env-vars-C3TSZc4f.js.map → env-vars--fyhY-ew.js.map} +1 -1
- package/dist/chunks/{generate-CbchamhA.js → generate-B2z0kA5C.js} +2 -2
- package/dist/chunks/{generate-CbchamhA.js.map → generate-B2z0kA5C.js.map} +1 -1
- package/dist/chunks/{generate-CAYM7OUF.js → generate-BSCDKlyL.js} +2 -2
- package/dist/chunks/{generate-CAYM7OUF.js.map → generate-BSCDKlyL.js.map} +1 -1
- package/dist/chunks/{generate-DI58vuk1.js → generate-DZ2S8KDR.js} +3 -3
- package/dist/chunks/{generate-DI58vuk1.js.map → generate-DZ2S8KDR.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CZMVPVjS.js → generate.runtime-2T2j6Cgc.js} +5 -5
- package/dist/chunks/{generate.runtime-CZMVPVjS.js.map → generate.runtime-2T2j6Cgc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-_426A1Ij.js → generate.runtime-7rRHLyjy.js} +3 -3
- package/dist/chunks/{generate.runtime-_426A1Ij.js.map → generate.runtime-7rRHLyjy.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bo_s7gYB.js → generate.runtime-9wfx5sJK.js} +2 -2
- package/dist/chunks/{generate.runtime-Bo_s7gYB.js.map → generate.runtime-9wfx5sJK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B7VubPTW.js → generate.runtime-B6Tce286.js} +3 -3
- package/dist/chunks/{generate.runtime-B7VubPTW.js.map → generate.runtime-B6Tce286.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B11mOr45.js → generate.runtime-B9nqVvxO.js} +2 -2
- package/dist/chunks/{generate.runtime-B11mOr45.js.map → generate.runtime-B9nqVvxO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BL6DpWFI.js → generate.runtime-BCa20dNN.js} +3 -3
- package/dist/chunks/{generate.runtime-BL6DpWFI.js.map → generate.runtime-BCa20dNN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DP63Wwea.js → generate.runtime-BFyTIABc.js} +4 -4
- package/dist/chunks/{generate.runtime-DP63Wwea.js.map → generate.runtime-BFyTIABc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DlAJQ5Js.js → generate.runtime-B_md4EZa.js} +76 -68
- package/dist/chunks/generate.runtime-B_md4EZa.js.map +1 -0
- package/dist/chunks/{generate.runtime-BH6hHygm.js → generate.runtime-BpXoagaq.js} +76 -76
- package/dist/chunks/generate.runtime-BpXoagaq.js.map +1 -0
- package/dist/chunks/{generate.runtime-DW9bqOtC.js → generate.runtime-C1zb2WxI.js} +2 -2
- package/dist/chunks/{generate.runtime-DW9bqOtC.js.map → generate.runtime-C1zb2WxI.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C3IswX7B.js → generate.runtime-C4R919oE.js} +113 -104
- package/dist/chunks/generate.runtime-C4R919oE.js.map +1 -0
- package/dist/chunks/{generate.runtime-BCv4F1Wm.js → generate.runtime-C4qZ7Q30.js} +4 -4
- package/dist/chunks/{generate.runtime-BCv4F1Wm.js.map → generate.runtime-C4qZ7Q30.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C90_2L-8.js → generate.runtime-C8xFPEgP.js} +2 -2
- package/dist/chunks/{generate.runtime-C90_2L-8.js.map → generate.runtime-C8xFPEgP.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cs73i6Zf.js → generate.runtime-CC4XoTnb.js} +2 -2
- package/dist/chunks/{generate.runtime-Cs73i6Zf.js.map → generate.runtime-CC4XoTnb.js.map} +1 -1
- package/dist/chunks/{generate.runtime-jIlQ2GMh.js → generate.runtime-CCL_doqr.js} +2 -2
- package/dist/chunks/{generate.runtime-jIlQ2GMh.js.map → generate.runtime-CCL_doqr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BEWp57Y7.js → generate.runtime-CKyi82cZ.js} +2 -2
- package/dist/chunks/{generate.runtime-BEWp57Y7.js.map → generate.runtime-CKyi82cZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D7KYlnvb.js → generate.runtime-CNHEuhx4.js} +4 -4
- package/dist/chunks/{generate.runtime-D7KYlnvb.js.map → generate.runtime-CNHEuhx4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-JftBoKYS.js → generate.runtime-CPF0TcjM.js} +3 -3
- package/dist/chunks/{generate.runtime-JftBoKYS.js.map → generate.runtime-CPF0TcjM.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bs77Oc8P.js → generate.runtime-CWNIo1xQ.js} +4 -4
- package/dist/chunks/{generate.runtime-Bs77Oc8P.js.map → generate.runtime-CWNIo1xQ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CDY0Ot_t.js → generate.runtime-Cb2u0ft4.js} +5 -5
- package/dist/chunks/{generate.runtime-CDY0Ot_t.js.map → generate.runtime-Cb2u0ft4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ChSVP7cD.js → generate.runtime-CdpLsiqC.js} +4 -4
- package/dist/chunks/{generate.runtime-ChSVP7cD.js.map → generate.runtime-CdpLsiqC.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CdZ3GzPS.js → generate.runtime-ChstrVRw.js} +6 -6
- package/dist/chunks/{generate.runtime-CdZ3GzPS.js.map → generate.runtime-ChstrVRw.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bhs7ttZS.js → generate.runtime-CpDUk3Ev.js} +2 -2
- package/dist/chunks/{generate.runtime-Bhs7ttZS.js.map → generate.runtime-CpDUk3Ev.js.map} +1 -1
- package/dist/chunks/{generate.runtime-xrxAElb3.js → generate.runtime-Ctd_522e.js} +3 -3
- package/dist/chunks/{generate.runtime-xrxAElb3.js.map → generate.runtime-Ctd_522e.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B1Y2JrGW.js → generate.runtime-CviYhOWW.js} +202 -117
- package/dist/chunks/generate.runtime-CviYhOWW.js.map +1 -0
- package/dist/chunks/{generate.runtime-BRV9hIl5.js → generate.runtime-CxJaHusI.js} +2 -2
- package/dist/chunks/{generate.runtime-BRV9hIl5.js.map → generate.runtime-CxJaHusI.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DRPxOLnB.js → generate.runtime-D0acTMRF.js} +4 -4
- package/dist/chunks/{generate.runtime-DRPxOLnB.js.map → generate.runtime-D0acTMRF.js.map} +1 -1
- package/dist/chunks/{generate.runtime-fs6GEMx-.js → generate.runtime-D6vRzBoU.js} +4 -4
- package/dist/chunks/{generate.runtime-fs6GEMx-.js.map → generate.runtime-D6vRzBoU.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BRcP6sFt.js → generate.runtime-D7aGjoTD.js} +2 -2
- package/dist/chunks/{generate.runtime-BRcP6sFt.js.map → generate.runtime-D7aGjoTD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DG9LRwbt.js → generate.runtime-DPtjvhGr.js} +2 -2
- package/dist/chunks/{generate.runtime-DG9LRwbt.js.map → generate.runtime-DPtjvhGr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BjrtdoYE.js → generate.runtime-DmHZZz4Z.js} +2 -2
- package/dist/chunks/{generate.runtime-BjrtdoYE.js.map → generate.runtime-DmHZZz4Z.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DdY44Ulv.js → generate.runtime-O5eQdhHV.js} +4 -4
- package/dist/chunks/{generate.runtime-DdY44Ulv.js.map → generate.runtime-O5eQdhHV.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DKL7VAAd.js → generate.runtime-Uq_L7TtO.js} +5 -5
- package/dist/chunks/{generate.runtime-DKL7VAAd.js.map → generate.runtime-Uq_L7TtO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C_hrLPD4.js → generate.runtime-VWQfzXXv.js} +3 -3
- package/dist/chunks/{generate.runtime-C_hrLPD4.js.map → generate.runtime-VWQfzXXv.js.map} +1 -1
- package/dist/chunks/{generate.runtime-v3KCv1B6.js → generate.runtime-WL1mm8gp.js} +2 -2
- package/dist/chunks/{generate.runtime-v3KCv1B6.js.map → generate.runtime-WL1mm8gp.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DjEj-n6m.js → generate.runtime-vJFz9Q7V.js} +8 -8
- package/dist/chunks/{generate.runtime-DjEj-n6m.js.map → generate.runtime-vJFz9Q7V.js.map} +1 -1
- package/dist/chunks/{gitignore-CBiWFRif.js → gitignore-DUzIQXIo.js} +2 -2
- package/dist/chunks/{gitignore-CBiWFRif.js.map → gitignore-DUzIQXIo.js.map} +1 -1
- package/dist/chunks/{i18n-Ho8H91Ze.js → i18n-BoYcqVBi.js} +2 -2
- package/dist/chunks/{i18n-Ho8H91Ze.js.map → i18n-BoYcqVBi.js.map} +1 -1
- package/dist/chunks/{modify-file-BOEKlIDw.js → modify-file-DRdmZIvW.js} +2 -2
- package/dist/chunks/{modify-file-BOEKlIDw.js.map → modify-file-DRdmZIvW.js.map} +1 -1
- package/dist/chunks/{pocketbase-CvsJYXj-.js → pocketbase-BrDs1_84.js} +23 -7
- package/dist/chunks/pocketbase-BrDs1_84.js.map +1 -0
- package/dist/chunks/{providers-BEjDonyG.js → providers-Dhr_mzm6.js} +2 -2
- package/dist/chunks/{providers-BEjDonyG.js.map → providers-Dhr_mzm6.js.map} +1 -1
- package/dist/chunks/{schema-DnMqw2Hn.js → schema-C16iVOAG.js} +2 -2
- package/dist/chunks/{schema-DnMqw2Hn.js.map → schema-C16iVOAG.js.map} +1 -1
- package/dist/chunks/{shared-CSwGWMcN.js → shared-D7-ZAoqr.js} +2 -2
- package/dist/chunks/{shared-CSwGWMcN.js.map → shared-D7-ZAoqr.js.map} +1 -1
- package/dist/chunks/{ui-CpjUq_lm.js → ui-BI9OQpuR.js} +2 -2
- package/dist/chunks/{ui-CpjUq_lm.js.map → ui-BI9OQpuR.js.map} +1 -1
- package/dist/chunks/{unmodify-load-CdWXJ_Ac.js → unmodify-load-DWixBz7y.js} +17 -4
- package/dist/chunks/unmodify-load-DWixBz7y.js.map +1 -0
- package/dist/chunks/{write-result-DlB-id5k.js → write-result-Do8AcYbL.js} +2 -2
- package/dist/chunks/{write-result-DlB-id5k.js.map → write-result-Do8AcYbL.js.map} +1 -1
- package/dist/index.js +1700 -1681
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/_page-BFUn0CG1.js +0 -5
- package/dist/chunks/_page-Bt37d4uo.js +0 -5
- package/dist/chunks/_page-Bt37d4uo.js.map +0 -1
- package/dist/chunks/currency.server-BkzwY17R.js.map +0 -1
- package/dist/chunks/dispatch-BxlKS_5v.js +0 -5
- package/dist/chunks/generate.runtime-B1Y2JrGW.js.map +0 -1
- package/dist/chunks/generate.runtime-BH6hHygm.js.map +0 -1
- package/dist/chunks/generate.runtime-C3IswX7B.js.map +0 -1
- package/dist/chunks/generate.runtime-DlAJQ5Js.js.map +0 -1
- package/dist/chunks/pocketbase-CvsJYXj-.js.map +0 -1
- package/dist/chunks/unmodify-load-CdWXJ_Ac.js.map +0 -1
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { n as e } from "./logger-t1HxmpG2.js";
|
|
2
|
-
import {
|
|
2
|
+
import { i as t, n, o as r } from "./collections-CFTIAty-.js";
|
|
3
3
|
import { i, n as a, t as o } from "./pocketbase-B2ksFrvH.js";
|
|
4
|
-
import { r as s } from "./modify-file-
|
|
4
|
+
import { r as s } from "./modify-file-DRdmZIvW.js";
|
|
5
5
|
import { t as c } from "./modify-utils--zro3IGe.js";
|
|
6
6
|
import { t as l } from "./dedent-CCUOcPFW.js";
|
|
7
7
|
import { t as u } from "./svelte-file-DfplF3BU.js";
|
|
8
|
-
import { _ as d,
|
|
9
|
-
import { t as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { Project as
|
|
8
|
+
import { _ as d, i as f, o as p, r as m } from "./ts-morph-helpers-B4KZXP44.js";
|
|
9
|
+
import { t as h } from "./pocketbase-YG9yht8R.js";
|
|
10
|
+
import g from "node:fs";
|
|
11
|
+
import _ from "node:path";
|
|
12
|
+
import { Project as v, SyntaxKind as y } from "ts-morph";
|
|
13
13
|
// src/patterns/enable/notifications/modifies/modify-app-layout.ts
|
|
14
|
-
var
|
|
14
|
+
var b = "\n <div class=\"ml-auto px-4\">\n <NotificationsBell />\n </div>\n ", x = l`
|
|
15
15
|
import NotificationsBell from '#lib/components/notifications-bell.svelte';
|
|
16
|
-
`,
|
|
16
|
+
`, S = [
|
|
17
17
|
"Add the notifications bell inside the (app) layout's <header>.",
|
|
18
18
|
"",
|
|
19
19
|
"Imports to add to the <script> tag:",
|
|
20
20
|
"",
|
|
21
|
-
|
|
21
|
+
x,
|
|
22
22
|
"",
|
|
23
23
|
"Markup to add inside <header>:",
|
|
24
|
-
|
|
25
|
-
].join("\n"),
|
|
24
|
+
b
|
|
25
|
+
].join("\n"), C = [
|
|
26
26
|
"Create src/routes/(app)/+layout.svelte with a <header> that includes the bell.",
|
|
27
27
|
"",
|
|
28
28
|
"Imports for the <script> tag:",
|
|
29
29
|
"",
|
|
30
|
-
|
|
30
|
+
x,
|
|
31
31
|
"",
|
|
32
32
|
"Markup inside <header>:",
|
|
33
|
-
|
|
33
|
+
b
|
|
34
34
|
].join("\n");
|
|
35
|
-
function
|
|
36
|
-
if (!
|
|
35
|
+
function w(e) {
|
|
36
|
+
if (!g.existsSync(e)) return {
|
|
37
37
|
status: "not-found",
|
|
38
|
-
message:
|
|
38
|
+
message: C
|
|
39
39
|
};
|
|
40
40
|
let t = u.fromPath(e);
|
|
41
41
|
return t.hasElement("header") ? t.hasElement("NotificationsBell") ? {
|
|
@@ -43,60 +43,65 @@ function C(e) {
|
|
|
43
43
|
changed: !1
|
|
44
44
|
} : (t.modifyScript((e) => {
|
|
45
45
|
let { source: t } = d(e, (e) => {
|
|
46
|
-
|
|
46
|
+
m(e, [{
|
|
47
47
|
defaultImport: "NotificationsBell",
|
|
48
48
|
moduleSpecifier: "#lib/components/notifications-bell.svelte"
|
|
49
49
|
}]);
|
|
50
50
|
});
|
|
51
51
|
return t;
|
|
52
|
-
}), t.insertBeforeClosingTag("header",
|
|
52
|
+
}), t.insertBeforeClosingTag("header", b), t.writeTo(e), {
|
|
53
53
|
status: "success",
|
|
54
54
|
changed: t.hasChanged()
|
|
55
55
|
}) : {
|
|
56
56
|
status: "failed",
|
|
57
|
-
message:
|
|
57
|
+
message: S
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
// src/patterns/enable/notifications/modifies/+layout.server.ts
|
|
61
|
-
var
|
|
61
|
+
var T = "@velastack/pocketbase/auth", E = "const user = requireUser();", D = l`
|
|
62
62
|
const notificationsList = await locals.pb
|
|
63
63
|
.collection("notifications")
|
|
64
64
|
.getList(1, 5, {
|
|
65
|
-
filter:
|
|
65
|
+
filter: locals.pb.filter("user = {:user} && read = false", {
|
|
66
|
+
user: user.id,
|
|
67
|
+
}),
|
|
66
68
|
sort: "-created",
|
|
67
69
|
});
|
|
68
|
-
`,
|
|
69
|
-
function
|
|
70
|
-
if (!
|
|
70
|
+
`, O = "const notifications = { count: notificationsList.totalItems, items: notificationsList.items };", k = "depends(\"app:notifications\");";
|
|
71
|
+
function A(e) {
|
|
72
|
+
if (!g.existsSync(e)) {
|
|
71
73
|
let t = l`
|
|
74
|
+
import { requireUser } from "${T}";
|
|
75
|
+
|
|
72
76
|
export const load = async ({ locals, depends }) => {
|
|
73
|
-
${w}
|
|
74
|
-
${T}
|
|
75
77
|
${E}
|
|
78
|
+
${D}
|
|
79
|
+
${O}
|
|
80
|
+
${k}
|
|
76
81
|
return { notifications };
|
|
77
82
|
};
|
|
78
83
|
`;
|
|
79
|
-
return
|
|
84
|
+
return g.writeFileSync(e, t), {
|
|
80
85
|
status: "success",
|
|
81
86
|
changed: !0
|
|
82
87
|
};
|
|
83
88
|
}
|
|
84
|
-
let t =
|
|
89
|
+
let t = g.readFileSync(e, "utf8"), n = new v().addSourceFileAtPath(e), r = (e, t, n) => {
|
|
85
90
|
e.getProperty(t) || (t === n ? e.addShorthandPropertyAssignment({ name: t }) : e.addPropertyAssignment({
|
|
86
91
|
name: t,
|
|
87
92
|
initializer: n
|
|
88
93
|
}));
|
|
89
94
|
}, i, a, o = n.getVariableDeclaration("load");
|
|
90
|
-
if (o && o.getFirstAncestorByKind(
|
|
91
|
-
let e = o.getInitializerIfKind(
|
|
95
|
+
if (o && o.getFirstAncestorByKind(y.VariableStatement)?.hasExportKeyword()) {
|
|
96
|
+
let e = o.getInitializerIfKind(y.ArrowFunction);
|
|
92
97
|
if (e) i = e;
|
|
93
98
|
else {
|
|
94
99
|
let e = o.getInitializer();
|
|
95
100
|
if (e) {
|
|
96
|
-
let t = e.getFirstDescendantByKind(
|
|
101
|
+
let t = e.getFirstDescendantByKind(y.ArrowFunction);
|
|
97
102
|
if (t) i = t;
|
|
98
103
|
else {
|
|
99
|
-
let t = e.getFirstDescendantByKind(
|
|
104
|
+
let t = e.getFirstDescendantByKind(y.FunctionExpression);
|
|
100
105
|
t && (a = t);
|
|
101
106
|
}
|
|
102
107
|
}
|
|
@@ -112,12 +117,13 @@ function D(e) {
|
|
|
112
117
|
name: "load",
|
|
113
118
|
parameters: [{ name: "{ locals, depends }" }],
|
|
114
119
|
statements: [
|
|
115
|
-
w,
|
|
116
|
-
T,
|
|
117
120
|
E,
|
|
121
|
+
D,
|
|
122
|
+
O,
|
|
123
|
+
k,
|
|
118
124
|
"return { notifications };"
|
|
119
125
|
]
|
|
120
|
-
}), f(n), n.saveSync(), {
|
|
126
|
+
}), f(n, T, "requireUser"), p(n), n.saveSync(), {
|
|
121
127
|
status: "success",
|
|
122
128
|
changed: !0
|
|
123
129
|
};
|
|
@@ -125,7 +131,7 @@ function D(e) {
|
|
|
125
131
|
if (c.length === 0) s.insertParameter(0, { name: "{ locals, depends }" });
|
|
126
132
|
else {
|
|
127
133
|
let e = c[0], t = e.getStructure(), n = e.getNameNode();
|
|
128
|
-
if (n.getKind() ===
|
|
134
|
+
if (n.getKind() === y.ObjectBindingPattern) {
|
|
129
135
|
let r = n, i = r.getElements().map((e) => e.getName()), a = i.includes("depends"), o = i.includes("locals");
|
|
130
136
|
if (!a || !o) {
|
|
131
137
|
let n = r.getElements().map((e) => e.getText()).filter(Boolean), i = o ? [] : ["locals"];
|
|
@@ -150,58 +156,60 @@ function D(e) {
|
|
|
150
156
|
}
|
|
151
157
|
i && !i.isAsync() ? i.setIsAsync(!0) : a && !a.isAsync() && a.setIsAsync(!0);
|
|
152
158
|
let u = s.getBody();
|
|
153
|
-
if (u && u.getKind() ===
|
|
154
|
-
let e = u, t = e.getStatements(),
|
|
159
|
+
if (u && u.getKind() === y.Block) {
|
|
160
|
+
let e = u, t = e.getStatements(), r = (e) => t.some((t) => t.getKind() === y.VariableStatement && t.getDeclarations().some((t) => t.getName() === e)), i = t.some((e) => e.getKind() === y.ExpressionStatement && e.getDescendantsOfKind(y.CallExpression).some((e) => {
|
|
155
161
|
if (e.getExpression().getText() !== "depends") return !1;
|
|
156
162
|
let t = e.getArguments(), n = t[0]?.getText() ?? "";
|
|
157
163
|
return t.length === 1 && (n === "'app:notifications'" || n === "\"app:notifications\"");
|
|
158
|
-
})),
|
|
159
|
-
|
|
164
|
+
})), a = r("notificationsList"), o = r("notifications");
|
|
165
|
+
!a && !r("user") && (e.insertStatements(0, E), f(n, T, "requireUser"));
|
|
166
|
+
let s = e.getStatements(), c = s.findIndex((e) => e.getKind() === y.ReturnStatement), l = c >= 0 ? c : s.length;
|
|
167
|
+
a || (e.insertStatements(l, D), l++), o || (e.insertStatements(l, O), l++), i || e.insertStatements(l, k);
|
|
160
168
|
}
|
|
161
169
|
let d = (e) => {
|
|
162
170
|
r(e, "notifications", "notifications");
|
|
163
|
-
},
|
|
164
|
-
e.getDescendantsOfKind(
|
|
171
|
+
}, m = (e) => {
|
|
172
|
+
e.getDescendantsOfKind(y.ReturnStatement).forEach((e) => {
|
|
165
173
|
let t = e.getExpression();
|
|
166
174
|
if (t) {
|
|
167
|
-
if (t.getKind() ===
|
|
168
|
-
else if (t.getKind() ===
|
|
175
|
+
if (t.getKind() === y.ObjectLiteralExpression) d(t);
|
|
176
|
+
else if (t.getKind() === y.ParenthesizedExpression) {
|
|
169
177
|
let e = t.getExpression();
|
|
170
|
-
e.getKind() ===
|
|
178
|
+
e.getKind() === y.ObjectLiteralExpression && d(e);
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
181
|
});
|
|
174
182
|
};
|
|
175
183
|
if (i) {
|
|
176
184
|
let e = i.getBody();
|
|
177
|
-
if (e.getKind() ===
|
|
185
|
+
if (e.getKind() === y.Block) m(e);
|
|
178
186
|
else {
|
|
179
187
|
let t = e;
|
|
180
|
-
if (t.getKind() ===
|
|
188
|
+
if (t.getKind() === y.ParenthesizedExpression) {
|
|
181
189
|
let e = t.getExpression();
|
|
182
|
-
e.getKind() ===
|
|
183
|
-
} else t.getKind() ===
|
|
190
|
+
e.getKind() === y.ObjectLiteralExpression && d(e);
|
|
191
|
+
} else t.getKind() === y.ObjectLiteralExpression && d(t);
|
|
184
192
|
}
|
|
185
193
|
} else if (a) {
|
|
186
194
|
let e = a.getBody();
|
|
187
|
-
e &&
|
|
195
|
+
e && m(e);
|
|
188
196
|
}
|
|
189
|
-
return
|
|
197
|
+
return p(n), n.saveSync(), {
|
|
190
198
|
status: "success",
|
|
191
199
|
changed: n.getFullText() !== t
|
|
192
200
|
};
|
|
193
201
|
}
|
|
194
202
|
// src/patterns/enable/notifications/generate.runtime.ts
|
|
195
|
-
async function
|
|
203
|
+
async function j(e, t, n, i = !0) {
|
|
196
204
|
if (!i) return;
|
|
197
205
|
await a();
|
|
198
|
-
let s = o(
|
|
199
|
-
s && e.push(await
|
|
206
|
+
let s = o(t, "created", n);
|
|
207
|
+
s && e.push(await r(s, n));
|
|
200
208
|
}
|
|
201
|
-
async function
|
|
202
|
-
let a = e(
|
|
203
|
-
await i(
|
|
204
|
-
let i = await e.collections.getOne("users"), s = (
|
|
209
|
+
async function M(r) {
|
|
210
|
+
let a = e(r), o = [];
|
|
211
|
+
await i(r.root, async (e) => {
|
|
212
|
+
let i = await e.collections.getOne("users"), s = (n) => t(e, n, a);
|
|
205
213
|
a.info("Creating notifications collection");
|
|
206
214
|
let c = await s({
|
|
207
215
|
name: "notifications",
|
|
@@ -254,19 +262,19 @@ async function k(t) {
|
|
|
254
262
|
],
|
|
255
263
|
indexes: ["CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)"]
|
|
256
264
|
});
|
|
257
|
-
await
|
|
258
|
-
let l = await
|
|
265
|
+
await j(o, "notifications", r, c.created), a.info("Applying notifications rule patches");
|
|
266
|
+
let l = await n(e, h, r, a);
|
|
259
267
|
o.push(...l);
|
|
260
268
|
});
|
|
261
269
|
let l = [], u = (e) => {
|
|
262
270
|
e && l.push(e);
|
|
263
271
|
};
|
|
264
272
|
a.info("Modifying (app) +layout.svelte");
|
|
265
|
-
let d =
|
|
266
|
-
u(s(d,
|
|
267
|
-
let f =
|
|
268
|
-
u(s(f,
|
|
269
|
-
let p =
|
|
273
|
+
let d = _.join(r.root, "src", "routes", "(app)", "+layout.svelte");
|
|
274
|
+
u(s(d, w(d))), a.info("Modifying (app) +layout.server.ts");
|
|
275
|
+
let f = _.join(r.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
276
|
+
u(s(f, A(f))), a.info("Modifying utils.ts");
|
|
277
|
+
let p = _.join(r.root, "src", "lib", "utils.ts");
|
|
270
278
|
return u(s(p, c(p))), {
|
|
271
279
|
creates: o,
|
|
272
280
|
modifies: l,
|
|
@@ -278,6 +286,6 @@ async function k(t) {
|
|
|
278
286
|
collectionDrops: []
|
|
279
287
|
};
|
|
280
288
|
}
|
|
281
|
-
export {
|
|
289
|
+
export { M as generate };
|
|
282
290
|
|
|
283
|
-
//# sourceMappingURL=generate.runtime-
|
|
291
|
+
//# sourceMappingURL=generate.runtime-B_md4EZa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-B_md4EZa.js","names":["getLogger","createCollectionIdempotent","readMigration","migrationDelay","getMigrationFile","modifyOutcomeToFile","modifyUtils","dedent","SvelteFile","withInMemoryScript","ensureNamedImport","formatLikeSource","ensureImports","NOTIFICATION_RULE_PATCHES","fs","path","BELL_SNIPPET","IMPORT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","modifyAppLayout","layoutPath","file","out","source","sf","AUTH_MODULE","USER_STATEMENT","FETCH_STATEMENT","NOTIFICATIONS_STATEMENT","DEPENDS_STATEMENT","modifyLayoutServer","layoutServerPath","snippet","originalSource","sourceFile","Project","addProperty","obj","name","initializer","loadArrow","loadFn","varDecl","SyntaxKind","directArrow","init","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","nameNode","obp","elementNames","el","hasDepends","hasLocals","existingParts","parts","currentName","body","blockBody","statements","declaresVar","stmt","d","hasDependsCall","ce","args","argText","hasNotificationsList","hasNotifications","current","returnIdx","s","insertAt","augmentReturnObject","augmentReturns","expr","ret","inner","arrowBody","bodyExpr","fnBody","pushMigrationCreates","created","migrationFile","collectionName","options","creates","generate","logger","withPocketbase","userCollection","pb","create","spec","result","ruleMigrations","applyCollectionRulePatches","modifies","pushResult","appLayoutPath","appLayoutServerPath","utilsPath"],"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 {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst AUTH_MODULE = \"@velastack/pocketbase/auth\";\n\n/** For a load that has no `user` yet: the stock (app) layout declares one. */\nconst USER_STATEMENT = \"const user = requireUser();\";\n\nconst FETCH_STATEMENT = dedent`\n const notificationsList = await locals.pb\n .collection(\"notifications\")\n .getList(1, 5, {\n filter: locals.pb.filter(\"user = {:user} && read = false\", {\n user: user.id,\n }),\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 import { requireUser } from \"${AUTH_MODULE}\";\n\n export const load = async ({ locals, depends }) => {\n ${USER_STATEMENT}\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 USER_STATEMENT,\n FETCH_STATEMENT,\n NOTIFICATIONS_STATEMENT,\n DEPENDS_STATEMENT,\n \"return { notifications };\",\n ],\n });\n ensureNamedImport(sourceFile, AUTH_MODULE, \"requireUser\");\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 // The query filters on `user.id`. A load written by enable-auth has the\n // user already, by either name for it (`requireUser()` now,\n // `locals.pb.authStore.record!` before); any other gets it first.\n if (!hasNotificationsList && !declaresVar(\"user\")) {\n blockBody.insertStatements(0, USER_STATEMENT);\n ensureNamedImport(sourceFile, AUTH_MODULE, \"requireUser\");\n }\n\n const current = blockBody.getStatements();\n const returnIdx = current.findIndex(\n (s) => s.getKind() === SyntaxKind.ReturnStatement,\n );\n let insertAt = returnIdx >= 0 ? returnIdx : current.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 path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n applyCollectionRulePatches,\n createCollectionIdempotent,\n readMigration,\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(await readMigration(migrationFile, options));\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: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CAAC,CAAC,GAE1D;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import { n as e } from "./logger-t1HxmpG2.js";
|
|
2
|
-
import { r as t } from "./modify-file-
|
|
3
|
-
import { t as n } from "./shared-
|
|
4
|
-
import { _ as r, h as i,
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as
|
|
7
|
-
import { r as
|
|
8
|
-
import { n as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { Project as
|
|
2
|
+
import { r as t } from "./modify-file-DRdmZIvW.js";
|
|
3
|
+
import { t as n } from "./shared-D7-ZAoqr.js";
|
|
4
|
+
import { _ as r, h as i, n as a, o, u as s } from "./ts-morph-helpers-B4KZXP44.js";
|
|
5
|
+
import { t as c } from "./svelte-file-DfplF3BU.js";
|
|
6
|
+
import { t as l } from "./unmodify-load-DWixBz7y.js";
|
|
7
|
+
import { r as u, t as d } from "./modify-nav-user--7OwY9fI.js";
|
|
8
|
+
import { n as f, t as p } from "./_page-CFeYIl2d.js";
|
|
9
|
+
import m from "node:fs";
|
|
10
|
+
import h from "node:path";
|
|
11
|
+
import { Project as g, QuoteKind as _, SyntaxKind as v } from "ts-morph";
|
|
12
12
|
// src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts
|
|
13
|
-
var
|
|
13
|
+
var y = /* @__PURE__ */ new Set([
|
|
14
14
|
"customer.subscription.created",
|
|
15
15
|
"customer.subscription.updated",
|
|
16
16
|
"customer.subscription.deleted"
|
|
17
17
|
]);
|
|
18
|
-
function
|
|
19
|
-
if (!
|
|
18
|
+
function b(e) {
|
|
19
|
+
if (!m.existsSync(e)) return {
|
|
20
20
|
status: "success",
|
|
21
21
|
changed: !1
|
|
22
22
|
};
|
|
23
|
-
let t =
|
|
23
|
+
let t = m.readFileSync(e, "utf8");
|
|
24
24
|
if (!t.includes("handleSubscriptionCreated")) return {
|
|
25
25
|
status: "success",
|
|
26
26
|
changed: !1
|
|
27
27
|
};
|
|
28
28
|
let { source: n } = r(t, (e) => {
|
|
29
|
-
|
|
30
|
-
let t = e.getDescendantsOfKind(
|
|
29
|
+
s(e, "./subscription/created"), s(e, "./subscription/updated"), s(e, "./subscription/deleted");
|
|
30
|
+
let t = e.getDescendantsOfKind(v.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
|
|
31
31
|
if (!t) return;
|
|
32
32
|
let n = t.getCaseBlock().getClauses().filter((e) => {
|
|
33
|
-
if (e.getKind() !==
|
|
34
|
-
let t = e.asKindOrThrow(
|
|
35
|
-
return n ?
|
|
36
|
-
}).map((e) => e.asKindOrThrow(
|
|
33
|
+
if (e.getKind() !== v.CaseClause) return !1;
|
|
34
|
+
let t = e.asKindOrThrow(v.CaseClause).getExpression(), n = t.asKind(v.StringLiteral) ?? t.asKind(v.NoSubstitutionTemplateLiteral);
|
|
35
|
+
return n ? y.has(n.getLiteralValue()) : !1;
|
|
36
|
+
}).map((e) => e.asKindOrThrow(v.CaseClause));
|
|
37
37
|
for (let e of n.reverse()) e.remove();
|
|
38
|
-
|
|
38
|
+
o(e);
|
|
39
39
|
}), i = n.replace(/(break;)\n(\s*default:)/, "$1\n\n$2");
|
|
40
40
|
return i === t ? {
|
|
41
41
|
status: "success",
|
|
42
42
|
changed: !1
|
|
43
|
-
} : (
|
|
43
|
+
} : (m.writeFileSync(e, i, "utf8"), {
|
|
44
44
|
status: "success",
|
|
45
45
|
changed: !0
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
// src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts
|
|
49
|
-
function
|
|
50
|
-
if (!
|
|
49
|
+
function x(e) {
|
|
50
|
+
if (!m.existsSync(e)) return {
|
|
51
51
|
status: "success",
|
|
52
52
|
changed: !1
|
|
53
53
|
};
|
|
54
|
-
let t =
|
|
54
|
+
let t = c.fromPath(e);
|
|
55
55
|
return !t.hasElement("AppSidebar") || !t.hasAttribute("AppSidebar", "subscription") || !t.removeAttribute("AppSidebar", "subscription") ? {
|
|
56
56
|
status: "success",
|
|
57
57
|
changed: !1
|
|
@@ -61,19 +61,19 @@ function b(e) {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
// src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts
|
|
64
|
-
function
|
|
64
|
+
function S(e) {
|
|
65
65
|
let { source: t } = r(e, (e) => {
|
|
66
66
|
for (let t of e.getVariableDeclarations()) {
|
|
67
67
|
let e = t.getInitializer();
|
|
68
68
|
if (!e || e.getText() !== "$props()") continue;
|
|
69
69
|
let n = t.getNameNode();
|
|
70
|
-
if (n.getKind() !==
|
|
71
|
-
let r = n.asKindOrThrow(
|
|
72
|
-
if (o?.getKind() ===
|
|
73
|
-
let e = o.asKindOrThrow(
|
|
70
|
+
if (n.getKind() !== v.ObjectBindingPattern) continue;
|
|
71
|
+
let r = n.asKindOrThrow(v.ObjectBindingPattern), i = r.getElements(), a = i.some((e) => e.getName() === "subscription"), o = t.getTypeNode();
|
|
72
|
+
if (o?.getKind() === v.IntersectionType) {
|
|
73
|
+
let e = o.asKindOrThrow(v.IntersectionType);
|
|
74
74
|
for (let t of e.getTypeNodes()) {
|
|
75
|
-
if (t.getKind() !==
|
|
76
|
-
let e = t.asKindOrThrow(
|
|
75
|
+
if (t.getKind() !== v.TypeLiteral) continue;
|
|
76
|
+
let e = t.asKindOrThrow(v.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, "")).filter((e) => !/^\s*subscription\??\s*:/.test(e));
|
|
77
77
|
e.replaceWithText(n.length ? `{ ${n.join("; ")}; }` : "{}");
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
@@ -83,76 +83,76 @@ function x(e) {
|
|
|
83
83
|
r.replaceWithText(`{ ${e.join(", ")} }`);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
o(e);
|
|
87
87
|
});
|
|
88
88
|
return t;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
if (!
|
|
90
|
+
function C(e) {
|
|
91
|
+
if (!m.existsSync(e)) return {
|
|
92
92
|
status: "success",
|
|
93
93
|
changed: !1
|
|
94
94
|
};
|
|
95
|
-
let t =
|
|
95
|
+
let t = m.readFileSync(e, "utf8"), n = /subscription\??\s*:\s*\{/.test(t), r = /\bsubscription\s*=\s*null\b/.test(t), i = new c(t), a = i.hasElement("NavUser") && i.hasAttribute("NavUser", "subscription");
|
|
96
96
|
return !n && !r && !a ? {
|
|
97
97
|
status: "success",
|
|
98
98
|
changed: !1
|
|
99
|
-
} : ((n || r) && i.modifyScript(
|
|
99
|
+
} : ((n || r) && i.modifyScript(S), a && i.removeAttribute("NavUser", "subscription"), i.writeTo(e), {
|
|
100
100
|
status: "success",
|
|
101
101
|
changed: i.hasChanged()
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
// src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts
|
|
105
|
-
function
|
|
106
|
-
if (!
|
|
105
|
+
function w(e) {
|
|
106
|
+
if (!m.existsSync(e)) return {
|
|
107
107
|
status: "success",
|
|
108
108
|
changed: !1
|
|
109
109
|
};
|
|
110
|
-
let t =
|
|
110
|
+
let t = m.readFileSync(e, "utf8");
|
|
111
111
|
if (!t.includes("loadActiveSubscription")) return {
|
|
112
112
|
status: "success",
|
|
113
113
|
changed: !1
|
|
114
114
|
};
|
|
115
|
-
let n =
|
|
115
|
+
let n = l(e, {
|
|
116
116
|
variables: ["subscription"],
|
|
117
117
|
dependsKeys: [],
|
|
118
118
|
returnProps: ["subscription"]
|
|
119
119
|
});
|
|
120
120
|
if (n.status !== "success") return n;
|
|
121
|
-
let r = new
|
|
122
|
-
return i(r, "loadActiveSubscription"), a(r), r.saveSync(), {
|
|
121
|
+
let r = new g({ manipulationSettings: { quoteKind: _.Single } }).addSourceFileAtPath(e);
|
|
122
|
+
return i(r, "loadActiveSubscription"), o(r), a(r), r.saveSync(), {
|
|
123
123
|
status: "success",
|
|
124
|
-
changed:
|
|
124
|
+
changed: m.readFileSync(e, "utf8") !== t
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
// src/patterns/disable/subscriptions/modifies/modify-nav-user.ts
|
|
128
|
-
function
|
|
129
|
-
if (!
|
|
128
|
+
function T(e) {
|
|
129
|
+
if (!m.existsSync(e)) return {
|
|
130
130
|
status: "success",
|
|
131
131
|
changed: !1
|
|
132
132
|
};
|
|
133
|
-
let t =
|
|
133
|
+
let t = m.readFileSync(e, "utf8");
|
|
134
134
|
if (!t.includes("planLabel")) return {
|
|
135
135
|
status: "success",
|
|
136
136
|
changed: !1
|
|
137
137
|
};
|
|
138
|
-
let n = new
|
|
138
|
+
let n = new c(t);
|
|
139
139
|
n.modifyScript((e) => r(e.replace(/\n[ \t]*\n[ \t]*const planLabel = \$derived\([^\n]*\);/, ""), (e) => {
|
|
140
|
-
let t =
|
|
141
|
-
n && r && n.replaceWithText(
|
|
140
|
+
let t = u(e)?.getDeclarations()[0], n = t?.getNameNode().asKind(v.ObjectBindingPattern), r = n?.getElements().filter((e) => e.getName() !== "subscription").map((e) => e.getText());
|
|
141
|
+
n && r && n.replaceWithText(d(n.getText(), r)), t?.getTypeNode()?.asKind(v.TypeLiteral)?.getProperty("subscription")?.remove();
|
|
142
142
|
}).source);
|
|
143
143
|
let i = n.toString().replace(/\n[ \t]*<span class="[^"]*">\s*\{planLabel\}\s*<\/span>/g, "");
|
|
144
|
-
return
|
|
144
|
+
return m.writeFileSync(e, i, "utf8"), {
|
|
145
145
|
status: "success",
|
|
146
146
|
changed: i !== t
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
// src/patterns/disable/subscriptions/modifies/revert-by-template.ts
|
|
150
|
-
function
|
|
151
|
-
if (!
|
|
150
|
+
function E(e, t, n) {
|
|
151
|
+
if (!m.existsSync(e)) return {
|
|
152
152
|
status: "success",
|
|
153
153
|
changed: !1
|
|
154
154
|
};
|
|
155
|
-
let r =
|
|
155
|
+
let r = m.readFileSync(e, "utf8");
|
|
156
156
|
if (!r.includes(n)) return {
|
|
157
157
|
status: "success",
|
|
158
158
|
changed: !1
|
|
@@ -161,39 +161,39 @@ function T(e, t, n) {
|
|
|
161
161
|
return r === i ? {
|
|
162
162
|
status: "success",
|
|
163
163
|
changed: !1
|
|
164
|
-
} : (
|
|
164
|
+
} : (m.writeFileSync(e, i, "utf8"), {
|
|
165
165
|
status: "success",
|
|
166
166
|
changed: !0
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
// src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts
|
|
170
|
-
function
|
|
171
|
-
return
|
|
170
|
+
function D(e, t) {
|
|
171
|
+
return E(e, t, "selectPlan");
|
|
172
172
|
}
|
|
173
173
|
// src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts
|
|
174
|
-
function
|
|
175
|
-
return
|
|
174
|
+
function O(e, t) {
|
|
175
|
+
return E(e, t, "availablePlans");
|
|
176
176
|
}
|
|
177
177
|
// src/patterns/disable/subscriptions/generate.runtime.ts
|
|
178
|
-
async function
|
|
178
|
+
async function k(r) {
|
|
179
179
|
let i = e(r), a = [], o = (e) => {
|
|
180
180
|
e && a.push(e);
|
|
181
181
|
};
|
|
182
182
|
i.info("Reverting webhooks/stripe/handlers/dispatch.ts");
|
|
183
|
-
let s =
|
|
184
|
-
o(t(s,
|
|
185
|
-
let c =
|
|
186
|
-
o(t(c,
|
|
187
|
-
let l =
|
|
188
|
-
o(t(l,
|
|
189
|
-
let u =
|
|
190
|
-
o(t(u,
|
|
191
|
-
let
|
|
192
|
-
o(t(
|
|
193
|
-
let
|
|
194
|
-
o(t(
|
|
195
|
-
let g =
|
|
196
|
-
return o(t(g,
|
|
183
|
+
let s = h.join(r.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
|
|
184
|
+
o(t(s, b(s))), i.info("Reverting (app)/+layout.server.ts");
|
|
185
|
+
let c = h.join(r.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
186
|
+
o(t(c, w(c))), i.info("Reverting (app)/+layout.svelte");
|
|
187
|
+
let l = h.join(r.root, "src", "routes", "(app)", "+layout.svelte");
|
|
188
|
+
o(t(l, x(l))), i.info("Reverting app-sidebar.svelte");
|
|
189
|
+
let u = h.join(r.root, "src", "lib", "components", "app-sidebar.svelte");
|
|
190
|
+
o(t(u, C(u))), i.info("Reverting nav-user.svelte");
|
|
191
|
+
let d = h.join(r.root, "src", "lib", "components", "nav-user.svelte");
|
|
192
|
+
o(t(d, T(d))), i.info("Reverting billing/+page.server.ts");
|
|
193
|
+
let m = h.join(r.root, "src", "routes", "(app)", "billing", "+page.server.ts");
|
|
194
|
+
o(t(m, D(m, f))), i.info("Reverting billing/+page.svelte");
|
|
195
|
+
let g = h.join(r.root, "src", "routes", "(app)", "billing", "+page.svelte");
|
|
196
|
+
return o(t(g, O(g, p))), {
|
|
197
197
|
creates: [],
|
|
198
198
|
modifies: a,
|
|
199
199
|
deletes: [],
|
|
@@ -204,6 +204,6 @@ async function O(r) {
|
|
|
204
204
|
collectionDrops: await n(["stripe_subscriptions"], r)
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
-
export {
|
|
207
|
+
export { k as generate };
|
|
208
208
|
|
|
209
|
-
//# sourceMappingURL=generate.runtime-
|
|
209
|
+
//# sourceMappingURL=generate.runtime-BpXoagaq.js.map
|