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
|
@@ -43,17 +43,29 @@ const SDK_ID_FIELD = 'id';
|
|
|
43
43
|
/**
|
|
44
44
|
* Check if a string is a valid Airtable record ID
|
|
45
45
|
*/
|
|
46
|
-
export const isValidRecordId = (value) =>
|
|
47
|
-
return !!value.match(AIRTABLE_RECORD_ID_REGEX);
|
|
48
|
-
};
|
|
46
|
+
export const isValidRecordId = (value) => typeof value === 'string' && AIRTABLE_RECORD_ID_REGEX.test(value);
|
|
49
47
|
/**
|
|
50
|
-
* Escape
|
|
48
|
+
* Escape a string value for an Airtable formula. Backslashes go first: a
|
|
49
|
+
* caller's trailing backslash would otherwise escape the closing quote and let
|
|
50
|
+
* the rest of the value into the formula.
|
|
51
51
|
*/
|
|
52
|
-
const escapeFormulaString = (value) => value.replace(/"/g, '\\"');
|
|
52
|
+
const escapeFormulaString = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
53
|
+
// Record ids go into the formula unquoted, so only well-formed ones may: any
|
|
54
|
+
// other value matches no record anyway.
|
|
55
|
+
export const isRecordId = (value) => typeof value === 'string' && isValidRecordId(value);
|
|
56
|
+
const anyRecordIdOf = (recordIds) => recordIds.length
|
|
57
|
+
? `OR(${recordIds.map(id => `RECORD_ID() = '${id}'`).join(', ')})`
|
|
58
|
+
: 'FALSE()';
|
|
59
|
+
// A linked record's id comes as a one-item list.
|
|
60
|
+
const singleValue = (value) => Array.isArray(value) && value.length === 1 ? value[0] : value;
|
|
53
61
|
/**
|
|
54
|
-
* Format a value for use in Airtable formulas
|
|
62
|
+
* Format a value for use in Airtable formulas. A lookup's value, or a linked
|
|
63
|
+
* record's primary value, comes as a one-item list, at any depth.
|
|
55
64
|
*/
|
|
56
65
|
const getAirtableFilterValue = (value) => {
|
|
66
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
67
|
+
return getAirtableFilterValue(value[0]);
|
|
68
|
+
}
|
|
57
69
|
if (value instanceof Date) {
|
|
58
70
|
if (!Number.isFinite(value.getTime())) {
|
|
59
71
|
throw new Error('Invalid Date passed to Airtable filter formula. Use a valid Date or ISO date string.');
|
|
@@ -69,8 +81,17 @@ const getAirtableFilterValue = (value) => {
|
|
|
69
81
|
if (value === undefined || value === null) {
|
|
70
82
|
return 'BLANK()';
|
|
71
83
|
}
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
if ((typeof value === 'number' && Number.isFinite(value)) ||
|
|
85
|
+
typeof value === 'bigint') {
|
|
86
|
+
return String(value);
|
|
87
|
+
}
|
|
88
|
+
// Anything else would be pasted into the formula as is.
|
|
89
|
+
const what = Array.isArray(value)
|
|
90
|
+
? 'a list'
|
|
91
|
+
: typeof value === 'number'
|
|
92
|
+
? "a number that isn't finite"
|
|
93
|
+
: typeof value;
|
|
94
|
+
throw new Error(`Can't filter an Airtable field by ${what} here: pass a string, number, boolean, date or null.`);
|
|
74
95
|
};
|
|
75
96
|
/**
|
|
76
97
|
* Convert filters to Airtable filterByFormula string.
|
|
@@ -97,19 +118,18 @@ export const filtersToFormula = async ({ filters, tableSchema, getPrimaryFieldFo
|
|
|
97
118
|
let value = condition;
|
|
98
119
|
let operator = 'equals';
|
|
99
120
|
if (isNestedCondition(condition)) {
|
|
100
|
-
operator = Object.keys(condition)
|
|
121
|
+
operator = Object.keys(condition).find(isConditionOperator);
|
|
101
122
|
value = condition[operator];
|
|
102
123
|
}
|
|
103
124
|
// Special case for id field - use RECORD_ID()
|
|
104
125
|
if (field === SDK_ID_FIELD || field === 'id') {
|
|
105
|
-
const recordIds = Array.isArray(value) ? value : [value];
|
|
126
|
+
const recordIds = (Array.isArray(value) ? value : [value]).map(singleValue);
|
|
106
127
|
if (operator === 'equals') {
|
|
107
|
-
|
|
128
|
+
const [recordId] = recordIds;
|
|
129
|
+
conditions.push(isRecordId(recordId) ? `RECORD_ID() = '${recordId}'` : 'FALSE()');
|
|
108
130
|
}
|
|
109
131
|
else {
|
|
110
|
-
const recordIdClause =
|
|
111
|
-
.map(recordId => `RECORD_ID() = '${recordId}'`)
|
|
112
|
-
.join(', ')})`;
|
|
132
|
+
const recordIdClause = anyRecordIdOf(recordIds.filter(isRecordId));
|
|
113
133
|
if (operator === 'notIn' || operator === 'not') {
|
|
114
134
|
conditions.push(`NOT(${recordIdClause})`);
|
|
115
135
|
continue;
|
|
@@ -123,7 +143,11 @@ export const filtersToFormula = async ({ filters, tableSchema, getPrimaryFieldFo
|
|
|
123
143
|
// Skip undefined conditions
|
|
124
144
|
if (condition === undefined)
|
|
125
145
|
continue;
|
|
126
|
-
// Use field name from schema if available, otherwise use the key as-is
|
|
146
|
+
// Use field name from schema if available, otherwise use the key as-is,
|
|
147
|
+
// which then can't close the braces it's pasted between.
|
|
148
|
+
if (!fieldInfo && /[{}]/.test(field)) {
|
|
149
|
+
throw new Error(`Can't filter by "${field}": an Airtable field name can't contain { or }.`);
|
|
150
|
+
}
|
|
127
151
|
const fieldName = `{${fieldInfo?.name || field}}`;
|
|
128
152
|
// Pre-process linked record values
|
|
129
153
|
if (fieldInfo?.type === 'multipleRecordLinks' && getPrimaryFieldForRecord) {
|
|
@@ -142,8 +166,9 @@ export const filtersToFormula = async ({ filters, tableSchema, getPrimaryFieldFo
|
|
|
142
166
|
// Resolve record IDs to primary field values
|
|
143
167
|
if (linkedRecordOptions?.linkedTableId) {
|
|
144
168
|
value = (await Promise.all(linkedRecords.map(async (recordValue) => {
|
|
145
|
-
|
|
146
|
-
|
|
169
|
+
const recordId = singleValue(recordValue);
|
|
170
|
+
if (isValidRecordId(recordId)) {
|
|
171
|
+
const primaryColumn = await getPrimaryFieldForRecord(linkedRecordOptions.linkedTableId, recordId);
|
|
147
172
|
if (primaryColumn) {
|
|
148
173
|
return primaryColumn;
|
|
149
174
|
}
|
|
@@ -198,18 +223,19 @@ export const filtersToFormula = async ({ filters, tableSchema, getPrimaryFieldFo
|
|
|
198
223
|
? `OR(${value.map(equalsClause).join(',')})`
|
|
199
224
|
: equalsClause(value)})`);
|
|
200
225
|
break;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
226
|
+
// One value stands for a list of it, as on the id path: skipping it would match every record.
|
|
227
|
+
case 'in': {
|
|
228
|
+
const orClauses = (Array.isArray(value) ? value : [value]).map(equalsClause);
|
|
229
|
+
conditions.push(`OR(${orClauses.join(',')})`);
|
|
206
230
|
break;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
231
|
+
}
|
|
232
|
+
case 'notIn': {
|
|
233
|
+
const orClauses = (Array.isArray(value) ? value : [value]).map(equalsClause);
|
|
234
|
+
if (orClauses.length > 0) {
|
|
210
235
|
conditions.push(`NOT(OR(${orClauses.join(',')}))`);
|
|
211
236
|
}
|
|
212
237
|
break;
|
|
238
|
+
}
|
|
213
239
|
case 'lt':
|
|
214
240
|
conditions.push(`${fieldName}<${getAirtableFilterValue(value)}`);
|
|
215
241
|
break;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AirtableSettings } from './dispatch.js';
|
|
2
|
+
import type { HostRequestState, PlatformCallResult } from '../../types.js';
|
|
3
|
+
/** The build's Airtable integration `integrationId`, or undefined when it isn't one. */
|
|
4
|
+
export declare const airtableSettingsOf: (integrationId: string) => AirtableSettings | undefined;
|
|
5
|
+
/** One generated Airtable table call, run here with the connection's token, which the outbound fetch refreshes on a 401. */
|
|
6
|
+
export declare function runAirtableCall(host: HostRequestState, connectionOf: () => Promise<PlatformCallResult>, integrationId: string, settings: AirtableSettings, methodName: string, params: unknown): Promise<unknown>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { builtAirtableSettings } from './built.js';
|
|
2
|
+
import { createAirtableCache } from './cache.js';
|
|
3
|
+
import { executeAirtableCall } from './dispatch.js';
|
|
4
|
+
import { ZiteError, isZiteErrorCode } from '../../errors.js';
|
|
5
|
+
import { rememberConnection } from '../outbound.js';
|
|
6
|
+
const AIRTABLE_API = 'https://api.airtable.com';
|
|
7
|
+
/** The build's Airtable integration `integrationId`, or undefined when it isn't one. */
|
|
8
|
+
export const airtableSettingsOf = (integrationId) => builtAirtableSettings && Object.hasOwn(builtAirtableSettings, integrationId)
|
|
9
|
+
? builtAirtableSettings[integrationId]
|
|
10
|
+
: undefined;
|
|
11
|
+
/** One generated Airtable table call, run here with the connection's token, which the outbound fetch refreshes on a 401. */
|
|
12
|
+
export async function runAirtableCall(host, connectionOf, integrationId, settings, methodName, params) {
|
|
13
|
+
// As classic: a demo reaches no connected account.
|
|
14
|
+
if (host.mode === 'demo')
|
|
15
|
+
throw new ZiteError('FORBIDDEN', 'This action is not available in demo mode');
|
|
16
|
+
const connection = await connectionOf();
|
|
17
|
+
if ('error' in connection) {
|
|
18
|
+
const { code, message, userFacingMessage } = connection.error;
|
|
19
|
+
throw new ZiteError({
|
|
20
|
+
code: isZiteErrorCode(code) ? code : 'INTERNAL_ERROR',
|
|
21
|
+
message,
|
|
22
|
+
userFacingMessage,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const token = connection.value
|
|
26
|
+
?.accessToken;
|
|
27
|
+
if (typeof token !== 'string') {
|
|
28
|
+
throw new ZiteError('INTERNAL_ERROR', `The ${integrationId} connection has no token`);
|
|
29
|
+
}
|
|
30
|
+
rememberConnection(host, integrationId, connection.value);
|
|
31
|
+
host.airtableReads ??= new Map();
|
|
32
|
+
const caches = (host.airtableCaches ??= new Map());
|
|
33
|
+
let cache = caches.get(token);
|
|
34
|
+
if (!cache) {
|
|
35
|
+
cache = createAirtableCache({ token, waitUntil: host.waitUntil });
|
|
36
|
+
caches.set(token, cache);
|
|
37
|
+
}
|
|
38
|
+
return executeAirtableCall({
|
|
39
|
+
settings,
|
|
40
|
+
reads: host.airtableReads,
|
|
41
|
+
cache: await cache,
|
|
42
|
+
fetch: (path, init) => fetch(`${AIRTABLE_API}${path}`, {
|
|
43
|
+
method: init.method,
|
|
44
|
+
headers: {
|
|
45
|
+
authorization: `Bearer ${token}`,
|
|
46
|
+
'content-type': 'application/json',
|
|
47
|
+
},
|
|
48
|
+
body: init.body === undefined ? undefined : JSON.stringify(init.body),
|
|
49
|
+
}),
|
|
50
|
+
}, methodName, params);
|
|
51
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AirtableLockTable } from '../../../sync/lib.js';
|
|
2
|
+
import type { AirtableNameMappings } from './dispatch.js';
|
|
3
|
+
/** An Airtable integration as the build declares it, in the platform's shape. */
|
|
4
|
+
export type BuiltAirtableSettings = {
|
|
5
|
+
serviceType: 'airtable';
|
|
6
|
+
baseId: string;
|
|
7
|
+
nameMappings: AirtableNameMappings | null;
|
|
8
|
+
};
|
|
9
|
+
/** A zite.config.json, as far as the build reads it: each entry is checked where it's used. */
|
|
10
|
+
export type ConfigFile = {
|
|
11
|
+
integrations?: Record<string, unknown>;
|
|
12
|
+
integrationSettings?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
/** What an Airtable integration's zite.lock entry maps: its base, and each table's and field's id by SDK name. */
|
|
15
|
+
type AirtableIdMappings = {
|
|
16
|
+
base: string;
|
|
17
|
+
tables: AirtableLockTable[];
|
|
18
|
+
};
|
|
19
|
+
/** A zite.lock's Airtable integrations, by name. */
|
|
20
|
+
export type LockFile = {
|
|
21
|
+
airtable: Record<string, AirtableIdMappings>;
|
|
22
|
+
};
|
|
23
|
+
export type AirtableSources = {
|
|
24
|
+
appConfig?: ConfigFile;
|
|
25
|
+
appLock?: LockFile;
|
|
26
|
+
workspaceConfig?: ConfigFile;
|
|
27
|
+
workspaceLock?: LockFile;
|
|
28
|
+
/** With zite.schema.json the workspace database is the schema's, and an app's own `databases` entry is dropped. */
|
|
29
|
+
hasSchema: boolean;
|
|
30
|
+
};
|
|
31
|
+
/** A zite.config.json's JSON as the build reads it; undefined when it isn't one. */
|
|
32
|
+
export declare const configFileOf: (json: unknown) => ConfigFile | undefined;
|
|
33
|
+
/** A zite.lock's JSON as the build reads it: the Airtable entries the platform writes, and nothing else. */
|
|
34
|
+
export declare const lockFileOf: (json: unknown) => LockFile | undefined;
|
|
35
|
+
/** Each Airtable integration the build can call, by name, as the platform's `startIntegrationSettings` answers. */
|
|
36
|
+
export declare const airtableSettingsFrom: ({ appConfig, appLock, workspaceConfig, workspaceLock, hasSchema, }: AirtableSources) => Record<string, BuiltAirtableSettings>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// A build's Airtable integrations, from the repo files the platform derives them from (restly's
|
|
2
|
+
// `getEffectiveAppIntegrations`, through `startIntegrationSettings`): the app's own entries, then the workspace's it
|
|
3
|
+
// has settings for, each read against the app's zite.lock. Keep the two in step.
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { isCredentialServiceType, NON_CREDENTIAL_SERVICE_TYPES, normalizeIntegrationServiceType, } from '../../../integrations/rules.js';
|
|
6
|
+
const record = z.record(z.string(), z.unknown());
|
|
7
|
+
const configFile = z.object({
|
|
8
|
+
integrations: record.optional().catch(undefined),
|
|
9
|
+
integrationSettings: record.optional().catch(undefined),
|
|
10
|
+
});
|
|
11
|
+
const idMappings = z.object({
|
|
12
|
+
base: z.string(),
|
|
13
|
+
tables: z.array(z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
sdkName: z.string(),
|
|
16
|
+
name: z.string().optional(),
|
|
17
|
+
primaryFieldId: z.string(),
|
|
18
|
+
fields: z.array(z.object({
|
|
19
|
+
id: z.string(),
|
|
20
|
+
sdkName: z.string(),
|
|
21
|
+
type: z.string(),
|
|
22
|
+
name: z.string(),
|
|
23
|
+
config: record.optional(),
|
|
24
|
+
})),
|
|
25
|
+
})),
|
|
26
|
+
});
|
|
27
|
+
/** A zite.config.json's JSON as the build reads it; undefined when it isn't one. */
|
|
28
|
+
export const configFileOf = (json) => {
|
|
29
|
+
const parsed = configFile.safeParse(json);
|
|
30
|
+
return parsed.success ? parsed.data : undefined;
|
|
31
|
+
};
|
|
32
|
+
/** A zite.lock's JSON as the build reads it: the Airtable entries the platform writes, and nothing else. */
|
|
33
|
+
export const lockFileOf = (json) => {
|
|
34
|
+
const parsed = z.object({ integrations: record }).safeParse(json);
|
|
35
|
+
if (!parsed.success)
|
|
36
|
+
return undefined;
|
|
37
|
+
const airtable = {};
|
|
38
|
+
for (const [name, entry] of Object.entries(parsed.data.integrations)) {
|
|
39
|
+
const mapped = z.object({ idMappings }).safeParse(entry);
|
|
40
|
+
if (mapped.success)
|
|
41
|
+
airtable[name] = mapped.data.idMappings;
|
|
42
|
+
}
|
|
43
|
+
return { airtable };
|
|
44
|
+
};
|
|
45
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
46
|
+
const hasOwn = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
|
|
47
|
+
// Airtable base ids look like `appXYZ…`; anything else is a display name, which only the lock resolves.
|
|
48
|
+
const isAirtableBaseId = (value) => /^app[A-Za-z0-9]{14}$/.test(String(value));
|
|
49
|
+
/** An Airtable entry with its base and the lock's mappings; a base that isn't text names none the platform can use. */
|
|
50
|
+
const convert = (name, base, lock) => {
|
|
51
|
+
const mappings = lock?.airtable[name];
|
|
52
|
+
const locked = mappings && (!isAirtableBaseId(base) || mappings.base === base)
|
|
53
|
+
? mappings
|
|
54
|
+
: undefined;
|
|
55
|
+
const given = base ?? '';
|
|
56
|
+
const baseId = locked?.base ?? (typeof given === 'string' ? given : undefined);
|
|
57
|
+
const tables = Object.fromEntries((locked?.tables ?? []).map(table => [
|
|
58
|
+
table.id,
|
|
59
|
+
{
|
|
60
|
+
mapping: { sdkName: table.sdkName },
|
|
61
|
+
primaryFieldId: table.primaryFieldId,
|
|
62
|
+
fields: Object.fromEntries(table.fields.map(field => [
|
|
63
|
+
field.id,
|
|
64
|
+
{
|
|
65
|
+
mapping: { sdkName: field.sdkName },
|
|
66
|
+
fieldType: field.type,
|
|
67
|
+
fieldName: field.name,
|
|
68
|
+
...(field.config ? { fieldOptions: field.config } : {}),
|
|
69
|
+
},
|
|
70
|
+
])),
|
|
71
|
+
},
|
|
72
|
+
]));
|
|
73
|
+
return {
|
|
74
|
+
baseId,
|
|
75
|
+
nameMappings: {
|
|
76
|
+
bases: {
|
|
77
|
+
[String(baseId)]: {
|
|
78
|
+
mapping: { sdkName: typeof base === 'string' ? base : '' },
|
|
79
|
+
tables,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
const isAirtable = (entry) => isRecord(entry) && entry.type === 'airtable';
|
|
86
|
+
const isServiceType = (type) => {
|
|
87
|
+
const normalized = typeof type === 'string'
|
|
88
|
+
? normalizeIntegrationServiceType(type)
|
|
89
|
+
: undefined;
|
|
90
|
+
return (normalized !== undefined &&
|
|
91
|
+
(isCredentialServiceType(normalized) ||
|
|
92
|
+
NON_CREDENTIAL_SERVICE_TYPES.includes(normalized)));
|
|
93
|
+
};
|
|
94
|
+
const isOptionalString = (value) => value === undefined || value === null || typeof value === 'string';
|
|
95
|
+
/**
|
|
96
|
+
* Whether the platform's conversion of an entry gets past what any type checks (`convertConfigToIntegrationTemplate`
|
|
97
|
+
* throws on an unknown or missing type, a connectionId that isn't a string, and an email sender that isn't one).
|
|
98
|
+
* The platform skips an entry it can't read, whatever its type.
|
|
99
|
+
*/
|
|
100
|
+
const platformReads = (entry) => isRecord(entry) &&
|
|
101
|
+
isServiceType(entry.type) &&
|
|
102
|
+
(!entry.connectionId || typeof entry.connectionId === 'string') &&
|
|
103
|
+
(normalizeIntegrationServiceType(String(entry.type)) !== 'email' ||
|
|
104
|
+
(isOptionalString(entry.fromName) && isOptionalString(entry.fromEmail)));
|
|
105
|
+
/** Each Airtable integration the build can call, by name, as the platform's `startIntegrationSettings` answers. */
|
|
106
|
+
export const airtableSettingsFrom = ({ appConfig, appLock, workspaceConfig, workspaceLock, hasSchema, }) => {
|
|
107
|
+
// The app's own entries, each shadowing the workspace's of its name: only those the platform could read.
|
|
108
|
+
const own = new Set();
|
|
109
|
+
const effective = [];
|
|
110
|
+
for (const [name, entry] of Object.entries(appConfig?.integrations ?? {})) {
|
|
111
|
+
if (!platformReads(entry) || (hasSchema && entry.type === 'databases'))
|
|
112
|
+
continue;
|
|
113
|
+
if (isAirtable(entry))
|
|
114
|
+
effective.push([name, convert(name, entry.base, appLock)]);
|
|
115
|
+
own.add(name);
|
|
116
|
+
}
|
|
117
|
+
const settings = appConfig?.integrationSettings;
|
|
118
|
+
for (const [name, entry] of Object.entries(workspaceConfig?.integrations ?? {})) {
|
|
119
|
+
// A workspace Airtable is the app's only once the app names it in its settings.
|
|
120
|
+
if (!isAirtable(entry) ||
|
|
121
|
+
!platformReads(entry) ||
|
|
122
|
+
own.has(name) ||
|
|
123
|
+
!settings ||
|
|
124
|
+
!hasOwn(settings, name))
|
|
125
|
+
continue;
|
|
126
|
+
const workspace = convert(name, entry.base, workspaceLock);
|
|
127
|
+
const appSettings = settings[name];
|
|
128
|
+
const base = isRecord(appSettings) && hasOwn(appSettings, 'base')
|
|
129
|
+
? appSettings.base
|
|
130
|
+
: workspace.baseId;
|
|
131
|
+
const applied = appSettings ? convert(name, base, appLock) : workspace;
|
|
132
|
+
if (applied.baseId)
|
|
133
|
+
effective.push([name, applied]);
|
|
134
|
+
}
|
|
135
|
+
return Object.fromEntries(effective.flatMap(([name, { baseId, nameMappings }]) => baseId === undefined
|
|
136
|
+
? []
|
|
137
|
+
: [[name, { serviceType: 'airtable', baseId, nameMappings }]]));
|
|
138
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The runtime's page analytics, taken on the app's own origin and handed to the platform's runs service on the
|
|
2
|
+
// request's token. The service checks the events and stamps the org and app from the token, never from the page.
|
|
3
|
+
import { textUpTo } from './caps.js';
|
|
4
|
+
import { directAccess, sendOnToken } from './transport.js';
|
|
5
|
+
const MAX_ANALYTICS_BYTES = 256 * 1024;
|
|
6
|
+
const RUNS_TIMEOUT_MS = 5_000;
|
|
7
|
+
const accepted = () => Response.json({ accepted: true }, { status: 202 });
|
|
8
|
+
const parsed = (raw) => {
|
|
9
|
+
if (raw === undefined)
|
|
10
|
+
return undefined;
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(raw);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
// Workers sets the visitor's country on the request; Node has none.
|
|
19
|
+
const countryOf = (request) => {
|
|
20
|
+
const country = request.headers.get('cf-ipcountry') ??
|
|
21
|
+
request.cf?.country;
|
|
22
|
+
return typeof country === 'string' ? country : undefined;
|
|
23
|
+
};
|
|
24
|
+
/** A beacon from the runtime: a batch of events, or one. Only a live page's reach the platform. */
|
|
25
|
+
export const takeAnalytics = async (request, host) => {
|
|
26
|
+
if (request.method !== 'POST')
|
|
27
|
+
return new Response('Method not allowed', { status: 405 });
|
|
28
|
+
if (host.mode !== 'live')
|
|
29
|
+
return accepted();
|
|
30
|
+
const access = await directAccess(host);
|
|
31
|
+
if (!access?.urls.runs)
|
|
32
|
+
return accepted();
|
|
33
|
+
const body = parsed(await textUpTo(request, MAX_ANALYTICS_BYTES));
|
|
34
|
+
if (body === undefined)
|
|
35
|
+
return Response.json({ error: 'Invalid analytics payload' }, { status: 400 });
|
|
36
|
+
const events = body && typeof body === 'object' && 'events' in body ? body.events : [body];
|
|
37
|
+
try {
|
|
38
|
+
const answer = await sendOnToken(access.token, `${access.urls.runs}/ingest`, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
body: JSON.stringify({
|
|
41
|
+
kind: 'analytics',
|
|
42
|
+
events,
|
|
43
|
+
userAgent: request.headers.get('user-agent') ?? '',
|
|
44
|
+
country: countryOf(request),
|
|
45
|
+
}),
|
|
46
|
+
timeoutMs: RUNS_TIMEOUT_MS,
|
|
47
|
+
});
|
|
48
|
+
if (!answer.ok && answer.status !== 400)
|
|
49
|
+
console.error(`[zite] page analytics not kept: the runs service answered ${answer.status}`);
|
|
50
|
+
return new Response(answer.body, {
|
|
51
|
+
status: answer.status,
|
|
52
|
+
headers: { 'content-type': 'application/json' },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error('[zite] page analytics not kept', error);
|
|
57
|
+
return accepted();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HostRequestState, PlatformCallInput } from '../types.js';
|
|
2
|
+
/** One call the app's SDK made, under the access it ran with: its value, or a throw the app may catch. */
|
|
3
|
+
export declare const callPlatform: (host: HostRequestState, input: PlatformCallInput) => Promise<unknown>;
|
|
4
|
+
/** For tests: forget what this isolate learned. */
|
|
5
|
+
export declare const resetLocalConnections: () => void;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Every platform call an app's SDK makes, by integration id: the data and the ids the platform answers itself, then an
|
|
2
|
+
// Airtable integration the build declares, then email under its integration's own name. Server-only.
|
|
3
|
+
import { RESERVED_INTEGRATION_IDS } from '../../internal/reservedIds.js';
|
|
4
|
+
import { isZiteErrorCode, ZiteError } from '../errors.js';
|
|
5
|
+
import { workspaceSchemaNames } from '../build/placeholders/workspaceSchema.js';
|
|
6
|
+
import { airtableSettingsOf, runAirtableCall } from './airtable/index.js';
|
|
7
|
+
import { integrationsGet, resetConnections } from './connections.js';
|
|
8
|
+
import { DATA_INTEGRATION_ID, runDataCall } from './data/index.js';
|
|
9
|
+
import { dataFetch } from './data/fetch.js';
|
|
10
|
+
import { resetLocal } from './local.js';
|
|
11
|
+
import { metaCall } from './meta.js';
|
|
12
|
+
import { rememberConnection, withGatewayUrl, withRefreshedTokens, } from './outbound.js';
|
|
13
|
+
import { recordCall, somethingWentWrong } from './runLog.js';
|
|
14
|
+
import { serviceCall } from './services.js';
|
|
15
|
+
import { NoPlatformError, requireAccess } from './transport.js';
|
|
16
|
+
const failedWith = ({ code, message, userFacingMessage, }) => new ZiteError({
|
|
17
|
+
code: isZiteErrorCode(code) ? code : 'INTERNAL_ERROR',
|
|
18
|
+
message,
|
|
19
|
+
userFacingMessage,
|
|
20
|
+
});
|
|
21
|
+
// Errors come back as values, so the one the app sees keeps its code; one of ours is logged and said no more of.
|
|
22
|
+
const answered = async (host, input, run) => {
|
|
23
|
+
let result;
|
|
24
|
+
try {
|
|
25
|
+
result = await run();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error instanceof NoPlatformError)
|
|
29
|
+
throw error;
|
|
30
|
+
result = somethingWentWrong(host, input, error);
|
|
31
|
+
}
|
|
32
|
+
if ('value' in result)
|
|
33
|
+
return result.value;
|
|
34
|
+
throw failedWith(result.error);
|
|
35
|
+
};
|
|
36
|
+
const notServed = async ({ className, methodName, }) => {
|
|
37
|
+
throw new ZiteError('NOT_FOUND', `${className}.${methodName} isn't served yet`);
|
|
38
|
+
};
|
|
39
|
+
const data = async (host, input) => {
|
|
40
|
+
await requireAccess(host);
|
|
41
|
+
const target = {
|
|
42
|
+
baseId: (await host.provider?.context())?.baseId ?? null,
|
|
43
|
+
names: workspaceSchemaNames,
|
|
44
|
+
};
|
|
45
|
+
return recordCall(host, input, input.params, () => runDataCall({ dataFetch: dataFetch(host) }, target, host.mode, input.methodName, input.params));
|
|
46
|
+
};
|
|
47
|
+
// Its values then name the calls made with them.
|
|
48
|
+
const connections = async (host, input) => {
|
|
49
|
+
const value = withGatewayUrl(host, withRefreshedTokens(await answered(host, input, () => integrationsGet(host, input))));
|
|
50
|
+
rememberConnection(host, String(input.params?.name ?? ''), value);
|
|
51
|
+
return value;
|
|
52
|
+
};
|
|
53
|
+
const service = (name) => (host, input) => answered(host, input, () => serviceCall(host, input, name));
|
|
54
|
+
const HANDLERS = {
|
|
55
|
+
[DATA_INTEGRATION_ID]: data,
|
|
56
|
+
[RESERVED_INTEGRATION_IDS.connections]: connections,
|
|
57
|
+
[RESERVED_INTEGRATION_IDS.meta]: (host, input) => answered(host, input, () => metaCall(host, input)),
|
|
58
|
+
[RESERVED_INTEGRATION_IDS.pdf]: (host, input) => input.methodName === 'renderHtml'
|
|
59
|
+
? service('pdf')(host, input)
|
|
60
|
+
: notServed(input),
|
|
61
|
+
[RESERVED_INTEGRATION_IDS.schedules]: service('schedules'),
|
|
62
|
+
};
|
|
63
|
+
const airtable = (host, input, settings) => {
|
|
64
|
+
const connection = {
|
|
65
|
+
integrationId: RESERVED_INTEGRATION_IDS.connections,
|
|
66
|
+
className: 'Connections',
|
|
67
|
+
methodName: 'get',
|
|
68
|
+
params: { name: input.integrationId },
|
|
69
|
+
access: input.access,
|
|
70
|
+
};
|
|
71
|
+
const connectionOf = async () => {
|
|
72
|
+
try {
|
|
73
|
+
return await integrationsGet(host, connection);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error instanceof NoPlatformError)
|
|
77
|
+
throw error;
|
|
78
|
+
return somethingWentWrong(host, connection, error);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return recordCall(host, input, input.params, () => runAirtableCall(host, connectionOf, input.integrationId, settings, input.methodName, input.params));
|
|
82
|
+
};
|
|
83
|
+
// Classic's workflow-runner serves only send too, and answers the rest with this message.
|
|
84
|
+
const email = async (host, input) => {
|
|
85
|
+
if (input.methodName !== 'send')
|
|
86
|
+
throw new ZiteError('BAD_REQUEST', `Unknown email method: ${input.methodName}`);
|
|
87
|
+
return service('email')(host, input);
|
|
88
|
+
};
|
|
89
|
+
/** One call the app's SDK made, under the access it ran with: its value, or a throw the app may catch. */
|
|
90
|
+
export const callPlatform = (host, input) => {
|
|
91
|
+
if (Object.hasOwn(HANDLERS, input.integrationId))
|
|
92
|
+
return HANDLERS[input.integrationId](host, input);
|
|
93
|
+
const settings = airtableSettingsOf(input.integrationId);
|
|
94
|
+
if (settings)
|
|
95
|
+
return airtable(host, input, settings);
|
|
96
|
+
if (input.className === 'Email')
|
|
97
|
+
return email(host, input);
|
|
98
|
+
return notServed(input);
|
|
99
|
+
};
|
|
100
|
+
/** For tests: forget what this isolate learned. */
|
|
101
|
+
export const resetLocalConnections = () => {
|
|
102
|
+
resetConnections();
|
|
103
|
+
resetLocal();
|
|
104
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A body's text, read up to `max` bytes. Past the cap, undefined, or with `truncate` what was read; a declared length
|
|
3
|
+
* past the cap is refused before anything is read.
|
|
4
|
+
*/
|
|
5
|
+
export declare const textUpTo: (message: Request | Response, max: number, { truncate }?: {
|
|
6
|
+
truncate?: boolean | undefined;
|
|
7
|
+
}) => Promise<string | undefined>;
|
|
8
|
+
/** Sets `key` as the newest entry, dropping the oldest past `max`: a Map keeps insertion order. */
|
|
9
|
+
export declare const setCapped: <K, V>(map: Map<K, V>, key: K, value: V, max: number) => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Bounded reads and maps: what a request or an isolate keeps can't grow without limit.
|
|
2
|
+
/**
|
|
3
|
+
* A body's text, read up to `max` bytes. Past the cap, undefined, or with `truncate` what was read; a declared length
|
|
4
|
+
* past the cap is refused before anything is read.
|
|
5
|
+
*/
|
|
6
|
+
export const textUpTo = async (message, max, { truncate = false } = {}) => {
|
|
7
|
+
if (!truncate && Number(message.headers.get('content-length')) > max) {
|
|
8
|
+
await message.body?.cancel().catch(() => { });
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (!message.body)
|
|
12
|
+
return '';
|
|
13
|
+
const reader = message.body.getReader();
|
|
14
|
+
const chunks = [];
|
|
15
|
+
let size = 0;
|
|
16
|
+
for (;;) {
|
|
17
|
+
const { done, value } = await reader.read();
|
|
18
|
+
if (done)
|
|
19
|
+
return new Blob(chunks).text();
|
|
20
|
+
chunks.push(value);
|
|
21
|
+
size += value.byteLength;
|
|
22
|
+
if (size > max) {
|
|
23
|
+
await reader.cancel().catch(() => { });
|
|
24
|
+
return truncate ? new Blob(chunks).text() : undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/** Sets `key` as the newest entry, dropping the oldest past `max`: a Map keeps insertion order. */
|
|
29
|
+
export const setCapped = (map, key, value, max) => {
|
|
30
|
+
map.delete(key);
|
|
31
|
+
map.set(key, value);
|
|
32
|
+
const oldest = map.keys().next();
|
|
33
|
+
if (map.size > max && !oldest.done)
|
|
34
|
+
map.delete(oldest.value);
|
|
35
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type DirectAccess } from './transport.js';
|
|
2
|
+
import type { AppContext, HostRequestState, PlatformCallInput, PlatformCallResult } from '../types.js';
|
|
3
|
+
type Connection = Record<string, unknown> & {
|
|
4
|
+
status?: unknown;
|
|
5
|
+
message?: unknown;
|
|
6
|
+
userFacingMessage?: unknown;
|
|
7
|
+
connectUrl?: unknown;
|
|
8
|
+
};
|
|
9
|
+
type Connections = {
|
|
10
|
+
connections: Record<string, Connection>;
|
|
11
|
+
env: Record<string, string>;
|
|
12
|
+
envConnections: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The backend's `GET connections` on the token, once per reuse window: all `local` has, and what an app on Zite asks
|
|
16
|
+
* when the host didn't hand them over. Stale if the backend didn't answer.
|
|
17
|
+
*/
|
|
18
|
+
export declare const connectionsOnToken: (access: DirectAccess, context: AppContext | undefined) => Promise<Connections>;
|
|
19
|
+
/** `integrations.get`: one answer from whichever set the request has, recorded with the connection's values redacted. */
|
|
20
|
+
export declare const integrationsGet: (host: HostRequestState, input: PlatformCallInput) => Promise<PlatformCallResult>;
|
|
21
|
+
/** After a provider answered 401: the connection refreshed by the backend. */
|
|
22
|
+
export declare const refreshConnection: (host: HostRequestState, name: string) => Promise<PlatformCallResult>;
|
|
23
|
+
/** For tests: forget the connections this isolate learned. */
|
|
24
|
+
export declare const resetConnections: () => void;
|
|
25
|
+
export {};
|