@velastack/patterns 0.0.36 → 0.0.38
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/_server-BCbQIYCn.js +6 -0
- package/dist/chunks/_server-BCbQIYCn.js.map +1 -0
- package/dist/chunks/{collections-DcCZ0dam.js → collections-RlxhqXdR.js} +2 -2
- package/dist/chunks/{collections-DcCZ0dam.js.map → collections-RlxhqXdR.js.map} +1 -1
- package/dist/chunks/{env-DfA_NCKk.js → env-CDsRI_A5.js} +1 -1
- package/dist/chunks/{env-DfA_NCKk.js.map → env-CDsRI_A5.js.map} +1 -1
- package/dist/chunks/{env.preview-7Cc9KCgc.js → env.preview-Ds0NigL8.js} +1 -1
- package/dist/chunks/{env.preview-7Cc9KCgc.js.map → env.preview-Ds0NigL8.js.map} +1 -1
- package/dist/chunks/{env.runtime-l1ssTZog.js → env.runtime-BGmr1gQZ.js} +1 -1
- package/dist/chunks/{env.runtime-l1ssTZog.js.map → env.runtime-BGmr1gQZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-mPNuFTCh.js → generate.runtime-7N_86Kl1.js} +6 -6
- package/dist/chunks/{generate.runtime-mPNuFTCh.js.map → generate.runtime-7N_86Kl1.js.map} +1 -1
- package/dist/chunks/{generate.runtime-NdlYevoh.js → generate.runtime-B_NxLFKW.js} +2 -2
- package/dist/chunks/{generate.runtime-NdlYevoh.js.map → generate.runtime-B_NxLFKW.js.map} +1 -1
- package/dist/chunks/generate.runtime-B_Z_225G.js +107 -0
- package/dist/chunks/generate.runtime-B_Z_225G.js.map +1 -0
- package/dist/chunks/generate.runtime-BllWzqI_.js +211 -0
- package/dist/chunks/generate.runtime-BllWzqI_.js.map +1 -0
- package/dist/chunks/{generate.runtime-GmszNklA.js → generate.runtime-C8Wbgx77.js} +2 -2
- package/dist/chunks/{generate.runtime-GmszNklA.js.map → generate.runtime-C8Wbgx77.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bu5bO86n.js → generate.runtime-CFH03New.js} +4 -4
- package/dist/chunks/{generate.runtime-Bu5bO86n.js.map → generate.runtime-CFH03New.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D8DxU99S.js → generate.runtime-CZwuYNbQ.js} +4 -4
- package/dist/chunks/{generate.runtime-D8DxU99S.js.map → generate.runtime-CZwuYNbQ.js.map} +1 -1
- package/dist/chunks/generate.runtime-CdawV-C4.js +309 -0
- package/dist/chunks/generate.runtime-CdawV-C4.js.map +1 -0
- package/dist/chunks/{generate.runtime-eYyscad0.js → generate.runtime-CojXsWmJ.js} +5 -5
- package/dist/chunks/{generate.runtime-eYyscad0.js.map → generate.runtime-CojXsWmJ.js.map} +1 -1
- package/dist/chunks/generate.runtime-CsFOIAEO.js +224 -0
- package/dist/chunks/generate.runtime-CsFOIAEO.js.map +1 -0
- package/dist/chunks/{generate.runtime-CS55berV.js → generate.runtime-DgYEht-Z.js} +3 -3
- package/dist/chunks/{generate.runtime-CS55berV.js.map → generate.runtime-DgYEht-Z.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CKouBODu.js → generate.runtime-DgoCWziW.js} +4 -4
- package/dist/chunks/{generate.runtime-CKouBODu.js.map → generate.runtime-DgoCWziW.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DV9S4KW_.js → generate.runtime-DhbtqZYL.js} +87 -31
- package/dist/chunks/generate.runtime-DhbtqZYL.js.map +1 -0
- package/dist/chunks/generate.runtime-DlJPYj_8.js +135 -0
- package/dist/chunks/generate.runtime-DlJPYj_8.js.map +1 -0
- package/dist/chunks/{generate.runtime-DPbHzukR.js → generate.runtime-DmU6R2Ez.js} +6 -6
- package/dist/chunks/{generate.runtime-DPbHzukR.js.map → generate.runtime-DmU6R2Ez.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BB0XISiq.js → generate.runtime-MNNdJitS.js} +2 -2
- package/dist/chunks/{generate.runtime-BB0XISiq.js.map → generate.runtime-MNNdJitS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D3H_yNZA.js → generate.runtime-mjs_qfUh.js} +3 -3
- package/dist/chunks/{generate.runtime-D3H_yNZA.js.map → generate.runtime-mjs_qfUh.js.map} +1 -1
- package/dist/chunks/{modify-file-Bi-4GRwL.js → modify-file-DGBe3ycw.js} +1 -1
- package/dist/chunks/{modify-file-Bi-4GRwL.js.map → modify-file-DGBe3ycw.js.map} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-B-jnjYqs.js → modify-svelte-config-remote-C-Wl2nk1.js} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-B-jnjYqs.js.map → modify-svelte-config-remote-C-Wl2nk1.js.map} +1 -1
- package/dist/chunks/nav-user-Jp5yYtw5.js +6 -0
- package/dist/chunks/nav-user-Jp5yYtw5.js.map +1 -0
- package/dist/chunks/{pocketbase-CT78tKFG.js → pocketbase-CEhGbssT.js} +1 -1
- package/dist/chunks/{pocketbase-CT78tKFG.js.map → pocketbase-CEhGbssT.js.map} +1 -1
- package/dist/chunks/{pocketbase-BiRWz-OQ.js → pocketbase-D5p0NSdu.js} +1 -1
- package/dist/chunks/{pocketbase-BiRWz-OQ.js.map → pocketbase-D5p0NSdu.js.map} +1 -1
- package/dist/chunks/{shared-D9iYuKxV.js → shared-CG8Qf95D.js} +2 -2
- package/dist/chunks/{shared-D9iYuKxV.js.map → shared-CG8Qf95D.js.map} +1 -1
- package/dist/chunks/{ts-morph-helpers-B0oxeDUU.js → ts-morph-helpers-DjpZhZ7I.js} +10 -1
- package/dist/chunks/ts-morph-helpers-DjpZhZ7I.js.map +1 -0
- package/dist/chunks/{write-result-CRq0kUvL.js → write-result-CjSxx3ZD.js} +2 -2
- package/dist/chunks/{write-result-CRq0kUvL.js.map → write-result-CjSxx3ZD.js.map} +1 -1
- package/dist/index.d.ts +142 -30
- package/dist/index.js +1631 -1249
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/generate.runtime-Bag8x62P.js +0 -37
- package/dist/chunks/generate.runtime-Bag8x62P.js.map +0 -1
- package/dist/chunks/generate.runtime-CVsBIZm4.js +0 -37
- package/dist/chunks/generate.runtime-CVsBIZm4.js.map +0 -1
- package/dist/chunks/generate.runtime-Cy56Ypws.js +0 -215
- package/dist/chunks/generate.runtime-Cy56Ypws.js.map +0 -1
- package/dist/chunks/generate.runtime-DV9S4KW_.js.map +0 -1
- package/dist/chunks/hooks.server-CPVyj3rv.js +0 -75
- package/dist/chunks/hooks.server-CPVyj3rv.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-B0oxeDUU.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-BllWzqI_.js","names":[],"sources":["../../src/patterns/disable/subscriptions/modifies/modify-stripe-hooks.ts","../../src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/disable/subscriptions/modifies/revert-by-template.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/disable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Matches the entire cronAdd(\"stripe-subscriptions\", ...) {...}); block with\n// optional surrounding blank lines. Tolerates single- or double-quoted name\n// and trailing semicolon variants.\nconst SUBSCRIPTION_CRON_RE =\n /\\n*cronAdd\\(\\s*[\"']stripe-subscriptions[\"'][\\s\\S]*?\\}\\s*\\)\\s*;?\\s*\\n?/m;\n\nexport function unmodifyStripeHooks(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"stripe-subscriptions\")) {\n return { status: \"success\", changed: false };\n }\n const next = original.replace(SUBSCRIPTION_CRON_RE, \"\\n\");\n if (next === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst SUBSCRIPTION_CASE_VALUES = new Set([\n '\"customer.subscription.created\"',\n '\"customer.subscription.updated\"',\n '\"customer.subscription.deleted\"',\n]);\n\nexport function unmodifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n const { source } = withInMemoryScript(original, (sf) => {\n removeImportByModuleSpecifier(sf, \"./handlers/subscription/created\");\n removeImportByModuleSpecifier(sf, \"./handlers/subscription/updated\");\n removeImportByModuleSpecifier(sf, \"./handlers/subscription/deleted\");\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n // Collect matching case clauses first — removing invalidates node refs.\n const toRemove = caseBlock\n .getClauses()\n .filter((clause) => {\n if (clause.getKind() !== SyntaxKind.CaseClause) return false;\n const caseClause = clause.asKindOrThrow(SyntaxKind.CaseClause);\n const exprText = caseClause.getExpression().getText();\n return SUBSCRIPTION_CASE_VALUES.has(exprText);\n })\n .map((c) => c.asKindOrThrow(SyntaxKind.CaseClause));\n\n for (const clause of toRemove.reverse()) {\n clause.remove();\n }\n\n sf.formatText();\n });\n\n if (source === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const removed = file.removeAttribute(\"AppSidebar\", \"subscription\");\n if (!removed) {\n return { status: \"success\", changed: false };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { withInMemoryScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nfunction updateScript(source: string): string {\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n const hasSub = elements.some((e) => e.getName() === \"subscription\");\n\n // Strip subscription from the props type literal (the specific type\n // added by enable-subscriptions — leave unrelated `subscription` props\n // alone).\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"))\n .filter((t) => !/^\\s*subscription\\??\\s*:/.test(t));\n lit.replaceWithText(\n propTexts.length ? `{ ${propTexts.join(\"; \")}; }` : \"{}\",\n );\n break;\n }\n }\n\n if (hasSub) {\n const remaining = elements\n .filter((e) => e.getName() !== \"subscription\")\n .map((e) => e.getText());\n pattern.replaceWithText(`{ ${remaining.join(\", \")} }`);\n }\n }\n sf.formatText();\n });\n return out;\n}\n\nexport function unmodifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(filePath, \"utf8\");\n const hasSubPropType = /subscription\\??\\s*:\\s*\\{/.test(source);\n const hasSubProp = /\\bsubscription\\s*=\\s*null\\b/.test(source);\n\n const file = new SvelteFile(source);\n const hasNavUserSubAttr =\n file.hasElement(\"NavUser\") && file.hasAttribute(\"NavUser\", \"subscription\");\n\n if (!hasSubPropType && !hasSubProp && !hasNavUserSubAttr) {\n return { status: \"success\", changed: false };\n }\n\n if (hasSubPropType || hasSubProp) {\n file.modifyScript(updateScript);\n }\n if (hasNavUserSubAttr) {\n file.removeAttribute(\"NavUser\", \"subscription\");\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Rewrites a file to the given `template` if the current content still shows\n * the `enabledMarker` (meaning enable-subscriptions is applied). If the marker\n * is absent (already reverted or never applied), it's a no-op.\n *\n * Strips leading `// [!code highlight:N]` / `<!-- [!code highlight:N] -->`\n * lines so templates can be pulled from `preview-modifies/` directories which\n * use those for documentation highlighting.\n */\nexport function revertByTemplate(\n filePath: string,\n template: string,\n enabledMarker: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (!current.includes(enabledMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(/^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm, \"\");\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import dedent from \"dedent\";\nimport { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Baseline velastack-auth (app)/+layout.server.ts — the state of the file\n// before enable-subscriptions wrapped it with loadActiveSubscription.\nconst BASELINE = dedent`\n export const load = ({ locals }) => {\n \\tconst user = locals.pb.authStore.record!;\n \\tconst breadcrumbs = [{ title: 'Home', url: '/dashboard' }];\n\n \\treturn { user, breadcrumbs };\n };\n` + \"\\n\";\n\nexport function unmodifyAppLayoutServer(filePath: string): ModifyOutcome {\n return revertByTemplate(filePath, BASELINE, \"loadActiveSubscription\");\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(\n filePath: string,\n paymentsNavUserTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(filePath, paymentsNavUserTemplate, \"planLabel\");\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageServer(\n filePath: string,\n paymentsBillingPageServerTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageServerTemplate,\n \"selectPlan\",\n );\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageSvelte(\n filePath: string,\n paymentsBillingPageSvelteTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageSvelteTemplate,\n \"availablePlans\",\n );\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\nimport { unmodifyStripeHooks } from \"./modifies/modify-stripe-hooks\";\nimport { unmodifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { unmodifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { unmodifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { unmodifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { unmodifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Pull the \"post-payments\" state of files that enable-subscriptions fully\n// overwrote. For the billing pages, that's exactly what enable-payments\n// writes in creates-app-mode; for nav-user it's the payments preview-modifies\n// snapshot (with highlight annotations stripped by the revert helper).\nimport paymentsNavUserTemplate from \"../../enable/payments/preview-modifies/src/lib/components/nav-user.svelte?raw\";\nimport paymentsBillingPageServerTemplate from \"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.server.ts?raw\";\nimport paymentsBillingPageSvelteTemplate from \"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.svelte?raw\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting data/hooks/stripe.pb.js\");\n const stripeHooksPath = path.join(\n options.root,\n \"data\",\n \"hooks\",\n \"stripe.pb.js\",\n );\n pushResult(\n modifyOutcomeToFile(stripeHooksPath, unmodifyStripeHooks(stripeHooksPath)),\n );\n\n logger.info(\"Reverting webhooks/stripe/+server.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"+server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n unmodifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Reverting (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 unmodifyAppLayoutServer(appLayoutServerPath),\n ),\n );\n\n logger.info(\"Reverting (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n unmodifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Reverting app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, unmodifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n navUserPath,\n unmodifyNavUser(navUserPath, paymentsNavUserTemplate),\n ),\n );\n\n logger.info(\"Reverting billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n unmodifyBillingPageServer(\n billingPageServerPath,\n paymentsBillingPageServerTemplate,\n ),\n ),\n );\n\n logger.info(\"Reverting billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n unmodifyBillingPageSvelte(\n billingPageSveltePath,\n paymentsBillingPageSvelteTemplate,\n ),\n ),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"stripe_subscriptions\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAMA,IAAM,IACJ;AAEF,SAAgB,EAAoB,GAAiC;AACnE,KAAI,CAAC,EAAG,WAAW,EAAS,CAC1B,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAE9C,IAAM,IAAW,EAAG,aAAa,GAAU,OAAO;AAClD,KAAI,CAAC,EAAS,SAAS,uBAAuB,CAC5C,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAE9C,IAAM,IAAO,EAAS,QAAQ,GAAsB,KAAK;AAKzD,QAJI,MAAS,IACJ;EAAE,QAAQ;EAAW,SAAS;EAAO,IAE9C,EAAG,cAAc,GAAU,GAAM,OAAO,EACjC;EAAE,QAAQ;EAAW,SAAS;EAAM;;;;ACd7C,IAAM,IAA2B,IAAI,IAAI;CACvC;CACA;CACA;CACD,CAAC;AAEF,SAAgB,EAAsB,GAAiC;AACrE,KAAI,CAAC,EAAG,WAAW,EAAS,CAC1B,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAE9C,IAAM,IAAW,EAAG,aAAa,GAAU,OAAO;AAClD,KAAI,CAAC,EAAS,SAAS,4BAA4B,CACjD,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,EAAE,cAAW,EAAmB,IAAW,MAAO;AAGtD,EAFA,EAA8B,GAAI,kCAAkC,EACpE,EAA8B,GAAI,kCAAkC,EACpE,EAA8B,GAAI,kCAAkC;EAEpE,IAAM,IAAa,EAChB,qBAAqB,EAAW,gBAAgB,CAChD,MAAM,MAAS,EAAK,eAAe,CAAC,SAAS,CAAC,SAAS,aAAa,CAAC;AACxE,MAAI,CAAC,EAAY;EAIjB,IAAM,IAFY,EAAW,cAAc,CA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ACR,OACA,UACA,SACA,oBACD;AAQD,CAPA,EACE,EACE,GACA,EAAwB,EAAoB,CAC7C,CACF,EAED,EAAO,KAAK,iCAAiC;CAC7C,IAAM,IAAsB,EAAK,KAC/B,EAAQ,MACR,OACA,UACA,SACA,iBACD;AAQD,CAPA,EACE,EACE,GACA,EAAwB,EAAoB,CAC7C,CACF,EAED,EAAO,KAAK,+BAA+B;CAC3C,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,OACA,cACA,qBACD;AAKD,CAJA,EACE,EAAoB,GAAgB,EAAmB,EAAe,CAAC,CACxE,EAED,EAAO,KAAK,4BAA4B;CACxC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,kBACD;AAQD,CAPA,EACE,EACE,GACA,EAAgB,GAAa,EAAwB,CACtD,CACF,EAED,EAAO,KAAK,oCAAoC;CAChD,IAAM,IAAwB,EAAK,KACjC,EAAQ,MACR,OACA,UACA,SACA,WACA,kBACD;AAWD,CAVA,EACE,EACE,GACA,EACE,GACA,EACD,CACF,CACF,EAED,EAAO,KAAK,iCAAiC;CAC7C,IAAM,IAAwB,EAAK,KACjC,EAAQ,MACR,OACA,UACA,SACA,WACA,eACD;AAgBD,QAfA,EACE,EACE,GACA,EACE,GACA,EACD,CACF,CACF,EAOM;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAbsB,MAAM,EAC5B,CAAC,uBAAuB,EACxB,EACD;EAWA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./logger-BpgCb-ZG.js";
|
|
2
|
-
import { modifyOutcomeToFile as t } from "./modify-file-
|
|
2
|
+
import { modifyOutcomeToFile as t } from "./modify-file-DGBe3ycw.js";
|
|
3
3
|
import n from "node:fs";
|
|
4
4
|
import r from "node:path";
|
|
5
5
|
import { Project as i, SyntaxKind as a } from "ts-morph";
|
|
@@ -53,4 +53,4 @@ async function s(n) {
|
|
|
53
53
|
//#endregion
|
|
54
54
|
export { s as generate };
|
|
55
55
|
|
|
56
|
-
//# sourceMappingURL=generate.runtime-
|
|
56
|
+
//# sourceMappingURL=generate.runtime-C8Wbgx77.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-C8Wbgx77.js","names":[],"sources":["../../src/patterns/disable/api/modifies/hooks.server.ts","../../src/patterns/disable/api/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"success\", changed: false };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n return { status: \"success\", changed: false };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n return { status: \"success\", changed: false };\n }\n\n apiProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\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 { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;AAIA,SAAgB,EAAoB,GAAwC;AAC1E,KAAI,CAAC,EAAG,WAAW,EAAgB,CACjC,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAiB,EAAG,aAAa,GAAiB,OAAO,EAEzD,IADU,IAAI,GAAS,CACF,oBAAoB,EAAgB,EAEzD,IAAW,EACd,qBAAqB,EAAW,eAAe,CAC/C,MAAM,MAAO,EAAG,eAAe,CAAC,SAAS,KAAK,mBAAmB;AAEpE,KAAI,CAAC,EACH,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAO,EAAS,cAAc;AACpC,KAAI,EAAK,WAAW,EAClB,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAW,EAAK;AACtB,KAAI,EAAS,SAAS,KAAK,EAAW,wBACpC,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAa,EAAS,cAAc,EAAW,wBAAwB,EACvE,IAAU,EAAW,YAAY,MAAM;AAc7C,QAbK,KAIL,EAAQ,QAAQ,EAEZ,EAAW,eAAe,CAAC,WAAW,KACxC,EAAS,eAAe,EAAE,EAG5B,EAAW,YAAY,EACvB,EAAW,UAAU,EAEd;EACL,QAAQ;EACR,SAAS,EAAW,aAAa,KAAK;EACvC,IAfQ;EAAE,QAAQ;EAAW,SAAS;EAAO;;;;AC5BhD,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,EAAQ,EAC3B,IAAmB,EAAE;AAE3B,GAAO,KAAK,4BAA4B;CACxC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,kBAAkB,EACnE,IAAO,EACX,GACA,EAAoB,EAAgB,CACrC;AAGD,QAFI,KAAM,EAAS,KAAK,EAAK,EAEtB;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAAiB,EAAE;EACpB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e } from "./logger-BpgCb-ZG.js";
|
|
2
|
-
import { t } from "./shared-
|
|
3
|
-
import { modifyOutcomeToFile as n } from "./modify-file-
|
|
4
|
-
import { i as r, o as i } from "./ts-morph-helpers-
|
|
2
|
+
import { t } from "./shared-CG8Qf95D.js";
|
|
3
|
+
import { modifyOutcomeToFile as n } from "./modify-file-DGBe3ycw.js";
|
|
4
|
+
import { i as r, o as i } from "./ts-morph-helpers-DjpZhZ7I.js";
|
|
5
5
|
import a from "node:fs";
|
|
6
6
|
import o from "node:path";
|
|
7
7
|
//#region src/patterns/disable/teams/modifies/modify-nav-user.ts
|
|
@@ -57,4 +57,4 @@ async function l(r) {
|
|
|
57
57
|
//#endregion
|
|
58
58
|
export { l as generate };
|
|
59
59
|
|
|
60
|
-
//# sourceMappingURL=generate.runtime-
|
|
60
|
+
//# sourceMappingURL=generate.runtime-CFH03New.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-CFH03New.js","names":[],"sources":["../../src/patterns/disable/teams/modifies/modify-nav-user.ts","../../src/patterns/disable/teams/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/teams\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Teams\",\n \"@lucide/svelte/icons/users\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nconst MANUAL_REMEDIATION = [\n \"app-sidebar, +layout.server.ts (teams loader), and app-layout.svelte (AppSidebar team props) must be reverted manually.\",\n \"These edits are substantial and are not safely reversed by tooling.\",\n].join(\" \");\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserCandidates = [\n path.join(options.root, \"src\", \"lib\", \"components\", \"nav-user.svelte\"),\n ];\n const navUserPath =\n navUserCandidates.find((p) => fs.existsSync(p)) ?? navUserCandidates[0];\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(MANUAL_REMEDIATION);\n\n const collectionDrops = await planDropsForCollections(\n [\"team_invite_links\", \"team_invites\", \"team_memberships\", \"teams\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,EAAgB,GAAoC;AAClE,KAAI,CAAC,EAAG,WAAW,EAAY,CAC7B,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAS,EAAG,aAAa,GAAa,OAAO;AACnD,KAAI,CAAC,EAAO,SAAS,SAAS,CAC5B,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAO,IAAI,EAAW,EAAO,EAC/B,IAAa,IAEX,KAAa,MAAgD;AAC7D,OACJ,GAAK,MAAQ;GACX,IAAM,IAAS,EACb,GACA,SACA,6BACD;AAED,UADI,EAAO,eAAY,IAAa,KAC7B,EAAO;IACd;;AAWJ,QARA,GAAW,MAAO,EAAK,mBAAmB,EAAG,CAAC,EACzC,KAAY,GAAW,MAAO,EAAK,aAAa,EAAG,CAAC,EAEpD,KAIL,EAAG,cAAc,GAAa,EAAK,UAAU,EAAE,OAAO,EAC/C;EAAE,QAAQ;EAAW,SAAS;EAAM,IAJlC;EAAE,QAAQ;EAAW,SAAS;EAAO;;;;AC3BhD,IAAM,IAAqB,CACzB,2HACA,sEACD,CAAC,KAAK,IAAI;AAEX,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,EAAQ,EAC3B,IAAmB,EAAE,EACrB,KAAc,MAAsB;AACxC,EAAI,KAAM,EAAS,KAAK,EAAK;;AAG/B,GAAO,KAAK,4BAA4B;CACxC,IAAM,IAAoB,CACxB,EAAK,KAAK,EAAQ,MAAM,OAAO,OAAO,cAAc,kBAAkB,CACvE,EACK,IACJ,EAAkB,MAAM,MAAM,EAAG,WAAW,EAAE,CAAC,IAAI,EAAkB;AAUvE,QATA,EAAW,EAAoB,GAAa,EAAgB,EAAY,CAAC,CAAC,EAE1E,EAAO,KAAK,EAAmB,EAOxB;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAbsB,MAAM,EAC5B;GAAC;GAAqB;GAAgB;GAAoB;GAAQ,EAClE,EACD;EAWA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e } from "./logger-BpgCb-ZG.js";
|
|
2
|
-
import { t } from "./shared-
|
|
3
|
-
import { modifyOutcomeToFile as n } from "./modify-file-
|
|
4
|
-
import { i as r, o as i } from "./ts-morph-helpers-
|
|
2
|
+
import { t } from "./shared-CG8Qf95D.js";
|
|
3
|
+
import { modifyOutcomeToFile as n } from "./modify-file-DGBe3ycw.js";
|
|
4
|
+
import { i as r, o as i } from "./ts-morph-helpers-DjpZhZ7I.js";
|
|
5
5
|
import a from "node:fs";
|
|
6
6
|
import o from "node:path";
|
|
7
7
|
import { Project as s, SyntaxKind as c } from "ts-morph";
|
|
@@ -90,4 +90,4 @@ async function d(r) {
|
|
|
90
90
|
//#endregion
|
|
91
91
|
export { d as generate };
|
|
92
92
|
|
|
93
|
-
//# sourceMappingURL=generate.runtime-
|
|
93
|
+
//# sourceMappingURL=generate.runtime-CZwuYNbQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-CZwuYNbQ.js","names":[],"sources":["../../src/patterns/disable/api-keys/modifies/hooks.server.ts","../../src/patterns/disable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/disable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp || apiProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { status: \"success\", changed: false };\n }\n\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!apiInit || apiInit.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n return { status: \"success\", changed: false };\n }\n\n apiKeysProp.remove();\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/api-keys\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"API Keys\",\n \"@lucide/svelte/icons/key-round\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { unmodifyNavUser } from \"./modifies/nav-user.svelte\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, unmodifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n const collectionDrops = await planDropsForCollections([\"api_keys\"], options);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,EAAoB,GAAwC;AAC1E,KAAI,CAAC,EAAG,WAAW,EAAgB,CACjC,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9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I,EAAO,eAAY,IAAa,KAC7B,EAAO;IACd;;AAWJ,QARA,GAAW,MAAO,EAAK,mBAAmB,EAAG,CAAC,EACzC,KAAY,GAAW,MAAO,EAAK,aAAa,EAAG,CAAC,EAEpD,KAIL,EAAG,cAAc,GAAa,EAAK,UAAU,EAAE,OAAO,EAC/C;EAAE,QAAQ;EAAW,SAAS;EAAM,IAJlC;EAAE,QAAQ;EAAW,SAAS;EAAO;;;;AC3BhD,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,EAAQ,EAC3B,IAAmB,EAAE,EACrB,KAAc,MAAsB;AACxC,EAAI,KAAM,EAAS,KAAK,EAAK;;AAG/B,GAAO,KAAK,4BAA4B;CACxC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,kBAAkB;AAKzE,CAJA,EACE,EAAoB,GAAiB,EAAoB,EAAgB,CAAC,CAC3E,EAED,EAAO,KAAK,4BAA4B;CACxC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,kBACD;AAKD,QAJA,EAAW,EAAoB,GAAa,EAAgB,EAAY,CAAC,CAAC,EAInE;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAVsB,MAAM,EAAwB,CAAC,WAAW,EAAE,EAAQ;EAW3E"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { t as e } from "./dedent-C4qKBQXh.js";
|
|
2
|
+
import { n as t } from "./logger-BpgCb-ZG.js";
|
|
3
|
+
import { a as n, c as r, i, n as a, o, r as s, s as c, t as l } from "./_server-BCbQIYCn.js";
|
|
4
|
+
import { modifyOutcomeToFile as u } from "./modify-file-DGBe3ycw.js";
|
|
5
|
+
import { a as d, n as f, o as p } from "./ts-morph-helpers-DjpZhZ7I.js";
|
|
6
|
+
import m from "node:fs";
|
|
7
|
+
import h from "node:path";
|
|
8
|
+
import { SyntaxKind as g } from "ts-morph";
|
|
9
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-stripe-hooks.ts
|
|
10
|
+
var _ = e`
|
|
11
|
+
cronAdd("stripe-subscriptions", "*/2 * * * *", () => {
|
|
12
|
+
const utils = require(\`\${__hooks}/utils.js\`);
|
|
13
|
+
utils.triggerJob("/api/stripe/sync/subscriptions");
|
|
14
|
+
});
|
|
15
|
+
`, v = [
|
|
16
|
+
"Append the stripe-subscriptions cron to data/hooks/stripe.pb.js:",
|
|
17
|
+
"",
|
|
18
|
+
_
|
|
19
|
+
].join("\n"), y = [
|
|
20
|
+
"Enable payments first — data/hooks/stripe.pb.js is created by enable-payments.",
|
|
21
|
+
"",
|
|
22
|
+
"Once present, append:",
|
|
23
|
+
"",
|
|
24
|
+
_
|
|
25
|
+
].join("\n");
|
|
26
|
+
function b(e) {
|
|
27
|
+
if (!m.existsSync(e)) return {
|
|
28
|
+
status: "not-found",
|
|
29
|
+
message: y
|
|
30
|
+
};
|
|
31
|
+
let t = m.readFileSync(e, "utf8");
|
|
32
|
+
if (t.includes("stripe-subscriptions")) return {
|
|
33
|
+
status: "success",
|
|
34
|
+
changed: !1
|
|
35
|
+
};
|
|
36
|
+
if (!t.includes("cronAdd(")) return {
|
|
37
|
+
status: "failed",
|
|
38
|
+
message: v
|
|
39
|
+
};
|
|
40
|
+
let n = `${t}${t.endsWith("\n") ? "" : "\n"}\n${_}\n`;
|
|
41
|
+
return m.writeFileSync(e, n, "utf8"), {
|
|
42
|
+
status: "success",
|
|
43
|
+
changed: !0
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts
|
|
48
|
+
var x = e`
|
|
49
|
+
Wire the subscription event handlers into src/routes/webhooks/stripe/+server.ts:
|
|
50
|
+
|
|
51
|
+
Add imports:
|
|
52
|
+
import { handleSubscriptionCreated } from "./handlers/subscription/created";
|
|
53
|
+
import { handleSubscriptionUpdated } from "./handlers/subscription/updated";
|
|
54
|
+
import { handleSubscriptionDeleted } from "./handlers/subscription/deleted";
|
|
55
|
+
|
|
56
|
+
Add switch cases inside the event.type switch:
|
|
57
|
+
case "customer.subscription.created":
|
|
58
|
+
await handleSubscriptionCreated(event.data.object, locals);
|
|
59
|
+
break;
|
|
60
|
+
case "customer.subscription.updated":
|
|
61
|
+
await handleSubscriptionUpdated(event.data.object, locals);
|
|
62
|
+
break;
|
|
63
|
+
case "customer.subscription.deleted":
|
|
64
|
+
await handleSubscriptionDeleted(event.data.object, locals);
|
|
65
|
+
break;
|
|
66
|
+
`, S = "Enable payments first — src/routes/webhooks/stripe/+server.ts is created by enable-payments.", C = e`
|
|
67
|
+
case "customer.subscription.created":
|
|
68
|
+
await handleSubscriptionCreated(event.data.object, locals);
|
|
69
|
+
break;
|
|
70
|
+
|
|
71
|
+
case "customer.subscription.updated":
|
|
72
|
+
await handleSubscriptionUpdated(event.data.object, locals);
|
|
73
|
+
break;
|
|
74
|
+
|
|
75
|
+
case "customer.subscription.deleted":
|
|
76
|
+
await handleSubscriptionDeleted(event.data.object, locals);
|
|
77
|
+
break;
|
|
78
|
+
`;
|
|
79
|
+
function w(e) {
|
|
80
|
+
if (!m.existsSync(e)) return {
|
|
81
|
+
status: "not-found",
|
|
82
|
+
message: S
|
|
83
|
+
};
|
|
84
|
+
let t = m.readFileSync(e, "utf8");
|
|
85
|
+
if (t.includes("handleSubscriptionCreated")) return {
|
|
86
|
+
status: "success",
|
|
87
|
+
changed: !1
|
|
88
|
+
};
|
|
89
|
+
let n = !1, { source: r } = d(t, (e) => {
|
|
90
|
+
f(e, [
|
|
91
|
+
{
|
|
92
|
+
namedImports: ["handleSubscriptionCreated"],
|
|
93
|
+
moduleSpecifier: "./handlers/subscription/created"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
namedImports: ["handleSubscriptionUpdated"],
|
|
97
|
+
moduleSpecifier: "./handlers/subscription/updated"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
namedImports: ["handleSubscriptionDeleted"],
|
|
101
|
+
moduleSpecifier: "./handlers/subscription/deleted"
|
|
102
|
+
}
|
|
103
|
+
]);
|
|
104
|
+
let t = e.getDescendantsOfKind(g.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
|
|
105
|
+
if (!t) return;
|
|
106
|
+
let r = t.getCaseBlock().getClauses(), i = r.find((e) => e.getKind() === g.DefaultClause), a = `${C}\n\n`;
|
|
107
|
+
if (i) i.replaceWithText(a + i.getText());
|
|
108
|
+
else if (r.length > 0) {
|
|
109
|
+
let e = r[r.length - 1];
|
|
110
|
+
e.replaceWithText(e.getText() + `\n\n${C}`);
|
|
111
|
+
} else return;
|
|
112
|
+
e.formatText(), n = !0;
|
|
113
|
+
});
|
|
114
|
+
return n ? (m.writeFileSync(e, r, "utf8"), {
|
|
115
|
+
status: "success",
|
|
116
|
+
changed: !0
|
|
117
|
+
}) : {
|
|
118
|
+
status: "failed",
|
|
119
|
+
message: x
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-by-template.ts
|
|
124
|
+
function T(e, t, n, r) {
|
|
125
|
+
if (!m.existsSync(e)) return {
|
|
126
|
+
status: "not-found",
|
|
127
|
+
message: r
|
|
128
|
+
};
|
|
129
|
+
let i = m.readFileSync(e, "utf8");
|
|
130
|
+
if (i.includes(n)) return {
|
|
131
|
+
status: "success",
|
|
132
|
+
changed: !1
|
|
133
|
+
};
|
|
134
|
+
let a = t.replace(/^[ \t]*\/\/[ \t]*\[!code highlight:\d+\][ \t]*\r?\n/gm, "").replace(/^[ \t]*<!--[ \t]*\[!code highlight:\d+\][ \t]*-->[ \t]*\r?\n/gm, "");
|
|
135
|
+
return i === a ? {
|
|
136
|
+
status: "success",
|
|
137
|
+
changed: !1
|
|
138
|
+
} : (m.writeFileSync(e, a, "utf8"), {
|
|
139
|
+
status: "success",
|
|
140
|
+
changed: !0
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts
|
|
145
|
+
var E = ["Create src/routes/(app)/+layout.server.ts before enabling subscriptions.", "Enable auth first — the (app) layout is provided by the velastack-auth baseline."].join("\n");
|
|
146
|
+
function D(e, t) {
|
|
147
|
+
return T(e, t, "loadActiveSubscription", E);
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts
|
|
151
|
+
var O = [
|
|
152
|
+
"Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:",
|
|
153
|
+
"",
|
|
154
|
+
"<AppSidebar user={data.user} meta={data.meta} subscription={data.subscription} />"
|
|
155
|
+
].join("\n"), k = ["Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop."].join("\n");
|
|
156
|
+
function A(e) {
|
|
157
|
+
if (!m.existsSync(e)) return {
|
|
158
|
+
status: "not-found",
|
|
159
|
+
message: k
|
|
160
|
+
};
|
|
161
|
+
let t = p.fromPath(e);
|
|
162
|
+
return t.hasElement("AppSidebar") ? t.hasAttribute("AppSidebar", "subscription") ? {
|
|
163
|
+
status: "success",
|
|
164
|
+
changed: !1
|
|
165
|
+
} : t.appendToAttributes("AppSidebar", " subscription={data.subscription}") ? (t.writeTo(e), {
|
|
166
|
+
status: "success",
|
|
167
|
+
changed: t.hasChanged()
|
|
168
|
+
}) : {
|
|
169
|
+
status: "failed",
|
|
170
|
+
message: O
|
|
171
|
+
} : {
|
|
172
|
+
status: "failed",
|
|
173
|
+
message: O
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts
|
|
178
|
+
var j = "{ id: string; productName: string | null } | null", M = [
|
|
179
|
+
"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:",
|
|
180
|
+
"",
|
|
181
|
+
"1. Add `subscription = null` to the destructured $props() call.",
|
|
182
|
+
`2. Add \`subscription?: ${j}\` to the props type.`,
|
|
183
|
+
"3. Pass `{subscription}` to <NavUser>."
|
|
184
|
+
].join("\n"), N = ["Create src/lib/components/app-sidebar.svelte before enabling subscriptions."].join("\n");
|
|
185
|
+
function P(e) {
|
|
186
|
+
let t = !1, { source: n } = d(e, (e) => {
|
|
187
|
+
for (let n of e.getVariableDeclarations()) {
|
|
188
|
+
let e = n.getInitializer();
|
|
189
|
+
if (!e || e.getText() !== "$props()") continue;
|
|
190
|
+
let r = n.getNameNode();
|
|
191
|
+
if (r.getKind() !== g.ObjectBindingPattern) continue;
|
|
192
|
+
let i = r.asKindOrThrow(g.ObjectBindingPattern), a = i.getElements();
|
|
193
|
+
if (a.some((e) => e.getName() === "subscription")) return;
|
|
194
|
+
let o = n.getTypeNode();
|
|
195
|
+
if (o?.getKind() === g.IntersectionType) {
|
|
196
|
+
let e = o.asKindOrThrow(g.IntersectionType);
|
|
197
|
+
for (let t of e.getTypeNodes()) {
|
|
198
|
+
if (t.getKind() !== g.TypeLiteral) continue;
|
|
199
|
+
let e = t.asKindOrThrow(g.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, ""));
|
|
200
|
+
if (!n.some((e) => /^\s*subscription\??\s*:/.test(e))) {
|
|
201
|
+
n.push(`subscription?: ${j}`), e.replaceWithText(`{ ${n.join("; ")}; }`);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let s = a.map((e) => e.getText()), c = a.findIndex((e) => e.getDotDotDotToken() || e.getInitializer());
|
|
207
|
+
c === -1 && (c = s.length), s.splice(c, 0, "subscription = null"), i.replaceWithText(`{ ${s.join(", ")} }`), t = !0;
|
|
208
|
+
}
|
|
209
|
+
e.formatText();
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
source: n,
|
|
213
|
+
wasAdded: t
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function F(e) {
|
|
217
|
+
if (!m.existsSync(e)) return {
|
|
218
|
+
status: "not-found",
|
|
219
|
+
message: N
|
|
220
|
+
};
|
|
221
|
+
let t = m.readFileSync(e, "utf8");
|
|
222
|
+
if (t.includes("subscription?: {") || t.includes("subscription={subscription}") || t.includes("{subscription}")) return {
|
|
223
|
+
status: "success",
|
|
224
|
+
changed: !1
|
|
225
|
+
};
|
|
226
|
+
let n = new p(t);
|
|
227
|
+
if (!n.hasElement("NavUser")) return {
|
|
228
|
+
status: "failed",
|
|
229
|
+
message: M
|
|
230
|
+
};
|
|
231
|
+
let r = n.modifyScript((e) => P(e).source), i = n.hasAttribute("NavUser", "subscription") ? !1 : n.appendToAttributes("NavUser", " {subscription}");
|
|
232
|
+
return !r && !i ? {
|
|
233
|
+
status: "failed",
|
|
234
|
+
message: M
|
|
235
|
+
} : (n.writeTo(e), {
|
|
236
|
+
status: "success",
|
|
237
|
+
changed: n.hasChanged()
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-nav-user.ts
|
|
242
|
+
var I = ["src/lib/components/nav-user.svelte is missing.", "Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user."].join("\n");
|
|
243
|
+
function L(e, t) {
|
|
244
|
+
return T(e, t, "planLabel", I);
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts
|
|
248
|
+
var R = ["src/routes/(app)/billing/+page.server.ts is missing.", "Enable payments first — subscriptions extends the billing page with plan management."].join("\n");
|
|
249
|
+
function z(e, t) {
|
|
250
|
+
return T(e, t, "selectPlan", R);
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts
|
|
254
|
+
var B = ["src/routes/(app)/billing/+page.svelte is missing.", "Enable payments first — subscriptions extends the billing page with plan management."].join("\n");
|
|
255
|
+
function V(e, t) {
|
|
256
|
+
return T(e, t, "availablePlans", B);
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/patterns/enable/subscriptions/generate.runtime.ts
|
|
260
|
+
var H = /* @__PURE__ */ Object.assign({
|
|
261
|
+
"./preview-modifies/data/hooks/stripe.pb.js": r,
|
|
262
|
+
"./preview-modifies/src/lib/components/app-sidebar.svelte": c,
|
|
263
|
+
"./preview-modifies/src/lib/components/nav-user.svelte": o,
|
|
264
|
+
"./preview-modifies/src/routes/(app)/+layout.server.ts": n,
|
|
265
|
+
"./preview-modifies/src/routes/(app)/+layout.svelte": i,
|
|
266
|
+
"./preview-modifies/src/routes/(app)/billing/+page.server.ts": s,
|
|
267
|
+
"./preview-modifies/src/routes/(app)/billing/+page.svelte": a,
|
|
268
|
+
"./preview-modifies/src/routes/webhooks/stripe/+server.ts": l
|
|
269
|
+
});
|
|
270
|
+
function U(e) {
|
|
271
|
+
let t = H[`./preview-modifies/${e}`];
|
|
272
|
+
if (t === void 0) throw Error(`Missing template for ${e} in subscriptions preview-modifies`);
|
|
273
|
+
return t;
|
|
274
|
+
}
|
|
275
|
+
async function W(e) {
|
|
276
|
+
let n = t(e), r = [], i = (e) => {
|
|
277
|
+
e && r.push(e);
|
|
278
|
+
};
|
|
279
|
+
n.info("Modifying data/hooks/stripe.pb.js");
|
|
280
|
+
let a = h.join(e.root, "data", "hooks", "stripe.pb.js");
|
|
281
|
+
i(u(a, b(a))), n.info("Modifying webhooks/stripe/+server.ts");
|
|
282
|
+
let o = h.join(e.root, "src", "routes", "webhooks", "stripe", "+server.ts");
|
|
283
|
+
i(u(o, w(o))), n.info("Modifying (app)/+layout.server.ts");
|
|
284
|
+
let s = h.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
285
|
+
i(u(s, D(s, U("src/routes/(app)/+layout.server.ts")))), n.info("Modifying (app)/+layout.svelte");
|
|
286
|
+
let c = h.join(e.root, "src", "routes", "(app)", "+layout.svelte");
|
|
287
|
+
i(u(c, A(c))), n.info("Modifying app-sidebar.svelte");
|
|
288
|
+
let l = h.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
|
|
289
|
+
i(u(l, F(l))), n.info("Modifying nav-user.svelte");
|
|
290
|
+
let d = h.join(e.root, "src", "lib", "components", "nav-user.svelte");
|
|
291
|
+
i(u(d, L(d, U("src/lib/components/nav-user.svelte")))), n.info("Modifying billing/+page.server.ts");
|
|
292
|
+
let f = h.join(e.root, "src", "routes", "(app)", "billing", "+page.server.ts");
|
|
293
|
+
i(u(f, z(f, U("src/routes/(app)/billing/+page.server.ts")))), n.info("Modifying billing/+page.svelte");
|
|
294
|
+
let p = h.join(e.root, "src", "routes", "(app)", "billing", "+page.svelte");
|
|
295
|
+
return i(u(p, V(p, U("src/routes/(app)/billing/+page.svelte")))), {
|
|
296
|
+
creates: [],
|
|
297
|
+
modifies: r,
|
|
298
|
+
deletes: [],
|
|
299
|
+
components: [],
|
|
300
|
+
packages: [],
|
|
301
|
+
collections: [],
|
|
302
|
+
collectionPatches: [],
|
|
303
|
+
collectionDrops: []
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
//#endregion
|
|
307
|
+
export { W as generate };
|
|
308
|
+
|
|
309
|
+
//# sourceMappingURL=generate.runtime-CdawV-C4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-CdawV-C4.js","names":[],"sources":["../../src/patterns/enable/subscriptions/modifies/modify-stripe-hooks.ts","../../src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-by-template.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/enable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/enable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst CRON_SNIPPET = dedent`\n cronAdd(\"stripe-subscriptions\", \"*/2 * * * *\", () => {\n const utils = require(\\`\\${__hooks}/utils.js\\`);\n utils.triggerJob(\"/api/stripe/sync/subscriptions\");\n });\n`;\n\nconst FAILURE_HINT = [\n \"Append the stripe-subscriptions cron to data/hooks/stripe.pb.js:\",\n \"\",\n CRON_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Enable payments first — data/hooks/stripe.pb.js is created by enable-payments.\",\n \"\",\n \"Once present, append:\",\n \"\",\n CRON_SNIPPET,\n].join(\"\\n\");\n\nexport function modifyStripeHooks(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(\"stripe-subscriptions\")) {\n return { status: \"success\", changed: false };\n }\n if (!current.includes(\"cronAdd(\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const trailing = current.endsWith(\"\\n\") ? \"\" : \"\\n\";\n const next = `${current}${trailing}\\n${CRON_SNIPPET}\\n`;\n fs.writeFileSync(filePath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wire the subscription event handlers into src/routes/webhooks/stripe/+server.ts:\n\n Add imports:\n import { handleSubscriptionCreated } from \"./handlers/subscription/created\";\n import { handleSubscriptionUpdated } from \"./handlers/subscription/updated\";\n import { handleSubscriptionDeleted } from \"./handlers/subscription/deleted\";\n\n Add switch cases inside the event.type switch:\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nconst NOT_FOUND_HINT =\n \"Enable payments first — src/routes/webhooks/stripe/+server.ts is created by enable-payments.\";\n\nconst SUBSCRIPTION_CASES_SNIPPET = dedent`\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nexport function modifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n let addedCases = false;\n const { source } = withInMemoryScript(original, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"handleSubscriptionCreated\"],\n moduleSpecifier: \"./handlers/subscription/created\",\n },\n {\n namedImports: [\"handleSubscriptionUpdated\"],\n moduleSpecifier: \"./handlers/subscription/updated\",\n },\n {\n namedImports: [\"handleSubscriptionDeleted\"],\n moduleSpecifier: \"./handlers/subscription/deleted\",\n },\n ]);\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n const clauses = caseBlock.getClauses();\n const defaultClause = clauses.find(\n (c) => c.getKind() === SyntaxKind.DefaultClause,\n );\n\n // Prepend subscription cases in front of the default clause, or append\n // before the closing brace of the case block if there's no default.\n const prefix = `${SUBSCRIPTION_CASES_SNIPPET}\\n\\n`;\n if (defaultClause) {\n defaultClause.replaceWithText(prefix + defaultClause.getText());\n } else if (clauses.length > 0) {\n const last = clauses[clauses.length - 1];\n last.replaceWithText(last.getText() + `\\n\\n${SUBSCRIPTION_CASES_SNIPPET}`);\n } else {\n return;\n }\n\n sf.formatText();\n addedCases = true;\n });\n\n if (!addedCases) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Overwrites a file with the given template content, guarded by an idempotency\n * marker: if the current file already contains the marker, the modify is a\n * no-op. Used for complex rewrites where surgical AST changes aren't worth it\n * (e.g. pages that are largely replaced).\n *\n * Strips leading `// [!code highlight:N]` and `<!-- [!code highlight:N] -->`\n * lines so the same content can be shared with preview-modifies, which uses\n * those comments for documentation highlighting.\n */\nexport function modifyByTemplate(\n filePath: string,\n template: string,\n idempotencyMarker: string,\n notFoundHint: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: notFoundHint };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(idempotencyMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(/^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm, \"\");\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.server.ts before enabling subscriptions.\",\n \"Enable auth first — the (app) layout is provided by the velastack-auth baseline.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(\n filePath,\n template,\n \"loadActiveSubscription\",\n NOT_FOUND_HINT,\n );\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:\",\n \"\",\n \"<AppSidebar user={data.user} meta={data.meta} subscription={data.subscription} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const appended = file.appendToAttributes(\n \"AppSidebar\",\n \" subscription={data.subscription}\",\n );\n if (!appended) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { withInMemoryScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst SUBSCRIPTION_TYPE = \"{ id: string; productName: string | null } | null\";\n\nconst FAILURE_HINT = [\n \"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:\",\n \"\",\n \"1. Add `subscription = null` to the destructured $props() call.\",\n `2. Add \\`subscription?: ${SUBSCRIPTION_TYPE}\\` to the props type.`,\n \"3. Pass `{subscription}` to <NavUser>.\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/lib/components/app-sidebar.svelte before enabling subscriptions.\",\n].join(\"\\n\");\n\nfunction updateScript(source: string): {\n source: string;\n wasAdded: boolean;\n} {\n let wasAdded = false;\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n if (elements.some((e) => e.getName() === \"subscription\")) {\n // Already has subscription prop — no-op.\n return;\n }\n\n // Insert subscription?: ... into the props type literal if present.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^\\s*subscription\\??\\s*:/.test(t))) {\n continue;\n }\n propTexts.push(`subscription?: ${SUBSCRIPTION_TYPE}`);\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Insert `subscription = null` before the first rest/default-only element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elementTexts.length;\n elementTexts.splice(insertIdx, 0, \"subscription = null\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n wasAdded = true;\n }\n sf.formatText();\n });\n return { source: out, wasAdded };\n}\n\nexport function modifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (\n original.includes(\"subscription?: {\") ||\n original.includes(\"subscription={subscription}\") ||\n original.includes(\"{subscription}\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n if (!file.hasElement(\"NavUser\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const scriptChanged = file.modifyScript(\n (src) => updateScript(src).source,\n );\n\n const templateChanged = !file.hasAttribute(\"NavUser\", \"subscription\")\n ? file.appendToAttributes(\"NavUser\", \" {subscription}\")\n : false;\n\n if (!scriptChanged && !templateChanged) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/lib/components/nav-user.svelte is missing.\",\n \"Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user.\",\n].join(\"\\n\");\n\nexport function modifyNavUser(\n filePath: string,\n template: string,\n): ModifyOutcome {\n // `planLabel` is unique to subscriptions — safe idempotency marker.\n return modifyByTemplate(filePath, template, \"planLabel\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.server.ts is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(\n filePath,\n template,\n \"selectPlan\",\n NOT_FOUND_HINT,\n );\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.svelte is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageSvelte(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(\n filePath,\n template,\n \"availablePlans\",\n NOT_FOUND_HINT,\n );\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyStripeHooks } from \"./modifies/modify-stripe-hooks\";\nimport { modifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { modifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { modifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Share the final-state files between preview (rendered as-is) and runtime\n// (used as overwrite templates for modifies that amount to full rewrites).\nconst previewRaw = import.meta.glob<string>(\"./preview-modifies/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nfunction template(relativePath: string): string {\n const key = `./preview-modifies/${relativePath}`;\n const content = previewRaw[key];\n if (content === undefined) {\n throw new Error(\n `Missing template for ${relativePath} in subscriptions preview-modifies`,\n );\n }\n return content;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying data/hooks/stripe.pb.js\");\n const stripeHooksPath = path.join(\n options.root,\n \"data\",\n \"hooks\",\n \"stripe.pb.js\",\n );\n pushResult(\n modifyOutcomeToFile(stripeHooksPath, modifyStripeHooks(stripeHooksPath)),\n );\n\n logger.info(\"Modifying webhooks/stripe/+server.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"+server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n modifyWebhookServer(webhookServerPath),\n ),\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 modifyAppLayoutServer(\n appLayoutServerPath,\n template(\"src/routes/(app)/+layout.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n modifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Modifying app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Modifying nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n navUserPath,\n modifyNavUser(\n navUserPath,\n template(\"src/lib/components/nav-user.svelte\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n modifyBillingPageServer(\n billingPageServerPath,\n template(\"src/routes/(app)/billing/+page.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n modifyBillingPageSvelte(\n billingPageSveltePath,\n template(\"src/routes/(app)/billing/+page.svelte\"),\n ),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAIA,IAAM,IAAe,CAAM;;;;;GAOrB,IAAe;CACnB;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACD,CAAC,KAAK,KAAK;AAEZ,SAAgB,EAAkB,GAAiC;AACjE,KAAI,CAAC,EAAG,WAAW,EAAS,CAC1B,QAAO;EAAE,QAAQ;EAAa,SAAS;EAAgB;CAEzD,IAAM,IAAU,EAAG,aAAa,GAAU,OAAO;AACjD,KAAI,EAAQ,SAAS,uBAAuB,CAC1C,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;AAE9C,KAAI,CAAC,EAAQ,SAAS,WAAW,CAC/B,QAAO;EAAE,QAAQ;EAAU,SAAS;EAAc;CAGpD,IAAM,IAAO,GAAG,IADC,EAAQ,SAAS,KAAK,GAAG,KAAK,KACZ,IAAI,EAAa;AAEpD,QADA,EAAG,cAAc,GAAU,GAAM,OAAO,EACjC;EAAE,QAAQ;EAAW,SAAS;EAAM;;;;AC9B7C,IAAM,IAAe,CAAM;;;;;;;;;;;;;;;;;;GAoBrB,IACJ,gGAEI,IAA6B,CAAM;;;;;;;;;;;;;AAczC,SAAgB,EAAoB,GAAiC;AACnE,KAAI,CAAC,EAAG,WAAW,EAAS,CAC1B,QAAO;EAAE,QAAQ;EAAa,SAAS;EAAgB;CAGzD,IAAM,IAAW,EAAG,aAAa,GAAU,OAAO;AAClD,KAAI,EAAS,SAAS,4BAA4B,CAChD,QAAO;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ACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAAiB,EAAA;EAClB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as e } from "./dedent-C4qKBQXh.js";
|
|
2
2
|
import { n as t } from "./logger-BpgCb-ZG.js";
|
|
3
|
-
import { modifyOutcomeToFile as n } from "./modify-file-
|
|
4
|
-
import { a as r, n as i, o as a } from "./ts-morph-helpers-
|
|
5
|
-
import { getMigrationFile as o, migrationDelay as s, withPocketbase as c } from "./pocketbase-
|
|
6
|
-
import { findSvelteConfigPath as l, modifySvelteConfigRemote as u } from "./modify-svelte-config-remote-
|
|
3
|
+
import { modifyOutcomeToFile as n } from "./modify-file-DGBe3ycw.js";
|
|
4
|
+
import { a as r, n as i, o as a } from "./ts-morph-helpers-DjpZhZ7I.js";
|
|
5
|
+
import { getMigrationFile as o, migrationDelay as s, withPocketbase as c } from "./pocketbase-CEhGbssT.js";
|
|
6
|
+
import { findSvelteConfigPath as l, modifySvelteConfigRemote as u } from "./modify-svelte-config-remote-C-Wl2nk1.js";
|
|
7
7
|
import d from "node:fs";
|
|
8
8
|
import f from "node:path";
|
|
9
9
|
import { Project as p, SyntaxKind as m } from "ts-morph";
|
|
@@ -294,4 +294,4 @@ async function w(e) {
|
|
|
294
294
|
//#endregion
|
|
295
295
|
export { w as generate };
|
|
296
296
|
|
|
297
|
-
//# sourceMappingURL=generate.runtime-
|
|
297
|
+
//# sourceMappingURL=generate.runtime-CojXsWmJ.js.map
|