@delopay/sdk 0.277.0 → 0.280.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-424242UX.js → chunk-3CHJT5YW.js} +611 -71
- package/dist/chunk-3CHJT5YW.js.map +1 -0
- package/dist/index-DmObtUEw.d.cts +29526 -0
- package/dist/index-DmObtUEw.d.ts +29526 -0
- package/dist/index.cjs +611 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -29117
- package/dist/index.d.ts +1 -29117
- package/dist/index.js +5 -1
- package/dist/internal.cjs +675 -70
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +45 -3
- package/dist/internal.d.ts +45 -3
- package/dist/internal.js +69 -1
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-424242UX.js.map +0 -1
package/dist/internal.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(internal_exports, {
|
|
|
36
36
|
APPLE_PAY_BUTTON_STYLES: () => APPLE_PAY_BUTTON_STYLES,
|
|
37
37
|
APPLE_PAY_BUTTON_TYPES: () => APPLE_PAY_BUTTON_TYPES,
|
|
38
38
|
Admin: () => Admin,
|
|
39
|
+
AdminLive: () => AdminLive,
|
|
39
40
|
AdminPortal: () => AdminPortal,
|
|
40
41
|
Analytics: () => Analytics,
|
|
41
42
|
AnalyticsDashboard: () => AnalyticsDashboard,
|
|
@@ -94,6 +95,8 @@ __export(internal_exports, {
|
|
|
94
95
|
InvoiceSettingsResource: () => InvoiceSettingsResource,
|
|
95
96
|
Invoices: () => Invoices,
|
|
96
97
|
LOCALIZABLE_COPY_FIELDS: () => LOCALIZABLE_COPY_FIELDS,
|
|
98
|
+
Live: () => Live,
|
|
99
|
+
LiveEventStream: () => LiveEventStream,
|
|
97
100
|
MAX_SECTION_LABEL_LENGTH: () => MAX_SECTION_LABEL_LENGTH,
|
|
98
101
|
MAX_SECTION_ORDER: () => MAX_SECTION_ORDER,
|
|
99
102
|
METHOD_SECTIONS: () => METHOD_SECTIONS,
|
|
@@ -324,6 +327,100 @@ var DelopayAuthenticationError = class extends DelopayError {
|
|
|
324
327
|
}
|
|
325
328
|
};
|
|
326
329
|
|
|
330
|
+
// src/eventStream.ts
|
|
331
|
+
var LF = 10;
|
|
332
|
+
var CR = 13;
|
|
333
|
+
var EventStreamParser = class {
|
|
334
|
+
/**
|
|
335
|
+
* @param lastEventId - The id the stream resumes after, as `EventSource`
|
|
336
|
+
* carries it into a reconnection: a dispatch before the server names an
|
|
337
|
+
* id keeps this one.
|
|
338
|
+
*/
|
|
339
|
+
constructor(lastEventId = "") {
|
|
340
|
+
this.line = "";
|
|
341
|
+
/** The previous chunk ended in CR: a LF opening the next one belongs to it. */
|
|
342
|
+
this.skipLf = false;
|
|
343
|
+
this.data = "";
|
|
344
|
+
this.hasData = false;
|
|
345
|
+
this.eventType = "";
|
|
346
|
+
this.retry = null;
|
|
347
|
+
this.idBuffer = lastEventId;
|
|
348
|
+
}
|
|
349
|
+
/** Feed the next piece of decoded text; returns the dispatches it completed. */
|
|
350
|
+
push(text) {
|
|
351
|
+
const out = [];
|
|
352
|
+
if (text.length === 0) return out;
|
|
353
|
+
let start = 0;
|
|
354
|
+
if (this.skipLf) {
|
|
355
|
+
this.skipLf = false;
|
|
356
|
+
if (text.charCodeAt(0) === LF) start = 1;
|
|
357
|
+
}
|
|
358
|
+
for (let i = start; i < text.length; i++) {
|
|
359
|
+
const c = text.charCodeAt(i);
|
|
360
|
+
if (c !== LF && c !== CR) continue;
|
|
361
|
+
const line = this.line + text.slice(start, i);
|
|
362
|
+
this.line = "";
|
|
363
|
+
this.processLine(line, out);
|
|
364
|
+
if (c === CR) {
|
|
365
|
+
if (i + 1 < text.length) {
|
|
366
|
+
if (text.charCodeAt(i + 1) === LF) i++;
|
|
367
|
+
} else {
|
|
368
|
+
this.skipLf = true;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
start = i + 1;
|
|
372
|
+
}
|
|
373
|
+
this.line += text.slice(start);
|
|
374
|
+
return out;
|
|
375
|
+
}
|
|
376
|
+
processLine(line, out) {
|
|
377
|
+
if (line === "") {
|
|
378
|
+
this.dispatch(out);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (line.charCodeAt(0) === 58) return;
|
|
382
|
+
const colon = line.indexOf(":");
|
|
383
|
+
let field;
|
|
384
|
+
let value;
|
|
385
|
+
if (colon === -1) {
|
|
386
|
+
field = line;
|
|
387
|
+
value = "";
|
|
388
|
+
} else {
|
|
389
|
+
field = line.slice(0, colon);
|
|
390
|
+
value = line.slice(colon + 1);
|
|
391
|
+
if (value.charCodeAt(0) === 32) value = value.slice(1);
|
|
392
|
+
}
|
|
393
|
+
switch (field) {
|
|
394
|
+
case "event":
|
|
395
|
+
this.eventType = value;
|
|
396
|
+
break;
|
|
397
|
+
case "data":
|
|
398
|
+
this.data = this.hasData ? `${this.data}
|
|
399
|
+
${value}` : value;
|
|
400
|
+
this.hasData = true;
|
|
401
|
+
break;
|
|
402
|
+
case "id":
|
|
403
|
+
if (!value.includes("\0")) this.idBuffer = value;
|
|
404
|
+
break;
|
|
405
|
+
case "retry":
|
|
406
|
+
if (/^[0-9]+$/.test(value)) {
|
|
407
|
+
const ms = Number(value);
|
|
408
|
+
if (Number.isSafeInteger(ms)) this.retry = ms;
|
|
409
|
+
}
|
|
410
|
+
break;
|
|
411
|
+
default:
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
dispatch(out) {
|
|
416
|
+
const event = this.hasData ? { type: this.eventType || "message", data: this.data } : null;
|
|
417
|
+
out.push({ lastEventId: this.idBuffer, retry: this.retry, event });
|
|
418
|
+
this.data = "";
|
|
419
|
+
this.hasData = false;
|
|
420
|
+
this.eventType = "";
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
|
|
327
424
|
// src/resources/apiKeys.ts
|
|
328
425
|
var ApiKeys = class {
|
|
329
426
|
constructor(request) {
|
|
@@ -1569,8 +1666,8 @@ var Customers = class {
|
|
|
1569
1666
|
};
|
|
1570
1667
|
|
|
1571
1668
|
// src/recordCounter.ts
|
|
1572
|
-
var
|
|
1573
|
-
var
|
|
1669
|
+
var LF2 = 10;
|
|
1670
|
+
var CR2 = 13;
|
|
1574
1671
|
var QUOTE = 34;
|
|
1575
1672
|
var BACKSLASH = 92;
|
|
1576
1673
|
var OPEN_BRACE = 123;
|
|
@@ -1594,10 +1691,10 @@ var CsvRecordCounter = class {
|
|
|
1594
1691
|
lineHasContent = true;
|
|
1595
1692
|
} else if (inQuotes) {
|
|
1596
1693
|
lineHasContent = true;
|
|
1597
|
-
} else if (byte ===
|
|
1694
|
+
} else if (byte === LF2) {
|
|
1598
1695
|
newlines++;
|
|
1599
1696
|
lineHasContent = false;
|
|
1600
|
-
} else if (byte !==
|
|
1697
|
+
} else if (byte !== CR2) {
|
|
1601
1698
|
lineHasContent = true;
|
|
1602
1699
|
}
|
|
1603
1700
|
}
|
|
@@ -5118,6 +5215,33 @@ var Users = class {
|
|
|
5118
5215
|
body: params
|
|
5119
5216
|
});
|
|
5120
5217
|
}
|
|
5218
|
+
/**
|
|
5219
|
+
* Which checkout payment methods a member may change in your merchant.
|
|
5220
|
+
* `GET /user/employees/{user_id}/method-access`
|
|
5221
|
+
*
|
|
5222
|
+
* Needs the *Users* read permission, and answers only for a member
|
|
5223
|
+
* `listUsersInLineage` shows you (any other id is a 404 `UR_68` with
|
|
5224
|
+
* `data.reason: 'member_not_found'`). `can_edit` says whether you may
|
|
5225
|
+
* change it; `grant_all` and `grantable` say which methods you may grant.
|
|
5226
|
+
*/
|
|
5227
|
+
async getMemberMethodAccess(userId) {
|
|
5228
|
+
return this.request("GET", `/user/employees/${encodeURIComponent(userId)}/method-access`);
|
|
5229
|
+
}
|
|
5230
|
+
/**
|
|
5231
|
+
* Limit a member to some checkout payment methods, or give every method
|
|
5232
|
+
* back. `PUT /user/employees/{user_id}/method-access`
|
|
5233
|
+
*
|
|
5234
|
+
* Needs the *Connectors* edit and *Payment methods* write permissions and a
|
|
5235
|
+
* member within your reach, other than yourself. A caller limited itself
|
|
5236
|
+
* grants only within its own limit. The change is audited and applies to
|
|
5237
|
+
* the member's next request. A refusal is a `UR_68` whose `data` is
|
|
5238
|
+
* `{ reason: 'method_access', refusal }` (see {@link MethodAccessRefusal}).
|
|
5239
|
+
*/
|
|
5240
|
+
async updateMemberMethodAccess(userId, params) {
|
|
5241
|
+
return this.request("PUT", `/user/employees/${encodeURIComponent(userId)}/method-access`, {
|
|
5242
|
+
body: params
|
|
5243
|
+
});
|
|
5244
|
+
}
|
|
5121
5245
|
/** Sign in via OIDC. `POST /user/oidc` */
|
|
5122
5246
|
async signInOidc(params) {
|
|
5123
5247
|
return this.request("POST", "/user/oidc", { body: params });
|
|
@@ -9131,6 +9255,133 @@ var Risk = class {
|
|
|
9131
9255
|
}
|
|
9132
9256
|
};
|
|
9133
9257
|
|
|
9258
|
+
// src/resources/live.ts
|
|
9259
|
+
function readField(data, key) {
|
|
9260
|
+
let value;
|
|
9261
|
+
try {
|
|
9262
|
+
value = JSON.parse(data);
|
|
9263
|
+
} catch {
|
|
9264
|
+
return void 0;
|
|
9265
|
+
}
|
|
9266
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
9267
|
+
return Object.getOwnPropertyDescriptor(value, key)?.value;
|
|
9268
|
+
}
|
|
9269
|
+
function toLiveStreamEvent(event, id, retry) {
|
|
9270
|
+
switch (event.type) {
|
|
9271
|
+
case "ready": {
|
|
9272
|
+
const resumed = readField(event.data, "resumed");
|
|
9273
|
+
return { type: "ready", id, retry, resumed: typeof resumed === "boolean" ? resumed : null };
|
|
9274
|
+
}
|
|
9275
|
+
case "change": {
|
|
9276
|
+
const changes = readField(event.data, "changes");
|
|
9277
|
+
if (!Array.isArray(changes)) return { type: "resync", id };
|
|
9278
|
+
return { type: "change", id, changes };
|
|
9279
|
+
}
|
|
9280
|
+
case "resync":
|
|
9281
|
+
return { type: "resync", id };
|
|
9282
|
+
default:
|
|
9283
|
+
return null;
|
|
9284
|
+
}
|
|
9285
|
+
}
|
|
9286
|
+
var LiveEventStream = class {
|
|
9287
|
+
constructor(connection, lastEventId = null) {
|
|
9288
|
+
this.connection = connection;
|
|
9289
|
+
this._retry = null;
|
|
9290
|
+
this._lastEventId = lastEventId || null;
|
|
9291
|
+
}
|
|
9292
|
+
/**
|
|
9293
|
+
* The position to resume after: the id of the last event read, advanced by
|
|
9294
|
+
* keepalives too. `null` before the server named one. Send it as
|
|
9295
|
+
* `lastEventId` when reconnecting.
|
|
9296
|
+
*/
|
|
9297
|
+
get lastEventId() {
|
|
9298
|
+
return this._lastEventId;
|
|
9299
|
+
}
|
|
9300
|
+
/** The wait before reconnecting the server asked for, in ms; `null` until it says. */
|
|
9301
|
+
get retry() {
|
|
9302
|
+
return this._retry;
|
|
9303
|
+
}
|
|
9304
|
+
/** Close the stream; the iteration ends without an error. */
|
|
9305
|
+
close() {
|
|
9306
|
+
this.connection.close();
|
|
9307
|
+
}
|
|
9308
|
+
[Symbol.asyncIterator]() {
|
|
9309
|
+
this.iterator ?? (this.iterator = this.events());
|
|
9310
|
+
return this.iterator;
|
|
9311
|
+
}
|
|
9312
|
+
async *events() {
|
|
9313
|
+
for await (const dispatch of this.connection.dispatches) {
|
|
9314
|
+
const event = this.read(dispatch);
|
|
9315
|
+
if (event) yield event;
|
|
9316
|
+
}
|
|
9317
|
+
}
|
|
9318
|
+
read(dispatch) {
|
|
9319
|
+
this._lastEventId = dispatch.lastEventId || null;
|
|
9320
|
+
if (dispatch.retry !== null) this._retry = dispatch.retry;
|
|
9321
|
+
if (!dispatch.event) return null;
|
|
9322
|
+
return toLiveStreamEvent(dispatch.event, this._lastEventId, this._retry);
|
|
9323
|
+
}
|
|
9324
|
+
};
|
|
9325
|
+
async function openLiveStream(openStream, path, options = {}) {
|
|
9326
|
+
const connection = await openStream(path, {
|
|
9327
|
+
...options.lastEventId ? { lastEventId: options.lastEventId } : {},
|
|
9328
|
+
...options.signal ? { signal: options.signal } : {},
|
|
9329
|
+
...options.idleTimeoutMs !== void 0 ? { idleTimeoutMs: options.idleTimeoutMs } : {},
|
|
9330
|
+
...options.headers ? { headers: options.headers } : {}
|
|
9331
|
+
});
|
|
9332
|
+
return new LiveEventStream(connection, options.lastEventId ?? null);
|
|
9333
|
+
}
|
|
9334
|
+
var Live = class {
|
|
9335
|
+
constructor(request, openStream) {
|
|
9336
|
+
this.request = request;
|
|
9337
|
+
this.openStream = openStream;
|
|
9338
|
+
}
|
|
9339
|
+
/**
|
|
9340
|
+
* Open the stream of what changed in the caller's merchant, as their role
|
|
9341
|
+
* may read it. Resolves once the server answered; a `401` rejects with
|
|
9342
|
+
* `DelopayAuthenticationError`.
|
|
9343
|
+
*
|
|
9344
|
+
* The first event is `ready`. `change` names the kinds of record and, when
|
|
9345
|
+
* few, the ids that changed: read them again through the usual endpoints.
|
|
9346
|
+
* `resync`, and `ready` with `resumed: false`, mean read everything again.
|
|
9347
|
+
* The SDK does not reconnect — see {@link LiveEventStream}.
|
|
9348
|
+
*
|
|
9349
|
+
* `GET /live/stream`
|
|
9350
|
+
*
|
|
9351
|
+
* @example
|
|
9352
|
+
* ```typescript
|
|
9353
|
+
* const stream = await delopay.live.stream({ lastEventId, signal });
|
|
9354
|
+
* for await (const event of stream) {
|
|
9355
|
+
* if (event.type === 'change') refresh(event.changes);
|
|
9356
|
+
* else if (event.type === 'resync' || event.resumed === false) refreshAll();
|
|
9357
|
+
* }
|
|
9358
|
+
* lastEventId = stream.lastEventId; // reconnect after stream.retry
|
|
9359
|
+
* ```
|
|
9360
|
+
*/
|
|
9361
|
+
async stream(options) {
|
|
9362
|
+
return openLiveStream(this.openStream, "/live/stream", options);
|
|
9363
|
+
}
|
|
9364
|
+
/**
|
|
9365
|
+
* The current version of each kind of record named, in the caller's
|
|
9366
|
+
* merchant and shop. Read it before the record and send the entry's
|
|
9367
|
+
* `if_match` in the `If-Match` header of the save: a save over a newer
|
|
9368
|
+
* version is refused with `IR_16` (400), `error.data` a
|
|
9369
|
+
* `LiveChangedElsewhere` naming who made the change.
|
|
9370
|
+
*
|
|
9371
|
+
* `GET /live/versions`
|
|
9372
|
+
*/
|
|
9373
|
+
async versions(params, options) {
|
|
9374
|
+
return this.request("GET", "/live/versions", {
|
|
9375
|
+
query: {
|
|
9376
|
+
entities: params.entities.join(","),
|
|
9377
|
+
profile_id: params.profile_id,
|
|
9378
|
+
record_id: params.record_id
|
|
9379
|
+
},
|
|
9380
|
+
...options
|
|
9381
|
+
});
|
|
9382
|
+
}
|
|
9383
|
+
};
|
|
9384
|
+
|
|
9134
9385
|
// src/client.ts
|
|
9135
9386
|
var PRODUCTION_URL = "https://api.delopay.net";
|
|
9136
9387
|
var SANDBOX_URL = "https://sandbox.delopay.net";
|
|
@@ -9154,6 +9405,40 @@ function truncateRawBody(raw) {
|
|
|
9154
9405
|
if (!raw) return void 0;
|
|
9155
9406
|
return raw.length > MAX_RAW_BODY_BYTES ? raw.slice(0, MAX_RAW_BODY_BYTES) + "\u2026" : raw;
|
|
9156
9407
|
}
|
|
9408
|
+
async function errorFromResponse(response, requestId) {
|
|
9409
|
+
const rawBody = await response.text().catch(() => "");
|
|
9410
|
+
let parsed = {};
|
|
9411
|
+
if (rawBody) {
|
|
9412
|
+
try {
|
|
9413
|
+
parsed = JSON.parse(rawBody);
|
|
9414
|
+
} catch {
|
|
9415
|
+
}
|
|
9416
|
+
}
|
|
9417
|
+
const err = parsed.error ?? parsed;
|
|
9418
|
+
const message = err.message ?? `Request failed with status ${response.status}`;
|
|
9419
|
+
const code = err.code ?? "";
|
|
9420
|
+
const type = err.error_type ?? err.type ?? "";
|
|
9421
|
+
const data = err.data && typeof err.data === "object" && !Array.isArray(err.data) ? err.data : void 0;
|
|
9422
|
+
const truncatedRaw = truncateRawBody(rawBody);
|
|
9423
|
+
const isConnectorPassthrough = type === "connector" || code.startsWith("CE_");
|
|
9424
|
+
if (response.status === 401 && !isConnectorPassthrough) {
|
|
9425
|
+
return new DelopayAuthenticationError(message, {
|
|
9426
|
+
code,
|
|
9427
|
+
type,
|
|
9428
|
+
requestId,
|
|
9429
|
+
rawBody: truncatedRaw,
|
|
9430
|
+
data
|
|
9431
|
+
});
|
|
9432
|
+
}
|
|
9433
|
+
return new DelopayError(message, {
|
|
9434
|
+
status: response.status,
|
|
9435
|
+
code,
|
|
9436
|
+
type,
|
|
9437
|
+
requestId,
|
|
9438
|
+
rawBody: truncatedRaw,
|
|
9439
|
+
data
|
|
9440
|
+
});
|
|
9441
|
+
}
|
|
9157
9442
|
function findIdempotencyKey(headers) {
|
|
9158
9443
|
for (const [k, v] of Object.entries(headers)) {
|
|
9159
9444
|
if (k.toLowerCase() === "idempotency-key") return v;
|
|
@@ -9314,6 +9599,7 @@ function redactUrlForLogging(url) {
|
|
|
9314
9599
|
});
|
|
9315
9600
|
return `${base}?${parts.join("&")}`;
|
|
9316
9601
|
}
|
|
9602
|
+
var DEFAULT_STREAM_IDLE_TIMEOUT_MS = 45e3;
|
|
9317
9603
|
var Delopay = class {
|
|
9318
9604
|
/**
|
|
9319
9605
|
* Create a new Delopay client.
|
|
@@ -9336,6 +9622,7 @@ var Delopay = class {
|
|
|
9336
9622
|
this.baseUrl = PRODUCTION_URL;
|
|
9337
9623
|
}
|
|
9338
9624
|
const request = this.request.bind(this);
|
|
9625
|
+
const openStream = this.openEventStream.bind(this);
|
|
9339
9626
|
this.payments = new Payments(request);
|
|
9340
9627
|
this.refunds = new Refunds(request);
|
|
9341
9628
|
this.customers = new Customers(request);
|
|
@@ -9372,6 +9659,7 @@ var Delopay = class {
|
|
|
9372
9659
|
this.settings = new Settings(request);
|
|
9373
9660
|
this.messageTemplates = new MessageTemplates(request);
|
|
9374
9661
|
this.risk = new Risk(request);
|
|
9662
|
+
this.live = new Live(request, openStream);
|
|
9375
9663
|
this.subscriptions = new Subscriptions(request);
|
|
9376
9664
|
this.buyerPortal = new BuyerPortal(request);
|
|
9377
9665
|
this.buyerAccount = new BuyerAccount(request);
|
|
@@ -9448,24 +9736,12 @@ var Delopay = class {
|
|
|
9448
9736
|
this.setJwtToken(response.token);
|
|
9449
9737
|
return response;
|
|
9450
9738
|
}
|
|
9451
|
-
/**
|
|
9452
|
-
|
|
9453
|
-
*
|
|
9454
|
-
* You rarely need to call this directly — prefer the typed resource methods.
|
|
9455
|
-
* Use it only for endpoints not yet covered by a resource class.
|
|
9456
|
-
*
|
|
9457
|
-
* @param method - HTTP method (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`).
|
|
9458
|
-
* @param path - API path starting with `/` (e.g. `/payments`).
|
|
9459
|
-
* @param options - Optional body, query parameters, and headers.
|
|
9460
|
-
* @returns Parsed JSON response body typed as `T`.
|
|
9461
|
-
* @throws {DelopayAuthenticationError} On 401 responses.
|
|
9462
|
-
* @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.
|
|
9463
|
-
*/
|
|
9464
|
-
async request(method, path, options) {
|
|
9739
|
+
/** `path` on the base URL, with the query string `query` makes. */
|
|
9740
|
+
buildUrl(path, query) {
|
|
9465
9741
|
let url = `${this.baseUrl}${path}`;
|
|
9466
|
-
if (
|
|
9742
|
+
if (query) {
|
|
9467
9743
|
const params = new URLSearchParams();
|
|
9468
|
-
for (const [key, value] of Object.entries(
|
|
9744
|
+
for (const [key, value] of Object.entries(query)) {
|
|
9469
9745
|
if (value === void 0 || value === null) continue;
|
|
9470
9746
|
if (Array.isArray(value)) {
|
|
9471
9747
|
for (const v of value) {
|
|
@@ -9480,8 +9756,189 @@ var Delopay = class {
|
|
|
9480
9756
|
url += `?${qs}`;
|
|
9481
9757
|
}
|
|
9482
9758
|
}
|
|
9759
|
+
return url;
|
|
9760
|
+
}
|
|
9761
|
+
/** The credential header: the JWT when one is set, else the API key. */
|
|
9762
|
+
authHeaders() {
|
|
9763
|
+
if (this.jwtToken) return { Authorization: `Bearer ${this.jwtToken}` };
|
|
9764
|
+
if (this.apiKey) return { "api-key": this.apiKey };
|
|
9765
|
+
return {};
|
|
9766
|
+
}
|
|
9767
|
+
/** One debug event, when `debug` is on. */
|
|
9768
|
+
log(event, data) {
|
|
9769
|
+
if (!this.debug) return;
|
|
9770
|
+
if (this.logger) {
|
|
9771
|
+
this.logger(event, data);
|
|
9772
|
+
return;
|
|
9773
|
+
}
|
|
9774
|
+
if (event === "request")
|
|
9775
|
+
console.log(`[delopay] ${data.method} ${data.url}`);
|
|
9776
|
+
else if (event === "response")
|
|
9777
|
+
console.log(
|
|
9778
|
+
`[delopay] ${data.status} ${data.method} ${data.path}`
|
|
9779
|
+
);
|
|
9780
|
+
else
|
|
9781
|
+
console.log(
|
|
9782
|
+
`[delopay] retry ${data.attempt}/${data.maxRetries} ${data.method} ${data.path}`
|
|
9783
|
+
);
|
|
9784
|
+
}
|
|
9785
|
+
/**
|
|
9786
|
+
* Open a `GET` `text/event-stream` and read it as it arrives.
|
|
9787
|
+
*
|
|
9788
|
+
* `request()` keeps every chunk of a body until the body ends, which a
|
|
9789
|
+
* stream that stays open for half an hour must not do; this reads the body
|
|
9790
|
+
* chunk by chunk through {@link EventStreamParser} and keeps nothing it has
|
|
9791
|
+
* dispatched. Credentials, the base URL, debug logging and the mapping of a
|
|
9792
|
+
* non-2xx answer to `DelopayError` / `DelopayAuthenticationError` are the
|
|
9793
|
+
* ones `request()` uses.
|
|
9794
|
+
*
|
|
9795
|
+
* Never retried, and never reconnected: the caller owns reconnection.
|
|
9796
|
+
* Resolves once the response headers arrive; rejects on a non-2xx answer,
|
|
9797
|
+
* on a 2xx that is not `text/event-stream` (code `NOT_EVENT_STREAM`), and
|
|
9798
|
+
* with `TIMEOUT`, `NETWORK` or `ABORTED` like `request()`.
|
|
9799
|
+
*/
|
|
9800
|
+
async openEventStream(path, options = {}) {
|
|
9801
|
+
const url = this.buildUrl(path, options.query);
|
|
9802
|
+
const lastEventId = options.lastEventId ?? "";
|
|
9803
|
+
const headers = {
|
|
9804
|
+
...this.authHeaders(),
|
|
9805
|
+
Accept: "text/event-stream",
|
|
9806
|
+
...lastEventId ? { "Last-Event-ID": lastEventId } : {},
|
|
9807
|
+
...options.headers
|
|
9808
|
+
};
|
|
9809
|
+
const idleMs = options.idleTimeoutMs ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS;
|
|
9810
|
+
const callerSignal = options.signal;
|
|
9811
|
+
const aborted = () => new DelopayError("Request aborted", { status: 0, code: "ABORTED", type: "abort_error" });
|
|
9812
|
+
if (callerSignal?.aborted) throw aborted();
|
|
9813
|
+
const idleCtrl = new AbortController();
|
|
9814
|
+
const closeCtrl = new AbortController();
|
|
9815
|
+
let timer;
|
|
9816
|
+
const stopIdleTimer = () => {
|
|
9817
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
9818
|
+
timer = void 0;
|
|
9819
|
+
};
|
|
9820
|
+
const startIdleTimer = () => {
|
|
9821
|
+
stopIdleTimer();
|
|
9822
|
+
if (!idleCtrl.signal.aborted) timer = setTimeout(() => idleCtrl.abort(), idleMs);
|
|
9823
|
+
};
|
|
9824
|
+
const combined = combineSignals(
|
|
9825
|
+
callerSignal ? [idleCtrl.signal, closeCtrl.signal, callerSignal] : [idleCtrl.signal, closeCtrl.signal]
|
|
9826
|
+
);
|
|
9827
|
+
const release = () => {
|
|
9828
|
+
stopIdleTimer();
|
|
9829
|
+
combined.dispose();
|
|
9830
|
+
};
|
|
9831
|
+
const timedOut = () => new DelopayError(`Event stream silent for ${idleMs} ms`, {
|
|
9832
|
+
status: 0,
|
|
9833
|
+
code: "TIMEOUT",
|
|
9834
|
+
type: "timeout_error"
|
|
9835
|
+
});
|
|
9836
|
+
const network = (cause) => new DelopayError(
|
|
9837
|
+
`Network error: ${cause instanceof Error ? cause.message : String(cause ?? "stream failed")}`,
|
|
9838
|
+
{ status: 0, code: "NETWORK", type: "network_error" }
|
|
9839
|
+
);
|
|
9840
|
+
this.log("request", { method: "GET", url: redactUrlForLogging(url), path });
|
|
9841
|
+
startIdleTimer();
|
|
9842
|
+
let response;
|
|
9843
|
+
try {
|
|
9844
|
+
response = await fetch(url, { method: "GET", headers, signal: combined.signal });
|
|
9845
|
+
} catch (err) {
|
|
9846
|
+
release();
|
|
9847
|
+
if (callerSignal?.aborted) throw aborted();
|
|
9848
|
+
if (idleCtrl.signal.aborted) throw timedOut();
|
|
9849
|
+
throw network(err);
|
|
9850
|
+
}
|
|
9851
|
+
const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
|
|
9852
|
+
this.log("response", { status: response.status, method: "GET", path, requestId });
|
|
9853
|
+
if (!response.ok) {
|
|
9854
|
+
const error = await errorFromResponse(response, requestId);
|
|
9855
|
+
release();
|
|
9856
|
+
throw error;
|
|
9857
|
+
}
|
|
9858
|
+
const body = response.body;
|
|
9859
|
+
const contentType = response.headers?.get("content-type") ?? "";
|
|
9860
|
+
const mediaType = (contentType.split(";")[0] ?? "").trim().toLowerCase();
|
|
9861
|
+
if (mediaType !== "text/event-stream" || !body || typeof body.getReader !== "function") {
|
|
9862
|
+
release();
|
|
9863
|
+
body?.cancel().catch(noop);
|
|
9864
|
+
throw new DelopayError(
|
|
9865
|
+
mediaType === "text/event-stream" ? "The event stream has no readable body" : `Expected a text/event-stream response, got ${contentType ? `"${contentType}"` : "no content type"}`,
|
|
9866
|
+
{
|
|
9867
|
+
status: response.status,
|
|
9868
|
+
code: "NOT_EVENT_STREAM",
|
|
9869
|
+
type: "invalid_response",
|
|
9870
|
+
requestId
|
|
9871
|
+
}
|
|
9872
|
+
);
|
|
9873
|
+
}
|
|
9874
|
+
stopIdleTimer();
|
|
9875
|
+
const reader = body.getReader();
|
|
9876
|
+
const parser = new EventStreamParser(lastEventId);
|
|
9877
|
+
const decoder = new TextDecoder();
|
|
9878
|
+
const stopped = () => Boolean(callerSignal?.aborted) || closeCtrl.signal.aborted;
|
|
9879
|
+
let finished = false;
|
|
9880
|
+
const finish = () => {
|
|
9881
|
+
if (finished) return;
|
|
9882
|
+
finished = true;
|
|
9883
|
+
release();
|
|
9884
|
+
reader.cancel().catch(noop);
|
|
9885
|
+
};
|
|
9886
|
+
async function* dispatches() {
|
|
9887
|
+
try {
|
|
9888
|
+
for (; ; ) {
|
|
9889
|
+
let result;
|
|
9890
|
+
startIdleTimer();
|
|
9891
|
+
try {
|
|
9892
|
+
result = await readChunk(reader, combined.signal);
|
|
9893
|
+
} catch (err) {
|
|
9894
|
+
if (callerSignal?.aborted || closeCtrl.signal.aborted) return;
|
|
9895
|
+
if (idleCtrl.signal.aborted) throw timedOut();
|
|
9896
|
+
throw network(err instanceof BodyStreamFailure ? err.cause : err);
|
|
9897
|
+
} finally {
|
|
9898
|
+
stopIdleTimer();
|
|
9899
|
+
}
|
|
9900
|
+
if (result.done) {
|
|
9901
|
+
for (const dispatch of parser.push(decoder.decode())) {
|
|
9902
|
+
if (stopped()) return;
|
|
9903
|
+
yield dispatch;
|
|
9904
|
+
}
|
|
9905
|
+
return;
|
|
9906
|
+
}
|
|
9907
|
+
if (!result.value || result.value.byteLength === 0) continue;
|
|
9908
|
+
for (const dispatch of parser.push(decoder.decode(result.value, { stream: true }))) {
|
|
9909
|
+
if (stopped()) return;
|
|
9910
|
+
yield dispatch;
|
|
9911
|
+
}
|
|
9912
|
+
}
|
|
9913
|
+
} finally {
|
|
9914
|
+
finish();
|
|
9915
|
+
}
|
|
9916
|
+
}
|
|
9917
|
+
return {
|
|
9918
|
+
dispatches: dispatches(),
|
|
9919
|
+
close: () => {
|
|
9920
|
+
closeCtrl.abort();
|
|
9921
|
+
finish();
|
|
9922
|
+
}
|
|
9923
|
+
};
|
|
9924
|
+
}
|
|
9925
|
+
/**
|
|
9926
|
+
* Make a raw HTTP request to the Delopay API.
|
|
9927
|
+
*
|
|
9928
|
+
* You rarely need to call this directly — prefer the typed resource methods.
|
|
9929
|
+
* Use it only for endpoints not yet covered by a resource class.
|
|
9930
|
+
*
|
|
9931
|
+
* @param method - HTTP method (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`).
|
|
9932
|
+
* @param path - API path starting with `/` (e.g. `/payments`).
|
|
9933
|
+
* @param options - Optional body, query parameters, and headers.
|
|
9934
|
+
* @returns Parsed JSON response body typed as `T`.
|
|
9935
|
+
* @throws {DelopayAuthenticationError} On 401 responses.
|
|
9936
|
+
* @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.
|
|
9937
|
+
*/
|
|
9938
|
+
async request(method, path, options) {
|
|
9939
|
+
const url = this.buildUrl(path, options?.query);
|
|
9483
9940
|
let headers = {
|
|
9484
|
-
...this.
|
|
9941
|
+
...this.authHeaders(),
|
|
9485
9942
|
...options?.headers
|
|
9486
9943
|
};
|
|
9487
9944
|
const isRawBody = options?.body !== void 0 && options?.body !== null && (options.body instanceof FormData || options.body instanceof Blob || options.body instanceof ArrayBuffer || options.body instanceof URLSearchParams);
|
|
@@ -9534,23 +9991,7 @@ var Delopay = class {
|
|
|
9534
9991
|
let lastError;
|
|
9535
9992
|
let retryAfterOverrideMs = null;
|
|
9536
9993
|
const safeUrl = () => redactUrlForLogging(url);
|
|
9537
|
-
const emit = (event, data) =>
|
|
9538
|
-
if (!this.debug) return;
|
|
9539
|
-
if (this.logger) {
|
|
9540
|
-
this.logger(event, data);
|
|
9541
|
-
return;
|
|
9542
|
-
}
|
|
9543
|
-
if (event === "request")
|
|
9544
|
-
console.log(`[delopay] ${data.method} ${data.url}`);
|
|
9545
|
-
else if (event === "response")
|
|
9546
|
-
console.log(
|
|
9547
|
-
`[delopay] ${data.status} ${data.method} ${data.path}`
|
|
9548
|
-
);
|
|
9549
|
-
else
|
|
9550
|
-
console.log(
|
|
9551
|
-
`[delopay] retry ${data.attempt}/${data.maxRetries} ${data.method} ${data.path}`
|
|
9552
|
-
);
|
|
9553
|
-
};
|
|
9994
|
+
const emit = (event, data) => this.log(event, data);
|
|
9554
9995
|
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
9555
9996
|
if (attempt > 0) {
|
|
9556
9997
|
const base = Math.min(500 * 2 ** (attempt - 1), 5e3);
|
|
@@ -9582,38 +10023,7 @@ var Delopay = class {
|
|
|
9582
10023
|
const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
|
|
9583
10024
|
emit("response", { status: response.status, method, path, requestId });
|
|
9584
10025
|
if (!response.ok) {
|
|
9585
|
-
const
|
|
9586
|
-
let parsed = {};
|
|
9587
|
-
if (rawBody) {
|
|
9588
|
-
try {
|
|
9589
|
-
parsed = JSON.parse(rawBody);
|
|
9590
|
-
} catch {
|
|
9591
|
-
}
|
|
9592
|
-
}
|
|
9593
|
-
const err = parsed.error ?? parsed;
|
|
9594
|
-
const message = err.message ?? `Request failed with status ${response.status}`;
|
|
9595
|
-
const code = err.code ?? "";
|
|
9596
|
-
const type = err.error_type ?? err.type ?? "";
|
|
9597
|
-
const data = err.data && typeof err.data === "object" && !Array.isArray(err.data) ? err.data : void 0;
|
|
9598
|
-
const truncatedRaw = truncateRawBody(rawBody);
|
|
9599
|
-
const isConnectorPassthrough = type === "connector" || code.startsWith("CE_");
|
|
9600
|
-
if (response.status === 401 && !isConnectorPassthrough) {
|
|
9601
|
-
throw new DelopayAuthenticationError(message, {
|
|
9602
|
-
code,
|
|
9603
|
-
type,
|
|
9604
|
-
requestId,
|
|
9605
|
-
rawBody: truncatedRaw,
|
|
9606
|
-
data
|
|
9607
|
-
});
|
|
9608
|
-
}
|
|
9609
|
-
const error = new DelopayError(message, {
|
|
9610
|
-
status: response.status,
|
|
9611
|
-
code,
|
|
9612
|
-
type,
|
|
9613
|
-
requestId,
|
|
9614
|
-
rawBody: truncatedRaw,
|
|
9615
|
-
data
|
|
9616
|
-
});
|
|
10026
|
+
const error = await errorFromResponse(response, requestId);
|
|
9617
10027
|
const isTransientStatus = response.status >= 500 || response.status === 429;
|
|
9618
10028
|
if (isTransientStatus && isRetryable && attempt < this.maxRetries) {
|
|
9619
10029
|
if (response.status === 429) {
|
|
@@ -11081,6 +11491,13 @@ var DEFAULT_BRANDING_BASE = {
|
|
|
11081
11491
|
paypalFocusRing: "strong",
|
|
11082
11492
|
mollieFocusRing: "strong",
|
|
11083
11493
|
paypalValidTint: false,
|
|
11494
|
+
epayoutsCardLayout: "split",
|
|
11495
|
+
epayoutsLabelStyle: "above",
|
|
11496
|
+
epayoutsFieldChrome: "outlined",
|
|
11497
|
+
epayoutsFieldFontSize: "md",
|
|
11498
|
+
epayoutsFieldWeight: "regular",
|
|
11499
|
+
epayoutsFocusRing: "strong",
|
|
11500
|
+
epayoutsValidTint: false,
|
|
11084
11501
|
nomupayFormStyle: "plain",
|
|
11085
11502
|
nomupayShowLabels: true,
|
|
11086
11503
|
nomupayShowPlaceholders: true,
|
|
@@ -12111,6 +12528,66 @@ function decodeBranding(source) {
|
|
|
12111
12528
|
DEFAULT_BRANDING.whopSelection
|
|
12112
12529
|
),
|
|
12113
12530
|
paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
|
|
12531
|
+
// A look stored before todos#412 has no e-Payouts keys: the form keeps
|
|
12532
|
+
// the PayPal values it was drawn with until then.
|
|
12533
|
+
epayoutsCardLayout: pickEnum(
|
|
12534
|
+
extras["epayoutsCardLayout"],
|
|
12535
|
+
PAYPAL_CARD_LAYOUTS,
|
|
12536
|
+
pickEnum(
|
|
12537
|
+
extras["paypalCardLayout"],
|
|
12538
|
+
PAYPAL_CARD_LAYOUTS,
|
|
12539
|
+
DEFAULT_BRANDING.epayoutsCardLayout
|
|
12540
|
+
)
|
|
12541
|
+
),
|
|
12542
|
+
epayoutsLabelStyle: pickEnum(
|
|
12543
|
+
extras["epayoutsLabelStyle"],
|
|
12544
|
+
PAYPAL_LABEL_STYLES,
|
|
12545
|
+
pickEnum(
|
|
12546
|
+
extras["paypalLabelStyle"],
|
|
12547
|
+
PAYPAL_LABEL_STYLES,
|
|
12548
|
+
DEFAULT_BRANDING.epayoutsLabelStyle
|
|
12549
|
+
)
|
|
12550
|
+
),
|
|
12551
|
+
epayoutsFieldChrome: pickEnum(
|
|
12552
|
+
extras["epayoutsFieldChrome"],
|
|
12553
|
+
CARD_FIELD_CHROMES,
|
|
12554
|
+
pickEnum(
|
|
12555
|
+
extras["paypalFieldChrome"],
|
|
12556
|
+
CARD_FIELD_CHROMES,
|
|
12557
|
+
DEFAULT_BRANDING.epayoutsFieldChrome
|
|
12558
|
+
)
|
|
12559
|
+
),
|
|
12560
|
+
epayoutsFieldFontSize: pickEnum(
|
|
12561
|
+
extras["epayoutsFieldFontSize"],
|
|
12562
|
+
CARD_FIELD_FONT_SIZES,
|
|
12563
|
+
pickEnum(
|
|
12564
|
+
extras["paypalFieldFontSize"],
|
|
12565
|
+
CARD_FIELD_FONT_SIZES,
|
|
12566
|
+
DEFAULT_BRANDING.epayoutsFieldFontSize
|
|
12567
|
+
)
|
|
12568
|
+
),
|
|
12569
|
+
epayoutsFieldWeight: pickEnum(
|
|
12570
|
+
extras["epayoutsFieldWeight"],
|
|
12571
|
+
CARD_FIELD_WEIGHTS,
|
|
12572
|
+
pickEnum(
|
|
12573
|
+
extras["paypalFieldWeight"],
|
|
12574
|
+
CARD_FIELD_WEIGHTS,
|
|
12575
|
+
DEFAULT_BRANDING.epayoutsFieldWeight
|
|
12576
|
+
)
|
|
12577
|
+
),
|
|
12578
|
+
epayoutsFocusRing: pickEnum(
|
|
12579
|
+
extras["epayoutsFocusRing"],
|
|
12580
|
+
CARD_FOCUS_RINGS,
|
|
12581
|
+
pickEnum(
|
|
12582
|
+
extras["paypalFocusRing"],
|
|
12583
|
+
CARD_FOCUS_RINGS,
|
|
12584
|
+
DEFAULT_BRANDING.epayoutsFocusRing
|
|
12585
|
+
)
|
|
12586
|
+
),
|
|
12587
|
+
epayoutsValidTint: parseBool(
|
|
12588
|
+
extras["epayoutsValidTint"],
|
|
12589
|
+
parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.epayoutsValidTint)
|
|
12590
|
+
),
|
|
12114
12591
|
nomupayFormStyle: pickEnum(
|
|
12115
12592
|
extras["nomupayFormStyle"],
|
|
12116
12593
|
NOMUPAY_FORM_STYLES,
|
|
@@ -12272,6 +12749,13 @@ function encodeBranding(branding, base) {
|
|
|
12272
12749
|
whopMethodIcons: String(branding.whopMethodIcons),
|
|
12273
12750
|
whopSelection: branding.whopSelection,
|
|
12274
12751
|
paypalValidTint: String(branding.paypalValidTint),
|
|
12752
|
+
epayoutsCardLayout: branding.epayoutsCardLayout,
|
|
12753
|
+
epayoutsLabelStyle: branding.epayoutsLabelStyle,
|
|
12754
|
+
epayoutsFieldChrome: branding.epayoutsFieldChrome,
|
|
12755
|
+
epayoutsFieldFontSize: branding.epayoutsFieldFontSize,
|
|
12756
|
+
epayoutsFieldWeight: branding.epayoutsFieldWeight,
|
|
12757
|
+
epayoutsFocusRing: branding.epayoutsFocusRing,
|
|
12758
|
+
epayoutsValidTint: String(branding.epayoutsValidTint),
|
|
12275
12759
|
nomupayFormStyle: branding.nomupayFormStyle,
|
|
12276
12760
|
nomupayShowLabels: String(branding.nomupayShowLabels),
|
|
12277
12761
|
nomupayShowPlaceholders: String(branding.nomupayShowPlaceholders),
|
|
@@ -12733,6 +13217,62 @@ function parseImportedBranding(raw) {
|
|
|
12733
13217
|
dflt.whopSelection
|
|
12734
13218
|
),
|
|
12735
13219
|
paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
|
|
13220
|
+
// A look stored before todos#412 has no e-Payouts keys: the form keeps
|
|
13221
|
+
// the PayPal values it was drawn with until then.
|
|
13222
|
+
epayoutsCardLayout: pickEnum(
|
|
13223
|
+
root["epayoutsCardLayout"],
|
|
13224
|
+
PAYPAL_CARD_LAYOUTS,
|
|
13225
|
+
pickEnum(
|
|
13226
|
+
root["paypalCardLayout"],
|
|
13227
|
+
PAYPAL_CARD_LAYOUTS,
|
|
13228
|
+
dflt.epayoutsCardLayout
|
|
13229
|
+
)
|
|
13230
|
+
),
|
|
13231
|
+
epayoutsLabelStyle: pickEnum(
|
|
13232
|
+
root["epayoutsLabelStyle"],
|
|
13233
|
+
PAYPAL_LABEL_STYLES,
|
|
13234
|
+
pickEnum(
|
|
13235
|
+
root["paypalLabelStyle"],
|
|
13236
|
+
PAYPAL_LABEL_STYLES,
|
|
13237
|
+
dflt.epayoutsLabelStyle
|
|
13238
|
+
)
|
|
13239
|
+
),
|
|
13240
|
+
epayoutsFieldChrome: pickEnum(
|
|
13241
|
+
root["epayoutsFieldChrome"],
|
|
13242
|
+
CARD_FIELD_CHROMES,
|
|
13243
|
+
pickEnum(
|
|
13244
|
+
root["paypalFieldChrome"],
|
|
13245
|
+
CARD_FIELD_CHROMES,
|
|
13246
|
+
dflt.epayoutsFieldChrome
|
|
13247
|
+
)
|
|
13248
|
+
),
|
|
13249
|
+
epayoutsFieldFontSize: pickEnum(
|
|
13250
|
+
root["epayoutsFieldFontSize"],
|
|
13251
|
+
CARD_FIELD_FONT_SIZES,
|
|
13252
|
+
pickEnum(
|
|
13253
|
+
root["paypalFieldFontSize"],
|
|
13254
|
+
CARD_FIELD_FONT_SIZES,
|
|
13255
|
+
dflt.epayoutsFieldFontSize
|
|
13256
|
+
)
|
|
13257
|
+
),
|
|
13258
|
+
epayoutsFieldWeight: pickEnum(
|
|
13259
|
+
root["epayoutsFieldWeight"],
|
|
13260
|
+
CARD_FIELD_WEIGHTS,
|
|
13261
|
+
pickEnum(
|
|
13262
|
+
root["paypalFieldWeight"],
|
|
13263
|
+
CARD_FIELD_WEIGHTS,
|
|
13264
|
+
dflt.epayoutsFieldWeight
|
|
13265
|
+
)
|
|
13266
|
+
),
|
|
13267
|
+
epayoutsFocusRing: pickEnum(
|
|
13268
|
+
root["epayoutsFocusRing"],
|
|
13269
|
+
CARD_FOCUS_RINGS,
|
|
13270
|
+
pickEnum(root["paypalFocusRing"], CARD_FOCUS_RINGS, dflt.epayoutsFocusRing)
|
|
13271
|
+
),
|
|
13272
|
+
epayoutsValidTint: parseBool(
|
|
13273
|
+
root["epayoutsValidTint"],
|
|
13274
|
+
parseBool(root["paypalValidTint"], dflt.epayoutsValidTint)
|
|
13275
|
+
),
|
|
12736
13276
|
nomupayFormStyle: pickEnum(
|
|
12737
13277
|
root["nomupayFormStyle"],
|
|
12738
13278
|
NOMUPAY_FORM_STYLES,
|
|
@@ -14247,6 +14787,41 @@ var Admin = class {
|
|
|
14247
14787
|
}
|
|
14248
14788
|
};
|
|
14249
14789
|
|
|
14790
|
+
// src/internal/resources/adminLive.ts
|
|
14791
|
+
var AdminLive = class {
|
|
14792
|
+
constructor(request, openStream) {
|
|
14793
|
+
this.request = request;
|
|
14794
|
+
this.openStream = openStream;
|
|
14795
|
+
}
|
|
14796
|
+
/**
|
|
14797
|
+
* Open the stream of what changed in every merchant. Each change names its
|
|
14798
|
+
* `merchant_id`. The SDK does not reconnect — see `LiveEventStream`.
|
|
14799
|
+
*
|
|
14800
|
+
* `GET /admin-portal/live/stream`
|
|
14801
|
+
*/
|
|
14802
|
+
async stream(options) {
|
|
14803
|
+
return openLiveStream(this.openStream, "/admin-portal/live/stream", options);
|
|
14804
|
+
}
|
|
14805
|
+
/**
|
|
14806
|
+
* The versions an admin editor of `merchantId` names in `If-Match`. A save
|
|
14807
|
+
* over a newer version is refused with `IR_16` (400), `error.data` a
|
|
14808
|
+
* `LiveChangedElsewhere`.
|
|
14809
|
+
*
|
|
14810
|
+
* `GET /admin-portal/live/versions`
|
|
14811
|
+
*/
|
|
14812
|
+
async versions(merchantId, params, options) {
|
|
14813
|
+
return this.request("GET", "/admin-portal/live/versions", {
|
|
14814
|
+
query: {
|
|
14815
|
+
merchant_id: merchantId,
|
|
14816
|
+
entities: params.entities.join(","),
|
|
14817
|
+
profile_id: params.profile_id,
|
|
14818
|
+
record_id: params.record_id
|
|
14819
|
+
},
|
|
14820
|
+
...options
|
|
14821
|
+
});
|
|
14822
|
+
}
|
|
14823
|
+
};
|
|
14824
|
+
|
|
14250
14825
|
// src/internal/resources/adminPortal.ts
|
|
14251
14826
|
var AdminPortal = class {
|
|
14252
14827
|
constructor(request) {
|
|
@@ -14801,6 +15376,31 @@ var AdminPortal = class {
|
|
|
14801
15376
|
async updateUser(userId, body) {
|
|
14802
15377
|
return this.request("PATCH", `/admin-portal/users/${encodeURIComponent(userId)}`, { body });
|
|
14803
15378
|
}
|
|
15379
|
+
/**
|
|
15380
|
+
* Which checkout payment methods a member of `merchantId` may change.
|
|
15381
|
+
* `GET /admin-portal/accounts/{merchant_id}/members/{user_id}/method-access`
|
|
15382
|
+
*
|
|
15383
|
+
* Any internal role may read it; `can_edit` is `false` for one without
|
|
15384
|
+
* `UsersManage`. A user holding no role in the merchant is a 404 `UR_68`.
|
|
15385
|
+
*/
|
|
15386
|
+
async getMemberMethodAccess(merchantId, userId) {
|
|
15387
|
+
return this.request(
|
|
15388
|
+
"GET",
|
|
15389
|
+
`/admin-portal/accounts/${encodeURIComponent(merchantId)}/members/${encodeURIComponent(userId)}/method-access`
|
|
15390
|
+
);
|
|
15391
|
+
}
|
|
15392
|
+
/**
|
|
15393
|
+
* Limit a member of `merchantId` to some checkout payment methods, or give
|
|
15394
|
+
* every method back. Needs `UsersManage`. Recorded in the merchant's audit
|
|
15395
|
+
* log. `PUT /admin-portal/accounts/{merchant_id}/members/{user_id}/method-access`
|
|
15396
|
+
*/
|
|
15397
|
+
async updateMemberMethodAccess(merchantId, userId, body) {
|
|
15398
|
+
return this.request(
|
|
15399
|
+
"PUT",
|
|
15400
|
+
`/admin-portal/accounts/${encodeURIComponent(merchantId)}/members/${encodeURIComponent(userId)}/method-access`,
|
|
15401
|
+
{ body }
|
|
15402
|
+
);
|
|
15403
|
+
}
|
|
14804
15404
|
/**
|
|
14805
15405
|
* Soft-delete a user globally: deactivates the row, blacklists existing
|
|
14806
15406
|
* JWTs, and wipes credentials. Distinct from `deleteUserRole`, which
|
|
@@ -15912,6 +16512,8 @@ var DelopayInternal = class extends Delopay {
|
|
|
15912
16512
|
const request = this.request.bind(this);
|
|
15913
16513
|
this.admin = new Admin(request);
|
|
15914
16514
|
this.adminPortal = new AdminPortal(request);
|
|
16515
|
+
const openStream = this.openEventStream.bind(this);
|
|
16516
|
+
this.adminLive = new AdminLive(request, openStream);
|
|
15915
16517
|
this.auditLogs = new AuditLogs(request);
|
|
15916
16518
|
this.cache = new Cache(request);
|
|
15917
16519
|
this.cardIssuers = new CardIssuers(request);
|
|
@@ -15945,6 +16547,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
15945
16547
|
APPLE_PAY_BUTTON_STYLES,
|
|
15946
16548
|
APPLE_PAY_BUTTON_TYPES,
|
|
15947
16549
|
Admin,
|
|
16550
|
+
AdminLive,
|
|
15948
16551
|
AdminPortal,
|
|
15949
16552
|
Analytics,
|
|
15950
16553
|
AnalyticsDashboard,
|
|
@@ -16003,6 +16606,8 @@ var DelopayInternal = class extends Delopay {
|
|
|
16003
16606
|
InvoiceSettingsResource,
|
|
16004
16607
|
Invoices,
|
|
16005
16608
|
LOCALIZABLE_COPY_FIELDS,
|
|
16609
|
+
Live,
|
|
16610
|
+
LiveEventStream,
|
|
16006
16611
|
MAX_SECTION_LABEL_LENGTH,
|
|
16007
16612
|
MAX_SECTION_ORDER,
|
|
16008
16613
|
METHOD_SECTIONS,
|