@brigadasos/nadeshiko-sdk 1.5.1-dev.e889ab8 → 2.0.0-dev.384ecdc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -39,6 +39,7 @@ var __export = (target, all) => {
39
39
  // generated/dev/index.ts
40
40
  var exports_dev = {};
41
41
  __export(exports_dev, {
42
+ withRetry: () => withRetry,
42
43
  user: () => exports_user_gen,
43
44
  updateUserPreferences: () => updateUserPreferences,
44
45
  updateSeriesMedia: () => updateSeriesMedia,
@@ -63,6 +64,7 @@ __export(exports_dev, {
63
64
  removeSegmentFromCollection: () => removeSegmentFromCollection,
64
65
  removeMediaFromSeries: () => removeMediaFromSeries,
65
66
  purgeAdminQueueFailed: () => purgeAdminQueueFailed,
67
+ paginate: () => paginate,
66
68
  media: () => exports_media_gen,
67
69
  listUserLabs: () => listUserLabs,
68
70
  listUserActivity: () => listUserActivity,
@@ -123,7 +125,8 @@ __export(exports_dev, {
123
125
  autocompleteMedia: () => autocompleteMedia,
124
126
  admin: () => exports_admin_gen,
125
127
  addSegmentToCollection: () => addSegmentToCollection,
126
- addMediaToSeries: () => addMediaToSeries
128
+ addMediaToSeries: () => addMediaToSeries,
129
+ NadeshikoError: () => NadeshikoError
127
130
  });
128
131
  module.exports = __toCommonJS(exports_dev);
129
132
 
@@ -1732,6 +1735,98 @@ var updateAnnouncement = (options) => (options.client ?? client).put({
1732
1735
  ...options.headers
1733
1736
  }
1734
1737
  });
1738
+ // generated/dev/retry.ts
1739
+ var RETRYABLE_STATUS = new Set([408, 429, 500, 502, 503, 504]);
1740
+ function parseRetryAfter(value) {
1741
+ const seconds = Number(value);
1742
+ if (!Number.isNaN(seconds))
1743
+ return seconds * 1000;
1744
+ const date = new Date(value);
1745
+ if (!Number.isNaN(date.getTime()))
1746
+ return Math.max(0, date.getTime() - Date.now());
1747
+ return 1000;
1748
+ }
1749
+ function backoffDelay(attempt, initial, max) {
1750
+ const jitter = Math.random() * 100;
1751
+ return Math.min(initial * 2 ** attempt + jitter, max);
1752
+ }
1753
+ function sleep(ms) {
1754
+ return new Promise((resolve) => setTimeout(resolve, ms));
1755
+ }
1756
+ function withRetry(fetchImpl = globalThis.fetch, options = {}) {
1757
+ const { maxRetries = 2, initialDelayMs = 500, maxDelayMs = 30000, timeout } = options;
1758
+ return async function retryingFetch(input, init) {
1759
+ let attempt = 0;
1760
+ while (true) {
1761
+ let timedInit = init;
1762
+ if (timeout !== undefined && !init?.signal) {
1763
+ const controller = new AbortController;
1764
+ const timeoutId = setTimeout(() => controller.abort(new Error(`Request timed out after ${timeout}ms`)), timeout);
1765
+ timedInit = { ...init, signal: controller.signal };
1766
+ let response2;
1767
+ try {
1768
+ response2 = await fetchImpl(input, timedInit);
1769
+ clearTimeout(timeoutId);
1770
+ } catch (networkError) {
1771
+ clearTimeout(timeoutId);
1772
+ if (attempt >= maxRetries)
1773
+ throw networkError;
1774
+ await sleep(backoffDelay(attempt, initialDelayMs, maxDelayMs));
1775
+ attempt++;
1776
+ continue;
1777
+ }
1778
+ if (!RETRYABLE_STATUS.has(response2.status) || attempt >= maxRetries) {
1779
+ return response2;
1780
+ }
1781
+ const retryAfter2 = response2.headers.get("Retry-After");
1782
+ const waitMs2 = retryAfter2 ? parseRetryAfter(retryAfter2) : backoffDelay(attempt, initialDelayMs, maxDelayMs);
1783
+ await sleep(waitMs2);
1784
+ attempt++;
1785
+ continue;
1786
+ }
1787
+ let response;
1788
+ try {
1789
+ response = await fetchImpl(input, timedInit);
1790
+ } catch (networkError) {
1791
+ if (attempt >= maxRetries)
1792
+ throw networkError;
1793
+ await sleep(backoffDelay(attempt, initialDelayMs, maxDelayMs));
1794
+ attempt++;
1795
+ continue;
1796
+ }
1797
+ if (!RETRYABLE_STATUS.has(response.status) || attempt >= maxRetries) {
1798
+ return response;
1799
+ }
1800
+ const retryAfter = response.headers.get("Retry-After");
1801
+ const waitMs = retryAfter ? parseRetryAfter(retryAfter) : backoffDelay(attempt, initialDelayMs, maxDelayMs);
1802
+ await sleep(waitMs);
1803
+ attempt++;
1804
+ }
1805
+ };
1806
+ }
1807
+
1808
+ // generated/dev/errors.ts
1809
+ class NadeshikoError extends Error {
1810
+ code;
1811
+ title;
1812
+ detail;
1813
+ type;
1814
+ status;
1815
+ traceId;
1816
+ errors;
1817
+ constructor(body) {
1818
+ super(body.detail || body.title || `API error ${body.status}`);
1819
+ this.name = "NadeshikoError";
1820
+ this.code = body.code;
1821
+ this.title = body.title;
1822
+ this.detail = body.detail;
1823
+ this.type = body.type;
1824
+ this.status = body.status;
1825
+ this.traceId = body.instance;
1826
+ this.errors = body.errors;
1827
+ }
1828
+ }
1829
+
1735
1830
  // generated/dev/nadeshiko.gen.ts
1736
1831
  var environments = {
1737
1832
  LOCAL: "http://localhost:5000/api",
@@ -1746,7 +1841,8 @@ var defaultSessionTokenGetter = () => {
1746
1841
  return match ? decodeURIComponent(match[1]) : undefined;
1747
1842
  };
1748
1843
  function createNadeshikoClient(config) {
1749
- const baseUrl = config.baseUrl === undefined ? environments.PRODUCTION : (config.baseUrl in environments) ? environments[config.baseUrl] : config.baseUrl;
1844
+ const rawBaseUrl = config.baseURL ?? config.baseUrl;
1845
+ const baseUrl = rawBaseUrl === undefined ? environments.PRODUCTION : (rawBaseUrl in environments) ? environments[rawBaseUrl] : rawBaseUrl;
1750
1846
  const getApiKey = async () => {
1751
1847
  if (typeof config.apiKey === "function") {
1752
1848
  return await config.apiKey();
@@ -1756,6 +1852,7 @@ function createNadeshikoClient(config) {
1756
1852
  const getSessionToken = config.sessionToken ?? defaultSessionTokenGetter;
1757
1853
  const clientInstance = createClient(createConfig({
1758
1854
  baseUrl,
1855
+ fetch: withRetry(globalThis.fetch, config.retryOptions),
1759
1856
  auth: (auth) => {
1760
1857
  if (auth.in === "cookie") {
1761
1858
  return getSessionToken();
@@ -1763,87 +1860,93 @@ function createNadeshikoClient(config) {
1763
1860
  return getApiKey();
1764
1861
  }
1765
1862
  }));
1863
+ clientInstance.interceptors.error.use((error) => {
1864
+ if (error && typeof error === "object" && "code" in error && typeof error.code === "string") {
1865
+ return new NadeshikoError(error);
1866
+ }
1867
+ return error;
1868
+ });
1766
1869
  return {
1767
1870
  client: clientInstance,
1768
- search: (options) => search({ ...options, client: clientInstance }),
1769
- getSearchStats: (options) => getSearchStats({ ...options, client: clientInstance }),
1770
- searchWords: (options) => searchWords({ ...options, client: clientInstance }),
1771
- listMedia: (options) => listMedia({ ...options, client: clientInstance }),
1772
- getSegmentByUuid: (options) => getSegmentByUuid({ ...options, client: clientInstance }),
1773
- getSegmentContext: (options) => getSegmentContext({ ...options, client: clientInstance }),
1774
- listSeries: (options) => listSeries({ ...options, client: clientInstance }),
1775
- getSeries: (options) => getSeries({ ...options, client: clientInstance }),
1776
- getCharacter: (options) => getCharacter({ ...options, client: clientInstance }),
1777
- getSeiyuu: (options) => getSeiyuu({ ...options, client: clientInstance }),
1778
- getMedia: (options) => getMedia({ ...options, client: clientInstance }),
1779
- listEpisodes: (options) => listEpisodes({ ...options, client: clientInstance }),
1780
- getEpisode: (options) => getEpisode({ ...options, client: clientInstance }),
1781
- getSegment: (options) => getSegment({ ...options, client: clientInstance }),
1782
- createMedia: (options) => createMedia({ ...options, client: clientInstance }),
1783
- autocompleteMedia: (options) => autocompleteMedia({ ...options, client: clientInstance }),
1784
- updateSegmentByUuid: (options) => updateSegmentByUuid({ ...options, client: clientInstance }),
1785
- listSegmentRevisions: (options) => listSegmentRevisions({ ...options, client: clientInstance }),
1786
- createSeries: (options) => createSeries({ ...options, client: clientInstance }),
1787
- updateSeries: (options) => updateSeries({ ...options, client: clientInstance }),
1788
- deleteSeries: (options) => deleteSeries({ ...options, client: clientInstance }),
1789
- addMediaToSeries: (options) => addMediaToSeries({ ...options, client: clientInstance }),
1790
- updateSeriesMedia: (options) => updateSeriesMedia({ ...options, client: clientInstance }),
1791
- removeMediaFromSeries: (options) => removeMediaFromSeries({ ...options, client: clientInstance }),
1792
- updateMedia: (options) => updateMedia({ ...options, client: clientInstance }),
1793
- deleteMedia: (options) => deleteMedia({ ...options, client: clientInstance }),
1794
- createEpisode: (options) => createEpisode({ ...options, client: clientInstance }),
1795
- updateEpisode: (options) => updateEpisode({ ...options, client: clientInstance }),
1796
- deleteEpisode: (options) => deleteEpisode({ ...options, client: clientInstance }),
1797
- listSegments: (options) => listSegments({ ...options, client: clientInstance }),
1798
- createSegment: (options) => createSegment({ ...options, client: clientInstance }),
1799
- createSegmentsBatch: (options) => createSegmentsBatch({ ...options, client: clientInstance }),
1800
- updateSegment: (options) => updateSegment({ ...options, client: clientInstance }),
1801
- deleteSegment: (options) => deleteSegment({ ...options, client: clientInstance }),
1802
- getUserQuota: (options) => getUserQuota({ ...options, client: clientInstance }),
1803
- createUserReport: (options) => createUserReport({ ...options, client: clientInstance }),
1804
- getUserPreferences: (options) => getUserPreferences({ ...options, client: clientInstance }),
1805
- updateUserPreferences: (options) => updateUserPreferences({ ...options, client: clientInstance }),
1806
- listUserActivity: (options) => listUserActivity({ ...options, client: clientInstance }),
1807
- trackUserActivity: (options) => trackUserActivity({ ...options, client: clientInstance }),
1808
- deleteUserActivity: (options) => deleteUserActivity({ ...options, client: clientInstance }),
1809
- getUserActivityHeatmap: (options) => getUserActivityHeatmap({ ...options, client: clientInstance }),
1810
- getUserActivityStats: (options) => getUserActivityStats({ ...options, client: clientInstance }),
1811
- deleteUserActivityByDate: (options) => deleteUserActivityByDate({ ...options, client: clientInstance }),
1812
- deleteUserActivityById: (options) => deleteUserActivityById({ ...options, client: clientInstance }),
1813
- exportUserData: (options) => exportUserData({ ...options, client: clientInstance }),
1814
- listUserLabs: (options) => listUserLabs({ ...options, client: clientInstance }),
1815
- enrollUserLab: (options) => enrollUserLab({ ...options, client: clientInstance }),
1816
- unenrollUserLab: (options) => unenrollUserLab({ ...options, client: clientInstance }),
1817
- listCollections: (options) => listCollections({ ...options, client: clientInstance }),
1818
- createCollection: (options) => createCollection({ ...options, client: clientInstance }),
1819
- getCollection: (options) => getCollection({ ...options, client: clientInstance }),
1820
- updateCollection: (options) => updateCollection({ ...options, client: clientInstance }),
1821
- deleteCollection: (options) => deleteCollection({ ...options, client: clientInstance }),
1822
- addSegmentToCollection: (options) => addSegmentToCollection({ ...options, client: clientInstance }),
1823
- updateCollectionSegment: (options) => updateCollectionSegment({ ...options, client: clientInstance }),
1824
- removeSegmentFromCollection: (options) => removeSegmentFromCollection({ ...options, client: clientInstance }),
1825
- searchCollectionSegments: (options) => searchCollectionSegments({ ...options, client: clientInstance }),
1826
- getCollectionStats: (options) => getCollectionStats({ ...options, client: clientInstance }),
1827
- getAdminDashboard: (options) => getAdminDashboard({ ...options, client: clientInstance }),
1828
- getAdminHealth: (options) => getAdminHealth({ ...options, client: clientInstance }),
1829
- triggerReindex: (options) => triggerReindex({ ...options, client: clientInstance }),
1830
- listAdminQueueStats: (options) => listAdminQueueStats({ ...options, client: clientInstance }),
1831
- getAdminQueue: (options) => getAdminQueue({ ...options, client: clientInstance }),
1832
- listAdminQueueFailed: (options) => listAdminQueueFailed({ ...options, client: clientInstance }),
1833
- retryAdminQueueFailed: (options) => retryAdminQueueFailed({ ...options, client: clientInstance }),
1834
- purgeAdminQueueFailed: (options) => purgeAdminQueueFailed({ ...options, client: clientInstance }),
1835
- impersonateAdminUser: (options) => impersonateAdminUser({ ...options, client: clientInstance }),
1836
- clearAdminImpersonation: (options) => clearAdminImpersonation({ ...options, client: clientInstance }),
1837
- listAdminReports: (options) => listAdminReports({ ...options, client: clientInstance }),
1838
- batchUpdateAdminReports: (options) => batchUpdateAdminReports({ ...options, client: clientInstance }),
1839
- updateAdminReport: (options) => updateAdminReport({ ...options, client: clientInstance }),
1840
- listAdminMediaAudits: (options) => listAdminMediaAudits({ ...options, client: clientInstance }),
1841
- updateAdminMediaAudit: (options) => updateAdminMediaAudit({ ...options, client: clientInstance }),
1842
- runAdminMediaAudit: (options) => runAdminMediaAudit({ ...options, client: clientInstance }),
1843
- listAdminMediaAuditRuns: (options) => listAdminMediaAuditRuns({ ...options, client: clientInstance }),
1844
- getAdminMediaAuditRun: (options) => getAdminMediaAuditRun({ ...options, client: clientInstance }),
1845
- getAnnouncement: (options) => getAnnouncement({ ...options, client: clientInstance }),
1846
- updateAnnouncement: (options) => updateAnnouncement({ ...options, client: clientInstance })
1871
+ search: (options) => search({ throwOnError: true, ...options, client: clientInstance }),
1872
+ getSearchStats: (options) => getSearchStats({ throwOnError: true, ...options, client: clientInstance }),
1873
+ searchWords: (options) => searchWords({ throwOnError: true, ...options, client: clientInstance }),
1874
+ listMedia: (options) => listMedia({ throwOnError: true, ...options, client: clientInstance }),
1875
+ getSegmentByUuid: (options) => getSegmentByUuid({ throwOnError: true, ...options, client: clientInstance }),
1876
+ getSegmentContext: (options) => getSegmentContext({ throwOnError: true, ...options, client: clientInstance }),
1877
+ listSeries: (options) => listSeries({ throwOnError: true, ...options, client: clientInstance }),
1878
+ getSeries: (options) => getSeries({ throwOnError: true, ...options, client: clientInstance }),
1879
+ getCharacter: (options) => getCharacter({ throwOnError: true, ...options, client: clientInstance }),
1880
+ getSeiyuu: (options) => getSeiyuu({ throwOnError: true, ...options, client: clientInstance }),
1881
+ getMedia: (options) => getMedia({ throwOnError: true, ...options, client: clientInstance }),
1882
+ listEpisodes: (options) => listEpisodes({ throwOnError: true, ...options, client: clientInstance }),
1883
+ getEpisode: (options) => getEpisode({ throwOnError: true, ...options, client: clientInstance }),
1884
+ getSegment: (options) => getSegment({ throwOnError: true, ...options, client: clientInstance }),
1885
+ createMedia: (options) => createMedia({ throwOnError: true, ...options, client: clientInstance }),
1886
+ autocompleteMedia: (options) => autocompleteMedia({ throwOnError: true, ...options, client: clientInstance }),
1887
+ updateSegmentByUuid: (options) => updateSegmentByUuid({ throwOnError: true, ...options, client: clientInstance }),
1888
+ listSegmentRevisions: (options) => listSegmentRevisions({ throwOnError: true, ...options, client: clientInstance }),
1889
+ createSeries: (options) => createSeries({ throwOnError: true, ...options, client: clientInstance }),
1890
+ updateSeries: (options) => updateSeries({ throwOnError: true, ...options, client: clientInstance }),
1891
+ deleteSeries: (options) => deleteSeries({ throwOnError: true, ...options, client: clientInstance }),
1892
+ addMediaToSeries: (options) => addMediaToSeries({ throwOnError: true, ...options, client: clientInstance }),
1893
+ updateSeriesMedia: (options) => updateSeriesMedia({ throwOnError: true, ...options, client: clientInstance }),
1894
+ removeMediaFromSeries: (options) => removeMediaFromSeries({ throwOnError: true, ...options, client: clientInstance }),
1895
+ updateMedia: (options) => updateMedia({ throwOnError: true, ...options, client: clientInstance }),
1896
+ deleteMedia: (options) => deleteMedia({ throwOnError: true, ...options, client: clientInstance }),
1897
+ createEpisode: (options) => createEpisode({ throwOnError: true, ...options, client: clientInstance }),
1898
+ updateEpisode: (options) => updateEpisode({ throwOnError: true, ...options, client: clientInstance }),
1899
+ deleteEpisode: (options) => deleteEpisode({ throwOnError: true, ...options, client: clientInstance }),
1900
+ listSegments: (options) => listSegments({ throwOnError: true, ...options, client: clientInstance }),
1901
+ createSegment: (options) => createSegment({ throwOnError: true, ...options, client: clientInstance }),
1902
+ createSegmentsBatch: (options) => createSegmentsBatch({ throwOnError: true, ...options, client: clientInstance }),
1903
+ updateSegment: (options) => updateSegment({ throwOnError: true, ...options, client: clientInstance }),
1904
+ deleteSegment: (options) => deleteSegment({ throwOnError: true, ...options, client: clientInstance }),
1905
+ getUserQuota: (options) => getUserQuota({ throwOnError: true, ...options, client: clientInstance }),
1906
+ createUserReport: (options) => createUserReport({ throwOnError: true, ...options, client: clientInstance }),
1907
+ getUserPreferences: (options) => getUserPreferences({ throwOnError: true, ...options, client: clientInstance }),
1908
+ updateUserPreferences: (options) => updateUserPreferences({ throwOnError: true, ...options, client: clientInstance }),
1909
+ listUserActivity: (options) => listUserActivity({ throwOnError: true, ...options, client: clientInstance }),
1910
+ trackUserActivity: (options) => trackUserActivity({ throwOnError: true, ...options, client: clientInstance }),
1911
+ deleteUserActivity: (options) => deleteUserActivity({ throwOnError: true, ...options, client: clientInstance }),
1912
+ getUserActivityHeatmap: (options) => getUserActivityHeatmap({ throwOnError: true, ...options, client: clientInstance }),
1913
+ getUserActivityStats: (options) => getUserActivityStats({ throwOnError: true, ...options, client: clientInstance }),
1914
+ deleteUserActivityByDate: (options) => deleteUserActivityByDate({ throwOnError: true, ...options, client: clientInstance }),
1915
+ deleteUserActivityById: (options) => deleteUserActivityById({ throwOnError: true, ...options, client: clientInstance }),
1916
+ exportUserData: (options) => exportUserData({ throwOnError: true, ...options, client: clientInstance }),
1917
+ listUserLabs: (options) => listUserLabs({ throwOnError: true, ...options, client: clientInstance }),
1918
+ enrollUserLab: (options) => enrollUserLab({ throwOnError: true, ...options, client: clientInstance }),
1919
+ unenrollUserLab: (options) => unenrollUserLab({ throwOnError: true, ...options, client: clientInstance }),
1920
+ listCollections: (options) => listCollections({ throwOnError: true, ...options, client: clientInstance }),
1921
+ createCollection: (options) => createCollection({ throwOnError: true, ...options, client: clientInstance }),
1922
+ getCollection: (options) => getCollection({ throwOnError: true, ...options, client: clientInstance }),
1923
+ updateCollection: (options) => updateCollection({ throwOnError: true, ...options, client: clientInstance }),
1924
+ deleteCollection: (options) => deleteCollection({ throwOnError: true, ...options, client: clientInstance }),
1925
+ addSegmentToCollection: (options) => addSegmentToCollection({ throwOnError: true, ...options, client: clientInstance }),
1926
+ updateCollectionSegment: (options) => updateCollectionSegment({ throwOnError: true, ...options, client: clientInstance }),
1927
+ removeSegmentFromCollection: (options) => removeSegmentFromCollection({ throwOnError: true, ...options, client: clientInstance }),
1928
+ searchCollectionSegments: (options) => searchCollectionSegments({ throwOnError: true, ...options, client: clientInstance }),
1929
+ getCollectionStats: (options) => getCollectionStats({ throwOnError: true, ...options, client: clientInstance }),
1930
+ getAdminDashboard: (options) => getAdminDashboard({ throwOnError: true, ...options, client: clientInstance }),
1931
+ getAdminHealth: (options) => getAdminHealth({ throwOnError: true, ...options, client: clientInstance }),
1932
+ triggerReindex: (options) => triggerReindex({ throwOnError: true, ...options, client: clientInstance }),
1933
+ listAdminQueueStats: (options) => listAdminQueueStats({ throwOnError: true, ...options, client: clientInstance }),
1934
+ getAdminQueue: (options) => getAdminQueue({ throwOnError: true, ...options, client: clientInstance }),
1935
+ listAdminQueueFailed: (options) => listAdminQueueFailed({ throwOnError: true, ...options, client: clientInstance }),
1936
+ retryAdminQueueFailed: (options) => retryAdminQueueFailed({ throwOnError: true, ...options, client: clientInstance }),
1937
+ purgeAdminQueueFailed: (options) => purgeAdminQueueFailed({ throwOnError: true, ...options, client: clientInstance }),
1938
+ impersonateAdminUser: (options) => impersonateAdminUser({ throwOnError: true, ...options, client: clientInstance }),
1939
+ clearAdminImpersonation: (options) => clearAdminImpersonation({ throwOnError: true, ...options, client: clientInstance }),
1940
+ listAdminReports: (options) => listAdminReports({ throwOnError: true, ...options, client: clientInstance }),
1941
+ batchUpdateAdminReports: (options) => batchUpdateAdminReports({ throwOnError: true, ...options, client: clientInstance }),
1942
+ updateAdminReport: (options) => updateAdminReport({ throwOnError: true, ...options, client: clientInstance }),
1943
+ listAdminMediaAudits: (options) => listAdminMediaAudits({ throwOnError: true, ...options, client: clientInstance }),
1944
+ updateAdminMediaAudit: (options) => updateAdminMediaAudit({ throwOnError: true, ...options, client: clientInstance }),
1945
+ runAdminMediaAudit: (options) => runAdminMediaAudit({ throwOnError: true, ...options, client: clientInstance }),
1946
+ listAdminMediaAuditRuns: (options) => listAdminMediaAuditRuns({ throwOnError: true, ...options, client: clientInstance }),
1947
+ getAdminMediaAuditRun: (options) => getAdminMediaAuditRun({ throwOnError: true, ...options, client: clientInstance }),
1948
+ getAnnouncement: (options) => getAnnouncement({ throwOnError: true, ...options, client: clientInstance }),
1949
+ updateAnnouncement: (options) => updateAnnouncement({ throwOnError: true, ...options, client: clientInstance })
1847
1950
  };
1848
1951
  }
1849
1952
  // generated/dev/internal/media.gen.ts
@@ -1927,6 +2030,35 @@ __export(exports_admin_gen, {
1927
2030
  clearAdminImpersonation: () => clearAdminImpersonation,
1928
2031
  batchUpdateAdminReports: () => batchUpdateAdminReports
1929
2032
  });
2033
+ // generated/dev/paginate.ts
2034
+ async function* paginate(fn, options, extract) {
2035
+ let cursor = null;
2036
+ let first = true;
2037
+ while (true) {
2038
+ const callOptions = first ? options : patchCursor(options, cursor);
2039
+ first = false;
2040
+ const result = await fn(callOptions);
2041
+ if ("error" in result && result.error !== undefined) {
2042
+ throw result.error;
2043
+ }
2044
+ const { items, pagination } = extract(result.data);
2045
+ for (const item of items) {
2046
+ yield item;
2047
+ }
2048
+ if (!pagination.hasMore || pagination.cursor === null)
2049
+ break;
2050
+ cursor = pagination.cursor;
2051
+ }
2052
+ }
2053
+ function patchCursor(options, cursor) {
2054
+ if (options.body !== undefined) {
2055
+ return { ...options, body: { ...options.body, cursor } };
2056
+ }
2057
+ if (options.query !== undefined) {
2058
+ return { ...options, query: { ...options.query, cursor } };
2059
+ }
2060
+ return { ...options, body: { cursor } };
2061
+ }
1930
2062
 
1931
- //# debugId=4A1D906EF6A4392464756E2164756E21
2063
+ //# debugId=76BC49C38AFCB35B64756E2164756E21
1932
2064
  //# sourceMappingURL=index.js.map