zitejs 0.10.0-start.2 → 0.10.0-start.21
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/index.d.ts +2 -249
- package/dist/cjs/auth/index.js +11 -108
- package/dist/cjs/auth/index.test.js +48 -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 +121 -3
- package/dist/cjs/backend/index.test.js +58 -0
- package/dist/cjs/bundle/index.d.ts +8 -0
- package/dist/cjs/bundle/index.js +9 -8
- package/dist/cjs/check/index.d.ts +45 -1
- package/dist/cjs/check/index.js +198 -109
- package/dist/cjs/check/start/problem.d.ts +11 -0
- package/dist/cjs/check/start/problem.js +5 -0
- package/dist/cjs/check/start/routeTree.d.ts +9 -0
- package/dist/cjs/check/start/routeTree.js +111 -0
- package/dist/cjs/check/start/sourceRules.d.ts +8 -0
- package/dist/cjs/check/start/sourceRules.js +1159 -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 +1 -1
- package/dist/cjs/client/index.d.ts +24 -0
- package/dist/cjs/dev/index.js +14 -4
- package/dist/cjs/integrations/rules.d.ts +13 -0
- package/dist/cjs/integrations/rules.js +31 -0
- package/dist/cjs/integrations/rules.test.js +1 -0
- package/dist/cjs/internal/appMode.d.ts +3 -0
- package/dist/cjs/internal/appMode.js +15 -0
- package/dist/cjs/runtime/index.d.ts +64 -25
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +33 -0
- package/dist/cjs/start/entries.d.ts +10 -4
- package/dist/cjs/start/entries.js +23 -6
- package/dist/cjs/steps/index.d.ts +78 -0
- package/dist/cjs/steps/index.js +507 -0
- package/dist/cjs/steps/index.test.d.ts +1 -0
- package/dist/cjs/steps/index.test.js +635 -0
- package/dist/cjs/sync/index.js +2 -1
- package/dist/cjs/sync/lib.d.ts +10 -3
- package/dist/cjs/sync/lib.js +44 -25
- package/dist/cjs/sync/lib.test.js +116 -36
- package/dist/cjs/types/fields.d.ts +8 -1
- package/dist/cjs/types/fields.js +7 -1
- package/dist/cjs/types/tables.d.ts +16 -0
- package/dist/cjs/upload/index.js +12 -2
- package/dist/cjs/upload/index.test.js +39 -0
- package/dist/cjs/vite/index.js +8 -3
- package/dist/cjs/vite/index.test.js +10 -2
- package/dist/esm/auth/actions.d.ts +28 -0
- package/dist/esm/auth/actions.js +55 -0
- package/dist/esm/auth/client.d.ts +357 -0
- package/dist/esm/auth/client.js +62 -0
- package/dist/esm/auth/index.d.ts +2 -249
- package/dist/esm/auth/index.js +2 -103
- package/dist/esm/auth/index.test.js +48 -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 +121 -3
- package/dist/esm/backend/index.test.js +58 -0
- package/dist/esm/bundle/index.d.ts +8 -0
- package/dist/esm/bundle/index.js +8 -8
- package/dist/esm/check/index.d.ts +45 -1
- package/dist/esm/check/index.js +198 -113
- package/dist/esm/check/start/problem.d.ts +11 -0
- package/dist/esm/check/start/problem.js +1 -0
- package/dist/esm/check/start/routeTree.d.ts +9 -0
- package/dist/esm/check/start/routeTree.js +70 -0
- package/dist/esm/check/start/sourceRules.d.ts +8 -0
- package/dist/esm/check/start/sourceRules.js +1156 -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 +1 -1
- package/dist/esm/client/index.d.ts +24 -0
- package/dist/esm/dev/index.js +16 -6
- package/dist/esm/integrations/rules.d.ts +13 -0
- package/dist/esm/integrations/rules.js +31 -0
- package/dist/esm/integrations/rules.test.js +1 -0
- package/dist/esm/internal/appMode.d.ts +3 -0
- package/dist/esm/internal/appMode.js +10 -0
- package/dist/esm/runtime/index.d.ts +64 -25
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +31 -0
- package/dist/esm/start/aiUsage.d.ts +23 -0
- package/dist/esm/start/aiUsage.js +146 -0
- package/dist/esm/start/airtable/arrayFields.d.ts +10 -0
- package/dist/esm/start/airtable/arrayFields.js +30 -0
- package/dist/esm/start/airtable/dispatch.d.ts +54 -0
- package/dist/esm/start/airtable/dispatch.js +483 -0
- package/dist/esm/start/airtable/formulas.d.ts +70 -0
- package/dist/esm/start/airtable/formulas.js +260 -0
- package/dist/esm/start/airtable/index.d.ts +8 -0
- package/dist/esm/start/airtable/index.js +54 -0
- package/dist/esm/start/authHooks.d.ts +7 -0
- package/dist/esm/start/authHooks.js +10 -0
- package/dist/esm/start/authHooksModule.d.ts +1 -0
- package/dist/esm/start/authHooksModule.js +3 -0
- package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
- package/dist/esm/start/clientErrorMessage.test.js +105 -0
- package/dist/esm/start/credentials.d.ts +2 -0
- package/dist/esm/start/credentials.js +2 -0
- package/dist/esm/start/data/baseRunner.d.ts +92 -0
- package/dist/esm/start/data/baseRunner.js +83 -0
- package/dist/esm/start/data/dispatch.d.ts +16 -0
- package/dist/esm/start/data/dispatch.js +198 -0
- package/dist/esm/start/data/index.d.ts +15 -0
- package/dist/esm/start/data/index.js +58 -0
- package/dist/esm/start/data/sqlNameMappings.d.ts +58 -0
- package/dist/esm/start/data/sqlNameMappings.js +92 -0
- package/dist/esm/start/data/transformations.d.ts +97 -0
- package/dist/esm/start/data/transformations.js +262 -0
- package/dist/esm/start/data/types.d.ts +91 -0
- package/dist/esm/start/data/types.js +14 -0
- package/dist/esm/start/describe.d.ts +42 -5
- package/dist/esm/start/describe.js +77 -23
- package/dist/esm/start/entries.d.ts +10 -4
- package/dist/esm/start/entries.js +21 -5
- package/dist/esm/start/errors.d.ts +63 -0
- package/dist/esm/start/errors.js +146 -0
- package/dist/esm/start/errors.test.d.ts +1 -0
- package/dist/esm/start/errors.test.js +23 -0
- package/dist/esm/start/factories.test-d.d.ts +2 -0
- package/dist/esm/start/factories.test-d.js +20 -0
- package/dist/esm/start/host.d.ts +2 -2
- package/dist/esm/start/index.d.ts +32 -27
- package/dist/esm/start/index.js +79 -47
- package/dist/esm/start/instance.d.ts +4 -4
- package/dist/esm/start/instance.js +54 -11
- package/dist/esm/start/outbound.d.ts +11 -0
- package/dist/esm/start/outbound.js +400 -0
- package/dist/esm/start/previewClaim.d.ts +7 -0
- package/dist/esm/start/previewClaim.js +23 -0
- package/dist/esm/start/problems.js +1 -1
- package/dist/esm/start/quiet.d.ts +2 -0
- package/dist/esm/start/quiet.js +27 -0
- package/dist/esm/start/redactSecrets.d.ts +15 -0
- package/dist/esm/start/redactSecrets.js +154 -0
- package/dist/esm/start/redactSecrets.test.d.ts +1 -0
- package/dist/esm/start/redactSecrets.test.js +151 -0
- package/dist/esm/start/registration.d.ts +13 -0
- package/dist/esm/start/registration.js +21 -0
- package/dist/esm/start/registrationHash.d.ts +22 -0
- package/dist/esm/start/registrationHash.js +470 -0
- package/dist/esm/start/router.d.ts +25 -4
- package/dist/esm/start/router.js +169 -11
- package/dist/esm/start/runLog.d.ts +7 -4
- package/dist/esm/start/runLog.js +64 -6
- package/dist/esm/start/scope.d.ts +4 -4
- package/dist/esm/start/server.d.ts +40 -36
- package/dist/esm/start/server.js +322 -49
- package/dist/esm/start/steps.d.ts +28 -0
- package/dist/esm/start/steps.js +97 -0
- package/dist/esm/start/types.d.ts +179 -6
- package/dist/esm/start/version.d.ts +1 -0
- package/dist/esm/start/version.js +2 -0
- package/dist/esm/start/vite.js +91 -14
- package/dist/esm/start/worker.d.ts +6 -0
- package/dist/esm/start/worker.js +12 -0
- package/dist/esm/start/workflow.d.ts +46 -12
- package/dist/esm/start/workflow.js +10 -3
- package/dist/esm/start/workflow.test-d.js +50 -8
- package/dist/esm/start/workflowModules.js +1 -1
- package/dist/esm/start/workflowRun.d.ts +26 -8
- package/dist/esm/start/workflowRun.js +39 -8
- 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.js +2 -1
- package/dist/esm/sync/lib.d.ts +10 -3
- package/dist/esm/sync/lib.js +44 -25
- package/dist/esm/sync/lib.test.js +116 -36
- package/dist/esm/types/fields.d.ts +8 -1
- package/dist/esm/types/fields.js +6 -0
- package/dist/esm/types/tables.d.ts +16 -0
- package/dist/esm/upload/index.js +12 -2
- package/dist/esm/upload/index.test.js +39 -0
- package/dist/esm/vite/index.js +8 -3
- package/dist/esm/vite/index.test.js +10 -2
- package/package.json +37 -16
- package/dist/cjs/start/problems.d.ts +0 -19
- package/dist/cjs/start/problems.js +0 -11
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// TypeScript's native compiler, as the platform's checks run it, found the same
|
|
2
|
+
// way every time: never from PATH, so a check here and one in the sandbox use
|
|
3
|
+
// the same compiler.
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
const PACKAGE = "@typescript/native-preview";
|
|
8
|
+
// Where `npm install -g` put it for the node running this: the sandbox image's.
|
|
9
|
+
const globalRoot = () => process.env.npm_config_prefix
|
|
10
|
+
? path.join(process.env.npm_config_prefix, process.platform === "win32" ? "node_modules" : "lib/node_modules")
|
|
11
|
+
: process.platform === "win32"
|
|
12
|
+
? path.join(path.dirname(process.execPath), "node_modules")
|
|
13
|
+
: path.join(path.dirname(path.dirname(process.execPath)), "lib", "node_modules");
|
|
14
|
+
/** tsgo's launcher: the app's own, walking up from it as Node does, else the global install beside this node. */
|
|
15
|
+
export function findTsgo(appDir) {
|
|
16
|
+
let manifest;
|
|
17
|
+
try {
|
|
18
|
+
manifest = createRequire(path.join(path.resolve(appDir), "package.json")).resolve(`${PACKAGE}/package.json`);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
const global = path.join(globalRoot(), PACKAGE, "package.json");
|
|
22
|
+
manifest = existsSync(global) ? global : undefined;
|
|
23
|
+
}
|
|
24
|
+
if (!manifest)
|
|
25
|
+
return undefined;
|
|
26
|
+
const { bin } = JSON.parse(readFileSync(manifest, "utf-8"));
|
|
27
|
+
const launcher = typeof bin === "string" ? bin : bin?.tsgo;
|
|
28
|
+
return launcher ? path.join(path.dirname(manifest), launcher) : undefined;
|
|
29
|
+
}
|
package/dist/esm/cli.js
CHANGED
|
@@ -45,7 +45,7 @@ async function main() {
|
|
|
45
45
|
console.error(' sync Generate .zite/db.ts from database schema (single-app)');
|
|
46
46
|
console.error(' dev Run sync then watch for changes (like npx convex dev)');
|
|
47
47
|
console.error(' generate Regenerate every app and automation .zite/ (monorepo)');
|
|
48
|
-
console.error(' check
|
|
48
|
+
console.error(' check Typecheck and build every app and automation; a Start app is typechecked with tsgo against its regenerated route tree and its source checked by rule (--json for a report)');
|
|
49
49
|
console.error(' bundle Bundle endpoints (src/api/*.ts, or an automation\'s src/index.ts) for cloudflare-lambda');
|
|
50
50
|
console.error(' describe Print what a built TanStack Start app declares: functions, routes, access');
|
|
51
51
|
process.exit(1);
|
|
@@ -275,6 +275,10 @@ export declare class Zite {
|
|
|
275
275
|
sortEnabled?: boolean | undefined;
|
|
276
276
|
resultType?: "number" | "boolean" | "date" | "array" | "text" | undefined;
|
|
277
277
|
};
|
|
278
|
+
} | {
|
|
279
|
+
name: string;
|
|
280
|
+
type: "created_by";
|
|
281
|
+
template: globalThis.Record<string, never>;
|
|
278
282
|
} | {
|
|
279
283
|
name: string;
|
|
280
284
|
type: "updated_by";
|
|
@@ -488,6 +492,10 @@ export declare class Zite {
|
|
|
488
492
|
sortEnabled?: boolean | undefined;
|
|
489
493
|
resultType?: "number" | "boolean" | "date" | "array" | "text" | undefined;
|
|
490
494
|
};
|
|
495
|
+
} | {
|
|
496
|
+
name: string;
|
|
497
|
+
type: "created_by";
|
|
498
|
+
template: globalThis.Record<string, never>;
|
|
491
499
|
} | {
|
|
492
500
|
name: string;
|
|
493
501
|
type: "updated_by";
|
|
@@ -711,6 +719,10 @@ export declare class Zite {
|
|
|
711
719
|
sortEnabled?: boolean | undefined;
|
|
712
720
|
resultType?: "number" | "boolean" | "date" | "array" | "text" | undefined;
|
|
713
721
|
};
|
|
722
|
+
} | {
|
|
723
|
+
name: string;
|
|
724
|
+
type: "created_by";
|
|
725
|
+
template: globalThis.Record<string, never>;
|
|
714
726
|
} | {
|
|
715
727
|
name: string;
|
|
716
728
|
type: "updated_by";
|
|
@@ -937,6 +949,10 @@ export declare class Zite {
|
|
|
937
949
|
sortEnabled?: boolean | undefined;
|
|
938
950
|
resultType?: "number" | "boolean" | "date" | "array" | "text" | undefined;
|
|
939
951
|
};
|
|
952
|
+
} | {
|
|
953
|
+
name: string;
|
|
954
|
+
type: "created_by";
|
|
955
|
+
template: globalThis.Record<string, never>;
|
|
940
956
|
} | {
|
|
941
957
|
name: string;
|
|
942
958
|
type: "updated_by";
|
|
@@ -1171,6 +1187,10 @@ export declare class Zite {
|
|
|
1171
1187
|
sortEnabled?: boolean | undefined;
|
|
1172
1188
|
resultType?: "number" | "boolean" | "date" | "array" | "text" | undefined;
|
|
1173
1189
|
};
|
|
1190
|
+
} | {
|
|
1191
|
+
name: string;
|
|
1192
|
+
type: "created_by";
|
|
1193
|
+
template: globalThis.Record<string, never>;
|
|
1174
1194
|
} | {
|
|
1175
1195
|
name: string;
|
|
1176
1196
|
type: "updated_by";
|
|
@@ -1406,6 +1426,10 @@ export declare class Zite {
|
|
|
1406
1426
|
sortEnabled?: boolean | undefined;
|
|
1407
1427
|
resultType?: "number" | "boolean" | "date" | "array" | "text" | undefined;
|
|
1408
1428
|
};
|
|
1429
|
+
} | {
|
|
1430
|
+
name: string;
|
|
1431
|
+
type: "created_by";
|
|
1432
|
+
template: globalThis.Record<string, never>;
|
|
1409
1433
|
} | {
|
|
1410
1434
|
name: string;
|
|
1411
1435
|
type: "updated_by";
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { watch } from "fs";
|
|
2
|
-
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, } from "fs";
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, rmSync, } from "fs";
|
|
3
3
|
import { dirname, join, resolve } from "path";
|
|
4
4
|
import { findWorkspaceRoot, listSourceDirs, } from "../sourceRoots.js";
|
|
5
|
-
import { regenerateStartEntries } from "../start/entries.js";
|
|
5
|
+
import { isStartAppDir, regenerateStartEntries, workspaceHasStartApps, } from "../start/entries.js";
|
|
6
6
|
import { runSync } from "../sync/index.js";
|
|
7
7
|
import { generateDbTs, generateApiTs, generateBackendWrapperTs, generateAirtableTs, findEmailIntegrationId, generateEmailSdk, generateIntegrationsIndex, } from "../sync/lib.js";
|
|
8
8
|
import { gettableIntegrations, } from "../integrations/rules.js";
|
|
@@ -92,6 +92,7 @@ function getDeclaredEnvVarNames(appDir) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
function regenerateAppTypedWrappers(appDir) {
|
|
95
|
+
const runtime = isStartAppDir(appDir.path) ? "start" : "classic";
|
|
95
96
|
const outDir = join(appDir.path, ".zite");
|
|
96
97
|
mkdirSync(outDir, { recursive: true });
|
|
97
98
|
// user.ts and auth.ts no longer generated — User type is fixed in zitejs/auth
|
|
@@ -102,9 +103,16 @@ function regenerateAppTypedWrappers(appDir) {
|
|
|
102
103
|
if (emailIntegrationId) {
|
|
103
104
|
const intDir = join(outDir, "integrations");
|
|
104
105
|
mkdirSync(intDir, { recursive: true });
|
|
105
|
-
writeFileSync(join(intDir, "email.ts"), generateEmailSdk(emailIntegrationId));
|
|
106
|
+
writeFileSync(join(intDir, "email.ts"), generateEmailSdk(emailIntegrationId, runtime));
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
// A Start app's `zitejs/backend` is the package itself. This classic wrapper
|
|
109
|
+
// would only sit in its program with a second, id-only `hasRole`.
|
|
110
|
+
const backendPath = join(outDir, "backend.ts");
|
|
111
|
+
if (runtime === "start") {
|
|
112
|
+
rmSync(backendPath, { force: true });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
writeFileSync(backendPath, generateBackendWrapperTs(getDeclaredEnvVarNames(appDir)));
|
|
108
116
|
}
|
|
109
117
|
function regenerateAppApiTs(appDir) {
|
|
110
118
|
const apiDir = join(appDir.path, "src", "api");
|
|
@@ -153,7 +161,7 @@ function regenerateAppAirtableSdk(appDir) {
|
|
|
153
161
|
integrationId,
|
|
154
162
|
tables: int.idMappings.tables,
|
|
155
163
|
};
|
|
156
|
-
const content = generateAirtableTs(airtableLock);
|
|
164
|
+
const content = generateAirtableTs(airtableLock, isStartAppDir(appDir.path) ? "start" : "classic");
|
|
157
165
|
if (content) {
|
|
158
166
|
const outDir = join(appDir.path, ".zite", "integrations");
|
|
159
167
|
mkdirSync(outDir, { recursive: true });
|
|
@@ -185,7 +193,9 @@ export async function runGenerate() {
|
|
|
185
193
|
try {
|
|
186
194
|
if (existsSync("zite.schema.json")) {
|
|
187
195
|
const schema = JSON.parse(readFileSync("zite.schema.json", "utf-8"));
|
|
188
|
-
const dbTs = generateDbTs(schema
|
|
196
|
+
const dbTs = generateDbTs(schema, {
|
|
197
|
+
hasStartApps: workspaceHasStartApps(),
|
|
198
|
+
});
|
|
189
199
|
mkdirSync(".zite", { recursive: true });
|
|
190
200
|
writeFileSync(join(".zite", "db.ts"), dbTs);
|
|
191
201
|
console.log("Wrote .zite/db.ts");
|
|
@@ -38,11 +38,24 @@ declare const FIELDS_BY_TYPE: {
|
|
|
38
38
|
jira: readonly string[];
|
|
39
39
|
typeform: readonly string[];
|
|
40
40
|
apollo: readonly string[];
|
|
41
|
+
clay: readonly string[];
|
|
41
42
|
attio: readonly string[];
|
|
42
43
|
granola: readonly string[];
|
|
44
|
+
clickup: readonly string[];
|
|
43
45
|
dropbox: readonly string[];
|
|
46
|
+
zendesk: readonly string[];
|
|
47
|
+
smartsheet: readonly string[];
|
|
44
48
|
amazonS3: readonly string[];
|
|
45
49
|
snowflake: readonly string[];
|
|
50
|
+
databricks: readonly string[];
|
|
51
|
+
confluence: readonly string[];
|
|
52
|
+
pipedrive: readonly string[];
|
|
53
|
+
shopify: readonly string[];
|
|
54
|
+
sharepoint: readonly string[];
|
|
55
|
+
excel: readonly string[];
|
|
56
|
+
x: readonly string[];
|
|
57
|
+
zoomMeetings: readonly string[];
|
|
58
|
+
smartsuite: readonly string[];
|
|
46
59
|
};
|
|
47
60
|
/** A service type `integrations.get` serves: one used through its npm package with a token. */
|
|
48
61
|
export type CredentialServiceType = keyof typeof FIELDS_BY_TYPE;
|
|
@@ -44,15 +44,43 @@ const FIELDS_BY_TYPE = {
|
|
|
44
44
|
jira: extras("cloudId", "siteUrl"),
|
|
45
45
|
typeform: extras(),
|
|
46
46
|
apollo: extras(),
|
|
47
|
+
clay: extras(),
|
|
47
48
|
attio: extras(),
|
|
48
49
|
granola: extras(),
|
|
50
|
+
clickup: extras(),
|
|
49
51
|
dropbox: extras(),
|
|
52
|
+
// Every path is https://{subdomain}.zendesk.com/api/v2/..., and a token is
|
|
53
|
+
// only valid on the account it was issued for, so the subdomain travels with
|
|
54
|
+
// it rather than being configured per app.
|
|
55
|
+
zendesk: extras("subdomain"),
|
|
56
|
+
// Smartsheet's US, EU, AU and Gov regions are separate, and a token is only
|
|
57
|
+
// valid on its own region's host, so the host travels with it.
|
|
58
|
+
smartsheet: extras("apiBaseUrl"),
|
|
50
59
|
// The IAM key alone reaches nothing: every call needs the region and the
|
|
51
60
|
// bucket, and S3-compatible providers need the endpoint too.
|
|
52
61
|
amazonS3: extras("keyId", "region", "bucket", "endpoint", "pathPrefix"),
|
|
53
62
|
// The SQL API lives on each account's own host, and the token is pinned to
|
|
54
63
|
// one role; the warehouse is optional and falls back to the user's default.
|
|
55
64
|
snowflake: extras("accountUrl", "role", "warehouse"),
|
|
65
|
+
// A statement is addressed by workspace host and SQL warehouse, and the token
|
|
66
|
+
// derives neither.
|
|
67
|
+
databricks: extras("host", "warehouseId"),
|
|
68
|
+
// Cloud Confluence is addressed through api.atlassian.com by cloud id, the
|
|
69
|
+
// same as Jira; the site URL is only for links a human will click.
|
|
70
|
+
confluence: extras("cloudId", "siteUrl"),
|
|
71
|
+
// OAuth returns a per-company api_domain alongside the token, so there is no
|
|
72
|
+
// one host to call.
|
|
73
|
+
pipedrive: extras("apiBaseUrl"),
|
|
74
|
+
// Shopify has no global API host: every call goes to the store's own domain
|
|
75
|
+
// under a pinned API version. The storefront pair is the shopper-facing API;
|
|
76
|
+
// its URL comes from the store domain, so only the token can be missing.
|
|
77
|
+
shopify: extras("shopDomain", "apiBaseUrl", "storefrontApiUrl", "storefrontAccessToken"),
|
|
78
|
+
sharepoint: extras(),
|
|
79
|
+
excel: extras(),
|
|
80
|
+
x: extras(),
|
|
81
|
+
zoomMeetings: extras(),
|
|
82
|
+
// Every request names the workspace in an Account-Id header beside the key.
|
|
83
|
+
smartsuite: extras("workspaceId"),
|
|
56
84
|
};
|
|
57
85
|
/** Per service type: `accessToken`, then its extra labels sorted (Salesforce `instanceUrl`). */
|
|
58
86
|
export const CREDENTIAL_FIELDS = FIELDS_BY_TYPE;
|
|
@@ -65,6 +93,9 @@ export const OPTIONAL_CREDENTIAL_FIELDS = {
|
|
|
65
93
|
// Only S3-compatible providers set an endpoint, and a prefix is opt-in.
|
|
66
94
|
amazonS3: ["endpoint", "pathPrefix"],
|
|
67
95
|
snowflake: ["warehouse"],
|
|
96
|
+
// A store that didn't grant the storefront scopes gets no token, and
|
|
97
|
+
// Shopify then serves the Storefront API tokenless.
|
|
98
|
+
shopify: ["storefrontAccessToken"],
|
|
68
99
|
};
|
|
69
100
|
/**
|
|
70
101
|
* Types the runtime never serves: those with a generated client (Airtable, email,
|
|
@@ -16,6 +16,7 @@ describe("CREDENTIAL_FIELDS", () => {
|
|
|
16
16
|
]);
|
|
17
17
|
expect(CREDENTIAL_FIELDS.jira).toEqual(["accessToken", "cloudId", "siteUrl"]);
|
|
18
18
|
expect(CREDENTIAL_FIELDS.granola).toEqual(["accessToken"]);
|
|
19
|
+
expect(CREDENTIAL_FIELDS.smartsheet).toEqual(["accessToken", "apiBaseUrl"]);
|
|
19
20
|
});
|
|
20
21
|
it("has no type the runtime never serves", () => {
|
|
21
22
|
for (const type of NON_CREDENTIAL_SERVICE_TYPES) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Classic's upload client reads this too, so it imports nothing of Start: the
|
|
2
|
+
// request's host comes through the key src/start/host.ts reads it under.
|
|
3
|
+
const HOST_STORE_KEY = Symbol.for("zitejs:host-context");
|
|
4
|
+
// What a Start page was rendered with, kept in the browser when it hydrates.
|
|
5
|
+
const RENDERED_MODE = Symbol.for("zitejs:rendered-mode");
|
|
6
|
+
export const keepRenderedMode = (mode) => {
|
|
7
|
+
globalThis[RENDERED_MODE] = mode;
|
|
8
|
+
};
|
|
9
|
+
/** The mode the platform served this request or page in; undefined outside a Start app. */
|
|
10
|
+
export const platformMode = () => globalThis[HOST_STORE_KEY]?.getStore()?.mode ?? globalThis[RENDERED_MODE];
|
|
@@ -45,12 +45,12 @@ export type FilterOperators<V> = FilterCondition<V> | V;
|
|
|
45
45
|
* NOT `equals`, despite `formulas.ts` having a `case 'equals'`: that case only
|
|
46
46
|
* fires for the bare-value shorthand. `equals` is absent from
|
|
47
47
|
* `WhereConditionOperators`, so `isNestedCondition` doesn't recognize the
|
|
48
|
-
* object, the whole `{ equals: … }` is
|
|
49
|
-
*
|
|
48
|
+
* object, the whole `{ equals: … }` is taken as the value, and the filter
|
|
49
|
+
* fails.
|
|
50
50
|
*
|
|
51
|
-
* One operator per field on this path — `formulas.ts` reads
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* One operator per field on this path — `formulas.ts` reads the first key that
|
|
52
|
+
* is an operator and drops the rest, unlike the Zite DB filter builder which
|
|
53
|
+
* iterates them all.
|
|
54
54
|
*/
|
|
55
55
|
export type AirtableFilterCondition<V> = FilterCondition<V> & {
|
|
56
56
|
ilike?: V | V[];
|
|
@@ -85,20 +85,14 @@ export type FieldSelector<T> = Extract<keyof T, string> | (string & {});
|
|
|
85
85
|
export interface TableFindAllOptions<T = Record<string, unknown>> {
|
|
86
86
|
limit?: number;
|
|
87
87
|
offset?: number;
|
|
88
|
-
/**
|
|
89
|
-
* IGNORED on the table path. `DatabasesFindAllParamsSchema` has no `sort`
|
|
90
|
-
* key, so zod strips it before either dispatch, and neither destructures it.
|
|
91
|
-
* Kept in the type because removing it would only turn a silent no-op into a
|
|
92
|
-
* compile error for apps already passing it — the real fix is to forward it.
|
|
93
|
-
* It DOES work on `zite.auth.findAllUsers`, which is dispatched separately.
|
|
94
|
-
*/
|
|
88
|
+
/** `[{ field, direction }]`, applied in order. */
|
|
95
89
|
sort?: unknown[];
|
|
96
90
|
filters?: RecordFilters<T>;
|
|
97
91
|
/**
|
|
98
|
-
* The nested filter format (`filters` is the legacy flat one).
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
92
|
+
* The nested filter format (`filters` is the legacy flat one). Ignored here:
|
|
93
|
+
* `DatabasesFindAllParamsSchema` has no `filter`, so zod strips it, but it's
|
|
94
|
+
* kept so code already passing it still compiles. `zite.auth.findAllUsers`
|
|
95
|
+
* honors it.
|
|
102
96
|
*/
|
|
103
97
|
filter?: unknown;
|
|
104
98
|
fields?: Array<FieldSelector<T>>;
|
|
@@ -263,7 +257,7 @@ export interface AirtableTableClient<T, TInput = T> {
|
|
|
263
257
|
}): Promise<DeleteResult>;
|
|
264
258
|
}
|
|
265
259
|
export declare function createAirtableClient<T, TInput = T>(integrationId: string, className: string, implicitParams: Record<string, unknown>): AirtableTableClient<T, TInput>;
|
|
266
|
-
/** A block of
|
|
260
|
+
/** A block of the older `body` format. New emails are written with `html`. */
|
|
267
261
|
export type EmailBlock = {
|
|
268
262
|
type: "text";
|
|
269
263
|
content: string;
|
|
@@ -272,6 +266,12 @@ export type EmailBlock = {
|
|
|
272
266
|
label: string;
|
|
273
267
|
href: string;
|
|
274
268
|
alignment?: "left" | "center" | "right";
|
|
269
|
+
/** Hex colour, e.g. "#7c2d3a". Defaults to the platform blue. */
|
|
270
|
+
backgroundColor?: string;
|
|
271
|
+
/** Hex colour. Defaults to white. */
|
|
272
|
+
textColor?: string;
|
|
273
|
+
/** Corner radius in pixels. Defaults to 6. */
|
|
274
|
+
borderRadius?: number;
|
|
275
275
|
} | {
|
|
276
276
|
type: "image";
|
|
277
277
|
src: string;
|
|
@@ -286,25 +286,23 @@ export type EmailBlock = {
|
|
|
286
286
|
type: "divider";
|
|
287
287
|
borderColor?: string;
|
|
288
288
|
};
|
|
289
|
-
|
|
289
|
+
interface SendEmailBaseParams {
|
|
290
290
|
/** Recipient address(es). Must be valid emails — never placeholders like "me". */
|
|
291
291
|
to: string | string[];
|
|
292
292
|
subject: string;
|
|
293
|
-
/** Email body as an array of content blocks. */
|
|
294
|
-
body: EmailBlock[];
|
|
295
293
|
cc?: string[];
|
|
296
294
|
bcc?: string[];
|
|
297
295
|
replyTo?: string;
|
|
298
|
-
/** 'formatted' (default) for styled HTML, 'plain' for text-only. */
|
|
299
|
-
layout?: "formatted" | "plain";
|
|
300
296
|
/**
|
|
301
297
|
* Text direction of the email. Use 'rtl' for right-to-left languages
|
|
302
298
|
* (Hebrew, Arabic) — sets dir="rtl" on the email wrapper and right-aligns
|
|
303
|
-
* text
|
|
304
|
-
* by the sanitizer and will NOT work. Defaults to 'ltr'.
|
|
299
|
+
* text. Defaults to 'ltr'.
|
|
305
300
|
*/
|
|
306
301
|
direction?: "ltr" | "rtl";
|
|
307
|
-
/**
|
|
302
|
+
/**
|
|
303
|
+
* Logo shown above the email content (header area), for branding. On an
|
|
304
|
+
* html email it replaces the brand kit's logo.
|
|
305
|
+
*/
|
|
308
306
|
logo?: {
|
|
309
307
|
url: string;
|
|
310
308
|
width?: number;
|
|
@@ -317,9 +315,50 @@ export interface SendEmailParams {
|
|
|
317
315
|
contentType?: string;
|
|
318
316
|
}[];
|
|
319
317
|
}
|
|
318
|
+
/** An email written as HTML. */
|
|
319
|
+
export interface SendHtmlEmailParams extends SendEmailBaseParams {
|
|
320
|
+
/**
|
|
321
|
+
* Email-safe HTML: tables for layout, inline styles, `<a class="button">`
|
|
322
|
+
* for buttons. Sanitized and its `<style>` rules inlined at send time.
|
|
323
|
+
*/
|
|
324
|
+
html: string;
|
|
325
|
+
/** Plain-text part. Generated from `html` when omitted. */
|
|
326
|
+
text?: string;
|
|
327
|
+
/**
|
|
328
|
+
* 'formatted' (default) puts the html in a card under the logo, in the
|
|
329
|
+
* app's brand kit; 'plain' drops the card and logo.
|
|
330
|
+
*/
|
|
331
|
+
layout?: "formatted" | "plain";
|
|
332
|
+
/**
|
|
333
|
+
* Hex colour around the card, or behind a plain email's text as a sheet
|
|
334
|
+
* the width of its column. Defaults to the brand kit's.
|
|
335
|
+
*/
|
|
336
|
+
background?: string;
|
|
337
|
+
/** Hex colour of the card in a formatted email. Defaults to the brand kit's. */
|
|
338
|
+
cardBackground?: string;
|
|
339
|
+
body?: never;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* An email in the older block format. Existing emails keep working; new ones
|
|
343
|
+
* are written with `html`.
|
|
344
|
+
*/
|
|
345
|
+
export interface SendBlocksEmailParams extends SendEmailBaseParams {
|
|
346
|
+
/** Email body as an array of content blocks. */
|
|
347
|
+
body: EmailBlock[];
|
|
348
|
+
/**
|
|
349
|
+
* 'formatted' (default) for styled HTML, 'plain' for text-only. HTML like
|
|
350
|
+
* `<div dir="rtl">` inside text blocks is stripped by the sanitizer.
|
|
351
|
+
*/
|
|
352
|
+
layout?: "formatted" | "plain";
|
|
353
|
+
html?: never;
|
|
354
|
+
text?: never;
|
|
355
|
+
}
|
|
356
|
+
export type SendEmailParams = SendHtmlEmailParams | SendBlocksEmailParams;
|
|
320
357
|
export interface SendEmailResult {
|
|
321
358
|
success: boolean;
|
|
322
359
|
messageId: string;
|
|
360
|
+
/** Problems that did not stop the send, e.g. an email large enough for Gmail to clip. */
|
|
361
|
+
warnings?: string[];
|
|
323
362
|
}
|
|
324
363
|
export interface EmailClient {
|
|
325
364
|
send(params: SendEmailParams): Promise<SendEmailResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { expectTypeOf, test } from "vitest";
|
|
2
|
+
test("an email is written as html or as blocks, not both", () => {
|
|
3
|
+
expectTypeOf({
|
|
4
|
+
to: "a@example.com",
|
|
5
|
+
subject: "Hi",
|
|
6
|
+
html: "<p>Hi</p>",
|
|
7
|
+
layout: "plain",
|
|
8
|
+
background: "#e8efe6",
|
|
9
|
+
}).toExtend();
|
|
10
|
+
expectTypeOf({
|
|
11
|
+
to: "a@example.com",
|
|
12
|
+
subject: "Hi",
|
|
13
|
+
body: [{ type: "text", content: "Hi" }],
|
|
14
|
+
}).toExtend();
|
|
15
|
+
expectTypeOf({
|
|
16
|
+
to: "a@example.com",
|
|
17
|
+
subject: "Hi",
|
|
18
|
+
html: "<p>Hi</p>",
|
|
19
|
+
body: [],
|
|
20
|
+
}).not.toExtend();
|
|
21
|
+
expectTypeOf({
|
|
22
|
+
to: "a@example.com",
|
|
23
|
+
subject: "Hi",
|
|
24
|
+
html: "<p>Hi</p>",
|
|
25
|
+
layout: "none",
|
|
26
|
+
}).not.toExtend();
|
|
27
|
+
expectTypeOf({
|
|
28
|
+
to: "a@example.com",
|
|
29
|
+
subject: "Hi",
|
|
30
|
+
}).not.toExtend();
|
|
31
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
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 and Anthropic; the host meters Zite's own key itself.
|
|
5
|
+
*/
|
|
6
|
+
export type AiProvider = "openai" | "anthropic";
|
|
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
|
+
/** The response to hand the app, and its usage once read; a stream is split so the app reads one copy as it arrives. */
|
|
20
|
+
export declare const meterAiResponse: (provider: AiProvider, response: Response) => {
|
|
21
|
+
response: Response;
|
|
22
|
+
usage: Promise<AiUsageRecord | undefined>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
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 and Anthropic; the host meters Zite's own key itself.
|
|
5
|
+
*/
|
|
6
|
+
export const AI_USAGE_HOSTS = {
|
|
7
|
+
"api.openai.com": "openai",
|
|
8
|
+
"api.anthropic.com": "anthropic",
|
|
9
|
+
};
|
|
10
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
|
+
const isNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
12
|
+
/** As classic: an OpenAI chat stream reports its usage only when asked to. The body to send instead, if any. */
|
|
13
|
+
export const withStreamUsage = (url, method, body) => {
|
|
14
|
+
if (method !== "POST" || typeof body !== "string" || !url.pathname.endsWith("/chat/completions"))
|
|
15
|
+
return undefined;
|
|
16
|
+
try {
|
|
17
|
+
const json = JSON.parse(body);
|
|
18
|
+
if (!isRecord(json) || json.stream !== true)
|
|
19
|
+
return undefined;
|
|
20
|
+
const options = isRecord(json.stream_options) ? json.stream_options : {};
|
|
21
|
+
if (options.include_usage === true)
|
|
22
|
+
return undefined;
|
|
23
|
+
return JSON.stringify({ ...json, stream_options: { ...options, include_usage: true } });
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
// OpenAI counts cached tokens inside its input; classic takes them apart.
|
|
30
|
+
const tokensFromJson = (provider, body) => {
|
|
31
|
+
const tokens = {};
|
|
32
|
+
if (!isRecord(body))
|
|
33
|
+
return tokens;
|
|
34
|
+
if (provider === "openai") {
|
|
35
|
+
const source = isRecord(body.response) ? body.response : body;
|
|
36
|
+
if (typeof source.model === "string")
|
|
37
|
+
tokens.model = source.model;
|
|
38
|
+
const usage = isRecord(source.usage) ? source.usage : undefined;
|
|
39
|
+
if (!usage)
|
|
40
|
+
return tokens;
|
|
41
|
+
const details = (name) => (isRecord(usage[name]) ? usage[name] : {});
|
|
42
|
+
const cached = details("prompt_tokens_details").cached_tokens ?? details("input_tokens_details").cached_tokens;
|
|
43
|
+
const input = usage.prompt_tokens ?? usage.input_tokens;
|
|
44
|
+
const output = usage.completion_tokens ?? usage.output_tokens;
|
|
45
|
+
if (isNumber(input))
|
|
46
|
+
tokens.inputTokens = input - (isNumber(cached) ? cached : 0);
|
|
47
|
+
if (isNumber(output))
|
|
48
|
+
tokens.outputTokens = output;
|
|
49
|
+
if (isNumber(cached))
|
|
50
|
+
tokens.cachedReadInputTokens = cached;
|
|
51
|
+
return tokens;
|
|
52
|
+
}
|
|
53
|
+
// A stream splits these: message_start has the input, message_delta the running output.
|
|
54
|
+
const message = isRecord(body.message) ? body.message : body;
|
|
55
|
+
if (typeof message.model === "string")
|
|
56
|
+
tokens.model = message.model;
|
|
57
|
+
const usage = isRecord(message.usage) ? message.usage : isRecord(body.usage) ? body.usage : undefined;
|
|
58
|
+
if (!usage)
|
|
59
|
+
return tokens;
|
|
60
|
+
if (isNumber(usage.input_tokens))
|
|
61
|
+
tokens.inputTokens = usage.input_tokens;
|
|
62
|
+
if (isNumber(usage.output_tokens))
|
|
63
|
+
tokens.outputTokens = usage.output_tokens;
|
|
64
|
+
if (isNumber(usage.cache_read_input_tokens))
|
|
65
|
+
tokens.cachedReadInputTokens = usage.cache_read_input_tokens;
|
|
66
|
+
if (isNumber(usage.cache_creation_input_tokens))
|
|
67
|
+
tokens.cacheCreationInputTokens = usage.cache_creation_input_tokens;
|
|
68
|
+
return tokens;
|
|
69
|
+
};
|
|
70
|
+
// Later readings win: Anthropic's output is cumulative, OpenAI's usage comes last.
|
|
71
|
+
const merge = (into, next) => ({
|
|
72
|
+
model: next.model ?? into.model,
|
|
73
|
+
inputTokens: next.inputTokens ?? into.inputTokens,
|
|
74
|
+
outputTokens: next.outputTokens ?? into.outputTokens,
|
|
75
|
+
cachedReadInputTokens: next.cachedReadInputTokens ?? into.cachedReadInputTokens,
|
|
76
|
+
cacheCreationInputTokens: next.cacheCreationInputTokens ?? into.cacheCreationInputTokens,
|
|
77
|
+
});
|
|
78
|
+
const MAX_PENDING_LINE = 1024 * 1024;
|
|
79
|
+
const tokensFromStream = async (provider, stream) => {
|
|
80
|
+
const reader = stream.getReader();
|
|
81
|
+
const decoder = new TextDecoder();
|
|
82
|
+
let pending = "";
|
|
83
|
+
let tokens = {};
|
|
84
|
+
const readLine = (line) => {
|
|
85
|
+
if (!line.startsWith("data:"))
|
|
86
|
+
return;
|
|
87
|
+
const payload = line.slice(5).trim();
|
|
88
|
+
if (!payload || payload === "[DONE]")
|
|
89
|
+
return;
|
|
90
|
+
try {
|
|
91
|
+
tokens = merge(tokens, tokensFromJson(provider, JSON.parse(payload)));
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Not JSON; nothing to count.
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
try {
|
|
98
|
+
for (;;) {
|
|
99
|
+
const { done, value } = await reader.read();
|
|
100
|
+
if (done)
|
|
101
|
+
break;
|
|
102
|
+
pending += decoder.decode(value, { stream: true });
|
|
103
|
+
const lines = pending.split("\n");
|
|
104
|
+
pending = lines.pop() ?? "";
|
|
105
|
+
if (pending.length > MAX_PENDING_LINE)
|
|
106
|
+
pending = "";
|
|
107
|
+
lines.forEach(readLine);
|
|
108
|
+
}
|
|
109
|
+
readLine(pending);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// What was read before the stream broke still counts.
|
|
113
|
+
}
|
|
114
|
+
return tokens;
|
|
115
|
+
};
|
|
116
|
+
const counted = (tokens) => tokens.inputTokens !== undefined || tokens.outputTokens !== undefined;
|
|
117
|
+
const usageOf = (provider, tokens, streaming) => counted(tokens)
|
|
118
|
+
? {
|
|
119
|
+
provider,
|
|
120
|
+
...Object.fromEntries(Object.entries(tokens).filter(([, value]) => value !== undefined)),
|
|
121
|
+
...(streaming && { isStreaming: true }),
|
|
122
|
+
}
|
|
123
|
+
: undefined;
|
|
124
|
+
/** The response to hand the app, and its usage once read; a stream is split so the app reads one copy as it arrives. */
|
|
125
|
+
export const meterAiResponse = (provider, response) => {
|
|
126
|
+
const type = response.headers.get("content-type") ?? "";
|
|
127
|
+
if (!response.ok || !response.body)
|
|
128
|
+
return { response, usage: Promise.resolve(undefined) };
|
|
129
|
+
if (type.includes("text/event-stream")) {
|
|
130
|
+
const [forApp, forUs] = response.body.tee();
|
|
131
|
+
return {
|
|
132
|
+
response: new Response(forApp, response),
|
|
133
|
+
usage: tokensFromStream(provider, forUs).then((tokens) => usageOf(provider, tokens, true)),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (!type.includes("json"))
|
|
137
|
+
return { response, usage: Promise.resolve(undefined) };
|
|
138
|
+
return {
|
|
139
|
+
response,
|
|
140
|
+
usage: response
|
|
141
|
+
.clone()
|
|
142
|
+
.json()
|
|
143
|
+
.then((json) => usageOf(provider, tokensFromJson(provider, json), false))
|
|
144
|
+
.catch(() => undefined),
|
|
145
|
+
};
|
|
146
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type AirtableFieldShape = {
|
|
2
|
+
type: string;
|
|
3
|
+
options?: unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare const isArrayValuedAirtableField: (field: AirtableFieldShape) => boolean;
|
|
6
|
+
export declare const airtableEqualsFormula: ({ field, fieldName, value, }: {
|
|
7
|
+
field: AirtableFieldShape;
|
|
8
|
+
fieldName: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}) => string;
|