@tailor-platform/sdk 1.35.2 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/dist/application-ILhZq_oW.mjs +4 -0
- package/dist/{application-BnJRroGX.mjs → application-qRGMV8Tr.mjs} +150 -35
- package/dist/application-qRGMV8Tr.mjs.map +1 -0
- package/dist/{brand-0SscafcY.mjs → brand-D-d15jx3.mjs} +1 -1
- package/dist/{brand-0SscafcY.mjs.map → brand-D-d15jx3.mjs.map} +1 -1
- package/dist/cli/index.mjs +247 -12
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +190 -6
- package/dist/cli/lib.mjs +7 -7
- package/dist/{client-BmQP4kKS.mjs → client-424n_3T9.mjs} +1 -1
- package/dist/{client-CA2NM_4R.mjs → client-DllDLYmZ.mjs} +28 -11
- package/dist/client-DllDLYmZ.mjs.map +1 -0
- package/dist/configure/index.d.mts +5 -4
- package/dist/configure/index.mjs +42 -23
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{crash-report-CPkI2-cp.mjs → crash-report-CDQ2JvgR.mjs} +4 -4
- package/dist/{crash-report-CPkI2-cp.mjs.map → crash-report-CDQ2JvgR.mjs.map} +1 -1
- package/dist/{crash-report-Bd2T8BhU.mjs → crash-report-aHnky_xH.mjs} +1 -1
- package/dist/{enum-constants-DI85-fPE.mjs → enum-constants-Dx82rSjf.mjs} +1 -1
- package/dist/{enum-constants-DI85-fPE.mjs.map → enum-constants-Dx82rSjf.mjs.map} +1 -1
- package/dist/env-04IQXqsl.d.mts +30 -0
- package/dist/{file-utils-C4rXlOVt.mjs → file-utils-DeWpvq3T.mjs} +1 -1
- package/dist/{file-utils-C4rXlOVt.mjs.map → file-utils-DeWpvq3T.mjs.map} +1 -1
- package/dist/{index-DTJkkO-t.d.mts → index-BUT18Kak.d.mts} +2 -2
- package/dist/{index--9iVDOXn.d.mts → index-BVJQLjyN.d.mts} +98 -12
- package/dist/{index-D4pBPp65.d.mts → index-C3kcXHXJ.d.mts} +2 -2
- package/dist/{index-niQ9Qblw.d.mts → index-CeS4FA9o.d.mts} +2 -2
- package/dist/{index-qVqjEYnr.d.mts → index-DnIg_LfT.d.mts} +2 -2
- package/dist/{interceptor-f7slMkCC.mjs → interceptor-dSNiQq71.mjs} +1 -1
- package/dist/{interceptor-f7slMkCC.mjs.map → interceptor-dSNiQq71.mjs.map} +1 -1
- package/dist/{job-CPKYCk_e.mjs → job-DkAklmE4.mjs} +2 -2
- package/dist/{job-CPKYCk_e.mjs.map → job-DkAklmE4.mjs.map} +1 -1
- package/dist/{kysely-type-DtnNdHn3.mjs → kysely-type-CwtvQuxh.mjs} +1 -1
- package/dist/{kysely-type-DtnNdHn3.mjs.map → kysely-type-CwtvQuxh.mjs.map} +1 -1
- package/dist/{logger-qz-Y4sBV.mjs → logger-C8qBDCKO.mjs} +1 -1
- package/dist/{logger-qz-Y4sBV.mjs.map → logger-C8qBDCKO.mjs.map} +1 -1
- package/dist/package-json--6dmp6-h.mjs +4 -0
- package/dist/{package-json-CfUqjJaQ.mjs → package-json-BHViVisJ.mjs} +1 -1
- package/dist/{package-json-CfUqjJaQ.mjs.map → package-json-BHViVisJ.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.d.mts +2 -1
- package/dist/{plugin-D8hKE6rZ.d.mts → plugin-D6P4g_2L.d.mts} +17 -36
- package/dist/{runtime-D4O-RfcH.mjs → runtime-D9ejnCm6.mjs} +788 -109
- package/dist/runtime-D9ejnCm6.mjs.map +1 -0
- package/dist/{schema-D27cW0Ca.mjs → schema-CnwUqPyM.mjs} +4 -361
- package/dist/schema-CnwUqPyM.mjs.map +1 -0
- package/dist/{seed-BZIFDG27.mjs → seed-DrbB1VXd.mjs} +1 -1
- package/dist/{seed-BZIFDG27.mjs.map → seed-DrbB1VXd.mjs.map} +1 -1
- package/dist/telemetry-4IOPW6wE.mjs +4 -0
- package/dist/{telemetry-CREcGK8y.mjs → telemetry-DwHuiNiR.mjs} +2 -2
- package/dist/{telemetry-CREcGK8y.mjs.map → telemetry-DwHuiNiR.mjs.map} +1 -1
- package/dist/types-B9ZMosul.mjs +372 -0
- package/dist/types-B9ZMosul.mjs.map +1 -0
- package/dist/types-C45jRrCM.mjs +4 -0
- package/dist/utils/test/index.d.mts +2 -2
- package/dist/utils/test/index.mjs +1 -1
- package/dist/{workflow.generated-DMt8PNVd.d.mts → workflow.generated-Bj_DVqGh.d.mts} +212 -4
- package/docs/services/auth.md +6 -5
- package/docs/services/executor.md +5 -12
- package/docs/services/idp.md +50 -0
- package/docs/services/resolver.md +6 -13
- package/docs/services/secret.md +25 -0
- package/docs/services/workflow.md +4 -3
- package/package.json +7 -6
- package/dist/application-BnJRroGX.mjs.map +0 -1
- package/dist/application-mGasp_EX.mjs +0 -4
- package/dist/client-CA2NM_4R.mjs.map +0 -1
- package/dist/package-json-D5Km1jjt.mjs +0 -4
- package/dist/runtime-D4O-RfcH.mjs.map +0 -1
- package/dist/schema-D27cW0Ca.mjs.map +0 -1
- package/dist/telemetry-C508zIi1.mjs +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brand-
|
|
1
|
+
{"version":3,"file":"brand-D-d15jx3.mjs","names":[],"sources":["../src/utils/brand.ts"],"sourcesContent":["// Symbol.for ensures the same symbol is returned across different ESM module instances,\n// avoiding identity mismatches when multiple copies of the SDK are loaded.\nexport const SDK_BRAND: unique symbol = Symbol.for(\"tailor-platform/sdk\");\n\nexport type SdkBrandKind = \"tailordb-type\" | \"resolver\" | \"executor\" | \"workflow\" | \"workflow-job\";\n\n/**\n * Adds a non-enumerable SDK brand symbol to the given object (in-place).\n * The brand stores the kind so service loaders can distinguish between\n * different SDK object types (e.g. a type loader skips executors).\n * @param value - The object to brand\n * @param kind - The kind of SDK object\n * @returns The same object with the brand applied\n */\nexport function brandValue<T extends object>(value: T, kind: SdkBrandKind): T {\n Object.defineProperty(value, SDK_BRAND, {\n value: kind,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return value;\n}\n\n/**\n * Checks whether the given value has been branded by the SDK.\n * When kind is specified, only returns true if the brand matches that kind.\n * Accepts a single kind or an array of kinds for multi-kind matching.\n * @param value - The value to check\n * @param kind - Optional kind or kinds to match against\n * @returns True if the value has the SDK brand symbol (and matches kind if specified)\n */\nexport function isSdkBranded(\n value: unknown,\n kind?: SdkBrandKind | readonly SdkBrandKind[],\n): boolean {\n if (value === null || typeof value !== \"object\" || !(SDK_BRAND in value)) return false;\n const stored = (value as Record<symbol, unknown>)[SDK_BRAND];\n // No kind filter → any brand matches. Legacy `true` brand → matches any kind.\n return (\n kind === undefined ||\n stored === true ||\n (Array.isArray(kind) ? kind.includes(stored as SdkBrandKind) : stored === kind)\n );\n}\n"],"mappings":";;AAEA,MAAa,YAA2B,OAAO,IAAI,sBAAsB;;;;;;;;;AAYzE,SAAgB,WAA6B,OAAU,MAAuB;AAC5E,QAAO,eAAe,OAAO,WAAW;EACtC,OAAO;EACP,YAAY;EACZ,cAAc;EACd,UAAU;EACX,CAAC;AACF,QAAO;;;;;;;;;;AAWT,SAAgB,aACd,OACA,MACS;AACT,KAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,EAAE,aAAa,OAAQ,QAAO;CACjF,MAAM,SAAU,MAAkC;AAElD,QACE,SAAS,UACT,WAAW,SACV,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,OAAuB,GAAG,WAAW"}
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { n as logger, r as styles } from "../logger-
|
|
5
|
-
import { At as functionExecutionStatusToString, B as updateCommand$3, Ct as startCommand, D as resumeCommand, Dt as executionsCommand, E as healthCommand, Ft as executeScript, I as showCommand, J as updateCommand$2, Jt as formatMigrationNumber, K as getCommand$4, L as logBetaWarning, M as truncateCommand, Mt as getCommand$1, P as generateCommand$1, Pt as apply, Q as getCommand$3, Qt as getMigrationFiles, Rt as parseMigrationLabelNumber, Tt as getCommand$5, U as treeCommand, W as listCommand$10, X as listCommand$9, Zt as getMigrationFilePath, _ as getCommand$6, _n as isVerbose, _t as listCommand$6, a as updateCommand$4, bt as jobsCommand, cn as sdkNameLabelKey, d as inviteCommand, en as isValidMigrationNumber, et as deleteCommand$3, fn as apiCommand, ft as generate, gn as deploymentArgs, h as listCommand$14, hn as confirmationArgs, ht as triggerCommand, i as isCLIError, it as listCommand$8, jt as formatKeyValueTable, k as listCommand$11, l as listCommand$13, ln as trnPrefix, lt as tokenCommand, mn as commonArgs, mt as webhookCommand, nt as createCommand$3, on as getNamespacesWithMigrations, ot as getCommand$2, p as restoreCommand, pn as defineAppCommand, r as queryCommand, s as removeCommand, sn as prompt, t as isNativeTypeScriptRuntime, tn as loadDiff, ut as listCommand$7, vn as workspaceArgs, w as listCommand$12, x as createCommand$4, y as deleteCommand$4, z as removeCommand$1 } from "../runtime-
|
|
6
|
-
import { t as readPackageJson } from "../package-json-
|
|
7
|
-
import { C as resolveTokens, S as readPlatformConfig, T as writePlatformConfig, a as loadConfig, b as loadAccessToken, g as getDistDir, i as resolveInlineSourcemap, l as ExecutorSchema, o as WorkflowJobSchema, s as ResolverSchema, v as deleteUserTokens, w as saveUserTokens, x as loadWorkspaceId, y as fetchLatestToken } from "../application-
|
|
8
|
-
import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crash-report-
|
|
3
|
+
import { I as AuthInvokerSchema, U as PATScope, i as fetchAll, k as FunctionExecution_Type, l as initOAuth2Client, m as userAgent, n as closeConnectionPool, o as fetchPlatformMachineUserToken, s as fetchUserInfo, u as initOperatorClient } from "../client-DllDLYmZ.mjs";
|
|
4
|
+
import { n as logger, r as styles } from "../logger-C8qBDCKO.mjs";
|
|
5
|
+
import { At as functionExecutionStatusToString, B as updateCommand$3, Ct as startCommand, D as resumeCommand, Dt as executionsCommand, E as healthCommand, Ft as executeScript, I as showCommand, J as updateCommand$2, Jt as formatMigrationNumber, K as getCommand$4, L as logBetaWarning, M as truncateCommand, Mt as getCommand$1, P as generateCommand$1, Pt as apply, Q as getCommand$3, Qt as getMigrationFiles, Rt as parseMigrationLabelNumber, Tt as getCommand$5, U as treeCommand, W as listCommand$10, X as listCommand$9, Zt as getMigrationFilePath, _ as getCommand$6, _n as isVerbose, _t as listCommand$6, a as updateCommand$4, bt as jobsCommand, cn as sdkNameLabelKey, d as inviteCommand, en as isValidMigrationNumber, et as deleteCommand$3, fn as apiCommand, ft as generate, gn as deploymentArgs, h as listCommand$14, hn as confirmationArgs, ht as triggerCommand, i as isCLIError, it as listCommand$8, jt as formatKeyValueTable, k as listCommand$11, l as listCommand$13, ln as trnPrefix, lt as tokenCommand, mn as commonArgs, mt as webhookCommand, nt as createCommand$3, on as getNamespacesWithMigrations, ot as getCommand$2, p as restoreCommand, pn as defineAppCommand, r as queryCommand, s as removeCommand, sn as prompt, t as isNativeTypeScriptRuntime, tn as loadDiff, ut as listCommand$7, vn as workspaceArgs, w as listCommand$12, x as createCommand$4, y as deleteCommand$4, z as removeCommand$1 } from "../runtime-D9ejnCm6.mjs";
|
|
6
|
+
import { t as readPackageJson } from "../package-json-BHViVisJ.mjs";
|
|
7
|
+
import { C as resolveTokens, S as readPlatformConfig, T as writePlatformConfig, a as loadConfig, b as loadAccessToken, g as getDistDir, i as resolveInlineSourcemap, l as ExecutorSchema, o as WorkflowJobSchema, s as ResolverSchema, v as deleteUserTokens, w as saveUserTokens, x as loadWorkspaceId, y as fetchLatestToken } from "../application-qRGMV8Tr.mjs";
|
|
8
|
+
import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crash-report-CDQ2JvgR.mjs";
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
import { arg, defineCommand, runCommand, runMain } from "politty";
|
|
11
11
|
import { withCompletionCommand } from "politty/completion";
|
|
@@ -23,6 +23,7 @@ import ml from "multiline-ts";
|
|
|
23
23
|
import * as rolldown from "rolldown";
|
|
24
24
|
import { create } from "@bufbuild/protobuf";
|
|
25
25
|
import open from "open";
|
|
26
|
+
import { TraceMap, generatedPositionFor, originalPositionFor } from "@jridgewell/trace-mapping";
|
|
26
27
|
import { spawn, spawnSync } from "node:child_process";
|
|
27
28
|
import * as fs from "fs";
|
|
28
29
|
import { lookup } from "mime-types";
|
|
@@ -45,7 +46,7 @@ const applyCommand = defineAppCommand({
|
|
|
45
46
|
"clean-cache": arg(z.boolean().optional(), { description: "Clean the bundle cache before building" })
|
|
46
47
|
}).strict(),
|
|
47
48
|
run: async (args) => {
|
|
48
|
-
const { initTelemetry } = await import("../telemetry-
|
|
49
|
+
const { initTelemetry } = await import("../telemetry-4IOPW6wE.mjs");
|
|
49
50
|
await initTelemetry();
|
|
50
51
|
await apply({
|
|
51
52
|
workspaceId: args["workspace-id"],
|
|
@@ -523,6 +524,238 @@ const logsCommand = defineAppCommand({
|
|
|
523
524
|
}
|
|
524
525
|
});
|
|
525
526
|
|
|
527
|
+
//#endregion
|
|
528
|
+
//#region src/cli/shared/stack-trace.ts
|
|
529
|
+
/**
|
|
530
|
+
* Stack trace parsing, sourcemap-based source identification, and
|
|
531
|
+
* formatted error display for the test-run command.
|
|
532
|
+
*
|
|
533
|
+
* The platform runtime automatically applies inline sourcemaps to V8
|
|
534
|
+
* stack traces, so frame positions are already original source positions.
|
|
535
|
+
* This module identifies which source file each frame belongs to via
|
|
536
|
+
* reverse lookup (generatedPositionFor), then produces human-readable
|
|
537
|
+
* output with file paths and code snippets.
|
|
538
|
+
*/
|
|
539
|
+
const STACK_FRAME_REGEX = /^\s+at\s+(?:(.+?)\s+\()?(file:\/\/\/.+?):(\d+):(\d+)\)?$/;
|
|
540
|
+
const RPC_ERROR_PREFIX = "rpc error: code = Aborted desc = ";
|
|
541
|
+
/**
|
|
542
|
+
* Parse a V8 stack trace string into structured frames.
|
|
543
|
+
* Only frames with `file:///` URLs are included (eval frames are skipped).
|
|
544
|
+
* @param error - Raw error string potentially containing a V8 stack trace
|
|
545
|
+
* @returns Parsed error message and stack frames
|
|
546
|
+
*/
|
|
547
|
+
function parseStackTrace(error) {
|
|
548
|
+
const lines = error.split("\n");
|
|
549
|
+
const messageLines = [];
|
|
550
|
+
const frameLines = [];
|
|
551
|
+
for (const line of lines) if (/^\s+at\s+/.test(line)) frameLines.push(line);
|
|
552
|
+
else if (frameLines.length === 0) messageLines.push(line);
|
|
553
|
+
let errorMessage = messageLines.join("\n");
|
|
554
|
+
if (errorMessage.startsWith(RPC_ERROR_PREFIX)) errorMessage = errorMessage.slice(33);
|
|
555
|
+
const frames = [];
|
|
556
|
+
for (const line of frameLines) {
|
|
557
|
+
const match = STACK_FRAME_REGEX.exec(line);
|
|
558
|
+
if (match) frames.push({
|
|
559
|
+
functionName: match[1] || "<anonymous>",
|
|
560
|
+
file: match[2],
|
|
561
|
+
line: Number(match[3]),
|
|
562
|
+
column: Number(match[4])
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
return {
|
|
566
|
+
errorMessage,
|
|
567
|
+
frames
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
const INLINE_SOURCEMAP_REGEX = /\/\/[#@]\s*sourceMappingURL=data:application\/json[^,]*;base64,(.+)$/m;
|
|
571
|
+
/**
|
|
572
|
+
* Extract an inline sourcemap from bundled code and return a TraceMap.
|
|
573
|
+
* @param bundledCode - Bundled JavaScript code potentially containing an inline sourcemap
|
|
574
|
+
* @returns TraceMap instance, or null if no valid inline sourcemap is found
|
|
575
|
+
*/
|
|
576
|
+
function extractInlineSourcemap(bundledCode) {
|
|
577
|
+
const match = INLINE_SOURCEMAP_REGEX.exec(bundledCode);
|
|
578
|
+
if (!match) return null;
|
|
579
|
+
try {
|
|
580
|
+
const decoded = Buffer.from(match[1], "base64").toString("utf-8");
|
|
581
|
+
return new TraceMap(JSON.parse(decoded));
|
|
582
|
+
} catch {
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Map parsed stack frames to their source files using a TraceMap.
|
|
588
|
+
*
|
|
589
|
+
* The platform runtime applies inline sourcemaps automatically, so V8
|
|
590
|
+
* reports already-mapped original source positions in stack traces.
|
|
591
|
+
* This function uses generatedPositionFor to reverse-lookup which source
|
|
592
|
+
* file each frame's line:column belongs to.
|
|
593
|
+
* @param frames - Parsed stack frames (positions are already original source positions)
|
|
594
|
+
* @param traceMap - TraceMap from inline sourcemap, or null
|
|
595
|
+
* @returns Frames with identified source files
|
|
596
|
+
*/
|
|
597
|
+
function mapStackFrames(frames, traceMap) {
|
|
598
|
+
return frames.map((frame) => {
|
|
599
|
+
if (!traceMap) return {
|
|
600
|
+
original: frame,
|
|
601
|
+
mapped: null
|
|
602
|
+
};
|
|
603
|
+
try {
|
|
604
|
+
for (let i = traceMap.sources.length - 1; i >= 0; i--) {
|
|
605
|
+
const source = traceMap.sources[i];
|
|
606
|
+
if (source == null) continue;
|
|
607
|
+
const genPos = generatedPositionFor(traceMap, {
|
|
608
|
+
source,
|
|
609
|
+
line: frame.line,
|
|
610
|
+
column: frame.column - 1
|
|
611
|
+
});
|
|
612
|
+
if (genPos.line == null) continue;
|
|
613
|
+
const origPos = originalPositionFor(traceMap, {
|
|
614
|
+
line: genPos.line,
|
|
615
|
+
column: genPos.column
|
|
616
|
+
});
|
|
617
|
+
if (origPos.source !== source || origPos.line !== frame.line || origPos.column !== frame.column - 1) continue;
|
|
618
|
+
return {
|
|
619
|
+
original: frame,
|
|
620
|
+
mapped: {
|
|
621
|
+
source,
|
|
622
|
+
line: frame.line,
|
|
623
|
+
column: frame.column,
|
|
624
|
+
name: null
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
original: frame,
|
|
630
|
+
mapped: null
|
|
631
|
+
};
|
|
632
|
+
} catch {
|
|
633
|
+
return {
|
|
634
|
+
original: frame,
|
|
635
|
+
mapped: null
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Detect the URI scheme for opening files based on VISUAL/EDITOR env vars.
|
|
642
|
+
* @returns "vscode" if the editor looks like VS Code, otherwise null (use file://)
|
|
643
|
+
*/
|
|
644
|
+
function detectEditorScheme() {
|
|
645
|
+
const editor = process.env.VISUAL || process.env.EDITOR || "";
|
|
646
|
+
if (/\bcode\b/.test(editor)) return "vscode";
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Wrap text in an OSC 8 terminal hyperlink.
|
|
651
|
+
* @param uri - URI to open when the link is clicked
|
|
652
|
+
* @param text - Visible text displayed in the terminal
|
|
653
|
+
* @returns Escaped string with OSC 8 sequences
|
|
654
|
+
*/
|
|
655
|
+
function osc8Link(uri, text) {
|
|
656
|
+
return `\x1b]8;;${uri}\x07${text}\x1b]8;;\x07`;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Build a clickable terminal link for a source location.
|
|
660
|
+
* Uses vscode:// URI if the editor is VS Code, otherwise file:// URI.
|
|
661
|
+
* @param displayPath - Path to display in the terminal
|
|
662
|
+
* @param absolutePath - Absolute file path for the URI
|
|
663
|
+
* @param line - 1-based line number
|
|
664
|
+
* @param column - 1-based column number
|
|
665
|
+
* @returns OSC 8 hyperlinked location string
|
|
666
|
+
*/
|
|
667
|
+
function buildSourceLink(displayPath, absolutePath, line, column) {
|
|
668
|
+
const location = `${displayPath}:${line}:${column}`;
|
|
669
|
+
if (detectEditorScheme() === "vscode") return osc8Link(`vscode://file${absolutePath}:${line}:${column}`, location);
|
|
670
|
+
return osc8Link(`file://${absolutePath}`, location);
|
|
671
|
+
}
|
|
672
|
+
const SNIPPET_CONTEXT_LINES = 2;
|
|
673
|
+
/**
|
|
674
|
+
* Build a code snippet around a target line from source content.
|
|
675
|
+
* Shows SNIPPET_CONTEXT_LINES above and below with line numbers.
|
|
676
|
+
* The target line is marked with `>` and highlighted.
|
|
677
|
+
* @param content - Full source file content
|
|
678
|
+
* @param targetLine - 1-based line number to highlight
|
|
679
|
+
* @returns Formatted snippet string
|
|
680
|
+
*/
|
|
681
|
+
function buildCodeSnippet(content, targetLine) {
|
|
682
|
+
const lines = content.split("\n");
|
|
683
|
+
const start = Math.max(0, targetLine - 1 - SNIPPET_CONTEXT_LINES);
|
|
684
|
+
const end = Math.min(lines.length, targetLine + SNIPPET_CONTEXT_LINES);
|
|
685
|
+
const gutterWidth = String(end).length;
|
|
686
|
+
const snippetLines = [];
|
|
687
|
+
for (let i = start; i < end; i++) {
|
|
688
|
+
const lineNum = i + 1;
|
|
689
|
+
const gutter = String(lineNum).padStart(gutterWidth);
|
|
690
|
+
const lineContent = lines[i];
|
|
691
|
+
if (lineNum === targetLine) snippetLines.push(` ${styles.error(">")} ${styles.error(`${gutter} | ${lineContent}`)}`);
|
|
692
|
+
else snippetLines.push(` ${styles.dim(`${gutter} | ${lineContent}`)}`);
|
|
693
|
+
}
|
|
694
|
+
return snippetLines.join("\n");
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Format mapped stack frames into a human-readable error display.
|
|
698
|
+
* Includes file paths (clickable in terminals), code snippets, and
|
|
699
|
+
* falls back to raw frame info for unmapped frames.
|
|
700
|
+
* @param errorMessage - Cleaned error message
|
|
701
|
+
* @param frames - Mapped stack frames
|
|
702
|
+
* @param traceMap - TraceMap for retrieving source content (may be null)
|
|
703
|
+
* @param bundleDir - Absolute path to bundle output directory for resolving source paths
|
|
704
|
+
* @returns Formatted error string for display
|
|
705
|
+
*/
|
|
706
|
+
function formatMappedError(errorMessage, frames, traceMap, bundleDir) {
|
|
707
|
+
const parts = [` ${styles.error(errorMessage)}`];
|
|
708
|
+
for (const frame of frames) if (frame.mapped) {
|
|
709
|
+
const { source, line, column, name } = frame.mapped;
|
|
710
|
+
const absolutePath = bundleDir ? path.resolve(bundleDir, source) : path.resolve(source);
|
|
711
|
+
const rel = path.relative(process.cwd(), absolutePath);
|
|
712
|
+
const displaySource = rel.startsWith(".") ? rel : `./${rel}`;
|
|
713
|
+
const fnName = name ?? frame.original.functionName;
|
|
714
|
+
const link = buildSourceLink(displaySource, absolutePath, line, column);
|
|
715
|
+
parts.push(`\n at ${fnName} (${link})`);
|
|
716
|
+
if (traceMap) {
|
|
717
|
+
const sourceIndex = traceMap.sources.indexOf(source);
|
|
718
|
+
if (sourceIndex !== -1) {
|
|
719
|
+
const content = traceMap.sourcesContent?.[sourceIndex];
|
|
720
|
+
if (content) parts.push(buildCodeSnippet(content, line));
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
} else {
|
|
724
|
+
const location = `${frame.original.file.replace(/^file:\/\/\//, "")}:${frame.original.line}:${frame.original.column}`;
|
|
725
|
+
parts.push(`\n ${styles.dim(`at ${frame.original.functionName} (${location})`)}`);
|
|
726
|
+
}
|
|
727
|
+
return parts.join("\n");
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Format an error string with sourcemap-based source locations.
|
|
731
|
+
* This is the main entry point for test-run error display.
|
|
732
|
+
*
|
|
733
|
+
* The platform runtime applies inline sourcemaps automatically, so V8
|
|
734
|
+
* stack frames already contain original source positions. This function
|
|
735
|
+
* identifies which source file each frame belongs to and formats the
|
|
736
|
+
* error with file paths, line numbers, and code snippets.
|
|
737
|
+
*
|
|
738
|
+
* Returns null if sourcemap processing is not possible (no inline
|
|
739
|
+
* sourcemap, no stack trace, or processing error).
|
|
740
|
+
* @param error - Raw error string from script execution (may contain V8 stack trace)
|
|
741
|
+
* @param bundledCode - Bundled JavaScript code (may contain inline sourcemap)
|
|
742
|
+
* @param bundleDir - Absolute path to the bundle output directory (sourcemap paths are relative to this)
|
|
743
|
+
* @returns Formatted error string, or null to fall back to default display
|
|
744
|
+
*/
|
|
745
|
+
function formatErrorWithSourcemap(error, bundledCode, bundleDir) {
|
|
746
|
+
try {
|
|
747
|
+
const { errorMessage, frames } = parseStackTrace(error);
|
|
748
|
+
if (frames.length === 0) return null;
|
|
749
|
+
const traceMap = extractInlineSourcemap(bundledCode);
|
|
750
|
+
if (!traceMap) return null;
|
|
751
|
+
const mappedFrames = mapStackFrames(frames, traceMap);
|
|
752
|
+
if (mappedFrames.some((f) => f.mapped !== null)) return formatMappedError(errorMessage, mappedFrames, traceMap, bundleDir);
|
|
753
|
+
return null;
|
|
754
|
+
} catch {
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
526
759
|
//#endregion
|
|
527
760
|
//#region src/cli/commands/function/bundle.ts
|
|
528
761
|
/**
|
|
@@ -707,7 +940,7 @@ async function detectFunctionType(options) {
|
|
|
707
940
|
const rawInput = module.default.input;
|
|
708
941
|
let inputSchema;
|
|
709
942
|
if (rawInput) {
|
|
710
|
-
const { t } = await import("
|
|
943
|
+
const { t } = await import("../types-C45jRrCM.mjs");
|
|
711
944
|
inputSchema = t.object(rawInput);
|
|
712
945
|
}
|
|
713
946
|
return {
|
|
@@ -943,7 +1176,9 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
|
|
|
943
1176
|
}
|
|
944
1177
|
if (result.error && !result.success) {
|
|
945
1178
|
logger.log(styles.bold("\nError:"));
|
|
946
|
-
|
|
1179
|
+
const formatted = formatErrorWithSourcemap(result.error, bundledCode, process.cwd());
|
|
1180
|
+
if (formatted) logger.log(formatted);
|
|
1181
|
+
else logger.log(` ${styles.error(result.error)}`);
|
|
947
1182
|
}
|
|
948
1183
|
}
|
|
949
1184
|
if (!result.success) process.exit(1);
|
|
@@ -1075,7 +1310,7 @@ const generateCommand = defineAppCommand({
|
|
|
1075
1310
|
})
|
|
1076
1311
|
}).strict(),
|
|
1077
1312
|
run: async (args) => {
|
|
1078
|
-
const { initTelemetry } = await import("../telemetry-
|
|
1313
|
+
const { initTelemetry } = await import("../telemetry-4IOPW6wE.mjs");
|
|
1079
1314
|
await initTelemetry();
|
|
1080
1315
|
await generate({
|
|
1081
1316
|
configPath: args.config,
|
|
@@ -3539,11 +3774,11 @@ runMain(mainCommand, {
|
|
|
3539
3774
|
if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
|
|
3540
3775
|
} else logger.error(`Unknown error: ${error}`);
|
|
3541
3776
|
if (!isCLIError(error) && (!(error instanceof Error) || error instanceof TypeError || error instanceof RangeError)) {
|
|
3542
|
-
const { reportCrash } = await import("../crash-report-
|
|
3777
|
+
const { reportCrash } = await import("../crash-report-aHnky_xH.mjs");
|
|
3543
3778
|
await reportCrash(error, "handledError");
|
|
3544
3779
|
}
|
|
3545
3780
|
}
|
|
3546
|
-
const { shutdownTelemetry } = await import("../telemetry-
|
|
3781
|
+
const { shutdownTelemetry } = await import("../telemetry-4IOPW6wE.mjs");
|
|
3547
3782
|
await shutdownTelemetry();
|
|
3548
3783
|
}
|
|
3549
3784
|
});
|