zitejs 0.9.153 → 0.9.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/auth/actions.d.ts +28 -0
- package/dist/cjs/auth/actions.js +93 -0
- package/dist/cjs/auth/client.d.ts +357 -0
- package/dist/cjs/auth/client.js +66 -0
- package/dist/cjs/auth/config.js +9 -3
- package/dist/cjs/auth/index.d.ts +2 -249
- package/dist/cjs/auth/index.js +11 -108
- package/dist/cjs/auth/index.test.js +60 -0
- package/dist/cjs/auth/previewClaim.d.ts +7 -0
- package/dist/cjs/auth/previewClaim.js +16 -0
- package/dist/cjs/auth/profileUpdates.d.ts +9 -0
- package/dist/cjs/auth/profileUpdates.js +11 -0
- package/dist/cjs/backend/index.d.ts +6 -6
- package/dist/cjs/backend/index.js +13 -13
- package/dist/cjs/backend/index.test.js +102 -102
- package/dist/cjs/bundle/index.js +29 -16
- package/dist/cjs/caller/index.js +43 -43
- package/dist/cjs/check/index.d.ts +44 -1
- package/dist/cjs/check/index.js +198 -61
- package/dist/cjs/check/start/routeTree.d.ts +8 -0
- package/dist/cjs/check/start/routeTree.js +118 -0
- package/dist/cjs/check/start/tsgo.d.ts +2 -0
- package/dist/cjs/check/start/tsgo.js +35 -0
- package/dist/cjs/cli.js +19 -6
- package/dist/cjs/client/index.d.ts +2 -2
- package/dist/cjs/client/index.js +25 -25
- package/dist/cjs/dev/index.js +81 -53
- package/dist/cjs/dev/signin.d.ts +16 -0
- package/dist/cjs/dev/signin.js +84 -0
- package/dist/cjs/index.d.ts +5 -5
- package/dist/cjs/integrations/client.d.ts +3 -3
- package/dist/cjs/integrations/client.js +5 -4
- package/dist/cjs/integrations/client.test-d.js +15 -15
- package/dist/cjs/integrations/index.d.ts +2 -2
- package/dist/cjs/integrations/rules.js +42 -42
- package/dist/cjs/integrations/rules.test.js +60 -55
- package/dist/cjs/internal/appMode.d.ts +14 -0
- package/dist/cjs/internal/appMode.js +19 -0
- package/dist/cjs/internal/env.js +3 -2
- package/dist/cjs/internal/platformFetch.d.ts +2 -0
- package/dist/cjs/internal/platformFetch.js +14 -0
- package/dist/cjs/internal/reservedIds.d.ts +8 -0
- package/dist/cjs/internal/reservedIds.js +14 -0
- package/dist/cjs/internal/serviceUrls.d.ts +5 -0
- package/dist/cjs/internal/serviceUrls.js +14 -0
- package/dist/cjs/pdf/index.js +2 -1
- package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
- package/dist/cjs/runtime/index.d.ts +22 -22
- package/dist/cjs/runtime/index.js +28 -28
- package/dist/cjs/runtime/index.test.js +34 -34
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +29 -29
- package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
- package/dist/cjs/sourceRoots.js +15 -15
- package/dist/cjs/sourceRoots.test.js +29 -27
- package/dist/cjs/start/build/entries.d.ts +25 -0
- package/dist/cjs/start/build/entries.js +121 -0
- package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
- package/dist/cjs/start/build/placeholders/devApp.js +6 -0
- package/dist/cjs/start/describe/describeBuilt.d.ts +5 -0
- package/dist/cjs/start/describe/describeBuilt.js +144 -0
- package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
- package/dist/cjs/start/platform/aiUsage.js +215 -0
- package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
- package/dist/cjs/start/platform/airtable/cache.js +93 -0
- package/dist/cjs/start/protocol.d.ts +19 -0
- package/dist/cjs/start/protocol.js +33 -0
- package/dist/cjs/start/serve/local/provider.d.ts +25 -0
- package/dist/cjs/start/serve/local/provider.js +196 -0
- package/dist/cjs/start/serve/provider.d.ts +19 -0
- package/dist/cjs/start/serve/provider.js +86 -0
- package/dist/cjs/start/types.d.ts +373 -0
- package/dist/cjs/start/types.js +2 -0
- package/dist/cjs/steps/index.d.ts +8 -8
- package/dist/cjs/steps/index.js +53 -53
- package/dist/cjs/steps/index.test.js +218 -218
- package/dist/cjs/sync/index.d.ts +1 -1
- package/dist/cjs/sync/index.js +28 -27
- package/dist/cjs/sync/lib.d.ts +15 -8
- package/dist/cjs/sync/lib.js +651 -665
- package/dist/cjs/sync/lib.test.js +81 -14
- package/dist/cjs/sync/sdkNames.d.ts +67 -9
- package/dist/cjs/sync/sdkNames.js +97 -31
- package/dist/cjs/sync/sdkNames.test.js +189 -113
- package/dist/cjs/types/fields.d.ts +1 -1
- package/dist/cjs/types/fields.js +105 -97
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/tables.d.ts +1 -1
- package/dist/cjs/upload/index.js +89 -24
- package/dist/cjs/upload/index.test.js +104 -1
- package/dist/cjs/vite/domTagNames.js +252 -252
- package/dist/cjs/vite/index.d.ts +1 -1
- package/dist/cjs/vite/index.js +51 -42
- package/dist/cjs/vite/index.test.js +10 -2
- package/dist/esm/auth/actions.d.ts +28 -0
- package/dist/esm/auth/actions.js +55 -0
- package/dist/esm/auth/client.d.ts +357 -0
- package/dist/esm/auth/client.js +62 -0
- package/dist/esm/auth/config.js +9 -3
- package/dist/esm/auth/index.d.ts +2 -249
- package/dist/esm/auth/index.js +2 -103
- package/dist/esm/auth/index.test.js +60 -0
- package/dist/esm/auth/previewClaim.d.ts +7 -0
- package/dist/esm/auth/previewClaim.js +12 -0
- package/dist/esm/auth/profileUpdates.d.ts +9 -0
- package/dist/esm/auth/profileUpdates.js +6 -0
- package/dist/esm/backend/index.d.ts +6 -6
- package/dist/esm/backend/index.js +13 -13
- package/dist/esm/backend/index.test.js +106 -106
- package/dist/esm/bundle/index.js +29 -16
- package/dist/esm/caller/index.js +44 -44
- package/dist/esm/check/index.d.ts +44 -1
- package/dist/esm/check/index.js +194 -61
- package/dist/esm/check/start/routeTree.d.ts +8 -0
- package/dist/esm/check/start/routeTree.js +77 -0
- package/dist/esm/check/start/tsgo.d.ts +2 -0
- package/dist/esm/check/start/tsgo.js +29 -0
- package/dist/esm/cli.js +19 -6
- package/dist/esm/client/index.d.ts +2 -2
- package/dist/esm/client/index.js +25 -25
- package/dist/esm/dev/index.js +88 -60
- package/dist/esm/dev/signin.d.ts +16 -0
- package/dist/esm/dev/signin.js +80 -0
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +3 -3
- package/dist/esm/integrations/client.d.ts +3 -3
- package/dist/esm/integrations/client.js +6 -5
- package/dist/esm/integrations/client.test-d.js +19 -19
- package/dist/esm/integrations/index.d.ts +2 -2
- package/dist/esm/integrations/index.js +1 -1
- package/dist/esm/integrations/rules.js +42 -42
- package/dist/esm/integrations/rules.test.js +62 -57
- package/dist/esm/internal/appMode.d.ts +14 -0
- package/dist/esm/internal/appMode.js +13 -0
- package/dist/esm/internal/env.js +3 -2
- package/dist/esm/internal/platformFetch.d.ts +2 -0
- package/dist/esm/internal/platformFetch.js +9 -0
- package/dist/esm/internal/reservedIds.d.ts +8 -0
- package/dist/esm/internal/reservedIds.js +10 -0
- package/dist/esm/internal/serviceUrls.d.ts +5 -0
- package/dist/esm/internal/serviceUrls.js +10 -0
- package/dist/esm/pdf/index.js +2 -1
- package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
- package/dist/esm/runtime/index.d.ts +22 -22
- package/dist/esm/runtime/index.js +31 -31
- package/dist/esm/runtime/index.test.js +36 -36
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +30 -30
- package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
- package/dist/esm/signin/conformance.d.ts +100 -0
- package/dist/esm/signin/conformance.js +616 -0
- package/dist/esm/signin/cookies.d.ts +28 -0
- package/dist/esm/signin/cookies.js +67 -0
- package/dist/esm/signin/encoding.d.ts +1 -0
- package/dist/esm/signin/encoding.js +12 -0
- package/dist/esm/signin/endpoints.d.ts +12 -0
- package/dist/esm/signin/endpoints.js +32 -0
- package/dist/esm/signin/http.d.ts +25 -0
- package/dist/esm/signin/http.js +106 -0
- package/dist/esm/signin/index.d.ts +8 -0
- package/dist/esm/signin/index.js +9 -0
- package/dist/esm/signin/keys.d.ts +35 -0
- package/dist/esm/signin/keys.js +230 -0
- package/dist/esm/signin/paths.d.ts +2 -0
- package/dist/esm/signin/paths.js +5 -0
- package/dist/esm/signin/seal.d.ts +19 -0
- package/dist/esm/signin/seal.js +47 -0
- package/dist/esm/signin/signin.d.ts +60 -0
- package/dist/esm/signin/signin.js +447 -0
- package/dist/esm/signin/transport.d.ts +112 -0
- package/dist/esm/signin/transport.js +1 -0
- package/dist/esm/signin/verifier.d.ts +2 -0
- package/dist/esm/signin/verifier.js +4 -0
- package/dist/esm/signin/verify.d.ts +83 -0
- package/dist/esm/signin/verify.js +142 -0
- package/dist/esm/sourceRoots.js +17 -17
- package/dist/esm/sourceRoots.test.js +34 -32
- package/dist/esm/start/access.d.ts +19 -0
- package/dist/esm/start/access.js +43 -0
- package/dist/esm/start/auth.d.ts +28 -0
- package/dist/esm/start/auth.js +33 -0
- package/dist/esm/start/automations/quiet.d.ts +2 -0
- package/dist/esm/start/automations/quiet.js +36 -0
- package/dist/esm/start/automations/registration.d.ts +13 -0
- package/dist/esm/start/automations/registration.js +25 -0
- package/dist/esm/start/automations/steps.d.ts +29 -0
- package/dist/esm/start/automations/steps.js +95 -0
- package/dist/esm/start/automations/workflow.d.ts +83 -0
- package/dist/esm/start/automations/workflow.js +36 -0
- package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
- package/dist/esm/start/automations/workflow.test-d.js +130 -0
- package/dist/esm/start/automations/workflowRun.d.ts +130 -0
- package/dist/esm/start/automations/workflowRun.js +185 -0
- package/dist/esm/start/barrel.test-d.d.ts +10 -0
- package/dist/esm/start/barrel.test-d.js +6 -0
- package/dist/esm/start/build/entries.d.ts +25 -0
- package/dist/esm/start/build/entries.js +109 -0
- package/dist/esm/start/build/placeholders/authHooksModule.d.ts +1 -0
- package/dist/esm/start/build/placeholders/authHooksModule.js +3 -0
- package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
- package/dist/esm/start/build/placeholders/devApp.js +3 -0
- package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
- package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
- package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
- package/dist/esm/start/build/placeholders/siteHead.js +3 -0
- package/dist/esm/start/build/placeholders/workflowModules.d.ts +1 -0
- package/dist/esm/start/build/placeholders/workflowModules.js +3 -0
- package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
- package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
- package/dist/esm/start/build/registrationHash.d.ts +11 -0
- package/dist/esm/start/build/registrationHash.js +88 -0
- package/dist/esm/start/build/sdk/axios.d.ts +76 -0
- package/dist/esm/start/build/sdk/axios.js +253 -0
- package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
- package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
- package/dist/esm/start/build/sdk/undici.d.ts +34 -0
- package/dist/esm/start/build/sdk/undici.js +18 -0
- package/dist/esm/start/build/sdkPatches.d.ts +22 -0
- package/dist/esm/start/build/sdkPatches.js +430 -0
- package/dist/esm/start/build/siteHead.d.ts +26 -0
- package/dist/esm/start/build/siteHead.js +88 -0
- package/dist/esm/start/build/vite.d.ts +50 -0
- package/dist/esm/start/build/vite.js +487 -0
- package/dist/esm/start/classicOnly.d.ts +1 -0
- package/dist/esm/start/classicOnly.js +4 -0
- package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
- package/dist/esm/start/clientErrorMessage.test.js +105 -0
- package/dist/esm/start/describe/describe.d.ts +120 -0
- package/dist/esm/start/describe/describe.js +372 -0
- package/dist/esm/start/describe/describeBuilt.d.ts +5 -0
- package/dist/esm/start/describe/describeBuilt.js +102 -0
- package/dist/esm/start/describe/descriptions.d.ts +4 -0
- package/dist/esm/start/describe/descriptions.js +54 -0
- package/dist/esm/start/errors.d.ts +62 -0
- package/dist/esm/start/errors.js +163 -0
- package/dist/esm/start/errors.test.d.ts +1 -0
- package/dist/esm/start/errors.test.js +54 -0
- package/dist/esm/start/factories.d.ts +14 -0
- package/dist/esm/start/factories.js +23 -0
- package/dist/esm/start/factories.test-d.d.ts +2 -0
- package/dist/esm/start/factories.test-d.js +60 -0
- package/dist/esm/start/failures.d.ts +7 -0
- package/dist/esm/start/failures.js +62 -0
- package/dist/esm/start/fnFactory.d.ts +16 -0
- package/dist/esm/start/fnFactory.js +1 -0
- package/dist/esm/start/host.d.ts +3 -0
- package/dist/esm/start/host.js +4 -0
- package/dist/esm/start/index.d.ts +10 -0
- package/dist/esm/start/index.js +7 -0
- package/dist/esm/start/login.d.ts +5 -0
- package/dist/esm/start/login.js +29 -0
- package/dist/esm/start/middlewareKind.d.ts +13 -0
- package/dist/esm/start/middlewareKind.js +9 -0
- package/dist/esm/start/platform/aiUsage.d.ts +29 -0
- package/dist/esm/start/platform/aiUsage.js +210 -0
- package/dist/esm/start/platform/airtable/arrayFields.d.ts +10 -0
- package/dist/esm/start/platform/airtable/arrayFields.js +30 -0
- package/dist/esm/start/platform/airtable/built.d.ts +2 -0
- package/dist/esm/start/platform/airtable/built.js +3 -0
- package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
- package/dist/esm/start/platform/airtable/cache.js +89 -0
- package/dist/esm/start/platform/airtable/dispatch.d.ts +57 -0
- package/dist/esm/start/platform/airtable/dispatch.js +541 -0
- package/dist/esm/start/platform/airtable/formulas.d.ts +70 -0
- package/dist/esm/start/platform/airtable/formulas.js +261 -0
- package/dist/esm/start/platform/airtable/index.d.ts +6 -0
- package/dist/esm/start/platform/airtable/index.js +51 -0
- package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
- package/dist/esm/start/platform/airtable/settings.js +138 -0
- package/dist/esm/start/platform/analytics.d.ts +3 -0
- package/dist/esm/start/platform/analytics.js +59 -0
- package/dist/esm/start/platform/calls.d.ts +5 -0
- package/dist/esm/start/platform/calls.js +104 -0
- package/dist/esm/start/platform/caps.d.ts +9 -0
- package/dist/esm/start/platform/caps.js +35 -0
- package/dist/esm/start/platform/connections.d.ts +25 -0
- package/dist/esm/start/platform/connections.js +198 -0
- package/dist/esm/start/platform/data/baseRunner.d.ts +97 -0
- package/dist/esm/start/platform/data/baseRunner.js +117 -0
- package/dist/esm/start/platform/data/dispatch.d.ts +17 -0
- package/dist/esm/start/platform/data/dispatch.js +216 -0
- package/dist/esm/start/platform/data/fetch.d.ts +7 -0
- package/dist/esm/start/platform/data/fetch.js +9 -0
- package/dist/esm/start/platform/data/index.d.ts +27 -0
- package/dist/esm/start/platform/data/index.js +75 -0
- package/dist/esm/start/platform/data/names.d.ts +7 -0
- package/dist/esm/start/platform/data/names.js +18 -0
- package/dist/esm/start/platform/data/sqlNameMappings.d.ts +58 -0
- package/dist/esm/start/platform/data/sqlNameMappings.js +92 -0
- package/dist/esm/start/platform/data/transformations.d.ts +97 -0
- package/dist/esm/start/platform/data/transformations.js +262 -0
- package/dist/esm/start/platform/data/types.d.ts +94 -0
- package/dist/esm/start/platform/data/types.js +14 -0
- package/dist/esm/start/platform/local.d.ts +6 -0
- package/dist/esm/start/platform/local.js +18 -0
- package/dist/esm/start/platform/meta.d.ts +3 -0
- package/dist/esm/start/platform/meta.js +33 -0
- package/dist/esm/start/platform/outbound.d.ts +17 -0
- package/dist/esm/start/platform/outbound.js +510 -0
- package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
- package/dist/esm/start/platform/redactSecrets.js +156 -0
- package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
- package/dist/esm/start/platform/redactSecrets.test.js +151 -0
- package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
- package/dist/esm/start/platform/requestSecrets.js +41 -0
- package/dist/esm/start/platform/runLog.d.ts +40 -0
- package/dist/esm/start/platform/runLog.js +149 -0
- package/dist/esm/start/platform/services.d.ts +7 -0
- package/dist/esm/start/platform/services.js +46 -0
- package/dist/esm/start/platform/steps.d.ts +9 -0
- package/dist/esm/start/platform/steps.js +60 -0
- package/dist/esm/start/platform/telemetry.d.ts +13 -0
- package/dist/esm/start/platform/telemetry.js +71 -0
- package/dist/esm/start/platform/transport.d.ts +28 -0
- package/dist/esm/start/platform/transport.js +59 -0
- package/dist/esm/start/platformHead.d.ts +23 -0
- package/dist/esm/start/platformHead.js +133 -0
- package/dist/esm/start/previewClaim.d.ts +6 -0
- package/dist/esm/start/previewClaim.js +24 -0
- package/dist/esm/start/protocol.d.ts +19 -0
- package/dist/esm/start/protocol.js +27 -0
- package/dist/esm/start/roles.d.ts +12 -0
- package/dist/esm/start/roles.js +27 -0
- package/dist/esm/start/router.d.ts +44 -0
- package/dist/esm/start/router.js +280 -0
- package/dist/esm/start/serve/authHooks.d.ts +7 -0
- package/dist/esm/start/serve/authHooks.js +18 -0
- package/dist/esm/start/serve/demo.d.ts +9 -0
- package/dist/esm/start/serve/demo.js +24 -0
- package/dist/esm/start/serve/fetch.d.ts +1 -0
- package/dist/esm/start/serve/fetch.js +6 -0
- package/dist/esm/start/serve/instance.d.ts +12 -0
- package/dist/esm/start/serve/instance.js +134 -0
- package/dist/esm/start/serve/invoke.d.ts +13 -0
- package/dist/esm/start/serve/invoke.js +126 -0
- package/dist/esm/start/serve/local/load.d.ts +8 -0
- package/dist/esm/start/serve/local/load.js +44 -0
- package/dist/esm/start/serve/local/provider.d.ts +25 -0
- package/dist/esm/start/serve/local/provider.js +188 -0
- package/dist/esm/start/serve/local/signIn.d.ts +28 -0
- package/dist/esm/start/serve/local/signIn.js +123 -0
- package/dist/esm/start/serve/pageHead.d.ts +20 -0
- package/dist/esm/start/serve/pageHead.js +34 -0
- package/dist/esm/start/serve/provider.d.ts +19 -0
- package/dist/esm/start/serve/provider.js +78 -0
- package/dist/esm/start/serve/requestEnv.d.ts +2 -0
- package/dist/esm/start/serve/requestEnv.js +84 -0
- package/dist/esm/start/serve/scope.d.ts +18 -0
- package/dist/esm/start/serve/scope.js +67 -0
- package/dist/esm/start/serve/server.d.ts +56 -0
- package/dist/esm/start/serve/server.js +297 -0
- package/dist/esm/start/serve/uploads.d.ts +2 -0
- package/dist/esm/start/serve/uploads.js +49 -0
- package/dist/esm/start/serve/worker.d.ts +6 -0
- package/dist/esm/start/serve/worker.js +12 -0
- package/dist/esm/start/types.d.ts +373 -0
- package/dist/esm/start/types.js +1 -0
- package/dist/esm/start/version.d.ts +1 -0
- package/dist/esm/start/version.js +2 -0
- package/dist/esm/steps/index.d.ts +8 -8
- package/dist/esm/steps/index.js +54 -54
- package/dist/esm/steps/index.test.js +220 -220
- package/dist/esm/sync/index.d.ts +1 -1
- package/dist/esm/sync/index.js +32 -31
- package/dist/esm/sync/lib.d.ts +15 -8
- package/dist/esm/sync/lib.js +655 -669
- package/dist/esm/sync/lib.test.js +81 -14
- package/dist/esm/sync/sdkNames.d.ts +67 -9
- package/dist/esm/sync/sdkNames.js +94 -30
- package/dist/esm/sync/sdkNames.test.js +192 -116
- package/dist/esm/types/fields.d.ts +1 -1
- package/dist/esm/types/fields.js +106 -98
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/index.js +2 -2
- package/dist/esm/types/tables.d.ts +1 -1
- package/dist/esm/types/tables.js +2 -2
- package/dist/esm/upload/index.js +89 -24
- package/dist/esm/upload/index.test.js +104 -1
- package/dist/esm/vite/domTagNames.js +252 -252
- package/dist/esm/vite/index.d.ts +1 -1
- package/dist/esm/vite/index.js +56 -47
- package/dist/esm/vite/index.test.js +10 -2
- package/package.json +129 -16
- package/dist/cjs/auth-server/index.d.ts +0 -369
- package/dist/cjs/auth-server/index.js +0 -119
- package/dist/cjs/meta/index.d.ts +0 -14
- package/dist/cjs/meta/index.js +0 -12
- package/dist/cjs/notifications/index.d.ts +0 -25
- package/dist/cjs/notifications/index.js +0 -12
- package/dist/esm/auth-server/index.d.ts +0 -369
- package/dist/esm/auth-server/index.js +0 -116
- package/dist/esm/meta/index.d.ts +0 -14
- package/dist/esm/meta/index.js +0 -8
- package/dist/esm/notifications/index.d.ts +0 -25
- package/dist/esm/notifications/index.js +0 -8
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { ZiteTrigger } from '../../backend/index.js';
|
|
2
|
+
import { type AuthHookName } from '../serve/authHooks.js';
|
|
3
|
+
import { type LoadedTrigger, type LoadedWorkflow } from '../automations/workflowRun.js';
|
|
4
|
+
import { type AutomationConfig } from '../automations/workflow.js';
|
|
5
|
+
export type Access = {
|
|
6
|
+
kind: 'signedIn' | 'anyone' | 'webhook' | 'none';
|
|
7
|
+
roles: string[];
|
|
8
|
+
paused?: true;
|
|
9
|
+
};
|
|
10
|
+
export type DescribedFunction = {
|
|
11
|
+
id: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
file?: string;
|
|
14
|
+
method?: string;
|
|
15
|
+
/** From the factory's `description` option; display-only. */
|
|
16
|
+
description?: string;
|
|
17
|
+
access: Access;
|
|
18
|
+
input?: unknown;
|
|
19
|
+
problems: string[];
|
|
20
|
+
};
|
|
21
|
+
export type DescribedRoute = {
|
|
22
|
+
path: string;
|
|
23
|
+
file?: string;
|
|
24
|
+
/** From the route's `staticData.description`; display-only. */
|
|
25
|
+
description?: string;
|
|
26
|
+
methods: Record<string, Access>;
|
|
27
|
+
problems: string[];
|
|
28
|
+
};
|
|
29
|
+
/** A route that renders: what the editor's page picker and system map show. */
|
|
30
|
+
export type DescribedPage = {
|
|
31
|
+
id: string;
|
|
32
|
+
path: string;
|
|
33
|
+
file?: string;
|
|
34
|
+
};
|
|
35
|
+
export type DescribedWorkflow = {
|
|
36
|
+
id: string;
|
|
37
|
+
file: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
schedule?: AutomationConfig['schedule'];
|
|
40
|
+
/** As declared, without a provider trigger's `subscribe` and `unsubscribe`. */
|
|
41
|
+
trigger?: ZiteTrigger;
|
|
42
|
+
/**
|
|
43
|
+
* A provider trigger's: whether it can be taken down, its module, and a hash of everything that module runs, so
|
|
44
|
+
* publish registers it again when that changes.
|
|
45
|
+
*/
|
|
46
|
+
registration?: {
|
|
47
|
+
unsubscribe: boolean;
|
|
48
|
+
hash: string;
|
|
49
|
+
module: string;
|
|
50
|
+
};
|
|
51
|
+
problems: string[];
|
|
52
|
+
};
|
|
53
|
+
export type Description = {
|
|
54
|
+
functions: DescribedFunction[];
|
|
55
|
+
routes: DescribedRoute[];
|
|
56
|
+
pages: DescribedPage[];
|
|
57
|
+
workflows: DescribedWorkflow[];
|
|
58
|
+
/** The hooks the app's `zite.auth.ts` defines. */
|
|
59
|
+
authHooks: AuthHookName[];
|
|
60
|
+
/** What's wrong with the app as a whole, beside any one function, route or workflow. */
|
|
61
|
+
problems: string[];
|
|
62
|
+
};
|
|
63
|
+
/** What the build knows of the app beside its code: its access mode, and whether it's a standalone automation. */
|
|
64
|
+
export type AppFacts = {
|
|
65
|
+
internal: boolean;
|
|
66
|
+
automation: boolean;
|
|
67
|
+
};
|
|
68
|
+
/** Written in by `zite()` at build; both false where it didn't build the app. */
|
|
69
|
+
export declare const builtAppFacts: () => AppFacts;
|
|
70
|
+
/** @internal What the app's access mode and a function's own input say of it. */
|
|
71
|
+
export declare const functionRules: ({ access, input }: DescribedFunction, facts: AppFacts) => string[];
|
|
72
|
+
export declare function describeFunction(id: string, request: Request): Promise<DescribedFunction>;
|
|
73
|
+
type RouteLike = {
|
|
74
|
+
id: string;
|
|
75
|
+
fullPath: string;
|
|
76
|
+
parentRoute?: RouteLike;
|
|
77
|
+
options?: {
|
|
78
|
+
path?: string;
|
|
79
|
+
component?: unknown;
|
|
80
|
+
staticData?: {
|
|
81
|
+
description?: unknown;
|
|
82
|
+
};
|
|
83
|
+
server?: {
|
|
84
|
+
middleware?: unknown[];
|
|
85
|
+
handlers?: unknown;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export declare function describePages(routesById: Record<string, RouteLike>, files?: Record<string, string>): DescribedPage[];
|
|
90
|
+
export declare function describeRoutes(routesById: Record<string, RouteLike>, files?: Record<string, string>, facts?: AppFacts): DescribedRoute[];
|
|
91
|
+
/**
|
|
92
|
+
* A workflow's id is its export name: what the host invokes it by and the editor shows. `hashes` are the registration
|
|
93
|
+
* hashes zite() wrote in by module; `triggers`, every provider trigger the app's modules export, which places each
|
|
94
|
+
* automation's trigger in its module.
|
|
95
|
+
*/
|
|
96
|
+
export declare function describeWorkflows(workflows: LoadedWorkflow[], { hashes, unfinished, triggers, }?: {
|
|
97
|
+
hashes?: Record<string, string>;
|
|
98
|
+
unfinished?: Array<{
|
|
99
|
+
id: string;
|
|
100
|
+
file: string;
|
|
101
|
+
}>;
|
|
102
|
+
triggers?: LoadedTrigger[];
|
|
103
|
+
}): DescribedWorkflow[];
|
|
104
|
+
export declare function describeApp(opts: {
|
|
105
|
+
fnIds: string[];
|
|
106
|
+
descriptions?: Record<string, string>;
|
|
107
|
+
routeFiles?: Record<string, string>;
|
|
108
|
+
/** By module, as the workflow registry names it. */
|
|
109
|
+
registrationHashes?: Record<string, string>;
|
|
110
|
+
getRouter: () => unknown;
|
|
111
|
+
request: Request;
|
|
112
|
+
workflows?: LoadedWorkflow[];
|
|
113
|
+
unfinishedWorkflows?: Array<{
|
|
114
|
+
id: string;
|
|
115
|
+
file: string;
|
|
116
|
+
}>;
|
|
117
|
+
triggers?: LoadedTrigger[];
|
|
118
|
+
facts?: AppFacts;
|
|
119
|
+
}): Promise<Description>;
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
// Describes a built app by loading it, not by reading its source: each server
|
|
2
|
+
// function's real middleware chain, each server route's, and input schemas.
|
|
3
|
+
import { createMiddleware, flattenMiddlewares } from '@tanstack/react-start';
|
|
4
|
+
import { createSsrRpc } from '@tanstack/react-start/ssr-rpc';
|
|
5
|
+
import { runWithStartContext } from '@tanstack/start-storage-context';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { ziteMiddlewareKind, } from '../middlewareKind.js';
|
|
8
|
+
import { isZiteRouter } from '../router.js';
|
|
9
|
+
import { loadAuthHooks } from '../serve/authHooks.js';
|
|
10
|
+
import { loadProviderTriggers, } from '../automations/workflowRun.js';
|
|
11
|
+
import { isProviderTrigger, } from '../automations/workflow.js';
|
|
12
|
+
/** Written in by `zite()` at build; both false where it didn't build the app. */
|
|
13
|
+
export const builtAppFacts = () => {
|
|
14
|
+
try {
|
|
15
|
+
const facts = JSON.parse('__ZITE_APP_FACTS__');
|
|
16
|
+
return {
|
|
17
|
+
internal: facts.internal === true,
|
|
18
|
+
automation: facts.automation === true,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return { internal: false, automation: false };
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
// The host, TanStack and Cloudflare answer these before the app does.
|
|
26
|
+
const RESERVED_PATHS = [
|
|
27
|
+
/^\/_zite/,
|
|
28
|
+
/^\/__zite/,
|
|
29
|
+
/^\/_serverFn(\/|$)/,
|
|
30
|
+
/^\/cdn-cgi(\/|$)/,
|
|
31
|
+
/^\/auth(\/|$)/,
|
|
32
|
+
/^\/api\/auth(\/|$)/,
|
|
33
|
+
/^\/manifest\.webmanifest$/,
|
|
34
|
+
];
|
|
35
|
+
const RESERVED_PATH = 'reserved-path: the platform answers this path before the app does; give the route another';
|
|
36
|
+
const WEBHOOK_PATH_PARAM = "webhook-path-param: a webhook route's path can't have parameters, because its URL is registered once; put the value in the body or query";
|
|
37
|
+
const OWNER_INPUTS = ['userId', 'ownerId'];
|
|
38
|
+
const inputProperties = (input) => {
|
|
39
|
+
const properties = input
|
|
40
|
+
?.properties;
|
|
41
|
+
return properties && typeof properties === 'object'
|
|
42
|
+
? Object.keys(properties)
|
|
43
|
+
: [];
|
|
44
|
+
};
|
|
45
|
+
/** @internal What the app's access mode and a function's own input say of it. */
|
|
46
|
+
export const functionRules = ({ access, input }, facts) => {
|
|
47
|
+
// A role may act for other users, which is what its middleware is for.
|
|
48
|
+
const owner = access.kind === 'signedIn' && access.roles.length === 0
|
|
49
|
+
? inputProperties(input).find(key => OWNER_INPUTS.includes(key))
|
|
50
|
+
: undefined;
|
|
51
|
+
return [
|
|
52
|
+
...(facts.internal && access.kind === 'anyone'
|
|
53
|
+
? [
|
|
54
|
+
'public-in-internal: anyone can call it, and this internal app signs everyone in; make it a signedInFn',
|
|
55
|
+
]
|
|
56
|
+
: []),
|
|
57
|
+
...(owner
|
|
58
|
+
? [
|
|
59
|
+
`owner-from-input: it takes ${owner} as input, which any caller can set; use context.user.id, or if a role may act for other users, add role(id) to its middleware`,
|
|
60
|
+
]
|
|
61
|
+
: []),
|
|
62
|
+
];
|
|
63
|
+
};
|
|
64
|
+
const accessOf = (chain, problems) => {
|
|
65
|
+
const kinds = chain
|
|
66
|
+
.map(ziteMiddlewareKind)
|
|
67
|
+
.filter((k) => !!k);
|
|
68
|
+
const roles = kinds.flatMap(k => (k.kind === 'role' ? [k.role] : []));
|
|
69
|
+
const base = [
|
|
70
|
+
...new Set(kinds.flatMap(k => k.kind === 'signedIn' || k.kind === 'anyone' || k.kind === 'webhook'
|
|
71
|
+
? [k.kind]
|
|
72
|
+
: [])),
|
|
73
|
+
];
|
|
74
|
+
if (base.length === 0) {
|
|
75
|
+
problems.push('access-missing: no signedIn, anyone or webhook middleware in its chain');
|
|
76
|
+
return { kind: 'none', roles };
|
|
77
|
+
}
|
|
78
|
+
if (base.length > 1)
|
|
79
|
+
problems.push(`access-conflict: ${base.join(' + ')}`);
|
|
80
|
+
const kind = base.includes('webhook')
|
|
81
|
+
? 'webhook'
|
|
82
|
+
: base.includes('signedIn')
|
|
83
|
+
? 'signedIn'
|
|
84
|
+
: 'anyone';
|
|
85
|
+
const paused = kinds.some(k => k.kind === 'webhook' && k.paused === true);
|
|
86
|
+
return paused ? { kind, roles, paused } : { kind, roles };
|
|
87
|
+
};
|
|
88
|
+
const jsonSchemaOf = (validator) => {
|
|
89
|
+
if (validator && typeof validator === 'object' && '_zod' in validator) {
|
|
90
|
+
try {
|
|
91
|
+
return z.toJSONSchema(validator);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return { unrepresentable: true };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return validator ? { opaque: true } : undefined;
|
|
98
|
+
};
|
|
99
|
+
// Describe walks functions one at a time, so one probe slot is enough.
|
|
100
|
+
let probe = null;
|
|
101
|
+
// The only global function middleware while describing: it records what it was
|
|
102
|
+
// handed and ends the call, so no app middleware or handler runs.
|
|
103
|
+
const describeProbe = createMiddleware({ type: 'function' }).server(({ serverFnMeta, method }) => {
|
|
104
|
+
if (probe)
|
|
105
|
+
Object.assign(probe, { meta: serverFnMeta, method, reached: true });
|
|
106
|
+
return 'zite:describe';
|
|
107
|
+
});
|
|
108
|
+
const SERVER_ONLY = "server-only: nothing in the browser calls it, and a server function that only other server functions call can't run. " +
|
|
109
|
+
'Move the shared logic into a *.server.ts helper and call that.';
|
|
110
|
+
export async function describeFunction(id, request) {
|
|
111
|
+
let probeFailed;
|
|
112
|
+
let own;
|
|
113
|
+
probe = { reached: false };
|
|
114
|
+
// TanStack appends the function's own chain to the global middleware with
|
|
115
|
+
// `concat`. Recording what it appends gives the exact chain it would have run.
|
|
116
|
+
const functionMiddleware = Object.assign([describeProbe], {
|
|
117
|
+
concat: (chain) => {
|
|
118
|
+
own = chain;
|
|
119
|
+
return [describeProbe, ...chain];
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
const startContext = {
|
|
123
|
+
request,
|
|
124
|
+
startOptions: { functionMiddleware },
|
|
125
|
+
contextAfterGlobalMiddlewares: {},
|
|
126
|
+
handlerType: 'serverFn',
|
|
127
|
+
getRouter: () => {
|
|
128
|
+
throw new Error('describe has no router');
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
try {
|
|
132
|
+
await runWithStartContext(startContext, () => createSsrRpc(id)({ data: undefined, context: {} }));
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
136
|
+
// TanStack registers only functions something can call through it. One that
|
|
137
|
+
// only other server functions call isn't registered, and calling it fails.
|
|
138
|
+
if (message === `Server function info not found for ${id}`) {
|
|
139
|
+
probe = null;
|
|
140
|
+
return {
|
|
141
|
+
id,
|
|
142
|
+
access: { kind: 'none', roles: [] },
|
|
143
|
+
problems: [SERVER_ONLY],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
probeFailed = `probe-failed: ${message}`;
|
|
147
|
+
}
|
|
148
|
+
const state = probe;
|
|
149
|
+
probe = null;
|
|
150
|
+
const problems = [];
|
|
151
|
+
// Fails closed: if TanStack stops appending, or the probe never runs, every
|
|
152
|
+
// function reports a problem and the build stops.
|
|
153
|
+
if (!state.reached || own === undefined)
|
|
154
|
+
problems.push('probe-not-first: chain could not be read');
|
|
155
|
+
const chain = flattenMiddlewares((own ?? [])).filter(m => m !== describeProbe);
|
|
156
|
+
if (!chain.some(m => ziteMiddlewareKind(m)?.kind === 'factory')) {
|
|
157
|
+
problems.push('raw-server-fn: write signedInFn({ method, description }) or publicFn({ method, description }) from zitejs/start instead of createServerFn');
|
|
158
|
+
}
|
|
159
|
+
// TanStack keeps the validator under `inputValidator` up to 1.168 and `validator` from 1.169 (Start 1.0).
|
|
160
|
+
const handlerStep = chain.at(-1);
|
|
161
|
+
const access = accessOf(chain, problems);
|
|
162
|
+
return {
|
|
163
|
+
id,
|
|
164
|
+
name: state.meta?.name,
|
|
165
|
+
file: state.meta?.filename,
|
|
166
|
+
method: state.method,
|
|
167
|
+
access,
|
|
168
|
+
input: jsonSchemaOf(handlerStep?.options?.validator ?? handlerStep?.options?.inputValidator),
|
|
169
|
+
// A chain the probe never read says nothing of the function: only why it failed does.
|
|
170
|
+
problems: probeFailed ? [probeFailed] : problems,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const ROOT_ROUTE_ID = '__root__';
|
|
174
|
+
// Pathless layouts have no path of their own, and a file with only server handlers is an API route.
|
|
175
|
+
export function describePages(routesById, files = {}) {
|
|
176
|
+
return Object.values(routesById).flatMap(route => {
|
|
177
|
+
const options = route.options ?? {};
|
|
178
|
+
if (route.id === ROOT_ROUTE_ID || options.path === undefined)
|
|
179
|
+
return [];
|
|
180
|
+
if (options.server?.handlers && !options.component)
|
|
181
|
+
return [];
|
|
182
|
+
const file = files[route.id];
|
|
183
|
+
return [{ id: route.id, path: route.fullPath, ...(file && { file }) }];
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
export function describeRoutes(routesById, files = {}, facts = { internal: false, automation: false }) {
|
|
187
|
+
const out = [];
|
|
188
|
+
for (const route of Object.values(routesById)) {
|
|
189
|
+
const server = route.options?.server;
|
|
190
|
+
if (!server?.handlers)
|
|
191
|
+
continue;
|
|
192
|
+
const problems = [];
|
|
193
|
+
const ancestry = [];
|
|
194
|
+
for (let r = route; r; r = r.parentRoute)
|
|
195
|
+
ancestry.unshift(r);
|
|
196
|
+
const routeMiddleware = ancestry.flatMap(r => r.options?.server?.middleware ?? []);
|
|
197
|
+
const handlers = (typeof server.handlers === 'function'
|
|
198
|
+
? server.handlers({ createHandlers: d => d })
|
|
199
|
+
: server.handlers);
|
|
200
|
+
const methods = {};
|
|
201
|
+
for (const [method, handler] of Object.entries(handlers)) {
|
|
202
|
+
const own = typeof handler === 'function'
|
|
203
|
+
? []
|
|
204
|
+
: (handler.middleware ?? []);
|
|
205
|
+
const chain = flattenMiddlewares([
|
|
206
|
+
...routeMiddleware,
|
|
207
|
+
...own,
|
|
208
|
+
]);
|
|
209
|
+
const methodProblems = [];
|
|
210
|
+
methods[method] = accessOf(chain, methodProblems);
|
|
211
|
+
problems.push(...methodProblems.map(p => `${method}: ${p}`));
|
|
212
|
+
}
|
|
213
|
+
const file = files[route.id];
|
|
214
|
+
const description = route.options?.staticData?.description;
|
|
215
|
+
const described = typeof description === 'string' && description ? description : undefined;
|
|
216
|
+
if (!described)
|
|
217
|
+
problems.push('description-missing: add staticData: { description } for the editor');
|
|
218
|
+
if (RESERVED_PATHS.some(reserved => reserved.test(route.fullPath)))
|
|
219
|
+
problems.push(RESERVED_PATH);
|
|
220
|
+
if (route.fullPath.includes('$') &&
|
|
221
|
+
Object.values(methods).some(access => access.kind === 'webhook'))
|
|
222
|
+
problems.push(WEBHOOK_PATH_PARAM);
|
|
223
|
+
const open = Object.entries(methods).flatMap(([method, access]) => access.kind === 'anyone' ? [method] : []);
|
|
224
|
+
if (facts.internal && open.length > 0) {
|
|
225
|
+
problems.push(`public-in-internal: anyone can call ${open.join(', ')}, and this internal app signs everyone in; use signedIn`);
|
|
226
|
+
}
|
|
227
|
+
out.push({
|
|
228
|
+
path: route.fullPath,
|
|
229
|
+
...(file && { file }),
|
|
230
|
+
...(described && { description: described }),
|
|
231
|
+
methods,
|
|
232
|
+
problems,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return out;
|
|
236
|
+
}
|
|
237
|
+
const HANDLER_MISSING = 'workflow-handler-missing: give createAutomation its function with .handler(async (args) => { ... }), not in its config';
|
|
238
|
+
const TRIGGER_INLINE = 'trigger-inline: define the provider trigger with createProviderTrigger in a module of its own, export it, and pass it as trigger';
|
|
239
|
+
// A build zite() didn't hash: publish registers its triggers again every time rather than miss a change.
|
|
240
|
+
const unhashed = () => `unhashed:${crypto.randomUUID()}`;
|
|
241
|
+
/**
|
|
242
|
+
* A workflow's id is its export name: what the host invokes it by and the editor shows. `hashes` are the registration
|
|
243
|
+
* hashes zite() wrote in by module; `triggers`, every provider trigger the app's modules export, which places each
|
|
244
|
+
* automation's trigger in its module.
|
|
245
|
+
*/
|
|
246
|
+
export function describeWorkflows(workflows, { hashes = {}, unfinished = [], triggers = [], } = {}) {
|
|
247
|
+
const described = workflows.map(({ id, file, workflow }) => {
|
|
248
|
+
const problems = [];
|
|
249
|
+
if (id === 'default')
|
|
250
|
+
problems.push('workflow-default-export: export it by name, which becomes its id');
|
|
251
|
+
const elsewhere = workflows.find(other => other.id === id && other.file !== file);
|
|
252
|
+
if (elsewhere)
|
|
253
|
+
problems.push(`duplicate-workflow: ${id} is also exported from ${elsewhere.file}`);
|
|
254
|
+
const { description, schedule, trigger } = workflow.config;
|
|
255
|
+
if (schedule)
|
|
256
|
+
return { id, file, description, schedule, problems };
|
|
257
|
+
if (!trigger ||
|
|
258
|
+
trigger.every !== undefined ||
|
|
259
|
+
trigger.events !== undefined) {
|
|
260
|
+
return { id, file, description, trigger, problems };
|
|
261
|
+
}
|
|
262
|
+
const { subscribe, unsubscribe, ...declared } = trigger;
|
|
263
|
+
const refused = (problem) => ({
|
|
264
|
+
id,
|
|
265
|
+
file,
|
|
266
|
+
description,
|
|
267
|
+
trigger: declared,
|
|
268
|
+
problems: [...problems, problem],
|
|
269
|
+
});
|
|
270
|
+
// The types refuse these, but a build doesn't typecheck.
|
|
271
|
+
if ('table' in declared || 'form' in declared)
|
|
272
|
+
return refused("trigger-unsupported: a Start automation can't take a database or form trigger yet");
|
|
273
|
+
if (!isProviderTrigger(trigger))
|
|
274
|
+
return refused(TRIGGER_INLINE);
|
|
275
|
+
const [module] = [
|
|
276
|
+
...new Set(triggers.filter(t => t.trigger === trigger).map(t => t.file)),
|
|
277
|
+
].sort();
|
|
278
|
+
if (!module)
|
|
279
|
+
return refused(TRIGGER_INLINE);
|
|
280
|
+
const beside = [
|
|
281
|
+
...workflows
|
|
282
|
+
.filter(other => other.file === module)
|
|
283
|
+
.map(other => other.id),
|
|
284
|
+
...triggers
|
|
285
|
+
.filter(other => other.file === module && other.trigger !== trigger)
|
|
286
|
+
.map(other => other.id),
|
|
287
|
+
];
|
|
288
|
+
if (beside.length > 0) {
|
|
289
|
+
return refused(`trigger-module: ${module} also exports ${beside.join(', ')}; give the provider trigger a module of its own, so a change to the rest doesn't register it again`);
|
|
290
|
+
}
|
|
291
|
+
if (typeof subscribe !== 'function') {
|
|
292
|
+
return refused('workflow-trigger-unregistered: a provider trigger needs `subscribe` to register it with the provider');
|
|
293
|
+
}
|
|
294
|
+
const registration = {
|
|
295
|
+
unsubscribe: typeof unsubscribe === 'function',
|
|
296
|
+
hash: hashes[module] ?? unhashed(),
|
|
297
|
+
module,
|
|
298
|
+
};
|
|
299
|
+
return {
|
|
300
|
+
id,
|
|
301
|
+
file,
|
|
302
|
+
description,
|
|
303
|
+
trigger: declared,
|
|
304
|
+
registration,
|
|
305
|
+
problems,
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
return [
|
|
309
|
+
...described,
|
|
310
|
+
...unfinished.map(({ id, file }) => ({
|
|
311
|
+
id,
|
|
312
|
+
file,
|
|
313
|
+
problems: [HANDLER_MISSING],
|
|
314
|
+
})),
|
|
315
|
+
];
|
|
316
|
+
}
|
|
317
|
+
const ONE_TRIGGER = (labels) => `one-trigger: an automation has one trigger, and this one has ${labels.length} (${labels.join(', ')}); a second trigger is a second automation`;
|
|
318
|
+
/** A standalone automation is one workflow on one trigger, as classic's is: each one past the first is refused. */
|
|
319
|
+
const oneTrigger = (workflows, routes) => {
|
|
320
|
+
const webhooks = routes.filter(route => Object.values(route.methods).some(access => access.kind === 'webhook'));
|
|
321
|
+
const labels = [
|
|
322
|
+
...workflows.map(w => w.id),
|
|
323
|
+
...webhooks.map(route => `the webhook at ${route.path}`),
|
|
324
|
+
];
|
|
325
|
+
if (labels.length < 2)
|
|
326
|
+
return;
|
|
327
|
+
for (const extra of [...workflows, ...webhooks].slice(1))
|
|
328
|
+
extra.problems.push(ONE_TRIGGER(labels));
|
|
329
|
+
};
|
|
330
|
+
const ROUTER_FILE = 'router-file: export getRouter from src/router.tsx, built with createZiteRouter from zitejs/start, which gives pages the signed-in user';
|
|
331
|
+
const SHARED_ROUTER = "router-file: getRouter returns the same router every time, which shows every visitor the first one's user and data; call createZiteRouter inside getRouter";
|
|
332
|
+
export async function describeApp(opts) {
|
|
333
|
+
const facts = opts.facts ?? builtAppFacts();
|
|
334
|
+
const functions = [];
|
|
335
|
+
for (const id of opts.fnIds) {
|
|
336
|
+
const described = await describeFunction(id, opts.request);
|
|
337
|
+
const description = opts.descriptions?.[id];
|
|
338
|
+
described.problems.push(...functionRules(described, facts));
|
|
339
|
+
functions.push(description ? { ...described, description } : described);
|
|
340
|
+
}
|
|
341
|
+
const router = await opts.getRouter();
|
|
342
|
+
const problems = [];
|
|
343
|
+
if (!isZiteRouter(router))
|
|
344
|
+
problems.push(ROUTER_FILE);
|
|
345
|
+
// A router built once at import is the same object on every call.
|
|
346
|
+
else if ((await opts.getRouter()) === router)
|
|
347
|
+
problems.push(SHARED_ROUTER);
|
|
348
|
+
const { routesById } = router;
|
|
349
|
+
const routes = describeRoutes(routesById, opts.routeFiles, facts);
|
|
350
|
+
const pages = describePages(routesById, opts.routeFiles);
|
|
351
|
+
for (const page of pages) {
|
|
352
|
+
if (!routes.some(route => route.path === page.path) &&
|
|
353
|
+
RESERVED_PATHS.some(reserved => reserved.test(page.path))) {
|
|
354
|
+
problems.push(`${page.path}: ${RESERVED_PATH}`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
const workflows = describeWorkflows(opts.workflows ?? [], {
|
|
358
|
+
hashes: opts.registrationHashes,
|
|
359
|
+
unfinished: opts.unfinishedWorkflows,
|
|
360
|
+
triggers: opts.triggers ?? (await loadProviderTriggers()),
|
|
361
|
+
});
|
|
362
|
+
if (facts.automation)
|
|
363
|
+
oneTrigger(workflows, routes);
|
|
364
|
+
return {
|
|
365
|
+
functions,
|
|
366
|
+
routes,
|
|
367
|
+
pages,
|
|
368
|
+
workflows,
|
|
369
|
+
authHooks: Object.keys(await loadAuthHooks()),
|
|
370
|
+
problems,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Describes a built Start app from its `dist/server`: a Workers build in workerd, a Node build in-process. */
|
|
2
|
+
export declare function describeBuiltApp(appDir: string): Promise<unknown>;
|
|
3
|
+
/** @internal Each problem in a description, after what it's about: the app, or a function, route or automation. */
|
|
4
|
+
export declare const describedProblems: (description: unknown) => string[];
|
|
5
|
+
export declare function runDescribe(): Promise<void>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { createServer } from 'node:net';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
// Only the host can set x-zite-* in production: the front strips them from public traffic.
|
|
7
|
+
const DESCRIBE_HEADERS = { 'x-zite-invoke': 'describe' };
|
|
8
|
+
// Not "localhost": it can resolve to ::1 for vite's listen and to 127.0.0.1 for fetch.
|
|
9
|
+
const HOST = '127.0.0.1';
|
|
10
|
+
const freePort = () => new Promise((resolve, reject) => {
|
|
11
|
+
const server = createServer();
|
|
12
|
+
server.once('error', reject);
|
|
13
|
+
server.listen(0, HOST, () => {
|
|
14
|
+
const { port } = server.address();
|
|
15
|
+
server.close(() => resolve(port));
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
// A Workers build runs where it will run: workerd, through the app's own
|
|
19
|
+
// `vite preview`, so it uses the same Cloudflare plugin and config as the build.
|
|
20
|
+
async function describeInWorkerd(appDir) {
|
|
21
|
+
const port = await freePort();
|
|
22
|
+
// Its own process group, so stopping it also stops vite and workerd under npx.
|
|
23
|
+
const preview = spawn('npx', [
|
|
24
|
+
'--no-install',
|
|
25
|
+
'vite',
|
|
26
|
+
'preview',
|
|
27
|
+
'--host',
|
|
28
|
+
HOST,
|
|
29
|
+
'--port',
|
|
30
|
+
String(port),
|
|
31
|
+
'--strictPort',
|
|
32
|
+
], {
|
|
33
|
+
cwd: appDir,
|
|
34
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
35
|
+
detached: true,
|
|
36
|
+
});
|
|
37
|
+
let stderr = '';
|
|
38
|
+
preview.stderr.on('data', chunk => (stderr += chunk));
|
|
39
|
+
try {
|
|
40
|
+
const deadline = Date.now() + 60_000;
|
|
41
|
+
while (true) {
|
|
42
|
+
try {
|
|
43
|
+
const response = await fetch(`http://${HOST}:${port}/`, {
|
|
44
|
+
headers: DESCRIBE_HEADERS,
|
|
45
|
+
});
|
|
46
|
+
// Right after start, preview can answer before the Worker does; only the
|
|
47
|
+
// app's own describe answer is JSON.
|
|
48
|
+
if (response.ok &&
|
|
49
|
+
response.headers.get('content-type')?.includes('application/json')) {
|
|
50
|
+
return await response.json();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch { }
|
|
54
|
+
if (preview.exitCode !== null || Date.now() > deadline) {
|
|
55
|
+
throw new Error(`vite preview didn't serve the app: ${stderr.trim().slice(-500)}`);
|
|
56
|
+
}
|
|
57
|
+
await new Promise(resolve => setTimeout(resolve, 250));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
try {
|
|
62
|
+
process.kill(-preview.pid, 'SIGTERM');
|
|
63
|
+
}
|
|
64
|
+
catch { }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Describes a built Start app from its `dist/server`: a Workers build in workerd, a Node build in-process. */
|
|
68
|
+
export async function describeBuiltApp(appDir) {
|
|
69
|
+
const serverDir = path.join(appDir, 'dist/server');
|
|
70
|
+
if (existsSync(path.join(serverDir, 'wrangler.json')))
|
|
71
|
+
return describeInWorkerd(appDir);
|
|
72
|
+
const { default: server } = await import(pathToFileURL(path.join(serverDir, 'server.js')).href);
|
|
73
|
+
return (await server.fetch(new Request('http://describe.local/', { headers: DESCRIBE_HEADERS }))).json();
|
|
74
|
+
}
|
|
75
|
+
const listed = (value) => Array.isArray(value)
|
|
76
|
+
? value.filter(item => item && typeof item === 'object')
|
|
77
|
+
: [];
|
|
78
|
+
/** @internal Each problem in a description, after what it's about: the app, or a function, route or automation. */
|
|
79
|
+
export const describedProblems = (description) => {
|
|
80
|
+
const of = description;
|
|
81
|
+
const lines = (label, problems) => Array.isArray(problems)
|
|
82
|
+
? problems.map(problem => `${label}: ${String(problem)}`)
|
|
83
|
+
: [];
|
|
84
|
+
const where = (name, file) => typeof file === 'string' ? `${String(name)} (${file})` : String(name);
|
|
85
|
+
return [
|
|
86
|
+
...lines('app', of?.problems),
|
|
87
|
+
...listed(of?.functions).flatMap(fn => lines(`function ${where(fn.name ?? fn.id, fn.file)}`, fn.problems)),
|
|
88
|
+
...listed(of?.routes).flatMap(route => lines(`route ${where(route.path, route.file)}`, route.problems)),
|
|
89
|
+
...listed(of?.workflows).flatMap(workflow => lines(`automation ${where(workflow.id, workflow.file)}`, workflow.problems)),
|
|
90
|
+
];
|
|
91
|
+
};
|
|
92
|
+
// The JSON on stdout is the platform's, which reads a nonzero exit as no description at all; stderr is for whoever
|
|
93
|
+
// runs it by hand.
|
|
94
|
+
export async function runDescribe() {
|
|
95
|
+
const appDir = path.resolve(process.argv[3] ?? '.');
|
|
96
|
+
const description = await describeBuiltApp(appDir);
|
|
97
|
+
process.stdout.write(`${JSON.stringify(description, null, 2)}\n`);
|
|
98
|
+
const problems = describedProblems(description);
|
|
99
|
+
if (problems.length > 0) {
|
|
100
|
+
process.stderr.write(`zitejs describe: ${problems.length} problem${problems.length === 1 ? '' : 's'}\n${problems.map(line => ` - ${line}`).join('\n')}\n`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const stringValue = (node) => {
|
|
2
|
+
if (node?.type === 'Literal' && typeof node.value === 'string')
|
|
3
|
+
return node.value;
|
|
4
|
+
const quasis = node?.quasis;
|
|
5
|
+
if (node?.type === 'TemplateLiteral' &&
|
|
6
|
+
node.expressions.length === 0)
|
|
7
|
+
return quasis?.[0]?.value.cooked;
|
|
8
|
+
return undefined;
|
|
9
|
+
};
|
|
10
|
+
const descriptionProperty = (node) => {
|
|
11
|
+
for (const property of node.properties) {
|
|
12
|
+
const key = property.key;
|
|
13
|
+
const named = key?.type === 'Identifier'
|
|
14
|
+
? key.name
|
|
15
|
+
: key?.type === 'Literal'
|
|
16
|
+
? key.value
|
|
17
|
+
: undefined;
|
|
18
|
+
if (property.type === 'Property' && named === 'description')
|
|
19
|
+
return stringValue(property.value);
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
23
|
+
// Walks a builder chain, `signedInFn({ description }).validator(…).handler(…)`, to an object option.
|
|
24
|
+
const descriptionIn = (node) => {
|
|
25
|
+
if (node?.type === 'CallExpression') {
|
|
26
|
+
for (const arg of node.arguments) {
|
|
27
|
+
const found = arg.type === 'ObjectExpression' ? descriptionProperty(arg) : undefined;
|
|
28
|
+
if (found !== undefined)
|
|
29
|
+
return found;
|
|
30
|
+
}
|
|
31
|
+
return descriptionIn(node.callee);
|
|
32
|
+
}
|
|
33
|
+
if (node?.type === 'MemberExpression')
|
|
34
|
+
return descriptionIn(node.object);
|
|
35
|
+
return undefined;
|
|
36
|
+
};
|
|
37
|
+
/** `name -> description` for each top-level const built with a description option. */
|
|
38
|
+
export function factoryDescriptions(program) {
|
|
39
|
+
const found = new Map();
|
|
40
|
+
for (const statement of program.body) {
|
|
41
|
+
const declaration = (statement.type === 'ExportNamedDeclaration'
|
|
42
|
+
? statement.declaration
|
|
43
|
+
: statement);
|
|
44
|
+
if (declaration?.type !== 'VariableDeclaration')
|
|
45
|
+
continue;
|
|
46
|
+
for (const declarator of declaration.declarations) {
|
|
47
|
+
const id = declarator.id;
|
|
48
|
+
const description = descriptionIn(declarator.init);
|
|
49
|
+
if (id.type === 'Identifier' && description)
|
|
50
|
+
found.set(id.name, description);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return found;
|
|
54
|
+
}
|