@01.software/sdk 0.1.0-dev.260206.8918543 → 0.1.0-dev.260210.4ecca43

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 CHANGED
@@ -104,6 +104,41 @@ const { data } = await client.from('products').update('id', { name: 'Updated' })
104
104
  await client.from('products').remove('id')
105
105
  ```
106
106
 
107
+ ### API Response Structure
108
+
109
+ All SDK methods return a standardized response format:
110
+
111
+ ```typescript
112
+ // Success Response
113
+ interface ApiSuccessResponse<T> {
114
+ data: T // Actual data
115
+ success: true
116
+ message?: string // Optional message from server
117
+ pagination?: PaginationMeta // For list queries
118
+ }
119
+
120
+ // Error Response
121
+ interface ApiErrorResponse {
122
+ data: null
123
+ success: false
124
+ error: {
125
+ code: string
126
+ message: string
127
+ details?: unknown
128
+ }
129
+ }
130
+ ```
131
+
132
+ **Payload CMS API Mapping:**
133
+
134
+ | Operation | Payload Response | SDK Response |
135
+ |-----------|-----------------|--------------|
136
+ | `find()` | `{docs: [], totalDocs, ...}` | `{data: [], success: true, pagination: {...}}` |
137
+ | `findById()` | `{...document}` | `{data: {...}, success: true}` |
138
+ | `create()` | `{doc: {...}, message}` | `{data: {...}, success: true, message}` |
139
+ | `update()` | `{doc: {...}, message}` | `{data: {...}, success: true, message}` |
140
+ | `remove()` | `{doc: {...}, message}` | `{data: {...}, success: true, message}` |
141
+
107
142
  ### React Query Hooks
108
143
 
109
144
  ```typescript
package/dist/index.cjs CHANGED
@@ -106,10 +106,8 @@ __export(index_exports, {
106
106
  handleWebhook: () => handleWebhook,
107
107
  isApiError: () => isApiError,
108
108
  isConfigError: () => isConfigError,
109
- isErrorResponse: () => isErrorResponse,
110
109
  isNetworkError: () => isNetworkError,
111
110
  isSDKError: () => isSDKError,
112
- isSuccessResponse: () => isSuccessResponse,
113
111
  isTimeoutError: () => isTimeoutError,
114
112
  isValidWebhookEvent: () => isValidWebhookEvent,
115
113
  isValidationError: () => isValidationError,
@@ -125,38 +123,89 @@ var CollectionQueryBuilder = class {
125
123
  this.api = api;
126
124
  this.collection = collection;
127
125
  }
126
+ /**
127
+ * Find documents (list query)
128
+ * GET /api/{collection}
129
+ * @returns Payload CMS find response with docs array and pagination
130
+ */
128
131
  find(options) {
129
132
  return __async(this, null, function* () {
130
- return this.api.requestGet(
133
+ return this.api.requestFind(
131
134
  `/api/${String(this.collection)}`,
132
135
  options
133
136
  );
134
137
  });
135
138
  }
139
+ /**
140
+ * Find document by ID
141
+ * GET /api/{collection}/{id}
142
+ * @returns Document object directly (no wrapper)
143
+ */
136
144
  findById(id, options) {
137
145
  return __async(this, null, function* () {
138
- return this.api.requestGet(
146
+ return this.api.requestFindById(
139
147
  `/api/${String(this.collection)}/${String(id)}`,
140
148
  options
141
149
  );
142
150
  });
143
151
  }
152
+ /**
153
+ * Create a new document
154
+ * POST /api/{collection}
155
+ * @returns Payload CMS mutation response with doc and message
156
+ */
144
157
  create(data) {
145
158
  return __async(this, null, function* () {
146
- return this.api.requestPost(
159
+ return this.api.requestCreate(
147
160
  `/api/${String(this.collection)}`,
148
161
  data
149
162
  );
150
163
  });
151
164
  }
165
+ /**
166
+ * Update a document by ID
167
+ * PATCH /api/{collection}/{id}
168
+ * @returns Payload CMS mutation response with doc and message
169
+ */
152
170
  update(id, data) {
153
171
  return __async(this, null, function* () {
154
- return this.api.requestPatch(
172
+ return this.api.requestUpdate(
155
173
  `/api/${String(this.collection)}/${String(id)}`,
156
174
  data
157
175
  );
158
176
  });
159
177
  }
178
+ /**
179
+ * Count documents
180
+ * GET /api/{collection}/count
181
+ * @returns Count response with totalDocs
182
+ */
183
+ count(options) {
184
+ return __async(this, null, function* () {
185
+ return this.api.requestCount(
186
+ `/api/${String(this.collection)}/count`,
187
+ options
188
+ );
189
+ });
190
+ }
191
+ /**
192
+ * Update multiple documents (bulk update)
193
+ * PATCH /api/{collection}
194
+ * @returns Payload CMS find response with updated docs
195
+ */
196
+ updateMany(where, data) {
197
+ return __async(this, null, function* () {
198
+ return this.api.requestUpdateMany(
199
+ `/api/${String(this.collection)}`,
200
+ { where, data }
201
+ );
202
+ });
203
+ }
204
+ /**
205
+ * Delete a document by ID
206
+ * DELETE /api/{collection}/{id}
207
+ * @returns Deleted document object directly (no wrapper)
208
+ */
160
209
  remove(id) {
161
210
  return __async(this, null, function* () {
162
211
  return this.api.requestDelete(
@@ -164,14 +213,24 @@ var CollectionQueryBuilder = class {
164
213
  );
165
214
  });
166
215
  }
216
+ /**
217
+ * Delete multiple documents (bulk delete)
218
+ * DELETE /api/{collection}
219
+ * @returns Payload CMS find response with deleted docs
220
+ */
221
+ removeMany(where) {
222
+ return __async(this, null, function* () {
223
+ return this.api.requestDeleteMany(
224
+ `/api/${String(this.collection)}`,
225
+ { where }
226
+ );
227
+ });
228
+ }
167
229
  };
168
230
 
169
231
  // src/core/collection/base.ts
170
232
  var import_qs_esm = require("qs-esm");
171
233
 
172
- // src/core/internal/utils/index.ts
173
- var import_jose = require("jose");
174
-
175
234
  // src/core/internal/errors/index.ts
176
235
  var SDKError = class _SDKError extends Error {
177
236
  constructor(code, message, status, details, userMessage, suggestion) {
@@ -253,6 +312,112 @@ var createNetworkError = (message, status, details, userMessage, suggestion) =>
253
312
  var createValidationError = (message, details, userMessage, suggestion) => new ValidationError(message, details, userMessage, suggestion);
254
313
  var createApiError = (message, status, details, userMessage, suggestion) => new ApiError(message, status, details, userMessage, suggestion);
255
314
 
315
+ // src/core/collection/base.ts
316
+ var BaseApiClient = class {
317
+ constructor(clientKey, secretKey, baseUrl) {
318
+ if (!clientKey) {
319
+ throw createValidationError("clientKey\uB294 \uD544\uC218\uC785\uB2C8\uB2E4.");
320
+ }
321
+ this.clientKey = clientKey;
322
+ this.secretKey = secretKey;
323
+ this.baseUrl = baseUrl;
324
+ this.defaultOptions = { clientKey, secretKey, baseUrl };
325
+ }
326
+ buildUrl(endpoint, options) {
327
+ if (!options) return endpoint;
328
+ const queryString = (0, import_qs_esm.stringify)(options, { addQueryPrefix: true });
329
+ return queryString ? `${endpoint}${queryString}` : endpoint;
330
+ }
331
+ /**
332
+ * Parse Payload CMS find response (list query)
333
+ * Returns native Payload response structure
334
+ */
335
+ parseFindResponse(response) {
336
+ return __async(this, null, function* () {
337
+ var _a, _b;
338
+ const contentType = response.headers.get("content-type");
339
+ try {
340
+ if (!(contentType == null ? void 0 : contentType.includes("application/json"))) {
341
+ throw createApiError("\uC751\uB2F5\uC774 JSON \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4.", response.status, { contentType });
342
+ }
343
+ const jsonData = yield response.json();
344
+ if (jsonData.docs === void 0) {
345
+ throw createApiError("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 find \uC751\uB2F5\uC785\uB2C8\uB2E4.", response.status, { jsonData });
346
+ }
347
+ return {
348
+ docs: jsonData.docs,
349
+ totalDocs: jsonData.totalDocs || 0,
350
+ limit: jsonData.limit || 20,
351
+ totalPages: jsonData.totalPages || 0,
352
+ page: jsonData.page || 1,
353
+ pagingCounter: jsonData.pagingCounter || 1,
354
+ hasPrevPage: jsonData.hasPrevPage || false,
355
+ hasNextPage: jsonData.hasNextPage || false,
356
+ prevPage: (_a = jsonData.prevPage) != null ? _a : null,
357
+ nextPage: (_b = jsonData.nextPage) != null ? _b : null
358
+ };
359
+ } catch (error) {
360
+ throw createApiError("\uC751\uB2F5 \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", response.status, {
361
+ contentType,
362
+ error: error instanceof Error ? error.message : error
363
+ });
364
+ }
365
+ });
366
+ }
367
+ /**
368
+ * Parse Payload CMS mutation response (create/update)
369
+ * Returns native Payload response structure
370
+ */
371
+ parseMutationResponse(response) {
372
+ return __async(this, null, function* () {
373
+ const contentType = response.headers.get("content-type");
374
+ try {
375
+ if (!(contentType == null ? void 0 : contentType.includes("application/json"))) {
376
+ throw createApiError("\uC751\uB2F5\uC774 JSON \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4.", response.status, { contentType });
377
+ }
378
+ const jsonData = yield response.json();
379
+ if (jsonData.doc === void 0) {
380
+ throw createApiError("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 mutation \uC751\uB2F5\uC785\uB2C8\uB2E4.", response.status, { jsonData });
381
+ }
382
+ return {
383
+ message: jsonData.message || "",
384
+ doc: jsonData.doc,
385
+ errors: jsonData.errors
386
+ };
387
+ } catch (error) {
388
+ throw createApiError("\uC751\uB2F5 \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", response.status, {
389
+ contentType,
390
+ error: error instanceof Error ? error.message : error
391
+ });
392
+ }
393
+ });
394
+ }
395
+ /**
396
+ * Parse Payload CMS document response (findById/delete)
397
+ * Returns document directly without wrapper
398
+ */
399
+ parseDocumentResponse(response) {
400
+ return __async(this, null, function* () {
401
+ const contentType = response.headers.get("content-type");
402
+ try {
403
+ if (!(contentType == null ? void 0 : contentType.includes("application/json"))) {
404
+ throw createApiError("\uC751\uB2F5\uC774 JSON \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4.", response.status, { contentType });
405
+ }
406
+ const jsonData = yield response.json();
407
+ return jsonData;
408
+ } catch (error) {
409
+ throw createApiError("\uC751\uB2F5 \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", response.status, {
410
+ contentType,
411
+ error: error instanceof Error ? error.message : error
412
+ });
413
+ }
414
+ });
415
+ }
416
+ };
417
+
418
+ // src/core/internal/utils/index.ts
419
+ var import_jose = require("jose");
420
+
256
421
  // src/core/client/types.ts
257
422
  var API_URLS = {
258
423
  local: "http://localhost:3000",
@@ -273,12 +438,6 @@ function resolveApiUrl(config) {
273
438
  }
274
439
  return API_URLS.production;
275
440
  }
276
- function isSuccessResponse(response) {
277
- return response.success === true;
278
- }
279
- function isErrorResponse(response) {
280
- return response.success === false;
281
- }
282
441
 
283
442
  // src/core/internal/utils/index.ts
284
443
  var DEFAULT_TIMEOUT = 3e4;
@@ -510,105 +669,113 @@ function _fetch(url, options) {
510
669
  });
511
670
  }
512
671
 
513
- // src/core/collection/base.ts
514
- var BaseApiClient = class {
672
+ // src/core/collection/collections-api.ts
673
+ var CollectionsApi = class extends BaseApiClient {
515
674
  constructor(clientKey, secretKey, baseUrl) {
516
- if (!clientKey) {
517
- throw createValidationError("clientKey\uB294 \uD544\uC218\uC785\uB2C8\uB2E4.");
518
- }
519
- this.clientKey = clientKey;
520
- this.secretKey = secretKey;
521
- this.baseUrl = baseUrl;
522
- this.defaultOptions = { clientKey, secretKey, baseUrl };
675
+ super(clientKey, secretKey, baseUrl);
523
676
  }
524
- get(endpoint, options) {
677
+ from(collection) {
678
+ return new CollectionQueryBuilder(this, collection);
679
+ }
680
+ // ============================================================================
681
+ // New Payload-native methods
682
+ // ============================================================================
683
+ /**
684
+ * Find documents (list query)
685
+ * GET /api/{collection}
686
+ */
687
+ requestFind(endpoint, options) {
525
688
  return __async(this, null, function* () {
526
689
  const url = this.buildUrl(endpoint, options);
527
690
  const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
528
- return this.parseResponse(response);
691
+ return this.parseFindResponse(response);
529
692
  });
530
693
  }
531
- post(endpoint, data, options) {
694
+ /**
695
+ * Find document by ID
696
+ * GET /api/{collection}/{id}
697
+ */
698
+ requestFindById(endpoint, options) {
532
699
  return __async(this, null, function* () {
533
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues(__spreadValues({}, this.defaultOptions), options), {
700
+ const url = this.buildUrl(endpoint, options);
701
+ const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
702
+ return this.parseDocumentResponse(response);
703
+ });
704
+ }
705
+ /**
706
+ * Create document
707
+ * POST /api/{collection}
708
+ */
709
+ requestCreate(endpoint, data) {
710
+ return __async(this, null, function* () {
711
+ const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
534
712
  method: "POST",
535
713
  body: data ? JSON.stringify(data) : void 0
536
714
  }));
537
- return this.parseResponse(response);
715
+ return this.parseMutationResponse(response);
538
716
  });
539
717
  }
540
- patch(endpoint, data, options) {
718
+ /**
719
+ * Update document
720
+ * PATCH /api/{collection}/{id}
721
+ */
722
+ requestUpdate(endpoint, data) {
541
723
  return __async(this, null, function* () {
542
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues(__spreadValues({}, this.defaultOptions), options), {
724
+ const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
543
725
  method: "PATCH",
544
726
  body: data ? JSON.stringify(data) : void 0
545
727
  }));
546
- return this.parseResponse(response);
728
+ return this.parseMutationResponse(response);
547
729
  });
548
730
  }
549
- delete(endpoint, options) {
731
+ /**
732
+ * Count documents
733
+ * GET /api/{collection}/count
734
+ */
735
+ requestCount(endpoint, options) {
550
736
  return __async(this, null, function* () {
551
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues(__spreadValues({}, this.defaultOptions), options), {
552
- method: "DELETE"
553
- }));
554
- return this.parseResponse(response);
737
+ const url = this.buildUrl(endpoint, options);
738
+ const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
739
+ return this.parseDocumentResponse(response);
555
740
  });
556
741
  }
557
- buildUrl(endpoint, options) {
558
- if (!options) return endpoint;
559
- const queryString = (0, import_qs_esm.stringify)(options, { addQueryPrefix: true });
560
- return queryString ? `${endpoint}${queryString}` : endpoint;
561
- }
562
- parseResponse(response) {
742
+ /**
743
+ * Update multiple documents (bulk update)
744
+ * PATCH /api/{collection}
745
+ */
746
+ requestUpdateMany(endpoint, data) {
563
747
  return __async(this, null, function* () {
564
- const contentType = response.headers.get("content-type");
565
- try {
566
- if (contentType == null ? void 0 : contentType.includes("application/json")) {
567
- const jsonData = yield response.json();
568
- if (jsonData.docs !== void 0) {
569
- const pagination = {
570
- page: jsonData.page || 1,
571
- limit: jsonData.limit || 20,
572
- totalDocs: jsonData.totalDocs || 0,
573
- totalPages: jsonData.totalPages || 0,
574
- hasNextPage: jsonData.hasNextPage || false,
575
- hasPrevPage: jsonData.hasPrevPage || false
576
- };
577
- return { data: jsonData.docs, success: true, pagination };
578
- }
579
- return { data: jsonData, success: true };
580
- }
581
- const textData = yield response.text();
582
- return { data: textData, success: true };
583
- } catch (error) {
584
- throw createApiError("\uC751\uB2F5 \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", response.status, {
585
- contentType,
586
- error: error instanceof Error ? error.message : error
587
- });
588
- }
748
+ const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
749
+ method: "PATCH",
750
+ body: JSON.stringify(data)
751
+ }));
752
+ return this.parseFindResponse(response);
589
753
  });
590
754
  }
591
- };
592
-
593
- // src/core/collection/collections-api.ts
594
- var CollectionsApi = class extends BaseApiClient {
595
- constructor(clientKey, secretKey, baseUrl) {
596
- super(clientKey, secretKey, baseUrl);
597
- }
598
- from(collection) {
599
- return new CollectionQueryBuilder(this, collection);
600
- }
601
- requestGet(endpoint, options) {
602
- return this.get(endpoint, options);
603
- }
604
- requestPost(endpoint, data) {
605
- return this.post(endpoint, data);
606
- }
607
- requestPatch(endpoint, data) {
608
- return this.patch(endpoint, data);
609
- }
755
+ /**
756
+ * Delete document
757
+ * DELETE /api/{collection}/{id}
758
+ */
610
759
  requestDelete(endpoint) {
611
- return this.delete(endpoint);
760
+ return __async(this, null, function* () {
761
+ const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
762
+ method: "DELETE"
763
+ }));
764
+ return this.parseDocumentResponse(response);
765
+ });
766
+ }
767
+ /**
768
+ * Delete multiple documents (bulk delete)
769
+ * DELETE /api/{collection}
770
+ */
771
+ requestDeleteMany(endpoint, data) {
772
+ return __async(this, null, function* () {
773
+ const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
774
+ method: "DELETE",
775
+ body: JSON.stringify(data)
776
+ }));
777
+ return this.parseFindResponse(response);
778
+ });
612
779
  }
613
780
  };
614
781
 
@@ -702,7 +869,7 @@ var UnifiedQueryClient = class {
702
869
  queryFn: () => __async(this, null, function* () {
703
870
  var _a;
704
871
  const response = yield this.collectionsApi.from(collection).find(queryOptions);
705
- return (_a = response.data) != null ? _a : [];
872
+ return (_a = response.docs) != null ? _a : [];
706
873
  })
707
874
  }, options));
708
875
  }
@@ -714,7 +881,7 @@ var UnifiedQueryClient = class {
714
881
  queryFn: () => __async(this, null, function* () {
715
882
  var _a;
716
883
  const response = yield this.collectionsApi.from(collection).find(queryOptions);
717
- return (_a = response.data) != null ? _a : [];
884
+ return (_a = response.docs) != null ? _a : [];
718
885
  })
719
886
  }, options));
720
887
  }
@@ -724,9 +891,7 @@ var UnifiedQueryClient = class {
724
891
  return (0, import_react_query2.useQuery)(__spreadValues({
725
892
  queryKey: collectionKeys(collection).detail(id, queryOptions),
726
893
  queryFn: () => __async(this, null, function* () {
727
- var _a;
728
- const response = yield this.collectionsApi.from(collection).findById(id, queryOptions);
729
- return (_a = response.data) != null ? _a : null;
894
+ return yield this.collectionsApi.from(collection).findById(id, queryOptions);
730
895
  })
731
896
  }, options));
732
897
  }
@@ -736,9 +901,7 @@ var UnifiedQueryClient = class {
736
901
  return (0, import_react_query2.useSuspenseQuery)(__spreadValues({
737
902
  queryKey: collectionKeys(collection).detail(id, queryOptions),
738
903
  queryFn: () => __async(this, null, function* () {
739
- var _a;
740
- const response = yield this.collectionsApi.from(collection).findById(id, queryOptions);
741
- return (_a = response.data) != null ? _a : null;
904
+ return yield this.collectionsApi.from(collection).findById(id, queryOptions);
742
905
  })
743
906
  }, options));
744
907
  }
@@ -748,14 +911,12 @@ var UnifiedQueryClient = class {
748
911
  return (0, import_react_query2.useInfiniteQuery)(__spreadValues({
749
912
  queryKey: collectionKeys(collection).infinite(queryOptions),
750
913
  queryFn: (_0) => __async(this, [_0], function* ({ pageParam }) {
751
- var _a;
752
914
  const response = yield this.collectionsApi.from(collection).find(__spreadProps(__spreadValues({}, queryOptions), { page: pageParam, limit: pageSize }));
753
- return (_a = response.data) != null ? _a : [];
915
+ return response;
754
916
  }),
755
917
  initialPageParam: 1,
756
- getNextPageParam: (lastPage, _allPages, lastPageParam) => {
757
- if (!Array.isArray(lastPage) || lastPage.length < pageSize) return void 0;
758
- return lastPageParam + 1;
918
+ getNextPageParam: (lastPage) => {
919
+ return lastPage.hasNextPage ? lastPage.nextPage : void 0;
759
920
  }
760
921
  }, options));
761
922
  }
@@ -765,14 +926,12 @@ var UnifiedQueryClient = class {
765
926
  return (0, import_react_query2.useSuspenseInfiniteQuery)(__spreadValues({
766
927
  queryKey: collectionKeys(collection).infinite(queryOptions),
767
928
  queryFn: (_0) => __async(this, [_0], function* ({ pageParam }) {
768
- var _a;
769
929
  const response = yield this.collectionsApi.from(collection).find(__spreadProps(__spreadValues({}, queryOptions), { page: pageParam, limit: pageSize }));
770
- return (_a = response.data) != null ? _a : [];
930
+ return response;
771
931
  }),
772
932
  initialPageParam: 1,
773
- getNextPageParam: (lastPage, _allPages, lastPageParam) => {
774
- if (!Array.isArray(lastPage) || lastPage.length < pageSize) return void 0;
775
- return lastPageParam + 1;
933
+ getNextPageParam: (lastPage) => {
934
+ return lastPage.hasNextPage ? lastPage.nextPage : void 0;
776
935
  }
777
936
  }, options));
778
937
  }
@@ -785,7 +944,7 @@ var UnifiedQueryClient = class {
785
944
  queryFn: () => __async(this, null, function* () {
786
945
  var _a;
787
946
  const response = yield this.collectionsApi.from(collection).find(queryOptions);
788
- return (_a = response.data) != null ? _a : [];
947
+ return (_a = response.docs) != null ? _a : [];
789
948
  })
790
949
  }, options));
791
950
  });
@@ -797,9 +956,7 @@ var UnifiedQueryClient = class {
797
956
  return this.queryClient.prefetchQuery(__spreadValues({
798
957
  queryKey: collectionKeys(collection).detail(id, queryOptions),
799
958
  queryFn: () => __async(this, null, function* () {
800
- var _a;
801
- const response = yield this.collectionsApi.from(collection).findById(id, queryOptions);
802
- return (_a = response.data) != null ? _a : null;
959
+ return yield this.collectionsApi.from(collection).findById(id, queryOptions);
803
960
  })
804
961
  }, options));
805
962
  });
@@ -812,14 +969,12 @@ var UnifiedQueryClient = class {
812
969
  return this.queryClient.prefetchInfiniteQuery({
813
970
  queryKey: collectionKeys(collection).infinite(queryOptions),
814
971
  queryFn: (_0) => __async(this, [_0], function* ({ pageParam }) {
815
- var _a2;
816
972
  const response = yield this.collectionsApi.from(collection).find(__spreadProps(__spreadValues({}, queryOptions), { page: pageParam, limit: pageSize }));
817
- return (_a2 = response.data) != null ? _a2 : [];
973
+ return response;
818
974
  }),
819
975
  initialPageParam: 1,
820
- getNextPageParam: (lastPage, _allPages, lastPageParam) => {
821
- if (!Array.isArray(lastPage) || lastPage.length < pageSize) return void 0;
822
- return lastPageParam + 1;
976
+ getNextPageParam: (lastPage) => {
977
+ return lastPage.hasNextPage ? lastPage.nextPage : void 0;
823
978
  },
824
979
  pages: (_a = options == null ? void 0 : options.pages) != null ? _a : 1,
825
980
  staleTime: options == null ? void 0 : options.staleTime