@querykitjs/web 2.0.1 → 3.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/README.en.md +39 -15
- package/README.md +32 -8
- package/dist/index.cjs +22 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +22 -15
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +11 -4
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +11 -4
- package/dist/react/index.js.map +1 -1
- package/dist/{registry-DPIEOvLW.d.cts → registry-DbZQk28q.d.cts} +19 -13
- package/dist/{registry-DPIEOvLW.d.ts → registry-DbZQk28q.d.ts} +19 -13
- package/package.json +2 -2
|
@@ -24,12 +24,15 @@ type FilterNode<T = Record<string, unknown>> = Core.FilterNode<FieldKey<T>>;
|
|
|
24
24
|
*/
|
|
25
25
|
type Filter<T = Record<string, unknown>> = Core.Filter<FieldKey<T>>;
|
|
26
26
|
type SortDirection = Core.SortDirection;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
type SortItem = Core.SortItem;
|
|
28
|
+
/** Sort — **always an array** of `{ key, direction }` (multi-field). */
|
|
29
|
+
type Sort = Core.Sort;
|
|
30
|
+
/**
|
|
31
|
+
* Sort input — an array where each item is a `{ key, direction }` object OR a
|
|
32
|
+
* `"-field"` / `"field"` shorthand string (`["-createdAt", "id"]`). Builders map
|
|
33
|
+
* it to the canonical {@link Sort} (`SortItem[]`).
|
|
34
|
+
*/
|
|
35
|
+
type SortInput = ReadonlyArray<SortItem | string>;
|
|
33
36
|
interface Params<T = Record<string, unknown>> {
|
|
34
37
|
filter?: Filter<T>;
|
|
35
38
|
sort?: SortInput;
|
|
@@ -242,10 +245,13 @@ interface UrlConfig {
|
|
|
242
245
|
sizeParam?: string;
|
|
243
246
|
sortParam?: string;
|
|
244
247
|
}
|
|
245
|
-
/**
|
|
248
|
+
/**
|
|
249
|
+
* `"-createdAt,id,-appNumber"` → `[{ key, direction }, …]` — comma-separated,
|
|
250
|
+
* order preserved, `-` prefix = `desc` (else `asc`). Empty → `undefined`.
|
|
251
|
+
*/
|
|
246
252
|
declare function decodeSort(value: string | null | undefined): Sort | undefined;
|
|
247
|
-
/** `{
|
|
248
|
-
declare function encodeSort(sort:
|
|
253
|
+
/** `[{ key, direction }, …]` (or `"-field"` shorthand strings) → `"-createdAt,id,-appNumber"` (empty → `""`). */
|
|
254
|
+
declare function encodeSort(sort: SortInput): string;
|
|
249
255
|
/**
|
|
250
256
|
* Schema + searchParams → filter. Applies `range`/`between`/`search`/`split`/
|
|
251
257
|
* `default`/`trim`; empty/absent params are dropped. Returns a flat
|
|
@@ -263,7 +269,7 @@ declare function setParam(searchParams: URLSearchParams, name: string, value: st
|
|
|
263
269
|
declare function setPage(searchParams: URLSearchParams, page: number, url?: UrlConfig): URLSearchParams;
|
|
264
270
|
/** Sahifa o'lchamini o'rnatadi va `page`ni reset qiladi. */
|
|
265
271
|
declare function setSize(searchParams: URLSearchParams, size: number, url?: UrlConfig): URLSearchParams;
|
|
266
|
-
/** Sortni o'rnatadi (`
|
|
272
|
+
/** Sortni o'rnatadi (`[{ key, direction }, …]`) va `page`ni reset qiladi. */
|
|
267
273
|
declare function setSort(searchParams: URLSearchParams, sort: SortInput, url?: UrlConfig): URLSearchParams;
|
|
268
274
|
/** Barcha list param'larini tozalaydi (ixtiyoriy saqlanadigan kalitlar bilan). */
|
|
269
275
|
declare function resetParams(searchParams: URLSearchParams, keep?: string[]): URLSearchParams;
|
|
@@ -378,7 +384,7 @@ interface RegistryDefaults {
|
|
|
378
384
|
perPage?: number;
|
|
379
385
|
/** `infinite` + `cursor` page size. */
|
|
380
386
|
limit?: number;
|
|
381
|
-
/** `list`/`infinite` sort
|
|
387
|
+
/** `list`/`infinite` sort — `[{key,direction}]` or `["-createdAt", "id"]` shorthand. */
|
|
382
388
|
sort?: SortInput;
|
|
383
389
|
/** Cursor-only defaults. */
|
|
384
390
|
cursor?: {
|
|
@@ -407,11 +413,11 @@ interface Registry<A extends AdapterName> {
|
|
|
407
413
|
*
|
|
408
414
|
* @example
|
|
409
415
|
* ```ts
|
|
410
|
-
* export const qk = createRegistry({ adapter: "mongoose", defaults: { perPage: 20, sort: "-createdAt" } });
|
|
416
|
+
* export const qk = createRegistry({ adapter: "mongoose", defaults: { perPage: 20, sort: ["-createdAt"] } });
|
|
411
417
|
* const users = qk.resource<IUser>("users");
|
|
412
418
|
* const body = users.list({ filter: users.f.eq("status", "active"), page });
|
|
413
419
|
* ```
|
|
414
420
|
*/
|
|
415
421
|
declare function createRegistry<A extends AdapterName>(config: RegistryConfig<A>): Registry<A>;
|
|
416
422
|
|
|
417
|
-
export {
|
|
423
|
+
export { readListParams as $, type AdapterName as A, type ResourceCursorParams as B, type CursorParams as C, type DrizzleWith as D, type ResourceInfiniteParams as E, type Filter as F, type ResourceKeys as G, type ResourceListParams as H, type InfiniteParams as I, type ResourceParams as J, type SortDirection as K, type ListParams as L, type Meta as M, type NotGroup as N, type OrGroup as O, type Params as P, type QueryPayload as Q, type RawCursorMeta as R, type Sort as S, type SortItem as T, type UrlConfig as U, createFilters as V, type WithFor as W, createRegistry as X, decodeSort as Y, defineListSchema as Z, encodeSort as _, type CursorPayload as a, resetParams as a0, schemaToFilter as a1, searchParamsToPayload as a2, setPage as a3, setParam as a4, setSize as a5, setSort as a6, type InfinitePayload as b, type ListPayload as c, type FieldCondition as d, type FilterNode as e, type SortInput as f, type AndGroup as g, type CursorMeta as h, type CursorResult as i, type FieldDescriptor as j, type FieldKey as k, type FilterOperator as l, type FilterScalar as m, type FilterValue as n, type InfiniteMeta as o, type InfiniteResult as p, type ListResult as q, type ListSchema as r, type MongoosePopulate as s, type PrismaInclude as t, type RawInfiniteMeta as u, type RawMeta as v, type Registry as w, type RegistryConfig as x, type RegistryDefaults as y, type Resource as z };
|
|
@@ -24,12 +24,15 @@ type FilterNode<T = Record<string, unknown>> = Core.FilterNode<FieldKey<T>>;
|
|
|
24
24
|
*/
|
|
25
25
|
type Filter<T = Record<string, unknown>> = Core.Filter<FieldKey<T>>;
|
|
26
26
|
type SortDirection = Core.SortDirection;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
type SortItem = Core.SortItem;
|
|
28
|
+
/** Sort — **always an array** of `{ key, direction }` (multi-field). */
|
|
29
|
+
type Sort = Core.Sort;
|
|
30
|
+
/**
|
|
31
|
+
* Sort input — an array where each item is a `{ key, direction }` object OR a
|
|
32
|
+
* `"-field"` / `"field"` shorthand string (`["-createdAt", "id"]`). Builders map
|
|
33
|
+
* it to the canonical {@link Sort} (`SortItem[]`).
|
|
34
|
+
*/
|
|
35
|
+
type SortInput = ReadonlyArray<SortItem | string>;
|
|
33
36
|
interface Params<T = Record<string, unknown>> {
|
|
34
37
|
filter?: Filter<T>;
|
|
35
38
|
sort?: SortInput;
|
|
@@ -242,10 +245,13 @@ interface UrlConfig {
|
|
|
242
245
|
sizeParam?: string;
|
|
243
246
|
sortParam?: string;
|
|
244
247
|
}
|
|
245
|
-
/**
|
|
248
|
+
/**
|
|
249
|
+
* `"-createdAt,id,-appNumber"` → `[{ key, direction }, …]` — comma-separated,
|
|
250
|
+
* order preserved, `-` prefix = `desc` (else `asc`). Empty → `undefined`.
|
|
251
|
+
*/
|
|
246
252
|
declare function decodeSort(value: string | null | undefined): Sort | undefined;
|
|
247
|
-
/** `{
|
|
248
|
-
declare function encodeSort(sort:
|
|
253
|
+
/** `[{ key, direction }, …]` (or `"-field"` shorthand strings) → `"-createdAt,id,-appNumber"` (empty → `""`). */
|
|
254
|
+
declare function encodeSort(sort: SortInput): string;
|
|
249
255
|
/**
|
|
250
256
|
* Schema + searchParams → filter. Applies `range`/`between`/`search`/`split`/
|
|
251
257
|
* `default`/`trim`; empty/absent params are dropped. Returns a flat
|
|
@@ -263,7 +269,7 @@ declare function setParam(searchParams: URLSearchParams, name: string, value: st
|
|
|
263
269
|
declare function setPage(searchParams: URLSearchParams, page: number, url?: UrlConfig): URLSearchParams;
|
|
264
270
|
/** Sahifa o'lchamini o'rnatadi va `page`ni reset qiladi. */
|
|
265
271
|
declare function setSize(searchParams: URLSearchParams, size: number, url?: UrlConfig): URLSearchParams;
|
|
266
|
-
/** Sortni o'rnatadi (`
|
|
272
|
+
/** Sortni o'rnatadi (`[{ key, direction }, …]`) va `page`ni reset qiladi. */
|
|
267
273
|
declare function setSort(searchParams: URLSearchParams, sort: SortInput, url?: UrlConfig): URLSearchParams;
|
|
268
274
|
/** Barcha list param'larini tozalaydi (ixtiyoriy saqlanadigan kalitlar bilan). */
|
|
269
275
|
declare function resetParams(searchParams: URLSearchParams, keep?: string[]): URLSearchParams;
|
|
@@ -378,7 +384,7 @@ interface RegistryDefaults {
|
|
|
378
384
|
perPage?: number;
|
|
379
385
|
/** `infinite` + `cursor` page size. */
|
|
380
386
|
limit?: number;
|
|
381
|
-
/** `list`/`infinite` sort
|
|
387
|
+
/** `list`/`infinite` sort — `[{key,direction}]` or `["-createdAt", "id"]` shorthand. */
|
|
382
388
|
sort?: SortInput;
|
|
383
389
|
/** Cursor-only defaults. */
|
|
384
390
|
cursor?: {
|
|
@@ -407,11 +413,11 @@ interface Registry<A extends AdapterName> {
|
|
|
407
413
|
*
|
|
408
414
|
* @example
|
|
409
415
|
* ```ts
|
|
410
|
-
* export const qk = createRegistry({ adapter: "mongoose", defaults: { perPage: 20, sort: "-createdAt" } });
|
|
416
|
+
* export const qk = createRegistry({ adapter: "mongoose", defaults: { perPage: 20, sort: ["-createdAt"] } });
|
|
411
417
|
* const users = qk.resource<IUser>("users");
|
|
412
418
|
* const body = users.list({ filter: users.f.eq("status", "active"), page });
|
|
413
419
|
* ```
|
|
414
420
|
*/
|
|
415
421
|
declare function createRegistry<A extends AdapterName>(config: RegistryConfig<A>): Registry<A>;
|
|
416
422
|
|
|
417
|
-
export {
|
|
423
|
+
export { readListParams as $, type AdapterName as A, type ResourceCursorParams as B, type CursorParams as C, type DrizzleWith as D, type ResourceInfiniteParams as E, type Filter as F, type ResourceKeys as G, type ResourceListParams as H, type InfiniteParams as I, type ResourceParams as J, type SortDirection as K, type ListParams as L, type Meta as M, type NotGroup as N, type OrGroup as O, type Params as P, type QueryPayload as Q, type RawCursorMeta as R, type Sort as S, type SortItem as T, type UrlConfig as U, createFilters as V, type WithFor as W, createRegistry as X, decodeSort as Y, defineListSchema as Z, encodeSort as _, type CursorPayload as a, resetParams as a0, schemaToFilter as a1, searchParamsToPayload as a2, setPage as a3, setParam as a4, setSize as a5, setSort as a6, type InfinitePayload as b, type ListPayload as c, type FieldCondition as d, type FilterNode as e, type SortInput as f, type AndGroup as g, type CursorMeta as h, type CursorResult as i, type FieldDescriptor as j, type FieldKey as k, type FilterOperator as l, type FilterScalar as m, type FilterValue as n, type InfiniteMeta as o, type InfiniteResult as p, type ListResult as q, type ListSchema as r, type MongoosePopulate as s, type PrismaInclude as t, type RawInfiniteMeta as u, type RawMeta as v, type Registry as w, type RegistryConfig as x, type RegistryDefaults as y, type Resource as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@querykitjs/web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Frontend query-building for querykit — typed filters, pagination params & URL sync. Zero-dependency; you send the request.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"test:smoke": "bun run test/smoke.ts"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@querykitjs/core": "^1.
|
|
53
|
+
"@querykitjs/core": "^1.1.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": ">=18",
|