@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 +35 -0
- package/dist/index.cjs +270 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +149 -47
- package/dist/index.d.ts +149 -47
- package/dist/index.js +270 -115
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -57,38 +57,89 @@ var CollectionQueryBuilder = class {
|
|
|
57
57
|
this.api = api;
|
|
58
58
|
this.collection = collection;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Find documents (list query)
|
|
62
|
+
* GET /api/{collection}
|
|
63
|
+
* @returns Payload CMS find response with docs array and pagination
|
|
64
|
+
*/
|
|
60
65
|
find(options) {
|
|
61
66
|
return __async(this, null, function* () {
|
|
62
|
-
return this.api.
|
|
67
|
+
return this.api.requestFind(
|
|
63
68
|
`/api/${String(this.collection)}`,
|
|
64
69
|
options
|
|
65
70
|
);
|
|
66
71
|
});
|
|
67
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Find document by ID
|
|
75
|
+
* GET /api/{collection}/{id}
|
|
76
|
+
* @returns Document object directly (no wrapper)
|
|
77
|
+
*/
|
|
68
78
|
findById(id, options) {
|
|
69
79
|
return __async(this, null, function* () {
|
|
70
|
-
return this.api.
|
|
80
|
+
return this.api.requestFindById(
|
|
71
81
|
`/api/${String(this.collection)}/${String(id)}`,
|
|
72
82
|
options
|
|
73
83
|
);
|
|
74
84
|
});
|
|
75
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a new document
|
|
88
|
+
* POST /api/{collection}
|
|
89
|
+
* @returns Payload CMS mutation response with doc and message
|
|
90
|
+
*/
|
|
76
91
|
create(data) {
|
|
77
92
|
return __async(this, null, function* () {
|
|
78
|
-
return this.api.
|
|
93
|
+
return this.api.requestCreate(
|
|
79
94
|
`/api/${String(this.collection)}`,
|
|
80
95
|
data
|
|
81
96
|
);
|
|
82
97
|
});
|
|
83
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Update a document by ID
|
|
101
|
+
* PATCH /api/{collection}/{id}
|
|
102
|
+
* @returns Payload CMS mutation response with doc and message
|
|
103
|
+
*/
|
|
84
104
|
update(id, data) {
|
|
85
105
|
return __async(this, null, function* () {
|
|
86
|
-
return this.api.
|
|
106
|
+
return this.api.requestUpdate(
|
|
87
107
|
`/api/${String(this.collection)}/${String(id)}`,
|
|
88
108
|
data
|
|
89
109
|
);
|
|
90
110
|
});
|
|
91
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Count documents
|
|
114
|
+
* GET /api/{collection}/count
|
|
115
|
+
* @returns Count response with totalDocs
|
|
116
|
+
*/
|
|
117
|
+
count(options) {
|
|
118
|
+
return __async(this, null, function* () {
|
|
119
|
+
return this.api.requestCount(
|
|
120
|
+
`/api/${String(this.collection)}/count`,
|
|
121
|
+
options
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Update multiple documents (bulk update)
|
|
127
|
+
* PATCH /api/{collection}
|
|
128
|
+
* @returns Payload CMS find response with updated docs
|
|
129
|
+
*/
|
|
130
|
+
updateMany(where, data) {
|
|
131
|
+
return __async(this, null, function* () {
|
|
132
|
+
return this.api.requestUpdateMany(
|
|
133
|
+
`/api/${String(this.collection)}`,
|
|
134
|
+
{ where, data }
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Delete a document by ID
|
|
140
|
+
* DELETE /api/{collection}/{id}
|
|
141
|
+
* @returns Deleted document object directly (no wrapper)
|
|
142
|
+
*/
|
|
92
143
|
remove(id) {
|
|
93
144
|
return __async(this, null, function* () {
|
|
94
145
|
return this.api.requestDelete(
|
|
@@ -96,14 +147,24 @@ var CollectionQueryBuilder = class {
|
|
|
96
147
|
);
|
|
97
148
|
});
|
|
98
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Delete multiple documents (bulk delete)
|
|
152
|
+
* DELETE /api/{collection}
|
|
153
|
+
* @returns Payload CMS find response with deleted docs
|
|
154
|
+
*/
|
|
155
|
+
removeMany(where) {
|
|
156
|
+
return __async(this, null, function* () {
|
|
157
|
+
return this.api.requestDeleteMany(
|
|
158
|
+
`/api/${String(this.collection)}`,
|
|
159
|
+
{ where }
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
99
163
|
};
|
|
100
164
|
|
|
101
165
|
// src/core/collection/base.ts
|
|
102
166
|
import { stringify } from "qs-esm";
|
|
103
167
|
|
|
104
|
-
// src/core/internal/utils/index.ts
|
|
105
|
-
import { SignJWT, jwtVerify, decodeJwt } from "jose";
|
|
106
|
-
|
|
107
168
|
// src/core/internal/errors/index.ts
|
|
108
169
|
var SDKError = class _SDKError extends Error {
|
|
109
170
|
constructor(code, message, status, details, userMessage, suggestion) {
|
|
@@ -185,6 +246,112 @@ var createNetworkError = (message, status, details, userMessage, suggestion) =>
|
|
|
185
246
|
var createValidationError = (message, details, userMessage, suggestion) => new ValidationError(message, details, userMessage, suggestion);
|
|
186
247
|
var createApiError = (message, status, details, userMessage, suggestion) => new ApiError(message, status, details, userMessage, suggestion);
|
|
187
248
|
|
|
249
|
+
// src/core/collection/base.ts
|
|
250
|
+
var BaseApiClient = class {
|
|
251
|
+
constructor(clientKey, secretKey, baseUrl) {
|
|
252
|
+
if (!clientKey) {
|
|
253
|
+
throw createValidationError("clientKey\uB294 \uD544\uC218\uC785\uB2C8\uB2E4.");
|
|
254
|
+
}
|
|
255
|
+
this.clientKey = clientKey;
|
|
256
|
+
this.secretKey = secretKey;
|
|
257
|
+
this.baseUrl = baseUrl;
|
|
258
|
+
this.defaultOptions = { clientKey, secretKey, baseUrl };
|
|
259
|
+
}
|
|
260
|
+
buildUrl(endpoint, options) {
|
|
261
|
+
if (!options) return endpoint;
|
|
262
|
+
const queryString = stringify(options, { addQueryPrefix: true });
|
|
263
|
+
return queryString ? `${endpoint}${queryString}` : endpoint;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Parse Payload CMS find response (list query)
|
|
267
|
+
* Returns native Payload response structure
|
|
268
|
+
*/
|
|
269
|
+
parseFindResponse(response) {
|
|
270
|
+
return __async(this, null, function* () {
|
|
271
|
+
var _a, _b;
|
|
272
|
+
const contentType = response.headers.get("content-type");
|
|
273
|
+
try {
|
|
274
|
+
if (!(contentType == null ? void 0 : contentType.includes("application/json"))) {
|
|
275
|
+
throw createApiError("\uC751\uB2F5\uC774 JSON \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4.", response.status, { contentType });
|
|
276
|
+
}
|
|
277
|
+
const jsonData = yield response.json();
|
|
278
|
+
if (jsonData.docs === void 0) {
|
|
279
|
+
throw createApiError("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 find \uC751\uB2F5\uC785\uB2C8\uB2E4.", response.status, { jsonData });
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
docs: jsonData.docs,
|
|
283
|
+
totalDocs: jsonData.totalDocs || 0,
|
|
284
|
+
limit: jsonData.limit || 20,
|
|
285
|
+
totalPages: jsonData.totalPages || 0,
|
|
286
|
+
page: jsonData.page || 1,
|
|
287
|
+
pagingCounter: jsonData.pagingCounter || 1,
|
|
288
|
+
hasPrevPage: jsonData.hasPrevPage || false,
|
|
289
|
+
hasNextPage: jsonData.hasNextPage || false,
|
|
290
|
+
prevPage: (_a = jsonData.prevPage) != null ? _a : null,
|
|
291
|
+
nextPage: (_b = jsonData.nextPage) != null ? _b : null
|
|
292
|
+
};
|
|
293
|
+
} catch (error) {
|
|
294
|
+
throw createApiError("\uC751\uB2F5 \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", response.status, {
|
|
295
|
+
contentType,
|
|
296
|
+
error: error instanceof Error ? error.message : error
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Parse Payload CMS mutation response (create/update)
|
|
303
|
+
* Returns native Payload response structure
|
|
304
|
+
*/
|
|
305
|
+
parseMutationResponse(response) {
|
|
306
|
+
return __async(this, null, function* () {
|
|
307
|
+
const contentType = response.headers.get("content-type");
|
|
308
|
+
try {
|
|
309
|
+
if (!(contentType == null ? void 0 : contentType.includes("application/json"))) {
|
|
310
|
+
throw createApiError("\uC751\uB2F5\uC774 JSON \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4.", response.status, { contentType });
|
|
311
|
+
}
|
|
312
|
+
const jsonData = yield response.json();
|
|
313
|
+
if (jsonData.doc === void 0) {
|
|
314
|
+
throw createApiError("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 mutation \uC751\uB2F5\uC785\uB2C8\uB2E4.", response.status, { jsonData });
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
message: jsonData.message || "",
|
|
318
|
+
doc: jsonData.doc,
|
|
319
|
+
errors: jsonData.errors
|
|
320
|
+
};
|
|
321
|
+
} catch (error) {
|
|
322
|
+
throw createApiError("\uC751\uB2F5 \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", response.status, {
|
|
323
|
+
contentType,
|
|
324
|
+
error: error instanceof Error ? error.message : error
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Parse Payload CMS document response (findById/delete)
|
|
331
|
+
* Returns document directly without wrapper
|
|
332
|
+
*/
|
|
333
|
+
parseDocumentResponse(response) {
|
|
334
|
+
return __async(this, null, function* () {
|
|
335
|
+
const contentType = response.headers.get("content-type");
|
|
336
|
+
try {
|
|
337
|
+
if (!(contentType == null ? void 0 : contentType.includes("application/json"))) {
|
|
338
|
+
throw createApiError("\uC751\uB2F5\uC774 JSON \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4.", response.status, { contentType });
|
|
339
|
+
}
|
|
340
|
+
const jsonData = yield response.json();
|
|
341
|
+
return jsonData;
|
|
342
|
+
} catch (error) {
|
|
343
|
+
throw createApiError("\uC751\uB2F5 \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", response.status, {
|
|
344
|
+
contentType,
|
|
345
|
+
error: error instanceof Error ? error.message : error
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// src/core/internal/utils/index.ts
|
|
353
|
+
import { SignJWT, jwtVerify, decodeJwt } from "jose";
|
|
354
|
+
|
|
188
355
|
// src/core/client/types.ts
|
|
189
356
|
var API_URLS = {
|
|
190
357
|
local: "http://localhost:3000",
|
|
@@ -205,12 +372,6 @@ function resolveApiUrl(config) {
|
|
|
205
372
|
}
|
|
206
373
|
return API_URLS.production;
|
|
207
374
|
}
|
|
208
|
-
function isSuccessResponse(response) {
|
|
209
|
-
return response.success === true;
|
|
210
|
-
}
|
|
211
|
-
function isErrorResponse(response) {
|
|
212
|
-
return response.success === false;
|
|
213
|
-
}
|
|
214
375
|
|
|
215
376
|
// src/core/internal/utils/index.ts
|
|
216
377
|
var DEFAULT_TIMEOUT = 3e4;
|
|
@@ -442,105 +603,113 @@ function _fetch(url, options) {
|
|
|
442
603
|
});
|
|
443
604
|
}
|
|
444
605
|
|
|
445
|
-
// src/core/collection/
|
|
446
|
-
var
|
|
606
|
+
// src/core/collection/collections-api.ts
|
|
607
|
+
var CollectionsApi = class extends BaseApiClient {
|
|
447
608
|
constructor(clientKey, secretKey, baseUrl) {
|
|
448
|
-
|
|
449
|
-
throw createValidationError("clientKey\uB294 \uD544\uC218\uC785\uB2C8\uB2E4.");
|
|
450
|
-
}
|
|
451
|
-
this.clientKey = clientKey;
|
|
452
|
-
this.secretKey = secretKey;
|
|
453
|
-
this.baseUrl = baseUrl;
|
|
454
|
-
this.defaultOptions = { clientKey, secretKey, baseUrl };
|
|
609
|
+
super(clientKey, secretKey, baseUrl);
|
|
455
610
|
}
|
|
456
|
-
|
|
611
|
+
from(collection) {
|
|
612
|
+
return new CollectionQueryBuilder(this, collection);
|
|
613
|
+
}
|
|
614
|
+
// ============================================================================
|
|
615
|
+
// New Payload-native methods
|
|
616
|
+
// ============================================================================
|
|
617
|
+
/**
|
|
618
|
+
* Find documents (list query)
|
|
619
|
+
* GET /api/{collection}
|
|
620
|
+
*/
|
|
621
|
+
requestFind(endpoint, options) {
|
|
457
622
|
return __async(this, null, function* () {
|
|
458
623
|
const url = this.buildUrl(endpoint, options);
|
|
459
624
|
const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
|
|
460
|
-
return this.
|
|
625
|
+
return this.parseFindResponse(response);
|
|
461
626
|
});
|
|
462
627
|
}
|
|
463
|
-
|
|
628
|
+
/**
|
|
629
|
+
* Find document by ID
|
|
630
|
+
* GET /api/{collection}/{id}
|
|
631
|
+
*/
|
|
632
|
+
requestFindById(endpoint, options) {
|
|
464
633
|
return __async(this, null, function* () {
|
|
465
|
-
const
|
|
634
|
+
const url = this.buildUrl(endpoint, options);
|
|
635
|
+
const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
|
|
636
|
+
return this.parseDocumentResponse(response);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Create document
|
|
641
|
+
* POST /api/{collection}
|
|
642
|
+
*/
|
|
643
|
+
requestCreate(endpoint, data) {
|
|
644
|
+
return __async(this, null, function* () {
|
|
645
|
+
const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
466
646
|
method: "POST",
|
|
467
647
|
body: data ? JSON.stringify(data) : void 0
|
|
468
648
|
}));
|
|
469
|
-
return this.
|
|
649
|
+
return this.parseMutationResponse(response);
|
|
470
650
|
});
|
|
471
651
|
}
|
|
472
|
-
|
|
652
|
+
/**
|
|
653
|
+
* Update document
|
|
654
|
+
* PATCH /api/{collection}/{id}
|
|
655
|
+
*/
|
|
656
|
+
requestUpdate(endpoint, data) {
|
|
473
657
|
return __async(this, null, function* () {
|
|
474
|
-
const response = yield _fetch(endpoint, __spreadProps(__spreadValues(
|
|
658
|
+
const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
475
659
|
method: "PATCH",
|
|
476
660
|
body: data ? JSON.stringify(data) : void 0
|
|
477
661
|
}));
|
|
478
|
-
return this.
|
|
662
|
+
return this.parseMutationResponse(response);
|
|
479
663
|
});
|
|
480
664
|
}
|
|
481
|
-
|
|
665
|
+
/**
|
|
666
|
+
* Count documents
|
|
667
|
+
* GET /api/{collection}/count
|
|
668
|
+
*/
|
|
669
|
+
requestCount(endpoint, options) {
|
|
482
670
|
return __async(this, null, function* () {
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
return this.parseResponse(response);
|
|
671
|
+
const url = this.buildUrl(endpoint, options);
|
|
672
|
+
const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
|
|
673
|
+
return this.parseDocumentResponse(response);
|
|
487
674
|
});
|
|
488
675
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
parseResponse(response) {
|
|
676
|
+
/**
|
|
677
|
+
* Update multiple documents (bulk update)
|
|
678
|
+
* PATCH /api/{collection}
|
|
679
|
+
*/
|
|
680
|
+
requestUpdateMany(endpoint, data) {
|
|
495
681
|
return __async(this, null, function* () {
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
const pagination = {
|
|
502
|
-
page: jsonData.page || 1,
|
|
503
|
-
limit: jsonData.limit || 20,
|
|
504
|
-
totalDocs: jsonData.totalDocs || 0,
|
|
505
|
-
totalPages: jsonData.totalPages || 0,
|
|
506
|
-
hasNextPage: jsonData.hasNextPage || false,
|
|
507
|
-
hasPrevPage: jsonData.hasPrevPage || false
|
|
508
|
-
};
|
|
509
|
-
return { data: jsonData.docs, success: true, pagination };
|
|
510
|
-
}
|
|
511
|
-
return { data: jsonData, success: true };
|
|
512
|
-
}
|
|
513
|
-
const textData = yield response.text();
|
|
514
|
-
return { data: textData, success: true };
|
|
515
|
-
} catch (error) {
|
|
516
|
-
throw createApiError("\uC751\uB2F5 \uD30C\uC2F1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", response.status, {
|
|
517
|
-
contentType,
|
|
518
|
-
error: error instanceof Error ? error.message : error
|
|
519
|
-
});
|
|
520
|
-
}
|
|
682
|
+
const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
683
|
+
method: "PATCH",
|
|
684
|
+
body: JSON.stringify(data)
|
|
685
|
+
}));
|
|
686
|
+
return this.parseFindResponse(response);
|
|
521
687
|
});
|
|
522
688
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
constructor(clientKey, secretKey, baseUrl) {
|
|
528
|
-
super(clientKey, secretKey, baseUrl);
|
|
529
|
-
}
|
|
530
|
-
from(collection) {
|
|
531
|
-
return new CollectionQueryBuilder(this, collection);
|
|
532
|
-
}
|
|
533
|
-
requestGet(endpoint, options) {
|
|
534
|
-
return this.get(endpoint, options);
|
|
535
|
-
}
|
|
536
|
-
requestPost(endpoint, data) {
|
|
537
|
-
return this.post(endpoint, data);
|
|
538
|
-
}
|
|
539
|
-
requestPatch(endpoint, data) {
|
|
540
|
-
return this.patch(endpoint, data);
|
|
541
|
-
}
|
|
689
|
+
/**
|
|
690
|
+
* Delete document
|
|
691
|
+
* DELETE /api/{collection}/{id}
|
|
692
|
+
*/
|
|
542
693
|
requestDelete(endpoint) {
|
|
543
|
-
return this
|
|
694
|
+
return __async(this, null, function* () {
|
|
695
|
+
const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
696
|
+
method: "DELETE"
|
|
697
|
+
}));
|
|
698
|
+
return this.parseDocumentResponse(response);
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Delete multiple documents (bulk delete)
|
|
703
|
+
* DELETE /api/{collection}
|
|
704
|
+
*/
|
|
705
|
+
requestDeleteMany(endpoint, data) {
|
|
706
|
+
return __async(this, null, function* () {
|
|
707
|
+
const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
708
|
+
method: "DELETE",
|
|
709
|
+
body: JSON.stringify(data)
|
|
710
|
+
}));
|
|
711
|
+
return this.parseFindResponse(response);
|
|
712
|
+
});
|
|
544
713
|
}
|
|
545
714
|
};
|
|
546
715
|
|
|
@@ -639,7 +808,7 @@ var UnifiedQueryClient = class {
|
|
|
639
808
|
queryFn: () => __async(this, null, function* () {
|
|
640
809
|
var _a;
|
|
641
810
|
const response = yield this.collectionsApi.from(collection).find(queryOptions);
|
|
642
|
-
return (_a = response.
|
|
811
|
+
return (_a = response.docs) != null ? _a : [];
|
|
643
812
|
})
|
|
644
813
|
}, options));
|
|
645
814
|
}
|
|
@@ -651,7 +820,7 @@ var UnifiedQueryClient = class {
|
|
|
651
820
|
queryFn: () => __async(this, null, function* () {
|
|
652
821
|
var _a;
|
|
653
822
|
const response = yield this.collectionsApi.from(collection).find(queryOptions);
|
|
654
|
-
return (_a = response.
|
|
823
|
+
return (_a = response.docs) != null ? _a : [];
|
|
655
824
|
})
|
|
656
825
|
}, options));
|
|
657
826
|
}
|
|
@@ -661,9 +830,7 @@ var UnifiedQueryClient = class {
|
|
|
661
830
|
return useQueryOriginal(__spreadValues({
|
|
662
831
|
queryKey: collectionKeys(collection).detail(id, queryOptions),
|
|
663
832
|
queryFn: () => __async(this, null, function* () {
|
|
664
|
-
|
|
665
|
-
const response = yield this.collectionsApi.from(collection).findById(id, queryOptions);
|
|
666
|
-
return (_a = response.data) != null ? _a : null;
|
|
833
|
+
return yield this.collectionsApi.from(collection).findById(id, queryOptions);
|
|
667
834
|
})
|
|
668
835
|
}, options));
|
|
669
836
|
}
|
|
@@ -673,9 +840,7 @@ var UnifiedQueryClient = class {
|
|
|
673
840
|
return useSuspenseQueryOriginal(__spreadValues({
|
|
674
841
|
queryKey: collectionKeys(collection).detail(id, queryOptions),
|
|
675
842
|
queryFn: () => __async(this, null, function* () {
|
|
676
|
-
|
|
677
|
-
const response = yield this.collectionsApi.from(collection).findById(id, queryOptions);
|
|
678
|
-
return (_a = response.data) != null ? _a : null;
|
|
843
|
+
return yield this.collectionsApi.from(collection).findById(id, queryOptions);
|
|
679
844
|
})
|
|
680
845
|
}, options));
|
|
681
846
|
}
|
|
@@ -685,14 +850,12 @@ var UnifiedQueryClient = class {
|
|
|
685
850
|
return useInfiniteQueryOriginal(__spreadValues({
|
|
686
851
|
queryKey: collectionKeys(collection).infinite(queryOptions),
|
|
687
852
|
queryFn: (_0) => __async(this, [_0], function* ({ pageParam }) {
|
|
688
|
-
var _a;
|
|
689
853
|
const response = yield this.collectionsApi.from(collection).find(__spreadProps(__spreadValues({}, queryOptions), { page: pageParam, limit: pageSize }));
|
|
690
|
-
return
|
|
854
|
+
return response;
|
|
691
855
|
}),
|
|
692
856
|
initialPageParam: 1,
|
|
693
|
-
getNextPageParam: (lastPage
|
|
694
|
-
|
|
695
|
-
return lastPageParam + 1;
|
|
857
|
+
getNextPageParam: (lastPage) => {
|
|
858
|
+
return lastPage.hasNextPage ? lastPage.nextPage : void 0;
|
|
696
859
|
}
|
|
697
860
|
}, options));
|
|
698
861
|
}
|
|
@@ -702,14 +865,12 @@ var UnifiedQueryClient = class {
|
|
|
702
865
|
return useSuspenseInfiniteQueryOriginal(__spreadValues({
|
|
703
866
|
queryKey: collectionKeys(collection).infinite(queryOptions),
|
|
704
867
|
queryFn: (_0) => __async(this, [_0], function* ({ pageParam }) {
|
|
705
|
-
var _a;
|
|
706
868
|
const response = yield this.collectionsApi.from(collection).find(__spreadProps(__spreadValues({}, queryOptions), { page: pageParam, limit: pageSize }));
|
|
707
|
-
return
|
|
869
|
+
return response;
|
|
708
870
|
}),
|
|
709
871
|
initialPageParam: 1,
|
|
710
|
-
getNextPageParam: (lastPage
|
|
711
|
-
|
|
712
|
-
return lastPageParam + 1;
|
|
872
|
+
getNextPageParam: (lastPage) => {
|
|
873
|
+
return lastPage.hasNextPage ? lastPage.nextPage : void 0;
|
|
713
874
|
}
|
|
714
875
|
}, options));
|
|
715
876
|
}
|
|
@@ -722,7 +883,7 @@ var UnifiedQueryClient = class {
|
|
|
722
883
|
queryFn: () => __async(this, null, function* () {
|
|
723
884
|
var _a;
|
|
724
885
|
const response = yield this.collectionsApi.from(collection).find(queryOptions);
|
|
725
|
-
return (_a = response.
|
|
886
|
+
return (_a = response.docs) != null ? _a : [];
|
|
726
887
|
})
|
|
727
888
|
}, options));
|
|
728
889
|
});
|
|
@@ -734,9 +895,7 @@ var UnifiedQueryClient = class {
|
|
|
734
895
|
return this.queryClient.prefetchQuery(__spreadValues({
|
|
735
896
|
queryKey: collectionKeys(collection).detail(id, queryOptions),
|
|
736
897
|
queryFn: () => __async(this, null, function* () {
|
|
737
|
-
|
|
738
|
-
const response = yield this.collectionsApi.from(collection).findById(id, queryOptions);
|
|
739
|
-
return (_a = response.data) != null ? _a : null;
|
|
898
|
+
return yield this.collectionsApi.from(collection).findById(id, queryOptions);
|
|
740
899
|
})
|
|
741
900
|
}, options));
|
|
742
901
|
});
|
|
@@ -749,14 +908,12 @@ var UnifiedQueryClient = class {
|
|
|
749
908
|
return this.queryClient.prefetchInfiniteQuery({
|
|
750
909
|
queryKey: collectionKeys(collection).infinite(queryOptions),
|
|
751
910
|
queryFn: (_0) => __async(this, [_0], function* ({ pageParam }) {
|
|
752
|
-
var _a2;
|
|
753
911
|
const response = yield this.collectionsApi.from(collection).find(__spreadProps(__spreadValues({}, queryOptions), { page: pageParam, limit: pageSize }));
|
|
754
|
-
return
|
|
912
|
+
return response;
|
|
755
913
|
}),
|
|
756
914
|
initialPageParam: 1,
|
|
757
|
-
getNextPageParam: (lastPage
|
|
758
|
-
|
|
759
|
-
return lastPageParam + 1;
|
|
915
|
+
getNextPageParam: (lastPage) => {
|
|
916
|
+
return lastPage.hasNextPage ? lastPage.nextPage : void 0;
|
|
760
917
|
},
|
|
761
918
|
pages: (_a = options == null ? void 0 : options.pages) != null ? _a : 1,
|
|
762
919
|
staleTime: options == null ? void 0 : options.staleTime
|
|
@@ -1029,10 +1186,8 @@ export {
|
|
|
1029
1186
|
handleWebhook,
|
|
1030
1187
|
isApiError,
|
|
1031
1188
|
isConfigError,
|
|
1032
|
-
isErrorResponse,
|
|
1033
1189
|
isNetworkError,
|
|
1034
1190
|
isSDKError,
|
|
1035
|
-
isSuccessResponse,
|
|
1036
1191
|
isTimeoutError,
|
|
1037
1192
|
isValidWebhookEvent,
|
|
1038
1193
|
isValidationError,
|