proto.io 0.0.148 → 0.0.150
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 +6 -1
- package/dist/adapters/storage/progres.js +13 -4
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +13 -4
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -5
- package/dist/client.js +2 -2
- package/dist/client.mjs +3 -3
- package/dist/index.d.ts +3 -5
- package/dist/index.js +53 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-CvfRsxEZ.d.ts → index-013pxZ3P.d.ts} +5 -78
- package/dist/internals/index-013pxZ3P.d.ts.map +1 -0
- package/dist/internals/{index-EOtjV6U_.mjs → index-BmRuvHVZ.mjs} +11 -1
- package/dist/internals/index-BmRuvHVZ.mjs.map +1 -0
- package/dist/internals/index-BqFdBhFc.js.map +1 -1
- package/dist/internals/{index-DZS2c96L.js → index-CSNRyhjB.js} +2 -2
- package/dist/internals/{index-DZS2c96L.js.map → index-CSNRyhjB.js.map} +1 -1
- package/dist/internals/{index-C6zdNpc_.js → index-CVutVPmd.js} +11 -1
- package/dist/internals/{index-C6zdNpc_.js.map → index-CVutVPmd.js.map} +1 -1
- package/dist/internals/index-CsRN32Jf.d.ts +60 -0
- package/dist/internals/index-CsRN32Jf.d.ts.map +1 -0
- package/dist/internals/{index-D4VXQ1FB.d.ts → index-CyX8Lu9K.d.ts} +3 -2
- package/dist/internals/index-CyX8Lu9K.d.ts.map +1 -0
- package/dist/internals/{index-tNCIyuCp.js → index-D1YGwuNK.js} +8 -4
- package/dist/internals/index-D1YGwuNK.js.map +1 -0
- package/dist/internals/index-be1VYBY2.mjs.map +1 -1
- package/dist/internals/{index-DGau0Wqf.mjs → index-c-CaNuVY.mjs} +8 -4
- package/dist/internals/index-c-CaNuVY.mjs.map +1 -0
- package/dist/internals/{index-DTZ5uRgF.mjs → index-tU-lsQqj.mjs} +2 -2
- package/dist/internals/{index-DTZ5uRgF.mjs.map → index-tU-lsQqj.mjs.map} +1 -1
- package/dist/internals/{random-XGNkddOu.js → random-DBDmz54D.js} +3 -3
- package/dist/internals/{random-XGNkddOu.js.map → random-DBDmz54D.js.map} +1 -1
- package/dist/internals/{random-BjV_01xP.mjs → random-KZTFMK9-.mjs} +3 -3
- package/dist/internals/{random-BjV_01xP.mjs.map → random-KZTFMK9-.mjs.map} +1 -1
- package/package.json +2 -2
- package/dist/internals/index-BAB_APmb.d.ts +0 -116
- package/dist/internals/index-BAB_APmb.d.ts.map +0 -1
- package/dist/internals/index-CvfRsxEZ.d.ts.map +0 -1
- package/dist/internals/index-D4VXQ1FB.d.ts.map +0 -1
- package/dist/internals/index-DGau0Wqf.mjs.map +0 -1
- package/dist/internals/index-EOtjV6U_.mjs.map +0 -1
- package/dist/internals/index-tNCIyuCp.js.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Server } from '@o2ter/server-js';
|
|
3
|
-
import { Q as QueryValidator, g as generateId } from './internals/random-
|
|
3
|
+
import { Q as QueryValidator, g as generateId } from './internals/random-KZTFMK9-.mjs';
|
|
4
4
|
import { P as PVK } from './internals/private-BUpLAMZi.mjs';
|
|
5
5
|
import { asyncStream, asyncIterableToArray, isBinaryData, base64ToBuffer } from '@o2ter/utils-js';
|
|
6
|
-
import { T as TQuery, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, P as ProtoType, s as serialize, d as deserialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-
|
|
7
|
-
export { c as ProtoClient, e as classExtends, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser } from './internals/index-
|
|
8
|
-
import { d as decodeUpdateOp, T as TObject, i as isShape, a as isPointer, b as isRelation, c as defaultObjectKeyTypes, e as isPrimitive } from './internals/index-
|
|
6
|
+
import { T as TQuery, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, P as ProtoType, s as serialize, d as deserialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-c-CaNuVY.mjs';
|
|
7
|
+
export { c as ProtoClient, e as classExtends, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser } from './internals/index-c-CaNuVY.mjs';
|
|
8
|
+
import { d as decodeUpdateOp, T as TObject, i as isShape, a as isPointer, b as isRelation, c as defaultObjectKeyTypes, e as isPrimitive } from './internals/index-BmRuvHVZ.mjs';
|
|
9
9
|
import jwt from 'jsonwebtoken';
|
|
10
10
|
import { Blob } from 'node:buffer';
|
|
11
11
|
import { Readable } from 'node:stream';
|
|
12
12
|
import { scrypt } from 'node:crypto';
|
|
13
13
|
import { promisify } from 'util';
|
|
14
14
|
import { randomBytes, randomUUID } from '@o2ter/crypto-js';
|
|
15
|
-
import { Q as QuerySelector } from './internals/index-
|
|
15
|
+
import { Q as QuerySelector } from './internals/index-tU-lsQqj.mjs';
|
|
16
16
|
import queryType from 'query-types';
|
|
17
17
|
import busboy from 'busboy';
|
|
18
18
|
export { Decimal } from 'decimal.js';
|
|
@@ -135,12 +135,22 @@ const dispatcher = (proto, options, disableSecurity) => {
|
|
|
135
135
|
const _matches = _validator.decodeMatches(options.className, options.matches ?? {}, _includes);
|
|
136
136
|
if (!_validator.validateCLPs(options.className, 'create'))
|
|
137
137
|
throw Error('No permission');
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
const _attrs = normalize(_validator.validateFields(options.className, attrs, 'create', QueryValidator.patterns.path));
|
|
139
|
+
while (true) {
|
|
140
|
+
try {
|
|
141
|
+
return await proto.storage.atomic((storage) => storage.insert({
|
|
142
|
+
className: options.className,
|
|
143
|
+
includes: _includes,
|
|
144
|
+
matches: _matches,
|
|
145
|
+
objectIdSize: proto[PVK].options.objectIdSize
|
|
146
|
+
}, _attrs), { lockTable: options.className, retry: true });
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
if (proto.storage.isDuplicateIdError(e))
|
|
150
|
+
continue;
|
|
151
|
+
throw e;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
144
154
|
},
|
|
145
155
|
async insertMany(options, values) {
|
|
146
156
|
QueryValidator.recursiveCheck(values);
|
|
@@ -149,12 +159,22 @@ const dispatcher = (proto, options, disableSecurity) => {
|
|
|
149
159
|
const _matches = _validator.decodeMatches(options.className, options.matches ?? {}, _includes);
|
|
150
160
|
if (!_validator.validateCLPs(options.className, 'create'))
|
|
151
161
|
throw Error('No permission');
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
const _attrs = normalize(_.map(values, attr => _validator.validateFields(options.className, attr, 'create', QueryValidator.patterns.path)));
|
|
163
|
+
while (true) {
|
|
164
|
+
try {
|
|
165
|
+
return await proto.storage.atomic((storage) => storage.insertMany({
|
|
166
|
+
className: options.className,
|
|
167
|
+
includes: _includes,
|
|
168
|
+
matches: _matches,
|
|
169
|
+
objectIdSize: proto[PVK].options.objectIdSize
|
|
170
|
+
}, _attrs), { lockTable: options.className, retry: true });
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
if (proto.storage.isDuplicateIdError(e))
|
|
174
|
+
continue;
|
|
175
|
+
throw e;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
158
178
|
},
|
|
159
179
|
async updateOne(query, update) {
|
|
160
180
|
QueryValidator.recursiveCheck(query, update);
|
|
@@ -168,7 +188,19 @@ const dispatcher = (proto, options, disableSecurity) => {
|
|
|
168
188
|
const _validator = await validator();
|
|
169
189
|
if (!_validator.validateCLPs(query.className, 'create', 'update'))
|
|
170
190
|
throw Error('No permission');
|
|
171
|
-
|
|
191
|
+
const _query = _validator.decodeQuery(normalize(query), 'update');
|
|
192
|
+
const _update = normalize(_validator.validateFields(query.className, update, 'update', QueryValidator.patterns.path));
|
|
193
|
+
const _setOnInsert = normalize(_validator.validateFields(query.className, setOnInsert, 'create', QueryValidator.patterns.name));
|
|
194
|
+
while (true) {
|
|
195
|
+
try {
|
|
196
|
+
return await proto.storage.atomic((storage) => storage.upsertOne(_query, _update, _setOnInsert), { lockTable: query.className, retry: true });
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
if (proto.storage.isDuplicateIdError(e))
|
|
200
|
+
continue;
|
|
201
|
+
throw e;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
172
204
|
},
|
|
173
205
|
async deleteOne(query) {
|
|
174
206
|
QueryValidator.recursiveCheck(query);
|
|
@@ -330,7 +362,7 @@ class ProtoQuery extends TQuery {
|
|
|
330
362
|
className: this.className,
|
|
331
363
|
includes: this[PVK].options.includes,
|
|
332
364
|
matches: this[PVK].options.matches,
|
|
333
|
-
}, _.fromPairs([...object.
|
|
365
|
+
}, _.fromPairs([...object._set_entries()])));
|
|
334
366
|
if (!result)
|
|
335
367
|
throw Error('Unable to insert document');
|
|
336
368
|
if (_.isFunction(afterSave)) {
|
|
@@ -360,7 +392,7 @@ class ProtoQuery extends TQuery {
|
|
|
360
392
|
className: this.className,
|
|
361
393
|
includes: this[PVK].options.includes,
|
|
362
394
|
matches: this[PVK].options.matches,
|
|
363
|
-
}, _.map(objects, x => _.fromPairs([...x.
|
|
395
|
+
}, _.map(objects, x => _.fromPairs([...x._set_entries()])));
|
|
364
396
|
if (_.isFunction(afterSave)) {
|
|
365
397
|
await Promise.all(_.map(objects, object => afterSave(proxy(Object.setPrototypeOf({ object, context }, options?.session ?? this._proto)))));
|
|
366
398
|
}
|
|
@@ -917,7 +949,7 @@ class ProtoInternal {
|
|
|
917
949
|
object.set('nonce', nonce);
|
|
918
950
|
const created = await proto.Query('File')
|
|
919
951
|
.includes(...object.keys())
|
|
920
|
-
.insert(_.fromPairs([...object.
|
|
952
|
+
.insert(_.fromPairs([...object._set_entries()]), options);
|
|
921
953
|
if (created) {
|
|
922
954
|
object[PVK].attributes = created.attributes;
|
|
923
955
|
object[PVK].mutated = {};
|
|
@@ -1252,6 +1284,7 @@ const schedule = (proto) => {
|
|
|
1252
1284
|
// THE SOFTWARE.
|
|
1253
1285
|
//
|
|
1254
1286
|
class ProtoService extends ProtoType {
|
|
1287
|
+
/** @internal */
|
|
1255
1288
|
[PVK];
|
|
1256
1289
|
_storage;
|
|
1257
1290
|
_schedule = schedule(this);
|