zitejs 0.10.0-start.8 → 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 +44 -1
- package/dist/cjs/check/index.js +188 -113
- 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/{esm/start → cjs/start/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 +44 -1
- package/dist/esm/check/index.js +187 -116
- 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/describe.d.ts +120 -0
- package/dist/esm/start/describe/describe.js +372 -0
- package/dist/{cjs/start → esm/start/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 +20 -4
- package/dist/esm/start/errors.js +90 -26
- 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 -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 +2 -2
- package/dist/esm/start/host.js +3 -3
- package/dist/esm/start/index.d.ts +10 -63
- package/dist/esm/start/index.js +7 -149
- 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 +28 -4
- package/dist/esm/start/router.js +224 -21
- 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/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/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.d.ts +0 -80
- package/dist/esm/start/describe.js +0 -197
- 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 -50
- package/dist/esm/start/workflow.js +0 -13
- package/dist/esm/start/workflow.test-d.js +0 -39
- 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
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// the schema is the lock's (`nameMappings`), as the build bakes it; the per-base limiter is gone.
|
|
5
|
-
import { filtersToFormula as buildFiltersFormula } from "./formulas.js";
|
|
6
|
-
const SDK_ID_FIELD = "id";
|
|
7
|
-
const UNIQUE_RECORD_ID_KEY = "recordID";
|
|
1
|
+
import { filtersToFormula as buildFiltersFormula, isRecordId, } from './formulas.js';
|
|
2
|
+
const SDK_ID_FIELD = 'id';
|
|
3
|
+
const UNIQUE_RECORD_ID_KEY = 'recordID';
|
|
8
4
|
const AIRTABLE_BATCH_SIZE = 10;
|
|
9
5
|
/** The npm SDK's error, whose shape apps (and the goldens) see: not an `Error`. */
|
|
10
6
|
export class AirtableError {
|
|
@@ -17,7 +13,13 @@ export class AirtableError {
|
|
|
17
13
|
this.statusCode = statusCode;
|
|
18
14
|
}
|
|
19
15
|
toString() {
|
|
20
|
-
return [
|
|
16
|
+
return [
|
|
17
|
+
this.message,
|
|
18
|
+
'(',
|
|
19
|
+
this.error,
|
|
20
|
+
')',
|
|
21
|
+
this.statusCode ? `[Http code ${this.statusCode}]` : '',
|
|
22
|
+
].join('');
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
// =============================================================================
|
|
@@ -45,7 +47,8 @@ function transformFiltersToFieldIds(filters, fieldMappings) {
|
|
|
45
47
|
const ids = sdkNameToFieldId(fieldMappings);
|
|
46
48
|
const result = {};
|
|
47
49
|
for (const [key, value] of Object.entries(filters)) {
|
|
48
|
-
result[key ===
|
|
50
|
+
result[key === 'id' || key === SDK_ID_FIELD ? key : (ids[key] ?? key)] =
|
|
51
|
+
value;
|
|
49
52
|
}
|
|
50
53
|
return result;
|
|
51
54
|
}
|
|
@@ -55,7 +58,7 @@ function transformRecordToFieldIds(record, fieldMappings) {
|
|
|
55
58
|
const ids = sdkNameToFieldId(fieldMappings);
|
|
56
59
|
const result = {};
|
|
57
60
|
for (const [key, value] of Object.entries(record)) {
|
|
58
|
-
if (key ===
|
|
61
|
+
if (key === 'id' || key === SDK_ID_FIELD || key === UNIQUE_RECORD_ID_KEY)
|
|
59
62
|
continue;
|
|
60
63
|
result[ids[key] ?? key] = value;
|
|
61
64
|
}
|
|
@@ -69,7 +72,7 @@ export function airtableRecordToSdkNames(record, fieldMappings) {
|
|
|
69
72
|
const names = fieldIdToSdkName(fieldMappings);
|
|
70
73
|
const result = {};
|
|
71
74
|
for (const [key, value] of Object.entries(record)) {
|
|
72
|
-
if (key ===
|
|
75
|
+
if (key === 'id' || key === UNIQUE_RECORD_ID_KEY) {
|
|
73
76
|
result[key] = value;
|
|
74
77
|
continue;
|
|
75
78
|
}
|
|
@@ -77,21 +80,19 @@ export function airtableRecordToSdkNames(record, fieldMappings) {
|
|
|
77
80
|
}
|
|
78
81
|
return result;
|
|
79
82
|
}
|
|
80
|
-
/** The table's fields as zite.lock records them
|
|
83
|
+
/** The table's fields as zite.lock records them. */
|
|
81
84
|
const lockSchema = (tableId, table) => {
|
|
82
85
|
if (!table)
|
|
83
86
|
return undefined;
|
|
84
|
-
const fields = Object.entries(table.fields).
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
: []);
|
|
94
|
-
return fields.length ? { id: tableId, primaryFieldId: table.primaryFieldId, fields } : undefined;
|
|
87
|
+
const fields = Object.entries(table.fields).map(([id, field]) => ({
|
|
88
|
+
id,
|
|
89
|
+
name: field.fieldName,
|
|
90
|
+
type: field.fieldType,
|
|
91
|
+
...(field.fieldOptions ? { options: field.fieldOptions } : {}),
|
|
92
|
+
}));
|
|
93
|
+
return fields.length
|
|
94
|
+
? { id: tableId, primaryFieldId: table.primaryFieldId, fields }
|
|
95
|
+
: undefined;
|
|
95
96
|
};
|
|
96
97
|
// =============================================================================
|
|
97
98
|
// Values
|
|
@@ -102,23 +103,25 @@ function processColumnValues(columnValues, tableSchema) {
|
|
|
102
103
|
return columnValues;
|
|
103
104
|
const result = { ...columnValues };
|
|
104
105
|
for (const columnId of Object.keys(columnValues)) {
|
|
105
|
-
const field = tableSchema.fields.find(
|
|
106
|
+
const field = tableSchema.fields.find(f => f.id === columnId || f.name === columnId);
|
|
106
107
|
if (!field)
|
|
107
108
|
continue;
|
|
108
109
|
const value = columnValues[columnId];
|
|
109
110
|
if (value === undefined || value === null)
|
|
110
111
|
continue;
|
|
111
112
|
// An empty object means an unmapped field.
|
|
112
|
-
if (typeof value ===
|
|
113
|
+
if (typeof value === 'object' &&
|
|
114
|
+
!Array.isArray(value) &&
|
|
115
|
+
Object.keys(value).length === 0) {
|
|
113
116
|
result[columnId] = undefined;
|
|
114
117
|
continue;
|
|
115
118
|
}
|
|
116
|
-
if (field.type ===
|
|
119
|
+
if (field.type === 'multipleRecordLinks') {
|
|
117
120
|
if (!Array.isArray(value))
|
|
118
|
-
result[columnId] = value ===
|
|
121
|
+
result[columnId] = value === '' ? [] : [value];
|
|
119
122
|
}
|
|
120
|
-
else if (field.type ===
|
|
121
|
-
if (value ===
|
|
123
|
+
else if (field.type === 'date' || field.type === 'dateTime') {
|
|
124
|
+
if (value === '') {
|
|
122
125
|
result[columnId] = undefined;
|
|
123
126
|
}
|
|
124
127
|
else {
|
|
@@ -126,7 +129,7 @@ function processColumnValues(columnValues, tableSchema) {
|
|
|
126
129
|
if (isNaN(dateValue.getTime())) {
|
|
127
130
|
throw new Error(`Invalid date provided for field ${field.name}: ${value}`);
|
|
128
131
|
}
|
|
129
|
-
if (field.type ===
|
|
132
|
+
if (field.type === 'date') {
|
|
130
133
|
const startOfDay = new Date(dateValue);
|
|
131
134
|
startOfDay.setUTCHours(0, 0, 0, 0);
|
|
132
135
|
result[columnId] = startOfDay.toISOString();
|
|
@@ -136,34 +139,38 @@ function processColumnValues(columnValues, tableSchema) {
|
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
|
-
else if (field.type ===
|
|
142
|
+
else if (field.type === 'multipleAttachments') {
|
|
140
143
|
if (Array.isArray(value) && value.length !== 0) {
|
|
141
144
|
const attachments = value
|
|
142
|
-
.map(
|
|
143
|
-
if (!v || typeof v !==
|
|
145
|
+
.map(v => {
|
|
146
|
+
if (!v || typeof v !== 'object' || !v.url)
|
|
144
147
|
return undefined;
|
|
145
|
-
return {
|
|
148
|
+
return {
|
|
149
|
+
url: v.url,
|
|
150
|
+
filename: v.filename || v.url.split('/').pop(),
|
|
151
|
+
};
|
|
146
152
|
})
|
|
147
|
-
.filter(
|
|
153
|
+
.filter(v => v !== undefined);
|
|
148
154
|
if (attachments.length > 0)
|
|
149
155
|
result[columnId] = attachments;
|
|
150
156
|
}
|
|
151
157
|
}
|
|
152
|
-
else if (field.type ===
|
|
158
|
+
else if (field.type === 'rating') {
|
|
153
159
|
const max = field.options?.max;
|
|
154
|
-
if (max && typeof value ===
|
|
160
|
+
if (max && typeof value === 'number' && value > max) {
|
|
155
161
|
throw new Error(`Value ${value} surpasses Airtable max value setting on the rating field "${field.name}"`);
|
|
156
162
|
}
|
|
157
|
-
if (typeof value ===
|
|
163
|
+
if (typeof value === 'number' && value <= 0)
|
|
158
164
|
result[columnId] = undefined;
|
|
159
165
|
}
|
|
160
|
-
else if (field.type ===
|
|
166
|
+
else if (field.type === 'singleLineText' ||
|
|
167
|
+
field.type === 'multilineText') {
|
|
161
168
|
if (Array.isArray(value))
|
|
162
|
-
result[columnId] = value.join(
|
|
163
|
-
else if (typeof value !==
|
|
169
|
+
result[columnId] = value.join(', ');
|
|
170
|
+
else if (typeof value !== 'string')
|
|
164
171
|
result[columnId] = String(value);
|
|
165
172
|
}
|
|
166
|
-
else if (field.type ===
|
|
173
|
+
else if (field.type === 'barcode') {
|
|
167
174
|
result[columnId] = String(value);
|
|
168
175
|
}
|
|
169
176
|
}
|
|
@@ -177,46 +184,66 @@ export function formatAirtableDuration(durationSeconds) {
|
|
|
177
184
|
const minutes = Math.floor((duration % 3600) / 60);
|
|
178
185
|
const seconds = Math.floor(duration % 60);
|
|
179
186
|
const milliseconds = Math.round((duration % 1) * 1000);
|
|
180
|
-
const fraction = milliseconds > 0
|
|
181
|
-
|
|
187
|
+
const fraction = milliseconds > 0
|
|
188
|
+
? `.${`${milliseconds}`.padStart(3, '0').replace(/0+$/, '')}`
|
|
189
|
+
: '';
|
|
190
|
+
return `${durationSeconds < 0 ? '-' : ''}${pad(hours)}:${pad(minutes)}:${pad(seconds)}${fraction}`;
|
|
182
191
|
}
|
|
183
|
-
const isErrorObject = (value) => typeof value ===
|
|
184
|
-
|
|
192
|
+
const isErrorObject = (value) => typeof value === 'object' &&
|
|
193
|
+
value !== null &&
|
|
194
|
+
typeof value.error === 'string';
|
|
195
|
+
const isNaNValue = (value) => typeof value === 'object' &&
|
|
196
|
+
value !== null &&
|
|
197
|
+
value.specialValue === 'NaN';
|
|
185
198
|
/** For reads: durations, barcodes, AI text, buttons, broken formulas and rollups. */
|
|
186
199
|
function getRecordFields(rawRecord, tableSchema) {
|
|
187
200
|
const fields = { ...rawRecord.fields };
|
|
188
201
|
if (tableSchema) {
|
|
189
202
|
for (const fieldId of Object.keys(fields)) {
|
|
190
203
|
const value = fields[fieldId];
|
|
191
|
-
const field = tableSchema.fields.find(
|
|
204
|
+
const field = tableSchema.fields.find(f => f.id === fieldId);
|
|
192
205
|
if (!field)
|
|
193
206
|
continue;
|
|
194
|
-
if (field.type ===
|
|
195
|
-
if (value ===
|
|
196
|
-
fields[fieldId] =
|
|
207
|
+
if (field.type === 'multilineText' || field.type === 'richText') {
|
|
208
|
+
if (value === '\n')
|
|
209
|
+
fields[fieldId] = '';
|
|
197
210
|
}
|
|
198
|
-
else if (field.type ===
|
|
199
|
-
|
|
211
|
+
else if (field.type === 'barcode' &&
|
|
212
|
+
value &&
|
|
213
|
+
typeof value === 'object') {
|
|
214
|
+
fields[fieldId] = value.text || '';
|
|
200
215
|
}
|
|
201
|
-
else if (field.type ===
|
|
216
|
+
else if (field.type === 'duration' && typeof value === 'number') {
|
|
202
217
|
fields[fieldId] = formatAirtableDuration(value);
|
|
203
218
|
}
|
|
204
|
-
else if (field.type ===
|
|
219
|
+
else if (field.type === 'button' &&
|
|
220
|
+
value &&
|
|
221
|
+
typeof value === 'object') {
|
|
205
222
|
fields[fieldId] = value.url;
|
|
206
223
|
}
|
|
207
|
-
else if (field.type ===
|
|
224
|
+
else if (field.type === 'aiText' &&
|
|
225
|
+
value &&
|
|
226
|
+
typeof value === 'object') {
|
|
208
227
|
const text = value.value;
|
|
209
|
-
fields[fieldId] =
|
|
228
|
+
fields[fieldId] =
|
|
229
|
+
text !== undefined && text !== null && text !== '' ? text : undefined;
|
|
210
230
|
}
|
|
211
|
-
else if (field.type ===
|
|
212
|
-
const numeric = field.options?.result
|
|
213
|
-
|
|
231
|
+
else if (field.type === 'formula') {
|
|
232
|
+
const numeric = field.options?.result
|
|
233
|
+
?.type === 'number';
|
|
234
|
+
if ((numeric && typeof value !== 'number') ||
|
|
235
|
+
isNaNValue(value) ||
|
|
236
|
+
isErrorObject(value)) {
|
|
214
237
|
fields[fieldId] = undefined;
|
|
215
238
|
}
|
|
216
239
|
}
|
|
217
|
-
else if (field.type ===
|
|
218
|
-
const numeric = field.options?.rollup
|
|
219
|
-
|
|
240
|
+
else if (field.type === 'rollup') {
|
|
241
|
+
const numeric = field.options?.rollup
|
|
242
|
+
?.type === 'number';
|
|
243
|
+
if ((numeric && typeof value !== 'number') ||
|
|
244
|
+
isNaNValue(value) ||
|
|
245
|
+
isErrorObject(value) ||
|
|
246
|
+
value === null) {
|
|
220
247
|
fields[fieldId] = undefined;
|
|
221
248
|
}
|
|
222
249
|
}
|
|
@@ -227,36 +254,37 @@ function getRecordFields(rawRecord, tableSchema) {
|
|
|
227
254
|
// =============================================================================
|
|
228
255
|
// Requests
|
|
229
256
|
// =============================================================================
|
|
230
|
-
const sleepMs = (ms) => new Promise(
|
|
257
|
+
const sleepMs = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
231
258
|
// As the npm SDK raises it (`_checkStatusForError`, `_getErrorForNonObjectBody`).
|
|
232
259
|
const sdkError = async (response) => {
|
|
233
260
|
const status = response.status;
|
|
234
261
|
const body = await response.json().catch(() => undefined);
|
|
235
|
-
const { type, message } = (body?.error ??
|
|
262
|
+
const { type, message } = (body?.error ??
|
|
263
|
+
{});
|
|
236
264
|
if (status === 401) {
|
|
237
|
-
return new AirtableError(
|
|
265
|
+
return new AirtableError('AUTHENTICATION_REQUIRED', 'You should provide valid api key to perform this operation', status);
|
|
238
266
|
}
|
|
239
267
|
if (status === 403)
|
|
240
|
-
return new AirtableError(
|
|
268
|
+
return new AirtableError('NOT_AUTHORIZED', 'You are not authorized to perform this operation', status);
|
|
241
269
|
if (status === 404)
|
|
242
|
-
return new AirtableError(
|
|
270
|
+
return new AirtableError('NOT_FOUND', message ?? 'Could not find what you are looking for', status);
|
|
243
271
|
if (status === 413)
|
|
244
|
-
return new AirtableError(
|
|
272
|
+
return new AirtableError('REQUEST_TOO_LARGE', 'Request body is too large', status);
|
|
245
273
|
if (status === 422) {
|
|
246
|
-
return new AirtableError(type ??
|
|
274
|
+
return new AirtableError(type ?? 'UNPROCESSABLE_ENTITY', message ?? 'The operation cannot be processed', status);
|
|
247
275
|
}
|
|
248
276
|
if (status === 429) {
|
|
249
|
-
return new AirtableError(
|
|
277
|
+
return new AirtableError('TOO_MANY_REQUESTS', 'You have made too many requests in a short period of time. Please retry your request later', status);
|
|
250
278
|
}
|
|
251
279
|
if (status === 500)
|
|
252
|
-
return new AirtableError(
|
|
280
|
+
return new AirtableError('SERVER_ERROR', 'Try again. If the problem persists, contact support.', status);
|
|
253
281
|
if (status === 503) {
|
|
254
|
-
return new AirtableError(
|
|
282
|
+
return new AirtableError('SERVICE_UNAVAILABLE', 'The service is temporarily unavailable. Please retry shortly.', status);
|
|
255
283
|
}
|
|
256
|
-
if (typeof body !==
|
|
257
|
-
return new AirtableError(
|
|
284
|
+
if (typeof body !== 'object' || body === null || Array.isArray(body)) {
|
|
285
|
+
return new AirtableError('UNEXPECTED_ERROR', 'The response from Airtable was invalid JSON. Please try again soon.', status);
|
|
258
286
|
}
|
|
259
|
-
return new AirtableError(type ??
|
|
287
|
+
return new AirtableError(type ?? 'UNEXPECTED_ERROR', message ?? 'An unexpected error occurred', status);
|
|
260
288
|
};
|
|
261
289
|
const MIN_RETRY_DELAY_MS = 200;
|
|
262
290
|
/** One bounded backoff on 429s, as classic's: five attempts, jittered over a doubling delay. */
|
|
@@ -268,29 +296,44 @@ async function withBackoff(operation, name, sleep, maxAttempts = 5, startingDela
|
|
|
268
296
|
return await operation();
|
|
269
297
|
}
|
|
270
298
|
catch (error) {
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
299
|
+
const { statusCode, status, message } = (error ?? {});
|
|
300
|
+
const text = typeof message === 'string' ? message : '';
|
|
301
|
+
const rateLimited = statusCode === 429 ||
|
|
302
|
+
status === 429 ||
|
|
303
|
+
text.includes('429') ||
|
|
304
|
+
text.toLowerCase().includes('rate limit');
|
|
275
305
|
if (!rateLimited)
|
|
276
306
|
throw error;
|
|
277
307
|
attempt++;
|
|
278
308
|
if (attempt >= maxAttempts) {
|
|
279
309
|
console.warn(`[Airtable429] ${name} attempt ${attempt}/${maxAttempts}: max retries exhausted, giving up`);
|
|
280
|
-
throw Object.assign(new Error(
|
|
310
|
+
throw Object.assign(new Error('Airtable rate limit exceeded after maximum retries'), {
|
|
281
311
|
status: 429,
|
|
282
312
|
originalError: error,
|
|
283
313
|
});
|
|
284
314
|
}
|
|
285
|
-
const jittered = MIN_RETRY_DELAY_MS +
|
|
315
|
+
const jittered = MIN_RETRY_DELAY_MS +
|
|
316
|
+
Math.floor(Math.random() * (delay - MIN_RETRY_DELAY_MS));
|
|
286
317
|
console.warn(`[Airtable429] ${name} attempt ${attempt}/${maxAttempts}: retrying in ${jittered}ms`);
|
|
287
318
|
await sleep(jittered);
|
|
288
319
|
delay = Math.min(delay * 2, maxDelay);
|
|
289
320
|
}
|
|
290
321
|
}
|
|
291
|
-
throw new Error(
|
|
322
|
+
throw new Error('Unexpected end of Airtable backoff loop');
|
|
292
323
|
}
|
|
293
324
|
const segment = (id) => encodeURIComponent(id);
|
|
325
|
+
// A record id is a path segment, where `..` would reach past the table, to another one. A linked record's value is a
|
|
326
|
+
// one-item list of its id, which stands for it.
|
|
327
|
+
function asRecordId(id) {
|
|
328
|
+
const single = Array.isArray(id) && id.length === 1 ? id[0] : id;
|
|
329
|
+
return isRecordId(single) ? single : undefined;
|
|
330
|
+
}
|
|
331
|
+
function recordIdFor(action, id) {
|
|
332
|
+
const recordId = asRecordId(id);
|
|
333
|
+
if (!recordId)
|
|
334
|
+
throw new Error(`Can't ${action} Airtable record ${JSON.stringify(id)}: it isn't a record id.`);
|
|
335
|
+
return recordId;
|
|
336
|
+
}
|
|
294
337
|
// =============================================================================
|
|
295
338
|
// Dispatch
|
|
296
339
|
// =============================================================================
|
|
@@ -298,34 +341,42 @@ const segment = (id) => encodeURIComponent(id);
|
|
|
298
341
|
export async function executeAirtableCall(context, methodName, params) {
|
|
299
342
|
const tableId = params?.tableId;
|
|
300
343
|
if (!tableId)
|
|
301
|
-
throw new Error(
|
|
344
|
+
throw new Error('Airtable calls require tableId in params');
|
|
302
345
|
const baseId = context.settings.baseId || params.baseId;
|
|
303
346
|
if (!baseId)
|
|
304
|
-
throw new Error(
|
|
347
|
+
throw new Error('Airtable calls require baseId (from integration settings or params)');
|
|
305
348
|
const tables = context.settings.nameMappings?.bases?.[baseId]?.tables;
|
|
306
349
|
const fieldMappings = tables?.[tableId]?.fields;
|
|
307
350
|
const tableSchema = lockSchema(tableId, tables?.[tableId]);
|
|
308
351
|
const sleep = context.sleep ?? sleepMs;
|
|
309
352
|
const tablePath = `/v0/${segment(baseId)}/${segment(tableId)}`;
|
|
310
|
-
// A write makes any read this request already made stale.
|
|
353
|
+
// A write makes any read this request already made stale, and the table's reads stale across requests.
|
|
311
354
|
const send = async (path, init) => {
|
|
312
|
-
|
|
355
|
+
const writes = init.method !== 'GET' && !path.endsWith('/listRecords');
|
|
356
|
+
if (writes)
|
|
313
357
|
context.reads?.clear();
|
|
314
|
-
|
|
358
|
+
const response = await context.fetch(path, init);
|
|
359
|
+
if (writes && response.ok)
|
|
360
|
+
await context.cache?.wrote(`${baseId}:${tableId}`);
|
|
361
|
+
return response;
|
|
315
362
|
};
|
|
316
|
-
const read = (key, load) => {
|
|
363
|
+
const read = (readTableId, key, load) => {
|
|
364
|
+
const cache = context.cache;
|
|
365
|
+
const loadKept = cache
|
|
366
|
+
? () => cache.read(`${baseId}:${readTableId}`, key, load)
|
|
367
|
+
: load;
|
|
317
368
|
if (!context.reads)
|
|
318
|
-
return
|
|
369
|
+
return loadKept();
|
|
319
370
|
const held = context.reads.get(key);
|
|
320
371
|
if (held)
|
|
321
372
|
return held;
|
|
322
|
-
const loading =
|
|
373
|
+
const loading = loadKept();
|
|
323
374
|
context.reads.set(key, loading);
|
|
324
375
|
loading.catch(() => context.reads?.delete(key));
|
|
325
376
|
return loading;
|
|
326
377
|
};
|
|
327
|
-
const getRecord = (recordTableId, recordId) => read(`get:${baseId}:${recordTableId}:${recordId}`, async () => {
|
|
328
|
-
const response = await send(`/v0/${segment(baseId)}/${segment(recordTableId)}/${segment(recordId)}?returnFieldsByFieldId=true`, { method:
|
|
378
|
+
const getRecord = (recordTableId, recordId) => read(recordTableId, `get:${baseId}:${recordTableId}:${recordId}`, async () => {
|
|
379
|
+
const response = await send(`/v0/${segment(baseId)}/${segment(recordTableId)}/${segment(recordId)}?returnFieldsByFieldId=true`, { method: 'GET' });
|
|
329
380
|
if (!response.ok)
|
|
330
381
|
throw await sdkError(response);
|
|
331
382
|
return (await response.json());
|
|
@@ -339,10 +390,14 @@ export async function executeAirtableCall(context, methodName, params) {
|
|
|
339
390
|
// A linked-record filter names the record by its primary field, which costs a lookup each.
|
|
340
391
|
const getPrimaryFieldForRecord = async (linkedTableId, recordId) => {
|
|
341
392
|
try {
|
|
342
|
-
const record = await withBackoff(() => getRecord(linkedTableId, recordId),
|
|
393
|
+
const record = await withBackoff(() => getRecord(linkedTableId, recordId), 'linkedRecord', sleep);
|
|
343
394
|
const primaryFieldId = tables?.[linkedTableId]?.primaryFieldId;
|
|
344
|
-
const value = primaryFieldId !== undefined
|
|
345
|
-
|
|
395
|
+
const value = primaryFieldId !== undefined
|
|
396
|
+
? record.fields[primaryFieldId]
|
|
397
|
+
: Object.values(record.fields)[0];
|
|
398
|
+
return value !== undefined && value !== null
|
|
399
|
+
? String(value)
|
|
400
|
+
: undefined;
|
|
346
401
|
}
|
|
347
402
|
catch {
|
|
348
403
|
return undefined;
|
|
@@ -356,12 +411,16 @@ export async function executeAirtableCall(context, methodName, params) {
|
|
|
356
411
|
};
|
|
357
412
|
const toSdk = (record) => airtableRecordToSdkNames(getRecordFields(record, tableSchema), fieldMappings);
|
|
358
413
|
switch (methodName) {
|
|
359
|
-
case
|
|
414
|
+
case 'findOne': {
|
|
360
415
|
const { id, filters } = params;
|
|
361
416
|
if (id) {
|
|
417
|
+
// Any other id names no record, and in the path could name another table's.
|
|
418
|
+
const recordId = asRecordId(id);
|
|
419
|
+
if (!recordId)
|
|
420
|
+
return undefined;
|
|
362
421
|
return withBackoff(async () => {
|
|
363
422
|
try {
|
|
364
|
-
return toSdk(await getRecord(tableId,
|
|
423
|
+
return toSdk(await getRecord(tableId, recordId));
|
|
365
424
|
}
|
|
366
425
|
catch (error) {
|
|
367
426
|
// A missing record is no record; 401 and 403 go up, where the platform refreshes a token.
|
|
@@ -369,15 +428,18 @@ export async function executeAirtableCall(context, methodName, params) {
|
|
|
369
428
|
return undefined;
|
|
370
429
|
throw error;
|
|
371
430
|
}
|
|
372
|
-
},
|
|
431
|
+
}, 'findOne', sleep);
|
|
373
432
|
}
|
|
374
433
|
const filterByFormula = await filterFormula(filters);
|
|
375
434
|
return withBackoff(async () => {
|
|
376
|
-
const list = await listRecords({
|
|
435
|
+
const list = await listRecords({
|
|
436
|
+
maxRecords: 1,
|
|
437
|
+
...(filterByFormula ? { filterByFormula } : {}),
|
|
438
|
+
});
|
|
377
439
|
return list.records.length === 0 ? undefined : toSdk(list.records[0]);
|
|
378
|
-
},
|
|
440
|
+
}, 'findOne', sleep);
|
|
379
441
|
}
|
|
380
|
-
case
|
|
442
|
+
case 'findAll': {
|
|
381
443
|
const { filters, limit, offset } = params;
|
|
382
444
|
const filterByFormula = await filterFormula(filters);
|
|
383
445
|
return withBackoff(async () => {
|
|
@@ -387,23 +449,25 @@ export async function executeAirtableCall(context, methodName, params) {
|
|
|
387
449
|
...(offset ? { offset } : {}),
|
|
388
450
|
});
|
|
389
451
|
return {
|
|
390
|
-
records: (json.records || [])
|
|
452
|
+
records: (json.records || [])
|
|
453
|
+
.map(toSdk)
|
|
454
|
+
.filter(r => r !== undefined),
|
|
391
455
|
offset: json.offset,
|
|
392
456
|
hasMore: json.offset !== undefined,
|
|
393
457
|
};
|
|
394
|
-
},
|
|
458
|
+
}, 'findAll', sleep);
|
|
395
459
|
}
|
|
396
|
-
case
|
|
460
|
+
case 'create': {
|
|
397
461
|
const { record } = params;
|
|
398
462
|
if (!record)
|
|
399
463
|
return undefined;
|
|
400
464
|
return withBackoff(async () => {
|
|
401
465
|
const fields = processColumnValues(transformRecordToFieldIds(record, fieldMappings) || record, tableSchema);
|
|
402
|
-
const [created] = await writeRecords(
|
|
466
|
+
const [created] = await writeRecords('POST', [{ fields }]);
|
|
403
467
|
return toSdk(created);
|
|
404
|
-
},
|
|
468
|
+
}, 'create', sleep);
|
|
405
469
|
}
|
|
406
|
-
case
|
|
470
|
+
case 'bulkCreate': {
|
|
407
471
|
const { records } = params;
|
|
408
472
|
if (!records || records.length === 0)
|
|
409
473
|
return [];
|
|
@@ -413,41 +477,50 @@ export async function executeAirtableCall(context, methodName, params) {
|
|
|
413
477
|
}));
|
|
414
478
|
const results = [];
|
|
415
479
|
for (let i = 0; i < prepared.length; i += AIRTABLE_BATCH_SIZE) {
|
|
416
|
-
const created = await withBackoff(() => writeRecords(
|
|
480
|
+
const created = await withBackoff(() => writeRecords('POST', prepared.slice(i, i + AIRTABLE_BATCH_SIZE)), 'bulkCreate', sleep);
|
|
417
481
|
for (const r of created)
|
|
418
482
|
results.push(toSdk(r));
|
|
419
483
|
}
|
|
420
484
|
return results;
|
|
421
485
|
}
|
|
422
|
-
case
|
|
486
|
+
case 'update': {
|
|
423
487
|
const { id, record } = params;
|
|
424
488
|
if (!id || !record)
|
|
425
489
|
return undefined;
|
|
490
|
+
const recordId = recordIdFor('update', id);
|
|
426
491
|
return withBackoff(async () => {
|
|
427
492
|
const fields = processColumnValues(transformRecordToFieldIds(record, fieldMappings) || record, tableSchema);
|
|
428
|
-
const [updated] = await writeRecords(
|
|
429
|
-
|
|
430
|
-
|
|
493
|
+
const [updated] = await writeRecords('PATCH', [
|
|
494
|
+
{ id: recordId, fields },
|
|
495
|
+
]);
|
|
496
|
+
return { id: recordId, fields: toSdk(updated) };
|
|
497
|
+
}, 'update', sleep);
|
|
431
498
|
}
|
|
432
|
-
case
|
|
499
|
+
case 'delete': {
|
|
433
500
|
const { id } = params;
|
|
434
501
|
if (!id)
|
|
435
|
-
throw new Error(
|
|
502
|
+
throw new Error('Delete requires id parameter');
|
|
503
|
+
const recordId = recordIdFor('delete', id);
|
|
436
504
|
return withBackoff(async () => {
|
|
437
|
-
const response = await send(`${tablePath}/${segment(
|
|
505
|
+
const response = await send(`${tablePath}/${segment(recordId)}`, {
|
|
506
|
+
method: 'DELETE',
|
|
507
|
+
});
|
|
438
508
|
if (!response.ok)
|
|
439
509
|
throw await sdkError(response);
|
|
440
510
|
const deleted = (await response.json());
|
|
441
511
|
return { success: true, id: deleted.id };
|
|
442
|
-
},
|
|
512
|
+
}, 'delete', sleep);
|
|
443
513
|
}
|
|
444
514
|
default:
|
|
445
515
|
throw new Error(`Unknown Airtable method: ${methodName}`);
|
|
446
516
|
}
|
|
447
517
|
async function listRecords(body) {
|
|
448
518
|
const request = { returnFieldsByFieldId: true, ...body };
|
|
449
|
-
return read(`list:${baseId}:${tableId}:${JSON.stringify(request)}`, async () => {
|
|
450
|
-
const response = await send(`${tablePath}/listRecords`, {
|
|
519
|
+
return read(tableId, `list:${baseId}:${tableId}:${JSON.stringify(request)}`, async () => {
|
|
520
|
+
const response = await send(`${tablePath}/listRecords`, {
|
|
521
|
+
method: 'POST',
|
|
522
|
+
body: request,
|
|
523
|
+
});
|
|
451
524
|
if (!response.ok) {
|
|
452
525
|
const error = new Error(`Airtable API error: ${await response.text()}`);
|
|
453
526
|
error.statusCode = response.status;
|
|
@@ -457,7 +530,10 @@ export async function executeAirtableCall(context, methodName, params) {
|
|
|
457
530
|
});
|
|
458
531
|
}
|
|
459
532
|
async function writeRecords(method, records) {
|
|
460
|
-
const response = await send(tablePath, {
|
|
533
|
+
const response = await send(tablePath, {
|
|
534
|
+
method,
|
|
535
|
+
body: { records, typecast: true, returnFieldsByFieldId: true },
|
|
536
|
+
});
|
|
461
537
|
if (!response.ok)
|
|
462
538
|
throw await sdkError(response);
|
|
463
539
|
return (await response.json()).records;
|
|
@@ -26,7 +26,8 @@ export declare const isNestedCondition: (value: unknown) => value is Partial<Rec
|
|
|
26
26
|
/**
|
|
27
27
|
* Check if a string is a valid Airtable record ID
|
|
28
28
|
*/
|
|
29
|
-
export declare const isValidRecordId: (value:
|
|
29
|
+
export declare const isValidRecordId: (value: unknown) => value is string;
|
|
30
|
+
export declare const isRecordId: (value: unknown) => value is string;
|
|
30
31
|
export type FiltersToFormulaOptions = {
|
|
31
32
|
/**
|
|
32
33
|
* Filters object with field names as keys.
|