@velastack/patterns 0.8.0 → 0.10.0

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.
Files changed (37) hide show
  1. package/dist/chunks/_page-B6yd6_Vl.js +6 -0
  2. package/dist/chunks/_page-B6yd6_Vl.js.map +1 -0
  3. package/dist/chunks/{collections-BrEA7a62.js → collections-DZOuRpvS.js} +6 -1
  4. package/dist/chunks/collections-DZOuRpvS.js.map +1 -0
  5. package/dist/chunks/{generate-BZ741GPx.js → currency.server-Bb2Ndutg.js} +6 -3
  6. package/dist/chunks/{generate-BZ741GPx.js.map → currency.server-Bb2Ndutg.js.map} +1 -1
  7. package/dist/chunks/{generate-6JS05dWK.js → generate-B-cqjI-U.js} +62 -55
  8. package/dist/chunks/generate-B-cqjI-U.js.map +1 -0
  9. package/dist/chunks/generate-BrOPb9tW.js +175 -0
  10. package/dist/chunks/generate-BrOPb9tW.js.map +1 -0
  11. package/dist/chunks/{generate.runtime-BOl3LpPB.js → generate.runtime-BnqS_Zq8.js} +84 -158
  12. package/dist/chunks/generate.runtime-BnqS_Zq8.js.map +1 -0
  13. package/dist/chunks/{generate.runtime-KrQk7mqG.js → generate.runtime-DG9Lp3vR.js} +39 -37
  14. package/dist/chunks/generate.runtime-DG9Lp3vR.js.map +1 -0
  15. package/dist/chunks/generate.runtime-DuDcKDUl.js +162 -0
  16. package/dist/chunks/generate.runtime-DuDcKDUl.js.map +1 -0
  17. package/dist/chunks/{generate.runtime-Dt3Edp8-.js → generate.runtime-J2lLMjDn.js} +97 -126
  18. package/dist/chunks/generate.runtime-J2lLMjDn.js.map +1 -0
  19. package/dist/chunks/generate.runtime-nyJ6v56q.js +64 -0
  20. package/dist/chunks/generate.runtime-nyJ6v56q.js.map +1 -0
  21. package/dist/chunks/load-function-Dmkhg1pQ.js +79 -0
  22. package/dist/chunks/load-function-Dmkhg1pQ.js.map +1 -0
  23. package/dist/chunks/modify-nav-user-iUpv2lm-.js +53 -0
  24. package/dist/chunks/modify-nav-user-iUpv2lm-.js.map +1 -0
  25. package/dist/chunks/root-layout.svelte-CUVbnlX-.js +302 -0
  26. package/dist/chunks/root-layout.svelte-CUVbnlX-.js.map +1 -0
  27. package/dist/index.d.ts +156 -2
  28. package/dist/index.js +1972 -1807
  29. package/dist/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunks/collections-BrEA7a62.js.map +0 -1
  32. package/dist/chunks/generate-6JS05dWK.js.map +0 -1
  33. package/dist/chunks/generate.runtime-BOl3LpPB.js.map +0 -1
  34. package/dist/chunks/generate.runtime-Dt3Edp8-.js.map +0 -1
  35. package/dist/chunks/generate.runtime-KrQk7mqG.js.map +0 -1
  36. package/dist/chunks/root-layout.svelte-CsJ2QJYi.js +0 -93
  37. package/dist/chunks/root-layout.svelte-CsJ2QJYi.js.map +0 -1
@@ -0,0 +1,53 @@
1
+ import { t as e } from "./ts-morph-helpers-CHI9wAil.js";
2
+ import { t } from "./svelte-file-Dv5-bl79.js";
3
+ import n from "node:fs";
4
+ //#region src/patterns/enable/payments/modifies/modify-nav-user.ts
5
+ var r = [
6
+ "import CreditCardIcon from '@lucide/svelte/icons/credit-card';",
7
+ "",
8
+ "// Add to your navUser array:",
9
+ "{ title: 'Billing', url: '/billing', icon: CreditCardIcon }"
10
+ ].join("\n"), i = [
11
+ "Add a Billing nav item to nav-user.svelte:",
12
+ "",
13
+ r
14
+ ].join("\n"), a = [
15
+ "Create nav-user.svelte with a Billing entry:",
16
+ "",
17
+ r
18
+ ].join("\n");
19
+ function o(n, r, i, a, o) {
20
+ let s = new t(n), c = !1, l = (t) => {
21
+ c || t((t) => {
22
+ let n = e(t, r, i, a, o);
23
+ return n.wasAdded && (c = !0), n.source;
24
+ });
25
+ };
26
+ return l((e) => s.modifyModuleScript(e)), c || l((e) => s.modifyScript(e)), {
27
+ newNavUserSnippet: s.toString(),
28
+ wasAdded: c
29
+ };
30
+ }
31
+ function s(e) {
32
+ if (!n.existsSync(e)) return {
33
+ status: "not-found",
34
+ message: a
35
+ };
36
+ let t = n.readFileSync(e, "utf8");
37
+ if (t.includes("/billing")) return {
38
+ status: "success",
39
+ changed: !1
40
+ };
41
+ let { newNavUserSnippet: r, wasAdded: s } = o(t, "Billing", "/billing", "CreditCardIcon", "@lucide/svelte/icons/credit-card");
42
+ return s ? (n.writeFileSync(e, r, "utf8"), {
43
+ status: "success",
44
+ changed: !0
45
+ }) : {
46
+ status: "failed",
47
+ message: i
48
+ };
49
+ }
50
+ //#endregion
51
+ export { s as n, o as t };
52
+
53
+ //# sourceMappingURL=modify-nav-user-iUpv2lm-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modify-nav-user-iUpv2lm-.js","names":["addNavItemToScript","fs","BILLING_NAV_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","addItemToNavUser","file","SvelteFile","navUserSnippet","wasAdded","tryAdd","run","result","source","title","url","icon","iconImportPath","fn","modifyNavUser","navUserPath","newNavUserSnippet"],"sources":["../../src/patterns/enable/payments/modifies/modify-nav-user.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BILLING_NAV_SNIPPET = [\n \"import CreditCardIcon from '@lucide/svelte/icons/credit-card';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'Billing', url: '/billing', icon: CreditCardIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add a Billing nav item to nav-user.svelte:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with a Billing entry:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Billing\",\n \"/billing\",\n \"CreditCardIcon\",\n \"@lucide/svelte/icons/credit-card\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;;;AAKA,IAAME,IAAsB;CAC1B;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAELC,IAAe;CACnB;CACA;CACAD;AACF,CAAC,CAAC,KAAK,IAAI,GAELE,IAAiB;CACrB;CACA;CACAF;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgBG,EACd,GACA,GACA,GACA,GACA,GACkD;CAClD,IAAMC,IAAO,IAAIC,EAAWC,CAAc,GACtCC,IAAW,IAETC,KAAU,MAAgD;EAC9D,AAAID,KACJE,GAAK,MAAW;GACd,IAAMC,IAASZ,EACba,GACAC,GACAC,GACAC,GACAC,CACF;GAEA,OADIL,EAAO,aAAU,IAAW,KACzBA,EAAO;EAChB,CAAC;CACH;CAKA,OAHAF,GAAQ,MAAOJ,EAAK,mBAAmBY,CAAE,CAAC,GACrCT,KAAUC,GAAQ,MAAOJ,EAAK,aAAaY,CAAE,CAAC,GAE5C;EAAE,mBAAmBZ,EAAK,SAAS;EAAG;CAAS;AACxD;AAEA,SAAgBa,EAAc,GAAoC;CAChE,IAAI,CAAClB,EAAG,WAAWmB,CAAW,GAC5B,OAAO;EAAE,QAAQ;EAAa,SAAShB;CAAe;CAGxD,IAAMI,IAAiBP,EAAG,aAAamB,GAAa,MAAM;CAC1D,IAAIZ,EAAe,SAAS,UAAU,GACpC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,EAAE,sBAAmB,gBAAaH,EACtCG,GACA,WACA,YACA,kBACA,kCACF;CAOA,OALKC,KAILR,EAAG,cAAcmB,GAAaC,GAAmB,MAAM,GAChD;EAAE,QAAQ;EAAW,SAAS;CAAK,KAJjC;EAAE,QAAQ;EAAU,SAASlB;CAAa;AAKrD"}
@@ -0,0 +1,302 @@
1
+ import { r as e } from "./lib-specifier-Cngo1zF_.js";
2
+ import { t } from "./dedent-Gq6Krl4n.js";
3
+ import { t as n } from "./taggedTemplateLiteral-KSUnuvOk.js";
4
+ import { _ as r, a as i, d as a, g as o, i as s, n as c, o as l, p as u, r as d, u as f } from "./ts-morph-helpers-CHI9wAil.js";
5
+ import { t as p } from "./svelte-file-Dv5-bl79.js";
6
+ import { n as m, t as h } from "./compose-handle-BBlamPfx.js";
7
+ import { a as g, c as _, i as v, l as y, r as b, s as x } from "./load-function-Dmkhg1pQ.js";
8
+ import S from "node:fs";
9
+ import C from "node:path";
10
+ import { Node as w, Project as T, QuoteKind as E } from "ts-morph";
11
+ //#region src/patterns/enable/payments/modifies/hooks.server.ts
12
+ var D = "handleCurrency", O = "#lib/currency.server.js", k = t`
13
+ Compose the currency handle into your exported handle:
14
+
15
+ import { sequence } from '@sveltejs/kit/hooks';
16
+ import { handleCurrency } from '#lib/currency.server.js';
17
+
18
+ export const handle = sequence(handleCurrency, /* your existing handle */);
19
+ `, A = t`
20
+ import { handleCurrency } from '#lib/currency.server.js';
21
+
22
+ export const handle = handleCurrency;
23
+ `;
24
+ function j() {
25
+ return new T({
26
+ compilerOptions: { allowJs: !0 },
27
+ manipulationSettings: { quoteKind: E.Single }
28
+ });
29
+ }
30
+ function M(e) {
31
+ if (!S.existsSync(e)) return S.existsSync(e.replace(/\.ts$/, ".js")) ? {
32
+ status: "failed",
33
+ message: k
34
+ } : (S.mkdirSync(C.dirname(e), { recursive: !0 }), S.writeFileSync(e, A + "\n"), {
35
+ status: "success",
36
+ changed: !0
37
+ });
38
+ let t = S.readFileSync(e, "utf8");
39
+ if (t.includes(D)) return {
40
+ status: "success",
41
+ changed: !1
42
+ };
43
+ let n = j().addSourceFileAtPath(e);
44
+ if (h(n, { expression: D }).status === "unsupported") return {
45
+ status: "failed",
46
+ message: k
47
+ };
48
+ s(n, O, D), l(n);
49
+ let r = n.getFullText();
50
+ return S.writeFileSync(e, r, "utf8"), {
51
+ status: "success",
52
+ changed: r !== t
53
+ };
54
+ }
55
+ function N(t) {
56
+ if (!S.existsSync(t)) return {
57
+ status: "success",
58
+ changed: !1
59
+ };
60
+ let n = S.readFileSync(t, "utf8");
61
+ if (!n.includes(D)) return {
62
+ status: "success",
63
+ changed: !1
64
+ };
65
+ let r = j().addSourceFileAtPath(t);
66
+ if (m(r, D).status === "unsupported") return {
67
+ status: "failed",
68
+ message: `Remove ${D} from the handle chain in src/hooks.server.ts and its import from '${O}'.`
69
+ };
70
+ a(r, e("currency.server.js"), D), c(r), l(r);
71
+ let i = r.getFullText();
72
+ return S.writeFileSync(t, i, "utf8"), {
73
+ status: "success",
74
+ changed: i !== n
75
+ };
76
+ }
77
+ //#endregion
78
+ //#region src/patterns/enable/payments/modifies/layout.server.ts
79
+ var P = "#lib/currency.server.js", F = ["currency", "rates"], I = t`
80
+ Return the visitor's currency and the day's rates from the root +layout.server.ts load:
81
+
82
+ import { displayRates } from '#lib/currency.server.js';
83
+
84
+ export const load = async ({ locals }) => {
85
+ return {
86
+ currency: locals.currency,
87
+ rates: await displayRates(locals.currency)
88
+ };
89
+ };
90
+
91
+ The load has to be async with a single, final return of an object literal.
92
+ `;
93
+ function L(e) {
94
+ if (!S.existsSync(e)) return {
95
+ status: "not-found",
96
+ message: I
97
+ };
98
+ let t = S.readFileSync(e, "utf8");
99
+ if (t.includes("displayRates(")) return {
100
+ status: "success",
101
+ changed: !1
102
+ };
103
+ let n = _().addSourceFileAtPath(e), r = v(n);
104
+ if (!r) return {
105
+ status: "failed",
106
+ message: I
107
+ };
108
+ let i = r.getBody();
109
+ if (!i || !w.isBlock(i) || !r.isAsync()) return {
110
+ status: "failed",
111
+ message: I
112
+ };
113
+ let a = x(r);
114
+ if (a.kind === "unsupported") return {
115
+ status: "failed",
116
+ message: I
117
+ };
118
+ let o = b(r, i), c = o && y(o);
119
+ if (!o || !c) return {
120
+ status: "failed",
121
+ message: I
122
+ };
123
+ let u = "locals";
124
+ if (a.kind === "identifier") u = `${a.name}.locals`;
125
+ else if (a.kind === "binding") {
126
+ if (!a.pattern.getElements().map((e) => e.getName()).includes("locals")) {
127
+ let e = a.pattern.getElements().map((e) => e.getText());
128
+ a.pattern.replaceWithText(`{ ${[...e, "locals"].join(", ")} }`);
129
+ }
130
+ } else r.addParameter({ name: "{ locals }" });
131
+ g(c, "currency") || c.addPropertyAssignment({
132
+ name: "currency",
133
+ initializer: `${u}.currency`
134
+ }), g(c, "rates") || c.addPropertyAssignment({
135
+ name: "rates",
136
+ initializer: `await displayRates(${u}.currency)`
137
+ }), s(n, P, "displayRates"), l(n);
138
+ let d = n.getFullText();
139
+ return S.writeFileSync(e, d, "utf8"), {
140
+ status: "success",
141
+ changed: d !== t
142
+ };
143
+ }
144
+ function R(t) {
145
+ if (!S.existsSync(t)) return {
146
+ status: "success",
147
+ changed: !1
148
+ };
149
+ let n = S.readFileSync(t, "utf8");
150
+ if (!n.includes("displayRates(")) return {
151
+ status: "success",
152
+ changed: !1
153
+ };
154
+ let r = _().addSourceFileAtPath(t), i = v(r), s = i?.getBody(), u = i && s && w.isBlock(s) ? b(i, s) : null, d = u && y(u);
155
+ if (!d) return {
156
+ status: "failed",
157
+ message: `Remove currency and rates from the root +layout.server.ts load and the import from '${P}'.`
158
+ };
159
+ for (let e of F) d.getProperty(e)?.remove();
160
+ a(r, e("currency.server.js"), "displayRates"), o(r, "locals"), c(r), l(r);
161
+ let f = r.getFullText();
162
+ return S.writeFileSync(t, f, "utf8"), {
163
+ status: "success",
164
+ changed: f !== n
165
+ };
166
+ }
167
+ //#endregion
168
+ //#region src/patterns/enable/payments/modifies/layout.svelte.ts
169
+ var z, B = "currency.hydrate(data.currency, data.rates);", V = t(z ||= n(["\n Start the currency store from the layout's data in src/routes/+layout.svelte:\n\n <script lang=\"ts\">\n import { currency } from '#lib/currency.svelte.js';\n\n let { data, children } = $props();\n currency.hydrate(data.currency, data.rates);\n <\/script>\n"]));
170
+ function H(e) {
171
+ if (!S.existsSync(e)) return {
172
+ status: "not-found",
173
+ message: V
174
+ };
175
+ let t = p.fromPath(e);
176
+ return t.toString().includes("currency.hydrate(") ? {
177
+ status: "success",
178
+ changed: !1
179
+ } : t.getScript() ? (t.modifyScript((e) => {
180
+ let { source: t } = r(e, (e) => {
181
+ d(e, [{
182
+ namedImports: ["currency"],
183
+ moduleSpecifier: "#lib/currency.svelte.js"
184
+ }]), i(e, "data");
185
+ let t = e.getVariableStatements().find((e) => e.getText().includes("$props()"));
186
+ t ? e.insertStatements(t.getChildIndex() + 1, B) : e.addStatements(B);
187
+ });
188
+ return t;
189
+ }), t.writeTo(e), {
190
+ status: "success",
191
+ changed: t.hasChanged()
192
+ }) : {
193
+ status: "failed",
194
+ message: V
195
+ };
196
+ }
197
+ function U(t) {
198
+ if (!S.existsSync(t) || !S.readFileSync(t, "utf8").includes("currency.hydrate(")) return {
199
+ status: "success",
200
+ changed: !1
201
+ };
202
+ let n = p.fromPath(t), i = n.toString().replace(/<script[\s\S]*?<\/script>/g, "");
203
+ return n.modifyScript((t) => {
204
+ let { source: n } = r(t, (t) => {
205
+ for (let e of t.getStatements()) e.getText().includes("currency.hydrate(") && e.remove();
206
+ f(t, e("currency.svelte.js")), u(t, "data", i), c(t);
207
+ });
208
+ return n;
209
+ }), n.writeTo(t), {
210
+ status: "success",
211
+ changed: n.hasChanged()
212
+ };
213
+ }
214
+ //#endregion
215
+ //#region src/patterns/enable/payments/modifies/root-layout.svelte.ts
216
+ function W(e) {
217
+ return `<Navbar.Item>\n${e}\t<CurrencySelect />\n${e}</Navbar.Item>\n${e}`;
218
+ }
219
+ var G = W(" "), K = t`
220
+ import CurrencySelect from '#lib/components/currency-select.svelte';
221
+ `, q = [
222
+ "Add the currency select inside your <Navbar.List> in the root layout.",
223
+ "",
224
+ "Import to add to the <script> tag:",
225
+ "",
226
+ K,
227
+ "",
228
+ "Markup to add at the end of <Navbar.List>, after the language select if there is one:",
229
+ G
230
+ ].join("\n"), J = [
231
+ "Create a root layout that includes a currency select inside <Navbar.List>.",
232
+ "",
233
+ "Import for the <script> tag:",
234
+ "",
235
+ K,
236
+ "",
237
+ "Markup at the end of <Navbar.List>:",
238
+ G
239
+ ].join("\n");
240
+ function Y(e) {
241
+ if (!S.existsSync(e)) return {
242
+ status: "not-found",
243
+ message: J
244
+ };
245
+ let t = p.fromPath(e);
246
+ if (t.hasElement("CurrencySelect")) return {
247
+ status: "success",
248
+ changed: !1
249
+ };
250
+ if (!t.hasElement("Navbar.List")) return {
251
+ status: "failed",
252
+ message: q
253
+ };
254
+ let n = t.findElementContaining("Navbar.Item", "LanguageSelect");
255
+ if (n) t.insertAfterElement(n, "<Navbar.Item>\n <CurrencySelect />\n</Navbar.Item>");
256
+ else {
257
+ let e = /^([ \t]*)<\/Navbar\.List>/m.exec(t.toString())?.[1] ?? " ", n = `\t<Navbar.Item>\n${e}\t\t<CurrencySelect />\n${e}\t</Navbar.Item>\n${e}`;
258
+ if (!t.insertBeforeClosingTag("Navbar.List", n)) return {
259
+ status: "failed",
260
+ message: q
261
+ };
262
+ }
263
+ return t.modifyScript((e) => {
264
+ let { source: t } = r(e, (e) => {
265
+ d(e, [{
266
+ defaultImport: "CurrencySelect",
267
+ moduleSpecifier: "#lib/components/currency-select.svelte"
268
+ }]);
269
+ });
270
+ return t;
271
+ }), t.writeTo(e), {
272
+ status: "success",
273
+ changed: t.hasChanged()
274
+ };
275
+ }
276
+ function X(t) {
277
+ if (!S.existsSync(t)) return {
278
+ status: "success",
279
+ changed: !1
280
+ };
281
+ let n = S.readFileSync(t, "utf8");
282
+ if (!n.includes("CurrencySelect")) return {
283
+ status: "success",
284
+ changed: !1
285
+ };
286
+ let i = p.fromPath(t);
287
+ i.modifyScript((t) => {
288
+ let { source: n } = r(t, (t) => {
289
+ f(t, e("components/currency-select.svelte")), c(t);
290
+ });
291
+ return n;
292
+ });
293
+ let a = i.toString();
294
+ return a = a.replace(/[ \t]*<Navbar\.Item>\s*<CurrencySelect\s*\/>\s*<\/Navbar\.Item>[ \t]*\r?\n?/g, ""), a = a.replace(/[ \t]*<CurrencySelect\s*\/>[ \t]*\r?\n?/g, ""), S.writeFileSync(t, a, "utf8"), {
295
+ status: "success",
296
+ changed: a !== n
297
+ };
298
+ }
299
+ //#endregion
300
+ export { L as a, N as c, U as i, X as n, R as o, H as r, M as s, Y as t };
301
+
302
+ //# sourceMappingURL=root-layout.svelte-CUVbnlX-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-layout.svelte-CUVbnlX-.js","names":["MODULE","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","libModule","_taggedTemplateLiteral","withInMemoryScript","ensurePropsBinding","removeNamedImportIfUnused","removeUnusedBindingElement","ensureNamedImport","ensureBlankLineAfterImports","formatLikeSource","removePropsBindingIfUnused","ensureImports","removeImportByModuleSpecifier","SvelteFile","removeHandle","addHandle","hasProperty","newProject","findLoadFunction","returnedObject","findFinalReturn","inspectEventParameter","fs","path","HANDLE","MODULE$1","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","project","Project","QuoteKind","modifyHooksServerCurrency","hooksServerPath","original","sourceFile","updated","unmodifyHooksServerCurrency","MODULE","PROPERTIES","FAILURE_HINT$2","modifyLayoutServerCurrency","layoutServerPath","fn","body","Node","event","returned","object","locals","texts","unmodifyLayoutServerCurrency","name","_templateObject","STATEMENT","FAILURE_HINT$1","dedent","modifyLayoutSvelteCurrency","layoutPath","file","out","source","sf","props","statement","unmodifyLayoutSvelteCurrency","markup","snippet","indent","SNIPPET","IMPORT","FAILURE_HINT","NOT_FOUND_HINT","modifyRootLayoutCurrencySelect","language","item","unmodifyRootLayoutCurrencySelect"],"sources":["../../src/patterns/enable/payments/modifies/hooks.server.ts","../../src/patterns/enable/payments/modifies/layout.server.ts","../../src/patterns/enable/payments/modifies/layout.svelte.ts","../../src/patterns/enable/payments/modifies/root-layout.svelte.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle, removeHandle } from \"../../../../runtime/compose-handle\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n formatLikeSource,\n removeNamedImportIfUnused,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst HANDLE = \"handleCurrency\";\nconst MODULE = \"#lib/currency.server.js\";\n\nconst FAILURE_HINT = dedent`\n Compose the currency handle into your exported handle:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { handleCurrency } from '#lib/currency.server.js';\n\n export const handle = sequence(handleCurrency, /* your existing handle */);\n`;\n\nconst HOOKS_SERVER_SNIPPET = dedent`\n import { handleCurrency } from '#lib/currency.server.js';\n\n export const handle = handleCurrency;\n`;\n\nfunction project(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\n/**\n * `handleCurrency` joins the server handle chain so every request knows the\n * currency its visitor reads prices in. Creates `hooks.server.ts` when the\n * project has none.\n */\nexport function modifyHooksServerCurrency(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(HANDLE)) return { status: \"success\", changed: false };\n\n const sourceFile = project().addSourceFileAtPath(hooksServerPath);\n // Composed first: an unsupported handle leaves the file untouched.\n const composed = addHandle(sourceFile, { expression: HANDLE });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n ensureNamedImport(sourceFile, MODULE, HANDLE);\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(hooksServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n\n/** Take `handleCurrency` back out of the chain, and its import with it. */\nexport function unmodifyHooksServerCurrency(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(HANDLE)) return { status: \"success\", changed: false };\n\n const sourceFile = project().addSourceFileAtPath(hooksServerPath);\n const removed = removeHandle(sourceFile, HANDLE);\n if (removed.status === \"unsupported\") {\n return {\n status: \"failed\",\n message: `Remove ${HANDLE} from the handle chain in src/hooks.server.ts and its import from '${MODULE}'.`,\n };\n }\n removeNamedImportIfUnused(\n sourceFile,\n libModule(\"currency.server.js\"),\n HANDLE,\n );\n ensureBlankLineAfterImports(sourceFile);\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(hooksServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n findFinalReturn,\n findLoadFunction,\n hasProperty,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"../../../../runtime/load-function\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n formatLikeSource,\n removeNamedImportIfUnused,\n removeUnusedBindingElement,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst MODULE = \"#lib/currency.server.js\";\nconst PROPERTIES = [\"currency\", \"rates\"] as const;\n\nconst FAILURE_HINT = dedent`\n Return the visitor's currency and the day's rates from the root +layout.server.ts load:\n\n import { displayRates } from '#lib/currency.server.js';\n\n export const load = async ({ locals }) => {\n \treturn {\n \t\tcurrency: locals.currency,\n \t\trates: await displayRates(locals.currency)\n \t};\n };\n\n The load has to be async with a single, final return of an object literal.\n`;\n\n/**\n * The root `+layout.server.ts` returns `currency` (what `handleCurrency`\n * resolved) and `rates` (the day's, when it isn't the business's own), so the\n * root layout can start the store before anything renders.\n *\n * A load that isn't async, has no final object-literal return, or receives\n * its event in a way the helpers can't extend is reported as `failed` with\n * the snippet to paste, and the file is left exactly as it was.\n */\nexport function modifyLayoutServerCurrency(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"not-found\", message: FAILURE_HINT };\n }\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (original.includes(\"displayRates(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"failed\", message: FAILURE_HINT };\n const body = fn.getBody();\n if (!body || !Node.isBlock(body) || !fn.isAsync()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const returned = findFinalReturn(fn, body);\n const object = returned && returnedObject(returned);\n if (!returned || !object) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // Where `locals` comes from: the destructured parameter, the event's\n // property, or a parameter added for it.\n let locals = \"locals\";\n if (event.kind === \"identifier\") {\n locals = `${event.name}.locals`;\n } else if (event.kind === \"binding\") {\n const names = event.pattern.getElements().map((e) => e.getName());\n if (!names.includes(\"locals\")) {\n const texts = event.pattern.getElements().map((e) => e.getText());\n event.pattern.replaceWithText(`{ ${[...texts, \"locals\"].join(\", \")} }`);\n }\n } else {\n fn.addParameter({ name: \"{ locals }\" });\n }\n\n // After any spread, so nothing in it can shadow these.\n if (!hasProperty(object, \"currency\")) {\n object.addPropertyAssignment({\n name: \"currency\",\n initializer: `${locals}.currency`,\n });\n }\n if (!hasProperty(object, \"rates\")) {\n object.addPropertyAssignment({\n name: \"rates\",\n initializer: `await displayRates(${locals}.currency)`,\n });\n }\n ensureNamedImport(sourceFile, MODULE, \"displayRates\");\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n\n/** Take `currency` and `rates` back out of the root layout's data. */\nexport function unmodifyLayoutServerCurrency(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"displayRates(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n const fn = findLoadFunction(sourceFile);\n const body = fn?.getBody();\n const returned =\n fn && body && Node.isBlock(body) ? findFinalReturn(fn, body) : null;\n const object = returned && returnedObject(returned);\n if (!object) {\n return {\n status: \"failed\",\n message: `Remove currency and rates from the root +layout.server.ts load and the import from '${MODULE}'.`,\n };\n }\n for (const name of PROPERTIES) {\n object.getProperty(name)?.remove();\n }\n removeNamedImportIfUnused(\n sourceFile,\n libModule(\"currency.server.js\"),\n \"displayRates\",\n );\n removeUnusedBindingElement(sourceFile, \"locals\");\n ensureBlankLineAfterImports(sourceFile);\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureImports,\n ensurePropsBinding,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst STATEMENT = \"currency.hydrate(data.currency, data.rates);\";\n\nconst FAILURE_HINT = dedent`\n Start the currency store from the layout's data in src/routes/+layout.svelte:\n\n <script lang=\"ts\">\n \timport { currency } from '#lib/currency.svelte.js';\n\n \tlet { data, children } = $props();\n \tcurrency.hydrate(data.currency, data.rates);\n </script>\n`;\n\n/**\n * The root `+layout.svelte` hands the store what the server resolved, before\n * any child renders: the first render already shows the visitor's currency,\n * on the server and in the browser alike.\n */\nexport function modifyLayoutSvelteCurrency(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: FAILURE_HINT };\n }\n const file = SvelteFile.fromPath(layoutPath);\n if (file.toString().includes(\"currency.hydrate(\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) return { status: \"failed\", message: FAILURE_HINT };\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"currency\"],\n moduleSpecifier: \"#lib/currency.svelte.js\",\n },\n ]);\n ensurePropsBinding(sf, \"data\");\n // Right after the props, which it reads.\n const props = sf\n .getVariableStatements()\n .find((statement) => statement.getText().includes(\"$props()\"));\n if (props) {\n sf.insertStatements(props.getChildIndex() + 1, STATEMENT);\n } else {\n sf.addStatements(STATEMENT);\n }\n });\n return out;\n });\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n\n/** Take the hydration back out, and the import and `data` prop if nothing else reads them. */\nexport function unmodifyLayoutSvelteCurrency(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"currency.hydrate(\")) {\n return { status: \"success\", changed: false };\n }\n const file = SvelteFile.fromPath(layoutPath);\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const statement of sf.getStatements()) {\n if (statement.getText().includes(\"currency.hydrate(\"))\n statement.remove();\n }\n removeImportByModuleSpecifier(sf, libModule(\"currency.svelte.js\"));\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** The item, indented like the list it joins; `indent` is the list's closing tag's. */\nfunction snippet(indent: string): string {\n return `<Navbar.Item>\\n${indent}\\t<CurrencySelect />\\n${indent}</Navbar.Item>\\n${indent}`;\n}\n\nconst SNIPPET = snippet(\"\\t\\t\\t\");\n\nconst IMPORT = dedent`\n import CurrencySelect from '#lib/components/currency-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the currency select inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT,\n \"\",\n \"Markup to add at the end of <Navbar.List>, after the language select if there is one:\",\n SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes a currency select inside <Navbar.List>.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT,\n \"\",\n \"Markup at the end of <Navbar.List>:\",\n SNIPPET,\n].join(\"\\n\");\n\n/**\n * The currency select goes in the navbar beside the language select, when\n * there is one, else as the last item. It renders nothing until the business\n * offers a second currency, so the layout gains it with payments.\n */\nexport function modifyRootLayoutCurrencySelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"CurrencySelect\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const language = file.findElementContaining(\"Navbar.Item\", \"LanguageSelect\");\n if (language) {\n // On the line after the language select's item; the helper indents it.\n file.insertAfterElement(\n language,\n \"<Navbar.Item>\\n\\t<CurrencySelect />\\n</Navbar.Item>\",\n );\n } else {\n // The closing tag's own indentation already precedes the insertion point,\n // so the item starts one level in and hands that indentation back.\n const indent =\n /^([ \\t]*)<\\/Navbar\\.List>/m.exec(file.toString())?.[1] ?? \"\\t\\t\";\n const item = `\\t<Navbar.Item>\\n${indent}\\t\\t<CurrencySelect />\\n${indent}\\t</Navbar.Item>\\n${indent}`;\n if (!file.insertBeforeClosingTag(\"Navbar.List\", item))\n return { status: \"failed\", message: FAILURE_HINT };\n }\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"CurrencySelect\",\n moduleSpecifier: \"#lib/components/currency-select.svelte\",\n },\n ]);\n });\n return out;\n });\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n\n/** Take the currency select (and the nav item around it) back out. */\nexport function unmodifyRootLayoutCurrencySelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"CurrencySelect\")) {\n return { status: \"success\", changed: false };\n }\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/currency-select.svelte\"),\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n let updated = file.toString();\n updated = updated.replace(\n /[ \\t]*<Navbar\\.Item>\\s*<CurrencySelect\\s*\\/>\\s*<\\/Navbar\\.Item>[ \\t]*\\r?\\n?/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<CurrencySelect\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n"],"mappings":";;;;;;;;;;;AAcA,IAAM2B,IAAS,kBACT3B,IAAS,2BAETC,IAAe,CAAM;;;;;;;GASrB6B,IAAuB,CAAM;;;;;AAMnC,SAASC,IAAmB;CAC1B,OAAO,IAAIC,EAAQ;EACjB,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CAAC;AACH;AAOA,SAAgBC,EACd,GACe;CACf,IAAI,CAACT,EAAG,WAAWU,CAAe,GAQhC,OALIV,EAAG,WAAWU,EAAgB,QAAQ,SAAS,KAAK,CAAC,IAChD;EAAE,QAAQ;EAAU,SAASlC;CAAa,KAEnDwB,EAAG,UAAUC,EAAK,QAAQS,CAAe,GAAG,EAAE,WAAW,GAAK,CAAC,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EAAW,SAASA,MAAYF;CAAS;AAC5D"}
package/dist/index.d.ts CHANGED
@@ -843,6 +843,43 @@ export declare const byCategory: Record<"auth" | "api" | "backend" | "i18n" | "p
843
843
  tests: number;
844
844
  baseline: "velastack";
845
845
  generate: typeof generate;
846
+ } | {
847
+ version: string;
848
+ slug: "enable-orders";
849
+ source: string;
850
+ docs: string;
851
+ plan: "pro";
852
+ title: string;
853
+ summary: string;
854
+ requires: {
855
+ auth: false;
856
+ api: false;
857
+ apiKeys: false;
858
+ backend: true;
859
+ i18n: false;
860
+ teams: false;
861
+ payments: true;
862
+ blog: false;
863
+ contentNegotiation: false;
864
+ cms: false;
865
+ workflows: true;
866
+ ecommerce: true;
867
+ ui: "shadcn";
868
+ providers: {
869
+ payments: string[];
870
+ };
871
+ };
872
+ category: "payments";
873
+ tags: string[];
874
+ command: {
875
+ raw: string;
876
+ base: string;
877
+ argv: never[];
878
+ };
879
+ examples: never[];
880
+ tests: number;
881
+ baseline: "velastack";
882
+ generate: typeof generate;
846
883
  } | {
847
884
  version: string;
848
885
  slug: "enable-teams";
@@ -1435,7 +1472,7 @@ export declare const byCategory: Record<"auth" | "api" | "backend" | "i18n" | "p
1435
1472
  contentNegotiation: false;
1436
1473
  cms: false;
1437
1474
  };
1438
- blockedBy: "ecommerce"[];
1475
+ blockedBy: ("ecommerce" | "subscriptions" | "orders")[];
1439
1476
  category: "payments";
1440
1477
  tags: string[];
1441
1478
  command: {
@@ -1468,6 +1505,7 @@ export declare const byCategory: Record<"auth" | "api" | "backend" | "i18n" | "p
1468
1505
  cms: false;
1469
1506
  ecommerce: true;
1470
1507
  };
1508
+ blockedBy: "orders"[];
1471
1509
  category: "payments";
1472
1510
  tags: string[];
1473
1511
  command: {
@@ -1513,6 +1551,37 @@ export declare const byCategory: Record<"auth" | "api" | "backend" | "i18n" | "p
1513
1551
  tests: number;
1514
1552
  baseline: "velastack";
1515
1553
  generate: typeof generate;
1554
+ } | {
1555
+ version: string;
1556
+ slug: "disable-orders";
1557
+ source: string;
1558
+ docs: string;
1559
+ plan: "pro";
1560
+ title: string;
1561
+ summary: string;
1562
+ requires: {
1563
+ auth: false;
1564
+ api: false;
1565
+ apiKeys: false;
1566
+ backend: false;
1567
+ i18n: false;
1568
+ teams: false;
1569
+ payments: false;
1570
+ blog: false;
1571
+ contentNegotiation: false;
1572
+ cms: false;
1573
+ };
1574
+ category: "payments";
1575
+ tags: string[];
1576
+ command: {
1577
+ raw: string;
1578
+ base: string;
1579
+ argv: never[];
1580
+ };
1581
+ examples: never[];
1582
+ tests: number;
1583
+ baseline: "velastack";
1584
+ generate: typeof generate;
1516
1585
  } | {
1517
1586
  version: string;
1518
1587
  slug: "disable-whatsapp";
@@ -1723,6 +1792,22 @@ declare interface Features {
1723
1792
  * the `requires` of patterns need not mention it.
1724
1793
  */
1725
1794
  ecommerce?: boolean;
1795
+ /**
1796
+ * In-app notifications (`src/lib/server/notifications.ts`, from
1797
+ * `enable-notifications`). Optional so the `requires` of patterns need not
1798
+ * mention it.
1799
+ */
1800
+ notifications?: boolean;
1801
+ /**
1802
+ * Stripe subscriptions (`enable-subscriptions`), detected by its sync
1803
+ * workflow. Optional so the `requires` of patterns need not mention it.
1804
+ */
1805
+ subscriptions?: boolean;
1806
+ /**
1807
+ * Orders recorded from Stripe Checkout (`enable-orders`), detected by its
1808
+ * webhook handlers. Optional so the `requires` of patterns need not mention it.
1809
+ */
1810
+ orders?: boolean;
1726
1811
  /**
1727
1812
  * The component kit the project has: `shadcn` is shadcn-svelte (a
1728
1813
  * `components.json` plus the package), `plain` is neither. Detected by the
@@ -2840,6 +2925,43 @@ export declare const patterns: ({
2840
2925
  tests: number;
2841
2926
  baseline: "velastack";
2842
2927
  generate: typeof generate;
2928
+ } | {
2929
+ version: string;
2930
+ slug: "enable-orders";
2931
+ source: string;
2932
+ docs: string;
2933
+ plan: "pro";
2934
+ title: string;
2935
+ summary: string;
2936
+ requires: {
2937
+ auth: false;
2938
+ api: false;
2939
+ apiKeys: false;
2940
+ backend: true;
2941
+ i18n: false;
2942
+ teams: false;
2943
+ payments: true;
2944
+ blog: false;
2945
+ contentNegotiation: false;
2946
+ cms: false;
2947
+ workflows: true;
2948
+ ecommerce: true;
2949
+ ui: "shadcn";
2950
+ providers: {
2951
+ payments: string[];
2952
+ };
2953
+ };
2954
+ category: "payments";
2955
+ tags: string[];
2956
+ command: {
2957
+ raw: string;
2958
+ base: string;
2959
+ argv: never[];
2960
+ };
2961
+ examples: never[];
2962
+ tests: number;
2963
+ baseline: "velastack";
2964
+ generate: typeof generate;
2843
2965
  } | {
2844
2966
  version: string;
2845
2967
  slug: "enable-teams";
@@ -3432,7 +3554,7 @@ export declare const patterns: ({
3432
3554
  contentNegotiation: false;
3433
3555
  cms: false;
3434
3556
  };
3435
- blockedBy: "ecommerce"[];
3557
+ blockedBy: ("ecommerce" | "subscriptions" | "orders")[];
3436
3558
  category: "payments";
3437
3559
  tags: string[];
3438
3560
  command: {
@@ -3465,6 +3587,7 @@ export declare const patterns: ({
3465
3587
  cms: false;
3466
3588
  ecommerce: true;
3467
3589
  };
3590
+ blockedBy: "orders"[];
3468
3591
  category: "payments";
3469
3592
  tags: string[];
3470
3593
  command: {
@@ -3510,6 +3633,37 @@ export declare const patterns: ({
3510
3633
  tests: number;
3511
3634
  baseline: "velastack";
3512
3635
  generate: typeof generate;
3636
+ } | {
3637
+ version: string;
3638
+ slug: "disable-orders";
3639
+ source: string;
3640
+ docs: string;
3641
+ plan: "pro";
3642
+ title: string;
3643
+ summary: string;
3644
+ requires: {
3645
+ auth: false;
3646
+ api: false;
3647
+ apiKeys: false;
3648
+ backend: false;
3649
+ i18n: false;
3650
+ teams: false;
3651
+ payments: false;
3652
+ blog: false;
3653
+ contentNegotiation: false;
3654
+ cms: false;
3655
+ };
3656
+ category: "payments";
3657
+ tags: string[];
3658
+ command: {
3659
+ raw: string;
3660
+ base: string;
3661
+ argv: never[];
3662
+ };
3663
+ examples: never[];
3664
+ tests: number;
3665
+ baseline: "velastack";
3666
+ generate: typeof generate;
3513
3667
  } | {
3514
3668
  version: string;
3515
3669
  slug: "disable-whatsapp";