proto.io 0.0.193 → 0.0.195

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 (32) hide show
  1. package/dist/adapters/file/database.d.ts +3 -3
  2. package/dist/adapters/file/filesystem.d.ts +3 -3
  3. package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
  4. package/dist/adapters/storage/progres.d.ts +1 -1
  5. package/dist/adapters/storage/progres.js +28 -7
  6. package/dist/adapters/storage/progres.js.map +1 -1
  7. package/dist/adapters/storage/progres.mjs +30 -9
  8. package/dist/adapters/storage/progres.mjs.map +1 -1
  9. package/dist/client.d.ts +3 -3
  10. package/dist/client.js +1 -1
  11. package/dist/client.mjs +2 -2
  12. package/dist/index.d.ts +3 -3
  13. package/dist/index.js +5 -3
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +6 -4
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/internals/{index-BAbXyJEC.mjs → index-C9eiMOSP.mjs} +3 -3
  18. package/dist/internals/index-C9eiMOSP.mjs.map +1 -0
  19. package/dist/internals/{index-z8mWupzT.d.ts → index-ClOV7WJp.d.ts} +2 -2
  20. package/dist/internals/index-ClOV7WJp.d.ts.map +1 -0
  21. package/dist/internals/{index-BDHXW8gd.d.ts → index-CqunpmT-.d.ts} +3 -3
  22. package/dist/internals/index-CqunpmT-.d.ts.map +1 -0
  23. package/dist/internals/{index-M-VqTiz9.js → index-DbXVThGW.js} +3 -3
  24. package/dist/internals/index-DbXVThGW.js.map +1 -0
  25. package/dist/internals/{index-BfsVioOA.d.ts → index-DjHHDI1M.d.ts} +3 -3
  26. package/dist/internals/index-DjHHDI1M.d.ts.map +1 -0
  27. package/package.json +3 -3
  28. package/dist/internals/index-BAbXyJEC.mjs.map +0 -1
  29. package/dist/internals/index-BDHXW8gd.d.ts.map +0 -1
  30. package/dist/internals/index-BfsVioOA.d.ts.map +0 -1
  31. package/dist/internals/index-M-VqTiz9.js.map +0 -1
  32. package/dist/internals/index-z8mWupzT.d.ts.map +0 -1
@@ -1,5 +1,5 @@
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';
1
+ import { T as TSchema, P as ProtoService } from '../../internals/index-CqunpmT-.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-DjHHDI1M.js';
3
3
  import '@o2ter/utils-js';
4
4
  import 'jsonwebtoken';
5
5
  import '@o2ter/server-js';
@@ -14,7 +14,7 @@ declare class DatabaseFileStorage extends FileStorageBase {
14
14
  createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): Promise<void>;
15
15
  readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined): AsyncGenerator<{
16
16
  start: number;
17
- data: Buffer | Uint8Array;
17
+ data: Buffer<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
18
18
  }, void, unknown>;
19
19
  destroy<E>(proto: ProtoService<E>, token: string): Promise<void>;
20
20
  }
@@ -1,5 +1,5 @@
1
- import { P as ProtoService } from '../../internals/index-BDHXW8gd.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BfsVioOA.js';
1
+ import { P as ProtoService } from '../../internals/index-CqunpmT-.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-DjHHDI1M.js';
3
3
  import '@o2ter/utils-js';
4
4
  import 'jsonwebtoken';
5
5
  import '@o2ter/server-js';
@@ -14,7 +14,7 @@ declare class FileSystemStorage extends FileStorageBase {
14
14
  createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): Promise<void>;
15
15
  readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined): AsyncGenerator<{
16
16
  start: number;
17
- data: Promise<Buffer>;
17
+ data: Promise<Buffer<ArrayBufferLike>>;
18
18
  }, void, unknown>;
19
19
  destroy<E>(proto: ProtoService<E>, token: string): Promise<void>;
20
20
  }
@@ -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-BDHXW8gd.js';
4
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BfsVioOA.js';
3
+ import { P as ProtoService } from '../../internals/index-CqunpmT-.js';
4
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-DjHHDI1M.js';
5
5
  import '@o2ter/utils-js';
6
6
  import 'jsonwebtoken';
7
7
  import '@o2ter/server-js';
@@ -18,7 +18,7 @@ declare class GoogleCloudStorage extends FileStorageBase {
18
18
  createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): Promise<void>;
19
19
  readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined): AsyncGenerator<{
20
20
  start: number;
21
- data: Promise<Buffer>;
21
+ data: Promise<Buffer<ArrayBufferLike>>;
22
22
  }, void, unknown>;
23
23
  destroy<E>(proto: ProtoService<E>, token: string): Promise<void>;
24
24
  }
@@ -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-BDHXW8gd.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-CqunpmT-.js';
3
3
  import * as _o2ter_utils_js from '@o2ter/utils-js';
4
4
  import { asyncStream } from '@o2ter/utils-js';
5
5
  import 'jsonwebtoken';
@@ -2905,6 +2905,21 @@ class PostgresStorageTransaction extends PostgresStorageClient {
2905
2905
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2906
2906
  // THE SOFTWARE.
2907
2907
  //
2908
+ const resolveDataType = (schema, path) => {
2909
+ let fields = schema.fields;
2910
+ let last;
2911
+ for (const key of _.toPath(path)) {
2912
+ const dataType = fields[key];
2913
+ if (_.isNil(dataType))
2914
+ throw Error(`Invalid path: ${path}`);
2915
+ if (index.isPrimitive(dataType) || index.isVector(dataType))
2916
+ return dataType;
2917
+ if (!index.isShape(dataType))
2918
+ return dataType;
2919
+ fields = dataType.shape;
2920
+ }
2921
+ return last;
2922
+ };
2908
2923
  class PostgresStorage extends PostgresStorageClient {
2909
2924
  constructor(config) {
2910
2925
  super(new PostgresDriver(config));
@@ -3010,7 +3025,9 @@ class PostgresStorage extends PostgresStorageClient {
3010
3025
  ],
3011
3026
  };
3012
3027
  }
3013
- _indexBasicName(className, keys) {
3028
+ _indexBasicName(className, keys, unique) {
3029
+ if (unique)
3030
+ return `${className}$u$${_.map(keys, (v, k) => `${k}:${v}`).join('$')}`;
3014
3031
  return `${className}$b$${_.map(keys, (v, k) => `${k}:${v}`).join('$')}`;
3015
3032
  }
3016
3033
  _indexVectorName(className, keys) {
@@ -3032,7 +3049,7 @@ class PostgresStorage extends PostgresStorageClient {
3032
3049
  names.push(..._.values(this._indexVectorName(className, _.castArray(index.keys))));
3033
3050
  break;
3034
3051
  default:
3035
- names.push(this._indexBasicName(className, index.keys));
3052
+ names.push(this._indexBasicName(className, index.keys, !!index.unique));
3036
3053
  break;
3037
3054
  }
3038
3055
  }
@@ -3128,16 +3145,20 @@ class PostgresStorage extends PostgresStorageClient {
3128
3145
  break;
3129
3146
  default:
3130
3147
  {
3131
- const name = this._indexBasicName(className, index$1.keys);
3132
- const isAcl = _.isEqual(index$1.keys, { _rperm: 1 }) || _.isEqual(index$1.keys, { _wperm: 1 });
3133
- const isRelation = _.has(relations, _.last(_.keys(index$1.keys)));
3148
+ const name = this._indexBasicName(className, index$1.keys, !!index$1.unique);
3149
+ const useGin = _.some(_.keys(index$1.keys), column => {
3150
+ const dataType = resolveDataType(schema, column);
3151
+ if (!dataType || index.isShape(dataType))
3152
+ throw Error('Invalid index type');
3153
+ return index._isTypeof(dataType, 'string[]') || _.has(relations, column);
3154
+ });
3134
3155
  await this.query(sql `
3135
3156
  CREATE ${{ literal: index$1.unique ? 'UNIQUE' : '' }} INDEX CONCURRENTLY
3136
3157
  IF NOT EXISTS ${{ identifier: name }}
3137
3158
  ON ${{ identifier: className }}
3138
- ${{ literal: isAcl || isRelation ? 'USING GIN' : '' }}
3159
+ ${{ literal: useGin ? 'USING GIN' : '' }}
3139
3160
  (${_.map(index$1.keys, (v, k) => sql `
3140
- ${{ identifier: k }} ${{ literal: isAcl || isRelation ? '' : v === 1 ? 'ASC' : 'DESC' }}
3161
+ ${{ identifier: k }} ${{ literal: useGin ? '' : v === 1 ? 'ASC' : 'DESC' }}
3141
3162
  `)})
3142
3163
  `);
3143
3164
  }