@delopay/sdk 0.167.0 → 0.169.0
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/{chunk-RWCROWXW.js → chunk-ZBNUOFNR.js} +29 -15
- package/dist/chunk-ZBNUOFNR.js.map +1 -0
- package/dist/index.cjs +28 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -2
- package/dist/index.d.ts +124 -2
- package/dist/index.js +1 -1
- package/dist/internal.cjs +28 -14
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-RWCROWXW.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1304,6 +1304,26 @@ var JsonArrayRecordCounter = class {
|
|
|
1304
1304
|
|
|
1305
1305
|
// src/exportDownload.ts
|
|
1306
1306
|
var RECORD_COUNT_HEADER = "x-delopay-record-count";
|
|
1307
|
+
var PRESENTATION_HEADER = "X-Delopay-Export-Presentation";
|
|
1308
|
+
var MAX_PRESENTATION_HEADER = 6 * 1024;
|
|
1309
|
+
function encodePresentation(presentation) {
|
|
1310
|
+
const bytes = new TextEncoder().encode(JSON.stringify(presentation));
|
|
1311
|
+
let binary = "";
|
|
1312
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
1313
|
+
const encoded = btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1314
|
+
if (encoded.length > MAX_PRESENTATION_HEADER) {
|
|
1315
|
+
throw new DelopayError(
|
|
1316
|
+
`Export presentation is ${encoded.length} bytes encoded; the server reads at most ${MAX_PRESENTATION_HEADER}`,
|
|
1317
|
+
{
|
|
1318
|
+
status: 0,
|
|
1319
|
+
code: "EXPORT_PRESENTATION_TOO_LARGE",
|
|
1320
|
+
type: "invalid_request",
|
|
1321
|
+
data: { encoded_length: encoded.length, max_length: MAX_PRESENTATION_HEADER }
|
|
1322
|
+
}
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
return encoded;
|
|
1326
|
+
}
|
|
1307
1327
|
var LIST_ENVELOPE = { rows: "records", count: "record_count" };
|
|
1308
1328
|
var WORKSPACE_ENVELOPE = { rows: "data", count: "total_count" };
|
|
1309
1329
|
function parseRecordCount(header) {
|
|
@@ -1449,15 +1469,18 @@ var ACCEPT = {
|
|
|
1449
1469
|
json: "application/json",
|
|
1450
1470
|
pdf: "application/pdf"
|
|
1451
1471
|
};
|
|
1452
|
-
function negotiated(options, format) {
|
|
1472
|
+
function negotiated(options, format, presentation) {
|
|
1453
1473
|
const headers = { ...options.headers, Accept: ACCEPT[format] };
|
|
1474
|
+
if (format === "pdf" && presentation !== void 0) {
|
|
1475
|
+
headers[PRESENTATION_HEADER] = encodePresentation(presentation);
|
|
1476
|
+
}
|
|
1454
1477
|
return format === "json" ? { ...options, headers } : { ...options, headers, responseType: "blob" };
|
|
1455
1478
|
}
|
|
1456
1479
|
function runExport(request, method, path, base, options) {
|
|
1457
1480
|
const format = options?.format ?? "json";
|
|
1458
1481
|
return downloadExport(
|
|
1459
1482
|
request,
|
|
1460
|
-
{ method, path, request: negotiated(base, format), format },
|
|
1483
|
+
{ method, path, request: negotiated(base, format, options?.presentation), format },
|
|
1461
1484
|
options
|
|
1462
1485
|
);
|
|
1463
1486
|
}
|
|
@@ -1490,24 +1513,15 @@ var Disputes = class {
|
|
|
1490
1513
|
async workspaceAggregate(params) {
|
|
1491
1514
|
return this.request("GET", "/disputes/workspace/aggregate", { query: workspaceQuery(params) });
|
|
1492
1515
|
}
|
|
1493
|
-
/**
|
|
1494
|
-
* Export the complete filtered set, or throw on the server's explicit
|
|
1495
|
-
* export-limit refusal. `GET /disputes/workspace/export`
|
|
1496
|
-
*
|
|
1497
|
-
* The body is streamed, and held to the `X-Delopay-Record-Count` the server
|
|
1498
|
-
* announces and to its own `total_count`: a set that arrives short rejects
|
|
1499
|
-
* with `EXPORT_INCOMPLETE` rather than resolving. `options` reports the
|
|
1500
|
-
* download's progress and takes a signal and an idle timeout — see
|
|
1501
|
-
* {@link ExportTransferOptions}.
|
|
1502
|
-
*/
|
|
1503
1516
|
async workspaceExport(params, options) {
|
|
1517
|
+
const format = options?.format ?? "json";
|
|
1504
1518
|
return downloadExport(
|
|
1505
1519
|
this.request,
|
|
1506
1520
|
{
|
|
1507
1521
|
method: "GET",
|
|
1508
1522
|
path: "/disputes/workspace/export",
|
|
1509
|
-
request: { query: workspaceQuery(params) },
|
|
1510
|
-
format
|
|
1523
|
+
request: negotiated({ query: workspaceQuery(params) }, format, options?.presentation),
|
|
1524
|
+
format,
|
|
1511
1525
|
envelope: WORKSPACE_ENVELOPE
|
|
1512
1526
|
},
|
|
1513
1527
|
options
|