zitejs 0.10.0-start.9 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/auth/actions.d.ts +28 -0
- package/dist/cjs/auth/actions.js +93 -0
- package/dist/cjs/auth/client.d.ts +357 -0
- package/dist/cjs/auth/client.js +66 -0
- package/dist/cjs/auth/config.js +9 -3
- package/dist/cjs/auth/index.d.ts +2 -249
- package/dist/cjs/auth/index.js +11 -108
- package/dist/cjs/auth/index.test.js +60 -0
- package/dist/cjs/auth/previewClaim.d.ts +7 -0
- package/dist/cjs/auth/previewClaim.js +16 -0
- package/dist/cjs/auth/profileUpdates.d.ts +9 -0
- package/dist/cjs/auth/profileUpdates.js +11 -0
- package/dist/cjs/backend/index.d.ts +15 -9
- package/dist/cjs/backend/index.js +13 -13
- package/dist/cjs/backend/index.test.js +102 -102
- package/dist/cjs/bundle/index.d.ts +8 -0
- package/dist/cjs/bundle/index.js +38 -24
- package/dist/cjs/caller/index.js +43 -43
- package/dist/cjs/check/index.d.ts +20 -9
- package/dist/cjs/check/index.js +113 -88
- package/dist/cjs/check/start/routeTree.d.ts +8 -0
- package/dist/cjs/check/start/routeTree.js +118 -0
- package/dist/cjs/check/start/tsgo.d.ts +2 -0
- package/dist/cjs/check/start/tsgo.js +35 -0
- package/dist/cjs/cli.js +10 -4
- package/dist/cjs/client/index.d.ts +26 -2
- package/dist/cjs/client/index.js +25 -25
- package/dist/cjs/dev/index.js +79 -54
- package/dist/cjs/dev/signin.d.ts +16 -0
- package/dist/cjs/dev/signin.js +84 -0
- package/dist/cjs/index.d.ts +5 -5
- package/dist/cjs/integrations/client.d.ts +3 -3
- package/dist/cjs/integrations/client.js +5 -4
- package/dist/cjs/integrations/client.test-d.js +15 -15
- package/dist/cjs/integrations/index.d.ts +2 -2
- package/dist/cjs/integrations/rules.d.ts +1 -0
- package/dist/cjs/integrations/rules.js +48 -43
- package/dist/cjs/integrations/rules.test.js +60 -54
- package/dist/cjs/internal/appMode.d.ts +14 -0
- package/dist/cjs/internal/appMode.js +19 -0
- package/dist/cjs/internal/env.js +3 -2
- package/dist/cjs/internal/platformFetch.d.ts +2 -0
- package/dist/cjs/internal/platformFetch.js +14 -0
- package/dist/cjs/internal/reservedIds.d.ts +8 -0
- package/dist/cjs/internal/reservedIds.js +14 -0
- package/dist/cjs/internal/serviceUrls.d.ts +5 -0
- package/dist/cjs/internal/serviceUrls.js +14 -0
- package/dist/cjs/pdf/index.js +2 -1
- package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
- package/dist/cjs/runtime/index.d.ts +126 -39
- package/dist/cjs/runtime/index.js +32 -26
- package/dist/cjs/runtime/index.test.js +34 -34
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +50 -0
- package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
- package/dist/cjs/sourceRoots.js +15 -15
- package/dist/cjs/sourceRoots.test.js +29 -27
- package/dist/cjs/start/{entries.d.ts → build/entries.d.ts} +9 -4
- package/dist/cjs/start/{entries.js → build/entries.js} +38 -21
- package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
- package/dist/cjs/start/build/placeholders/devApp.js +6 -0
- package/dist/cjs/start/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
- package/dist/cjs/start/{describeBuilt.js → describe/describeBuilt.js} +55 -17
- package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
- package/dist/cjs/start/platform/aiUsage.js +215 -0
- package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
- package/dist/cjs/start/platform/airtable/cache.js +93 -0
- package/dist/cjs/start/protocol.d.ts +19 -0
- package/dist/cjs/start/protocol.js +33 -0
- package/dist/cjs/start/serve/local/provider.d.ts +25 -0
- package/dist/cjs/start/serve/local/provider.js +196 -0
- package/dist/cjs/start/serve/provider.d.ts +19 -0
- package/dist/cjs/start/serve/provider.js +86 -0
- package/dist/cjs/start/types.d.ts +373 -0
- package/dist/cjs/start/types.js +2 -0
- package/dist/cjs/steps/index.d.ts +78 -0
- package/dist/cjs/steps/index.js +507 -0
- package/dist/cjs/steps/index.test.js +635 -0
- package/dist/cjs/sync/index.d.ts +1 -1
- package/dist/cjs/sync/index.js +28 -27
- package/dist/cjs/sync/lib.d.ts +15 -8
- package/dist/cjs/sync/lib.js +655 -655
- package/dist/cjs/sync/lib.test.js +177 -46
- package/dist/cjs/sync/sdkNames.d.ts +67 -9
- package/dist/cjs/sync/sdkNames.js +97 -31
- package/dist/cjs/sync/sdkNames.test.js +189 -113
- package/dist/cjs/types/fields.d.ts +9 -2
- package/dist/cjs/types/fields.js +110 -96
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/tables.d.ts +17 -1
- package/dist/cjs/upload/index.js +89 -24
- package/dist/cjs/upload/index.test.js +104 -1
- package/dist/cjs/vite/domTagNames.js +252 -252
- package/dist/cjs/vite/index.d.ts +1 -1
- package/dist/cjs/vite/index.js +46 -42
- package/dist/esm/auth/actions.d.ts +28 -0
- package/dist/esm/auth/actions.js +55 -0
- package/dist/esm/auth/client.d.ts +357 -0
- package/dist/esm/auth/client.js +62 -0
- package/dist/esm/auth/config.js +9 -3
- package/dist/esm/auth/index.d.ts +2 -249
- package/dist/esm/auth/index.js +2 -103
- package/dist/esm/auth/index.test.js +60 -0
- package/dist/esm/auth/previewClaim.d.ts +7 -0
- package/dist/esm/auth/previewClaim.js +12 -0
- package/dist/esm/auth/profileUpdates.d.ts +9 -0
- package/dist/esm/auth/profileUpdates.js +6 -0
- package/dist/esm/backend/index.d.ts +15 -9
- package/dist/esm/backend/index.js +13 -13
- package/dist/esm/backend/index.test.js +106 -106
- package/dist/esm/bundle/index.d.ts +8 -0
- package/dist/esm/bundle/index.js +37 -24
- package/dist/esm/caller/index.js +44 -44
- package/dist/esm/check/index.d.ts +20 -9
- package/dist/esm/check/index.js +117 -93
- package/dist/esm/check/start/routeTree.d.ts +8 -0
- package/dist/esm/check/start/routeTree.js +77 -0
- package/dist/esm/check/start/tsgo.d.ts +2 -0
- package/dist/esm/check/start/tsgo.js +29 -0
- package/dist/esm/cli.js +10 -4
- package/dist/esm/client/index.d.ts +26 -2
- package/dist/esm/client/index.js +25 -25
- package/dist/esm/dev/index.js +86 -61
- package/dist/esm/dev/signin.d.ts +16 -0
- package/dist/esm/dev/signin.js +80 -0
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +3 -3
- package/dist/esm/integrations/client.d.ts +3 -3
- package/dist/esm/integrations/client.js +6 -5
- package/dist/esm/integrations/client.test-d.js +19 -19
- package/dist/esm/integrations/index.d.ts +2 -2
- package/dist/esm/integrations/index.js +1 -1
- package/dist/esm/integrations/rules.d.ts +1 -0
- package/dist/esm/integrations/rules.js +48 -43
- package/dist/esm/integrations/rules.test.js +62 -56
- package/dist/esm/internal/appMode.d.ts +14 -0
- package/dist/esm/internal/appMode.js +13 -0
- package/dist/esm/internal/env.js +3 -2
- package/dist/esm/internal/platformFetch.d.ts +2 -0
- package/dist/esm/internal/platformFetch.js +9 -0
- package/dist/esm/internal/reservedIds.d.ts +8 -0
- package/dist/esm/internal/reservedIds.js +10 -0
- package/dist/esm/internal/serviceUrls.d.ts +5 -0
- package/dist/esm/internal/serviceUrls.js +10 -0
- package/dist/esm/pdf/index.js +2 -1
- package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
- package/dist/esm/runtime/index.d.ts +126 -39
- package/dist/esm/runtime/index.js +35 -29
- package/dist/esm/runtime/index.test.js +36 -36
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +48 -0
- package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
- package/dist/esm/signin/conformance.d.ts +100 -0
- package/dist/esm/signin/conformance.js +616 -0
- package/dist/esm/signin/cookies.d.ts +28 -0
- package/dist/esm/signin/cookies.js +67 -0
- package/dist/esm/signin/encoding.d.ts +1 -0
- package/dist/esm/signin/encoding.js +12 -0
- package/dist/esm/signin/endpoints.d.ts +12 -0
- package/dist/esm/signin/endpoints.js +32 -0
- package/dist/esm/signin/http.d.ts +25 -0
- package/dist/esm/signin/http.js +106 -0
- package/dist/esm/signin/index.d.ts +8 -0
- package/dist/esm/signin/index.js +9 -0
- package/dist/esm/signin/keys.d.ts +35 -0
- package/dist/esm/signin/keys.js +230 -0
- package/dist/esm/signin/paths.d.ts +2 -0
- package/dist/esm/signin/paths.js +5 -0
- package/dist/esm/signin/seal.d.ts +19 -0
- package/dist/esm/signin/seal.js +47 -0
- package/dist/esm/signin/signin.d.ts +60 -0
- package/dist/esm/signin/signin.js +447 -0
- package/dist/esm/signin/transport.d.ts +112 -0
- package/dist/esm/signin/transport.js +1 -0
- package/dist/esm/signin/verifier.d.ts +2 -0
- package/dist/esm/signin/verifier.js +4 -0
- package/dist/esm/signin/verify.d.ts +83 -0
- package/dist/esm/signin/verify.js +142 -0
- package/dist/esm/sourceRoots.js +17 -17
- package/dist/esm/sourceRoots.test.js +34 -32
- package/dist/esm/start/access.d.ts +19 -0
- package/dist/esm/start/access.js +43 -0
- package/dist/esm/start/auth.d.ts +28 -0
- package/dist/esm/start/auth.js +33 -0
- package/dist/esm/start/automations/quiet.d.ts +2 -0
- package/dist/esm/start/automations/quiet.js +36 -0
- package/dist/esm/start/{registration.d.ts → automations/registration.d.ts} +1 -1
- package/dist/esm/start/{registration.js → automations/registration.js} +11 -7
- package/dist/esm/start/automations/steps.d.ts +29 -0
- package/dist/esm/start/automations/steps.js +95 -0
- package/dist/esm/start/automations/workflow.d.ts +83 -0
- package/dist/esm/start/automations/workflow.js +36 -0
- package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
- package/dist/esm/start/automations/workflow.test-d.js +130 -0
- package/dist/esm/start/automations/workflowRun.d.ts +130 -0
- package/dist/esm/start/automations/workflowRun.js +185 -0
- package/dist/esm/start/barrel.test-d.d.ts +10 -0
- package/dist/esm/start/barrel.test-d.js +6 -0
- package/dist/esm/start/{entries.d.ts → build/entries.d.ts} +9 -4
- package/dist/esm/start/{entries.js → build/entries.js} +38 -22
- package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
- package/dist/esm/start/build/placeholders/devApp.js +3 -0
- package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
- package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
- package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
- package/dist/esm/start/build/placeholders/siteHead.js +3 -0
- package/dist/esm/start/{workflowModules.js → build/placeholders/workflowModules.js} +1 -1
- package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
- package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
- package/dist/esm/start/build/registrationHash.d.ts +11 -0
- package/dist/esm/start/build/registrationHash.js +88 -0
- package/dist/esm/start/build/sdk/axios.d.ts +76 -0
- package/dist/esm/start/build/sdk/axios.js +253 -0
- package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
- package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
- package/dist/esm/start/build/sdk/undici.d.ts +34 -0
- package/dist/esm/start/build/sdk/undici.js +18 -0
- package/dist/esm/start/build/sdkPatches.d.ts +22 -0
- package/dist/esm/start/build/sdkPatches.js +430 -0
- package/dist/esm/start/build/siteHead.d.ts +26 -0
- package/dist/esm/start/build/siteHead.js +88 -0
- package/dist/esm/start/build/vite.d.ts +50 -0
- package/dist/esm/start/build/vite.js +487 -0
- package/dist/esm/start/classicOnly.d.ts +1 -0
- package/dist/esm/start/classicOnly.js +4 -0
- package/dist/esm/start/{describe.d.ts → describe/describe.d.ts} +44 -9
- package/dist/esm/start/describe/describe.js +372 -0
- package/dist/esm/start/{describeBuilt.d.ts → describe/describeBuilt.d.ts} +2 -0
- package/dist/esm/start/describe/describeBuilt.js +102 -0
- package/dist/esm/start/{descriptions.js → describe/descriptions.js} +17 -10
- package/dist/esm/start/errors.d.ts +15 -4
- package/dist/esm/start/errors.js +87 -28
- package/dist/esm/start/errors.test.js +47 -16
- package/dist/esm/start/factories.d.ts +14 -0
- package/dist/esm/start/factories.js +23 -0
- package/dist/esm/start/factories.test-d.d.ts +2 -1
- package/dist/esm/start/factories.test-d.js +52 -12
- package/dist/esm/start/failures.d.ts +7 -0
- package/dist/esm/start/failures.js +62 -0
- package/dist/esm/start/fnFactory.d.ts +16 -0
- package/dist/esm/start/fnFactory.js +1 -0
- package/dist/esm/start/host.d.ts +2 -2
- package/dist/esm/start/host.js +3 -3
- package/dist/esm/start/index.d.ts +10 -66
- package/dist/esm/start/index.js +7 -146
- package/dist/esm/start/login.d.ts +5 -0
- package/dist/esm/start/login.js +29 -0
- package/dist/esm/start/middlewareKind.d.ts +13 -0
- package/dist/esm/start/middlewareKind.js +9 -0
- package/dist/esm/start/platform/aiUsage.d.ts +29 -0
- package/dist/esm/start/platform/aiUsage.js +210 -0
- package/dist/esm/start/platform/airtable/built.d.ts +2 -0
- package/dist/esm/start/platform/airtable/built.js +3 -0
- package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
- package/dist/esm/start/platform/airtable/cache.js +89 -0
- package/dist/esm/start/{airtable → platform/airtable}/dispatch.d.ts +5 -2
- package/dist/esm/start/{airtable → platform/airtable}/dispatch.js +195 -119
- package/dist/esm/start/{airtable → platform/airtable}/formulas.d.ts +2 -1
- package/dist/esm/start/{airtable → platform/airtable}/formulas.js +51 -25
- package/dist/esm/start/platform/airtable/index.d.ts +6 -0
- package/dist/esm/start/platform/airtable/index.js +51 -0
- package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
- package/dist/esm/start/platform/airtable/settings.js +138 -0
- package/dist/esm/start/platform/analytics.d.ts +3 -0
- package/dist/esm/start/platform/analytics.js +59 -0
- package/dist/esm/start/platform/calls.d.ts +5 -0
- package/dist/esm/start/platform/calls.js +104 -0
- package/dist/esm/start/platform/caps.d.ts +9 -0
- package/dist/esm/start/platform/caps.js +35 -0
- package/dist/esm/start/platform/connections.d.ts +25 -0
- package/dist/esm/start/platform/connections.js +198 -0
- package/dist/esm/start/{data → platform/data}/baseRunner.d.ts +11 -6
- package/dist/esm/start/platform/data/baseRunner.js +117 -0
- package/dist/esm/start/{data → platform/data}/dispatch.d.ts +3 -2
- package/dist/esm/start/{data → platform/data}/dispatch.js +69 -51
- package/dist/esm/start/platform/data/fetch.d.ts +7 -0
- package/dist/esm/start/platform/data/fetch.js +9 -0
- package/dist/esm/start/platform/data/index.d.ts +27 -0
- package/dist/esm/start/platform/data/index.js +75 -0
- package/dist/esm/start/platform/data/names.d.ts +7 -0
- package/dist/esm/start/platform/data/names.js +18 -0
- package/dist/esm/start/{data → platform/data}/transformations.d.ts +0 -31
- package/dist/esm/start/{data → platform/data}/transformations.js +0 -56
- package/dist/esm/start/{data → platform/data}/types.d.ts +4 -1
- package/dist/esm/start/{data → platform/data}/types.js +2 -2
- package/dist/esm/start/platform/local.d.ts +6 -0
- package/dist/esm/start/platform/local.js +18 -0
- package/dist/esm/start/platform/meta.d.ts +3 -0
- package/dist/esm/start/platform/meta.js +33 -0
- package/dist/esm/start/platform/outbound.d.ts +17 -0
- package/dist/esm/start/platform/outbound.js +510 -0
- package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
- package/dist/esm/start/{redactSecrets.js → platform/redactSecrets.js} +32 -7
- package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
- package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
- package/dist/esm/start/platform/requestSecrets.js +41 -0
- package/dist/esm/start/platform/runLog.d.ts +40 -0
- package/dist/esm/start/platform/runLog.js +149 -0
- package/dist/esm/start/platform/services.d.ts +7 -0
- package/dist/esm/start/platform/services.js +46 -0
- package/dist/esm/start/platform/steps.d.ts +9 -0
- package/dist/esm/start/platform/steps.js +60 -0
- package/dist/esm/start/platform/telemetry.d.ts +13 -0
- package/dist/esm/start/platform/telemetry.js +71 -0
- package/dist/esm/start/platform/transport.d.ts +28 -0
- package/dist/esm/start/platform/transport.js +59 -0
- package/dist/esm/start/platformHead.d.ts +23 -0
- package/dist/esm/start/platformHead.js +133 -0
- package/dist/esm/start/previewClaim.d.ts +3 -7
- package/dist/esm/start/previewClaim.js +9 -17
- package/dist/esm/start/protocol.d.ts +19 -0
- package/dist/esm/start/protocol.js +27 -0
- package/dist/esm/start/roles.d.ts +12 -0
- package/dist/esm/start/roles.js +27 -0
- package/dist/esm/start/router.d.ts +27 -4
- package/dist/esm/start/router.js +221 -22
- package/dist/esm/start/serve/authHooks.js +18 -0
- package/dist/esm/start/serve/demo.d.ts +9 -0
- package/dist/esm/start/serve/demo.js +24 -0
- package/dist/esm/start/serve/fetch.d.ts +1 -0
- package/dist/esm/start/serve/fetch.js +6 -0
- package/dist/esm/start/{instance.d.ts → serve/instance.d.ts} +6 -5
- package/dist/esm/start/serve/instance.js +134 -0
- package/dist/esm/start/serve/invoke.d.ts +13 -0
- package/dist/esm/start/serve/invoke.js +126 -0
- package/dist/esm/start/serve/local/load.d.ts +8 -0
- package/dist/esm/start/serve/local/load.js +44 -0
- package/dist/esm/start/serve/local/provider.d.ts +25 -0
- package/dist/esm/start/serve/local/provider.js +188 -0
- package/dist/esm/start/serve/local/signIn.d.ts +28 -0
- package/dist/esm/start/serve/local/signIn.js +123 -0
- package/dist/esm/start/serve/pageHead.d.ts +20 -0
- package/dist/esm/start/serve/pageHead.js +34 -0
- package/dist/esm/start/serve/provider.d.ts +19 -0
- package/dist/esm/start/serve/provider.js +78 -0
- package/dist/esm/start/serve/requestEnv.d.ts +2 -0
- package/dist/esm/start/serve/requestEnv.js +84 -0
- package/dist/esm/start/serve/scope.d.ts +18 -0
- package/dist/esm/start/serve/scope.js +67 -0
- package/dist/esm/start/serve/server.d.ts +56 -0
- package/dist/esm/start/serve/server.js +297 -0
- package/dist/esm/start/serve/uploads.d.ts +2 -0
- package/dist/esm/start/serve/uploads.js +49 -0
- package/dist/esm/start/serve/worker.d.ts +6 -0
- package/dist/esm/start/serve/worker.js +12 -0
- package/dist/esm/start/types.d.ts +270 -56
- package/dist/esm/start/version.d.ts +1 -1
- package/dist/esm/start/version.js +1 -1
- package/dist/esm/steps/index.d.ts +78 -0
- package/dist/esm/steps/index.js +502 -0
- package/dist/esm/steps/index.test.d.ts +1 -0
- package/dist/esm/steps/index.test.js +633 -0
- package/dist/esm/sync/index.d.ts +1 -1
- package/dist/esm/sync/index.js +32 -31
- package/dist/esm/sync/lib.d.ts +15 -8
- package/dist/esm/sync/lib.js +659 -659
- package/dist/esm/sync/lib.test.js +177 -46
- package/dist/esm/sync/sdkNames.d.ts +67 -9
- package/dist/esm/sync/sdkNames.js +94 -30
- package/dist/esm/sync/sdkNames.test.js +192 -116
- package/dist/esm/types/fields.d.ts +9 -2
- package/dist/esm/types/fields.js +110 -96
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/index.js +2 -2
- package/dist/esm/types/tables.d.ts +17 -1
- package/dist/esm/types/tables.js +2 -2
- package/dist/esm/upload/index.js +89 -24
- package/dist/esm/upload/index.test.js +104 -1
- package/dist/esm/vite/domTagNames.js +252 -252
- package/dist/esm/vite/index.d.ts +1 -1
- package/dist/esm/vite/index.js +51 -47
- package/package.json +95 -37
- package/dist/cjs/auth-server/index.d.ts +0 -369
- package/dist/cjs/auth-server/index.js +0 -119
- package/dist/cjs/check/start/describeRules.d.ts +0 -35
- package/dist/cjs/check/start/describeRules.js +0 -89
- package/dist/cjs/check/start/problem.d.ts +0 -11
- package/dist/cjs/check/start/problem.js +0 -5
- package/dist/cjs/check/start/sourceRules.d.ts +0 -3
- package/dist/cjs/check/start/sourceRules.js +0 -441
- package/dist/cjs/start/problems.d.ts +0 -19
- package/dist/cjs/start/problems.js +0 -11
- package/dist/esm/auth-server/index.d.ts +0 -369
- package/dist/esm/auth-server/index.js +0 -116
- package/dist/esm/check/start/describeRules.d.ts +0 -35
- package/dist/esm/check/start/describeRules.js +0 -86
- package/dist/esm/check/start/problem.d.ts +0 -11
- package/dist/esm/check/start/problem.js +0 -1
- package/dist/esm/check/start/sourceRules.d.ts +0 -3
- package/dist/esm/check/start/sourceRules.js +0 -438
- package/dist/esm/start/airtable/index.d.ts +0 -11
- package/dist/esm/start/airtable/index.js +0 -70
- package/dist/esm/start/authHooks.js +0 -10
- package/dist/esm/start/data/baseRunner.js +0 -83
- package/dist/esm/start/data/index.d.ts +0 -18
- package/dist/esm/start/data/index.js +0 -76
- package/dist/esm/start/describe.js +0 -204
- package/dist/esm/start/describeBuilt.js +0 -66
- package/dist/esm/start/instance.js +0 -80
- package/dist/esm/start/problems.d.ts +0 -19
- package/dist/esm/start/problems.js +0 -8
- package/dist/esm/start/redactSecrets.d.ts +0 -7
- package/dist/esm/start/runLog.d.ts +0 -8
- package/dist/esm/start/runLog.js +0 -76
- package/dist/esm/start/scope.d.ts +0 -15
- package/dist/esm/start/scope.js +0 -58
- package/dist/esm/start/server.d.ts +0 -55
- package/dist/esm/start/server.js +0 -317
- package/dist/esm/start/vite.d.ts +0 -9
- package/dist/esm/start/vite.js +0 -173
- package/dist/esm/start/worker.d.ts +0 -11
- package/dist/esm/start/worker.js +0 -20
- package/dist/esm/start/workflow.d.ts +0 -53
- package/dist/esm/start/workflow.js +0 -13
- package/dist/esm/start/workflow.test-d.js +0 -44
- package/dist/esm/start/workflowRun.d.ts +0 -80
- package/dist/esm/start/workflowRun.js +0 -108
- /package/dist/{esm/start/redactSecrets.test.d.ts → cjs/runtime/sendEmailParamsTypes.test-d.d.ts} +0 -0
- /package/dist/{esm/start/workflow.test-d.d.ts → cjs/steps/index.test.d.ts} +0 -0
- /package/dist/esm/start/{authHooksModule.d.ts → build/placeholders/authHooksModule.d.ts} +0 -0
- /package/dist/esm/start/{authHooksModule.js → build/placeholders/authHooksModule.js} +0 -0
- /package/dist/esm/start/{workflowModules.d.ts → build/placeholders/workflowModules.d.ts} +0 -0
- /package/dist/esm/start/{descriptions.d.ts → describe/descriptions.d.ts} +0 -0
- /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.d.ts +0 -0
- /package/dist/esm/start/{airtable → platform/airtable}/arrayFields.js +0 -0
- /package/dist/esm/start/{data → platform/data}/sqlNameMappings.d.ts +0 -0
- /package/dist/esm/start/{data → platform/data}/sqlNameMappings.js +0 -0
- /package/dist/esm/start/{redactSecrets.test.js → platform/redactSecrets.test.js} +0 -0
- /package/dist/esm/start/{authHooks.d.ts → serve/authHooks.d.ts} +0 -0
|
@@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.describedProblems = void 0;
|
|
39
40
|
exports.describeBuiltApp = describeBuiltApp;
|
|
40
41
|
exports.runDescribe = runDescribe;
|
|
41
42
|
const node_child_process_1 = require("node:child_process");
|
|
@@ -44,12 +45,12 @@ const node_net_1 = require("node:net");
|
|
|
44
45
|
const node_path_1 = __importDefault(require("node:path"));
|
|
45
46
|
const node_url_1 = require("node:url");
|
|
46
47
|
// Only the host can set x-zite-* in production: the front strips them from public traffic.
|
|
47
|
-
const DESCRIBE_HEADERS = {
|
|
48
|
+
const DESCRIBE_HEADERS = { 'x-zite-invoke': 'describe' };
|
|
48
49
|
// Not "localhost": it can resolve to ::1 for vite's listen and to 127.0.0.1 for fetch.
|
|
49
|
-
const HOST =
|
|
50
|
+
const HOST = '127.0.0.1';
|
|
50
51
|
const freePort = () => new Promise((resolve, reject) => {
|
|
51
52
|
const server = (0, node_net_1.createServer)();
|
|
52
|
-
server.once(
|
|
53
|
+
server.once('error', reject);
|
|
53
54
|
server.listen(0, HOST, () => {
|
|
54
55
|
const { port } = server.address();
|
|
55
56
|
server.close(() => resolve(port));
|
|
@@ -60,21 +61,33 @@ const freePort = () => new Promise((resolve, reject) => {
|
|
|
60
61
|
async function describeInWorkerd(appDir) {
|
|
61
62
|
const port = await freePort();
|
|
62
63
|
// Its own process group, so stopping it also stops vite and workerd under npx.
|
|
63
|
-
const preview = (0, node_child_process_1.spawn)(
|
|
64
|
+
const preview = (0, node_child_process_1.spawn)('npx', [
|
|
65
|
+
'--no-install',
|
|
66
|
+
'vite',
|
|
67
|
+
'preview',
|
|
68
|
+
'--host',
|
|
69
|
+
HOST,
|
|
70
|
+
'--port',
|
|
71
|
+
String(port),
|
|
72
|
+
'--strictPort',
|
|
73
|
+
], {
|
|
64
74
|
cwd: appDir,
|
|
65
|
-
stdio: [
|
|
75
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
66
76
|
detached: true,
|
|
67
77
|
});
|
|
68
|
-
let stderr =
|
|
69
|
-
preview.stderr.on(
|
|
78
|
+
let stderr = '';
|
|
79
|
+
preview.stderr.on('data', chunk => (stderr += chunk));
|
|
70
80
|
try {
|
|
71
81
|
const deadline = Date.now() + 60_000;
|
|
72
82
|
while (true) {
|
|
73
83
|
try {
|
|
74
|
-
const response = await fetch(`http://${HOST}:${port}/`, {
|
|
84
|
+
const response = await fetch(`http://${HOST}:${port}/`, {
|
|
85
|
+
headers: DESCRIBE_HEADERS,
|
|
86
|
+
});
|
|
75
87
|
// Right after start, preview can answer before the Worker does; only the
|
|
76
88
|
// app's own describe answer is JSON.
|
|
77
|
-
if (response.ok &&
|
|
89
|
+
if (response.ok &&
|
|
90
|
+
response.headers.get('content-type')?.includes('application/json')) {
|
|
78
91
|
return await response.json();
|
|
79
92
|
}
|
|
80
93
|
}
|
|
@@ -82,25 +95,50 @@ async function describeInWorkerd(appDir) {
|
|
|
82
95
|
if (preview.exitCode !== null || Date.now() > deadline) {
|
|
83
96
|
throw new Error(`vite preview didn't serve the app: ${stderr.trim().slice(-500)}`);
|
|
84
97
|
}
|
|
85
|
-
await new Promise(
|
|
98
|
+
await new Promise(resolve => setTimeout(resolve, 250));
|
|
86
99
|
}
|
|
87
100
|
}
|
|
88
101
|
finally {
|
|
89
102
|
try {
|
|
90
|
-
process.kill(-preview.pid,
|
|
103
|
+
process.kill(-preview.pid, 'SIGTERM');
|
|
91
104
|
}
|
|
92
105
|
catch { }
|
|
93
106
|
}
|
|
94
107
|
}
|
|
95
108
|
/** Describes a built Start app from its `dist/server`: a Workers build in workerd, a Node build in-process. */
|
|
96
109
|
async function describeBuiltApp(appDir) {
|
|
97
|
-
const serverDir = node_path_1.default.join(appDir,
|
|
98
|
-
if ((0, node_fs_1.existsSync)(node_path_1.default.join(serverDir,
|
|
110
|
+
const serverDir = node_path_1.default.join(appDir, 'dist/server');
|
|
111
|
+
if ((0, node_fs_1.existsSync)(node_path_1.default.join(serverDir, 'wrangler.json')))
|
|
99
112
|
return describeInWorkerd(appDir);
|
|
100
|
-
const { default: server } = await Promise.resolve(`${(0, node_url_1.pathToFileURL)(node_path_1.default.join(serverDir,
|
|
101
|
-
return (await server.fetch(new Request(
|
|
113
|
+
const { default: server } = await Promise.resolve(`${(0, node_url_1.pathToFileURL)(node_path_1.default.join(serverDir, 'server.js')).href}`).then(s => __importStar(require(s)));
|
|
114
|
+
return (await server.fetch(new Request('http://describe.local/', { headers: DESCRIBE_HEADERS }))).json();
|
|
102
115
|
}
|
|
116
|
+
const listed = (value) => Array.isArray(value)
|
|
117
|
+
? value.filter(item => item && typeof item === 'object')
|
|
118
|
+
: [];
|
|
119
|
+
/** @internal Each problem in a description, after what it's about: the app, or a function, route or automation. */
|
|
120
|
+
const describedProblems = (description) => {
|
|
121
|
+
const of = description;
|
|
122
|
+
const lines = (label, problems) => Array.isArray(problems)
|
|
123
|
+
? problems.map(problem => `${label}: ${String(problem)}`)
|
|
124
|
+
: [];
|
|
125
|
+
const where = (name, file) => typeof file === 'string' ? `${String(name)} (${file})` : String(name);
|
|
126
|
+
return [
|
|
127
|
+
...lines('app', of?.problems),
|
|
128
|
+
...listed(of?.functions).flatMap(fn => lines(`function ${where(fn.name ?? fn.id, fn.file)}`, fn.problems)),
|
|
129
|
+
...listed(of?.routes).flatMap(route => lines(`route ${where(route.path, route.file)}`, route.problems)),
|
|
130
|
+
...listed(of?.workflows).flatMap(workflow => lines(`automation ${where(workflow.id, workflow.file)}`, workflow.problems)),
|
|
131
|
+
];
|
|
132
|
+
};
|
|
133
|
+
exports.describedProblems = describedProblems;
|
|
134
|
+
// The JSON on stdout is the platform's, which reads a nonzero exit as no description at all; stderr is for whoever
|
|
135
|
+
// runs it by hand.
|
|
103
136
|
async function runDescribe() {
|
|
104
|
-
const appDir = node_path_1.default.resolve(process.argv[3] ??
|
|
105
|
-
|
|
137
|
+
const appDir = node_path_1.default.resolve(process.argv[3] ?? '.');
|
|
138
|
+
const description = await describeBuiltApp(appDir);
|
|
139
|
+
process.stdout.write(`${JSON.stringify(description, null, 2)}\n`);
|
|
140
|
+
const problems = (0, exports.describedProblems)(description);
|
|
141
|
+
if (problems.length > 0) {
|
|
142
|
+
process.stderr.write(`zitejs describe: ${problems.length} problem${problems.length === 1 ? '' : 's'}\n${problems.map(line => ` - ${line}`).join('\n')}\n`);
|
|
143
|
+
}
|
|
106
144
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a call on an org's own AI key used, read from the provider's answer as
|
|
3
|
+
* classic's runtime reads it. For analytics only: the org pays the provider.
|
|
4
|
+
* OpenAI, Anthropic and Gemini; the host meters Zite's own key itself.
|
|
5
|
+
*/
|
|
6
|
+
export type AiProvider = 'openai' | 'anthropic' | 'gemini';
|
|
7
|
+
export type AiUsageRecord = {
|
|
8
|
+
provider: AiProvider;
|
|
9
|
+
model?: string;
|
|
10
|
+
inputTokens?: number;
|
|
11
|
+
outputTokens?: number;
|
|
12
|
+
cachedReadInputTokens?: number;
|
|
13
|
+
cacheCreationInputTokens?: number;
|
|
14
|
+
isStreaming?: true;
|
|
15
|
+
};
|
|
16
|
+
export declare const AI_USAGE_HOSTS: Record<string, AiProvider>;
|
|
17
|
+
/** As classic: an OpenAI chat stream reports its usage only when asked to. The body to send instead, if any. */
|
|
18
|
+
export declare const withStreamUsage: (url: URL, method: string, body: unknown) => string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The response to hand the app, and its usage once read; a stream is split so the app reads one copy as it arrives.
|
|
21
|
+
* `request` is what the app sent, which names Gemini's model and holds what its embeddings are estimated from.
|
|
22
|
+
*/
|
|
23
|
+
export declare const meterAiResponse: (provider: AiProvider, response: Response, request: {
|
|
24
|
+
url: URL;
|
|
25
|
+
body: unknown;
|
|
26
|
+
}) => {
|
|
27
|
+
response: Response;
|
|
28
|
+
usage: Promise<AiUsageRecord | undefined>;
|
|
29
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What a call on an org's own AI key used, read from the provider's answer as
|
|
4
|
+
* classic's runtime reads it. For analytics only: the org pays the provider.
|
|
5
|
+
* OpenAI, Anthropic and Gemini; the host meters Zite's own key itself.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.meterAiResponse = exports.withStreamUsage = exports.AI_USAGE_HOSTS = void 0;
|
|
9
|
+
exports.AI_USAGE_HOSTS = {
|
|
10
|
+
'api.openai.com': 'openai',
|
|
11
|
+
'api.anthropic.com': 'anthropic',
|
|
12
|
+
'generativelanguage.googleapis.com': 'gemini',
|
|
13
|
+
};
|
|
14
|
+
// Gemini's answers name no model, so it's read from the path: `/v1beta/models/gemini-2.0-flash:generateContent`.
|
|
15
|
+
const geminiModelOf = (url) => /\/models\/([^/:]+)/.exec(url.pathname)?.[1];
|
|
16
|
+
// Gemini's embeddings answer with no usage, so classic estimates their input at four characters a token.
|
|
17
|
+
const GEMINI_EMBED_PATH = /:(embedContent|batchEmbedContents)$/;
|
|
18
|
+
const geminiEmbedTokens = (body) => {
|
|
19
|
+
let parsed;
|
|
20
|
+
try {
|
|
21
|
+
parsed = typeof body === 'string' ? JSON.parse(body) : undefined;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
if (!isRecord(parsed))
|
|
27
|
+
return 0;
|
|
28
|
+
const contents = Array.isArray(parsed.requests)
|
|
29
|
+
? parsed.requests.map(request => isRecord(request) ? request.content : undefined)
|
|
30
|
+
: [parsed.content];
|
|
31
|
+
const chars = contents
|
|
32
|
+
.flatMap(content => isRecord(content) && Array.isArray(content.parts) ? content.parts : [])
|
|
33
|
+
.reduce((sum, part) => sum +
|
|
34
|
+
(isRecord(part) && typeof part.text === 'string'
|
|
35
|
+
? part.text.length
|
|
36
|
+
: 0), 0);
|
|
37
|
+
return chars > 0 ? Math.ceil(chars / 4) : 0;
|
|
38
|
+
};
|
|
39
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
40
|
+
const isNumber = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
41
|
+
/** As classic: an OpenAI chat stream reports its usage only when asked to. The body to send instead, if any. */
|
|
42
|
+
const withStreamUsage = (url, method, body) => {
|
|
43
|
+
if (method !== 'POST' ||
|
|
44
|
+
typeof body !== 'string' ||
|
|
45
|
+
!url.pathname.endsWith('/chat/completions'))
|
|
46
|
+
return undefined;
|
|
47
|
+
try {
|
|
48
|
+
const json = JSON.parse(body);
|
|
49
|
+
if (!isRecord(json) || json.stream !== true)
|
|
50
|
+
return undefined;
|
|
51
|
+
const options = isRecord(json.stream_options) ? json.stream_options : {};
|
|
52
|
+
if (options.include_usage === true)
|
|
53
|
+
return undefined;
|
|
54
|
+
return JSON.stringify({
|
|
55
|
+
...json,
|
|
56
|
+
stream_options: { ...options, include_usage: true },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
exports.withStreamUsage = withStreamUsage;
|
|
64
|
+
// OpenAI and Gemini count cached tokens inside their input; classic takes them apart.
|
|
65
|
+
const tokensFromJson = (provider, body) => {
|
|
66
|
+
const tokens = {};
|
|
67
|
+
if (!isRecord(body))
|
|
68
|
+
return tokens;
|
|
69
|
+
if (provider === 'gemini') {
|
|
70
|
+
if (typeof body.model === 'string')
|
|
71
|
+
tokens.model = body.model;
|
|
72
|
+
const usage = isRecord(body.usageMetadata) ? body.usageMetadata : undefined;
|
|
73
|
+
if (!usage)
|
|
74
|
+
return tokens;
|
|
75
|
+
const cached = usage.cachedContentTokenCount;
|
|
76
|
+
if (isNumber(usage.promptTokenCount))
|
|
77
|
+
tokens.inputTokens =
|
|
78
|
+
usage.promptTokenCount - (isNumber(cached) ? cached : 0);
|
|
79
|
+
if (isNumber(usage.candidatesTokenCount))
|
|
80
|
+
tokens.outputTokens = usage.candidatesTokenCount;
|
|
81
|
+
if (isNumber(cached))
|
|
82
|
+
tokens.cachedReadInputTokens = cached;
|
|
83
|
+
return tokens;
|
|
84
|
+
}
|
|
85
|
+
if (provider === 'openai') {
|
|
86
|
+
const source = isRecord(body.response) ? body.response : body;
|
|
87
|
+
if (typeof source.model === 'string')
|
|
88
|
+
tokens.model = source.model;
|
|
89
|
+
const usage = isRecord(source.usage) ? source.usage : undefined;
|
|
90
|
+
if (!usage)
|
|
91
|
+
return tokens;
|
|
92
|
+
const details = (name) => isRecord(usage[name]) ? usage[name] : {};
|
|
93
|
+
const cached = details('prompt_tokens_details').cached_tokens ??
|
|
94
|
+
details('input_tokens_details').cached_tokens;
|
|
95
|
+
const input = usage.prompt_tokens ?? usage.input_tokens;
|
|
96
|
+
const output = usage.completion_tokens ?? usage.output_tokens;
|
|
97
|
+
if (isNumber(input))
|
|
98
|
+
tokens.inputTokens = input - (isNumber(cached) ? cached : 0);
|
|
99
|
+
if (isNumber(output))
|
|
100
|
+
tokens.outputTokens = output;
|
|
101
|
+
if (isNumber(cached))
|
|
102
|
+
tokens.cachedReadInputTokens = cached;
|
|
103
|
+
return tokens;
|
|
104
|
+
}
|
|
105
|
+
// A stream splits these: message_start has the input, message_delta the running output.
|
|
106
|
+
const message = isRecord(body.message) ? body.message : body;
|
|
107
|
+
if (typeof message.model === 'string')
|
|
108
|
+
tokens.model = message.model;
|
|
109
|
+
const usage = isRecord(message.usage)
|
|
110
|
+
? message.usage
|
|
111
|
+
: isRecord(body.usage)
|
|
112
|
+
? body.usage
|
|
113
|
+
: undefined;
|
|
114
|
+
if (!usage)
|
|
115
|
+
return tokens;
|
|
116
|
+
if (isNumber(usage.input_tokens))
|
|
117
|
+
tokens.inputTokens = usage.input_tokens;
|
|
118
|
+
if (isNumber(usage.output_tokens))
|
|
119
|
+
tokens.outputTokens = usage.output_tokens;
|
|
120
|
+
if (isNumber(usage.cache_read_input_tokens))
|
|
121
|
+
tokens.cachedReadInputTokens = usage.cache_read_input_tokens;
|
|
122
|
+
if (isNumber(usage.cache_creation_input_tokens))
|
|
123
|
+
tokens.cacheCreationInputTokens = usage.cache_creation_input_tokens;
|
|
124
|
+
return tokens;
|
|
125
|
+
};
|
|
126
|
+
// Later readings win: Anthropic's output is cumulative, OpenAI's usage comes last.
|
|
127
|
+
const merge = (into, next) => ({
|
|
128
|
+
model: next.model ?? into.model,
|
|
129
|
+
inputTokens: next.inputTokens ?? into.inputTokens,
|
|
130
|
+
outputTokens: next.outputTokens ?? into.outputTokens,
|
|
131
|
+
cachedReadInputTokens: next.cachedReadInputTokens ?? into.cachedReadInputTokens,
|
|
132
|
+
cacheCreationInputTokens: next.cacheCreationInputTokens ?? into.cacheCreationInputTokens,
|
|
133
|
+
});
|
|
134
|
+
const MAX_PENDING_LINE = 1024 * 1024;
|
|
135
|
+
const tokensFromStream = async (provider, stream, model) => {
|
|
136
|
+
const reader = stream.getReader();
|
|
137
|
+
const decoder = new TextDecoder();
|
|
138
|
+
let pending = '';
|
|
139
|
+
let tokens = { model };
|
|
140
|
+
const readLine = (line) => {
|
|
141
|
+
if (!line.startsWith('data:'))
|
|
142
|
+
return;
|
|
143
|
+
const payload = line.slice(5).trim();
|
|
144
|
+
if (!payload || payload === '[DONE]')
|
|
145
|
+
return;
|
|
146
|
+
try {
|
|
147
|
+
tokens = merge(tokens, tokensFromJson(provider, JSON.parse(payload)));
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// Not JSON; nothing to count.
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
try {
|
|
154
|
+
for (;;) {
|
|
155
|
+
const { done, value } = await reader.read();
|
|
156
|
+
if (done)
|
|
157
|
+
break;
|
|
158
|
+
pending += decoder.decode(value, { stream: true });
|
|
159
|
+
const lines = pending.split('\n');
|
|
160
|
+
pending = lines.pop() ?? '';
|
|
161
|
+
if (pending.length > MAX_PENDING_LINE)
|
|
162
|
+
pending = '';
|
|
163
|
+
lines.forEach(readLine);
|
|
164
|
+
}
|
|
165
|
+
readLine(pending);
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
// What was read before the stream broke still counts.
|
|
169
|
+
}
|
|
170
|
+
return tokens;
|
|
171
|
+
};
|
|
172
|
+
const counted = (tokens) => tokens.inputTokens !== undefined || tokens.outputTokens !== undefined;
|
|
173
|
+
const usageOf = (provider, tokens, streaming) => counted(tokens)
|
|
174
|
+
? {
|
|
175
|
+
provider,
|
|
176
|
+
...Object.fromEntries(Object.entries(tokens).filter(([, value]) => value !== undefined)),
|
|
177
|
+
...(streaming && { isStreaming: true }),
|
|
178
|
+
}
|
|
179
|
+
: undefined;
|
|
180
|
+
/**
|
|
181
|
+
* The response to hand the app, and its usage once read; a stream is split so the app reads one copy as it arrives.
|
|
182
|
+
* `request` is what the app sent, which names Gemini's model and holds what its embeddings are estimated from.
|
|
183
|
+
*/
|
|
184
|
+
const meterAiResponse = (provider, response, request) => {
|
|
185
|
+
const type = response.headers.get('content-type') ?? '';
|
|
186
|
+
const model = provider === 'gemini' ? geminiModelOf(request.url) : undefined;
|
|
187
|
+
if (!response.ok)
|
|
188
|
+
return { response, usage: Promise.resolve(undefined) };
|
|
189
|
+
if (provider === 'gemini' && GEMINI_EMBED_PATH.test(request.url.pathname)) {
|
|
190
|
+
return {
|
|
191
|
+
response,
|
|
192
|
+
usage: Promise.resolve(usageOf(provider, { model, inputTokens: geminiEmbedTokens(request.body) }, false)),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (!response.body)
|
|
196
|
+
return { response, usage: Promise.resolve(undefined) };
|
|
197
|
+
if (type.includes('text/event-stream')) {
|
|
198
|
+
const [forApp, forUs] = response.body.tee();
|
|
199
|
+
return {
|
|
200
|
+
response: new Response(forApp, response),
|
|
201
|
+
usage: tokensFromStream(provider, forUs, model).then(tokens => usageOf(provider, tokens, true)),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
if (!type.includes('json'))
|
|
205
|
+
return { response, usage: Promise.resolve(undefined) };
|
|
206
|
+
return {
|
|
207
|
+
response,
|
|
208
|
+
usage: response
|
|
209
|
+
.clone()
|
|
210
|
+
.json()
|
|
211
|
+
.then((json) => usageOf(provider, merge({ model }, tokensFromJson(provider, json)), false))
|
|
212
|
+
.catch(() => undefined),
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
exports.meterAiResponse = meterAiResponse;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** How long a read is served from the cache, as classic's. */
|
|
2
|
+
export declare const AIRTABLE_READ_TTL_MS = 10000;
|
|
3
|
+
export type AirtableCache = {
|
|
4
|
+
/** A read kept across requests; a write to `table` makes it stale. */
|
|
5
|
+
read<T>(table: string, key: string, load: () => Promise<T>): Promise<T>;
|
|
6
|
+
/** A write to `table`, which makes its reads stale in every isolate the cache reaches, this request's at once. */
|
|
7
|
+
wrote(table: string): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* One request's view of the cache for one connection. Entries are keyed by its token's hash, so only a caller holding
|
|
11
|
+
* the same token reads them, whoever shares the cache.
|
|
12
|
+
*/
|
|
13
|
+
export declare const createAirtableCache: ({ token, waitUntil, now, }: {
|
|
14
|
+
token: string;
|
|
15
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
16
|
+
now?: () => number;
|
|
17
|
+
}) => Promise<AirtableCache | undefined>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Classic keeps an Airtable read for 10 s across runs, in KV, and a write makes the table's reads stale wherever the
|
|
3
|
+
// version it bumps reaches (restly's apps/cloudflare-lambda/src/integrationCache.ts). A Start app keeps them in its
|
|
4
|
+
// Worker's own Cache API cache, per colo, on the same terms. Off Workers there is none, and each read goes to Airtable.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createAirtableCache = exports.AIRTABLE_READ_TTL_MS = void 0;
|
|
7
|
+
const CACHE_NAME = 'zite-airtable';
|
|
8
|
+
const ORIGIN = 'https://airtable-cache.zite.invalid';
|
|
9
|
+
/** How long a read is served from the cache, as classic's. */
|
|
10
|
+
exports.AIRTABLE_READ_TTL_MS = 10_000;
|
|
11
|
+
// What the cache may keep an entry for, past which it's gone whether read or not; classic's KV minimum.
|
|
12
|
+
const HARD_TTL_S = 60;
|
|
13
|
+
const VERSION_TTL_S = 24 * 60 * 60;
|
|
14
|
+
// Classic's cap, KV's largest value.
|
|
15
|
+
const MAX_ENTRY_CHARS = 25 * 1024 * 1024;
|
|
16
|
+
const openCache = async () => {
|
|
17
|
+
const storage = globalThis.caches;
|
|
18
|
+
if (!storage?.open)
|
|
19
|
+
return undefined;
|
|
20
|
+
try {
|
|
21
|
+
return await storage.open(CACHE_NAME);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const sha256 = async (text) => [
|
|
28
|
+
...new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))),
|
|
29
|
+
]
|
|
30
|
+
.map(b => b.toString(16).padStart(2, '0'))
|
|
31
|
+
.join('');
|
|
32
|
+
/**
|
|
33
|
+
* One request's view of the cache for one connection. Entries are keyed by its token's hash, so only a caller holding
|
|
34
|
+
* the same token reads them, whoever shares the cache.
|
|
35
|
+
*/
|
|
36
|
+
const createAirtableCache = async ({ token, waitUntil, now = () => Date.now(), }) => {
|
|
37
|
+
const cache = await openCache();
|
|
38
|
+
if (!cache)
|
|
39
|
+
return undefined;
|
|
40
|
+
const scope = (await sha256(token)).slice(0, 32);
|
|
41
|
+
// This request's writes, added to what the cache says, so a read after a write misses even before the bump lands.
|
|
42
|
+
const bumps = new Map();
|
|
43
|
+
const at = (...parts) => new Request(`${ORIGIN}/${parts.map(encodeURIComponent).join('/')}`);
|
|
44
|
+
const stored = async (table) => {
|
|
45
|
+
const held = await cache
|
|
46
|
+
.match(at('v', scope, table))
|
|
47
|
+
.catch(() => undefined);
|
|
48
|
+
return Number.parseInt((await held?.text().catch(() => '')) ?? '', 10) || 0;
|
|
49
|
+
};
|
|
50
|
+
const kept = (put) => {
|
|
51
|
+
const quiet = put.catch((error) => console.warn('[zite] Airtable cache write failed', error));
|
|
52
|
+
waitUntil?.(quiet);
|
|
53
|
+
return quiet;
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
async read(table, key, load) {
|
|
57
|
+
let entry;
|
|
58
|
+
try {
|
|
59
|
+
entry = at('r', scope, table, String((await stored(table)) + (bumps.get(table) ?? 0)), await sha256(key));
|
|
60
|
+
const held = await cache.match(entry);
|
|
61
|
+
const found = held
|
|
62
|
+
? (await held.json())
|
|
63
|
+
: undefined;
|
|
64
|
+
if (found &&
|
|
65
|
+
typeof found.at === 'number' &&
|
|
66
|
+
now() - found.at < exports.AIRTABLE_READ_TTL_MS)
|
|
67
|
+
return found.value;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.warn('[zite] Airtable cache read failed', error);
|
|
71
|
+
}
|
|
72
|
+
const value = await load();
|
|
73
|
+
const body = entry ? JSON.stringify({ at: now(), value }) : undefined;
|
|
74
|
+
if (entry && body && body.length <= MAX_ENTRY_CHARS) {
|
|
75
|
+
void kept(cache.put(entry, new Response(body, {
|
|
76
|
+
headers: {
|
|
77
|
+
'content-type': 'application/json',
|
|
78
|
+
'cache-control': `max-age=${HARD_TTL_S}`,
|
|
79
|
+
},
|
|
80
|
+
})));
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
},
|
|
84
|
+
async wrote(table) {
|
|
85
|
+
bumps.set(table, (bumps.get(table) ?? 0) + 1);
|
|
86
|
+
const next = String((await stored(table)) + 1);
|
|
87
|
+
await kept(cache.put(at('v', scope, table), new Response(next, {
|
|
88
|
+
headers: { 'cache-control': `max-age=${VERSION_TTL_S}` },
|
|
89
|
+
})));
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
exports.createAirtableCache = createAirtableCache;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { isReservedIntegrationId, RESERVED_INTEGRATION_IDS, } from '../internal/reservedIds.js';
|
|
2
|
+
export type { AppContext, ExpiringToken, HostConnection, HostMode, HostPage, HostProps, PlatformBinding, SiteHead, WebManifest, } from './types.js';
|
|
3
|
+
/** What the host dispatches a request to do beside serving it; without props, only `warm` and `describe`. */
|
|
4
|
+
export declare const INVOKE_KINDS: readonly ["webhook", "describe", "workflow", "register", "warm", "authHook", "function"];
|
|
5
|
+
export type InvokeKind = (typeof INVOKE_KINDS)[number];
|
|
6
|
+
export declare const isInvokeKind: (kind: unknown) => kind is InvokeKind;
|
|
7
|
+
/** `warm` or `describe`, on a request the host sends without props. */
|
|
8
|
+
export declare const INVOKE_HEADER = "x-zite-invoke";
|
|
9
|
+
/** Where the host POSTs a workflow, registration, auth hook or test run, with `{ input }`. */
|
|
10
|
+
export declare const INVOKE_PATH = "/_zite/invoke";
|
|
11
|
+
/** On describe's answer: the zitejs the build's server code was bundled from. */
|
|
12
|
+
export declare const RUNTIME_VERSION_HEADER = "x-zitejs-version";
|
|
13
|
+
/** An editor preview's access, on every same-origin fetch its pages make. */
|
|
14
|
+
export declare const PREVIEW_CLAIM_HEADER = "x-zite-preview";
|
|
15
|
+
/** At the gateway, the connection a call on Zite's AI key bills to. */
|
|
16
|
+
export declare const GATEWAY_CONNECTION_HEADER = "x-zite-gateway-connection";
|
|
17
|
+
/** On a demo's refused answer, beside its 403, so the platform's runtime shows the demo notice. */
|
|
18
|
+
export declare const ERROR_CODE_HEADER = "x-zite-error-code";
|
|
19
|
+
export declare const DEMO_READ_ONLY_CODE = "DEMO_READ_ONLY";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// What a Start build and the platform's host say to each other on the wire. Import-free but for the reserved ids,
|
|
3
|
+
// themselves import-free, so the host takes these without loading anything of zitejs.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.DEMO_READ_ONLY_CODE = exports.ERROR_CODE_HEADER = exports.GATEWAY_CONNECTION_HEADER = exports.PREVIEW_CLAIM_HEADER = exports.RUNTIME_VERSION_HEADER = exports.INVOKE_PATH = exports.INVOKE_HEADER = exports.isInvokeKind = exports.INVOKE_KINDS = exports.RESERVED_INTEGRATION_IDS = exports.isReservedIntegrationId = void 0;
|
|
6
|
+
var reservedIds_js_1 = require("../internal/reservedIds.js");
|
|
7
|
+
Object.defineProperty(exports, "isReservedIntegrationId", { enumerable: true, get: function () { return reservedIds_js_1.isReservedIntegrationId; } });
|
|
8
|
+
Object.defineProperty(exports, "RESERVED_INTEGRATION_IDS", { enumerable: true, get: function () { return reservedIds_js_1.RESERVED_INTEGRATION_IDS; } });
|
|
9
|
+
/** What the host dispatches a request to do beside serving it; without props, only `warm` and `describe`. */
|
|
10
|
+
exports.INVOKE_KINDS = [
|
|
11
|
+
'webhook',
|
|
12
|
+
'describe',
|
|
13
|
+
'workflow',
|
|
14
|
+
'register',
|
|
15
|
+
'warm',
|
|
16
|
+
'authHook',
|
|
17
|
+
'function',
|
|
18
|
+
];
|
|
19
|
+
const isInvokeKind = (kind) => exports.INVOKE_KINDS.includes(kind);
|
|
20
|
+
exports.isInvokeKind = isInvokeKind;
|
|
21
|
+
/** `warm` or `describe`, on a request the host sends without props. */
|
|
22
|
+
exports.INVOKE_HEADER = 'x-zite-invoke';
|
|
23
|
+
/** Where the host POSTs a workflow, registration, auth hook or test run, with `{ input }`. */
|
|
24
|
+
exports.INVOKE_PATH = '/_zite/invoke';
|
|
25
|
+
/** On describe's answer: the zitejs the build's server code was bundled from. */
|
|
26
|
+
exports.RUNTIME_VERSION_HEADER = 'x-zitejs-version';
|
|
27
|
+
/** An editor preview's access, on every same-origin fetch its pages make. */
|
|
28
|
+
exports.PREVIEW_CLAIM_HEADER = 'x-zite-preview';
|
|
29
|
+
/** At the gateway, the connection a call on Zite's AI key bills to. */
|
|
30
|
+
exports.GATEWAY_CONNECTION_HEADER = 'x-zite-gateway-connection';
|
|
31
|
+
/** On a demo's refused answer, beside its 403, so the platform's runtime shows the demo notice. */
|
|
32
|
+
exports.ERROR_CODE_HEADER = 'x-zite-error-code';
|
|
33
|
+
exports.DEMO_READ_ONLY_CODE = 'DEMO_READ_ONLY';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AppContext, ExpiringToken, PlatformProvider, PlatformUrls } from '../../types.js';
|
|
2
|
+
/** What `local` reads, documented in `zitejs`'s help. */
|
|
3
|
+
export declare const LOCAL_ENV: {
|
|
4
|
+
readonly token: "ZITE_DEV_TOKEN";
|
|
5
|
+
readonly apiKey: "ZITE_DEV_API_KEY";
|
|
6
|
+
readonly urls: "ZITE_URLS";
|
|
7
|
+
readonly user: "ZITE_DEV_USER";
|
|
8
|
+
};
|
|
9
|
+
type Env = Record<string, string | undefined>;
|
|
10
|
+
/** `ZITE_URLS`, or a throw saying what it must name. */
|
|
11
|
+
export declare const localUrls: (raw: string | undefined) => PlatformUrls;
|
|
12
|
+
/** For tests: forget the minted dev token and what the backend said of it. */
|
|
13
|
+
export declare const resetDevToken: () => void;
|
|
14
|
+
export declare const mintDevToken: (backend: string, appId: string, apiKey: string) => Promise<ExpiringToken>;
|
|
15
|
+
/**
|
|
16
|
+
* What the backend says of a dev token, from the claims it verified, as OAuth's token introspection answers: asked
|
|
17
|
+
* once per token, whose claims never change. Throws, saying why, when it won't say.
|
|
18
|
+
*/
|
|
19
|
+
export declare const describeDevToken: (backend: string, token: string) => Promise<AppContext>;
|
|
20
|
+
/**
|
|
21
|
+
* `local` when the developer set a dev token, or a key to mint them with, else undefined. Throws on env it can't read,
|
|
22
|
+
* so a typo fails loudly rather than signing nobody in.
|
|
23
|
+
*/
|
|
24
|
+
export declare const localPlatform: (env?: Env, appId?: string | null) => PlatformProvider | undefined;
|
|
25
|
+
export {};
|