@tailor-platform/sdk 1.84.0 → 1.85.1

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 (31) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/application-C-zsrNjn.mjs +3 -0
  3. package/dist/{application-CnCljDwk.mjs → application-m5tYtz0-.mjs} +235 -62
  4. package/dist/application-m5tYtz0-.mjs.map +1 -0
  5. package/dist/cli/commands/deploy/tailordb/index.d.mts +1 -0
  6. package/dist/cli/commands/generate/seed/bundler.d.mts +2 -1
  7. package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +5 -0
  8. package/dist/cli/index.mjs +229 -22
  9. package/dist/cli/index.mjs.map +1 -1
  10. package/dist/cli/lib.mjs +92 -36
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/completion/zsh-worker.zsh +52 -2
  13. package/dist/node-builtins-CmaL2Cbq.mjs +36 -0
  14. package/dist/node-builtins-CmaL2Cbq.mjs.map +1 -0
  15. package/dist/plugin/builtin/seed/index.mjs +1 -1
  16. package/dist/{register-typescript-runtime-BCvWR3HC.mjs → register-typescript-runtime-nG-n9lPw.mjs} +336 -268
  17. package/dist/register-typescript-runtime-nG-n9lPw.mjs.map +1 -0
  18. package/dist/rolldown-runtime-DXywRVcq.mjs +0 -1
  19. package/dist/{seed-DFFigL8V.mjs → seed-6eTFj-3Q.mjs} +158 -41
  20. package/dist/seed-6eTFj-3Q.mjs.map +1 -0
  21. package/dist/vitest/index.mjs +3 -35
  22. package/dist/vitest/index.mjs.map +1 -1
  23. package/docs/cli/tailordb.md +29 -7
  24. package/docs/cli-reference.md +16 -15
  25. package/docs/generator/builtin.md +7 -0
  26. package/docs/services/tailordb-migration.md +11 -2
  27. package/package.json +7 -8
  28. package/dist/application-5FOWIxFQ.mjs +0 -3
  29. package/dist/application-CnCljDwk.mjs.map +0 -1
  30. package/dist/register-typescript-runtime-BCvWR3HC.mjs.map +0 -1
  31. package/dist/seed-DFFigL8V.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 1.85.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2016](https://github.com/tailor-platform/sdk/pull/2016) [`3af95bb`](https://github.com/tailor-platform/sdk/commit/3af95bb486b6df71b835b3529fd0757eff0e8c47) Thanks [@toiroakr](https://github.com/toiroakr)! - Remove a dead `node:module` import from a shared runtime helper chunk that could cause resolver bundling (and `deploy`) to fail with an `UNRESOLVED_IMPORT` error for projects importing `@tailor-platform/sdk/runtime`
8
+
9
+ ## 1.85.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#1910](https://github.com/tailor-platform/sdk/pull/1910) [`3153400`](https://github.com/tailor-platform/sdk/commit/3153400e27d8fefcdc6d7c0d0c5ab902f4bb73a3) Thanks [@dqn](https://github.com/dqn)! - Add an `--upsert` flag to seed. Without it, seeding a workspace that already holds some of the rows fails the whole batch for that type on the first duplicate id and inserts nothing. With `--upsert`, every TailorDB row must include an `id`; rows with new ids are inserted, rows with existing ids are updated, and omitted optional fields keep their stored values. Built-In IdP users are created or updated by name, with separate counts for each result. Default behavior is unchanged.
14
+
15
+ - [#1891](https://github.com/tailor-platform/sdk/pull/1891) [`1c323c3`](https://github.com/tailor-platform/sdk/commit/1c323c3809c825293d3aef7c5ac4605755d39baf) Thanks [@dqn](https://github.com/dqn)! - Add `tailordb migration validate` command that runs the same schema checks as `deploy` without applying anything: migration file integrity (including required `migrate.ts` scripts), local types vs. the latest migration snapshot, and remote schema vs. the migration checkpoint. Issues are reported per namespace with type/field-level detail, `--json` emits a machine-readable report, and the command exits with a non-zero code when drift is found, making it usable as a CI safety gate before deploying.
16
+
17
+ As part of this, `deploy`'s remote schema verification now propagates migration state lookup failures instead of silently skipping verification; only a not-yet-deployed namespace is still treated as a first apply.
18
+
19
+ ### Patch Changes
20
+
21
+ - [#1911](https://github.com/tailor-platform/sdk/pull/1911) [`62faf2f`](https://github.com/tailor-platform/sdk/commit/62faf2fd3c1260a7aa1aa809db77f31f66ca3b42) Thanks [@dqn](https://github.com/dqn)! - Use each importing file's nearest tsconfig `paths` aliases as a fallback when bundling resolvers, executors, workflows, auth hooks, HTTP adapters, TailorDB hooks and validators, functions, seeds, queries, and migration scripts. A local dependency belonging to a different TypeScript project could previously leave an import unresolved when the bundle entry's project could not resolve it. Normal bundle resolution still takes precedence, so the importing file's aliases apply only when the import would otherwise be unresolved.
22
+
23
+ - [#1911](https://github.com/tailor-platform/sdk/pull/1911) [`8afbff1`](https://github.com/tailor-platform/sdk/commit/8afbff1c7b12d0fdedb03e0601b81c851dcafb4f) Thanks [@dqn](https://github.com/dqn)! - Fail the build when a bundled file imports a module that cannot be resolved. Previously such an import was silently left in the bundle and only failed at runtime after deploy, including when the tsconfig selected for the build did not declare an alias used by the source. The error names the unresolved specifier, the importing file, and the `tsconfig.json` the build used. Imports explicitly marked as external by a bundler, such as the platform-provided `tailordb` module, remain unaffected.
24
+
25
+ - [#1937](https://github.com/tailor-platform/sdk/pull/1937) [`648351e`](https://github.com/tailor-platform/sdk/commit/648351ea7ea7b42f18650c1766b5e3c9ff8de83f) Thanks [@dqn](https://github.com/dqn)! - Retry transient connection interruptions for read-only CLI requests
26
+
27
+ - [#1920](https://github.com/tailor-platform/sdk/pull/1920) [`26626e0`](https://github.com/tailor-platform/sdk/commit/26626e0f05d269a36d0d75cc73a70150fc94f3aa) Thanks [@toiroakr](https://github.com/toiroakr)! - Remove the `undici` dependency. Running the CLI no longer replaces the process-wide HTTP stack with a bundled `undici` build.
28
+
29
+ - [#1928](https://github.com/tailor-platform/sdk/pull/1928) [`0c97bc7`](https://github.com/tailor-platform/sdk/commit/0c97bc787eb4157626ddd21bbce52e14b015b854) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency globals to v17.8.0
30
+
31
+ - [#1935](https://github.com/tailor-platform/sdk/pull/1935) [`174eae9`](https://github.com/tailor-platform/sdk/commit/174eae988236ef32a98bcc294150a67ae6eda58d) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency @0no-co/graphql.web to v1.3.3
32
+
33
+ - [#1936](https://github.com/tailor-platform/sdk/pull/1936) [`54a2690`](https://github.com/tailor-platform/sdk/commit/54a2690b1223318f82d5358e41995ab93368ec86) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update oxc
34
+
3
35
  ## 1.84.0
4
36
 
5
37
  ### Minor Changes
@@ -0,0 +1,3 @@
1
+ import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-m5tYtz0-.mjs";
2
+
3
+ export { defineApplication, generatePluginFilesIfNeeded };
@@ -5,7 +5,9 @@ import { a as TailorFieldSchema, i as AuthInvokerSchema, n as ExecutorSchema, o
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
 
@@ -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;
@@ -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
  /**
@@ -4118,9 +4284,10 @@ async function bundleSingleExecutor(executor, tsconfig, triggerContext, cache, i
4118
4284
  name: executor.name,
4119
4285
  sourceFile: executor.sourceFile,
4120
4286
  contextHash,
4121
- async build(cachePlugins) {
4287
+ async build(cachePlugins, trackDependency) {
4288
+ const absoluteSourcePath = path.resolve(executor.sourceFile);
4122
4289
  const entryContent = multiline`
4123
- import _internalExecutor from "${path.resolve(executor.sourceFile)}";
4290
+ import _internalExecutor from "${absoluteSourcePath}";
4124
4291
 
4125
4292
  const __executor_function = async (args) => {
4126
4293
  const invoker = ${INVOKER_EXPR};
@@ -4129,12 +4296,13 @@ async function bundleSingleExecutor(executor, tsconfig, triggerContext, cache, i
4129
4296
 
4130
4297
  export { __executor_function as main };
4131
4298
  `;
4132
- const entry = createVirtualEntry(`executor:${executor.name}`, entryContent);
4299
+ const entry = createVirtualEntry(`executor:${executor.name}`, entryContent, "js", absoluteSourcePath);
4133
4300
  const triggerPlugin = createTriggerTransformPlugin(triggerContext);
4134
4301
  const plugins = [entry.plugin];
4135
4302
  if (triggerPlugin) plugins.push(triggerPlugin);
4136
- plugins.push(platformBundleDefinePlugin, ...cachePlugins);
4137
- return (await rolldown.build({
4303
+ plugins.push(createTsconfigPathsPlugin({ onTsconfigRead: trackDependency }), platformBundleDefinePlugin, ...cachePlugins);
4304
+ const bundleLog = createBundleLog({ tsconfig });
4305
+ const result = await rolldown.build({
4138
4306
  input: entry.input,
4139
4307
  write: false,
4140
4308
  output: {
@@ -4146,22 +4314,15 @@ async function bundleSingleExecutor(executor, tsconfig, triggerContext, cache, i
4146
4314
  tsconfig,
4147
4315
  plugins,
4148
4316
  treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
4149
- logLevel: "silent"
4150
- })).output[0].code;
4317
+ ...bundleLog.options
4318
+ });
4319
+ bundleLog.assertAllResolved();
4320
+ return result.output[0].code;
4151
4321
  }
4152
4322
  });
4153
4323
  return [executor.name, code];
4154
4324
  }
4155
4325
 
4156
- //#endregion
4157
- //#region src/cli/services/http-adapter/node-builtins.ts
4158
- const NODE_BUILTINS = new Set(builtinModules.filter((m) => !m.startsWith("_")));
4159
- function isNodeBuiltinImport(source) {
4160
- if (source.startsWith("node:")) return true;
4161
- const root = source.includes("/") ? source.slice(0, source.indexOf("/")) : source;
4162
- return NODE_BUILTINS.has(root);
4163
- }
4164
-
4165
4326
  //#endregion
4166
4327
  //#region src/parser/service/http-adapter/methods.ts
4167
4328
  /**
@@ -4251,16 +4412,16 @@ async function bundleAdapterScript(adapter, kind, tsconfig, cache, bundleLogLeve
4251
4412
  name: adapter.name,
4252
4413
  sourceFile: adapter.sourceFile,
4253
4414
  contextHash,
4254
- async build(cachePlugins) {
4415
+ async build(cachePlugins, trackDependency) {
4255
4416
  const absoluteSourcePath = path.resolve(adapter.sourceFile);
4256
4417
  const entryContent = kind === "input" ? buildInputEntry(absoluteSourcePath, adapter.methods, GRAPHQL_WEB_MODULE) : buildOutputEntry(absoluteSourcePath);
4257
- const entry = createVirtualEntry(`http-adapter:${adapter.name}:${kind}`, entryContent);
4418
+ const entry = createVirtualEntry(`http-adapter:${adapter.name}:${kind}`, entryContent, "js", absoluteSourcePath);
4258
4419
  const plugins = [
4259
4420
  entry.plugin,
4260
4421
  {
4261
4422
  name: "http-adapter-reject-node-imports",
4262
4423
  resolveId(source) {
4263
- 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)}`);
4264
4425
  return null;
4265
4426
  }
4266
4427
  },
@@ -4278,9 +4439,11 @@ async function bundleAdapterScript(adapter, kind, tsconfig, cache, bundleLogLeve
4278
4439
  return null;
4279
4440
  }
4280
4441
  },
4442
+ createTsconfigPathsPlugin({ onTsconfigRead: trackDependency }),
4281
4443
  ...cachePlugins
4282
4444
  ];
4283
- const bundled = (await rolldown.build({
4445
+ const bundleLog = createBundleLog({ tsconfig });
4446
+ const result = await rolldown.build({
4284
4447
  input: entry.input,
4285
4448
  write: false,
4286
4449
  output: {
@@ -4293,8 +4456,10 @@ async function bundleAdapterScript(adapter, kind, tsconfig, cache, bundleLogLeve
4293
4456
  plugins,
4294
4457
  transform: { target: "es2017" },
4295
4458
  treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
4296
- logLevel: "silent"
4297
- })).output[0].code;
4459
+ ...bundleLog.options
4460
+ });
4461
+ bundleLog.assertAllResolved();
4462
+ const bundled = result.output[0].code;
4298
4463
  const byteLength = Buffer.byteLength(bundled, "utf8");
4299
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`);
4300
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`);
@@ -4585,9 +4750,10 @@ async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContex
4585
4750
  name: resolver.name,
4586
4751
  sourceFile: resolver.sourceFile,
4587
4752
  contextHash,
4588
- async build(cachePlugins) {
4753
+ async build(cachePlugins, trackDependency) {
4754
+ const absoluteSourcePath = path.resolve(resolver.sourceFile);
4589
4755
  const entryContent = multiline`
4590
- import _internalResolver from "${path.resolve(resolver.sourceFile)}";
4756
+ import _internalResolver from "${absoluteSourcePath}";
4591
4757
  import { t } from "@tailor-platform/sdk";
4592
4758
 
4593
4759
  const $tailor_resolver_body = async (context) => {
@@ -4598,12 +4764,13 @@ async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContex
4598
4764
 
4599
4765
  export { $tailor_resolver_body as main };
4600
4766
  `;
4601
- const entry = createVirtualEntry(`resolver:${resolver.name}`, entryContent);
4767
+ const entry = createVirtualEntry(`resolver:${resolver.name}`, entryContent, "js", absoluteSourcePath);
4602
4768
  const triggerPlugin = createTriggerTransformPlugin(triggerContext);
4603
4769
  const plugins = [entry.plugin];
4604
4770
  if (triggerPlugin) plugins.push(triggerPlugin);
4605
- plugins.push(platformBundleDefinePlugin, ...cachePlugins);
4606
- return (await rolldown.build({
4771
+ plugins.push(createTsconfigPathsPlugin({ onTsconfigRead: trackDependency }), platformBundleDefinePlugin, ...cachePlugins);
4772
+ const bundleLog = createBundleLog({ tsconfig });
4773
+ const result = await rolldown.build({
4607
4774
  input: entry.input,
4608
4775
  write: false,
4609
4776
  output: {
@@ -4615,8 +4782,10 @@ async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContex
4615
4782
  tsconfig,
4616
4783
  plugins,
4617
4784
  treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
4618
- logLevel: "silent"
4619
- })).output[0].code;
4785
+ ...bundleLog.options
4786
+ });
4787
+ bundleLog.assertAllResolved();
4788
+ return result.output[0].code;
4620
4789
  }
4621
4790
  });
4622
4791
  return [resolver.name, code];
@@ -4924,7 +5093,7 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4924
5093
  name: job.name,
4925
5094
  sourceFile: job.sourceFile,
4926
5095
  contextHash,
4927
- async build(cachePlugins) {
5096
+ async build(cachePlugins, trackDependency) {
4928
5097
  const absoluteSourcePath = path.resolve(job.sourceFile);
4929
5098
  const entryContent = multiline`
4930
5099
  import { ${job.exportName} } from "${absoluteSourcePath}";
@@ -4935,7 +5104,7 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4935
5104
  return await ${job.exportName}.body(input, { env, invoker });
4936
5105
  }
4937
5106
  `;
4938
- const entry = createVirtualEntry(`workflow-job:${job.name}`, entryContent);
5107
+ const entry = createVirtualEntry(`workflow-job:${job.name}`, entryContent, "js", absoluteSourcePath);
4939
5108
  const resolvedSourceFile = safeRealpath(job.sourceFile);
4940
5109
  const otherJobExportNames = allJobs.filter((candidate) => candidate.name !== job.name && safeRealpath(candidate.sourceFile) === resolvedSourceFile).map((j) => j.exportName);
4941
5110
  const plugins = [
@@ -4954,10 +5123,12 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4954
5123
  }
4955
5124
  }
4956
5125
  },
5126
+ createTsconfigPathsPlugin({ onTsconfigRead: trackDependency }),
4957
5127
  platformBundleDefinePlugin,
4958
5128
  ...cachePlugins
4959
5129
  ];
4960
- return (await rolldown.build({
5130
+ const bundleLog = createBundleLog({ tsconfig });
5131
+ const result = await rolldown.build({
4961
5132
  input: entry.input,
4962
5133
  write: false,
4963
5134
  output: {
@@ -4969,8 +5140,10 @@ async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cach
4969
5140
  tsconfig,
4970
5141
  plugins,
4971
5142
  treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
4972
- logLevel: "silent"
4973
- })).output[0].code;
5143
+ ...bundleLog.options
5144
+ });
5145
+ bundleLog.assertAllResolved();
5146
+ return result.output[0].code;
4974
5147
  }
4975
5148
  });
4976
5149
  return [job.name, code];
@@ -5761,5 +5934,5 @@ async function loadApplication(params) {
5761
5934
  }
5762
5935
 
5763
5936
  //#endregion
5764
- export { defaultPlatformBaseUrl as A, getPlatformBaseUrl as B, getPluginGenerationDependencies as C, hashContent as D, getDistDir as E, fetchPlatformMachineUserToken as F, normalizeBaseUrl as G, initOperatorClient as H, fetchUserInfo as I, byName as J, rememberPlatformConfigForToken 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, isNotFoundError as W, LOG_LEVELS as X, createApplyLimiter 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, resolveStaticWebsiteUrls 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 };
5765
- //# sourceMappingURL=application-CnCljDwk.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