@tailor-platform/sdk 1.83.0 → 1.85.0

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 (70) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/application-C-zsrNjn.mjs +3 -0
  3. package/dist/{application-Cp0FxIm2.mjs → application-m5tYtz0-.mjs} +246 -68
  4. package/dist/application-m5tYtz0-.mjs.map +1 -0
  5. package/dist/cli/commands/deploy/tailordb/index.d.mts +2 -0
  6. package/dist/cli/commands/generate/seed/bundler.d.mts +2 -1
  7. package/dist/cli/commands/generate/service.d.mts +1 -1
  8. package/dist/cli/commands/generate/types.d.mts +1 -1
  9. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -1
  10. package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +5 -0
  11. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -1
  12. package/dist/cli/index.mjs +291 -29
  13. package/dist/cli/index.mjs.map +1 -1
  14. package/dist/cli/lib.d.mts +1 -1
  15. package/dist/cli/lib.mjs +92 -36
  16. package/dist/cli/lib.mjs.map +1 -1
  17. package/dist/cli/shared/client.d.mts +28 -3
  18. package/dist/cli/skills.d.mts +1 -1
  19. package/dist/completion/zsh-worker.zsh +85 -22
  20. package/dist/configure/index.d.mts +2 -2
  21. package/dist/configure/index.mjs +170 -2
  22. package/dist/configure/index.mjs.map +1 -1
  23. package/dist/configure/services/executor/index.d.mts +2 -2
  24. package/dist/configure/services/executor/trigger/event.d.mts +245 -2
  25. package/dist/configure/services/executor/trigger/index.d.mts +3 -3
  26. package/dist/configure/services/index.d.mts +2 -2
  27. package/dist/configure/services/tailordb/index.d.mts +0 -1
  28. package/dist/configure/services/workflow/job.d.mts +9 -0
  29. package/dist/configure/services/workflow/workflow.d.mts +10 -0
  30. package/dist/node-builtins-CmaL2Cbq.mjs +36 -0
  31. package/dist/node-builtins-CmaL2Cbq.mjs.map +1 -0
  32. package/dist/plugin/builtin/seed/index.mjs +1 -1
  33. package/dist/{register-typescript-runtime-CCHyKeXO.mjs → register-typescript-runtime-nG-n9lPw.mjs} +752 -403
  34. package/dist/register-typescript-runtime-nG-n9lPw.mjs.map +1 -0
  35. package/dist/{seed-DFFigL8V.mjs → seed-6eTFj-3Q.mjs} +158 -41
  36. package/dist/seed-6eTFj-3Q.mjs.map +1 -0
  37. package/dist/{service-B0MaodSg.mjs → service-CPJWhTLn.mjs} +29 -2
  38. package/dist/service-CPJWhTLn.mjs.map +1 -0
  39. package/dist/service-Cigg_U-v.mjs +3 -0
  40. package/dist/{service_pb-BwZRiNug.mjs → service_pb-D5--My_M.mjs} +5 -5
  41. package/dist/service_pb-D5--My_M.mjs.map +1 -0
  42. package/dist/{service_pb-wRkxUta6.mjs → service_pb-i8CmnQP4.mjs} +1 -1
  43. package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +106 -1
  44. package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +24 -1
  45. package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +49 -1
  46. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +89 -6
  47. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +26 -1
  48. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +101 -1
  49. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +22 -1
  50. package/dist/types/executor.generated.d.mts +23 -3
  51. package/dist/vitest/index.mjs +3 -35
  52. package/dist/vitest/index.mjs.map +1 -1
  53. package/dist/{workspace_resource_pb-UGK1SSn_.mjs → workspace_resource_pb-DXnO2AT-.mjs} +7 -7
  54. package/dist/workspace_resource_pb-DXnO2AT-.mjs.map +1 -0
  55. package/docs/cli/tailordb.md +36 -12
  56. package/docs/cli-reference.md +16 -15
  57. package/docs/generator/builtin.md +7 -0
  58. package/docs/services/executor.md +83 -3
  59. package/docs/services/idp.md +3 -3
  60. package/docs/services/tailordb-migration.md +24 -4
  61. package/docs/services/workflow.md +26 -0
  62. package/package.json +17 -18
  63. package/dist/application-CP7JKG9R.mjs +0 -3
  64. package/dist/application-Cp0FxIm2.mjs.map +0 -1
  65. package/dist/register-typescript-runtime-CCHyKeXO.mjs.map +0 -1
  66. package/dist/seed-DFFigL8V.mjs.map +0 -1
  67. package/dist/service-B0MaodSg.mjs.map +0 -1
  68. package/dist/service-KnAiVofD.mjs +0 -3
  69. package/dist/service_pb-BwZRiNug.mjs.map +0 -1
  70. package/dist/workspace_resource_pb-UGK1SSn_.mjs.map +0 -1
@@ -1,11 +1,13 @@
1
1
  import { n as isSdkBranded } from "./brand-Eo4pLXPJ.mjs";
2
2
  import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
3
3
  import { a as parseBoolean, n as logger, r as styles } from "./logger-CXQq9YIp.mjs";
4
- import { a as TailorFieldSchema, i as AuthInvokerSchema, n as ExecutorSchema, o as loadFilesWithIgnores, r as AuthConfigSchema, s as functionSchema, t as createExecutorService } from "./service-B0MaodSg.mjs";
4
+ import { a as TailorFieldSchema, i as AuthInvokerSchema, n as ExecutorSchema, o as loadFilesWithIgnores, r as AuthConfigSchema, s as functionSchema, t as createExecutorService } from "./service-CPJWhTLn.mjs";
5
5
  import { t as multiline } from "./multiline-sfHpTZZK.mjs";
6
6
  import { t as isPluginGeneratedType } from "./type-source-DH_LH20p.mjs";
7
7
  import { t as userAgent } from "./user-agent-DX2Jnw0-.mjs";
8
- import { builtinModules, createRequire } from "node:module";
8
+ import { t as createCLIError } from "./errors-DVFS0AZk.mjs";
9
+ import { n as isNodeBuiltinImport, t as getNodeBuiltinMessage } from "./node-builtins-CmaL2Cbq.mjs";
10
+ import { createRequire } from "node:module";
9
11
  import { z } from "zod";
10
12
  import { create } from "@bufbuild/protobuf";
11
13
  import * as fs from "node:fs";
@@ -17,12 +19,12 @@ import { pathToFileURL } from "node:url";
17
19
  import * as os from "node:os";
18
20
  import { OAuth2Client } from "@badgateway/oauth2-client";
19
21
  import { Code, ConnectError, createClient } from "@connectrpc/connect";
20
- import { getGlobalDispatcher } from "undici";
21
22
  import pLimit from "p-limit";
22
23
  import { resolveTSConfig } from "pkg-types";
23
24
  import * as crypto from "node:crypto";
24
25
  import * as rolldown from "rolldown";
25
26
  import { parseSync } from "oxc-parser";
27
+ import { createPathsMatcher, getTsconfig } from "get-tsconfig";
26
28
  import * as inflection from "inflection";
27
29
  import * as globals from "globals";
28
30
 
@@ -180,7 +182,7 @@ function initOAuth2Client(config) {
180
182
  */
181
183
  async function initOperatorClient(accessToken, config) {
182
184
  const platformConfig = config ?? getPlatformConfigForToken(accessToken);
183
- const [{ createTracingInterceptor }, { OperatorService }] = await Promise.all([import("./interceptor-D-q1rvRl.mjs"), import("./service_pb-wRkxUta6.mjs")]);
185
+ const [{ createTracingInterceptor }, { OperatorService }] = await Promise.all([import("./interceptor-D-q1rvRl.mjs"), import("./service_pb-i8CmnQP4.mjs")]);
184
186
  const interceptors = [
185
187
  await userAgentInterceptor(),
186
188
  await bearerTokenInterceptor(accessToken),
@@ -233,9 +235,10 @@ async function bearerTokenInterceptor(accessToken) {
233
235
  /**
234
236
  * Create an interceptor that retries failed unary requests with backoff.
235
237
  *
236
- * Retries unary methods on `Unavailable`/`ResourceExhausted`, and `Internal`
237
- * only for methods declared idempotent, up to 3 attempts. Workspace creation is
238
- * excluded because it has no idempotency key and a lost response is ambiguous.
238
+ * Retries unary methods on `Unavailable`/`ResourceExhausted`, and
239
+ * `Aborted`/`Internal` only for methods declared side-effect-free or idempotent,
240
+ * up to 3 attempts. Workspace creation is excluded because it has no idempotency
241
+ * key and a lost response is ambiguous.
239
242
  * As a targeted exception for the deploy/apply flow, a post-retry `AlreadyExists`
240
243
  * from an allowlisted Create (see `RETRY_SAFE_CREATE_METHODS`) is treated as
241
244
  * success, since it means a prior attempt already committed the resource
@@ -414,6 +417,7 @@ function isRetirable(error, idempotency) {
414
417
  switch (error.code) {
415
418
  case Code.ResourceExhausted:
416
419
  case Code.Unavailable: return true;
420
+ case Code.Aborted:
417
421
  case Code.Internal: return idempotency === MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS || idempotency === MethodOptions_IdempotencyLevel.IDEMPOTENT;
418
422
  default: return false;
419
423
  }
@@ -659,12 +663,20 @@ async function fetchPlatformMachineUserToken(clientId, clientSecret, config) {
659
663
  }).clientCredentials();
660
664
  }
661
665
  /**
662
- * Close undici's global HTTP connection pool to prevent libuv UV_HANDLE_CLOSING
666
+ * Close the global HTTP connection pool to prevent libuv UV_HANDLE_CLOSING
663
667
  * assertion failure on Windows at process exit (Node.js 23.x+).
664
668
  * See: https://github.com/nodejs/node/issues/56645
669
+ *
670
+ * The pool is reached through the global dispatcher symbol rather than the `undici`
671
+ * package: importing that package installs its own Agent over these same globals,
672
+ * replacing the HTTP stack Node's `fetch` already uses. The symbol is versioned per
673
+ * Dispatcher API generation, and the newest one wins because older symbols hold a
674
+ * wrapper around that same pool — closing both would destroy it twice.
665
675
  */
666
676
  async function closeConnectionPool() {
667
- await getGlobalDispatcher().close();
677
+ const globals = globalThis;
678
+ const dispatcher = globals[Symbol.for("undici.globalDispatcher.2")] ?? globals[Symbol.for("undici.globalDispatcher.1")];
679
+ if (typeof dispatcher?.close === "function") await dispatcher.close();
668
680
  }
669
681
 
670
682
  //#endregion
@@ -686,17 +698,27 @@ function hashFile(filePath) {
686
698
  const content = fs.readFileSync(filePath);
687
699
  return crypto.createHash("sha256").update(content).digest("hex");
688
700
  }
701
+ const MISSING_FILE_MARKER = "<missing>";
689
702
  /**
690
703
  * Compute a deterministic SHA-256 hash for multiple files.
691
704
  *
692
705
  * Paths are sorted alphabetically before hashing so that the result
693
706
  * is independent of the order the paths are supplied (e.g. glob ordering).
694
- * Each file's individual hash is concatenated and then hashed again.
707
+ * Each file's individual hash is concatenated and then hashed again. A path
708
+ * that does not exist contributes a fixed marker instead of a content hash.
695
709
  * @param filePaths - Array of absolute file paths
696
710
  * @returns Hex-encoded SHA-256 hash representing all files
697
711
  */
698
712
  function hashFiles(filePaths) {
699
- return hashContent(filePaths.toSorted().map((fp) => hashFile(fp)).join(""));
713
+ return hashContent(filePaths.toSorted().map((fp) => hashFileOrMissing(fp)).join(""));
714
+ }
715
+ function hashFileOrMissing(filePath) {
716
+ try {
717
+ return hashFile(filePath);
718
+ } catch (error) {
719
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return MISSING_FILE_MARKER;
720
+ throw error;
721
+ }
700
722
  }
701
723
 
702
724
  //#endregion
@@ -771,7 +793,7 @@ function computeBundlerContextHash(params) {
771
793
  */
772
794
  async function withCache(params) {
773
795
  const { cache, kind, namespace, name, sourceFile, contextHash, build } = params;
774
- if (!cache) return await build([]);
796
+ if (!cache) return await build([], () => {});
775
797
  const content = cache.tryRestore({
776
798
  kind,
777
799
  namespace,
@@ -782,15 +804,16 @@ async function withCache(params) {
782
804
  logger.debug(` ${styles.dim("cached")}: ${name}`);
783
805
  return content;
784
806
  }
807
+ const extraDependencies = /* @__PURE__ */ new Set();
785
808
  const { plugin, getResult } = createDepCollectorPlugin();
786
- const code = await build([plugin]);
809
+ const code = await build([plugin], (filePath) => extraDependencies.add(filePath));
787
810
  cache.save({
788
811
  kind,
789
812
  namespace,
790
813
  name,
791
814
  sourceFile,
792
815
  content: code,
793
- dependencyPaths: getResult(),
816
+ dependencyPaths: [...getResult(), ...extraDependencies],
794
817
  contextHash
795
818
  });
796
819
  return code;
@@ -2020,7 +2043,7 @@ function transformFunctionTriggers(source, triggerContext, currentFilePath) {
2020
2043
  return needsNormalizerHelper && authNamespace ? buildNormalizerHelperSource(authNamespace) + transformed : transformed;
2021
2044
  }
2022
2045
  function createTriggerTransformPlugin(triggerContext) {
2023
- if (!triggerContext) return void 0;
2046
+ if (!triggerContext || triggerContext.modules.size === 0) return void 0;
2024
2047
  return {
2025
2048
  name: "trigger-transform",
2026
2049
  transform: {
@@ -2033,6 +2056,50 @@ function createTriggerTransformPlugin(triggerContext) {
2033
2056
  };
2034
2057
  }
2035
2058
 
2059
+ //#endregion
2060
+ //#region src/cli/shared/bundle-log.ts
2061
+ const ESCALATED_LOG_CODE = "UNRESOLVED_IMPORT";
2062
+ /**
2063
+ * Collect unresolved imports while keeping every other rolldown log suppressed.
2064
+ * @param options - Context used to explain which tsconfig was in effect
2065
+ * @returns Rolldown options and a post-build assertion
2066
+ */
2067
+ function createBundleLog(options = {}) {
2068
+ const unresolvedImports = /* @__PURE__ */ new Map();
2069
+ return {
2070
+ options: {
2071
+ logLevel: "warn",
2072
+ onLog: (_level, log) => {
2073
+ if (log.code !== ESCALATED_LOG_CODE) return;
2074
+ unresolvedImports.set(JSON.stringify([log.exporter, log.id]), log);
2075
+ }
2076
+ },
2077
+ assertAllResolved() {
2078
+ if (unresolvedImports.size > 0) throw unresolvedImportError([...unresolvedImports.values()], options.tsconfig);
2079
+ }
2080
+ };
2081
+ }
2082
+ function unresolvedImportError(logs, tsconfig) {
2083
+ const imports = logs.map(formatUnresolvedImport);
2084
+ return createCLIError({
2085
+ code: "UNRESOLVED_IMPORT",
2086
+ message: imports.length === 1 ? `Could not resolve ${imports[0]}.` : `Could not resolve ${imports.length} imports.`,
2087
+ details: imports.length === 1 ? void 0 : imports.map((item) => `- ${item}`).join("\n"),
2088
+ suggestion: unresolvedImportSuggestion(logs, tsconfig)
2089
+ });
2090
+ }
2091
+ function unresolvedImportSuggestion(logs, tsconfig) {
2092
+ const nodeSuggestions = logs.map((log) => log.exporter).filter((specifier) => specifier !== void 0).filter(isNodeBuiltinImport).map(getNodeBuiltinMessage);
2093
+ const hasOtherImports = logs.some((log) => log.exporter === void 0 || !isNodeBuiltinImport(log.exporter));
2094
+ const pathSuggestion = tsconfig ? `Check that each import path is correct, and that a \`compilerOptions.paths\` entry covering it is declared in the importing file's own tsconfig.json or an ancestor. The build used "${tsconfig}".` : "No tsconfig.json was found, so `compilerOptions.paths` aliases were not applied. Add a tsconfig.json declaring the aliases these files import.";
2095
+ return [.../* @__PURE__ */ new Set([...nodeSuggestions, ...hasOtherImports ? [pathSuggestion] : []])].join("\n");
2096
+ }
2097
+ function formatUnresolvedImport(log) {
2098
+ const specifier = log.exporter ?? "an imported module";
2099
+ const importerId = log.id?.startsWith("\0") ? `a generated entry (${log.id.slice(1)})` : log.id && `"${log.id}"`;
2100
+ return `"${specifier}"${importerId ? ` imported from ${importerId}` : ""}`;
2101
+ }
2102
+
2036
2103
  //#endregion
2037
2104
  //#region src/cli/shared/bundle-log-level.ts
2038
2105
  const INFO_LEVEL_CONSOLE_METHODS = [
@@ -2167,6 +2234,71 @@ async function tryResolve(dir) {
2167
2234
  }
2168
2235
  }
2169
2236
 
2237
+ //#endregion
2238
+ //#region src/cli/shared/tsconfig-paths-plugin.ts
2239
+ /**
2240
+ * Create the rolldown plugin that falls back to tsconfig `paths` aliases from
2241
+ * the importing file's own nearest tsconfig.
2242
+ * @param options - Resolution context for bundlers whose entry inlines user code
2243
+ * @returns Rolldown plugin to add to a bundler's plugin list
2244
+ */
2245
+ function createTsconfigPathsPlugin(options = {}) {
2246
+ const tsconfigCache = /* @__PURE__ */ new Map();
2247
+ const contextCache = /* @__PURE__ */ new Map();
2248
+ return {
2249
+ name: "tailor-sdk-tsconfig-paths",
2250
+ resolveId: {
2251
+ order: "post",
2252
+ async handler(source, importer) {
2253
+ if (!importer) return null;
2254
+ if (source.startsWith(".") || source.startsWith("/") || source.startsWith("\0")) return null;
2255
+ const resolutionBasis = importer.startsWith("\0") ? options.virtualEntrySourceFile : importer;
2256
+ if (!resolutionBasis) return null;
2257
+ const resolution = getResolutionContext(path.dirname(resolutionBasis), tsconfigCache, contextCache, options.onTsconfigRead);
2258
+ if (!resolution) return null;
2259
+ const candidates = resolution.matcher(source);
2260
+ if (candidates.length === 0) return null;
2261
+ if (await this.resolve(source, importer, { skipSelf: true })) return null;
2262
+ for (const candidate of candidates) {
2263
+ const resolved = await this.resolve(candidate, importer, { skipSelf: true });
2264
+ if (resolved) return resolved;
2265
+ }
2266
+ return null;
2267
+ }
2268
+ }
2269
+ };
2270
+ }
2271
+ function getResolutionContext(startDir, tsconfigCache, contextCache, onTsconfigRead) {
2272
+ const cached = contextCache.get(startDir);
2273
+ if (cached !== void 0) return cached;
2274
+ const tsconfig = getTsconfig(startDir, "tsconfig.json", tsconfigCache);
2275
+ reportTsconfigDependencies(tsconfigCache, onTsconfigRead);
2276
+ const paths = tsconfig?.config.compilerOptions?.paths;
2277
+ const matcher = paths && Object.keys(paths).length > 0 ? createPathsMatcher(tsconfig) : null;
2278
+ const resolution = matcher ? { matcher } : null;
2279
+ contextCache.set(startDir, resolution);
2280
+ return resolution;
2281
+ }
2282
+ function reportTsconfigDependencies(cache, onTsconfigRead) {
2283
+ if (!onTsconfigRead) return;
2284
+ const directories = /* @__PURE__ */ new Set();
2285
+ const dependencies = /* @__PURE__ */ new Set();
2286
+ for (const [key, value] of cache) {
2287
+ const dependencyPath = dependencyPathFromCacheKey(key);
2288
+ if (!dependencyPath) continue;
2289
+ if (key.startsWith("statSync:") && isDirectoryStat(value)) directories.add(dependencyPath);
2290
+ else dependencies.add(dependencyPath);
2291
+ }
2292
+ for (const dependencyPath of dependencies) if (!directories.has(dependencyPath)) onTsconfigRead(dependencyPath);
2293
+ }
2294
+ function dependencyPathFromCacheKey(key) {
2295
+ if (key.startsWith("readFileSync:") && key.endsWith(":utf8")) return key.slice(13, -5);
2296
+ for (const prefix of ["existsSync:", "statSync:"]) if (key.startsWith(prefix)) return key.slice(prefix.length);
2297
+ }
2298
+ function isDirectoryStat(value) {
2299
+ return typeof value === "object" && value !== null && "isDirectory" in value && typeof value.isDirectory === "function" && value.isDirectory();
2300
+ }
2301
+
2170
2302
  //#endregion
2171
2303
  //#region src/cli/shared/virtual-entry.ts
2172
2304
  /**
@@ -2174,17 +2306,20 @@ async function tryResolve(dir) {
2174
2306
  * @param name - Logical entry name
2175
2307
  * @param code - Entry module source
2176
2308
  * @param sourceType - Parser type for the generated module
2309
+ * @param resolutionBasis - Source file whose directory resolves generated imports
2177
2310
  * @returns Rolldown input and plugin for loading the entry
2178
2311
  */
2179
- function createVirtualEntry(name, code, sourceType = "js") {
2312
+ function createVirtualEntry(name, code, sourceType = "js", resolutionBasis) {
2180
2313
  const input = `tailor-sdk-entry:${name}.${sourceType}`;
2181
2314
  const resolvedId = `\0${input}`;
2182
2315
  return {
2183
2316
  input,
2184
2317
  plugin: {
2185
2318
  name: "tailor-sdk-virtual-entry",
2186
- resolveId(source, importer) {
2187
- return source === input && importer === void 0 ? resolvedId : null;
2319
+ async resolveId(source, importer) {
2320
+ if (source === input && importer === void 0) return resolvedId;
2321
+ if (importer !== resolvedId || !resolutionBasis) return null;
2322
+ return this.resolve(source, resolutionBasis, { skipSelf: true });
2188
2323
  },
2189
2324
  load(id) {
2190
2325
  return id === resolvedId ? code : null;
@@ -2192,6 +2327,27 @@ function createVirtualEntry(name, code, sourceType = "js") {
2192
2327
  }
2193
2328
  };
2194
2329
  }
2330
+ /**
2331
+ * Resolve bare imports in a generated on-disk entry from its owning project.
2332
+ *
2333
+ * Generated entries live under the CLI output directory, which may be outside
2334
+ * the project selected by a config path. Resolving their injected dependencies
2335
+ * from that output directory would ignore the selected project's installation.
2336
+ * @param entryPath - Absolute path of the generated entry
2337
+ * @param projectDir - Directory whose dependencies the generated entry uses
2338
+ * @returns Rolldown plugin that rebases generated bare imports
2339
+ */
2340
+ function createGeneratedEntryResolverPlugin(entryPath, projectDir) {
2341
+ const normalizedEntryPath = path.resolve(entryPath);
2342
+ const resolutionBasis = path.join(path.resolve(projectDir), "__tailor_sdk_generated_entry__.js");
2343
+ return {
2344
+ name: "tailor-sdk-generated-entry-resolver",
2345
+ async resolveId(source, importer) {
2346
+ if (importer === void 0 || path.resolve(importer) !== normalizedEntryPath || source.startsWith(".") || path.isAbsolute(source) || source.startsWith("\0")) return null;
2347
+ return this.resolve(source, resolutionBasis, { skipSelf: true });
2348
+ }
2349
+ };
2350
+ }
2195
2351
 
2196
2352
  //#endregion
2197
2353
  //#region src/cli/services/auth/bundler.ts
@@ -2224,7 +2380,7 @@ async function bundleAuthHooks(options) {
2224
2380
  bundleLogLevel,
2225
2381
  prefix: JSON.stringify(Object.fromEntries(Object.entries(env).toSorted(([a], [b]) => a.localeCompare(b))))
2226
2382
  }),
2227
- async build(cachePlugins) {
2383
+ async build(cachePlugins, trackDependency) {
2228
2384
  const entryContent = multiline`
2229
2385
  import _config from "${absoluteConfigPath}";
2230
2386
  const __auth_hook_function = _config.${handlerAccessPath};
@@ -2233,12 +2389,13 @@ async function bundleAuthHooks(options) {
2233
2389
  return await __auth_hook_function({ ...args, env });
2234
2390
  }
2235
2391
  `;
2236
- const entry = createVirtualEntry(`auth-hook:${functionName}`, entryContent);
2392
+ const entry = createVirtualEntry(`auth-hook:${functionName}`, entryContent, "js", absoluteConfigPath);
2237
2393
  const triggerPlugin = createTriggerTransformPlugin(triggerContext);
2238
2394
  const plugins = [entry.plugin];
2239
2395
  if (triggerPlugin) plugins.push(triggerPlugin);
2240
- plugins.push(platformBundleDefinePlugin, ...cachePlugins);
2241
- return (await rolldown.build({
2396
+ plugins.push(createTsconfigPathsPlugin({ onTsconfigRead: trackDependency }), platformBundleDefinePlugin, ...cachePlugins);
2397
+ const bundleLog = createBundleLog({ tsconfig });
2398
+ const result = await rolldown.build({
2242
2399
  input: entry.input,
2243
2400
  write: false,
2244
2401
  output: {
@@ -2251,8 +2408,10 @@ async function bundleAuthHooks(options) {
2251
2408
  plugins,
2252
2409
  transform: { define: { "process.env.LOG_LEVEL": JSON.stringify(bundleLogLevel) } },
2253
2410
  treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
2254
- logLevel: "silent"
2255
- })).output[0].code;
2411
+ ...bundleLog.options
2412
+ });
2413
+ bundleLog.assertAllResolved();
2414
+ return result.output[0].code;
2256
2415
  }
2257
2416
  });
2258
2417
  logger.log(`${styles.success("Bundled")} auth hook for ${styles.info(`"${authName}"`)}`);
@@ -3401,9 +3560,14 @@ async function bundleScriptTarget(args) {
3401
3560
  if (unresolved.length > 0) throw new Error(`${context} captures unresolvable variables (${unresolved.join(", ")}). Hooks and validators must not reference variables that cannot be resolved from the source file.
3402
3561
  ${kind}: ${fnSource}`);
3403
3562
  const entryContent = buildMinimalEntryFromResolved(imports, declarations, fnSource, sourceFilePath);
3404
- const entry = createVirtualEntry(`tailordb-script:${typeName}:${targetIndex}`, entryContent, "ts");
3405
- const bundledCode = (await rolldown.build({
3406
- plugins: [entry.plugin, platformBundleDefinePlugin],
3563
+ const entry = createVirtualEntry(`tailordb-script:${typeName}:${targetIndex}`, entryContent, "ts", sourceFilePath);
3564
+ const bundleLog = createBundleLog({ tsconfig });
3565
+ const buildResult = await rolldown.build({
3566
+ plugins: [
3567
+ entry.plugin,
3568
+ createTsconfigPathsPlugin({ virtualEntrySourceFile: sourceFilePath }),
3569
+ platformBundleDefinePlugin
3570
+ ],
3407
3571
  input: entry.input,
3408
3572
  write: false,
3409
3573
  output: {
@@ -3418,8 +3582,10 @@ async function bundleScriptTarget(args) {
3418
3582
  annotations: true,
3419
3583
  unknownGlobalSideEffects: false
3420
3584
  },
3421
- logLevel: "silent"
3422
- })).output[0].code;
3585
+ ...bundleLog.options
3586
+ });
3587
+ bundleLog.assertAllResolved();
3588
+ const bundledCode = buildResult.output[0].code;
3423
3589
  return assertParsableExpression(buildPrecompiledExpr(bundledCode), context);
3424
3590
  }
3425
3591
  /**
@@ -3917,6 +4083,8 @@ function buildExecutorArgsExpr(triggerKind, env) {
3917
4083
  case "schedule": return `({ ...args, appNamespace: args.namespaceName, ${ACTOR_TRANSFORM_EXPR}, ${envExpr} })`;
3918
4084
  case "resolverExecuted": return `({ ...args, appNamespace: args.namespaceName, ${ACTOR_TRANSFORM_EXPR}, success: !!args.succeeded, result: args.succeeded?.result.resolver, error: args.failed?.error, ${envExpr} })`;
3919
4085
  case "incomingWebhook": return `({ ...args, appNamespace: args.namespaceName, rawBody: args.raw_body, ${envExpr} })`;
4086
+ case "workflowExecution":
4087
+ case "workflowJobExecution": return `({ ...args, event: args.eventType?.split(".").pop(), rawEvent: args.eventType, ${ACTOR_TRANSFORM_EXPR}, ...(args.succeeded ? { success: true } : args.failed ? { success: false, error: args.failed.error ?? "" } : {}), ${envExpr} })`;
3920
4088
  default: return `({ ...args, event: args.eventType?.split(".").pop(), rawEvent: args.eventType, appNamespace: args.namespaceName, ${ACTOR_TRANSFORM_EXPR}, ${envExpr} })`;
3921
4089
  }
3922
4090
  }
@@ -4116,9 +4284,10 @@ async function bundleSingleExecutor(executor, tsconfig, triggerContext, cache, i
4116
4284
  name: executor.name,
4117
4285
  sourceFile: executor.sourceFile,
4118
4286
  contextHash,
4119
- async build(cachePlugins) {
4287
+ async build(cachePlugins, trackDependency) {
4288
+ const absoluteSourcePath = path.resolve(executor.sourceFile);
4120
4289
  const entryContent = multiline`
4121
- import _internalExecutor from "${path.resolve(executor.sourceFile)}";
4290
+ import _internalExecutor from "${absoluteSourcePath}";
4122
4291
 
4123
4292
  const __executor_function = async (args) => {
4124
4293
  const invoker = ${INVOKER_EXPR};
@@ -4127,12 +4296,13 @@ async function bundleSingleExecutor(executor, tsconfig, triggerContext, cache, i
4127
4296
 
4128
4297
  export { __executor_function as main };
4129
4298
  `;
4130
- const entry = createVirtualEntry(`executor:${executor.name}`, entryContent);
4299
+ const entry = createVirtualEntry(`executor:${executor.name}`, entryContent, "js", absoluteSourcePath);
4131
4300
  const triggerPlugin = createTriggerTransformPlugin(triggerContext);
4132
4301
  const plugins = [entry.plugin];
4133
4302
  if (triggerPlugin) plugins.push(triggerPlugin);
4134
- plugins.push(platformBundleDefinePlugin, ...cachePlugins);
4135
- return (await rolldown.build({
4303
+ plugins.push(createTsconfigPathsPlugin({ onTsconfigRead: trackDependency }), platformBundleDefinePlugin, ...cachePlugins);
4304
+ const bundleLog = createBundleLog({ tsconfig });
4305
+ const result = await rolldown.build({
4136
4306
  input: entry.input,
4137
4307
  write: false,
4138
4308
  output: {
@@ -4144,22 +4314,15 @@ async function bundleSingleExecutor(executor, tsconfig, triggerContext, cache, i
4144
4314
  tsconfig,
4145
4315
  plugins,
4146
4316
  treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
4147
- logLevel: "silent"
4148
- })).output[0].code;
4317
+ ...bundleLog.options
4318
+ });
4319
+ bundleLog.assertAllResolved();
4320
+ return result.output[0].code;
4149
4321
  }
4150
4322
  });
4151
4323
  return [executor.name, code];
4152
4324
  }
4153
4325
 
4154
- //#endregion
4155
- //#region src/cli/services/http-adapter/node-builtins.ts
4156
- const NODE_BUILTINS = new Set(builtinModules.filter((m) => !m.startsWith("_")));
4157
- function isNodeBuiltinImport(source) {
4158
- if (source.startsWith("node:")) return true;
4159
- const root = source.includes("/") ? source.slice(0, source.indexOf("/")) : source;
4160
- return NODE_BUILTINS.has(root);
4161
- }
4162
-
4163
4326
  //#endregion
4164
4327
  //#region src/parser/service/http-adapter/methods.ts
4165
4328
  /**
@@ -4249,16 +4412,16 @@ async function bundleAdapterScript(adapter, kind, tsconfig, cache, bundleLogLeve
4249
4412
  name: adapter.name,
4250
4413
  sourceFile: adapter.sourceFile,
4251
4414
  contextHash,
4252
- async build(cachePlugins) {
4415
+ async build(cachePlugins, trackDependency) {
4253
4416
  const absoluteSourcePath = path.resolve(adapter.sourceFile);
4254
4417
  const entryContent = kind === "input" ? buildInputEntry(absoluteSourcePath, adapter.methods, GRAPHQL_WEB_MODULE) : buildOutputEntry(absoluteSourcePath);
4255
- const entry = createVirtualEntry(`http-adapter:${adapter.name}:${kind}`, entryContent);
4418
+ const entry = createVirtualEntry(`http-adapter:${adapter.name}:${kind}`, entryContent, "js", absoluteSourcePath);
4256
4419
  const plugins = [
4257
4420
  entry.plugin,
4258
4421
  {
4259
4422
  name: "http-adapter-reject-node-imports",
4260
4423
  resolveId(source) {
4261
- if (isNodeBuiltinImport(source)) throw new Error(`HTTP adapter "${adapter.name}" imports Node module "${source}", which is unavailable in the gateway runtime`);
4424
+ if (isNodeBuiltinImport(source)) throw new Error(`HTTP adapter "${adapter.name}": ${getNodeBuiltinMessage(source)}`);
4262
4425
  return null;
4263
4426
  }
4264
4427
  },
@@ -4276,9 +4439,11 @@ async function bundleAdapterScript(adapter, kind, tsconfig, cache, bundleLogLeve
4276
4439
  return null;
4277
4440
  }
4278
4441
  },
4442
+ createTsconfigPathsPlugin({ onTsconfigRead: trackDependency }),
4279
4443
  ...cachePlugins
4280
4444
  ];
4281
- const bundled = (await rolldown.build({
4445
+ const bundleLog = createBundleLog({ tsconfig });
4446
+ const result = await rolldown.build({
4282
4447
  input: entry.input,
4283
4448
  write: false,
4284
4449
  output: {
@@ -4291,8 +4456,10 @@ async function bundleAdapterScript(adapter, kind, tsconfig, cache, bundleLogLeve
4291
4456
  plugins,
4292
4457
  transform: { target: "es2017" },
4293
4458
  treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
4294
- logLevel: "silent"
4295
- })).output[0].code;
4459
+ ...bundleLog.options
4460
+ });
4461
+ bundleLog.assertAllResolved();
4462
+ const bundled = result.output[0].code;
4296
4463
  const byteLength = Buffer.byteLength(bundled, "utf8");
4297
4464
  if (byteLength > ADAPTER_BUNDLE_ERROR_BYTES) throw new Error(`HTTP adapter "${adapter.name}" ${kind} script is ${byteLength} bytes, exceeding the ${ADAPTER_BUNDLE_ERROR_BYTES} byte limit`);
4298
4465
  if (byteLength > ADAPTER_BUNDLE_WARN_BYTES) logger.warn(`HTTP adapter "${adapter.name}" ${kind} script is ${byteLength} bytes, larger than the recommended ${ADAPTER_BUNDLE_WARN_BYTES} byte limit`);
@@ -4583,9 +4750,10 @@ async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContex
4583
4750
  name: resolver.name,
4584
4751
  sourceFile: resolver.sourceFile,
4585
4752
  contextHash,
4586
- async build(cachePlugins) {
4753
+ async build(cachePlugins, trackDependency) {
4754
+ const absoluteSourcePath = path.resolve(resolver.sourceFile);
4587
4755
  const entryContent = multiline`
4588
- import _internalResolver from "${path.resolve(resolver.sourceFile)}";
4756
+ import _internalResolver from "${absoluteSourcePath}";
4589
4757
  import { t } from "@tailor-platform/sdk";
4590
4758
 
4591
4759
  const $tailor_resolver_body = async (context) => {
@@ -4596,12 +4764,13 @@ async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContex
4596
4764
 
4597
4765
  export { $tailor_resolver_body as main };
4598
4766
  `;
4599
- const entry = createVirtualEntry(`resolver:${resolver.name}`, entryContent);
4767
+ const entry = createVirtualEntry(`resolver:${resolver.name}`, entryContent, "js", absoluteSourcePath);
4600
4768
  const triggerPlugin = createTriggerTransformPlugin(triggerContext);
4601
4769
  const plugins = [entry.plugin];
4602
4770
  if (triggerPlugin) plugins.push(triggerPlugin);
4603
- plugins.push(platformBundleDefinePlugin, ...cachePlugins);
4604
- return (await rolldown.build({
4771
+ plugins.push(createTsconfigPathsPlugin({ onTsconfigRead: trackDependency }), platformBundleDefinePlugin, ...cachePlugins);
4772
+ const bundleLog = createBundleLog({ tsconfig });
4773
+ const result = await rolldown.build({
4605
4774
  input: entry.input,
4606
4775
  write: false,
4607
4776
  output: {
@@ -4613,8 +4782,10 @@ async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContex
4613
4782
  tsconfig,
4614
4783
  plugins,
4615
4784
  treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
4616
- logLevel: "silent"
4617
- })).output[0].code;
4785
+ ...bundleLog.options
4786
+ });
4787
+ bundleLog.assertAllResolved();
4788
+ return result.output[0].code;
4618
4789
  }
4619
4790
  });
4620
4791
  return [resolver.name, code];
@@ -4922,7 +5093,7 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4922
5093
  name: job.name,
4923
5094
  sourceFile: job.sourceFile,
4924
5095
  contextHash,
4925
- async build(cachePlugins) {
5096
+ async build(cachePlugins, trackDependency) {
4926
5097
  const absoluteSourcePath = path.resolve(job.sourceFile);
4927
5098
  const entryContent = multiline`
4928
5099
  import { ${job.exportName} } from "${absoluteSourcePath}";
@@ -4933,7 +5104,7 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4933
5104
  return await ${job.exportName}.body(input, { env, invoker });
4934
5105
  }
4935
5106
  `;
4936
- const entry = createVirtualEntry(`workflow-job:${job.name}`, entryContent);
5107
+ const entry = createVirtualEntry(`workflow-job:${job.name}`, entryContent, "js", absoluteSourcePath);
4937
5108
  const resolvedSourceFile = safeRealpath(job.sourceFile);
4938
5109
  const otherJobExportNames = allJobs.filter((candidate) => candidate.name !== job.name && safeRealpath(candidate.sourceFile) === resolvedSourceFile).map((j) => j.exportName);
4939
5110
  const plugins = [
@@ -4952,10 +5123,12 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4952
5123
  }
4953
5124
  }
4954
5125
  },
5126
+ createTsconfigPathsPlugin({ onTsconfigRead: trackDependency }),
4955
5127
  platformBundleDefinePlugin,
4956
5128
  ...cachePlugins
4957
5129
  ];
4958
- return (await rolldown.build({
5130
+ const bundleLog = createBundleLog({ tsconfig });
5131
+ const result = await rolldown.build({
4959
5132
  input: entry.input,
4960
5133
  write: false,
4961
5134
  output: {
@@ -4967,8 +5140,10 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4967
5140
  tsconfig,
4968
5141
  plugins,
4969
5142
  treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
4970
- logLevel: "silent"
4971
- })).output[0].code;
5143
+ ...bundleLog.options
5144
+ });
5145
+ bundleLog.assertAllResolved();
5146
+ return result.output[0].code;
4972
5147
  }
4973
5148
  });
4974
5149
  return [job.name, code];
@@ -4979,7 +5154,8 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4979
5154
  const WorkflowJobSchema = z.object({
4980
5155
  name: z.string().describe("Job name (must be unique across the project)"),
4981
5156
  trigger: functionSchema.describe("Trigger function that initiates the job"),
4982
- body: functionSchema.describe("Job implementation function")
5157
+ body: functionSchema.describe("Job implementation function"),
5158
+ publishEvents: z.boolean().optional().describe("Enable publishing job execution events for this job")
4983
5159
  });
4984
5160
  const durationUnits = [
4985
5161
  "ms",
@@ -5025,7 +5201,8 @@ const WorkflowSchema = z.object({
5025
5201
  name: z.string().describe("Workflow name"),
5026
5202
  mainJob: WorkflowJobSchema.describe("Main job that starts the workflow"),
5027
5203
  retryPolicy: RetryPolicySchema.optional().describe("Retry policy for the workflow"),
5028
- concurrencyPolicy: ConcurrencyPolicySchema.optional().describe("Concurrency policy for the workflow")
5204
+ concurrencyPolicy: ConcurrencyPolicySchema.optional().describe("Concurrency policy for the workflow"),
5205
+ publishEvents: z.boolean().optional().describe("Enable publishing workflow execution events for this workflow")
5029
5206
  });
5030
5207
 
5031
5208
  //#endregion
@@ -5147,7 +5324,8 @@ async function loadFileContent(filePath) {
5147
5324
  if (jobResult.success) jobs.push({
5148
5325
  name: jobResult.data.name,
5149
5326
  exportName,
5150
- sourceFile: filePath
5327
+ sourceFile: filePath,
5328
+ ...jobResult.data.publishEvents !== void 0 ? { publishEvents: jobResult.data.publishEvents } : {}
5151
5329
  });
5152
5330
  else if (isSdkBranded(exportValue, ["workflow", "workflow-job"])) throw jobResult.error;
5153
5331
  }
@@ -5756,5 +5934,5 @@ async function loadApplication(params) {
5756
5934
  }
5757
5935
 
5758
5936
  //#endregion
5759
- export { defaultPlatformBaseUrl as A, getPlatformBaseUrl as B, getPluginGenerationDependencies as C, hashContent as D, getDistDir as E, fetchPlatformMachineUserToken as F, rememberPlatformConfigForToken as G, initOperatorClient as H, fetchUserInfo as I, createApplyLimiter as J, resolveStaticWebsiteUrls as K, getConsoleBaseUrl as L, fetchAllTolerant as M, fetchMachineUserToken as N, hashFile as O, fetchPaged as P, getOAuth2ClientId as R, resolveBundleLogLevel as S, createBundleCache as T, isDefaultPlatform as U, initOAuth2Client as V, normalizeBaseUrl as W, LOG_LEVELS as Y, stringifyFunction as _, resolveInlineSourcemap as a, composeFunctionTreeshakeOptions as b, ResolverSchema as c, buildExecutorArgsExpr as d, buildResolverOperationHookExpr as f, TailorDBTypeSchema as g, assertUniqueTailorDBTypeNamesWithExternal as h, resolverBundleKey as i, fetchAll as j, closeConnectionPool as k, HTTP_METHODS as l, assertUniqueLocalTailorDBTypeNames as m, generatePluginFilesIfNeeded as n, WorkflowJobFunctionExecutionPolicySchema as o, buildResolverPermissionAndInputCheckExpr as p, byName as q, loadApplication as r, WorkflowJobSchema as s, defineApplication as t, INVOKER_EXPR as u, resolveTSConfigWithFallback as v, hasGenerationHooks as w, createLogLevelTreeshakeOptions as x, platformBundleDefinePlugin as y, getOrNull as z };
5760
- //# sourceMappingURL=application-Cp0FxIm2.mjs.map
5937
+ export { LOG_LEVELS as $, hashContent as A, getConsoleBaseUrl as B, createLogLevelTreeshakeOptions as C, hasGenerationHooks as D, getPluginGenerationDependencies as E, fetchAllTolerant as F, initOperatorClient as G, getOrNull as H, fetchMachineUserToken as I, normalizeBaseUrl as J, isDefaultPlatform as K, fetchPaged as L, closeConnectionPool as M, defaultPlatformBaseUrl as N, createBundleCache as O, fetchAll as P, createApplyLimiter as Q, fetchPlatformMachineUserToken as R, composeFunctionTreeshakeOptions as S, createBundleLog as T, getPlatformBaseUrl as U, getOAuth2ClientId as V, initOAuth2Client as W, resolveStaticWebsiteUrls as X, rememberPlatformConfigForToken as Y, byName as Z, stringifyFunction as _, resolveInlineSourcemap as a, resolveTSConfigWithFallback as b, ResolverSchema as c, buildExecutorArgsExpr as d, buildResolverOperationHookExpr as f, TailorDBTypeSchema as g, assertUniqueTailorDBTypeNamesWithExternal as h, resolverBundleKey as i, hashFile as j, getDistDir as k, HTTP_METHODS as l, assertUniqueLocalTailorDBTypeNames as m, generatePluginFilesIfNeeded as n, WorkflowJobFunctionExecutionPolicySchema as o, buildResolverPermissionAndInputCheckExpr as p, isNotFoundError as q, loadApplication as r, WorkflowJobSchema as s, defineApplication as t, INVOKER_EXPR as u, createGeneratedEntryResolverPlugin as v, resolveBundleLogLevel as w, platformBundleDefinePlugin as x, createTsconfigPathsPlugin as y, fetchUserInfo as z };
5938
+ //# sourceMappingURL=application-m5tYtz0-.mjs.map