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/index.d.mts CHANGED
@@ -1325,7 +1325,7 @@ declare class DeeplineClient {
1325
1325
  }>;
1326
1326
  }
1327
1327
 
1328
- declare const SDK_VERSION = "0.1.4";
1328
+ declare const SDK_VERSION = "0.1.7";
1329
1329
  declare const SDK_API_CONTRACT = "2026-04-plays-v1";
1330
1330
 
1331
1331
  /**
package/dist/index.d.ts CHANGED
@@ -1325,7 +1325,7 @@ declare class DeeplineClient {
1325
1325
  }>;
1326
1326
  }
1327
1327
 
1328
- declare const SDK_VERSION = "0.1.4";
1328
+ declare const SDK_VERSION = "0.1.7";
1329
1329
  declare const SDK_API_CONTRACT = "2026-04-plays-v1";
1330
1330
 
1331
1331
  /**
package/dist/index.js CHANGED
@@ -196,7 +196,7 @@ function resolveConfig(options) {
196
196
  }
197
197
 
198
198
  // src/version.ts
199
- var SDK_VERSION = "0.1.4";
199
+ var SDK_VERSION = "0.1.7";
200
200
  var SDK_API_CONTRACT = "2026-04-plays-v1";
201
201
 
202
202
  // ../shared_libs/play-runtime/coordinator-headers.ts
package/dist/index.mjs CHANGED
@@ -149,7 +149,7 @@ function resolveConfig(options) {
149
149
  }
150
150
 
151
151
  // src/version.ts
152
- var SDK_VERSION = "0.1.4";
152
+ var SDK_VERSION = "0.1.7";
153
153
  var SDK_API_CONTRACT = "2026-04-plays-v1";
154
154
 
155
155
  // ../shared_libs/play-runtime/coordinator-headers.ts
@@ -1,6 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import {
3
3
  existsSync,
4
+ mkdirSync,
4
5
  readFileSync,
5
6
  readdirSync,
6
7
  realpathSync,
@@ -140,6 +141,81 @@ function defaultMaterializedPlayPath(reference: string): string {
140
141
  return resolve(`${safeName || 'play'}.play.ts`);
141
142
  }
142
143
 
144
+ function sanitizeGeneratedPlayName(value: string): string {
145
+ return (
146
+ value
147
+ .trim()
148
+ .toLowerCase()
149
+ .replace(/^prebuilt\//, '')
150
+ .replace(/[^a-z0-9-]/g, '-')
151
+ .replace(/-+/g, '-')
152
+ .replace(/^-|-$/g, '') || 'play'
153
+ );
154
+ }
155
+
156
+ function buildGeneratedCsvWrapperSource(input: {
157
+ wrapperName: string;
158
+ playRef: string;
159
+ }): string {
160
+ return `import { definePlay } from 'deepline';
161
+
162
+ export default definePlay(
163
+ ${JSON.stringify(input.wrapperName)},
164
+ async (ctx, input: Record<string, unknown> & { file: string }) => {
165
+ const rows = await ctx.csv<Record<string, unknown>>(input.file);
166
+ const constants = Object.fromEntries(
167
+ Object.entries(input).filter(([key]) => key !== 'file'),
168
+ );
169
+
170
+ const mappedRows = await ctx
171
+ .map('csv_rows', rows, {
172
+ key: (row, index) =>
173
+ String(
174
+ row.id ??
175
+ row.lead_id ??
176
+ row.email ??
177
+ row.linkedin_url ??
178
+ row.domain ??
179
+ index,
180
+ ),
181
+ })
182
+ .step('result', (row, rowCtx) =>
183
+ rowCtx.runPlay(
184
+ 'row_play',
185
+ ${JSON.stringify(input.playRef)},
186
+ {
187
+ ...constants,
188
+ ...row,
189
+ },
190
+ {
191
+ description: 'Run the source play for this CSV row.',
192
+ },
193
+ ),
194
+ )
195
+ .run({ description: 'Run the source play once per CSV row.' });
196
+
197
+ return { rows: mappedRows };
198
+ },
199
+ );
200
+ `;
201
+ }
202
+
203
+ function writeGeneratedCsvWrapperPlay(playRef: string): string {
204
+ const baseName = sanitizeGeneratedPlayName(
205
+ parseReferencedPlayTarget(playRef).unqualifiedPlayName,
206
+ );
207
+ const wrapperName = `${baseName}-csv`;
208
+ const outputDir = resolve('.deepline', 'generated');
209
+ const outputPath = join(outputDir, `${wrapperName}.play.ts`);
210
+ mkdirSync(outputDir, { recursive: true });
211
+ writeFileSync(
212
+ outputPath,
213
+ buildGeneratedCsvWrapperSource({ wrapperName, playRef }),
214
+ 'utf-8',
215
+ );
216
+ return outputPath;
217
+ }
218
+
143
219
  type MaterializedRemotePlaySource = {
144
220
  path: string;
145
221
  status: 'created' | 'updated' | 'unchanged';
@@ -2184,6 +2260,22 @@ async function handleNamedRun(options: PlayRunCommandOptions): Promise<number> {
2184
2260
  waitTimeoutMs: options.waitTimeoutMs,
2185
2261
  progress,
2186
2262
  });
2263
+ if (finalStatus.status !== 'completed' && options.csvPath) {
2264
+ progress.phase('generating csv wrapper play');
2265
+ const generatedPlayPath = writeGeneratedCsvWrapperPlay(
2266
+ options.target.name,
2267
+ );
2268
+ progress.writeLogLine(
2269
+ `Generated CSV wrapper play: ${generatedPlayPath}`,
2270
+ );
2271
+ progress.phase('running generated csv wrapper play');
2272
+ return handleFileBackedRun({
2273
+ ...options,
2274
+ target: { kind: 'file', path: generatedPlayPath },
2275
+ revisionId: null,
2276
+ revisionSelector: null,
2277
+ });
2278
+ }
2187
2279
  const exportedPath = exportPlayStatusRows(finalStatus, options.outPath);
2188
2280
  if (finalStatus.status === 'completed') {
2189
2281
  progress.complete();
@@ -131,6 +131,7 @@ Output:
131
131
  ok: false,
132
132
  error: error instanceof Error ? error.message : String(error),
133
133
  });
134
+ progress?.fail();
134
135
  if (process.argv.includes('--json')) {
135
136
  printJsonError(error);
136
137
  } else if (error instanceof Error) {
@@ -1,2 +1,2 @@
1
- export const SDK_VERSION = "0.1.4";
1
+ export const SDK_VERSION = "0.1.7";
2
2
  export const SDK_API_CONTRACT = "2026-04-plays-v1";
@@ -165,6 +165,14 @@ function formatTypeScriptDiagnostic(diagnostic: ts.Diagnostic): string | null {
165
165
  return `${diagnostic.file.fileName}:${line + 1}:${character + 1} ${message}`;
166
166
  }
167
167
 
168
+ function resolveBundledTypeRoots(): string[] {
169
+ try {
170
+ return [dirname(dirname(playArtifactRequire.resolve('@types/node/package.json')))];
171
+ } catch {
172
+ return [];
173
+ }
174
+ }
175
+
168
176
  function typecheckPlaySource(
169
177
  input: SourceGraphAnalysis,
170
178
  adapter: PlayBundlingAdapter,
@@ -196,6 +204,7 @@ function typecheckPlaySource(
196
204
  allowJs: true,
197
205
  resolveJsonModule: true,
198
206
  types: ['node'],
207
+ typeRoots: resolveBundledTypeRoots(),
199
208
  });
200
209
  return ts
201
210
  .getPreEmitDiagnostics(program)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.4",
3
+ "version": "0.1.7",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,12 +44,14 @@
44
44
  "prepublishOnly": "tsup"
45
45
  },
46
46
  "dependencies": {
47
+ "@types/node": "^20.0.0",
48
+ "acorn": "^8.16.0",
49
+ "acorn-walk": "^8.3.5",
47
50
  "commander": "^14.0.3",
48
51
  "csv-parse": "^5.6.0",
49
52
  "csv-stringify": "^6.5.0",
50
53
  "esbuild": "^0.25.11",
51
- "typescript": "^5.9.3",
52
- "@types/node": "^20.0.0"
54
+ "typescript": "^5.9.3"
53
55
  },
54
56
  "devDependencies": {
55
57
  "tsup": "^8.0.0"