@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.
@@ -2116,6 +2116,7 @@ var ProtokolSDK010 = (function (exports, axios) {
2116
2116
  // @ts-ignore
2117
2117
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
2118
2118
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
2119
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
2119
2120
  if (isBrowser) {
2120
2121
  if (sessionStorage.getItem('protokol_context') === 'forge') {
2121
2122
  headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
@@ -2171,6 +2172,70 @@ var ProtokolSDK010 = (function (exports, axios) {
2171
2172
  }
2172
2173
  }
2173
2174
 
2175
+ /**
2176
+ * Build an RFC 7233 Range header value from the SDK's range options.
2177
+ *
2178
+ * Validation happens here rather than at the server so a typo (a float offset, a
2179
+ * negative length) fails immediately and locally instead of arriving as an opaque
2180
+ * 400 after a round trip.
2181
+ */
2182
+ function buildRangeHeader(range) {
2183
+ const { offset, length, suffix } = range;
2184
+ if (suffix !== undefined) {
2185
+ if (offset !== undefined || length !== undefined) {
2186
+ throw new Error('readRange: `suffix` cannot be combined with `offset` or `length`');
2187
+ }
2188
+ if (!Number.isInteger(suffix) || suffix <= 0) {
2189
+ throw new Error('readRange: `suffix` must be a positive integer');
2190
+ }
2191
+ return `bytes=-${suffix}`;
2192
+ }
2193
+ const start = offset !== null && offset !== void 0 ? offset : 0;
2194
+ if (!Number.isInteger(start) || start < 0) {
2195
+ throw new Error('readRange: `offset` must be a non-negative integer');
2196
+ }
2197
+ if (length === undefined) {
2198
+ return `bytes=${start}-`;
2199
+ }
2200
+ if (!Number.isInteger(length) || length <= 0) {
2201
+ throw new Error('readRange: `length` must be a positive integer');
2202
+ }
2203
+ // Range end offsets are inclusive, so a length of N ends at start + N - 1.
2204
+ return `bytes=${start}-${start + length - 1}`;
2205
+ }
2206
+ /**
2207
+ * Turn a 206 response into a ByteRangeResult.
2208
+ *
2209
+ * The Content-Range check is the important part. Requests reach media-api through
2210
+ * two proxies, and if any hop ever dropped the Range header the response would be
2211
+ * a perfectly valid 200 carrying the *entire* file — a caller asking for 64 KiB
2212
+ * of a 2 GB object would quietly receive all 2 GB. Failing loudly here turns that
2213
+ * from a silent memory blow-up into an actionable error.
2214
+ */
2215
+ function toByteRangeResult(resp) {
2216
+ var _a, _b, _c, _d, _e, _f, _g;
2217
+ 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'];
2218
+ const parsed = /^bytes\s+(\d+)-(\d+)\/(\d+)$/.exec(String(contentRange !== null && contentRange !== void 0 ? contentRange : '').trim());
2219
+ if (!parsed) {
2220
+ throw new Error('readRange: response did not include a Content-Range header, so the returned body ' +
2221
+ 'may be the entire object rather than the requested range. ' +
2222
+ 'Check that the media host supports ranged reads and that no proxy is stripping the Range header.');
2223
+ }
2224
+ const start = Number(parsed[1]);
2225
+ const end = Number(parsed[2]);
2226
+ const totalSize = Number(parsed[3]);
2227
+ 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;
2228
+ return {
2229
+ data: resp.data,
2230
+ start,
2231
+ end,
2232
+ length: end - start + 1,
2233
+ totalSize,
2234
+ eof: end >= totalSize - 1,
2235
+ etag: typeof etag === 'string' ? etag.replace(/^"|"$/g, '') : undefined,
2236
+ contentType: (_g = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _g === void 0 ? void 0 : _g['content-type'],
2237
+ };
2238
+ }
2174
2239
  /**
2175
2240
  * Document Management System (DMS) API client
2176
2241
  *
@@ -2345,6 +2410,93 @@ var ProtokolSDK010 = (function (exports, axios) {
2345
2410
  responseType: (!encoding) ? 'blob' : null
2346
2411
  });
2347
2412
  }
2413
+ /**
2414
+ * Read a slice of a stored file without transferring the whole object.
2415
+ *
2416
+ * Uses an HTTP Range request, so only the requested bytes cross the wire.
2417
+ * Slicing is positional and format-agnostic — it works on any file.
2418
+ *
2419
+ * ```ts
2420
+ * // First 64 KiB
2421
+ * const head = await dms.readRange('reports/big.csv', { length: 65536 })
2422
+ *
2423
+ * // Continue from where that stopped
2424
+ * const next = await dms.readRange('reports/big.csv', { offset: head.end + 1, length: 65536 })
2425
+ *
2426
+ * // Final 1 KiB
2427
+ * const tail = await dms.readRange('reports/big.csv', { suffix: 1024 })
2428
+ * ```
2429
+ *
2430
+ * The server caps how much a single call may return, so `length` is an upper
2431
+ * bound rather than a guarantee: always advance using the returned `end`
2432
+ * rather than assuming the window you asked for. `eof` tells you when to stop.
2433
+ *
2434
+ * Byte ranges are not meaningful for .xlsx, .zip or .gz — their contents are
2435
+ * compressed as a unit, so no byte window corresponds to a range of rows.
2436
+ *
2437
+ * @param key Path of the file within the library
2438
+ * @param range Which bytes to read
2439
+ * @throws If the object is smaller than `offset` (nothing left to read), or if
2440
+ * the response came back without range metadata — see `readRange`'s
2441
+ * Content-Range check, which prevents silently receiving a whole file.
2442
+ */
2443
+ async readRange(key, range = {}) {
2444
+ const { responseType = 'arraybuffer' } = range;
2445
+ const resp = await this.request('GET', `media/get/${key}`, {
2446
+ headers: { Range: buildRangeHeader(range) },
2447
+ responseType,
2448
+ });
2449
+ return toByteRangeResult(resp);
2450
+ }
2451
+ /**
2452
+ * Read a file as a sequence of byte windows, newest request issued only when
2453
+ * the previous window has been consumed.
2454
+ *
2455
+ * This is the memory-bounded way to process a large file: the whole object is
2456
+ * never held at once, and a caller can stop early simply by breaking out.
2457
+ *
2458
+ * ```ts
2459
+ * for await (const chunk of dms.streamRanges('logs/huge.ndjson', { chunkSize: 1 << 20 })) {
2460
+ * process(chunk.data) // one window at a time
2461
+ * if (foundWhatIWanted) break // no further requests are made
2462
+ * }
2463
+ * ```
2464
+ *
2465
+ * Windows are contiguous and non-overlapping, so concatenating every `data`
2466
+ * reproduces the file byte for byte. A record spanning a window boundary is
2467
+ * the caller's to reassemble — this yields bytes, not records.
2468
+ *
2469
+ * An empty object yields nothing rather than throwing.
2470
+ *
2471
+ * @param key Path of the file within the library
2472
+ * @param options Where to start and how large each window should be
2473
+ */
2474
+ async *streamRanges(key, options = {}) {
2475
+ var _a, _b;
2476
+ const { chunkSize = 1024 * 1024, responseType = 'arraybuffer' } = options;
2477
+ let offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
2478
+ for (;;) {
2479
+ let chunk;
2480
+ try {
2481
+ chunk = await this.readRange(key, { offset, length: chunkSize, responseType });
2482
+ }
2483
+ catch (err) {
2484
+ // 416 means the offset is at or past the end. For the first request
2485
+ // that is an empty object; afterwards it is a benign race with a
2486
+ // truncating writer. Either way the stream is simply over.
2487
+ if (((_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.status) === 416)
2488
+ return;
2489
+ throw err;
2490
+ }
2491
+ yield chunk;
2492
+ if (chunk.eof)
2493
+ return;
2494
+ // Advance from what the server actually returned, never from chunkSize:
2495
+ // the per-request cap can make a window shorter than requested, and
2496
+ // assuming otherwise would skip bytes.
2497
+ offset = chunk.end + 1;
2498
+ }
2499
+ }
2348
2500
  async download(key) {
2349
2501
  return this.request('POST', `media/download`, {
2350
2502
  data: {
@@ -3321,36 +3473,41 @@ var ProtokolSDK010 = (function (exports, axios) {
3321
3473
  }
3322
3474
 
3323
3475
  class Payments extends IntegrationsBaseClient {
3476
+ // FIXME: No backend route exists for listing/searching transactions (neither
3477
+ // monri.route.ts nor wspay.route.ts under karadjordje/src/routes/v1/payments/
3478
+ // expose a "list" endpoint). This method's URL is left as-is (still broken)
3479
+ // rather than being "fixed" to another guessed path that would still 404.
3480
+ // Do not call this method until a corresponding backend route is added.
3324
3481
  async getTransactions(userId, params) {
3325
3482
  return await this.client.get(`/karadjordje/v1/payment/${userId}/list`, {
3326
3483
  params,
3327
3484
  });
3328
3485
  }
3329
- async getTransaction(provider, userId, transactionId) {
3330
- return await this.client.get(`/karadjordje/v1/payment/${provider}/${userId}/getTransaction`, {
3486
+ async getTransaction(provider, transactionId) {
3487
+ return await this.client.get(`/karadjordje/v1/payment/${provider}/getTransaction`, {
3331
3488
  params: { transactionId },
3332
3489
  });
3333
3490
  }
3334
3491
  async settings(provider) {
3335
3492
  return await this.client.get(`/karadjordje/v1/payment/${provider}/settings`);
3336
3493
  }
3337
- async deactivatePaymentLink(provider, user, transactionId) {
3338
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/deactivate/${transactionId}`);
3494
+ async deactivatePaymentLink(provider, transactionId) {
3495
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/deactivate/${transactionId}`);
3339
3496
  }
3340
- async voidTransaction(provider, user, transactionId) {
3341
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/void/${transactionId}`);
3497
+ async voidTransaction(provider, transactionId) {
3498
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/void/${transactionId}`);
3342
3499
  }
3343
- async refund(provider, user, transactionId) {
3344
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/refund/${transactionId}`);
3500
+ async refund(provider, transactionId) {
3501
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/refund/${transactionId}`);
3345
3502
  }
3346
- async getPaymentLink(provider, user, options) {
3347
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, options);
3503
+ async getPaymentLink(provider, options) {
3504
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getPaymentLink`, options);
3348
3505
  }
3349
- async getTokenRequestLink(provider, user, options) {
3350
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getTokenRequestLink`, options);
3506
+ async getTokenRequestLink(provider, options) {
3507
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getTokenRequestLink`, options);
3351
3508
  }
3352
- async directPayUsingToken(provider, user, options) {
3353
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/directPayUsingToken`, options);
3509
+ async directPayUsingToken(provider, options) {
3510
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/directPayUsingToken`, options);
3354
3511
  }
3355
3512
  }
3356
3513
 
package/dist/index.0.9.js CHANGED
@@ -1311,6 +1311,7 @@ var ProtokolSDK09 = (function (exports, axios) {
1311
1311
  // @ts-ignore
1312
1312
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
1313
1313
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
1314
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
1314
1315
  if (isBrowser) {
1315
1316
  if (sessionStorage.getItem('protokol_context') === 'forge') {
1316
1317
  headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
@@ -1354,6 +1355,70 @@ var ProtokolSDK09 = (function (exports, axios) {
1354
1355
  }
1355
1356
  }
1356
1357
 
1358
+ /**
1359
+ * Build an RFC 7233 Range header value from the SDK's range options.
1360
+ *
1361
+ * Validation happens here rather than at the server so a typo (a float offset, a
1362
+ * negative length) fails immediately and locally instead of arriving as an opaque
1363
+ * 400 after a round trip.
1364
+ */
1365
+ function buildRangeHeader(range) {
1366
+ const { offset, length, suffix } = range;
1367
+ if (suffix !== undefined) {
1368
+ if (offset !== undefined || length !== undefined) {
1369
+ throw new Error('readRange: `suffix` cannot be combined with `offset` or `length`');
1370
+ }
1371
+ if (!Number.isInteger(suffix) || suffix <= 0) {
1372
+ throw new Error('readRange: `suffix` must be a positive integer');
1373
+ }
1374
+ return `bytes=-${suffix}`;
1375
+ }
1376
+ const start = offset !== null && offset !== void 0 ? offset : 0;
1377
+ if (!Number.isInteger(start) || start < 0) {
1378
+ throw new Error('readRange: `offset` must be a non-negative integer');
1379
+ }
1380
+ if (length === undefined) {
1381
+ return `bytes=${start}-`;
1382
+ }
1383
+ if (!Number.isInteger(length) || length <= 0) {
1384
+ throw new Error('readRange: `length` must be a positive integer');
1385
+ }
1386
+ // Range end offsets are inclusive, so a length of N ends at start + N - 1.
1387
+ return `bytes=${start}-${start + length - 1}`;
1388
+ }
1389
+ /**
1390
+ * Turn a 206 response into a ByteRangeResult.
1391
+ *
1392
+ * The Content-Range check is the important part. Requests reach media-api through
1393
+ * two proxies, and if any hop ever dropped the Range header the response would be
1394
+ * a perfectly valid 200 carrying the *entire* file — a caller asking for 64 KiB
1395
+ * of a 2 GB object would quietly receive all 2 GB. Failing loudly here turns that
1396
+ * from a silent memory blow-up into an actionable error.
1397
+ */
1398
+ function toByteRangeResult(resp) {
1399
+ var _a, _b, _c, _d, _e, _f, _g;
1400
+ 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'];
1401
+ const parsed = /^bytes\s+(\d+)-(\d+)\/(\d+)$/.exec(String(contentRange !== null && contentRange !== void 0 ? contentRange : '').trim());
1402
+ if (!parsed) {
1403
+ throw new Error('readRange: response did not include a Content-Range header, so the returned body ' +
1404
+ 'may be the entire object rather than the requested range. ' +
1405
+ 'Check that the media host supports ranged reads and that no proxy is stripping the Range header.');
1406
+ }
1407
+ const start = Number(parsed[1]);
1408
+ const end = Number(parsed[2]);
1409
+ const totalSize = Number(parsed[3]);
1410
+ 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;
1411
+ return {
1412
+ data: resp.data,
1413
+ start,
1414
+ end,
1415
+ length: end - start + 1,
1416
+ totalSize,
1417
+ eof: end >= totalSize - 1,
1418
+ etag: typeof etag === 'string' ? etag.replace(/^"|"$/g, '') : undefined,
1419
+ contentType: (_g = resp === null || resp === void 0 ? void 0 : resp.headers) === null || _g === void 0 ? void 0 : _g['content-type'],
1420
+ };
1421
+ }
1357
1422
  /**
1358
1423
  * Document Management System (DMS) API client
1359
1424
  *
@@ -1487,6 +1552,95 @@ var ProtokolSDK09 = (function (exports, axios) {
1487
1552
  responseType: (!encoding) ? 'blob' : null
1488
1553
  });
1489
1554
  }
1555
+ /**
1556
+ * Read a slice of a stored file without transferring the whole object.
1557
+ *
1558
+ * Uses an HTTP Range request, so only the requested bytes cross the wire.
1559
+ * Slicing is positional and format-agnostic — it works on any file.
1560
+ *
1561
+ * ```ts
1562
+ * // First 64 KiB
1563
+ * const head = await dms.readRange(libraryUuid, 'reports/big.csv', { length: 65536 })
1564
+ *
1565
+ * // Continue from where that stopped
1566
+ * const next = await dms.readRange(libraryUuid, 'reports/big.csv', { offset: head.end + 1, length: 65536 })
1567
+ *
1568
+ * // Final 1 KiB
1569
+ * const tail = await dms.readRange(libraryUuid, 'reports/big.csv', { suffix: 1024 })
1570
+ * ```
1571
+ *
1572
+ * The server caps how much a single call may return, so `length` is an upper
1573
+ * bound rather than a guarantee: always advance using the returned `end`
1574
+ * rather than assuming the window you asked for. `eof` tells you when to stop.
1575
+ *
1576
+ * Byte ranges are not meaningful for .xlsx, .zip or .gz — their contents are
1577
+ * compressed as a unit, so no byte window corresponds to a range of rows.
1578
+ *
1579
+ * @param lib Library UUID
1580
+ * @param key Path of the file within the library
1581
+ * @param range Which bytes to read
1582
+ * @throws If the object is smaller than `offset` (nothing left to read), or if
1583
+ * the response came back without range metadata — see `readRange`'s
1584
+ * Content-Range check, which prevents silently receiving a whole file.
1585
+ */
1586
+ async readRange(lib, key, range = {}) {
1587
+ const { responseType = 'arraybuffer' } = range;
1588
+ const resp = await this.request('GET', `media/library/${lib}/get/${key}`, {
1589
+ headers: { Range: buildRangeHeader(range) },
1590
+ responseType,
1591
+ });
1592
+ return toByteRangeResult(resp);
1593
+ }
1594
+ /**
1595
+ * Read a file as a sequence of byte windows, newest request issued only when
1596
+ * the previous window has been consumed.
1597
+ *
1598
+ * This is the memory-bounded way to process a large file: the whole object is
1599
+ * never held at once, and a caller can stop early simply by breaking out.
1600
+ *
1601
+ * ```ts
1602
+ * for await (const chunk of dms.streamRanges(libraryUuid, 'logs/huge.ndjson', { chunkSize: 1 << 20 })) {
1603
+ * process(chunk.data) // one window at a time
1604
+ * if (foundWhatIWanted) break // no further requests are made
1605
+ * }
1606
+ * ```
1607
+ *
1608
+ * Windows are contiguous and non-overlapping, so concatenating every `data`
1609
+ * reproduces the file byte for byte. A record spanning a window boundary is
1610
+ * the caller's to reassemble — this yields bytes, not records.
1611
+ *
1612
+ * An empty object yields nothing rather than throwing.
1613
+ *
1614
+ * @param lib Library UUID
1615
+ * @param key Path of the file within the library
1616
+ * @param options Where to start and how large each window should be
1617
+ */
1618
+ async *streamRanges(lib, key, options = {}) {
1619
+ var _a, _b;
1620
+ const { chunkSize = 1024 * 1024, responseType = 'arraybuffer' } = options;
1621
+ let offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
1622
+ for (;;) {
1623
+ let chunk;
1624
+ try {
1625
+ chunk = await this.readRange(lib, key, { offset, length: chunkSize, responseType });
1626
+ }
1627
+ catch (err) {
1628
+ // 416 means the offset is at or past the end. For the first request
1629
+ // that is an empty object; afterwards it is a benign race with a
1630
+ // truncating writer. Either way the stream is simply over.
1631
+ if (((_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.status) === 416)
1632
+ return;
1633
+ throw err;
1634
+ }
1635
+ yield chunk;
1636
+ if (chunk.eof)
1637
+ return;
1638
+ // Advance from what the server actually returned, never from chunkSize:
1639
+ // the per-request cap can make a window shorter than requested, and
1640
+ // assuming otherwise would skip bytes.
1641
+ offset = chunk.end + 1;
1642
+ }
1643
+ }
1490
1644
  async download(lib, key) {
1491
1645
  return this.request('POST', `media/library/${lib}/download`, {
1492
1646
  data: {
@@ -2175,36 +2329,41 @@ var ProtokolSDK09 = (function (exports, axios) {
2175
2329
  }
2176
2330
 
2177
2331
  class Payments extends IntegrationsBaseClient {
2332
+ // FIXME: No backend route exists for listing/searching transactions (neither
2333
+ // monri.route.ts nor wspay.route.ts under karadjordje/src/routes/v1/payments/
2334
+ // expose a "list" endpoint). This method's URL is left as-is (still broken)
2335
+ // rather than being "fixed" to another guessed path that would still 404.
2336
+ // Do not call this method until a corresponding backend route is added.
2178
2337
  async getTransactions(userId, params) {
2179
2338
  return await this.client.get(`/karadjordje/v1/payment/${userId}/list`, {
2180
2339
  params,
2181
2340
  });
2182
2341
  }
2183
- async getTransaction(provider, userId, transactionId) {
2184
- return await this.client.get(`/karadjordje/v1/payment/${provider}/${userId}/getTransaction`, {
2342
+ async getTransaction(provider, transactionId) {
2343
+ return await this.client.get(`/karadjordje/v1/payment/${provider}/getTransaction`, {
2185
2344
  params: { transactionId },
2186
2345
  });
2187
2346
  }
2188
2347
  async settings(provider) {
2189
2348
  return await this.client.get(`/karadjordje/v1/payment/${provider}/settings`);
2190
2349
  }
2191
- async deactivatePaymentLink(provider, user, transactionId) {
2192
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/deactivate/${transactionId}`);
2350
+ async deactivatePaymentLink(provider, transactionId) {
2351
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/deactivate/${transactionId}`);
2193
2352
  }
2194
- async voidTransaction(provider, user, transactionId) {
2195
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/void/${transactionId}`);
2353
+ async voidTransaction(provider, transactionId) {
2354
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/void/${transactionId}`);
2196
2355
  }
2197
- async refund(provider, user, transactionId) {
2198
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/refund/${transactionId}`);
2356
+ async refund(provider, transactionId) {
2357
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/refund/${transactionId}`);
2199
2358
  }
2200
- async getPaymentLink(provider, user, options) {
2201
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, options);
2359
+ async getPaymentLink(provider, options) {
2360
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getPaymentLink`, options);
2202
2361
  }
2203
- async getTokenRequestLink(provider, user, options) {
2204
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getTokenRequestLink`, options);
2362
+ async getTokenRequestLink(provider, options) {
2363
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getTokenRequestLink`, options);
2205
2364
  }
2206
- async directPayUsingToken(provider, user, options) {
2207
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/directPayUsingToken`, options);
2365
+ async directPayUsingToken(provider, options) {
2366
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/directPayUsingToken`, options);
2208
2367
  }
2209
2368
  }
2210
2369
 
package/dist/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",
@@ -1,6 +1,6 @@
1
1
  import IntegrationsBaseClient from "../integrationsBaseClient";
2
2
  import { AxiosResponse } from "axios";
3
- import { PDFFillOptions, DataConversionParams, DataValidationParams, DataInfoParams, DataInfo, DataValidationResult, ConversionOptions, HTML2PDFOptions, PDF2HTMLOptions, MediaUploadPayload, MediaUploadBase64Payload, DocumentListParams, DocumentListResponse, DocumentCreatePayload, DocumentUpdatePayload, DocumentRestorePayload, DocumentCommentPayload, DocumentResponse, DocumentGeneratePayload, DocumentGenerateResponse, DocumentRevisionListResponse, ExtractTextPayload, ExtractTextResult, OCRExtractPayload, OCRExtractResult, LibraryExportCreatePayload, LibraryExportListResponse, MediaExportCreateResult, LibraryExportGetResult, LibraryPolicy, LibraryPolicyPayload, DirPolicy, DirPolicyPayload, NotificationRuleCreatePayload, NotificationRule, NotificationRuleListResponse, FileNotificationCreatePayload, FileNotification, FileNotificationListResponse } from "../../types/integrations";
3
+ import { PDFFillOptions, DataConversionParams, DataValidationParams, DataInfoParams, DataInfo, DataValidationResult, ConversionOptions, HTML2PDFOptions, PDF2HTMLOptions, MediaUploadPayload, MediaUploadBase64Payload, DocumentListParams, DocumentListResponse, DocumentCreatePayload, DocumentUpdatePayload, DocumentRestorePayload, DocumentCommentPayload, DocumentResponse, DocumentGeneratePayload, DocumentGenerateResponse, DocumentRevisionListResponse, ExtractTextPayload, ExtractTextResult, OCRExtractPayload, OCRExtractResult, LibraryExportCreatePayload, LibraryExportListResponse, MediaExportCreateResult, LibraryExportGetResult, LibraryPolicy, LibraryPolicyPayload, DirPolicy, DirPolicyPayload, NotificationRuleCreatePayload, NotificationRule, NotificationRuleListResponse, FileNotificationCreatePayload, FileNotification, FileNotificationListResponse, ByteRangeRequest, ByteRangeResult, ByteStreamOptions } from "../../types/integrations";
4
4
  /**
5
5
  * Document Management System (DMS) API client
6
6
  *
@@ -126,6 +126,61 @@ export default class DMS extends IntegrationsBaseClient {
126
126
  */
127
127
  uploadBase64(data: MediaUploadBase64Payload): Promise<AxiosResponse<any, any>>;
128
128
  getMedia(key: string, encoding: string): Promise<AxiosResponse<any, any>>;
129
+ /**
130
+ * Read a slice of a stored file without transferring the whole object.
131
+ *
132
+ * Uses an HTTP Range request, so only the requested bytes cross the wire.
133
+ * Slicing is positional and format-agnostic — it works on any file.
134
+ *
135
+ * ```ts
136
+ * // First 64 KiB
137
+ * const head = await dms.readRange('reports/big.csv', { length: 65536 })
138
+ *
139
+ * // Continue from where that stopped
140
+ * const next = await dms.readRange('reports/big.csv', { offset: head.end + 1, length: 65536 })
141
+ *
142
+ * // Final 1 KiB
143
+ * const tail = await dms.readRange('reports/big.csv', { suffix: 1024 })
144
+ * ```
145
+ *
146
+ * The server caps how much a single call may return, so `length` is an upper
147
+ * bound rather than a guarantee: always advance using the returned `end`
148
+ * rather than assuming the window you asked for. `eof` tells you when to stop.
149
+ *
150
+ * Byte ranges are not meaningful for .xlsx, .zip or .gz — their contents are
151
+ * compressed as a unit, so no byte window corresponds to a range of rows.
152
+ *
153
+ * @param key Path of the file within the library
154
+ * @param range Which bytes to read
155
+ * @throws If the object is smaller than `offset` (nothing left to read), or if
156
+ * the response came back without range metadata — see `readRange`'s
157
+ * Content-Range check, which prevents silently receiving a whole file.
158
+ */
159
+ readRange(key: string, range?: ByteRangeRequest): Promise<ByteRangeResult>;
160
+ /**
161
+ * Read a file as a sequence of byte windows, newest request issued only when
162
+ * the previous window has been consumed.
163
+ *
164
+ * This is the memory-bounded way to process a large file: the whole object is
165
+ * never held at once, and a caller can stop early simply by breaking out.
166
+ *
167
+ * ```ts
168
+ * for await (const chunk of dms.streamRanges('logs/huge.ndjson', { chunkSize: 1 << 20 })) {
169
+ * process(chunk.data) // one window at a time
170
+ * if (foundWhatIWanted) break // no further requests are made
171
+ * }
172
+ * ```
173
+ *
174
+ * Windows are contiguous and non-overlapping, so concatenating every `data`
175
+ * reproduces the file byte for byte. A record spanning a window boundary is
176
+ * the caller's to reassemble — this yields bytes, not records.
177
+ *
178
+ * An empty object yields nothing rather than throwing.
179
+ *
180
+ * @param key Path of the file within the library
181
+ * @param options Where to start and how large each window should be
182
+ */
183
+ streamRanges(key: string, options?: ByteStreamOptions): AsyncGenerator<ByteRangeResult>;
129
184
  download(key: string): Promise<AxiosResponse<any, any>>;
130
185
  getExifData(key: string): Promise<AxiosResponse<any, any>>;
131
186
  html2pdf(data: HTML2PDFOptions): Promise<AxiosResponse<any, any>>;
@@ -13,27 +13,27 @@ export default class Payments extends IntegrationsBaseClient {
13
13
  currentPage: number;
14
14
  pageSize: number;
15
15
  }>;
16
- getTransaction(provider: PaymentProvider, userId: string, transactionId: string): Promise<Transaction>;
16
+ getTransaction(provider: PaymentProvider, transactionId: string): Promise<Transaction>;
17
17
  settings(provider: PaymentProvider): Promise<{
18
18
  merchant_key: string;
19
19
  authenticity_token: string;
20
20
  }>;
21
- deactivatePaymentLink(provider: PaymentProvider, user: string, transactionId: string): Promise<import("axios").AxiosResponse<any, any>>;
22
- voidTransaction(provider: PaymentProvider, user: string, transactionId: string): Promise<import("axios").AxiosResponse<any, any>>;
23
- refund(provider: PaymentProvider, user: string, transactionId: string): Promise<import("axios").AxiosResponse<any, any>>;
24
- getPaymentLink(provider: PaymentProvider, user: string, options: PaymentAmount & {
21
+ deactivatePaymentLink(provider: PaymentProvider, transactionId: string): Promise<import("axios").AxiosResponse<any, any>>;
22
+ voidTransaction(provider: PaymentProvider, transactionId: string): Promise<import("axios").AxiosResponse<any, any>>;
23
+ refund(provider: PaymentProvider, transactionId: string): Promise<import("axios").AxiosResponse<any, any>>;
24
+ getPaymentLink(provider: PaymentProvider, options: PaymentAmount & {
25
25
  description: string;
26
26
  token?: string;
27
27
  isTokenRequest?: boolean;
28
28
  redirectUrl?: string;
29
29
  lang?: "en" | "es" | "ba" | "hr";
30
30
  }): Promise<import("axios").AxiosResponse<any, any>>;
31
- getTokenRequestLink(provider: PaymentProvider, user: string, options: {
31
+ getTokenRequestLink(provider: PaymentProvider, options: {
32
32
  description: string;
33
33
  redirectUrl?: string;
34
34
  lang?: "en" | "es" | "ba" | "hr";
35
35
  }): Promise<import("axios").AxiosResponse<any, any>>;
36
- directPayUsingToken(provider: PaymentProvider, user: string, options: PaymentAmount & {
36
+ directPayUsingToken(provider: PaymentProvider, options: PaymentAmount & {
37
37
  description: string;
38
38
  token: string;
39
39
  }): Promise<import("axios").AxiosResponse<any, any>>;