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,198 @@
|
|
|
1
|
+
// `integrations.get`, from the connections the host handed the request or, without them, the backend's on the token;
|
|
2
|
+
// and a connection refreshed after a provider answered 401.
|
|
3
|
+
import { setCapped } from './caps.js';
|
|
4
|
+
import { notedCall, preview } from './runLog.js';
|
|
5
|
+
import { backendJson, DEMO_REFUSED, directAccess, NoPlatformError, PlatformError, requireAccess, } from './transport.js';
|
|
6
|
+
// Per isolate, as the host keeps them: until the request's settings version moves, or a minute without one.
|
|
7
|
+
const CONNECTIONS_REUSE_MS = 60_000;
|
|
8
|
+
const CONNECTIONS_MAX_AGE_MS = 10 * 60_000;
|
|
9
|
+
// Only answers, never a pending call: Workers ties a request's I/O to that request.
|
|
10
|
+
let tokenHeld;
|
|
11
|
+
/**
|
|
12
|
+
* The backend's `GET connections` on the token, once per reuse window: all `local` has, and what an app on Zite asks
|
|
13
|
+
* when the host didn't hand them over. Stale if the backend didn't answer.
|
|
14
|
+
*/
|
|
15
|
+
export const connectionsOnToken = async (access, context) => {
|
|
16
|
+
// A demo's answers are classic's demo set, never a live request's.
|
|
17
|
+
const key = `${context?.mode ?? ''}:${context?.appId ?? ''}:${context?.buildId ?? ''}:${context?.orgSettingsVersion ?? ''}`;
|
|
18
|
+
const reuseMs = typeof context?.orgSettingsVersion === 'number'
|
|
19
|
+
? CONNECTIONS_MAX_AGE_MS
|
|
20
|
+
: CONNECTIONS_REUSE_MS;
|
|
21
|
+
if (tokenHeld?.key === key && Date.now() - tokenHeld.at < reuseMs)
|
|
22
|
+
return tokenHeld.answer;
|
|
23
|
+
try {
|
|
24
|
+
const answer = await backendJson(access, 'GET', '/connections');
|
|
25
|
+
tokenHeld = {
|
|
26
|
+
key,
|
|
27
|
+
at: Date.now(),
|
|
28
|
+
answer: {
|
|
29
|
+
connections: answer.connections ?? {},
|
|
30
|
+
env: answer.env ?? {},
|
|
31
|
+
envConnections: answer.envConnections ?? {},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (!tokenHeld)
|
|
37
|
+
throw error;
|
|
38
|
+
console.error("[zite] couldn't refresh connections; using the last ones", error);
|
|
39
|
+
}
|
|
40
|
+
return tokenHeld.answer;
|
|
41
|
+
};
|
|
42
|
+
const notFound = (name) => ({
|
|
43
|
+
error: { code: 'BAD_REQUEST', message: `Integration ${name} not found` },
|
|
44
|
+
});
|
|
45
|
+
const nameOf = ({ methodName, params, }) => {
|
|
46
|
+
const name = params?.name;
|
|
47
|
+
return methodName === 'get' && typeof name === 'string' && name
|
|
48
|
+
? name
|
|
49
|
+
: undefined;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* `integrations.get` from the connections the request was handed. A connection that needs
|
|
53
|
+
* reconnecting fails with classic's error, which visitors can see; the link to reconnect is a note for the run log,
|
|
54
|
+
* which only the owner reads.
|
|
55
|
+
*/
|
|
56
|
+
const connectionAnswer = (connections, name) => {
|
|
57
|
+
const answer = Object.hasOwn(connections, name)
|
|
58
|
+
? connections[name]
|
|
59
|
+
: undefined;
|
|
60
|
+
if (!answer)
|
|
61
|
+
return { result: notFound(name) };
|
|
62
|
+
if (answer.status !== 'unavailable')
|
|
63
|
+
return { result: { value: answer } };
|
|
64
|
+
const message = String(answer.message);
|
|
65
|
+
return {
|
|
66
|
+
result: {
|
|
67
|
+
error: {
|
|
68
|
+
code: 'INTERNAL_ERROR',
|
|
69
|
+
message,
|
|
70
|
+
...(typeof answer.userFacingMessage === 'string' && {
|
|
71
|
+
userFacingMessage: answer.userFacingMessage,
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
...(typeof answer.connectUrl === 'string' && {
|
|
76
|
+
note: `${message}; reconnect at ${answer.connectUrl}`,
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const MAX_REFRESHED = 50;
|
|
81
|
+
// A connection refreshed after a 401, by name, with the copy the host handed over when it was: later requests in the
|
|
82
|
+
// isolate use it rather than that copy, which failed, until the host hands over a different one.
|
|
83
|
+
const refreshed = new Map();
|
|
84
|
+
const keepRefreshed = (name, from, connection) => setCapped(refreshed, name, { from: JSON.stringify(from), connection }, MAX_REFRESHED);
|
|
85
|
+
const withRefreshed = (given, name) => {
|
|
86
|
+
const held = refreshed.get(name);
|
|
87
|
+
if (!held || !Object.hasOwn(given, name))
|
|
88
|
+
return given;
|
|
89
|
+
if (JSON.stringify(given[name]) !== held.from) {
|
|
90
|
+
refreshed.delete(name);
|
|
91
|
+
return given;
|
|
92
|
+
}
|
|
93
|
+
return { ...given, [name]: held.connection };
|
|
94
|
+
};
|
|
95
|
+
// As the host's run log kept it: a connection's values are its secrets, so only its status is shown.
|
|
96
|
+
const redactedConnection = (value) => value &&
|
|
97
|
+
typeof value === 'object' &&
|
|
98
|
+
value.status === 'connected'
|
|
99
|
+
? Object.fromEntries(Object.entries(value).map(([key, field]) => [
|
|
100
|
+
key,
|
|
101
|
+
key !== 'status' && typeof field === 'string' ? '[redacted]' : field,
|
|
102
|
+
]))
|
|
103
|
+
: value;
|
|
104
|
+
const UNLOADED = {
|
|
105
|
+
error: {
|
|
106
|
+
code: 'INTERNAL_ERROR',
|
|
107
|
+
message: "The app's connections couldn't be loaded; try again in a moment",
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* `integrations.get`'s set: the host's, with any refreshed since, when it handed them over; else the backend's on the
|
|
112
|
+
* token, asked on the first call. Undefined when they couldn't be loaded. A registration is handed its one connection
|
|
113
|
+
* or nothing, since the backend's answer would name the rest.
|
|
114
|
+
*/
|
|
115
|
+
const connectionsOf = async (host, name) => {
|
|
116
|
+
if (host.connections)
|
|
117
|
+
return withRefreshed(host.connections, name);
|
|
118
|
+
if (host.invoke?.kind === 'register')
|
|
119
|
+
return undefined;
|
|
120
|
+
const access = await requireAccess(host);
|
|
121
|
+
try {
|
|
122
|
+
const context = await host.provider?.context();
|
|
123
|
+
return (await (host.connectionsLoad ??= connectionsOnToken(access, context))).connections;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.error("[zite] couldn't load the app's connections", error);
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
/** `integrations.get`: one answer from whichever set the request has, recorded with the connection's values redacted. */
|
|
131
|
+
export const integrationsGet = async (host, input) => {
|
|
132
|
+
const name = nameOf(input);
|
|
133
|
+
const connections = name ? await connectionsOf(host, name) : undefined;
|
|
134
|
+
const answered = !name
|
|
135
|
+
? {
|
|
136
|
+
result: {
|
|
137
|
+
error: {
|
|
138
|
+
code: 'BAD_REQUEST',
|
|
139
|
+
message: 'integrations.get(name): name must be a non-empty string',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
: connections
|
|
144
|
+
? connectionAnswer(connections, name)
|
|
145
|
+
: { result: UNLOADED };
|
|
146
|
+
return notedCall(host, input, answered.result, {
|
|
147
|
+
outputs: value => preview(redactedConnection(value)),
|
|
148
|
+
note: answered.note,
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
/** After a provider answered 401: the connection refreshed by the backend. */
|
|
152
|
+
export const refreshConnection = async (host, name) => {
|
|
153
|
+
const access = await directAccess(host);
|
|
154
|
+
if (!access)
|
|
155
|
+
return {
|
|
156
|
+
error: { code: 'INTERNAL_ERROR', message: new NoPlatformError().message },
|
|
157
|
+
};
|
|
158
|
+
if (host.mode === 'demo')
|
|
159
|
+
return DEMO_REFUSED;
|
|
160
|
+
let fresh;
|
|
161
|
+
try {
|
|
162
|
+
fresh = (await backendJson(access, 'POST', `/connections/${encodeURIComponent(name)}/refresh`)).connection;
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
return error instanceof PlatformError && error.status === 404
|
|
166
|
+
? notFound(name)
|
|
167
|
+
: {
|
|
168
|
+
error: {
|
|
169
|
+
code: 'INTERNAL_ERROR',
|
|
170
|
+
message: `Integration ${name} could not be refreshed`,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// Over whichever set the request read: the host's copy is replaced until the host hands over another, the backend's
|
|
175
|
+
// answer in place.
|
|
176
|
+
const given = host.connections;
|
|
177
|
+
if (fresh && given && Object.hasOwn(given, name))
|
|
178
|
+
keepRefreshed(name, given[name], fresh);
|
|
179
|
+
else if (fresh && !given && tokenHeld) {
|
|
180
|
+
tokenHeld.answer = {
|
|
181
|
+
...tokenHeld.answer,
|
|
182
|
+
connections: { ...tokenHeld.answer.connections, [name]: fresh },
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
if (fresh?.status !== 'connected')
|
|
186
|
+
return {
|
|
187
|
+
error: {
|
|
188
|
+
code: 'INTERNAL_ERROR',
|
|
189
|
+
message: `Integration ${name} is not connected`,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
return { value: fresh };
|
|
193
|
+
};
|
|
194
|
+
/** For tests: forget the connections this isolate learned. */
|
|
195
|
+
export const resetConnections = () => {
|
|
196
|
+
refreshed.clear();
|
|
197
|
+
tokenHeld = undefined;
|
|
198
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BulkCreateResponseType, type FindAllResponseType, type FindOneResponseType, type GetBaseResponseType, type LegacyRecordsFilterClauseType, type NameMappings } from
|
|
1
|
+
import { type BulkCreateResponseType, type FindAllResponseType, type FindOneResponseType, type GetBaseResponseType, type LegacyRecordsFilterClauseType, type NameMappings } from './types.js';
|
|
2
2
|
/** One base-runner request, `path` from `/api/v1`; the platform sends it and answers with base-runner's response. */
|
|
3
3
|
export type DataTransport = (request: {
|
|
4
4
|
method: string;
|
|
@@ -7,18 +7,23 @@ export type DataTransport = (request: {
|
|
|
7
7
|
}) => Promise<Response>;
|
|
8
8
|
type Sort = string | Array<{
|
|
9
9
|
field: string;
|
|
10
|
-
direction:
|
|
10
|
+
direction: 'asc' | 'desc';
|
|
11
11
|
}>;
|
|
12
12
|
/** An id as one path segment: an unencoded `/` or a `..` would move the request to another base's URL. */
|
|
13
13
|
export declare const segment: (id: string | number) => string;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* As restly's workflow-edge waits: base-runner's limit window is a second, so its reset is a whole second at most; the
|
|
16
|
+
* backoff grows past it for a burst that outlasts one window, and the jitter spreads runs turned away together.
|
|
17
|
+
*/
|
|
18
|
+
export declare const rateLimitDelayMs: (headers: Headers, retry: number, random?: () => number) => number;
|
|
19
|
+
export declare const createBaseRunner: (transport: DataTransport, sleep?: (ms: number) => Promise<void>) => {
|
|
15
20
|
bases: {
|
|
16
21
|
get: ({ baseId }: {
|
|
17
22
|
baseId: string;
|
|
18
23
|
}) => Promise<GetBaseResponseType>;
|
|
19
24
|
};
|
|
20
25
|
records: {
|
|
21
|
-
get: ({ baseId, tableId, recordId, fields }: {
|
|
26
|
+
get: ({ baseId, tableId, recordId, fields, }: {
|
|
22
27
|
baseId: string;
|
|
23
28
|
tableId: string;
|
|
24
29
|
recordId: string;
|
|
@@ -33,7 +38,7 @@ export declare const createBaseRunner: (transport: DataTransport) => {
|
|
|
33
38
|
limit?: number;
|
|
34
39
|
fields?: string[];
|
|
35
40
|
}) => Promise<FindAllResponseType>;
|
|
36
|
-
create: ({ baseId, tableId, record }: {
|
|
41
|
+
create: ({ baseId, tableId, record, }: {
|
|
37
42
|
baseId: string;
|
|
38
43
|
tableId: string;
|
|
39
44
|
record: Record<string, unknown>;
|
|
@@ -44,7 +49,7 @@ export declare const createBaseRunner: (transport: DataTransport) => {
|
|
|
44
49
|
recordId: string;
|
|
45
50
|
record: Record<string, unknown>;
|
|
46
51
|
}) => Promise<FindOneResponseType>;
|
|
47
|
-
delete: ({ baseId, tableId, recordId }: {
|
|
52
|
+
delete: ({ baseId, tableId, recordId, }: {
|
|
48
53
|
baseId: string;
|
|
49
54
|
tableId: string;
|
|
50
55
|
recordId: string;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Ported from restly's packages/workflow-edge/src/databases (client, records, sql, authUsers, bases):
|
|
2
|
+
// the requests are the same bytes classic's DatabasesSdk sends; the host adds the key and the acting user.
|
|
3
|
+
import { DatabasesApiError, } from './types.js';
|
|
4
|
+
/** An id as one path segment: an unencoded `/` or a `..` would move the request to another base's URL. */
|
|
5
|
+
export const segment = (id) => {
|
|
6
|
+
const value = String(id);
|
|
7
|
+
const invalid = new DatabasesApiError(`Invalid id: "${value}"`, 400, 'Bad Request');
|
|
8
|
+
if (value === '' || value === '.' || value === '..')
|
|
9
|
+
throw invalid;
|
|
10
|
+
try {
|
|
11
|
+
return encodeURIComponent(value);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
// A lone surrogate, which a visitor can send as JSON.
|
|
15
|
+
throw invalid;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/** Every path, however it was built: none may climb out of where it starts. */
|
|
19
|
+
const apiPath = (path) => {
|
|
20
|
+
const full = `/api/v1${path}`;
|
|
21
|
+
const pathname = full.split('?')[0];
|
|
22
|
+
if (!new URL(full, 'https://base-runner.invalid').pathname.endsWith(pathname)) {
|
|
23
|
+
throw new DatabasesApiError(`Invalid path: ${pathname}`, 400, 'Bad Request');
|
|
24
|
+
}
|
|
25
|
+
return full;
|
|
26
|
+
};
|
|
27
|
+
const RATE_LIMIT_RETRIES = 5;
|
|
28
|
+
const RATE_LIMIT_MAX_DELAY_MS = 4_000;
|
|
29
|
+
/**
|
|
30
|
+
* As restly's workflow-edge waits: base-runner's limit window is a second, so its reset is a whole second at most; the
|
|
31
|
+
* backoff grows past it for a burst that outlasts one window, and the jitter spreads runs turned away together.
|
|
32
|
+
*/
|
|
33
|
+
export const rateLimitDelayMs = (headers, retry, random = Math.random) => {
|
|
34
|
+
const resetSeconds = Number(headers.get('retry-after') ?? headers.get('ratelimit-reset'));
|
|
35
|
+
const reset = Number.isFinite(resetSeconds) ? resetSeconds * 1000 : 0;
|
|
36
|
+
return Math.min(Math.max(reset, 250 * 2 ** retry) + Math.floor(random() * 500), RATE_LIMIT_MAX_DELAY_MS);
|
|
37
|
+
};
|
|
38
|
+
const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
39
|
+
export const createBaseRunner = (transport, sleep = wait) => {
|
|
40
|
+
// A 429 is base-runner's per-base limit turning the request away before it ran, so sending it again is safe.
|
|
41
|
+
const sendRetrying = async (request) => {
|
|
42
|
+
for (let retry = 0;; retry++) {
|
|
43
|
+
const response = await transport(request);
|
|
44
|
+
if (response.status !== 429 || retry >= RATE_LIMIT_RETRIES)
|
|
45
|
+
return response;
|
|
46
|
+
await response.body?.cancel();
|
|
47
|
+
await sleep(rateLimitDelayMs(response.headers, retry));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const send = async (method, path, body) => {
|
|
51
|
+
const response = await sendRetrying({
|
|
52
|
+
method,
|
|
53
|
+
path: apiPath(path),
|
|
54
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
55
|
+
});
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
let errorMessage = response.statusText;
|
|
58
|
+
try {
|
|
59
|
+
const errorBody = (await response.json());
|
|
60
|
+
errorMessage =
|
|
61
|
+
errorBody?.error?.message || errorBody?.message || errorMessage;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// If we can't parse the error body, fall back to statusText
|
|
65
|
+
}
|
|
66
|
+
throw new DatabasesApiError(errorMessage, response.status, response.statusText);
|
|
67
|
+
}
|
|
68
|
+
return response;
|
|
69
|
+
};
|
|
70
|
+
const json = async (method, path, body) => (await send(method, path, body)).json();
|
|
71
|
+
return {
|
|
72
|
+
bases: {
|
|
73
|
+
get: ({ baseId }) => json('GET', `/bases/${segment(baseId)}`),
|
|
74
|
+
},
|
|
75
|
+
records: {
|
|
76
|
+
get: ({ baseId, tableId, recordId, fields, }) => json('GET', `/bases/${segment(baseId)}/tables/${segment(tableId)}/records/${segment(recordId)}${fields?.length
|
|
77
|
+
? `?fields=${encodeURIComponent(fields.join(','))}`
|
|
78
|
+
: ''}`),
|
|
79
|
+
findAll: ({ baseId, tableId, filters, offset, sort, limit = 500, fields, }) => json('POST', `/bases/${segment(baseId)}/tables/${segment(tableId)}/records/list`, {
|
|
80
|
+
filters,
|
|
81
|
+
offset,
|
|
82
|
+
sort,
|
|
83
|
+
limit,
|
|
84
|
+
fields,
|
|
85
|
+
}),
|
|
86
|
+
create: ({ baseId, tableId, record, }) => json('POST', `/bases/${segment(baseId)}/tables/${segment(tableId)}/records`, { record }),
|
|
87
|
+
update: ({ baseId, tableId, recordId, record, }) => json('PATCH', `/bases/${segment(baseId)}/tables/${segment(tableId)}/records/${segment(recordId)}`, { record }),
|
|
88
|
+
delete: async ({ baseId, tableId, recordId, }) => {
|
|
89
|
+
await send('DELETE', `/bases/${segment(baseId)}/tables/${segment(tableId)}/records/${segment(recordId)}`);
|
|
90
|
+
return { id: recordId };
|
|
91
|
+
},
|
|
92
|
+
bulkCreate: ({ baseId, tableId, records, matchOn, }) => json('POST', `/bases/${segment(baseId)}/tables/${segment(tableId)}/records/bulk`, {
|
|
93
|
+
records,
|
|
94
|
+
matchOn,
|
|
95
|
+
}),
|
|
96
|
+
},
|
|
97
|
+
sql: {
|
|
98
|
+
execute: ({ baseId, sql, params, statementTimeoutMs, nameMappings, }) => json('POST', `/bases/${segment(baseId)}/sql`, {
|
|
99
|
+
sql,
|
|
100
|
+
params,
|
|
101
|
+
statementTimeoutMs,
|
|
102
|
+
nameMappings,
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
auth: {
|
|
106
|
+
findAll: ({ baseId, appIds, filters, filter, offset, sort, limit = 500, }) => json('POST', `/bases/${segment(baseId)}/auth/users/list`, {
|
|
107
|
+
appIds,
|
|
108
|
+
filters,
|
|
109
|
+
filter,
|
|
110
|
+
offset,
|
|
111
|
+
sort,
|
|
112
|
+
limit,
|
|
113
|
+
}),
|
|
114
|
+
update: ({ baseId, userId, profile, }) => json('PATCH', `/bases/${segment(baseId)}/auth/users/${segment(userId)}`, profile),
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BaseRunner } from
|
|
2
|
-
import { type BaseTable, type DataNameMappings } from
|
|
1
|
+
import type { BaseRunner } from './baseRunner.js';
|
|
2
|
+
import { type BaseTable, type DataNameMappings } from './types.js';
|
|
3
3
|
export type DataContext = {
|
|
4
4
|
baseRunner: BaseRunner;
|
|
5
5
|
/** The build's base, from the platform; a base id the app sends is ignored. */
|
|
@@ -11,6 +11,7 @@ export type DataContext = {
|
|
|
11
11
|
readOnly: boolean;
|
|
12
12
|
};
|
|
13
13
|
export declare const DEMO_UNAVAILABLE_MESSAGE = "This action is not available in demo mode";
|
|
14
|
+
export declare const DEMO_READ_DATABASE_METHODS: ReadonlySet<string>;
|
|
14
15
|
export declare function asZiteClientError(error: unknown): unknown;
|
|
15
16
|
/** One `zite.*` data call, as classic's dispatch runs it. */
|
|
16
17
|
export declare function executeDatabasesCall(context: DataContext, methodName: string, params: any): Promise<any>;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { buildSdkNameMappingsForBase } from
|
|
2
|
-
import { transformFieldNamesToIds, transformFieldsToFieldIds, transformFiltersToFieldIds, transformLinkedRecordFields, transformMatchOnFields, transformRecordToSdkNames, transformSortToFieldIds, } from
|
|
3
|
-
import { ZITE_PLATFORM_FAULT_FLAG, } from
|
|
4
|
-
export const DEMO_UNAVAILABLE_MESSAGE =
|
|
1
|
+
import { buildSdkNameMappingsForBase } from './sqlNameMappings.js';
|
|
2
|
+
import { transformFieldNamesToIds, transformFieldsToFieldIds, transformFiltersToFieldIds, transformLinkedRecordFields, transformMatchOnFields, transformRecordToSdkNames, transformSortToFieldIds, } from './transformations.js';
|
|
3
|
+
import { ZITE_PLATFORM_FAULT_FLAG, } from './types.js';
|
|
4
|
+
export const DEMO_UNAVAILABLE_MESSAGE = 'This action is not available in demo mode';
|
|
5
5
|
// An allowlist, so a database method added later is refused until it's listed.
|
|
6
|
-
const DEMO_READ_DATABASE_METHODS = new Set([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"getDatabaseSchema",
|
|
6
|
+
export const DEMO_READ_DATABASE_METHODS = new Set([
|
|
7
|
+
'findOne',
|
|
8
|
+
'findAll',
|
|
9
|
+
'executeSql',
|
|
10
|
+
'findAllUsers',
|
|
12
11
|
]);
|
|
13
12
|
const STATUS_TO_ZITE_ERROR_CODE = {
|
|
14
|
-
400:
|
|
15
|
-
401:
|
|
16
|
-
403:
|
|
17
|
-
404:
|
|
18
|
-
409:
|
|
19
|
-
429:
|
|
13
|
+
400: 'BAD_REQUEST',
|
|
14
|
+
401: 'UNAUTHORIZED',
|
|
15
|
+
403: 'FORBIDDEN',
|
|
16
|
+
404: 'NOT_FOUND',
|
|
17
|
+
409: 'CONFLICT',
|
|
18
|
+
429: 'RATE_LIMITED',
|
|
20
19
|
};
|
|
21
20
|
// A 4xx answers with its status as a coded ZiteError; a 5xx stays as thrown, flagged as ours, not the app's.
|
|
22
21
|
export function asZiteClientError(error) {
|
|
23
22
|
const status = error?.statusCode;
|
|
24
|
-
if (typeof status !==
|
|
23
|
+
if (typeof status !== 'number' || status < 400)
|
|
25
24
|
return error;
|
|
26
25
|
if (status >= 500) {
|
|
27
|
-
if (error && typeof error ===
|
|
26
|
+
if (error && typeof error === 'object')
|
|
28
27
|
error[ZITE_PLATFORM_FAULT_FLAG] = true;
|
|
29
28
|
return error;
|
|
30
29
|
}
|
|
31
30
|
const tagged = new Error(error instanceof Error ? error.message : String(error));
|
|
32
|
-
tagged.name =
|
|
33
|
-
tagged.code =
|
|
31
|
+
tagged.name = 'ZiteError';
|
|
32
|
+
tagged.code =
|
|
33
|
+
STATUS_TO_ZITE_ERROR_CODE[status] ?? 'BAD_REQUEST';
|
|
34
34
|
tagged.statusCode = status;
|
|
35
35
|
tagged.cause = error;
|
|
36
36
|
if (error instanceof Error)
|
|
@@ -49,9 +49,11 @@ export async function executeDatabasesCall(context, methodName, params) {
|
|
|
49
49
|
async function runDatabasesCall(context, methodName, params) {
|
|
50
50
|
const { baseRunner: sdk, baseId, nameMappings, tables } = context;
|
|
51
51
|
if (context.readOnly && !DEMO_READ_DATABASE_METHODS.has(methodName)) {
|
|
52
|
-
throw Object.assign(new Error(DEMO_UNAVAILABLE_MESSAGE), {
|
|
52
|
+
throw Object.assign(new Error(DEMO_UNAVAILABLE_MESSAGE), {
|
|
53
|
+
statusCode: 403,
|
|
54
|
+
});
|
|
53
55
|
}
|
|
54
|
-
if (methodName ===
|
|
56
|
+
if (methodName === 'findAllUsers') {
|
|
55
57
|
return sdk.auth.findAll({
|
|
56
58
|
baseId,
|
|
57
59
|
appIds: params.appIds,
|
|
@@ -62,25 +64,29 @@ async function runDatabasesCall(context, methodName, params) {
|
|
|
62
64
|
limit: params.limit,
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
|
-
if (methodName ===
|
|
67
|
+
if (methodName === 'updateUserProfile') {
|
|
66
68
|
const userId = params.userId ?? params.id;
|
|
67
69
|
const profile = params.profile ?? params.data ?? params.record ?? params;
|
|
68
|
-
if (!userId || !profile || typeof profile !==
|
|
69
|
-
throw new Error(
|
|
70
|
+
if (!userId || !profile || typeof profile !== 'object') {
|
|
71
|
+
throw new Error('updateUserProfile requires a user id and profile data');
|
|
70
72
|
}
|
|
71
|
-
if (
|
|
72
|
-
throw new Error(
|
|
73
|
+
if ('email' in profile) {
|
|
74
|
+
throw new Error('A Zite user email address cannot be updated');
|
|
73
75
|
}
|
|
74
76
|
return sdk.auth.update({
|
|
75
77
|
baseId,
|
|
76
78
|
userId,
|
|
77
|
-
profile: {
|
|
79
|
+
profile: {
|
|
80
|
+
firstName: profile.firstName,
|
|
81
|
+
lastName: profile.lastName,
|
|
82
|
+
image: profile.image,
|
|
83
|
+
},
|
|
78
84
|
});
|
|
79
85
|
}
|
|
80
|
-
if (methodName ===
|
|
86
|
+
if (methodName === 'executeSql') {
|
|
81
87
|
const query = params?.query ?? params?.sql;
|
|
82
|
-
if (typeof query !==
|
|
83
|
-
throw new Error(
|
|
88
|
+
if (typeof query !== 'string' || query.trim() === '') {
|
|
89
|
+
throw new Error('executeSql requires a non-empty `query` parameter');
|
|
84
90
|
}
|
|
85
91
|
return await sdk.sql.execute({
|
|
86
92
|
baseId,
|
|
@@ -88,28 +94,38 @@ async function runDatabasesCall(context, methodName, params) {
|
|
|
88
94
|
params: params.params,
|
|
89
95
|
statementTimeoutMs: params.statementTimeoutMs,
|
|
90
96
|
nameMappings: nameMappings && tables
|
|
91
|
-
? buildSdkNameMappingsForBase({
|
|
97
|
+
? buildSdkNameMappingsForBase({
|
|
98
|
+
metadata: { tables },
|
|
99
|
+
settingsNameMappings: nameMappings,
|
|
100
|
+
})
|
|
92
101
|
: undefined,
|
|
93
102
|
});
|
|
94
103
|
}
|
|
95
104
|
const tableId = params.tableId;
|
|
96
105
|
if (!tableId) {
|
|
97
|
-
throw new Error(
|
|
106
|
+
throw new Error('Databases calls require tableId in params');
|
|
98
107
|
}
|
|
99
108
|
const fieldMappings = nameMappings?.tables?.[tableId]?.fields;
|
|
100
|
-
const table = tables?.find(
|
|
109
|
+
const table = tables?.find(t => t.id === tableId);
|
|
101
110
|
switch (methodName) {
|
|
102
|
-
case
|
|
111
|
+
case 'findOne': {
|
|
103
112
|
const { id: recordId, filters, fields } = params;
|
|
104
113
|
const transformedFields = transformFieldsToFieldIds(fields, table, fieldMappings);
|
|
105
114
|
if (recordId) {
|
|
106
|
-
const record = await sdk.records.get({
|
|
115
|
+
const record = await sdk.records.get({
|
|
116
|
+
baseId,
|
|
117
|
+
tableId,
|
|
118
|
+
recordId,
|
|
119
|
+
fields: transformedFields,
|
|
120
|
+
});
|
|
107
121
|
return transformRecordToSdkNames(record, fieldMappings);
|
|
108
122
|
}
|
|
109
123
|
const result = await sdk.records.findAll({
|
|
110
124
|
baseId,
|
|
111
125
|
tableId,
|
|
112
|
-
filters: filters
|
|
126
|
+
filters: filters
|
|
127
|
+
? transformFiltersToFieldIds(filters, fieldMappings)
|
|
128
|
+
: undefined,
|
|
113
129
|
limit: 1,
|
|
114
130
|
fields: transformedFields,
|
|
115
131
|
});
|
|
@@ -117,12 +133,14 @@ async function runDatabasesCall(context, methodName, params) {
|
|
|
117
133
|
return undefined;
|
|
118
134
|
return transformRecordToSdkNames(result.records[0], fieldMappings);
|
|
119
135
|
}
|
|
120
|
-
case
|
|
136
|
+
case 'findAll': {
|
|
121
137
|
const { filters, sort, limit, offset, fields } = params;
|
|
122
138
|
const result = await sdk.records.findAll({
|
|
123
139
|
baseId,
|
|
124
140
|
tableId,
|
|
125
|
-
filters: filters
|
|
141
|
+
filters: filters
|
|
142
|
+
? transformFiltersToFieldIds(filters, fieldMappings)
|
|
143
|
+
: undefined,
|
|
126
144
|
sort: transformSortToFieldIds(sort, table, fieldMappings),
|
|
127
145
|
limit: limit || 500,
|
|
128
146
|
offset,
|
|
@@ -130,15 +148,15 @@ async function runDatabasesCall(context, methodName, params) {
|
|
|
130
148
|
});
|
|
131
149
|
return {
|
|
132
150
|
records: result.records
|
|
133
|
-
.map(
|
|
151
|
+
.map(r => transformRecordToSdkNames(r, fieldMappings))
|
|
134
152
|
.filter((r) => r !== undefined),
|
|
135
153
|
hasMore: result.hasMore,
|
|
136
154
|
};
|
|
137
155
|
}
|
|
138
|
-
case
|
|
156
|
+
case 'create': {
|
|
139
157
|
const { record: recordData } = params;
|
|
140
158
|
if (!recordData)
|
|
141
|
-
throw new Error(
|
|
159
|
+
throw new Error('Create requires record data');
|
|
142
160
|
const record = await sdk.records.create({
|
|
143
161
|
baseId,
|
|
144
162
|
tableId,
|
|
@@ -146,13 +164,13 @@ async function runDatabasesCall(context, methodName, params) {
|
|
|
146
164
|
});
|
|
147
165
|
const transformed = transformRecordToSdkNames(record, fieldMappings);
|
|
148
166
|
if (!transformed)
|
|
149
|
-
throw new Error(
|
|
167
|
+
throw new Error('Failed to create record');
|
|
150
168
|
return transformed;
|
|
151
169
|
}
|
|
152
|
-
case
|
|
170
|
+
case 'update': {
|
|
153
171
|
const { id: recordId, record: recordData } = params;
|
|
154
172
|
if (!recordId || !recordData)
|
|
155
|
-
throw new Error(
|
|
173
|
+
throw new Error('Update requires id and record data');
|
|
156
174
|
const record = await sdk.records.update({
|
|
157
175
|
baseId,
|
|
158
176
|
tableId,
|
|
@@ -161,18 +179,18 @@ async function runDatabasesCall(context, methodName, params) {
|
|
|
161
179
|
});
|
|
162
180
|
const transformed = transformRecordToSdkNames(record, fieldMappings);
|
|
163
181
|
if (!transformed)
|
|
164
|
-
throw new Error(
|
|
182
|
+
throw new Error('Failed to update record');
|
|
165
183
|
// Both flat and `fields`, for compatibility.
|
|
166
184
|
return { ...transformed, fields: transformed };
|
|
167
185
|
}
|
|
168
|
-
case
|
|
186
|
+
case 'delete': {
|
|
169
187
|
const { id: recordId } = params;
|
|
170
188
|
if (!recordId)
|
|
171
|
-
throw new Error(
|
|
189
|
+
throw new Error('Delete requires id parameter');
|
|
172
190
|
await sdk.records.delete({ baseId, tableId, recordId });
|
|
173
191
|
return { success: true, id: recordId };
|
|
174
192
|
}
|
|
175
|
-
case
|
|
193
|
+
case 'bulkCreate': {
|
|
176
194
|
const { records: recordsData, matchOn } = params;
|
|
177
195
|
if (!recordsData || recordsData.length === 0)
|
|
178
196
|
return { records: [] };
|
|
@@ -183,9 +201,9 @@ async function runDatabasesCall(context, methodName, params) {
|
|
|
183
201
|
matchOn: transformMatchOnFields(matchOn, fieldMappings),
|
|
184
202
|
});
|
|
185
203
|
const records = result.records
|
|
186
|
-
.map(
|
|
204
|
+
.map(r => transformRecordToSdkNames(r, fieldMappings))
|
|
187
205
|
.filter((r) => r !== undefined)
|
|
188
|
-
.map(
|
|
206
|
+
.map(record => {
|
|
189
207
|
// Both flat and nested fields, for backwards compatibility.
|
|
190
208
|
const { id, ...fields } = record;
|
|
191
209
|
return { id, ...fields, fields };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HostRequestState } from '../../types.js';
|
|
2
|
+
/** The app's own data dispatch's requests, to base-runner on the token, which says the base, mode and user. */
|
|
3
|
+
export declare const dataFetch: (host: HostRequestState) => ({ method, path, body, }: {
|
|
4
|
+
method: string;
|
|
5
|
+
path: string;
|
|
6
|
+
body?: string;
|
|
7
|
+
}) => Promise<Response>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { requireAccess, sendOnToken } from '../transport.js';
|
|
2
|
+
/** The app's own data dispatch's requests, to base-runner on the token, which says the base, mode and user. */
|
|
3
|
+
export const dataFetch = (host) => async ({ method, path, body, }) => {
|
|
4
|
+
const access = await requireAccess(host);
|
|
5
|
+
return sendOnToken(access.token, `${access.urls.baseRunner}${path}`, {
|
|
6
|
+
method,
|
|
7
|
+
body,
|
|
8
|
+
});
|
|
9
|
+
};
|