zitejs 0.10.6 → 0.10.7

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.
@@ -149,8 +149,8 @@ export declare const describedScheduleSchema: z.ZodDiscriminatedUnion<[z.ZodObje
149
149
  paused: z.ZodOptional<z.ZodBoolean>;
150
150
  }, z.core.$strip>], "scheduleType">;
151
151
  /**
152
- * `ZiteTrigger`, as an automation declares it, without a provider trigger's `subscribe` and `unsubscribe`. Database
153
- * and form triggers are in it: describe reports one it refuses.
152
+ * `ZiteTrigger`, as an automation declares it, without a provider trigger's `subscribe` and `unsubscribe`. A form
153
+ * trigger is in it: describe reports it as refused.
154
154
  */
155
155
  export declare const describedTriggerSchema: z.ZodUnion<readonly [z.ZodObject<{
156
156
  every: z.ZodOptional<z.ZodNever>;
@@ -350,6 +350,9 @@ export declare const describedWorkflowSchema: z.ZodObject<{
350
350
  form: z.ZodString;
351
351
  on: z.ZodArray<z.ZodLiteral<"submitted">>;
352
352
  }, z.core.$strip>]>>;
353
+ webhook: z.ZodOptional<z.ZodObject<{
354
+ paused: z.ZodOptional<z.ZodBoolean>;
355
+ }, z.core.$strip>>;
353
356
  registration: z.ZodOptional<z.ZodObject<{
354
357
  unsubscribe: z.ZodBoolean;
355
358
  hash: z.ZodString;
@@ -556,6 +559,9 @@ export declare const describeOutputSchema: z.ZodObject<{
556
559
  form: z.ZodString;
557
560
  on: z.ZodArray<z.ZodLiteral<"submitted">>;
558
561
  }, z.core.$strip>]>>;
562
+ webhook: z.ZodOptional<z.ZodObject<{
563
+ paused: z.ZodOptional<z.ZodBoolean>;
564
+ }, z.core.$strip>>;
559
565
  registration: z.ZodOptional<z.ZodObject<{
560
566
  unsubscribe: z.ZodBoolean;
561
567
  hash: z.ZodString;
@@ -107,8 +107,8 @@ exports.describedScheduleSchema = zod_1.z.discriminatedUnion('scheduleType', [
107
107
  const absent = zod_1.z.never().optional();
108
108
  const shown = { label: zod_1.z.string().optional(), paused: zod_1.z.boolean().optional() };
109
109
  /**
110
- * `ZiteTrigger`, as an automation declares it, without a provider trigger's `subscribe` and `unsubscribe`. Database
111
- * and form triggers are in it: describe reports one it refuses.
110
+ * `ZiteTrigger`, as an automation declares it, without a provider trigger's `subscribe` and `unsubscribe`. A form
111
+ * trigger is in it: describe reports it as refused.
112
112
  */
113
113
  exports.describedTriggerSchema = zod_1.z.union([
114
114
  zod_1.z.object({
@@ -161,6 +161,7 @@ exports.describedWorkflowSchema = zod_1.z.object({
161
161
  description: zod_1.z.string().optional(),
162
162
  schedule: exports.describedScheduleSchema.optional(),
163
163
  trigger: exports.describedTriggerSchema.optional(),
164
+ webhook: zod_1.z.object({ paused: zod_1.z.boolean().optional() }).optional(),
164
165
  registration: zod_1.z
165
166
  .object({ unsubscribe: zod_1.z.boolean(), hash: zod_1.z.string(), module: zod_1.z.string() })
166
167
  .optional(),
@@ -56,7 +56,7 @@ export type RunReport = {
56
56
  output?: string;
57
57
  error?: RunRecord['error'];
58
58
  console?: ConsoleRecord[];
59
- };
59
+ } & Pick<RunRecord, 'steps' | 'failedStep' | 'suspended'>;
60
60
  /** One step of a workflow call, as zitejs/steps reports it. `failed` marks a replayed final failure. */
61
61
  export type StepRecord = {
62
62
  name: string;
@@ -3,21 +3,23 @@ import type { StepStore } from '../platform/steps.js';
3
3
  import type { DurableCall, StepRecord } from '../types.js';
4
4
  /** @internal An automation runs outside any request: TanStack's error for that, as one naming the fix. */
5
5
  export declare const asAutomationError: (error: unknown) => unknown;
6
- /** What a workflow's handler gets as `step`. Waits join it once the host can wait between calls. */
7
- export type StartStep = Pick<ZiteStep, 'run'>;
6
+ /** What a workflow's handler gets as `step`: classic's, retries and waits included. */
7
+ export type StartStep = ZiteStep;
8
8
  export type StepLog = StepRecord;
9
9
  /**
10
10
  * Each completed step's result is saved before the code after it runs, so a resumed run gets it back instead of
11
11
  * running the step's side effects again. Only a resumed run reads saved results, once, at its first step. Without
12
- * `durable` a step's error reaches the code at once, as in classic's one-call runs.
12
+ * `durable` a step's error reaches the code at once, and a sleep is skipped or refused, as in classic's one-call runs.
13
13
  */
14
- export declare function createSteps({ store, resuming, durable, now, }: {
14
+ export declare function createSteps({ store, resuming, durable, sleeps, now, }: {
15
15
  store: StepStore;
16
16
  resuming: boolean;
17
17
  durable?: DurableCall;
18
+ /** Outside a durable call: an editor's run skips a sleep, any other refuses it. */
19
+ sleeps?: 'skip' | 'refuse';
18
20
  now?: () => number;
19
21
  }): {
20
- step: StartStep;
22
+ step: ZiteStep;
21
23
  log: StepRecord[];
22
24
  failedStep: () => string | undefined;
23
25
  stopped: Promise<void>;
@@ -26,9 +26,9 @@ const SETTLE_DEADLINE_MS = 280_000;
26
26
  /**
27
27
  * Each completed step's result is saved before the code after it runs, so a resumed run gets it back instead of
28
28
  * running the step's side effects again. Only a resumed run reads saved results, once, at its first step. Without
29
- * `durable` a step's error reaches the code at once, as in classic's one-call runs.
29
+ * `durable` a step's error reaches the code at once, and a sleep is skipped or refused, as in classic's one-call runs.
30
30
  */
31
- export function createSteps({ store, resuming, durable, now = Date.now, }) {
31
+ export function createSteps({ store, resuming, durable, sleeps, now = Date.now, }) {
32
32
  // No prototype: a step named `__proto__` would otherwise set it.
33
33
  const memos = Object.create(null);
34
34
  const log = [];
@@ -36,6 +36,7 @@ export function createSteps({ store, resuming, durable, now = Date.now, }) {
36
36
  const runtime = createStepRuntime({
37
37
  memos,
38
38
  durable: durable !== undefined,
39
+ sleeps,
39
40
  budgetMs: durable?.budgetMs,
40
41
  attempts: durable?.attempts,
41
42
  deadlineMs: SETTLE_DEADLINE_MS,
@@ -72,14 +73,25 @@ export function createSteps({ store, resuming, durable, now = Date.now, }) {
72
73
  throw new Error(`Could not read this run's saved steps (${err instanceof Error ? err.message : String(err)}); nothing ran again. Resume it once more.`);
73
74
  })
74
75
  : Promise.resolve());
76
+ const prepared = async () => {
77
+ await (readying ??= store.ready());
78
+ await loaded();
79
+ };
75
80
  const step = {
76
81
  run: async (name, fn, options) => {
77
- await (readying ??= store.ready());
78
- await loaded();
82
+ await prepared();
79
83
  // Anything but a function goes as it is, for the runtime to refuse.
80
84
  const run = typeof fn === 'function' ? () => explainingErrors(fn) : fn;
81
85
  return runtime.step.run(name, run, options);
82
86
  },
87
+ sleep: async (name, duration) => {
88
+ await prepared();
89
+ return runtime.step.sleep(name, duration);
90
+ },
91
+ sleepUntil: async (name, when) => {
92
+ await prepared();
93
+ return runtime.step.sleepUntil(name, when);
94
+ },
83
95
  };
84
96
  return {
85
97
  step,
@@ -1,4 +1,4 @@
1
- import type { ZiteTrigger, ZiteTriggerContext, ZiteTriggerSubscribe, ZiteTriggerUnsubscribe } from '../../backend/index.js';
1
+ import type { ZiteDatabaseTriggerInput, ZiteTrigger, ZiteTriggerContext, ZiteTriggerSubscribe, ZiteTriggerUnsubscribe, ZiteWebhook } from '../../backend/index.js';
2
2
  import type { ZiteSchedule } from '../../schedules/index.js';
3
3
  import type { StartStep } from './steps.js';
4
4
  declare const WORKFLOW: unique symbol;
@@ -30,10 +30,8 @@ export type StartProviderTrigger = ProviderTriggerConfig & {
30
30
  * anything it imports, changes, and an edit to the automation alone leaves it registered.
31
31
  */
32
32
  export declare function createProviderTrigger(trigger: ProviderTriggerConfig): StartProviderTrigger;
33
- /** Database and form triggers aren't supported in a Start automation yet. */
33
+ /** Form triggers aren't served on either runtime yet. */
34
34
  export type StartTrigger = Exclude<ZiteTrigger, ProviderTriggerBase | {
35
- table: string;
36
- } | {
37
35
  form: string;
38
36
  }> | StartProviderTrigger;
39
37
  export type AutomationConfig = {
@@ -42,20 +40,32 @@ export type AutomationConfig = {
42
40
  } & ({
43
41
  schedule: ZiteSchedule;
44
42
  trigger?: never;
43
+ webhook?: never;
45
44
  } | {
46
45
  trigger: StartTrigger;
47
46
  schedule?: never;
47
+ webhook?: never;
48
+ } | {
49
+ webhook: ZiteWebhook;
50
+ schedule?: never;
51
+ trigger?: never;
48
52
  } | {
49
53
  schedule?: never;
50
54
  trigger?: never;
55
+ webhook?: never;
51
56
  });
52
57
  /**
53
- * What an automation's handler gets. A trigger adds `trigger`, typed by the kind it declares.
58
+ * What an automation's handler gets. A trigger adds `trigger`, typed by the kind it declares, and a database trigger's
59
+ * `input` is the changed record. A webhook's `input` is the posted body, with its headers at `input.__webhook.headers`.
54
60
  * `step.run(name, fn)` runs `fn` once per run: its result is saved before the code after it,
55
61
  * and a failed run resumed from run history replays completed steps from their saved results.
56
62
  */
57
63
  export type AutomationArgs<TConfig extends AutomationConfig> = {
58
- input: unknown;
64
+ input: TConfig extends {
65
+ trigger: {
66
+ table: string;
67
+ };
68
+ } ? ZiteDatabaseTriggerInput : unknown;
59
69
  step: StartStep;
60
70
  } & (TConfig extends {
61
71
  trigger: infer T;
@@ -72,7 +82,7 @@ export type Automation<TConfig extends AutomationConfig = AutomationConfig> = {
72
82
  * `export const nightly = createAutomation({ description, schedule }).handler(async () => { ... })`.
73
83
  * Only the platform runs it. It has no user and no URL, and reads data like a server function does.
74
84
  */
75
- export declare function createAutomation<const TConfig extends AutomationConfig>(config: TConfig & Record<Exclude<keyof TConfig, 'description' | 'schedule' | 'trigger'>, never>): {
85
+ export declare function createAutomation<const TConfig extends AutomationConfig>(config: TConfig & Record<Exclude<keyof TConfig, 'description' | 'schedule' | 'trigger' | 'webhook'>, never>): {
76
86
  [UNFINISHED]: boolean;
77
87
  handler: (fn: (args: AutomationArgs<TConfig>) => unknown) => Automation<TConfig>;
78
88
  };
@@ -76,13 +76,35 @@ describe('createAutomation handler args', () => {
76
76
  trigger: { integration: 'asana' },
77
77
  });
78
78
  });
79
- it('takes no database or form trigger yet, with or without subscribe', () => {
80
- const subscribe = async () => ({ externalId: 'w1' });
79
+ it('takes a database trigger, whose input is the changed record', () => {
80
+ createAutomation({
81
+ description: 'Runs for this test',
82
+ trigger: { table: 'orders', on: ['created', 'updated'] },
83
+ }).handler(({ input, trigger }) => {
84
+ expectTypeOf(input).toEqualTypeOf();
85
+ expectTypeOf(trigger).toEqualTypeOf();
86
+ });
87
+ });
88
+ it('takes a webhook, whose input is the posted body', () => {
89
+ createAutomation({
90
+ description: 'Runs for this test',
91
+ webhook: {},
92
+ }).handler(args => {
93
+ expectTypeOf(args).toEqualTypeOf();
94
+ });
95
+ // @ts-expect-error one firing: a webhook or a schedule, not both
81
96
  createAutomation({
82
97
  description: 'Runs for this test',
83
- // @ts-expect-error a Start automation can't take a database trigger yet
84
- trigger: { table: 'orders', on: ['created'], subscribe },
98
+ webhook: {},
99
+ schedule: {
100
+ scheduleType: 'oneTime',
101
+ fireAt: '2026-10-10T03:00:00Z',
102
+ timezone: 'UTC',
103
+ },
85
104
  });
105
+ });
106
+ it('takes no form trigger yet, with or without subscribe', () => {
107
+ const subscribe = async () => ({ externalId: 'w1' });
86
108
  createAutomation({
87
109
  description: 'Runs for this test',
88
110
  // @ts-expect-error nor a form trigger
@@ -101,9 +101,10 @@ export declare function triggerContext(workflow: Automation, rawInput: unknown):
101
101
  * Runs the handler in a workflow access scope: no user, and data calls allowed.
102
102
  * A resumed run replays the steps its first attempt saved.
103
103
  */
104
- export declare function runWorkflow(workflow: Automation, rawInput: unknown, { resuming, durable, store, }?: {
104
+ export declare function runWorkflow(workflow: Automation, rawInput: unknown, { resuming, durable, sleeps, store, }?: {
105
105
  resuming?: boolean;
106
106
  durable?: DurableCall;
107
+ sleeps?: 'skip' | 'refuse';
107
108
  store?: StepStore;
108
109
  }): Promise<WorkflowRunResult>;
109
110
  export type LoadedWorkflow = {
@@ -23,6 +23,9 @@ const idOf = (id) => {
23
23
  * reported: billing reads an empty list as a run that found nothing new.
24
24
  */
25
25
  export function triggerContext(workflow, rawInput) {
26
+ // A webhook's code reads its headers at `input.__webhook`, as classic's does.
27
+ if (workflow.config.webhook)
28
+ return { input: rawInput };
26
29
  const raw = asRecord(rawInput);
27
30
  // `__cron` stays in the input, as on classic: scheduled code reads its scheduleId and scheduledAt there.
28
31
  const { __poll, __webhook, ...input } = raw ?? {};
@@ -44,7 +47,8 @@ export function triggerContext(workflow, rawInput) {
44
47
  : declared.every
45
48
  ? {}
46
49
  : { headers: {} };
47
- if (!poll && declared.events)
50
+ // An app event and a database change keep no cursor.
51
+ if (!poll && (declared.events || declared.table !== undefined))
48
52
  return { input, trigger: info };
49
53
  const state = poll ?? delivery ?? {};
50
54
  const known = new Set(Array.isArray(state.seen) ? state.seen.map(String) : []);
@@ -78,9 +82,9 @@ export function triggerContext(workflow, rawInput) {
78
82
  * Runs the handler in a workflow access scope: no user, and data calls allowed.
79
83
  * A resumed run replays the steps its first attempt saved.
80
84
  */
81
- export async function runWorkflow(workflow, rawInput, { resuming = false, durable, store = platformSteps(getHost()), } = {}) {
85
+ export async function runWorkflow(workflow, rawInput, { resuming = false, durable, sleeps, store = platformSteps(getHost()), } = {}) {
82
86
  const { input, trigger, report } = triggerContext(workflow, rawInput);
83
- const steps = createSteps({ store, resuming, durable });
87
+ const steps = createSteps({ store, resuming, durable, sleeps });
84
88
  const args = {
85
89
  input,
86
90
  step: steps.step,
@@ -39,6 +39,7 @@ export type DescribedWorkflow = {
39
39
  schedule?: AutomationConfig['schedule'];
40
40
  /** As declared, without a provider trigger's `subscribe` and `unsubscribe`. */
41
41
  trigger?: ZiteTrigger;
42
+ webhook?: AutomationConfig['webhook'];
42
43
  /**
43
44
  * A provider trigger's: whether it can be taken down, its module, and a hash of everything that module runs, so
44
45
  * publish registers it again when that changes.
@@ -231,12 +231,21 @@ export function describeWorkflows(workflows, { hashes = {}, unfinished = [], tri
231
231
  const elsewhere = workflows.find(other => other.id === id && other.file !== file);
232
232
  if (elsewhere)
233
233
  problems.push(`duplicate-workflow: ${id} is also exported from ${elsewhere.file}`);
234
- const { description, schedule, trigger } = workflow.config;
234
+ const { description, schedule, trigger, webhook } = workflow.config;
235
+ const firings = Object.entries({ schedule, trigger, webhook })
236
+ .filter(([, declared]) => declared !== undefined)
237
+ .map(([name]) => name);
238
+ // The types refuse it, but a build doesn't typecheck.
239
+ if (firings.length > 1)
240
+ problems.push(`one-firing: an automation fires one way, so declare one of schedule, trigger or webhook, not ${firings.join(' and ')}`);
235
241
  if (schedule)
236
242
  return { id, file, description, schedule, problems };
243
+ if (webhook)
244
+ return { id, file, description, webhook, problems };
237
245
  if (!trigger ||
238
246
  trigger.every !== undefined ||
239
- trigger.events !== undefined) {
247
+ trigger.events !== undefined ||
248
+ trigger.table !== undefined) {
240
249
  return { id, file, description, trigger, problems };
241
250
  }
242
251
  const { subscribe, unsubscribe, ...declared } = trigger;
@@ -247,9 +256,9 @@ export function describeWorkflows(workflows, { hashes = {}, unfinished = [], tri
247
256
  trigger: declared,
248
257
  problems: [...problems, problem],
249
258
  });
250
- // The types refuse these, but a build doesn't typecheck.
251
- if ('table' in declared || 'form' in declared)
252
- return refused("trigger-unsupported: a Start automation can't take a database or form trigger yet");
259
+ // The types refuse it, but a build doesn't typecheck.
260
+ if ('form' in declared)
261
+ return refused("trigger-unsupported: a form trigger isn't available yet");
253
262
  if (!isProviderTrigger(trigger))
254
263
  return refused(TRIGGER_INLINE);
255
264
  const [module] = [
@@ -149,8 +149,8 @@ export declare const describedScheduleSchema: z.ZodDiscriminatedUnion<[z.ZodObje
149
149
  paused: z.ZodOptional<z.ZodBoolean>;
150
150
  }, z.core.$strip>], "scheduleType">;
151
151
  /**
152
- * `ZiteTrigger`, as an automation declares it, without a provider trigger's `subscribe` and `unsubscribe`. Database
153
- * and form triggers are in it: describe reports one it refuses.
152
+ * `ZiteTrigger`, as an automation declares it, without a provider trigger's `subscribe` and `unsubscribe`. A form
153
+ * trigger is in it: describe reports it as refused.
154
154
  */
155
155
  export declare const describedTriggerSchema: z.ZodUnion<readonly [z.ZodObject<{
156
156
  every: z.ZodOptional<z.ZodNever>;
@@ -350,6 +350,9 @@ export declare const describedWorkflowSchema: z.ZodObject<{
350
350
  form: z.ZodString;
351
351
  on: z.ZodArray<z.ZodLiteral<"submitted">>;
352
352
  }, z.core.$strip>]>>;
353
+ webhook: z.ZodOptional<z.ZodObject<{
354
+ paused: z.ZodOptional<z.ZodBoolean>;
355
+ }, z.core.$strip>>;
353
356
  registration: z.ZodOptional<z.ZodObject<{
354
357
  unsubscribe: z.ZodBoolean;
355
358
  hash: z.ZodString;
@@ -556,6 +559,9 @@ export declare const describeOutputSchema: z.ZodObject<{
556
559
  form: z.ZodString;
557
560
  on: z.ZodArray<z.ZodLiteral<"submitted">>;
558
561
  }, z.core.$strip>]>>;
562
+ webhook: z.ZodOptional<z.ZodObject<{
563
+ paused: z.ZodOptional<z.ZodBoolean>;
564
+ }, z.core.$strip>>;
559
565
  registration: z.ZodOptional<z.ZodObject<{
560
566
  unsubscribe: z.ZodBoolean;
561
567
  hash: z.ZodString;
@@ -104,8 +104,8 @@ export const describedScheduleSchema = z.discriminatedUnion('scheduleType', [
104
104
  const absent = z.never().optional();
105
105
  const shown = { label: z.string().optional(), paused: z.boolean().optional() };
106
106
  /**
107
- * `ZiteTrigger`, as an automation declares it, without a provider trigger's `subscribe` and `unsubscribe`. Database
108
- * and form triggers are in it: describe reports one it refuses.
107
+ * `ZiteTrigger`, as an automation declares it, without a provider trigger's `subscribe` and `unsubscribe`. A form
108
+ * trigger is in it: describe reports it as refused.
109
109
  */
110
110
  export const describedTriggerSchema = z.union([
111
111
  z.object({
@@ -158,6 +158,7 @@ export const describedWorkflowSchema = z.object({
158
158
  description: z.string().optional(),
159
159
  schedule: describedScheduleSchema.optional(),
160
160
  trigger: describedTriggerSchema.optional(),
161
+ webhook: z.object({ paused: z.boolean().optional() }).optional(),
161
162
  registration: z
162
163
  .object({ unsubscribe: z.boolean(), hash: z.string(), module: z.string() })
163
164
  .optional(),
@@ -31,7 +31,7 @@ export declare const ranTo: (outcome: {
31
31
  } | {
32
32
  error: unknown;
33
33
  }) => Pick<RunRecord, "output" | "error">;
34
- /** The request's report: its top-level run, the one that failed if any did, and its console; null when it has neither. */
34
+ /** The request's report: its top-level run (a workflow's with its steps), the one that failed if any did, and its console; null when it has neither. */
35
35
  export declare const runReportOf: (host: HostRequestState) => RunReport | null;
36
36
  /** One run of app code for the request's run log, timed from `startedAt` to now. */
37
37
  export declare const recordRun: (host: HostRequestState | undefined, run: Omit<RunRecord, "durationMs">, endedAt?: number) => void;
@@ -90,7 +90,7 @@ export const reportedCall = async (host, input, run) => {
90
90
  export const ranTo = (outcome) => 'error' in outcome
91
91
  ? { error: errorOf(outcome.error) }
92
92
  : { output: preview(outcome.output) };
93
- /** The request's report: its top-level run, the one that failed if any did, and its console; null when it has neither. */
93
+ /** The request's report: its top-level run (a workflow's with its steps), the one that failed if any did, and its console; null when it has neither. */
94
94
  export const runReportOf = (host) => {
95
95
  const top = host.runs.filter(run => !run.nested);
96
96
  const run = top.find(({ error }) => error) ?? top[0];
@@ -100,6 +100,9 @@ export const runReportOf = (host) => {
100
100
  ...(run?.input !== undefined && { input: run.input }),
101
101
  ...(run?.output !== undefined && { output: run.output }),
102
102
  ...(run?.error && { error: run.error }),
103
+ ...(run?.steps?.length && { steps: run.steps }),
104
+ ...(run?.failedStep !== undefined && { failedStep: run.failedStep }),
105
+ ...(run?.suspended && { suspended: run.suspended }),
103
106
  ...(host.console?.length && { console: host.console }),
104
107
  };
105
108
  };
@@ -23,6 +23,21 @@ export const headerInvoke = (headers) => {
23
23
  const POSTED = ['workflow', 'register', 'authHook', 'function'];
24
24
  const isPosted = (kind) => POSTED.includes(kind);
25
25
  const notFound = (message) => Response.json({ ok: false, error: { code: 'NOT_FOUND', message } }, { status: 404 });
26
+ /**
27
+ * How a run stopped, for the host, which reads the answer whole: the output, the steps and the error's stack, any
28
+ * size, go only to the run's record.
29
+ */
30
+ const stopOf = (result) => {
31
+ const { steps: _steps, ...ran } = result;
32
+ if (ran.stop === 'finished') {
33
+ const { output: _output, ...stop } = ran;
34
+ return stop;
35
+ }
36
+ if (ran.stop === 'suspended')
37
+ return ran;
38
+ const { code, message } = ran.error;
39
+ return { ...ran, error: { code, message } };
40
+ };
26
41
  const handlersOf = ({ workflows, functionIds, handler, }) => ({
27
42
  // A platform-fired run's input carries the runner's `__cron`, `__poll` or `__webhook` state, as classic endpoints get.
28
43
  workflow: async ({ name, body, host }) => {
@@ -33,6 +48,8 @@ const handlersOf = ({ workflows, functionIds, handler, }) => ({
33
48
  const result = await runWorkflow(found.workflow, body.input, {
34
49
  resuming: host.runRoot !== undefined,
35
50
  durable: host.durable,
51
+ // As classic: a preview run, which is the editor's, skips a sleep.
52
+ sleeps: host.mode === 'preview' ? 'skip' : 'refuse',
36
53
  });
37
54
  recordRun(host, {
38
55
  fn: `workflow:${name}`,
@@ -49,7 +66,7 @@ const handlersOf = ({ workflows, functionIds, handler, }) => ({
49
66
  ...(!result.ok &&
50
67
  result.failedStep !== undefined && { failedStep: result.failedStep }),
51
68
  });
52
- return Response.json(result, { status: result.ok ? 200 : 500 });
69
+ return Response.json(stopOf(result), { status: result.ok ? 200 : 500 });
53
70
  },
54
71
  // `{ op, input }`: `subscribe` with the platform's notification URL and secret, or `unsubscribe` with what
55
72
  // `subscribe` returned.
@@ -56,7 +56,7 @@ export type RunReport = {
56
56
  output?: string;
57
57
  error?: RunRecord['error'];
58
58
  console?: ConsoleRecord[];
59
- };
59
+ } & Pick<RunRecord, 'steps' | 'failedStep' | 'suspended'>;
60
60
  /** One step of a workflow call, as zitejs/steps reports it. `failed` marks a replayed final failure. */
61
61
  export type StepRecord = {
62
62
  name: string;
@@ -1 +1 @@
1
- export declare const ZITEJS_VERSION = "0.10.6";
1
+ export declare const ZITEJS_VERSION = "0.10.7";
@@ -1,2 +1,2 @@
1
1
  // Written by scripts/write-version.mjs from package.json.
2
- export const ZITEJS_VERSION = '0.10.6';
2
+ export const ZITEJS_VERSION = '0.10.7';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.10.6",
3
+ "version": "0.10.7",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "sideEffects": [