zitejs 0.9.147 → 0.9.149

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.
Files changed (37) hide show
  1. package/dist/cjs/backend/index.d.ts +7 -1
  2. package/dist/cjs/bundle/index.d.ts +8 -0
  3. package/dist/cjs/bundle/index.js +9 -8
  4. package/dist/cjs/check/index.js +41 -25
  5. package/dist/cjs/client/index.d.ts +24 -0
  6. package/dist/cjs/integrations/rules.js +5 -3
  7. package/dist/cjs/runtime/index.d.ts +49 -19
  8. package/dist/cjs/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
  9. package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +32 -0
  10. package/dist/cjs/steps/index.d.ts +78 -0
  11. package/dist/cjs/steps/index.js +507 -0
  12. package/dist/cjs/steps/index.test.d.ts +1 -0
  13. package/dist/cjs/steps/index.test.js +635 -0
  14. package/dist/cjs/sync/lib.js +10 -6
  15. package/dist/cjs/sync/lib.test.js +100 -36
  16. package/dist/cjs/types/fields.d.ts +8 -1
  17. package/dist/cjs/types/fields.js +7 -1
  18. package/dist/cjs/types/tables.d.ts +16 -0
  19. package/dist/esm/backend/index.d.ts +7 -1
  20. package/dist/esm/bundle/index.d.ts +8 -0
  21. package/dist/esm/bundle/index.js +8 -8
  22. package/dist/esm/check/index.js +10 -27
  23. package/dist/esm/client/index.d.ts +24 -0
  24. package/dist/esm/integrations/rules.js +5 -3
  25. package/dist/esm/runtime/index.d.ts +49 -19
  26. package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
  27. package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +30 -0
  28. package/dist/esm/steps/index.d.ts +78 -0
  29. package/dist/esm/steps/index.js +502 -0
  30. package/dist/esm/steps/index.test.d.ts +1 -0
  31. package/dist/esm/steps/index.test.js +633 -0
  32. package/dist/esm/sync/lib.js +10 -6
  33. package/dist/esm/sync/lib.test.js +100 -36
  34. package/dist/esm/types/fields.d.ts +8 -1
  35. package/dist/esm/types/fields.js +6 -0
  36. package/dist/esm/types/tables.d.ts +16 -0
  37. package/package.json +9 -1
@@ -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). IGNORED here
99
- * for the same reason as `sort` — not in `DatabasesFindAllParamsSchema`, so
100
- * zod strips it — but kept so code already passing it still compiles. It IS
101
- * honored by `zite.auth.findAllUsers`.
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>>;
@@ -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
- export interface SendEmailParams {
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 blocks. HTML like `<div dir="rtl">` inside text blocks is stripped
304
- * by the sanitizer and will NOT work. Defaults to 'ltr'.
299
+ * text. Defaults to 'ltr'.
305
300
  */
306
301
  direction?: "ltr" | "rtl";
307
- /** Custom logo shown above the email content (header area), for branding. */
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,41 @@ 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; 'none' sends the html
330
+ * as the whole document, with no frame or brand.
331
+ */
332
+ layout?: "formatted" | "plain" | "none";
333
+ body?: never;
334
+ }
335
+ /** An email written as an array of content blocks. */
336
+ export interface SendBlocksEmailParams extends SendEmailBaseParams {
337
+ /** Email body as an array of content blocks. */
338
+ body: EmailBlock[];
339
+ /**
340
+ * 'formatted' (default) for styled HTML, 'plain' for text-only. HTML like
341
+ * `<div dir="rtl">` inside text blocks is stripped by the sanitizer.
342
+ */
343
+ layout?: "formatted" | "plain";
344
+ html?: never;
345
+ text?: never;
346
+ }
347
+ export type SendEmailParams = SendHtmlEmailParams | SendBlocksEmailParams;
320
348
  export interface SendEmailResult {
321
349
  success: boolean;
322
350
  messageId: string;
351
+ /** Problems that did not stop the send, e.g. an email large enough for Gmail to clip. */
352
+ warnings?: string[];
323
353
  }
324
354
  export interface EmailClient {
325
355
  send(params: SendEmailParams): Promise<SendEmailResult>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import { expectTypeOf, test } from "vitest";
2
+ test("an email is written as html or as blocks, not both", () => {
3
+ expectTypeOf({
4
+ to: "a@example.com",
5
+ subject: "Hi",
6
+ html: "<p>Hi</p>",
7
+ layout: "none",
8
+ }).toExtend();
9
+ expectTypeOf({
10
+ to: "a@example.com",
11
+ subject: "Hi",
12
+ body: [{ type: "text", content: "Hi" }],
13
+ }).toExtend();
14
+ expectTypeOf({
15
+ to: "a@example.com",
16
+ subject: "Hi",
17
+ html: "<p>Hi</p>",
18
+ body: [],
19
+ }).not.toExtend();
20
+ expectTypeOf({
21
+ to: "a@example.com",
22
+ subject: "Hi",
23
+ body: [],
24
+ layout: "none",
25
+ }).not.toExtend();
26
+ expectTypeOf({
27
+ to: "a@example.com",
28
+ subject: "Hi",
29
+ }).not.toExtend();
30
+ });
@@ -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;