deepline 0.1.59 → 0.1.60

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
@@ -220,10 +220,10 @@ function resolveConfig(options) {
220
220
 
221
221
  // src/release.ts
222
222
  var SDK_RELEASE = {
223
- version: "0.1.59",
223
+ version: "0.1.60",
224
224
  apiContract: "2026-05-play-bootstrap-dataset-summary",
225
225
  supportPolicy: {
226
- latest: "0.1.59",
226
+ latest: "0.1.60",
227
227
  minimumSupported: "0.1.53",
228
228
  deprecatedBelow: "0.1.53"
229
229
  }
@@ -197,10 +197,10 @@ function resolveConfig(options) {
197
197
 
198
198
  // src/release.ts
199
199
  var SDK_RELEASE = {
200
- version: "0.1.59",
200
+ version: "0.1.60",
201
201
  apiContract: "2026-05-play-bootstrap-dataset-summary",
202
202
  supportPolicy: {
203
- latest: "0.1.59",
203
+ latest: "0.1.60",
204
204
  minimumSupported: "0.1.53",
205
205
  deprecatedBelow: "0.1.53"
206
206
  }
package/dist/index.d.mts CHANGED
@@ -1803,6 +1803,10 @@ type PlayDatasetWorkProgressSummary = {
1803
1803
  };
1804
1804
  };
1805
1805
  type PlayDatasetInput<T> = ReadonlyArray<T> | Iterable<T> | AsyncIterable<T> | PlayDataset<T>;
1806
+ type PlayDatasetTransformOptions = {
1807
+ key?: string;
1808
+ sourceLabel?: string | null;
1809
+ };
1806
1810
  /**
1807
1811
  * Durable handle for rows produced by `ctx.csv(...)` or `ctx.map(...).run()`.
1808
1812
  *
@@ -1832,6 +1836,10 @@ interface PlayDataset<T> extends AsyncIterable<T> {
1832
1836
  count(): Promise<number>;
1833
1837
  /** Preview rows. */
1834
1838
  peek(limit?: number): Promise<T[]>;
1839
+ map<U>(mapper: (row: T, index: number) => U | Promise<U>, options?: PlayDatasetTransformOptions): PlayDataset<U>;
1840
+ filter(predicate: (row: T, index: number) => boolean | Promise<boolean>, options?: PlayDatasetTransformOptions): PlayDataset<T>;
1841
+ slice(start?: number, end?: number, options?: PlayDatasetTransformOptions): PlayDataset<T>;
1842
+ take(limit: number, options?: PlayDatasetTransformOptions): PlayDataset<T>;
1835
1843
  /**
1836
1844
  * Explicit escape hatch for bounded result sets.
1837
1845
  * Large datasets should flow by handle through Neon-backed storage, not
package/dist/index.d.ts CHANGED
@@ -1803,6 +1803,10 @@ type PlayDatasetWorkProgressSummary = {
1803
1803
  };
1804
1804
  };
1805
1805
  type PlayDatasetInput<T> = ReadonlyArray<T> | Iterable<T> | AsyncIterable<T> | PlayDataset<T>;
1806
+ type PlayDatasetTransformOptions = {
1807
+ key?: string;
1808
+ sourceLabel?: string | null;
1809
+ };
1806
1810
  /**
1807
1811
  * Durable handle for rows produced by `ctx.csv(...)` or `ctx.map(...).run()`.
1808
1812
  *
@@ -1832,6 +1836,10 @@ interface PlayDataset<T> extends AsyncIterable<T> {
1832
1836
  count(): Promise<number>;
1833
1837
  /** Preview rows. */
1834
1838
  peek(limit?: number): Promise<T[]>;
1839
+ map<U>(mapper: (row: T, index: number) => U | Promise<U>, options?: PlayDatasetTransformOptions): PlayDataset<U>;
1840
+ filter(predicate: (row: T, index: number) => boolean | Promise<boolean>, options?: PlayDatasetTransformOptions): PlayDataset<T>;
1841
+ slice(start?: number, end?: number, options?: PlayDatasetTransformOptions): PlayDataset<T>;
1842
+ take(limit: number, options?: PlayDatasetTransformOptions): PlayDataset<T>;
1835
1843
  /**
1836
1844
  * Explicit escape hatch for bounded result sets.
1837
1845
  * Large datasets should flow by handle through Neon-backed storage, not
package/dist/index.js CHANGED
@@ -232,10 +232,10 @@ function resolveConfig(options) {
232
232
 
233
233
  // src/release.ts
234
234
  var SDK_RELEASE = {
235
- version: "0.1.59",
235
+ version: "0.1.60",
236
236
  apiContract: "2026-05-play-bootstrap-dataset-summary",
237
237
  supportPolicy: {
238
- latest: "0.1.59",
238
+ latest: "0.1.60",
239
239
  minimumSupported: "0.1.53",
240
240
  deprecatedBelow: "0.1.53"
241
241
  }
package/dist/index.mjs CHANGED
@@ -170,10 +170,10 @@ function resolveConfig(options) {
170
170
 
171
171
  // src/release.ts
172
172
  var SDK_RELEASE = {
173
- version: "0.1.59",
173
+ version: "0.1.60",
174
174
  apiContract: "2026-05-play-bootstrap-dataset-summary",
175
175
  supportPolicy: {
176
- latest: "0.1.59",
176
+ latest: "0.1.60",
177
177
  minimumSupported: "0.1.53",
178
178
  deprecatedBelow: "0.1.53"
179
179
  }
@@ -50,10 +50,10 @@ export type SdkRelease = {
50
50
  };
51
51
 
52
52
  export const SDK_RELEASE = {
53
- version: '0.1.59',
53
+ version: '0.1.60',
54
54
  apiContract: '2026-05-play-bootstrap-dataset-summary',
55
55
  supportPolicy: {
56
- latest: '0.1.59',
56
+ latest: '0.1.60',
57
57
  minimumSupported: '0.1.53',
58
58
  deprecatedBelow: '0.1.53',
59
59
  },
@@ -55,6 +55,11 @@ export type PlayDatasetInput<T> =
55
55
  | AsyncIterable<T>
56
56
  | PlayDataset<T>;
57
57
 
58
+ export type PlayDatasetTransformOptions = {
59
+ key?: string;
60
+ sourceLabel?: string | null;
61
+ };
62
+
58
63
  /**
59
64
  * Durable handle for rows produced by `ctx.csv(...)` or `ctx.map(...).run()`.
60
65
  *
@@ -84,6 +89,20 @@ export interface PlayDataset<T> extends AsyncIterable<T> {
84
89
  count(): Promise<number>;
85
90
  /** Preview rows. */
86
91
  peek(limit?: number): Promise<T[]>;
92
+ map<U>(
93
+ mapper: (row: T, index: number) => U | Promise<U>,
94
+ options?: PlayDatasetTransformOptions,
95
+ ): PlayDataset<U>;
96
+ filter(
97
+ predicate: (row: T, index: number) => boolean | Promise<boolean>,
98
+ options?: PlayDatasetTransformOptions,
99
+ ): PlayDataset<T>;
100
+ slice(
101
+ start?: number,
102
+ end?: number,
103
+ options?: PlayDatasetTransformOptions,
104
+ ): PlayDataset<T>;
105
+ take(limit: number, options?: PlayDatasetTransformOptions): PlayDataset<T>;
87
106
  /**
88
107
  * Explicit escape hatch for bounded result sets.
89
108
  * Large datasets should flow by handle through Neon-backed storage, not
@@ -113,6 +132,21 @@ type PlayDatasetResolvers<T> = {
113
132
  iterate: () => AsyncIterable<T>;
114
133
  };
115
134
 
135
+ type PlayDatasetTransform<T, U = T> =
136
+ | {
137
+ kind: 'map';
138
+ mapper: (row: T, index: number) => U | Promise<U>;
139
+ }
140
+ | {
141
+ kind: 'filter';
142
+ predicate: (row: T, index: number) => boolean | Promise<boolean>;
143
+ }
144
+ | {
145
+ kind: 'slice';
146
+ start?: number;
147
+ end?: number;
148
+ };
149
+
116
150
  function resolveMaterializeLimitCap(): number {
117
151
  const raw = process.env.DEEPLINE_PLAY_DATASET_MATERIALIZE_LIMIT;
118
152
  const parsed = raw ? Number(raw) : NaN;
@@ -216,6 +250,40 @@ class DeferredPlayDataset<T> implements PlayDataset<T> {
216
250
  return await this.resolvers.peek(limit);
217
251
  }
218
252
 
253
+ map<U>(
254
+ mapper: (row: T, index: number) => U | Promise<U>,
255
+ options?: PlayDatasetTransformOptions,
256
+ ): PlayDataset<U> {
257
+ return createTransformedPlayDataset(this, { kind: 'map', mapper }, options);
258
+ }
259
+
260
+ filter(
261
+ predicate: (row: T, index: number) => boolean | Promise<boolean>,
262
+ options?: PlayDatasetTransformOptions,
263
+ ): PlayDataset<T> {
264
+ return createTransformedPlayDataset(
265
+ this,
266
+ { kind: 'filter', predicate },
267
+ options,
268
+ );
269
+ }
270
+
271
+ slice(
272
+ start?: number,
273
+ end?: number,
274
+ options?: PlayDatasetTransformOptions,
275
+ ): PlayDataset<T> {
276
+ return createTransformedPlayDataset(
277
+ this,
278
+ { kind: 'slice', start, end },
279
+ options,
280
+ );
281
+ }
282
+
283
+ take(limit: number, options?: PlayDatasetTransformOptions): PlayDataset<T> {
284
+ return this.slice(0, limit, options);
285
+ }
286
+
219
287
  async materialize(limit?: number): Promise<T[]> {
220
288
  const requestedLimit =
221
289
  limit !== undefined ? Math.max(0, Math.floor(limit)) : undefined;
@@ -268,6 +336,136 @@ class DeferredPlayDataset<T> implements PlayDataset<T> {
268
336
  }
269
337
  }
270
338
 
339
+ function normalizeSliceBounds(input: {
340
+ start?: number;
341
+ end?: number;
342
+ count: number;
343
+ }): { start: number; end: number } {
344
+ const count = Math.max(0, Math.floor(input.count));
345
+ const rawStart = input.start ?? 0;
346
+ const rawEnd = input.end ?? count;
347
+ const startInteger = Number.isFinite(rawStart) ? Math.trunc(rawStart) : 0;
348
+ const endInteger = Number.isFinite(rawEnd) ? Math.trunc(rawEnd) : count;
349
+ const start =
350
+ startInteger < 0
351
+ ? Math.max(count + startInteger, 0)
352
+ : Math.min(startInteger, count);
353
+ const end =
354
+ endInteger < 0
355
+ ? Math.max(count + endInteger, 0)
356
+ : Math.min(endInteger, count);
357
+ return { start, end: Math.max(start, end) };
358
+ }
359
+
360
+ function transformDatasetId(input: {
361
+ source: PlayDataset<unknown>;
362
+ kind: string;
363
+ key?: string;
364
+ }): string {
365
+ const key = input.key?.trim();
366
+ return key
367
+ ? `${input.source.datasetId}:${input.kind}:${key}`
368
+ : `${input.source.datasetId}:${input.kind}`;
369
+ }
370
+
371
+ function createTransformedPlayDataset<T, U>(
372
+ source: PlayDataset<T>,
373
+ transform: PlayDatasetTransform<T, U>,
374
+ options?: PlayDatasetTransformOptions,
375
+ ): PlayDataset<U> {
376
+ const sourceLabel =
377
+ options?.sourceLabel ??
378
+ `${source.sourceLabel ?? source.tableNamespace ?? source.datasetId}.${transform.kind}`;
379
+
380
+ const iterate = async function* (): AsyncIterable<U> {
381
+ if (transform.kind === 'slice') {
382
+ const bounds = normalizeSliceBounds({
383
+ start: transform.start,
384
+ end: transform.end,
385
+ count: await source.count(),
386
+ });
387
+ let index = 0;
388
+ for await (const row of source) {
389
+ if (index >= bounds.end) break;
390
+ if (index >= bounds.start) {
391
+ yield row as unknown as U;
392
+ }
393
+ index += 1;
394
+ }
395
+ return;
396
+ }
397
+
398
+ let inputIndex = 0;
399
+ let outputIndex = 0;
400
+ for await (const row of source) {
401
+ if (transform.kind === 'filter') {
402
+ if (await transform.predicate(row, inputIndex)) {
403
+ yield row as unknown as U;
404
+ outputIndex += 1;
405
+ }
406
+ } else {
407
+ yield await transform.mapper(row, outputIndex);
408
+ outputIndex += 1;
409
+ }
410
+ inputIndex += 1;
411
+ }
412
+ };
413
+
414
+ const collect = async (limit?: number): Promise<U[]> => {
415
+ const rows: U[] = [];
416
+ const boundedLimit =
417
+ limit === undefined ? undefined : Math.max(0, Math.floor(limit));
418
+ if (boundedLimit === 0) return rows;
419
+ for await (const row of iterate()) {
420
+ rows.push(row);
421
+ if (boundedLimit !== undefined && rows.length >= boundedLimit) break;
422
+ }
423
+ return rows;
424
+ };
425
+
426
+ const count = async (): Promise<number> => {
427
+ if (transform.kind === 'map') return await source.count();
428
+ if (transform.kind === 'slice') {
429
+ const bounds = normalizeSliceBounds({
430
+ start: transform.start,
431
+ end: transform.end,
432
+ count: await source.count(),
433
+ });
434
+ return Math.max(0, bounds.end - bounds.start);
435
+ }
436
+ let total = 0;
437
+ for await (const _row of iterate()) {
438
+ void _row;
439
+ total += 1;
440
+ }
441
+ return total;
442
+ };
443
+
444
+ return createDeferredPlayDataset({
445
+ datasetKind: source.datasetKind,
446
+ datasetId: transformDatasetId({
447
+ source: source as PlayDataset<unknown>,
448
+ kind: transform.kind,
449
+ key: options?.key,
450
+ }),
451
+ count: 0,
452
+ backing: source.backing,
453
+ sourceLabel,
454
+ tableNamespace: options?.key ?? null,
455
+ resolvers: {
456
+ count,
457
+ peek: async (limit) => collect(limit),
458
+ materialize: async (limit) => collect(limit),
459
+ iterate: () =>
460
+ ({
461
+ async *[Symbol.asyncIterator]() {
462
+ yield* iterate();
463
+ },
464
+ }) as AsyncIterable<U>,
465
+ },
466
+ });
467
+ }
468
+
271
469
  export function createDeferredPlayDataset<T>(input: {
272
470
  datasetKind: PlayDatasetKind;
273
471
  datasetId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {