proto.io 0.0.212 → 0.0.214

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.
Files changed (44) hide show
  1. package/dist/adapters/file/aliyun-oss.d.ts +3 -3
  2. package/dist/adapters/file/database.d.ts +2 -2
  3. package/dist/adapters/file/database.js +2 -2
  4. package/dist/adapters/file/database.js.map +1 -1
  5. package/dist/adapters/file/database.mjs +1 -1
  6. package/dist/adapters/file/filesystem.d.ts +3 -3
  7. package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
  8. package/dist/adapters/storage/progres.d.ts +1 -1
  9. package/dist/adapters/storage/progres.js +117 -84
  10. package/dist/adapters/storage/progres.js.map +1 -1
  11. package/dist/adapters/storage/progres.mjs +79 -46
  12. package/dist/adapters/storage/progres.mjs.map +1 -1
  13. package/dist/client.d.ts +3 -3
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +42 -42
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +2 -2
  18. package/dist/internals/{base-CZGalGrd.d.ts → base-E1b8J-Fs.d.ts} +2 -2
  19. package/dist/internals/base-E1b8J-Fs.d.ts.map +1 -0
  20. package/dist/internals/{chunk-BsT9SYny.d.ts → chunk-D1bD7otk.d.ts} +3 -3
  21. package/dist/internals/chunk-D1bD7otk.d.ts.map +1 -0
  22. package/dist/internals/{index-Boxwkqe0.d.ts → index-CbjY-gJ7.d.ts} +6 -8
  23. package/dist/internals/index-CbjY-gJ7.d.ts.map +1 -0
  24. package/dist/internals/{index-NF-U_3zG.d.ts → index-SSEdPyhp.d.ts} +2 -2
  25. package/dist/internals/index-SSEdPyhp.d.ts.map +1 -0
  26. package/dist/internals/random-CYjWDvex.mjs +37 -0
  27. package/dist/internals/random-CYjWDvex.mjs.map +1 -0
  28. package/dist/internals/random-nkOQ9U6S.js +39 -0
  29. package/dist/internals/random-nkOQ9U6S.js.map +1 -0
  30. package/dist/internals/{index-D8O7SinR.js → validator-DoRPoIs2.js} +586 -2
  31. package/dist/internals/validator-DoRPoIs2.js.map +1 -0
  32. package/dist/internals/{index-DG9HHO_U.mjs → validator-Dxmbwa3P.mjs} +583 -3
  33. package/dist/internals/validator-Dxmbwa3P.mjs.map +1 -0
  34. package/package.json +1 -1
  35. package/dist/internals/base-CZGalGrd.d.ts.map +0 -1
  36. package/dist/internals/chunk-BsT9SYny.d.ts.map +0 -1
  37. package/dist/internals/index-Boxwkqe0.d.ts.map +0 -1
  38. package/dist/internals/index-D8O7SinR.js.map +0 -1
  39. package/dist/internals/index-DG9HHO_U.mjs.map +0 -1
  40. package/dist/internals/index-NF-U_3zG.d.ts.map +0 -1
  41. package/dist/internals/random-CufRbivU.mjs +0 -526
  42. package/dist/internals/random-CufRbivU.mjs.map +0 -1
  43. package/dist/internals/random-DzvxbWAc.js +0 -532
  44. package/dist/internals/random-DzvxbWAc.js.map +0 -1
@@ -1,526 +0,0 @@
1
- import _ from 'lodash';
2
- import { k as QueryExpression, Q as QuerySelector, a as QueryCoditionalSelector, b as QueryFieldSelector } from './index-DG9HHO_U.mjs';
3
- import { c as isPrimitive, f as isVector, b as isShape, T as TObject, s as shapePaths, a as isRelation, i as isPointer, k as _typeof, l as isPrimitiveValue } from './index-al1N-qi7.mjs';
4
- import { P as PVK } from './private-CNw40LZ7.mjs';
5
- import { randomBytes } from '@o2ter/crypto-js';
6
-
7
- //
8
- // accumulators.ts
9
- //
10
- // The MIT License
11
- // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
12
- //
13
- // Permission is hereby granted, free of charge, to any person obtaining a copy
14
- // of this software and associated documentation files (the "Software"), to deal
15
- // in the Software without restriction, including without limitation the rights
16
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- // copies of the Software, and to permit persons to whom the Software is
18
- // furnished to do so, subject to the following conditions:
19
- //
20
- // The above copyright notice and this permission notice shall be included in
21
- // all copies or substantial portions of the Software.
22
- //
23
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
- // THE SOFTWARE.
30
- //
31
- const accumulatorExprKeys = ['$sum', '$avg'];
32
- const accumulatorNoExprKeys = ['$count'];
33
- const accumulatorKeyTypes = {
34
- '$count': 'number',
35
- '$sum': 'number',
36
- '$avg': 'number',
37
- };
38
-
39
- //
40
- // accumulators.ts
41
- //
42
- // The MIT License
43
- // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
44
- //
45
- // Permission is hereby granted, free of charge, to any person obtaining a copy
46
- // of this software and associated documentation files (the "Software"), to deal
47
- // in the Software without restriction, including without limitation the rights
48
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49
- // copies of the Software, and to permit persons to whom the Software is
50
- // furnished to do so, subject to the following conditions:
51
- //
52
- // The above copyright notice and this permission notice shall be included in
53
- // all copies or substantial portions of the Software.
54
- //
55
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
61
- // THE SOFTWARE.
62
- //
63
- class QueryAccumulator {
64
- type;
65
- expr;
66
- static decode(query) {
67
- for (const [key, expr] of _.toPairs(query)) {
68
- if (_.includes(accumulatorExprKeys, key)) {
69
- return new QueryAccumulator(key, QueryExpression.decode(expr ?? [], false));
70
- }
71
- else if (_.includes(accumulatorNoExprKeys, key)) {
72
- return new QueryAccumulator(key);
73
- }
74
- else {
75
- throw Error('Invalid expression');
76
- }
77
- }
78
- throw Error('Invalid expression');
79
- }
80
- constructor(type, expr) {
81
- this.type = type;
82
- this.expr = expr;
83
- }
84
- simplify() {
85
- return new QueryAccumulator(this.type, this.expr?.simplify());
86
- }
87
- keyPaths() {
88
- return this.expr?.keyPaths() ?? [];
89
- }
90
- mapKey(callback) {
91
- return new QueryAccumulator(this.type, this.expr?.mapKey(callback));
92
- }
93
- }
94
-
95
- //
96
- // validator.ts
97
- //
98
- // The MIT License
99
- // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
100
- //
101
- // Permission is hereby granted, free of charge, to any person obtaining a copy
102
- // of this software and associated documentation files (the "Software"), to deal
103
- // in the Software without restriction, including without limitation the rights
104
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
105
- // copies of the Software, and to permit persons to whom the Software is
106
- // furnished to do so, subject to the following conditions:
107
- //
108
- // The above copyright notice and this permission notice shall be included in
109
- // all copies or substantial portions of the Software.
110
- //
111
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
112
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
113
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
114
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
115
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
116
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
117
- // THE SOFTWARE.
118
- //
119
- const recursiveCheck = (x, stack) => {
120
- if (_.indexOf(stack, x) !== -1)
121
- throw Error('Recursive data detected');
122
- if (_.isRegExp(x) || isPrimitiveValue(x) || x instanceof TObject)
123
- return;
124
- const children = _.isArray(x) ? x : _.values(x);
125
- children.forEach(v => recursiveCheck(v, [...stack, x]));
126
- };
127
- const resolveDataType = (schema, classname, path) => {
128
- let fields = schema[classname].fields;
129
- let last;
130
- for (const key of _.toPath(path)) {
131
- const dataType = fields[key];
132
- if (_.isNil(dataType))
133
- throw Error(`Invalid path: ${path}`);
134
- if (isPrimitive(dataType) || isVector(dataType))
135
- return dataType;
136
- if (isShape(dataType)) {
137
- fields = dataType.shape;
138
- continue;
139
- }
140
- if (_.isNil(schema[dataType.target]))
141
- throw Error(`Invalid path: ${path}`);
142
- fields = schema[dataType.target].fields;
143
- last = dataType;
144
- }
145
- return last;
146
- };
147
- const resolveColumn = (schema, className, path) => {
148
- const _schema = schema[className] ?? {};
149
- let [colname, ...subpath] = path.split('.');
150
- let dataType = _schema.fields[colname];
151
- while (dataType && !_.isEmpty(subpath) && isShape(dataType)) {
152
- const [key, ...remain] = subpath;
153
- if (!dataType.shape[key])
154
- break;
155
- dataType = dataType.shape[key];
156
- colname = `${colname}.${key}`;
157
- subpath = remain;
158
- }
159
- return {
160
- paths: [colname, ...subpath],
161
- dataType,
162
- };
163
- };
164
- class QueryValidator {
165
- proto;
166
- acls;
167
- options;
168
- static patterns = {
169
- path: /^[a-z_][\w-]*(\[\d+\]|\.\d*|\.[a-z_][\w-]*)*$/gi,
170
- className: /^[a-z_][\w]*$/gi,
171
- fieldName: /^[a-z_][\w-]*$/gi,
172
- digits: /^\d+$/g,
173
- };
174
- _rperm(className) {
175
- if (this.options.master)
176
- return [];
177
- const check = _.intersection(this.schema[className]?.additionalObjectPermissions?.read, this.acls);
178
- if (!_.isEmpty(check))
179
- return [];
180
- return [{ _rperm: { $intersect: this.acls } }];
181
- }
182
- _wperm(className) {
183
- if (this.options.master)
184
- return [];
185
- const check = _.intersection(this.schema[className]?.additionalObjectPermissions?.update, this.acls);
186
- if (!_.isEmpty(check))
187
- return [];
188
- return [{ _wperm: { $intersect: this.acls } }];
189
- }
190
- _expiredAt = { $or: [{ _expired_at: { $eq: null } }, { _expired_at: { $gt: new Date() } }] };
191
- constructor(proto, acls, options) {
192
- this.proto = proto;
193
- this.acls = _.uniq(['*', ...acls]);
194
- this.options = options;
195
- }
196
- get schema() {
197
- return this.proto.schema;
198
- }
199
- get objectIdSize() {
200
- return this.proto[PVK].options.objectIdSize;
201
- }
202
- static recursiveCheck(...x) {
203
- recursiveCheck(x, []);
204
- }
205
- validateKeyPerm(key, type, schema) {
206
- key = _.first(key?.split('.')) ?? key;
207
- if (_.isEmpty(key) || (!_.has(schema.fields, key) && !TObject.defaultKeys.includes(key)))
208
- throw Error(`Invalid key: ${key}`);
209
- if (type === 'read' && TObject.defaultKeys.includes(key))
210
- return true;
211
- if (type !== 'read' && TObject.defaultReadonlyKeys.includes(key))
212
- return false;
213
- if (!this.options.disableSecurity && _.includes(schema.secureFields, key))
214
- return false;
215
- return this.options.master || !_.every(schema.fieldLevelPermissions?.[key]?.[type] ?? ['*'], x => !_.includes(this.acls, x));
216
- }
217
- validateCLPs(className, ...keys) {
218
- if (!_.has(this.schema, className))
219
- throw Error('No permission');
220
- return this.options.master || this.proto[PVK].validateCLPs(className, this.acls, keys);
221
- }
222
- validateForeignField(dataType, type, errorMeg) {
223
- if (_.isNil(dataType.foreignField))
224
- return;
225
- const foreignField = resolveDataType(this.schema, dataType.target, dataType.foreignField);
226
- if (_.isNil(foreignField) || _.isString(foreignField))
227
- throw Error(errorMeg);
228
- if (isPrimitive(foreignField))
229
- throw Error(errorMeg);
230
- if (foreignField.type === 'relation' && !_.isNil(foreignField.foreignField))
231
- throw Error(errorMeg);
232
- if (!this.validateKeyPerm(dataType.foreignField, type, this.schema[dataType.target]))
233
- throw Error('No permission');
234
- }
235
- validateKey(className, key, type, validator) {
236
- const schema = this.schema[className] ?? {};
237
- const _key = _.isArray(key) ? key.join('.') : key;
238
- if (!_key.match(validator))
239
- throw Error(`Invalid key: ${_key}`);
240
- const [colname, ..._subpath] = _.toPath(_key);
241
- if (!this.validateKeyPerm(colname, type, schema))
242
- return false;
243
- if (_.isEmpty(_subpath) && TObject.defaultKeys.includes(colname))
244
- return true;
245
- if (_.isEmpty(_subpath))
246
- return true;
247
- const { paths: [_colname, ...subpath], dataType } = resolveColumn(this.schema, className, _key);
248
- const isElem = _.first(subpath)?.match(QueryValidator.patterns.digits);
249
- if (isElem) {
250
- if (dataType === 'array' || dataType === 'string[]')
251
- return true;
252
- if (!_.isString(dataType) && dataType.type !== 'relation')
253
- return false;
254
- }
255
- if (isPrimitive(dataType))
256
- return true;
257
- if (isVector(dataType))
258
- return true;
259
- const relations = [];
260
- if (isShape(dataType)) {
261
- for (const { type } of shapePaths(dataType)) {
262
- if (!isPrimitive(type) && !isVector(type))
263
- relations.push(type);
264
- }
265
- }
266
- else {
267
- relations.push(dataType);
268
- }
269
- for (const relation of relations) {
270
- if (_.isNil(this.schema[relation.target]))
271
- return false;
272
- if (type === 'read' && !this.validateCLPs(relation.target, 'get'))
273
- return false;
274
- if (relation.type === 'relation')
275
- this.validateForeignField(relation, type, `Invalid key: ${_key}`);
276
- }
277
- if (isShape(dataType)) {
278
- if (!_.isEmpty(subpath))
279
- throw Error(`Invalid key: ${_key}`);
280
- return true;
281
- }
282
- const _sub = isElem ? subpath.slice(1) : subpath;
283
- return _.isEmpty(_sub) || this.validateKey(dataType.target, _sub, type, validator);
284
- }
285
- validateFields(className, values, type, validator) {
286
- const _values = { ...values };
287
- for (const key of _.keys(_values)) {
288
- if (!this.validateKey(className, key, type, validator))
289
- throw Error('No permission');
290
- }
291
- return _values;
292
- }
293
- decodeGroupMatches(className, groupMatches) {
294
- const result = _.mapValues(groupMatches, m => _.mapValues(m, x => QueryAccumulator.decode(x).simplify()));
295
- for (const [colname, group] of _.entries(result)) {
296
- const dataType = resolveDataType(this.schema, className, colname);
297
- if (!dataType || !isRelation(dataType))
298
- throw Error(`Invalid relation key: ${colname}`);
299
- for (const key of _.keys(group)) {
300
- if (!key.match(QueryValidator.patterns.fieldName))
301
- throw Error(`Invalid field name: ${key}`);
302
- }
303
- }
304
- return result;
305
- }
306
- decodeIncludes(className, includes, groupMatches) {
307
- const schema = this.schema[className] ?? {};
308
- const _includes = [];
309
- const populates = {};
310
- for (const include of includes) {
311
- if (include === '*') {
312
- const primitive = _.pickBy(schema.fields, (v, k) => isPrimitive(v) && this.validateKeyPerm(k, 'read', schema));
313
- const shapedObject = _.pickBy(schema.fields, (v, k) => isShape(v) && this.validateKeyPerm(k, 'read', schema));
314
- _includes.push(..._.keys(primitive), ..._.flatMap(shapedObject, (v, k) => _.flatMap(shapePaths(v), x => isPrimitive(x.type) ? [`${k}.${x.path}`] : [])));
315
- }
316
- else {
317
- const { paths: [colname, ...subpath], dataType } = resolveColumn(this.schema, className, include);
318
- if (!this.validateKeyPerm(colname, 'read', schema))
319
- throw Error('No permission');
320
- if (isPointer(dataType) || isRelation(dataType)) {
321
- if (!this.validateCLPs(dataType.target, 'get'))
322
- throw Error('No permission');
323
- if (dataType.type === 'relation')
324
- this.validateForeignField(dataType, 'read', `Invalid include: ${include}`);
325
- const isDigit = _.first(subpath)?.match(QueryValidator.patterns.digits);
326
- const _subpath = isRelation(dataType) && isDigit ? _.slice(subpath, 1) : subpath;
327
- populates[colname] = populates[colname] ?? { className: dataType.target, subpaths: [], groupMatches: {} };
328
- const s = _.first(_subpath);
329
- if (!s || !groupMatches[colname]?.[s]) {
330
- populates[colname].subpaths.push(_.isEmpty(_subpath) ? '*' : _subpath.join('.'));
331
- populates[colname].groupMatches = _.mapKeys(_.pickBy(groupMatches, (x, k) => _.startsWith(k, `${colname}.`)), (x, k) => k.slice(colname.length + 1));
332
- }
333
- }
334
- else if (_.isEmpty(subpath) && isShape(dataType)) {
335
- for (const { path, type } of shapePaths(dataType)) {
336
- if (isPrimitive(type) || isVector(type)) {
337
- _includes.push(`${colname}.${path}`);
338
- }
339
- else {
340
- if (!this.validateCLPs(type.target, 'get'))
341
- throw Error('No permission');
342
- if (type.type === 'relation')
343
- this.validateForeignField(type, 'read', `Invalid include: ${include}`);
344
- populates[`${colname}.${path}`] = populates[`${colname}.${path}`] ?? { className: type.target, subpaths: [], groupMatches: {} };
345
- populates[`${colname}.${path}`].subpaths.push('*');
346
- populates[`${colname}.${path}`].groupMatches = _.mapKeys(_.pickBy(groupMatches, (x, k) => _.startsWith(k, `${colname}.${path}.`)), (x, k) => k.slice(`${colname}.${path}`.length + 1));
347
- }
348
- }
349
- }
350
- else if (_.isEmpty(subpath) || _.includes(['object', 'array'], _typeof(dataType))) {
351
- _includes.push(colname);
352
- }
353
- else {
354
- throw Error(`Invalid include: ${include}`);
355
- }
356
- }
357
- }
358
- for (const [key, populate] of _.toPairs(populates)) {
359
- const subpaths = this.decodeIncludes(populate.className, populate.subpaths, populate.groupMatches);
360
- _includes.push(..._.map(subpaths, x => `${key}.${x}`));
361
- }
362
- _includes.push(...TObject.defaultKeys);
363
- return _.uniq(_includes);
364
- }
365
- decodeSort(sort) {
366
- if (_.isArray(sort)) {
367
- return _.map(sort, s => ({
368
- order: s.order,
369
- expr: QueryExpression.decode(s.expr, false).simplify(),
370
- }));
371
- }
372
- return sort;
373
- }
374
- decodeMatches(className, matches, includes) {
375
- const schema = this.schema[className] ?? {};
376
- const _matches = {};
377
- const _includes = _.groupBy(_.map(includes, x => resolveColumn(this.schema, className, x)), ({ paths: [colname] }) => colname);
378
- for (const [colname, [{ dataType }]] of _.entries(_includes)) {
379
- if (!this.validateKeyPerm(colname, 'read', schema))
380
- continue;
381
- if (isPrimitive(dataType) || isVector(dataType) || isShape(dataType))
382
- continue;
383
- _matches[colname] = {
384
- matches: this.decodeMatches(dataType.target, {}, includes.filter(x => x.startsWith(`${colname}.`)).map(x => x.slice(colname.length + 1))),
385
- };
386
- }
387
- for (const [colname, match] of _.toPairs(matches)) {
388
- if (!this.validateKeyPerm(colname, 'read', schema))
389
- throw Error('No permission');
390
- const { paths: [_colname, ...subpath], dataType } = resolveColumn(this.schema, className, colname);
391
- if (isPointer(dataType) && !_.isEmpty(subpath)) {
392
- _matches[_colname] = {
393
- matches: this.decodeMatches(dataType.target, { [subpath.join('.')]: match }, includes.filter(x => x.startsWith(`${_colname}.`)).map(x => x.slice(_colname.length + 1))),
394
- };
395
- }
396
- else if (isRelation(dataType)) {
397
- if (!this.validateCLPs(dataType.target, 'get'))
398
- throw Error('No permission');
399
- this.validateForeignField(dataType, 'read', `Invalid match: ${colname}`);
400
- const groupMatches = this.decodeGroupMatches(dataType.target, match.groupMatches ?? {});
401
- _matches[_colname] = {
402
- ...match,
403
- groupMatches,
404
- filter: QuerySelector.decode(_.castArray(match.filter)).simplify(),
405
- matches: this.decodeMatches(dataType.target, match.matches ?? {}, includes.filter(x => x.startsWith(`${_colname}.`)).map(x => x.slice(_colname.length + 1))),
406
- sort: match.sort && this.decodeSort(match.sort),
407
- };
408
- }
409
- else {
410
- throw Error(`Invalid match: ${colname}`);
411
- }
412
- }
413
- return _matches;
414
- }
415
- validateRelatedBy(className, relation) {
416
- if (!this.validateCLPs(relation.className, 'get'))
417
- throw Error('No permission');
418
- if (!this.validateKey(relation.className, relation.key, 'read', QueryValidator.patterns.path))
419
- throw Error('No permission');
420
- const { dataType } = resolveColumn(this.schema, relation.className, relation.key);
421
- if (!isPointer(dataType) && !isRelation(dataType))
422
- throw Error(`Invalid relation key: ${relation.key}`);
423
- if (className && dataType.target !== className)
424
- throw Error(`Invalid relation key: ${relation.key}`);
425
- if (isRelation(dataType) && dataType.foreignField) {
426
- this.validateForeignField(dataType, 'read', `Invalid relation key: ${relation.key}`);
427
- this.validateRelatedBy(null, { className: dataType.target, key: dataType.foreignField });
428
- }
429
- }
430
- decodeQuery(query, action) {
431
- if ('relatedBy' in query && query.relatedBy)
432
- this.validateRelatedBy(query.className, query.relatedBy);
433
- const filter = QuerySelector.decode([
434
- ...action === 'read' ? this._rperm(query.className) : this._wperm(query.className),
435
- ..._.castArray(query.filter),
436
- this._expiredAt,
437
- ]).simplify();
438
- const groupMatches = this.decodeGroupMatches(query.className, query.groupMatches ?? {});
439
- const matchKeyPaths = (matches) => _.flatMap(matches, (match, key) => [
440
- ..._.keys(match.sort),
441
- ...QuerySelector.decode(match.filter ?? []).keyPaths(),
442
- ...matchKeyPaths(match.matches ?? {}),
443
- ..._.keys(match.groupMatches),
444
- ..._.flatMap(_.values(match.groupMatches), x => QueryAccumulator.decode(x).keyPaths()),
445
- ].map(x => `${key}.${x}`));
446
- const sort = query.sort && this.decodeSort(query.sort);
447
- const keyPaths = _.uniq([
448
- ...query.includes ?? ['*'],
449
- ..._.isArray(sort) ? _.flatMap(sort, s => s.expr.keyPaths()) : _.keys(sort),
450
- ...filter.keyPaths(),
451
- ...matchKeyPaths(query.matches ?? {}),
452
- ..._.keys(groupMatches),
453
- ..._.flatMap(_.values(groupMatches), m => _.flatMap(_.values(m), x => x.keyPaths())),
454
- ]);
455
- const includes = this.decodeIncludes(query.className, keyPaths, groupMatches);
456
- const matches = this.decodeMatches(query.className, query.matches ?? {}, includes);
457
- return {
458
- ...query,
459
- groupMatches,
460
- filter,
461
- matches,
462
- includes,
463
- sort,
464
- objectIdSize: this.objectIdSize,
465
- extraFilter: (className) => QuerySelector.decode([...this._rperm(className), this._expiredAt]).simplify(),
466
- };
467
- }
468
- isGetMethod(query) {
469
- const objectIds = [];
470
- if (query instanceof QueryCoditionalSelector && query.type === '$and') {
471
- for (const expr of query.exprs) {
472
- if (expr instanceof QueryFieldSelector &&
473
- expr.field === '_id' &&
474
- expr.expr.type === '$eq') {
475
- if (!_.isString(expr.expr.value))
476
- return false;
477
- objectIds.push(expr.expr.value);
478
- }
479
- }
480
- }
481
- else if (query instanceof QueryFieldSelector &&
482
- query.field === '_id' &&
483
- query.expr.type === '$eq') {
484
- if (!_.isString(query.expr.value))
485
- return false;
486
- objectIds.push(query.expr.value);
487
- }
488
- return _.uniq(objectIds).length === 1;
489
- }
490
- }
491
-
492
- //
493
- // random.ts
494
- //
495
- // The MIT License
496
- // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
497
- //
498
- // Permission is hereby granted, free of charge, to any person obtaining a copy
499
- // of this software and associated documentation files (the "Software"), to deal
500
- // in the Software without restriction, including without limitation the rights
501
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
502
- // copies of the Software, and to permit persons to whom the Software is
503
- // furnished to do so, subject to the following conditions:
504
- //
505
- // The above copyright notice and this permission notice shall be included in
506
- // all copies or substantial portions of the Software.
507
- //
508
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
509
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
510
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
511
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
512
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
513
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
514
- // THE SOFTWARE.
515
- //
516
- const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
517
- const generateId = (size) => {
518
- let id = '';
519
- for (const x of randomBytes(size)) {
520
- id += chars[x % chars.length];
521
- }
522
- return id;
523
- };
524
-
525
- export { QueryValidator as Q, resolveDataType as a, accumulatorKeyTypes as b, generateId as g, resolveColumn as r };
526
- //# sourceMappingURL=random-CufRbivU.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random-CufRbivU.mjs","sources":["../../../src/internals/query/types/accumulators.ts","../../../src/server/query/dispatcher/parser/accumulators.ts","../../../src/server/query/dispatcher/validator.ts","../../../src/server/crypto/random.ts"],"sourcesContent":["//\n// accumulators.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { TExpression } from './expressions';\n\nexport const accumulatorExprKeys = ['$sum', '$avg'] as const;\nexport const accumulatorNoExprKeys = ['$count'] as const;\n\nexport type TQueryAccumulator = {\n [x in (typeof accumulatorNoExprKeys)[number]]?: true | {};\n} & {\n [x in (typeof accumulatorExprKeys)[number]]?: TExpression;\n};\n\nexport const accumulatorKeyTypes = {\n '$count': 'number',\n '$sum': 'number',\n '$avg': 'number',\n} as const;\n","//\n// accumulators.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { accumulatorExprKeys, accumulatorNoExprKeys, TQueryAccumulator } from '../../../../internals/query/types/accumulators';\nimport { QueryExpression } from './expressions';\n\ntype AccumulatorKeys = typeof accumulatorExprKeys[number] | typeof accumulatorNoExprKeys[number];\n\nexport class QueryAccumulator {\n\n type: AccumulatorKeys;\n expr?: QueryExpression;\n\n static decode(query: TQueryAccumulator): QueryAccumulator {\n for (const [key, expr] of _.toPairs(query)) {\n if (_.includes(accumulatorExprKeys, key)) {\n return new QueryAccumulator(key as AccumulatorKeys, QueryExpression.decode(expr as any ?? [], false));\n } else if (_.includes(accumulatorNoExprKeys, key)) {\n return new QueryAccumulator(key as AccumulatorKeys);\n } else {\n throw Error('Invalid expression');\n }\n }\n throw Error('Invalid expression');\n }\n\n constructor(type: AccumulatorKeys, expr?: QueryExpression) {\n this.type = type;\n this.expr = expr;\n }\n\n simplify() {\n return new QueryAccumulator(this.type, this.expr?.simplify());\n }\n\n keyPaths() {\n return this.expr?.keyPaths() ?? [];\n }\n\n mapKey(callback: (key: string) => string) {\n return new QueryAccumulator(this.type, this.expr?.mapKey(callback));\n }\n\n}\n","//\n// validator.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { DecodedBaseQuery, DecodedQuery, FindOptions, DecodedSortOption, RelationOptions } from '../../storage';\nimport { QueryCoditionalSelector, QueryFieldSelector, QuerySelector } from './parser';\nimport { TSchema, _typeof, isPointer, isPrimitive, isRelation, isShape, isVector, shapePaths } from '../../../internals/schema';\nimport { ProtoService } from '../../proto';\nimport { TQueryBaseOptions, TSortOption } from '../../../internals/query/base';\nimport { isPrimitiveValue } from '../../../internals/object';\nimport { TObject } from '../../../internals/object';\nimport { PVK } from '../../../internals/private';\nimport { TQuerySelector } from '../../../internals/query/types/selectors';\nimport { QueryExpression } from './parser/expressions';\nimport { TQueryAccumulator } from '../../../internals/query/types/accumulators';\nimport { QueryAccumulator } from './parser/accumulators';\n\nexport const recursiveCheck = (x: any, stack: any[]) => {\n if (_.indexOf(stack, x) !== -1) throw Error('Recursive data detected');\n if (_.isRegExp(x) || isPrimitiveValue(x) || x instanceof TObject) return;\n const children = _.isArray(x) ? x : _.values(x);\n children.forEach(v => recursiveCheck(v, [...stack, x]));\n}\n\nexport const resolveDataType = (\n schema: Record<string, TSchema>,\n classname: string,\n path: string,\n) => {\n let fields = schema[classname].fields;\n let last;\n for (const key of _.toPath(path)) {\n const dataType = fields[key];\n if (_.isNil(dataType)) throw Error(`Invalid path: ${path}`);\n if (isPrimitive(dataType) || isVector(dataType)) return dataType;\n if (isShape(dataType)) {\n fields = dataType.shape;\n continue;\n }\n if (_.isNil(schema[dataType.target])) throw Error(`Invalid path: ${path}`);\n fields = schema[dataType.target].fields;\n last = dataType;\n }\n return last;\n}\n\nexport const resolveColumn = (\n schema: Record<string, TSchema>,\n className: string,\n path: string,\n) => {\n const _schema = schema[className] ?? {};\n let [colname, ...subpath] = path.split('.');\n let dataType = _schema.fields[colname];\n while (dataType && !_.isEmpty(subpath) && isShape(dataType)) {\n const [key, ...remain] = subpath;\n if (!dataType.shape[key]) break;\n dataType = dataType.shape[key];\n colname = `${colname}.${key}`;\n subpath = remain;\n }\n return {\n paths: [colname, ...subpath],\n dataType,\n };\n}\n\ntype QueryValidatorOption = {\n master: boolean;\n disableSecurity: boolean;\n};\n\nexport class QueryValidator<E> {\n\n proto: ProtoService<E>\n acls: string[];\n options: QueryValidatorOption;\n\n static patterns = {\n path: /^[a-z_][\\w-]*(\\[\\d+\\]|\\.\\d*|\\.[a-z_][\\w-]*)*$/gi,\n className: /^[a-z_][\\w]*$/gi,\n fieldName: /^[a-z_][\\w-]*$/gi,\n digits: /^\\d+$/g,\n }\n\n _rperm(className: string) {\n if (this.options.master) return [];\n const check = _.intersection(this.schema[className]?.additionalObjectPermissions?.read, this.acls);\n if (!_.isEmpty(check)) return [];\n return [{ _rperm: { $intersect: this.acls } }];\n }\n _wperm(className: string) {\n if (this.options.master) return [];\n const check = _.intersection(this.schema[className]?.additionalObjectPermissions?.update, this.acls);\n if (!_.isEmpty(check)) return [];\n return [{ _wperm: { $intersect: this.acls } }];\n }\n _expiredAt = { $or: [{ _expired_at: { $eq: null } }, { _expired_at: { $gt: new Date() } }] };\n\n constructor(\n proto: ProtoService<E>,\n acls: string[],\n options: QueryValidatorOption,\n ) {\n this.proto = proto;\n this.acls = _.uniq(['*', ...acls]);\n this.options = options;\n }\n\n get schema() {\n return this.proto.schema;\n }\n\n get objectIdSize() {\n return this.proto[PVK].options.objectIdSize;\n }\n\n static recursiveCheck(...x: any[]) {\n recursiveCheck(x, []);\n }\n\n validateKeyPerm(\n key: string,\n type: keyof TSchema.FLPs,\n schema: TSchema,\n ) {\n key = _.first(key?.split('.')) ?? key;\n if (_.isEmpty(key) || (!_.has(schema.fields, key) && !TObject.defaultKeys.includes(key))) throw Error(`Invalid key: ${key}`);\n if (type === 'read' && TObject.defaultKeys.includes(key)) return true;\n if (type !== 'read' && TObject.defaultReadonlyKeys.includes(key)) return false;\n if (!this.options.disableSecurity && _.includes(schema.secureFields, key)) return false;\n return this.options.master || !_.every(schema.fieldLevelPermissions?.[key]?.[type] ?? ['*'], x => !_.includes(this.acls, x));\n }\n\n validateCLPs(\n className: string,\n ...keys: (keyof TSchema.CLPs)[]\n ) {\n if (!_.has(this.schema, className)) throw Error('No permission');\n return this.options.master || this.proto[PVK].validateCLPs(className, this.acls, keys);\n }\n\n validateForeignField(dataType: TSchema.RelationType, type: keyof TSchema.FLPs, errorMeg: string) {\n if (_.isNil(dataType.foreignField)) return;\n const foreignField = resolveDataType(this.schema, dataType.target, dataType.foreignField);\n if (_.isNil(foreignField) || _.isString(foreignField)) throw Error(errorMeg);\n if (isPrimitive(foreignField)) throw Error(errorMeg);\n if (foreignField.type === 'relation' && !_.isNil(foreignField.foreignField)) throw Error(errorMeg);\n if (!this.validateKeyPerm(dataType.foreignField, type, this.schema[dataType.target])) throw Error('No permission');\n }\n\n validateKey(\n className: string,\n key: string | string[],\n type: keyof TSchema.FLPs,\n validator: RegExp,\n ): boolean {\n\n const schema = this.schema[className] ?? {};\n const _key = _.isArray(key) ? key.join('.') : key;\n if (!_key.match(validator)) throw Error(`Invalid key: ${_key}`);\n\n const [colname, ..._subpath] = _.toPath(_key);\n if (!this.validateKeyPerm(colname, type, schema)) return false;\n if (_.isEmpty(_subpath) && TObject.defaultKeys.includes(colname)) return true;\n if (_.isEmpty(_subpath)) return true;\n\n const { paths: [_colname, ...subpath], dataType } = resolveColumn(this.schema, className, _key);\n const isElem = _.first(subpath)?.match(QueryValidator.patterns.digits);\n if (isElem) {\n if (dataType === 'array' || dataType === 'string[]') return true;\n if (!_.isString(dataType) && dataType.type !== 'relation') return false;\n }\n\n if (isPrimitive(dataType)) return true;\n if (isVector(dataType)) return true;\n\n const relations: (TSchema.PointerType | TSchema.RelationType)[] = [];\n\n if (isShape(dataType)) {\n for (const { type } of shapePaths(dataType)) {\n if (!isPrimitive(type) && !isVector(type)) relations.push(type);\n }\n } else {\n relations.push(dataType);\n }\n\n for (const relation of relations) {\n if (_.isNil(this.schema[relation.target])) return false;\n if (type === 'read' && !this.validateCLPs(relation.target, 'get')) return false;\n if (relation.type === 'relation') this.validateForeignField(relation, type, `Invalid key: ${_key}`);\n }\n\n if (isShape(dataType)) {\n if (!_.isEmpty(subpath)) throw Error(`Invalid key: ${_key}`);\n return true;\n }\n\n const _sub = isElem ? subpath.slice(1) : subpath;\n return _.isEmpty(_sub) || this.validateKey(dataType.target, _sub, type, validator);\n }\n\n validateFields<T extends Record<string, any>>(\n className: string,\n values: T,\n type: keyof TSchema.FLPs,\n validator: RegExp,\n ) {\n const _values = { ...values };\n for (const key of _.keys(_values)) {\n if (!this.validateKey(className, key, type, validator)) throw Error('No permission');\n }\n return _values;\n }\n\n decodeGroupMatches(className: string, groupMatches: Record<string, Record<string, TQueryAccumulator>>): Record<string, Record<string, QueryAccumulator>> {\n const result = _.mapValues(groupMatches, m => _.mapValues(m, x => QueryAccumulator.decode(x).simplify()));\n for (const [colname, group] of _.entries(result)) {\n const dataType = resolveDataType(this.schema, className, colname);\n if (!dataType || !isRelation(dataType)) throw Error(`Invalid relation key: ${colname}`);\n for (const key of _.keys(group)) {\n if (!key.match(QueryValidator.patterns.fieldName)) throw Error(`Invalid field name: ${key}`);\n }\n }\n return result;\n }\n\n decodeIncludes(className: string, includes: string[], groupMatches: Record<string, Record<string, QueryAccumulator>>): string[] {\n\n const schema = this.schema[className] ?? {};\n\n const _includes: string[] = [];\n const populates: Record<string, {\n className: string;\n subpaths: string[];\n groupMatches: Record<string, Record<string, QueryAccumulator>>;\n }> = {};\n\n for (const include of includes) {\n if (include === '*') {\n const primitive = _.pickBy(schema.fields, (v, k) => isPrimitive(v) && this.validateKeyPerm(k, 'read', schema));\n const shapedObject = _.pickBy(schema.fields, (v, k) => isShape(v) && this.validateKeyPerm(k, 'read', schema));\n _includes.push(\n ..._.keys(primitive),\n ..._.flatMap(shapedObject, (v, k) => _.flatMap(shapePaths(v as any), x => isPrimitive(x.type) ? [`${k}.${x.path}`] : [])),\n );\n } else {\n const { paths: [colname, ...subpath], dataType } = resolveColumn(this.schema, className, include);\n if (!this.validateKeyPerm(colname, 'read', schema)) throw Error('No permission');\n\n if (isPointer(dataType) || isRelation(dataType)) {\n if (!this.validateCLPs(dataType.target, 'get')) throw Error('No permission');\n if (dataType.type === 'relation') this.validateForeignField(dataType, 'read', `Invalid include: ${include}`);\n\n const isDigit = _.first(subpath)?.match(QueryValidator.patterns.digits);\n const _subpath = isRelation(dataType) && isDigit ? _.slice(subpath, 1) : subpath;\n\n populates[colname] = populates[colname] ?? { className: dataType.target, subpaths: [], groupMatches: {} };\n const s = _.first(_subpath);\n if (!s || !groupMatches[colname]?.[s]) {\n populates[colname].subpaths.push(_.isEmpty(_subpath) ? '*' : _subpath.join('.'));\n populates[colname].groupMatches = _.mapKeys(_.pickBy(groupMatches, (x, k) => _.startsWith(k, `${colname}.`)), (x, k) => k.slice(colname.length + 1));\n }\n\n } else if (_.isEmpty(subpath) && isShape(dataType)) {\n\n for (const { path, type } of shapePaths(dataType)) {\n if (isPrimitive(type) || isVector(type)) {\n _includes.push(`${colname}.${path}`);\n } else {\n\n if (!this.validateCLPs(type.target, 'get')) throw Error('No permission');\n if (type.type === 'relation') this.validateForeignField(type, 'read', `Invalid include: ${include}`);\n\n populates[`${colname}.${path}`] = populates[`${colname}.${path}`] ?? { className: type.target, subpaths: [], groupMatches: {} };\n populates[`${colname}.${path}`].subpaths.push('*');\n populates[`${colname}.${path}`].groupMatches = _.mapKeys(_.pickBy(groupMatches, (x, k) => _.startsWith(k, `${colname}.${path}.`)), (x, k) => k.slice(`${colname}.${path}`.length + 1));\n }\n }\n\n } else if (_.isEmpty(subpath) || _.includes(['object', 'array'], _typeof(dataType))) {\n _includes.push(colname);\n } else {\n throw Error(`Invalid include: ${include}`);\n }\n }\n }\n\n for (const [key, populate] of _.toPairs(populates)) {\n const subpaths = this.decodeIncludes(populate.className, populate.subpaths, populate.groupMatches);\n _includes.push(..._.map(subpaths, x => `${key}.${x}`));\n }\n\n _includes.push(...TObject.defaultKeys);\n return _.uniq(_includes);\n }\n\n decodeSort(sort: Record<string, 1 | -1> | TSortOption[]): Record<string, 1 | -1> | DecodedSortOption[] {\n if (_.isArray(sort)) {\n return _.map(sort, s => ({\n order: s.order,\n expr: QueryExpression.decode(s.expr, false).simplify(),\n }))\n }\n return sort;\n }\n\n decodeMatches(className: string, matches: Record<string, TQueryBaseOptions>, includes: string[]): Record<string, DecodedBaseQuery> {\n\n const schema = this.schema[className] ?? {};\n const _matches: Record<string, DecodedBaseQuery> = {};\n\n const _includes = _.groupBy(_.map(includes, x => resolveColumn(this.schema, className, x)), ({ paths: [colname] }) => colname);\n\n for (const [colname, [{ dataType }]] of _.entries(_includes)) {\n if (!this.validateKeyPerm(colname, 'read', schema)) continue;\n if (isPrimitive(dataType) || isVector(dataType) || isShape(dataType)) continue;\n _matches[colname] = {\n matches: this.decodeMatches(\n dataType.target, {},\n includes.filter(x => x.startsWith(`${colname}.`)).map(x => x.slice(colname.length + 1)),\n ),\n };\n }\n\n for (const [colname, match] of _.toPairs(matches)) {\n if (!this.validateKeyPerm(colname, 'read', schema)) throw Error('No permission');\n\n const { paths: [_colname, ...subpath], dataType } = resolveColumn(this.schema, className, colname);\n\n if (isPointer(dataType) && !_.isEmpty(subpath)) {\n _matches[_colname] = {\n matches: this.decodeMatches(\n dataType.target, { [subpath.join('.')]: match },\n includes.filter(x => x.startsWith(`${_colname}.`)).map(x => x.slice(_colname.length + 1)),\n ),\n };\n } else if (isRelation(dataType)) {\n if (!this.validateCLPs(dataType.target, 'get')) throw Error('No permission');\n this.validateForeignField(dataType, 'read', `Invalid match: ${colname}`);\n const groupMatches = this.decodeGroupMatches(dataType.target, match.groupMatches ?? {});\n _matches[_colname] = {\n ...match,\n groupMatches,\n filter: QuerySelector.decode(_.castArray<TQuerySelector>(match.filter)).simplify(),\n matches: this.decodeMatches(\n dataType.target, match.matches ?? {},\n includes.filter(x => x.startsWith(`${_colname}.`)).map(x => x.slice(_colname.length + 1)),\n ),\n sort: match.sort && this.decodeSort(match.sort),\n };\n } else {\n throw Error(`Invalid match: ${colname}`);\n }\n }\n\n return _matches;\n }\n\n validateRelatedBy(className: string | null, relation: { className: string; key: string; }) {\n\n if (!this.validateCLPs(relation.className, 'get')) throw Error('No permission');\n if (!this.validateKey(relation.className, relation.key, 'read', QueryValidator.patterns.path)) throw Error('No permission');\n\n const { dataType } = resolveColumn(this.schema, relation.className, relation.key);\n if (!isPointer(dataType) && !isRelation(dataType)) throw Error(`Invalid relation key: ${relation.key}`);\n if (className && dataType.target !== className) throw Error(`Invalid relation key: ${relation.key}`);\n\n if (isRelation(dataType) && dataType.foreignField) {\n this.validateForeignField(dataType, 'read', `Invalid relation key: ${relation.key}`);\n this.validateRelatedBy(null, { className: dataType.target, key: dataType.foreignField });\n }\n }\n\n decodeQuery<Q extends FindOptions & RelationOptions>(query: Q, action: keyof TSchema.ACLs): DecodedQuery<Q> {\n\n if ('relatedBy' in query && query.relatedBy) this.validateRelatedBy(query.className, query.relatedBy);\n\n const filter = QuerySelector.decode([\n ...action === 'read' ? this._rperm(query.className) : this._wperm(query.className),\n ..._.castArray<TQuerySelector>(query.filter),\n this._expiredAt,\n ]).simplify();\n\n const groupMatches = this.decodeGroupMatches(query.className, query.groupMatches ?? {});\n\n const matchKeyPaths = (\n matches: Record<string, TQueryBaseOptions>\n ): string[] => _.flatMap(matches, (match, key) => [\n ..._.keys(match.sort),\n ...QuerySelector.decode(match.filter ?? []).keyPaths(),\n ...matchKeyPaths(match.matches ?? {}),\n ..._.keys(match.groupMatches),\n ..._.flatMap(_.values(match.groupMatches), x => QueryAccumulator.decode(x).keyPaths()),\n ].map(x => `${key}.${x}`));\n\n const sort = query.sort && this.decodeSort(query.sort);\n\n const keyPaths = _.uniq([\n ...query.includes ?? ['*'],\n ..._.isArray(sort) ? _.flatMap(sort, s => s.expr.keyPaths()) : _.keys(sort),\n ...filter.keyPaths(),\n ...matchKeyPaths(query.matches ?? {}),\n ..._.keys(groupMatches),\n ..._.flatMap(_.values(groupMatches), m => _.flatMap(_.values(m), x => x.keyPaths())),\n ]);\n\n const includes = this.decodeIncludes(query.className, keyPaths, groupMatches);\n const matches = this.decodeMatches(query.className, query.matches ?? {}, includes);\n\n return {\n ...query,\n groupMatches,\n filter,\n matches,\n includes,\n sort,\n objectIdSize: this.objectIdSize,\n extraFilter: (className) => QuerySelector.decode([...this._rperm(className), this._expiredAt]).simplify(),\n };\n }\n\n isGetMethod(query: QuerySelector) {\n\n const objectIds = [];\n\n if (query instanceof QueryCoditionalSelector && query.type === '$and') {\n for (const expr of query.exprs) {\n if (\n expr instanceof QueryFieldSelector &&\n expr.field === '_id' &&\n expr.expr.type === '$eq'\n ) {\n if (!_.isString(expr.expr.value)) return false;\n objectIds.push(expr.expr.value);\n }\n }\n } else if (\n query instanceof QueryFieldSelector &&\n query.field === '_id' &&\n query.expr.type === '$eq'\n ) {\n if (!_.isString(query.expr.value)) return false;\n objectIds.push(query.expr.value);\n }\n\n return _.uniq(objectIds).length === 1;\n }\n\n}\n","//\n// random.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { randomBytes } from '@o2ter/crypto-js';\n\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\n\nexport const generateId = (size: number): string => {\n let id = '';\n for (const x of randomBytes(size)) {\n id += chars[x % chars.length];\n }\n return id;\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIO,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU;AACrD,MAAM,qBAAqB,GAAG,CAAC,QAAQ,CAAU;AAQ3C,MAAA,mBAAmB,GAAG;AACjC,IAAA,QAAQ,EAAE,QAAQ;AAClB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