@wasp.sh/wasp-cli-darwin-arm64-unknown 0.23.0 → 0.24.0-rc.2
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/data/Cli/starters/basic/main.wasp.ts +60 -0
- package/data/Cli/starters/basic/package.json +4 -1
- package/data/Cli/starters/basic/prettier.config.mjs +9 -0
- package/data/Cli/starters/basic/src/tags/tags.wasp.ts +8 -0
- package/data/Cli/starters/basic/src/tasks/task.wasp.ts +16 -0
- package/data/Cli/starters/minimal/main.wasp.ts +12 -0
- package/data/Cli/starters/minimal/package.json +4 -1
- package/data/Cli/starters/skeleton/AGENTS.md +23 -0
- package/data/Cli/starters/skeleton/CLAUDE.md +23 -0
- package/data/Cli/starters/skeleton/tsconfig.json +5 -26
- package/data/Cli/starters/{ts-minimal → skeleton}/tsconfig.src.json +2 -1
- package/data/Cli/starters/{ts-minimal → skeleton}/tsconfig.wasp.json +5 -2
- package/data/Generator/libs/auth/{wasp.sh-lib-auth-0.23.0.tgz → wasp.sh-lib-auth-0.24.0.tgz} +0 -0
- package/data/Generator/libs/vite-ssr/{wasp.sh-lib-vite-ssr-0.23.0.tgz → wasp.sh-lib-vite-ssr-0.24.0.tgz} +0 -0
- package/data/Generator/templates/sdk/wasp/api/index.ts +51 -47
- package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +5 -2
- package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +9 -4
- package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +5 -2
- package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +5 -2
- package/data/Generator/templates/sdk/wasp/auth/responseSchemas.ts +10 -0
- package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +5 -3
- package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +3 -2
- package/data/Generator/templates/sdk/wasp/client/app/layout.tsx +13 -20
- package/data/Generator/templates/sdk/wasp/client/app/pages/OAuthCallback.tsx +12 -11
- package/data/Generator/templates/sdk/wasp/client/env/schema.ts +8 -8
- package/data/Generator/templates/sdk/wasp/client/env.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +4 -2
- package/data/Generator/templates/sdk/wasp/client/router/NavLink.tsx +21 -0
- package/data/Generator/templates/sdk/wasp/client/router/index.ts +2 -0
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/typescriptCheck.ts +8 -4
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/validateEnv.ts +72 -44
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/wasp.ts +1 -1
- package/data/Generator/templates/sdk/wasp/tsconfig.json +3 -0
- package/data/Generator/templates/types/spec/register.ts +14 -0
- package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +9 -0
- package/data/packages/deploy/dist/providers/railway/jsonOutputSchemas.js +47 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/deployment.js +45 -0
- package/data/packages/deploy/package-lock.json +2 -2
- package/data/packages/deploy/package.json +1 -1
- package/data/packages/prisma/package-lock.json +2 -2
- package/data/packages/prisma/package.json +1 -2
- package/data/packages/spec/dist/__tests__/cli.unit.test.js +128 -0
- package/data/packages/spec/dist/__tests__/legacy/appAnalyzer.unit.test.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/appAnalyzer.unit.test.js +3 -3
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.integration.test.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/mapTsAppSpecToAppSpecDecls.integration.test.js +2 -2
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.unit.test.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/mapTsAppSpecToAppSpecDecls.unit.test.js +4 -18
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/testFixtures.d.ts +4 -4
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/testFixtures.js +2 -2
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.test-d.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/appAnalyzer.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/appAnalyzer.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/appAnalyzer.unit.test.js +68 -0
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.js +814 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.test-d.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.test-d.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.test-d.js +148 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.unit.test.js +49 -0
- package/data/packages/spec/dist/__tests__/spec/refObjectPath.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/refObjectPath.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/refObjectPath.unit.test.js +204 -0
- package/data/packages/spec/dist/__tests__/spec/testFixtures.d.ts +85 -0
- package/data/packages/spec/dist/__tests__/spec/testFixtures.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/testFixtures.js +473 -0
- package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.js +44 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/pipeline.integration.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/pipeline.integration.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/pipeline.integration.test.js +218 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/imports.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/imports.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/imports.unit.test.js +174 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/refHelper.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/refHelper.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/refHelper.unit.test.js +119 -0
- package/data/packages/{wasp-config → spec}/dist/src/appSpec.d.ts +11 -4
- package/data/packages/spec/dist/src/appSpec.d.ts.map +1 -0
- package/data/packages/{wasp-config → spec}/dist/src/cli.d.ts +3 -1
- package/data/packages/spec/dist/src/cli.d.ts.map +1 -0
- package/data/packages/spec/dist/src/cli.js +28 -0
- package/data/packages/spec/dist/src/index.d.ts +2 -0
- package/data/packages/spec/dist/src/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/index.js +1 -0
- package/data/packages/spec/dist/src/internal.d.ts +2 -0
- package/data/packages/spec/dist/src/internal.d.ts.map +1 -0
- package/data/packages/spec/dist/src/internal.js +1 -0
- package/data/packages/spec/dist/src/legacy/_private.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/appAnalyzer.d.ts +1 -1
- package/data/packages/spec/dist/src/legacy/appAnalyzer.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/mapTsAppSpecToAppSpecDecls.d.ts +1 -1
- package/data/packages/spec/dist/src/legacy/mapTsAppSpecToAppSpecDecls.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/mapTsAppSpecToAppSpecDecls.js +3 -6
- package/data/packages/spec/dist/src/legacy/publicApi/App.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/publicApi/tsAppSpec.d.ts +3 -3
- package/data/packages/spec/dist/src/legacy/publicApi/tsAppSpec.d.ts.map +1 -0
- package/data/packages/spec/dist/src/run.js +28 -0
- package/data/packages/spec/dist/src/spec/appAnalyzer.d.ts +8 -0
- package/data/packages/spec/dist/src/spec/appAnalyzer.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/appAnalyzer.js +35 -0
- package/data/packages/spec/dist/src/spec/mapApp.d.ts +54 -0
- package/data/packages/spec/dist/src/spec/mapApp.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/mapApp.js +336 -0
- package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts +296 -0
- package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/constructors.js +277 -0
- package/data/packages/spec/dist/src/spec/publicApi/index.d.ts +5 -0
- package/data/packages/spec/dist/src/spec/publicApi/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/index.js +2 -0
- package/data/packages/spec/dist/src/spec/publicApi/register.d.ts +9 -0
- package/data/packages/spec/dist/src/spec/publicApi/register.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/register.js +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts +872 -0
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.js +1 -0
- package/data/packages/spec/dist/src/spec/refObject.d.ts +95 -0
- package/data/packages/spec/dist/src/spec/refObject.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/refObject.js +119 -0
- package/data/packages/spec/dist/src/spec/refObjectPath.d.ts +18 -0
- package/data/packages/spec/dist/src/spec/refObjectPath.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/refObjectPath.js +79 -0
- package/data/packages/spec/dist/src/spec/specUserError.d.ts +9 -0
- package/data/packages/spec/dist/src/spec/specUserError.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/specUserError.js +8 -0
- package/data/packages/spec/dist/src/spec-pipeline/common.d.ts +2 -0
- package/data/packages/spec/dist/src/spec-pipeline/common.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/common.js +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/loadWaspTsSpec.d.ts +5 -0
- package/data/packages/spec/dist/src/spec-pipeline/loadWaspTsSpec.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/loadWaspTsSpec.js +46 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/apply.d.ts +4 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/apply.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/apply.js +34 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/check.d.ts +3 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/check.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/check.js +14 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/index.d.ts +5 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/index.js +40 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.d.ts +26 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.js +57 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/index.d.ts +3 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/index.js +8 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/apply.d.ts +4 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/apply.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/apply.js +18 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/check.d.ts +3 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/check.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/check.js +13 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/index.d.ts +5 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/index.js +40 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/plan.d.ts +19 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/plan.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/plan.js +60 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/util.d.ts +10 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/util.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/util.js +53 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/index.d.ts +5 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/index.js +38 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/project.d.ts +9 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/project.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/project.js +66 -0
- package/data/packages/spec/dist/src/typeUtils.d.ts +3 -0
- package/data/packages/spec/dist/src/typeUtils.d.ts.map +1 -0
- package/data/packages/spec/dist/src/typeUtils.js +1 -0
- package/data/packages/{wasp-config → spec}/package-lock.json +921 -1475
- package/data/packages/spec/package.json +48 -0
- package/data/packages/studio/package-lock.json +2 -2
- package/data/packages/studio/package.json +1 -1
- package/data/packages/ts-inspect/package-lock.json +2 -2
- package/data/packages/ts-inspect/package.json +1 -1
- package/package.json +1 -1
- package/wasp-bin +0 -0
- package/data/Cli/starters/basic/.prettierrc +0 -3
- package/data/Cli/starters/basic/main.wasp +0 -100
- package/data/Cli/starters/minimal/main.wasp +0 -14
- package/data/Cli/starters/ts-minimal/main.wasp.ts +0 -15
- package/data/Cli/starters/ts-minimal/package.json +0 -18
- package/data/Cli/starters/ts-minimal/schema.prisma +0 -10
- package/data/Cli/starters/ts-minimal/src/Main.css +0 -103
- package/data/Cli/starters/ts-minimal/src/MainPage.tsx +0 -37
- package/data/Cli/starters/ts-minimal/src/assets/logo.svg +0 -1
- package/data/Cli/starters/ts-minimal/tsconfig.json +0 -7
- package/data/Cli/starters/ts-minimal/vite.config.ts +0 -9
- package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/__tests__/cli.unit.test.js +0 -65
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/__tests__/testFixtures.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/_private.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/appAnalyzer.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/appSpec.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/cli.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/cli.js +0 -24
- package/data/packages/wasp-config/dist/src/index.d.ts +0 -8
- package/data/packages/wasp-config/dist/src/index.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/index.js +0 -1
- package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/publicApi/App.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/run.js +0 -18
- package/data/packages/wasp-config/package.json +0 -40
- /package/data/packages/{wasp-config → spec}/dist/__tests__/cli.unit.test.d.ts +0 -0
- /package/data/packages/{wasp-config → spec}/dist/__tests__/cli.unit.test.d.ts.map +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/appAnalyzer.unit.test.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/mapTsAppSpecToAppSpecDecls.integration.test.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/mapTsAppSpecToAppSpecDecls.unit.test.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/testFixtures.test-d.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/testFixtures.test-d.js +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/appSpec.js +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/branded.d.ts +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/branded.d.ts.map +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/branded.js +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/_private.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/_private.js +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/appAnalyzer.js +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/publicApi/App.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/publicApi/App.js +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/publicApi/tsAppSpec.js +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/run.d.ts +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/run.d.ts.map +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waspSpec.d.ts","sourceRoot":"","sources":["../../../../src/spec/publicApi/waspSpec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,GAAG;IAClB;;;;OAIG;IACH,IAAI,EAAE,MAA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A0B;AAC1B;;GAEG;AACH,wBAAwB;AACxB;;;GAGG;AACH,SAAS;AACT;;GAEG;AACH,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,UAAU,eAAe,CAAC,IAAI,SAAS,MAAM;IAC3C;;;OAGG;IACH,IAAI,EAAE,IAAI,CAAC;CACZ;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type * as AppSpec from "../appSpec.js";
|
|
2
|
+
import type { Branded } from "../branded.js";
|
|
3
|
+
/**
|
|
4
|
+
* A reference to code in your app's `src` directory.
|
|
5
|
+
*
|
|
6
|
+
* @category References
|
|
7
|
+
*/
|
|
8
|
+
export type RefObject = Branded<RefObjectDescriptor & {
|
|
9
|
+
kind: "refObject";
|
|
10
|
+
}, "RefObject">;
|
|
11
|
+
/**
|
|
12
|
+
* Input accepted by {@link ref}.
|
|
13
|
+
*
|
|
14
|
+
* @category References
|
|
15
|
+
*/
|
|
16
|
+
export type RefObjectDescriptor = NamedRefObjectDescriptor | DefaultRefObjectDescriptor;
|
|
17
|
+
/**
|
|
18
|
+
* Named import reference, equivalent to
|
|
19
|
+
* `import { SomeValue } from "./src/someModule" with { type: "ref" }`.
|
|
20
|
+
*
|
|
21
|
+
* @category References
|
|
22
|
+
*/
|
|
23
|
+
export interface NamedRefObjectDescriptor {
|
|
24
|
+
/** Exported name to import. */
|
|
25
|
+
import: string;
|
|
26
|
+
/**
|
|
27
|
+
* Optional local alias.
|
|
28
|
+
*
|
|
29
|
+
* Alias takes precedence over the `import` field when
|
|
30
|
+
* Wasp Spec dervies some {@link WaspSpec.SpecElement} name.
|
|
31
|
+
*/
|
|
32
|
+
alias?: string;
|
|
33
|
+
/** Module path, relative to the `*.wasp.ts` file using it. */
|
|
34
|
+
from: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Default import reference, equivalent to
|
|
38
|
+
* `import SomeValue from "./src/someModule" with { type: "ref" }`.
|
|
39
|
+
*
|
|
40
|
+
* @category References
|
|
41
|
+
*/
|
|
42
|
+
export interface DefaultRefObjectDescriptor {
|
|
43
|
+
/** Local name for the default import. */
|
|
44
|
+
importDefault: string;
|
|
45
|
+
/** Module path, relative to the `*.wasp.ts` file using it. */
|
|
46
|
+
from: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates a fallback reference object for a value from your app.
|
|
50
|
+
*
|
|
51
|
+
* {@include ./publicApi/referenceImports.md}
|
|
52
|
+
*
|
|
53
|
+
* Reference imports are preferred because editors can follow and rename real
|
|
54
|
+
* imports.
|
|
55
|
+
*
|
|
56
|
+
* The import path must be relative to the `*.wasp.ts` file where it is used
|
|
57
|
+
* and resolve inside the app's `src/` directory. Absolute
|
|
58
|
+
* paths are not supported.
|
|
59
|
+
*
|
|
60
|
+
* @category References
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { page, ref } from "@wasp.sh/spec"
|
|
65
|
+
*
|
|
66
|
+
* const MainPage = ref({
|
|
67
|
+
* importDefault: "MainPage",
|
|
68
|
+
* from: "./src/MainPage",
|
|
69
|
+
* })
|
|
70
|
+
*
|
|
71
|
+
* export const mainPage = page(MainPage)
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function ref(_descriptor: RefObjectDescriptor): RefObject;
|
|
75
|
+
/**
|
|
76
|
+
* Creates a `ref` helper bound to the user's `.wasp.ts` file.
|
|
77
|
+
*
|
|
78
|
+
* Ref objects need the current spec file location to resolve relative paths,
|
|
79
|
+
* but `ref` itself can't use `import.meta.url` because it would point to this
|
|
80
|
+
* helper module. `_waspMakeRef(sourceFilePath)` lets each `.wasp.ts` file
|
|
81
|
+
* create a local `ref` that carries its own source file path.
|
|
82
|
+
*
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
export declare function _waspMakeRef(sourceFilePath: string): (descriptor: RefObjectDescriptor) => SourceAwareRefObject;
|
|
86
|
+
export declare function mapRefObject(refObject: unknown, { projectRootDir }: {
|
|
87
|
+
projectRootDir: string;
|
|
88
|
+
}): AppSpec.ExtImport;
|
|
89
|
+
export declare function getRefObjectDeclarationName(refObject: unknown): string;
|
|
90
|
+
type RefObjectSource = {
|
|
91
|
+
sourceFilePath: string;
|
|
92
|
+
};
|
|
93
|
+
type SourceAwareRefObject = RefObject & RefObjectSource;
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=refObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refObject.d.ts","sourceRoot":"","sources":["../../../src/spec/refObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK7C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,CAC7B,mBAAmB,GAAG;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,EAC3C,WAAW,CACZ,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B,wBAAwB,GACxB,0BAA0B,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,yCAAyC;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,GAAG,CAAC,WAAW,EAAE,mBAAmB,GAAG,SAAS,CAI/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,cAAc,EAAE,MAAM,GACrB,CAAC,UAAU,EAAE,mBAAmB,KAAK,oBAAoB,CAS3D;AAED,wBAAgB,YAAY,CAC1B,SAAS,EAAE,OAAO,EAClB,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,GAC7C,OAAO,CAAC,SAAS,CAqBnB;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAatE;AAmBD,KAAK,eAAe,GAAG;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,oBAAoB,GAAG,SAAS,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { normalizeRefObjectPath } from "./refObjectPath.js";
|
|
2
|
+
import { SpecUserError } from "./specUserError.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a fallback reference object for a value from your app.
|
|
5
|
+
*
|
|
6
|
+
* {@include ./publicApi/referenceImports.md}
|
|
7
|
+
*
|
|
8
|
+
* Reference imports are preferred because editors can follow and rename real
|
|
9
|
+
* imports.
|
|
10
|
+
*
|
|
11
|
+
* The import path must be relative to the `*.wasp.ts` file where it is used
|
|
12
|
+
* and resolve inside the app's `src/` directory. Absolute
|
|
13
|
+
* paths are not supported.
|
|
14
|
+
*
|
|
15
|
+
* @category References
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { page, ref } from "@wasp.sh/spec"
|
|
20
|
+
*
|
|
21
|
+
* const MainPage = ref({
|
|
22
|
+
* importDefault: "MainPage",
|
|
23
|
+
* from: "./src/MainPage",
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* export const mainPage = page(MainPage)
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function ref(_descriptor) {
|
|
30
|
+
throw new Error("Missing Wasp transformation. The `.wasp.ts` files are not directly executable, use the Wasp CLI.");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a `ref` helper bound to the user's `.wasp.ts` file.
|
|
34
|
+
*
|
|
35
|
+
* Ref objects need the current spec file location to resolve relative paths,
|
|
36
|
+
* but `ref` itself can't use `import.meta.url` because it would point to this
|
|
37
|
+
* helper module. `_waspMakeRef(sourceFilePath)` lets each `.wasp.ts` file
|
|
38
|
+
* create a local `ref` that carries its own source file path.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export function _waspMakeRef(sourceFilePath) {
|
|
43
|
+
return (descriptor) => {
|
|
44
|
+
const refObject = {
|
|
45
|
+
...descriptor,
|
|
46
|
+
kind: "refObject",
|
|
47
|
+
};
|
|
48
|
+
return { ...refObject, sourceFilePath };
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function mapRefObject(refObject, { projectRootDir }) {
|
|
52
|
+
if (isNamedRefObject(refObject)) {
|
|
53
|
+
return {
|
|
54
|
+
kind: "named",
|
|
55
|
+
name: refObject.import,
|
|
56
|
+
path: mapRefObjectPath(refObject, { projectRootDir }),
|
|
57
|
+
alias: refObject.alias,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
else if (isDefaultRefObject(refObject)) {
|
|
61
|
+
return {
|
|
62
|
+
kind: "default",
|
|
63
|
+
name: refObject.importDefault,
|
|
64
|
+
path: mapRefObjectPath(refObject, { projectRootDir }),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw new SpecUserError("Got an import in the Wasp file that we couldn't process: " +
|
|
69
|
+
JSON.stringify(refObject) +
|
|
70
|
+
'\nYou either used a value imported without `with { type: "ref" }` or didn\'t write the ref object correctly.');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function getRefObjectDeclarationName(refObject) {
|
|
74
|
+
if (isNamedRefObject(refObject)) {
|
|
75
|
+
return refObject.alias ?? refObject.import;
|
|
76
|
+
}
|
|
77
|
+
if (isDefaultRefObject(refObject)) {
|
|
78
|
+
return refObject.importDefault;
|
|
79
|
+
}
|
|
80
|
+
throw new SpecUserError("Got an import in the Wasp file that we couldn't process: " +
|
|
81
|
+
JSON.stringify(refObject));
|
|
82
|
+
}
|
|
83
|
+
function mapRefObjectPath(refObject, { projectRootDir }) {
|
|
84
|
+
if (!hasSourceFilePath(refObject)) {
|
|
85
|
+
throw new SpecUserError(`Relative ref path ${JSON.stringify(refObject.from)} is missing source file information. Use \`ref(...)\` in a \`*.wasp.ts\` file.`);
|
|
86
|
+
}
|
|
87
|
+
return normalizeRefObjectPath({
|
|
88
|
+
importPath: refObject.from,
|
|
89
|
+
importingFilePath: refObject.sourceFilePath,
|
|
90
|
+
projectRootDir,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function hasSourceFilePath(value) {
|
|
94
|
+
return (isObject(value) &&
|
|
95
|
+
"sourceFilePath" in value &&
|
|
96
|
+
typeof value.sourceFilePath === "string");
|
|
97
|
+
}
|
|
98
|
+
function isNamedRefObject(value) {
|
|
99
|
+
return (isObject(value) &&
|
|
100
|
+
typeof value.import === "string" &&
|
|
101
|
+
typeof value.from === "string" &&
|
|
102
|
+
hasValidAlias(value) &&
|
|
103
|
+
hasRefObjectMarker(value));
|
|
104
|
+
}
|
|
105
|
+
function isDefaultRefObject(value) {
|
|
106
|
+
return (isObject(value) &&
|
|
107
|
+
typeof value.importDefault === "string" &&
|
|
108
|
+
typeof value.from === "string" &&
|
|
109
|
+
hasRefObjectMarker(value));
|
|
110
|
+
}
|
|
111
|
+
function hasRefObjectMarker(value) {
|
|
112
|
+
return value.kind === "refObject";
|
|
113
|
+
}
|
|
114
|
+
function hasValidAlias(value) {
|
|
115
|
+
return value.alias === undefined || typeof value.alias === "string";
|
|
116
|
+
}
|
|
117
|
+
function isObject(value) {
|
|
118
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
119
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as AppSpec from "../appSpec.js";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a relative ref object path from the user's `.wasp.ts` file into
|
|
4
|
+
* AppSpec's absolute `@src/...` path format.
|
|
5
|
+
*
|
|
6
|
+
* This keeps user-authored paths source-relative while giving the Haskell side
|
|
7
|
+
* the same project-rooted paths it already understands.
|
|
8
|
+
*
|
|
9
|
+
* For example, `./src/MainPage` from `/app/main.wasp.ts` becomes
|
|
10
|
+
* `@src/MainPage`, while `./LoginPage` from `/app/src/auth/auth.wasp.ts`
|
|
11
|
+
* becomes `@src/auth/LoginPage`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizeRefObjectPath({ importPath, importingFilePath, projectRootDir, }: {
|
|
14
|
+
importPath: string;
|
|
15
|
+
importingFilePath: string;
|
|
16
|
+
projectRootDir: string;
|
|
17
|
+
}): AppSpec.ExtImport["path"];
|
|
18
|
+
//# sourceMappingURL=refObjectPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refObjectPath.d.ts","sourceRoot":"","sources":["../../../src/spec/refObjectPath.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAG9C;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,UAAU,EACV,iBAAiB,EACjB,cAAc,GACf,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAQ5B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import * as path from "node:path/posix"; // Module paths are always `/`-delimited
|
|
3
|
+
import { SpecUserError } from "./specUserError.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts a relative ref object path from the user's `.wasp.ts` file into
|
|
6
|
+
* AppSpec's absolute `@src/...` path format.
|
|
7
|
+
*
|
|
8
|
+
* This keeps user-authored paths source-relative while giving the Haskell side
|
|
9
|
+
* the same project-rooted paths it already understands.
|
|
10
|
+
*
|
|
11
|
+
* For example, `./src/MainPage` from `/app/main.wasp.ts` becomes
|
|
12
|
+
* `@src/MainPage`, while `./LoginPage` from `/app/src/auth/auth.wasp.ts`
|
|
13
|
+
* becomes `@src/auth/LoginPage`.
|
|
14
|
+
*/
|
|
15
|
+
export function normalizeRefObjectPath({ importPath, importingFilePath, projectRootDir, }) {
|
|
16
|
+
const srcRelativePath = getValidSrcRelativePath({
|
|
17
|
+
importPath,
|
|
18
|
+
importingFilePath,
|
|
19
|
+
projectRootDir,
|
|
20
|
+
});
|
|
21
|
+
return toAppSpecExtImportPath(srcRelativePath);
|
|
22
|
+
}
|
|
23
|
+
function getValidSrcRelativePath({ importPath, importingFilePath, projectRootDir, }) {
|
|
24
|
+
// The bundler resolves symlinks in module ids, so we compare paths under a
|
|
25
|
+
// canonical project root. Otherwise valid in-src imports can look like they
|
|
26
|
+
// escape src/ because one path has symlinks resolved and the other does not.
|
|
27
|
+
const projectRootPath = path.resolve(projectRootDir);
|
|
28
|
+
const canonicalProjectRootPath = getCanonicalPath(projectRootPath);
|
|
29
|
+
const canonicalImportingFilePath = toCanonicalProjectPath({
|
|
30
|
+
filePath: path.resolve(importingFilePath),
|
|
31
|
+
projectRootPath,
|
|
32
|
+
canonicalProjectRootPath,
|
|
33
|
+
});
|
|
34
|
+
const importingDir = path.dirname(canonicalImportingFilePath);
|
|
35
|
+
const srcRootDir = path.resolve(canonicalProjectRootPath, "src");
|
|
36
|
+
const importedFilePath = path.resolve(importingDir, importPath);
|
|
37
|
+
const srcRelativePath = path.relative(srcRootDir, importedFilePath);
|
|
38
|
+
if (!isValidSrcRelativeFilePath(srcRelativePath)) {
|
|
39
|
+
throw new SpecUserError(`Reference import path ${JSON.stringify(importPath)} in ${JSON.stringify(importingFilePath)} must resolve to a file inside the app src/ directory.`);
|
|
40
|
+
}
|
|
41
|
+
return srcRelativePath;
|
|
42
|
+
}
|
|
43
|
+
function getCanonicalPath(filePath) {
|
|
44
|
+
try {
|
|
45
|
+
return realpathSync(filePath);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (isNodeError(error) && error.code === "ENOENT") {
|
|
49
|
+
return filePath;
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function toCanonicalProjectPath({ filePath, projectRootPath, canonicalProjectRootPath, }) {
|
|
55
|
+
const projectRelativePath = getPathInsideRoot(filePath, projectRootPath) ??
|
|
56
|
+
getPathInsideRoot(filePath, canonicalProjectRootPath);
|
|
57
|
+
return projectRelativePath !== undefined
|
|
58
|
+
? path.resolve(canonicalProjectRootPath, projectRelativePath)
|
|
59
|
+
: filePath;
|
|
60
|
+
}
|
|
61
|
+
function getPathInsideRoot(filePath, rootDir) {
|
|
62
|
+
const relativePath = path.relative(rootDir, filePath);
|
|
63
|
+
return isInsideRootRelativePath(relativePath) ? relativePath : undefined;
|
|
64
|
+
}
|
|
65
|
+
function toAppSpecExtImportPath(srcRelativePath) {
|
|
66
|
+
return path.join("@src", srcRelativePath);
|
|
67
|
+
}
|
|
68
|
+
function isValidSrcRelativeFilePath(srcRelativePath) {
|
|
69
|
+
return srcRelativePath !== "" && isInsideRootRelativePath(srcRelativePath);
|
|
70
|
+
}
|
|
71
|
+
function isInsideRootRelativePath(relativePath) {
|
|
72
|
+
return (!startsWithParentSegment(relativePath) && !path.isAbsolute(relativePath));
|
|
73
|
+
}
|
|
74
|
+
function startsWithParentSegment(filePath) {
|
|
75
|
+
return filePath === ".." || filePath.startsWith(`..${path.sep}`);
|
|
76
|
+
}
|
|
77
|
+
function isNodeError(error) {
|
|
78
|
+
return error instanceof Error && "code" in error;
|
|
79
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error caused by invalid user input (unknown entities, bad imports, etc.).
|
|
3
|
+
*
|
|
4
|
+
* These are the errors users hit most often during development, so their
|
|
5
|
+
* messages should be short, clear, and actionable.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SpecUserError extends Error {
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=specUserError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specUserError.d.ts","sourceRoot":"","sources":["../../../src/spec/specUserError.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,KAAK;CAAG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error caused by invalid user input (unknown entities, bad imports, etc.).
|
|
3
|
+
*
|
|
4
|
+
* These are the errors users hit most often during development, so their
|
|
5
|
+
* messages should be short, clear, and actionable.
|
|
6
|
+
*/
|
|
7
|
+
export class SpecUserError extends Error {
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/spec-pipeline/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,QAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const WASP_SPEC_FILE_REGEX = /\.wasp\.ts$/;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadWaspTsSpec.d.ts","sourceRoot":"","sources":["../../../src/spec-pipeline/loadWaspTsSpec.ts"],"names":[],"mappings":"AAKA,wBAAsB,2BAA2B,CAAC,EAChD,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBnB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { unrun } from "unrun";
|
|
2
|
+
import { SpecUserError } from "../spec/specUserError.js";
|
|
3
|
+
import { transformWaspTsSpecFilesPlugin } from "./transformWaspTsSpecFilesPlugin/index.js";
|
|
4
|
+
import { typecheckPlugin } from "./typecheckPlugin/index.js";
|
|
5
|
+
export async function loadWaspTsSpecDefaultExport({ specPath, tsconfigPath, }) {
|
|
6
|
+
const { module: specModule } = await unrun({
|
|
7
|
+
path: specPath,
|
|
8
|
+
inputOptions: {
|
|
9
|
+
plugins: [
|
|
10
|
+
transformWaspTsSpecFilesPlugin(),
|
|
11
|
+
typecheckPlugin({ tsconfigPath }),
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
// By default, unrun will directly return the `default` export. We want to
|
|
15
|
+
// get it ourselves, so we use this option.
|
|
16
|
+
// https://gugustinette.github.io/unrun/advanced/presets.html
|
|
17
|
+
preset: "bundle-require",
|
|
18
|
+
}).catch((error) => {
|
|
19
|
+
// When a plugin throws, the bundler wraps the original error in an
|
|
20
|
+
// aggregate build error and exposes the originals on `.errors`. We dig out
|
|
21
|
+
// the `SpecUserError` so it reaches the top-level handler in `run.ts` as a
|
|
22
|
+
// clean user error instead of an internal crash.
|
|
23
|
+
throw getSpecUserError(error) ?? error;
|
|
24
|
+
});
|
|
25
|
+
return getDefaultExport(specModule);
|
|
26
|
+
}
|
|
27
|
+
function getSpecUserError(error) {
|
|
28
|
+
if (
|
|
29
|
+
// Checks to convince TypeScript that we can access `error.errors[0]`.
|
|
30
|
+
error instanceof Error &&
|
|
31
|
+
"errors" in error &&
|
|
32
|
+
Array.isArray(error.errors) &&
|
|
33
|
+
error.errors.length === 1 &&
|
|
34
|
+
error.errors[0] instanceof SpecUserError) {
|
|
35
|
+
return error.errors[0];
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function getDefaultExport(loadedModule) {
|
|
42
|
+
if (typeof loadedModule !== "object" || loadedModule === null) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return "default" in loadedModule ? loadedModule.default : undefined;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../../src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/apply.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAOpD,OAAO,KAAK,EAAE,IAAI,EAAsB,MAAM,WAAW,CAAC;AAE1D,wBAAgB,gCAAgC,CAC9C,WAAW,EAAE,mBAAmB,EAChC,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,IAAI,GACtC,IAAI,CA0BN"}
|
package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/apply.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SpecUserError } from "../../../spec/specUserError.js";
|
|
2
|
+
import { buildImportStatement, PUBLIC_REF_HELPER_IMPORT_NAME, PUBLIC_REF_HELPER_IMPORT_SOURCE, } from "../util.js";
|
|
3
|
+
export function applyTransformImportsPlan_mutate(magicString, { refImports, safeRefHelperName }) {
|
|
4
|
+
for (const { removeImport } of refImports) {
|
|
5
|
+
magicString.remove(removeImport.start, removeImport.end);
|
|
6
|
+
}
|
|
7
|
+
magicString.prepend([
|
|
8
|
+
// Add the `ref` helper import
|
|
9
|
+
buildImportStatement([[PUBLIC_REF_HELPER_IMPORT_NAME, safeRefHelperName]], PUBLIC_REF_HELPER_IMPORT_SOURCE),
|
|
10
|
+
// Convert each original ref import to a `const` declaration that uses the
|
|
11
|
+
// `ref` helper.
|
|
12
|
+
// In ES Modules, imports are always hoisted, so we add these declarations
|
|
13
|
+
// at the top of the file to preserve the original semantics.
|
|
14
|
+
...refImports.flatMap(({ references }) => references.map((ref) => getLoweredImportSource(ref, {
|
|
15
|
+
refHelperName: safeRefHelperName,
|
|
16
|
+
}))),
|
|
17
|
+
].join(""));
|
|
18
|
+
}
|
|
19
|
+
function getLoweredImportSource(ref, ctx) {
|
|
20
|
+
switch (ref.kind) {
|
|
21
|
+
case "named":
|
|
22
|
+
return getRefObjectBindingSource(ref.refObject.alias ?? ref.refObject.import, ref.refObject, ctx);
|
|
23
|
+
case "default":
|
|
24
|
+
return getRefObjectBindingSource(ref.refObject.importDefault, ref.refObject, ctx);
|
|
25
|
+
case "namespace":
|
|
26
|
+
throw new SpecUserError([
|
|
27
|
+
"Namespace imports are not supported for reference imports.",
|
|
28
|
+
`Replace \`import * as ${ref.alias} from "${ref.from}" with { type: "ref" }\` with a named or default reference import.`,
|
|
29
|
+
].join("\n"));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function getRefObjectBindingSource(identifier, descriptor, { refHelperName }) {
|
|
33
|
+
return `const ${identifier} = ${refHelperName}(${JSON.stringify(descriptor)});\n`;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../../../src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAIlD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,GAAG,IAAI,CAO9D"}
|
package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/check.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SpecUserError } from "../../../spec/specUserError.js";
|
|
2
|
+
import { getStringValue } from "../util.js";
|
|
3
|
+
export function assertCanTransformImports(ast) {
|
|
4
|
+
const hasRefExports = ast.body.some(isRefExportDeclaration);
|
|
5
|
+
if (hasRefExports) {
|
|
6
|
+
throw new SpecUserError("Re-exporting refs is not supported. First import the reference and then re-export it if needed.");
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function isRefExportDeclaration(node) {
|
|
10
|
+
return ((node.type === "ExportNamedDeclaration" ||
|
|
11
|
+
node.type === "ExportAllDeclaration") &&
|
|
12
|
+
node.attributes.some((attr) => getStringValue(attr.key) === "type" &&
|
|
13
|
+
getStringValue(attr.value) === "ref"));
|
|
14
|
+
}
|
package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Plugin, RolldownMagicString } from "rolldown";
|
|
2
|
+
import type { ESTree as t } from "rolldown/utils";
|
|
3
|
+
export declare function transformRefImportsPlugin(): Plugin;
|
|
4
|
+
export declare function transformRefImports_mutate(ast: t.Program, magicString: RolldownMagicString): void;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAMlD,wBAAgB,yBAAyB,IAAI,MAAM,CA+BlD;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,CAAC,CAAC,OAAO,EACd,WAAW,EAAE,mBAAmB,GAC/B,IAAI,CAUN"}
|
package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { WASP_SPEC_FILE_REGEX } from "../../common.js";
|
|
3
|
+
import { applyTransformImportsPlan_mutate } from "./apply.js";
|
|
4
|
+
import { assertCanTransformImports } from "./check.js";
|
|
5
|
+
import { planTransformImports } from "./plan.js";
|
|
6
|
+
export function transformRefImportsPlugin() {
|
|
7
|
+
return {
|
|
8
|
+
name: "wasp/spec/transform-ref-imports",
|
|
9
|
+
options(opts) {
|
|
10
|
+
return {
|
|
11
|
+
...opts,
|
|
12
|
+
experimental: {
|
|
13
|
+
...opts.experimental,
|
|
14
|
+
// TODO: Remove this once it goes out of experimental phase.
|
|
15
|
+
// https://rolldown.rs/in-depth/native-magic-string
|
|
16
|
+
nativeMagicString: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
transform: {
|
|
21
|
+
filter: { id: WASP_SPEC_FILE_REGEX },
|
|
22
|
+
async handler(code, id, meta) {
|
|
23
|
+
assert(meta.magicString);
|
|
24
|
+
// If the AST is already available, use it; otherwise ask the bundler to
|
|
25
|
+
// parse it.
|
|
26
|
+
const ast = meta.ast || this.parse(code, { lang: "ts" });
|
|
27
|
+
transformRefImports_mutate(ast, meta.magicString);
|
|
28
|
+
return { code: meta.magicString };
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function transformRefImports_mutate(ast, magicString) {
|
|
34
|
+
assertCanTransformImports(ast);
|
|
35
|
+
const importsPlan = planTransformImports(ast);
|
|
36
|
+
if (!importsPlan) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
applyTransformImportsPlan_mutate(magicString, importsPlan);
|
|
40
|
+
}
|
package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ESTree as t } from "rolldown/utils";
|
|
2
|
+
import type { DefaultRefObjectDescriptor, NamedRefObjectDescriptor } from "@wasp.sh/spec";
|
|
3
|
+
export type Plan = {
|
|
4
|
+
refImports: RefImport[];
|
|
5
|
+
safeRefHelperName: string;
|
|
6
|
+
};
|
|
7
|
+
export type RefImportReference = {
|
|
8
|
+
kind: "named";
|
|
9
|
+
refObject: NamedRefObjectDescriptor;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "default";
|
|
12
|
+
refObject: DefaultRefObjectDescriptor;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "namespace";
|
|
15
|
+
from: string;
|
|
16
|
+
alias: string;
|
|
17
|
+
};
|
|
18
|
+
export interface RefImport {
|
|
19
|
+
references: RefImportReference[];
|
|
20
|
+
removeImport: {
|
|
21
|
+
start: number;
|
|
22
|
+
end: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare function planTransformImports(ast: t.Program): Plan | null;
|
|
26
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../../../src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AASlD,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,IAAI,GAAG;IACjB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,wBAAwB,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,0BAA0B,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,YAAY,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,GAAG,IAAI,GAAG,IAAI,CAWhE"}
|
package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { SpecUserError } from "../../../spec/specUserError.js";
|
|
2
|
+
import { getStringValue, getTopLevelBindings, makeSafeName, PUBLIC_REF_HELPER_IMPORT_NAME, } from "../util.js";
|
|
3
|
+
export function planTransformImports(ast) {
|
|
4
|
+
const refImports = findRefImports(ast);
|
|
5
|
+
if (refImports.length === 0) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const scope = getTopLevelBindings(ast);
|
|
9
|
+
const safeRefHelperName = makeSafeName(PUBLIC_REF_HELPER_IMPORT_NAME, scope);
|
|
10
|
+
return { refImports, safeRefHelperName };
|
|
11
|
+
}
|
|
12
|
+
function findRefImports(ast) {
|
|
13
|
+
return ast.body.filter(isRefImportDeclaration).map((node) => {
|
|
14
|
+
const importSource = getStringValue(node.source);
|
|
15
|
+
if (node.specifiers.length === 0) {
|
|
16
|
+
throw new SpecUserError(`Ref import from ${JSON.stringify(importSource)} must import at least one binding.`);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
references: node.specifiers.map((specifier) => makeRefObject(importSource, specifier)),
|
|
20
|
+
removeImport: { start: node.start, end: node.end },
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function isRefImportDeclaration(node) {
|
|
25
|
+
return (node.type === "ImportDeclaration" &&
|
|
26
|
+
node.attributes.some((attr) => getStringValue(attr.key) === "type" &&
|
|
27
|
+
getStringValue(attr.value) === "ref"));
|
|
28
|
+
}
|
|
29
|
+
function makeRefObject(importSource, specifier) {
|
|
30
|
+
switch (specifier.type) {
|
|
31
|
+
case "ImportSpecifier":
|
|
32
|
+
return {
|
|
33
|
+
kind: "named",
|
|
34
|
+
refObject: {
|
|
35
|
+
import: getStringValue(specifier.imported),
|
|
36
|
+
alias: getStringValue(specifier.local),
|
|
37
|
+
from: importSource,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
case "ImportDefaultSpecifier":
|
|
41
|
+
return {
|
|
42
|
+
kind: "default",
|
|
43
|
+
refObject: {
|
|
44
|
+
importDefault: getStringValue(specifier.local),
|
|
45
|
+
from: importSource,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
case "ImportNamespaceSpecifier":
|
|
49
|
+
return {
|
|
50
|
+
kind: "namespace",
|
|
51
|
+
alias: getStringValue(specifier.local),
|
|
52
|
+
from: importSource,
|
|
53
|
+
};
|
|
54
|
+
default:
|
|
55
|
+
return specifier;
|
|
56
|
+
}
|
|
57
|
+
}
|