vsrepo 2.5.0 → 2.6.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/CHANGELOG.md +587 -531
- package/LICENSE +20 -20
- package/README.md +220 -1243
- package/README.pt-BR.md +220 -1246
- package/dist/VSRepoAdapter.js.map +1 -1
- package/dist/VSRepository.d.ts +43 -1
- package/dist/VSRepository.js +61 -9
- package/dist/VSRepository.js.map +1 -1
- package/dist/decorators/dynamic-method.decorator.d.ts +1 -1
- package/dist/decorators/dynamic-method.decorator.js +2 -4
- package/dist/decorators/dynamic-method.decorator.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/enums/vsrepo-error-type.enum.d.ts +3 -1
- package/dist/internal/enums/vsrepo-error-type.enum.js +2 -0
- package/dist/internal/enums/vsrepo-error-type.enum.js.map +1 -1
- package/dist/internal/resolvers/dynamic-methods.resolver.d.ts +5 -0
- package/dist/internal/resolvers/dynamic-methods.resolver.js +163 -98
- package/dist/internal/resolvers/dynamic-methods.resolver.js.map +1 -1
- package/dist/internal/utils/vs-logger.util.js.map +1 -1
- package/dist/internal/utils/vs-query-builder.util.d.ts +235 -0
- package/dist/internal/utils/vs-query-builder.util.js +413 -0
- package/dist/internal/utils/vs-query-builder.util.js.map +1 -0
- package/dist/internal/utils/with-db.util.js.map +1 -1
- package/dist/internal/validators/decorators.validator.js +2 -6
- package/dist/internal/validators/decorators.validator.js.map +1 -1
- package/dist/internal/validators/schemas/pagination.schema.d.ts +2 -2
- package/dist/internal/validators/schemas/pagination.schema.js +2 -2
- package/dist/internal/validators/schemas/pagination.schema.js.map +1 -1
- package/dist/internal/validators/schemas/relations.schema.d.ts +4 -0
- package/dist/internal/validators/schemas/relations.schema.js +39 -0
- package/dist/internal/validators/schemas/relations.schema.js.map +1 -0
- package/dist/internal/validators/schemas/see-mode.schema.d.ts +3 -0
- package/dist/internal/validators/schemas/see-mode.schema.js +38 -0
- package/dist/internal/validators/schemas/see-mode.schema.js.map +1 -0
- package/dist/internal/validators/schemas/select.schema.d.ts +4 -0
- package/dist/internal/validators/schemas/select.schema.js +39 -0
- package/dist/internal/validators/schemas/select.schema.js.map +1 -0
- package/dist/internal/validators/vsrepo.validator.js +6 -5
- package/dist/internal/validators/vsrepo.validator.js.map +1 -1
- package/dist/types/dynamic-methods/dynamic-method-info.type.d.ts +1 -0
- package/dist/types/utils/query-args.type.d.ts +1 -4
- package/dist/types/vsrepo/vsrepo-options.type.d.ts +9 -0
- package/package.json +87 -80
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.VSQueryBuilder = void 0;
|
|
40
|
+
const VSRepoError_1 = require("../../errors/VSRepoError");
|
|
41
|
+
const vsrepo_error_type_enum_1 = require("../enums/vsrepo-error-type.enum");
|
|
42
|
+
const ordering_schema_1 = __importDefault(require("../validators/schemas/ordering.schema"));
|
|
43
|
+
const relations_schema_1 = __importDefault(require("../validators/schemas/relations.schema"));
|
|
44
|
+
const see_mode_schema_1 = __importDefault(require("../validators/schemas/see-mode.schema"));
|
|
45
|
+
const select_schema_1 = __importDefault(require("../validators/schemas/select.schema"));
|
|
46
|
+
const where_schema_1 = __importDefault(require("../validators/schemas/where.schema"));
|
|
47
|
+
const v = __importStar(require("valibot"));
|
|
48
|
+
/**
|
|
49
|
+
* Fluent builder for queries whose shape is only known at runtime (optional filters, user-controlled
|
|
50
|
+
* ordering and pagination, ...). Get one from `VSRepository#createQueryBuilder()`.
|
|
51
|
+
*
|
|
52
|
+
* Chain the configuration methods (`select`, `relations`, `where`, `orderBy`, `limit`, `offset`,
|
|
53
|
+
* `distinctOn`, `see`) and run the query with a terminal method (`getResult`,
|
|
54
|
+
* `getOneResult`, `getOneResultOrThrow`, `getCount`, `getExistence` or `getResultAndCount`). Nothing
|
|
55
|
+
* reaches the database until a terminal method is called.
|
|
56
|
+
*
|
|
57
|
+
* The builder is **mutable**: every chained call changes the same instance and returns it. Use
|
|
58
|
+
* {@link VSQueryBuilder.clone} to derive variations from a common base.
|
|
59
|
+
*
|
|
60
|
+
* Soft-delete is respected the same way as in the repository methods: when the repository has a
|
|
61
|
+
* `softRemoveKey`, only non-deleted records are seen unless {@link VSQueryBuilder.see} says otherwise.
|
|
62
|
+
*
|
|
63
|
+
* Arguments are validated as soon as they are passed to a chained method; an invalid one throws a
|
|
64
|
+
* `VSRepoError` of type `QUERY_BUILDER` and leaves the builder unchanged.
|
|
65
|
+
*
|
|
66
|
+
* @template Entity Type of the entity being queried.
|
|
67
|
+
* @template OrmTypes ORM-specific client/transaction types. See `VSRepoOrmTypes`.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const { result, count } = await userRepository
|
|
72
|
+
* .createQueryBuilder()
|
|
73
|
+
* .where({ active: true, balance: { gte: 100 } })
|
|
74
|
+
* .relations({ address: true })
|
|
75
|
+
* .orderBy({ createdAt: "desc" })
|
|
76
|
+
* .limit(20)
|
|
77
|
+
* .offset(40)
|
|
78
|
+
* .getResultAndCount();
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @publicApi
|
|
82
|
+
*/
|
|
83
|
+
class VSQueryBuilder {
|
|
84
|
+
db;
|
|
85
|
+
adapter;
|
|
86
|
+
mergeWheresResolver;
|
|
87
|
+
logger;
|
|
88
|
+
options = {};
|
|
89
|
+
distinct;
|
|
90
|
+
seeMode = "active";
|
|
91
|
+
whereFilter;
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
constructor(db, adapter, mergeWheresResolver, logger) {
|
|
96
|
+
this.db = db;
|
|
97
|
+
this.adapter = adapter;
|
|
98
|
+
this.mergeWheresResolver = mergeWheresResolver;
|
|
99
|
+
this.logger = logger;
|
|
100
|
+
}
|
|
101
|
+
failValidation(issue, fallbackPath = "options") {
|
|
102
|
+
const path = issue?.path?.length ? issue.path.map(p => String(p.key)).join(".") : fallbackPath;
|
|
103
|
+
const message = `${path}: ${issue?.message ?? "validation failed"}`;
|
|
104
|
+
this.logger?.logError(`Validation failed (${vsrepo_error_type_enum_1.VSRepoErrorType.QUERY_BUILDER}): ${message}`);
|
|
105
|
+
throw new VSRepoError_1.VSRepoError(message, vsrepo_error_type_enum_1.VSRepoErrorType.QUERY_BUILDER);
|
|
106
|
+
}
|
|
107
|
+
validate(value, schema, fallbackPath) {
|
|
108
|
+
const parsed = v.safeParse(schema, value);
|
|
109
|
+
if (!parsed.success) {
|
|
110
|
+
this.failValidation(parsed.issues[0], fallbackPath);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
resolveWhere() {
|
|
114
|
+
return this.mergeWheresResolver.resolve(this.seeMode, this.whereFilter ?? {});
|
|
115
|
+
}
|
|
116
|
+
// * Log de debug dos passos do builder e das queries. O objeto só é serializado se o nível for DEBUG
|
|
117
|
+
trace(message, obj) {
|
|
118
|
+
this.logger?.logDebug(`VSQueryBuilder: ${message}`, obj);
|
|
119
|
+
}
|
|
120
|
+
// * Nunca logar o `db` aqui (client/transação do ORM), só os parâmetros da query
|
|
121
|
+
async execute(operation, params, run) {
|
|
122
|
+
this.trace(operation, { see: this.seeMode, ...params });
|
|
123
|
+
const start = this.logger?.startPerformLog(`run query builder ${operation}`);
|
|
124
|
+
try {
|
|
125
|
+
return await run();
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
this.logger?.endPerformLog(start);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
setOptions(options) {
|
|
135
|
+
this.options = options;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
setWhereFilter(whereFilter) {
|
|
141
|
+
this.whereFilter = whereFilter;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
setDistinct(distinct) {
|
|
147
|
+
this.distinct = distinct;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
setSeeMode(seeMode) {
|
|
153
|
+
this.seeMode = seeMode;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Sets the client or transaction the query runs on, replacing the one given to `createQueryBuilder()`.
|
|
157
|
+
*
|
|
158
|
+
* It's lazy — it only matters when a terminal method runs — so a builder can be created before a
|
|
159
|
+
* transaction and pointed at it from inside, or a {@link VSQueryBuilder.clone} can be pointed at another
|
|
160
|
+
* client without touching the original builder.
|
|
161
|
+
*
|
|
162
|
+
* @param db Client or transaction that every following terminal call will use.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const qb = userRepository.createQueryBuilder().where({ active: true });
|
|
167
|
+
*
|
|
168
|
+
* await userRepository.transaction(async tx => {
|
|
169
|
+
* qb.setDb(tx);
|
|
170
|
+
* return qb.getResult();
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
setDb(db) {
|
|
175
|
+
this.db = db;
|
|
176
|
+
this.trace("db replaced");
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Runs the query and returns every matching record.
|
|
180
|
+
*
|
|
181
|
+
* Uses everything configured on the builder: filter, `select`, `relations`, `orderBy`, `limit`/`offset`
|
|
182
|
+
* and `distinctOn` (the only terminal method that applies `distinct`).
|
|
183
|
+
*
|
|
184
|
+
* @returns The matching records (an empty array if none).
|
|
185
|
+
*/
|
|
186
|
+
async getResult() {
|
|
187
|
+
const where = this.resolveWhere();
|
|
188
|
+
const options = { ...this.options, distinct: this.distinct };
|
|
189
|
+
return this.execute("getResult", { where, options }, () => this.adapter.findMany(where, { ...options, db: this.db }));
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Runs the query and returns the first matching record, or `null` if there is none.
|
|
193
|
+
*
|
|
194
|
+
* Uses the filter, `select`, `relations`, `orderBy` and `limit`/`offset`. `distinctOn` is not applied.
|
|
195
|
+
*
|
|
196
|
+
* @returns The record, or `null` when nothing matches.
|
|
197
|
+
*/
|
|
198
|
+
async getOneResult() {
|
|
199
|
+
const where = this.resolveWhere();
|
|
200
|
+
const options = { ...this.options };
|
|
201
|
+
return this.execute("getOneResult", { where, options }, () => this.adapter.findOne(where, { ...options, db: this.db }));
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Same as {@link VSQueryBuilder.getOneResult}, but throws instead of returning `null`.
|
|
205
|
+
*
|
|
206
|
+
* The error thrown when nothing matches is the one the adapter's `findOneOrThrow` raises; it is not wrapped.
|
|
207
|
+
*
|
|
208
|
+
* @returns The first matching record.
|
|
209
|
+
*/
|
|
210
|
+
async getOneResultOrThrow() {
|
|
211
|
+
const where = this.resolveWhere();
|
|
212
|
+
const options = { ...this.options };
|
|
213
|
+
return this.execute("getOneResultOrThrow", { where, options }, () => this.adapter.findOneOrThrow(where, { ...options, db: this.db }));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Counts the records matching the filter.
|
|
217
|
+
*
|
|
218
|
+
* Forwards `orderBy` and `limit`/`offset` to the adapter's `count` as configured, so if you want the
|
|
219
|
+
* total of a builder that has pagination use {@link VSQueryBuilder.getResultAndCount} or count from a
|
|
220
|
+
* {@link VSQueryBuilder.clone} without it. `select`, `relations` and `distinctOn` are not used
|
|
221
|
+
* (`count` doesn't support `distinct`).
|
|
222
|
+
*
|
|
223
|
+
* @returns The number of matching records.
|
|
224
|
+
*/
|
|
225
|
+
async getCount() {
|
|
226
|
+
const where = this.resolveWhere();
|
|
227
|
+
const options = { order: this.options.order, pagination: this.options.pagination };
|
|
228
|
+
return this.execute("getCount", { where, options }, () => this.adapter.count(where, { ...options, db: this.db }));
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Checks whether at least one record matches the filter. Only the filter (and soft-delete visibility) is used.
|
|
232
|
+
*
|
|
233
|
+
* @returns `true` if a matching record exists, `false` otherwise.
|
|
234
|
+
*/
|
|
235
|
+
async getExistence() {
|
|
236
|
+
const where = this.resolveWhere();
|
|
237
|
+
return this.execute("getExistence", { where }, () => this.adapter.exists(where, { db: this.db }));
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Fetches a page of records and the total of records matching the filter, in a single call
|
|
241
|
+
* (like MikroORM's `getResultAndCount()`).
|
|
242
|
+
*
|
|
243
|
+
* `result` honors `orderBy` and `limit`/`offset`; `count` deliberately ignores `orderBy` and
|
|
244
|
+
* pagination, so it is the total that lets you compute the number of pages. Both queries run in
|
|
245
|
+
* parallel with the same filter and the same `db`. `distinctOn` is not used by either.
|
|
246
|
+
*
|
|
247
|
+
* @returns The page (`result`) and the total of matching records (`count`).
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* const { result, count } = await userRepository
|
|
252
|
+
* .createQueryBuilder()
|
|
253
|
+
* .where({ active: true })
|
|
254
|
+
* .limit(20)
|
|
255
|
+
* .offset(40)
|
|
256
|
+
* .getResultAndCount();
|
|
257
|
+
*
|
|
258
|
+
* const totalPages = Math.ceil(count / 20);
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
async getResultAndCount() {
|
|
262
|
+
const where = this.resolveWhere();
|
|
263
|
+
const options = { ...this.options };
|
|
264
|
+
return this.execute("getResultAndCount", { where, options }, async () => {
|
|
265
|
+
const [result, count] = await Promise.all([
|
|
266
|
+
this.adapter.findMany(where, { ...options, db: this.db }),
|
|
267
|
+
this.adapter.count(where, { db: this.db }),
|
|
268
|
+
]);
|
|
269
|
+
return { result, count };
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Returns an independent builder with the same filter, options, `distinctOn` fields, `see` mode and `db`.
|
|
274
|
+
* Changes made to either builder afterwards don't affect the other.
|
|
275
|
+
*
|
|
276
|
+
* @returns The new builder.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* const active = userRepository.createQueryBuilder().where({ active: true });
|
|
281
|
+
*
|
|
282
|
+
* const total = await active.clone().getCount();
|
|
283
|
+
* const firstPage = await active.clone().orderBy({ name: "asc" }).limit(10).getResult();
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
clone() {
|
|
287
|
+
const qbClone = new VSQueryBuilder(this.db, this.adapter, this.mergeWheresResolver, this.logger);
|
|
288
|
+
qbClone.setOptions(structuredClone(this.options));
|
|
289
|
+
qbClone.setWhereFilter(this.whereFilter);
|
|
290
|
+
qbClone.setDistinct(this.distinct);
|
|
291
|
+
qbClone.setSeeMode(this.seeMode);
|
|
292
|
+
this.trace("clone");
|
|
293
|
+
return qbClone;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Sets the fields (and nested relation fields) to select. Replaces any previous `select`.
|
|
297
|
+
*
|
|
298
|
+
* @param select Fields to select, e.g. `{ id: true, name: true, address: { city: true } }`.
|
|
299
|
+
* @throws {VSRepoError} `QUERY_BUILDER` if `select` doesn't have a valid shape.
|
|
300
|
+
*/
|
|
301
|
+
select(select) {
|
|
302
|
+
this.validate(select, select_schema_1.default, "select");
|
|
303
|
+
this.options.select = select;
|
|
304
|
+
this.trace("select", select);
|
|
305
|
+
return this;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Sets the relations to load together with the records. Replaces any previous `relations`.
|
|
309
|
+
*
|
|
310
|
+
* @param relations Relations to load, e.g. `{ address: true, products: true }`.
|
|
311
|
+
* @throws {VSRepoError} `QUERY_BUILDER` if `relations` doesn't have a valid shape.
|
|
312
|
+
*/
|
|
313
|
+
relations(relations) {
|
|
314
|
+
this.validate(relations, relations_schema_1.default, "relations");
|
|
315
|
+
this.options.relations = relations;
|
|
316
|
+
this.trace("relations", relations);
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Sets the filter, replacing any previous one. It accepts the same `VSRepoWhere` used by the rest of
|
|
321
|
+
* the library: field-level filters (`{ active: true, balance: { gte: 100 } }`), relation filters
|
|
322
|
+
* (`_some`/`_every`/`_none`, `_with`/`_without`) and the logical operators `AND`, `OR` and `NOT`.
|
|
323
|
+
*
|
|
324
|
+
* The soft-delete filter (see {@link VSQueryBuilder.see}) is added on top of it when the query runs.
|
|
325
|
+
*
|
|
326
|
+
* @param where Filter of the query.
|
|
327
|
+
* @throws {VSRepoError} `QUERY_BUILDER` if `where` doesn't have a valid shape.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* qb.where({
|
|
332
|
+
* active: true,
|
|
333
|
+
* OR: [{ name: { contains: "Maria" } }, { email: { contains: "maria" } }],
|
|
334
|
+
* });
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
where(where) {
|
|
338
|
+
this.validate(where, where_schema_1.default, "where");
|
|
339
|
+
this.whereFilter = where;
|
|
340
|
+
this.trace("where", where);
|
|
341
|
+
return this;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Sets the ordering. Replaces any previous ordering.
|
|
345
|
+
*
|
|
346
|
+
* @param order An object, or an array of objects, mapping primitive fields to `"asc"`/`"desc"`
|
|
347
|
+
* (lower or upper case), e.g. `{ createdAt: "desc" }`.
|
|
348
|
+
* @throws {VSRepoError} `QUERY_BUILDER` if `order` doesn't have a valid shape.
|
|
349
|
+
*/
|
|
350
|
+
orderBy(order) {
|
|
351
|
+
this.validate(order, ordering_schema_1.default, "order");
|
|
352
|
+
this.options.order = order;
|
|
353
|
+
this.trace("orderBy", order);
|
|
354
|
+
return this;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Sets the maximum number of records to return. Can be combined with {@link VSQueryBuilder.offset}.
|
|
358
|
+
*
|
|
359
|
+
* @param limit Non-negative integer.
|
|
360
|
+
* @throws {VSRepoError} `QUERY_BUILDER` if `limit` isn't a non-negative integer.
|
|
361
|
+
*/
|
|
362
|
+
limit(limit) {
|
|
363
|
+
this.validate(limit, v.pipe(v.number(), v.integer(), v.minValue(0)), "limit");
|
|
364
|
+
this.options.pagination ??= {};
|
|
365
|
+
this.options.pagination.limit = limit;
|
|
366
|
+
this.trace(`limit ${limit}`);
|
|
367
|
+
return this;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Sets how many records to skip. Can be combined with {@link VSQueryBuilder.limit}.
|
|
371
|
+
*
|
|
372
|
+
* @param offset Non-negative integer.
|
|
373
|
+
* @throws {VSRepoError} `QUERY_BUILDER` if `offset` isn't a non-negative integer.
|
|
374
|
+
*/
|
|
375
|
+
offset(offset) {
|
|
376
|
+
this.validate(offset, v.pipe(v.number(), v.integer(), v.minValue(0)), "offset");
|
|
377
|
+
this.options.pagination ??= {};
|
|
378
|
+
this.options.pagination.offset = offset;
|
|
379
|
+
this.trace(`offset ${offset}`);
|
|
380
|
+
return this;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Sets the field(s) to apply `distinct` on. Replaces any previous `distinctOn`.
|
|
384
|
+
*
|
|
385
|
+
* Only {@link VSQueryBuilder.getResult} uses it: the ecosystem's `count` doesn't support `distinct`.
|
|
386
|
+
*
|
|
387
|
+
* @param fields A primitive field, or an array of them.
|
|
388
|
+
* @throws {VSRepoError} `QUERY_BUILDER` if `fields` isn't a string or an array of strings.
|
|
389
|
+
*/
|
|
390
|
+
distinctOn(fields) {
|
|
391
|
+
this.validate(fields, v.union([v.string(), v.array(v.string())]), "fields");
|
|
392
|
+
this.distinct = Array.isArray(fields) ? fields : [fields];
|
|
393
|
+
this.trace("distinctOn", this.distinct);
|
|
394
|
+
return this;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Sets which records the query sees when the repository has a `softRemoveKey`. Applies to every
|
|
398
|
+
* terminal method (both queries of `getResultAndCount` included) and is ignored by repositories
|
|
399
|
+
* without soft-delete.
|
|
400
|
+
*
|
|
401
|
+
* @param seeMode `"active"` (default) for non-deleted records, `"removed"` for soft-deleted ones
|
|
402
|
+
* or `"all"` to ignore soft-delete.
|
|
403
|
+
* @throws {VSRepoError} `QUERY_BUILDER` if `seeMode` isn't one of the modes above.
|
|
404
|
+
*/
|
|
405
|
+
see(seeMode) {
|
|
406
|
+
this.validate(seeMode, see_mode_schema_1.default, "seeMode");
|
|
407
|
+
this.seeMode = seeMode;
|
|
408
|
+
this.trace(`see '${seeMode}'`);
|
|
409
|
+
return this;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
exports.VSQueryBuilder = VSQueryBuilder;
|
|
413
|
+
//# sourceMappingURL=vs-query-builder.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vs-query-builder.util.js","sourceRoot":"","sources":["../../../src/internal/utils/vs-query-builder.util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAuD;AAWvD,4EAAkE;AAElE,4FAAmE;AACnE,8FAAqE;AACrE,4FAAkE;AAClE,wFAA+D;AAC/D,sFAA6D;AAE7D,2CAA6B;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,cAAc;IAUX;IACS;IACA;IACA;IAZb,OAAO,GAA6C,EAAE,CAAC;IACvD,QAAQ,CAAmC;IAC3C,OAAO,GAAY,QAAQ,CAAC;IAC5B,WAAW,CAAuB;IAE1C;;OAEG;IACH,YACY,EAAoD,EAC3C,OAA8B,EAC9B,mBAAgD,EAChD,MAAiB;QAH1B,OAAE,GAAF,EAAE,CAAkD;QAC3C,YAAO,GAAP,OAAO,CAAuB;QAC9B,wBAAmB,GAAnB,mBAAmB,CAA6B;QAChD,WAAM,GAAN,MAAM,CAAW;IACnC,CAAC;IAEI,cAAc,CAAC,KAAiC,EAAE,YAAY,GAAG,SAAS;QAC9E,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,C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AAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAE5E,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAExC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;OAQG;IACH,GAAG,CAAC,OAAgB;QAChB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,yBAAa,EAAE,SAAS,CAAC,CAAC;QAEjD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,KAAK,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC;QAE/B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAlZD,wCAkZC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-db.util.js","sourceRoot":"","sources":["../../../src/internal/utils/with-db.util.ts"],"names":[],"mappings":";;AAmBA,
|
|
1
|
+
{"version":3,"file":"with-db.util.js","sourceRoot":"","sources":["../../../src/internal/utils/with-db.util.ts"],"names":[],"mappings":";;AAmBA,wBAEC;AApBD,+CAAsC;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,MAAM,CAA4C,EAAsC;IACpG,OAAO,IAAI,mBAAK,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -50,9 +50,7 @@ class DecoratorsValidator {
|
|
|
50
50
|
const parsed = v.safeParse(this.dynamicMethodOptionsSchema, options);
|
|
51
51
|
if (!parsed.success) {
|
|
52
52
|
const firstIssue = parsed.issues[0];
|
|
53
|
-
const path = firstIssue.path?.length
|
|
54
|
-
? firstIssue.path.map(p => String(p.key)).join(".")
|
|
55
|
-
: "options";
|
|
53
|
+
const path = firstIssue.path?.length ? firstIssue.path.map(p => String(p.key)).join(".") : "options";
|
|
56
54
|
throw new VSRepoError_1.VSRepoError(`${path}: ${firstIssue.message}`, vsrepo_error_type_enum_1.VSRepoErrorType.DECORATOR);
|
|
57
55
|
}
|
|
58
56
|
return parsed.output;
|
|
@@ -66,9 +64,7 @@ class DecoratorsValidator {
|
|
|
66
64
|
const parsed = v.safeParse(this.queryMethodOptionsSchema, options);
|
|
67
65
|
if (!parsed.success) {
|
|
68
66
|
const firstIssue = parsed.issues[0];
|
|
69
|
-
const path = firstIssue.path?.length
|
|
70
|
-
? firstIssue.path.map(p => String(p.key)).join(".")
|
|
71
|
-
: "options";
|
|
67
|
+
const path = firstIssue.path?.length ? firstIssue.path.map(p => String(p.key)).join(".") : "options";
|
|
72
68
|
throw new VSRepoError_1.VSRepoError(`${path}: ${firstIssue.message}`, vsrepo_error_type_enum_1.VSRepoErrorType.DECORATOR);
|
|
73
69
|
}
|
|
74
70
|
return parsed.output;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.validator.js","sourceRoot":"","sources":["../../../src/internal/validators/decorators.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,0DAAuD;AACvD,gFAAuD;AAEvD,4EAAkE;AAElE,MAAa,mBAAmB;IACpB,MAAM,CAAU,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;QAC1D,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,yBAAc,CAAC;KAC7C,CAAC,CAAC;IAEH,MAAM,CAAC,4BAA4B,CAAC,OAAgB;QAChD,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;QAErE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"decorators.validator.js","sourceRoot":"","sources":["../../../src/internal/validators/decorators.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,0DAAuD;AACvD,gFAAuD;AAEvD,4EAAkE;AAElE,MAAa,mBAAmB;IACpB,MAAM,CAAU,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;QAC1D,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,yBAAc,CAAC;KAC7C,CAAC,CAAC;IAEH,MAAM,CAAC,4BAA4B,CAAC,OAAgB;QAChD,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;QAErE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrG,MAAM,IAAI,yBAAW,CAAC,GAAG,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,EAAE,wCAAe,CAAC,SAAS,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;QAC/C,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC;QACzC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACrC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;KACtC,CAAC,CAAC;IAEH,MAAM,CAAC,0BAA0B,CAAC,OAAgB;QAC9C,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;QAEnE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrG,MAAM,IAAI,yBAAW,CAAC,GAAG,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,EAAE,wCAAe,CAAC,SAAS,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC;IACzB,CAAC;;AAlCL,kDAmCC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
declare const _default: v.ObjectSchema<{
|
|
3
|
-
readonly limit: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
4
|
-
readonly offset: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
3
|
+
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
4
|
+
readonly offset: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
5
5
|
}, undefined>;
|
|
6
6
|
export default _default;
|
|
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const v = __importStar(require("valibot"));
|
|
37
37
|
exports.default = v.object({
|
|
38
|
-
limit: v.optional(v.number()),
|
|
39
|
-
offset: v.optional(v.number()),
|
|
38
|
+
limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))),
|
|
39
|
+
offset: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))),
|
|
40
40
|
});
|
|
41
41
|
//# sourceMappingURL=pagination.schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.schema.js","sourceRoot":"","sources":["../../../../src/internal/validators/schemas/pagination.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,kBAAe,CAAC,CAAC,MAAM,CAAC;IACpB,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"pagination.schema.js","sourceRoot":"","sources":["../../../../src/internal/validators/schemas/pagination.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,kBAAe,CAAC,CAAC,MAAM,CAAC;IACpB,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACrE,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const v = __importStar(require("valibot"));
|
|
37
|
+
const relationsSchema = v.lazy(() => v.record(v.string(), v.optional(v.union([v.boolean(), relationsSchema]))));
|
|
38
|
+
exports.default = relationsSchema;
|
|
39
|
+
//# sourceMappingURL=relations.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.schema.js","sourceRoot":"","sources":["../../../../src/internal/validators/schemas/relations.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAG7B,MAAM,eAAe,GAA8D,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC3F,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAC5E,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const v = __importStar(require("valibot"));
|
|
37
|
+
exports.default = v.picklist(["active", "removed", "all"]);
|
|
38
|
+
//# sourceMappingURL=see-mode.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"see-mode.schema.js","sourceRoot":"","sources":["../../../../src/internal/validators/schemas/see-mode.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,kBAAe,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const v = __importStar(require("valibot"));
|
|
37
|
+
const selectSchema = v.lazy(() => v.record(v.string(), v.optional(v.union([v.boolean(), selectSchema]))));
|
|
38
|
+
exports.default = selectSchema;
|
|
39
|
+
//# sourceMappingURL=select.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.schema.js","sourceRoot":"","sources":["../../../../src/internal/validators/schemas/select.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAG7B,MAAM,YAAY,GAA2D,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACrF,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CACzE,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|