@querykitjs/class-validator 2.0.0 → 2.0.1
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/{chunk-X7HMP7H7.cjs → chunk-AX53IY63.cjs} +11 -11
- package/dist/{chunk-X7HMP7H7.cjs.map → chunk-AX53IY63.cjs.map} +1 -1
- package/dist/chunk-HKLXL3NW.cjs +42 -0
- package/dist/chunk-HKLXL3NW.cjs.map +1 -0
- package/dist/{chunk-BZRPXHJC.cjs → chunk-PKGWV2JC.cjs} +22 -22
- package/dist/chunk-PKGWV2JC.cjs.map +1 -0
- package/dist/chunk-QMFPUYJO.js +30 -0
- package/dist/chunk-QMFPUYJO.js.map +1 -0
- package/dist/{chunk-UICYH7OH.js → chunk-V4E73HMQ.js} +3 -3
- package/dist/{chunk-UICYH7OH.js.map → chunk-V4E73HMQ.js.map} +1 -1
- package/dist/{chunk-F3KZNLYZ.js → chunk-XF6C4EG2.js} +4 -4
- package/dist/chunk-XF6C4EG2.js.map +1 -0
- package/dist/decorators.cjs +8 -8
- package/dist/decorators.js +2 -2
- package/dist/index.cjs +68 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -82
- package/dist/index.d.ts +38 -82
- package/dist/index.js +46 -5
- package/dist/index.js.map +1 -1
- package/dist/legacy-dto.cjs +7 -7
- package/dist/legacy-dto.js +3 -3
- package/dist/validate.cjs +4 -4
- package/dist/validate.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-BZRPXHJC.cjs.map +0 -1
- package/dist/chunk-F3KZNLYZ.js.map +0 -1
- package/dist/chunk-KT5JRG6S.js +0 -194
- package/dist/chunk-KT5JRG6S.js.map +0 -1
- package/dist/chunk-KXCJO556.cjs +0 -207
- package/dist/chunk-KXCJO556.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,31 +1,71 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkPKGWV2JC_cjs = require('./chunk-PKGWV2JC.cjs');
|
|
4
|
+
var chunkAX53IY63_cjs = require('./chunk-AX53IY63.cjs');
|
|
5
|
+
var chunkHKLXL3NW_cjs = require('./chunk-HKLXL3NW.cjs');
|
|
6
|
+
var internal = require('@querykitjs/core/internal');
|
|
6
7
|
var classTransformer = require('class-transformer');
|
|
7
8
|
var classValidator = require('class-validator');
|
|
8
9
|
var core = require('@querykitjs/core');
|
|
9
10
|
|
|
11
|
+
var QUERYKIT_MESSAGES_UZ = {
|
|
12
|
+
"querykit.filter.invalid_node": "{path} filter sharti yoki and/or/not guruhi bo'lishi kerak",
|
|
13
|
+
"querykit.filter.missing_key": "{path} da majburiy `key` (string) yo'q",
|
|
14
|
+
"querykit.filter.unknown_key": "{path}: `{key}` ruxsat etilgan filter kaliti emas",
|
|
15
|
+
"querykit.filter.invalid_operator": "{path}: `{operation}` qo'llab-quvvatlanadigan filter operatori emas",
|
|
16
|
+
"querykit.filter.invalid_value": "{path} string, raqam, boolean, null yoki shularning massivi bo'lishi kerak",
|
|
17
|
+
"querykit.filter.invalid_group": "{path} filter tugunlari massivi bo'lishi kerak",
|
|
18
|
+
"querykit.filter.max_depth": "{path} limitdan oshdi: maxDepth ({max})",
|
|
19
|
+
"querykit.filter.value_requires_array": "{path}: `{operation}` massiv qiymat talab qiladi",
|
|
20
|
+
"querykit.filter.value_requires_tuple": "{path}: `{operation}` aynan ikkita qiymat talab qiladi",
|
|
21
|
+
"querykit.filter.value_forbidden": "{path}: `{operation}` qiymat qabul qilmaydi",
|
|
22
|
+
"querykit.sort.not_array": "{path} `{ key, direction }` elementlaridan iborat massiv bo'lishi kerak",
|
|
23
|
+
"querykit.sort.invalid_item": "{path} `key` (string) maydoniga ega obyekt bo'lishi kerak",
|
|
24
|
+
"querykit.sort.missing_key": "{path} da majburiy `key` (string) yo'q",
|
|
25
|
+
"querykit.sort.unknown_key": "{path}: `{key}` ruxsat etilgan sort kaliti emas",
|
|
26
|
+
"querykit.sort.invalid_direction": "{path}: direction `asc` yoki `desc` bo'lishi kerak",
|
|
27
|
+
"querykit.limit.exceeded": "{path} limitdan oshdi: {limit} ({max})"
|
|
28
|
+
}, QUERYKIT_MESSAGES_RU = {
|
|
29
|
+
"querykit.filter.invalid_node": "{path} \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0443\u0441\u043B\u043E\u0432\u0438\u0435\u043C \u0444\u0438\u043B\u044C\u0442\u0440\u0430 \u0438\u043B\u0438 \u0433\u0440\u0443\u043F\u043F\u043E\u0439 and/or/not",
|
|
30
|
+
"querykit.filter.missing_key": "\u0432 {path} \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435 `key` (\u0441\u0442\u0440\u043E\u043A\u0430)",
|
|
31
|
+
"querykit.filter.unknown_key": "{path}: `{key}` \u2014 \u043D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0439 \u043A\u043B\u044E\u0447 \u0444\u0438\u043B\u044C\u0442\u0440\u0430",
|
|
32
|
+
"querykit.filter.invalid_operator": "{path}: `{operation}` \u2014 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440 \u0444\u0438\u043B\u044C\u0442\u0440\u0430",
|
|
33
|
+
"querykit.filter.invalid_value": "{path} \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u043E\u0439, \u0447\u0438\u0441\u043B\u043E\u043C, boolean, null \u0438\u043B\u0438 \u043C\u0430\u0441\u0441\u0438\u0432\u043E\u043C \u0438\u0437 \u043D\u0438\u0445",
|
|
34
|
+
"querykit.filter.invalid_group": "{path} \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u043C\u0430\u0441\u0441\u0438\u0432\u043E\u043C \u0443\u0437\u043B\u043E\u0432 \u0444\u0438\u043B\u044C\u0442\u0440\u0430",
|
|
35
|
+
"querykit.filter.max_depth": "{path} \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043B\u0438\u043C\u0438\u0442 maxDepth ({max})",
|
|
36
|
+
"querykit.filter.value_requires_array": "{path}: `{operation}` \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435-\u043C\u0430\u0441\u0441\u0438\u0432",
|
|
37
|
+
"querykit.filter.value_requires_tuple": "{path}: `{operation}` \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0440\u043E\u0432\u043D\u043E \u0434\u0432\u0430 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F",
|
|
38
|
+
"querykit.filter.value_forbidden": "{path}: `{operation}` \u043D\u0435 \u0434\u043E\u043B\u0436\u0435\u043D \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",
|
|
39
|
+
"querykit.sort.not_array": "{path} \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u043C\u0430\u0441\u0441\u0438\u0432\u043E\u043C \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432 `{ key, direction }`",
|
|
40
|
+
"querykit.sort.invalid_item": "{path} \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u043C \u0441 \u043F\u043E\u043B\u0435\u043C `key` (\u0441\u0442\u0440\u043E\u043A\u0430)",
|
|
41
|
+
"querykit.sort.missing_key": "\u0432 {path} \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435 `key` (\u0441\u0442\u0440\u043E\u043A\u0430)",
|
|
42
|
+
"querykit.sort.unknown_key": "{path}: `{key}` \u2014 \u043D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0439 \u043A\u043B\u044E\u0447 \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0438",
|
|
43
|
+
"querykit.sort.invalid_direction": "{path}: direction \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C `asc` \u0438\u043B\u0438 `desc`",
|
|
44
|
+
"querykit.limit.exceeded": "{path} \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043B\u0438\u043C\u0438\u0442 {limit} ({max})"
|
|
45
|
+
}, QUERYKIT_LOCALES = {
|
|
46
|
+
en: internal.QUERYKIT_MESSAGES_EN,
|
|
47
|
+
uz: QUERYKIT_MESSAGES_UZ,
|
|
48
|
+
ru: QUERYKIT_MESSAGES_RU
|
|
49
|
+
};
|
|
10
50
|
var applyNumber = (proto, property, bounds) => {
|
|
11
51
|
classValidator.IsOptional()(proto, property), classTransformer.Type(() => Number)(proto, property), classValidator.IsInt()(proto, property), bounds.positive && classValidator.IsPositive()(proto, property), bounds.min !== void 0 && classValidator.Min(bounds.min)(proto, property), bounds.max !== void 0 && Number.isFinite(bounds.max) && classValidator.Max(bounds.max)(proto, property);
|
|
12
52
|
}, applyServerOwned = (proto, field) => {
|
|
13
53
|
classValidator.IsOptional()(proto, field), field === "withDeleted" ? classValidator.IsBoolean()(proto, field) : classValidator.IsObject()(proto, field);
|
|
14
54
|
}, applyFilterAndSort = (proto, options, limits, withSort) => {
|
|
15
|
-
classValidator.IsOptional()(proto, "filter"),
|
|
55
|
+
classValidator.IsOptional()(proto, "filter"), chunkAX53IY63_cjs.IsQueryFilter({ ...limits, ...options.filter, allowedKeys: options.filter?.allowedKeys ?? options.allowedKeys })(proto, "filter"), withSort && (classValidator.IsOptional()(proto, "sort"), chunkAX53IY63_cjs.IsQuerySort({ ...limits, ...options.sort, allowedKeys: options.sort?.allowedKeys ?? options.allowedKeys })(proto, "sort"));
|
|
16
56
|
for (let field of options.allow ?? []) applyServerOwned(proto, field);
|
|
17
57
|
}, nameClass = (cls, name) => (Object.defineProperty(cls, "name", { value: name, configurable: true }), cls);
|
|
18
58
|
function makeOffsetParamsDto(options = {}) {
|
|
19
59
|
class OffsetParams {
|
|
20
60
|
}
|
|
21
61
|
let limits = core.resolveLimits(options.limits);
|
|
22
|
-
return applyFilterAndSort(OffsetParams.prototype, options, limits, true), applyNumber(OffsetParams.prototype, "page", { positive: true }),
|
|
62
|
+
return applyFilterAndSort(OffsetParams.prototype, options, limits, true), applyNumber(OffsetParams.prototype, "page", { positive: true }), chunkAX53IY63_cjs.IsWithinMaxOffset({ mode: "page", maxOffset: limits.maxOffset })(OffsetParams.prototype, "page"), applyNumber(OffsetParams.prototype, "perPage", { positive: true, max: options.maxPerPage ?? core.DEFAULT_MAX_PER_PAGE }), classValidator.IsOptional()(OffsetParams.prototype, "withTotal"), classValidator.IsBoolean()(OffsetParams.prototype, "withTotal"), nameClass(OffsetParams, "OffsetParamsDto");
|
|
23
63
|
}
|
|
24
64
|
function makeInfiniteParamsDto(options = {}) {
|
|
25
65
|
class InfiniteParams {
|
|
26
66
|
}
|
|
27
67
|
let limits = core.resolveLimits(options.limits);
|
|
28
|
-
return applyFilterAndSort(InfiniteParams.prototype, options, limits, true), applyNumber(InfiniteParams.prototype, "limit", { positive: true, max: options.maxLimit ?? core.DEFAULT_MAX_LIMIT }), applyNumber(InfiniteParams.prototype, "offset", { min: 0 }),
|
|
68
|
+
return applyFilterAndSort(InfiniteParams.prototype, options, limits, true), applyNumber(InfiniteParams.prototype, "limit", { positive: true, max: options.maxLimit ?? core.DEFAULT_MAX_LIMIT }), applyNumber(InfiniteParams.prototype, "offset", { min: 0 }), chunkAX53IY63_cjs.IsWithinMaxOffset({ mode: "offset", maxOffset: limits.maxOffset })(InfiniteParams.prototype, "offset"), nameClass(InfiniteParams, "InfiniteParamsDto");
|
|
29
69
|
}
|
|
30
70
|
function makeCursorParamsDto(options = {}) {
|
|
31
71
|
class CursorParams {
|
|
@@ -36,80 +76,71 @@ function makeCursorParamsDto(options = {}) {
|
|
|
36
76
|
|
|
37
77
|
Object.defineProperty(exports, "BaseParamsDto", {
|
|
38
78
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
79
|
+
get: function () { return chunkPKGWV2JC_cjs.BaseParamsDto; }
|
|
40
80
|
});
|
|
41
81
|
Object.defineProperty(exports, "CursorParamsDto", {
|
|
42
82
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
83
|
+
get: function () { return chunkPKGWV2JC_cjs.CursorParamsDto; }
|
|
44
84
|
});
|
|
45
85
|
Object.defineProperty(exports, "InfiniteParamsDto", {
|
|
46
86
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
87
|
+
get: function () { return chunkPKGWV2JC_cjs.InfiniteParamsDto; }
|
|
48
88
|
});
|
|
49
89
|
Object.defineProperty(exports, "OffsetParamsDto", {
|
|
50
90
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
91
|
+
get: function () { return chunkPKGWV2JC_cjs.OffsetParamsDto; }
|
|
52
92
|
});
|
|
53
93
|
Object.defineProperty(exports, "IsQueryFilter", {
|
|
54
94
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
95
|
+
get: function () { return chunkAX53IY63_cjs.IsQueryFilter; }
|
|
56
96
|
});
|
|
57
97
|
Object.defineProperty(exports, "IsQueryFilterConstraint", {
|
|
58
98
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
99
|
+
get: function () { return chunkAX53IY63_cjs.IsQueryFilterConstraint; }
|
|
60
100
|
});
|
|
61
101
|
Object.defineProperty(exports, "IsQuerySort", {
|
|
62
102
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
103
|
+
get: function () { return chunkAX53IY63_cjs.IsQuerySort; }
|
|
64
104
|
});
|
|
65
105
|
Object.defineProperty(exports, "IsQuerySortConstraint", {
|
|
66
106
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
107
|
+
get: function () { return chunkAX53IY63_cjs.IsQuerySortConstraint; }
|
|
68
108
|
});
|
|
69
109
|
Object.defineProperty(exports, "IsWithinMaxOffset", {
|
|
70
110
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
111
|
+
get: function () { return chunkAX53IY63_cjs.IsWithinMaxOffset; }
|
|
72
112
|
});
|
|
73
113
|
Object.defineProperty(exports, "IsWithinMaxOffsetConstraint", {
|
|
74
114
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
115
|
+
get: function () { return chunkAX53IY63_cjs.IsWithinMaxOffsetConstraint; }
|
|
76
116
|
});
|
|
77
117
|
Object.defineProperty(exports, "DEFAULT_MAX_FILTER_DEPTH", {
|
|
78
118
|
enumerable: true,
|
|
79
|
-
get: function () { return
|
|
80
|
-
});
|
|
81
|
-
Object.defineProperty(exports, "QUERYKIT_LOCALES", {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
get: function () { return chunkKXCJO556_cjs.QUERYKIT_LOCALES; }
|
|
84
|
-
});
|
|
85
|
-
Object.defineProperty(exports, "QUERYKIT_MESSAGES_EN", {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
get: function () { return chunkKXCJO556_cjs.QUERYKIT_MESSAGES_EN; }
|
|
88
|
-
});
|
|
89
|
-
Object.defineProperty(exports, "QUERYKIT_MESSAGES_RU", {
|
|
90
|
-
enumerable: true,
|
|
91
|
-
get: function () { return chunkKXCJO556_cjs.QUERYKIT_MESSAGES_RU; }
|
|
92
|
-
});
|
|
93
|
-
Object.defineProperty(exports, "QUERYKIT_MESSAGES_UZ", {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
get: function () { return chunkKXCJO556_cjs.QUERYKIT_MESSAGES_UZ; }
|
|
119
|
+
get: function () { return chunkHKLXL3NW_cjs.DEFAULT_MAX_FILTER_DEPTH; }
|
|
96
120
|
});
|
|
97
121
|
Object.defineProperty(exports, "formatMessage", {
|
|
98
122
|
enumerable: true,
|
|
99
|
-
get: function () { return
|
|
123
|
+
get: function () { return chunkHKLXL3NW_cjs.formatMessage; }
|
|
100
124
|
});
|
|
101
125
|
Object.defineProperty(exports, "localizeIssue", {
|
|
102
126
|
enumerable: true,
|
|
103
|
-
get: function () { return
|
|
127
|
+
get: function () { return chunkHKLXL3NW_cjs.localizeIssue; }
|
|
104
128
|
});
|
|
105
129
|
Object.defineProperty(exports, "validateFilter", {
|
|
106
130
|
enumerable: true,
|
|
107
|
-
get: function () { return
|
|
131
|
+
get: function () { return chunkHKLXL3NW_cjs.validateFilter; }
|
|
108
132
|
});
|
|
109
133
|
Object.defineProperty(exports, "validateSort", {
|
|
110
134
|
enumerable: true,
|
|
111
|
-
get: function () { return
|
|
135
|
+
get: function () { return chunkHKLXL3NW_cjs.validateSort; }
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(exports, "QUERYKIT_MESSAGES_EN", {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function () { return internal.QUERYKIT_MESSAGES_EN; }
|
|
112
140
|
});
|
|
141
|
+
exports.QUERYKIT_LOCALES = QUERYKIT_LOCALES;
|
|
142
|
+
exports.QUERYKIT_MESSAGES_RU = QUERYKIT_MESSAGES_RU;
|
|
143
|
+
exports.QUERYKIT_MESSAGES_UZ = QUERYKIT_MESSAGES_UZ;
|
|
113
144
|
exports.makeCursorParamsDto = makeCursorParamsDto;
|
|
114
145
|
exports.makeInfiniteParamsDto = makeInfiniteParamsDto;
|
|
115
146
|
exports.makeOffsetParamsDto = makeOffsetParamsDto;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dto.ts"],"names":["IsOptional","Type","IsInt","IsPositive","Min","Max","IsBoolean","IsObject","IsQueryFilter","IsQuerySort","resolveLimits","IsWithinMaxOffset","DEFAULT_MAX_PER_PAG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AA,EAAW,CAAE,KAAA,EAAO,WAAW,CAAA,EAC/Be,oBAAK,CAAC,SAAA,EAAW,UAAU,CAAC,EAAE,KAAA,EAAO,WAAW,CAAA,EAEzC,SAAA,CAAU,cAAc,iBAAiB,CAAA;AAClD","file":"index.cjs","sourcesContent":["/**\n * Param DTO'lari — uchala paginatsiya uchun (offset / infinite / cursor).\n *\n * Ikki yo'l bilan ishlatiladi (ikkalasi ham bitta `validateFilter` yadrosiga\n * tayanadi):\n *\n * 1. **Subclass** — `class ListUsersDto extends OffsetParamsDto` va kerak bo'lsa\n * `filter`ni `@IsQueryFilter({ allowedKeys })` bilan qayta e'lon qilish;\n * 2. **Factory** — `makeOffsetParamsDto({ allowedKeys })`, boilerplatesiz.\n *\n * **Xavfsiz default:** `columns` / `with` / `withDeleted` hech qaysi DTO'da\n * e'lon qilinmagan, ya'ni `ValidationPipe({ whitelist: true })` ularni o'chiradi;\n * `perPage` / `limit` esa core'ning `DEFAULT_MAX_PER_PAGE` / `DEFAULT_MAX_LIMIT`\n * chegarasi bilan cheklangan. Ochish faqat factory'ning `allow` opsiyasi orqali.\n * Har DTO core so'rov limitlarini ham qo'llaydi (filtr hajmi, sort soni, offset\n * chuqurligi); factory'da `limits` bilan o'zgartiriladi.\n */\nimport { Type } from \"class-transformer\";\nimport { IsBoolean, IsIn, IsInt, IsObject, IsOptional, IsPositive, IsString, Max, Min } from \"class-validator\";\nimport { DEFAULT_MAX_LIMIT, DEFAULT_MAX_PER_PAGE, resolveLimits } from \"@querykitjs/core\";\nimport type { Filter, QueryLimits, Sort, SortDirection } from \"@querykitjs/core\";\nimport { IsQueryFilter, IsQuerySort, IsWithinMaxOffset, type IsQueryFilterOptions, type IsQuerySortOptions } from \"./decorators\";\n\n/* -------------------------------- factories ------------------------------- */\n\n/** Server'ga tegishli, default'da clientdan qabul qilinmaydigan maydonlar. */\nexport type ServerOwnedField = \"columns\" | \"with\" | \"withDeleted\";\n\n/** `allow` bilan ochiladigan maydonlarning shakli. */\nexport interface ServerOwnedParams {\n columns?: Record<string, boolean>;\n with?: Record<string, unknown>;\n withDeleted?: boolean;\n}\n\nexport interface ParamsDtoOptions {\n /** `filter` uchun to'liq opsiyalar — `allowedKeys`, `allowedOperators`, `maxDepth`, `strictValue`, `messageStyle`. */\n filter?: IsQueryFilterOptions;\n /** `sort` uchun opsiyalar — `allowedKeys`, `messageStyle`. */\n sort?: IsQuerySortOptions;\n /**\n * `filter` va `sort` uchun umumiy allowlist qisqartmasi — odatda ikkalasi bir xil.\n * Aniq berilgan `filter.allowedKeys` / `sort.allowedKeys` bundan **ustun**.\n */\n allowedKeys?: readonly string[];\n /** `perPage` yuqori chegarasi. Default — core `DEFAULT_MAX_PER_PAGE` (200). `Infinity` — cap yo'q (⚠️ DoS). */\n maxPerPage?: number;\n /** `limit` yuqori chegarasi. Default — core `DEFAULT_MAX_LIMIT` (200). */\n maxLimit?: number;\n /**\n * So'rov limitlari; berilmaganlari core default'ida (`DEFAULT_QUERY_LIMITS`). Aniq\n * berilgan `filter.maxDepth`, `sort.maxSortFields`, … bundan **ustun**.\n * `Infinity` limitni o'chiradi (⚠️ DoS yuzasi).\n */\n limits?: Partial<QueryLimits>;\n /** Server-owned maydonlarni **ataylab** ochish. Default — bo'sh. */\n allow?: readonly ServerOwnedField[];\n}\n\n/* Dinamik klasslar static klasslardan meros OLMAYDI: meros bo'lsa ota-klassning\n * default `@IsQueryFilter()` dekoratori ham qo'shilib, filter ikki marta —\n * bir marta opsiyalar bilan, bir marta ularsiz — tekshirilardi. Shuningdek\n * static klasslar prototipiga hech qachon imperativ dekorator qo'yilmaydi:\n * u global ifloslanish bo'lardi. */\n\nconst applyNumber = (proto: object, property: string, bounds: { positive?: boolean; min?: number; max?: number }): void => {\n IsOptional()(proto, property);\n Type(() => Number)(proto, property);\n IsInt()(proto, property);\n if (bounds.positive) IsPositive()(proto, property);\n if (bounds.min !== undefined) Min(bounds.min)(proto, property);\n /* `Infinity` cap'ni butunlay o'chiradi — cheksiz `@Max` konstrainti qo'yishdan\n * ko'ra uni umuman qo'ymagan ma'qul (xato xabari ham chalg'itmaydi). */\n if (bounds.max !== undefined && Number.isFinite(bounds.max)) Max(bounds.max)(proto, property);\n};\n\nconst applyServerOwned = (proto: object, field: ServerOwnedField): void => {\n IsOptional()(proto, field);\n if (field === \"withDeleted\") IsBoolean()(proto, field);\n else IsObject()(proto, field);\n};\n\nconst applyFilterAndSort = (proto: object, options: ParamsDtoOptions, limits: QueryLimits, withSort: boolean): void => {\n /* `limits` first: a dedicated `filter.*` / `sort.*` option wins. Unrelated limit keys are ignored by the validators. */\n IsOptional()(proto, \"filter\");\n IsQueryFilter({ ...limits, ...options.filter, allowedKeys: options.filter?.allowedKeys ?? options.allowedKeys })(proto, \"filter\");\n\n if (withSort) {\n IsOptional()(proto, \"sort\");\n IsQuerySort({ ...limits, ...options.sort, allowedKeys: options.sort?.allowedKeys ?? options.allowedKeys })(proto, \"sort\");\n }\n\n for (const field of options.allow ?? []) applyServerOwned(proto, field);\n};\n\n/** Nest xato loglarida `class_1` emas, tushunarli nom chiqsin. */\nconst nameClass = <T extends abstract new (...args: never[]) => unknown>(cls: T, name: string): T => {\n Object.defineProperty(cls, \"name\", { value: name, configurable: true });\n return cls;\n};\n\n/**\n * Offset (sahifali) params DTO'si — `allowedKeys` va cap'lar bilan.\n *\n * @example\n * ```ts\n * const ListBuyersDto = makeOffsetParamsDto({ allowedKeys: [\"buyerName\", \"createdAt\"] });\n * type ListBuyersDto = InstanceType<typeof ListBuyersDto>;\n *\n * @Post(\"list\")\n * list(@Body() params: ListBuyersDto) {\n * return this.buyersRepository.findList(params);\n * }\n * ```\n */\nexport function makeOffsetParamsDto(options: ParamsDtoOptions = {}) {\n class OffsetParams implements ServerOwnedParams {\n filter?: Filter;\n sort?: Sort;\n page?: number;\n perPage?: number;\n withTotal?: boolean;\n columns?: Record<string, boolean>;\n with?: Record<string, unknown>;\n withDeleted?: boolean;\n }\n\n const limits = resolveLimits(options.limits);\n applyFilterAndSort(OffsetParams.prototype, options, limits, true);\n applyNumber(OffsetParams.prototype, \"page\", { positive: true });\n IsWithinMaxOffset({ mode: \"page\", maxOffset: limits.maxOffset })(OffsetParams.prototype, \"page\");\n applyNumber(OffsetParams.prototype, \"perPage\", { positive: true, max: options.maxPerPage ?? DEFAULT_MAX_PER_PAGE });\n IsOptional()(OffsetParams.prototype, \"withTotal\");\n IsBoolean()(OffsetParams.prototype, \"withTotal\");\n\n return nameClass(OffsetParams, \"OffsetParamsDto\");\n}\n\n/** Infinite-scroll params DTO'si. Qarang: {@link makeOffsetParamsDto}. */\nexport function makeInfiniteParamsDto(options: ParamsDtoOptions = {}) {\n class InfiniteParams implements ServerOwnedParams {\n filter?: Filter;\n sort?: Sort;\n limit?: number;\n offset?: number;\n columns?: Record<string, boolean>;\n with?: Record<string, unknown>;\n withDeleted?: boolean;\n }\n\n const limits = resolveLimits(options.limits);\n applyFilterAndSort(InfiniteParams.prototype, options, limits, true);\n applyNumber(InfiniteParams.prototype, \"limit\", { positive: true, max: options.maxLimit ?? DEFAULT_MAX_LIMIT });\n applyNumber(InfiniteParams.prototype, \"offset\", { min: 0 });\n IsWithinMaxOffset({ mode: \"offset\", maxOffset: limits.maxOffset })(InfiniteParams.prototype, \"offset\");\n\n return nameClass(InfiniteParams, \"InfiniteParamsDto\");\n}\n\n/** Cursor (keyset) params DTO'si — `sort` yo'q. Qarang: {@link makeOffsetParamsDto}. */\nexport function makeCursorParamsDto(options: ParamsDtoOptions = {}) {\n class CursorParams implements ServerOwnedParams {\n filter?: Filter;\n limit?: number;\n cursor?: string | null;\n cursorKey?: string;\n order?: SortDirection;\n direction?: \"forward\" | \"backward\";\n columns?: Record<string, boolean>;\n with?: Record<string, unknown>;\n withDeleted?: boolean;\n }\n\n const proto = CursorParams.prototype;\n applyFilterAndSort(proto, options, resolveLimits(options.limits), false);\n applyNumber(proto, \"limit\", { positive: true, max: options.maxLimit ?? DEFAULT_MAX_LIMIT });\n\n IsOptional()(proto, \"cursor\");\n IsString()(proto, \"cursor\");\n IsOptional()(proto, \"cursorKey\");\n IsString()(proto, \"cursorKey\");\n IsOptional()(proto, \"order\");\n IsIn([\"asc\", \"desc\"])(proto, \"order\");\n IsOptional()(proto, \"direction\");\n IsIn([\"forward\", \"backward\"])(proto, \"direction\");\n\n return nameClass(CursorParams, \"CursorParamsDto\");\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/locales.ts","../src/dto.ts"],"names":["QUERYKIT_MESSAGES_EN","IsOptional","Type","IsInt","IsPositive","Min","Max","IsBoolean","IsObject","IsQueryFilter","IsQuerySort","resolveLimits","IsWithinMaxOffset","DEFAULT_MAX_PER_PAGE","DEFAULT_MAX_LIMIT","IsString","IsIn"],"mappings":";;;;;;;;;;AAwBO,IAAM,oBAAA,GAA+C;AAAA,EAC1D,8BAAA,EAAgC,4DAAA;AAAA,EAChC,6BAAA,EAA+B,wCAAA;AAAA,EAC/B,6BAAA,EAA+B,mDAAA;AAAA,EAC/B,kCAAA,EAAoC,qEAAA;AAAA,EACpC,+BAAA,EAAiC,4EAAA;AAAA,EACjC,+BAAA,EAAiC,gDAAA;AAAA,EACjC,2BAAA,EAA6B,yCAAA;AAAA,EAC7B,sCAAA,EAAwC,kDAAA;AAAA,EACxC,sCAAA,EAAwC,wDAAA;AAAA,EACxC,iCAAA,EAAmC,6CAAA;AAAA,EACnC,yBAAA,EAA2B,yEAAA;AAAA,EAC3B,4BAAA,EAA8B,2DAAA;AAAA,EAC9B,2BAAA,EAA6B,wCAAA;AAAA,EAC7B,2BAAA,EAA6B,iDAAA;AAAA,EAC7B,iCAAA,EAAmC,oDAAA;AAAA,EACnC,yBAAA,EAA2B;AAC7B,CAAA,CAAA,CAGa,oBAAA,GAA+C;AAAA,EAC1D,8BAAA,EAAgC,2OAAA;AAAA,EAChC,6BAAA,EAA+B,iOAAA;AAAA,EAC/B,6BAAA,EAA+B,qKAAA;AAAA,EAC/B,kCAAA,EAAoC,2NAAA;AAAA,EACpC,+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AK,CAAA,EACvE,WAAA,CAAY,KAAA,EAAO,OAAA,EAAS,EAAE,QAAA,EAAU,MAAM,GAAA,EAAK,OAAA,CAAQ,QAAA,IAAYG,sBAAA,EAAmB,CAAA,EAE1Fb,yBAAA,EAAW,CAAE,OAAO,QAAQ,CAAA,EAC5Bc,uBAAA,EAAS,CAAE,OAAO,QAAQ,CAAA,EAC1Bd,yBAAA,EAAW,CAAE,OAAO,WAAW,CAAA,EAC/Bc,uBAAA,EAAS,CAAE,KAAA,EAAO,WAAW,CAAA,EAC7Bd,yBAAA,GAAa,KAAA,EAAO,OAAO,CAAA,EAC3Be,mBAAA,CAAK,CAAC,KAAA,EAAO,MAAM,CAAC,EAAE,KAAA,EAAO,OAAO,CAAA,EACpCf,yBAAA,EAAW,CAAE,KAAA,EAAO,WAAW,CAAA,EAC/Be,oBAAK,CAAC,SAAA,EAAW,UAAU,CAAC,EAAE,KAAA,EAAO,WAAW,CAAA,EAEzC,SAAA,CAAU,cAAc,iBAAiB,CAAA;AAClD","file":"index.cjs","sourcesContent":["/**\n * Xabar kataloglari — **yagona manba**. Har bir til bir xil kalitlar to'plamini\n * to'ldiradi; kalitlarning o'zi shu yerdagi inglizcha katalogdan chiqadi.\n *\n * Paket xatoni kalit bilan qaytargani uchun tillar soni cheklanmagan: tarjima\n * har doim iste'molchi tomonida (`nestjs-i18n` `I18nValidationPipe` yoki oddiy\n * `formatMessage(key, args, catalog)`). Bu yerdagi uchta katalog shunchaki eng\n * ko'p kerak bo'ladiganini qutidan beradi — hech biri majburiy emas.\n *\n * `QueryKitMessageCatalog` ataylab qat'iy (`Record<QueryKitMessageKey, string>`):\n * inglizchaga yangi kalit qo'shilsa, qolgan kataloglar **compile-time**da yorilib\n * beradi va eskirib qololmaydi.\n */\n\nimport { QUERYKIT_MESSAGES_EN, type QueryKitMessageCatalog } from \"@querykitjs/core/internal\";\n\n/**\n * Inglizcha katalog (kalitlarning kanonik ro'yxati), `QueryKitMessageKey` va\n * `QueryKitMessageCatalog` — core'dan (boshqa validatorlar bilan bitta matn).\n */\nexport { QUERYKIT_MESSAGES_EN };\nexport type { QueryKitMessageCatalog, QueryKitMessageKey } from \"@querykitjs/core/internal\";\n\n/** O'zbekcha katalog. Placeholder nomlari inglizchasi bilan bir xil. */\nexport const QUERYKIT_MESSAGES_UZ: QueryKitMessageCatalog = {\n \"querykit.filter.invalid_node\": \"{path} filter sharti yoki and/or/not guruhi bo'lishi kerak\",\n \"querykit.filter.missing_key\": \"{path} da majburiy `key` (string) yo'q\",\n \"querykit.filter.unknown_key\": \"{path}: `{key}` ruxsat etilgan filter kaliti emas\",\n \"querykit.filter.invalid_operator\": \"{path}: `{operation}` qo'llab-quvvatlanadigan filter operatori emas\",\n \"querykit.filter.invalid_value\": \"{path} string, raqam, boolean, null yoki shularning massivi bo'lishi kerak\",\n \"querykit.filter.invalid_group\": \"{path} filter tugunlari massivi bo'lishi kerak\",\n \"querykit.filter.max_depth\": \"{path} limitdan oshdi: maxDepth ({max})\",\n \"querykit.filter.value_requires_array\": \"{path}: `{operation}` massiv qiymat talab qiladi\",\n \"querykit.filter.value_requires_tuple\": \"{path}: `{operation}` aynan ikkita qiymat talab qiladi\",\n \"querykit.filter.value_forbidden\": \"{path}: `{operation}` qiymat qabul qilmaydi\",\n \"querykit.sort.not_array\": \"{path} `{ key, direction }` elementlaridan iborat massiv bo'lishi kerak\",\n \"querykit.sort.invalid_item\": \"{path} `key` (string) maydoniga ega obyekt bo'lishi kerak\",\n \"querykit.sort.missing_key\": \"{path} da majburiy `key` (string) yo'q\",\n \"querykit.sort.unknown_key\": \"{path}: `{key}` ruxsat etilgan sort kaliti emas\",\n \"querykit.sort.invalid_direction\": \"{path}: direction `asc` yoki `desc` bo'lishi kerak\",\n \"querykit.limit.exceeded\": \"{path} limitdan oshdi: {limit} ({max})\",\n};\n\n/** Ruscha katalog. */\nexport const QUERYKIT_MESSAGES_RU: QueryKitMessageCatalog = {\n \"querykit.filter.invalid_node\": \"{path} должен быть условием фильтра или группой and/or/not\",\n \"querykit.filter.missing_key\": \"в {path} отсутствует обязательное поле `key` (строка)\",\n \"querykit.filter.unknown_key\": \"{path}: `{key}` — недопустимый ключ фильтра\",\n \"querykit.filter.invalid_operator\": \"{path}: `{operation}` — неподдерживаемый оператор фильтра\",\n \"querykit.filter.invalid_value\": \"{path} должен быть строкой, числом, boolean, null или массивом из них\",\n \"querykit.filter.invalid_group\": \"{path} должен быть массивом узлов фильтра\",\n \"querykit.filter.max_depth\": \"{path} превышает лимит maxDepth ({max})\",\n \"querykit.filter.value_requires_array\": \"{path}: `{operation}` требует значение-массив\",\n \"querykit.filter.value_requires_tuple\": \"{path}: `{operation}` требует ровно два значения\",\n \"querykit.filter.value_forbidden\": \"{path}: `{operation}` не должен содержать значение\",\n \"querykit.sort.not_array\": \"{path} должен быть массивом элементов `{ key, direction }`\",\n \"querykit.sort.invalid_item\": \"{path} должен быть объектом с полем `key` (строка)\",\n \"querykit.sort.missing_key\": \"в {path} отсутствует обязательное поле `key` (строка)\",\n \"querykit.sort.unknown_key\": \"{path}: `{key}` — недопустимый ключ сортировки\",\n \"querykit.sort.invalid_direction\": \"{path}: direction должен быть `asc` или `desc`\",\n \"querykit.limit.exceeded\": \"{path} превышает лимит {limit} ({max})\",\n};\n\n/**\n * Til kodi → katalog. Qutidagi tillar; iste'molchi o'z katalogini shu shaklda\n * qo'shib, `formatMessage`ga uzata oladi.\n */\nexport const QUERYKIT_LOCALES = {\n en: QUERYKIT_MESSAGES_EN,\n uz: QUERYKIT_MESSAGES_UZ,\n ru: QUERYKIT_MESSAGES_RU,\n} as const satisfies Record<string, QueryKitMessageCatalog>;\n\n/** Qutidan chiqadigan til kodlari. */\nexport type QueryKitLocale = keyof typeof QUERYKIT_LOCALES;\n","/**\n * Param DTO'lari — uchala paginatsiya uchun (offset / infinite / cursor).\n *\n * Ikki yo'l bilan ishlatiladi (ikkalasi ham bitta `validateFilter` yadrosiga\n * tayanadi):\n *\n * 1. **Subclass** — `class ListUsersDto extends OffsetParamsDto` va kerak bo'lsa\n * `filter`ni `@IsQueryFilter({ allowedKeys })` bilan qayta e'lon qilish;\n * 2. **Factory** — `makeOffsetParamsDto({ allowedKeys })`, boilerplatesiz.\n *\n * **Xavfsiz default:** `columns` / `with` / `withDeleted` hech qaysi DTO'da\n * e'lon qilinmagan, ya'ni `ValidationPipe({ whitelist: true })` ularni o'chiradi;\n * `perPage` / `limit` esa core'ning `DEFAULT_MAX_PER_PAGE` / `DEFAULT_MAX_LIMIT`\n * chegarasi bilan cheklangan. Ochish faqat factory'ning `allow` opsiyasi orqali.\n * Har DTO core so'rov limitlarini ham qo'llaydi (filtr hajmi, sort soni, offset\n * chuqurligi); factory'da `limits` bilan o'zgartiriladi.\n */\nimport { Type } from \"class-transformer\";\nimport { IsBoolean, IsIn, IsInt, IsObject, IsOptional, IsPositive, IsString, Max, Min } from \"class-validator\";\nimport { DEFAULT_MAX_LIMIT, DEFAULT_MAX_PER_PAGE, resolveLimits } from \"@querykitjs/core\";\nimport type { Filter, QueryLimits, Sort, SortDirection } from \"@querykitjs/core\";\nimport { IsQueryFilter, IsQuerySort, IsWithinMaxOffset, type IsQueryFilterOptions, type IsQuerySortOptions } from \"./decorators\";\n\n/* -------------------------------- factories ------------------------------- */\n\n/** Server'ga tegishli, default'da clientdan qabul qilinmaydigan maydonlar. */\nexport type ServerOwnedField = \"columns\" | \"with\" | \"withDeleted\";\n\n/** `allow` bilan ochiladigan maydonlarning shakli. */\nexport interface ServerOwnedParams {\n columns?: Record<string, boolean>;\n with?: Record<string, unknown>;\n withDeleted?: boolean;\n}\n\nexport interface ParamsDtoOptions {\n /** `filter` uchun to'liq opsiyalar — `allowedKeys`, `allowedOperators`, `maxDepth`, `strictValue`, `messageStyle`. */\n filter?: IsQueryFilterOptions;\n /** `sort` uchun opsiyalar — `allowedKeys`, `messageStyle`. */\n sort?: IsQuerySortOptions;\n /**\n * `filter` va `sort` uchun umumiy allowlist qisqartmasi — odatda ikkalasi bir xil.\n * Aniq berilgan `filter.allowedKeys` / `sort.allowedKeys` bundan **ustun**.\n */\n allowedKeys?: readonly string[];\n /** `perPage` yuqori chegarasi. Default — core `DEFAULT_MAX_PER_PAGE` (200). `Infinity` — cap yo'q (⚠️ DoS). */\n maxPerPage?: number;\n /** `limit` yuqori chegarasi. Default — core `DEFAULT_MAX_LIMIT` (200). */\n maxLimit?: number;\n /**\n * So'rov limitlari; berilmaganlari core default'ida (`DEFAULT_QUERY_LIMITS`). Aniq\n * berilgan `filter.maxDepth`, `sort.maxSortFields`, … bundan **ustun**.\n * `Infinity` limitni o'chiradi (⚠️ DoS yuzasi).\n */\n limits?: Partial<QueryLimits>;\n /** Server-owned maydonlarni **ataylab** ochish. Default — bo'sh. */\n allow?: readonly ServerOwnedField[];\n}\n\n/* Dinamik klasslar static klasslardan meros OLMAYDI: meros bo'lsa ota-klassning\n * default `@IsQueryFilter()` dekoratori ham qo'shilib, filter ikki marta —\n * bir marta opsiyalar bilan, bir marta ularsiz — tekshirilardi. Shuningdek\n * static klasslar prototipiga hech qachon imperativ dekorator qo'yilmaydi:\n * u global ifloslanish bo'lardi. */\n\nconst applyNumber = (proto: object, property: string, bounds: { positive?: boolean; min?: number; max?: number }): void => {\n IsOptional()(proto, property);\n Type(() => Number)(proto, property);\n IsInt()(proto, property);\n if (bounds.positive) IsPositive()(proto, property);\n if (bounds.min !== undefined) Min(bounds.min)(proto, property);\n /* `Infinity` cap'ni butunlay o'chiradi — cheksiz `@Max` konstrainti qo'yishdan\n * ko'ra uni umuman qo'ymagan ma'qul (xato xabari ham chalg'itmaydi). */\n if (bounds.max !== undefined && Number.isFinite(bounds.max)) Max(bounds.max)(proto, property);\n};\n\nconst applyServerOwned = (proto: object, field: ServerOwnedField): void => {\n IsOptional()(proto, field);\n if (field === \"withDeleted\") IsBoolean()(proto, field);\n else IsObject()(proto, field);\n};\n\nconst applyFilterAndSort = (proto: object, options: ParamsDtoOptions, limits: QueryLimits, withSort: boolean): void => {\n /* `limits` first: a dedicated `filter.*` / `sort.*` option wins. Unrelated limit keys are ignored by the validators. */\n IsOptional()(proto, \"filter\");\n IsQueryFilter({ ...limits, ...options.filter, allowedKeys: options.filter?.allowedKeys ?? options.allowedKeys })(proto, \"filter\");\n\n if (withSort) {\n IsOptional()(proto, \"sort\");\n IsQuerySort({ ...limits, ...options.sort, allowedKeys: options.sort?.allowedKeys ?? options.allowedKeys })(proto, \"sort\");\n }\n\n for (const field of options.allow ?? []) applyServerOwned(proto, field);\n};\n\n/** Nest xato loglarida `class_1` emas, tushunarli nom chiqsin. */\nconst nameClass = <T extends abstract new (...args: never[]) => unknown>(cls: T, name: string): T => {\n Object.defineProperty(cls, \"name\", { value: name, configurable: true });\n return cls;\n};\n\n/**\n * Offset (sahifali) params DTO'si — `allowedKeys` va cap'lar bilan.\n *\n * @example\n * ```ts\n * const ListBuyersDto = makeOffsetParamsDto({ allowedKeys: [\"buyerName\", \"createdAt\"] });\n * type ListBuyersDto = InstanceType<typeof ListBuyersDto>;\n *\n * @Post(\"list\")\n * list(@Body() params: ListBuyersDto) {\n * return this.buyersRepository.findList(params);\n * }\n * ```\n */\nexport function makeOffsetParamsDto(options: ParamsDtoOptions = {}) {\n class OffsetParams implements ServerOwnedParams {\n filter?: Filter;\n sort?: Sort;\n page?: number;\n perPage?: number;\n withTotal?: boolean;\n columns?: Record<string, boolean>;\n with?: Record<string, unknown>;\n withDeleted?: boolean;\n }\n\n const limits = resolveLimits(options.limits);\n applyFilterAndSort(OffsetParams.prototype, options, limits, true);\n applyNumber(OffsetParams.prototype, \"page\", { positive: true });\n IsWithinMaxOffset({ mode: \"page\", maxOffset: limits.maxOffset })(OffsetParams.prototype, \"page\");\n applyNumber(OffsetParams.prototype, \"perPage\", { positive: true, max: options.maxPerPage ?? DEFAULT_MAX_PER_PAGE });\n IsOptional()(OffsetParams.prototype, \"withTotal\");\n IsBoolean()(OffsetParams.prototype, \"withTotal\");\n\n return nameClass(OffsetParams, \"OffsetParamsDto\");\n}\n\n/** Infinite-scroll params DTO'si. Qarang: {@link makeOffsetParamsDto}. */\nexport function makeInfiniteParamsDto(options: ParamsDtoOptions = {}) {\n class InfiniteParams implements ServerOwnedParams {\n filter?: Filter;\n sort?: Sort;\n limit?: number;\n offset?: number;\n columns?: Record<string, boolean>;\n with?: Record<string, unknown>;\n withDeleted?: boolean;\n }\n\n const limits = resolveLimits(options.limits);\n applyFilterAndSort(InfiniteParams.prototype, options, limits, true);\n applyNumber(InfiniteParams.prototype, \"limit\", { positive: true, max: options.maxLimit ?? DEFAULT_MAX_LIMIT });\n applyNumber(InfiniteParams.prototype, \"offset\", { min: 0 });\n IsWithinMaxOffset({ mode: \"offset\", maxOffset: limits.maxOffset })(InfiniteParams.prototype, \"offset\");\n\n return nameClass(InfiniteParams, \"InfiniteParamsDto\");\n}\n\n/** Cursor (keyset) params DTO'si — `sort` yo'q. Qarang: {@link makeOffsetParamsDto}. */\nexport function makeCursorParamsDto(options: ParamsDtoOptions = {}) {\n class CursorParams implements ServerOwnedParams {\n filter?: Filter;\n limit?: number;\n cursor?: string | null;\n cursorKey?: string;\n order?: SortDirection;\n direction?: \"forward\" | \"backward\";\n columns?: Record<string, boolean>;\n with?: Record<string, unknown>;\n withDeleted?: boolean;\n }\n\n const proto = CursorParams.prototype;\n applyFilterAndSort(proto, options, resolveLimits(options.limits), false);\n applyNumber(proto, \"limit\", { positive: true, max: options.maxLimit ?? DEFAULT_MAX_LIMIT });\n\n IsOptional()(proto, \"cursor\");\n IsString()(proto, \"cursor\");\n IsOptional()(proto, \"cursorKey\");\n IsString()(proto, \"cursorKey\");\n IsOptional()(proto, \"order\");\n IsIn([\"asc\", \"desc\"])(proto, \"order\");\n IsOptional()(proto, \"direction\");\n IsIn([\"forward\", \"backward\"])(proto, \"direction\");\n\n return nameClass(CursorParams, \"CursorParamsDto\");\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
|
+
import { QueryKitMessageKey, MessageArgs, QueryKitMessageCatalog } from '@querykitjs/core/internal';
|
|
2
|
+
export { MessageArgs, QUERYKIT_MESSAGES_EN, QueryKitMessageCatalog, QueryKitMessageKey, formatMessage } from '@querykitjs/core/internal';
|
|
1
3
|
import { FilterOperator, Filter, Sort, SortDirection, QueryLimits } from '@querykitjs/core';
|
|
2
4
|
export { DEFAULT_MAX_FILTER_DEPTH } from '@querykitjs/core';
|
|
3
5
|
import { ValidationOptions, ValidatorConstraintInterface, ValidationArguments } from 'class-validator';
|
|
4
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Xabar formatlash. Kataloglar `locales.ts`da; `formatMessage` core'da
|
|
9
|
+
* (boshqa validatorlar bilan bitta), bu yerda faqat `localizeIssue`.
|
|
10
|
+
*
|
|
11
|
+
* Har bir {@link ValidationIssue} uchta narsani olib yuradi: `key` (tarjima
|
|
12
|
+
* kaliti), `message` (tayyor matn) va `args` (interpolatsiya qiymatlari). Shu
|
|
13
|
+
* sababli paket i18n'ga **majburlamaydi**, lekin unga to'liq mos.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Issue'ni tanlangan tilda qayta formatlaydi — `message` inglizcha yozilgan
|
|
18
|
+
* bo'lsa ham, javobni boshqa tilda berish uchun.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* issues.map(issue => localizeIssue(issue, QUERYKIT_MESSAGES_RU));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function localizeIssue(issue: {
|
|
26
|
+
key: QueryKitMessageKey;
|
|
27
|
+
args: MessageArgs;
|
|
28
|
+
}, catalog: QueryKitMessageCatalog): string;
|
|
29
|
+
|
|
5
30
|
/**
|
|
6
31
|
* Xabar kataloglari — **yagona manba**. Har bir til bir xil kalitlar to'plamini
|
|
7
32
|
* to'ldiradi; kalitlarning o'zi shu yerdagi inglizcha katalogdan chiqadi.
|
|
@@ -15,35 +40,7 @@ import { ValidationOptions, ValidatorConstraintInterface, ValidationArguments }
|
|
|
15
40
|
* inglizchaga yangi kalit qo'shilsa, qolgan kataloglar **compile-time**da yorilib
|
|
16
41
|
* beradi va eskirib qololmaydi.
|
|
17
42
|
*/
|
|
18
|
-
|
|
19
|
-
* Inglizcha katalog — kalitlarning kanonik ro'yxati va default fallback.
|
|
20
|
-
* `{placeholder}` lar `formatMessage` bilan to'ldiriladi.
|
|
21
|
-
*/
|
|
22
|
-
declare const QUERYKIT_MESSAGES_EN: {
|
|
23
|
-
readonly "querykit.filter.invalid_node": "{path} must be a filter condition or an and/or/not group";
|
|
24
|
-
readonly "querykit.filter.missing_key": "{path} is missing the required `key` string";
|
|
25
|
-
readonly "querykit.filter.unknown_key": "{path}: `{key}` is not an allowed filter key";
|
|
26
|
-
readonly "querykit.filter.invalid_operator": "{path}: `{operation}` is not a supported filter operator";
|
|
27
|
-
readonly "querykit.filter.invalid_value": "{path} must be a string, number, boolean, null, or an array of those";
|
|
28
|
-
readonly "querykit.filter.invalid_group": "{path} must be an array of filter nodes";
|
|
29
|
-
readonly "querykit.filter.max_depth": "{path} exceeds maxDepth ({max})";
|
|
30
|
-
readonly "querykit.filter.value_requires_array": "{path}: `{operation}` requires an array value";
|
|
31
|
-
readonly "querykit.filter.value_requires_tuple": "{path}: `{operation}` requires exactly two values";
|
|
32
|
-
readonly "querykit.filter.value_forbidden": "{path}: `{operation}` must not carry a value";
|
|
33
|
-
readonly "querykit.sort.not_array": "{path} must be an array of { key, direction } items";
|
|
34
|
-
readonly "querykit.sort.invalid_item": "{path} must be an object with a `key` string";
|
|
35
|
-
readonly "querykit.sort.missing_key": "{path} is missing the required `key` string";
|
|
36
|
-
readonly "querykit.sort.unknown_key": "{path}: `{key}` is not an allowed sort key";
|
|
37
|
-
readonly "querykit.sort.invalid_direction": "{path}: direction must be `asc` or `desc`";
|
|
38
|
-
readonly "querykit.limit.exceeded": "{path} exceeds {limit} ({max})";
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Har bir validatsiya xatosining i18n kaliti. Union inglizcha katalogdan chiqadi —
|
|
42
|
-
* yangi xabar qo'shilsa tip o'zi kengayadi, qo'lda ro'yxat yuritilmaydi.
|
|
43
|
-
*/
|
|
44
|
-
type QueryKitMessageKey = keyof typeof QUERYKIT_MESSAGES_EN;
|
|
45
|
-
/** Bitta tilning to'liq katalogi — barcha kalitlar majburiy. */
|
|
46
|
-
type QueryKitMessageCatalog = Record<QueryKitMessageKey, string>;
|
|
43
|
+
|
|
47
44
|
/** O'zbekcha katalog. Placeholder nomlari inglizchasi bilan bir xil. */
|
|
48
45
|
declare const QUERYKIT_MESSAGES_UZ: QueryKitMessageCatalog;
|
|
49
46
|
/** Ruscha katalog. */
|
|
@@ -78,52 +75,11 @@ declare const QUERYKIT_LOCALES: {
|
|
|
78
75
|
type QueryKitLocale = keyof typeof QUERYKIT_LOCALES;
|
|
79
76
|
|
|
80
77
|
/**
|
|
81
|
-
*
|
|
82
|
-
* `
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* sababli paket i18n'ga **majburlamaydi**, lekin unga to'liq mos.
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
/** Shablon interpolatsiyasi argumentlari — `I18nValidationPipe`ga ham shu shaklda uzatiladi. */
|
|
90
|
-
type MessageArgs = Record<string, string | number>;
|
|
91
|
-
/**
|
|
92
|
-
* Kalitni matnga aylantiradi: katalogdan shablon olinadi va `{placeholder}` lar
|
|
93
|
-
* `args` bilan almashtiriladi. Mos argument topilmasa placeholder o'z holicha
|
|
94
|
-
* qoladi — xabar hech qachon bo'sh chiqmaydi.
|
|
95
|
-
*
|
|
96
|
-
* @param catalog Til katalogi. Default — inglizcha; `QUERYKIT_MESSAGES_UZ`,
|
|
97
|
-
* `QUERYKIT_MESSAGES_RU` yoki o'zingizniki uzatilishi mumkin.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```ts
|
|
101
|
-
* formatMessage(issue.key, issue.args, QUERYKIT_MESSAGES_UZ);
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
declare function formatMessage(key: QueryKitMessageKey, args?: MessageArgs, catalog?: QueryKitMessageCatalog): string;
|
|
105
|
-
/**
|
|
106
|
-
* Issue'ni tanlangan tilda qayta formatlaydi — `message` inglizcha yozilgan
|
|
107
|
-
* bo'lsa ham, javobni boshqa tilda berish uchun.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* issues.map(issue => localizeIssue(issue, QUERYKIT_MESSAGES_RU));
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
declare function localizeIssue(issue: {
|
|
115
|
-
key: QueryKitMessageKey;
|
|
116
|
-
args: MessageArgs;
|
|
117
|
-
}, catalog: QueryKitMessageCatalog): string;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Sof TS validatsiya yadrosi — **framework-agnostik**. Butun rekursiya va qaror
|
|
121
|
-
* mantiqi shu yerda; `class-validator` dekoratorlari (`decorators.ts`) faqat
|
|
122
|
-
* yupqa o'rov. Shu sababli yadroni Nest'siz ham (Express, Hono, oddiy funksiya)
|
|
123
|
-
* ishlatish mumkin va uni test qilish uchun dekorator mashinasi kerak emas.
|
|
124
|
-
*
|
|
125
|
-
* Kontrakt manbasi — `@querykitjs/core`: operatorlar `FILTER_OPERATORS`dan,
|
|
126
|
-
* daraxt shakli esa `Filter`/`FilterNode`/`FieldCondition` tiplaridan.
|
|
78
|
+
* Sof TS validatsiya yadrosi — **framework-agnostik**. Tekshiruv mantiqi core
|
|
79
|
+
* `checkFilter`/`checkSort` da (`@querykitjs/core/internal`) — boshqa validatorlar
|
|
80
|
+
* bilan bitta; bu yerda faqat yo'l satri va xabar matni quriladi.
|
|
81
|
+
* `class-validator` dekoratorlari (`decorators.ts`) faqat yupqa o'rov, shuning
|
|
82
|
+
* uchun yadroni Nest'siz ham (Express, Hono, oddiy funksiya) ishlatish mumkin.
|
|
127
83
|
*/
|
|
128
84
|
|
|
129
85
|
interface QueryFilterOptions {
|
|
@@ -267,7 +223,7 @@ declare function IsQuerySort(options?: IsQuerySortOptions, validationOptions?: V
|
|
|
267
223
|
/**
|
|
268
224
|
* Paginatsiyasiz umumiy params — `filter` + `sort`.
|
|
269
225
|
*
|
|
270
|
-
* @deprecated Use `makeOffsetParamsDto` / `makeInfiniteParamsDto` / `makeCursorParamsDto` (safe defaults
|
|
226
|
+
* @deprecated Use `makeOffsetParamsDto` / `makeInfiniteParamsDto` / `makeCursorParamsDto` (safe defaults). Removed in the next major.
|
|
271
227
|
*/
|
|
272
228
|
declare class BaseParamsDto {
|
|
273
229
|
filter?: Filter;
|
|
@@ -276,18 +232,18 @@ declare class BaseParamsDto {
|
|
|
276
232
|
/**
|
|
277
233
|
* Offset (sahifali) params — `page` + `perPage` (`perPage` ≤ core cap).
|
|
278
234
|
*
|
|
279
|
-
* @deprecated Use `makeOffsetParamsDto` (safe defaults
|
|
235
|
+
* @deprecated Use `makeOffsetParamsDto` (safe defaults). Removed in the next major.
|
|
280
236
|
*/
|
|
281
237
|
declare class OffsetParamsDto extends BaseParamsDto {
|
|
282
238
|
page?: number;
|
|
283
239
|
perPage?: number;
|
|
284
|
-
/** `false` — no count; the meta totals are `null
|
|
240
|
+
/** `false` — no count; the meta totals are `null`. */
|
|
285
241
|
withTotal?: boolean;
|
|
286
242
|
}
|
|
287
243
|
/**
|
|
288
244
|
* Infinite-scroll params — `limit` + `offset`.
|
|
289
245
|
*
|
|
290
|
-
* @deprecated Use `makeInfiniteParamsDto` (safe defaults
|
|
246
|
+
* @deprecated Use `makeInfiniteParamsDto` (safe defaults). Removed in the next major.
|
|
291
247
|
*/
|
|
292
248
|
declare class InfiniteParamsDto extends BaseParamsDto {
|
|
293
249
|
limit?: number;
|
|
@@ -298,7 +254,7 @@ declare class InfiniteParamsDto extends BaseParamsDto {
|
|
|
298
254
|
* boshqariladi. Shu sababli `BaseParamsDto`dan meros olinmaydi — aks holda
|
|
299
255
|
* `sort` kontraktga qarshi ravishda meros bo'lib qolardi.
|
|
300
256
|
*
|
|
301
|
-
* @deprecated Use `makeCursorParamsDto` (safe defaults
|
|
257
|
+
* @deprecated Use `makeCursorParamsDto` (safe defaults). Removed in the next major.
|
|
302
258
|
*/
|
|
303
259
|
declare class CursorParamsDto {
|
|
304
260
|
filter?: Filter;
|
|
@@ -393,5 +349,5 @@ declare function makeCursorParamsDto(options?: ParamsDtoOptions): {
|
|
|
393
349
|
};
|
|
394
350
|
};
|
|
395
351
|
|
|
396
|
-
export { BaseParamsDto, CursorParamsDto, InfiniteParamsDto, IsQueryFilter, IsQueryFilterConstraint, IsQuerySort, IsQuerySortConstraint, IsWithinMaxOffset, IsWithinMaxOffsetConstraint, OffsetParamsDto, QUERYKIT_LOCALES,
|
|
397
|
-
export type { IsQueryFilterOptions, IsQuerySortOptions, IsWithinMaxOffsetOptions,
|
|
352
|
+
export { BaseParamsDto, CursorParamsDto, InfiniteParamsDto, IsQueryFilter, IsQueryFilterConstraint, IsQuerySort, IsQuerySortConstraint, IsWithinMaxOffset, IsWithinMaxOffsetConstraint, OffsetParamsDto, QUERYKIT_LOCALES, QUERYKIT_MESSAGES_RU, QUERYKIT_MESSAGES_UZ, localizeIssue, makeCursorParamsDto, makeInfiniteParamsDto, makeOffsetParamsDto, validateFilter, validateSort };
|
|
353
|
+
export type { IsQueryFilterOptions, IsQuerySortOptions, IsWithinMaxOffsetOptions, MessageStyleOptions, ParamsDtoOptions, QueryFilterOptions, QueryKitLocale, QuerySortOptions, ServerOwnedField, ServerOwnedParams, ValidationIssue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
|
+
import { QueryKitMessageKey, MessageArgs, QueryKitMessageCatalog } from '@querykitjs/core/internal';
|
|
2
|
+
export { MessageArgs, QUERYKIT_MESSAGES_EN, QueryKitMessageCatalog, QueryKitMessageKey, formatMessage } from '@querykitjs/core/internal';
|
|
1
3
|
import { FilterOperator, Filter, Sort, SortDirection, QueryLimits } from '@querykitjs/core';
|
|
2
4
|
export { DEFAULT_MAX_FILTER_DEPTH } from '@querykitjs/core';
|
|
3
5
|
import { ValidationOptions, ValidatorConstraintInterface, ValidationArguments } from 'class-validator';
|
|
4
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Xabar formatlash. Kataloglar `locales.ts`da; `formatMessage` core'da
|
|
9
|
+
* (boshqa validatorlar bilan bitta), bu yerda faqat `localizeIssue`.
|
|
10
|
+
*
|
|
11
|
+
* Har bir {@link ValidationIssue} uchta narsani olib yuradi: `key` (tarjima
|
|
12
|
+
* kaliti), `message` (tayyor matn) va `args` (interpolatsiya qiymatlari). Shu
|
|
13
|
+
* sababli paket i18n'ga **majburlamaydi**, lekin unga to'liq mos.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Issue'ni tanlangan tilda qayta formatlaydi — `message` inglizcha yozilgan
|
|
18
|
+
* bo'lsa ham, javobni boshqa tilda berish uchun.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* issues.map(issue => localizeIssue(issue, QUERYKIT_MESSAGES_RU));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function localizeIssue(issue: {
|
|
26
|
+
key: QueryKitMessageKey;
|
|
27
|
+
args: MessageArgs;
|
|
28
|
+
}, catalog: QueryKitMessageCatalog): string;
|
|
29
|
+
|
|
5
30
|
/**
|
|
6
31
|
* Xabar kataloglari — **yagona manba**. Har bir til bir xil kalitlar to'plamini
|
|
7
32
|
* to'ldiradi; kalitlarning o'zi shu yerdagi inglizcha katalogdan chiqadi.
|
|
@@ -15,35 +40,7 @@ import { ValidationOptions, ValidatorConstraintInterface, ValidationArguments }
|
|
|
15
40
|
* inglizchaga yangi kalit qo'shilsa, qolgan kataloglar **compile-time**da yorilib
|
|
16
41
|
* beradi va eskirib qololmaydi.
|
|
17
42
|
*/
|
|
18
|
-
|
|
19
|
-
* Inglizcha katalog — kalitlarning kanonik ro'yxati va default fallback.
|
|
20
|
-
* `{placeholder}` lar `formatMessage` bilan to'ldiriladi.
|
|
21
|
-
*/
|
|
22
|
-
declare const QUERYKIT_MESSAGES_EN: {
|
|
23
|
-
readonly "querykit.filter.invalid_node": "{path} must be a filter condition or an and/or/not group";
|
|
24
|
-
readonly "querykit.filter.missing_key": "{path} is missing the required `key` string";
|
|
25
|
-
readonly "querykit.filter.unknown_key": "{path}: `{key}` is not an allowed filter key";
|
|
26
|
-
readonly "querykit.filter.invalid_operator": "{path}: `{operation}` is not a supported filter operator";
|
|
27
|
-
readonly "querykit.filter.invalid_value": "{path} must be a string, number, boolean, null, or an array of those";
|
|
28
|
-
readonly "querykit.filter.invalid_group": "{path} must be an array of filter nodes";
|
|
29
|
-
readonly "querykit.filter.max_depth": "{path} exceeds maxDepth ({max})";
|
|
30
|
-
readonly "querykit.filter.value_requires_array": "{path}: `{operation}` requires an array value";
|
|
31
|
-
readonly "querykit.filter.value_requires_tuple": "{path}: `{operation}` requires exactly two values";
|
|
32
|
-
readonly "querykit.filter.value_forbidden": "{path}: `{operation}` must not carry a value";
|
|
33
|
-
readonly "querykit.sort.not_array": "{path} must be an array of { key, direction } items";
|
|
34
|
-
readonly "querykit.sort.invalid_item": "{path} must be an object with a `key` string";
|
|
35
|
-
readonly "querykit.sort.missing_key": "{path} is missing the required `key` string";
|
|
36
|
-
readonly "querykit.sort.unknown_key": "{path}: `{key}` is not an allowed sort key";
|
|
37
|
-
readonly "querykit.sort.invalid_direction": "{path}: direction must be `asc` or `desc`";
|
|
38
|
-
readonly "querykit.limit.exceeded": "{path} exceeds {limit} ({max})";
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Har bir validatsiya xatosining i18n kaliti. Union inglizcha katalogdan chiqadi —
|
|
42
|
-
* yangi xabar qo'shilsa tip o'zi kengayadi, qo'lda ro'yxat yuritilmaydi.
|
|
43
|
-
*/
|
|
44
|
-
type QueryKitMessageKey = keyof typeof QUERYKIT_MESSAGES_EN;
|
|
45
|
-
/** Bitta tilning to'liq katalogi — barcha kalitlar majburiy. */
|
|
46
|
-
type QueryKitMessageCatalog = Record<QueryKitMessageKey, string>;
|
|
43
|
+
|
|
47
44
|
/** O'zbekcha katalog. Placeholder nomlari inglizchasi bilan bir xil. */
|
|
48
45
|
declare const QUERYKIT_MESSAGES_UZ: QueryKitMessageCatalog;
|
|
49
46
|
/** Ruscha katalog. */
|
|
@@ -78,52 +75,11 @@ declare const QUERYKIT_LOCALES: {
|
|
|
78
75
|
type QueryKitLocale = keyof typeof QUERYKIT_LOCALES;
|
|
79
76
|
|
|
80
77
|
/**
|
|
81
|
-
*
|
|
82
|
-
* `
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* sababli paket i18n'ga **majburlamaydi**, lekin unga to'liq mos.
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
/** Shablon interpolatsiyasi argumentlari — `I18nValidationPipe`ga ham shu shaklda uzatiladi. */
|
|
90
|
-
type MessageArgs = Record<string, string | number>;
|
|
91
|
-
/**
|
|
92
|
-
* Kalitni matnga aylantiradi: katalogdan shablon olinadi va `{placeholder}` lar
|
|
93
|
-
* `args` bilan almashtiriladi. Mos argument topilmasa placeholder o'z holicha
|
|
94
|
-
* qoladi — xabar hech qachon bo'sh chiqmaydi.
|
|
95
|
-
*
|
|
96
|
-
* @param catalog Til katalogi. Default — inglizcha; `QUERYKIT_MESSAGES_UZ`,
|
|
97
|
-
* `QUERYKIT_MESSAGES_RU` yoki o'zingizniki uzatilishi mumkin.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```ts
|
|
101
|
-
* formatMessage(issue.key, issue.args, QUERYKIT_MESSAGES_UZ);
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
declare function formatMessage(key: QueryKitMessageKey, args?: MessageArgs, catalog?: QueryKitMessageCatalog): string;
|
|
105
|
-
/**
|
|
106
|
-
* Issue'ni tanlangan tilda qayta formatlaydi — `message` inglizcha yozilgan
|
|
107
|
-
* bo'lsa ham, javobni boshqa tilda berish uchun.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* issues.map(issue => localizeIssue(issue, QUERYKIT_MESSAGES_RU));
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
declare function localizeIssue(issue: {
|
|
115
|
-
key: QueryKitMessageKey;
|
|
116
|
-
args: MessageArgs;
|
|
117
|
-
}, catalog: QueryKitMessageCatalog): string;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Sof TS validatsiya yadrosi — **framework-agnostik**. Butun rekursiya va qaror
|
|
121
|
-
* mantiqi shu yerda; `class-validator` dekoratorlari (`decorators.ts`) faqat
|
|
122
|
-
* yupqa o'rov. Shu sababli yadroni Nest'siz ham (Express, Hono, oddiy funksiya)
|
|
123
|
-
* ishlatish mumkin va uni test qilish uchun dekorator mashinasi kerak emas.
|
|
124
|
-
*
|
|
125
|
-
* Kontrakt manbasi — `@querykitjs/core`: operatorlar `FILTER_OPERATORS`dan,
|
|
126
|
-
* daraxt shakli esa `Filter`/`FilterNode`/`FieldCondition` tiplaridan.
|
|
78
|
+
* Sof TS validatsiya yadrosi — **framework-agnostik**. Tekshiruv mantiqi core
|
|
79
|
+
* `checkFilter`/`checkSort` da (`@querykitjs/core/internal`) — boshqa validatorlar
|
|
80
|
+
* bilan bitta; bu yerda faqat yo'l satri va xabar matni quriladi.
|
|
81
|
+
* `class-validator` dekoratorlari (`decorators.ts`) faqat yupqa o'rov, shuning
|
|
82
|
+
* uchun yadroni Nest'siz ham (Express, Hono, oddiy funksiya) ishlatish mumkin.
|
|
127
83
|
*/
|
|
128
84
|
|
|
129
85
|
interface QueryFilterOptions {
|
|
@@ -267,7 +223,7 @@ declare function IsQuerySort(options?: IsQuerySortOptions, validationOptions?: V
|
|
|
267
223
|
/**
|
|
268
224
|
* Paginatsiyasiz umumiy params — `filter` + `sort`.
|
|
269
225
|
*
|
|
270
|
-
* @deprecated Use `makeOffsetParamsDto` / `makeInfiniteParamsDto` / `makeCursorParamsDto` (safe defaults
|
|
226
|
+
* @deprecated Use `makeOffsetParamsDto` / `makeInfiniteParamsDto` / `makeCursorParamsDto` (safe defaults). Removed in the next major.
|
|
271
227
|
*/
|
|
272
228
|
declare class BaseParamsDto {
|
|
273
229
|
filter?: Filter;
|
|
@@ -276,18 +232,18 @@ declare class BaseParamsDto {
|
|
|
276
232
|
/**
|
|
277
233
|
* Offset (sahifali) params — `page` + `perPage` (`perPage` ≤ core cap).
|
|
278
234
|
*
|
|
279
|
-
* @deprecated Use `makeOffsetParamsDto` (safe defaults
|
|
235
|
+
* @deprecated Use `makeOffsetParamsDto` (safe defaults). Removed in the next major.
|
|
280
236
|
*/
|
|
281
237
|
declare class OffsetParamsDto extends BaseParamsDto {
|
|
282
238
|
page?: number;
|
|
283
239
|
perPage?: number;
|
|
284
|
-
/** `false` — no count; the meta totals are `null
|
|
240
|
+
/** `false` — no count; the meta totals are `null`. */
|
|
285
241
|
withTotal?: boolean;
|
|
286
242
|
}
|
|
287
243
|
/**
|
|
288
244
|
* Infinite-scroll params — `limit` + `offset`.
|
|
289
245
|
*
|
|
290
|
-
* @deprecated Use `makeInfiniteParamsDto` (safe defaults
|
|
246
|
+
* @deprecated Use `makeInfiniteParamsDto` (safe defaults). Removed in the next major.
|
|
291
247
|
*/
|
|
292
248
|
declare class InfiniteParamsDto extends BaseParamsDto {
|
|
293
249
|
limit?: number;
|
|
@@ -298,7 +254,7 @@ declare class InfiniteParamsDto extends BaseParamsDto {
|
|
|
298
254
|
* boshqariladi. Shu sababli `BaseParamsDto`dan meros olinmaydi — aks holda
|
|
299
255
|
* `sort` kontraktga qarshi ravishda meros bo'lib qolardi.
|
|
300
256
|
*
|
|
301
|
-
* @deprecated Use `makeCursorParamsDto` (safe defaults
|
|
257
|
+
* @deprecated Use `makeCursorParamsDto` (safe defaults). Removed in the next major.
|
|
302
258
|
*/
|
|
303
259
|
declare class CursorParamsDto {
|
|
304
260
|
filter?: Filter;
|
|
@@ -393,5 +349,5 @@ declare function makeCursorParamsDto(options?: ParamsDtoOptions): {
|
|
|
393
349
|
};
|
|
394
350
|
};
|
|
395
351
|
|
|
396
|
-
export { BaseParamsDto, CursorParamsDto, InfiniteParamsDto, IsQueryFilter, IsQueryFilterConstraint, IsQuerySort, IsQuerySortConstraint, IsWithinMaxOffset, IsWithinMaxOffsetConstraint, OffsetParamsDto, QUERYKIT_LOCALES,
|
|
397
|
-
export type { IsQueryFilterOptions, IsQuerySortOptions, IsWithinMaxOffsetOptions,
|
|
352
|
+
export { BaseParamsDto, CursorParamsDto, InfiniteParamsDto, IsQueryFilter, IsQueryFilterConstraint, IsQuerySort, IsQuerySortConstraint, IsWithinMaxOffset, IsWithinMaxOffsetConstraint, OffsetParamsDto, QUERYKIT_LOCALES, QUERYKIT_MESSAGES_RU, QUERYKIT_MESSAGES_UZ, localizeIssue, makeCursorParamsDto, makeInfiniteParamsDto, makeOffsetParamsDto, validateFilter, validateSort };
|
|
353
|
+
export type { IsQueryFilterOptions, IsQuerySortOptions, IsWithinMaxOffsetOptions, MessageStyleOptions, ParamsDtoOptions, QueryFilterOptions, QueryKitLocale, QuerySortOptions, ServerOwnedField, ServerOwnedParams, ValidationIssue };
|