zitejs 0.10.0-start.9 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +15 -9
- package/dist/cjs/backend/index.js +13 -13
- package/dist/cjs/backend/index.test.js +102 -102
- package/dist/cjs/bundle/index.d.ts +8 -0
- package/dist/cjs/bundle/index.js +38 -24
- package/dist/cjs/caller/index.js +43 -43
- package/dist/cjs/check/index.d.ts +20 -9
- package/dist/cjs/check/index.js +113 -88
- 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 +10 -4
- package/dist/cjs/client/index.d.ts +26 -2
- package/dist/cjs/client/index.js +25 -25
- package/dist/cjs/dev/index.js +79 -54
- 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.d.ts +1 -0
- package/dist/cjs/integrations/rules.js +48 -43
- package/dist/cjs/integrations/rules.test.js +60 -54
- 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 +126 -39
- package/dist/cjs/runtime/index.js +32 -26
- package/dist/cjs/runtime/index.test.js +34 -34
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +50 -0
- 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/{entries.d.ts → build/entries.d.ts} +9 -4
- package/dist/cjs/start/{entries.js → build/entries.js} +38 -21
- 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/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
- package/dist/cjs/start/{describeBuilt.js → describe/describeBuilt.js} +55 -17
- 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 +78 -0
- package/dist/cjs/steps/index.js +507 -0
- package/dist/cjs/steps/index.test.js +635 -0
- 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 +655 -655
- package/dist/cjs/sync/lib.test.js +177 -46
- 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 +9 -2
- package/dist/cjs/types/fields.js +110 -96
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/tables.d.ts +17 -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 +46 -42
- 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 +15 -9
- package/dist/esm/backend/index.js +13 -13
- package/dist/esm/backend/index.test.js +106 -106
- package/dist/esm/bundle/index.d.ts +8 -0
- package/dist/esm/bundle/index.js +37 -24
- package/dist/esm/caller/index.js +44 -44
- package/dist/esm/check/index.d.ts +20 -9
- package/dist/esm/check/index.js +117 -93
- 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 +10 -4
- package/dist/esm/client/index.d.ts +26 -2
- package/dist/esm/client/index.js +25 -25
- package/dist/esm/dev/index.js +86 -61
- 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.d.ts +1 -0
- package/dist/esm/integrations/rules.js +48 -43
- package/dist/esm/integrations/rules.test.js +62 -56
- 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 +126 -39
- package/dist/esm/runtime/index.js +35 -29
- package/dist/esm/runtime/index.test.js +36 -36
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +48 -0
- 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/{registration.d.ts → automations/registration.d.ts} +1 -1
- package/dist/esm/start/{registration.js → automations/registration.js} +11 -7
- 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/{entries.d.ts → build/entries.d.ts} +9 -4
- package/dist/esm/start/{entries.js → build/entries.js} +38 -22
- 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/{workflowModules.js → build/placeholders/workflowModules.js} +1 -1
- 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/{describe.d.ts → describe/describe.d.ts} +44 -9
- package/dist/esm/start/describe/describe.js +372 -0
- package/dist/esm/start/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
- package/dist/esm/start/describe/describeBuilt.js +102 -0
- package/dist/esm/start/{descriptions.js → describe/descriptions.js} +17 -10
- package/dist/esm/start/errors.d.ts +15 -4
- package/dist/esm/start/errors.js +87 -28
- package/dist/esm/start/errors.test.js +47 -16
- 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 -1
- package/dist/esm/start/factories.test-d.js +52 -12
- 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 +2 -2
- package/dist/esm/start/host.js +3 -3
- package/dist/esm/start/index.d.ts +10 -66
- package/dist/esm/start/index.js +7 -146
- 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/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/{airtable → platform/airtable}/dispatch.d.ts +5 -2
- package/dist/esm/start/{airtable → platform/airtable}/dispatch.js +195 -119
- package/dist/esm/start/{airtable → platform/airtable}/formulas.d.ts +2 -1
- package/dist/esm/start/{airtable → platform/airtable}/formulas.js +51 -25
- 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/{data → platform/data}/baseRunner.d.ts +11 -6
- package/dist/esm/start/platform/data/baseRunner.js +117 -0
- package/dist/esm/start/{data → platform/data}/dispatch.d.ts +3 -2
- package/dist/esm/start/{data → platform/data}/dispatch.js +69 -51
- 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/{data → platform/data}/transformations.d.ts +0 -31
- package/dist/esm/start/{data → platform/data}/transformations.js +0 -56
- package/dist/esm/start/{data → platform/data}/types.d.ts +4 -1
- package/dist/esm/start/{data → platform/data}/types.js +2 -2
- 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/{redactSecrets.js → platform/redactSecrets.js} +32 -7
- package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -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 +3 -7
- package/dist/esm/start/previewClaim.js +9 -17
- 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 +27 -4
- package/dist/esm/start/router.js +221 -22
- 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/{instance.d.ts → serve/instance.d.ts} +6 -5
- 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 +270 -56
- package/dist/esm/start/version.d.ts +1 -1
- package/dist/esm/start/version.js +1 -1
- package/dist/esm/steps/index.d.ts +78 -0
- package/dist/esm/steps/index.js +502 -0
- package/dist/esm/steps/index.test.d.ts +1 -0
- package/dist/esm/steps/index.test.js +633 -0
- 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 +659 -659
- package/dist/esm/sync/lib.test.js +177 -46
- 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 +9 -2
- package/dist/esm/types/fields.js +110 -96
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/index.js +2 -2
- package/dist/esm/types/tables.d.ts +17 -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 +51 -47
- package/package.json +95 -37
- package/dist/cjs/auth-server/index.d.ts +0 -369
- package/dist/cjs/auth-server/index.js +0 -119
- package/dist/cjs/check/start/describeRules.d.ts +0 -35
- package/dist/cjs/check/start/describeRules.js +0 -89
- package/dist/cjs/check/start/problem.d.ts +0 -11
- package/dist/cjs/check/start/problem.js +0 -5
- package/dist/cjs/check/start/sourceRules.d.ts +0 -3
- package/dist/cjs/check/start/sourceRules.js +0 -441
- package/dist/cjs/start/problems.d.ts +0 -19
- package/dist/cjs/start/problems.js +0 -11
- package/dist/esm/auth-server/index.d.ts +0 -369
- package/dist/esm/auth-server/index.js +0 -116
- package/dist/esm/check/start/describeRules.d.ts +0 -35
- package/dist/esm/check/start/describeRules.js +0 -86
- package/dist/esm/check/start/problem.d.ts +0 -11
- package/dist/esm/check/start/problem.js +0 -1
- package/dist/esm/check/start/sourceRules.d.ts +0 -3
- package/dist/esm/check/start/sourceRules.js +0 -438
- package/dist/esm/start/airtable/index.d.ts +0 -11
- package/dist/esm/start/airtable/index.js +0 -70
- package/dist/esm/start/authHooks.js +0 -10
- package/dist/esm/start/data/baseRunner.js +0 -83
- package/dist/esm/start/data/index.d.ts +0 -18
- package/dist/esm/start/data/index.js +0 -76
- package/dist/esm/start/describe.js +0 -204
- package/dist/esm/start/describeBuilt.js +0 -66
- package/dist/esm/start/instance.js +0 -80
- package/dist/esm/start/problems.d.ts +0 -19
- package/dist/esm/start/problems.js +0 -8
- package/dist/esm/start/redactSecrets.d.ts +0 -7
- package/dist/esm/start/runLog.d.ts +0 -8
- package/dist/esm/start/runLog.js +0 -76
- package/dist/esm/start/scope.d.ts +0 -15
- package/dist/esm/start/scope.js +0 -58
- package/dist/esm/start/server.d.ts +0 -55
- package/dist/esm/start/server.js +0 -317
- package/dist/esm/start/vite.d.ts +0 -9
- package/dist/esm/start/vite.js +0 -173
- package/dist/esm/start/worker.d.ts +0 -11
- package/dist/esm/start/worker.js +0 -20
- package/dist/esm/start/workflow.d.ts +0 -53
- package/dist/esm/start/workflow.js +0 -13
- package/dist/esm/start/workflow.test-d.js +0 -44
- package/dist/esm/start/workflowRun.d.ts +0 -80
- package/dist/esm/start/workflowRun.js +0 -108
- /package/dist/{esm/start/redactSecrets.test.d.ts → cjs/runtime/sendEmailParamsTypes.test-d.d.ts} +0 -0
- /package/dist/{esm/start/workflow.test-d.d.ts → cjs/steps/index.test.d.ts} +0 -0
- /package/dist/esm/start/{authHooksModule.d.ts → build/placeholders/authHooksModule.d.ts} +0 -0
- /package/dist/esm/start/{authHooksModule.js → build/placeholders/authHooksModule.js} +0 -0
- /package/dist/esm/start/{workflowModules.d.ts → build/placeholders/workflowModules.d.ts} +0 -0
- /package/dist/esm/start/{descriptions.d.ts → describe/descriptions.d.ts} +0 -0
- /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.d.ts +0 -0
- /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.js +0 -0
- /package/dist/esm/start/{data → platform/data}/sqlNameMappings.d.ts +0 -0
- /package/dist/esm/start/{data → platform/data}/sqlNameMappings.js +0 -0
- /package/dist/esm/start/{redactSecrets.test.js → platform/redactSecrets.test.js} +0 -0
- /package/dist/esm/start/{authHooks.d.ts → serve/authHooks.d.ts} +0 -0
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { createBaseRunner } from "./baseRunner.js";
|
|
2
|
-
import { asZiteClientError, executeDatabasesCall } from "./dispatch.js";
|
|
3
|
-
/** What generated `zite.*` calls go out under. */
|
|
4
|
-
export const DATA_INTEGRATION_ID = "databases";
|
|
5
|
-
// Schema changes aren't redeployed, so a new table or field reaches calls within this, as on the host.
|
|
6
|
-
const TABLES_REUSE_MS = 60_000;
|
|
7
|
-
// One build per script, so per isolate: what the platform says the build's base is, and that base's tables.
|
|
8
|
-
// Only answers are kept, never a pending call: one request's RPC session mustn't hold up another's.
|
|
9
|
-
let context;
|
|
10
|
-
let tables;
|
|
11
|
-
let unsupported = false;
|
|
12
|
-
const tablesOf = async (baseRunner, baseId) => {
|
|
13
|
-
if (tables?.baseId === baseId && Date.now() - tables.at < TABLES_REUSE_MS)
|
|
14
|
-
return tables.tables;
|
|
15
|
-
const base = await baseRunner.bases.get({ baseId });
|
|
16
|
-
tables = { baseId, tables: base.tables, at: Date.now() };
|
|
17
|
-
return base.tables;
|
|
18
|
-
};
|
|
19
|
-
// What Workers RPC throws for a method the host doesn't have yet.
|
|
20
|
-
const NOT_IMPLEMENTED = /does not implement (?:the )?method/i;
|
|
21
|
-
/**
|
|
22
|
-
* The build's data context, or undefined from a host that predates the app's own
|
|
23
|
-
* dispatch, whose `databases` platform call still answers.
|
|
24
|
-
*/
|
|
25
|
-
export const dataContextOf = async (session) => {
|
|
26
|
-
if (unsupported || !session.dataContext || !session.dataFetch)
|
|
27
|
-
return undefined;
|
|
28
|
-
if (context)
|
|
29
|
-
return context;
|
|
30
|
-
try {
|
|
31
|
-
const answer = await session.dataContext();
|
|
32
|
-
context = { baseId: answer.baseId, nameMappings: answer.nameMappings ?? null };
|
|
33
|
-
return context;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
if (error instanceof Error && NOT_IMPLEMENTED.test(error.message)) {
|
|
37
|
-
unsupported = true;
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* The table id classic's generated client sends: its SDK name mapped through the
|
|
45
|
-
* build's name mappings, which on classic the client does from the run's config.
|
|
46
|
-
*/
|
|
47
|
-
const tableIdOf = (nameMappings, sent) => {
|
|
48
|
-
for (const [id, table] of Object.entries(nameMappings?.tables ?? {})) {
|
|
49
|
-
if (table.mapping?.sdkName === sent)
|
|
50
|
-
return id;
|
|
51
|
-
}
|
|
52
|
-
return sent;
|
|
53
|
-
};
|
|
54
|
-
/** One `zite.*` call, translated here and sent to base-runner through the platform. */
|
|
55
|
-
export async function runDataCall(session, found, mode, methodName, sent) {
|
|
56
|
-
const params = sent && typeof sent === "object" && typeof sent.tableId === "string"
|
|
57
|
-
? { ...sent, tableId: tableIdOf(found.nameMappings, sent.tableId) }
|
|
58
|
-
: sent;
|
|
59
|
-
if (!found.baseId)
|
|
60
|
-
throw asZiteClientError(Object.assign(new Error("This app has no database"), { statusCode: 404 }));
|
|
61
|
-
const baseRunner = createBaseRunner((request) => session.dataFetch(request));
|
|
62
|
-
let baseTables;
|
|
63
|
-
try {
|
|
64
|
-
baseTables = await tablesOf(baseRunner, found.baseId);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
throw asZiteClientError(error);
|
|
68
|
-
}
|
|
69
|
-
return executeDatabasesCall({ baseRunner, baseId: found.baseId, nameMappings: found.nameMappings, tables: baseTables, readOnly: mode === "demo" }, methodName, params);
|
|
70
|
-
}
|
|
71
|
-
/** For tests: forget what this isolate learned. */
|
|
72
|
-
export const resetDataDispatch = () => {
|
|
73
|
-
context = undefined;
|
|
74
|
-
tables = undefined;
|
|
75
|
-
unsupported = false;
|
|
76
|
-
};
|
|
@@ -1,204 +0,0 @@
|
|
|
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 "./index.js";
|
|
8
|
-
import { loadAuthHooks } from "./authHooks.js";
|
|
9
|
-
const accessOf = (chain, problems) => {
|
|
10
|
-
const kinds = chain.map(ziteMiddlewareKind).filter((k) => !!k);
|
|
11
|
-
const roles = kinds.flatMap((k) => (k.kind === "role" ? [k.role] : []));
|
|
12
|
-
const base = [...new Set(kinds.flatMap((k) => (k.kind === "signedIn" || k.kind === "anyone" || k.kind === "webhook" ? [k.kind] : [])))];
|
|
13
|
-
if (base.length === 0) {
|
|
14
|
-
problems.push("access-missing: no signedIn, anyone or webhook middleware in its chain");
|
|
15
|
-
return { kind: "none", roles };
|
|
16
|
-
}
|
|
17
|
-
if (base.length > 1)
|
|
18
|
-
problems.push(`access-conflict: ${base.join(" + ")}`);
|
|
19
|
-
const kind = base.includes("webhook") ? "webhook" : base.includes("signedIn") ? "signedIn" : "anyone";
|
|
20
|
-
const paused = kinds.some((k) => k.kind === "webhook" && k.paused === true);
|
|
21
|
-
return paused ? { kind, roles, paused } : { kind, roles };
|
|
22
|
-
};
|
|
23
|
-
const jsonSchemaOf = (validator) => {
|
|
24
|
-
if (validator && typeof validator === "object" && "_zod" in validator) {
|
|
25
|
-
try {
|
|
26
|
-
return z.toJSONSchema(validator);
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return { unrepresentable: true };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return validator ? { opaque: true } : undefined;
|
|
33
|
-
};
|
|
34
|
-
// Describe walks functions one at a time, so one probe slot is enough.
|
|
35
|
-
let probe = null;
|
|
36
|
-
// The only global function middleware while describing: it records what it was
|
|
37
|
-
// handed and ends the call, so no app middleware or handler runs.
|
|
38
|
-
const describeProbe = createMiddleware({ type: "function" }).server(({ serverFnMeta, method }) => {
|
|
39
|
-
if (probe)
|
|
40
|
-
Object.assign(probe, { meta: serverFnMeta, method, reached: true });
|
|
41
|
-
return "zite:describe";
|
|
42
|
-
});
|
|
43
|
-
const SERVER_ONLY = "server-only: nothing in the browser calls it, and a server function that only other server functions call can't run. " +
|
|
44
|
-
"Move the shared logic into a *.server.ts helper and call that.";
|
|
45
|
-
export async function describeFunction(id, request) {
|
|
46
|
-
const problems = [];
|
|
47
|
-
const seen = [];
|
|
48
|
-
probe = { reached: false };
|
|
49
|
-
// Before running a chain, TanStack asks this set about every middleware in it.
|
|
50
|
-
// Recording the questions gives the exact chain it would have run.
|
|
51
|
-
const executedRequestMiddlewares = {
|
|
52
|
-
has: (middleware) => {
|
|
53
|
-
seen.push(middleware);
|
|
54
|
-
return false;
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
const startContext = {
|
|
58
|
-
request,
|
|
59
|
-
startOptions: { functionMiddleware: [describeProbe] },
|
|
60
|
-
executedRequestMiddlewares,
|
|
61
|
-
contextAfterGlobalMiddlewares: {},
|
|
62
|
-
handlerType: "serverFn",
|
|
63
|
-
getRouter: () => {
|
|
64
|
-
throw new Error("describe has no router");
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
try {
|
|
68
|
-
await runWithStartContext(startContext, () => createSsrRpc(id)({ data: undefined, context: {} }));
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
72
|
-
// TanStack registers only functions something can call through it. One that
|
|
73
|
-
// only other server functions call isn't registered, and calling it fails.
|
|
74
|
-
if (message === `Server function info not found for ${id}`) {
|
|
75
|
-
probe = null;
|
|
76
|
-
return { id, access: { kind: "none", roles: [] }, problems: [SERVER_ONLY] };
|
|
77
|
-
}
|
|
78
|
-
problems.push(`probe-failed: ${message}`);
|
|
79
|
-
}
|
|
80
|
-
const state = probe;
|
|
81
|
-
probe = null;
|
|
82
|
-
// Fails closed: if TanStack stops asking, or stops running globals first, every
|
|
83
|
-
// function reports a problem and the build stops.
|
|
84
|
-
if (!state.reached || seen[0] !== describeProbe)
|
|
85
|
-
problems.push("probe-not-first: chain could not be read");
|
|
86
|
-
const chain = seen.filter((m) => m !== describeProbe);
|
|
87
|
-
if (!chain.some((m) => ziteMiddlewareKind(m)?.kind === "factory")) {
|
|
88
|
-
problems.push("raw-server-fn: define it with signedInFn or publicFn from zitejs/start");
|
|
89
|
-
}
|
|
90
|
-
// TanStack keeps the validator under `inputValidator` up to 1.168 and `validator` from 1.169 (Start 1.0).
|
|
91
|
-
const handlerStep = chain.at(-1);
|
|
92
|
-
return {
|
|
93
|
-
id,
|
|
94
|
-
name: state.meta?.name,
|
|
95
|
-
file: state.meta?.filename,
|
|
96
|
-
method: state.method,
|
|
97
|
-
access: accessOf(chain, problems),
|
|
98
|
-
input: jsonSchemaOf(handlerStep?.options?.validator ?? handlerStep?.options?.inputValidator),
|
|
99
|
-
problems,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const ROOT_ROUTE_ID = "__root__";
|
|
103
|
-
// Pathless layouts have no path of their own, and a file with only server handlers is an API route.
|
|
104
|
-
export function describePages(routesById, files = {}) {
|
|
105
|
-
return Object.values(routesById).flatMap((route) => {
|
|
106
|
-
const options = route.options ?? {};
|
|
107
|
-
if (route.id === ROOT_ROUTE_ID || options.path === undefined)
|
|
108
|
-
return [];
|
|
109
|
-
if (options.server?.handlers && !options.component)
|
|
110
|
-
return [];
|
|
111
|
-
const file = files[route.id];
|
|
112
|
-
return [{ id: route.id, path: route.fullPath, ...(file && { file }) }];
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
export function describeRoutes(routesById, files = {}) {
|
|
116
|
-
const out = [];
|
|
117
|
-
for (const route of Object.values(routesById)) {
|
|
118
|
-
const server = route.options?.server;
|
|
119
|
-
if (!server?.handlers)
|
|
120
|
-
continue;
|
|
121
|
-
const problems = [];
|
|
122
|
-
const ancestry = [];
|
|
123
|
-
for (let r = route; r; r = r.parentRoute)
|
|
124
|
-
ancestry.unshift(r);
|
|
125
|
-
const routeMiddleware = ancestry.flatMap((r) => r.options?.server?.middleware ?? []);
|
|
126
|
-
const handlers = (typeof server.handlers === "function"
|
|
127
|
-
? server.handlers({ createHandlers: (d) => d })
|
|
128
|
-
: server.handlers);
|
|
129
|
-
const methods = {};
|
|
130
|
-
for (const [method, handler] of Object.entries(handlers)) {
|
|
131
|
-
const own = typeof handler === "function" ? [] : (handler.middleware ?? []);
|
|
132
|
-
const chain = flattenMiddlewares([...routeMiddleware, ...own]);
|
|
133
|
-
const methodProblems = [];
|
|
134
|
-
methods[method] = accessOf(chain, methodProblems);
|
|
135
|
-
problems.push(...methodProblems.map((p) => `${method}: ${p}`));
|
|
136
|
-
}
|
|
137
|
-
const file = files[route.id];
|
|
138
|
-
const description = route.options?.staticData?.description;
|
|
139
|
-
out.push({
|
|
140
|
-
path: route.fullPath,
|
|
141
|
-
...(file && { file }),
|
|
142
|
-
...(typeof description === "string" && description && { description }),
|
|
143
|
-
methods,
|
|
144
|
-
problems,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return out;
|
|
148
|
-
}
|
|
149
|
-
// cyrb53: enough to tell when the code changed, which is all publish asks.
|
|
150
|
-
const sourceHash = (text) => {
|
|
151
|
-
let h1 = 0xdeadbeef;
|
|
152
|
-
let h2 = 0x41c6ce57;
|
|
153
|
-
for (let i = 0; i < text.length; i++) {
|
|
154
|
-
const ch = text.charCodeAt(i);
|
|
155
|
-
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
156
|
-
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
157
|
-
}
|
|
158
|
-
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
159
|
-
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
160
|
-
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16).padStart(14, "0");
|
|
161
|
-
};
|
|
162
|
-
// A workflow's id is its export name: what the host invokes it by and the editor shows.
|
|
163
|
-
export function describeWorkflows(workflows) {
|
|
164
|
-
return workflows.map(({ id, file, workflow }) => {
|
|
165
|
-
const problems = [];
|
|
166
|
-
if (id === "default")
|
|
167
|
-
problems.push("workflow-default-export: export it by name, which becomes its id");
|
|
168
|
-
const elsewhere = workflows.find((other) => other.id === id && other.file !== file);
|
|
169
|
-
if (elsewhere)
|
|
170
|
-
problems.push(`duplicate-workflow: ${id} is also exported from ${elsewhere.file}`);
|
|
171
|
-
const { description, schedule, trigger } = workflow.config;
|
|
172
|
-
if (schedule)
|
|
173
|
-
return { id, file, description, schedule, problems };
|
|
174
|
-
if (!trigger || trigger.every !== undefined || trigger.events !== undefined) {
|
|
175
|
-
return { id, file, description, trigger, problems };
|
|
176
|
-
}
|
|
177
|
-
const { subscribe, unsubscribe, ...declared } = trigger;
|
|
178
|
-
if (typeof subscribe !== "function") {
|
|
179
|
-
problems.push("workflow-trigger-unregistered: a provider trigger needs `subscribe` to register it with the provider");
|
|
180
|
-
return { id, file, description, trigger: declared, problems };
|
|
181
|
-
}
|
|
182
|
-
const registration = {
|
|
183
|
-
unsubscribe: typeof unsubscribe === "function",
|
|
184
|
-
hash: sourceHash(`${String(subscribe)}\n${typeof unsubscribe === "function" ? String(unsubscribe) : ""}`),
|
|
185
|
-
};
|
|
186
|
-
return { id, file, description, trigger: declared, registration, problems };
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
export async function describeApp(opts) {
|
|
190
|
-
const functions = [];
|
|
191
|
-
for (const id of opts.fnIds) {
|
|
192
|
-
const described = await describeFunction(id, opts.request);
|
|
193
|
-
const description = opts.descriptions?.[id];
|
|
194
|
-
functions.push(description ? { ...described, description } : described);
|
|
195
|
-
}
|
|
196
|
-
const { routesById } = (await opts.getRouter());
|
|
197
|
-
return {
|
|
198
|
-
functions,
|
|
199
|
-
routes: describeRoutes(routesById, opts.routeFiles),
|
|
200
|
-
pages: describePages(routesById, opts.routeFiles),
|
|
201
|
-
workflows: describeWorkflows(opts.workflows ?? []),
|
|
202
|
-
authHooks: Object.keys(await loadAuthHooks()),
|
|
203
|
-
};
|
|
204
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
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", ["--no-install", "vite", "preview", "--host", HOST, "--port", String(port), "--strictPort"], {
|
|
24
|
-
cwd: appDir,
|
|
25
|
-
stdio: ["ignore", "ignore", "pipe"],
|
|
26
|
-
detached: true,
|
|
27
|
-
});
|
|
28
|
-
let stderr = "";
|
|
29
|
-
preview.stderr.on("data", (chunk) => (stderr += chunk));
|
|
30
|
-
try {
|
|
31
|
-
const deadline = Date.now() + 60_000;
|
|
32
|
-
while (true) {
|
|
33
|
-
try {
|
|
34
|
-
const response = await fetch(`http://${HOST}:${port}/`, { headers: DESCRIBE_HEADERS });
|
|
35
|
-
// Right after start, preview can answer before the Worker does; only the
|
|
36
|
-
// app's own describe answer is JSON.
|
|
37
|
-
if (response.ok && response.headers.get("content-type")?.includes("application/json")) {
|
|
38
|
-
return await response.json();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch { }
|
|
42
|
-
if (preview.exitCode !== null || Date.now() > deadline) {
|
|
43
|
-
throw new Error(`vite preview didn't serve the app: ${stderr.trim().slice(-500)}`);
|
|
44
|
-
}
|
|
45
|
-
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
finally {
|
|
49
|
-
try {
|
|
50
|
-
process.kill(-preview.pid, "SIGTERM");
|
|
51
|
-
}
|
|
52
|
-
catch { }
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/** Describes a built Start app from its `dist/server`: a Workers build in workerd, a Node build in-process. */
|
|
56
|
-
export async function describeBuiltApp(appDir) {
|
|
57
|
-
const serverDir = path.join(appDir, "dist/server");
|
|
58
|
-
if (existsSync(path.join(serverDir, "wrangler.json")))
|
|
59
|
-
return describeInWorkerd(appDir);
|
|
60
|
-
const { default: server } = await import(pathToFileURL(path.join(serverDir, "server.js")).href);
|
|
61
|
-
return (await server.fetch(new Request("http://describe.local/", { headers: DESCRIBE_HEADERS }))).json();
|
|
62
|
-
}
|
|
63
|
-
export async function runDescribe() {
|
|
64
|
-
const appDir = path.resolve(process.argv[3] ?? ".");
|
|
65
|
-
process.stdout.write(`${JSON.stringify(await describeBuiltApp(appDir), null, 2)}\n`);
|
|
66
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// For the generated `.zite/start.ts` only. Apps put their own options in
|
|
2
|
-
// `src/start.ts`, which the generated instance composes after the platform's.
|
|
3
|
-
import { createCsrfMiddleware, createMiddleware, createStart } from "@tanstack/react-start";
|
|
4
|
-
import { createSerializationAdapter, redirect } from "@tanstack/react-router";
|
|
5
|
-
import { toClientError, ZiteError } from "./errors.js";
|
|
6
|
-
import { isSignInRequired, loginHref } from "./index.js";
|
|
7
|
-
import { errorOf, preview } from "./runLog.js";
|
|
8
|
-
import { getHost, inScope } from "./scope.js";
|
|
9
|
-
// TanStack drops its default CSRF check once an app has a start instance.
|
|
10
|
-
const csrf = createCsrfMiddleware({ filter: (ctx) => ctx.handlerType === "serverFn" });
|
|
11
|
-
// The host answers a signed-out call with a plain 401, the app with a ZiteError;
|
|
12
|
-
// either way the browser goes to sign in rather than showing an error.
|
|
13
|
-
const signInOn401 = createMiddleware({ type: "function" }).client(async ({ next }) => {
|
|
14
|
-
try {
|
|
15
|
-
return await next();
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
if (!isSignInRequired(error))
|
|
19
|
-
throw error;
|
|
20
|
-
const href = loginHref();
|
|
21
|
-
if (typeof window !== "undefined")
|
|
22
|
-
window.location.assign(href);
|
|
23
|
-
throw redirect({ href, reloadDocument: true });
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
// Records each call for the run log. The host's own record of the request is the
|
|
27
|
-
// floor; this adds what only the app sees: decoded input, output and errors.
|
|
28
|
-
const runCapture = createMiddleware({ type: "function" }).server(async ({ next, data, serverFnMeta }) => {
|
|
29
|
-
const runs = getHost()?.runs;
|
|
30
|
-
const startedAt = Date.now();
|
|
31
|
-
const record = (outcome) => runs?.push({
|
|
32
|
-
fn: serverFnMeta.id,
|
|
33
|
-
name: serverFnMeta.name,
|
|
34
|
-
nested: inScope(),
|
|
35
|
-
startedAt,
|
|
36
|
-
durationMs: Date.now() - startedAt,
|
|
37
|
-
input: preview(data),
|
|
38
|
-
...("error" in outcome ? { error: errorOf(outcome.error) } : { output: preview(outcome.output) }),
|
|
39
|
-
});
|
|
40
|
-
try {
|
|
41
|
-
const out = await next();
|
|
42
|
-
const failed = out.error;
|
|
43
|
-
record(failed === undefined ? { output: out.result } : { error: failed });
|
|
44
|
-
return out;
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
record({ error });
|
|
48
|
-
throw error;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
/**
|
|
52
|
-
* Every error a server function or a page's loader sends the browser arrives as a ZiteError, with its code and the
|
|
53
|
-
* message classic would show. Anything else on it, a stack or an SDK's request, stays on the server.
|
|
54
|
-
*/
|
|
55
|
-
const ziteErrorAdapter = createSerializationAdapter({
|
|
56
|
-
key: "zite-error",
|
|
57
|
-
test: (value) => value instanceof Error,
|
|
58
|
-
toSerializable: (error) => {
|
|
59
|
-
const { code, message } = toClientError(error);
|
|
60
|
-
return { code, message };
|
|
61
|
-
},
|
|
62
|
-
fromSerializable: ({ code, message }) => new ZiteError(code, message),
|
|
63
|
-
});
|
|
64
|
-
/**
|
|
65
|
-
* The start instance every Start app builds with: the platform's middleware and
|
|
66
|
-
* adapters first, then whatever the app's own `src/start.ts` sets.
|
|
67
|
-
*/
|
|
68
|
-
export function createZiteStart(app) {
|
|
69
|
-
return createStart(async () => {
|
|
70
|
-
const own = app ? await app.getOptions() : undefined;
|
|
71
|
-
// Spreading the app's optional arrays loses their tuple types, which the
|
|
72
|
-
// route tree registers for typed context and serialization.
|
|
73
|
-
return {
|
|
74
|
-
...own,
|
|
75
|
-
requestMiddleware: [csrf, ...(own?.requestMiddleware ?? [])],
|
|
76
|
-
functionMiddleware: [signInOn401, runCapture, ...(own?.functionMiddleware ?? [])],
|
|
77
|
-
serializationAdapters: [ziteErrorAdapter, ...(own?.serializationAdapters ?? [])],
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
type WithProblems = {
|
|
2
|
-
problems: string[];
|
|
3
|
-
};
|
|
4
|
-
type Described = {
|
|
5
|
-
functions: Array<WithProblems & {
|
|
6
|
-
id: string;
|
|
7
|
-
file?: string;
|
|
8
|
-
}>;
|
|
9
|
-
routes: Array<WithProblems & {
|
|
10
|
-
path: string;
|
|
11
|
-
}>;
|
|
12
|
-
workflows?: Array<WithProblems & {
|
|
13
|
-
id: string;
|
|
14
|
-
file: string;
|
|
15
|
-
}>;
|
|
16
|
-
};
|
|
17
|
-
/** Every problem in a description, one line each, named by its rule. Any of them fails the build. */
|
|
18
|
-
export declare function descriptionProblems(description: Described): string[];
|
|
19
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Every problem in a description, one line each, named by its rule. Any of them fails the build. */
|
|
2
|
-
export function descriptionProblems(description) {
|
|
3
|
-
return [
|
|
4
|
-
...description.functions.flatMap((f) => f.problems.map((p) => `function ${f.id}${f.file ? ` (${f.file})` : ""}: ${p}`)),
|
|
5
|
-
...description.routes.flatMap((r) => r.problems.map((p) => `route ${r.path}: ${p}`)),
|
|
6
|
-
...(description.workflows ?? []).flatMap((w) => w.problems.map((p) => `workflow ${w.id} (${w.file}): ${p}`)),
|
|
7
|
-
];
|
|
8
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const REDACTED = "REDACTED";
|
|
2
|
-
/**
|
|
3
|
-
* Replace any credentials in `text` with a placeholder, leaving the rest
|
|
4
|
-
* intact. Returns the input unchanged when there is nothing to redact, so
|
|
5
|
-
* callers that pass clean text see byte-identical output.
|
|
6
|
-
*/
|
|
7
|
-
export declare function redactSecrets(text: string): string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { RunRecord, ZiteRequestContext } from "./types.js";
|
|
2
|
-
export declare const preview: (value: unknown) => string | undefined;
|
|
3
|
-
export declare const errorOf: (error: unknown) => NonNullable<RunRecord["error"]>;
|
|
4
|
-
/**
|
|
5
|
-
* A server route's run, which run capture doesn't see: its body in, and its status and body out. The bodies are
|
|
6
|
-
* read from copies after the fact, so the response never waits; the run log waits for them before it flushes.
|
|
7
|
-
*/
|
|
8
|
-
export declare function recordRoute<T>(host: ZiteRequestContext | undefined, request: Request, run: () => Promise<T>): Promise<T>;
|
package/dist/esm/start/runLog.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { asZiteError } from "./errors.js";
|
|
2
|
-
// Classic's per-field cap. The host caps again; this keeps a large value from crossing at all.
|
|
3
|
-
const RUN_FIELD_LIMIT = 50 * 1024;
|
|
4
|
-
const capped = (text) => (text.length > RUN_FIELD_LIMIT ? `${text.slice(0, RUN_FIELD_LIMIT)}…` : text);
|
|
5
|
-
export const preview = (value) => {
|
|
6
|
-
if (value === undefined)
|
|
7
|
-
return undefined;
|
|
8
|
-
if (typeof value === "object" && value !== null && Symbol.asyncIterator in value)
|
|
9
|
-
return "[stream]";
|
|
10
|
-
try {
|
|
11
|
-
const json = JSON.stringify(value);
|
|
12
|
-
return json === undefined ? undefined : capped(json);
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return "[unserializable]";
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
export const errorOf = (error) => ({
|
|
19
|
-
code: asZiteError(error)?.code ?? "INTERNAL_ERROR",
|
|
20
|
-
message: error instanceof Error ? error.message : String(error),
|
|
21
|
-
...(error instanceof Error && error.stack ? { stack: capped(error.stack) } : {}),
|
|
22
|
-
});
|
|
23
|
-
const TEXT_BODY = /^(application\/(json|x-www-form-urlencoded)|text\/(?!event-stream))/i;
|
|
24
|
-
// Up to the cap of a copy of the body, so the app still reads the original. Uploads and streams aren't read.
|
|
25
|
-
const bodyText = async (message) => {
|
|
26
|
-
if (!message.body || !TEXT_BODY.test(message.headers.get("content-type") ?? ""))
|
|
27
|
-
return undefined;
|
|
28
|
-
const reader = message.clone().body.pipeThrough(new TextDecoderStream()).getReader();
|
|
29
|
-
let text = "";
|
|
30
|
-
try {
|
|
31
|
-
while (text.length <= RUN_FIELD_LIMIT) {
|
|
32
|
-
const { done, value } = await reader.read();
|
|
33
|
-
if (done)
|
|
34
|
-
break;
|
|
35
|
-
text += value;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
reader.cancel().catch(() => { });
|
|
40
|
-
}
|
|
41
|
-
return capped(text);
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* A server route's run, which run capture doesn't see: its body in, and its status and body out. The bodies are
|
|
45
|
-
* read from copies after the fact, so the response never waits; the run log waits for them before it flushes.
|
|
46
|
-
*/
|
|
47
|
-
export async function recordRoute(host, request, run) {
|
|
48
|
-
if (!host)
|
|
49
|
-
return run();
|
|
50
|
-
const startedAt = Date.now();
|
|
51
|
-
const path = new URL(request.url).pathname;
|
|
52
|
-
const input = bodyText(request).catch(() => undefined);
|
|
53
|
-
const record = (outcome) => {
|
|
54
|
-
const durationMs = Date.now() - startedAt;
|
|
55
|
-
const recorded = (async () => {
|
|
56
|
-
const fields = { input: await input, ...(await outcome) };
|
|
57
|
-
host.runs.push({ fn: `route:${request.method} ${path}`, name: path, nested: false, startedAt, durationMs, ...fields });
|
|
58
|
-
})();
|
|
59
|
-
(host.pending ??= []).push(recorded.catch(() => { }));
|
|
60
|
-
};
|
|
61
|
-
try {
|
|
62
|
-
const out = await run();
|
|
63
|
-
const response = out instanceof Response ? out : out?.response;
|
|
64
|
-
if (response instanceof Response) {
|
|
65
|
-
record(bodyText(response).then((body) => ({ output: preview({ status: response.status, body }) }), () => ({})));
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
record(Promise.resolve({}));
|
|
69
|
-
}
|
|
70
|
-
return out;
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
record(Promise.resolve({ error: errorOf(error) }));
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AccessKind, User, ZiteRequestContext } from "./types.js";
|
|
2
|
-
export type { AccessKind } from "./types.js";
|
|
3
|
-
export type AccessScope = {
|
|
4
|
-
kind: AccessKind;
|
|
5
|
-
user: User | null;
|
|
6
|
-
};
|
|
7
|
-
export declare const runInScope: <T>(scope: AccessScope, fn: () => T) => T;
|
|
8
|
-
/** True inside another server function's scope, i.e. a nested server-side call. */
|
|
9
|
-
export declare const inScope: () => boolean;
|
|
10
|
-
export declare class NoAccessDecisionError extends Error {
|
|
11
|
-
constructor(what: string);
|
|
12
|
-
}
|
|
13
|
-
export declare const requireScope: (what: string) => AccessScope;
|
|
14
|
-
export declare const runWithHost: <T>(host: ZiteRequestContext, fn: () => T) => T;
|
|
15
|
-
export declare const getHost: () => ZiteRequestContext | undefined;
|
package/dist/esm/start/scope.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Server-only. Only zitejs's access middleware opens an access scope, and the
|
|
2
|
-
// platform transport refuses calls outside one, so code with no access decision
|
|
3
|
-
// can't reach data, integrations or email however it was written.
|
|
4
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
|
-
import { HOST_STORE_KEY } from "./host.js";
|
|
6
|
-
// Keyed on globalThis so two copies of zitejs in one bundle share the stores.
|
|
7
|
-
const stores = globalThis;
|
|
8
|
-
const scopeStorage = (stores[Symbol.for("zitejs:access-scope")] ??=
|
|
9
|
-
new AsyncLocalStorage());
|
|
10
|
-
const hostStorage = (stores[HOST_STORE_KEY] ??=
|
|
11
|
-
new AsyncLocalStorage());
|
|
12
|
-
const isAsyncIterable = (value) => typeof value === "object" &&
|
|
13
|
-
value !== null &&
|
|
14
|
-
Symbol.asyncIterator in value &&
|
|
15
|
-
!(value instanceof ReadableStream);
|
|
16
|
-
// TanStack resumes a streamed async generator from its serializer, outside the
|
|
17
|
-
// middleware's async context, so each step re-enters the scope it started in.
|
|
18
|
-
const rescope = (scope, source) => (async function* () {
|
|
19
|
-
const iterator = source[Symbol.asyncIterator]();
|
|
20
|
-
try {
|
|
21
|
-
while (true) {
|
|
22
|
-
const step = await scopeStorage.run(scope, () => iterator.next());
|
|
23
|
-
if (step.done)
|
|
24
|
-
return step.value;
|
|
25
|
-
yield step.value;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
29
|
-
await scopeStorage.run(scope, async () => iterator.return?.());
|
|
30
|
-
}
|
|
31
|
-
})();
|
|
32
|
-
const rescopeResult = (scope, out) => {
|
|
33
|
-
const result = out?.result;
|
|
34
|
-
return isAsyncIterable(result) ? { ...out, result: rescope(scope, result) } : out;
|
|
35
|
-
};
|
|
36
|
-
export const runInScope = (scope, fn) => {
|
|
37
|
-
const out = scopeStorage.run(scope, fn);
|
|
38
|
-
return (out instanceof Promise
|
|
39
|
-
? out.then((value) => rescopeResult(scope, value))
|
|
40
|
-
: rescopeResult(scope, out));
|
|
41
|
-
};
|
|
42
|
-
/** True inside another server function's scope, i.e. a nested server-side call. */
|
|
43
|
-
export const inScope = () => scopeStorage.getStore() !== undefined;
|
|
44
|
-
export class NoAccessDecisionError extends Error {
|
|
45
|
-
constructor(what) {
|
|
46
|
-
super(`${what} ran outside an access decision. Define server functions with signedInFn or publicFn, ` +
|
|
47
|
-
"and give server routes signedIn, anyone or webhook middleware. Loaders get data by calling a server function.");
|
|
48
|
-
this.name = "NoAccessDecisionError";
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export const requireScope = (what) => {
|
|
52
|
-
const scope = scopeStorage.getStore();
|
|
53
|
-
if (!scope)
|
|
54
|
-
throw new NoAccessDecisionError(what);
|
|
55
|
-
return scope;
|
|
56
|
-
};
|
|
57
|
-
export const runWithHost = (host, fn) => hostStorage.run(host, fn);
|
|
58
|
-
export const getHost = () => hostStorage.getStore();
|