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,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.findTsgo = findTsgo;
|
|
7
|
+
// TypeScript's native compiler, as the platform's checks run it, found the same
|
|
8
|
+
// way every time: never from PATH, so a check here and one in the sandbox use
|
|
9
|
+
// the same compiler.
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_module_1 = require("node:module");
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const PACKAGE = "@typescript/native-preview";
|
|
14
|
+
// Where `npm install -g` put it for the node running this: the sandbox image's.
|
|
15
|
+
const globalRoot = () => process.env.npm_config_prefix
|
|
16
|
+
? node_path_1.default.join(process.env.npm_config_prefix, process.platform === "win32" ? "node_modules" : "lib/node_modules")
|
|
17
|
+
: process.platform === "win32"
|
|
18
|
+
? node_path_1.default.join(node_path_1.default.dirname(process.execPath), "node_modules")
|
|
19
|
+
: node_path_1.default.join(node_path_1.default.dirname(node_path_1.default.dirname(process.execPath)), "lib", "node_modules");
|
|
20
|
+
/** tsgo's launcher: the app's own, walking up from it as Node does, else the global install beside this node. */
|
|
21
|
+
function findTsgo(appDir) {
|
|
22
|
+
let manifest;
|
|
23
|
+
try {
|
|
24
|
+
manifest = (0, node_module_1.createRequire)(node_path_1.default.join(node_path_1.default.resolve(appDir), "package.json")).resolve(`${PACKAGE}/package.json`);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
const global = node_path_1.default.join(globalRoot(), PACKAGE, "package.json");
|
|
28
|
+
manifest = (0, node_fs_1.existsSync)(global) ? global : undefined;
|
|
29
|
+
}
|
|
30
|
+
if (!manifest)
|
|
31
|
+
return undefined;
|
|
32
|
+
const { bin } = JSON.parse((0, node_fs_1.readFileSync)(manifest, "utf-8"));
|
|
33
|
+
const launcher = typeof bin === "string" ? bin : bin?.tsgo;
|
|
34
|
+
return launcher ? node_path_1.default.join(node_path_1.default.dirname(manifest), launcher) : undefined;
|
|
35
|
+
}
|
package/dist/cjs/cli.js
CHANGED
|
@@ -80,7 +80,7 @@ async function main() {
|
|
|
80
80
|
console.error(' sync Generate .zite/db.ts from database schema (single-app)');
|
|
81
81
|
console.error(' dev Run sync then watch for changes (like npx convex dev)');
|
|
82
82
|
console.error(' generate Regenerate every app and automation .zite/ (monorepo)');
|
|
83
|
-
console.error(' check
|
|
83
|
+
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)');
|
|
84
84
|
console.error(' bundle Bundle endpoints (src/api/*.ts, or an automation\'s src/index.ts) for cloudflare-lambda');
|
|
85
85
|
console.error(' describe Print what a built TanStack Start app declares: functions, routes, access');
|
|
86
86
|
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/cjs/dev/index.js
CHANGED
|
@@ -97,6 +97,7 @@ function getDeclaredEnvVarNames(appDir) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
function regenerateAppTypedWrappers(appDir) {
|
|
100
|
+
const runtime = (0, entries_js_1.isStartAppDir)(appDir.path) ? "start" : "classic";
|
|
100
101
|
const outDir = (0, path_1.join)(appDir.path, ".zite");
|
|
101
102
|
(0, fs_2.mkdirSync)(outDir, { recursive: true });
|
|
102
103
|
// user.ts and auth.ts no longer generated — User type is fixed in zitejs/auth
|
|
@@ -107,9 +108,16 @@ function regenerateAppTypedWrappers(appDir) {
|
|
|
107
108
|
if (emailIntegrationId) {
|
|
108
109
|
const intDir = (0, path_1.join)(outDir, "integrations");
|
|
109
110
|
(0, fs_2.mkdirSync)(intDir, { recursive: true });
|
|
110
|
-
(0, fs_2.writeFileSync)((0, path_1.join)(intDir, "email.ts"), (0, lib_js_1.generateEmailSdk)(emailIntegrationId));
|
|
111
|
+
(0, fs_2.writeFileSync)((0, path_1.join)(intDir, "email.ts"), (0, lib_js_1.generateEmailSdk)(emailIntegrationId, runtime));
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
+
// A Start app's `zitejs/backend` is the package itself. This classic wrapper
|
|
114
|
+
// would only sit in its program with a second, id-only `hasRole`.
|
|
115
|
+
const backendPath = (0, path_1.join)(outDir, "backend.ts");
|
|
116
|
+
if (runtime === "start") {
|
|
117
|
+
(0, fs_2.rmSync)(backendPath, { force: true });
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
(0, fs_2.writeFileSync)(backendPath, (0, lib_js_1.generateBackendWrapperTs)(getDeclaredEnvVarNames(appDir)));
|
|
113
121
|
}
|
|
114
122
|
function regenerateAppApiTs(appDir) {
|
|
115
123
|
const apiDir = (0, path_1.join)(appDir.path, "src", "api");
|
|
@@ -158,7 +166,7 @@ function regenerateAppAirtableSdk(appDir) {
|
|
|
158
166
|
integrationId,
|
|
159
167
|
tables: int.idMappings.tables,
|
|
160
168
|
};
|
|
161
|
-
const content = (0, lib_js_1.generateAirtableTs)(airtableLock);
|
|
169
|
+
const content = (0, lib_js_1.generateAirtableTs)(airtableLock, (0, entries_js_1.isStartAppDir)(appDir.path) ? "start" : "classic");
|
|
162
170
|
if (content) {
|
|
163
171
|
const outDir = (0, path_1.join)(appDir.path, ".zite", "integrations");
|
|
164
172
|
(0, fs_2.mkdirSync)(outDir, { recursive: true });
|
|
@@ -190,7 +198,9 @@ async function runGenerate() {
|
|
|
190
198
|
try {
|
|
191
199
|
if ((0, fs_2.existsSync)("zite.schema.json")) {
|
|
192
200
|
const schema = JSON.parse((0, fs_2.readFileSync)("zite.schema.json", "utf-8"));
|
|
193
|
-
const dbTs = (0, lib_js_1.generateDbTs)(schema
|
|
201
|
+
const dbTs = (0, lib_js_1.generateDbTs)(schema, {
|
|
202
|
+
hasStartApps: (0, entries_js_1.workspaceHasStartApps)(),
|
|
203
|
+
});
|
|
194
204
|
(0, fs_2.mkdirSync)(".zite", { recursive: true });
|
|
195
205
|
(0, fs_2.writeFileSync)((0, path_1.join)(".zite", "db.ts"), dbTs);
|
|
196
206
|
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;
|
|
@@ -47,15 +47,43 @@ const FIELDS_BY_TYPE = {
|
|
|
47
47
|
jira: extras("cloudId", "siteUrl"),
|
|
48
48
|
typeform: extras(),
|
|
49
49
|
apollo: extras(),
|
|
50
|
+
clay: extras(),
|
|
50
51
|
attio: extras(),
|
|
51
52
|
granola: extras(),
|
|
53
|
+
clickup: extras(),
|
|
52
54
|
dropbox: extras(),
|
|
55
|
+
// Every path is https://{subdomain}.zendesk.com/api/v2/..., and a token is
|
|
56
|
+
// only valid on the account it was issued for, so the subdomain travels with
|
|
57
|
+
// it rather than being configured per app.
|
|
58
|
+
zendesk: extras("subdomain"),
|
|
59
|
+
// Smartsheet's US, EU, AU and Gov regions are separate, and a token is only
|
|
60
|
+
// valid on its own region's host, so the host travels with it.
|
|
61
|
+
smartsheet: extras("apiBaseUrl"),
|
|
53
62
|
// The IAM key alone reaches nothing: every call needs the region and the
|
|
54
63
|
// bucket, and S3-compatible providers need the endpoint too.
|
|
55
64
|
amazonS3: extras("keyId", "region", "bucket", "endpoint", "pathPrefix"),
|
|
56
65
|
// The SQL API lives on each account's own host, and the token is pinned to
|
|
57
66
|
// one role; the warehouse is optional and falls back to the user's default.
|
|
58
67
|
snowflake: extras("accountUrl", "role", "warehouse"),
|
|
68
|
+
// A statement is addressed by workspace host and SQL warehouse, and the token
|
|
69
|
+
// derives neither.
|
|
70
|
+
databricks: extras("host", "warehouseId"),
|
|
71
|
+
// Cloud Confluence is addressed through api.atlassian.com by cloud id, the
|
|
72
|
+
// same as Jira; the site URL is only for links a human will click.
|
|
73
|
+
confluence: extras("cloudId", "siteUrl"),
|
|
74
|
+
// OAuth returns a per-company api_domain alongside the token, so there is no
|
|
75
|
+
// one host to call.
|
|
76
|
+
pipedrive: extras("apiBaseUrl"),
|
|
77
|
+
// Shopify has no global API host: every call goes to the store's own domain
|
|
78
|
+
// under a pinned API version. The storefront pair is the shopper-facing API;
|
|
79
|
+
// its URL comes from the store domain, so only the token can be missing.
|
|
80
|
+
shopify: extras("shopDomain", "apiBaseUrl", "storefrontApiUrl", "storefrontAccessToken"),
|
|
81
|
+
sharepoint: extras(),
|
|
82
|
+
excel: extras(),
|
|
83
|
+
x: extras(),
|
|
84
|
+
zoomMeetings: extras(),
|
|
85
|
+
// Every request names the workspace in an Account-Id header beside the key.
|
|
86
|
+
smartsuite: extras("workspaceId"),
|
|
59
87
|
};
|
|
60
88
|
/** Per service type: `accessToken`, then its extra labels sorted (Salesforce `instanceUrl`). */
|
|
61
89
|
exports.CREDENTIAL_FIELDS = FIELDS_BY_TYPE;
|
|
@@ -68,6 +96,9 @@ exports.OPTIONAL_CREDENTIAL_FIELDS = {
|
|
|
68
96
|
// Only S3-compatible providers set an endpoint, and a prefix is opt-in.
|
|
69
97
|
amazonS3: ["endpoint", "pathPrefix"],
|
|
70
98
|
snowflake: ["warehouse"],
|
|
99
|
+
// A store that didn't grant the storefront scopes gets no token, and
|
|
100
|
+
// Shopify then serves the Storefront API tokenless.
|
|
101
|
+
shopify: ["storefrontAccessToken"],
|
|
71
102
|
};
|
|
72
103
|
/**
|
|
73
104
|
* Types the runtime never serves: those with a generated client (Airtable, email,
|
|
@@ -18,6 +18,7 @@ const index_js_1 = require("../index.js");
|
|
|
18
18
|
]);
|
|
19
19
|
(0, vitest_1.expect)(index_js_1.CREDENTIAL_FIELDS.jira).toEqual(["accessToken", "cloudId", "siteUrl"]);
|
|
20
20
|
(0, vitest_1.expect)(index_js_1.CREDENTIAL_FIELDS.granola).toEqual(["accessToken"]);
|
|
21
|
+
(0, vitest_1.expect)(index_js_1.CREDENTIAL_FIELDS.smartsheet).toEqual(["accessToken", "apiBaseUrl"]);
|
|
21
22
|
});
|
|
22
23
|
(0, vitest_1.it)("has no type the runtime never serves", () => {
|
|
23
24
|
for (const type of index_js_1.NON_CREDENTIAL_SERVICE_TYPES) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.platformMode = exports.keepRenderedMode = void 0;
|
|
4
|
+
// Classic's upload client reads this too, so it imports nothing of Start: the
|
|
5
|
+
// request's host comes through the key src/start/host.ts reads it under.
|
|
6
|
+
const HOST_STORE_KEY = Symbol.for("zitejs:host-context");
|
|
7
|
+
// What a Start page was rendered with, kept in the browser when it hydrates.
|
|
8
|
+
const RENDERED_MODE = Symbol.for("zitejs:rendered-mode");
|
|
9
|
+
const keepRenderedMode = (mode) => {
|
|
10
|
+
globalThis[RENDERED_MODE] = mode;
|
|
11
|
+
};
|
|
12
|
+
exports.keepRenderedMode = keepRenderedMode;
|
|
13
|
+
/** The mode the platform served this request or page in; undefined outside a Start app. */
|
|
14
|
+
const platformMode = () => globalThis[HOST_STORE_KEY]?.getStore()?.mode ?? globalThis[RENDERED_MODE];
|
|
15
|
+
exports.platformMode = platformMode;
|
|
@@ -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,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
(0, vitest_1.test)("an email is written as html or as blocks, not both", () => {
|
|
5
|
+
(0, vitest_1.expectTypeOf)({
|
|
6
|
+
to: "a@example.com",
|
|
7
|
+
subject: "Hi",
|
|
8
|
+
html: "<p>Hi</p>",
|
|
9
|
+
layout: "plain",
|
|
10
|
+
background: "#e8efe6",
|
|
11
|
+
}).toExtend();
|
|
12
|
+
(0, vitest_1.expectTypeOf)({
|
|
13
|
+
to: "a@example.com",
|
|
14
|
+
subject: "Hi",
|
|
15
|
+
body: [{ type: "text", content: "Hi" }],
|
|
16
|
+
}).toExtend();
|
|
17
|
+
(0, vitest_1.expectTypeOf)({
|
|
18
|
+
to: "a@example.com",
|
|
19
|
+
subject: "Hi",
|
|
20
|
+
html: "<p>Hi</p>",
|
|
21
|
+
body: [],
|
|
22
|
+
}).not.toExtend();
|
|
23
|
+
(0, vitest_1.expectTypeOf)({
|
|
24
|
+
to: "a@example.com",
|
|
25
|
+
subject: "Hi",
|
|
26
|
+
html: "<p>Hi</p>",
|
|
27
|
+
layout: "none",
|
|
28
|
+
}).not.toExtend();
|
|
29
|
+
(0, vitest_1.expectTypeOf)({
|
|
30
|
+
to: "a@example.com",
|
|
31
|
+
subject: "Hi",
|
|
32
|
+
}).not.toExtend();
|
|
33
|
+
});
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SourceDir } from "../sourceRoots.js";
|
|
2
2
|
export declare const START_SERVER_ENTRY = ".zite/server.ts";
|
|
3
3
|
export declare const START_INSTANCE_ENTRY = ".zite/start.ts";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export type StartTarget = "cloudflare" | "node";
|
|
5
|
+
/**
|
|
6
|
+
* The server entry every Start app builds with. Platform-owned: regenerated,
|
|
7
|
+
* never edited. On Workers it's an entrypoint, so the host can hand each fetch
|
|
8
|
+
* its props; on Node, a plain fetch handler.
|
|
9
|
+
*/
|
|
10
|
+
export declare const renderStartServerEntry: (target?: StartTarget) => string;
|
|
6
11
|
/** The start instance: the platform's middleware, then the app's own `src/start.ts` when it has one. */
|
|
7
12
|
export declare const renderStartInstance: (hasAppStart: boolean) => string;
|
|
8
13
|
export declare const hasAppStart: (appDir: string) => boolean;
|
|
9
14
|
/** Writes `file` under `appDir` when its content differs. Returns whether it wrote. */
|
|
10
15
|
export declare const writeIfChanged: (appDir: string, file: string, content: string) => boolean;
|
|
11
16
|
export declare const isStartAppDir: (appPath: string) => boolean;
|
|
17
|
+
export declare const workspaceHasStartApps: () => boolean;
|
|
12
18
|
export declare function regenerateStartEntries(app: SourceDir): void;
|
|
13
|
-
/** App modules that mention
|
|
19
|
+
/** App modules that mention createAutomation: what the workflow registry imports. Describe decides what each one really exports. */
|
|
14
20
|
export declare function workflowFiles(appDir: string): string[];
|
|
15
21
|
/** The registry zite() builds in place of zitejs's empty one. */
|
|
16
22
|
export declare const renderWorkflowModules: (appDir: string, files: string[]) => string;
|
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderWorkflowModules = exports.isStartAppDir = exports.writeIfChanged = exports.hasAppStart = exports.renderStartInstance = exports.renderStartServerEntry = exports.START_INSTANCE_ENTRY = exports.START_SERVER_ENTRY = void 0;
|
|
3
|
+
exports.renderWorkflowModules = exports.workspaceHasStartApps = exports.isStartAppDir = exports.writeIfChanged = exports.hasAppStart = exports.renderStartInstance = exports.renderStartServerEntry = exports.START_INSTANCE_ENTRY = exports.START_SERVER_ENTRY = void 0;
|
|
4
4
|
exports.regenerateStartEntries = regenerateStartEntries;
|
|
5
5
|
exports.workflowFiles = workflowFiles;
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
|
+
const sourceRoots_js_1 = require("../sourceRoots.js");
|
|
8
9
|
exports.START_SERVER_ENTRY = ".zite/server.ts";
|
|
9
10
|
exports.START_INSTANCE_ENTRY = ".zite/start.ts";
|
|
10
11
|
const APP_START_FILES = ["src/start.ts", "src/start.tsx"];
|
|
11
|
-
/**
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The server entry every Start app builds with. Platform-owned: regenerated,
|
|
14
|
+
* never edited. On Workers it's an entrypoint, so the host can hand each fetch
|
|
15
|
+
* its props; on Node, a plain fetch handler.
|
|
16
|
+
*/
|
|
17
|
+
const renderStartServerEntry = (target = "cloudflare") => target === "cloudflare"
|
|
18
|
+
? `// Generated by zitejs for TanStack Start apps. The platform owns this file.
|
|
19
|
+
import handler from '@tanstack/react-start/server-entry';
|
|
20
|
+
import { createZiteWorker } from 'zitejs/start/worker';
|
|
21
|
+
import { getRouter } from '../src/router';
|
|
22
|
+
import { startInstance } from './start';
|
|
23
|
+
|
|
24
|
+
export default createZiteWorker({ handler, getRouter, startInstance });
|
|
25
|
+
`
|
|
26
|
+
: `// Generated by zitejs for TanStack Start apps. The platform owns this file.
|
|
13
27
|
import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
|
|
14
28
|
import { createZiteFetch } from 'zitejs/start/server';
|
|
15
29
|
import { getRouter } from '../src/router';
|
|
30
|
+
import { startInstance } from './start';
|
|
16
31
|
|
|
17
|
-
export default createServerEntry({ fetch: createZiteFetch({ handler, getRouter }) });
|
|
32
|
+
export default createServerEntry({ fetch: createZiteFetch({ handler, getRouter, startInstance }) });
|
|
18
33
|
`;
|
|
19
34
|
exports.renderStartServerEntry = renderStartServerEntry;
|
|
20
35
|
/** The start instance: the platform's middleware, then the app's own `src/start.ts` when it has one. */
|
|
@@ -53,6 +68,8 @@ const isStartAppDir = (appPath) => {
|
|
|
53
68
|
};
|
|
54
69
|
exports.isStartAppDir = isStartAppDir;
|
|
55
70
|
const isStartApp = (app) => (0, exports.isStartAppDir)(app.path);
|
|
71
|
+
const workspaceHasStartApps = () => (0, sourceRoots_js_1.listSourceDirs)().some(isStartApp);
|
|
72
|
+
exports.workspaceHasStartApps = workspaceHasStartApps;
|
|
56
73
|
function regenerateStartEntries(app) {
|
|
57
74
|
if (!isStartApp(app))
|
|
58
75
|
return;
|
|
@@ -67,7 +84,7 @@ function regenerateStartEntries(app) {
|
|
|
67
84
|
}
|
|
68
85
|
const SOURCE_FILE = /\.[mc]?[jt]sx?$/;
|
|
69
86
|
const NOT_APP_CODE = /(\.(test|spec)\.[^.]+|\.d\.ts|routeTree\.gen\.ts)$/;
|
|
70
|
-
/** App modules that mention
|
|
87
|
+
/** App modules that mention createAutomation: what the workflow registry imports. Describe decides what each one really exports. */
|
|
71
88
|
function workflowFiles(appDir) {
|
|
72
89
|
const found = [];
|
|
73
90
|
const walk = (dir) => {
|
|
@@ -77,7 +94,7 @@ function workflowFiles(appDir) {
|
|
|
77
94
|
if (entry.name !== "node_modules")
|
|
78
95
|
walk(full);
|
|
79
96
|
}
|
|
80
|
-
else if (SOURCE_FILE.test(entry.name) && !NOT_APP_CODE.test(entry.name) && (0, node_fs_1.readFileSync)(full, "utf-8").includes("
|
|
97
|
+
else if (SOURCE_FILE.test(entry.name) && !NOT_APP_CODE.test(entry.name) && (0, node_fs_1.readFileSync)(full, "utf-8").includes("createAutomation")) {
|
|
81
98
|
found.push((0, node_path_1.relative)(appDir, full).split("\\").join("/"));
|
|
82
99
|
}
|
|
83
100
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ZiteStep } from "../backend/index.js";
|
|
2
|
+
export declare const STEP_FAILURE_MEMO_KEY = "__ziteStepError";
|
|
3
|
+
export declare const STEP_FAILED_STEP_KEY = "__ziteFailedStep";
|
|
4
|
+
export declare const STEP_RESULT_MAX_BYTES: number;
|
|
5
|
+
export declare const STEP_SLEEP_MAX_MS: number;
|
|
6
|
+
export declare const STEP_DEFAULT_RETRIES = 3;
|
|
7
|
+
export declare const STEP_MAX_RETRIES = 10;
|
|
8
|
+
/** Why a durable call stops short. A retry outranks the other two. */
|
|
9
|
+
export type StepStop = {
|
|
10
|
+
kind: "retry";
|
|
11
|
+
name: string;
|
|
12
|
+
attempt: number;
|
|
13
|
+
error: unknown;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "sleep";
|
|
16
|
+
name: string;
|
|
17
|
+
wakeAt: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "step";
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
/** A stop that isn't a failure: the run goes on at a wake time, or at once. */
|
|
23
|
+
export type StepSuspension = {
|
|
24
|
+
kind: "sleep";
|
|
25
|
+
name: string;
|
|
26
|
+
wakeAt: string;
|
|
27
|
+
} | {
|
|
28
|
+
kind: "step";
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
/** A stop to try a step again: each failed step's next try, in the next call. */
|
|
32
|
+
export type StepRetry = {
|
|
33
|
+
step: string;
|
|
34
|
+
attempt: number;
|
|
35
|
+
attempts: Record<string, number>;
|
|
36
|
+
};
|
|
37
|
+
export type StepEventStatus = "ran" | "memoized" | "failed" | "sleeping" | "skipped";
|
|
38
|
+
export type StepRuntimeOptions = {
|
|
39
|
+
/** The run's saved steps by name, from earlier calls; filled in as steps save. */
|
|
40
|
+
memos: Record<string, unknown>;
|
|
41
|
+
/** A durable call may stop at a step for its orchestrator to call it again. */
|
|
42
|
+
durable: boolean;
|
|
43
|
+
/** Outside a durable call, what a sleep does: an editor test skips it, an app's request refuses it. */
|
|
44
|
+
sleeps?: "skip" | "refuse";
|
|
45
|
+
/** In a durable call, how long it starts new steps for. */
|
|
46
|
+
budgetMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* How long after the call starts `settle` waits for steps still working.
|
|
49
|
+
* A step past it runs again in the next call. Four minutes by default, so
|
|
50
|
+
* the call answers inside a five-minute request timeout.
|
|
51
|
+
*/
|
|
52
|
+
deadlineMs?: number;
|
|
53
|
+
/** Which try each step that failed in an earlier call is on; others are on their first. */
|
|
54
|
+
attempts?: Record<string, number>;
|
|
55
|
+
/** Saves a step's result, or its final failure. Throws when it can't. */
|
|
56
|
+
save: (name: string, value: unknown, durationMs: number) => Promise<unknown>;
|
|
57
|
+
onEvent?: (name: string, status: StepEventStatus, durationMs?: number, extra?: Record<string, unknown>) => void;
|
|
58
|
+
/** Marks a failed save as the platform's failure rather than the app's. */
|
|
59
|
+
onPlatformFault?: (error: Error) => void;
|
|
60
|
+
now?: () => number;
|
|
61
|
+
};
|
|
62
|
+
export type StepRuntime = {
|
|
63
|
+
step: ZiteStep;
|
|
64
|
+
/** Resolves at the call's first stop. */
|
|
65
|
+
stopped: Promise<void>;
|
|
66
|
+
stop(): StepStop | undefined;
|
|
67
|
+
suspension(): StepSuspension | undefined;
|
|
68
|
+
retry(): StepRetry | undefined;
|
|
69
|
+
/** How many steps this call saved, sleeps included. */
|
|
70
|
+
saved(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Waits for steps still doing work to save, including ones they start, but
|
|
73
|
+
* not for one stuck behind a stop, nor past the deadline.
|
|
74
|
+
*/
|
|
75
|
+
settle(): Promise<void>;
|
|
76
|
+
};
|
|
77
|
+
export declare const isStepFailureMemo: (memo: unknown) => boolean;
|
|
78
|
+
export declare function createStepRuntime(options: StepRuntimeOptions): StepRuntime;
|