proto.io 0.0.189 → 0.0.191

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/index.js CHANGED
@@ -161,6 +161,8 @@ const dispatcher = (proto, options) => {
161
161
  }
162
162
  },
163
163
  async insertMany(options, values) {
164
+ if (options.className === 'File')
165
+ throw Error('File is not support insertMany');
164
166
  random.QueryValidator.recursiveCheck(values);
165
167
  const _validator = await validator();
166
168
  _validator.validateCountMatches(options.className, options.countMatches ?? []);
@@ -201,6 +203,8 @@ const dispatcher = (proto, options) => {
201
203
  return proto.storage.atomic((storage) => storage.updateMany(_validator.decodeQuery(normalize(query), 'update'), normalize(_validator.validateFields(query.className, update, 'update', random.QueryValidator.patterns.path))));
202
204
  },
203
205
  async upsertOne(query, update, setOnInsert) {
206
+ if (query.className === 'File')
207
+ throw Error('File is not support upsertOne');
204
208
  random.QueryValidator.recursiveCheck(query, update, setOnInsert);
205
209
  const _validator = await validator();
206
210
  if (!_validator.validateCLPs(query.className, 'create', 'update'))
@@ -220,6 +224,8 @@ const dispatcher = (proto, options) => {
220
224
  }
221
225
  },
222
226
  async upsertMany(query, update, setOnInsert) {
227
+ if (query.className === 'File')
228
+ throw Error('File is not support upsertOne');
223
229
  random.QueryValidator.recursiveCheck(query, update, setOnInsert);
224
230
  const _validator = await validator();
225
231
  if (!_validator.validateCLPs(query.className, 'create', 'update'))
@@ -908,7 +914,7 @@ class ProtoInternal {
908
914
  throw Error('Upload token is required');
909
915
  return {
910
916
  nonce,
911
- attributes: _.isObject(attributes) ? index.deserialize(JSON.stringify(attributes)) : {},
917
+ attributes: _.isObject(attributes) ? index.deserialize(JSON.stringify(attributes), { objAttrs: ['_id'] }) : {},
912
918
  maxUploadSize: maxUploadSize ?? this.options.maxUploadSize,
913
919
  };
914
920
  }
@@ -916,7 +922,7 @@ class ProtoInternal {
916
922
  const data = object[_private.PVK].extra.data;
917
923
  if (_.isNil(data))
918
924
  throw Error('Invalid file object');
919
- const { nonce, maxUploadSize, attributes } = this.varifyUploadToken(proto, options?.uploadToken, options?.master);
925
+ const { nonce, attributes = {}, maxUploadSize = this.options.maxUploadSize, } = options?.uploadToken ? this.varifyUploadToken(proto, options.uploadToken, options.master) : {};
920
926
  if (nonce) {
921
927
  const found = await proto.Query('File').equalTo('nonce', nonce).first({ master: true });
922
928
  if (found)
@@ -1629,7 +1635,7 @@ class ProtoService extends index.ProtoType {
1629
1635
  return this[_private.PVK].jwtSign({
1630
1636
  nonce: cryptoJs.randomUUID(),
1631
1637
  maxUploadSize: options.maxUploadSize,
1632
- attributes: JSON.parse(index.serialize(options.attributes ?? {})),
1638
+ attributes: JSON.parse(index.serialize(options.attributes ?? {}, { objAttrs: ['_id'] })),
1633
1639
  }, options?.jwtSignOptions ?? 'upload');
1634
1640
  }
1635
1641
  jwtSign(payload, options) {
@@ -1825,6 +1831,9 @@ var classesRoute = (router, proto) => {
1825
1831
  const query = relatedBy ? payload.Relation(payload.Object(relatedBy.className, relatedBy.objectId), relatedBy.key) : payload.Query(name);
1826
1832
  query[_private.PVK].options = options;
1827
1833
  const opts = { master: payload.isMaster };
1834
+ if (_.includes(['File', '_Job', '_JobScope'], name) &&
1835
+ _.includes(['insert', 'insertMany', 'upsertOne', 'upsertMany'], operation))
1836
+ throw Error('Invaild operation');
1828
1837
  switch (operation) {
1829
1838
  case 'explain':
1830
1839
  if (!payload.isMaster)