@velastack/patterns 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/dist/chunks/{_layout-D-FzWqn0.js → _layout-DQhSAhfF.js} +3 -3
- package/dist/chunks/{_layout-D-FzWqn0.js.map → _layout-DQhSAhfF.js.map} +1 -1
- package/dist/chunks/{auth-pages-B52ei-4z.js → auth-pages-jsyDV1GR.js} +7 -10
- package/dist/chunks/{auth-pages-B52ei-4z.js.map → auth-pages-jsyDV1GR.js.map} +1 -1
- package/dist/chunks/{collections-B_DisSfA.js → collections-BYcVyY9O.js} +39 -35
- package/dist/chunks/collections-BYcVyY9O.js.map +1 -0
- package/dist/chunks/collections-BrEA7a62.js +309 -0
- package/dist/chunks/collections-BrEA7a62.js.map +1 -0
- package/dist/chunks/{compose-handle-BDlZ7Pif.js → compose-handle-BBlamPfx.js} +18 -22
- package/dist/chunks/{compose-handle-BDlZ7Pif.js.map → compose-handle-BBlamPfx.js.map} +1 -1
- package/dist/chunks/{config-target-rHgjaA8u.js → config-target-BgyFkbFL.js} +2 -2
- package/dist/chunks/{config-target-rHgjaA8u.js.map → config-target-BgyFkbFL.js.map} +1 -1
- package/dist/chunks/constants-Bdx8mp7v.js +6 -0
- package/dist/chunks/constants-Bdx8mp7v.js.map +1 -0
- package/dist/chunks/dedent-Gq6Krl4n.js.map +1 -1
- package/dist/chunks/{env-BPfk1VAw.js → env-BugddEjd.js} +5 -9
- package/dist/chunks/{env-BPfk1VAw.js.map → env-BugddEjd.js.map} +1 -1
- package/dist/chunks/{env-vars-cqQU0ECK.js → env-vars-0hvKe55u.js} +6 -11
- package/dist/chunks/{env-vars-cqQU0ECK.js.map → env-vars-0hvKe55u.js.map} +1 -1
- package/dist/chunks/generate-BOQA-Flq.js +171 -0
- package/dist/chunks/generate-BOQA-Flq.js.map +1 -0
- package/dist/chunks/{generate-CXoQPz7n.js → generate-CNabcEBx.js} +2 -2
- package/dist/chunks/{generate-CXoQPz7n.js.map → generate-CNabcEBx.js.map} +1 -1
- package/dist/chunks/{generate-jx5Iuq5w.js → generate-CO88bEvs.js} +54 -53
- package/dist/chunks/generate-CO88bEvs.js.map +1 -0
- package/dist/chunks/{generate-Bm_jOMtF.js → generate-Df7t5Nbk.js} +3 -3
- package/dist/chunks/{generate-Bm_jOMtF.js.map → generate-Df7t5Nbk.js.map} +1 -1
- package/dist/chunks/{generate-Cqwa8kD9.js → generate-DoHn_xJZ.js} +2 -2
- package/dist/chunks/{generate-Cqwa8kD9.js.map → generate-DoHn_xJZ.js.map} +1 -1
- package/dist/chunks/generate-DyV5R8NP.js.map +1 -1
- package/dist/chunks/{generate-D3mSFPdT.js → generate-l2JZTRKb.js} +2 -2
- package/dist/chunks/{generate-D3mSFPdT.js.map → generate-l2JZTRKb.js.map} +1 -1
- package/dist/chunks/{generate.runtime-FGYc365Q.js → generate.runtime-1ldXcpiD.js} +6 -6
- package/dist/chunks/{generate.runtime-FGYc365Q.js.map → generate.runtime-1ldXcpiD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B2r11K7S.js → generate.runtime-B53OTMcE.js} +6 -6
- package/dist/chunks/{generate.runtime-B2r11K7S.js.map → generate.runtime-B53OTMcE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DCqf7nYM.js → generate.runtime-B84ymwlD.js} +7 -7
- package/dist/chunks/{generate.runtime-DCqf7nYM.js.map → generate.runtime-B84ymwlD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dug2UIhV.js → generate.runtime-BOl3LpPB.js} +10 -13
- package/dist/chunks/{generate.runtime-Dug2UIhV.js.map → generate.runtime-BOl3LpPB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BxDUtkpT.js → generate.runtime-BP31tAcD.js} +5 -5
- package/dist/chunks/{generate.runtime-BxDUtkpT.js.map → generate.runtime-BP31tAcD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DdcVnK8J.js → generate.runtime-BoYwV0nt.js} +133 -121
- package/dist/chunks/generate.runtime-BoYwV0nt.js.map +1 -0
- package/dist/chunks/{generate.runtime-wGRE1zwZ.js → generate.runtime-BqCbJ-No.js} +4 -4
- package/dist/chunks/{generate.runtime-wGRE1zwZ.js.map → generate.runtime-BqCbJ-No.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BVavIXtX.js → generate.runtime-Bvjj3zn0.js} +6 -6
- package/dist/chunks/{generate.runtime-BVavIXtX.js.map → generate.runtime-Bvjj3zn0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-_c7daMAw.js → generate.runtime-ByPcr9vJ.js} +4 -4
- package/dist/chunks/{generate.runtime-_c7daMAw.js.map → generate.runtime-ByPcr9vJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dmob2wFf.js → generate.runtime-C4LUUuq7.js} +5 -5
- package/dist/chunks/{generate.runtime-Dmob2wFf.js.map → generate.runtime-C4LUUuq7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-wziCW3ct.js → generate.runtime-CGjDfO1P.js} +5 -5
- package/dist/chunks/{generate.runtime-wziCW3ct.js.map → generate.runtime-CGjDfO1P.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DYdkrHJ1.js → generate.runtime-CHQ_MQJQ.js} +6 -6
- package/dist/chunks/{generate.runtime-DYdkrHJ1.js.map → generate.runtime-CHQ_MQJQ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-aN5QWygO.js → generate.runtime-CHS5lyHL.js} +39 -36
- package/dist/chunks/generate.runtime-CHS5lyHL.js.map +1 -0
- package/dist/chunks/{generate.runtime-CyGR8VTx.js → generate.runtime-CHUCMVa2.js} +3 -3
- package/dist/chunks/{generate.runtime-CyGR8VTx.js.map → generate.runtime-CHUCMVa2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BxUGDXIK.js → generate.runtime-CVWCUn52.js} +6 -6
- package/dist/chunks/{generate.runtime-BxUGDXIK.js.map → generate.runtime-CVWCUn52.js.map} +1 -1
- package/dist/chunks/generate.runtime-C_5Ghjri.js +17 -0
- package/dist/chunks/generate.runtime-C_5Ghjri.js.map +1 -0
- package/dist/chunks/{generate.runtime-CRhD98rs.js → generate.runtime-Cv3unKap.js} +5 -5
- package/dist/chunks/{generate.runtime-CRhD98rs.js.map → generate.runtime-Cv3unKap.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CkmledBw.js → generate.runtime-D677SB4v.js} +12 -20
- package/dist/chunks/{generate.runtime-CkmledBw.js.map → generate.runtime-D677SB4v.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DeniHg8L.js → generate.runtime-DERcpgc-.js} +5 -5
- package/dist/chunks/{generate.runtime-DeniHg8L.js.map → generate.runtime-DERcpgc-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-x-o4LS8d.js → generate.runtime-DJ5uF6EN.js} +4 -4
- package/dist/chunks/{generate.runtime-x-o4LS8d.js.map → generate.runtime-DJ5uF6EN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CYBs0JgY.js → generate.runtime-Dfz53sSK.js} +5 -5
- package/dist/chunks/{generate.runtime-CYBs0JgY.js.map → generate.runtime-Dfz53sSK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CWnIiXwV.js → generate.runtime-DiqfbDfk.js} +3 -3
- package/dist/chunks/{generate.runtime-CWnIiXwV.js.map → generate.runtime-DiqfbDfk.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CHb4znYx.js → generate.runtime-Dq6yS7tN.js} +6 -6
- package/dist/chunks/{generate.runtime-CHb4znYx.js.map → generate.runtime-Dq6yS7tN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BRCzUO94.js → generate.runtime-T7JLE4Wc.js} +10 -14
- package/dist/chunks/{generate.runtime-BRCzUO94.js.map → generate.runtime-T7JLE4Wc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Du4uf98c.js → generate.runtime-WPq7bHRA.js} +3 -3
- package/dist/chunks/{generate.runtime-Du4uf98c.js.map → generate.runtime-WPq7bHRA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-kpqW3dVO.js → generate.runtime-WeDv05E2.js} +8 -8
- package/dist/chunks/{generate.runtime-kpqW3dVO.js.map → generate.runtime-WeDv05E2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-N1KtAG8C.js → generate.runtime-aKNvrk3M.js} +90 -175
- package/dist/chunks/generate.runtime-aKNvrk3M.js.map +1 -0
- package/dist/chunks/{generate.runtime-Bh9Z2cRN.js → generate.runtime-e_BkDyP0.js} +3 -3
- package/dist/chunks/{generate.runtime-Bh9Z2cRN.js.map → generate.runtime-e_BkDyP0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DY5vQ3aZ.js → generate.runtime-gZ4wfYBP.js} +8 -8
- package/dist/chunks/{generate.runtime-DY5vQ3aZ.js.map → generate.runtime-gZ4wfYBP.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DUo-pLRr.js → generate.runtime-oUJUQRdg.js} +7 -7
- package/dist/chunks/{generate.runtime-DUo-pLRr.js.map → generate.runtime-oUJUQRdg.js.map} +1 -1
- package/dist/chunks/{generate.runtime-gFr2Gsjz.js → generate.runtime-q17D7QUT.js} +5 -5
- package/dist/chunks/{generate.runtime-gFr2Gsjz.js.map → generate.runtime-q17D7QUT.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B4u9C2YH.js → generate.runtime-rLlDp4R6.js} +5 -5
- package/dist/chunks/{generate.runtime-B4u9C2YH.js.map → generate.runtime-rLlDp4R6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-bpH3DB0t.js → generate.runtime-zr6uIHCd.js} +3 -3
- package/dist/chunks/{generate.runtime-bpH3DB0t.js.map → generate.runtime-zr6uIHCd.js.map} +1 -1
- package/dist/chunks/{modify-file-289rStJ2.js → modify-file-B4uJzOEj.js} +4 -4
- package/dist/chunks/{modify-file-289rStJ2.js.map → modify-file-B4uJzOEj.js.map} +1 -1
- package/dist/chunks/{modify-nav-user-B8h8WTrM.js → modify-nav-user-CJ1LevSU.js} +2 -2
- package/dist/chunks/{modify-nav-user-B8h8WTrM.js.map → modify-nav-user-CJ1LevSU.js.map} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js → modify-svelte-config-remote-CEyYydL7.js} +2 -2
- package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js.map → modify-svelte-config-remote-CEyYydL7.js.map} +1 -1
- package/dist/chunks/{modify-user-signup-BbqTiUuA.js → modify-user-signup-DLtopazD.js} +2 -2
- package/dist/chunks/{modify-user-signup-BbqTiUuA.js.map → modify-user-signup-DLtopazD.js.map} +1 -1
- package/dist/chunks/{package-imports-Bbw3iMPg.js → package-imports-B9Asv3ZH.js} +3 -3
- package/dist/chunks/{package-imports-Bbw3iMPg.js.map → package-imports-B9Asv3ZH.js.map} +1 -1
- package/dist/chunks/{pocketbase-B017Cqjq.js → pocketbase-BtN-wL8f.js} +9 -17
- package/dist/chunks/{pocketbase-B017Cqjq.js.map → pocketbase-BtN-wL8f.js.map} +1 -1
- package/dist/chunks/{providers-CN5J5_fY.js → providers-DRwJnSzb.js} +2 -2
- package/dist/chunks/{providers-CN5J5_fY.js.map → providers-DRwJnSzb.js.map} +1 -1
- package/dist/chunks/{rolldown-runtime-DArdT4gl.js → rolldown-runtime-5HNE8Q1r.js} +1 -1
- package/dist/chunks/{shared-BPlAVf-T.js → shared-BbxLil4g.js} +2 -2
- package/dist/chunks/{shared-BPlAVf-T.js.map → shared-BbxLil4g.js.map} +1 -1
- package/dist/chunks/{site-DkU1-VRq.js → site-Dw2KIRJu.js} +2 -2
- package/dist/chunks/{site-DkU1-VRq.js.map → site-Dw2KIRJu.js.map} +1 -1
- package/dist/chunks/{table-core-vXEjJDYP.js → table-core-BHFT-uMX.js} +3 -3
- package/dist/chunks/{table-core-vXEjJDYP.js.map → table-core-BHFT-uMX.js.map} +1 -1
- package/dist/chunks/{taggedTemplateLiteral-CswN2AAa.js → taggedTemplateLiteral-KSUnuvOk.js} +1 -1
- package/dist/chunks/{test-setup-CAfgVlwc.js → test-setup-BVJwm22s.js} +5 -5
- package/dist/chunks/{test-setup-CAfgVlwc.js.map → test-setup-BVJwm22s.js.map} +1 -1
- package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js → ts-morph-helpers-CHI9wAil.js} +7 -11
- package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js.map → ts-morph-helpers-CHI9wAil.js.map} +1 -1
- package/dist/chunks/{ui-CTdsenEv.js → ui-gG8i_Mzk.js} +3 -3
- package/dist/chunks/{ui-CTdsenEv.js.map → ui-gG8i_Mzk.js.map} +1 -1
- package/dist/chunks/{unmodify-load-Bl5vXQiL.js → unmodify-load-Buak-r1f.js} +2 -2
- package/dist/chunks/{unmodify-load-Bl5vXQiL.js.map → unmodify-load-Buak-r1f.js.map} +1 -1
- package/dist/chunks/{whatsapp-5qJ_xCV1.js → whatsapp-DbjOxHaZ.js} +2 -2
- package/dist/chunks/{whatsapp-5qJ_xCV1.js.map → whatsapp-DbjOxHaZ.js.map} +1 -1
- package/dist/chunks/write-result-DcqMefuP.js +499 -0
- package/dist/chunks/write-result-DcqMefuP.js.map +1 -0
- package/dist/chunks/wuchale-config-c3Q4JVSF.js +50 -0
- package/dist/chunks/wuchale-config-c3Q4JVSF.js.map +1 -0
- package/dist/index.d.ts +173 -19
- package/dist/index.js +2330 -2505
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/collections-B_DisSfA.js.map +0 -1
- package/dist/chunks/constants-iej3WkEa.js +0 -6
- package/dist/chunks/constants-iej3WkEa.js.map +0 -1
- package/dist/chunks/generate-8FS2ROOJ.js +0 -170
- package/dist/chunks/generate-8FS2ROOJ.js.map +0 -1
- package/dist/chunks/generate-jx5Iuq5w.js.map +0 -1
- package/dist/chunks/generate.runtime-DdcVnK8J.js.map +0 -1
- package/dist/chunks/generate.runtime-N1KtAG8C.js.map +0 -1
- package/dist/chunks/generate.runtime-aN5QWygO.js.map +0 -1
- package/dist/chunks/shopify-page-D-VFwGxI.js +0 -11
- package/dist/chunks/shopify-page-D-VFwGxI.js.map +0 -1
- package/dist/chunks/write-result-0HYIr5a6.js +0 -511
- package/dist/chunks/write-result-0HYIr5a6.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,9 +15,10 @@ SvelteKit 3. A project with a `svelte.config.*`, or with options still nested un
|
|
|
15
15
|
reads one declares it in `src/env.ts` (`modifyEnvVars` in `src/runtime/env-vars.ts`, creating the file when there
|
|
16
16
|
is none) as optional, `schema: (value) => value ?? ''`, so a build with an empty `.env` still passes. Existing
|
|
17
17
|
entries are never changed; `disable-*` removes the names its `enable-*` declares.
|
|
18
|
-
- formsnap 2
|
|
19
|
-
|
|
20
|
-
and
|
|
18
|
+
- formsnap 2.1 is the first release whose superforms peer admits 3.x. Installing formsnap, or superforms into a
|
|
19
|
+
project that has it, first moves a `3.0.0-next` superforms pin to the release, raises a formsnap range below 2.1
|
|
20
|
+
and drops the `"overrides": { "formsnap": … }` entry earlier releases wrote for formsnap 2.0; otherwise npm stops
|
|
21
|
+
with ERESOLVE or keeps the lockfile's formsnap 2.0. superforms and flash-message are installed with `--save-exact`.
|
|
21
22
|
|
|
22
23
|
## Runtime
|
|
23
24
|
|
|
@@ -117,6 +118,17 @@ pattern supports per capability (`{ payments: ["stripe"] }`). A provider can car
|
|
|
117
118
|
over the pattern's. `unmetRequirements(pattern, { features, detected, provider })` lists what a project is
|
|
118
119
|
missing. Only `true` flags count, and `false` means "not required". `ui` is checked separately.
|
|
119
120
|
|
|
121
|
+
`blockedBy` is the other direction: the features that must be off before a pattern runs, because their code
|
|
122
|
+
imports what it removes (`disable-payments` is blocked by `ecommerce`, whose cart imports the payments client).
|
|
123
|
+
`blockingFeatures(pattern, features)` lists the ones a project has on; the CLI and the harness refuse while it
|
|
124
|
+
is not empty. `ecommerce` itself is a feature flag detected from `src/lib/cart.svelte.ts`.
|
|
125
|
+
|
|
126
|
+
A sibling root beside `providers/` holds a variant of one provider's files for a project state the base files
|
|
127
|
+
can't assume: `providers-app-mode/<id>/` when auth is on, `providers-cms/<id>/` when the CMS is, `providers-i18n/<id>/` when wuchale is (a server
|
|
128
|
+
load then takes the page's language from the URL, as enable-cms's layout load does). `generate.ts` adds the
|
|
129
|
+
sibling's files over the base ones; `allProviderPaths` and the `SHIPPED` directory test already cover
|
|
130
|
+
`providers-*`, and the new root goes in the `tsconfig.json` / `vite.config.ts` excludes.
|
|
131
|
+
|
|
120
132
|
The generated code never sees any of this. Each provider's files are what a developer would write for that
|
|
121
133
|
provider alone, with no adapter layer or shared types for swapping providers.
|
|
122
134
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
|
-
import { i as t, o as n, r } from "./ts-morph-helpers-
|
|
3
|
-
import { t as i } from "./package-imports-
|
|
2
|
+
import { i as t, o as n, r } from "./ts-morph-helpers-CHI9wAil.js";
|
|
3
|
+
import { t as i } from "./package-imports-B9Asv3ZH.js";
|
|
4
4
|
import a from "node:fs";
|
|
5
5
|
import o from "node:path";
|
|
6
6
|
import { Project as s, QuoteKind as c } from "ts-morph";
|
|
@@ -59,4 +59,4 @@ function h(e) {
|
|
|
59
59
|
//#endregion
|
|
60
60
|
export { u as i, h as n, l as r, f as t };
|
|
61
61
|
|
|
62
|
-
//# sourceMappingURL=_layout-
|
|
62
|
+
//# sourceMappingURL=_layout-DQhSAhfF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_layout-
|
|
1
|
+
{"version":3,"file":"_layout-DQhSAhfF.js","names":["dedent","ensureNamedImport","formatLikeSource","ensurePackageImports","fs","path","LOCALES_IMPORTS","modifyPackageImportsI18n","root","IMPORT_SNIPPET","LOAD_STATEMENT","LOAD_SNIPPET","FAILURE_HINT","ensureRootLayoutI18n","layoutPath","existing","sourceFile","Project","QuoteKind","ensureImports"],"sources":["../../src/patterns/enable/i18n/modifies/package-imports.ts","../../src/patterns/enable/i18n/modifies/+layout.ts"],"sourcesContent":["import {\n ensurePackageImports,\n type PackageJsonEditResult,\n} from \"../../../../runtime/package-imports\";\n\n/**\n * The package.json `imports` entry the app's `#locales/*.js` specifiers\n * resolve through. wuchale writes its loaders and data to `src/locales`;\n * SvelteKit 3 deprecates `alias`, so the directory is mapped the way `#lib`\n * is. wuchale's own generated imports are relative and never go through it.\n */\nexport const LOCALES_IMPORTS = { \"#locales/*\": \"./src/locales/*\" };\n\n/** Add `#locales/*` to package.json `imports`; a different value already there is reported. */\nexport function modifyPackageImportsI18n(root: string): PackageJsonEditResult {\n return ensurePackageImports(root, LOCALES_IMPORTS);\n}\n","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 {\n ensureImports,\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst IMPORT_SNIPPET = dedent`\n import { browser } from '$app/env';\n import { loadLocale } from 'wuchale/load-utils';\n\n import { getLocale } from '#locales/main.url.js';\n import '#locales/main.loader.svelte.js';\n import '#locales/js.loader.js';\n`;\n\n/** The load `disable-i18n` looks for to take it out again. */\nexport const LOAD_STATEMENT = dedent`\n export const load = async ({ url, data }) => {\n const locale = getLocale(url);\n\n if (browser) {\n await loadLocale(locale);\n }\n\n return data;\n };\n`;\n\n/** The whole file, for a project that had no root `+layout.ts`. */\nexport const LOAD_SNIPPET = `${IMPORT_SNIPPET}\\n\\n${LOAD_STATEMENT}`;\n\nconst FAILURE_HINT = [\n \"Merge the wuchale loader into your existing load function in +layout.ts:\",\n \"\",\n LOAD_SNIPPET,\n].join(\"\\n\");\n\nexport function ensureRootLayoutI18n(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n fs.mkdirSync(path.dirname(layoutPath), { recursive: true });\n fs.writeFileSync(layoutPath, LOAD_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const existing = fs.readFileSync(layoutPath, \"utf8\");\n if (existing.includes(\"loadLocale\") || existing.includes(\"translateUrl\")) {\n return { status: \"success\", changed: false };\n }\n\n if (/\\bexport\\s+(const|function)\\s+load\\b/.test(existing)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // No load to merge with, but the file may hold other route options\n // (`export const prerender = true`, say), so the load is added to it\n // rather than written over it.\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n ensureNamedImport(sourceFile, \"$app/env\", \"browser\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils\", \"loadLocale\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"getLocale\");\n ensureImports(sourceFile, [\n { moduleSpecifier: \"#locales/main.loader.svelte.js\" },\n { moduleSpecifier: \"#locales/js.loader.js\" },\n ]);\n\n sourceFile.addStatements(`\\n${LOAD_STATEMENT}\\n`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;;;;;;AAWA,IAAaM,IAAkB,EAAE,cAAc,kBAAkB;AAGjE,SAAgBC,EAAyB,GAAqC;CAC5E,OAAOJ,EAAqBK,GAAMF,CAAe;AACnD;;;ACLA,IAAMG,IAAiB,CAAM;;;;;;;GAUhBC,IAAiB,CAAM;;;;;;;;;;GAavBC,IAAe,GAAGF,EAAe,MAAMC,KAE9CE,IAAe;CACnB;CACA;CACAD;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgBE,EAAqB,GAAmC;CACtE,IAAI,CAACT,EAAG,WAAWU,CAAU,GAG3B,OAFAV,EAAG,UAAUC,EAAK,QAAQS,CAAU,GAAG,EAAE,WAAW,GAAK,CAAC,GAC1DV,EAAG,cAAcU,GAAYH,IAAe,IAAI,GACzC;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMI,IAAWX,EAAG,aAAaU,GAAY,MAAM;CACnD,IAAIC,EAAS,SAAS,YAAY,KAAKA,EAAS,SAAS,cAAc,GACrE,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAI,uCAAuC,KAAKA,CAAQ,GACtD,OAAO;EAAE,QAAQ;EAAU,SAASH;CAAa;CAUnD,IAAMI,IAAa,IAJCC,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBJ,CAAU;CAazD,OAXAb,EAAkBe,GAAY,YAAY,SAAS,GACnDf,EAAkBe,GAAY,sBAAsB,YAAY,GAChEf,EAAkBe,GAAY,wBAAwB,WAAW,GACjEG,EAAcH,GAAY,CACxB,EAAE,iBAAiB,iCAAiC,GACpD,EAAE,iBAAiB,wBAAwB,CAC7C,CAAC,GAEDA,EAAW,cAAc,KAAKN,EAAe,GAAG,GAChDR,EAAiBc,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $ as e, $t as t, A as n, At as r, B as i, Bt as a, C as o, Ct as s, D as ee, Dt as te, E as ne, Et as re, F as ie, Ft as ae, G as oe, Gt as se, H as ce, Ht as le, I as ue, It as c, J as l, Jt as u, K as d, Kt as f, L as p, Lt as m, M as h, Mt as g, N as _, Nt as v, O as y, Ot as b, P as x, Pt as S, Q as C, Qt as w, R as T, Rt as E, S as D, St as O, T as k, Tt as A, U as j, Ut as M, V as N, Vt as P, W as F, Wt as I, X as L, Xt as R, Y as z, Yt as B, Z as V, Zt as H, _ as U, _n as de, _t as fe, a as pe, an as me, at as he, b as ge, bt as _e, c as ve, cn as ye, ct as be, d as xe, dn as Se, dt as Ce, en as we, et as Te, f as Ee, fn as De, ft as Oe, g as ke, gn as Ae, gt as je, h as Me, hn as Ne, ht as Pe, i as Fe, in as Ie, it as Le, j as Re, jt as ze, k as Be, kt as Ve, l as He, ln as Ue, lt as W, m as We, mn as Ge, mt as Ke, n as qe, nn as Je, nt as Ye, o as Xe, on as Ze, ot as Qe, p as $e, pn as et, pt as tt, q as nt, qt as rt, r as it, rn as at, rt as ot, s as st, sn as ct, st as lt, t as ut, tn as dt, tt as ft, u as pt, un as mt, ut as ht, v as gt, vn as _t, vt, w as yt, wt as bt, x as xt, xt as St, y as Ct, yn as wt, yt as Tt, z as Et, zt as Dt } from "./_page-C7kGoW7_.js";
|
|
2
|
-
import { t as Ot } from "./modify-user-signup-
|
|
2
|
+
import { t as Ot } from "./modify-user-signup-DLtopazD.js";
|
|
3
3
|
import G from "node:fs";
|
|
4
4
|
import K from "node:path";
|
|
5
5
|
import kt from "prettier";
|
|
@@ -257,14 +257,11 @@ function tn(e, t, n) {
|
|
|
257
257
|
for (let a of $t[e]) {
|
|
258
258
|
let e = $(Zt, a, t), o = en(a, t);
|
|
259
259
|
if (e && o) {
|
|
260
|
-
if (n === "disable") {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
continue;
|
|
266
|
-
}
|
|
267
|
-
for (let n of [o, $(Xt, a, t)]) n && !i.has(n) && (i.add(n), r.push({
|
|
260
|
+
if (n === "disable") i.has(e) || r.push({
|
|
261
|
+
original: e,
|
|
262
|
+
template: o
|
|
263
|
+
}), i.add(e);
|
|
264
|
+
else for (let n of [o, $(Xt, a, t)]) n && !i.has(n) && (i.add(n), r.push({
|
|
268
265
|
original: n,
|
|
269
266
|
template: e
|
|
270
267
|
}));
|
|
@@ -288,4 +285,4 @@ async function rn(e, t, n) {
|
|
|
288
285
|
//#endregion
|
|
289
286
|
export { Q as detectMode, rn as swapAuthPages };
|
|
290
287
|
|
|
291
|
-
//# sourceMappingURL=auth-pages-
|
|
288
|
+
//# sourceMappingURL=auth-pages-jsyDV1GR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-pages-B52ei-4z.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__0_4_","__import_glob__0_5_","__import_glob__0_6_","__import_glob__0_7_","__import_glob__0_8_","__import_glob__0_9_","__import_glob__0_10_","__import_glob__0_11_","__import_glob__0_12_","__import_glob__0_13_","__import_glob__0_14_","__import_glob__0_15_","__import_glob__0_16_","__import_glob__0_18_","__import_glob__0_19_","__import_glob__0_20_","__import_glob__0_21_","__import_glob__0_22_","__import_glob__0_23_","__import_glob__0_24_","__import_glob__0_25_","__import_glob__0_26_","__import_glob__0_27_","__import_glob__0_28_","__import_glob__0_29_","__import_glob__0_30_","__import_glob__0_31_","__import_glob__0_32_","__import_glob__0_33_","__import_glob__0_34_","__import_glob__0_35_","__import_glob__0_36_","__import_glob__0_37_","__import_glob__0_38_","__import_glob__0_39_","__import_glob__0_40_","__import_glob__0_41_","__import_glob__0_42_","__import_glob__0_43_","__import_glob__0_44_","__import_glob__0_45_","__import_glob__0_46_","__import_glob__0_47_","__import_glob__0_48_","__import_glob__0_49_","__import_glob__0_50_","__import_glob__0_51_","__import_glob__0_52_","__import_glob__0_53_","__import_glob__0_54_","__import_glob__0_55_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__2_0_","__import_glob__2_1_","__import_glob__2_2_","__import_glob__2_3_","__import_glob__2_4_","__import_glob__2_5_","__import_glob__2_6_","__import_glob__2_7_","__import_glob__2_8_","__import_glob__2_9_","__import_glob__2_10_","__import_glob__2_11_","__import_glob__2_12_","__import_glob__2_13_","__import_glob__2_14_","__import_glob__2_15_","__import_glob__2_16_","__import_glob__2_18_","__import_glob__2_19_","__import_glob__2_20_","__import_glob__2_21_","__import_glob__2_22_","__import_glob__2_23_","__import_glob__2_24_","__import_glob__2_25_","__import_glob__2_26_","__import_glob__2_27_","__import_glob__2_28_","__import_glob__2_29_","__import_glob__2_30_","__import_glob__2_31_","__import_glob__2_32_","__import_glob__2_33_","__import_glob__2_34_","__import_glob__2_35_","__import_glob__2_36_","__import_glob__2_37_","__import_glob__2_38_","__import_glob__2_39_","__import_glob__2_40_","__import_glob__2_41_","__import_glob__2_42_","__import_glob__2_43_","__import_glob__2_44_","__import_glob__2_45_","__import_glob__2_46_","__import_glob__2_47_","__import_glob__2_48_","__import_glob__2_49_","__import_glob__2_50_","__import_glob__2_51_","__import_glob__2_52_","__import_glob__2_53_","__import_glob__2_54_","__import_glob__2_55_","__import_glob__2_56_","__import_glob__2_57_","__import_glob__2_58_","__import_glob__2_59_","__import_glob__2_60_","__import_glob__2_61_","__import_glob__2_62_","__import_glob__2_63_","__import_glob__2_64_","__import_glob__3_0_","__import_glob__3_1_","__import_glob__3_2_","__import_glob__3_3_","__import_glob__3_4_","__import_glob__3_5_","__import_glob__3_6_","__import_glob__4_0_","__import_glob__4_1_","__import_glob__4_2_","__import_glob__4_3_","__import_glob__4_4_","__import_glob__4_5_","__import_glob__4_6_","__import_glob__4_7_","__import_glob__4_8_","__import_glob__4_9_","__import_glob__4_10_","__import_glob__4_11_","__import_glob__4_12_","__import_glob__4_13_","__import_glob__4_14_","__import_glob__4_15_","_page_default$26","_page_server_default$3","server_test_default$14","_page_server_default$8","_page_default$31","_page_server_default$6","server_test_default$16","server_test_default$8","_page_server_default$15","server_test_default$7","_page_default$35","_page_server_default$9","server_test_default$13","server_test_default$5","_page_default$29","_page_default$12","server_test_default$11","_server_default","_server_default$2","_server_default$1","_page_default$28","_page_default$11","_page_server_default$12","_page_server_default$5","server_test_default$12","server_test_default$4","_page_default$34","_page_default$17","_page_default$33","_page_default$16","server_test_default$15","_page_default$19","_page_server_default$14","_page_server_default$7","server_test_default$10","_page_default$8","form_remote_default$5","_page_default$15","_page_server_default$16","_page_server_default$10","_page_default$36","_page_default$20","form_remote_default$4","server_test_default$2","_page_server_default$13","server_test_default$3","_page_default$30","_page_default$13","_page_server_default$11","_page_server_default$4","_page_default$27","_page_default$10","_layout_server_default$3","_page_default$9","_page_server_default$17","nav_user_default","_page_default$25","signup_default$5","user_default","reset_default$1","_page_default$38","_page_default$23","next_url_default","reset_default","login_default$2","_page_default$41","login_default$1","changePassword_default$1","_layout_server_default$1","_layout_default$1","_page_server_default$18","confirmReset_default","changeEmail_default$1","_page_default$39","user_avatar_default","app_sidebar_default$1","_page_default$40","changeEmail_default","nav_main_default$1","_page_server_default$19","_layout_server_default","signup_default$4","form_remote_default$6","server_test_default$6","_server_default$3","_page_default$18","form_remote_default$10","profile_default","confirmReset_default$1","form_remote_default$9","changePassword_default","nav_user_default$1","_page_server_default$20","_page_default$7","user_default$1","login_default$3","welcome_default","profile_default$1","server_test_default$18","confirmEmailChange_default","user_avatar_default$1","form_remote_default$3","server_test_default$1","_page_default$43","_layout_default","welcome_default$1","server_test_default$19","signup_default$3","otp_default$1","_page_default$44","server_test_default","_layout_server_default$2","_page_default$42","otp_default","confirmEmailChange_default$1","server_test_default$17","nav_main_default","form_remote_default$7","_page_default$21","_page_default$37","_page_default$22","form_remote_default$8","app_sidebar_default","server_test_default$9","_page_default$32","_page_default$14","modifyUserSignup","fs","path","prettier","sveltePlugin","signup_default$2","_page_server_default$2","_page_default$6","signup_default$1","_page_default$5","form_remote_default$2","_page_default$4","login_default","signup_default","_page_server_default$1","_page_default$3","form_remote_default$1","_page_server_default","_page_default$2","form_remote_default","_page_default$1","_page_default","normalize","content","filePath","planFile","current","marker","normalized","overlay","overlays","candidate","candidates","original","applyGroup","outcomes","blocked","planned","p","outcome","hint","others","raw","glob","key","prefix","STOCK","_page_default$24","LEGACY","TEMPLATES","WHATSAPP_CODE","AUTH","pageGroups","group","name","mode","detectMode","root","SHAPES","pick","files","shape","rel","stock","candidatesFor","seen","whatsapp","direction","PAYMENTS_SIGNUP","swapAuthPages"],"sources":["../../src/patterns/enable/whatsapp/modifies/modify-by-original.ts","../../src/patterns/enable/whatsapp/modifies/auth-pages.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport prettier from \"prettier\";\nimport sveltePlugin from \"prettier-plugin-svelte\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** A stock version of a file, and what it becomes. */\nexport interface Candidate {\n original: string;\n template: string;\n}\n\n/**\n * Another pattern's edit to the file that the swap carries over: `strip`\n * takes it out of the normalized source to compare that against the\n * originals, `apply` puts it back into the written template.\n */\nexport interface Overlay {\n /** Whether the current file has the edit. */\n detect: (content: string) => boolean;\n /** Gets the normalized source (prettier defaults), returns it without the edit. */\n strip: (normalized: string) => string;\n apply: (filePath: string) => ModifyOutcome;\n}\n\n/** One file of a group, and the swap decided for it. */\nexport interface Planned {\n filePath: string;\n outcome:\n | { kind: \"write\"; template: string; overlay?: Overlay }\n | { kind: \"done\" }\n | { kind: \"missing\" }\n | { kind: \"customized\" };\n}\n\n/**\n * Reprints a source with fixed settings, so the project's own prettier\n * config (tabs, quotes, print width) does not count as a change. Content\n * prettier cannot parse is compared as is.\n */\nasync function normalize(content: string, filePath: string): Promise<string> {\n try {\n return await prettier.format(content, {\n filepath: filePath,\n plugins: [sveltePlugin],\n });\n } catch {\n return content;\n }\n}\n\n/**\n * Decides what to do with one file: `write` the template of the stock\n * original it still matches, `done` when it already has `marker`, else\n * `customized`. A file with an overlay's edit is compared without it.\n */\nexport async function planFile(\n filePath: string,\n candidates: Candidate[],\n marker: RegExp,\n overlays: Overlay[] = [],\n): Promise<Planned> {\n if (!fs.existsSync(filePath)) {\n return { filePath, outcome: { kind: \"missing\" } };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (marker.test(current)) {\n return { filePath, outcome: { kind: \"done\" } };\n }\n\n let normalized = await normalize(current, filePath);\n const overlay = overlays.find((candidate) => candidate.detect(current));\n if (overlay) normalized = overlay.strip(normalized);\n\n for (const { original, template } of candidates) {\n if ((await normalize(original, filePath)) === normalized) {\n return { filePath, outcome: { kind: \"write\", template, overlay } };\n }\n }\n return { filePath, outcome: { kind: \"customized\" } };\n}\n\n/**\n * Applies a group of planned swaps (a page with its server code and schema)\n * all or nothing: one customized or missing file leaves the whole group as\n * it is, since half a swap would not type-check.\n */\nexport function applyGroup(\n planned: Planned[],\n hint: (filePath: string) => string,\n): Map<string, ModifyOutcome> {\n const outcomes = new Map<string, ModifyOutcome>();\n const blocked = planned.filter(\n (p) => p.outcome.kind === \"customized\" || p.outcome.kind === \"missing\",\n );\n\n for (const { filePath, outcome } of planned) {\n if (outcome.kind === \"missing\") {\n outcomes.set(filePath, { status: \"not-found\", message: hint(filePath) });\n } else if (outcome.kind === \"customized\") {\n outcomes.set(filePath, { status: \"failed\", message: hint(filePath) });\n } else if (outcome.kind === \"done\") {\n outcomes.set(filePath, { status: \"success\", changed: false });\n } else if (blocked.length > 0) {\n const others = blocked\n .map(\n (p) =>\n path.basename(path.dirname(p.filePath)) +\n \"/\" +\n path.basename(p.filePath),\n )\n .join(\", \");\n outcomes.set(filePath, {\n status: \"failed\",\n message: `Left as is, along with ${others}, which has changes of its own.\\n${hint(filePath)}`,\n });\n } else {\n fs.writeFileSync(filePath, outcome.template, \"utf8\");\n outcome.overlay?.apply(filePath);\n outcomes.set(filePath, { status: \"success\", changed: true });\n }\n }\n return outcomes;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { modifyUserSignup } from \"../../payments/modifies/modify-user-signup\";\nimport {\n applyGroup,\n planFile,\n type Candidate,\n type Overlay,\n} from \"./modify-by-original\";\n\n/**\n * The login and signup pages as enable-auth writes them, and with WhatsApp.\n * The stock files come straight from the auth patterns, so a change there\n * that is not mirrored in `templates/` fails the tests instead of drifting.\n */\nconst raw = (glob: Record<string, string>, prefix: string) =>\n Object.fromEntries(\n Object.entries(glob).map(([key, content]) => [\n key.slice(prefix.length),\n content,\n ]),\n );\n\nconst STOCK = {\n base: raw(\n import.meta.glob<string>(\"../../auth/creates/src/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../../auth/creates/\",\n ),\n split: raw(\n import.meta.glob<string>(\"../../auth/variants/split/src/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../../auth/variants/split/\",\n ),\n remote: raw(\n import.meta.glob<string>(\"../../auth-remote/creates/src/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../../auth-remote/creates/\",\n ),\n};\n\n/** The pages enable-auth 1.1 wrote, before signup had a one-time code. */\nconst LEGACY = raw(\n import.meta.glob<string>(\"../originals/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../originals/auth-1.1/\",\n);\n\nconst TEMPLATES = raw(\n import.meta.glob<string>(\"../templates/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../templates/\",\n);\n\ntype Shape = \"base\" | \"split\" | \"remote\";\n\n/** In every file of the WhatsApp versions: the form type, or the helpers. */\nconst WHATSAPP_CODE = /[\"']whatsapp[\"']|whatsappAuthMethod|requestWhatsAppOTP/;\nexport type Mode = \"superforms\" | \"remote\";\n\nconst AUTH = \"src/routes/(public)/(auth)\";\n\n/** The files of each form, all swapped or none. */\nexport function pageGroups(mode: Mode): Record<\"login\" | \"signup\", string[]> {\n const group = (name: \"login\" | \"signup\") => [\n `${AUTH}/${name}/+page.svelte`,\n `${AUTH}/${name}/+page.server.ts`,\n ...(mode === \"remote\" ? [`${AUTH}/${name}/form.remote.ts`] : []),\n `src/lib/schemas/${name}.ts`,\n ];\n return { login: group(\"login\"), signup: group(\"signup\") };\n}\n\n/** A login form posts to a remote function in auth-remote projects. */\nexport function detectMode(root: string): Mode {\n return fs.existsSync(path.join(root, AUTH, \"login\", \"form.remote.ts\"))\n ? \"remote\"\n : \"superforms\";\n}\n\nconst SHAPES: Record<Mode, Shape[]> = {\n superforms: [\"base\", \"split\"],\n remote: [\"remote\"],\n};\n\n/** The split variant only has its own pages; the rest is the base one. */\nfunction pick(\n files: Record<string, string>,\n shape: Shape,\n rel: string,\n): string | undefined {\n return (\n files[`${shape}/${rel}`] ??\n (shape === \"split\" ? files[`base/${rel}`] : undefined)\n );\n}\n\nfunction stock(shape: Shape, rel: string): string | undefined {\n return STOCK[shape][rel] ?? (shape === \"split\" ? STOCK.base[rel] : undefined);\n}\n\n/**\n * Every stock version of `rel` paired with its WhatsApp version: the current\n * and the legacy original of each shape on `enable`, and the WhatsApp version\n * paired with the current stock one on `disable`.\n */\nexport function candidatesFor(\n mode: Mode,\n rel: string,\n direction: \"enable\" | \"disable\",\n): Candidate[] {\n const candidates: Candidate[] = [];\n const seen = new Set<string>();\n for (const shape of SHAPES[mode]) {\n const whatsapp = pick(TEMPLATES, shape, rel);\n const current = stock(shape, rel);\n if (!whatsapp || !current) continue;\n if (direction === \"disable\") {\n if (!seen.has(whatsapp))\n candidates.push({ original: whatsapp, template: current });\n seen.add(whatsapp);\n continue;\n }\n for (const original of [current, pick(LEGACY, shape, rel)]) {\n if (!original || seen.has(original)) continue;\n seen.add(original);\n candidates.push({ original, template: whatsapp });\n }\n }\n return candidates;\n}\n\n/**\n * enable-payments' signup hook, carried over the swap: its import and the\n * `linkStripeCustomer.run(...)` call (comment included) it adds before\n * `requestVerification`.\n */\nconst PAYMENTS_SIGNUP: Overlay = {\n detect: (content) => content.includes(\"linkStripeCustomer\"),\n strip: (normalized) =>\n normalized\n .replace(\n /^import \\{ linkStripeCustomer \\} from \"#lib\\/workflows\\/link-stripe-customer\\.js\";\\n/m,\n \"\",\n )\n .replace(\n /^[ \\t]*\\/\\/ Queued here, done in the background[^\\n]*\\n[ \\t]*\\/\\/ and the key means[^\\n]*\\n[ \\t]*await linkStripeCustomer\\.run\\([\\s\\S]*?\\n[ \\t]*\\);\\n\\n?/m,\n \"\",\n ),\n apply: modifyUserSignup,\n};\n\n/**\n * Swaps the login and signup pages between the stock and WhatsApp versions.\n * A form whose files all still match a known version is swapped; one with\n * changes of its own is left alone and reported with `hint`.\n */\nexport async function swapAuthPages(\n root: string,\n direction: \"enable\" | \"disable\",\n hint: (filePath: string) => string,\n): Promise<Map<string, ModifyOutcome>> {\n const mode = detectMode(root);\n // Code only the WhatsApp versions have (not a comment that mentions it):\n // enabling skips files with it, disabling files without it.\n const marker =\n direction === \"enable\"\n ? WHATSAPP_CODE\n : new RegExp(`^(?![\\\\s\\\\S]*(${WHATSAPP_CODE.source}))`);\n const outcomes = new Map<string, ModifyOutcome>();\n\n for (const files of Object.values(pageGroups(mode))) {\n const planned = await Promise.all(\n files.map((rel) =>\n planFile(\n path.join(root, rel),\n candidatesFor(mode, rel, direction),\n marker,\n rel.endsWith(\"signup/+page.server.ts\") ? [PAYMENTS_SIGNUP] : [],\n ),\n ),\n );\n for (const [filePath, outcome] of applyGroup(planned, hint)) {\n outcomes.set(filePath, outcome);\n }\n }\n return outcomes;\n}\n"],"mappings":";;;;;;;;;;AAwCA,eAAeoS,EAAU,GAAiB,GAAmC;CAC3E,IAAI;EACF,OAAO,MAAMnB,GAAS,OAAOoB,GAAS;GACpC,UAAUC;GACV,SAAS,CAACpB,EAAY;EACxB,CAAC;CACH,QAAQ;EACN,OAAOmB;CACT;AACF;AAOA,eAAsBE,GACpB,GACA,GACA,GACA,IAAsB,CAAC,GACL;CAClB,IAAI,CAACxB,EAAG,WAAWuB,CAAQ,GACzB,OAAO;EAAE;EAAU,SAAS,EAAE,MAAM,UAAU;CAAE;CAElD,IAAME,IAAUzB,EAAG,aAAauB,GAAU,MAAM;CAChD,IAAIG,EAAO,KAAKD,CAAO,GACrB,OAAO;EAAE;EAAU,SAAS,EAAE,MAAM,OAAO;CAAE;CAG/C,IAAIE,IAAa,MAAMN,EAAUI,GAASF,CAAQ,GAC5CK,IAAUC,EAAS,MAAM,MAAcC,EAAU,OAAOL,CAAO,CAAC;CACtE,AAAIG,MAAS,IAAaA,EAAQ,MAAMD,CAAU;CAElD,KAAK,IAAM,EAAE,aAAU,iBAAcI,GACnC,IAAK,MAAMV,EAAUW,GAAUT,CAAQ,MAAOI,GAC5C,OAAO;EAAE;EAAU,SAAS;GAAE,MAAM;GAAS;GAAU;EAAQ;CAAE;CAGrE,OAAO;EAAE;EAAU,SAAS,EAAE,MAAM,aAAa;CAAE;AACrD;AAOA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CAMF;CACA,OAAOlC;AACT;AAOA,IAAMoC,KAA2B;CAC/B,SAAS,MAAY7C,EAAQ,SAAS,oBAAoB;CAC1D,QAAQ,MACNK,EACG,QACC,yFACA,EACF,CAAC,CACA,QACC,6JACA,EACF;CACJ,OAAO5B;AACT;AAOA,eAAsBqE,GACpB,GACA,GACA,GACqC;CACrC,IAAMd,IAAOC,EAAWC,CAAI,GAGtB9B,IACJwC,MAAc,WACVjB,IACI,OAAO,iBAAiBA,EAAc,OAAO,GAAG,GACpDf,oBAAW,IAAI,IAA2B;CAEhD,KAAK,IAAMyB,KAAS,OAAO,OAAOR,GAAWG,CAAI,CAAC,GAAG;EACnD,IAAMlB,IAAU,MAAM,QAAQ,IAC5BuB,EAAM,KAAK,MACTnC,GACEvB,EAAK,KAAKuD,GAAMK,CAAG,GACnBE,GAAcT,GAAMO,GAAKK,CAAS,GAClCxC,GACAmC,EAAI,SAAS,wBAAwB,IAAI,CAACM,EAAe,IAAI,CAAC,CAChE,CACF,CACF;EACA,KAAK,IAAM,CAAC5C,GAAUe,MAAYL,GAAWG,GAASG,CAAI,GACxD,EAAS,IAAIhB,GAAUe,CAAO;CAElC;CACA,OAAOJ;AACT"}
|
|
1
|
+
{"version":3,"file":"auth-pages-jsyDV1GR.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__0_4_","__import_glob__0_5_","__import_glob__0_6_","__import_glob__0_7_","__import_glob__0_8_","__import_glob__0_9_","__import_glob__0_10_","__import_glob__0_11_","__import_glob__0_12_","__import_glob__0_13_","__import_glob__0_14_","__import_glob__0_15_","__import_glob__0_16_","__import_glob__0_18_","__import_glob__0_19_","__import_glob__0_20_","__import_glob__0_21_","__import_glob__0_22_","__import_glob__0_23_","__import_glob__0_24_","__import_glob__0_25_","__import_glob__0_26_","__import_glob__0_27_","__import_glob__0_28_","__import_glob__0_29_","__import_glob__0_30_","__import_glob__0_31_","__import_glob__0_32_","__import_glob__0_33_","__import_glob__0_34_","__import_glob__0_35_","__import_glob__0_36_","__import_glob__0_37_","__import_glob__0_38_","__import_glob__0_39_","__import_glob__0_40_","__import_glob__0_41_","__import_glob__0_42_","__import_glob__0_43_","__import_glob__0_44_","__import_glob__0_45_","__import_glob__0_46_","__import_glob__0_47_","__import_glob__0_48_","__import_glob__0_49_","__import_glob__0_50_","__import_glob__0_51_","__import_glob__0_52_","__import_glob__0_53_","__import_glob__0_54_","__import_glob__0_55_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__2_0_","__import_glob__2_1_","__import_glob__2_2_","__import_glob__2_3_","__import_glob__2_4_","__import_glob__2_5_","__import_glob__2_6_","__import_glob__2_7_","__import_glob__2_8_","__import_glob__2_9_","__import_glob__2_10_","__import_glob__2_11_","__import_glob__2_12_","__import_glob__2_13_","__import_glob__2_14_","__import_glob__2_15_","__import_glob__2_16_","__import_glob__2_18_","__import_glob__2_19_","__import_glob__2_20_","__import_glob__2_21_","__import_glob__2_22_","__import_glob__2_23_","__import_glob__2_24_","__import_glob__2_25_","__import_glob__2_26_","__import_glob__2_27_","__import_glob__2_28_","__import_glob__2_29_","__import_glob__2_30_","__import_glob__2_31_","__import_glob__2_32_","__import_glob__2_33_","__import_glob__2_34_","__import_glob__2_35_","__import_glob__2_36_","__import_glob__2_37_","__import_glob__2_38_","__import_glob__2_39_","__import_glob__2_40_","__import_glob__2_41_","__import_glob__2_42_","__import_glob__2_43_","__import_glob__2_44_","__import_glob__2_45_","__import_glob__2_46_","__import_glob__2_47_","__import_glob__2_48_","__import_glob__2_49_","__import_glob__2_50_","__import_glob__2_51_","__import_glob__2_52_","__import_glob__2_53_","__import_glob__2_54_","__import_glob__2_55_","__import_glob__2_56_","__import_glob__2_57_","__import_glob__2_58_","__import_glob__2_59_","__import_glob__2_60_","__import_glob__2_61_","__import_glob__2_62_","__import_glob__2_63_","__import_glob__2_64_","__import_glob__3_0_","__import_glob__3_1_","__import_glob__3_2_","__import_glob__3_3_","__import_glob__3_4_","__import_glob__3_5_","__import_glob__3_6_","__import_glob__4_0_","__import_glob__4_1_","__import_glob__4_2_","__import_glob__4_3_","__import_glob__4_4_","__import_glob__4_5_","__import_glob__4_6_","__import_glob__4_7_","__import_glob__4_8_","__import_glob__4_9_","__import_glob__4_10_","__import_glob__4_11_","__import_glob__4_12_","__import_glob__4_13_","__import_glob__4_14_","__import_glob__4_15_","_page_default$26","_page_server_default$3","server_test_default$14","_page_server_default$8","_page_default$31","_page_server_default$6","server_test_default$16","server_test_default$8","_page_server_default$15","server_test_default$7","_page_default$35","_page_server_default$9","server_test_default$13","server_test_default$5","_page_default$29","_page_default$12","server_test_default$11","_server_default","_server_default$2","_server_default$1","_page_default$28","_page_default$11","_page_server_default$12","_page_server_default$5","server_test_default$12","server_test_default$4","_page_default$34","_page_default$17","_page_default$33","_page_default$16","server_test_default$15","_page_default$19","_page_server_default$14","_page_server_default$7","server_test_default$10","_page_default$8","form_remote_default$5","_page_default$15","_page_server_default$16","_page_server_default$10","_page_default$36","_page_default$20","form_remote_default$4","server_test_default$2","_page_server_default$13","server_test_default$3","_page_default$30","_page_default$13","_page_server_default$11","_page_server_default$4","_page_default$27","_page_default$10","_layout_server_default$3","_page_default$9","_page_server_default$17","nav_user_default","_page_default$25","signup_default$5","user_default","reset_default$1","_page_default$38","_page_default$23","next_url_default","reset_default","login_default$2","_page_default$41","login_default$1","changePassword_default$1","_layout_server_default$1","_layout_default$1","_page_server_default$18","confirmReset_default","changeEmail_default$1","_page_default$39","user_avatar_default","app_sidebar_default$1","_page_default$40","changeEmail_default","nav_main_default$1","_page_server_default$19","_layout_server_default","signup_default$4","form_remote_default$6","server_test_default$6","_server_default$3","_page_default$18","form_remote_default$10","profile_default","confirmReset_default$1","form_remote_default$9","changePassword_default","nav_user_default$1","_page_server_default$20","_page_default$7","user_default$1","login_default$3","welcome_default","profile_default$1","server_test_default$18","confirmEmailChange_default","user_avatar_default$1","form_remote_default$3","server_test_default$1","_page_default$43","_layout_default","welcome_default$1","server_test_default$19","signup_default$3","otp_default$1","_page_default$44","server_test_default","_layout_server_default$2","_page_default$42","otp_default","confirmEmailChange_default$1","server_test_default$17","nav_main_default","form_remote_default$7","_page_default$21","_page_default$37","_page_default$22","form_remote_default$8","app_sidebar_default","server_test_default$9","_page_default$32","_page_default$14","modifyUserSignup","fs","path","prettier","sveltePlugin","signup_default$2","_page_server_default$2","_page_default$6","signup_default$1","_page_default$5","form_remote_default$2","_page_default$4","login_default","signup_default","_page_server_default$1","_page_default$3","form_remote_default$1","_page_server_default","_page_default$2","form_remote_default","_page_default$1","_page_default","normalize","content","filePath","planFile","current","marker","normalized","overlay","overlays","candidate","candidates","original","applyGroup","outcomes","blocked","planned","p","outcome","hint","others","raw","glob","key","prefix","STOCK","_page_default$24","LEGACY","TEMPLATES","WHATSAPP_CODE","AUTH","pageGroups","group","name","mode","detectMode","root","SHAPES","pick","files","shape","rel","stock","candidatesFor","seen","whatsapp","direction","PAYMENTS_SIGNUP","swapAuthPages"],"sources":["../../src/patterns/enable/whatsapp/modifies/modify-by-original.ts","../../src/patterns/enable/whatsapp/modifies/auth-pages.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport prettier from \"prettier\";\nimport sveltePlugin from \"prettier-plugin-svelte\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** A stock version of a file, and what it becomes. */\nexport interface Candidate {\n original: string;\n template: string;\n}\n\n/**\n * Another pattern's edit to the file that the swap carries over: `strip`\n * takes it out of the normalized source to compare that against the\n * originals, `apply` puts it back into the written template.\n */\nexport interface Overlay {\n /** Whether the current file has the edit. */\n detect: (content: string) => boolean;\n /** Gets the normalized source (prettier defaults), returns it without the edit. */\n strip: (normalized: string) => string;\n apply: (filePath: string) => ModifyOutcome;\n}\n\n/** One file of a group, and the swap decided for it. */\nexport interface Planned {\n filePath: string;\n outcome:\n | { kind: \"write\"; template: string; overlay?: Overlay }\n | { kind: \"done\" }\n | { kind: \"missing\" }\n | { kind: \"customized\" };\n}\n\n/**\n * Reprints a source with fixed settings, so the project's own prettier\n * config (tabs, quotes, print width) does not count as a change. Content\n * prettier cannot parse is compared as is.\n */\nasync function normalize(content: string, filePath: string): Promise<string> {\n try {\n return await prettier.format(content, {\n filepath: filePath,\n plugins: [sveltePlugin],\n });\n } catch {\n return content;\n }\n}\n\n/**\n * Decides what to do with one file: `write` the template of the stock\n * original it still matches, `done` when it already has `marker`, else\n * `customized`. A file with an overlay's edit is compared without it.\n */\nexport async function planFile(\n filePath: string,\n candidates: Candidate[],\n marker: RegExp,\n overlays: Overlay[] = [],\n): Promise<Planned> {\n if (!fs.existsSync(filePath)) {\n return { filePath, outcome: { kind: \"missing\" } };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (marker.test(current)) {\n return { filePath, outcome: { kind: \"done\" } };\n }\n\n let normalized = await normalize(current, filePath);\n const overlay = overlays.find((candidate) => candidate.detect(current));\n if (overlay) normalized = overlay.strip(normalized);\n\n for (const { original, template } of candidates) {\n if ((await normalize(original, filePath)) === normalized) {\n return { filePath, outcome: { kind: \"write\", template, overlay } };\n }\n }\n return { filePath, outcome: { kind: \"customized\" } };\n}\n\n/**\n * Applies a group of planned swaps (a page with its server code and schema)\n * all or nothing: one customized or missing file leaves the whole group as\n * it is, since half a swap would not type-check.\n */\nexport function applyGroup(\n planned: Planned[],\n hint: (filePath: string) => string,\n): Map<string, ModifyOutcome> {\n const outcomes = new Map<string, ModifyOutcome>();\n const blocked = planned.filter(\n (p) => p.outcome.kind === \"customized\" || p.outcome.kind === \"missing\",\n );\n\n for (const { filePath, outcome } of planned) {\n if (outcome.kind === \"missing\") {\n outcomes.set(filePath, { status: \"not-found\", message: hint(filePath) });\n } else if (outcome.kind === \"customized\") {\n outcomes.set(filePath, { status: \"failed\", message: hint(filePath) });\n } else if (outcome.kind === \"done\") {\n outcomes.set(filePath, { status: \"success\", changed: false });\n } else if (blocked.length > 0) {\n const others = blocked\n .map(\n (p) =>\n path.basename(path.dirname(p.filePath)) +\n \"/\" +\n path.basename(p.filePath),\n )\n .join(\", \");\n outcomes.set(filePath, {\n status: \"failed\",\n message: `Left as is, along with ${others}, which has changes of its own.\\n${hint(filePath)}`,\n });\n } else {\n fs.writeFileSync(filePath, outcome.template, \"utf8\");\n outcome.overlay?.apply(filePath);\n outcomes.set(filePath, { status: \"success\", changed: true });\n }\n }\n return outcomes;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { modifyUserSignup } from \"../../payments/modifies/modify-user-signup\";\nimport {\n applyGroup,\n planFile,\n type Candidate,\n type Overlay,\n} from \"./modify-by-original\";\n\n/**\n * The login and signup pages as enable-auth writes them, and with WhatsApp.\n * The stock files come straight from the auth patterns, so a change there\n * that is not mirrored in `templates/` fails the tests instead of drifting.\n */\nconst raw = (glob: Record<string, string>, prefix: string) =>\n Object.fromEntries(\n Object.entries(glob).map(([key, content]) => [\n key.slice(prefix.length),\n content,\n ]),\n );\n\nconst STOCK = {\n base: raw(\n import.meta.glob<string>(\"../../auth/creates/src/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../../auth/creates/\",\n ),\n split: raw(\n import.meta.glob<string>(\"../../auth/variants/split/src/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../../auth/variants/split/\",\n ),\n remote: raw(\n import.meta.glob<string>(\"../../auth-remote/creates/src/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../../auth-remote/creates/\",\n ),\n};\n\n/** The pages enable-auth 1.1 wrote, before signup had a one-time code. */\nconst LEGACY = raw(\n import.meta.glob<string>(\"../originals/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../originals/auth-1.1/\",\n);\n\nconst TEMPLATES = raw(\n import.meta.glob<string>(\"../templates/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n }),\n \"../templates/\",\n);\n\ntype Shape = \"base\" | \"split\" | \"remote\";\n\n/** In every file of the WhatsApp versions: the form type, or the helpers. */\nconst WHATSAPP_CODE = /[\"']whatsapp[\"']|whatsappAuthMethod|requestWhatsAppOTP/;\nexport type Mode = \"superforms\" | \"remote\";\n\nconst AUTH = \"src/routes/(public)/(auth)\";\n\n/** The files of each form, all swapped or none. */\nexport function pageGroups(mode: Mode): Record<\"login\" | \"signup\", string[]> {\n const group = (name: \"login\" | \"signup\") => [\n `${AUTH}/${name}/+page.svelte`,\n `${AUTH}/${name}/+page.server.ts`,\n ...(mode === \"remote\" ? [`${AUTH}/${name}/form.remote.ts`] : []),\n `src/lib/schemas/${name}.ts`,\n ];\n return { login: group(\"login\"), signup: group(\"signup\") };\n}\n\n/** A login form posts to a remote function in auth-remote projects. */\nexport function detectMode(root: string): Mode {\n return fs.existsSync(path.join(root, AUTH, \"login\", \"form.remote.ts\"))\n ? \"remote\"\n : \"superforms\";\n}\n\nconst SHAPES: Record<Mode, Shape[]> = {\n superforms: [\"base\", \"split\"],\n remote: [\"remote\"],\n};\n\n/** The split variant only has its own pages; the rest is the base one. */\nfunction pick(\n files: Record<string, string>,\n shape: Shape,\n rel: string,\n): string | undefined {\n return (\n files[`${shape}/${rel}`] ??\n (shape === \"split\" ? files[`base/${rel}`] : undefined)\n );\n}\n\nfunction stock(shape: Shape, rel: string): string | undefined {\n return STOCK[shape][rel] ?? (shape === \"split\" ? STOCK.base[rel] : undefined);\n}\n\n/**\n * Every stock version of `rel` paired with its WhatsApp version: the current\n * and the legacy original of each shape on `enable`, and the WhatsApp version\n * paired with the current stock one on `disable`.\n */\nexport function candidatesFor(\n mode: Mode,\n rel: string,\n direction: \"enable\" | \"disable\",\n): Candidate[] {\n const candidates: Candidate[] = [];\n const seen = new Set<string>();\n for (const shape of SHAPES[mode]) {\n const whatsapp = pick(TEMPLATES, shape, rel);\n const current = stock(shape, rel);\n if (!whatsapp || !current) continue;\n if (direction === \"disable\") {\n if (!seen.has(whatsapp))\n candidates.push({ original: whatsapp, template: current });\n seen.add(whatsapp);\n continue;\n }\n for (const original of [current, pick(LEGACY, shape, rel)]) {\n if (!original || seen.has(original)) continue;\n seen.add(original);\n candidates.push({ original, template: whatsapp });\n }\n }\n return candidates;\n}\n\n/**\n * enable-payments' signup hook, carried over the swap: its import and the\n * `linkStripeCustomer.run(...)` call (comment included) it adds before\n * `requestVerification`.\n */\nconst PAYMENTS_SIGNUP: Overlay = {\n detect: (content) => content.includes(\"linkStripeCustomer\"),\n strip: (normalized) =>\n normalized\n .replace(\n /^import \\{ linkStripeCustomer \\} from \"#lib\\/workflows\\/link-stripe-customer\\.js\";\\n/m,\n \"\",\n )\n .replace(\n /^[ \\t]*\\/\\/ Queued here, done in the background[^\\n]*\\n[ \\t]*\\/\\/ and the key means[^\\n]*\\n[ \\t]*await linkStripeCustomer\\.run\\([\\s\\S]*?\\n[ \\t]*\\);\\n\\n?/m,\n \"\",\n ),\n apply: modifyUserSignup,\n};\n\n/**\n * Swaps the login and signup pages between the stock and WhatsApp versions.\n * A form whose files all still match a known version is swapped; one with\n * changes of its own is left alone and reported with `hint`.\n */\nexport async function swapAuthPages(\n root: string,\n direction: \"enable\" | \"disable\",\n hint: (filePath: string) => string,\n): Promise<Map<string, ModifyOutcome>> {\n const mode = detectMode(root);\n // Code only the WhatsApp versions have (not a comment that mentions it):\n // enabling skips files with it, disabling files without it.\n const marker =\n direction === \"enable\"\n ? WHATSAPP_CODE\n : new RegExp(`^(?![\\\\s\\\\S]*(${WHATSAPP_CODE.source}))`);\n const outcomes = new Map<string, ModifyOutcome>();\n\n for (const files of Object.values(pageGroups(mode))) {\n const planned = await Promise.all(\n files.map((rel) =>\n planFile(\n path.join(root, rel),\n candidatesFor(mode, rel, direction),\n marker,\n rel.endsWith(\"signup/+page.server.ts\") ? [PAYMENTS_SIGNUP] : [],\n ),\n ),\n );\n for (const [filePath, outcome] of applyGroup(planned, hint)) {\n outcomes.set(filePath, outcome);\n }\n }\n return outcomes;\n}\n"],"mappings":";;;;;;;;;;AAwCA,eAAeoS,EAAU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AAQ,IAC5BuB,EAAM,KAAK,MACTnC,GACEvB,EAAK,KAAKuD,GAAMK,CAAG,GACnBE,GAAcT,GAAMO,GAAKK,CAAS,GAClCxC,GACAmC,EAAI,SAAS,wBAAwB,IAAI,CAACM,EAAe,IAAI,CAAC,CAChE,CACF,CACF;EACA,KAAK,IAAM,CAAC5C,GAAUe,MAAYL,GAAWG,GAASG,CAAI,GACxD,EAAS,IAAIhB,GAAUe,CAAO;CAElC;CACA,OAAOJ;AACT"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { n as e } from "./rolldown-runtime-
|
|
1
|
+
import { n as e } from "./rolldown-runtime-5HNE8Q1r.js";
|
|
2
2
|
import { t } from "./errors-DR3gF_7a.js";
|
|
3
3
|
import { a as n } from "./util-BLYliuUK.js";
|
|
4
4
|
import { n as r, t as i } from "./logger-CQONztPm.js";
|
|
5
|
-
import { i as a, n as o, t as s } from "./pocketbase-
|
|
5
|
+
import { i as a, n as o, t as s } from "./pocketbase-BtN-wL8f.js";
|
|
6
6
|
import { readFileSync as c } from "node:fs";
|
|
7
7
|
//#region src/runtime/collections.ts
|
|
8
8
|
var l = /* @__PURE__ */ e({
|
|
9
9
|
applyCollectionFieldsPatches: () => g,
|
|
10
10
|
applyCollectionRulePatches: () => m,
|
|
11
11
|
createCollectionIdempotent: () => f,
|
|
12
|
-
createCollections: () =>
|
|
13
|
-
dropCollectionIdempotent: () =>
|
|
14
|
-
dropCollections: () =>
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
createCollections: () => S,
|
|
13
|
+
dropCollectionIdempotent: () => v,
|
|
14
|
+
dropCollections: () => x,
|
|
15
|
+
ensureCollectionFields: () => _,
|
|
16
|
+
getCollectionStats: () => y,
|
|
17
|
+
planCollectionDrops: () => b
|
|
17
18
|
});
|
|
18
19
|
function u(e) {
|
|
19
20
|
if (e.response?.data?.name?.code === "validation_collection_name_exists") return !0;
|
|
@@ -73,25 +74,18 @@ async function m(e, t, r, a = i) {
|
|
|
73
74
|
}
|
|
74
75
|
function h(e, n) {
|
|
75
76
|
let r = e.map((e) => ({ ...e }));
|
|
76
|
-
for (let e of n.changes) {
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (e.op === "rename") {
|
|
89
|
-
let i = r.find((t) => t.name === e.from);
|
|
90
|
-
if (!i) throw new t(`Field "${e.from}" does not exist on collection "${n.collectionName}"`);
|
|
91
|
-
if (r.some((t) => t.name === e.to)) throw new t(`Field "${e.to}" already exists on collection "${n.collectionName}"`);
|
|
92
|
-
i.name = e.to;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
77
|
+
for (let e of n.changes) if (e.op === "add") {
|
|
78
|
+
if (r.some((t) => t.name === e.field.name)) throw new t(`Field "${e.field.name}" already exists on collection "${n.collectionName}"`);
|
|
79
|
+
r.push(e.field);
|
|
80
|
+
} else if (e.op === "remove") {
|
|
81
|
+
let i = r.findIndex((t) => t.name === e.fieldName);
|
|
82
|
+
if (i === -1) throw new t(`Field "${e.fieldName}" does not exist on collection "${n.collectionName}"`);
|
|
83
|
+
r.splice(i, 1);
|
|
84
|
+
} else if (e.op === "rename") {
|
|
85
|
+
let i = r.find((t) => t.name === e.from);
|
|
86
|
+
if (!i) throw new t(`Field "${e.from}" does not exist on collection "${n.collectionName}"`);
|
|
87
|
+
if (r.some((t) => t.name === e.to)) throw new t(`Field "${e.to}" already exists on collection "${n.collectionName}"`);
|
|
88
|
+
i.name = e.to;
|
|
95
89
|
}
|
|
96
90
|
return r;
|
|
97
91
|
}
|
|
@@ -110,7 +104,17 @@ async function g(e, t, r, a = i) {
|
|
|
110
104
|
}
|
|
111
105
|
return l;
|
|
112
106
|
}
|
|
113
|
-
async function _(e, t, n = i) {
|
|
107
|
+
async function _(e, t, n, r = i) {
|
|
108
|
+
let a = await e.collections.getOne(t.name), o = new Set(a.fields.map((e) => e.name)), s = t.fields.filter((e) => !o.has(e.name));
|
|
109
|
+
return s.length === 0 ? [] : (r.info(`Adding ${s.map((e) => e.name).join(", ")} to collection "${t.name}"`), g(e, [{
|
|
110
|
+
collectionName: t.name,
|
|
111
|
+
changes: s.map((e) => ({
|
|
112
|
+
op: "add",
|
|
113
|
+
field: e
|
|
114
|
+
}))
|
|
115
|
+
}], n, r));
|
|
116
|
+
}
|
|
117
|
+
async function v(e, t, n = i) {
|
|
114
118
|
try {
|
|
115
119
|
await e.collections.getOne(t);
|
|
116
120
|
} catch (e) {
|
|
@@ -125,7 +129,7 @@ async function _(e, t, n = i) {
|
|
|
125
129
|
existed: !0
|
|
126
130
|
};
|
|
127
131
|
}
|
|
128
|
-
async function
|
|
132
|
+
async function y(e, t) {
|
|
129
133
|
try {
|
|
130
134
|
await e.collections.getOne(t);
|
|
131
135
|
} catch (e) {
|
|
@@ -147,10 +151,10 @@ async function v(e, t) {
|
|
|
147
151
|
};
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
|
-
async function
|
|
154
|
+
async function b(e, t) {
|
|
151
155
|
let n = [];
|
|
152
156
|
for (let r of t) {
|
|
153
|
-
let t = await
|
|
157
|
+
let t = await y(e, r);
|
|
154
158
|
n.push({
|
|
155
159
|
name: r,
|
|
156
160
|
exists: t.exists,
|
|
@@ -159,13 +163,13 @@ async function y(e, t) {
|
|
|
159
163
|
}
|
|
160
164
|
return n;
|
|
161
165
|
}
|
|
162
|
-
async function
|
|
166
|
+
async function x(e, t) {
|
|
163
167
|
if (e.length === 0) return [];
|
|
164
168
|
let i = [], l = r(t);
|
|
165
169
|
return await a(t.root, async (r) => {
|
|
166
170
|
for (let a of e) {
|
|
167
171
|
l.info(`Dropping collection "${a.name}"`);
|
|
168
|
-
let { dropped: e } = await
|
|
172
|
+
let { dropped: e } = await v(r, a.name, l);
|
|
169
173
|
if (!e) continue;
|
|
170
174
|
await o();
|
|
171
175
|
let u = s(a.name, "deleted", t);
|
|
@@ -178,7 +182,7 @@ async function b(e, t) {
|
|
|
178
182
|
}
|
|
179
183
|
}), i;
|
|
180
184
|
}
|
|
181
|
-
async function
|
|
185
|
+
async function S(e, t) {
|
|
182
186
|
if (e.length === 0) return [];
|
|
183
187
|
let i = [], l = r(t);
|
|
184
188
|
return await a(t.root, async (r) => {
|
|
@@ -198,6 +202,6 @@ async function x(e, t) {
|
|
|
198
202
|
}), i;
|
|
199
203
|
}
|
|
200
204
|
//#endregion
|
|
201
|
-
export { l as n, f as r, m as t };
|
|
205
|
+
export { _ as i, l as n, f as r, m as t };
|
|
202
206
|
|
|
203
|
-
//# sourceMappingURL=collections-
|
|
207
|
+
//# sourceMappingURL=collections-BYcVyY9O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections-BYcVyY9O.js","names":["__exportAll","languageFromPath","getLogger","NOOP_LOGGER","withPocketbase","migrationDelay","getMigrationFile","collections_exports","applyCollectionFieldsPatches","applyCollectionRulePatches","createCollectionIdempotent","createCollections","dropCollectionIdempotent","dropCollections","ensureCollectionFields","getCollectionStats","planCollectionDrops","isCollectionAlreadyExistsError","error","message","resolveRelationTargets","fields","spec","relations","field","existing","pb","ids","c","byName","id","name","logger","rulePayloadFromPatch","payload","patch","migrations","patches","escaped","col","options","migrationFile","readFileSync","applyFieldChanges","change","f","InvalidArgumentError","index","collection","newFields","have","missing","plans","names","stats","specs","dropped","collections","created"],"sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type PocketBase from \"pocketbase\";\nimport type { CollectionModel } from \"pocketbase\";\nimport type {\n CollectionDropSpec,\n CollectionFieldSpec,\n CollectionFieldsPatch,\n CollectionRulesPatch,\n CollectionSpec,\n File,\n Options,\n} from \"../core/types\";\nimport { InvalidArgumentError } from \"../core/errors\";\nimport { getLogger, NOOP_LOGGER, type Logger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, migrationDelay, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (\n error.response?.data?.name?.code === \"validation_collection_name_exists\"\n ) {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return (\n message.includes(\"already exists\") || message.includes(\"must be unique\")\n );\n}\n\ntype CollectionCreateInput = Parameters<PocketBase[\"collections\"][\"create\"]>[0];\n\ninterface RelationFieldLike {\n type?: string;\n collectionId?: string;\n}\n\n/**\n * A spec may name the collection a relation points at (`stripe_customers`)\n * where PocketBase wants its id; specs read better by name, and the id is\n * only known once the target exists. Names are swapped for ids here, and a\n * value that already is an id (`_pb_users_auth_`) is left alone.\n */\nasync function resolveRelationTargets(\n pb: PocketBase,\n spec: CollectionCreateInput,\n): Promise<CollectionCreateInput> {\n const fields = (spec as { fields?: RelationFieldLike[] }).fields;\n const relations = (fields ?? []).filter(\n (field) => field.type === \"relation\" && field.collectionId,\n );\n if (relations.length === 0) return spec;\n\n const existing = await pb.collections.getFullList();\n const ids = new Set(existing.map((c) => c.id));\n const byName = new Map(existing.map((c) => [c.name, c.id]));\n if (relations.every((field) => ids.has(field.collectionId!))) return spec;\n\n return {\n ...spec,\n fields: fields!.map((field) => {\n if (field.type !== \"relation\" || !field.collectionId) return field;\n const id = byName.get(field.collectionId);\n return id && !ids.has(field.collectionId)\n ? { ...field, collectionId: id }\n : field;\n }),\n } as CollectionCreateInput;\n}\n\nexport interface CreateCollectionResult {\n collection: CollectionModel;\n created: boolean;\n}\n\n/**\n * Idempotent wrapper around `pb.collections.create`. If the collection already\n * exists, logs and returns the existing model with `created: false` so callers\n * can skip work tied to a fresh create (e.g. appending a newly-generated\n * migration file to the result).\n */\nexport async function createCollectionIdempotent(\n pb: PocketBase,\n spec: CollectionCreateInput,\n logger: Logger = NOOP_LOGGER,\n): Promise<CreateCollectionResult> {\n const name = (spec as { name: string }).name;\n try {\n const collection = await pb.collections.create(\n await resolveRelationTargets(pb, spec),\n );\n return { collection, created: true };\n } catch (error) {\n if (\n !isCollectionAlreadyExistsError(error as PocketBaseCollectionCreateError)\n ) {\n throw error;\n }\n logger.info(`Collection \"${name}\" already exists, skipping`);\n const collection = await pb.collections.getOne(name);\n return { collection, created: false };\n }\n}\n\nfunction rulePayloadFromPatch(\n patch: CollectionRulesPatch,\n): Record<string, unknown> {\n const payload: Record<string, unknown> = {};\n if (patch.listRule !== undefined) payload.listRule = patch.listRule;\n if (patch.viewRule !== undefined) payload.viewRule = patch.viewRule;\n if (patch.createRule !== undefined) payload.createRule = patch.createRule;\n if (patch.updateRule !== undefined) payload.updateRule = patch.updateRule;\n if (patch.deleteRule !== undefined) payload.deleteRule = patch.deleteRule;\n return payload;\n}\n\n/**\n * Applies API rule updates in array order. Call after all referenced collections exist.\n * Collects migration files produced by each update when `options` is provided.\n */\nexport async function applyCollectionRulePatches(\n pb: {\n collections: {\n getFirstListItem: (filter: string) => Promise<{ id: string }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionRulesPatch[],\n options?: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const escaped = patch.collectionName.replace(/'/g, \"''\");\n const col = await pb.collections.getFirstListItem(`name='${escaped}'`);\n logger.info(`Updating rules on collection \"${patch.collectionName}\"`);\n await pb.collections.update(col.id, rulePayloadFromPatch(patch));\n await migrationDelay();\n\n if (options) {\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (migrationFile) {\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n }\n }\n\n return migrations;\n}\n\nfunction applyFieldChanges(\n existing: CollectionFieldSpec[],\n patch: CollectionFieldsPatch,\n): CollectionFieldSpec[] {\n const fields = existing.map((field) => ({ ...field }));\n\n for (const change of patch.changes) {\n if (change.op === \"add\") {\n if (fields.some((f) => f.name === change.field.name)) {\n throw new InvalidArgumentError(\n `Field \"${change.field.name}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n fields.push(change.field);\n continue;\n }\n if (change.op === \"remove\") {\n const index = fields.findIndex((f) => f.name === change.fieldName);\n if (index === -1) {\n throw new InvalidArgumentError(\n `Field \"${change.fieldName}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n fields.splice(index, 1);\n continue;\n }\n if (change.op === \"rename\") {\n const field = fields.find((f) => f.name === change.from);\n if (!field) {\n throw new InvalidArgumentError(\n `Field \"${change.from}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n if (fields.some((f) => f.name === change.to)) {\n throw new InvalidArgumentError(\n `Field \"${change.to}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n field.name = change.to;\n continue;\n }\n }\n\n return fields;\n}\n\nexport async function applyCollectionFieldsPatches(\n pb: {\n collections: {\n getOne: (\n name: string,\n ) => Promise<{ id: string; fields: CollectionFieldSpec[] }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionFieldsPatch[],\n options: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const collection = await pb.collections.getOne(patch.collectionName);\n const newFields = applyFieldChanges(collection.fields, patch);\n logger.info(`Updating fields on collection \"${patch.collectionName}\"`);\n await pb.collections.update(collection.id, { fields: newFields });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n\n return migrations;\n}\n\n/**\n * Adds to an existing collection every field of `spec` it lacks, by name, so a\n * project that created it under an older spec gets the new fields. Fields are\n * only added, never changed or removed. Returns the migration files written.\n */\nexport async function ensureCollectionFields(\n pb: PocketBase,\n spec: CollectionSpec,\n options: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const existing = await pb.collections.getOne(spec.name);\n const have = new Set(\n (existing.fields as { name: string }[]).map((field) => field.name),\n );\n const missing = spec.fields.filter((field) => !have.has(field.name));\n if (missing.length === 0) return [];\n logger.info(\n `Adding ${missing.map((field) => field.name).join(\", \")} to collection \"${spec.name}\"`,\n );\n return applyCollectionFieldsPatches(\n pb,\n [\n {\n collectionName: spec.name,\n changes: missing.map((field) => ({ op: \"add\" as const, field })),\n },\n ],\n options,\n logger,\n );\n}\n\nexport interface DropCollectionResult {\n dropped: boolean;\n existed: boolean;\n}\n\n/**\n * Idempotent collection drop. Returns `{ existed: false, dropped: false }` if\n * the collection is already gone, matching the idempotency contract of\n * `createCollectionIdempotent`.\n */\nexport async function dropCollectionIdempotent(\n pb: PocketBase,\n name: string,\n logger: Logger = NOOP_LOGGER,\n): Promise<DropCollectionResult> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n logger.info(`Collection \"${name}\" does not exist, skipping drop`);\n return { dropped: false, existed: false };\n }\n throw error;\n }\n await pb.collections.delete(name);\n return { dropped: true, existed: true };\n}\n\nexport interface CollectionStats {\n exists: boolean;\n rowCount: number;\n}\n\nexport async function getCollectionStats(\n pb: PocketBase,\n name: string,\n): Promise<CollectionStats> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n return { exists: false, rowCount: 0 };\n }\n throw error;\n }\n\n try {\n const result = await pb\n .collection(name)\n .getList(1, 1, { skipTotal: false });\n return { exists: true, rowCount: result.totalItems };\n } catch {\n return { exists: true, rowCount: 0 };\n }\n}\n\n/**\n * Resolve the set of collections to drop, with current row counts. Missing\n * collections are included with `exists: false, rowCount: 0` so callers can\n * display the full reversal plan even when some collections were already gone.\n */\nexport async function planCollectionDrops(\n pb: PocketBase,\n names: string[],\n): Promise<CollectionDropSpec[]> {\n const plans: CollectionDropSpec[] = [];\n for (const name of names) {\n const stats = await getCollectionStats(pb, name);\n plans.push({ name, exists: stats.exists, rowCount: stats.rowCount });\n }\n return plans;\n}\n\n/**\n * Drop each of the given collections (skipping those that are already gone)\n * and collect the `_deleted_<name>.js` migration file PocketBase emits for\n * each successful drop. Symmetric to `createCollections`.\n */\nexport async function dropCollections(\n specs: CollectionDropSpec[],\n options: Options,\n): Promise<File[]> {\n if (specs.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const spec of specs) {\n logger.info(`Dropping collection \"${spec.name}\"`);\n const { dropped } = await dropCollectionIdempotent(pb, spec.name, logger);\n if (!dropped) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(spec.name, \"deleted\", options);\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n logger.info(`Creating collection \"${collection.name}\"`);\n const { created } = await createCollectionIdempotent(\n pb,\n collection,\n logger,\n );\n if (!created) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n collection.name,\n \"created\",\n options,\n );\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,SAASiB,EACP,GACS;CACT,IACEC,EAAM,UAAU,MAAM,MAAM,SA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