@tailor-platform/sdk 2.0.0-next.6 → 2.0.0-next.8

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 (62) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/{application-BJXRpQj5.mjs → application-GzW98_Xr.mjs} +199 -172
  3. package/dist/application-GzW98_Xr.mjs.map +1 -0
  4. package/dist/application-OM0taSPn.mjs +3 -0
  5. package/dist/cli/index.mjs +12 -9
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.mjs +2 -2
  8. package/dist/completion/zsh-worker.zsh +1 -1
  9. package/dist/configure/config/types.d.mts +5 -1
  10. package/dist/configure/index.mjs +16 -16
  11. package/dist/configure/index.mjs.map +1 -1
  12. package/dist/configure/services/auth/types.d.mts +18 -23
  13. package/dist/configure/services/executor/operation.d.mts +1 -1
  14. package/dist/configure/services/idp/permission.d.mts +4 -4
  15. package/dist/configure/services/tailordb/permission.d.mts +4 -4
  16. package/dist/configure/services/workflow/job.d.mts +10 -10
  17. package/dist/configure/services/workflow/workflow.d.mts +6 -4
  18. package/dist/{globals-D-YbJKW-.mjs → globals-CBZ0egXT.mjs} +3 -6
  19. package/dist/globals-CBZ0egXT.mjs.map +1 -0
  20. package/dist/{register-ts-hook-DL31O2W9.mjs → register-ts-hook-DvEs6YsL.mjs} +35 -78
  21. package/dist/register-ts-hook-DvEs6YsL.mjs.map +1 -0
  22. package/dist/{registry-CC3CbQiF.mjs → registry-i7EdJ-D5.mjs} +10 -10
  23. package/dist/registry-i7EdJ-D5.mjs.map +1 -0
  24. package/dist/runtime/globals.d.mts +1 -4
  25. package/dist/runtime/index.mjs +1 -1
  26. package/dist/runtime/workflow.d.mts +1 -76
  27. package/dist/runtime/workflow.mjs +1 -1
  28. package/dist/service-BJAQ70e5.mjs +3 -0
  29. package/dist/{service-CnHz9rwz.mjs → service-Dmxa2I4i.mjs} +31 -17
  30. package/dist/service-Dmxa2I4i.mjs.map +1 -0
  31. package/dist/utils/test/index.mjs +11 -11
  32. package/dist/utils/test/index.mjs.map +1 -1
  33. package/dist/utils/test/mock.d.mts +6 -6
  34. package/dist/vitest/environment.mjs +1 -1
  35. package/dist/vitest/index.mjs +67 -99
  36. package/dist/vitest/index.mjs.map +1 -1
  37. package/dist/vitest/mocks/workflow.d.mts +21 -41
  38. package/dist/vitest/setup.mjs +1 -1
  39. package/dist/vitest/workflow-local.d.mts +2 -2
  40. package/dist/workflow-CsBvRE3g.mjs +34 -0
  41. package/dist/workflow-CsBvRE3g.mjs.map +1 -0
  42. package/docs/cli/application.md +2 -0
  43. package/docs/cli/function.md +2 -2
  44. package/docs/cli/tailordb.md +2 -2
  45. package/docs/cli-reference.md +1 -1
  46. package/docs/configuration.md +2 -0
  47. package/docs/github-actions.md +2 -2
  48. package/docs/migration/v2.md +128 -11
  49. package/docs/runtime.md +1 -1
  50. package/docs/services/auth.md +7 -7
  51. package/docs/services/workflow.md +43 -43
  52. package/docs/testing.md +9 -9
  53. package/package.json +2 -2
  54. package/dist/application-BJXRpQj5.mjs.map +0 -1
  55. package/dist/application-BV-AXawv.mjs +0 -3
  56. package/dist/globals-D-YbJKW-.mjs.map +0 -1
  57. package/dist/register-ts-hook-DL31O2W9.mjs.map +0 -1
  58. package/dist/registry-CC3CbQiF.mjs.map +0 -1
  59. package/dist/service-CnHz9rwz.mjs.map +0 -1
  60. package/dist/service-nU6ITOHL.mjs +0 -3
  61. package/dist/workflow-9kHGKxF2.mjs +0 -64
  62. package/dist/workflow-9kHGKxF2.mjs.map +0 -1
@@ -1,7 +1,7 @@
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-BwS4ppwO.mjs";
4
- import { a as AuthConfigSchema, c as stripTailorDBTypeBuilderHelpers, d as applyRelationMetadataToFieldConfig, f as buildRelationInfo, g as functionSchema, h as loadFilesWithIgnores, l as TailorDBServiceConfigSchema, m as validateRelationConfig, n as loadExecutor, o as AuthInvokerSchema, p as processRelationMetadata, s as TailorFieldSchema, t as createExecutorService, u as TailorDBTypeSchema } from "./service-CnHz9rwz.mjs";
4
+ import { a as AuthConfigSchema, c as stripTailorDBTypeBuilderHelpers, d as applyRelationMetadataToFieldConfig, f as buildRelationInfo, g as functionSchema, h as loadFilesWithIgnores, l as TailorDBServiceConfigSchema, m as validateRelationConfig, n as loadExecutor, o as AuthInvokerSchema, p as processRelationMetadata, s as TailorFieldSchema, t as createExecutorService, u as TailorDBTypeSchema } from "./service-Dmxa2I4i.mjs";
5
5
  import { t as multiline } from "./multiline-sfHpTZZK.mjs";
6
6
  import { t as userAgent } from "./user-agent-Bgsszb5I.mjs";
7
7
  import { t as isPluginGeneratedType } from "./type-source-DH_LH20p.mjs";
@@ -753,15 +753,16 @@ function combineHash(fileHash, contextHash) {
753
753
  /**
754
754
  * Compute a context hash for cache invalidation across bundlers.
755
755
  *
756
- * Combines the source file path, serialized trigger context, tsconfig hash,
757
- * sourcemap mode, bundle log level, and an optional prefix (e.g., serialized
758
- * env variables) into a single SHA-256 hash.
756
+ * Combines the source file path, a caller-supplied extra context string
757
+ * (e.g. serialized workflow start-call bindings, or an HTTP adapter's method
758
+ * list), tsconfig hash, sourcemap mode, bundle log level, and an optional
759
+ * prefix (e.g., serialized env variables) into a single SHA-256 hash.
759
760
  * @param params - Context hash computation parameters
760
761
  * @returns SHA-256 hex digest of the combined context
761
762
  */
762
763
  function computeBundlerContextHash(params) {
763
- const { sourceFile, serializedTriggerContext, tsconfig, inlineSourcemap, bundleLogLevel, prefix } = params;
764
- return hashContent((prefix ?? "") + path.resolve(sourceFile) + serializedTriggerContext + (tsconfig ? hashFile(tsconfig) : "") + String(inlineSourcemap ?? false) + (bundleLogLevel ?? ""));
764
+ const { sourceFile, extraContext, tsconfig, inlineSourcemap, bundleLogLevel, prefix } = params;
765
+ return hashContent((prefix ?? "") + path.resolve(sourceFile) + extraContext + (tsconfig ? hashFile(tsconfig) : "") + String(inlineSourcemap ?? false) + (bundleLogLevel ?? ""));
765
766
  }
766
767
  /**
767
768
  * Run a build with optional cache restore/save around it.
@@ -1442,18 +1443,18 @@ function argumentSourceText(arg, sourceText) {
1442
1443
  if (arg && typeof arg === "object" && "start" in arg && "end" in arg) return sourceText.slice(arg.start, arg.end);
1443
1444
  }
1444
1445
  /**
1445
- * Get metadata for a static `identifier.trigger(...)` call.
1446
+ * Get metadata for a static `identifier.start(...)` call.
1446
1447
  * @param node - AST node to inspect
1447
1448
  * @param sourceText - Source code text
1448
- * @returns Trigger call metadata, or null when the node is not a trigger call
1449
+ * @returns Start call metadata, or null when the node is not a start call
1449
1450
  */
1450
- function getTriggerCallInfo(node, sourceText) {
1451
+ function getStartCallInfo(node, sourceText) {
1451
1452
  if (!node || typeof node !== "object" || node.type !== "CallExpression") return null;
1452
1453
  const callExpr = node;
1453
1454
  const callee = callExpr.callee;
1454
1455
  if (callee.type !== "MemberExpression") return null;
1455
1456
  const memberExpr = callee;
1456
- if (memberExpr.computed || memberExpr.property.name !== "trigger" || memberExpr.object.type !== "Identifier") return null;
1457
+ if (memberExpr.computed || memberExpr.property.name !== "start" || memberExpr.object.type !== "Identifier") return null;
1457
1458
  return {
1458
1459
  identifierName: memberExpr.object.name,
1459
1460
  callRange: {
@@ -1736,9 +1737,9 @@ function findAllWorkflows(program, _sourceText) {
1736
1737
  }
1737
1738
 
1738
1739
  //#endregion
1739
- //#region src/cli/shared/trigger-context.ts
1740
+ //#region src/cli/shared/start-context.ts
1740
1741
  /**
1741
- * Normalize a source module path for trigger binding lookup.
1742
+ * Normalize a source module path for start-call binding lookup.
1742
1743
  * @param filePath - Source file path or extensionless relative import path
1743
1744
  * @returns Absolute path without a JavaScript or TypeScript extension
1744
1745
  */
@@ -1793,18 +1794,19 @@ function createModuleBindings(program, source) {
1793
1794
  };
1794
1795
  }
1795
1796
  /**
1796
- * Build trigger context from configured workflow source files.
1797
+ * Build start-call context from configured workflow source files.
1797
1798
  * @param workflowConfig - Workflow file loading configuration
1798
1799
  * @param authNamespace - Auth service namespace (optional, used for string-literal invoker expansion)
1800
+ * @param baseDir - Directory the workflow config's file patterns are resolved against (defaults to process.cwd())
1799
1801
  * @returns Module-local workflow and job binding metadata
1800
1802
  */
1801
- async function buildTriggerContext(workflowConfig, authNamespace) {
1803
+ async function buildStartContext(workflowConfig, authNamespace, baseDir = process.cwd()) {
1802
1804
  const modules = /* @__PURE__ */ new Map();
1803
1805
  if (!workflowConfig) return {
1804
1806
  modules,
1805
1807
  authNamespace
1806
1808
  };
1807
- for (const file of loadFilesWithIgnores(workflowConfig)) try {
1809
+ for (const file of loadFilesWithIgnores(workflowConfig, baseDir)) try {
1808
1810
  const source = await fs.promises.readFile(file, "utf-8");
1809
1811
  const { program } = parseSync("input.ts", source);
1810
1812
  modules.set(normalizeFilePath(file), createModuleBindings(program, source));
@@ -1825,11 +1827,11 @@ function sortedTargets(bindings) {
1825
1827
  ]);
1826
1828
  }
1827
1829
  /**
1828
- * Serialize trigger context to a deterministic cache input.
1829
- * @param context - Trigger context to serialize
1830
+ * Serialize start-call context to a deterministic cache input.
1831
+ * @param context - Start-call context to serialize
1830
1832
  * @returns Deterministic string, or an empty string when context is absent
1831
1833
  */
1832
- function serializeTriggerContext(context) {
1834
+ function serializeStartContext(context) {
1833
1835
  if (!context) return "";
1834
1836
  const modules = [...context.modules].toSorted(([a], [b]) => a.localeCompare(b)).map(([file, bindings]) => [
1835
1837
  file,
@@ -1840,12 +1842,23 @@ function serializeTriggerContext(context) {
1840
1842
  }
1841
1843
 
1842
1844
  //#endregion
1843
- //#region src/cli/services/workflow/trigger-transformer.ts
1844
- const NORMALIZER_IDENTIFIER = "__tailor_normalizeTriggerOptions";
1845
+ //#region src/cli/services/workflow/start-transformer.ts
1846
+ const START_CALL_RE = /\.start(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*\n)*\(/;
1847
+ /**
1848
+ * Fast pre-check for whether `code` contains a `.start(` call, tolerating
1849
+ * whitespace, newlines, and comments between `.start` and `(` that a plain
1850
+ * substring check would miss.
1851
+ * @param code - Source text to scan
1852
+ * @returns Whether `code` contains a `.start(` call
1853
+ */
1854
+ function hasStartCall(code) {
1855
+ return START_CALL_RE.test(code);
1856
+ }
1857
+ const NORMALIZER_IDENTIFIER = "__tailor_normalizeStartOptions";
1845
1858
  /**
1846
1859
  * Build the source text of the injected normalizer helper.
1847
1860
  *
1848
- * Renames an `invoker` in the trigger options to the `authInvoker` form the
1861
+ * Renames an `invoker` in the start options to the `authInvoker` form the
1849
1862
  * platform RPC expects: a plain string (machine user name) becomes
1850
1863
  * `{ namespace, machineUserName }`, while an object form passes through
1851
1864
  * as-is. Any other options value is unchanged. The auth namespace is baked
@@ -1973,42 +1986,42 @@ function collectLocalTargets(program, context, currentFilePath) {
1973
1986
  }
1974
1987
  return targets;
1975
1988
  }
1976
- function detectTriggerCallsWithTargets(program, sourceText, targets) {
1989
+ function detectStartCallsWithTargets(program, sourceText, targets) {
1977
1990
  const calls = [];
1978
1991
  walkBindingAware(program, new Set(targets.keys()), (node, shadowedNames) => {
1979
- const triggerCall = getTriggerCallInfo(node, sourceText);
1980
- if (!triggerCall || shadowedNames.has(triggerCall.identifierName)) return;
1981
- const target = targets.get(triggerCall.identifierName);
1992
+ const startCall = getStartCallInfo(node, sourceText);
1993
+ if (!startCall || shadowedNames.has(startCall.identifierName)) return;
1994
+ const target = targets.get(startCall.identifierName);
1982
1995
  if (target) calls.push({
1983
- ...triggerCall,
1996
+ ...startCall,
1984
1997
  kind: target.kind,
1985
1998
  targetName: target.name
1986
1999
  });
1987
2000
  });
1988
2001
  return calls;
1989
2002
  }
1990
- function detectResolvedTriggerCalls(program, sourceText, context, currentFilePath) {
1991
- return detectTriggerCallsWithTargets(program, sourceText, collectLocalTargets(program, context, currentFilePath));
2003
+ function detectResolvedStartCalls(program, sourceText, context, currentFilePath) {
2004
+ return detectStartCallsWithTargets(program, sourceText, collectLocalTargets(program, context, currentFilePath));
1992
2005
  }
1993
- function transformFunctionTriggers(source, triggerContext, currentFilePath) {
2006
+ function transformStartCalls(source, startContext, currentFilePath) {
1994
2007
  const { program } = parseSync("input.ts", source);
1995
- const localTargets = collectLocalTargets(program, triggerContext, currentFilePath);
1996
- const { authNamespace } = triggerContext;
1997
- const allTriggerCalls = detectTriggerCallsWithTargets(program, source, localTargets);
1998
- const nestedTriggerCalls = [];
1999
- const triggerCalls = allTriggerCalls.filter((call) => {
2000
- const parent = allTriggerCalls.find((other) => other !== call && other.callRange.start <= call.callRange.start && call.callRange.end <= other.callRange.end);
2008
+ const localTargets = collectLocalTargets(program, startContext, currentFilePath);
2009
+ const { authNamespace } = startContext;
2010
+ const allStartCalls = detectStartCallsWithTargets(program, source, localTargets);
2011
+ const nestedStartCalls = [];
2012
+ const startCalls = allStartCalls.filter((call) => {
2013
+ const parent = allStartCalls.find((other) => other !== call && other.callRange.start <= call.callRange.start && call.callRange.end <= other.callRange.end);
2001
2014
  if (!parent) return true;
2002
- nestedTriggerCalls.push({
2015
+ nestedStartCalls.push({
2003
2016
  call,
2004
2017
  parent
2005
2018
  });
2006
2019
  return false;
2007
2020
  });
2008
- for (const { call, parent } of nestedTriggerCalls) logger.warn(`Nested trigger call "${call.identifierName}.trigger(...)" inside "${parent.identifierName}.trigger(...)" cannot be converted. Move it to a separate statement and pass the result instead.`);
2021
+ for (const { call, parent } of nestedStartCalls) logger.warn(`Nested start call "${call.identifierName}.start(...)" inside "${parent.identifierName}.start(...)" cannot be converted. Move it to a separate statement and pass the result instead.`);
2009
2022
  const replacements = [];
2010
2023
  let needsNormalizerHelper = false;
2011
- for (const call of triggerCalls) {
2024
+ for (const call of startCalls) {
2012
2025
  let transformedCall;
2013
2026
  if (call.kind === "workflow") {
2014
2027
  let optionsPart = "";
@@ -2016,10 +2029,10 @@ function transformFunctionTriggers(source, triggerContext, currentFilePath) {
2016
2029
  optionsPart = `, ${NORMALIZER_IDENTIFIER}(${call.optionsText})`;
2017
2030
  needsNormalizerHelper = true;
2018
2031
  } else optionsPart = `, ${call.optionsText}`;
2019
- transformedCall = `tailor.workflow.triggerWorkflow(${JSON.stringify(call.targetName)}, ${call.argsText || "undefined"}${optionsPart})`;
2032
+ transformedCall = `tailor.workflow.startWorkflow(${JSON.stringify(call.targetName)}, ${call.argsText || "undefined"}${optionsPart})`;
2020
2033
  } else {
2021
2034
  const optionsPart = call.optionsText !== void 0 ? `, ${call.optionsText}` : "";
2022
- transformedCall = `tailor.workflow.triggerJobFunction(${JSON.stringify(call.targetName)}, ${call.argsText || "undefined"}${optionsPart})`;
2035
+ transformedCall = `tailor.workflow.startJobFunction(${JSON.stringify(call.targetName)}, ${call.argsText || "undefined"}${optionsPart})`;
2023
2036
  }
2024
2037
  replacements.push({
2025
2038
  start: call.callRange.start,
@@ -2030,15 +2043,15 @@ function transformFunctionTriggers(source, triggerContext, currentFilePath) {
2030
2043
  const transformed = applyReplacements(source, replacements);
2031
2044
  return needsNormalizerHelper && authNamespace ? buildNormalizerHelperSource(authNamespace) + transformed : transformed;
2032
2045
  }
2033
- function createTriggerTransformPlugin(triggerContext) {
2034
- if (!triggerContext) return void 0;
2046
+ function createStartTransformPlugin(startContext) {
2047
+ if (!startContext) return void 0;
2035
2048
  return {
2036
- name: "trigger-transform",
2049
+ name: "start-transform",
2037
2050
  transform: {
2038
2051
  filter: { id: { include: [/\.(ts|mts|cts|js|mjs|cjs)$/] } },
2039
2052
  handler(code, id) {
2040
- if (!code.includes(".trigger(")) return null;
2041
- return { code: transformFunctionTriggers(code, triggerContext, id) };
2053
+ if (!hasStartCall(code)) return null;
2054
+ return { code: transformStartCalls(code, startContext, id) };
2042
2055
  }
2043
2056
  }
2044
2057
  };
@@ -2135,6 +2148,33 @@ const platformBundleDefinePlugin = {
2135
2148
  }
2136
2149
  };
2137
2150
 
2151
+ //#endregion
2152
+ //#region src/cli/shared/resolve-tsconfig.ts
2153
+ const warnedBaseDirs = /* @__PURE__ */ new Set();
2154
+ /**
2155
+ * Resolve the nearest tsconfig.json for baseDir, falling back to the tsconfig
2156
+ * resolved from the invocation cwd when baseDir's own ancestry has none.
2157
+ * @param baseDir - Directory to resolve the tsconfig against
2158
+ * @returns Absolute path to the resolved tsconfig.json, or undefined if none was found
2159
+ */
2160
+ async function resolveTSConfigWithFallback(baseDir) {
2161
+ const tsconfig = await tryResolve(baseDir);
2162
+ if (tsconfig || baseDir === process.cwd()) return tsconfig;
2163
+ const fallback = await tryResolve(process.cwd());
2164
+ if (fallback && !warnedBaseDirs.has(baseDir)) {
2165
+ warnedBaseDirs.add(baseDir);
2166
+ logger.warn(`No tsconfig found from "${baseDir}"; falling back to the tsconfig resolved from process.cwd(). Move (or extend) a tsconfig into this config's own directory before v2, when this fallback will be removed.`);
2167
+ }
2168
+ return fallback;
2169
+ }
2170
+ async function tryResolve(dir) {
2171
+ try {
2172
+ return await resolveTSConfig(dir);
2173
+ } catch {
2174
+ return;
2175
+ }
2176
+ }
2177
+
2138
2178
  //#endregion
2139
2179
  //#region src/cli/shared/virtual-entry.ts
2140
2180
  /**
@@ -2173,19 +2213,12 @@ function createVirtualEntry(name, code, sourceType = "js") {
2173
2213
  * @returns Map of function name to bundled code
2174
2214
  */
2175
2215
  async function bundleAuthHooks(options) {
2176
- const { configPath, authName, handlerAccessPath, env = {}, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG" } = options;
2216
+ const { configPath, authName, handlerAccessPath, env = {}, startContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG", baseDir } = options;
2177
2217
  logger.newline();
2178
2218
  logger.log(`Bundling auth hook for ${styles.info(`"${authName}"`)}`);
2179
- let tsconfig;
2180
- try {
2181
- tsconfig = await resolveTSConfig();
2182
- } catch {
2183
- tsconfig = void 0;
2184
- }
2185
- const functionName = `auth-hook--${authName}--before-login`;
2186
2219
  const absoluteConfigPath = path.resolve(configPath);
2187
- const serializedTriggerContext = serializeTriggerContext(triggerContext);
2188
- const sortedEnvPrefix = JSON.stringify(Object.fromEntries(Object.entries(env).toSorted(([a], [b]) => a.localeCompare(b))));
2220
+ const tsconfig = await resolveTSConfigWithFallback(baseDir);
2221
+ const functionName = `auth-hook--${authName}--before-login`;
2189
2222
  const code = await withCache({
2190
2223
  cache,
2191
2224
  kind: "auth-hook",
@@ -2193,11 +2226,11 @@ async function bundleAuthHooks(options) {
2193
2226
  sourceFile: absoluteConfigPath,
2194
2227
  contextHash: computeBundlerContextHash({
2195
2228
  sourceFile: absoluteConfigPath,
2196
- serializedTriggerContext,
2229
+ extraContext: serializeStartContext(startContext),
2197
2230
  tsconfig,
2198
2231
  inlineSourcemap,
2199
2232
  bundleLogLevel,
2200
- prefix: sortedEnvPrefix
2233
+ prefix: JSON.stringify(Object.fromEntries(Object.entries(env).toSorted(([a], [b]) => a.localeCompare(b))))
2201
2234
  }),
2202
2235
  async build(cachePlugins) {
2203
2236
  const entryContent = multiline`
@@ -2209,9 +2242,9 @@ async function bundleAuthHooks(options) {
2209
2242
  }
2210
2243
  `;
2211
2244
  const entry = createVirtualEntry(`auth-hook:${functionName}`, entryContent);
2212
- const triggerPlugin = createTriggerTransformPlugin(triggerContext);
2245
+ const startPlugin = createStartTransformPlugin(startContext);
2213
2246
  const plugins = [entry.plugin];
2214
- if (triggerPlugin) plugins.push(triggerPlugin);
2247
+ if (startPlugin) plugins.push(startPlugin);
2215
2248
  plugins.push(platformBundleDefinePlugin, ...cachePlugins);
2216
2249
  return (await rolldown.build({
2217
2250
  input: entry.input,
@@ -3331,7 +3364,7 @@ function formatTailorDBTypeNameSource(source) {
3331
3364
  * @returns A new TailorDBService instance
3332
3365
  */
3333
3366
  function createTailorDBService(params) {
3334
- const { namespace, config, pluginManager } = params;
3367
+ const { namespace, config, pluginManager, baseDir } = params;
3335
3368
  const createRawTypesByName = () => Object.create(null);
3336
3369
  const rawTypes = Object.create(null);
3337
3370
  let types = {};
@@ -3451,13 +3484,8 @@ function createTailorDBService(params) {
3451
3484
  loadTypes: async () => {
3452
3485
  if (!loadPromise) loadPromise = (async () => {
3453
3486
  if (config.files.length === 0) return;
3454
- const typeFiles = [...new Set(loadFilesWithIgnores(config))];
3455
- let tsconfig;
3456
- try {
3457
- tsconfig = await resolveTSConfig();
3458
- } catch {
3459
- tsconfig = void 0;
3460
- }
3487
+ const typeFiles = [...new Set(loadFilesWithIgnores(config, baseDir))];
3488
+ const tsconfig = await resolveTSConfigWithFallback(baseDir);
3461
3489
  logger.newline();
3462
3490
  logger.log(`Found ${styles.highlight(typeFiles.length.toString())} type files for TailorDB service ${styles.highlight(`"${namespace}"`)}`);
3463
3491
  if (pluginManager) for (const typeFile of typeFiles) await loadTypeFile(typeFile, tsconfig);
@@ -3728,8 +3756,8 @@ function buildResolverOperationHookExpr(env) {
3728
3756
  */
3729
3757
  async function bundleExecutors(options) {
3730
3758
  const bundledCode = /* @__PURE__ */ new Map();
3731
- const { config, triggerContext, additionalFiles = [], cache, inlineSourcemap, bundleLogLevel = "DEBUG" } = options;
3732
- const files = [...loadFilesWithIgnores(config), ...additionalFiles];
3759
+ const { config, startContext, additionalFiles = [], cache, inlineSourcemap, bundleLogLevel = "DEBUG", baseDir } = options;
3760
+ const files = [...loadFilesWithIgnores(config, baseDir), ...additionalFiles];
3733
3761
  if (files.length === 0) {
3734
3762
  logger.warn(`No executor files found for patterns: ${config.files.join(", ")}`);
3735
3763
  return bundledCode;
@@ -3756,22 +3784,17 @@ async function bundleExecutors(options) {
3756
3784
  logger.debug(" No function executors to bundle");
3757
3785
  return bundledCode;
3758
3786
  }
3759
- let tsconfig;
3760
- try {
3761
- tsconfig = await resolveTSConfig();
3762
- } catch {
3763
- tsconfig = void 0;
3764
- }
3765
- const results = await withBundleConcurrency(executors, (executor) => bundleSingleExecutor(executor, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel));
3787
+ const tsconfig = await resolveTSConfigWithFallback(baseDir);
3788
+ const results = await withBundleConcurrency(executors, (executor) => bundleSingleExecutor(executor, tsconfig, startContext, cache, inlineSourcemap, bundleLogLevel));
3766
3789
  for (const [name, code] of results) bundledCode.set(name, code);
3767
3790
  logger.log(`${styles.success("Bundled")} ${styles.info("\"executor\"")}`);
3768
3791
  return bundledCode;
3769
3792
  }
3770
- async function bundleSingleExecutor(executor, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
3771
- const serializedTriggerContext = serializeTriggerContext(triggerContext);
3793
+ async function bundleSingleExecutor(executor, tsconfig, startContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
3794
+ const serializedStartContext = serializeStartContext(startContext);
3772
3795
  const contextHash = computeBundlerContextHash({
3773
3796
  sourceFile: executor.sourceFile,
3774
- serializedTriggerContext,
3797
+ extraContext: serializedStartContext,
3775
3798
  tsconfig,
3776
3799
  inlineSourcemap,
3777
3800
  bundleLogLevel
@@ -3794,9 +3817,9 @@ async function bundleSingleExecutor(executor, tsconfig, triggerContext, cache, i
3794
3817
  export { __executor_function as main };
3795
3818
  `;
3796
3819
  const entry = createVirtualEntry(`executor:${executor.name}`, entryContent);
3797
- const triggerPlugin = createTriggerTransformPlugin(triggerContext);
3820
+ const startPlugin = createStartTransformPlugin(startContext);
3798
3821
  const plugins = [entry.plugin];
3799
- if (triggerPlugin) plugins.push(triggerPlugin);
3822
+ if (startPlugin) plugins.push(startPlugin);
3800
3823
  plugins.push(platformBundleDefinePlugin, ...cachePlugins);
3801
3824
  return (await rolldown.build({
3802
3825
  input: entry.input,
@@ -3871,23 +3894,19 @@ const GRAPHQL_WEB_MODULE = createRequire(import.meta.url).resolve("@0no-co/graph
3871
3894
  * IIFE defining a global `transform(input)` entry point. `input` gets a
3872
3895
  * generated dispatcher that routes by `req.method`; `output` is used as is.
3873
3896
  * @param adapters - Detected adapters to bundle
3897
+ * @param baseDir - Directory the owning config's tsconfig is resolved against
3874
3898
  * @param cache - Optional bundle cache for skipping unchanged builds
3875
3899
  * @param bundleLogLevel - Controls which console calls are kept in bundled code
3876
3900
  * @returns Bundled scripts keyed by adapter name
3877
3901
  */
3878
- async function bundleHttpAdapters(adapters, cache, bundleLogLevel = "DEBUG") {
3902
+ async function bundleHttpAdapters(adapters, baseDir, cache, bundleLogLevel = "DEBUG") {
3879
3903
  if (adapters.length === 0) return {
3880
3904
  bundledInputs: /* @__PURE__ */ new Map(),
3881
3905
  bundledOutputs: /* @__PURE__ */ new Map()
3882
3906
  };
3883
3907
  logger.newline();
3884
3908
  logger.log(`Bundling ${styles.highlight(adapters.length.toString())} files for ${styles.info("\"http-adapter\"")}`);
3885
- let tsconfig;
3886
- try {
3887
- tsconfig = await resolveTSConfig();
3888
- } catch {
3889
- tsconfig = void 0;
3890
- }
3909
+ const tsconfig = await resolveTSConfigWithFallback(baseDir);
3891
3910
  const results = await withBundleConcurrency(adapters.flatMap((adapter) => {
3892
3911
  return (adapter.hasOutput ? ["input", "output"] : ["input"]).map((kind) => ({
3893
3912
  adapter,
@@ -3907,7 +3926,7 @@ async function bundleHttpAdapters(adapters, cache, bundleLogLevel = "DEBUG") {
3907
3926
  async function bundleAdapterScript(adapter, kind, tsconfig, cache, bundleLogLevel = "DEBUG") {
3908
3927
  const contextHash = computeBundlerContextHash({
3909
3928
  sourceFile: adapter.sourceFile,
3910
- serializedTriggerContext: kind === "input" ? adapter.methods.join(",") : "",
3929
+ extraContext: kind === "input" ? adapter.methods.join(",") : "",
3911
3930
  tsconfig,
3912
3931
  inlineSourcemap: false,
3913
3932
  bundleLogLevel,
@@ -4036,7 +4055,7 @@ function rejectAsyncInBundle(code, adapterName, kind) {
4036
4055
  //#endregion
4037
4056
  //#region src/cli/services/http-adapter/service.ts
4038
4057
  function createHttpAdapterService(params) {
4039
- const { config } = params;
4058
+ const { config, baseDir } = params;
4040
4059
  let adapters = [];
4041
4060
  let fileCount = 0;
4042
4061
  let loaded = false;
@@ -4050,7 +4069,7 @@ function createHttpAdapterService(params) {
4050
4069
  },
4051
4070
  loadAdapters: async () => {
4052
4071
  if (loaded) return;
4053
- const result = await loadAdapterFiles(config);
4072
+ const result = await loadAdapterFiles(config, baseDir);
4054
4073
  adapters = result.adapters;
4055
4074
  fileCount = result.fileCount;
4056
4075
  loaded = true;
@@ -4066,12 +4085,12 @@ function createHttpAdapterService(params) {
4066
4085
  }
4067
4086
  };
4068
4087
  }
4069
- async function loadAdapterFiles(config) {
4088
+ async function loadAdapterFiles(config, baseDir) {
4070
4089
  if (config.files.length === 0) return {
4071
4090
  adapters: [],
4072
4091
  fileCount: 0
4073
4092
  };
4074
- const files = loadFilesWithIgnores(config);
4093
+ const files = loadFilesWithIgnores(config, baseDir);
4075
4094
  const loadResults = await Promise.all(files.map(loadAdapterFromFile));
4076
4095
  const adapters = [];
4077
4096
  const seenNames = /* @__PURE__ */ new Map();
@@ -4165,15 +4184,16 @@ async function loadResolver(resolverFilePath) {
4165
4184
  * 3. Bundles in a single step with tree-shaking
4166
4185
  * @param namespace - Resolver namespace name
4167
4186
  * @param config - Resolver file loading configuration
4168
- * @param triggerContext - Trigger context for workflow/job transformations
4187
+ * @param baseDir - Directory the config's file patterns are resolved against
4188
+ * @param startContext - Start context for workflow/job transformations
4169
4189
  * @param cache - Optional bundle cache for skipping unchanged builds
4170
4190
  * @param inlineSourcemap - Whether to enable inline sourcemaps
4171
4191
  * @param bundleLogLevel - Controls which console calls are kept in bundled code
4172
4192
  * @returns Map of resolver name to bundled code
4173
4193
  */
4174
- async function bundleResolvers(namespace, config, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
4194
+ async function bundleResolvers(namespace, config, baseDir, startContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
4175
4195
  const bundledCode = /* @__PURE__ */ new Map();
4176
- const files = loadFilesWithIgnores(config);
4196
+ const files = loadFilesWithIgnores(config, baseDir);
4177
4197
  if (files.length === 0) {
4178
4198
  logger.warn(`No resolver files found for patterns: ${config.files.join(", ")}`);
4179
4199
  return bundledCode;
@@ -4192,22 +4212,17 @@ async function bundleResolvers(namespace, config, triggerContext, cache, inlineS
4192
4212
  sourceFile: file
4193
4213
  });
4194
4214
  }
4195
- let tsconfig;
4196
- try {
4197
- tsconfig = await resolveTSConfig();
4198
- } catch {
4199
- tsconfig = void 0;
4200
- }
4201
- const results = await withBundleConcurrency(resolvers, (resolver) => bundleSingleResolver(namespace, resolver, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel));
4215
+ const tsconfig = await resolveTSConfigWithFallback(baseDir);
4216
+ const results = await withBundleConcurrency(resolvers, (resolver) => bundleSingleResolver(namespace, resolver, tsconfig, startContext, cache, inlineSourcemap, bundleLogLevel));
4202
4217
  for (const [name, code] of results) bundledCode.set(name, code);
4203
4218
  logger.log(`${styles.success("Bundled")} ${styles.info(`"${namespace}"`)}`);
4204
4219
  return bundledCode;
4205
4220
  }
4206
- async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
4207
- const serializedTriggerContext = serializeTriggerContext(triggerContext);
4221
+ async function bundleSingleResolver(namespace, resolver, tsconfig, startContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
4222
+ const serializedStartContext = serializeStartContext(startContext);
4208
4223
  const contextHash = computeBundlerContextHash({
4209
4224
  sourceFile: resolver.sourceFile,
4210
- serializedTriggerContext,
4225
+ extraContext: serializedStartContext,
4211
4226
  tsconfig,
4212
4227
  inlineSourcemap,
4213
4228
  bundleLogLevel
@@ -4247,9 +4262,9 @@ async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContex
4247
4262
  export { $tailor_resolver_body as main };
4248
4263
  `;
4249
4264
  const entry = createVirtualEntry(`resolver:${resolver.name}`, entryContent);
4250
- const triggerPlugin = createTriggerTransformPlugin(triggerContext);
4265
+ const startPlugin = createStartTransformPlugin(startContext);
4251
4266
  const plugins = [entry.plugin];
4252
- if (triggerPlugin) plugins.push(triggerPlugin);
4267
+ if (startPlugin) plugins.push(startPlugin);
4253
4268
  plugins.push(platformBundleDefinePlugin, ...cachePlugins);
4254
4269
  return (await rolldown.build({
4255
4270
  input: entry.input,
@@ -4276,9 +4291,10 @@ async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContex
4276
4291
  * Creates a new ResolverService instance.
4277
4292
  * @param namespace - The namespace for this resolver service
4278
4293
  * @param config - The resolver service configuration
4294
+ * @param baseDir - Directory the config's file patterns are resolved against
4279
4295
  * @returns A new ResolverService instance
4280
4296
  */
4281
- function createResolverService(namespace, config) {
4297
+ function createResolverService(namespace, config, baseDir) {
4282
4298
  const resolvers = {};
4283
4299
  const loadResolverForFile = async (resolverFile) => {
4284
4300
  try {
@@ -4307,7 +4323,7 @@ function createResolverService(namespace, config) {
4307
4323
  loadResolvers: async () => {
4308
4324
  if (Object.keys(resolvers).length > 0) return;
4309
4325
  if (config.files.length === 0) return;
4310
- const resolverFiles = loadFilesWithIgnores(config);
4326
+ const resolverFiles = loadFilesWithIgnores(config, baseDir);
4311
4327
  logger.log(`Found ${styles.highlight(resolverFiles.length.toString())} resolver files for service ${styles.highlight(`"${namespace}"`)}`);
4312
4328
  await Promise.all(resolverFiles.map((resolverFile) => loadResolverForFile(resolverFile)));
4313
4329
  assertUniqueResolverNames(resolvers, namespace);
@@ -4451,20 +4467,21 @@ function safeRealpath(p) {
4451
4467
  *
4452
4468
  * This function:
4453
4469
  * 1. Detects which jobs are actually used (mainJobs + their dependencies)
4454
- * 2. Uses a transform plugin to transform trigger calls during bundling
4470
+ * 2. Uses a transform plugin to transform start calls during bundling
4455
4471
  * 3. Creates an in-memory entry module and bundles with tree-shaking
4456
4472
  *
4457
4473
  * Returns metadata about which jobs each workflow uses.
4458
4474
  * @param allJobs - All available job infos
4459
4475
  * @param mainJobNames - Names of main jobs
4460
4476
  * @param env - Environment variables to inject
4461
- * @param triggerContext - Trigger context for transformations
4477
+ * @param startContext - Start context for transformations
4478
+ * @param baseDir - Directory the owning config's tsconfig is resolved against
4462
4479
  * @param cache - Optional bundle cache for skipping unchanged builds
4463
4480
  * @param inlineSourcemap - Whether to enable inline sourcemaps
4464
4481
  * @param bundleLogLevel - Controls which console calls are kept in bundled code
4465
4482
  * @returns Workflow job bundling result
4466
4483
  */
4467
- async function bundleWorkflowJobs(allJobs, mainJobNames, env = {}, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
4484
+ async function bundleWorkflowJobs(allJobs, mainJobNames, env = {}, startContext, baseDir, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
4468
4485
  if (allJobs.length === 0) {
4469
4486
  logger.warn("No workflow jobs to bundle");
4470
4487
  return {
@@ -4473,16 +4490,11 @@ async function bundleWorkflowJobs(allJobs, mainJobNames, env = {}, triggerContex
4473
4490
  bundledCode: /* @__PURE__ */ new Map()
4474
4491
  };
4475
4492
  }
4476
- const { usedJobs, mainJobDeps } = await filterUsedJobs(allJobs, mainJobNames, triggerContext);
4493
+ const { usedJobs, mainJobDeps } = await filterUsedJobs(allJobs, mainJobNames, startContext);
4477
4494
  logger.newline();
4478
4495
  logger.log(`Bundling ${styles.highlight(usedJobs.length.toString())} files for ${styles.info("\"workflow-job\"")}`);
4479
- let tsconfig;
4480
- try {
4481
- tsconfig = await resolveTSConfig();
4482
- } catch {
4483
- tsconfig = void 0;
4484
- }
4485
- const results = await withBundleConcurrency(usedJobs, (job) => bundleSingleJob(job, usedJobs, tsconfig, env, triggerContext, cache, inlineSourcemap, bundleLogLevel));
4496
+ const tsconfig = await resolveTSConfigWithFallback(baseDir);
4497
+ const results = await withBundleConcurrency(usedJobs, (job) => bundleSingleJob(job, usedJobs, tsconfig, env, startContext, cache, inlineSourcemap, bundleLogLevel));
4486
4498
  const bundledCode = /* @__PURE__ */ new Map();
4487
4499
  for (const [name, code] of results) bundledCode.set(name, code);
4488
4500
  logger.log(`${styles.success("Bundled")} ${styles.info("\"workflow-job\"")}`);
@@ -4496,15 +4508,15 @@ async function bundleWorkflowJobs(allJobs, mainJobNames, env = {}, triggerContex
4496
4508
  * Filter jobs to only include those that are actually used.
4497
4509
  * A job is "used" if:
4498
4510
  * - It's a mainJob of a workflow
4499
- * - It's called via .trigger() from another used job (transitively)
4511
+ * - It's called via .start() from another used job (transitively)
4500
4512
  *
4501
4513
  * Also returns a map of mainJob -> all jobs it depends on (for metadata).
4502
4514
  * @param allJobs - All available job infos
4503
4515
  * @param mainJobNames - Names of main jobs
4504
- * @param triggerContext - Module binding metadata for resolving trigger targets
4516
+ * @param startContext - Module binding metadata for resolving start targets
4505
4517
  * @returns Used jobs and main job dependency map
4506
4518
  */
4507
- async function filterUsedJobs(allJobs, mainJobNames, triggerContext) {
4519
+ async function filterUsedJobs(allJobs, mainJobNames, startContext) {
4508
4520
  if (allJobs.length === 0 || mainJobNames.length === 0) return {
4509
4521
  usedJobs: [],
4510
4522
  mainJobDeps: {}
@@ -4521,13 +4533,13 @@ async function filterUsedJobs(allJobs, mainJobNames, triggerContext) {
4521
4533
  const source = await fs.promises.readFile(sourceFile, "utf-8");
4522
4534
  const { program } = parseSync("input.ts", source);
4523
4535
  const detectedJobs = findAllJobs(program, source);
4524
- const triggerCalls = detectResolvedTriggerCalls(program, source, triggerContext, sourceFile);
4536
+ const startCalls = detectResolvedStartCalls(program, source, startContext, sourceFile);
4525
4537
  const jobDependencies = [];
4526
4538
  for (const job of jobs) {
4527
4539
  const detectedJob = detectedJobs.find((d) => d.name === job.name);
4528
4540
  if (!detectedJob) continue;
4529
4541
  const jobDeps = /* @__PURE__ */ new Set();
4530
- for (const call of triggerCalls) if (call.kind === "job" && call.callRange.start >= detectedJob.bodyValueRange.start && call.callRange.end <= detectedJob.bodyValueRange.end) jobDeps.add(call.targetName);
4542
+ for (const call of startCalls) if (call.kind === "job" && call.callRange.start >= detectedJob.bodyValueRange.start && call.callRange.end <= detectedJob.bodyValueRange.end) jobDeps.add(call.targetName);
4531
4543
  if (jobDeps.size > 0) jobDependencies.push({
4532
4544
  jobName: job.name,
4533
4545
  deps: jobDeps
@@ -4558,12 +4570,12 @@ async function filterUsedJobs(allJobs, mainJobNames, triggerContext) {
4558
4570
  mainJobDeps
4559
4571
  };
4560
4572
  }
4561
- async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
4562
- const serializedTriggerContext = serializeTriggerContext(triggerContext);
4573
+ async function bundleSingleJob(job, allJobs, tsconfig, env, startContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
4574
+ const serializedStartContext = serializeStartContext(startContext);
4563
4575
  const sortedEnvPrefix = JSON.stringify(Object.fromEntries(Object.entries(env).toSorted(([a], [b]) => a.localeCompare(b))));
4564
4576
  const contextHash = computeBundlerContextHash({
4565
4577
  sourceFile: job.sourceFile,
4566
- serializedTriggerContext,
4578
+ extraContext: serializedStartContext,
4567
4579
  tsconfig,
4568
4580
  inlineSourcemap,
4569
4581
  bundleLogLevel,
@@ -4596,10 +4608,10 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4596
4608
  transform: {
4597
4609
  filter: { id: { include: [/\.(ts|mts|cts|js|mjs|cjs)$/] } },
4598
4610
  handler(code, id) {
4599
- if (!code.includes("createWorkflowJob") && !code.includes("createWorkflow") && !code.includes(".trigger(")) return null;
4611
+ if (!code.includes("createWorkflowJob") && !code.includes("createWorkflow") && !hasStartCall(code)) return null;
4600
4612
  let transformed = code;
4601
4613
  if (safeRealpath(id) === resolvedSourceFile) transformed = transformWorkflowSource(code, job.name, job.exportName, otherJobExportNames);
4602
- if (transformed.includes(".trigger(")) transformed = transformFunctionTriggers(transformed, triggerContext, id);
4614
+ if (hasStartCall(transformed)) transformed = transformStartCalls(transformed, startContext, id);
4603
4615
  if (transformed === code) return null;
4604
4616
  return { code: transformed };
4605
4617
  }
@@ -4631,7 +4643,7 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4631
4643
  //#region src/parser/service/workflow/schema.ts
4632
4644
  const WorkflowJobSchema = z.strictObject({
4633
4645
  name: z.string().describe("Job name (must be unique across the project)"),
4634
- trigger: functionSchema.describe("Trigger function that initiates the job"),
4646
+ start: functionSchema.describe("Start function that initiates the job"),
4635
4647
  body: functionSchema.describe("Job implementation function")
4636
4648
  });
4637
4649
  const durationUnits = [
@@ -4668,7 +4680,7 @@ const RetryPolicySchema = z.strictObject({
4668
4680
  });
4669
4681
  const ConcurrencyPolicySchema = z.strictObject({ maxConcurrentExecutions: z.number().int().min(1).max(1e3).describe("Maximum number of concurrent executions (1-1000)") });
4670
4682
  const ExecutionPolicyNameSchema = z.string().regex(/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/, "Invalid execution policy name: must match [a-z0-9-] (3-63 chars; must start and end with [a-z0-9])").describe("Workspace-unique execution policy name embedded in the resource TRN");
4671
- const ExecutionPolicyKeySchema = z.string().regex(/^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9*]$/, "Invalid execution policy key: must match [a-z0-9_:.-] (2-64 chars; must start with [a-z0-9] and end with [a-z0-9] or a trailing '*')").describe("Execution policy key passed to startJobFunction's (or its frozen alias triggerJobFunction's) executionPolicyKey option");
4683
+ const ExecutionPolicyKeySchema = z.string().regex(/^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9*]$/, "Invalid execution policy key: must match [a-z0-9_:.-] (2-64 chars; must start with [a-z0-9] and end with [a-z0-9] or a trailing '*')").describe("Execution policy key passed to startJobFunction's executionPolicyKey option");
4672
4684
  const WorkflowJobFunctionExecutionPolicySchema = z.strictObject({
4673
4685
  name: ExecutionPolicyNameSchema,
4674
4686
  key: ExecutionPolicyKeySchema,
@@ -4683,9 +4695,9 @@ const WorkflowSchema = z.strictObject({
4683
4695
 
4684
4696
  //#endregion
4685
4697
  //#region src/cli/services/workflow/service.ts
4686
- function stripRuntimeTrigger(workflow) {
4687
- if (!isSdkBranded(workflow, "workflow") || workflow === null || typeof workflow !== "object" || !("trigger" in workflow)) return workflow;
4688
- const { trigger: _trigger, ...rest } = workflow;
4698
+ function stripRuntimeStart(workflow) {
4699
+ if (!isSdkBranded(workflow, "workflow") || workflow === null || typeof workflow !== "object" || !("start" in workflow)) return workflow;
4700
+ const { start: _start, ...rest } = workflow;
4689
4701
  return rest;
4690
4702
  }
4691
4703
  /**
@@ -4694,7 +4706,7 @@ function stripRuntimeTrigger(workflow) {
4694
4706
  * @returns A new WorkflowService instance
4695
4707
  */
4696
4708
  function createWorkflowService(params) {
4697
- const { config } = params;
4709
+ const { config, baseDir } = params;
4698
4710
  let workflows = {};
4699
4711
  let workflowSources = [];
4700
4712
  let jobs = [];
@@ -4716,7 +4728,7 @@ function createWorkflowService(params) {
4716
4728
  },
4717
4729
  loadWorkflows: async () => {
4718
4730
  if (loaded) return;
4719
- const result = await loadAndCollectJobs(config);
4731
+ const result = await loadAndCollectJobs(config, baseDir);
4720
4732
  workflows = result.workflows;
4721
4733
  workflowSources = result.workflowSources;
4722
4734
  jobs = result.jobs;
@@ -4738,9 +4750,10 @@ function createWorkflowService(params) {
4738
4750
  * Load workflow files and collect all jobs in a single pass.
4739
4751
  * Dependencies are detected at bundle time via AST analysis.
4740
4752
  * @param config - Workflow service configuration
4753
+ * @param baseDir - Directory the config's file patterns are resolved against
4741
4754
  * @returns Loaded workflows and collected jobs
4742
4755
  */
4743
- async function loadAndCollectJobs(config) {
4756
+ async function loadAndCollectJobs(config, baseDir) {
4744
4757
  const workflows = {};
4745
4758
  const workflowSources = [];
4746
4759
  const collectedJobs = [];
@@ -4750,7 +4763,7 @@ async function loadAndCollectJobs(config) {
4750
4763
  jobs: collectedJobs,
4751
4764
  fileCount: 0
4752
4765
  };
4753
- const workflowFiles = loadFilesWithIgnores(config);
4766
+ const workflowFiles = loadFilesWithIgnores(config, baseDir);
4754
4767
  const fileCount = workflowFiles.length;
4755
4768
  const allJobsMap = /* @__PURE__ */ new Map();
4756
4769
  const loadResults = await Promise.all(workflowFiles.map(async (workflowFile) => {
@@ -4795,7 +4808,7 @@ async function loadFileContent(filePath) {
4795
4808
  const module = await import(pathToFileURL(filePath).href);
4796
4809
  for (const [exportName, exportValue] of Object.entries(module)) {
4797
4810
  if (exportName === "default") {
4798
- const workflowResult = WorkflowSchema.safeParse(stripRuntimeTrigger(exportValue));
4811
+ const workflowResult = WorkflowSchema.safeParse(stripRuntimeStart(exportValue));
4799
4812
  if (workflowResult.success) workflow = workflowResult.data;
4800
4813
  else if (isSdkBranded(exportValue, ["workflow", "workflow-job"])) throw workflowResult.error;
4801
4814
  continue;
@@ -5063,7 +5076,7 @@ const StaticWebsiteSchema = z.strictObject({
5063
5076
 
5064
5077
  //#endregion
5065
5078
  //#region src/cli/services/application.ts
5066
- function defineTailorDB(config, pluginManager) {
5079
+ function defineTailorDB(config, baseDir, pluginManager) {
5067
5080
  const tailorDBServices = [];
5068
5081
  const externalTailorDBNamespaces = [];
5069
5082
  const subgraphs = [];
@@ -5078,7 +5091,8 @@ function defineTailorDB(config, pluginManager) {
5078
5091
  const tailorDB = createTailorDBService({
5079
5092
  namespace,
5080
5093
  config: TailorDBServiceConfigSchema.parse(serviceConfig),
5081
- pluginManager
5094
+ pluginManager,
5095
+ baseDir
5082
5096
  });
5083
5097
  tailorDBServices.push(tailorDB);
5084
5098
  }
@@ -5093,7 +5107,7 @@ function defineTailorDB(config, pluginManager) {
5093
5107
  subgraphs
5094
5108
  };
5095
5109
  }
5096
- function defineResolver(config) {
5110
+ function defineResolver(config, baseDir) {
5097
5111
  const resolverServices = [];
5098
5112
  const subgraphs = [];
5099
5113
  if (!config) return {
@@ -5102,7 +5116,7 @@ function defineResolver(config) {
5102
5116
  };
5103
5117
  for (const [namespace, serviceConfig] of Object.entries(config)) {
5104
5118
  if (!("external" in serviceConfig)) {
5105
- const resolverService = createResolverService(namespace, serviceConfig);
5119
+ const resolverService = createResolverService(namespace, serviceConfig, baseDir);
5106
5120
  resolverServices.push(resolverService);
5107
5121
  }
5108
5122
  subgraphs.push({
@@ -5164,17 +5178,26 @@ function defineAuth(config, tailorDBServices, externalTailorDBNamespaces) {
5164
5178
  subgraphs
5165
5179
  };
5166
5180
  }
5167
- function defineExecutor(config, hasPluginExecutors) {
5181
+ function defineExecutor(config, baseDir, hasPluginExecutors) {
5168
5182
  if (!config && !hasPluginExecutors) return;
5169
- return createExecutorService({ config: config ?? { files: [] } });
5183
+ return createExecutorService({
5184
+ config: config ?? { files: [] },
5185
+ baseDir
5186
+ });
5170
5187
  }
5171
- function defineWorkflow(config) {
5188
+ function defineWorkflow(config, baseDir) {
5172
5189
  if (!config) return;
5173
- return createWorkflowService({ config });
5190
+ return createWorkflowService({
5191
+ config,
5192
+ baseDir
5193
+ });
5174
5194
  }
5175
- function defineHttpAdapterService(config) {
5195
+ function defineHttpAdapterService(config, baseDir) {
5176
5196
  if (!config) return;
5177
- return createHttpAdapterService({ config });
5197
+ return createHttpAdapterService({
5198
+ config,
5199
+ baseDir
5200
+ });
5178
5201
  }
5179
5202
  function stripStaticWebsiteUrlHelper(config) {
5180
5203
  const configWithUrl = config;
@@ -5226,9 +5249,9 @@ function parseSecretManager(config) {
5226
5249
  ignoreNullishValues
5227
5250
  };
5228
5251
  }
5229
- function defineServices(config, pluginManager) {
5230
- const tailordbResult = defineTailorDB(config.db, pluginManager);
5231
- const resolverResult = defineResolver(config.resolver);
5252
+ function defineServices(config, baseDir, pluginManager) {
5253
+ const tailordbResult = defineTailorDB(config.db, baseDir, pluginManager);
5254
+ const resolverResult = defineResolver(config.resolver, baseDir);
5232
5255
  const idpResult = defineIdp(config.idp);
5233
5256
  const authResult = defineAuth(config.auth, tailordbResult.tailorDBServices, tailordbResult.externalTailorDBNamespaces);
5234
5257
  const staticWebsiteServices = defineStaticWebsites(config.staticWebsites);
@@ -5284,10 +5307,11 @@ function buildApplication(params) {
5284
5307
  */
5285
5308
  function defineApplication(params) {
5286
5309
  const { config, pluginManager } = params;
5287
- const services = defineServices(config, pluginManager);
5288
- const executorService = defineExecutor(config.executor, false);
5289
- const workflowService = defineWorkflow(config.workflow);
5290
- const httpAdapterService = defineHttpAdapterService(config.httpAdapter);
5310
+ const baseDir = path.dirname(config.path);
5311
+ const services = defineServices(config, baseDir, pluginManager);
5312
+ const executorService = defineExecutor(config.executor, baseDir, false);
5313
+ const workflowService = defineWorkflow(config.workflow, baseDir);
5314
+ const httpAdapterService = defineHttpAdapterService(config.httpAdapter, baseDir);
5291
5315
  return buildApplication({
5292
5316
  config,
5293
5317
  ...services,
@@ -5332,22 +5356,23 @@ function generatePluginFilesIfNeeded(pluginManager, tailorDBServices, configPath
5332
5356
  */
5333
5357
  async function loadApplication(params) {
5334
5358
  const { config, pluginManager, bundleCache } = params;
5335
- const { tailordbResult, resolverResult, idpResult, authResult, staticWebsiteServices, aiGatewayServices, secrets, ignoreNullishValues } = defineServices(config, pluginManager);
5359
+ const baseDir = path.dirname(config.path);
5360
+ const { tailordbResult, resolverResult, idpResult, authResult, staticWebsiteServices, aiGatewayServices, secrets, ignoreNullishValues } = defineServices(config, baseDir, pluginManager);
5336
5361
  for (const tailordb of tailordbResult.tailorDBServices) {
5337
5362
  await tailordb.loadTypes();
5338
5363
  await tailordb.processNamespacePlugins();
5339
5364
  }
5340
5365
  assertUniqueLocalTailorDBTypeNames({ tailorDBServices: tailordbResult.tailorDBServices });
5341
5366
  const pluginExecutorFiles = generatePluginFilesIfNeeded(pluginManager, tailordbResult.tailorDBServices, config.path);
5342
- const executorService = defineExecutor(config.executor, pluginExecutorFiles.length > 0);
5343
- const workflowService = defineWorkflow(config.workflow);
5367
+ const executorService = defineExecutor(config.executor, baseDir, pluginExecutorFiles.length > 0);
5368
+ const workflowService = defineWorkflow(config.workflow, baseDir);
5344
5369
  if (workflowService) await workflowService.loadWorkflows();
5345
- const httpAdapterService = defineHttpAdapterService(config.httpAdapter);
5370
+ const httpAdapterService = defineHttpAdapterService(config.httpAdapter, baseDir);
5346
5371
  if (httpAdapterService) await httpAdapterService.loadAdapters();
5347
- const triggerContext = await buildTriggerContext(config.workflow, getApplicationAuthNamespace({
5372
+ const startContext = await buildStartContext(config.workflow, getApplicationAuthNamespace({
5348
5373
  authService: authResult.authService,
5349
5374
  config
5350
- }));
5375
+ }), baseDir);
5351
5376
  const inlineSourcemap = resolveInlineSourcemap(config.inlineSourcemap);
5352
5377
  const bundleLogLevel = resolveBundleLogLevel(config.logLevel);
5353
5378
  const bundledScripts = {
@@ -5357,21 +5382,22 @@ async function loadApplication(params) {
5357
5382
  authHooks: /* @__PURE__ */ new Map()
5358
5383
  };
5359
5384
  for (const pipeline of resolverResult.resolverServices) {
5360
- const resolverBundles = await bundleResolvers(pipeline.namespace, pipeline.config, triggerContext, bundleCache, inlineSourcemap, bundleLogLevel);
5385
+ const resolverBundles = await bundleResolvers(pipeline.namespace, pipeline.config, baseDir, startContext, bundleCache, inlineSourcemap, bundleLogLevel);
5361
5386
  for (const [name, code] of resolverBundles) bundledScripts.resolvers.set(resolverBundleKey(pipeline.namespace, name), code);
5362
5387
  }
5363
5388
  if (executorService) bundledScripts.executors = await bundleExecutors({
5364
5389
  config: executorService.config,
5365
- triggerContext,
5390
+ startContext,
5366
5391
  additionalFiles: [...pluginExecutorFiles],
5367
5392
  cache: bundleCache,
5368
5393
  inlineSourcemap,
5369
- bundleLogLevel
5394
+ bundleLogLevel,
5395
+ baseDir
5370
5396
  });
5371
5397
  let workflowBuildResult;
5372
5398
  if (workflowService && workflowService.jobs.length > 0) {
5373
5399
  const mainJobNames = workflowService.workflowSources.map((ws) => ws.workflow.mainJob.name);
5374
- workflowBuildResult = await bundleWorkflowJobs(workflowService.jobs, mainJobNames, config.env ?? {}, triggerContext, bundleCache, inlineSourcemap, bundleLogLevel);
5400
+ workflowBuildResult = await bundleWorkflowJobs(workflowService.jobs, mainJobNames, config.env ?? {}, startContext, baseDir, bundleCache, inlineSourcemap, bundleLogLevel);
5375
5401
  bundledScripts.workflowJobs = workflowBuildResult.bundledCode;
5376
5402
  }
5377
5403
  let httpAdapterBuildResult;
@@ -5380,7 +5406,7 @@ async function loadApplication(params) {
5380
5406
  sourceFile: a.sourceFile,
5381
5407
  methods: a.methods,
5382
5408
  hasOutput: a.hasOutput
5383
- })), bundleCache, bundleLogLevel);
5409
+ })), baseDir, bundleCache, bundleLogLevel);
5384
5410
  if (authResult.authService?.config.hooks?.beforeLogin) {
5385
5411
  const authName = authResult.authService.config.name;
5386
5412
  bundledScripts.authHooks = await bundleAuthHooks({
@@ -5388,10 +5414,11 @@ async function loadApplication(params) {
5388
5414
  authName,
5389
5415
  handlerAccessPath: `auth.hooks.beforeLogin.handler`,
5390
5416
  env: config.env ?? {},
5391
- triggerContext,
5417
+ startContext,
5392
5418
  cache: bundleCache,
5393
5419
  inlineSourcemap,
5394
- bundleLogLevel
5420
+ bundleLogLevel,
5421
+ baseDir
5395
5422
  });
5396
5423
  }
5397
5424
  for (const pipeline of resolverResult.resolverServices) await pipeline.loadResolvers();
@@ -5426,4 +5453,4 @@ async function loadApplication(params) {
5426
5453
 
5427
5454
  //#endregion
5428
5455
  export { fetchAllTolerant as A, initOperatorClient as B, createBundleCache as C, closeConnectionPool as D, hashFile as E, getConsoleBaseUrl as F, byName as G, normalizeBaseUrl as H, getOAuth2ClientId as I, LOG_LEVELS as K, getOrNull as L, fetchPaged as M, fetchPlatformMachineUserToken as N, defaultPlatformBaseUrl as O, fetchUserInfo as P, getPlatformBaseUrl as R, hasGenerationHooks as S, hashContent as T, rememberPlatformConfigForToken as U, isDefaultPlatform as V, resolveStaticWebsiteUrls as W, platformBundleDefinePlugin as _, resolveInlineSourcemap as a, resolveBundleLogLevel as b, WorkflowJobSchema as c, INVOKER_EXPR as d, buildExecutorArgsExpr as f, stringifyFunction as g, assertUniqueTailorDBTypeNamesWithExternal as h, resolverBundleKey as i, fetchMachineUserToken as j, fetchAll as k, ResolverSchema as l, assertUniqueLocalTailorDBTypeNames as m, generatePluginFilesIfNeeded as n, getApplicationAuthNamespace as o, buildResolverOperationHookExpr as p, loadApplication as r, WorkflowJobFunctionExecutionPolicySchema as s, defineApplication as t, HTTP_METHODS as u, composeFunctionTreeshakeOptions as v, getDistDir as w, getPluginGenerationDependencies as x, createLogLevelTreeshakeOptions as y, initOAuth2Client as z };
5429
- //# sourceMappingURL=application-BJXRpQj5.mjs.map
5456
+ //# sourceMappingURL=application-GzW98_Xr.mjs.map