zitejs 0.10.0-start.2 → 0.10.0-start.20

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 (171) hide show
  1. package/dist/cjs/auth/index.d.ts +2 -2
  2. package/dist/cjs/auth/index.js +6 -0
  3. package/dist/cjs/auth/index.test.js +30 -0
  4. package/dist/cjs/auth/previewClaim.d.ts +7 -0
  5. package/dist/cjs/auth/previewClaim.js +16 -0
  6. package/dist/cjs/backend/index.d.ts +121 -3
  7. package/dist/cjs/backend/index.test.js +58 -0
  8. package/dist/cjs/bundle/index.d.ts +8 -0
  9. package/dist/cjs/bundle/index.js +9 -8
  10. package/dist/cjs/check/index.d.ts +45 -1
  11. package/dist/cjs/check/index.js +198 -109
  12. package/dist/cjs/check/start/problem.d.ts +11 -0
  13. package/dist/cjs/check/start/problem.js +5 -0
  14. package/dist/cjs/check/start/routeTree.d.ts +9 -0
  15. package/dist/cjs/check/start/routeTree.js +111 -0
  16. package/dist/cjs/check/start/sourceRules.d.ts +8 -0
  17. package/dist/cjs/check/start/sourceRules.js +1110 -0
  18. package/dist/cjs/check/start/tsgo.d.ts +2 -0
  19. package/dist/cjs/check/start/tsgo.js +35 -0
  20. package/dist/cjs/cli.js +1 -1
  21. package/dist/cjs/client/index.d.ts +24 -0
  22. package/dist/cjs/dev/index.js +14 -4
  23. package/dist/cjs/integrations/rules.d.ts +13 -0
  24. package/dist/cjs/integrations/rules.js +29 -0
  25. package/dist/cjs/integrations/rules.test.js +1 -0
  26. package/dist/cjs/internal/appMode.d.ts +3 -0
  27. package/dist/cjs/internal/appMode.js +15 -0
  28. package/dist/cjs/runtime/index.d.ts +13 -13
  29. package/dist/cjs/start/entries.d.ts +10 -4
  30. package/dist/cjs/start/entries.js +23 -6
  31. package/dist/cjs/steps/index.d.ts +78 -0
  32. package/dist/cjs/steps/index.js +507 -0
  33. package/dist/cjs/steps/index.test.d.ts +1 -0
  34. package/dist/cjs/steps/index.test.js +635 -0
  35. package/dist/cjs/sync/index.js +2 -1
  36. package/dist/cjs/sync/lib.d.ts +10 -3
  37. package/dist/cjs/sync/lib.js +35 -21
  38. package/dist/cjs/sync/lib.test.js +106 -36
  39. package/dist/cjs/types/fields.d.ts +8 -1
  40. package/dist/cjs/types/fields.js +7 -1
  41. package/dist/cjs/types/tables.d.ts +16 -0
  42. package/dist/cjs/upload/index.js +12 -2
  43. package/dist/cjs/upload/index.test.js +39 -0
  44. package/dist/cjs/vite/index.js +8 -3
  45. package/dist/cjs/vite/index.test.js +10 -2
  46. package/dist/esm/auth/index.d.ts +2 -2
  47. package/dist/esm/auth/index.js +6 -0
  48. package/dist/esm/auth/index.test.js +30 -0
  49. package/dist/esm/auth/previewClaim.d.ts +7 -0
  50. package/dist/esm/auth/previewClaim.js +12 -0
  51. package/dist/esm/backend/index.d.ts +121 -3
  52. package/dist/esm/backend/index.test.js +58 -0
  53. package/dist/esm/bundle/index.d.ts +8 -0
  54. package/dist/esm/bundle/index.js +8 -8
  55. package/dist/esm/check/index.d.ts +45 -1
  56. package/dist/esm/check/index.js +198 -113
  57. package/dist/esm/check/start/problem.d.ts +11 -0
  58. package/dist/esm/check/start/problem.js +1 -0
  59. package/dist/esm/check/start/routeTree.d.ts +9 -0
  60. package/dist/esm/check/start/routeTree.js +70 -0
  61. package/dist/esm/check/start/sourceRules.d.ts +8 -0
  62. package/dist/esm/check/start/sourceRules.js +1107 -0
  63. package/dist/esm/check/start/tsgo.d.ts +2 -0
  64. package/dist/esm/check/start/tsgo.js +29 -0
  65. package/dist/esm/cli.js +1 -1
  66. package/dist/esm/client/index.d.ts +24 -0
  67. package/dist/esm/dev/index.js +16 -6
  68. package/dist/esm/integrations/rules.d.ts +13 -0
  69. package/dist/esm/integrations/rules.js +29 -0
  70. package/dist/esm/integrations/rules.test.js +1 -0
  71. package/dist/esm/internal/appMode.d.ts +3 -0
  72. package/dist/esm/internal/appMode.js +10 -0
  73. package/dist/esm/runtime/index.d.ts +13 -13
  74. package/dist/esm/start/aiUsage.d.ts +23 -0
  75. package/dist/esm/start/aiUsage.js +146 -0
  76. package/dist/esm/start/airtable/arrayFields.d.ts +10 -0
  77. package/dist/esm/start/airtable/arrayFields.js +30 -0
  78. package/dist/esm/start/airtable/dispatch.d.ts +54 -0
  79. package/dist/esm/start/airtable/dispatch.js +483 -0
  80. package/dist/esm/start/airtable/formulas.d.ts +70 -0
  81. package/dist/esm/start/airtable/formulas.js +258 -0
  82. package/dist/esm/start/airtable/index.d.ts +8 -0
  83. package/dist/esm/start/airtable/index.js +54 -0
  84. package/dist/esm/start/authHooks.d.ts +7 -0
  85. package/dist/esm/start/authHooks.js +10 -0
  86. package/dist/esm/start/authHooksModule.d.ts +1 -0
  87. package/dist/esm/start/authHooksModule.js +3 -0
  88. package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
  89. package/dist/esm/start/clientErrorMessage.test.js +105 -0
  90. package/dist/esm/start/credentials.d.ts +2 -0
  91. package/dist/esm/start/credentials.js +2 -0
  92. package/dist/esm/start/data/baseRunner.d.ts +92 -0
  93. package/dist/esm/start/data/baseRunner.js +83 -0
  94. package/dist/esm/start/data/dispatch.d.ts +16 -0
  95. package/dist/esm/start/data/dispatch.js +198 -0
  96. package/dist/esm/start/data/index.d.ts +15 -0
  97. package/dist/esm/start/data/index.js +58 -0
  98. package/dist/esm/start/data/sqlNameMappings.d.ts +58 -0
  99. package/dist/esm/start/data/sqlNameMappings.js +92 -0
  100. package/dist/esm/start/data/transformations.d.ts +97 -0
  101. package/dist/esm/start/data/transformations.js +262 -0
  102. package/dist/esm/start/data/types.d.ts +91 -0
  103. package/dist/esm/start/data/types.js +14 -0
  104. package/dist/esm/start/describe.d.ts +35 -5
  105. package/dist/esm/start/describe.js +74 -22
  106. package/dist/esm/start/entries.d.ts +10 -4
  107. package/dist/esm/start/entries.js +21 -5
  108. package/dist/esm/start/errors.d.ts +63 -0
  109. package/dist/esm/start/errors.js +146 -0
  110. package/dist/esm/start/errors.test.d.ts +1 -0
  111. package/dist/esm/start/errors.test.js +23 -0
  112. package/dist/esm/start/factories.test-d.d.ts +1 -0
  113. package/dist/esm/start/factories.test-d.js +20 -0
  114. package/dist/esm/start/index.d.ts +32 -27
  115. package/dist/esm/start/index.js +77 -47
  116. package/dist/esm/start/instance.d.ts +4 -4
  117. package/dist/esm/start/instance.js +54 -11
  118. package/dist/esm/start/outbound.d.ts +11 -0
  119. package/dist/esm/start/outbound.js +398 -0
  120. package/dist/esm/start/previewClaim.d.ts +7 -0
  121. package/dist/esm/start/previewClaim.js +23 -0
  122. package/dist/esm/start/problems.js +1 -1
  123. package/dist/esm/start/quiet.d.ts +2 -0
  124. package/dist/esm/start/quiet.js +27 -0
  125. package/dist/esm/start/redactSecrets.d.ts +15 -0
  126. package/dist/esm/start/redactSecrets.js +154 -0
  127. package/dist/esm/start/redactSecrets.test.d.ts +1 -0
  128. package/dist/esm/start/redactSecrets.test.js +151 -0
  129. package/dist/esm/start/registration.d.ts +13 -0
  130. package/dist/esm/start/registration.js +21 -0
  131. package/dist/esm/start/registrationHash.d.ts +22 -0
  132. package/dist/esm/start/registrationHash.js +470 -0
  133. package/dist/esm/start/router.d.ts +18 -4
  134. package/dist/esm/start/router.js +134 -11
  135. package/dist/esm/start/runLog.d.ts +7 -4
  136. package/dist/esm/start/runLog.js +64 -6
  137. package/dist/esm/start/scope.d.ts +2 -2
  138. package/dist/esm/start/server.d.ts +40 -36
  139. package/dist/esm/start/server.js +320 -48
  140. package/dist/esm/start/steps.d.ts +28 -0
  141. package/dist/esm/start/steps.js +97 -0
  142. package/dist/esm/start/types.d.ts +178 -5
  143. package/dist/esm/start/version.d.ts +1 -0
  144. package/dist/esm/start/version.js +2 -0
  145. package/dist/esm/start/vite.js +88 -11
  146. package/dist/esm/start/worker.d.ts +6 -0
  147. package/dist/esm/start/worker.js +12 -0
  148. package/dist/esm/start/workflow.d.ts +42 -12
  149. package/dist/esm/start/workflow.js +3 -3
  150. package/dist/esm/start/workflow.test-d.js +41 -8
  151. package/dist/esm/start/workflowModules.js +1 -1
  152. package/dist/esm/start/workflowRun.d.ts +21 -8
  153. package/dist/esm/start/workflowRun.js +29 -8
  154. package/dist/esm/steps/index.d.ts +78 -0
  155. package/dist/esm/steps/index.js +502 -0
  156. package/dist/esm/steps/index.test.d.ts +1 -0
  157. package/dist/esm/steps/index.test.js +633 -0
  158. package/dist/esm/sync/index.js +2 -1
  159. package/dist/esm/sync/lib.d.ts +10 -3
  160. package/dist/esm/sync/lib.js +35 -21
  161. package/dist/esm/sync/lib.test.js +106 -36
  162. package/dist/esm/types/fields.d.ts +8 -1
  163. package/dist/esm/types/fields.js +6 -0
  164. package/dist/esm/types/tables.d.ts +16 -0
  165. package/dist/esm/upload/index.js +12 -2
  166. package/dist/esm/upload/index.test.js +39 -0
  167. package/dist/esm/vite/index.js +8 -3
  168. package/dist/esm/vite/index.test.js +10 -2
  169. package/package.json +37 -16
  170. package/dist/cjs/start/problems.d.ts +0 -19
  171. package/dist/cjs/start/problems.js +0 -11
@@ -0,0 +1,2 @@
1
+ /** tsgo's launcher: the app's own, walking up from it as Node does, else the global install beside this node. */
2
+ export declare function findTsgo(appDir: string): string | undefined;
@@ -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 Run tsc --noEmit (and vite build where there is one) for every app and automation');
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";
@@ -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
- (0, fs_2.writeFileSync)((0, path_1.join)(outDir, "backend.ts"), (0, lib_js_1.generateBackendWrapperTs)(getDeclaredEnvVarNames(appDir)));
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
+ // which installs predating those scopes do not have.
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,7 @@ 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
+ shopify: ["storefrontApiUrl", "storefrontAccessToken"],
71
100
  };
72
101
  /**
73
102
  * 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,3 @@
1
+ export declare const keepRenderedMode: (mode: string | undefined) => void;
2
+ /** The mode the platform served this request or page in; undefined outside a Start app. */
3
+ export declare const platformMode: () => string | undefined;
@@ -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,8 +45,8 @@ 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 stringified as the operand, and Airtable
49
- * 422s on `{Email}=[object Object]`.
48
+ * object, the whole `{ equals: … }` is taken as the value, and the filter
49
+ * fails.
50
50
  *
51
51
  * One operator per field on this path — `formulas.ts` reads
52
52
  * `Object.keys(condition)[0]` and drops the rest, unlike the Zite DB filter
@@ -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
+ /** A hex or `rgb()` color; defaults to the platform's button color. */
270
+ backgroundColor?: string;
271
+ /** A hex or `rgb()` color; 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;
@@ -1,16 +1,22 @@
1
- import type { SourceDir } from "../sourceRoots.js";
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
- /** The server entry every Start app builds with. Platform-owned: regenerated, never edited. */
5
- export declare const renderStartServerEntry: () => string;
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 createWorkflow: what the workflow registry imports. Describe decides what each one really exports. */
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
- /** The server entry every Start app builds with. Platform-owned: regenerated, never edited. */
12
- const renderStartServerEntry = () => `// Generated by zitejs for TanStack Start apps. The platform owns this file.
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 createWorkflow: what the workflow registry imports. Describe decides what each one really exports. */
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("createWorkflow")) {
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;