@ptkl/sdk 1.15.0 → 1.17.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.
@@ -20279,6 +20279,7 @@ class IntegrationsBaseClient extends BaseClient {
20279
20279
  // @ts-ignore
20280
20280
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
20281
20281
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
20282
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
20282
20283
  if (isBrowser) {
20283
20284
  if (sessionStorage.getItem('protokol_context') === 'forge') {
20284
20285
  headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
@@ -20322,6 +20323,70 @@ class IntegrationsBaseClient extends BaseClient {
20322
20323
  }
20323
20324
  }
20324
20325
 
20326
+ /**
20327
+ * Build an RFC 7233 Range header value from the SDK's range options.
20328
+ *
20329
+ * Validation happens here rather than at the server so a typo (a float offset, a
20330
+ * negative length) fails immediately and locally instead of arriving as an opaque
20331
+ * 400 after a round trip.
20332
+ */
20333
+ function buildRangeHeader(range) {
20334
+ const { offset, length, suffix } = range;
20335
+ if (suffix !== undefined) {
20336
+ if (offset !== undefined || length !== undefined) {
20337
+ throw new Error('readRange: `suffix` cannot be combined with `offset` or `length`');
20338
+ }
20339
+ if (!Number.isInteger(suffix) || suffix <= 0) {
20340
+ throw new Error('readRange: `suffix` must be a positive integer');
20341
+ }
20342
+ return `bytes=-${suffix}`;
20343
+ }
20344
+ const start = offset !== null && offset !== void 0 ? offset : 0;
20345
+ if (!Number.isInteger(start) || start < 0) {
20346
+ throw new Error('readRange: `offset` must be a non-negative integer');
20347
+ }
20348
+ if (length === undefined) {
20349
+ return `bytes=${start}-`;
20350
+ }
20351
+ if (!Number.isInteger(length) || length <= 0) {
20352
+ throw new Error('readRange: `length` must be a positive integer');
20353
+ }
20354
+ // Range end offsets are inclusive, so a length of N ends at start + N - 1.
20355
+ return `bytes=${start}-${start + length - 1}`;
20356
+ }
20357
+ /**
20358
+ * Turn a 206 response into a ByteRangeResult.
20359
+ *
20360
+ * The Content-Range check is the important part. Requests reach media-api through
20361
+ * two proxies, and if any hop ever dropped the Range header the response would be
20362
+ * a perfectly valid 200 carrying the *entire* file — a caller asking for 64 KiB
20363
+ * of a 2 GB object would quietly receive all 2 GB. Failing loudly here turns that
20364
+ * from a silent memory blow-up into an actionable error.
20365
+ */
20366
+ function toByteRangeResult(resp) {
20367
+ var _a, _b, _c, _d, _e, _f, _g;
20368
+ const contentRange = (_b = (_a = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _a === void 0 ? void 0 : _a['content-range']) !== null && _b !== void 0 ? _b : (_c = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _c === void 0 ? void 0 : _c['Content-Range'];
20369
+ const parsed = /^bytes\s+(\d+)-(\d+)\/(\d+)$/.exec(String(contentRange !== null && contentRange !== void 0 ? contentRange : '').trim());
20370
+ if (!parsed) {
20371
+ throw new Error('readRange: response did not include a Content-Range header, so the returned body ' +
20372
+ 'may be the entire object rather than the requested range. ' +
20373
+ 'Check that the media host supports ranged reads and that no proxy is stripping the Range header.');
20374
+ }
20375
+ const start = Number(parsed[1]);
20376
+ const end = Number(parsed[2]);
20377
+ const totalSize = Number(parsed[3]);
20378
+ const etag = (_e = (_d = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _d === void 0 ? void 0 : _d.etag) !== null && _e !== void 0 ? _e : (_f = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _f === void 0 ? void 0 : _f.ETag;
20379
+ return {
20380
+ data: resp.data,
20381
+ start,
20382
+ end,
20383
+ length: end - start + 1,
20384
+ totalSize,
20385
+ eof: end >= totalSize - 1,
20386
+ etag: typeof etag === 'string' ? etag.replace(/^"|"$/g, '') : undefined,
20387
+ contentType: (_g = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _g === void 0 ? void 0 : _g['content-type'],
20388
+ };
20389
+ }
20325
20390
  /**
20326
20391
  * Document Management System (DMS) API client
20327
20392
  *
@@ -20455,6 +20520,95 @@ class DMS extends IntegrationsBaseClient {
20455
20520
  responseType: (!encoding) ? 'blob' : null
20456
20521
  });
20457
20522
  }
20523
+ /**
20524
+ * Read a slice of a stored file without transferring the whole object.
20525
+ *
20526
+ * Uses an HTTP Range request, so only the requested bytes cross the wire.
20527
+ * Slicing is positional and format-agnostic — it works on any file.
20528
+ *
20529
+ * ```ts
20530
+ * // First 64 KiB
20531
+ * const head = await dms.readRange(libraryUuid, 'reports/big.csv', { length: 65536 })
20532
+ *
20533
+ * // Continue from where that stopped
20534
+ * const next = await dms.readRange(libraryUuid, 'reports/big.csv', { offset: head.end + 1, length: 65536 })
20535
+ *
20536
+ * // Final 1 KiB
20537
+ * const tail = await dms.readRange(libraryUuid, 'reports/big.csv', { suffix: 1024 })
20538
+ * ```
20539
+ *
20540
+ * The server caps how much a single call may return, so `length` is an upper
20541
+ * bound rather than a guarantee: always advance using the returned `end`
20542
+ * rather than assuming the window you asked for. `eof` tells you when to stop.
20543
+ *
20544
+ * Byte ranges are not meaningful for .xlsx, .zip or .gz — their contents are
20545
+ * compressed as a unit, so no byte window corresponds to a range of rows.
20546
+ *
20547
+ * @param lib Library UUID
20548
+ * @param key Path of the file within the library
20549
+ * @param range Which bytes to read
20550
+ * @throws If the object is smaller than `offset` (nothing left to read), or if
20551
+ * the response came back without range metadata — see `readRange`'s
20552
+ * Content-Range check, which prevents silently receiving a whole file.
20553
+ */
20554
+ async readRange(lib, key, range = {}) {
20555
+ const { responseType = 'arraybuffer' } = range;
20556
+ const resp = await this.request('GET', `media/library/${lib}/get/${key}`, {
20557
+ headers: { Range: buildRangeHeader(range) },
20558
+ responseType,
20559
+ });
20560
+ return toByteRangeResult(resp);
20561
+ }
20562
+ /**
20563
+ * Read a file as a sequence of byte windows, newest request issued only when
20564
+ * the previous window has been consumed.
20565
+ *
20566
+ * This is the memory-bounded way to process a large file: the whole object is
20567
+ * never held at once, and a caller can stop early simply by breaking out.
20568
+ *
20569
+ * ```ts
20570
+ * for await (const chunk of dms.streamRanges(libraryUuid, 'logs/huge.ndjson', { chunkSize: 1 << 20 })) {
20571
+ * process(chunk.data) // one window at a time
20572
+ * if (foundWhatIWanted) break // no further requests are made
20573
+ * }
20574
+ * ```
20575
+ *
20576
+ * Windows are contiguous and non-overlapping, so concatenating every `data`
20577
+ * reproduces the file byte for byte. A record spanning a window boundary is
20578
+ * the caller's to reassemble — this yields bytes, not records.
20579
+ *
20580
+ * An empty object yields nothing rather than throwing.
20581
+ *
20582
+ * @param lib Library UUID
20583
+ * @param key Path of the file within the library
20584
+ * @param options Where to start and how large each window should be
20585
+ */
20586
+ async *streamRanges(lib, key, options = {}) {
20587
+ var _a, _b;
20588
+ const { chunkSize = 1024 * 1024, responseType = 'arraybuffer' } = options;
20589
+ let offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
20590
+ for (;;) {
20591
+ let chunk;
20592
+ try {
20593
+ chunk = await this.readRange(lib, key, { offset, length: chunkSize, responseType });
20594
+ }
20595
+ catch (err) {
20596
+ // 416 means the offset is at or past the end. For the first request
20597
+ // that is an empty object; afterwards it is a benign race with a
20598
+ // truncating writer. Either way the stream is simply over.
20599
+ if (((_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.status) === 416)
20600
+ return;
20601
+ throw err;
20602
+ }
20603
+ yield chunk;
20604
+ if (chunk.eof)
20605
+ return;
20606
+ // Advance from what the server actually returned, never from chunkSize:
20607
+ // the per-request cap can make a window shorter than requested, and
20608
+ // assuming otherwise would skip bytes.
20609
+ offset = chunk.end + 1;
20610
+ }
20611
+ }
20458
20612
  async download(lib, key) {
20459
20613
  return this.request('POST', `media/library/${lib}/download`, {
20460
20614
  data: {
@@ -21143,36 +21297,41 @@ class VPFR extends IntegrationsBaseClient {
21143
21297
  }
21144
21298
 
21145
21299
  class Payments extends IntegrationsBaseClient {
21300
+ // FIXME: No backend route exists for listing/searching transactions (neither
21301
+ // monri.route.ts nor wspay.route.ts under karadjordje/src/routes/v1/payments/
21302
+ // expose a "list" endpoint). This method's URL is left as-is (still broken)
21303
+ // rather than being "fixed" to another guessed path that would still 404.
21304
+ // Do not call this method until a corresponding backend route is added.
21146
21305
  async getTransactions(userId, params) {
21147
21306
  return await this.client.get(`/karadjordje/v1/payment/${userId}/list`, {
21148
21307
  params,
21149
21308
  });
21150
21309
  }
21151
- async getTransaction(provider, userId, transactionId) {
21152
- return await this.client.get(`/karadjordje/v1/payment/${provider}/${userId}/getTransaction`, {
21310
+ async getTransaction(provider, transactionId) {
21311
+ return await this.client.get(`/karadjordje/v1/payment/${provider}/getTransaction`, {
21153
21312
  params: { transactionId },
21154
21313
  });
21155
21314
  }
21156
21315
  async settings(provider) {
21157
21316
  return await this.client.get(`/karadjordje/v1/payment/${provider}/settings`);
21158
21317
  }
21159
- async deactivatePaymentLink(provider, user, transactionId) {
21160
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/deactivate/${transactionId}`);
21318
+ async deactivatePaymentLink(provider, transactionId) {
21319
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/deactivate/${transactionId}`);
21161
21320
  }
21162
- async voidTransaction(provider, user, transactionId) {
21163
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/void/${transactionId}`);
21321
+ async voidTransaction(provider, transactionId) {
21322
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/void/${transactionId}`);
21164
21323
  }
21165
- async refund(provider, user, transactionId) {
21166
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/refund/${transactionId}`);
21324
+ async refund(provider, transactionId) {
21325
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/refund/${transactionId}`);
21167
21326
  }
21168
- async getPaymentLink(provider, user, options) {
21169
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, options);
21327
+ async getPaymentLink(provider, options) {
21328
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getPaymentLink`, options);
21170
21329
  }
21171
- async getTokenRequestLink(provider, user, options) {
21172
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getTokenRequestLink`, options);
21330
+ async getTokenRequestLink(provider, options) {
21331
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getTokenRequestLink`, options);
21173
21332
  }
21174
- async directPayUsingToken(provider, user, options) {
21175
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/directPayUsingToken`, options);
21333
+ async directPayUsingToken(provider, options) {
21334
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/directPayUsingToken`, options);
21176
21335
  }
21177
21336
  }
21178
21337
 
@@ -1310,6 +1310,7 @@ class IntegrationsBaseClient extends BaseClient {
1310
1310
  // @ts-ignore
1311
1311
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
1312
1312
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
1313
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
1313
1314
  if (isBrowser) {
1314
1315
  if (sessionStorage.getItem('protokol_context') === 'forge') {
1315
1316
  headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
@@ -1353,6 +1354,70 @@ class IntegrationsBaseClient extends BaseClient {
1353
1354
  }
1354
1355
  }
1355
1356
 
1357
+ /**
1358
+ * Build an RFC 7233 Range header value from the SDK's range options.
1359
+ *
1360
+ * Validation happens here rather than at the server so a typo (a float offset, a
1361
+ * negative length) fails immediately and locally instead of arriving as an opaque
1362
+ * 400 after a round trip.
1363
+ */
1364
+ function buildRangeHeader(range) {
1365
+ const { offset, length, suffix } = range;
1366
+ if (suffix !== undefined) {
1367
+ if (offset !== undefined || length !== undefined) {
1368
+ throw new Error('readRange: `suffix` cannot be combined with `offset` or `length`');
1369
+ }
1370
+ if (!Number.isInteger(suffix) || suffix <= 0) {
1371
+ throw new Error('readRange: `suffix` must be a positive integer');
1372
+ }
1373
+ return `bytes=-${suffix}`;
1374
+ }
1375
+ const start = offset !== null && offset !== void 0 ? offset : 0;
1376
+ if (!Number.isInteger(start) || start < 0) {
1377
+ throw new Error('readRange: `offset` must be a non-negative integer');
1378
+ }
1379
+ if (length === undefined) {
1380
+ return `bytes=${start}-`;
1381
+ }
1382
+ if (!Number.isInteger(length) || length <= 0) {
1383
+ throw new Error('readRange: `length` must be a positive integer');
1384
+ }
1385
+ // Range end offsets are inclusive, so a length of N ends at start + N - 1.
1386
+ return `bytes=${start}-${start + length - 1}`;
1387
+ }
1388
+ /**
1389
+ * Turn a 206 response into a ByteRangeResult.
1390
+ *
1391
+ * The Content-Range check is the important part. Requests reach media-api through
1392
+ * two proxies, and if any hop ever dropped the Range header the response would be
1393
+ * a perfectly valid 200 carrying the *entire* file — a caller asking for 64 KiB
1394
+ * of a 2 GB object would quietly receive all 2 GB. Failing loudly here turns that
1395
+ * from a silent memory blow-up into an actionable error.
1396
+ */
1397
+ function toByteRangeResult(resp) {
1398
+ var _a, _b, _c, _d, _e, _f, _g;
1399
+ const contentRange = (_b = (_a = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _a === void 0 ? void 0 : _a['content-range']) !== null && _b !== void 0 ? _b : (_c = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _c === void 0 ? void 0 : _c['Content-Range'];
1400
+ const parsed = /^bytes\s+(\d+)-(\d+)\/(\d+)$/.exec(String(contentRange !== null && contentRange !== void 0 ? contentRange : '').trim());
1401
+ if (!parsed) {
1402
+ throw new Error('readRange: response did not include a Content-Range header, so the returned body ' +
1403
+ 'may be the entire object rather than the requested range. ' +
1404
+ 'Check that the media host supports ranged reads and that no proxy is stripping the Range header.');
1405
+ }
1406
+ const start = Number(parsed[1]);
1407
+ const end = Number(parsed[2]);
1408
+ const totalSize = Number(parsed[3]);
1409
+ const etag = (_e = (_d = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _d === void 0 ? void 0 : _d.etag) !== null && _e !== void 0 ? _e : (_f = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _f === void 0 ? void 0 : _f.ETag;
1410
+ return {
1411
+ data: resp.data,
1412
+ start,
1413
+ end,
1414
+ length: end - start + 1,
1415
+ totalSize,
1416
+ eof: end >= totalSize - 1,
1417
+ etag: typeof etag === 'string' ? etag.replace(/^"|"$/g, '') : undefined,
1418
+ contentType: (_g = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _g === void 0 ? void 0 : _g['content-type'],
1419
+ };
1420
+ }
1356
1421
  /**
1357
1422
  * Document Management System (DMS) API client
1358
1423
  *
@@ -1486,6 +1551,95 @@ class DMS extends IntegrationsBaseClient {
1486
1551
  responseType: (!encoding) ? 'blob' : null
1487
1552
  });
1488
1553
  }
1554
+ /**
1555
+ * Read a slice of a stored file without transferring the whole object.
1556
+ *
1557
+ * Uses an HTTP Range request, so only the requested bytes cross the wire.
1558
+ * Slicing is positional and format-agnostic — it works on any file.
1559
+ *
1560
+ * ```ts
1561
+ * // First 64 KiB
1562
+ * const head = await dms.readRange(libraryUuid, 'reports/big.csv', { length: 65536 })
1563
+ *
1564
+ * // Continue from where that stopped
1565
+ * const next = await dms.readRange(libraryUuid, 'reports/big.csv', { offset: head.end + 1, length: 65536 })
1566
+ *
1567
+ * // Final 1 KiB
1568
+ * const tail = await dms.readRange(libraryUuid, 'reports/big.csv', { suffix: 1024 })
1569
+ * ```
1570
+ *
1571
+ * The server caps how much a single call may return, so `length` is an upper
1572
+ * bound rather than a guarantee: always advance using the returned `end`
1573
+ * rather than assuming the window you asked for. `eof` tells you when to stop.
1574
+ *
1575
+ * Byte ranges are not meaningful for .xlsx, .zip or .gz — their contents are
1576
+ * compressed as a unit, so no byte window corresponds to a range of rows.
1577
+ *
1578
+ * @param lib Library UUID
1579
+ * @param key Path of the file within the library
1580
+ * @param range Which bytes to read
1581
+ * @throws If the object is smaller than `offset` (nothing left to read), or if
1582
+ * the response came back without range metadata — see `readRange`'s
1583
+ * Content-Range check, which prevents silently receiving a whole file.
1584
+ */
1585
+ async readRange(lib, key, range = {}) {
1586
+ const { responseType = 'arraybuffer' } = range;
1587
+ const resp = await this.request('GET', `media/library/${lib}/get/${key}`, {
1588
+ headers: { Range: buildRangeHeader(range) },
1589
+ responseType,
1590
+ });
1591
+ return toByteRangeResult(resp);
1592
+ }
1593
+ /**
1594
+ * Read a file as a sequence of byte windows, newest request issued only when
1595
+ * the previous window has been consumed.
1596
+ *
1597
+ * This is the memory-bounded way to process a large file: the whole object is
1598
+ * never held at once, and a caller can stop early simply by breaking out.
1599
+ *
1600
+ * ```ts
1601
+ * for await (const chunk of dms.streamRanges(libraryUuid, 'logs/huge.ndjson', { chunkSize: 1 << 20 })) {
1602
+ * process(chunk.data) // one window at a time
1603
+ * if (foundWhatIWanted) break // no further requests are made
1604
+ * }
1605
+ * ```
1606
+ *
1607
+ * Windows are contiguous and non-overlapping, so concatenating every `data`
1608
+ * reproduces the file byte for byte. A record spanning a window boundary is
1609
+ * the caller's to reassemble — this yields bytes, not records.
1610
+ *
1611
+ * An empty object yields nothing rather than throwing.
1612
+ *
1613
+ * @param lib Library UUID
1614
+ * @param key Path of the file within the library
1615
+ * @param options Where to start and how large each window should be
1616
+ */
1617
+ async *streamRanges(lib, key, options = {}) {
1618
+ var _a, _b;
1619
+ const { chunkSize = 1024 * 1024, responseType = 'arraybuffer' } = options;
1620
+ let offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
1621
+ for (;;) {
1622
+ let chunk;
1623
+ try {
1624
+ chunk = await this.readRange(lib, key, { offset, length: chunkSize, responseType });
1625
+ }
1626
+ catch (err) {
1627
+ // 416 means the offset is at or past the end. For the first request
1628
+ // that is an empty object; afterwards it is a benign race with a
1629
+ // truncating writer. Either way the stream is simply over.
1630
+ if (((_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.status) === 416)
1631
+ return;
1632
+ throw err;
1633
+ }
1634
+ yield chunk;
1635
+ if (chunk.eof)
1636
+ return;
1637
+ // Advance from what the server actually returned, never from chunkSize:
1638
+ // the per-request cap can make a window shorter than requested, and
1639
+ // assuming otherwise would skip bytes.
1640
+ offset = chunk.end + 1;
1641
+ }
1642
+ }
1489
1643
  async download(lib, key) {
1490
1644
  return this.request('POST', `media/library/${lib}/download`, {
1491
1645
  data: {
@@ -2174,36 +2328,41 @@ class VPFR extends IntegrationsBaseClient {
2174
2328
  }
2175
2329
 
2176
2330
  class Payments extends IntegrationsBaseClient {
2331
+ // FIXME: No backend route exists for listing/searching transactions (neither
2332
+ // monri.route.ts nor wspay.route.ts under karadjordje/src/routes/v1/payments/
2333
+ // expose a "list" endpoint). This method's URL is left as-is (still broken)
2334
+ // rather than being "fixed" to another guessed path that would still 404.
2335
+ // Do not call this method until a corresponding backend route is added.
2177
2336
  async getTransactions(userId, params) {
2178
2337
  return await this.client.get(`/karadjordje/v1/payment/${userId}/list`, {
2179
2338
  params,
2180
2339
  });
2181
2340
  }
2182
- async getTransaction(provider, userId, transactionId) {
2183
- return await this.client.get(`/karadjordje/v1/payment/${provider}/${userId}/getTransaction`, {
2341
+ async getTransaction(provider, transactionId) {
2342
+ return await this.client.get(`/karadjordje/v1/payment/${provider}/getTransaction`, {
2184
2343
  params: { transactionId },
2185
2344
  });
2186
2345
  }
2187
2346
  async settings(provider) {
2188
2347
  return await this.client.get(`/karadjordje/v1/payment/${provider}/settings`);
2189
2348
  }
2190
- async deactivatePaymentLink(provider, user, transactionId) {
2191
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/deactivate/${transactionId}`);
2349
+ async deactivatePaymentLink(provider, transactionId) {
2350
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/deactivate/${transactionId}`);
2192
2351
  }
2193
- async voidTransaction(provider, user, transactionId) {
2194
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/void/${transactionId}`);
2352
+ async voidTransaction(provider, transactionId) {
2353
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/void/${transactionId}`);
2195
2354
  }
2196
- async refund(provider, user, transactionId) {
2197
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/refund/${transactionId}`);
2355
+ async refund(provider, transactionId) {
2356
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/refund/${transactionId}`);
2198
2357
  }
2199
- async getPaymentLink(provider, user, options) {
2200
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, options);
2358
+ async getPaymentLink(provider, options) {
2359
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getPaymentLink`, options);
2201
2360
  }
2202
- async getTokenRequestLink(provider, user, options) {
2203
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getTokenRequestLink`, options);
2361
+ async getTokenRequestLink(provider, options) {
2362
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getTokenRequestLink`, options);
2204
2363
  }
2205
- async directPayUsingToken(provider, user, options) {
2206
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/directPayUsingToken`, options);
2364
+ async directPayUsingToken(provider, options) {
2365
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/directPayUsingToken`, options);
2207
2366
  }
2208
2367
  }
2209
2368
 
@@ -307,3 +307,47 @@ export type DocumentCommentPayload = {
307
307
  /** Comment end position */
308
308
  to?: number;
309
309
  };
310
+ /**
311
+ * Which bytes to read. Supply either `offset`/`length` or `suffix`, not both.
312
+ */
313
+ export type ByteRangeRequest = {
314
+ /** First byte to read, 0-based. Defaults to 0. */
315
+ offset?: number;
316
+ /** How many bytes to read. Omit to read to the end of the object, subject to the server's per-request cap. */
317
+ length?: number;
318
+ /** Read the final N bytes instead. Mutually exclusive with `offset`/`length`. */
319
+ suffix?: number;
320
+ /** Axios response type for the body. Defaults to `arraybuffer`. */
321
+ responseType?: 'arraybuffer' | 'blob' | 'text';
322
+ };
323
+ /**
324
+ * A single window of bytes plus the position metadata needed to request the next one.
325
+ */
326
+ export type ByteRangeResult<T = any> = {
327
+ /** The bytes, in the shape requested via `responseType`. */
328
+ data: T;
329
+ /** Offset of the first byte returned. */
330
+ start: number;
331
+ /** Offset of the last byte returned, inclusive. */
332
+ end: number;
333
+ /** Number of bytes returned. May be less than requested — see `ByteRangeRequest.length`. */
334
+ length: number;
335
+ /** Total size of the whole object. */
336
+ totalSize: number;
337
+ /** True when this window ends at the last byte of the object. */
338
+ eof: boolean;
339
+ /** Object validator. Changes if the object is replaced, so a multi-window scan can detect it. */
340
+ etag?: string;
341
+ contentType?: string;
342
+ };
343
+ /**
344
+ * Options for walking an object window by window.
345
+ */
346
+ export type ByteStreamOptions = {
347
+ /** Byte offset to start from. Defaults to 0. */
348
+ offset?: number;
349
+ /** Bytes per window. Defaults to 1 MiB. The server may return less. */
350
+ chunkSize?: number;
351
+ /** Axios response type for each window. Defaults to `arraybuffer`. */
352
+ responseType?: 'arraybuffer' | 'blob' | 'text';
353
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",