deepline 0.1.4 → 0.1.7

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/dist/cli/index.js CHANGED
@@ -192,7 +192,7 @@ function resolveConfig(options) {
192
192
  }
193
193
 
194
194
  // src/version.ts
195
- var SDK_VERSION = "0.1.4";
195
+ var SDK_VERSION = "0.1.7";
196
196
  var SDK_API_CONTRACT = "2026-04-plays-v1";
197
197
 
198
198
  // ../shared_libs/play-runtime/coordinator-headers.ts
@@ -2611,6 +2611,13 @@ function formatTypeScriptDiagnostic(diagnostic) {
2611
2611
  }
2612
2612
  return `${diagnostic.file.fileName}:${line + 1}:${character + 1} ${message}`;
2613
2613
  }
2614
+ function resolveBundledTypeRoots() {
2615
+ try {
2616
+ return [(0, import_node_path5.dirname)((0, import_node_path5.dirname)(playArtifactRequire.resolve("@types/node/package.json")))];
2617
+ } catch {
2618
+ return [];
2619
+ }
2620
+ }
2614
2621
  function typecheckPlaySource(input, adapter) {
2615
2622
  const rootNames = Array.from(
2616
2623
  /* @__PURE__ */ new Set([
@@ -2636,7 +2643,8 @@ function typecheckPlaySource(input, adapter) {
2636
2643
  allowImportingTsExtensions: true,
2637
2644
  allowJs: true,
2638
2645
  resolveJsonModule: true,
2639
- types: ["node"]
2646
+ types: ["node"],
2647
+ typeRoots: resolveBundledTypeRoots()
2640
2648
  });
2641
2649
  return import_typescript.default.getPreEmitDiagnostics(program).map(formatTypeScriptDiagnostic).filter((message) => Boolean(message));
2642
2650
  }
@@ -4003,6 +4011,67 @@ function defaultMaterializedPlayPath(reference) {
4003
4011
  const safeName = playName.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
4004
4012
  return (0, import_node_path8.resolve)(`${safeName || "play"}.play.ts`);
4005
4013
  }
4014
+ function sanitizeGeneratedPlayName(value) {
4015
+ return value.trim().toLowerCase().replace(/^prebuilt\//, "").replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "") || "play";
4016
+ }
4017
+ function buildGeneratedCsvWrapperSource(input) {
4018
+ return `import { definePlay } from 'deepline';
4019
+
4020
+ export default definePlay(
4021
+ ${JSON.stringify(input.wrapperName)},
4022
+ async (ctx, input: Record<string, unknown> & { file: string }) => {
4023
+ const rows = await ctx.csv<Record<string, unknown>>(input.file);
4024
+ const constants = Object.fromEntries(
4025
+ Object.entries(input).filter(([key]) => key !== 'file'),
4026
+ );
4027
+
4028
+ const mappedRows = await ctx
4029
+ .map('csv_rows', rows, {
4030
+ key: (row, index) =>
4031
+ String(
4032
+ row.id ??
4033
+ row.lead_id ??
4034
+ row.email ??
4035
+ row.linkedin_url ??
4036
+ row.domain ??
4037
+ index,
4038
+ ),
4039
+ })
4040
+ .step('result', (row, rowCtx) =>
4041
+ rowCtx.runPlay(
4042
+ 'row_play',
4043
+ ${JSON.stringify(input.playRef)},
4044
+ {
4045
+ ...constants,
4046
+ ...row,
4047
+ },
4048
+ {
4049
+ description: 'Run the source play for this CSV row.',
4050
+ },
4051
+ ),
4052
+ )
4053
+ .run({ description: 'Run the source play once per CSV row.' });
4054
+
4055
+ return { rows: mappedRows };
4056
+ },
4057
+ );
4058
+ `;
4059
+ }
4060
+ function writeGeneratedCsvWrapperPlay(playRef) {
4061
+ const baseName = sanitizeGeneratedPlayName(
4062
+ parseReferencedPlayTarget(playRef).unqualifiedPlayName
4063
+ );
4064
+ const wrapperName = `${baseName}-csv`;
4065
+ const outputDir = (0, import_node_path8.resolve)(".deepline", "generated");
4066
+ const outputPath = (0, import_node_path8.join)(outputDir, `${wrapperName}.play.ts`);
4067
+ (0, import_node_fs6.mkdirSync)(outputDir, { recursive: true });
4068
+ (0, import_node_fs6.writeFileSync)(
4069
+ outputPath,
4070
+ buildGeneratedCsvWrapperSource({ wrapperName, playRef }),
4071
+ "utf-8"
4072
+ );
4073
+ return outputPath;
4074
+ }
4006
4075
  function materializeRemotePlaySource(input) {
4007
4076
  if (isFileTarget(input.target)) {
4008
4077
  return null;
@@ -5402,6 +5471,22 @@ async function handleNamedRun(options) {
5402
5471
  waitTimeoutMs: options.waitTimeoutMs,
5403
5472
  progress
5404
5473
  });
5474
+ if (finalStatus.status !== "completed" && options.csvPath) {
5475
+ progress.phase("generating csv wrapper play");
5476
+ const generatedPlayPath = writeGeneratedCsvWrapperPlay(
5477
+ options.target.name
5478
+ );
5479
+ progress.writeLogLine(
5480
+ `Generated CSV wrapper play: ${generatedPlayPath}`
5481
+ );
5482
+ progress.phase("running generated csv wrapper play");
5483
+ return handleFileBackedRun({
5484
+ ...options,
5485
+ target: { kind: "file", path: generatedPlayPath },
5486
+ revisionId: null,
5487
+ revisionSelector: null
5488
+ });
5489
+ }
5405
5490
  const exportedPath = exportPlayStatusRows(finalStatus, options.outPath);
5406
5491
  if (finalStatus.status === "completed") {
5407
5492
  progress.complete();
@@ -7117,6 +7202,7 @@ Output:
7117
7202
  ok: false,
7118
7203
  error: error instanceof Error ? error.message : String(error)
7119
7204
  });
7205
+ progress?.fail();
7120
7206
  if (process.argv.includes("--json")) {
7121
7207
  printJsonError(error);
7122
7208
  } else if (error instanceof Error) {