@delopay/sdk 0.165.0 → 0.167.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/README.md +2 -0
- package/dist/{chunk-CP5M5WR6.js → chunk-RWCROWXW.js} +491 -44
- package/dist/chunk-RWCROWXW.js.map +1 -0
- package/dist/index.cjs +489 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +283 -44
- package/dist/index.d.ts +283 -44
- package/dist/index.js +1 -1
- package/dist/internal.cjs +511 -54
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +77 -7
- package/dist/internal.d.ts +77 -7
- package/dist/internal.js +24 -12
- package/dist/internal.js.map +1 -1
- package/package.json +18 -17
- package/dist/chunk-CP5M5WR6.js.map +0 -1
package/README.md
CHANGED
|
@@ -403,6 +403,8 @@ try {
|
|
|
403
403
|
|
|
404
404
|
Network timeouts throw `DelopayError` with `code: 'TIMEOUT'`. Network failures throw with `code: 'NETWORK'`.
|
|
405
405
|
|
|
406
|
+
An export (`delopay.export.*`, `disputes.workspaceExport`) is held to the record count the server announces in `X-Delopay-Record-Count`: a file that arrives with a different number of records — or ends part-way through a line or a JSON document — throws with `code: 'EXPORT_INCOMPLETE'` (`err.data` is `{ expected_records, received_records }`) instead of resolving to a file that is missing rows. Pass `onProgress` in an export's options to follow the download, and `signal` to cancel it.
|
|
407
|
+
|
|
406
408
|
**Structured error context (`err.data`):** populated for a small set of codes that benefit from a machine-readable hint. Currently:
|
|
407
409
|
|
|
408
410
|
| `err.code` | `err.data` shape | Meaning |
|
|
@@ -938,6 +938,289 @@ var Customers = class {
|
|
|
938
938
|
}
|
|
939
939
|
};
|
|
940
940
|
|
|
941
|
+
// src/recordCounter.ts
|
|
942
|
+
var LF = 10;
|
|
943
|
+
var CR = 13;
|
|
944
|
+
var QUOTE = 34;
|
|
945
|
+
var BACKSLASH = 92;
|
|
946
|
+
var OPEN_BRACE = 123;
|
|
947
|
+
var CLOSE_BRACE = 125;
|
|
948
|
+
var OPEN_BRACKET = 91;
|
|
949
|
+
var CLOSE_BRACKET = 93;
|
|
950
|
+
var CsvRecordCounter = class {
|
|
951
|
+
constructor() {
|
|
952
|
+
this.inQuotes = false;
|
|
953
|
+
this.newlines = 0;
|
|
954
|
+
/** Whether anything but a line break has arrived since the last newline. */
|
|
955
|
+
this.lineHasContent = false;
|
|
956
|
+
}
|
|
957
|
+
push(chunk) {
|
|
958
|
+
let inQuotes = this.inQuotes;
|
|
959
|
+
let newlines = this.newlines;
|
|
960
|
+
let lineHasContent = this.lineHasContent;
|
|
961
|
+
for (const byte of chunk) {
|
|
962
|
+
if (byte === QUOTE) {
|
|
963
|
+
inQuotes = !inQuotes;
|
|
964
|
+
lineHasContent = true;
|
|
965
|
+
} else if (inQuotes) {
|
|
966
|
+
lineHasContent = true;
|
|
967
|
+
} else if (byte === LF) {
|
|
968
|
+
newlines++;
|
|
969
|
+
lineHasContent = false;
|
|
970
|
+
} else if (byte !== CR) {
|
|
971
|
+
lineHasContent = true;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
this.inQuotes = inQuotes;
|
|
975
|
+
this.newlines = newlines;
|
|
976
|
+
this.lineHasContent = lineHasContent;
|
|
977
|
+
}
|
|
978
|
+
get records() {
|
|
979
|
+
return Math.max(0, this.newlines - 1);
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* The export writer ends every line — the header and each record — with a
|
|
983
|
+
* newline, so a whole body ends on one, outside quotes. RFC 4180 lets a
|
|
984
|
+
* final line break be omitted, but these bodies never omit it, and without
|
|
985
|
+
* that rule a file cut part-way through its last unquoted field
|
|
986
|
+
* (`pay_1,12` of `pay_1,123`) would count as one more whole record and
|
|
987
|
+
* match the figure it was announced with.
|
|
988
|
+
*/
|
|
989
|
+
get complete() {
|
|
990
|
+
return this.newlines >= 1 && !this.inQuotes && !this.lineHasContent;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* The records that ended. An unterminated tail is not one of them — see
|
|
994
|
+
* {@link complete}.
|
|
995
|
+
*/
|
|
996
|
+
finish() {
|
|
997
|
+
return this.records;
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
var SEEKING = 0;
|
|
1001
|
+
var COUNTING = 1;
|
|
1002
|
+
var CLOSED = 2;
|
|
1003
|
+
var JsonArrayRecordCounter = class {
|
|
1004
|
+
constructor() {
|
|
1005
|
+
this.depth = 0;
|
|
1006
|
+
this.inString = false;
|
|
1007
|
+
this.escaped = false;
|
|
1008
|
+
this.topIsObject = false;
|
|
1009
|
+
this.state = SEEKING;
|
|
1010
|
+
this.count = 0;
|
|
1011
|
+
}
|
|
1012
|
+
push(chunk) {
|
|
1013
|
+
if (this.state === CLOSED) return;
|
|
1014
|
+
let { depth, inString, escaped, topIsObject, count } = this;
|
|
1015
|
+
let state = this.state;
|
|
1016
|
+
for (const byte of chunk) {
|
|
1017
|
+
if (inString) {
|
|
1018
|
+
if (escaped) escaped = false;
|
|
1019
|
+
else if (byte === BACKSLASH) escaped = true;
|
|
1020
|
+
else if (byte === QUOTE) inString = false;
|
|
1021
|
+
continue;
|
|
1022
|
+
}
|
|
1023
|
+
if (byte === QUOTE) {
|
|
1024
|
+
inString = true;
|
|
1025
|
+
} else if (byte === OPEN_BRACE || byte === OPEN_BRACKET) {
|
|
1026
|
+
if (depth === 0 && byte === OPEN_BRACE) topIsObject = true;
|
|
1027
|
+
if (byte === OPEN_BRACKET && depth === 1 && topIsObject && state === SEEKING) {
|
|
1028
|
+
state = COUNTING;
|
|
1029
|
+
}
|
|
1030
|
+
depth++;
|
|
1031
|
+
} else if (byte === CLOSE_BRACE || byte === CLOSE_BRACKET) {
|
|
1032
|
+
depth--;
|
|
1033
|
+
if (state === COUNTING) {
|
|
1034
|
+
if (depth === 2) count++;
|
|
1035
|
+
else if (depth === 1) {
|
|
1036
|
+
state = CLOSED;
|
|
1037
|
+
break;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
this.depth = depth;
|
|
1043
|
+
this.inString = inString;
|
|
1044
|
+
this.escaped = escaped;
|
|
1045
|
+
this.topIsObject = topIsObject;
|
|
1046
|
+
this.state = state;
|
|
1047
|
+
this.count = count;
|
|
1048
|
+
}
|
|
1049
|
+
get records() {
|
|
1050
|
+
return this.count;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Whether the rows array has closed. What follows it is checked by parsing
|
|
1054
|
+
* the whole document, which a cut-off body fails.
|
|
1055
|
+
*/
|
|
1056
|
+
get complete() {
|
|
1057
|
+
return this.state === CLOSED;
|
|
1058
|
+
}
|
|
1059
|
+
finish() {
|
|
1060
|
+
return this.count;
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
// src/exportDownload.ts
|
|
1065
|
+
var RECORD_COUNT_HEADER = "x-delopay-record-count";
|
|
1066
|
+
var LIST_ENVELOPE = { rows: "records", count: "record_count" };
|
|
1067
|
+
var WORKSPACE_ENVELOPE = { rows: "data", count: "total_count" };
|
|
1068
|
+
function parseRecordCount(header) {
|
|
1069
|
+
if (header === null) return null;
|
|
1070
|
+
const trimmed = header.trim();
|
|
1071
|
+
if (!/^\d+$/.test(trimmed)) return null;
|
|
1072
|
+
const value = Number(trimmed);
|
|
1073
|
+
return Number.isSafeInteger(value) ? value : null;
|
|
1074
|
+
}
|
|
1075
|
+
function counterFor(format) {
|
|
1076
|
+
if (format === "csv") return new CsvRecordCounter();
|
|
1077
|
+
if (format === "json") return new JsonArrayRecordCounter();
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1080
|
+
function isRecord(value) {
|
|
1081
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1082
|
+
}
|
|
1083
|
+
function announced(expected) {
|
|
1084
|
+
return expected === null ? "" : ` of the ${expected} announced`;
|
|
1085
|
+
}
|
|
1086
|
+
function incomplete(message, expected, received, requestId) {
|
|
1087
|
+
return new DelopayError(message, {
|
|
1088
|
+
status: 0,
|
|
1089
|
+
code: "EXPORT_INCOMPLETE",
|
|
1090
|
+
type: "export_incomplete",
|
|
1091
|
+
...requestId !== void 0 ? { requestId } : {},
|
|
1092
|
+
data: { expected_records: expected, received_records: received }
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
async function downloadExport(request, call, options) {
|
|
1096
|
+
const { format } = call;
|
|
1097
|
+
const envelope = call.envelope ?? LIST_ENVELOPE;
|
|
1098
|
+
const onProgress = options?.onProgress;
|
|
1099
|
+
let latest = {
|
|
1100
|
+
phase: "preparing",
|
|
1101
|
+
receivedBytes: 0,
|
|
1102
|
+
totalBytes: null,
|
|
1103
|
+
receivedRecords: 0,
|
|
1104
|
+
expectedRecords: null
|
|
1105
|
+
};
|
|
1106
|
+
const seen = { attempt: -1, counter: null, expected: null, requestId: void 0, listenerError: null };
|
|
1107
|
+
const report = (progress) => {
|
|
1108
|
+
latest = progress;
|
|
1109
|
+
if (!onProgress) return;
|
|
1110
|
+
try {
|
|
1111
|
+
onProgress({ ...progress });
|
|
1112
|
+
} catch (error) {
|
|
1113
|
+
seen.listenerError = { error };
|
|
1114
|
+
throw error;
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
report(latest);
|
|
1118
|
+
const onDownloadProgress = (event) => {
|
|
1119
|
+
if (event.attempt !== seen.attempt) {
|
|
1120
|
+
seen.attempt = event.attempt;
|
|
1121
|
+
seen.counter = counterFor(format);
|
|
1122
|
+
seen.expected = format === "pdf" ? null : parseRecordCount(event.headers.get(RECORD_COUNT_HEADER));
|
|
1123
|
+
seen.requestId = event.headers.get("x-request-id") ?? event.headers.get("x-trace-id") ?? void 0;
|
|
1124
|
+
}
|
|
1125
|
+
if (event.chunk.byteLength > 0) seen.counter?.push(event.chunk);
|
|
1126
|
+
report({
|
|
1127
|
+
phase: "receiving",
|
|
1128
|
+
receivedBytes: event.loaded,
|
|
1129
|
+
totalBytes: event.total,
|
|
1130
|
+
receivedRecords: seen.counter?.records ?? 0,
|
|
1131
|
+
expectedRecords: seen.expected
|
|
1132
|
+
});
|
|
1133
|
+
};
|
|
1134
|
+
let result;
|
|
1135
|
+
try {
|
|
1136
|
+
result = await request(call.method, call.path, {
|
|
1137
|
+
...call.request,
|
|
1138
|
+
...options?.signal !== void 0 ? { signal: options.signal } : {},
|
|
1139
|
+
...options?.timeout !== void 0 ? { timeout: options.timeout } : {},
|
|
1140
|
+
onDownloadProgress
|
|
1141
|
+
});
|
|
1142
|
+
} catch (err) {
|
|
1143
|
+
if (seen.listenerError !== null && err === seen.listenerError.error) throw err;
|
|
1144
|
+
if (format === "json" && seen.attempt >= 0 && err instanceof SyntaxError) {
|
|
1145
|
+
const received2 = seen.counter?.records ?? 0;
|
|
1146
|
+
throw incomplete(
|
|
1147
|
+
seen.expected === null ? `Export incomplete: the body ended part-way through the JSON document, after ${received2} records` : `Export incomplete: the server announced ${seen.expected} records, and the body ended part-way through the JSON document after ${received2}`,
|
|
1148
|
+
seen.expected,
|
|
1149
|
+
received2,
|
|
1150
|
+
seen.requestId
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
throw err;
|
|
1154
|
+
}
|
|
1155
|
+
const { expected, requestId } = seen;
|
|
1156
|
+
let received = 0;
|
|
1157
|
+
if (format === "json") {
|
|
1158
|
+
const rows = isRecord(result) ? result[envelope.rows] : void 0;
|
|
1159
|
+
if (!Array.isArray(rows)) {
|
|
1160
|
+
throw incomplete(
|
|
1161
|
+
`Export incomplete: the body is not an export envelope with a "${envelope.rows}" array, so it carries 0 records${announced(expected)}`,
|
|
1162
|
+
expected,
|
|
1163
|
+
0,
|
|
1164
|
+
requestId
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
received = rows.length;
|
|
1168
|
+
const declared = isRecord(result) ? result[envelope.count] : void 0;
|
|
1169
|
+
if (typeof declared === "number" && declared !== rows.length) {
|
|
1170
|
+
throw incomplete(
|
|
1171
|
+
`Export incomplete: the file's ${envelope.count} is ${declared}, but it carries ${rows.length} records`,
|
|
1172
|
+
declared,
|
|
1173
|
+
rows.length,
|
|
1174
|
+
requestId
|
|
1175
|
+
);
|
|
1176
|
+
}
|
|
1177
|
+
} else if (format === "csv") {
|
|
1178
|
+
const counter = seen.counter;
|
|
1179
|
+
received = counter?.finish() ?? 0;
|
|
1180
|
+
if (!counter?.complete) {
|
|
1181
|
+
throw incomplete(
|
|
1182
|
+
`Export incomplete: the CSV body ended part-way through a line, after ${received} complete records${announced(expected)}`,
|
|
1183
|
+
expected,
|
|
1184
|
+
received,
|
|
1185
|
+
requestId
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
if (expected !== null && received !== expected) {
|
|
1190
|
+
throw incomplete(
|
|
1191
|
+
`Export incomplete: the server announced ${expected} records, and the body carried ${received}`,
|
|
1192
|
+
expected,
|
|
1193
|
+
received,
|
|
1194
|
+
requestId
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
report({
|
|
1198
|
+
phase: "done",
|
|
1199
|
+
receivedBytes: latest.receivedBytes,
|
|
1200
|
+
totalBytes: latest.totalBytes,
|
|
1201
|
+
receivedRecords: received,
|
|
1202
|
+
expectedRecords: expected
|
|
1203
|
+
});
|
|
1204
|
+
return result;
|
|
1205
|
+
}
|
|
1206
|
+
var ACCEPT = {
|
|
1207
|
+
csv: "text/csv",
|
|
1208
|
+
json: "application/json",
|
|
1209
|
+
pdf: "application/pdf"
|
|
1210
|
+
};
|
|
1211
|
+
function negotiated(options, format) {
|
|
1212
|
+
const headers = { ...options.headers, Accept: ACCEPT[format] };
|
|
1213
|
+
return format === "json" ? { ...options, headers } : { ...options, headers, responseType: "blob" };
|
|
1214
|
+
}
|
|
1215
|
+
function runExport(request, method, path, base, options) {
|
|
1216
|
+
const format = options?.format ?? "json";
|
|
1217
|
+
return downloadExport(
|
|
1218
|
+
request,
|
|
1219
|
+
{ method, path, request: negotiated(base, format), format },
|
|
1220
|
+
options
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
941
1224
|
// src/resources/disputes.ts
|
|
942
1225
|
function workspaceQuery(params) {
|
|
943
1226
|
if (!params) return void 0;
|
|
@@ -966,9 +1249,28 @@ var Disputes = class {
|
|
|
966
1249
|
async workspaceAggregate(params) {
|
|
967
1250
|
return this.request("GET", "/disputes/workspace/aggregate", { query: workspaceQuery(params) });
|
|
968
1251
|
}
|
|
969
|
-
/**
|
|
970
|
-
|
|
971
|
-
|
|
1252
|
+
/**
|
|
1253
|
+
* Export the complete filtered set, or throw on the server's explicit
|
|
1254
|
+
* export-limit refusal. `GET /disputes/workspace/export`
|
|
1255
|
+
*
|
|
1256
|
+
* The body is streamed, and held to the `X-Delopay-Record-Count` the server
|
|
1257
|
+
* announces and to its own `total_count`: a set that arrives short rejects
|
|
1258
|
+
* with `EXPORT_INCOMPLETE` rather than resolving. `options` reports the
|
|
1259
|
+
* download's progress and takes a signal and an idle timeout — see
|
|
1260
|
+
* {@link ExportTransferOptions}.
|
|
1261
|
+
*/
|
|
1262
|
+
async workspaceExport(params, options) {
|
|
1263
|
+
return downloadExport(
|
|
1264
|
+
this.request,
|
|
1265
|
+
{
|
|
1266
|
+
method: "GET",
|
|
1267
|
+
path: "/disputes/workspace/export",
|
|
1268
|
+
request: { query: workspaceQuery(params) },
|
|
1269
|
+
format: "json",
|
|
1270
|
+
envelope: WORKSPACE_ENVELOPE
|
|
1271
|
+
},
|
|
1272
|
+
options
|
|
1273
|
+
);
|
|
972
1274
|
}
|
|
973
1275
|
/**
|
|
974
1276
|
* Retrieve a dispute by its ID.
|
|
@@ -4125,77 +4427,68 @@ var Export = class {
|
|
|
4125
4427
|
this.request = request;
|
|
4126
4428
|
}
|
|
4127
4429
|
async transactions(params, options) {
|
|
4128
|
-
return this.request
|
|
4129
|
-
"POST",
|
|
4130
|
-
"/export/transactions",
|
|
4131
|
-
transactionBody(params, options)
|
|
4132
|
-
);
|
|
4430
|
+
return runExport(this.request, "POST", "/export/transactions", { body: params ?? {} }, options);
|
|
4133
4431
|
}
|
|
4134
4432
|
async transactionsForProfile(params, options) {
|
|
4135
|
-
return
|
|
4433
|
+
return runExport(
|
|
4434
|
+
this.request,
|
|
4136
4435
|
"POST",
|
|
4137
4436
|
"/export/profile/transactions",
|
|
4138
|
-
|
|
4437
|
+
{ body: params ?? {} },
|
|
4438
|
+
options
|
|
4139
4439
|
);
|
|
4140
4440
|
}
|
|
4141
4441
|
async refunds(params, options) {
|
|
4142
|
-
return this.request
|
|
4442
|
+
return runExport(this.request, "POST", "/refunds/list/export", { body: params ?? {} }, options);
|
|
4143
4443
|
}
|
|
4144
4444
|
async refundsForProfile(params, options) {
|
|
4145
|
-
return
|
|
4445
|
+
return runExport(
|
|
4446
|
+
this.request,
|
|
4146
4447
|
"POST",
|
|
4147
4448
|
"/refunds/profile/list/export",
|
|
4148
|
-
|
|
4449
|
+
{ body: params ?? {} },
|
|
4450
|
+
options
|
|
4149
4451
|
);
|
|
4150
4452
|
}
|
|
4151
4453
|
async disputes(params, options) {
|
|
4152
|
-
return this.request
|
|
4454
|
+
return runExport(this.request, "GET", "/disputes/list/export", queried(params), options);
|
|
4153
4455
|
}
|
|
4154
4456
|
async disputesForProfile(params, options) {
|
|
4155
|
-
return
|
|
4457
|
+
return runExport(
|
|
4458
|
+
this.request,
|
|
4156
4459
|
"GET",
|
|
4157
4460
|
"/disputes/profile/list/export",
|
|
4158
|
-
queried(params,
|
|
4461
|
+
queried(params),
|
|
4462
|
+
options
|
|
4159
4463
|
);
|
|
4160
4464
|
}
|
|
4161
4465
|
async payouts(params, options) {
|
|
4162
|
-
return this.request
|
|
4466
|
+
return runExport(this.request, "POST", "/payouts/list/export", { body: params }, options);
|
|
4163
4467
|
}
|
|
4164
4468
|
async payoutsForProfile(params, options) {
|
|
4165
|
-
return
|
|
4469
|
+
return runExport(
|
|
4470
|
+
this.request,
|
|
4471
|
+
"POST",
|
|
4472
|
+
"/payouts/profile/list/export",
|
|
4473
|
+
{ body: params },
|
|
4474
|
+
options
|
|
4475
|
+
);
|
|
4166
4476
|
}
|
|
4167
4477
|
async subscriptions(profileId, params, options) {
|
|
4168
|
-
return
|
|
4478
|
+
return runExport(
|
|
4479
|
+
this.request,
|
|
4169
4480
|
"GET",
|
|
4170
4481
|
"/subscriptions/list/export",
|
|
4171
|
-
queried(params,
|
|
4482
|
+
queried(params, { "X-Profile-Id": profileId }),
|
|
4483
|
+
options
|
|
4172
4484
|
);
|
|
4173
4485
|
}
|
|
4174
4486
|
async auditLog(params, options) {
|
|
4175
|
-
return this.request
|
|
4487
|
+
return runExport(this.request, "GET", "/audit/export", queried(params), options);
|
|
4176
4488
|
}
|
|
4177
4489
|
};
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
json: "application/json",
|
|
4181
|
-
pdf: "application/pdf"
|
|
4182
|
-
};
|
|
4183
|
-
function negotiated(options, format) {
|
|
4184
|
-
const headers = { ...options.headers, Accept: ACCEPT[format] };
|
|
4185
|
-
return format === "json" ? { ...options, headers } : { ...options, headers, responseType: "blob" };
|
|
4186
|
-
}
|
|
4187
|
-
function transactionBody(params, options) {
|
|
4188
|
-
const format = options?.format ?? "json";
|
|
4189
|
-
return negotiated({ body: { ...params, format } }, format);
|
|
4190
|
-
}
|
|
4191
|
-
function bodied(body, options) {
|
|
4192
|
-
return negotiated({ body }, options?.format ?? "json");
|
|
4193
|
-
}
|
|
4194
|
-
function queried(params, options, headers) {
|
|
4195
|
-
return negotiated(
|
|
4196
|
-
{ query: params ?? {}, ...headers ? { headers } : {} },
|
|
4197
|
-
options?.format ?? "json"
|
|
4198
|
-
);
|
|
4490
|
+
function queried(params, headers) {
|
|
4491
|
+
return { query: params ?? {}, ...headers ? { headers } : {} };
|
|
4199
4492
|
}
|
|
4200
4493
|
|
|
4201
4494
|
// src/resources/featureMatrix.ts
|
|
@@ -4479,6 +4772,24 @@ var ExternalRecords = class {
|
|
|
4479
4772
|
async create(params) {
|
|
4480
4773
|
return this.request("POST", "/external-records", { body: params });
|
|
4481
4774
|
}
|
|
4775
|
+
/**
|
|
4776
|
+
* What this deployment will accept, per kind.
|
|
4777
|
+
* `GET /external-records/capabilities`
|
|
4778
|
+
*
|
|
4779
|
+
* Read it before offering the operator a form. Every kind is listed, so an
|
|
4780
|
+
* entry that is not served is distinguishable from a kind this release does
|
|
4781
|
+
* not know at all — and `create` says *why* it is not served: a gap
|
|
4782
|
+
* (`not_implemented`) or a rule (`not_applicable`). Treating those as the
|
|
4783
|
+
* same thing is how a caller ends up waiting for something that will never
|
|
4784
|
+
* be built.
|
|
4785
|
+
*
|
|
4786
|
+
* The answer describes the binary rather than anything a merchant owns, so
|
|
4787
|
+
* it is the same for every caller of one deployment and is safe to cache for
|
|
4788
|
+
* the life of a dashboard session.
|
|
4789
|
+
*/
|
|
4790
|
+
async capabilities() {
|
|
4791
|
+
return this.request("GET", "/external-records/capabilities");
|
|
4792
|
+
}
|
|
4482
4793
|
};
|
|
4483
4794
|
|
|
4484
4795
|
// src/resources/products.ts
|
|
@@ -5568,6 +5879,112 @@ function findIdempotencyKey(headers) {
|
|
|
5568
5879
|
}
|
|
5569
5880
|
function noop() {
|
|
5570
5881
|
}
|
|
5882
|
+
var ListenerFailure = class {
|
|
5883
|
+
constructor(cause) {
|
|
5884
|
+
this.cause = cause;
|
|
5885
|
+
}
|
|
5886
|
+
};
|
|
5887
|
+
var BodyStreamFailure = class {
|
|
5888
|
+
constructor(cause) {
|
|
5889
|
+
this.cause = cause;
|
|
5890
|
+
}
|
|
5891
|
+
};
|
|
5892
|
+
function abortError() {
|
|
5893
|
+
const error = new Error("The operation was aborted");
|
|
5894
|
+
error.name = "AbortError";
|
|
5895
|
+
return error;
|
|
5896
|
+
}
|
|
5897
|
+
function parseContentLength(header) {
|
|
5898
|
+
if (header === null || !/^\s*\d+\s*$/.test(header)) return null;
|
|
5899
|
+
const value = Number(header);
|
|
5900
|
+
return Number.isSafeInteger(value) ? value : null;
|
|
5901
|
+
}
|
|
5902
|
+
function readChunk(reader, signal) {
|
|
5903
|
+
if (signal.aborted) return Promise.reject(abortError());
|
|
5904
|
+
return new Promise((resolve, reject) => {
|
|
5905
|
+
const onAbort = () => reject(abortError());
|
|
5906
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
5907
|
+
reader.read().then(
|
|
5908
|
+
(result) => {
|
|
5909
|
+
signal.removeEventListener("abort", onAbort);
|
|
5910
|
+
resolve(result);
|
|
5911
|
+
},
|
|
5912
|
+
(cause) => {
|
|
5913
|
+
signal.removeEventListener("abort", onAbort);
|
|
5914
|
+
reject(signal.aborted ? abortError() : new BodyStreamFailure(cause));
|
|
5915
|
+
}
|
|
5916
|
+
);
|
|
5917
|
+
});
|
|
5918
|
+
}
|
|
5919
|
+
function concatChunks(chunks, length) {
|
|
5920
|
+
const out = new Uint8Array(length);
|
|
5921
|
+
let offset = 0;
|
|
5922
|
+
for (const chunk of chunks) {
|
|
5923
|
+
out.set(chunk, offset);
|
|
5924
|
+
offset += chunk.byteLength;
|
|
5925
|
+
}
|
|
5926
|
+
return out.buffer;
|
|
5927
|
+
}
|
|
5928
|
+
async function receiveWithProgress(response, responseType, listener, attempt, signal, onActivity) {
|
|
5929
|
+
const headers = response.headers ?? new Headers();
|
|
5930
|
+
const total = parseContentLength(headers.get("content-length"));
|
|
5931
|
+
let loaded = 0;
|
|
5932
|
+
const notify = (chunk) => {
|
|
5933
|
+
try {
|
|
5934
|
+
listener({ loaded, total, chunk: chunk.slice(), headers, attempt });
|
|
5935
|
+
} catch (cause) {
|
|
5936
|
+
throw new ListenerFailure(cause);
|
|
5937
|
+
}
|
|
5938
|
+
};
|
|
5939
|
+
onActivity();
|
|
5940
|
+
notify(new Uint8Array(0));
|
|
5941
|
+
const body = response.body;
|
|
5942
|
+
if (!body || typeof body.getReader !== "function") {
|
|
5943
|
+
if (responseType === "blob") {
|
|
5944
|
+
const blob = await response.blob();
|
|
5945
|
+
const bytes3 = new Uint8Array(await blob.arrayBuffer());
|
|
5946
|
+
loaded = bytes3.byteLength;
|
|
5947
|
+
if (loaded > 0) notify(bytes3);
|
|
5948
|
+
return blob;
|
|
5949
|
+
}
|
|
5950
|
+
if (responseType === "arraybuffer") {
|
|
5951
|
+
const buffer = await response.arrayBuffer();
|
|
5952
|
+
loaded = buffer.byteLength;
|
|
5953
|
+
if (loaded > 0) notify(new Uint8Array(buffer));
|
|
5954
|
+
return buffer;
|
|
5955
|
+
}
|
|
5956
|
+
const text2 = await response.text();
|
|
5957
|
+
const bytes2 = new TextEncoder().encode(text2);
|
|
5958
|
+
loaded = bytes2.byteLength;
|
|
5959
|
+
if (loaded > 0) notify(bytes2);
|
|
5960
|
+
return text2 ? JSON.parse(text2) : void 0;
|
|
5961
|
+
}
|
|
5962
|
+
const reader = body.getReader();
|
|
5963
|
+
const chunks = [];
|
|
5964
|
+
try {
|
|
5965
|
+
for (; ; ) {
|
|
5966
|
+
const { done, value } = await readChunk(reader, signal);
|
|
5967
|
+
if (done) break;
|
|
5968
|
+
if (!value || value.byteLength === 0) continue;
|
|
5969
|
+
chunks.push(value);
|
|
5970
|
+
loaded += value.byteLength;
|
|
5971
|
+
onActivity();
|
|
5972
|
+
notify(value);
|
|
5973
|
+
}
|
|
5974
|
+
} catch (err) {
|
|
5975
|
+
reader.cancel().catch(noop);
|
|
5976
|
+
throw err;
|
|
5977
|
+
}
|
|
5978
|
+
const bytes = concatChunks(chunks, loaded);
|
|
5979
|
+
if (responseType === "blob") {
|
|
5980
|
+
return new Blob([bytes], { type: headers.get("content-type") ?? "" });
|
|
5981
|
+
}
|
|
5982
|
+
if (responseType === "arraybuffer") {
|
|
5983
|
+
return bytes;
|
|
5984
|
+
}
|
|
5985
|
+
const text = new TextDecoder().decode(bytes);
|
|
5986
|
+
return text ? JSON.parse(text) : void 0;
|
|
5987
|
+
}
|
|
5571
5988
|
function combineSignals(signals) {
|
|
5572
5989
|
const controller = new AbortController();
|
|
5573
5990
|
const listeners = [];
|
|
@@ -5849,7 +6266,12 @@ var Delopay = class {
|
|
|
5849
6266
|
emit("retry", { attempt, maxRetries: this.maxRetries, method, path });
|
|
5850
6267
|
}
|
|
5851
6268
|
const timeoutCtrl = new AbortController();
|
|
5852
|
-
|
|
6269
|
+
let timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);
|
|
6270
|
+
const restartIdleTimer = () => {
|
|
6271
|
+
if (timeoutCtrl.signal.aborted) return;
|
|
6272
|
+
clearTimeout(timeoutId);
|
|
6273
|
+
timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);
|
|
6274
|
+
};
|
|
5853
6275
|
const combined = combineSignals(
|
|
5854
6276
|
callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal]
|
|
5855
6277
|
);
|
|
@@ -5907,6 +6329,16 @@ var Delopay = class {
|
|
|
5907
6329
|
}
|
|
5908
6330
|
throw error;
|
|
5909
6331
|
}
|
|
6332
|
+
if (options?.onDownloadProgress) {
|
|
6333
|
+
return await receiveWithProgress(
|
|
6334
|
+
response,
|
|
6335
|
+
options.responseType,
|
|
6336
|
+
options.onDownloadProgress,
|
|
6337
|
+
attempt,
|
|
6338
|
+
combined.signal,
|
|
6339
|
+
restartIdleTimer
|
|
6340
|
+
);
|
|
6341
|
+
}
|
|
5910
6342
|
if (options?.responseType === "blob") {
|
|
5911
6343
|
return await response.blob();
|
|
5912
6344
|
}
|
|
@@ -5919,6 +6351,20 @@ var Delopay = class {
|
|
|
5919
6351
|
if (err instanceof DelopayError || err instanceof DelopayAuthenticationError) {
|
|
5920
6352
|
throw err;
|
|
5921
6353
|
}
|
|
6354
|
+
if (err instanceof ListenerFailure) {
|
|
6355
|
+
throw err.cause;
|
|
6356
|
+
}
|
|
6357
|
+
if (err instanceof BodyStreamFailure) {
|
|
6358
|
+
const cause = err.cause;
|
|
6359
|
+
const detail = cause instanceof Error ? cause.message : String(cause ?? "body stream failed");
|
|
6360
|
+
lastError = new DelopayError(`Network error: ${detail}`, {
|
|
6361
|
+
status: 0,
|
|
6362
|
+
code: "NETWORK",
|
|
6363
|
+
type: "network_error"
|
|
6364
|
+
});
|
|
6365
|
+
if (isRetryable && attempt < this.maxRetries) continue;
|
|
6366
|
+
throw lastError;
|
|
6367
|
+
}
|
|
5922
6368
|
if (err instanceof Error && err.name === "AbortError") {
|
|
5923
6369
|
if (callerSignal?.aborted) {
|
|
5924
6370
|
throw new DelopayError("Request aborted", {
|
|
@@ -9510,6 +9956,7 @@ var encodeNativePanes = encodePanes;
|
|
|
9510
9956
|
export {
|
|
9511
9957
|
DelopayError,
|
|
9512
9958
|
DelopayAuthenticationError,
|
|
9959
|
+
runExport,
|
|
9513
9960
|
PaypalDisputes,
|
|
9514
9961
|
Search,
|
|
9515
9962
|
isSubscriptionLifecycleWebhook,
|
|
@@ -9725,4 +10172,4 @@ export {
|
|
|
9725
10172
|
decodeNativePanes,
|
|
9726
10173
|
encodeNativePanes
|
|
9727
10174
|
};
|
|
9728
|
-
//# sourceMappingURL=chunk-
|
|
10175
|
+
//# sourceMappingURL=chunk-RWCROWXW.js.map
|