proto.io 0.0.213 → 0.0.215

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