zitejs 0.9.153 → 0.9.154
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 +6 -6
- package/dist/cjs/backend/index.js +13 -13
- package/dist/cjs/backend/index.test.js +102 -102
- package/dist/cjs/bundle/index.js +29 -16
- package/dist/cjs/caller/index.js +43 -43
- package/dist/cjs/check/index.d.ts +44 -1
- package/dist/cjs/check/index.js +198 -61
- 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 +19 -6
- package/dist/cjs/client/index.d.ts +2 -2
- package/dist/cjs/client/index.js +25 -25
- package/dist/cjs/dev/index.js +81 -53
- 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.js +42 -42
- package/dist/cjs/integrations/rules.test.js +60 -55
- 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 +22 -22
- package/dist/cjs/runtime/index.js +28 -28
- package/dist/cjs/runtime/index.test.js +34 -34
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +29 -29
- 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/build/entries.d.ts +25 -0
- package/dist/cjs/start/build/entries.js +121 -0
- 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/describe/describeBuilt.d.ts +5 -0
- package/dist/cjs/start/describe/describeBuilt.js +144 -0
- 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 +8 -8
- package/dist/cjs/steps/index.js +53 -53
- package/dist/cjs/steps/index.test.js +218 -218
- 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 +651 -665
- package/dist/cjs/sync/lib.test.js +81 -14
- 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 +1 -1
- package/dist/cjs/types/fields.js +105 -97
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/tables.d.ts +1 -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 +51 -42
- package/dist/cjs/vite/index.test.js +10 -2
- 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 +6 -6
- package/dist/esm/backend/index.js +13 -13
- package/dist/esm/backend/index.test.js +106 -106
- package/dist/esm/bundle/index.js +29 -16
- package/dist/esm/caller/index.js +44 -44
- package/dist/esm/check/index.d.ts +44 -1
- package/dist/esm/check/index.js +194 -61
- 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 +19 -6
- package/dist/esm/client/index.d.ts +2 -2
- package/dist/esm/client/index.js +25 -25
- package/dist/esm/dev/index.js +88 -60
- 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.js +42 -42
- package/dist/esm/integrations/rules.test.js +62 -57
- 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 +22 -22
- package/dist/esm/runtime/index.js +31 -31
- package/dist/esm/runtime/index.test.js +36 -36
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +30 -30
- 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/automations/registration.d.ts +13 -0
- package/dist/esm/start/automations/registration.js +25 -0
- 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/build/entries.d.ts +25 -0
- package/dist/esm/start/build/entries.js +109 -0
- package/dist/esm/start/build/placeholders/authHooksModule.d.ts +1 -0
- package/dist/esm/start/build/placeholders/authHooksModule.js +3 -0
- 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/build/placeholders/workflowModules.d.ts +1 -0
- package/dist/esm/start/build/placeholders/workflowModules.js +3 -0
- 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/clientErrorMessage.test.d.ts +1 -0
- package/dist/esm/start/clientErrorMessage.test.js +105 -0
- package/dist/esm/start/describe/describe.d.ts +120 -0
- package/dist/esm/start/describe/describe.js +372 -0
- package/dist/esm/start/describe/describeBuilt.d.ts +5 -0
- package/dist/esm/start/describe/describeBuilt.js +102 -0
- package/dist/esm/start/describe/descriptions.d.ts +4 -0
- package/dist/esm/start/describe/descriptions.js +54 -0
- package/dist/esm/start/errors.d.ts +62 -0
- package/dist/esm/start/errors.js +163 -0
- package/dist/esm/start/errors.test.d.ts +1 -0
- package/dist/esm/start/errors.test.js +54 -0
- package/dist/esm/start/factories.d.ts +14 -0
- package/dist/esm/start/factories.js +23 -0
- package/dist/esm/start/factories.test-d.d.ts +2 -0
- package/dist/esm/start/factories.test-d.js +60 -0
- package/dist/esm/start/failures.d.ts +7 -0
- package/dist/esm/start/failures.js +62 -0
- package/dist/esm/start/fnFactory.d.ts +16 -0
- package/dist/esm/start/fnFactory.js +1 -0
- package/dist/esm/start/host.d.ts +3 -0
- package/dist/esm/start/host.js +4 -0
- package/dist/esm/start/index.d.ts +10 -0
- package/dist/esm/start/index.js +7 -0
- 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/arrayFields.d.ts +10 -0
- package/dist/esm/start/platform/airtable/arrayFields.js +30 -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/platform/airtable/dispatch.d.ts +57 -0
- package/dist/esm/start/platform/airtable/dispatch.js +541 -0
- package/dist/esm/start/platform/airtable/formulas.d.ts +70 -0
- package/dist/esm/start/platform/airtable/formulas.js +261 -0
- 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/platform/data/baseRunner.d.ts +97 -0
- package/dist/esm/start/platform/data/baseRunner.js +117 -0
- package/dist/esm/start/platform/data/dispatch.d.ts +17 -0
- package/dist/esm/start/platform/data/dispatch.js +216 -0
- 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/platform/data/sqlNameMappings.d.ts +58 -0
- package/dist/esm/start/platform/data/sqlNameMappings.js +92 -0
- package/dist/esm/start/platform/data/transformations.d.ts +97 -0
- package/dist/esm/start/platform/data/transformations.js +262 -0
- package/dist/esm/start/platform/data/types.d.ts +94 -0
- package/dist/esm/start/platform/data/types.js +14 -0
- 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/platform/redactSecrets.js +156 -0
- package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
- package/dist/esm/start/platform/redactSecrets.test.js +151 -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 +6 -0
- package/dist/esm/start/previewClaim.js +24 -0
- 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 +44 -0
- package/dist/esm/start/router.js +280 -0
- package/dist/esm/start/serve/authHooks.d.ts +7 -0
- 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/serve/instance.d.ts +12 -0
- 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 +373 -0
- package/dist/esm/start/types.js +1 -0
- package/dist/esm/start/version.d.ts +1 -0
- package/dist/esm/start/version.js +2 -0
- package/dist/esm/steps/index.d.ts +8 -8
- package/dist/esm/steps/index.js +54 -54
- package/dist/esm/steps/index.test.js +220 -220
- 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 +655 -669
- package/dist/esm/sync/lib.test.js +81 -14
- 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 +1 -1
- package/dist/esm/types/fields.js +106 -98
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/index.js +2 -2
- package/dist/esm/types/tables.d.ts +1 -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 +56 -47
- package/dist/esm/vite/index.test.js +10 -2
- package/package.json +129 -16
- package/dist/cjs/auth-server/index.d.ts +0 -369
- package/dist/cjs/auth-server/index.js +0 -119
- package/dist/cjs/meta/index.d.ts +0 -14
- package/dist/cjs/meta/index.js +0 -12
- package/dist/cjs/notifications/index.d.ts +0 -25
- package/dist/cjs/notifications/index.js +0 -12
- package/dist/esm/auth-server/index.d.ts +0 -369
- package/dist/esm/auth-server/index.js +0 -116
- package/dist/esm/meta/index.d.ts +0 -14
- package/dist/esm/meta/index.js +0 -8
- package/dist/esm/notifications/index.d.ts +0 -25
- package/dist/esm/notifications/index.js +0 -8
|
@@ -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 {};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type BulkCreateResponseType, type FindAllResponseType, type FindOneResponseType, type GetBaseResponseType, type LegacyRecordsFilterClauseType, type NameMappings } from './types.js';
|
|
2
|
+
/** One base-runner request, `path` from `/api/v1`; the platform sends it and answers with base-runner's response. */
|
|
3
|
+
export type DataTransport = (request: {
|
|
4
|
+
method: string;
|
|
5
|
+
path: string;
|
|
6
|
+
body?: string;
|
|
7
|
+
}) => Promise<Response>;
|
|
8
|
+
type Sort = string | Array<{
|
|
9
|
+
field: string;
|
|
10
|
+
direction: 'asc' | 'desc';
|
|
11
|
+
}>;
|
|
12
|
+
/** An id as one path segment: an unencoded `/` or a `..` would move the request to another base's URL. */
|
|
13
|
+
export declare const segment: (id: string | number) => string;
|
|
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>) => {
|
|
20
|
+
bases: {
|
|
21
|
+
get: ({ baseId }: {
|
|
22
|
+
baseId: string;
|
|
23
|
+
}) => Promise<GetBaseResponseType>;
|
|
24
|
+
};
|
|
25
|
+
records: {
|
|
26
|
+
get: ({ baseId, tableId, recordId, fields, }: {
|
|
27
|
+
baseId: string;
|
|
28
|
+
tableId: string;
|
|
29
|
+
recordId: string;
|
|
30
|
+
fields?: string[];
|
|
31
|
+
}) => Promise<FindOneResponseType>;
|
|
32
|
+
findAll: ({ baseId, tableId, filters, offset, sort, limit, fields, }: {
|
|
33
|
+
baseId: string;
|
|
34
|
+
tableId: string;
|
|
35
|
+
filters?: LegacyRecordsFilterClauseType;
|
|
36
|
+
offset?: number;
|
|
37
|
+
sort?: Sort;
|
|
38
|
+
limit?: number;
|
|
39
|
+
fields?: string[];
|
|
40
|
+
}) => Promise<FindAllResponseType>;
|
|
41
|
+
create: ({ baseId, tableId, record, }: {
|
|
42
|
+
baseId: string;
|
|
43
|
+
tableId: string;
|
|
44
|
+
record: Record<string, unknown>;
|
|
45
|
+
}) => Promise<FindOneResponseType>;
|
|
46
|
+
update: ({ baseId, tableId, recordId, record, }: {
|
|
47
|
+
baseId: string;
|
|
48
|
+
tableId: string;
|
|
49
|
+
recordId: string;
|
|
50
|
+
record: Record<string, unknown>;
|
|
51
|
+
}) => Promise<FindOneResponseType>;
|
|
52
|
+
delete: ({ baseId, tableId, recordId, }: {
|
|
53
|
+
baseId: string;
|
|
54
|
+
tableId: string;
|
|
55
|
+
recordId: string;
|
|
56
|
+
}) => Promise<{
|
|
57
|
+
id: string;
|
|
58
|
+
}>;
|
|
59
|
+
bulkCreate: ({ baseId, tableId, records, matchOn, }: {
|
|
60
|
+
baseId: string;
|
|
61
|
+
tableId: string;
|
|
62
|
+
records: Record<string, unknown>[];
|
|
63
|
+
matchOn?: string[];
|
|
64
|
+
}) => Promise<BulkCreateResponseType>;
|
|
65
|
+
};
|
|
66
|
+
sql: {
|
|
67
|
+
execute: ({ baseId, sql, params, statementTimeoutMs, nameMappings, }: {
|
|
68
|
+
baseId: string;
|
|
69
|
+
sql: string;
|
|
70
|
+
params?: unknown[];
|
|
71
|
+
statementTimeoutMs?: number;
|
|
72
|
+
nameMappings?: NameMappings;
|
|
73
|
+
}) => Promise<unknown>;
|
|
74
|
+
};
|
|
75
|
+
auth: {
|
|
76
|
+
findAll: ({ baseId, appIds, filters, filter, offset, sort, limit, }: {
|
|
77
|
+
baseId: string;
|
|
78
|
+
appIds?: string[];
|
|
79
|
+
filters?: LegacyRecordsFilterClauseType;
|
|
80
|
+
filter?: unknown;
|
|
81
|
+
offset?: number;
|
|
82
|
+
sort?: Sort;
|
|
83
|
+
limit?: number;
|
|
84
|
+
}) => Promise<unknown>;
|
|
85
|
+
update: ({ baseId, userId, profile, }: {
|
|
86
|
+
baseId: string;
|
|
87
|
+
userId: string;
|
|
88
|
+
profile: {
|
|
89
|
+
firstName?: string | null;
|
|
90
|
+
lastName?: string | null;
|
|
91
|
+
image?: string | null;
|
|
92
|
+
};
|
|
93
|
+
}) => Promise<unknown>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export type BaseRunner = ReturnType<typeof createBaseRunner>;
|
|
97
|
+
export {};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseRunner } from './baseRunner.js';
|
|
2
|
+
import { type BaseTable, type DataNameMappings } from './types.js';
|
|
3
|
+
export type DataContext = {
|
|
4
|
+
baseRunner: BaseRunner;
|
|
5
|
+
/** The build's base, from the platform; a base id the app sends is ignored. */
|
|
6
|
+
baseId: string;
|
|
7
|
+
nameMappings: DataNameMappings | null;
|
|
8
|
+
/** The base's tables, for field names and SQL names. */
|
|
9
|
+
tables: BaseTable[] | undefined;
|
|
10
|
+
/** A demo: only reads reach the database. */
|
|
11
|
+
readOnly: boolean;
|
|
12
|
+
};
|
|
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>;
|
|
15
|
+
export declare function asZiteClientError(error: unknown): unknown;
|
|
16
|
+
/** One `zite.*` data call, as classic's dispatch runs it. */
|
|
17
|
+
export declare function executeDatabasesCall(context: DataContext, methodName: string, params: any): Promise<any>;
|