proto.io 0.0.149 → 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.
@@ -1,5 +1,5 @@
1
- import { T as TSchema, P as ProtoService } from '../../internals/index-DnREUbmG.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BuXVzVd8.js';
1
+ import { T as TSchema, P as ProtoService } from '../../internals/index-013pxZ3P.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-CyX8Lu9K.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-DnREUbmG.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BuXVzVd8.js';
1
+ import { P as ProtoService } from '../../internals/index-013pxZ3P.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-CyX8Lu9K.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-DnREUbmG.js';
4
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BuXVzVd8.js';
3
+ import { P as ProtoService } from '../../internals/index-013pxZ3P.js';
4
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-CyX8Lu9K.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, n as EventData, T as TSchema, o as DecodedQuery, F as FindOptions, Q as QuerySelector, p as DecodedSortOption, I as InsertOptions, q as TValue, r as FindOneOptions, t as TUpdateOp, u as FieldSelectorExpression, v as QueryExpression, w as TStorage, x as TransactionOptions, h as TObject, y as TQueryRandomOptions, z as TPubSub } from '../../internals/index-DnREUbmG.js';
2
+ import { _ as _TValue, n as EventData, T as TSchema, o as DecodedQuery, F as FindOptions, Q as QuerySelector, p as DecodedSortOption, I as InsertOptions, q as TValue, r as FindOneOptions, t as TUpdateOp, u as FieldSelectorExpression, v as QueryExpression, w as TStorage, x as TransactionOptions, h as TObject, y as TQueryRandomOptions, z as TPubSub } from '../../internals/index-013pxZ3P.js';
3
3
  import * as _o2ter_utils_js from '@o2ter/utils-js';
4
4
  import { asyncStream } from '@o2ter/utils-js';
5
5
  import 'jsonwebtoken';
@@ -181,6 +181,7 @@ declare abstract class SqlStorage implements TStorage {
181
181
  abstract isDuplicateIdError(error: any): boolean;
182
182
  abstract atomic<T>(callback: (connection: TStorage) => PromiseLike<T>, options?: {
183
183
  lockTable?: string;
184
+ retry?: boolean;
184
185
  }): PromiseLike<T>;
185
186
  abstract withTransaction<T>(callback: (connection: TStorage) => PromiseLike<T>, options?: TransactionOptions): PromiseLike<T>;
186
187
  abstract get dialect(): SqlDialect;
@@ -240,6 +241,7 @@ declare class PostgresStorageClient<Driver extends PostgresClientDriver> extends
240
241
  isDuplicateIdError(error: any): any;
241
242
  atomic<T>(callback: (connection: PostgresStorageTransaction) => PromiseLike<T>, options?: {
242
243
  lockTable?: string;
244
+ retry?: boolean;
243
245
  }): PromiseLike<T>;
244
246
  withTransaction<T>(callback: (connection: PostgresStorageTransaction) => PromiseLike<T>, options?: TransactionOptions): Promise<T>;
245
247
  subscribe(callback: (payload: EventData) => void): () => void;
@@ -253,6 +255,7 @@ declare class PostgresStorageTransaction extends PostgresStorageClient<PostgresC
253
255
  selectLock(): boolean;
254
256
  atomic<T>(callback: (connection: PostgresStorageTransaction) => PromiseLike<T>, options?: {
255
257
  lockTable?: string;
258
+ retry?: boolean;
256
259
  }): PromiseLike<T>;
257
260
  withTransaction<T>(callback: (connection: PostgresStorageTransaction) => PromiseLike<T>): Promise<T>;
258
261
  }
@@ -2535,7 +2535,13 @@ class PostgresStorageTransaction extends PostgresStorageClient {
2535
2535
  return this._selectLock;
2536
2536
  }
2537
2537
  atomic(callback, options) {
2538
- return callback(this);
2538
+ if (!options?.retry)
2539
+ return callback(this);
2540
+ return this.withTransaction(async (conn) => {
2541
+ if (options?.lockTable)
2542
+ await conn.lockTable(options.lockTable, true);
2543
+ return callback(conn);
2544
+ });
2539
2545
  }
2540
2546
  async withTransaction(callback) {
2541
2547
  const transaction = new PostgresStorageTransaction(this._driver, this.counter + 1, this._selectLock);