@tailor-platform/sdk 1.35.2 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/application-BB5TqXWY.mjs +4 -0
  3. package/dist/{application-BnJRroGX.mjs → application-BwboBFcU.mjs} +102 -17
  4. package/dist/application-BwboBFcU.mjs.map +1 -0
  5. package/dist/cli/index.mjs +241 -6
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +190 -6
  8. package/dist/cli/lib.mjs +3 -3
  9. package/dist/{client-BmQP4kKS.mjs → client-B6icVEv4.mjs} +1 -1
  10. package/dist/{client-CA2NM_4R.mjs → client-CN15WgW2.mjs} +25 -8
  11. package/dist/client-CN15WgW2.mjs.map +1 -0
  12. package/dist/configure/index.d.mts +5 -4
  13. package/dist/configure/index.mjs +38 -9
  14. package/dist/configure/index.mjs.map +1 -1
  15. package/dist/{crash-report-Bd2T8BhU.mjs → crash-report-CB1UtT3O.mjs} +1 -1
  16. package/dist/{crash-report-CPkI2-cp.mjs → crash-report-CdxPj_SW.mjs} +2 -2
  17. package/dist/{crash-report-CPkI2-cp.mjs.map → crash-report-CdxPj_SW.mjs.map} +1 -1
  18. package/dist/env-_ce3IYbl.d.mts +30 -0
  19. package/dist/{index-DTJkkO-t.d.mts → index-C7vIBAg8.d.mts} +2 -2
  20. package/dist/{index--9iVDOXn.d.mts → index-CYaunQeL.d.mts} +76 -5
  21. package/dist/{index-qVqjEYnr.d.mts → index-CxSLivW7.d.mts} +2 -2
  22. package/dist/{index-D4pBPp65.d.mts → index-DDCyefuU.d.mts} +2 -2
  23. package/dist/{index-niQ9Qblw.d.mts → index-DZN1QFLM.d.mts} +2 -2
  24. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  25. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  26. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  27. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  28. package/dist/plugin/index.d.mts +2 -1
  29. package/dist/{plugin-D8hKE6rZ.d.mts → plugin-CiPUxkyN.d.mts} +4 -28
  30. package/dist/{runtime-D4O-RfcH.mjs → runtime-C7RRDaB3.mjs} +230 -22
  31. package/dist/runtime-C7RRDaB3.mjs.map +1 -0
  32. package/dist/utils/test/index.d.mts +2 -2
  33. package/dist/{workflow.generated-DMt8PNVd.d.mts → workflow.generated-8BeGQsVU.d.mts} +212 -4
  34. package/docs/services/idp.md +50 -0
  35. package/docs/services/secret.md +25 -0
  36. package/package.json +4 -3
  37. package/dist/application-BnJRroGX.mjs.map +0 -1
  38. package/dist/application-mGasp_EX.mjs +0 -4
  39. package/dist/client-CA2NM_4R.mjs.map +0 -1
  40. package/dist/runtime-D4O-RfcH.mjs.map +0 -1
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { D as FunctionExecution_Type, P as AuthInvokerSchema, V as PATScope, i as fetchAll, l as initOAuth2Client, m as userAgent, n as closeConnectionPool, o as fetchPlatformMachineUserToken, s as fetchUserInfo, u as initOperatorClient } from "../client-CA2NM_4R.mjs";
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-CN15WgW2.mjs";
4
4
  import { n as logger, r as styles } from "../logger-qz-Y4sBV.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-D4O-RfcH.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-C7RRDaB3.mjs";
6
6
  import { t as readPackageJson } from "../package-json-CfUqjJaQ.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-BnJRroGX.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-CPkI2-cp.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-BwboBFcU.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-CdxPj_SW.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";
@@ -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
  /**
@@ -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
- logger.log(` ${styles.error(result.error)}`);
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);
@@ -3539,7 +3774,7 @@ 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-Bd2T8BhU.mjs");
3777
+ const { reportCrash } = await import("../crash-report-CB1UtT3O.mjs");
3543
3778
  await reportCrash(error, "handledError");
3544
3779
  }
3545
3780
  }