zitejs 0.10.0-start.9 → 0.10.1-device.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 +95 -0
- package/dist/cjs/auth/client.d.ts +357 -0
- package/dist/cjs/auth/client.js +71 -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/auth/useAuth.test.js +1 -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 +37 -48
- 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/browserMode.d.ts +2 -0
- package/dist/cjs/internal/browserMode.js +18 -0
- package/dist/cjs/internal/deviceCache.d.ts +11 -0
- package/dist/cjs/internal/deviceCache.js +29 -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/query/deviceCache.d.ts +14 -0
- package/dist/cjs/query/deviceCache.js +304 -0
- package/dist/cjs/query/index.d.ts +19 -0
- package/dist/cjs/query/index.js +369 -0
- 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 +87 -42
- package/dist/cjs/vite/index.test.js +36 -0
- package/dist/esm/auth/actions.d.ts +28 -0
- package/dist/esm/auth/actions.js +57 -0
- package/dist/esm/auth/client.d.ts +357 -0
- package/dist/esm/auth/client.js +67 -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/auth/useAuth.test.js +1 -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 +37 -48
- 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/browserMode.d.ts +2 -0
- package/dist/esm/internal/browserMode.js +15 -0
- package/dist/esm/internal/deviceCache.d.ts +11 -0
- package/dist/esm/internal/deviceCache.js +24 -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/query/deviceCache.d.ts +14 -0
- package/dist/esm/query/deviceCache.js +301 -0
- package/dist/esm/query/index.d.ts +19 -0
- package/dist/esm/query/index.js +366 -0
- 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 +491 -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 +92 -47
- package/dist/esm/vite/index.test.js +36 -0
- package/package.json +106 -38
- 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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// What a Start build and the platform's host say to each other on the wire. Import-free but for the reserved ids,
|
|
3
|
+
// themselves import-free, so the host takes these without loading anything of zitejs.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.DEMO_READ_ONLY_CODE = exports.ERROR_CODE_HEADER = exports.GATEWAY_CONNECTION_HEADER = exports.PREVIEW_CLAIM_HEADER = exports.RUNTIME_VERSION_HEADER = exports.INVOKE_PATH = exports.INVOKE_HEADER = exports.isInvokeKind = exports.INVOKE_KINDS = exports.RESERVED_INTEGRATION_IDS = exports.isReservedIntegrationId = void 0;
|
|
6
|
+
var reservedIds_js_1 = require("../internal/reservedIds.js");
|
|
7
|
+
Object.defineProperty(exports, "isReservedIntegrationId", { enumerable: true, get: function () { return reservedIds_js_1.isReservedIntegrationId; } });
|
|
8
|
+
Object.defineProperty(exports, "RESERVED_INTEGRATION_IDS", { enumerable: true, get: function () { return reservedIds_js_1.RESERVED_INTEGRATION_IDS; } });
|
|
9
|
+
/** What the host dispatches a request to do beside serving it; without props, only `warm` and `describe`. */
|
|
10
|
+
exports.INVOKE_KINDS = [
|
|
11
|
+
'webhook',
|
|
12
|
+
'describe',
|
|
13
|
+
'workflow',
|
|
14
|
+
'register',
|
|
15
|
+
'warm',
|
|
16
|
+
'authHook',
|
|
17
|
+
'function',
|
|
18
|
+
];
|
|
19
|
+
const isInvokeKind = (kind) => exports.INVOKE_KINDS.includes(kind);
|
|
20
|
+
exports.isInvokeKind = isInvokeKind;
|
|
21
|
+
/** `warm` or `describe`, on a request the host sends without props. */
|
|
22
|
+
exports.INVOKE_HEADER = 'x-zite-invoke';
|
|
23
|
+
/** Where the host POSTs a workflow, registration, auth hook or test run, with `{ input }`. */
|
|
24
|
+
exports.INVOKE_PATH = '/_zite/invoke';
|
|
25
|
+
/** On describe's answer: the zitejs the build's server code was bundled from. */
|
|
26
|
+
exports.RUNTIME_VERSION_HEADER = 'x-zitejs-version';
|
|
27
|
+
/** An editor preview's access, on every same-origin fetch its pages make. */
|
|
28
|
+
exports.PREVIEW_CLAIM_HEADER = 'x-zite-preview';
|
|
29
|
+
/** At the gateway, the connection a call on Zite's AI key bills to. */
|
|
30
|
+
exports.GATEWAY_CONNECTION_HEADER = 'x-zite-gateway-connection';
|
|
31
|
+
/** On a demo's refused answer, beside its 403, so the platform's runtime shows the demo notice. */
|
|
32
|
+
exports.ERROR_CODE_HEADER = 'x-zite-error-code';
|
|
33
|
+
exports.DEMO_READ_ONLY_CODE = 'DEMO_READ_ONLY';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AppContext, ExpiringToken, PlatformProvider, PlatformUrls } from '../../types.js';
|
|
2
|
+
/** What `local` reads, documented in `zitejs`'s help. */
|
|
3
|
+
export declare const LOCAL_ENV: {
|
|
4
|
+
readonly token: "ZITE_DEV_TOKEN";
|
|
5
|
+
readonly apiKey: "ZITE_DEV_API_KEY";
|
|
6
|
+
readonly urls: "ZITE_URLS";
|
|
7
|
+
readonly user: "ZITE_DEV_USER";
|
|
8
|
+
};
|
|
9
|
+
type Env = Record<string, string | undefined>;
|
|
10
|
+
/** `ZITE_URLS`, or a throw saying what it must name. */
|
|
11
|
+
export declare const localUrls: (raw: string | undefined) => PlatformUrls;
|
|
12
|
+
/** For tests: forget the minted dev token and what the backend said of it. */
|
|
13
|
+
export declare const resetDevToken: () => void;
|
|
14
|
+
export declare const mintDevToken: (backend: string, appId: string, apiKey: string) => Promise<ExpiringToken>;
|
|
15
|
+
/**
|
|
16
|
+
* What the backend says of a dev token, from the claims it verified, as OAuth's token introspection answers: asked
|
|
17
|
+
* once per token, whose claims never change. Throws, saying why, when it won't say.
|
|
18
|
+
*/
|
|
19
|
+
export declare const describeDevToken: (backend: string, token: string) => Promise<AppContext>;
|
|
20
|
+
/**
|
|
21
|
+
* `local` when the developer set a dev token, or a key to mint them with, else undefined. Throws on env it can't read,
|
|
22
|
+
* so a typo fails loudly rather than signing nobody in.
|
|
23
|
+
*/
|
|
24
|
+
export declare const localPlatform: (env?: Env, appId?: string | null) => PlatformProvider | undefined;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.localPlatform = exports.describeDevToken = exports.mintDevToken = exports.resetDevToken = exports.localUrls = exports.LOCAL_ENV = void 0;
|
|
4
|
+
// `local`: a developer's machine, with a dev token the backend minted, which the backend also describes.
|
|
5
|
+
const platformFetch_js_1 = require("../../../internal/platformFetch.js");
|
|
6
|
+
const devApp_js_1 = require("../../build/placeholders/devApp.js");
|
|
7
|
+
const provider_js_1 = require("../provider.js");
|
|
8
|
+
/** What `local` reads, documented in `zitejs`'s help. */
|
|
9
|
+
exports.LOCAL_ENV = {
|
|
10
|
+
token: 'ZITE_DEV_TOKEN',
|
|
11
|
+
apiKey: 'ZITE_DEV_API_KEY',
|
|
12
|
+
urls: 'ZITE_URLS',
|
|
13
|
+
user: 'ZITE_DEV_USER',
|
|
14
|
+
};
|
|
15
|
+
const processEnv = () => globalThis.process?.env;
|
|
16
|
+
// `local` may leave out the gateway (a call on Zite's AI key is then refused), `runs` (a preview sends no analytics,
|
|
17
|
+
// and `local` keeps no run detail) and each service's own URL.
|
|
18
|
+
const OPTIONAL_URLS = new Set([
|
|
19
|
+
'gateway',
|
|
20
|
+
'runs',
|
|
21
|
+
'email',
|
|
22
|
+
'pdf',
|
|
23
|
+
'uploads',
|
|
24
|
+
'steps',
|
|
25
|
+
'schedules',
|
|
26
|
+
]);
|
|
27
|
+
// Where the backend `ZITE_URLS` names answers a service it doesn't name. A dev token runs no workflow, so no steps.
|
|
28
|
+
const BACKEND_SERVICE_ROUTES = {
|
|
29
|
+
email: '/v1/start/app/email',
|
|
30
|
+
pdf: '/v1/start/app/pdf',
|
|
31
|
+
uploads: '/v1/start/app/uploads/session',
|
|
32
|
+
schedules: '/v1/start/app/schedules',
|
|
33
|
+
};
|
|
34
|
+
/** `ZITE_URLS`, or a throw saying what it must name. */
|
|
35
|
+
const localUrls = (raw) => {
|
|
36
|
+
let parsed;
|
|
37
|
+
try {
|
|
38
|
+
parsed = JSON.parse(raw ?? '');
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
parsed = undefined;
|
|
42
|
+
}
|
|
43
|
+
const given = (parsed ?? {});
|
|
44
|
+
const isUrl = (value) => typeof value === 'string' && /^https?:\/\//.test(value);
|
|
45
|
+
if (provider_js_1.URL_NAMES.some(name => given[name] === undefined
|
|
46
|
+
? !OPTIONAL_URLS.has(name)
|
|
47
|
+
: !isUrl(given[name]))) {
|
|
48
|
+
throw new Error(`${exports.LOCAL_ENV.urls} must be JSON naming the baseRunner and backend URLs, and may name gateway, runs, email, pdf, uploads, steps and schedules`);
|
|
49
|
+
}
|
|
50
|
+
const urls = (0, provider_js_1.trimmed)(given);
|
|
51
|
+
const defaults = Object.fromEntries(Object.entries(BACKEND_SERVICE_ROUTES).map(([name, route]) => [
|
|
52
|
+
name,
|
|
53
|
+
`${urls.backend}${route}`,
|
|
54
|
+
]));
|
|
55
|
+
return { ...defaults, ...urls };
|
|
56
|
+
};
|
|
57
|
+
exports.localUrls = localUrls;
|
|
58
|
+
const localUser = (raw) => {
|
|
59
|
+
if (!raw)
|
|
60
|
+
return null;
|
|
61
|
+
let given;
|
|
62
|
+
try {
|
|
63
|
+
given = JSON.parse(raw);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
given = undefined;
|
|
67
|
+
}
|
|
68
|
+
if (typeof given?.id !== 'string' || typeof given.email !== 'string') {
|
|
69
|
+
throw new Error(`${exports.LOCAL_ENV.user} must be JSON with the stand-in user's id and email`);
|
|
70
|
+
}
|
|
71
|
+
const roles = Array.isArray(given.roles) ? given.roles : [];
|
|
72
|
+
return {
|
|
73
|
+
id: given.id,
|
|
74
|
+
email: given.email,
|
|
75
|
+
name: typeof given.name === 'string' ? given.name : given.email,
|
|
76
|
+
roles: roles.map((role) => typeof role === 'string' ? { id: role, name: role } : role),
|
|
77
|
+
isInternal: given.isInternal === true,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
// The backend mints them for 15 minutes.
|
|
81
|
+
const RENEW_DEV_TOKEN_WITHIN_MS = 60_000;
|
|
82
|
+
const BACKEND_TIMEOUT_MS = 10_000;
|
|
83
|
+
// Per isolate, only answers, never a pending call: Workers ties a request's I/O to that request.
|
|
84
|
+
let held;
|
|
85
|
+
let described;
|
|
86
|
+
/** For tests: forget the minted dev token and what the backend said of it. */
|
|
87
|
+
const resetDevToken = () => {
|
|
88
|
+
held = undefined;
|
|
89
|
+
described = undefined;
|
|
90
|
+
};
|
|
91
|
+
exports.resetDevToken = resetDevToken;
|
|
92
|
+
const reasonOf = (response, answer) => {
|
|
93
|
+
const why = [answer?.message, answer?.error].find(text => typeof text === 'string');
|
|
94
|
+
return `${response.status}${why ? ` ${why}` : ''}`;
|
|
95
|
+
};
|
|
96
|
+
const mintDevToken = async (backend, appId, apiKey) => {
|
|
97
|
+
const response = await (0, platformFetch_js_1.platformFetch)(new Request(`${backend}/v1/start/apps/${encodeURIComponent(appId)}/dev-token`, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: { authorization: `Bearer ${apiKey}` },
|
|
100
|
+
signal: AbortSignal.timeout(BACKEND_TIMEOUT_MS),
|
|
101
|
+
}));
|
|
102
|
+
const answer = (await response.json().catch(() => null));
|
|
103
|
+
if (response.ok && (0, provider_js_1.isExpiringToken)(answer))
|
|
104
|
+
return { token: answer.token, expiresAt: answer.expiresAt };
|
|
105
|
+
throw new Error(`The backend didn't mint a dev token for app ${appId} with ${exports.LOCAL_ENV.apiKey}: ${reasonOf(response, answer)}`);
|
|
106
|
+
};
|
|
107
|
+
exports.mintDevToken = mintDevToken;
|
|
108
|
+
const MODES = new Set([
|
|
109
|
+
'live',
|
|
110
|
+
'preview',
|
|
111
|
+
'demo',
|
|
112
|
+
]);
|
|
113
|
+
const isWhole = (value) => Number.isSafeInteger(value) && value >= 0;
|
|
114
|
+
const isText = (value) => typeof value === 'string' && value !== '';
|
|
115
|
+
const isTextOrNull = (value) => value === null || isText(value);
|
|
116
|
+
/** The backend's `/context` answer, or undefined when it isn't one. */
|
|
117
|
+
const appContextOf = (answer) => {
|
|
118
|
+
const given = answer;
|
|
119
|
+
if (!given ||
|
|
120
|
+
!isText(given.appId) ||
|
|
121
|
+
!isWhole(given.buildId) ||
|
|
122
|
+
!isTextOrNull(given.baseId) ||
|
|
123
|
+
!MODES.has(given.mode) ||
|
|
124
|
+
!(given.orgSettingsVersion === null || isWhole(given.orgSettingsVersion)) ||
|
|
125
|
+
typeof given.showZiteBadge !== 'boolean' ||
|
|
126
|
+
!isTextOrNull(given.appUrl)) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
return (0, provider_js_1.contextOf)(given);
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* What the backend says of a dev token, from the claims it verified, as OAuth's token introspection answers: asked
|
|
133
|
+
* once per token, whose claims never change. Throws, saying why, when it won't say.
|
|
134
|
+
*/
|
|
135
|
+
const describeDevToken = async (backend, token) => {
|
|
136
|
+
const key = `${backend} ${token}`;
|
|
137
|
+
if (described?.key === key)
|
|
138
|
+
return described.context;
|
|
139
|
+
const response = await (0, platformFetch_js_1.platformFetch)(new Request(`${backend}/v1/start/app/context`, {
|
|
140
|
+
headers: { authorization: `Bearer ${token}` },
|
|
141
|
+
signal: AbortSignal.timeout(BACKEND_TIMEOUT_MS),
|
|
142
|
+
}));
|
|
143
|
+
const answer = await response.json().catch(() => null);
|
|
144
|
+
const context = response.ok ? appContextOf(answer) : undefined;
|
|
145
|
+
if (!context)
|
|
146
|
+
throw new Error(`The backend didn't say which app the dev token is for: ${reasonOf(response, answer)}`);
|
|
147
|
+
described = { key, context };
|
|
148
|
+
return context;
|
|
149
|
+
};
|
|
150
|
+
exports.describeDevToken = describeDevToken;
|
|
151
|
+
/** The app's dev token, minted with the developer's key, and minted again when the mint's expiry is near. */
|
|
152
|
+
const mintedDevToken = (backend, appId, apiKey) => {
|
|
153
|
+
const key = `${backend} ${appId} ${apiKey}`;
|
|
154
|
+
const token = (0, provider_js_1.renewedToken)({
|
|
155
|
+
held: () => (held?.key === key ? held.minted : undefined),
|
|
156
|
+
keep: minted => (held = { key, minted }),
|
|
157
|
+
renew: () => (0, exports.mintDevToken)(backend, appId, apiKey),
|
|
158
|
+
withinMs: RENEW_DEV_TOKEN_WITHIN_MS,
|
|
159
|
+
});
|
|
160
|
+
return async () => {
|
|
161
|
+
const minted = await token();
|
|
162
|
+
if (!minted)
|
|
163
|
+
throw new Error(`The backend didn't mint a dev token for app ${appId}`);
|
|
164
|
+
return minted;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
// A given dev token is used as it is. A key mints them only under `vite dev`, which knows the app's id.
|
|
168
|
+
const localToken = (env, appId) => {
|
|
169
|
+
const given = env[exports.LOCAL_ENV.token];
|
|
170
|
+
if (given)
|
|
171
|
+
return () => async () => given;
|
|
172
|
+
const apiKey = env[exports.LOCAL_ENV.apiKey];
|
|
173
|
+
return apiKey && appId
|
|
174
|
+
? backend => mintedDevToken(backend, appId, apiKey)
|
|
175
|
+
: undefined;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* `local` when the developer set a dev token, or a key to mint them with, else undefined. Throws on env it can't read,
|
|
179
|
+
* so a typo fails loudly rather than signing nobody in.
|
|
180
|
+
*/
|
|
181
|
+
const localPlatform = (env = processEnv() ?? {}, appId = devApp_js_1.devAppId) => {
|
|
182
|
+
const token = localToken(env, appId);
|
|
183
|
+
if (!token)
|
|
184
|
+
return undefined;
|
|
185
|
+
const urls = (0, exports.localUrls)(env[exports.LOCAL_ENV.urls]);
|
|
186
|
+
const user = localUser(env[exports.LOCAL_ENV.user]);
|
|
187
|
+
const tokenOf = token(urls.backend);
|
|
188
|
+
return {
|
|
189
|
+
kind: 'local',
|
|
190
|
+
urls,
|
|
191
|
+
user: () => user,
|
|
192
|
+
token: tokenOf,
|
|
193
|
+
context: async () => (0, exports.describeDevToken)(urls.backend, await tokenOf()),
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
exports.localPlatform = localPlatform;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AppContext, ExpiringToken, HostProps, PlatformProvider, PlatformUrls } from '../types.js';
|
|
2
|
+
export declare const isExpiringToken: (value: unknown) => value is ExpiringToken;
|
|
3
|
+
/**
|
|
4
|
+
* The token to send: the one held until its expiry is near, then a renewed one. Callers at once share one renewal,
|
|
5
|
+
* and one that fails keeps the held token while it still serves.
|
|
6
|
+
*/
|
|
7
|
+
export declare const renewedToken: ({ held, keep, renew, withinMs, }: {
|
|
8
|
+
held: () => {
|
|
9
|
+
token: string;
|
|
10
|
+
expiresAt?: number;
|
|
11
|
+
} | undefined;
|
|
12
|
+
keep: (fresh: ExpiringToken) => void;
|
|
13
|
+
renew: () => Promise<ExpiringToken | null>;
|
|
14
|
+
withinMs: number;
|
|
15
|
+
}) => (() => Promise<string | undefined>);
|
|
16
|
+
export declare const contextOf: ({ appId, buildId, baseId, mode, orgSettingsVersion, showZiteBadge, appUrl, }: AppContext) => AppContext;
|
|
17
|
+
export declare const URL_NAMES: readonly ["baseRunner", "backend", "gateway", "runs", "email", "pdf", "uploads", "steps", "schedules"];
|
|
18
|
+
export declare const trimmed: (urls: PlatformUrls) => PlatformUrls;
|
|
19
|
+
export declare const ziteProvider: (props: HostProps) => PlatformProvider;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ziteProvider = exports.trimmed = exports.URL_NAMES = exports.contextOf = exports.renewedToken = exports.isExpiringToken = void 0;
|
|
4
|
+
// A streamed answer can outlive the request's deadline, which the token's expiry follows.
|
|
5
|
+
const RENEW_WITHIN_MS = 30_000;
|
|
6
|
+
const expiresWithin = (expiresAt, ms) => expiresAt !== undefined && expiresAt - Date.now() < ms;
|
|
7
|
+
const isExpiringToken = (value) => {
|
|
8
|
+
const given = value;
|
|
9
|
+
return (typeof given?.token === 'string' &&
|
|
10
|
+
given.token !== '' &&
|
|
11
|
+
typeof given.expiresAt === 'number' &&
|
|
12
|
+
Number.isFinite(given.expiresAt));
|
|
13
|
+
};
|
|
14
|
+
exports.isExpiringToken = isExpiringToken;
|
|
15
|
+
/**
|
|
16
|
+
* The token to send: the one held until its expiry is near, then a renewed one. Callers at once share one renewal,
|
|
17
|
+
* and one that fails keeps the held token while it still serves.
|
|
18
|
+
*/
|
|
19
|
+
const renewedToken = ({ held, keep, renew, withinMs, }) => {
|
|
20
|
+
let renewing;
|
|
21
|
+
return async () => {
|
|
22
|
+
const current = held();
|
|
23
|
+
if (current && !expiresWithin(current.expiresAt, withinMs))
|
|
24
|
+
return current.token;
|
|
25
|
+
renewing ??= renew()
|
|
26
|
+
.then(fresh => {
|
|
27
|
+
if (fresh)
|
|
28
|
+
keep(fresh);
|
|
29
|
+
}, (error) => {
|
|
30
|
+
if (!current || expiresWithin(current.expiresAt, 0))
|
|
31
|
+
throw error;
|
|
32
|
+
console.error("[zite] couldn't renew the token; using the one held until it expires", error);
|
|
33
|
+
})
|
|
34
|
+
.finally(() => (renewing = undefined));
|
|
35
|
+
await renewing;
|
|
36
|
+
return held()?.token;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.renewedToken = renewedToken;
|
|
40
|
+
const contextOf = ({ appId, buildId, baseId, mode, orgSettingsVersion, showZiteBadge, appUrl, }) => ({
|
|
41
|
+
appId,
|
|
42
|
+
buildId,
|
|
43
|
+
baseId,
|
|
44
|
+
mode,
|
|
45
|
+
orgSettingsVersion,
|
|
46
|
+
showZiteBadge,
|
|
47
|
+
appUrl,
|
|
48
|
+
});
|
|
49
|
+
exports.contextOf = contextOf;
|
|
50
|
+
exports.URL_NAMES = [
|
|
51
|
+
'baseRunner',
|
|
52
|
+
'backend',
|
|
53
|
+
'gateway',
|
|
54
|
+
'runs',
|
|
55
|
+
'email',
|
|
56
|
+
'pdf',
|
|
57
|
+
'uploads',
|
|
58
|
+
'steps',
|
|
59
|
+
'schedules',
|
|
60
|
+
];
|
|
61
|
+
const trimmed = (urls) => Object.fromEntries(exports.URL_NAMES.flatMap(name => urls[name] ? [[name, urls[name].replace(/\/+$/, '')]] : []));
|
|
62
|
+
exports.trimmed = trimmed;
|
|
63
|
+
const ziteProvider = (props) => {
|
|
64
|
+
let current = props.appToken
|
|
65
|
+
? { token: props.appToken, expiresAt: props.appTokenExpiresAt }
|
|
66
|
+
: undefined;
|
|
67
|
+
const renewed = (0, exports.renewedToken)({
|
|
68
|
+
held: () => current,
|
|
69
|
+
keep: fresh => (current = fresh),
|
|
70
|
+
renew: async () => {
|
|
71
|
+
const fresh = await props.platform.appToken();
|
|
72
|
+
return (0, exports.isExpiringToken)(fresh) ? fresh : null;
|
|
73
|
+
},
|
|
74
|
+
withinMs: RENEW_WITHIN_MS,
|
|
75
|
+
});
|
|
76
|
+
const context = (0, exports.contextOf)(props);
|
|
77
|
+
return {
|
|
78
|
+
kind: 'zite',
|
|
79
|
+
urls: props.urls && (0, exports.trimmed)(props.urls),
|
|
80
|
+
user: () => props.user,
|
|
81
|
+
context: async () => context,
|
|
82
|
+
// A dispatch with no token has nothing to renew.
|
|
83
|
+
token: async () => (current ? renewed() : undefined),
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
exports.ziteProvider = ziteProvider;
|