@querykitjs/core 1.2.0 → 2.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 +36 -0
- package/README.md +36 -0
- package/dist/chunk-NHNDPIPM.js +54 -0
- package/dist/chunk-NHNDPIPM.js.map +1 -0
- package/dist/chunk-VD7XT52J.cjs +72 -0
- package/dist/chunk-VD7XT52J.cjs.map +1 -0
- package/dist/index.cjs +67 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -173
- package/dist/index.d.ts +23 -173
- package/dist/index.js +4 -26
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +357 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +249 -0
- package/dist/internal.d.ts +249 -0
- package/dist/internal.js +327 -0
- package/dist/internal.js.map +1 -0
- package/dist/raw-Bx8c-TrC.d.cts +290 -0
- package/dist/raw-Bx8c-TrC.d.ts +290 -0
- package/package.json +32 -6
- package/skills/querykit-core/SKILL.md +160 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,157 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* shundan chiqadi; `@querykitjs/zod` shu massivdan zod enum quradi.
|
|
4
|
-
*/
|
|
5
|
-
declare const FILTER_OPERATORS: readonly ["=", "!=", ">", ">=", "<", "<=", "eq", "ne", "gt", "gte", "lt", "lte", "like", "ilike", "notLike", "contains", "startsWith", "endsWith", "%_%", "%_", "_%", "in", "notIn", "between", "notBetween", "isNull", "isNotNull"];
|
|
6
|
-
/**
|
|
7
|
-
* Qiymati **text pattern** bo'lgan operatorlar. Backend adapterlari wire qiymatni
|
|
8
|
-
* ustun/path tipiga cast qilishda shularni chetlab o'tadi — aks holda
|
|
9
|
-
* `ilike(dateColumn, "%2026%")` ISO string o'rniga `String(Date)` olardi
|
|
10
|
-
* (`"Mon Jul 28 2026 …"`). Ro'yxat ikki adapterda divergent bo'lmasligi uchun
|
|
11
|
-
* shu yerda — yagona manba.
|
|
12
|
-
*/
|
|
13
|
-
declare const TEXT_FILTER_OPERATORS: readonly ["like", "ilike", "notLike", "contains", "startsWith", "endsWith", "%_%", "%_", "_%"];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* `@querykitjs/core` — ORM-agnostik query DSL tiplari. Backend adapterlar
|
|
17
|
-
* (`@querykitjs/drizzle-pg`) va frontend (`@querykitjs/web`) shu bir xil kontraktga
|
|
18
|
-
* tayanadi. Tiplar ustun-kaliti (`TKey`) bo'yicha generic; adapterlar uni o'z
|
|
19
|
-
* kalit tipiga (Drizzle jadval ustuni yoki entity maydoni) ixtisoslashtiradi.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/** Qo'llab-quvvatlanadigan filter operatorlari (token va nom aliaslari). */
|
|
23
|
-
type FilterOperator = (typeof FILTER_OPERATORS)[number];
|
|
24
|
-
/**
|
|
25
|
-
* Tiplangan kalit, lekin har qanday `string` ham qabul qilinadi. Wire (JSON) har
|
|
26
|
-
* doim string-keyed keladi va adapterlar noma'lum kalitni baribir skip qiladi —
|
|
27
|
-
* tip shunchaki haqiqatni aytsin, route'da `as` cast kerak bo'lmasin.
|
|
28
|
-
*
|
|
29
|
-
* `(string & {})` — autocomplete'ni saqlaydigan TS trick'i: IDE `TKey`
|
|
30
|
-
* variantlarini taklif qiladi, boshqa string esa xato bermaydi.
|
|
31
|
-
*/
|
|
32
|
-
type LooseKey<TKey extends string> = TKey | (string & {});
|
|
33
|
-
/**
|
|
34
|
-
* A filter scalar. `Date` is accepted **in-memory** (adapters cast it for local
|
|
35
|
-
* queries); over the JSON wire it serializes to an ISO string, so
|
|
36
|
-
* `@querykitjs/zod` validates scalars **without** `Date` (string/number/boolean/null).
|
|
37
|
-
*/
|
|
38
|
-
type FilterScalar = string | number | boolean | Date | null;
|
|
39
|
-
type FilterValue = FilterScalar | FilterScalar[];
|
|
40
|
-
/** Bitta maydon sharti (`operation` default `"="`). */
|
|
41
|
-
interface FieldCondition<TKey extends string = string> {
|
|
42
|
-
key: TKey;
|
|
43
|
-
operation?: FilterOperator;
|
|
44
|
-
value?: FilterValue;
|
|
45
|
-
}
|
|
46
|
-
interface AndGroup<TKey extends string = string, TRaw = never> {
|
|
47
|
-
and: FilterNode<TKey, TRaw>[];
|
|
48
|
-
}
|
|
49
|
-
interface OrGroup<TKey extends string = string, TRaw = never> {
|
|
50
|
-
or: FilterNode<TKey, TRaw>[];
|
|
51
|
-
}
|
|
52
|
-
interface NotGroup<TKey extends string = string, TRaw = never> {
|
|
53
|
-
not: FilterNode<TKey, TRaw>;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Filter daraxti tuguni: maydon sharti, mantiqiy guruh, yoki adapter qo'shadigan
|
|
57
|
-
* raw escape-hatch (`TRaw`, masalan Drizzle `SQL`; default `never`).
|
|
58
|
-
*/
|
|
59
|
-
type FilterNode<TKey extends string = string, TRaw = never> = FieldCondition<TKey> | AndGroup<TKey, TRaw> | OrGroup<TKey, TRaw> | NotGroup<TKey, TRaw> | TRaw;
|
|
60
|
-
/** Public filter: daraxt/tugun yoki flat massiv (implicit AND). */
|
|
61
|
-
type Filter<TKey extends string = string, TRaw = never> = FilterNode<TKey, TRaw> | FieldCondition<TKey>[];
|
|
62
|
-
type SortDirection = "asc" | "desc";
|
|
63
|
-
/** One sort field — `{ key, direction }`. */
|
|
64
|
-
interface SortItem<TKey extends string = string> {
|
|
65
|
-
key: TKey;
|
|
66
|
-
direction?: SortDirection;
|
|
67
|
-
}
|
|
68
|
-
/** Sort is **always an array** of {@link SortItem} (multi-field capable). */
|
|
69
|
-
type Sort<TKey extends string = string> = SortItem<TKey>[];
|
|
70
|
-
/** Equality scope applied to every operation of a scoped repository. */
|
|
71
|
-
type Scope<TKey extends string = string> = Partial<Record<TKey, FilterScalar>>;
|
|
72
|
-
/** Options for upsert / upsertMany — conflict target(s) + optional update set. */
|
|
73
|
-
interface UpsertOptions<TKey extends string = string, TInsert = Record<string, unknown>> {
|
|
74
|
-
/** Unique/conflict key(s) whose match triggers an update instead of an insert. */
|
|
75
|
-
target: TKey | TKey[];
|
|
76
|
-
/** Columns/fields to update on conflict. Defaults to the inserted values minus `target`. */
|
|
77
|
-
set?: Partial<TInsert>;
|
|
78
|
-
}
|
|
79
|
-
/** Aggregate query spec — group + count/sum/avg/min/max, each keyed by field. */
|
|
80
|
-
interface AggregateSpec<TKey extends string = string, TFilter = unknown> {
|
|
81
|
-
filter?: TFilter;
|
|
82
|
-
/** Group rows by these field(s); each appears in the output rows. */
|
|
83
|
-
groupBy?: TKey | TKey[];
|
|
84
|
-
count?: boolean;
|
|
85
|
-
sum?: TKey | TKey[];
|
|
86
|
-
avg?: TKey | TKey[];
|
|
87
|
-
min?: TKey | TKey[];
|
|
88
|
-
max?: TKey | TKey[];
|
|
89
|
-
withDeleted?: boolean;
|
|
90
|
-
}
|
|
91
|
-
/** Paginatsiyasiz umumiy wire params. */
|
|
92
|
-
interface WireBaseParams {
|
|
93
|
-
filter?: Filter;
|
|
94
|
-
sort?: Sort;
|
|
95
|
-
columns?: Record<string, boolean>;
|
|
96
|
-
with?: Record<string, unknown>;
|
|
97
|
-
withDeleted?: boolean;
|
|
98
|
-
}
|
|
99
|
-
/** Offset (sahifali) wire params. */
|
|
100
|
-
interface WireOffsetParams extends WireBaseParams {
|
|
101
|
-
page?: number;
|
|
102
|
-
perPage?: number;
|
|
103
|
-
}
|
|
104
|
-
/** Infinite-scroll wire params. */
|
|
105
|
-
interface WireInfiniteParams extends WireBaseParams {
|
|
106
|
-
limit?: number;
|
|
107
|
-
offset?: number;
|
|
108
|
-
}
|
|
109
|
-
/** Cursor (keyset) wire params — `sort` yo'q, tartib `order` + `direction` bilan. */
|
|
110
|
-
interface WireCursorParams extends Omit<WireBaseParams, "sort"> {
|
|
111
|
-
limit?: number;
|
|
112
|
-
cursor?: string | null;
|
|
113
|
-
cursorKey?: string;
|
|
114
|
-
order?: SortDirection;
|
|
115
|
-
direction?: "forward" | "backward";
|
|
116
|
-
}
|
|
117
|
-
/** Shart nima uchun tashlab yuborilgani. */
|
|
118
|
-
type SkipReason = "unknown-key" | "invalid-value";
|
|
119
|
-
/** Shart qayerda tashlab yuborilgani. */
|
|
120
|
-
type SkipSite = "filter" | "sort" | "cursorKey" | "aggregate";
|
|
121
|
-
/** Tashlab yuborilgan bitta shart haqida ma'lumot. */
|
|
122
|
-
interface SkippedCondition {
|
|
123
|
-
/** Jadval (drizzle) yoki model (mongoose) nomi. */
|
|
124
|
-
source: string;
|
|
125
|
-
site: SkipSite;
|
|
126
|
-
key: string;
|
|
127
|
-
operation?: FilterOperator;
|
|
128
|
-
reason: SkipReason;
|
|
129
|
-
}
|
|
130
|
-
/** Offset (sahifali) paginatsiya meta'si. */
|
|
131
|
-
interface OffsetMeta {
|
|
132
|
-
total_items: number;
|
|
133
|
-
total_pages: number;
|
|
134
|
-
current_page: number;
|
|
135
|
-
per_page: number;
|
|
136
|
-
has_next: boolean;
|
|
137
|
-
has_prev: boolean;
|
|
138
|
-
}
|
|
139
|
-
/** Infinite-scroll paginatsiya meta'si. */
|
|
140
|
-
interface InfiniteMeta {
|
|
141
|
-
limit: number;
|
|
142
|
-
offset: number;
|
|
143
|
-
count: number;
|
|
144
|
-
has_more: boolean;
|
|
145
|
-
next_offset: number | null;
|
|
146
|
-
}
|
|
147
|
-
/** Cursor (keyset) paginatsiya meta'si. */
|
|
148
|
-
interface CursorMeta {
|
|
149
|
-
limit: number;
|
|
150
|
-
has_next: boolean;
|
|
151
|
-
has_prev: boolean;
|
|
152
|
-
next_cursor: string | null;
|
|
153
|
-
prev_cursor: string | null;
|
|
154
|
-
}
|
|
1
|
+
import { F as FilterValue, a as FieldCondition, b as FilterScalar, c as FilterNode, A as AndGroup, O as OrGroup, N as NotGroup, S as SkippedCondition } from './raw-Bx8c-TrC.cjs';
|
|
2
|
+
export { d as AggregateSpec, e as AllRows, C as CursorMeta, D as DEFAULT_LIMIT, f as DEFAULT_MAX_CONDITIONS, g as DEFAULT_MAX_FILTER_DEPTH, h as DEFAULT_MAX_IN_ITEMS, i as DEFAULT_MAX_LIKE_WILDCARDS, j as DEFAULT_MAX_LIMIT, k as DEFAULT_MAX_OFFSET, l as DEFAULT_MAX_PER_PAGE, m as DEFAULT_MAX_SORT_FIELDS, n as DEFAULT_MAX_STRING_LENGTH, o as DEFAULT_PER_PAGE, p as DEFAULT_QUERY_LIMITS, q as FILTER_OPERATORS, r as Filter, s as FilterOperator, t as Filterable, I as InfiniteMeta, L as LooseKey, M as MutationCount, u as MutationOptions, v as MutationRows, w as OffsetMeta, Q as QueryLimits, R as RelationRule, x as Relations, y as Scope, z as ScopeIn, B as SkipReason, E as SkipSite, G as Sort, H as SortDirection, J as SortItem, T as TEXT_FILTER_OPERATORS, U as UpsertOptions, W as WireBaseParams, K as WireCursorParams, P as WireInfiniteParams, V as WireOffsetParams, X as raw, Y as resolveLimits } from './raw-Bx8c-TrC.cjs';
|
|
155
3
|
|
|
156
4
|
/**
|
|
157
5
|
* Filter shartlarini tipli, ergonomik quruvchilar to'plamini qaytaradi. Kalit
|
|
@@ -218,24 +66,6 @@ declare const f: {
|
|
|
218
66
|
not: (node: FilterNode<string, never>) => NotGroup<string, never>;
|
|
219
67
|
};
|
|
220
68
|
|
|
221
|
-
/**
|
|
222
|
-
* Umumiy pagination default'lari — yagona manba. Backend adapter (`createRegistry`
|
|
223
|
-
* options) va frontend (`createQuery` config) shu qiymatlarni fallback sifatida
|
|
224
|
-
* ishlatadi, shuning uchun ular hech qachon bir-biridan farq qilmaydi.
|
|
225
|
-
*/
|
|
226
|
-
/** Offset (list) sahifa o'lchami default'i. */
|
|
227
|
-
declare const DEFAULT_PER_PAGE = 20;
|
|
228
|
-
/** Infinite/cursor `limit` default'i. */
|
|
229
|
-
declare const DEFAULT_LIMIT = 20;
|
|
230
|
-
/**
|
|
231
|
-
* `perPage` uchun yuqori chegara — cap'siz paginatsiya DoS yuzasi. Validatsiya
|
|
232
|
-
* (`@querykitjs/zod` factory'lari), backend repositorylari va frontend `createQuery`
|
|
233
|
-
* shu bitta qiymatga tayanadi, shuning uchun ular hech qachon farq qilmaydi.
|
|
234
|
-
*/
|
|
235
|
-
declare const DEFAULT_MAX_PER_PAGE = 200;
|
|
236
|
-
/** Infinite/cursor `limit` uchun yuqori chegara. Qarang: {@link DEFAULT_MAX_PER_PAGE}. */
|
|
237
|
-
declare const DEFAULT_MAX_LIMIT = 200;
|
|
238
|
-
|
|
239
69
|
/**
|
|
240
70
|
* querykit xatolari. Backend adapterlari (`drizzle-pg`, `mongoose`) `strict`
|
|
241
71
|
* rejimda shu bitta klassni tashlaydi — ya'ni ikkala backend uchun xatoni
|
|
@@ -262,5 +92,25 @@ declare class QueryKitError extends Error {
|
|
|
262
92
|
readonly info: SkippedCondition;
|
|
263
93
|
constructor(info: SkippedCondition);
|
|
264
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* A read ran past its time limit (`maxTimeMS` on MongoDB). Kept apart from
|
|
97
|
+
* {@link QueryKitError}: the request was valid, the database was slow — map it to
|
|
98
|
+
* 503 / 504, not 400.
|
|
99
|
+
*/
|
|
100
|
+
declare class QueryKitTimeoutError extends Error {
|
|
101
|
+
/** Collection / model name. */
|
|
102
|
+
readonly source: string;
|
|
103
|
+
/** The limit that was hit, in milliseconds. */
|
|
104
|
+
readonly maxTimeMS: number;
|
|
105
|
+
/** Stable code for boundaries where `instanceof` does not work. */
|
|
106
|
+
readonly code = "QUERYKIT_TIMEOUT";
|
|
107
|
+
constructor(
|
|
108
|
+
/** Collection / model name. */
|
|
109
|
+
source: string,
|
|
110
|
+
/** The limit that was hit, in milliseconds. */
|
|
111
|
+
maxTimeMS: number, options?: {
|
|
112
|
+
cause?: unknown;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
265
115
|
|
|
266
|
-
export {
|
|
116
|
+
export { AndGroup, FieldCondition, FilterNode, FilterScalar, FilterValue, NotGroup, OrGroup, QueryKitError, QueryKitTimeoutError, SkippedCondition, createFilters, f };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,157 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* shundan chiqadi; `@querykitjs/zod` shu massivdan zod enum quradi.
|
|
4
|
-
*/
|
|
5
|
-
declare const FILTER_OPERATORS: readonly ["=", "!=", ">", ">=", "<", "<=", "eq", "ne", "gt", "gte", "lt", "lte", "like", "ilike", "notLike", "contains", "startsWith", "endsWith", "%_%", "%_", "_%", "in", "notIn", "between", "notBetween", "isNull", "isNotNull"];
|
|
6
|
-
/**
|
|
7
|
-
* Qiymati **text pattern** bo'lgan operatorlar. Backend adapterlari wire qiymatni
|
|
8
|
-
* ustun/path tipiga cast qilishda shularni chetlab o'tadi — aks holda
|
|
9
|
-
* `ilike(dateColumn, "%2026%")` ISO string o'rniga `String(Date)` olardi
|
|
10
|
-
* (`"Mon Jul 28 2026 …"`). Ro'yxat ikki adapterda divergent bo'lmasligi uchun
|
|
11
|
-
* shu yerda — yagona manba.
|
|
12
|
-
*/
|
|
13
|
-
declare const TEXT_FILTER_OPERATORS: readonly ["like", "ilike", "notLike", "contains", "startsWith", "endsWith", "%_%", "%_", "_%"];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* `@querykitjs/core` — ORM-agnostik query DSL tiplari. Backend adapterlar
|
|
17
|
-
* (`@querykitjs/drizzle-pg`) va frontend (`@querykitjs/web`) shu bir xil kontraktga
|
|
18
|
-
* tayanadi. Tiplar ustun-kaliti (`TKey`) bo'yicha generic; adapterlar uni o'z
|
|
19
|
-
* kalit tipiga (Drizzle jadval ustuni yoki entity maydoni) ixtisoslashtiradi.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/** Qo'llab-quvvatlanadigan filter operatorlari (token va nom aliaslari). */
|
|
23
|
-
type FilterOperator = (typeof FILTER_OPERATORS)[number];
|
|
24
|
-
/**
|
|
25
|
-
* Tiplangan kalit, lekin har qanday `string` ham qabul qilinadi. Wire (JSON) har
|
|
26
|
-
* doim string-keyed keladi va adapterlar noma'lum kalitni baribir skip qiladi —
|
|
27
|
-
* tip shunchaki haqiqatni aytsin, route'da `as` cast kerak bo'lmasin.
|
|
28
|
-
*
|
|
29
|
-
* `(string & {})` — autocomplete'ni saqlaydigan TS trick'i: IDE `TKey`
|
|
30
|
-
* variantlarini taklif qiladi, boshqa string esa xato bermaydi.
|
|
31
|
-
*/
|
|
32
|
-
type LooseKey<TKey extends string> = TKey | (string & {});
|
|
33
|
-
/**
|
|
34
|
-
* A filter scalar. `Date` is accepted **in-memory** (adapters cast it for local
|
|
35
|
-
* queries); over the JSON wire it serializes to an ISO string, so
|
|
36
|
-
* `@querykitjs/zod` validates scalars **without** `Date` (string/number/boolean/null).
|
|
37
|
-
*/
|
|
38
|
-
type FilterScalar = string | number | boolean | Date | null;
|
|
39
|
-
type FilterValue = FilterScalar | FilterScalar[];
|
|
40
|
-
/** Bitta maydon sharti (`operation` default `"="`). */
|
|
41
|
-
interface FieldCondition<TKey extends string = string> {
|
|
42
|
-
key: TKey;
|
|
43
|
-
operation?: FilterOperator;
|
|
44
|
-
value?: FilterValue;
|
|
45
|
-
}
|
|
46
|
-
interface AndGroup<TKey extends string = string, TRaw = never> {
|
|
47
|
-
and: FilterNode<TKey, TRaw>[];
|
|
48
|
-
}
|
|
49
|
-
interface OrGroup<TKey extends string = string, TRaw = never> {
|
|
50
|
-
or: FilterNode<TKey, TRaw>[];
|
|
51
|
-
}
|
|
52
|
-
interface NotGroup<TKey extends string = string, TRaw = never> {
|
|
53
|
-
not: FilterNode<TKey, TRaw>;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Filter daraxti tuguni: maydon sharti, mantiqiy guruh, yoki adapter qo'shadigan
|
|
57
|
-
* raw escape-hatch (`TRaw`, masalan Drizzle `SQL`; default `never`).
|
|
58
|
-
*/
|
|
59
|
-
type FilterNode<TKey extends string = string, TRaw = never> = FieldCondition<TKey> | AndGroup<TKey, TRaw> | OrGroup<TKey, TRaw> | NotGroup<TKey, TRaw> | TRaw;
|
|
60
|
-
/** Public filter: daraxt/tugun yoki flat massiv (implicit AND). */
|
|
61
|
-
type Filter<TKey extends string = string, TRaw = never> = FilterNode<TKey, TRaw> | FieldCondition<TKey>[];
|
|
62
|
-
type SortDirection = "asc" | "desc";
|
|
63
|
-
/** One sort field — `{ key, direction }`. */
|
|
64
|
-
interface SortItem<TKey extends string = string> {
|
|
65
|
-
key: TKey;
|
|
66
|
-
direction?: SortDirection;
|
|
67
|
-
}
|
|
68
|
-
/** Sort is **always an array** of {@link SortItem} (multi-field capable). */
|
|
69
|
-
type Sort<TKey extends string = string> = SortItem<TKey>[];
|
|
70
|
-
/** Equality scope applied to every operation of a scoped repository. */
|
|
71
|
-
type Scope<TKey extends string = string> = Partial<Record<TKey, FilterScalar>>;
|
|
72
|
-
/** Options for upsert / upsertMany — conflict target(s) + optional update set. */
|
|
73
|
-
interface UpsertOptions<TKey extends string = string, TInsert = Record<string, unknown>> {
|
|
74
|
-
/** Unique/conflict key(s) whose match triggers an update instead of an insert. */
|
|
75
|
-
target: TKey | TKey[];
|
|
76
|
-
/** Columns/fields to update on conflict. Defaults to the inserted values minus `target`. */
|
|
77
|
-
set?: Partial<TInsert>;
|
|
78
|
-
}
|
|
79
|
-
/** Aggregate query spec — group + count/sum/avg/min/max, each keyed by field. */
|
|
80
|
-
interface AggregateSpec<TKey extends string = string, TFilter = unknown> {
|
|
81
|
-
filter?: TFilter;
|
|
82
|
-
/** Group rows by these field(s); each appears in the output rows. */
|
|
83
|
-
groupBy?: TKey | TKey[];
|
|
84
|
-
count?: boolean;
|
|
85
|
-
sum?: TKey | TKey[];
|
|
86
|
-
avg?: TKey | TKey[];
|
|
87
|
-
min?: TKey | TKey[];
|
|
88
|
-
max?: TKey | TKey[];
|
|
89
|
-
withDeleted?: boolean;
|
|
90
|
-
}
|
|
91
|
-
/** Paginatsiyasiz umumiy wire params. */
|
|
92
|
-
interface WireBaseParams {
|
|
93
|
-
filter?: Filter;
|
|
94
|
-
sort?: Sort;
|
|
95
|
-
columns?: Record<string, boolean>;
|
|
96
|
-
with?: Record<string, unknown>;
|
|
97
|
-
withDeleted?: boolean;
|
|
98
|
-
}
|
|
99
|
-
/** Offset (sahifali) wire params. */
|
|
100
|
-
interface WireOffsetParams extends WireBaseParams {
|
|
101
|
-
page?: number;
|
|
102
|
-
perPage?: number;
|
|
103
|
-
}
|
|
104
|
-
/** Infinite-scroll wire params. */
|
|
105
|
-
interface WireInfiniteParams extends WireBaseParams {
|
|
106
|
-
limit?: number;
|
|
107
|
-
offset?: number;
|
|
108
|
-
}
|
|
109
|
-
/** Cursor (keyset) wire params — `sort` yo'q, tartib `order` + `direction` bilan. */
|
|
110
|
-
interface WireCursorParams extends Omit<WireBaseParams, "sort"> {
|
|
111
|
-
limit?: number;
|
|
112
|
-
cursor?: string | null;
|
|
113
|
-
cursorKey?: string;
|
|
114
|
-
order?: SortDirection;
|
|
115
|
-
direction?: "forward" | "backward";
|
|
116
|
-
}
|
|
117
|
-
/** Shart nima uchun tashlab yuborilgani. */
|
|
118
|
-
type SkipReason = "unknown-key" | "invalid-value";
|
|
119
|
-
/** Shart qayerda tashlab yuborilgani. */
|
|
120
|
-
type SkipSite = "filter" | "sort" | "cursorKey" | "aggregate";
|
|
121
|
-
/** Tashlab yuborilgan bitta shart haqida ma'lumot. */
|
|
122
|
-
interface SkippedCondition {
|
|
123
|
-
/** Jadval (drizzle) yoki model (mongoose) nomi. */
|
|
124
|
-
source: string;
|
|
125
|
-
site: SkipSite;
|
|
126
|
-
key: string;
|
|
127
|
-
operation?: FilterOperator;
|
|
128
|
-
reason: SkipReason;
|
|
129
|
-
}
|
|
130
|
-
/** Offset (sahifali) paginatsiya meta'si. */
|
|
131
|
-
interface OffsetMeta {
|
|
132
|
-
total_items: number;
|
|
133
|
-
total_pages: number;
|
|
134
|
-
current_page: number;
|
|
135
|
-
per_page: number;
|
|
136
|
-
has_next: boolean;
|
|
137
|
-
has_prev: boolean;
|
|
138
|
-
}
|
|
139
|
-
/** Infinite-scroll paginatsiya meta'si. */
|
|
140
|
-
interface InfiniteMeta {
|
|
141
|
-
limit: number;
|
|
142
|
-
offset: number;
|
|
143
|
-
count: number;
|
|
144
|
-
has_more: boolean;
|
|
145
|
-
next_offset: number | null;
|
|
146
|
-
}
|
|
147
|
-
/** Cursor (keyset) paginatsiya meta'si. */
|
|
148
|
-
interface CursorMeta {
|
|
149
|
-
limit: number;
|
|
150
|
-
has_next: boolean;
|
|
151
|
-
has_prev: boolean;
|
|
152
|
-
next_cursor: string | null;
|
|
153
|
-
prev_cursor: string | null;
|
|
154
|
-
}
|
|
1
|
+
import { F as FilterValue, a as FieldCondition, b as FilterScalar, c as FilterNode, A as AndGroup, O as OrGroup, N as NotGroup, S as SkippedCondition } from './raw-Bx8c-TrC.js';
|
|
2
|
+
export { d as AggregateSpec, e as AllRows, C as CursorMeta, D as DEFAULT_LIMIT, f as DEFAULT_MAX_CONDITIONS, g as DEFAULT_MAX_FILTER_DEPTH, h as DEFAULT_MAX_IN_ITEMS, i as DEFAULT_MAX_LIKE_WILDCARDS, j as DEFAULT_MAX_LIMIT, k as DEFAULT_MAX_OFFSET, l as DEFAULT_MAX_PER_PAGE, m as DEFAULT_MAX_SORT_FIELDS, n as DEFAULT_MAX_STRING_LENGTH, o as DEFAULT_PER_PAGE, p as DEFAULT_QUERY_LIMITS, q as FILTER_OPERATORS, r as Filter, s as FilterOperator, t as Filterable, I as InfiniteMeta, L as LooseKey, M as MutationCount, u as MutationOptions, v as MutationRows, w as OffsetMeta, Q as QueryLimits, R as RelationRule, x as Relations, y as Scope, z as ScopeIn, B as SkipReason, E as SkipSite, G as Sort, H as SortDirection, J as SortItem, T as TEXT_FILTER_OPERATORS, U as UpsertOptions, W as WireBaseParams, K as WireCursorParams, P as WireInfiniteParams, V as WireOffsetParams, X as raw, Y as resolveLimits } from './raw-Bx8c-TrC.js';
|
|
155
3
|
|
|
156
4
|
/**
|
|
157
5
|
* Filter shartlarini tipli, ergonomik quruvchilar to'plamini qaytaradi. Kalit
|
|
@@ -218,24 +66,6 @@ declare const f: {
|
|
|
218
66
|
not: (node: FilterNode<string, never>) => NotGroup<string, never>;
|
|
219
67
|
};
|
|
220
68
|
|
|
221
|
-
/**
|
|
222
|
-
* Umumiy pagination default'lari — yagona manba. Backend adapter (`createRegistry`
|
|
223
|
-
* options) va frontend (`createQuery` config) shu qiymatlarni fallback sifatida
|
|
224
|
-
* ishlatadi, shuning uchun ular hech qachon bir-biridan farq qilmaydi.
|
|
225
|
-
*/
|
|
226
|
-
/** Offset (list) sahifa o'lchami default'i. */
|
|
227
|
-
declare const DEFAULT_PER_PAGE = 20;
|
|
228
|
-
/** Infinite/cursor `limit` default'i. */
|
|
229
|
-
declare const DEFAULT_LIMIT = 20;
|
|
230
|
-
/**
|
|
231
|
-
* `perPage` uchun yuqori chegara — cap'siz paginatsiya DoS yuzasi. Validatsiya
|
|
232
|
-
* (`@querykitjs/zod` factory'lari), backend repositorylari va frontend `createQuery`
|
|
233
|
-
* shu bitta qiymatga tayanadi, shuning uchun ular hech qachon farq qilmaydi.
|
|
234
|
-
*/
|
|
235
|
-
declare const DEFAULT_MAX_PER_PAGE = 200;
|
|
236
|
-
/** Infinite/cursor `limit` uchun yuqori chegara. Qarang: {@link DEFAULT_MAX_PER_PAGE}. */
|
|
237
|
-
declare const DEFAULT_MAX_LIMIT = 200;
|
|
238
|
-
|
|
239
69
|
/**
|
|
240
70
|
* querykit xatolari. Backend adapterlari (`drizzle-pg`, `mongoose`) `strict`
|
|
241
71
|
* rejimda shu bitta klassni tashlaydi — ya'ni ikkala backend uchun xatoni
|
|
@@ -262,5 +92,25 @@ declare class QueryKitError extends Error {
|
|
|
262
92
|
readonly info: SkippedCondition;
|
|
263
93
|
constructor(info: SkippedCondition);
|
|
264
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* A read ran past its time limit (`maxTimeMS` on MongoDB). Kept apart from
|
|
97
|
+
* {@link QueryKitError}: the request was valid, the database was slow — map it to
|
|
98
|
+
* 503 / 504, not 400.
|
|
99
|
+
*/
|
|
100
|
+
declare class QueryKitTimeoutError extends Error {
|
|
101
|
+
/** Collection / model name. */
|
|
102
|
+
readonly source: string;
|
|
103
|
+
/** The limit that was hit, in milliseconds. */
|
|
104
|
+
readonly maxTimeMS: number;
|
|
105
|
+
/** Stable code for boundaries where `instanceof` does not work. */
|
|
106
|
+
readonly code = "QUERYKIT_TIMEOUT";
|
|
107
|
+
constructor(
|
|
108
|
+
/** Collection / model name. */
|
|
109
|
+
source: string,
|
|
110
|
+
/** The limit that was hit, in milliseconds. */
|
|
111
|
+
maxTimeMS: number, options?: {
|
|
112
|
+
cause?: unknown;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
265
115
|
|
|
266
|
-
export {
|
|
116
|
+
export { AndGroup, FieldCondition, FilterNode, FilterScalar, FilterValue, NotGroup, OrGroup, QueryKitError, QueryKitTimeoutError, SkippedCondition, createFilters, f };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1
|
+
export { DEFAULT_LIMIT, DEFAULT_MAX_CONDITIONS, DEFAULT_MAX_FILTER_DEPTH, DEFAULT_MAX_IN_ITEMS, DEFAULT_MAX_LIKE_WILDCARDS, DEFAULT_MAX_LIMIT, DEFAULT_MAX_OFFSET, DEFAULT_MAX_PER_PAGE, DEFAULT_MAX_SORT_FIELDS, DEFAULT_MAX_STRING_LENGTH, DEFAULT_PER_PAGE, DEFAULT_QUERY_LIMITS, QueryKitError, QueryKitTimeoutError, raw, resolveLimits } from './chunk-NHNDPIPM.js';
|
|
4
2
|
|
|
5
3
|
// src/filters.ts
|
|
6
4
|
function field(key, operation, value) {
|
|
@@ -36,26 +34,7 @@ function createFilters() {
|
|
|
36
34
|
not: (node) => ({ not: node })
|
|
37
35
|
};
|
|
38
36
|
}
|
|
39
|
-
var f = createFilters();
|
|
40
|
-
|
|
41
|
-
// src/defaults.ts
|
|
42
|
-
var DEFAULT_PER_PAGE = 20;
|
|
43
|
-
var DEFAULT_LIMIT = 20;
|
|
44
|
-
var DEFAULT_MAX_PER_PAGE = 200;
|
|
45
|
-
var DEFAULT_MAX_LIMIT = 200;
|
|
46
|
-
|
|
47
|
-
// src/errors.ts
|
|
48
|
-
var QueryKitError = class extends Error {
|
|
49
|
-
constructor(info) {
|
|
50
|
-
super(`querykit: ${info.reason} \u2014 "${info.key}" (${info.site}) on "${info.source}".`);
|
|
51
|
-
/** Barqaror kod — `instanceof` ishlamaydigan chegaralarda (RPC, worker) tekshirish uchun. */
|
|
52
|
-
__publicField(this, "code", "QUERYKIT_INVALID_CONDITION");
|
|
53
|
-
/** Tashlab yuborilgan shart haqida to'liq ma'lumot (hook argumenti bilan bir xil shakl). */
|
|
54
|
-
__publicField(this, "info");
|
|
55
|
-
this.name = "QueryKitError";
|
|
56
|
-
this.info = info;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
37
|
+
var f = /* @__PURE__ */ createFilters();
|
|
59
38
|
|
|
60
39
|
// src/operators.ts
|
|
61
40
|
var FILTER_OPERATORS = [
|
|
@@ -89,8 +68,7 @@ var FILTER_OPERATORS = [
|
|
|
89
68
|
"notBetween",
|
|
90
69
|
"isNull",
|
|
91
70
|
"isNotNull"
|
|
92
|
-
]
|
|
93
|
-
var TEXT_FILTER_OPERATORS = [
|
|
71
|
+
], TEXT_FILTER_OPERATORS = [
|
|
94
72
|
"like",
|
|
95
73
|
"ilike",
|
|
96
74
|
"notLike",
|
|
@@ -102,6 +80,6 @@ var TEXT_FILTER_OPERATORS = [
|
|
|
102
80
|
"_%"
|
|
103
81
|
];
|
|
104
82
|
|
|
105
|
-
export {
|
|
83
|
+
export { FILTER_OPERATORS, TEXT_FILTER_OPERATORS, createFilters, f };
|
|
106
84
|
//# sourceMappingURL=index.js.map
|
|
107
85
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/filters.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/filters.ts","../src/operators.ts"],"names":[],"mappings":";;;AAEA,SAAS,KAAA,CAA2B,GAAA,EAAW,SAAA,EAA2B,KAAA,EAA2C;AACnH,EAAA,OAAO,EAAE,GAAA,EAAK,SAAA,EAAW,KAAA,EAAM;AACjC;AAeO,SAAS,aAAA,GAA4D;AAG1E,EAAA,OAAO;AAAA,IACL,IAAI,CAAC,GAAA,EAAW,UAAuB,KAAA,CAAM,GAAA,EAAK,KAAK,KAAK,CAAA;AAAA,IAC5D,IAAI,CAAC,GAAA,EAAW,UAAuB,KAAA,CAAM,GAAA,EAAK,MAAM,KAAK,CAAA;AAAA,IAC7D,IAAI,CAAC,GAAA,EAAW,UAAuB,KAAA,CAAM,GAAA,EAAK,KAAK,KAAK,CAAA;AAAA,IAC5D,KAAK,CAAC,GAAA,EAAW,UAAuB,KAAA,CAAM,GAAA,EAAK,MAAM,KAAK,CAAA;AAAA,IAC9D,IAAI,CAAC,GAAA,EAAW,UAAuB,KAAA,CAAM,GAAA,EAAK,KAAK,KAAK,CAAA;AAAA,IAC5D,KAAK,CAAC,GAAA,EAAW,UAAuB,KAAA,CAAM,GAAA,EAAK,MAAM,KAAK,CAAA;AAAA,IAE9D,UAAU,CAAC,GAAA,EAAW,UAAkB,KAAA,CAAM,GAAA,EAAK,OAAO,KAAK,CAAA;AAAA,IAC/D,YAAY,CAAC,GAAA,EAAW,UAAkB,KAAA,CAAM,GAAA,EAAK,MAAM,KAAK,CAAA;AAAA,IAChE,UAAU,CAAC,GAAA,EAAW,UAAkB,KAAA,CAAM,GAAA,EAAK,MAAM,KAAK,CAAA;AAAA,IAC9D,MAAM,CAAC,GAAA,EAAW,UAAkB,KAAA,CAAM,GAAA,EAAK,QAAQ,KAAK,CAAA;AAAA,IAC5D,OAAO,CAAC,GAAA,EAAW,UAAkB,KAAA,CAAM,GAAA,EAAK,SAAS,KAAK,CAAA;AAAA,IAC9D,SAAS,CAAC,GAAA,EAAW,UAAkB,KAAA,CAAM,GAAA,EAAK,WAAW,KAAK,CAAA;AAAA,IAElE,IAAI,CAAC,GAAA,EAAW,UAAkC,KAAA,CAAM,GAAA,EAAK,MAAM,KAAK,CAAA;AAAA,IACxE,OAAO,CAAC,GAAA,EAAW,UAAkC,KAAA,CAAM,GAAA,EAAK,SAAS,KAAK,CAAA;AAAA,IAC9E,OAAA,EAAS,CAAC,GAAA,EAAW,GAAA,EAA0B,GAAA,KAA6B,KAAA,CAAM,GAAA,EAAK,SAAA,EAAW,CAAC,GAAA,EAAK,GAAG,CAAgB,CAAA;AAAA,IAC3H,UAAA,EAAY,CAAC,GAAA,EAAW,GAAA,EAA0B,GAAA,KAA6B,KAAA,CAAM,GAAA,EAAK,YAAA,EAAc,CAAC,GAAA,EAAK,GAAG,CAAgB,CAAA;AAAA;AAAA,IAEjI,KAAA,EAAO,CAAC,GAAA,EAAW,IAAA,EAA2B,EAAA,KAAoD;AAAA,MAChG,KAAA,CAAM,GAAA,EAAK,IAAA,EAAM,IAAmB,CAAA;AAAA,MACpC,KAAA,CAAM,GAAA,EAAK,IAAA,EAAM,EAAiB;AAAA,KACpC;AAAA,IAEA,MAAA,EAAQ,CAAC,GAAA,KAAc,KAAA,CAAM,KAAK,QAAQ,CAAA;AAAA,IAC1C,SAAA,EAAW,CAAC,GAAA,KAAc,KAAA,CAAM,KAAK,WAAW,CAAA;AAAA,IAEhD,GAAA,EAAK,CAAA,GAAI,KAAA,MAAyC,EAAE,KAAK,KAAA,EAAM,CAAA;AAAA,IAC/D,EAAA,EAAI,CAAA,GAAI,KAAA,MAAwC,EAAE,IAAI,KAAA,EAAM,CAAA;AAAA,IAC5D,GAAA,EAAK,CAAC,IAAA,MAAsC,EAAE,KAAK,IAAA,EAAK;AAAA,GAC1D;AACF;AAGO,IAAM,oBAAoB,aAAA;;;ACrD1B,IAAM,gBAAA,GAAmB;AAAA,EAC9B,GAAA;AAAA,EACA,IAAA;AAAA,EACA,GAAA;AAAA,EACA,IAAA;AAAA,EACA,GAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,KAAA;AAAA;AAAA,EACA,IAAA;AAAA;AAAA,EACA,IAAA;AAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,CAAA,CASa,qBAAA,GAAwB;AAAA,EACnC,MAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["import type { AndGroup, FieldCondition, FilterNode, FilterOperator, FilterScalar, FilterValue, NotGroup, OrGroup } from \"./types\";\n\nfunction field<TKey extends string>(key: TKey, operation: FilterOperator, value?: FilterValue): FieldCondition<TKey> {\n return { key, operation, value };\n}\n\n/**\n * Filter shartlarini tipli, ergonomik quruvchilar to'plamini qaytaradi. Kalit\n * tipiga (`TKey`) bog'lanadi; adapterlar uni o'z ustun/maydon kaliti bilan\n * chaqiradi. `TRaw` — guruhlarga (`and/or/not`) qo'shsa bo'ladigan raw tugun tipi.\n *\n * @typeParam TKey - ustun/maydon kaliti (string union).\n * @typeParam TRaw - raw escape-hatch tugun tipi (masalan Drizzle `SQL`).\n * @example\n * ```ts\n * const f = createFilters<\"status\" | \"age\">();\n * f.and(f.eq(\"status\", \"active\"), f.gte(\"age\", 18));\n * ```\n */\nexport function createFilters<TKey extends string = string, TRaw = never>() {\n type Node = FilterNode<TKey, TRaw>;\n\n return {\n eq: (key: TKey, value: FilterValue) => field(key, \"=\", value),\n ne: (key: TKey, value: FilterValue) => field(key, \"!=\", value),\n gt: (key: TKey, value: FilterValue) => field(key, \">\", value),\n gte: (key: TKey, value: FilterValue) => field(key, \">=\", value),\n lt: (key: TKey, value: FilterValue) => field(key, \"<\", value),\n lte: (key: TKey, value: FilterValue) => field(key, \"<=\", value),\n\n contains: (key: TKey, value: string) => field(key, \"%_%\", value),\n startsWith: (key: TKey, value: string) => field(key, \"%_\", value),\n endsWith: (key: TKey, value: string) => field(key, \"_%\", value),\n like: (key: TKey, value: string) => field(key, \"like\", value),\n ilike: (key: TKey, value: string) => field(key, \"ilike\", value),\n notLike: (key: TKey, value: string) => field(key, \"notLike\", value),\n\n in: (key: TKey, value: Array<string | number>) => field(key, \"in\", value),\n notIn: (key: TKey, value: Array<string | number>) => field(key, \"notIn\", value),\n between: (key: TKey, min: FilterScalar | Date, max: FilterScalar | Date) => field(key, \"between\", [min, max] as FilterValue),\n notBetween: (key: TKey, min: FilterScalar | Date, max: FilterScalar | Date) => field(key, \"notBetween\", [min, max] as FilterValue),\n /** Diapazon — ikkita shart (`>=` va `<=`) massivi (flat filterga spread qilinadi). */\n range: (key: TKey, from: FilterScalar | Date, to: FilterScalar | Date): FieldCondition<TKey>[] => [\n field(key, \">=\", from as FilterValue),\n field(key, \"<=\", to as FilterValue),\n ],\n\n isNull: (key: TKey) => field(key, \"isNull\"),\n isNotNull: (key: TKey) => field(key, \"isNotNull\"),\n\n and: (...nodes: Node[]): AndGroup<TKey, TRaw> => ({ and: nodes }),\n or: (...nodes: Node[]): OrGroup<TKey, TRaw> => ({ or: nodes }),\n not: (node: Node): NotGroup<TKey, TRaw> => ({ not: node }),\n };\n}\n\n/** Tipsiz (kalitga bog'lanmagan) filter quruvchilar — tez foydalanish uchun. */\nexport const f = /* @__PURE__ */ createFilters();\n","/**\n * Filter operatorlari — yagona runtime manba. `FilterOperator` tipi (`types.ts`)\n * shundan chiqadi; `@querykitjs/zod` shu massivdan zod enum quradi.\n */\nexport const FILTER_OPERATORS = [\n \"=\",\n \"!=\",\n \">\",\n \">=\",\n \"<\",\n \"<=\",\n \"eq\",\n \"ne\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"like\",\n \"ilike\",\n \"notLike\",\n \"contains\",\n \"startsWith\",\n \"endsWith\",\n \"%_%\", // contains\n \"%_\", // startsWith\n \"_%\", // endsWith\n \"in\",\n \"notIn\",\n \"between\",\n \"notBetween\",\n \"isNull\",\n \"isNotNull\",\n] as const;\n\n/**\n * Qiymati **text pattern** bo'lgan operatorlar. Backend adapterlari wire qiymatni\n * ustun/path tipiga cast qilishda shularni chetlab o'tadi — aks holda\n * `ilike(dateColumn, \"%2026%\")` ISO string o'rniga `String(Date)` olardi\n * (`\"Mon Jul 28 2026 …\"`). Ro'yxat ikki adapterda divergent bo'lmasligi uchun\n * shu yerda — yagona manba.\n */\nexport const TEXT_FILTER_OPERATORS = [\n \"like\",\n \"ilike\",\n \"notLike\",\n \"contains\",\n \"startsWith\",\n \"endsWith\",\n \"%_%\",\n \"%_\",\n \"_%\",\n] as const satisfies readonly (typeof FILTER_OPERATORS)[number][];\n"]}
|