proto.io 0.0.188 → 0.0.189

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.
@@ -1,5 +1,5 @@
1
- import { T as TSchema, P as ProtoService } from '../../internals/index-fdvea17W.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-wofihxjH.js';
1
+ import { T as TSchema, P as ProtoService } from '../../internals/index-BDHXW8gd.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BfsVioOA.js';
3
3
  import '@o2ter/utils-js';
4
4
  import 'jsonwebtoken';
5
5
  import '@o2ter/server-js';
@@ -1,5 +1,5 @@
1
- import { P as ProtoService } from '../../internals/index-fdvea17W.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-wofihxjH.js';
1
+ import { P as ProtoService } from '../../internals/index-BDHXW8gd.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BfsVioOA.js';
3
3
  import '@o2ter/utils-js';
4
4
  import 'jsonwebtoken';
5
5
  import '@o2ter/server-js';
@@ -1,7 +1,7 @@
1
1
  import * as _google_cloud_storage from '@google-cloud/storage';
2
2
  import { Storage } from '@google-cloud/storage';
3
- import { P as ProtoService } from '../../internals/index-fdvea17W.js';
4
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-wofihxjH.js';
3
+ import { P as ProtoService } from '../../internals/index-BDHXW8gd.js';
4
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BfsVioOA.js';
5
5
  import '@o2ter/utils-js';
6
6
  import 'jsonwebtoken';
7
7
  import '@o2ter/server-js';
@@ -1,5 +1,5 @@
1
1
  import { Pool, PoolClient, PoolConfig } from 'pg';
2
- import { _ as _TValue, T as TSchema, Q as QuerySelector, q as DecodedQuery, F as FindOptions, R as RelationOptions, r as DecodedSortOption, I as InsertOptions, t as TValue, u as FindOneOptions, v as TUpdateOp, w as FieldSelectorExpression, x as QueryExpression, y as TStorage, z as TransactionOptions, h as TObject, A as TQueryRandomOptions, B as TPubSub } from '../../internals/index-fdvea17W.js';
2
+ import { _ as _TValue, T as TSchema, Q as QuerySelector, q as DecodedQuery, F as FindOptions, R as RelationOptions, r as DecodedSortOption, I as InsertOptions, t as TValue, u as FindOneOptions, v as TUpdateOp, w as FieldSelectorExpression, x as QueryExpression, y as TStorage, z as TransactionOptions, h as TObject, A as TQueryRandomOptions, B as TPubSub } from '../../internals/index-BDHXW8gd.js';
3
3
  import * as _o2ter_utils_js from '@o2ter/utils-js';
4
4
  import { asyncStream } from '@o2ter/utils-js';
5
5
  import 'jsonwebtoken';
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { P as ProtoClient } from './internals/index-DSxxREND.js';
2
- export { c as classExtends, e as isFile, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-DSxxREND.js';
1
+ import { P as ProtoClient } from './internals/index-z8mWupzT.js';
2
+ export { c as classExtends, e as isFile, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-z8mWupzT.js';
3
3
  export { Decimal } from 'decimal.js';
4
- export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-fdvea17W.js';
4
+ export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BDHXW8gd.js';
5
5
  import '@o2ter/utils-js';
6
6
  import 'socket.io-client';
7
7
  import '@socket.io/component-emitter';
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./internals/index-BvaBC85z.js');
5
+ var index = require('./internals/index-M-VqTiz9.js');
6
6
  var Decimal = require('decimal.js');
7
7
  require('@o2ter/utils-js');
8
8
  require('./internals/private-Ciddhure.js');
package/dist/client.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { e as ProtoClient } from './internals/index-C3PZ692k.mjs';
2
- export { f as classExtends, d as deserialize, k as isFile, l as isJob, g as isObject, i as isQuery, j as isRole, h as isUser, s as serialize } from './internals/index-C3PZ692k.mjs';
1
+ import { e as ProtoClient } from './internals/index-BAbXyJEC.mjs';
2
+ export { f as classExtends, d as deserialize, k as isFile, l as isJob, g as isObject, i as isQuery, j as isRole, h as isUser, s as serialize } from './internals/index-BAbXyJEC.mjs';
3
3
  export { Decimal } from 'decimal.js';
4
4
  import '@o2ter/utils-js';
5
5
  import './internals/private-CNw40LZ7.mjs';
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as socket_io from 'socket.io';
2
2
  import { Router } from 'express';
3
3
  import { Server } from '@o2ter/server-js';
4
- import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-fdvea17W.js';
5
- export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-fdvea17W.js';
4
+ import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-BDHXW8gd.js';
5
+ export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BDHXW8gd.js';
6
6
  import Decimal from 'decimal.js';
7
7
  export { Decimal } from 'decimal.js';
8
- export { P as ProtoClient, c as classExtends, e as isFile, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-DSxxREND.js';
8
+ export { P as ProtoClient, c as classExtends, e as isFile, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-z8mWupzT.js';
9
9
  import '@o2ter/utils-js';
10
10
  import 'jsonwebtoken';
11
11
  import 'lodash';
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var serverJs = require('@o2ter/server-js');
7
7
  var random = require('./internals/random-CObICDCy.js');
8
8
  var _private = require('./internals/private-Ciddhure.js');
9
9
  var utilsJs = require('@o2ter/utils-js');
10
- var index = require('./internals/index-BvaBC85z.js');
10
+ var index = require('./internals/index-M-VqTiz9.js');
11
11
  var index$1 = require('./internals/index-Dej3GgVf.js');
12
12
  var jwt = require('jsonwebtoken');
13
13
  var node_buffer = require('node:buffer');
@@ -15,10 +15,10 @@ var node_stream = require('node:stream');
15
15
  var node_crypto = require('node:crypto');
16
16
  var util = require('util');
17
17
  var cryptoJs = require('@o2ter/crypto-js');
18
+ var Decimal = require('decimal.js');
18
19
  var index$2 = require('./internals/index-COOeeeBE.js');
19
20
  var queryType = require('query-types');
20
21
  var busboy = require('busboy');
21
- var Decimal = require('decimal.js');
22
22
  require('axios');
23
23
  require('@o2ter/server-js/dist/const');
24
24
  require('socket.io-client');
@@ -493,7 +493,7 @@ const defaultSchema = {
493
493
  type: { update: [] },
494
494
  token: { update: [] },
495
495
  nonce: { update: [] },
496
- _expired_at: { create: [], update: [] },
496
+ _expired_at: { update: [] },
497
497
  },
498
498
  indexes: [
499
499
  {
@@ -903,11 +903,12 @@ class ProtoInternal {
903
903
  return object;
904
904
  }
905
905
  varifyUploadToken(proto, token, isMaster) {
906
- const { nonce, maxUploadSize } = (_.isString(token) ? this.jwtVarify(token, 'upload') ?? {} : {});
906
+ const { nonce, attributes, maxUploadSize, } = (_.isString(token) ? this.jwtVarify(token, 'upload') ?? {} : {});
907
907
  if (!isMaster && !nonce)
908
908
  throw Error('Upload token is required');
909
909
  return {
910
910
  nonce,
911
+ attributes: _.isObject(attributes) ? index.deserialize(JSON.stringify(attributes)) : {},
911
912
  maxUploadSize: maxUploadSize ?? this.options.maxUploadSize,
912
913
  };
913
914
  }
@@ -915,7 +916,7 @@ class ProtoInternal {
915
916
  const data = object[_private.PVK].extra.data;
916
917
  if (_.isNil(data))
917
918
  throw Error('Invalid file object');
918
- const { nonce, maxUploadSize } = this.varifyUploadToken(proto, options?.uploadToken, options?.master);
919
+ const { nonce, maxUploadSize, attributes } = this.varifyUploadToken(proto, options?.uploadToken, options?.master);
919
920
  if (nonce) {
920
921
  const found = await proto.Query('File').equalTo('nonce', nonce).first({ master: true });
921
922
  if (found)
@@ -949,6 +950,9 @@ class ProtoInternal {
949
950
  throw Error('Invalid file object');
950
951
  }
951
952
  try {
953
+ for (const [key, value] of _.entries(attributes)) {
954
+ object.set(key, value);
955
+ }
952
956
  object.set('token', file._id);
953
957
  object.set('size', file.size);
954
958
  if (nonce)
@@ -1625,6 +1629,7 @@ class ProtoService extends index.ProtoType {
1625
1629
  return this[_private.PVK].jwtSign({
1626
1630
  nonce: cryptoJs.randomUUID(),
1627
1631
  maxUploadSize: options.maxUploadSize,
1632
+ attributes: JSON.parse(index.serialize(options.attributes ?? {})),
1628
1633
  }, options?.jwtSignOptions ?? 'upload');
1629
1634
  }
1630
1635
  jwtSign(payload, options) {