zitejs 0.10.0-start.9 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/auth/actions.d.ts +28 -0
- package/dist/cjs/auth/actions.js +93 -0
- package/dist/cjs/auth/client.d.ts +357 -0
- package/dist/cjs/auth/client.js +66 -0
- package/dist/cjs/auth/config.js +9 -3
- package/dist/cjs/auth/index.d.ts +2 -249
- package/dist/cjs/auth/index.js +11 -108
- package/dist/cjs/auth/index.test.js +60 -0
- package/dist/cjs/auth/previewClaim.d.ts +7 -0
- package/dist/cjs/auth/previewClaim.js +16 -0
- package/dist/cjs/auth/profileUpdates.d.ts +9 -0
- package/dist/cjs/auth/profileUpdates.js +11 -0
- package/dist/cjs/backend/index.d.ts +15 -9
- package/dist/cjs/backend/index.js +13 -13
- package/dist/cjs/backend/index.test.js +102 -102
- package/dist/cjs/bundle/index.d.ts +8 -0
- package/dist/cjs/bundle/index.js +38 -24
- package/dist/cjs/caller/index.js +43 -43
- package/dist/cjs/check/index.d.ts +20 -9
- package/dist/cjs/check/index.js +113 -88
- package/dist/cjs/check/start/routeTree.d.ts +8 -0
- package/dist/cjs/check/start/routeTree.js +118 -0
- package/dist/cjs/check/start/tsgo.d.ts +2 -0
- package/dist/cjs/check/start/tsgo.js +35 -0
- package/dist/cjs/cli.js +10 -4
- package/dist/cjs/client/index.d.ts +26 -2
- package/dist/cjs/client/index.js +25 -25
- package/dist/cjs/dev/index.js +79 -54
- package/dist/cjs/dev/signin.d.ts +16 -0
- package/dist/cjs/dev/signin.js +84 -0
- package/dist/cjs/index.d.ts +5 -5
- package/dist/cjs/integrations/client.d.ts +3 -3
- package/dist/cjs/integrations/client.js +5 -4
- package/dist/cjs/integrations/client.test-d.js +15 -15
- package/dist/cjs/integrations/index.d.ts +2 -2
- package/dist/cjs/integrations/rules.d.ts +1 -0
- package/dist/cjs/integrations/rules.js +48 -43
- package/dist/cjs/integrations/rules.test.js +60 -54
- package/dist/cjs/internal/appMode.d.ts +14 -0
- package/dist/cjs/internal/appMode.js +19 -0
- package/dist/cjs/internal/env.js +3 -2
- package/dist/cjs/internal/platformFetch.d.ts +2 -0
- package/dist/cjs/internal/platformFetch.js +14 -0
- package/dist/cjs/internal/reservedIds.d.ts +8 -0
- package/dist/cjs/internal/reservedIds.js +14 -0
- package/dist/cjs/internal/serviceUrls.d.ts +5 -0
- package/dist/cjs/internal/serviceUrls.js +14 -0
- package/dist/cjs/pdf/index.js +2 -1
- package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
- package/dist/cjs/runtime/index.d.ts +126 -39
- package/dist/cjs/runtime/index.js +32 -26
- package/dist/cjs/runtime/index.test.js +34 -34
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +50 -0
- package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
- package/dist/cjs/sourceRoots.js +15 -15
- package/dist/cjs/sourceRoots.test.js +29 -27
- package/dist/cjs/start/{entries.d.ts → build/entries.d.ts} +9 -4
- package/dist/cjs/start/{entries.js → build/entries.js} +38 -21
- package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
- package/dist/cjs/start/build/placeholders/devApp.js +6 -0
- package/dist/cjs/start/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
- package/dist/cjs/start/{describeBuilt.js → describe/describeBuilt.js} +55 -17
- package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
- package/dist/cjs/start/platform/aiUsage.js +215 -0
- package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
- package/dist/cjs/start/platform/airtable/cache.js +93 -0
- package/dist/cjs/start/protocol.d.ts +19 -0
- package/dist/cjs/start/protocol.js +33 -0
- package/dist/cjs/start/serve/local/provider.d.ts +25 -0
- package/dist/cjs/start/serve/local/provider.js +196 -0
- package/dist/cjs/start/serve/provider.d.ts +19 -0
- package/dist/cjs/start/serve/provider.js +86 -0
- package/dist/cjs/start/types.d.ts +373 -0
- package/dist/cjs/start/types.js +2 -0
- package/dist/cjs/steps/index.d.ts +78 -0
- package/dist/cjs/steps/index.js +507 -0
- package/dist/cjs/steps/index.test.js +635 -0
- package/dist/cjs/sync/index.d.ts +1 -1
- package/dist/cjs/sync/index.js +28 -27
- package/dist/cjs/sync/lib.d.ts +15 -8
- package/dist/cjs/sync/lib.js +655 -655
- package/dist/cjs/sync/lib.test.js +177 -46
- package/dist/cjs/sync/sdkNames.d.ts +67 -9
- package/dist/cjs/sync/sdkNames.js +97 -31
- package/dist/cjs/sync/sdkNames.test.js +189 -113
- package/dist/cjs/types/fields.d.ts +9 -2
- package/dist/cjs/types/fields.js +110 -96
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/tables.d.ts +17 -1
- package/dist/cjs/upload/index.js +89 -24
- package/dist/cjs/upload/index.test.js +104 -1
- package/dist/cjs/vite/domTagNames.js +252 -252
- package/dist/cjs/vite/index.d.ts +1 -1
- package/dist/cjs/vite/index.js +46 -42
- package/dist/esm/auth/actions.d.ts +28 -0
- package/dist/esm/auth/actions.js +55 -0
- package/dist/esm/auth/client.d.ts +357 -0
- package/dist/esm/auth/client.js +62 -0
- package/dist/esm/auth/config.js +9 -3
- package/dist/esm/auth/index.d.ts +2 -249
- package/dist/esm/auth/index.js +2 -103
- package/dist/esm/auth/index.test.js +60 -0
- package/dist/esm/auth/previewClaim.d.ts +7 -0
- package/dist/esm/auth/previewClaim.js +12 -0
- package/dist/esm/auth/profileUpdates.d.ts +9 -0
- package/dist/esm/auth/profileUpdates.js +6 -0
- package/dist/esm/backend/index.d.ts +15 -9
- package/dist/esm/backend/index.js +13 -13
- package/dist/esm/backend/index.test.js +106 -106
- package/dist/esm/bundle/index.d.ts +8 -0
- package/dist/esm/bundle/index.js +37 -24
- package/dist/esm/caller/index.js +44 -44
- package/dist/esm/check/index.d.ts +20 -9
- package/dist/esm/check/index.js +117 -93
- package/dist/esm/check/start/routeTree.d.ts +8 -0
- package/dist/esm/check/start/routeTree.js +77 -0
- package/dist/esm/check/start/tsgo.d.ts +2 -0
- package/dist/esm/check/start/tsgo.js +29 -0
- package/dist/esm/cli.js +10 -4
- package/dist/esm/client/index.d.ts +26 -2
- package/dist/esm/client/index.js +25 -25
- package/dist/esm/dev/index.js +86 -61
- package/dist/esm/dev/signin.d.ts +16 -0
- package/dist/esm/dev/signin.js +80 -0
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +3 -3
- package/dist/esm/integrations/client.d.ts +3 -3
- package/dist/esm/integrations/client.js +6 -5
- package/dist/esm/integrations/client.test-d.js +19 -19
- package/dist/esm/integrations/index.d.ts +2 -2
- package/dist/esm/integrations/index.js +1 -1
- package/dist/esm/integrations/rules.d.ts +1 -0
- package/dist/esm/integrations/rules.js +48 -43
- package/dist/esm/integrations/rules.test.js +62 -56
- package/dist/esm/internal/appMode.d.ts +14 -0
- package/dist/esm/internal/appMode.js +13 -0
- package/dist/esm/internal/env.js +3 -2
- package/dist/esm/internal/platformFetch.d.ts +2 -0
- package/dist/esm/internal/platformFetch.js +9 -0
- package/dist/esm/internal/reservedIds.d.ts +8 -0
- package/dist/esm/internal/reservedIds.js +10 -0
- package/dist/esm/internal/serviceUrls.d.ts +5 -0
- package/dist/esm/internal/serviceUrls.js +10 -0
- package/dist/esm/pdf/index.js +2 -1
- package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
- package/dist/esm/runtime/index.d.ts +126 -39
- package/dist/esm/runtime/index.js +35 -29
- package/dist/esm/runtime/index.test.js +36 -36
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +48 -0
- package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
- package/dist/esm/signin/conformance.d.ts +100 -0
- package/dist/esm/signin/conformance.js +616 -0
- package/dist/esm/signin/cookies.d.ts +28 -0
- package/dist/esm/signin/cookies.js +67 -0
- package/dist/esm/signin/encoding.d.ts +1 -0
- package/dist/esm/signin/encoding.js +12 -0
- package/dist/esm/signin/endpoints.d.ts +12 -0
- package/dist/esm/signin/endpoints.js +32 -0
- package/dist/esm/signin/http.d.ts +25 -0
- package/dist/esm/signin/http.js +106 -0
- package/dist/esm/signin/index.d.ts +8 -0
- package/dist/esm/signin/index.js +9 -0
- package/dist/esm/signin/keys.d.ts +35 -0
- package/dist/esm/signin/keys.js +230 -0
- package/dist/esm/signin/paths.d.ts +2 -0
- package/dist/esm/signin/paths.js +5 -0
- package/dist/esm/signin/seal.d.ts +19 -0
- package/dist/esm/signin/seal.js +47 -0
- package/dist/esm/signin/signin.d.ts +60 -0
- package/dist/esm/signin/signin.js +447 -0
- package/dist/esm/signin/transport.d.ts +112 -0
- package/dist/esm/signin/transport.js +1 -0
- package/dist/esm/signin/verifier.d.ts +2 -0
- package/dist/esm/signin/verifier.js +4 -0
- package/dist/esm/signin/verify.d.ts +83 -0
- package/dist/esm/signin/verify.js +142 -0
- package/dist/esm/sourceRoots.js +17 -17
- package/dist/esm/sourceRoots.test.js +34 -32
- package/dist/esm/start/access.d.ts +19 -0
- package/dist/esm/start/access.js +43 -0
- package/dist/esm/start/auth.d.ts +28 -0
- package/dist/esm/start/auth.js +33 -0
- package/dist/esm/start/automations/quiet.d.ts +2 -0
- package/dist/esm/start/automations/quiet.js +36 -0
- package/dist/esm/start/{registration.d.ts → automations/registration.d.ts} +1 -1
- package/dist/esm/start/{registration.js → automations/registration.js} +11 -7
- package/dist/esm/start/automations/steps.d.ts +29 -0
- package/dist/esm/start/automations/steps.js +95 -0
- package/dist/esm/start/automations/workflow.d.ts +83 -0
- package/dist/esm/start/automations/workflow.js +36 -0
- package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
- package/dist/esm/start/automations/workflow.test-d.js +130 -0
- package/dist/esm/start/automations/workflowRun.d.ts +130 -0
- package/dist/esm/start/automations/workflowRun.js +185 -0
- package/dist/esm/start/barrel.test-d.d.ts +10 -0
- package/dist/esm/start/barrel.test-d.js +6 -0
- package/dist/esm/start/{entries.d.ts → build/entries.d.ts} +9 -4
- package/dist/esm/start/{entries.js → build/entries.js} +38 -22
- package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
- package/dist/esm/start/build/placeholders/devApp.js +3 -0
- package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
- package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
- package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
- package/dist/esm/start/build/placeholders/siteHead.js +3 -0
- package/dist/esm/start/{workflowModules.js → build/placeholders/workflowModules.js} +1 -1
- package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
- package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
- package/dist/esm/start/build/registrationHash.d.ts +11 -0
- package/dist/esm/start/build/registrationHash.js +88 -0
- package/dist/esm/start/build/sdk/axios.d.ts +76 -0
- package/dist/esm/start/build/sdk/axios.js +253 -0
- package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
- package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
- package/dist/esm/start/build/sdk/undici.d.ts +34 -0
- package/dist/esm/start/build/sdk/undici.js +18 -0
- package/dist/esm/start/build/sdkPatches.d.ts +22 -0
- package/dist/esm/start/build/sdkPatches.js +430 -0
- package/dist/esm/start/build/siteHead.d.ts +26 -0
- package/dist/esm/start/build/siteHead.js +88 -0
- package/dist/esm/start/build/vite.d.ts +50 -0
- package/dist/esm/start/build/vite.js +487 -0
- package/dist/esm/start/classicOnly.d.ts +1 -0
- package/dist/esm/start/classicOnly.js +4 -0
- package/dist/esm/start/{describe.d.ts → describe/describe.d.ts} +44 -9
- package/dist/esm/start/describe/describe.js +372 -0
- package/dist/esm/start/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
- package/dist/esm/start/describe/describeBuilt.js +102 -0
- package/dist/esm/start/{descriptions.js → describe/descriptions.js} +17 -10
- package/dist/esm/start/errors.d.ts +15 -4
- package/dist/esm/start/errors.js +87 -28
- package/dist/esm/start/errors.test.js +47 -16
- package/dist/esm/start/factories.d.ts +14 -0
- package/dist/esm/start/factories.js +23 -0
- package/dist/esm/start/factories.test-d.d.ts +2 -1
- package/dist/esm/start/factories.test-d.js +52 -12
- package/dist/esm/start/failures.d.ts +7 -0
- package/dist/esm/start/failures.js +62 -0
- package/dist/esm/start/fnFactory.d.ts +16 -0
- package/dist/esm/start/fnFactory.js +1 -0
- package/dist/esm/start/host.d.ts +2 -2
- package/dist/esm/start/host.js +3 -3
- package/dist/esm/start/index.d.ts +10 -66
- package/dist/esm/start/index.js +7 -146
- package/dist/esm/start/login.d.ts +5 -0
- package/dist/esm/start/login.js +29 -0
- package/dist/esm/start/middlewareKind.d.ts +13 -0
- package/dist/esm/start/middlewareKind.js +9 -0
- package/dist/esm/start/platform/aiUsage.d.ts +29 -0
- package/dist/esm/start/platform/aiUsage.js +210 -0
- package/dist/esm/start/platform/airtable/built.d.ts +2 -0
- package/dist/esm/start/platform/airtable/built.js +3 -0
- package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
- package/dist/esm/start/platform/airtable/cache.js +89 -0
- package/dist/esm/start/{airtable → platform/airtable}/dispatch.d.ts +5 -2
- package/dist/esm/start/{airtable → platform/airtable}/dispatch.js +195 -119
- package/dist/esm/start/{airtable → platform/airtable}/formulas.d.ts +2 -1
- package/dist/esm/start/{airtable → platform/airtable}/formulas.js +51 -25
- package/dist/esm/start/platform/airtable/index.d.ts +6 -0
- package/dist/esm/start/platform/airtable/index.js +51 -0
- package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
- package/dist/esm/start/platform/airtable/settings.js +138 -0
- package/dist/esm/start/platform/analytics.d.ts +3 -0
- package/dist/esm/start/platform/analytics.js +59 -0
- package/dist/esm/start/platform/calls.d.ts +5 -0
- package/dist/esm/start/platform/calls.js +104 -0
- package/dist/esm/start/platform/caps.d.ts +9 -0
- package/dist/esm/start/platform/caps.js +35 -0
- package/dist/esm/start/platform/connections.d.ts +25 -0
- package/dist/esm/start/platform/connections.js +198 -0
- package/dist/esm/start/{data → platform/data}/baseRunner.d.ts +11 -6
- package/dist/esm/start/platform/data/baseRunner.js +117 -0
- package/dist/esm/start/{data → platform/data}/dispatch.d.ts +3 -2
- package/dist/esm/start/{data → platform/data}/dispatch.js +69 -51
- package/dist/esm/start/platform/data/fetch.d.ts +7 -0
- package/dist/esm/start/platform/data/fetch.js +9 -0
- package/dist/esm/start/platform/data/index.d.ts +27 -0
- package/dist/esm/start/platform/data/index.js +75 -0
- package/dist/esm/start/platform/data/names.d.ts +7 -0
- package/dist/esm/start/platform/data/names.js +18 -0
- package/dist/esm/start/{data → platform/data}/transformations.d.ts +0 -31
- package/dist/esm/start/{data → platform/data}/transformations.js +0 -56
- package/dist/esm/start/{data → platform/data}/types.d.ts +4 -1
- package/dist/esm/start/{data → platform/data}/types.js +2 -2
- package/dist/esm/start/platform/local.d.ts +6 -0
- package/dist/esm/start/platform/local.js +18 -0
- package/dist/esm/start/platform/meta.d.ts +3 -0
- package/dist/esm/start/platform/meta.js +33 -0
- package/dist/esm/start/platform/outbound.d.ts +17 -0
- package/dist/esm/start/platform/outbound.js +510 -0
- package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
- package/dist/esm/start/{redactSecrets.js → platform/redactSecrets.js} +32 -7
- package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
- package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
- package/dist/esm/start/platform/requestSecrets.js +41 -0
- package/dist/esm/start/platform/runLog.d.ts +40 -0
- package/dist/esm/start/platform/runLog.js +149 -0
- package/dist/esm/start/platform/services.d.ts +7 -0
- package/dist/esm/start/platform/services.js +46 -0
- package/dist/esm/start/platform/steps.d.ts +9 -0
- package/dist/esm/start/platform/steps.js +60 -0
- package/dist/esm/start/platform/telemetry.d.ts +13 -0
- package/dist/esm/start/platform/telemetry.js +71 -0
- package/dist/esm/start/platform/transport.d.ts +28 -0
- package/dist/esm/start/platform/transport.js +59 -0
- package/dist/esm/start/platformHead.d.ts +23 -0
- package/dist/esm/start/platformHead.js +133 -0
- package/dist/esm/start/previewClaim.d.ts +3 -7
- package/dist/esm/start/previewClaim.js +9 -17
- package/dist/esm/start/protocol.d.ts +19 -0
- package/dist/esm/start/protocol.js +27 -0
- package/dist/esm/start/roles.d.ts +12 -0
- package/dist/esm/start/roles.js +27 -0
- package/dist/esm/start/router.d.ts +27 -4
- package/dist/esm/start/router.js +221 -22
- package/dist/esm/start/serve/authHooks.js +18 -0
- package/dist/esm/start/serve/demo.d.ts +9 -0
- package/dist/esm/start/serve/demo.js +24 -0
- package/dist/esm/start/serve/fetch.d.ts +1 -0
- package/dist/esm/start/serve/fetch.js +6 -0
- package/dist/esm/start/{instance.d.ts → serve/instance.d.ts} +6 -5
- package/dist/esm/start/serve/instance.js +134 -0
- package/dist/esm/start/serve/invoke.d.ts +13 -0
- package/dist/esm/start/serve/invoke.js +126 -0
- package/dist/esm/start/serve/local/load.d.ts +8 -0
- package/dist/esm/start/serve/local/load.js +44 -0
- package/dist/esm/start/serve/local/provider.d.ts +25 -0
- package/dist/esm/start/serve/local/provider.js +188 -0
- package/dist/esm/start/serve/local/signIn.d.ts +28 -0
- package/dist/esm/start/serve/local/signIn.js +123 -0
- package/dist/esm/start/serve/pageHead.d.ts +20 -0
- package/dist/esm/start/serve/pageHead.js +34 -0
- package/dist/esm/start/serve/provider.d.ts +19 -0
- package/dist/esm/start/serve/provider.js +78 -0
- package/dist/esm/start/serve/requestEnv.d.ts +2 -0
- package/dist/esm/start/serve/requestEnv.js +84 -0
- package/dist/esm/start/serve/scope.d.ts +18 -0
- package/dist/esm/start/serve/scope.js +67 -0
- package/dist/esm/start/serve/server.d.ts +56 -0
- package/dist/esm/start/serve/server.js +297 -0
- package/dist/esm/start/serve/uploads.d.ts +2 -0
- package/dist/esm/start/serve/uploads.js +49 -0
- package/dist/esm/start/serve/worker.d.ts +6 -0
- package/dist/esm/start/serve/worker.js +12 -0
- package/dist/esm/start/types.d.ts +270 -56
- package/dist/esm/start/version.d.ts +1 -1
- package/dist/esm/start/version.js +1 -1
- package/dist/esm/steps/index.d.ts +78 -0
- package/dist/esm/steps/index.js +502 -0
- package/dist/esm/steps/index.test.d.ts +1 -0
- package/dist/esm/steps/index.test.js +633 -0
- package/dist/esm/sync/index.d.ts +1 -1
- package/dist/esm/sync/index.js +32 -31
- package/dist/esm/sync/lib.d.ts +15 -8
- package/dist/esm/sync/lib.js +659 -659
- package/dist/esm/sync/lib.test.js +177 -46
- package/dist/esm/sync/sdkNames.d.ts +67 -9
- package/dist/esm/sync/sdkNames.js +94 -30
- package/dist/esm/sync/sdkNames.test.js +192 -116
- package/dist/esm/types/fields.d.ts +9 -2
- package/dist/esm/types/fields.js +110 -96
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/index.js +2 -2
- package/dist/esm/types/tables.d.ts +17 -1
- package/dist/esm/types/tables.js +2 -2
- package/dist/esm/upload/index.js +89 -24
- package/dist/esm/upload/index.test.js +104 -1
- package/dist/esm/vite/domTagNames.js +252 -252
- package/dist/esm/vite/index.d.ts +1 -1
- package/dist/esm/vite/index.js +51 -47
- package/package.json +95 -37
- package/dist/cjs/auth-server/index.d.ts +0 -369
- package/dist/cjs/auth-server/index.js +0 -119
- package/dist/cjs/check/start/describeRules.d.ts +0 -35
- package/dist/cjs/check/start/describeRules.js +0 -89
- package/dist/cjs/check/start/problem.d.ts +0 -11
- package/dist/cjs/check/start/problem.js +0 -5
- package/dist/cjs/check/start/sourceRules.d.ts +0 -3
- package/dist/cjs/check/start/sourceRules.js +0 -441
- package/dist/cjs/start/problems.d.ts +0 -19
- package/dist/cjs/start/problems.js +0 -11
- package/dist/esm/auth-server/index.d.ts +0 -369
- package/dist/esm/auth-server/index.js +0 -116
- package/dist/esm/check/start/describeRules.d.ts +0 -35
- package/dist/esm/check/start/describeRules.js +0 -86
- package/dist/esm/check/start/problem.d.ts +0 -11
- package/dist/esm/check/start/problem.js +0 -1
- package/dist/esm/check/start/sourceRules.d.ts +0 -3
- package/dist/esm/check/start/sourceRules.js +0 -438
- package/dist/esm/start/airtable/index.d.ts +0 -11
- package/dist/esm/start/airtable/index.js +0 -70
- package/dist/esm/start/authHooks.js +0 -10
- package/dist/esm/start/data/baseRunner.js +0 -83
- package/dist/esm/start/data/index.d.ts +0 -18
- package/dist/esm/start/data/index.js +0 -76
- package/dist/esm/start/describe.js +0 -204
- package/dist/esm/start/describeBuilt.js +0 -66
- package/dist/esm/start/instance.js +0 -80
- package/dist/esm/start/problems.d.ts +0 -19
- package/dist/esm/start/problems.js +0 -8
- package/dist/esm/start/redactSecrets.d.ts +0 -7
- package/dist/esm/start/runLog.d.ts +0 -8
- package/dist/esm/start/runLog.js +0 -76
- package/dist/esm/start/scope.d.ts +0 -15
- package/dist/esm/start/scope.js +0 -58
- package/dist/esm/start/server.d.ts +0 -55
- package/dist/esm/start/server.js +0 -317
- package/dist/esm/start/vite.d.ts +0 -9
- package/dist/esm/start/vite.js +0 -173
- package/dist/esm/start/worker.d.ts +0 -11
- package/dist/esm/start/worker.js +0 -20
- package/dist/esm/start/workflow.d.ts +0 -53
- package/dist/esm/start/workflow.js +0 -13
- package/dist/esm/start/workflow.test-d.js +0 -44
- package/dist/esm/start/workflowRun.d.ts +0 -80
- package/dist/esm/start/workflowRun.js +0 -108
- /package/dist/{esm/start/redactSecrets.test.d.ts → cjs/runtime/sendEmailParamsTypes.test-d.d.ts} +0 -0
- /package/dist/{esm/start/workflow.test-d.d.ts → cjs/steps/index.test.d.ts} +0 -0
- /package/dist/esm/start/{authHooksModule.d.ts → build/placeholders/authHooksModule.d.ts} +0 -0
- /package/dist/esm/start/{authHooksModule.js → build/placeholders/authHooksModule.js} +0 -0
- /package/dist/esm/start/{workflowModules.d.ts → build/placeholders/workflowModules.d.ts} +0 -0
- /package/dist/esm/start/{descriptions.d.ts → describe/descriptions.d.ts} +0 -0
- /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.d.ts +0 -0
- /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.js +0 -0
- /package/dist/esm/start/{data → platform/data}/sqlNameMappings.d.ts +0 -0
- /package/dist/esm/start/{data → platform/data}/sqlNameMappings.js +0 -0
- /package/dist/esm/start/{redactSecrets.test.js → platform/redactSecrets.test.js} +0 -0
- /package/dist/esm/start/{authHooks.d.ts → serve/authHooks.d.ts} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CallRecord, HostRequestState, PlatformCallInput, PlatformCallResult, RunRecord } from '../types.js';
|
|
2
|
+
export declare const preview: (value: unknown) => string | undefined;
|
|
3
|
+
export declare const errorOf: (error: unknown) => NonNullable<RunRecord["error"]>;
|
|
4
|
+
/** Which call: what the run log names it by. */
|
|
5
|
+
export type CallKey = Pick<CallRecord, 'integrationId' | 'className' | 'methodName'>;
|
|
6
|
+
/** What a call answered, or why it failed. */
|
|
7
|
+
export type CallOutcome = {
|
|
8
|
+
value: unknown;
|
|
9
|
+
} | {
|
|
10
|
+
error: {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/** A call's record for the run log, from when it started. `outputs` previews what it answered. */
|
|
16
|
+
export declare const callRecord: (key: CallKey, params: unknown, at: number, outcome: CallOutcome, outputs?: (value: unknown) => string | undefined) => CallRecord;
|
|
17
|
+
/** Runs one of the app's platform calls and keeps its record, a failure included, for the request's run detail. */
|
|
18
|
+
export declare function recordCall<T>(host: HostRequestState, key: CallKey, params: unknown, run: () => Promise<T>): Promise<T>;
|
|
19
|
+
/** A call answered in the app, kept for the run's detail, which goes with the response's. A `note` stands for its error. */
|
|
20
|
+
export declare const notedCall: (host: HostRequestState, input: PlatformCallInput, result: PlatformCallResult, { outputs, note, }?: {
|
|
21
|
+
outputs?: (value: unknown) => string | undefined;
|
|
22
|
+
note?: string;
|
|
23
|
+
}) => PlatformCallResult;
|
|
24
|
+
/** A platform call that failed on our side: logged, and answered as nothing the app can act on. */
|
|
25
|
+
export declare const somethingWentWrong: (host: HostRequestState, input: PlatformCallInput, error: unknown) => PlatformCallResult;
|
|
26
|
+
/** A call that left the app for a service, failures included, reported for its run as it ends. */
|
|
27
|
+
export declare const reportedCall: (host: HostRequestState, input: PlatformCallInput, run: () => Promise<PlatformCallResult>) => Promise<PlatformCallResult>;
|
|
28
|
+
/** How a run ended, as the run log keeps it. */
|
|
29
|
+
export declare const ranTo: (outcome: {
|
|
30
|
+
output: unknown;
|
|
31
|
+
} | {
|
|
32
|
+
error: unknown;
|
|
33
|
+
}) => Pick<RunRecord, "output" | "error">;
|
|
34
|
+
/** One run of app code for the request's run log, timed from `startedAt` to now. */
|
|
35
|
+
export declare const recordRun: (host: HostRequestState | undefined, run: Omit<RunRecord, "durationMs">, endedAt?: number) => void;
|
|
36
|
+
/**
|
|
37
|
+
* A server route's run, which run capture doesn't see: its body in, and its status and body out. The bodies are
|
|
38
|
+
* read from copies after the fact, so the response never waits; the run log waits for them before it flushes.
|
|
39
|
+
*/
|
|
40
|
+
export declare function recordRoute<T>(host: HostRequestState | undefined, request: Request, run: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { asZiteError } from '../errors.js';
|
|
2
|
+
import { textUpTo } from './caps.js';
|
|
3
|
+
import { sendRunReport } from './telemetry.js';
|
|
4
|
+
// Classic's per-field cap. The host caps again; this keeps a large value from crossing at all.
|
|
5
|
+
const RUN_FIELD_LIMIT = 50 * 1024;
|
|
6
|
+
const capped = (text) => text.length > RUN_FIELD_LIMIT ? `${text.slice(0, RUN_FIELD_LIMIT)}…` : text;
|
|
7
|
+
export const preview = (value) => {
|
|
8
|
+
if (value === undefined)
|
|
9
|
+
return undefined;
|
|
10
|
+
if (typeof value === 'object' &&
|
|
11
|
+
value !== null &&
|
|
12
|
+
Symbol.asyncIterator in value)
|
|
13
|
+
return '[stream]';
|
|
14
|
+
try {
|
|
15
|
+
const json = JSON.stringify(value);
|
|
16
|
+
return json === undefined ? undefined : capped(json);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return '[unserializable]';
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export const errorOf = (error) => ({
|
|
23
|
+
code: asZiteError(error)?.code ?? 'INTERNAL_ERROR',
|
|
24
|
+
message: error instanceof Error ? error.message : String(error),
|
|
25
|
+
...(error instanceof Error && error.stack
|
|
26
|
+
? { stack: capped(error.stack) }
|
|
27
|
+
: {}),
|
|
28
|
+
});
|
|
29
|
+
/** A call's record for the run log, from when it started. `outputs` previews what it answered. */
|
|
30
|
+
export const callRecord = (key, params, at, outcome, outputs = preview) => ({
|
|
31
|
+
integrationId: key.integrationId,
|
|
32
|
+
className: key.className,
|
|
33
|
+
methodName: key.methodName,
|
|
34
|
+
at,
|
|
35
|
+
durationMs: Date.now() - at,
|
|
36
|
+
inputs: preview(params),
|
|
37
|
+
...('value' in outcome
|
|
38
|
+
? { outputs: outputs(outcome.value) }
|
|
39
|
+
: { error: { code: outcome.error.code, message: outcome.error.message } }),
|
|
40
|
+
});
|
|
41
|
+
/** Runs one of the app's platform calls and keeps its record, a failure included, for the request's run detail. */
|
|
42
|
+
export async function recordCall(host, key, params, run) {
|
|
43
|
+
const at = Date.now();
|
|
44
|
+
const keep = (outcome) => (host.calls ??= []).push(callRecord(key, params, at, outcome));
|
|
45
|
+
try {
|
|
46
|
+
const value = await run();
|
|
47
|
+
keep({ value });
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
keep({ error: errorOf(error) });
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** A call answered in the app, kept for the run's detail, which goes with the response's. A `note` stands for its error. */
|
|
56
|
+
export const notedCall = (host, input, result, { outputs = preview, note, } = {}) => {
|
|
57
|
+
const outcome = 'value' in result || note === undefined
|
|
58
|
+
? result
|
|
59
|
+
: { error: { ...result.error, message: note } };
|
|
60
|
+
(host.calls ??= []).push(callRecord(input, input.params, Date.now(), outcome, outputs));
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
/** A platform call that failed on our side: logged, and answered as nothing the app can act on. */
|
|
64
|
+
export const somethingWentWrong = (host, input, error) => {
|
|
65
|
+
console.error('[zite] platform call failed', {
|
|
66
|
+
requestId: host.requestId,
|
|
67
|
+
call: `${input.className}.${input.methodName}`,
|
|
68
|
+
error: errorOf(error).message,
|
|
69
|
+
});
|
|
70
|
+
return { error: { code: 'INTERNAL_ERROR', message: 'Something went wrong' } };
|
|
71
|
+
};
|
|
72
|
+
// Sent as the call ends rather than with the response's flush, which a request past its deadline never reaches.
|
|
73
|
+
// `local` has no run log to send it to.
|
|
74
|
+
const report = (host, record) => {
|
|
75
|
+
if (host.provider?.kind === 'local') {
|
|
76
|
+
(host.calls ??= []).push(record);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const sent = sendRunReport(host, { runs: [], calls: [record] }).catch((error) => console.error("[zite] couldn't record a platform call", error));
|
|
80
|
+
host.waitUntil?.(sent);
|
|
81
|
+
};
|
|
82
|
+
/** A call that left the app for a service, failures included, reported for its run as it ends. */
|
|
83
|
+
export const reportedCall = async (host, input, run) => {
|
|
84
|
+
const at = Date.now();
|
|
85
|
+
const result = await run().catch((error) => somethingWentWrong(host, input, error));
|
|
86
|
+
report(host, callRecord(input, input.params, at, result));
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
89
|
+
/** How a run ended, as the run log keeps it. */
|
|
90
|
+
export const ranTo = (outcome) => 'error' in outcome
|
|
91
|
+
? { error: errorOf(outcome.error) }
|
|
92
|
+
: { output: preview(outcome.output) };
|
|
93
|
+
/** One run of app code for the request's run log, timed from `startedAt` to now. */
|
|
94
|
+
export const recordRun = (host, run, endedAt = Date.now()) => {
|
|
95
|
+
host?.runs.push({ ...run, durationMs: endedAt - run.startedAt });
|
|
96
|
+
};
|
|
97
|
+
const TEXT_BODY = /^(application\/(json|x-www-form-urlencoded)|text\/(?!event-stream))/i;
|
|
98
|
+
// Up to the cap of a copy of the body, so the app still reads the original. Uploads and streams aren't read.
|
|
99
|
+
const bodyText = async (message) => {
|
|
100
|
+
if (!message.body ||
|
|
101
|
+
!TEXT_BODY.test(message.headers.get('content-type') ?? ''))
|
|
102
|
+
return undefined;
|
|
103
|
+
const text = await textUpTo(message.clone(), RUN_FIELD_LIMIT, {
|
|
104
|
+
truncate: true,
|
|
105
|
+
});
|
|
106
|
+
return text === undefined ? undefined : capped(text);
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* A server route's run, which run capture doesn't see: its body in, and its status and body out. The bodies are
|
|
110
|
+
* read from copies after the fact, so the response never waits; the run log waits for them before it flushes.
|
|
111
|
+
*/
|
|
112
|
+
export async function recordRoute(host, request, run) {
|
|
113
|
+
if (!host)
|
|
114
|
+
return run();
|
|
115
|
+
const startedAt = Date.now();
|
|
116
|
+
const path = new URL(request.url).pathname;
|
|
117
|
+
const input = bodyText(request).catch(() => undefined);
|
|
118
|
+
const record = (outcome) => {
|
|
119
|
+
const endedAt = Date.now();
|
|
120
|
+
const recorded = (async () => {
|
|
121
|
+
const fields = { input: await input, ...(await outcome) };
|
|
122
|
+
recordRun(host, {
|
|
123
|
+
fn: `route:${request.method} ${path}`,
|
|
124
|
+
name: path,
|
|
125
|
+
nested: false,
|
|
126
|
+
startedAt,
|
|
127
|
+
...fields,
|
|
128
|
+
}, endedAt);
|
|
129
|
+
})();
|
|
130
|
+
(host.pending ??= []).push(recorded.catch(() => { }));
|
|
131
|
+
};
|
|
132
|
+
try {
|
|
133
|
+
const out = await run();
|
|
134
|
+
const response = out instanceof Response
|
|
135
|
+
? out
|
|
136
|
+
: out?.response;
|
|
137
|
+
if (response instanceof Response) {
|
|
138
|
+
record(bodyText(response).then(body => ({ output: preview({ status: response.status, body }) }), () => ({})));
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
record(Promise.resolve({}));
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
record(Promise.resolve(ranTo({ error })));
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HostRequestState, PlatformCallInput, PlatformCallResult } from '../types.js';
|
|
2
|
+
export type Service = 'email' | 'pdf' | 'schedules';
|
|
3
|
+
/**
|
|
4
|
+
* One service call, reported for the run as it ends. As classic answers a demo: email pretends to succeed and
|
|
5
|
+
* schedules, which would queue runs on the author's live app, are refused.
|
|
6
|
+
*/
|
|
7
|
+
export declare const serviceCall: (host: HostRequestState, input: PlatformCallInput, service: Service) => Promise<PlatformCallResult>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Email, PDFs and schedules on the request's token, each at the URL the platform names for it, answering as classic's
|
|
2
|
+
// do.
|
|
3
|
+
import { serviceUrl } from '../../internal/serviceUrls.js';
|
|
4
|
+
import { isZiteErrorCode } from '../errors.js';
|
|
5
|
+
import { reportedCall } from './runLog.js';
|
|
6
|
+
import { DEMO_REFUSED, PlatformError, requireAccess, sendOnToken, } from './transport.js';
|
|
7
|
+
// Attachments take up to 30 s each, and a render 30 s, as on classic.
|
|
8
|
+
const SERVICE_TIMEOUT_MS = 90_000;
|
|
9
|
+
const bodyOf = (host, { integrationId, methodName, params }, service) => service === 'email'
|
|
10
|
+
? { integrationId, params, mode: host.mode }
|
|
11
|
+
: service === 'pdf'
|
|
12
|
+
? { params }
|
|
13
|
+
: { methodName, params };
|
|
14
|
+
// A 4xx naming a ZiteError code, or any 400, says what the app got wrong, as its error; anything else is ours.
|
|
15
|
+
const send = async (access, service, body) => {
|
|
16
|
+
const response = await sendOnToken(access.token, serviceUrl(access.urls, service), {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
body: JSON.stringify(body),
|
|
19
|
+
timeoutMs: SERVICE_TIMEOUT_MS,
|
|
20
|
+
});
|
|
21
|
+
const answer = (await response.json().catch(() => null));
|
|
22
|
+
const message = typeof answer?.error === 'string'
|
|
23
|
+
? answer.error
|
|
24
|
+
: `The ${service === 'pdf' ? 'PDF' : service} call failed`;
|
|
25
|
+
if (response.status >= 400 &&
|
|
26
|
+
response.status < 500 &&
|
|
27
|
+
isZiteErrorCode(answer?.code))
|
|
28
|
+
return { error: { code: answer.code, message } };
|
|
29
|
+
if (response.status === 400)
|
|
30
|
+
return { error: { code: 'BAD_REQUEST', message } };
|
|
31
|
+
if (!response.ok)
|
|
32
|
+
throw new PlatformError(service, response.status);
|
|
33
|
+
return { value: answer };
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* One service call, reported for the run as it ends. As classic answers a demo: email pretends to succeed and
|
|
37
|
+
* schedules, which would queue runs on the author's live app, are refused.
|
|
38
|
+
*/
|
|
39
|
+
export const serviceCall = async (host, input, service) => {
|
|
40
|
+
if (host.mode === 'demo' && service === 'email')
|
|
41
|
+
return { value: { success: true } };
|
|
42
|
+
if (host.mode === 'demo' && service === 'schedules')
|
|
43
|
+
return DEMO_REFUSED;
|
|
44
|
+
const access = await requireAccess(host);
|
|
45
|
+
return reportedCall(host, input, () => send(access, service, bodyOf(host, input, service)));
|
|
46
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HostRequestState } from '../types.js';
|
|
2
|
+
/** Where a run's step results are kept and read back. */
|
|
3
|
+
export type StepStore = {
|
|
4
|
+
/** Fails if the run can't save a step: checked before the first one runs, whose side effects would go unsaved. */
|
|
5
|
+
ready(): Promise<void>;
|
|
6
|
+
load(): Promise<Record<string, unknown>>;
|
|
7
|
+
persist(name: string, value: unknown, durationMs?: number): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export declare const platformSteps: (host: HostRequestState | undefined) => StepStore;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// A workflow run's saved steps at the platform's steps service, on the request's token, which says the workflow and
|
|
2
|
+
// run. The step runtime calls these directly; they never cross the SDK transport.
|
|
3
|
+
import { serviceUrl } from '../../internal/serviceUrls.js';
|
|
4
|
+
import { STEP_RESULT_MAX_BYTES } from '../../steps/index.js';
|
|
5
|
+
import { ZiteError } from '../errors.js';
|
|
6
|
+
import { NoPlatformError, platformJson, requireAccess } from './transport.js';
|
|
7
|
+
const refused = (message) => new ZiteError('BAD_REQUEST', message);
|
|
8
|
+
export const platformSteps = (host) => {
|
|
9
|
+
const at = async () => {
|
|
10
|
+
if (!host)
|
|
11
|
+
throw refused('step.run runs only in a workflow');
|
|
12
|
+
const access = await requireAccess(host);
|
|
13
|
+
if (host.invoke?.kind !== 'workflow')
|
|
14
|
+
throw refused('step.run runs only in a workflow');
|
|
15
|
+
// Before any step's value leaves the app: with no workspace database there's nowhere to keep it.
|
|
16
|
+
if ((await host.provider?.context())?.baseId === null)
|
|
17
|
+
throw refused('Durable steps need the workspace database, and this app has none');
|
|
18
|
+
const url = serviceUrl(access.urls, 'steps');
|
|
19
|
+
// A failure on our side reaches the run as nothing it can act on; the log keeps why.
|
|
20
|
+
const send = async (method, body) => {
|
|
21
|
+
try {
|
|
22
|
+
return await platformJson(access, method, url, 'steps', body);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (error instanceof NoPlatformError)
|
|
26
|
+
throw error;
|
|
27
|
+
console.error("[zite] the run's saved steps failed", {
|
|
28
|
+
requestId: host.requestId,
|
|
29
|
+
error: error instanceof Error ? error.message : String(error),
|
|
30
|
+
});
|
|
31
|
+
throw new ZiteError('INTERNAL_ERROR', 'Something went wrong');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return { send, workflow: host.invoke.name };
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
ready: async () => {
|
|
38
|
+
await at();
|
|
39
|
+
},
|
|
40
|
+
load: async () => (await (await at()).send('GET'))
|
|
41
|
+
.memos,
|
|
42
|
+
persist: async (name, value, durationMs) => {
|
|
43
|
+
const { send, workflow } = await at();
|
|
44
|
+
if (name.length === 0 || name.length > 255)
|
|
45
|
+
throw refused('A step needs a name of 1 to 255 characters');
|
|
46
|
+
if (new TextEncoder().encode(JSON.stringify(value ?? null)).length >
|
|
47
|
+
STEP_RESULT_MAX_BYTES) {
|
|
48
|
+
throw refused(`step "${name}" returned more than ${STEP_RESULT_MAX_BYTES / 1024}KB`);
|
|
49
|
+
}
|
|
50
|
+
await send('POST', {
|
|
51
|
+
workflow,
|
|
52
|
+
name,
|
|
53
|
+
value: value ?? null,
|
|
54
|
+
...(durationMs !== undefined &&
|
|
55
|
+
Number.isInteger(durationMs) &&
|
|
56
|
+
durationMs >= 0 && { durationMs }),
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CallRecord, FetchRecord, HostRequestState, RunRecord } from '../types.js';
|
|
2
|
+
export type RunReport = {
|
|
3
|
+
runs: RunRecord[];
|
|
4
|
+
calls?: CallRecord[];
|
|
5
|
+
fetches?: FetchRecord[];
|
|
6
|
+
};
|
|
7
|
+
/** The report in as few sends as fit under the runs service's limit, each record whole. */
|
|
8
|
+
export declare const reportSends: (report: RunReport) => RunReport[];
|
|
9
|
+
/**
|
|
10
|
+
* One report of the request's run; the caller keeps it going past the response with `waitUntil`. A request the host
|
|
11
|
+
* dispatched without a runs URL or a token has nowhere to send it, which the throw says.
|
|
12
|
+
*/
|
|
13
|
+
export declare const sendRunReport: (host: HostRequestState, report: RunReport) => Promise<void>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// What a request reports of its own run: what ran, the platform calls it made and its outbound fetches with what its
|
|
2
|
+
// own AI keys used. On the app token to the platform's runs service, which stamps the org, app and request from the
|
|
3
|
+
// token, never from the report. `local` keeps none: only the platform writes a run's row, and a dev token names no
|
|
4
|
+
// request of its own.
|
|
5
|
+
import { sendOnToken } from './transport.js';
|
|
6
|
+
// Half of what the runs service reads in one send; each record is capped far below it.
|
|
7
|
+
const MAX_SEND_BYTES = 512 * 1024;
|
|
8
|
+
const RUNS_TIMEOUT_MS = 10_000;
|
|
9
|
+
const encoder = new TextEncoder();
|
|
10
|
+
const emptySend = () => ({ runs: [], calls: [], fetches: [] });
|
|
11
|
+
const asReport = ({ runs, calls, fetches }) => ({
|
|
12
|
+
runs,
|
|
13
|
+
...(calls.length > 0 && { calls }),
|
|
14
|
+
...(fetches.length > 0 && { fetches }),
|
|
15
|
+
});
|
|
16
|
+
/** The report in as few sends as fit under the runs service's limit, each record whole. */
|
|
17
|
+
export const reportSends = (report) => {
|
|
18
|
+
const sends = [];
|
|
19
|
+
let send = emptySend();
|
|
20
|
+
let bytes = 0;
|
|
21
|
+
const place = (record, add) => {
|
|
22
|
+
const size = encoder.encode(JSON.stringify(record)).byteLength;
|
|
23
|
+
if (bytes > 0 && bytes + size > MAX_SEND_BYTES) {
|
|
24
|
+
sends.push(asReport(send));
|
|
25
|
+
send = emptySend();
|
|
26
|
+
bytes = 0;
|
|
27
|
+
}
|
|
28
|
+
add(send);
|
|
29
|
+
bytes += size;
|
|
30
|
+
};
|
|
31
|
+
for (const run of report.runs)
|
|
32
|
+
place(run, into => into.runs.push(run));
|
|
33
|
+
for (const call of report.calls ?? [])
|
|
34
|
+
place(call, into => into.calls.push(call));
|
|
35
|
+
for (const fetched of report.fetches ?? [])
|
|
36
|
+
place(fetched, into => into.fetches.push(fetched));
|
|
37
|
+
if (bytes > 0)
|
|
38
|
+
sends.push(asReport(send));
|
|
39
|
+
return sends;
|
|
40
|
+
};
|
|
41
|
+
const toRunsService = async (host, runs, token, report) => {
|
|
42
|
+
const answers = await Promise.all(reportSends(report).map(send => sendOnToken(token, `${runs}/ingest`, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
body: JSON.stringify({
|
|
45
|
+
kind: 'events',
|
|
46
|
+
...send,
|
|
47
|
+
// Names the integration call events its fetches become.
|
|
48
|
+
...(send.fetches?.length &&
|
|
49
|
+
host.connectionServices && { services: host.connectionServices }),
|
|
50
|
+
}),
|
|
51
|
+
timeoutMs: RUNS_TIMEOUT_MS,
|
|
52
|
+
})));
|
|
53
|
+
const refused = answers.find(answer => !answer.ok);
|
|
54
|
+
await Promise.all(answers.map(answer => answer.body?.cancel()));
|
|
55
|
+
if (refused)
|
|
56
|
+
throw new Error(`the runs service answered ${refused.status}`);
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* One report of the request's run; the caller keeps it going past the response with `waitUntil`. A request the host
|
|
60
|
+
* dispatched without a runs URL or a token has nowhere to send it, which the throw says.
|
|
61
|
+
*/
|
|
62
|
+
export const sendRunReport = async (host, report) => {
|
|
63
|
+
const { provider } = host;
|
|
64
|
+
if (!provider || provider.kind === 'local')
|
|
65
|
+
return;
|
|
66
|
+
const runs = provider.urls?.runs;
|
|
67
|
+
const token = runs ? await provider.token() : undefined;
|
|
68
|
+
if (!runs || !token)
|
|
69
|
+
throw new Error("This request has no runs URL or app token to send its run's detail with");
|
|
70
|
+
return toRunsService(host, runs, token, report);
|
|
71
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { HostRequestState, PlatformCallResult, PlatformUrls } from '../types.js';
|
|
2
|
+
export type DirectAccess = {
|
|
3
|
+
token: string;
|
|
4
|
+
urls: PlatformUrls;
|
|
5
|
+
};
|
|
6
|
+
export declare class PlatformError extends Error {
|
|
7
|
+
readonly route: string;
|
|
8
|
+
readonly status: number;
|
|
9
|
+
constructor(route: string, status: number);
|
|
10
|
+
}
|
|
11
|
+
/** Thrown for a platform call on a request that has no token or no platform URLs. */
|
|
12
|
+
export declare class NoPlatformError extends Error {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
/** What a demo's call is refused with when it would act on the author's live app. */
|
|
16
|
+
export declare const DEMO_REFUSED: PlatformCallResult;
|
|
17
|
+
/** The request's token and where to send it, renewed first if it's about to expire; undefined without either. */
|
|
18
|
+
export declare const directAccess: (host: HostRequestState) => Promise<DirectAccess | undefined>;
|
|
19
|
+
/** As `directAccess`, failing loudly without a token or URLs. */
|
|
20
|
+
export declare const requireAccess: (host: HostRequestState) => Promise<DirectAccess>;
|
|
21
|
+
/** One request to the platform as JSON, on the token. */
|
|
22
|
+
export declare const sendOnToken: (token: string, url: string, init: {
|
|
23
|
+
method: string;
|
|
24
|
+
body?: string;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
}) => Promise<Response>;
|
|
27
|
+
export declare const platformJson: <T>(access: DirectAccess, method: string, url: string, route: string, body?: unknown) => Promise<T>;
|
|
28
|
+
export declare const backendJson: <T>(access: DirectAccess, method: string, path: string, body?: unknown) => Promise<T>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The platform's own requests on the request's app token. A request with no token or platform URLs reaches nothing: the
|
|
2
|
+
// host dispatches every request with both, and `local` mints its own.
|
|
3
|
+
import { platformFetch } from '../../internal/platformFetch.js';
|
|
4
|
+
import { DEMO_UNAVAILABLE_MESSAGE } from './data/dispatch.js';
|
|
5
|
+
const BACKEND_TIMEOUT_MS = 5_000;
|
|
6
|
+
export class PlatformError extends Error {
|
|
7
|
+
route;
|
|
8
|
+
status;
|
|
9
|
+
constructor(route, status) {
|
|
10
|
+
super(`${route} answered ${status}`);
|
|
11
|
+
this.route = route;
|
|
12
|
+
this.status = status;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Thrown for a platform call on a request that has no token or no platform URLs. */
|
|
16
|
+
export class NoPlatformError extends Error {
|
|
17
|
+
constructor() {
|
|
18
|
+
super("This request has no app token or platform URLs: Zite didn't dispatch it");
|
|
19
|
+
this.name = 'NoPlatformError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** What a demo's call is refused with when it would act on the author's live app. */
|
|
23
|
+
export const DEMO_REFUSED = {
|
|
24
|
+
error: { code: 'FORBIDDEN', message: DEMO_UNAVAILABLE_MESSAGE },
|
|
25
|
+
};
|
|
26
|
+
/** The request's token and where to send it, renewed first if it's about to expire; undefined without either. */
|
|
27
|
+
export const directAccess = async (host) => {
|
|
28
|
+
const urls = host.provider?.urls;
|
|
29
|
+
const token = urls ? await host.provider?.token() : undefined;
|
|
30
|
+
return urls && token ? { token, urls } : undefined;
|
|
31
|
+
};
|
|
32
|
+
/** As `directAccess`, failing loudly without a token or URLs. */
|
|
33
|
+
export const requireAccess = async (host) => {
|
|
34
|
+
const access = await directAccess(host);
|
|
35
|
+
if (!access)
|
|
36
|
+
throw new NoPlatformError();
|
|
37
|
+
return access;
|
|
38
|
+
};
|
|
39
|
+
/** One request to the platform as JSON, on the token. */
|
|
40
|
+
export const sendOnToken = (token, url, init) => platformFetch(new Request(url, {
|
|
41
|
+
method: init.method,
|
|
42
|
+
headers: {
|
|
43
|
+
authorization: `Bearer ${token}`,
|
|
44
|
+
'content-type': 'application/json',
|
|
45
|
+
},
|
|
46
|
+
body: init.body,
|
|
47
|
+
...(init.timeoutMs && { signal: AbortSignal.timeout(init.timeoutMs) }),
|
|
48
|
+
}));
|
|
49
|
+
export const platformJson = async (access, method, url, route, body) => {
|
|
50
|
+
const response = await sendOnToken(access.token, url, {
|
|
51
|
+
method,
|
|
52
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
53
|
+
timeoutMs: BACKEND_TIMEOUT_MS,
|
|
54
|
+
});
|
|
55
|
+
if (!response.ok)
|
|
56
|
+
throw new PlatformError(route, response.status);
|
|
57
|
+
return (await response.json());
|
|
58
|
+
};
|
|
59
|
+
export const backendJson = (access, method, path, body) => platformJson(access, method, `${access.urls.backend}/v1/start/app${path}`, path, body);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { PlatformHead } from './types.js';
|
|
3
|
+
type Meta = JSX.IntrinsicElements['meta'];
|
|
4
|
+
type Link = JSX.IntrinsicElements['link'];
|
|
5
|
+
type Script = JSX.IntrinsicElements['script'];
|
|
6
|
+
/** What a route's `head()` answers, as TanStack's React router types it. */
|
|
7
|
+
export type RouteHead = {
|
|
8
|
+
meta?: Array<Meta | undefined>;
|
|
9
|
+
links?: Array<Link | undefined>;
|
|
10
|
+
scripts?: Array<Script | undefined>;
|
|
11
|
+
styles?: Array<JSX.IntrinsicElements['style'] | undefined>;
|
|
12
|
+
};
|
|
13
|
+
/** Where an installable app's web manifest is served. */
|
|
14
|
+
export declare const MANIFEST_PATH = "/manifest.webmanifest";
|
|
15
|
+
/** @internal Takes in what the page carried. */
|
|
16
|
+
export declare const keepHydratedHead: (head: PlatformHead | undefined) => void;
|
|
17
|
+
/**
|
|
18
|
+
* @internal The root route's head: the app's Settings first, as the site-wide default for its title, description and
|
|
19
|
+
* share tags, which `own` (the root's own entries) and any page's head() can set their own of. The platform's favicon,
|
|
20
|
+
* manifest and installable-app tags and its scripts come with them, and nothing of the app's replaces those.
|
|
21
|
+
*/
|
|
22
|
+
export declare const withPlatformHead: (own?: RouteHead) => RouteHead;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { currentHost } from './host.js';
|
|
2
|
+
/** Where an installable app's web manifest is served. */
|
|
3
|
+
export const MANIFEST_PATH = '/manifest.webmanifest';
|
|
4
|
+
// The browser's, from the page it hydrated; the server's is the request's own.
|
|
5
|
+
let hydrated;
|
|
6
|
+
/** @internal Takes in what the page carried. */
|
|
7
|
+
export const keepHydratedHead = (head) => {
|
|
8
|
+
hydrated = head;
|
|
9
|
+
};
|
|
10
|
+
const PWA_METAS = new Set([
|
|
11
|
+
'theme-color',
|
|
12
|
+
'mobile-web-app-capable',
|
|
13
|
+
'apple-mobile-web-app-capable',
|
|
14
|
+
'apple-mobile-web-app-title',
|
|
15
|
+
]);
|
|
16
|
+
const PLATFORM_SCRIPTS = [
|
|
17
|
+
'data-zite-branding',
|
|
18
|
+
'data-zite-analytics',
|
|
19
|
+
'data-zite-demo',
|
|
20
|
+
];
|
|
21
|
+
// Safe inside a <script>: nothing in it can close the tag.
|
|
22
|
+
const scriptJson = (value) => JSON.stringify(value).replace(/</g, '\\u003c');
|
|
23
|
+
const metaKey = (meta) => meta?.name ?? meta?.property;
|
|
24
|
+
const rels = (link) => (link?.rel ?? '').toLowerCase().split(/\s+/);
|
|
25
|
+
// Only the platform writes these, each marked so a copy in the app's own head can be told apart.
|
|
26
|
+
const platformScript = (marker, children) => ({
|
|
27
|
+
...{ [marker]: 'true' },
|
|
28
|
+
children,
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* @internal The root route's head: the app's Settings first, as the site-wide default for its title, description and
|
|
32
|
+
* share tags, which `own` (the root's own entries) and any page's head() can set their own of. The platform's favicon,
|
|
33
|
+
* manifest and installable-app tags and its scripts come with them, and nothing of the app's replaces those.
|
|
34
|
+
*/
|
|
35
|
+
export const withPlatformHead = (own = {}) => {
|
|
36
|
+
const head = typeof window === 'undefined' ? currentHost()?.head : hydrated;
|
|
37
|
+
if (!head)
|
|
38
|
+
return own;
|
|
39
|
+
const { site, platform } = head;
|
|
40
|
+
const appleTouchIcon = site.appleTouchIcon ?? site.icon;
|
|
41
|
+
const shared = site.title !== undefined ||
|
|
42
|
+
site.description !== undefined ||
|
|
43
|
+
site.image !== undefined;
|
|
44
|
+
const meta = [
|
|
45
|
+
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
|
46
|
+
...(site.title !== undefined
|
|
47
|
+
? [
|
|
48
|
+
{ title: site.title },
|
|
49
|
+
{ property: 'og:title', content: site.title },
|
|
50
|
+
{ property: 'og:site_name', content: site.title || 'Zite' },
|
|
51
|
+
{ name: 'twitter:title', content: site.title },
|
|
52
|
+
]
|
|
53
|
+
: []),
|
|
54
|
+
...(site.description !== undefined
|
|
55
|
+
? [
|
|
56
|
+
{ name: 'description', content: site.description },
|
|
57
|
+
{ property: 'og:description', content: site.description },
|
|
58
|
+
{ name: 'twitter:description', content: site.description },
|
|
59
|
+
]
|
|
60
|
+
: []),
|
|
61
|
+
...(shared
|
|
62
|
+
? [
|
|
63
|
+
{ property: 'og:type', content: 'website' },
|
|
64
|
+
{ name: 'twitter:card', content: 'summary_large_image' },
|
|
65
|
+
]
|
|
66
|
+
: []),
|
|
67
|
+
...(site.image
|
|
68
|
+
? [
|
|
69
|
+
{ property: 'og:image', content: site.image },
|
|
70
|
+
{ name: 'twitter:image', content: site.image },
|
|
71
|
+
]
|
|
72
|
+
: []),
|
|
73
|
+
...(site.manifest
|
|
74
|
+
? [
|
|
75
|
+
{ name: 'theme-color', content: site.manifest.theme_color },
|
|
76
|
+
{ name: 'mobile-web-app-capable', content: 'yes' },
|
|
77
|
+
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
|
78
|
+
{
|
|
79
|
+
name: 'apple-mobile-web-app-title',
|
|
80
|
+
content: site.manifest.short_name,
|
|
81
|
+
},
|
|
82
|
+
]
|
|
83
|
+
: []),
|
|
84
|
+
];
|
|
85
|
+
const links = [
|
|
86
|
+
...(site.icon
|
|
87
|
+
? [{ rel: 'icon', type: 'image/x-icon', href: site.icon }]
|
|
88
|
+
: []),
|
|
89
|
+
...(appleTouchIcon
|
|
90
|
+
? [{ rel: 'apple-touch-icon', href: appleTouchIcon }]
|
|
91
|
+
: []),
|
|
92
|
+
...(site.manifest
|
|
93
|
+
? [
|
|
94
|
+
{
|
|
95
|
+
rel: 'manifest',
|
|
96
|
+
href: MANIFEST_PATH,
|
|
97
|
+
crossOrigin: 'use-credentials',
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
: []),
|
|
101
|
+
];
|
|
102
|
+
// The demo's listing before the runtime, whose demo bridge reads it as it starts.
|
|
103
|
+
const scripts = platform
|
|
104
|
+
? [
|
|
105
|
+
...(platform.demo
|
|
106
|
+
? [
|
|
107
|
+
platformScript('data-zite-demo', `window.__ziteDemo = ${scriptJson(platform.demo)};`),
|
|
108
|
+
]
|
|
109
|
+
: []),
|
|
110
|
+
...(platform.runtimeUrl ? [{ src: platform.runtimeUrl }] : []),
|
|
111
|
+
platformScript('data-zite-branding', `window.__ziteBranding = ${platform.branding};`),
|
|
112
|
+
platformScript('data-zite-analytics', `window.__ziteAnalytics = ${scriptJson(platform.analytics)};`),
|
|
113
|
+
]
|
|
114
|
+
: [];
|
|
115
|
+
const kept = (rel) => (rel === 'icon' && !!site.icon) ||
|
|
116
|
+
(rel === 'apple-touch-icon' && !!appleTouchIcon) ||
|
|
117
|
+
(rel === 'manifest' && !!site.manifest);
|
|
118
|
+
return {
|
|
119
|
+
...own,
|
|
120
|
+
meta: [
|
|
121
|
+
...meta,
|
|
122
|
+
...(own.meta ?? []).filter(entry => !(site.manifest && PWA_METAS.has(metaKey(entry) ?? ''))),
|
|
123
|
+
],
|
|
124
|
+
links: [
|
|
125
|
+
...links,
|
|
126
|
+
...(own.links ?? []).filter(link => !rels(link).some(kept)),
|
|
127
|
+
],
|
|
128
|
+
scripts: [
|
|
129
|
+
...scripts,
|
|
130
|
+
...(own.scripts ?? []).filter(script => !PLATFORM_SCRIPTS.some(marker => script && marker in script)),
|
|
131
|
+
],
|
|
132
|
+
};
|
|
133
|
+
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
/**
|
|
4
|
-
* An editor preview's access, which the host keeps on the URL because the editor's frame may drop its cookie (WebKit
|
|
5
|
-
* drops even Partitioned ones). On the server the host hands it over; in the browser it's on the URL the host sent
|
|
6
|
-
* the page to, read once, before the router hides it.
|
|
7
|
-
*/
|
|
1
|
+
import { PREVIEW_CLAIM_PARAM } from '../auth/previewClaim.js';
|
|
2
|
+
export { PREVIEW_CLAIM_PARAM };
|
|
3
|
+
/** An editor preview's access: on the server the host hands it over, in the browser it's on the URL. */
|
|
8
4
|
export declare const previewClaim: () => string | undefined;
|
|
9
5
|
/** Every same-origin fetch from the page carries the claim: server functions and the app's own routes alike. */
|
|
10
6
|
export declare const carryPreviewClaim: (claim: string) => void;
|