zitejs 0.10.0-start.17 → 0.10.0-start.19
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/backend/index.d.ts +9 -3
- package/dist/cjs/bundle/index.d.ts +8 -0
- package/dist/cjs/bundle/index.js +9 -8
- package/dist/cjs/check/index.js +15 -28
- package/dist/cjs/check/start/sourceRules.d.ts +4 -1
- package/dist/cjs/check/start/sourceRules.js +33 -15
- package/dist/cjs/client/index.d.ts +24 -0
- package/dist/cjs/runtime/index.d.ts +5 -11
- package/dist/cjs/start/entries.d.ts +1 -1
- package/dist/cjs/start/entries.js +2 -2
- 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/lib.js +2 -2
- package/dist/cjs/sync/lib.test.js +90 -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/esm/backend/index.d.ts +9 -3
- package/dist/esm/bundle/index.d.ts +8 -0
- package/dist/esm/bundle/index.js +8 -8
- package/dist/esm/check/index.js +17 -30
- package/dist/esm/check/start/sourceRules.d.ts +4 -1
- package/dist/esm/check/start/sourceRules.js +33 -15
- package/dist/esm/client/index.d.ts +24 -0
- package/dist/esm/runtime/index.d.ts +5 -11
- package/dist/esm/start/describe.d.ts +2 -2
- package/dist/esm/start/describe.js +12 -13
- package/dist/esm/start/entries.d.ts +1 -1
- package/dist/esm/start/entries.js +2 -2
- package/dist/esm/start/index.d.ts +5 -5
- package/dist/esm/start/index.js +8 -8
- package/dist/esm/start/problems.js +1 -1
- package/dist/esm/start/server.js +14 -12
- package/dist/esm/start/version.d.ts +1 -1
- package/dist/esm/start/version.js +1 -1
- package/dist/esm/start/workflow.d.ts +10 -10
- package/dist/esm/start/workflow.js +3 -3
- package/dist/esm/start/workflow.test-d.js +12 -12
- package/dist/esm/start/workflowModules.js +1 -1
- package/dist/esm/start/workflowRun.d.ts +4 -4
- package/dist/esm/start/workflowRun.js +2 -2
- 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/lib.js +2 -2
- package/dist/esm/sync/lib.test.js +90 -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/package.json +18 -10
|
@@ -116,11 +116,11 @@ export type ZiteDatabaseTriggerInput<TRecord extends Record<string, unknown> = R
|
|
|
116
116
|
event: ZiteDatabaseTriggerEvent;
|
|
117
117
|
table: string;
|
|
118
118
|
recordId: string;
|
|
119
|
-
/** Null
|
|
119
|
+
/** Null on `"deleted"`, which leaves only `recordId`, and if it was deleted before the run read it. */
|
|
120
120
|
record: TRecord | null;
|
|
121
121
|
/** The record before an `"updated"`; null otherwise, and on a very large bulk write. */
|
|
122
122
|
previous: TRecord | null;
|
|
123
|
-
/** What an `"updated"` changed. */
|
|
123
|
+
/** What an `"updated"` changed; on a very large bulk write, what the write changed across its records. */
|
|
124
124
|
changedFields: string[];
|
|
125
125
|
};
|
|
126
126
|
/**
|
|
@@ -332,6 +332,11 @@ export interface ZiteStep {
|
|
|
332
332
|
* In a run fired by a schedule, webhook or trigger, a step that throws is
|
|
333
333
|
* tried again `retries` more times (default 3, at most 10), 30 seconds,
|
|
334
334
|
* 2 minutes, then 10 minutes apart. Elsewhere its error fails the request.
|
|
335
|
+
* Once its tries are spent the code gets its error, and later calls of the
|
|
336
|
+
* run throw it there again, rebuilt as an `Error` with its `name`,
|
|
337
|
+
* `message` and plain fields such as `code` or `status`, so branch on
|
|
338
|
+
* those rather than on `instanceof`. A result over 256KB, or one JSON
|
|
339
|
+
* can't hold such as a cycle, fails the step without a retry.
|
|
335
340
|
*/
|
|
336
341
|
run<T>(name: string, fn: () => Promise<T> | T, options?: ZiteStepOptions): Promise<T>;
|
|
337
342
|
/**
|
|
@@ -342,7 +347,8 @@ export interface ZiteStep {
|
|
|
342
347
|
*
|
|
343
348
|
* The run continues in a later call, which runs `execute` again from the
|
|
344
349
|
* top: finished steps return their saved results, and code outside a step
|
|
345
|
-
* runs again, so keep side effects inside steps.
|
|
350
|
+
* runs again, so keep side effects inside steps. Call it between steps, not
|
|
351
|
+
* inside a step's code: a step can't pause halfway, so a sleep there throws.
|
|
346
352
|
*/
|
|
347
353
|
sleep(name: string, duration: ZiteStepDuration): Promise<void>;
|
|
348
354
|
/** Pause the run until `when`, at most 30 days ahead. See {@link ZiteStep.sleep}. */
|
|
@@ -20,10 +20,18 @@
|
|
|
20
20
|
* "@babel/parser": "^7.26.0"
|
|
21
21
|
*/
|
|
22
22
|
import * as esbuild from 'esbuild';
|
|
23
|
+
import { type SourceRoot } from '../sourceRoots.js';
|
|
23
24
|
export declare const UNSUPPORTED_IN_WORKERD: Set<string>;
|
|
24
25
|
export declare const BASE_BUILD_OPTIONS: esbuild.BuildOptions;
|
|
25
26
|
export declare function createAliasPlugin(opts: {
|
|
26
27
|
baseDir?: string;
|
|
27
28
|
sdkPath?: string;
|
|
28
29
|
}): esbuild.Plugin;
|
|
30
|
+
export interface EndpointBundleResult {
|
|
31
|
+
bundledEndpoints: Record<string, string>;
|
|
32
|
+
endpointErrors?: Record<string, string>;
|
|
33
|
+
bundledAuthHooks?: string;
|
|
34
|
+
authHooksError?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function bundleEndpoints(baseDir: string, root: SourceRoot, endpointNames: string[], logLevel: esbuild.LogLevel): Promise<EndpointBundleResult>;
|
|
29
37
|
export declare function runBundle(): Promise<void>;
|
package/dist/cjs/bundle/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.BASE_BUILD_OPTIONS = exports.UNSUPPORTED_IN_WORKERD = void 0;
|
|
37
37
|
exports.createAliasPlugin = createAliasPlugin;
|
|
38
|
+
exports.bundleEndpoints = bundleEndpoints;
|
|
38
39
|
exports.runBundle = runBundle;
|
|
39
40
|
/**
|
|
40
41
|
* `npx zitejs bundle` — Bundle endpoint files for cloudflare-lambda deployment.
|
|
@@ -404,7 +405,7 @@ import endpoint from '${entryImport}';
|
|
|
404
405
|
globalThis.__endpoint = endpoint;
|
|
405
406
|
`;
|
|
406
407
|
}
|
|
407
|
-
async function
|
|
408
|
+
async function bundleEndpoints(baseDir, root, endpointNames, logLevel) {
|
|
408
409
|
const bundledEndpoints = {};
|
|
409
410
|
const endpointErrors = {};
|
|
410
411
|
const aliasPlugin = createAliasPlugin({ baseDir });
|
|
@@ -441,7 +442,7 @@ async function bundleEndpointsImpl(baseDir, root, endpointNames) {
|
|
|
441
442
|
resolveDir: `${baseDir}/src`,
|
|
442
443
|
loader: 'ts',
|
|
443
444
|
},
|
|
444
|
-
logLevel
|
|
445
|
+
logLevel,
|
|
445
446
|
plugins: [aliasPlugin],
|
|
446
447
|
});
|
|
447
448
|
if (result.warnings && result.warnings.length > 0) {
|
|
@@ -511,7 +512,7 @@ globalThis.__endpoint = endpoint;
|
|
|
511
512
|
resolveDir: `${baseDir}/src`,
|
|
512
513
|
loader: 'ts',
|
|
513
514
|
},
|
|
514
|
-
logLevel
|
|
515
|
+
logLevel,
|
|
515
516
|
plugins: [aliasPlugin],
|
|
516
517
|
});
|
|
517
518
|
if (result.outputFiles && result.outputFiles.length > 0) {
|
|
@@ -538,14 +539,12 @@ globalThis.__endpoint = endpoint;
|
|
|
538
539
|
}
|
|
539
540
|
}
|
|
540
541
|
}
|
|
541
|
-
|
|
542
|
+
return {
|
|
542
543
|
bundledEndpoints,
|
|
543
544
|
endpointErrors: Object.keys(endpointErrors).length > 0 ? endpointErrors : undefined,
|
|
544
545
|
bundledAuthHooks,
|
|
545
546
|
authHooksError,
|
|
546
|
-
}
|
|
547
|
-
fs.writeFileSync('/tmp/zitejs-bundle-result.json', output);
|
|
548
|
-
console.log(output);
|
|
547
|
+
};
|
|
549
548
|
}
|
|
550
549
|
async function bundleOneOffScriptImpl(scriptPath, sdkPath) {
|
|
551
550
|
const rawScript = fs.readFileSync(scriptPath, 'utf-8');
|
|
@@ -663,5 +662,7 @@ async function runBundle() {
|
|
|
663
662
|
endpointNames = (0, sourceRoots_js_1.listEndpointNames)(root, baseDir);
|
|
664
663
|
}
|
|
665
664
|
// Even with no endpoints, zite.auth.ts may still need bundling.
|
|
666
|
-
|
|
665
|
+
const output = JSON.stringify(await bundleEndpoints(baseDir, root, endpointNames, 'warning'));
|
|
666
|
+
fs.writeFileSync('/tmp/zitejs-bundle-result.json', output);
|
|
667
|
+
console.log(output);
|
|
667
668
|
}
|
package/dist/cjs/check/index.js
CHANGED
|
@@ -37,8 +37,10 @@ exports.Reporter = exports.withStdoutOnStderr = void 0;
|
|
|
37
37
|
exports.runTool = runTool;
|
|
38
38
|
exports.runCheck = runCheck;
|
|
39
39
|
const child_process_1 = require("child_process");
|
|
40
|
+
const esbuild = __importStar(require("esbuild"));
|
|
40
41
|
const fs_1 = require("fs");
|
|
41
42
|
const path_1 = require("path");
|
|
43
|
+
const index_js_1 = require("../bundle/index.js");
|
|
42
44
|
const sourceRoots_js_1 = require("../sourceRoots.js");
|
|
43
45
|
const problem_js_1 = require("./start/problem.js");
|
|
44
46
|
/**
|
|
@@ -64,28 +66,9 @@ function run(file, args, cwd) {
|
|
|
64
66
|
return { ok: false, output: (e.stderr ?? '') + (e.stdout ?? '') };
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
* still exits 0, so a non-empty `endpointErrors` is the only signal there is.
|
|
70
|
-
*/
|
|
71
|
-
function bundleFailures(output) {
|
|
72
|
-
const line = output
|
|
73
|
-
.trim()
|
|
74
|
-
.split('\n')
|
|
75
|
-
.reverse()
|
|
76
|
-
.find(l => l.startsWith('{'));
|
|
77
|
-
if (!line)
|
|
78
|
-
return ['bundle produced no result'];
|
|
79
|
-
let result;
|
|
80
|
-
try {
|
|
81
|
-
result = JSON.parse(line);
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return [`could not parse bundle output: ${line.slice(0, 200)}`];
|
|
85
|
-
}
|
|
69
|
+
async function bundleFailures(root, appPath, endpointNames) {
|
|
70
|
+
const result = await (0, index_js_1.bundleEndpoints)((0, path_1.resolve)(appPath), root, endpointNames, 'silent').finally(() => esbuild.stop());
|
|
86
71
|
const failures = [];
|
|
87
|
-
if (result.error)
|
|
88
|
-
failures.push(result.error);
|
|
89
72
|
for (const [name, err] of Object.entries(result.endpointErrors ?? {})) {
|
|
90
73
|
failures.push(`${name}: ${err}`);
|
|
91
74
|
}
|
|
@@ -227,11 +210,15 @@ async function checkStartApp(reporter, app, appPath) {
|
|
|
227
210
|
runTool(process.execPath, [tsgo, '--noEmit', '--pretty', '-p', 'tsconfig.app.json', '--checkers', '2'], appPath));
|
|
228
211
|
}
|
|
229
212
|
const { sourceProblems } = await Promise.resolve().then(() => __importStar(require('./start/sourceRules.js')));
|
|
230
|
-
const
|
|
213
|
+
const root = (0, sourceRoots_js_1.sourceRootOf)(appPath);
|
|
214
|
+
const hints = sourceProblems(readAppSources(appPath), {
|
|
215
|
+
internal: isInternalApp(appPath),
|
|
216
|
+
kind: root && { apps: 'app', automations: 'automation' }[root],
|
|
217
|
+
});
|
|
231
218
|
reporter.step(app, 'source', { ok: !hints.some(p => p.severity === 'error') });
|
|
232
219
|
reporter.problems(app, hints);
|
|
233
220
|
}
|
|
234
|
-
function checkClassicApp(reporter, app, root,
|
|
221
|
+
async function checkClassicApp(reporter, app, root, appPath) {
|
|
235
222
|
// Only tsconfig.app.json compiles anything. The app's tsconfig.json is a
|
|
236
223
|
// solution-style config — `"files": []` plus a reference — so
|
|
237
224
|
// `tsc --noEmit -p tsconfig.json` type-checks zero files and exits 0. It
|
|
@@ -244,9 +231,9 @@ function checkClassicApp(reporter, app, root, dir, appPath) {
|
|
|
244
231
|
// Endpoints never reach vite — they are bundled separately for the lambda,
|
|
245
232
|
// against a different resolver. tsc and vite both pass on an endpoint whose
|
|
246
233
|
// `zitejs/*` alias has no generated file behind it; only the bundler knows.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const failures =
|
|
234
|
+
const endpointNames = (0, sourceRoots_js_1.listEndpointNames)(root, appPath);
|
|
235
|
+
if (endpointNames.length > 0) {
|
|
236
|
+
const failures = await bundleFailures(root, appPath, endpointNames);
|
|
250
237
|
reporter.step(app, 'bundle endpoints', { ok: failures.length === 0, output: failures.join('\n') });
|
|
251
238
|
}
|
|
252
239
|
if ((0, fs_1.existsSync)((0, path_1.join)(appPath, 'vite.config.ts'))) {
|
|
@@ -268,12 +255,12 @@ async function runCheck(args = process.argv.slice(3)) {
|
|
|
268
255
|
const checkAll = async () => {
|
|
269
256
|
if (inStartApp)
|
|
270
257
|
await checkStartApp(reporter, reporter.app('.', 'start', false), '.');
|
|
271
|
-
for (const { root,
|
|
258
|
+
for (const { root, path: appPath } of appDirs) {
|
|
272
259
|
if (isStartAppDir(appPath)) {
|
|
273
260
|
await checkStartApp(reporter, reporter.app(appPath, 'start', true), appPath);
|
|
274
261
|
}
|
|
275
262
|
else {
|
|
276
|
-
checkClassicApp(reporter, reporter.app(appPath, 'classic', true), root,
|
|
263
|
+
await checkClassicApp(reporter, reporter.app(appPath, 'classic', true), root, appPath);
|
|
277
264
|
}
|
|
278
265
|
}
|
|
279
266
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Problem } from "./problem.js";
|
|
2
|
+
/** Which a Start project is, when the check can tell from where it sits. */
|
|
3
|
+
export type SourceKind = "app" | "automation";
|
|
2
4
|
/** Every source hint for one Start app, given its files by app-relative path. */
|
|
3
|
-
export declare function sourceProblems(sources: Record<string, string>, { internal }?: {
|
|
5
|
+
export declare function sourceProblems(sources: Record<string, string>, { internal, kind }?: {
|
|
4
6
|
internal?: boolean;
|
|
7
|
+
kind?: SourceKind;
|
|
5
8
|
}): Problem[];
|
|
@@ -184,7 +184,7 @@ const ownerInput = (calls) => {
|
|
|
184
184
|
const callsCreateWorkflow = (program) => {
|
|
185
185
|
let found = false;
|
|
186
186
|
walk(program, (node) => {
|
|
187
|
-
if (node.type === "CallExpression" && nameOf(node.callee) === "
|
|
187
|
+
if (node.type === "CallExpression" && nameOf(node.callee) === "createAutomation")
|
|
188
188
|
found = true;
|
|
189
189
|
});
|
|
190
190
|
return found;
|
|
@@ -215,8 +215,6 @@ const callsAny = (node, matches) => {
|
|
|
215
215
|
return found;
|
|
216
216
|
};
|
|
217
217
|
const ROOT_LAYOUTS = new Set(["src/routes/__root.tsx", "src/routes/_app.tsx", "src/routes/_app/route.tsx"]);
|
|
218
|
-
// The Start runtime reads a ZiteError thrown from any copy of zitejs, classic's included.
|
|
219
|
-
const CLASSIC_ALLOWED = { "zitejs/backend": new Set(["ZiteError"]) };
|
|
220
218
|
const CLASSIC_IMPORTS = {
|
|
221
219
|
"zitejs/backend": "server code is a signedInFn/publicFn server function from zitejs/start",
|
|
222
220
|
"zitejs/api": "pages call server functions directly, from a loader or an event handler",
|
|
@@ -425,8 +423,8 @@ const routeProblems = (files, internal) => {
|
|
|
425
423
|
}
|
|
426
424
|
return problems;
|
|
427
425
|
};
|
|
428
|
-
/** The workflows an app exports, by id, as the build loads them: every module that calls
|
|
429
|
-
const workflowProblems = (files) => {
|
|
426
|
+
/** The workflows an app exports, by id, as the build loads them: every module that calls createAutomation. */
|
|
427
|
+
const workflowProblems = (files, kind) => {
|
|
430
428
|
const problems = [];
|
|
431
429
|
const exported = [];
|
|
432
430
|
for (const file of files) {
|
|
@@ -437,7 +435,7 @@ const workflowProblems = (files) => {
|
|
|
437
435
|
return undefined;
|
|
438
436
|
const { root, calls } = chainOf(init);
|
|
439
437
|
const innermost = calls.at(-1);
|
|
440
|
-
return root && file.imports.get(root)?.imported === "
|
|
438
|
+
return root && file.imports.get(root)?.imported === "createAutomation" && innermost && nameOf(innermost.callee) === root
|
|
441
439
|
? innermost
|
|
442
440
|
: undefined;
|
|
443
441
|
};
|
|
@@ -454,7 +452,7 @@ const workflowProblems = (files) => {
|
|
|
454
452
|
severity: "error",
|
|
455
453
|
file: file.path,
|
|
456
454
|
...(lineOf(node) && { line: lineOf(node) }),
|
|
457
|
-
message: `
|
|
455
|
+
message: `automation ${id}: a provider trigger needs \`subscribe\` to register it with the provider`,
|
|
458
456
|
});
|
|
459
457
|
};
|
|
460
458
|
const locals = new Map();
|
|
@@ -489,7 +487,7 @@ const workflowProblems = (files) => {
|
|
|
489
487
|
severity: "error",
|
|
490
488
|
file: file.path,
|
|
491
489
|
...(lineOf(statement) && { line: lineOf(statement) }),
|
|
492
|
-
message: "
|
|
490
|
+
message: "automation default: export it by name, which becomes its id",
|
|
493
491
|
});
|
|
494
492
|
}
|
|
495
493
|
}
|
|
@@ -503,10 +501,31 @@ const workflowProblems = (files) => {
|
|
|
503
501
|
severity: "error",
|
|
504
502
|
file,
|
|
505
503
|
...(lineOf(node) && { line: lineOf(node) }),
|
|
506
|
-
message: `
|
|
504
|
+
message: `automation ${id}: ${id} is also exported from ${elsewhere.file}`,
|
|
507
505
|
});
|
|
508
506
|
}
|
|
509
507
|
}
|
|
508
|
+
// A standalone automation is one workflow with one trigger, as classic's is; an app may hold several.
|
|
509
|
+
const webhookImports = files.flatMap((file) => file.program.body
|
|
510
|
+
.filter((statement) => statement.type === "ImportDeclaration" &&
|
|
511
|
+
statement.source.value === "zitejs/start" &&
|
|
512
|
+
statement.importKind !== "type" &&
|
|
513
|
+
statement.specifiers.some((specifier) => nameOf(specifier.imported) === "webhook"))
|
|
514
|
+
.map((statement) => ({ file: file.path, node: statement })));
|
|
515
|
+
const triggers = [
|
|
516
|
+
...exported.map(({ id, file, node }) => ({ label: id, file, node })),
|
|
517
|
+
...webhookImports.map(({ file, node }) => ({ label: `the webhook in ${file}`, file, node })),
|
|
518
|
+
];
|
|
519
|
+
if (kind === "automation" && triggers.length > 1) {
|
|
520
|
+
const second = triggers[1];
|
|
521
|
+
problems.push({
|
|
522
|
+
rule: "one-trigger",
|
|
523
|
+
severity: "error",
|
|
524
|
+
file: second.file,
|
|
525
|
+
...(lineOf(second.node) && { line: lineOf(second.node) }),
|
|
526
|
+
message: `an automation has one trigger, and this one has ${triggers.length} (${triggers.map(({ label }) => label).join(", ")}); a second trigger is a second automation`,
|
|
527
|
+
});
|
|
528
|
+
}
|
|
510
529
|
return problems;
|
|
511
530
|
};
|
|
512
531
|
// What the build keeps out of the browser (zite()'s importProtection), by the specifier an app writes.
|
|
@@ -591,7 +610,7 @@ const serverImportProblems = (files, factories) => {
|
|
|
591
610
|
return problems;
|
|
592
611
|
};
|
|
593
612
|
/** Every source hint for one Start app, given its files by app-relative path. */
|
|
594
|
-
function sourceProblems(sources, { internal = false } = {}) {
|
|
613
|
+
function sourceProblems(sources, { internal = false, kind } = {}) {
|
|
595
614
|
const files = Object.entries(sources)
|
|
596
615
|
.filter(([path]) => /\.[cm]?[jt]sx?$/.test(path) && !path.endsWith("routeTree.gen.ts") && !path.endsWith(".d.ts"))
|
|
597
616
|
.flatMap(([path, code]) => parseFile(path, code) ?? []);
|
|
@@ -639,8 +658,7 @@ function sourceProblems(sources, { internal = false } = {}) {
|
|
|
639
658
|
const source = statement.source.value;
|
|
640
659
|
const values = valueImports(statement);
|
|
641
660
|
for (const [module, instead] of Object.entries(CLASSIC_IMPORTS)) {
|
|
642
|
-
const
|
|
643
|
-
const refused = values === "all" ? true : values.some((name) => !allowed?.has(name));
|
|
661
|
+
const refused = values === "all" || values.length > 0;
|
|
644
662
|
if (importsModule(source, module) && refused) {
|
|
645
663
|
report("classic-construct", "error", path, statement, `${module} is classic's; in a Start app, ${instead}`);
|
|
646
664
|
}
|
|
@@ -650,7 +668,7 @@ function sourceProblems(sources, { internal = false } = {}) {
|
|
|
650
668
|
}
|
|
651
669
|
const typeOnly = values !== "all" && values.length === 0;
|
|
652
670
|
if (callsWorkflow && !typeOnly && (/\.functions(\.[jt]sx?)?$/.test(source) || importsModule(source, "@tanstack/react-start/server"))) {
|
|
653
|
-
report("workflow-imports", "error", path, statement, `
|
|
671
|
+
report("workflow-imports", "error", path, statement, `an automation runs without a page request, so it can't use ${source}; move what it needs into a *.server.ts helper`);
|
|
654
672
|
}
|
|
655
673
|
}
|
|
656
674
|
const exported = statement.type === "ExportNamedDeclaration" ? statement.declaration : undefined;
|
|
@@ -736,7 +754,7 @@ function sourceProblems(sources, { internal = false } = {}) {
|
|
|
736
754
|
}
|
|
737
755
|
}
|
|
738
756
|
if (node.type === "MemberExpression" && nameOf(node.property) === "inputValidator" && !node.computed) {
|
|
739
|
-
report("input-validator", "
|
|
757
|
+
report("input-validator", "error", path, node, "inputValidator was removed in TanStack Start 1.0; call .validator(…)");
|
|
740
758
|
}
|
|
741
759
|
if (node.type === "CallExpression" && nameOf(node.callee) === "createEndpoint") {
|
|
742
760
|
report("classic-construct", "error", path, node, "createEndpoint is classic's; in a Start app, server code is a signedInFn/publicFn server function");
|
|
@@ -814,7 +832,7 @@ function sourceProblems(sources, { internal = false } = {}) {
|
|
|
814
832
|
}
|
|
815
833
|
});
|
|
816
834
|
}
|
|
817
|
-
problems.push(...routeProblems(files, internal), ...workflowProblems(files), ...serverImportProblems(files, factories));
|
|
835
|
+
problems.push(...routeProblems(files, internal), ...workflowProblems(files, kind), ...serverImportProblems(files, factories));
|
|
818
836
|
for (const [name, paths] of serverFnFiles) {
|
|
819
837
|
const distinct = [...new Set(paths)];
|
|
820
838
|
if (distinct.length > 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";
|
|
@@ -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>>;
|
|
@@ -15,7 +15,7 @@ export declare const writeIfChanged: (appDir: string, file: string, content: str
|
|
|
15
15
|
export declare const isStartAppDir: (appPath: string) => boolean;
|
|
16
16
|
export declare const workspaceHasStartApps: () => boolean;
|
|
17
17
|
export declare function regenerateStartEntries(app: SourceDir): void;
|
|
18
|
-
/** App modules that mention
|
|
18
|
+
/** App modules that mention createAutomation: what the workflow registry imports. Describe decides what each one really exports. */
|
|
19
19
|
export declare function workflowFiles(appDir: string): string[];
|
|
20
20
|
/** The registry zite() builds in place of zitejs's empty one. */
|
|
21
21
|
export declare const renderWorkflowModules: (appDir: string, files: string[]) => string;
|
|
@@ -83,7 +83,7 @@ function regenerateStartEntries(app) {
|
|
|
83
83
|
}
|
|
84
84
|
const SOURCE_FILE = /\.[mc]?[jt]sx?$/;
|
|
85
85
|
const NOT_APP_CODE = /(\.(test|spec)\.[^.]+|\.d\.ts|routeTree\.gen\.ts)$/;
|
|
86
|
-
/** App modules that mention
|
|
86
|
+
/** App modules that mention createAutomation: what the workflow registry imports. Describe decides what each one really exports. */
|
|
87
87
|
function workflowFiles(appDir) {
|
|
88
88
|
const found = [];
|
|
89
89
|
const walk = (dir) => {
|
|
@@ -93,7 +93,7 @@ function workflowFiles(appDir) {
|
|
|
93
93
|
if (entry.name !== "node_modules")
|
|
94
94
|
walk(full);
|
|
95
95
|
}
|
|
96
|
-
else if (SOURCE_FILE.test(entry.name) && !NOT_APP_CODE.test(entry.name) && (0, node_fs_1.readFileSync)(full, "utf-8").includes("
|
|
96
|
+
else if (SOURCE_FILE.test(entry.name) && !NOT_APP_CODE.test(entry.name) && (0, node_fs_1.readFileSync)(full, "utf-8").includes("createAutomation")) {
|
|
97
97
|
found.push((0, node_path_1.relative)(appDir, full).split("\\").join("/"));
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -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;
|