deepline 0.1.50 → 0.1.51

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
@@ -219,7 +219,7 @@ function resolveConfig(options) {
219
219
  }
220
220
 
221
221
  // src/version.ts
222
- var SDK_VERSION = "0.1.50";
222
+ var SDK_VERSION = "0.1.51";
223
223
  var SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
224
224
 
225
225
  // ../shared_libs/play-runtime/coordinator-headers.ts
@@ -196,7 +196,7 @@ function resolveConfig(options) {
196
196
  }
197
197
 
198
198
  // src/version.ts
199
- var SDK_VERSION = "0.1.50";
199
+ var SDK_VERSION = "0.1.51";
200
200
  var SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
201
201
 
202
202
  // ../shared_libs/play-runtime/coordinator-headers.ts
package/dist/index.d.mts CHANGED
@@ -1541,7 +1541,7 @@ declare class DeeplineClient {
1541
1541
  }>;
1542
1542
  }
1543
1543
 
1544
- declare const SDK_VERSION = "0.1.50";
1544
+ declare const SDK_VERSION = "0.1.51";
1545
1545
  declare const SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
1546
1546
 
1547
1547
  /**
package/dist/index.d.ts CHANGED
@@ -1541,7 +1541,7 @@ declare class DeeplineClient {
1541
1541
  }>;
1542
1542
  }
1543
1543
 
1544
- declare const SDK_VERSION = "0.1.50";
1544
+ declare const SDK_VERSION = "0.1.51";
1545
1545
  declare const SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
1546
1546
 
1547
1547
  /**
package/dist/index.js CHANGED
@@ -215,7 +215,7 @@ function resolveConfig(options) {
215
215
  }
216
216
 
217
217
  // src/version.ts
218
- var SDK_VERSION = "0.1.50";
218
+ var SDK_VERSION = "0.1.51";
219
219
  var SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
220
220
 
221
221
  // ../shared_libs/play-runtime/coordinator-headers.ts
package/dist/index.mjs CHANGED
@@ -169,7 +169,7 @@ function resolveConfig(options) {
169
169
  }
170
170
 
171
171
  // src/version.ts
172
- var SDK_VERSION = "0.1.50";
172
+ var SDK_VERSION = "0.1.51";
173
173
  var SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
174
174
 
175
175
  // ../shared_libs/play-runtime/coordinator-headers.ts
@@ -2372,6 +2372,56 @@ function canonicalizeJson(value: unknown): string {
2372
2372
  return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalizeJson(obj[k])}`).join(',')}}`;
2373
2373
  }
2374
2374
 
2375
+ type WorkerFetchResponse = {
2376
+ ok: boolean;
2377
+ status: number;
2378
+ statusText: string;
2379
+ url: string;
2380
+ headers: Record<string, string>;
2381
+ bodyText: string;
2382
+ json: unknown | null;
2383
+ };
2384
+
2385
+ function normalizeFetchHeaders(
2386
+ headers: RequestInit['headers'],
2387
+ ): Record<string, string> {
2388
+ if (!headers) return {};
2389
+ if (headers instanceof Headers) {
2390
+ return Object.fromEntries(
2391
+ [...headers.entries()].map(([key, value]) => [key.toLowerCase(), value]),
2392
+ );
2393
+ }
2394
+ if (Array.isArray(headers)) {
2395
+ return Object.fromEntries(
2396
+ headers.map(([key, value]) => [key.toLowerCase(), value]),
2397
+ );
2398
+ }
2399
+ return Object.fromEntries(
2400
+ Object.entries(headers).map(([key, value]) => [
2401
+ key.toLowerCase(),
2402
+ String(value),
2403
+ ]),
2404
+ );
2405
+ }
2406
+
2407
+ function fetchBodyIdentity(body: RequestInit['body']): string | null {
2408
+ if (body === undefined || body === null) return null;
2409
+ if (typeof body === 'string') return body;
2410
+ if (body instanceof URLSearchParams) return body.toString();
2411
+ throw new Error(
2412
+ 'ctx.fetch(...) in the Workers backend only supports string or URLSearchParams request bodies for durable identity.',
2413
+ );
2414
+ }
2415
+
2416
+ function parseFetchJsonOrNull(bodyText: string): unknown | null {
2417
+ if (!bodyText.trim()) return null;
2418
+ try {
2419
+ return JSON.parse(bodyText) as unknown;
2420
+ } catch {
2421
+ return null;
2422
+ }
2423
+ }
2424
+
2375
2425
  // ---------------------------------------------------------------------------
2376
2426
  // Streaming CSV parser. Pipes a `ReadableStream<Uint8Array>` from R2 through
2377
2427
  // a TextDecoder + line buffer + RFC-4180-ish state machine, yielding chunks
@@ -4435,10 +4485,46 @@ function createMinimalWorkerCtx(
4435
4485
  }
4436
4486
  });
4437
4487
  },
4438
- fetch(): never {
4439
- throw new Error(
4440
- 'ctx.fetch is not implemented in the Workers backend yet.',
4441
- );
4488
+ async fetch(
4489
+ key: string,
4490
+ input: string | URL,
4491
+ init: RequestInit = {},
4492
+ options?: { staleAfterSeconds?: number },
4493
+ ): Promise<WorkerFetchResponse> {
4494
+ assertNotAborted(abortSignal);
4495
+ const normalizedKey = normalizeContextKey(key, 'fetch');
4496
+ const url = input.toString();
4497
+ const method = (init.method ?? 'GET').toUpperCase();
4498
+ const safeHeaders = normalizeFetchHeaders(init.headers);
4499
+ const body = fetchBodyIdentity(init.body);
4500
+ const hasIdempotencyKey =
4501
+ safeHeaders['idempotency-key'] !== undefined ||
4502
+ safeHeaders['x-idempotency-key'] !== undefined;
4503
+ if (method !== 'GET' && method !== 'HEAD' && !hasIdempotencyKey) {
4504
+ throw new Error(
4505
+ `ctx.fetch(${method} ${url}) needs an Idempotency-Key header. Durable plays can replay after waits/retries; add an idempotency key or wrap the side effect in a Deepline integration tool.`,
4506
+ );
4507
+ }
4508
+ const receiptKey = `fetch:${normalizedKey}:${await hashJson({
4509
+ body,
4510
+ method,
4511
+ safeHeaders,
4512
+ url,
4513
+ })}${staleRuntimeSuffix(options?.staleAfterSeconds)}`;
4514
+ return await executeWithRuntimeReceipt(receiptKey, async () => {
4515
+ const response = await fetch(url, init);
4516
+ assertNotAborted(abortSignal);
4517
+ const bodyText = await response.text();
4518
+ return {
4519
+ ok: response.ok,
4520
+ status: response.status,
4521
+ statusText: response.statusText,
4522
+ url: response.url,
4523
+ headers: Object.fromEntries(response.headers.entries()),
4524
+ bodyText,
4525
+ json: parseFetchJsonOrNull(bodyText),
4526
+ };
4527
+ });
4442
4528
  },
4443
4529
  async waitForEvent(
4444
4530
  eventType: string,
@@ -1,2 +1,2 @@
1
- export const SDK_VERSION = "0.1.50";
1
+ export const SDK_VERSION = "0.1.51";
2
2
  export const SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.50",
3
+ "version": "0.1.51",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {