zitejs 0.10.0-start.8 → 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 +44 -1
- package/dist/cjs/check/index.js +188 -113
- 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/{esm/start → cjs/start/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 +44 -1
- package/dist/esm/check/index.js +187 -116
- 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/describe.d.ts +120 -0
- package/dist/esm/start/describe/describe.js +372 -0
- package/dist/{cjs/start → esm/start/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 +20 -4
- package/dist/esm/start/errors.js +90 -26
- 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 -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 +2 -2
- package/dist/esm/start/host.js +3 -3
- package/dist/esm/start/index.d.ts +10 -63
- package/dist/esm/start/index.js +7 -149
- 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 +28 -4
- package/dist/esm/start/router.js +224 -21
- 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/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/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.d.ts +0 -80
- package/dist/esm/start/describe.js +0 -197
- 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 -50
- package/dist/esm/start/workflow.js +0 -13
- package/dist/esm/start/workflow.test-d.js +0 -39
- 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,7 +1,6 @@
|
|
|
1
|
-
import type { HostMode } from
|
|
1
|
+
import type { HostMode } from './types.js';
|
|
2
2
|
declare const STATUS: {
|
|
3
3
|
readonly BAD_REQUEST: 400;
|
|
4
|
-
readonly INVALID_INPUT: 400;
|
|
5
4
|
readonly UNAUTHORIZED: 401;
|
|
6
5
|
readonly FORBIDDEN: 403;
|
|
7
6
|
readonly NOT_FOUND: 404;
|
|
@@ -37,10 +36,27 @@ export declare class ZiteError extends Error {
|
|
|
37
36
|
export declare const asZiteError: (error: unknown) => ZiteError | undefined;
|
|
38
37
|
/**
|
|
39
38
|
* What a failure may say to the app's users, as on classic. The message is the app author's, so it passes, with
|
|
40
|
-
* credentials redacted in place
|
|
41
|
-
* which reads it unchanged.
|
|
39
|
+
* credentials redacted in place: the request's own secrets wherever they appear, and whatever the patterns find. One
|
|
40
|
+
* naming our infrastructure or billing is replaced whole. Preview is the editor, which reads it unchanged.
|
|
42
41
|
*/
|
|
43
42
|
export declare function toClientErrorMessage(errorMessage: string, mode: HostMode | undefined, userFacingMessage?: string): string;
|
|
43
|
+
/** The message a server function fails with when it needs a session; the platform's client middleware sends the user to sign in. */
|
|
44
|
+
export declare const SIGN_IN_REQUIRED = "ZITE_SIGN_IN_REQUIRED";
|
|
45
|
+
export declare const isSignInRequired: (error: unknown) => boolean;
|
|
46
|
+
/** @internal Signed out: the visitor's state, not a bug in the app's code. */
|
|
47
|
+
export declare const isSignInError: (error: unknown) => boolean;
|
|
48
|
+
/**
|
|
49
|
+
* @internal A thrown string or object as an INTERNAL_ERROR: only an Error goes through the zite-error adapter, which
|
|
50
|
+
* redacts it on its way to the browser. A Response, a redirect among them, and a notFound are TanStack's to handle.
|
|
51
|
+
*/
|
|
52
|
+
export declare const errorFromThrown: (value: unknown) => unknown;
|
|
53
|
+
/** @internal A result whose promises reject as `errorFromThrown` would throw: they cross to the browser as thrown. */
|
|
54
|
+
export declare const withThrownRejections: <T>(value: T, cross?: (error: unknown) => unknown) => T;
|
|
44
55
|
/** A thrown value as the browser receives it: its code, and only the message `toClientErrorMessage` allows. */
|
|
45
56
|
export declare const toClientError: (error: unknown) => ZiteError;
|
|
57
|
+
/**
|
|
58
|
+
* @internal An error as the browser would receive it, for a caller on the server that nothing serializes it for.
|
|
59
|
+
* Its message is already the one to show, so the adapter sends it as it is, and crossing it again changes nothing.
|
|
60
|
+
*/
|
|
61
|
+
export declare const asCrossed: (error: Error) => ZiteError;
|
|
46
62
|
export {};
|
package/dist/esm/start/errors.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isNotFound } from '@tanstack/react-router';
|
|
2
|
+
import { currentHost } from './host.js';
|
|
3
|
+
import { redactKnown, replaceKnown } from './platform/redactSecrets.js';
|
|
4
|
+
import { requestSecrets } from './platform/requestSecrets.js';
|
|
3
5
|
const STATUS = {
|
|
4
6
|
BAD_REQUEST: 400,
|
|
5
|
-
INVALID_INPUT: 400,
|
|
6
7
|
UNAUTHORIZED: 401,
|
|
7
8
|
FORBIDDEN: 403,
|
|
8
9
|
NOT_FOUND: 404,
|
|
@@ -12,7 +13,8 @@ const STATUS = {
|
|
|
12
13
|
};
|
|
13
14
|
/** @internal The HTTP status each code answers with. */
|
|
14
15
|
export const ZITE_ERROR_STATUS = STATUS;
|
|
15
|
-
export const isZiteErrorCode = (code) => typeof code ===
|
|
16
|
+
export const isZiteErrorCode = (code) => typeof code === 'string' &&
|
|
17
|
+
Object.prototype.hasOwnProperty.call(STATUS, code);
|
|
16
18
|
/**
|
|
17
19
|
* Fail with a status: `throw new ZiteError('FORBIDDEN', 'Only the owner can edit this')`. On the live app,
|
|
18
20
|
* `userFacingMessage` is what users read in place of `message`, which stays for logs and the editor.
|
|
@@ -21,13 +23,16 @@ export class ZiteError extends Error {
|
|
|
21
23
|
code;
|
|
22
24
|
userFacingMessage;
|
|
23
25
|
constructor(first, second) {
|
|
24
|
-
const options = typeof first ===
|
|
26
|
+
const options = typeof first === 'object'
|
|
25
27
|
? first
|
|
26
28
|
: isZiteErrorCode(first)
|
|
27
29
|
? { code: first, message: second ?? first }
|
|
28
|
-
: {
|
|
30
|
+
: {
|
|
31
|
+
code: isZiteErrorCode(second) ? second : 'INTERNAL_ERROR',
|
|
32
|
+
message: first,
|
|
33
|
+
};
|
|
29
34
|
super(options.message);
|
|
30
|
-
this.name =
|
|
35
|
+
this.name = 'ZiteError';
|
|
31
36
|
this.code = options.code;
|
|
32
37
|
if (options.userFacingMessage)
|
|
33
38
|
this.userFacingMessage = options.userFacingMessage;
|
|
@@ -40,7 +45,7 @@ export class ZiteError extends Error {
|
|
|
40
45
|
export const asZiteError = (error) => {
|
|
41
46
|
if (error instanceof ZiteError)
|
|
42
47
|
return error;
|
|
43
|
-
if (!(error instanceof Error) || error.name !==
|
|
48
|
+
if (!(error instanceof Error) || error.name !== 'ZiteError')
|
|
44
49
|
return undefined;
|
|
45
50
|
const { code, userFacingMessage } = error;
|
|
46
51
|
if (!isZiteErrorCode(code))
|
|
@@ -48,27 +53,33 @@ export const asZiteError = (error) => {
|
|
|
48
53
|
return new ZiteError({
|
|
49
54
|
code,
|
|
50
55
|
message: error.message,
|
|
51
|
-
...(typeof userFacingMessage ===
|
|
56
|
+
...(typeof userFacingMessage === 'string' && { userFacingMessage }),
|
|
52
57
|
});
|
|
53
58
|
};
|
|
54
59
|
// Ported from restly's packages/endpoint-setup/src/endpointErrors.ts; keep the two in step. The fences are consumed
|
|
55
60
|
// characters rather than lookbehinds, which older Safari can't parse: this module ships to the browser.
|
|
56
61
|
const INTERNAL_SERVICE_NAMES = [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
'zite-shard-restly-server',
|
|
63
|
+
'restly-server',
|
|
64
|
+
'workflow-runner',
|
|
65
|
+
'base-runner',
|
|
66
|
+
'app-runner',
|
|
67
|
+
'utility-service',
|
|
63
68
|
];
|
|
64
69
|
const PRIVATE_IPV4 = String.raw `\b(?:10|127)\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|\b172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}\b|\b192\.168\.\d{1,3}\.\d{1,3}\b|\b169\.254\.\d{1,3}\.\d{1,3}\b`;
|
|
65
70
|
const PRIVATE_IPV6 = String.raw `(?:^|[^\w:])(?:::1|(?:f[cd][0-9a-f]{2}|fe[89ab][0-9a-f]):[0-9a-f:]+)(?![\w:])`;
|
|
66
|
-
const INTERNAL_HOSTNAME = String.raw `(?:^|[^\w.-])(?:${INTERNAL_SERVICE_NAMES.join(
|
|
67
|
-
const UNAVAILABLE =
|
|
68
|
-
const AI_UNAVAILABLE =
|
|
71
|
+
const INTERNAL_HOSTNAME = String.raw `(?:^|[^\w.-])(?:${INTERNAL_SERVICE_NAMES.join('|')}|localhost)(?:-\w+)*(?::\d+)?(?![\w.-])`;
|
|
72
|
+
const UNAVAILABLE = 'A service this app depends on is temporarily unavailable. Please try again.';
|
|
73
|
+
const AI_UNAVAILABLE = 'AI features are temporarily unavailable. Please contact the app owner.';
|
|
69
74
|
const INFRASTRUCTURE_PATTERNS = [
|
|
70
|
-
{
|
|
71
|
-
|
|
75
|
+
{
|
|
76
|
+
pattern: new RegExp(`${PRIVATE_IPV4}|${PRIVATE_IPV6}|${INTERNAL_HOSTNAME}`, 'i'),
|
|
77
|
+
replacement: UNAVAILABLE,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
pattern: /AI is paused: your organization is over its AI credit limit/i,
|
|
81
|
+
replacement: AI_UNAVAILABLE,
|
|
82
|
+
},
|
|
72
83
|
{
|
|
73
84
|
pattern: /platform\.openai\.com\/(?:settings\/organization\/billing|docs\/guides\/error-codes)/i,
|
|
74
85
|
replacement: AI_UNAVAILABLE,
|
|
@@ -76,24 +87,77 @@ const INFRASTRUCTURE_PATTERNS = [
|
|
|
76
87
|
];
|
|
77
88
|
/**
|
|
78
89
|
* What a failure may say to the app's users, as on classic. The message is the app author's, so it passes, with
|
|
79
|
-
* credentials redacted in place
|
|
80
|
-
* which reads it unchanged.
|
|
90
|
+
* credentials redacted in place: the request's own secrets wherever they appear, and whatever the patterns find. One
|
|
91
|
+
* naming our infrastructure or billing is replaced whole. Preview is the editor, which reads it unchanged.
|
|
81
92
|
*/
|
|
82
93
|
export function toClientErrorMessage(errorMessage, mode, userFacingMessage) {
|
|
83
|
-
if (mode ===
|
|
94
|
+
if (mode === 'preview')
|
|
84
95
|
return errorMessage;
|
|
96
|
+
const secrets = requestSecrets(currentHost());
|
|
85
97
|
if (userFacingMessage)
|
|
86
|
-
return userFacingMessage;
|
|
87
|
-
const redacted =
|
|
98
|
+
return replaceKnown(userFacingMessage, secrets);
|
|
99
|
+
const redacted = redactKnown(errorMessage, secrets);
|
|
88
100
|
for (const { pattern, replacement } of INFRASTRUCTURE_PATTERNS) {
|
|
89
101
|
if (pattern.test(redacted))
|
|
90
102
|
return replacement;
|
|
91
103
|
}
|
|
92
104
|
return redacted;
|
|
93
105
|
}
|
|
106
|
+
/** The message a server function fails with when it needs a session; the platform's client middleware sends the user to sign in. */
|
|
107
|
+
export const SIGN_IN_REQUIRED = 'ZITE_SIGN_IN_REQUIRED';
|
|
108
|
+
export const isSignInRequired = (error) => error instanceof Error && error.message === SIGN_IN_REQUIRED;
|
|
109
|
+
/** @internal Signed out: the visitor's state, not a bug in the app's code. */
|
|
110
|
+
export const isSignInError = (error) => isSignInRequired(error) || asZiteError(error)?.code === 'UNAUTHORIZED';
|
|
111
|
+
const thrownText = (value) => {
|
|
112
|
+
if (typeof value === 'string')
|
|
113
|
+
return value;
|
|
114
|
+
try {
|
|
115
|
+
return JSON.stringify(value) ?? String(value);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return String(value);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* @internal A thrown string or object as an INTERNAL_ERROR: only an Error goes through the zite-error adapter, which
|
|
123
|
+
* redacts it on its way to the browser. A Response, a redirect among them, and a notFound are TanStack's to handle.
|
|
124
|
+
*/
|
|
125
|
+
export const errorFromThrown = (value) => value instanceof Error || value instanceof Response || isNotFound(value)
|
|
126
|
+
? value
|
|
127
|
+
: new ZiteError('INTERNAL_ERROR', thrownText(value));
|
|
128
|
+
/** @internal A result whose promises reject as `errorFromThrown` would throw: they cross to the browser as thrown. */
|
|
129
|
+
export const withThrownRejections = (value, cross = error => error) => {
|
|
130
|
+
if (!value ||
|
|
131
|
+
typeof value !== 'object' ||
|
|
132
|
+
Object.getPrototypeOf(value) !== Object.prototype)
|
|
133
|
+
return value;
|
|
134
|
+
const promised = Object.entries(value).filter(([, item]) => item instanceof Promise);
|
|
135
|
+
if (!promised.length)
|
|
136
|
+
return value;
|
|
137
|
+
const out = {
|
|
138
|
+
...value,
|
|
139
|
+
};
|
|
140
|
+
for (const [key, item] of promised) {
|
|
141
|
+
out[key] = item.catch((error) => {
|
|
142
|
+
throw cross(errorFromThrown(error));
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return out;
|
|
146
|
+
};
|
|
94
147
|
/** A thrown value as the browser receives it: its code, and only the message `toClientErrorMessage` allows. */
|
|
95
148
|
export const toClientError = (error) => {
|
|
96
149
|
const zite = asZiteError(error);
|
|
97
150
|
const message = error instanceof Error ? error.message : String(error);
|
|
98
|
-
return new ZiteError(zite?.code ??
|
|
151
|
+
return new ZiteError(zite?.code ?? 'INTERNAL_ERROR', toClientErrorMessage(message, currentHost()?.mode, zite?.userFacingMessage));
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* @internal An error as the browser would receive it, for a caller on the server that nothing serializes it for.
|
|
155
|
+
* Its message is already the one to show, so the adapter sends it as it is, and crossing it again changes nothing.
|
|
156
|
+
*/
|
|
157
|
+
export const asCrossed = (error) => {
|
|
158
|
+
const { code, message } = toClientError(error);
|
|
159
|
+
const crossed = new ZiteError({ code, message, userFacingMessage: message });
|
|
160
|
+
if (currentHost()?.mode === 'preview')
|
|
161
|
+
crossed.stack = error.stack;
|
|
162
|
+
return crossed;
|
|
99
163
|
};
|
|
@@ -1,23 +1,54 @@
|
|
|
1
|
-
import { describe, expect, it } from
|
|
2
|
-
import { asZiteError, ZiteError } from
|
|
3
|
-
describe(
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { asZiteError, ZiteError } from './errors.js';
|
|
3
|
+
describe('ZiteError', () => {
|
|
4
4
|
it("takes Start's order, classic's order and classic's options", () => {
|
|
5
|
-
expect(new ZiteError(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
expect(new ZiteError(
|
|
10
|
-
|
|
5
|
+
expect(new ZiteError('FORBIDDEN', 'Owners only')).toMatchObject({
|
|
6
|
+
code: 'FORBIDDEN',
|
|
7
|
+
message: 'Owners only',
|
|
8
|
+
});
|
|
9
|
+
expect(new ZiteError('NOT_FOUND')).toMatchObject({
|
|
10
|
+
code: 'NOT_FOUND',
|
|
11
|
+
message: 'NOT_FOUND',
|
|
12
|
+
});
|
|
13
|
+
expect(new ZiteError('Owners only', 'FORBIDDEN')).toMatchObject({
|
|
14
|
+
code: 'FORBIDDEN',
|
|
15
|
+
message: 'Owners only',
|
|
16
|
+
});
|
|
17
|
+
expect(new ZiteError('Something broke')).toMatchObject({
|
|
18
|
+
code: 'INTERNAL_ERROR',
|
|
19
|
+
message: 'Something broke',
|
|
20
|
+
});
|
|
21
|
+
expect(new ZiteError({
|
|
22
|
+
code: 'CONFLICT',
|
|
23
|
+
message: 'Row 3 changed',
|
|
24
|
+
userFacingMessage: 'Someone else edited this.',
|
|
25
|
+
})).toMatchObject({
|
|
26
|
+
code: 'CONFLICT',
|
|
27
|
+
message: 'Row 3 changed',
|
|
28
|
+
userFacingMessage: 'Someone else edited this.',
|
|
29
|
+
});
|
|
11
30
|
});
|
|
12
31
|
});
|
|
13
|
-
describe(
|
|
32
|
+
describe('asZiteError', () => {
|
|
14
33
|
it("recognises another copy's ZiteError by name and code", () => {
|
|
15
|
-
const classic = Object.assign(new Error(
|
|
16
|
-
|
|
34
|
+
const classic = Object.assign(new Error('No such deal'), {
|
|
35
|
+
name: 'ZiteError',
|
|
36
|
+
code: 'NOT_FOUND',
|
|
37
|
+
userFacingMessage: 'Gone.',
|
|
38
|
+
});
|
|
39
|
+
expect(asZiteError(classic)).toMatchObject({
|
|
40
|
+
code: 'NOT_FOUND',
|
|
41
|
+
message: 'No such deal',
|
|
42
|
+
userFacingMessage: 'Gone.',
|
|
43
|
+
});
|
|
17
44
|
});
|
|
18
|
-
it(
|
|
19
|
-
expect(asZiteError(new Error(
|
|
20
|
-
expect(asZiteError(Object.assign(new Error(
|
|
21
|
-
expect(asZiteError({
|
|
45
|
+
it('refuses anything else', () => {
|
|
46
|
+
expect(asZiteError(new Error('plain'))).toBeUndefined();
|
|
47
|
+
expect(asZiteError(Object.assign(new Error('x'), { name: 'ZiteError', code: 'toString' }))).toBeUndefined();
|
|
48
|
+
expect(asZiteError({
|
|
49
|
+
name: 'ZiteError',
|
|
50
|
+
code: 'NOT_FOUND',
|
|
51
|
+
message: 'not an Error',
|
|
52
|
+
})).toBeUndefined();
|
|
22
53
|
});
|
|
23
54
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { anyone, signedIn } from './access.js';
|
|
2
|
+
import type { ZiteFnFactory } from './fnFactory.js';
|
|
3
|
+
declare module '@tanstack/react-router' {
|
|
4
|
+
interface StaticDataRouteOption {
|
|
5
|
+
/** What an API route does, in a sentence. Shown in the editor. */
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare const compiled: import("@tanstack/react-start").FunctionMiddlewareAfterClient<{}, unknown, undefined, undefined, undefined>;
|
|
10
|
+
/** A server function only signed-in users can call. */
|
|
11
|
+
export declare const signedInFn: ZiteFnFactory<readonly [typeof compiled, typeof signedIn]>;
|
|
12
|
+
/** A server function anyone can call (external apps only). */
|
|
13
|
+
export declare const publicFn: ZiteFnFactory<readonly [typeof compiled, typeof anyone]>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createMiddleware, createServerFn } from '@tanstack/react-start';
|
|
2
|
+
import { anyone, signedIn } from './access.js';
|
|
3
|
+
import { tag } from './middlewareKind.js';
|
|
4
|
+
// TanStack's compiler tags every server function it compiles with an id. A
|
|
5
|
+
// builder it didn't compile (an object property, one returned from a helper)
|
|
6
|
+
// has none and would run its handler wherever it was called, so it fails here.
|
|
7
|
+
const compiled = tag(createMiddleware({ type: 'function' }).client(({ next, serverFnMeta }) => {
|
|
8
|
+
if (!serverFnMeta?.id) {
|
|
9
|
+
throw new Error('This server function was not compiled by TanStack Start. Assign signedInFn(...)/publicFn(...)' +
|
|
10
|
+
".handler(...) directly to its own top-level const, not an object property or a helper's return value.");
|
|
11
|
+
}
|
|
12
|
+
return next();
|
|
13
|
+
}), { kind: 'factory' });
|
|
14
|
+
/** A server function only signed-in users can call. */
|
|
15
|
+
export const signedInFn = createServerFn().middleware([
|
|
16
|
+
compiled,
|
|
17
|
+
signedIn,
|
|
18
|
+
]);
|
|
19
|
+
/** A server function anyone can call (external apps only). */
|
|
20
|
+
export const publicFn = createServerFn().middleware([
|
|
21
|
+
compiled,
|
|
22
|
+
anyone,
|
|
23
|
+
]);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createServerFn } from '@tanstack/react-start';
|
|
2
|
+
import { describe, expectTypeOf, it } from 'vitest';
|
|
3
|
+
import { hasRole, publicFn, role, signedInFn } from './index.js';
|
|
4
|
+
describe('server function factories', () => {
|
|
5
|
+
it('take a method and a description', () => {
|
|
6
|
+
signedInFn({
|
|
7
|
+
method: 'GET',
|
|
8
|
+
description: "The signed-in user's orders",
|
|
9
|
+
}).handler(async () => []);
|
|
10
|
+
publicFn({ method: 'POST', description: 'Joins the waitlist' }).handler(async () => null);
|
|
11
|
+
});
|
|
12
|
+
it('refuse options without a description', () => {
|
|
13
|
+
// @ts-expect-error the editor shows what each function does
|
|
14
|
+
signedInFn({ method: 'GET' });
|
|
15
|
+
// @ts-expect-error the editor shows what each function does
|
|
16
|
+
publicFn({ method: 'POST' });
|
|
17
|
+
});
|
|
18
|
+
it("leave TanStack's own createServerFn as it is, for describe to refuse", () => {
|
|
19
|
+
createServerFn({ method: 'GET' }).handler(async () => null);
|
|
20
|
+
});
|
|
21
|
+
it('refuse options without a method, and a function built without options', () => {
|
|
22
|
+
// @ts-expect-error TanStack would make it a GET without saying so
|
|
23
|
+
signedInFn({ description: "The signed-in user's orders" });
|
|
24
|
+
// @ts-expect-error nor without options at all
|
|
25
|
+
signedInFn.handler(async () => []);
|
|
26
|
+
// @ts-expect-error nor through a validator first
|
|
27
|
+
publicFn.validator((input) => input);
|
|
28
|
+
});
|
|
29
|
+
it('type the handler by the method it was given', () => {
|
|
30
|
+
signedInFn({ method: 'POST', description: 'Archives an order' })
|
|
31
|
+
.validator((input) => input)
|
|
32
|
+
.handler(async ({ method, data }) => {
|
|
33
|
+
expectTypeOf(method).toEqualTypeOf();
|
|
34
|
+
expectTypeOf(data).toEqualTypeOf();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
it("carry the requirement through an app's own factory", () => {
|
|
38
|
+
const managerFn = signedInFn.middleware([role('manager')]);
|
|
39
|
+
managerFn({ method: 'POST', description: 'Reassigns a deal' }).handler(async () => null);
|
|
40
|
+
// @ts-expect-error the editor shows what each function does
|
|
41
|
+
managerFn({ method: 'POST' });
|
|
42
|
+
// @ts-expect-error and the method comes first here too
|
|
43
|
+
managerFn.handler(async () => null);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('hasRole', () => {
|
|
47
|
+
it("takes the user, none, or a context carrying one, as classic's does", () => {
|
|
48
|
+
publicFn({ method: 'GET', description: 'Reads the role' }).handler(async ({ context }) => {
|
|
49
|
+
expectTypeOf(hasRole(context.user, 'admin')).toEqualTypeOf();
|
|
50
|
+
expectTypeOf(hasRole(context, 'admin')).toEqualTypeOf();
|
|
51
|
+
});
|
|
52
|
+
signedInFn({ method: 'GET', description: 'Reads the role' }).handler(async ({ context }) => hasRole(context.user, 'admin'));
|
|
53
|
+
hasRole(null, 'admin');
|
|
54
|
+
hasRole(undefined, 'admin');
|
|
55
|
+
// @ts-expect-error a role by its id
|
|
56
|
+
hasRole(null, 3);
|
|
57
|
+
// @ts-expect-error a user, or a context carrying one
|
|
58
|
+
hasRole({ id: 'u_1' }, 'admin');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal TanStack answers a failed server function 200, with the error in the body. A nested call's failure is
|
|
3
|
+
* the caller's to handle, and so is one made while a page renders: its loader may catch it, and one that doesn't
|
|
4
|
+
* gets the error's status from the server entry. Redirects and notFound aren't Errors.
|
|
5
|
+
*/
|
|
6
|
+
export declare const setFailedStatus: (error: unknown) => void;
|
|
7
|
+
export declare const withStatus: <T>(isServerFn: boolean, fn: () => Promise<T>) => Promise<T | Response>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { setResponseStatus } from '@tanstack/react-start/server';
|
|
2
|
+
import { getStartContext } from '@tanstack/start-storage-context';
|
|
3
|
+
import { asZiteError, errorFromThrown, toClientErrorMessage, ZiteError, ZITE_ERROR_STATUS, } from './errors.js';
|
|
4
|
+
import { getHost, inScope } from './serve/scope.js';
|
|
5
|
+
// TanStack fails a validator with a plain Error whose message is the issues as JSON.
|
|
6
|
+
const validationIssues = (error) => {
|
|
7
|
+
if (!(error instanceof Error) || error.constructor !== Error)
|
|
8
|
+
return undefined;
|
|
9
|
+
try {
|
|
10
|
+
const issues = JSON.parse(error.message);
|
|
11
|
+
return Array.isArray(issues) &&
|
|
12
|
+
issues.length > 0 &&
|
|
13
|
+
issues.every(issue => typeof issue?.message === 'string')
|
|
14
|
+
? issues
|
|
15
|
+
: undefined;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const invalidInput = (issues) => {
|
|
22
|
+
if (getHost()?.mode !== 'preview')
|
|
23
|
+
return new ZiteError('BAD_REQUEST', 'Invalid input');
|
|
24
|
+
const describe = ({ message, path = [] }) => {
|
|
25
|
+
const at = path
|
|
26
|
+
.map(segment => String(typeof segment === 'object' ? segment.key : segment))
|
|
27
|
+
.join('.');
|
|
28
|
+
return at ? `${at}: ${message}` : message;
|
|
29
|
+
};
|
|
30
|
+
return new ZiteError('BAD_REQUEST', issues.map(describe).join('; '));
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @internal TanStack answers a failed server function 200, with the error in the body. A nested call's failure is
|
|
34
|
+
* the caller's to handle, and so is one made while a page renders: its loader may catch it, and one that doesn't
|
|
35
|
+
* gets the error's status from the server entry. Redirects and notFound aren't Errors.
|
|
36
|
+
*/
|
|
37
|
+
export const setFailedStatus = (error) => {
|
|
38
|
+
if (!(error instanceof Error) ||
|
|
39
|
+
inScope() ||
|
|
40
|
+
getStartContext({ throwIfNotFound: false })?.handlerType !== 'serverFn')
|
|
41
|
+
return;
|
|
42
|
+
setResponseStatus(ZITE_ERROR_STATUS[asZiteError(error)?.code ?? 'INTERNAL_ERROR']);
|
|
43
|
+
};
|
|
44
|
+
// Server functions report a status through TanStack's error envelope; server routes need a Response.
|
|
45
|
+
export const withStatus = async (isServerFn, fn) => {
|
|
46
|
+
try {
|
|
47
|
+
return await fn();
|
|
48
|
+
}
|
|
49
|
+
catch (thrown) {
|
|
50
|
+
const caught = errorFromThrown(thrown);
|
|
51
|
+
const issues = validationIssues(caught);
|
|
52
|
+
const error = issues ? invalidInput(issues) : asZiteError(caught);
|
|
53
|
+
if (!isServerFn) {
|
|
54
|
+
if (!error)
|
|
55
|
+
throw caught;
|
|
56
|
+
const message = toClientErrorMessage(error.message, getHost()?.mode, error.userFacingMessage);
|
|
57
|
+
return new Response(message, { status: ZITE_ERROR_STATUS[error.code] });
|
|
58
|
+
}
|
|
59
|
+
setFailedStatus(error ?? caught);
|
|
60
|
+
throw error ?? caught;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AnyFunctionMiddleware, AnyRequestMiddleware, Method, Register, ServerFnBuilder, ServerFnOptions, ServerFnStrict } from '@tanstack/react-start';
|
|
2
|
+
declare const withMiddleware: <TMiddlewares, TMethod extends Method, TStrict extends ServerFnStrict>(builder: ServerFnBuilder<Register, TMethod, TStrict>) => ReturnType<typeof builder.middleware<TMiddlewares>>;
|
|
3
|
+
type ServerFnAfter<TMiddlewares, TMethod extends Method, TStrict extends ServerFnStrict> = ReturnType<typeof withMiddleware<TMiddlewares, TMethod, TStrict>>;
|
|
4
|
+
/**
|
|
5
|
+
* `signedInFn`, `publicFn` and an app's factories built from them: called with a method and a description before
|
|
6
|
+
* anything else, since TanStack would quietly make a function without a method a GET.
|
|
7
|
+
*/
|
|
8
|
+
export type ZiteFnFactory<TMiddlewares extends ReadonlyArray<unknown>> = {
|
|
9
|
+
<TMethod extends Method, TStrict extends ServerFnStrict = true>(options: ServerFnOptions<TMethod, TStrict> & {
|
|
10
|
+
method: TMethod;
|
|
11
|
+
/** What this function does, in a sentence. Shown in the editor. */
|
|
12
|
+
description: string;
|
|
13
|
+
}): ServerFnAfter<TMiddlewares, TMethod, TStrict>;
|
|
14
|
+
middleware: <const TNew extends ReadonlyArray<AnyFunctionMiddleware | AnyRequestMiddleware>>(middlewares: TNew) => ZiteFnFactory<readonly [...TMiddlewares, ...TNew]>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/start/host.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostRequestState } from './types.js';
|
|
2
2
|
export declare const HOST_STORE_KEY: unique symbol;
|
|
3
|
-
export declare const currentHost: () =>
|
|
3
|
+
export declare const currentHost: () => HostRequestState | undefined;
|
package/dist/esm/start/host.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Isomorphic, so it can't import the server-only store: it reads
|
|
2
|
-
//
|
|
3
|
-
export const HOST_STORE_KEY = Symbol.for(
|
|
1
|
+
// Isomorphic, so it can't import the server-only store: it reads the request's host through the global key
|
|
2
|
+
// ./serve/scope.ts registers it under. In the browser there is none.
|
|
3
|
+
export const HOST_STORE_KEY = Symbol.for('zitejs:host-context');
|
|
4
4
|
export const currentHost = () => globalThis[HOST_STORE_KEY]?.getStore();
|
|
@@ -1,63 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export
|
|
6
|
-
export type {
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
description?: string;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
/** By the role's id or its name. */
|
|
15
|
-
export declare const hasRole: (user: User, role: string) => boolean;
|
|
16
|
-
/** The message a server function fails with when it needs a session; the platform's client middleware sends the user to sign in. */
|
|
17
|
-
export declare const SIGN_IN_REQUIRED = "ZITE_SIGN_IN_REQUIRED";
|
|
18
|
-
export declare const isSignInRequired: (error: unknown) => boolean;
|
|
19
|
-
/**
|
|
20
|
-
* The platform's sign-in page, returning to `redirectTo` (default: the current
|
|
21
|
-
* page). For guards: `throw redirect({ href: loginHref(), reloadDocument: true })`.
|
|
22
|
-
*/
|
|
23
|
-
export declare function loginHref(redirectTo?: string): string;
|
|
24
|
-
/** What a zitejs middleware means, for describe. Keyed by identity, so composing or re-exporting keeps it. */
|
|
25
|
-
export type ZiteMiddlewareKind = {
|
|
26
|
-
kind: "signedIn" | "anyone" | "factory";
|
|
27
|
-
} | {
|
|
28
|
-
kind: "webhook";
|
|
29
|
-
paused?: true;
|
|
30
|
-
} | {
|
|
31
|
-
kind: "role";
|
|
32
|
-
role: string;
|
|
33
|
-
};
|
|
34
|
-
/** @internal */
|
|
35
|
-
export declare const ziteMiddlewareKind: (middleware: unknown) => ZiteMiddlewareKind | undefined;
|
|
36
|
-
/** Only signed-in users. Handlers get `context.user: User`. */
|
|
37
|
-
export declare const signedIn: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, {
|
|
38
|
-
user: User;
|
|
39
|
-
}>;
|
|
40
|
-
/** Anyone, signed in or not. Handlers get `context.user: User | null`. */
|
|
41
|
-
export declare const anyone: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, {
|
|
42
|
-
user: User | null;
|
|
43
|
-
}>;
|
|
44
|
-
/**
|
|
45
|
-
* Webhooks delivered by the platform, which already checked the URL token.
|
|
46
|
-
* `webhook.paused` keeps the URL but runs nothing: the platform answers the
|
|
47
|
-
* provider 200 and drops the delivery until it's switched back.
|
|
48
|
-
*/
|
|
49
|
-
export declare const webhook: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, undefined> & {
|
|
50
|
-
paused: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, undefined>;
|
|
51
|
-
};
|
|
52
|
-
/** Signed-in users with this role. */
|
|
53
|
-
export declare const role: (name: string) => import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, readonly [import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, {
|
|
54
|
-
user: User;
|
|
55
|
-
}>], undefined>;
|
|
56
|
-
declare const compiled: import("@tanstack/react-start").FunctionMiddlewareAfterClient<{}, unknown, undefined, undefined, undefined>;
|
|
57
|
-
declare const builder: import("@tanstack/react-start").ServerFnBuilder<import("@tanstack/react-start").Register, import("@tanstack/react-start").Method, true>;
|
|
58
|
-
type SignedInFn = ReturnType<typeof builder.middleware<readonly [typeof compiled, typeof signedIn]>>;
|
|
59
|
-
type PublicFn = ReturnType<typeof builder.middleware<readonly [typeof compiled, typeof anyone]>>;
|
|
60
|
-
/** A server function only signed-in users can call. */
|
|
61
|
-
export declare const signedInFn: SignedInFn;
|
|
62
|
-
/** A server function anyone can call (external apps only). */
|
|
63
|
-
export declare const publicFn: PublicFn;
|
|
1
|
+
export type { Role, User } from './types.js';
|
|
2
|
+
export { isSignInRequired, SIGN_IN_REQUIRED, ZiteError, type ZiteErrorCode, type ZiteErrorOptions, } from './errors.js';
|
|
3
|
+
export { createZiteRouter, type ZiteRouterContext } from './router.js';
|
|
4
|
+
export { createAutomation, createProviderTrigger, type ProviderTriggerConfig, type StartProviderTrigger, type StartTrigger, type Automation, type AutomationArgs, type AutomationConfig, } from './automations/workflow.js';
|
|
5
|
+
export type { ZiteSchedule } from '../schedules/index.js';
|
|
6
|
+
export type { ZiteTrigger, ZiteTriggerSubscribe, ZiteTriggerSubscribeInput, ZiteTriggerSubscribeResult, ZiteTriggerUnsubscribe, ZiteTriggerUnsubscribeInput, } from '../backend/index.js';
|
|
7
|
+
export { anyone, signedIn, webhook } from './access.js';
|
|
8
|
+
export { publicFn, signedInFn } from './factories.js';
|
|
9
|
+
export { loginHref } from './login.js';
|
|
10
|
+
export { hasRole, role } from './roles.js';
|