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 +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/repo/apps/play-runner-workers/src/entry.ts +90 -4
- package/dist/repo/sdk/src/version.ts +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
package/dist/cli/index.mjs
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -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(
|
|
4439
|
-
|
|
4440
|
-
|
|
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.
|
|
1
|
+
export const SDK_VERSION = "0.1.51";
|
|
2
2
|
export const SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
|