@querykitjs/web 3.1.0 → 4.0.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.
package/dist/index.cjs CHANGED
@@ -1,361 +1,2 @@
1
- 'use strict';
2
-
3
- var core = require('@querykitjs/core');
4
-
5
- // src/filters.ts
6
- function createFilters() {
7
- return core.createFilters();
8
- }
9
- var DEFAULTS = {
10
- filterField: "filter",
11
- sortField: "sort",
12
- columnsField: "columns",
13
- withField: "with",
14
- withDeletedField: "withDeleted",
15
- pageField: "page",
16
- perPageField: "perPage",
17
- limitField: "limit",
18
- offsetField: "offset",
19
- cursorField: "cursor",
20
- defaultPerPage: core.DEFAULT_PER_PAGE,
21
- defaultLimit: core.DEFAULT_LIMIT,
22
- maxPerPage: core.DEFAULT_MAX_PER_PAGE,
23
- maxLimit: core.DEFAULT_MAX_LIMIT,
24
- defaultSort: [{ key: "createdAt", direction: "desc" }],
25
- pruneEmpty: true
26
- };
27
- function isEmptyValue(value) {
28
- if (value === void 0 || value === null || value === "") return true;
29
- if (Array.isArray(value) && value.length === 0) return true;
30
- return false;
31
- }
32
- function toSortItem(item) {
33
- if (typeof item === "string") {
34
- const desc = item.startsWith("-");
35
- const key = (desc ? item.slice(1) : item).trim();
36
- return key ? { key, direction: desc ? "desc" : "asc" } : void 0;
37
- }
38
- return item && item.key ? { key: item.key, direction: item.direction ?? "asc" } : void 0;
39
- }
40
- function normalizeSort(input, fallback) {
41
- if (!input || input.length === 0) return fallback;
42
- const items = input.map(toSortItem).filter((i) => i !== void 0);
43
- return items.length ? items : fallback;
44
- }
45
- function normalizeCondition(condition, prune) {
46
- const operation = condition.operation ?? "=";
47
- const noValue = operation === "isNull" || operation === "isNotNull";
48
- const value = condition.value;
49
- if (!noValue && prune && isEmptyValue(value)) return void 0;
50
- const out = { key: condition.key, operation };
51
- if (!noValue) out.value = value;
52
- return out;
53
- }
54
- function normalizeNode(node, prune) {
55
- if ("and" in node) {
56
- const kids = node.and.map((n) => normalizeNode(n, prune)).filter((n) => !!n);
57
- return kids.length ? { and: kids } : void 0;
58
- }
59
- if ("or" in node) {
60
- const kids = node.or.map((n) => normalizeNode(n, prune)).filter((n) => !!n);
61
- return kids.length ? { or: kids } : void 0;
62
- }
63
- if ("not" in node) {
64
- const inner = normalizeNode(node.not, prune);
65
- return inner ? { not: inner } : void 0;
66
- }
67
- return normalizeCondition(node, prune);
68
- }
69
- function normalizeFilter(filter, prune) {
70
- if (!filter) return [];
71
- if (Array.isArray(filter)) {
72
- return filter.map((c) => normalizeCondition(c, prune)).filter((c) => !!c);
73
- }
74
- return normalizeNode(filter, prune) ?? [];
75
- }
76
- function buildBase(input, cfg) {
77
- const base = {
78
- [cfg.filterField]: normalizeFilter(input.filter, cfg.pruneEmpty),
79
- [cfg.columnsField]: input.columns ?? {},
80
- [cfg.withField]: input.with ?? {}
81
- };
82
- if (input.withDeleted !== void 0) base[cfg.withDeletedField] = input.withDeleted;
83
- return base;
84
- }
85
- function clampInt(value, fallback, max = Infinity) {
86
- const resolved = value === void 0 || value < 1 || Number.isNaN(value) ? fallback : Math.trunc(value);
87
- return Math.min(max, resolved);
88
- }
89
- function build(input, cfg) {
90
- return { ...buildBase(input, cfg), [cfg.sortField]: normalizeSort(input.sort, cfg.defaultSort) };
91
- }
92
- function buildList(input, cfg) {
93
- return {
94
- ...build(input, cfg),
95
- [cfg.pageField]: clampInt(input.page, 1),
96
- // page >= 1 (kasr/0/manfiy → 1)
97
- [cfg.perPageField]: clampInt(input.perPage, cfg.defaultPerPage, cfg.maxPerPage)
98
- };
99
- }
100
- function buildInfinite(input, cfg) {
101
- return {
102
- ...build(input, cfg),
103
- [cfg.limitField]: clampInt(input.limit, cfg.defaultLimit, cfg.maxLimit),
104
- [cfg.offsetField]: input.offset && input.offset > 0 ? Math.trunc(input.offset) : 0
105
- };
106
- }
107
- function buildCursor(input, cfg) {
108
- const payload = {
109
- ...buildBase(input, cfg),
110
- [cfg.limitField]: clampInt(input.limit, cfg.defaultLimit, cfg.maxLimit),
111
- [cfg.cursorField]: input.cursor ?? null,
112
- order: input.order ?? "asc",
113
- direction: input.direction ?? "forward"
114
- };
115
- if (input.cursorKey !== void 0) payload.cursorKey = input.cursorKey;
116
- return payload;
117
- }
118
- function createQuery(config = {}) {
119
- const cfg = { ...DEFAULTS, ...config };
120
- return {
121
- params: (input = {}) => build(input, cfg),
122
- list: (input = {}) => buildList(input, cfg),
123
- infinite: (input = {}) => buildInfinite(input, cfg),
124
- cursor: (input = {}) => buildCursor(input, cfg)
125
- };
126
- }
127
- function buildParams(input = {}) {
128
- return build(input, DEFAULTS);
129
- }
130
- function buildListParams(input = {}) {
131
- return buildList(input, DEFAULTS);
132
- }
133
- function buildInfiniteParams(input = {}) {
134
- return buildInfinite(input, DEFAULTS);
135
- }
136
- function buildCursorParams(input = {}) {
137
- return buildCursor(input, DEFAULTS);
138
- }
139
-
140
- // src/meta.ts
141
- function mapMeta(raw) {
142
- return {
143
- totalPages: raw?.total_pages ?? 0,
144
- totalCount: raw?.total_items ?? 0,
145
- currentPage: raw?.current_page ?? 0,
146
- perPage: raw?.per_page ?? 0,
147
- hasNext: raw?.has_next ?? false,
148
- hasPrev: raw?.has_prev ?? false
149
- };
150
- }
151
- function mapInfiniteMeta(raw) {
152
- return {
153
- limit: raw?.limit ?? 0,
154
- offset: raw?.offset ?? 0,
155
- count: raw?.count ?? 0,
156
- hasMore: raw?.has_more ?? false,
157
- nextOffset: raw?.next_offset ?? null
158
- };
159
- }
160
- function mapCursorMeta(raw) {
161
- return {
162
- limit: raw?.limit ?? 0,
163
- hasNext: raw?.has_next ?? false,
164
- hasPrev: raw?.has_prev ?? false,
165
- nextCursor: raw?.next_cursor ?? null,
166
- prevCursor: raw?.prev_cursor ?? null
167
- };
168
- }
169
-
170
- // src/schema.ts
171
- function defineListSchema(schema) {
172
- return schema;
173
- }
174
-
175
- // src/url.ts
176
- var URL_DEFAULTS = {
177
- pageParam: "page",
178
- sizeParam: "size",
179
- sortParam: "sortType"
180
- };
181
- function decodeSort(value) {
182
- if (!value) return void 0;
183
- const items = value.split(",").map((s) => s.trim()).filter(Boolean).map((tok) => {
184
- const desc = tok.startsWith("-");
185
- return { key: desc ? tok.slice(1) : tok, direction: desc ? "desc" : "asc" };
186
- }).filter((i) => i.key);
187
- return items.length ? items : void 0;
188
- }
189
- function encodeSort(sort) {
190
- return sort.map((i) => typeof i === "string" ? i.trim() : i && i.key ? (i.direction === "desc" ? "-" : "") + i.key : "").filter(Boolean).join(",");
191
- }
192
- function schemaToFilter(schema, searchParams) {
193
- const conditions = [];
194
- const groups = [];
195
- for (const [param, d] of Object.entries(schema)) {
196
- const key = d.key ?? param;
197
- if (d.range) {
198
- const from = searchParams.get(d.range[0]);
199
- const to = searchParams.get(d.range[1]);
200
- if (from) conditions.push(cond(key, ">=", from));
201
- if (to) conditions.push(cond(key, "<=", to));
202
- continue;
203
- }
204
- if (d.between) {
205
- const from = searchParams.get(d.between[0]);
206
- const to = searchParams.get(d.between[1]);
207
- if (from && to) conditions.push(cond(key, "between", [from, to]));
208
- continue;
209
- }
210
- const raw = searchParams.get(param);
211
- let value = raw !== null ? raw : d.default;
212
- if (typeof value === "string" && d.trim) value = value.trim();
213
- if (value === void 0 || value === null || value === "") continue;
214
- if (Array.isArray(value) && value.length === 0) continue;
215
- if (d.search && typeof value === "string") {
216
- groups.push({ or: d.search.map((field) => cond(field, "%_%", value)) });
217
- continue;
218
- }
219
- if (d.split && typeof value === "string") {
220
- const delimiter = d.split === true ? "," : d.split;
221
- const parts = value.split(delimiter).map((s) => s.trim()).filter(Boolean);
222
- if (parts.length === 0) continue;
223
- value = parts;
224
- }
225
- conditions.push(cond(key, d.operation ?? "=", value));
226
- }
227
- return groups.length === 0 ? conditions : { and: [...groups, ...conditions] };
228
- }
229
- function cond(key, operation, value) {
230
- return { key, operation, value };
231
- }
232
- function readListParams(schema, searchParams, url = {}) {
233
- const cfg = { ...URL_DEFAULTS, ...url };
234
- const size = searchParams.get(cfg.sizeParam);
235
- return {
236
- filter: schemaToFilter(schema, searchParams),
237
- sort: decodeSort(searchParams.get(cfg.sortParam)),
238
- page: Number(searchParams.get(cfg.pageParam)) || 1,
239
- perPage: size ? Number(size) : void 0
240
- };
241
- }
242
- function searchParamsToPayload(schema, searchParams, url) {
243
- return buildListParams(readListParams(schema, searchParams, url));
244
- }
245
- function clone(searchParams) {
246
- return new URLSearchParams(searchParams);
247
- }
248
- function setParam(searchParams, name, value, url = {}) {
249
- const cfg = { ...URL_DEFAULTS, ...url };
250
- const next = clone(searchParams);
251
- next.delete(cfg.pageParam);
252
- if (value === null || value === void 0 || value === "") next.delete(name);
253
- else next.set(name, value);
254
- return next;
255
- }
256
- function setPage(searchParams, page, url = {}) {
257
- const cfg = { ...URL_DEFAULTS, ...url };
258
- const next = clone(searchParams);
259
- next.set(cfg.pageParam, String(page));
260
- return next;
261
- }
262
- function setSize(searchParams, size, url = {}) {
263
- const cfg = { ...URL_DEFAULTS, ...url };
264
- const next = clone(searchParams);
265
- next.delete(cfg.pageParam);
266
- next.set(cfg.sizeParam, String(size));
267
- return next;
268
- }
269
- function setSort(searchParams, sort, url = {}) {
270
- const cfg = { ...URL_DEFAULTS, ...url };
271
- const next = clone(searchParams);
272
- next.delete(cfg.pageParam);
273
- const encoded = encodeSort(sort);
274
- if (encoded) next.set(cfg.sortParam, encoded);
275
- else next.delete(cfg.sortParam);
276
- return next;
277
- }
278
- function resetParams(searchParams, keep = []) {
279
- const next = new URLSearchParams();
280
- for (const key of keep) {
281
- const value = searchParams.get(key);
282
- if (value !== null) next.set(key, value);
283
- }
284
- return next;
285
- }
286
-
287
- // src/registry.ts
288
- function createRegistry(config) {
289
- const defaults = config.defaults ?? {};
290
- const sort = normalizeSort(defaults.sort, []);
291
- const cursorOrder = defaults.cursor?.order ?? "asc";
292
- const qcfg = {};
293
- if (defaults.perPage !== void 0) qcfg.defaultPerPage = defaults.perPage;
294
- if (defaults.limit !== void 0) qcfg.defaultLimit = defaults.limit;
295
- if (defaults.maxPerPage !== void 0) qcfg.maxPerPage = defaults.maxPerPage;
296
- if (defaults.maxLimit !== void 0) qcfg.maxLimit = defaults.maxLimit;
297
- if (sort.length) qcfg.defaultSort = sort;
298
- if (config.pruneEmpty !== void 0) qcfg.pruneEmpty = config.pruneEmpty;
299
- const q = createQuery(qcfg);
300
- const parseList = (raw) => ({ data: raw?.data ?? [], meta: mapMeta(raw?.meta) });
301
- const parseInfinite = (raw) => ({
302
- data: raw?.data ?? [],
303
- meta: mapInfiniteMeta(raw?.meta)
304
- });
305
- const parseCursor = (raw) => ({
306
- data: raw?.data ?? [],
307
- meta: mapCursorMeta(raw?.meta)
308
- });
309
- function resource(name) {
310
- const f2 = createFilters();
311
- const keys = {
312
- all: [name],
313
- list: (p) => [name, "list", p],
314
- infinite: (p) => [name, "infinite", p],
315
- cursor: (p) => [name, "cursor", p],
316
- detail: (id) => [name, "detail", id]
317
- };
318
- return {
319
- list: (input) => q.list(input),
320
- infinite: (input) => q.infinite(input),
321
- cursor: (input) => q.cursor({ ...input, order: input?.order ?? cursorOrder }),
322
- params: (input) => q.params(input),
323
- f: f2,
324
- search: (term, fields) => core.f.or(...fields.map((field) => core.f.contains(field, term))),
325
- schema: (s) => defineListSchema(s),
326
- fromSearchParams: (searchParams, options) => q.list({ ...readListParams(options.schema, searchParams, options.url), with: options.with }),
327
- keys,
328
- parseList: (raw) => parseList(raw),
329
- parseInfinite: (raw) => parseInfinite(raw),
330
- parseCursor: (raw) => parseCursor(raw)
331
- };
332
- }
333
- return { adapter: config.adapter, resource, parseList, parseInfinite, parseCursor };
334
- }
335
-
336
- Object.defineProperty(exports, "f", {
337
- enumerable: true,
338
- get: function () { return core.f; }
339
- });
340
- exports.buildCursorParams = buildCursorParams;
341
- exports.buildInfiniteParams = buildInfiniteParams;
342
- exports.buildListParams = buildListParams;
343
- exports.buildParams = buildParams;
344
- exports.createFilters = createFilters;
345
- exports.createQuery = createQuery;
346
- exports.createRegistry = createRegistry;
347
- exports.decodeSort = decodeSort;
348
- exports.defineListSchema = defineListSchema;
349
- exports.encodeSort = encodeSort;
350
- exports.normalizeFilter = normalizeFilter;
351
- exports.normalizeSort = normalizeSort;
352
- exports.readListParams = readListParams;
353
- exports.resetParams = resetParams;
354
- exports.schemaToFilter = schemaToFilter;
355
- exports.searchParamsToPayload = searchParamsToPayload;
356
- exports.setPage = setPage;
357
- exports.setParam = setParam;
358
- exports.setSize = setSize;
359
- exports.setSort = setSort;
360
- //# sourceMappingURL=index.cjs.map
1
+ 'use strict';var core=require('@querykitjs/core');function k(){return core.createFilters()}var P={filterField:"filter",sortField:"sort",columnsField:"columns",withField:"with",withDeletedField:"withDeleted",withTotalField:"withTotal",pageField:"page",perPageField:"perPage",limitField:"limit",offsetField:"offset",cursorField:"cursor",defaultPerPage:core.DEFAULT_PER_PAGE,defaultLimit:core.DEFAULT_LIMIT,maxPerPage:core.DEFAULT_MAX_PER_PAGE,maxLimit:core.DEFAULT_MAX_LIMIT,maxOffset:core.DEFAULT_MAX_OFFSET,maxSortFields:core.DEFAULT_MAX_SORT_FIELDS,defaultSort:[{key:"createdAt",direction:"desc"}],pruneEmpty:true};function re(e){return !!(e==null||e===""||Array.isArray(e)&&e.length===0)}function ne(e){if(typeof e=="string"){let t=e.startsWith("-"),r=(t?e.slice(1):e).trim();return r?{key:r,direction:t?"desc":"asc"}:void 0}return e&&e.key?{key:e.key,direction:e.direction??"asc"}:void 0}function T(e,t){if(!e||e.length===0)return t;let r=e.map(ne).filter(n=>n!==void 0);return r.length?r:t}function U(e,t){let r=e.operation??"=",n=r==="isNull"||r==="isNotNull",i=e.value;if(!n&&t&&re(i))return;let a={key:e.key,operation:r};return n||(a.value=i),a}function h(e,t){if("and"in e){let r=e.and.map(n=>h(n,t)).filter(n=>!!n);return r.length?{and:r}:void 0}if("or"in e){let r=e.or.map(n=>h(n,t)).filter(n=>!!n);return r.length?{or:r}:void 0}if("not"in e){let r=h(e.not,t);return r?{not:r}:void 0}return U(e,t)}function M(e,t){return e?Array.isArray(e)?e.map(r=>U(r,t)).filter(r=>!!r):h(e,t)??[]:[]}function N(e,t){let r={[t.filterField]:M(e.filter,t.pruneEmpty),[t.columnsField]:e.columns??{},[t.withField]:e.with??{}};return e.withDeleted!==void 0&&(r[t.withDeletedField]=e.withDeleted),r}function c(e,t,r=1/0){let n=e===void 0||e<1||Number.isNaN(e)?t:Math.trunc(e);return Math.min(r,n)}function K(e,t,r,n=""){return new Error(`querykit: ${e} exceeds ${t} (${r})${n}`)}function w(e,t){let r=T(e.sort,t.defaultSort);if(r.length>t.maxSortFields)throw K(`sort with ${r.length} fields`,"maxSortFields",t.maxSortFields);return {...N(e,t),[t.sortField]:r}}var E="; use cursor pagination for deeper pages";function O(e,t){let r=c(e.page,1),n=c(e.perPage,t.defaultPerPage,t.maxPerPage);if((r-1)*n>t.maxOffset)throw K(`page ${r} \xD7 perPage ${n}`,"maxOffset",t.maxOffset,E);let i={...w(e,t),[t.pageField]:r,[t.perPageField]:n};return e.withTotal!==void 0&&(i[t.withTotalField]=e.withTotal),i}function D(e,t){let r=e.offset&&e.offset>0?Math.trunc(e.offset):0;if(r>t.maxOffset)throw K(`offset ${r}`,"maxOffset",t.maxOffset,E);return {...w(e,t),[t.limitField]:c(e.limit,t.defaultLimit,t.maxLimit),[t.offsetField]:r}}function _(e,t){let r={...N(e,t),[t.limitField]:c(e.limit,t.defaultLimit,t.maxLimit),[t.cursorField]:e.cursor??null,order:e.order??"asc",direction:e.direction??"forward"};return e.cursorKey!==void 0&&(r.cursorKey=e.cursorKey),r}function b(e={}){let t={...P,...e};return {params:(r={})=>w(r,t),list:(r={})=>O(r,t),infinite:(r={})=>D(r,t),cursor:(r={})=>_(r,t)}}function ie(e={}){return w(e,P)}function A(e={}){return O(e,P)}function ae(e={}){return D(e,P)}function oe(e={}){return _(e,P)}var Q=e=>e===null?null:e??0;function V(e){return {totalPages:Q(e?.total_pages),totalCount:Q(e?.total_items),currentPage:e?.current_page??0,perPage:e?.per_page??0,hasNext:e?.has_next??false,hasPrev:e?.has_prev??false}}function v(e){return {limit:e?.limit??0,offset:e?.offset??0,count:e?.count??0,hasMore:e?.has_more??false,nextOffset:e?.next_offset??null}}function W(e){return {limit:e?.limit??0,hasNext:e?.has_next??false,hasPrev:e?.has_prev??false,nextCursor:e?.next_cursor??null,prevCursor:e?.prev_cursor??null}}function se(e){return e}var F={pageParam:"page",sizeParam:"size",sortParam:"sortType"};function z(e){if(!e)return;let t=e.split(",").map(r=>r.trim()).filter(Boolean).map(r=>{let n=r.startsWith("-");return {key:n?r.slice(1):r,direction:n?"desc":"asc"}}).filter(r=>r.key);return t.length?t:void 0}function B(e){return e.map(t=>typeof t=="string"?t.trim():t&&t.key?(t.direction==="desc"?"-":"")+t.key:"").filter(Boolean).join(",")}function q(e,t){let r=[],n=[];for(let[i,a]of Object.entries(e)){let l=a.key??i;if(a.range){let u=t.get(a.range[0]),d=t.get(a.range[1]);u&&r.push(g(l,">=",u)),d&&r.push(g(l,"<=",d));continue}if(a.between){let u=t.get(a.between[0]),d=t.get(a.between[1]);u&&d&&r.push(g(l,"between",[u,d]));continue}let f=t.get(i),s=f!==null?f:a.default;if(typeof s=="string"&&a.trim&&(s=s.trim()),!(s==null||s==="")&&!(Array.isArray(s)&&s.length===0)){if(a.search&&typeof s=="string"){n.push({or:a.search.map(u=>g(u,"%_%",s))});continue}if(a.split&&typeof s=="string"){let u=a.split===true?",":a.split,d=s.split(u).map(p=>p.trim()).filter(Boolean);if(d.length===0)continue;s=d;}r.push(g(l,a.operation??"=",s));}}return n.length===0?r:{and:[...n,...r]}}function g(e,t,r){return {key:e,operation:t,value:r}}function I(e,t){return Object.defineProperty(e,"clamped",{value:t,enumerable:false})}function fe(e,t){let r=c(e,t.perPage??core.DEFAULT_PER_PAGE,t.maxPerPage??core.DEFAULT_MAX_PER_PAGE);return Math.floor((t.maxOffset??core.DEFAULT_MAX_OFFSET)/r)+1}function L(e,t,r={},n={}){let i={...F,...r},a=t.get(i.sizeParam),l=a?Number(a):void 0,f=Math.trunc(Number(t.get(i.pageParam)))||1,s=z(t.get(i.sortParam)),u=fe(l,n),d=n.maxSortFields??core.DEFAULT_MAX_SORT_FIELDS,p=f>u,x=s!==void 0&&s.length>d;return {filter:q(e,t),sort:x?s.slice(0,d):s,page:p?u:f,perPage:l,clamped:p||x}}function pe(e,t,r){let n=L(e,t,r);return I(A(n),n.clamped)}function C(e){return new URLSearchParams(e)}function ce(e,t,r,n={}){let i={...F,...n},a=C(e);return a.delete(i.pageParam),r==null||r===""?a.delete(t):a.set(t,r),a}function ye(e,t,r={}){let n={...F,...r},i=C(e);return i.set(n.pageParam,String(t)),i}function Pe(e,t,r={}){let n={...F,...r},i=C(e);return i.delete(n.pageParam),i.set(n.sizeParam,String(t)),i}function ge(e,t,r={}){let n={...F,...r},i=C(e);i.delete(n.pageParam);let a=B(t);return a?i.set(n.sortParam,a):i.delete(n.sortParam),i}function Fe(e,t=[]){let r=new URLSearchParams;for(let n of t){let i=e.get(n);i!==null&&r.set(n,i);}return r}function xe(e){let t=e.defaults??{},r=e.timestamps?.createdAt,n=r?[{key:r,direction:"desc"}]:[],i=T(t.sort,n),a=t.cursor?.order??"asc",l={};t.perPage!==void 0&&(l.defaultPerPage=t.perPage),t.limit!==void 0&&(l.defaultLimit=t.limit),t.maxPerPage!==void 0&&(l.maxPerPage=t.maxPerPage),t.maxLimit!==void 0&&(l.maxLimit=t.maxLimit),t.maxOffset!==void 0&&(l.maxOffset=t.maxOffset),t.maxSortFields!==void 0&&(l.maxSortFields=t.maxSortFields),i.length&&(l.defaultSort=i),e.pruneEmpty!==void 0&&(l.pruneEmpty=e.pruneEmpty);let f=b(l),s={perPage:t.perPage,maxPerPage:t.maxPerPage,maxOffset:t.maxOffset,maxSortFields:t.maxSortFields},u=m=>({data:m?.data??[],meta:V(m?.meta)}),d=m=>({data:m?.data??[],meta:v(m?.meta)}),p=m=>({data:m?.data??[],meta:W(m?.meta)});function x(m){let $=k();return {list:o=>f.list(o),infinite:o=>f.infinite(o),cursor:o=>f.cursor({...o,order:o?.order??a}),params:o=>f.params(o),f:$,search:(o,y,R)=>core.f.or(...y.map(X=>core.f[R?.operation??"contains"](X,o))),schema:o=>o,fromSearchParams:(o,y)=>{let R=L(y.schema,o,y.url,s);return I(f.list({...R,with:y.with}),R.clamped)},keys:{all:[m],list:o=>[m,"list",o],infinite:o=>[m,"infinite",o],cursor:o=>[m,"cursor",o],detail:o=>[m,"detail",o]},parseList:o=>u(o),parseInfinite:o=>d(o),parseCursor:o=>p(o)}}return {adapter:e.adapter,resource:x,parseList:u,parseInfinite:d,parseCursor:p}}var Re={"unknown-key":true,"invalid-value":true,"forbidden-key":true,"forbidden-operator":true,"limit-exceeded":true,"empty-filter":true},Se={filter:true,sort:true,cursorKey:true,aggregate:true,page:true,mutation:true,with:true},G=(e,t)=>typeof t=="string"&&Object.hasOwn(e,t);function he(e){if(typeof e!="object"||e===null)return false;let t=e;return G(Re,t.reason)&&G(Se,t.site)&&typeof t.key=="string"}Object.defineProperty(exports,"f",{enumerable:true,get:function(){return core.f}});exports.buildCursorParams=oe;exports.buildInfiniteParams=ae;exports.buildListParams=A;exports.buildParams=ie;exports.createFilters=k;exports.createQuery=b;exports.createRegistry=xe;exports.decodeSort=z;exports.defineListSchema=se;exports.encodeSort=B;exports.isQueryKitError=he;exports.normalizeFilter=M;exports.normalizeSort=T;exports.readListParams=L;exports.resetParams=Fe;exports.schemaToFilter=q;exports.searchParamsToPayload=pe;exports.setPage=ye;exports.setParam=ce;exports.setSize=Pe;exports.setSort=ge;//# sourceMappingURL=index.cjs.map
361
2
  //# sourceMappingURL=index.cjs.map