proto.io 0.0.172 → 0.0.174
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/database.js +2 -2
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/filesystem.d.ts +2 -2
- package/dist/adapters/file/google-cloud-storage.d.ts +2 -2
- package/dist/adapters/storage/progres.d.ts +9 -2
- package/dist/adapters/storage/progres.js +58 -5
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +58 -5
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +2 -2
- package/dist/client.mjs +3 -3
- package/dist/index.d.ts +75 -3
- package/dist/index.js +242 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +243 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-BYbMU-Ao.mjs → index--ifyu-GL.mjs} +139 -1
- package/dist/internals/index--ifyu-GL.mjs.map +1 -0
- package/dist/internals/{index-B1wqSio6.mjs → index-C3fbOqmn.mjs} +2 -2
- package/dist/internals/{index-B1wqSio6.mjs.map → index-C3fbOqmn.mjs.map} +1 -1
- package/dist/internals/index-CE5tdYK8.d.ts +1816 -0
- package/dist/internals/index-CE5tdYK8.d.ts.map +1 -0
- package/dist/internals/{index-K0jhERvZ.d.ts → index-CGX3qcjQ.d.ts} +2 -2
- package/dist/internals/index-CGX3qcjQ.d.ts.map +1 -0
- package/dist/internals/{index-CVutVPmd.js → index-DXuW8UiB.js} +139 -1
- package/dist/internals/index-DXuW8UiB.js.map +1 -0
- package/dist/internals/{index-CzfsyXvb.js → index-Dc3V_Bzw.js} +2 -2
- package/dist/internals/{index-CzfsyXvb.js.map → index-Dc3V_Bzw.js.map} +1 -1
- package/dist/internals/{index-D0hHgn2P.mjs → index-R0gbIGc-.mjs} +289 -2
- package/dist/internals/index-R0gbIGc-.mjs.map +1 -0
- package/dist/internals/{index-BJP46VGq.js → index-S_gTMQBh.js} +289 -2
- package/dist/internals/index-S_gTMQBh.js.map +1 -0
- package/dist/internals/{index-DchUjNEf.d.ts → index-uwXdnxqN.d.ts} +2 -2
- package/dist/internals/index-uwXdnxqN.d.ts.map +1 -0
- package/dist/internals/{random-BCpwYpyw.mjs → random-DPRG8oW6.mjs} +3 -3
- package/dist/internals/{random-BCpwYpyw.mjs.map → random-DPRG8oW6.mjs.map} +1 -1
- package/dist/internals/{random-Dytum6Nh.js → random-DVOUDDGg.js} +3 -3
- package/dist/internals/{random-Dytum6Nh.js.map → random-DVOUDDGg.js.map} +1 -1
- package/package.json +1 -1
- package/dist/internals/index-BJP46VGq.js.map +0 -1
- package/dist/internals/index-BYbMU-Ao.mjs.map +0 -1
- package/dist/internals/index-BhWRmBiq.d.ts +0 -726
- package/dist/internals/index-BhWRmBiq.d.ts.map +0 -1
- package/dist/internals/index-CVutVPmd.js.map +0 -1
- package/dist/internals/index-D0hHgn2P.mjs.map +0 -1
- package/dist/internals/index-DchUjNEf.d.ts.map +0 -1
- package/dist/internals/index-K0jhERvZ.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TObject, d as decodeUpdateOp } from './index-
|
|
1
|
+
import { T as TObject, d as decodeUpdateOp } from './index--ifyu-GL.mjs';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import { Decimal } from 'decimal.js';
|
|
4
4
|
import { prototypes, asyncStream, isBinaryData, isReadableStream, isBlob, base64ToBuffer, iterableToStream } from '@o2ter/utils-js';
|
|
@@ -45,9 +45,17 @@ const mergeOpts = (lhs, rhs) => {
|
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Base class for query filters.
|
|
50
|
+
*/
|
|
48
51
|
class TQueryFilterBase {
|
|
49
52
|
/** @internal */
|
|
50
53
|
[PVK] = { options: {} };
|
|
54
|
+
/**
|
|
55
|
+
* Applies a filter to the query.
|
|
56
|
+
* @param filter - The filter to apply.
|
|
57
|
+
* @returns The current instance for chaining.
|
|
58
|
+
*/
|
|
51
59
|
filter(filter) {
|
|
52
60
|
if (_.isNil(this[PVK].options.filter)) {
|
|
53
61
|
this[PVK].options.filter = filter;
|
|
@@ -60,70 +68,193 @@ class TQueryFilterBase {
|
|
|
60
68
|
}
|
|
61
69
|
return this;
|
|
62
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Applies an equality filter to the query.
|
|
73
|
+
* @param key - The key to filter.
|
|
74
|
+
* @param value - The value to filter.
|
|
75
|
+
* @returns The current instance for chaining.
|
|
76
|
+
*/
|
|
63
77
|
equalTo(key, value) {
|
|
64
78
|
return this.filter({ [key]: { $eq: value ?? null } });
|
|
65
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Applies a not equal filter to the query.
|
|
82
|
+
* @param key - The key to filter.
|
|
83
|
+
* @param value - The value to filter.
|
|
84
|
+
* @returns The current instance for chaining.
|
|
85
|
+
*/
|
|
66
86
|
notEqualTo(key, value) {
|
|
67
87
|
return this.filter({ [key]: { $ne: value ?? null } });
|
|
68
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Applies a less than filter to the query.
|
|
91
|
+
* @param key - The key to filter.
|
|
92
|
+
* @param value - The value to filter.
|
|
93
|
+
* @returns The current instance for chaining.
|
|
94
|
+
*/
|
|
69
95
|
lessThan(key, value) {
|
|
70
96
|
return this.filter({ [key]: { $lt: value ?? null } });
|
|
71
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Applies a greater than filter to the query.
|
|
100
|
+
* @param key - The key to filter.
|
|
101
|
+
* @param value - The value to filter.
|
|
102
|
+
* @returns The current instance for chaining.
|
|
103
|
+
*/
|
|
72
104
|
greaterThan(key, value) {
|
|
73
105
|
return this.filter({ [key]: { $gt: value ?? null } });
|
|
74
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Applies a less than or equal to filter to the query.
|
|
109
|
+
* @param key - The key to filter.
|
|
110
|
+
* @param value - The value to filter.
|
|
111
|
+
* @returns The current instance for chaining.
|
|
112
|
+
*/
|
|
75
113
|
lessThanOrEqualTo(key, value) {
|
|
76
114
|
return this.filter({ [key]: { $lte: value ?? null } });
|
|
77
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Applies a greater than or equal to filter to the query.
|
|
118
|
+
* @param key - The key to filter.
|
|
119
|
+
* @param value - The value to filter.
|
|
120
|
+
* @returns The current instance for chaining.
|
|
121
|
+
*/
|
|
78
122
|
greaterThanOrEqualTo(key, value) {
|
|
79
123
|
return this.filter({ [key]: { $gte: value ?? null } });
|
|
80
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Applies a pattern filter to the query.
|
|
127
|
+
* @param key - The key to filter.
|
|
128
|
+
* @param value - The pattern to filter.
|
|
129
|
+
* @returns The current instance for chaining.
|
|
130
|
+
*/
|
|
81
131
|
pattern(key, value) {
|
|
82
132
|
return this.filter({ [key]: { $pattern: value ?? null } });
|
|
83
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Applies a starts with filter to the query.
|
|
136
|
+
* @param key - The key to filter.
|
|
137
|
+
* @param value - The value to filter.
|
|
138
|
+
* @returns The current instance for chaining.
|
|
139
|
+
*/
|
|
84
140
|
startsWith(key, value) {
|
|
85
141
|
return this.filter({ [key]: { $starts: value ?? null } });
|
|
86
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Applies an ends with filter to the query.
|
|
145
|
+
* @param key - The key to filter.
|
|
146
|
+
* @param value - The value to filter.
|
|
147
|
+
* @returns The current instance for chaining.
|
|
148
|
+
*/
|
|
87
149
|
endsWith(key, value) {
|
|
88
150
|
return this.filter({ [key]: { $ends: value ?? null } });
|
|
89
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Applies a size filter to the query.
|
|
154
|
+
* @param key - The key to filter.
|
|
155
|
+
* @param value - The value to filter.
|
|
156
|
+
* @returns The current instance for chaining.
|
|
157
|
+
*/
|
|
90
158
|
size(key, value) {
|
|
91
159
|
return this.filter({ [key]: { $size: value } });
|
|
92
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Applies an empty filter to the query.
|
|
163
|
+
* @param key - The key to filter.
|
|
164
|
+
* @returns The current instance for chaining.
|
|
165
|
+
*/
|
|
93
166
|
empty(key) {
|
|
94
167
|
return this.filter({ [key]: { $empty: true } });
|
|
95
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Applies a not empty filter to the query.
|
|
171
|
+
* @param key - The key to filter.
|
|
172
|
+
* @returns The current instance for chaining.
|
|
173
|
+
*/
|
|
96
174
|
notEmpty(key) {
|
|
97
175
|
return this.filter({ [key]: { $empty: false } });
|
|
98
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Filters the query to include only documents where the specified key contains any of the specified values.
|
|
179
|
+
* @param key - The key to check for values.
|
|
180
|
+
* @param value - The array of values to check for.
|
|
181
|
+
* @returns The current instance for chaining.
|
|
182
|
+
*/
|
|
99
183
|
containsIn(key, value) {
|
|
100
184
|
return this.filter({ [key]: { $in: value } });
|
|
101
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Filters the query to exclude documents where the specified key contains any of the specified values.
|
|
188
|
+
* @param key - The key to check for values.
|
|
189
|
+
* @param value - The array of values to exclude.
|
|
190
|
+
* @returns The current instance for chaining.
|
|
191
|
+
*/
|
|
102
192
|
notContainsIn(key, value) {
|
|
103
193
|
return this.filter({ [key]: { $nin: value } });
|
|
104
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Filters the query to include only documents where the specified key is a subset of the specified values.
|
|
197
|
+
* @param key - The key to check for subset.
|
|
198
|
+
* @param value - The array of values to check against.
|
|
199
|
+
* @returns The current instance for chaining.
|
|
200
|
+
*/
|
|
105
201
|
isSubset(key, value) {
|
|
106
202
|
return this.filter({ [key]: { $subset: value } });
|
|
107
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Filters the query to include only documents where the specified key is a superset of the specified values.
|
|
206
|
+
* @param key - The key to check for superset.
|
|
207
|
+
* @param value - The array of values to check against.
|
|
208
|
+
* @returns The current instance for chaining.
|
|
209
|
+
*/
|
|
108
210
|
isSuperset(key, value) {
|
|
109
211
|
return this.filter({ [key]: { $superset: value } });
|
|
110
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Filters the query to include only documents where the specified key is disjoint from the specified values.
|
|
215
|
+
* @param key - The key to check for disjoint.
|
|
216
|
+
* @param value - The array of values to check against.
|
|
217
|
+
* @returns The current instance for chaining.
|
|
218
|
+
*/
|
|
111
219
|
isDisjoint(key, value) {
|
|
112
220
|
return this.filter({ [key]: { $not: { $intersect: value } } });
|
|
113
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Filters the query to include only documents where the specified key intersects with the specified values.
|
|
224
|
+
* @param key - The key to check for intersection.
|
|
225
|
+
* @param value - The array of values to check against.
|
|
226
|
+
* @returns The current instance for chaining.
|
|
227
|
+
*/
|
|
114
228
|
isIntersect(key, value) {
|
|
115
229
|
return this.filter({ [key]: { $intersect: value } });
|
|
116
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Filters the query to include only documents where every element of the specified key matches the provided callback query.
|
|
233
|
+
* @param key - The key to check for every element.
|
|
234
|
+
* @param callback - The callback query to apply to each element.
|
|
235
|
+
* @returns The current instance for chaining.
|
|
236
|
+
*/
|
|
117
237
|
every(key, callback) {
|
|
118
238
|
const query = new TQueryFilterBase();
|
|
119
239
|
callback(query);
|
|
120
240
|
return this.filter({ [key]: { $every: { $and: _.castArray(query[PVK].options.filter) } } });
|
|
121
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Filters the query to include only documents where some elements of the specified key match the provided callback query.
|
|
244
|
+
* @param key - The key to check for some elements.
|
|
245
|
+
* @param callback - The callback query to apply to each element.
|
|
246
|
+
* @returns The current instance for chaining.
|
|
247
|
+
*/
|
|
122
248
|
some(key, callback) {
|
|
123
249
|
const query = new TQueryFilterBase();
|
|
124
250
|
callback(query);
|
|
125
251
|
return this.filter({ [key]: { $some: { $and: _.castArray(query[PVK].options.filter) } } });
|
|
126
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Filters the query to include only documents that match all of the provided callback queries.
|
|
255
|
+
* @param callbacks - The callback queries to apply.
|
|
256
|
+
* @returns The current instance for chaining.
|
|
257
|
+
*/
|
|
127
258
|
and(...callbacks) {
|
|
128
259
|
return this.filter({
|
|
129
260
|
$and: _.flatMap(_.flatten(callbacks), callback => {
|
|
@@ -133,6 +264,11 @@ class TQueryFilterBase {
|
|
|
133
264
|
}),
|
|
134
265
|
});
|
|
135
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Filters the query to include only documents that match any of the provided callback queries.
|
|
269
|
+
* @param callbacks - The callback queries to apply.
|
|
270
|
+
* @returns The current instance for chaining.
|
|
271
|
+
*/
|
|
136
272
|
or(...callbacks) {
|
|
137
273
|
return this.filter({
|
|
138
274
|
$or: _.map(_.flatten(callbacks), callback => {
|
|
@@ -144,6 +280,11 @@ class TQueryFilterBase {
|
|
|
144
280
|
}),
|
|
145
281
|
});
|
|
146
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Filters the query to include only documents that do not match any of the provided callback queries.
|
|
285
|
+
* @param callbacks - The callback queries to apply.
|
|
286
|
+
* @returns The current instance for chaining.
|
|
287
|
+
*/
|
|
147
288
|
nor(...callbacks) {
|
|
148
289
|
return this.filter({
|
|
149
290
|
$nor: _.map(_.flatten(callbacks), callback => {
|
|
@@ -159,22 +300,43 @@ class TQueryFilterBase {
|
|
|
159
300
|
class TQueryBase extends TQueryFilterBase {
|
|
160
301
|
/** @internal */
|
|
161
302
|
[PVK] = { options: {} };
|
|
303
|
+
/**
|
|
304
|
+
* Sorts the query results.
|
|
305
|
+
* @param sort - The sorting criteria.
|
|
306
|
+
* @returns The current instance for chaining.
|
|
307
|
+
*/
|
|
162
308
|
sort(sort) {
|
|
163
309
|
this[PVK].options.sort = sort;
|
|
164
310
|
return this;
|
|
165
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Skips the specified number of results.
|
|
314
|
+
* @param skip - The number of results to skip.
|
|
315
|
+
* @returns The current instance for chaining.
|
|
316
|
+
*/
|
|
166
317
|
skip(skip) {
|
|
167
318
|
if (!_.isSafeInteger(skip) || skip < 0)
|
|
168
319
|
throw Error('Invalid skip number');
|
|
169
320
|
this[PVK].options.skip = skip;
|
|
170
321
|
return this;
|
|
171
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Limits the number of results.
|
|
325
|
+
* @param limit - The maximum number of results to return.
|
|
326
|
+
* @returns The current instance for chaining.
|
|
327
|
+
*/
|
|
172
328
|
limit(limit) {
|
|
173
329
|
if (!_.isSafeInteger(limit) || limit < 0)
|
|
174
330
|
throw Error('Invalid limit number');
|
|
175
331
|
this[PVK].options.limit = limit;
|
|
176
332
|
return this;
|
|
177
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Performs a nested query on a specific key.
|
|
336
|
+
* @param key - The key to match.
|
|
337
|
+
* @param callback - The callback function to execute.
|
|
338
|
+
* @returns The current instance for chaining.
|
|
339
|
+
*/
|
|
178
340
|
match(key, callback) {
|
|
179
341
|
const query = new TQueryBase();
|
|
180
342
|
callback(query);
|
|
@@ -217,27 +379,62 @@ class TQueryBase extends TQueryFilterBase {
|
|
|
217
379
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
218
380
|
// THE SOFTWARE.
|
|
219
381
|
//
|
|
382
|
+
/**
|
|
383
|
+
* Abstract base class for queries.
|
|
384
|
+
*/
|
|
220
385
|
class TQuery extends TQueryBase {
|
|
221
386
|
/** @internal */
|
|
222
387
|
[PVK] = { options: {} };
|
|
388
|
+
/**
|
|
389
|
+
* Adds fields to include in the query.
|
|
390
|
+
* @param includes - The fields to include.
|
|
391
|
+
* @returns The query instance.
|
|
392
|
+
*/
|
|
223
393
|
includes(...includes) {
|
|
224
394
|
this[PVK].options.includes = this[PVK].options.includes ? [...this[PVK].options.includes, ...includes] : includes;
|
|
225
395
|
return this;
|
|
226
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Gets a record by its ID.
|
|
399
|
+
* @param id - The ID of the record.
|
|
400
|
+
* @param options - Extra options for the query.
|
|
401
|
+
* @returns A promise that resolves to the record or undefined.
|
|
402
|
+
*/
|
|
227
403
|
async get(id, options) {
|
|
228
404
|
return _.first(await this.clone().equalTo('_id', id).limit(1).find(options));
|
|
229
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* Gets the first record.
|
|
408
|
+
* @param options - Extra options for the query.
|
|
409
|
+
* @returns A promise that resolves to the first record or undefined.
|
|
410
|
+
*/
|
|
230
411
|
async first(options) {
|
|
231
412
|
return _.first(await this.clone().limit(1).find(options));
|
|
232
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Gets a random record.
|
|
416
|
+
* @param opts - Options for the random selection.
|
|
417
|
+
* @param options - Extra options for the query.
|
|
418
|
+
* @returns A promise that resolves to the random record or undefined.
|
|
419
|
+
*/
|
|
233
420
|
async randomOne(opts, options) {
|
|
234
421
|
return _.first(await this.clone().limit(1).random(opts, options));
|
|
235
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* Checks if any records exist.
|
|
425
|
+
* @param options - Extra options for the query.
|
|
426
|
+
* @returns A promise that resolves to a boolean indicating if any records exist.
|
|
427
|
+
*/
|
|
236
428
|
async exists(options) {
|
|
237
429
|
const query = this.clone();
|
|
238
430
|
this[PVK].options.includes = [];
|
|
239
431
|
return !_.isNil(await query.limit(1).find(options));
|
|
240
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* Iterates over each batch of records.
|
|
435
|
+
* @param callback - The callback to execute for each batch.
|
|
436
|
+
* @param options - Extra options for the query.
|
|
437
|
+
*/
|
|
241
438
|
async eachBatch(callback, options) {
|
|
242
439
|
const sorting = this[PVK].options.sort ?? {};
|
|
243
440
|
const batchSize = options?.batchSize ?? 100;
|
|
@@ -253,6 +450,7 @@ class TQuery extends TQueryBase {
|
|
|
253
450
|
const keys = _.keys(sorting);
|
|
254
451
|
let batch = [];
|
|
255
452
|
while (true) {
|
|
453
|
+
options?.abortSignal?.throwIfAborted();
|
|
256
454
|
const q = _.isEmpty(batch) ? query : query.clone()
|
|
257
455
|
.filter(keys.length > 1 ? {
|
|
258
456
|
$expr: {
|
|
@@ -270,6 +468,11 @@ class TQuery extends TQueryBase {
|
|
|
270
468
|
await callback(batch);
|
|
271
469
|
}
|
|
272
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Iterates over each record.
|
|
473
|
+
* @param callback - The callback to execute for each record.
|
|
474
|
+
* @param options - Extra options for the query.
|
|
475
|
+
*/
|
|
273
476
|
async each(callback, options) {
|
|
274
477
|
await this.eachBatch(async (batch) => {
|
|
275
478
|
for (const object of batch) {
|
|
@@ -362,22 +565,46 @@ class TUser extends TObject {
|
|
|
362
565
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
363
566
|
// THE SOFTWARE.
|
|
364
567
|
//
|
|
568
|
+
/**
|
|
569
|
+
* Class representing a Role.
|
|
570
|
+
* @extends TObject
|
|
571
|
+
*/
|
|
365
572
|
class TRole extends TObject {
|
|
366
573
|
constructor(attributes) {
|
|
367
574
|
super('Role', attributes);
|
|
368
575
|
}
|
|
576
|
+
/**
|
|
577
|
+
* Get the name of the role.
|
|
578
|
+
* @return {string | undefined} The name of the role.
|
|
579
|
+
*/
|
|
369
580
|
get name() {
|
|
370
581
|
return this.get('name');
|
|
371
582
|
}
|
|
583
|
+
/**
|
|
584
|
+
* Get the users associated with the role.
|
|
585
|
+
* @return {TUser[]} The users associated with the role.
|
|
586
|
+
*/
|
|
372
587
|
get users() {
|
|
373
588
|
return this.get('users') ?? [];
|
|
374
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* Set the users associated with the role.
|
|
592
|
+
* @param {TUser[]} value - The users to associate with the role.
|
|
593
|
+
*/
|
|
375
594
|
set users(value) {
|
|
376
595
|
this.set('users', value);
|
|
377
596
|
}
|
|
597
|
+
/**
|
|
598
|
+
* Get the roles associated with the role.
|
|
599
|
+
* @return {TRole[]} The roles associated with the role.
|
|
600
|
+
*/
|
|
378
601
|
get roles() {
|
|
379
602
|
return this.get('roles') ?? [];
|
|
380
603
|
}
|
|
604
|
+
/**
|
|
605
|
+
* Set the roles associated with the role.
|
|
606
|
+
* @param {TRole[]} value - The roles to associate with the role.
|
|
607
|
+
*/
|
|
381
608
|
set roles(value) {
|
|
382
609
|
this.set('roles', value);
|
|
383
610
|
}
|
|
@@ -407,19 +634,38 @@ class TRole extends TObject {
|
|
|
407
634
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
408
635
|
// THE SOFTWARE.
|
|
409
636
|
//
|
|
637
|
+
/**
|
|
638
|
+
* Class representing a file.
|
|
639
|
+
*/
|
|
410
640
|
class TFile extends TObject {
|
|
411
641
|
constructor(attributes) {
|
|
412
642
|
super('File', attributes);
|
|
413
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Gets the filename of the file.
|
|
646
|
+
* @returns The filename.
|
|
647
|
+
*/
|
|
414
648
|
get filename() {
|
|
415
649
|
return this.get('filename');
|
|
416
650
|
}
|
|
651
|
+
/**
|
|
652
|
+
* Gets the size of the file.
|
|
653
|
+
* @returns The size of the file.
|
|
654
|
+
*/
|
|
417
655
|
get size() {
|
|
418
656
|
return this.get('size');
|
|
419
657
|
}
|
|
658
|
+
/**
|
|
659
|
+
* Gets the type of the file.
|
|
660
|
+
* @returns The type of the file.
|
|
661
|
+
*/
|
|
420
662
|
get type() {
|
|
421
663
|
return this.get('type');
|
|
422
664
|
}
|
|
665
|
+
/**
|
|
666
|
+
* Gets the token of the file.
|
|
667
|
+
* @returns The token of the file.
|
|
668
|
+
*/
|
|
423
669
|
get token() {
|
|
424
670
|
return this.get('token');
|
|
425
671
|
}
|
|
@@ -653,6 +899,10 @@ const applyObjectMethods = (object, proto) => {
|
|
|
653
899
|
// THE SOFTWARE.
|
|
654
900
|
//
|
|
655
901
|
class ProtoType {
|
|
902
|
+
/**
|
|
903
|
+
* Checks if the server is online.
|
|
904
|
+
* @returns A promise that resolves to a boolean indicating if the server is online.
|
|
905
|
+
*/
|
|
656
906
|
async online() {
|
|
657
907
|
try {
|
|
658
908
|
const res = await axios({
|
|
@@ -666,14 +916,32 @@ class ProtoType {
|
|
|
666
916
|
return false;
|
|
667
917
|
}
|
|
668
918
|
}
|
|
919
|
+
/**
|
|
920
|
+
* Rebinds an object to the proto instance.
|
|
921
|
+
* @param object - The object to rebind.
|
|
922
|
+
* @returns The rebinded object.
|
|
923
|
+
*/
|
|
669
924
|
rebind(object) {
|
|
670
925
|
return applyObjectMethods(object, this);
|
|
671
926
|
}
|
|
927
|
+
/**
|
|
928
|
+
* Creates a new object.
|
|
929
|
+
* @param className - The name of the class to create.
|
|
930
|
+
* @param objectId - The ID of the object to create.
|
|
931
|
+
* @returns The created object.
|
|
932
|
+
*/
|
|
672
933
|
Object(className, objectId) {
|
|
673
934
|
const attrs = objectId ? { _id: objectId } : {};
|
|
674
935
|
const obj = isObjKey(className, TObjectTypes) ? new TObjectTypes[className](attrs) : new TObject(className, attrs);
|
|
675
936
|
return this.rebind(obj);
|
|
676
937
|
}
|
|
938
|
+
/**
|
|
939
|
+
* Creates a new file object.
|
|
940
|
+
* @param filename - The name of the file.
|
|
941
|
+
* @param data - The file data.
|
|
942
|
+
* @param type - The type of the file.
|
|
943
|
+
* @returns The created file object.
|
|
944
|
+
*/
|
|
677
945
|
File(filename, data, type) {
|
|
678
946
|
const file = this.Object('File');
|
|
679
947
|
file.set('filename', filename);
|
|
@@ -928,6 +1196,15 @@ class _ProtoClientQuery extends TQuery {
|
|
|
928
1196
|
...this._queryOptions,
|
|
929
1197
|
}, this._requestOpt(options));
|
|
930
1198
|
}
|
|
1199
|
+
updateMany(update, options) {
|
|
1200
|
+
return this._proto[PVK].request(this._proto, {
|
|
1201
|
+
operation: 'updateMany',
|
|
1202
|
+
context: options?.context ?? {},
|
|
1203
|
+
silent: options?.silent,
|
|
1204
|
+
update,
|
|
1205
|
+
...this._queryOptions,
|
|
1206
|
+
}, this._requestOpt(options));
|
|
1207
|
+
}
|
|
931
1208
|
upsertOne(update, setOnInsert, options) {
|
|
932
1209
|
return this._proto[PVK].request(this._proto, {
|
|
933
1210
|
operation: 'upsertOne',
|
|
@@ -938,6 +1215,16 @@ class _ProtoClientQuery extends TQuery {
|
|
|
938
1215
|
...this._queryOptions,
|
|
939
1216
|
}, this._requestOpt(options));
|
|
940
1217
|
}
|
|
1218
|
+
upsertMany(update, setOnInsert, options) {
|
|
1219
|
+
return this._proto[PVK].request(this._proto, {
|
|
1220
|
+
operation: 'upsertMany',
|
|
1221
|
+
context: options?.context ?? {},
|
|
1222
|
+
silent: options?.silent,
|
|
1223
|
+
update,
|
|
1224
|
+
setOnInsert,
|
|
1225
|
+
...this._queryOptions,
|
|
1226
|
+
}, this._requestOpt(options));
|
|
1227
|
+
}
|
|
941
1228
|
deleteOne(options) {
|
|
942
1229
|
return this._proto[PVK].request(this._proto, {
|
|
943
1230
|
operation: 'deleteOne',
|
|
@@ -1511,4 +1798,4 @@ class ProtoClient extends ProtoType {
|
|
|
1511
1798
|
}
|
|
1512
1799
|
|
|
1513
1800
|
export { AUTH_COOKIE_KEY as A, MASTER_USER_HEADER_NAME as M, ProtoType as P, TQuery as T, UPLOAD_TOKEN_HEADER_NAME as U, MASTER_PASS_HEADER_NAME as a, TUser as b, ProtoClient as c, deserialize as d, classExtends as e, isObject as f, isUser as g, isRole as h, isQuery as i, isFile as j, serialize as s };
|
|
1514
|
-
//# sourceMappingURL=index-
|
|
1801
|
+
//# sourceMappingURL=index-R0gbIGc-.mjs.map
|