orchid-orm 1.37.2 → 1.37.4

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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Query, SelectableFromShape, CreateMethodsNames, CreateData, CreateBelongsToData, AddQueryDefaults, RelationConfigBase, SetQueryReturnsOne, SetQueryReturnsOneOptional, UpdateData, WhereArg, JoinQueryMethod, DeleteMethodsNames, Db, IsolationLevel, TransactionOptions, Adapter, FromArg, FromResult, AdapterOptions, DbSharedOptions, RelationsBase, ShapeColumnPrimaryKeys, ShapeUniqueColumns, TableDataItemsUniqueColumns, TableDataItemsUniqueColumnTuples, UniqueConstraints, TableDataItemsUniqueConstraints, ComputedColumnsFromOptions, MapTableScopesOption, TableDataItem, ComputedOptionsFactory, QueryData, TableDataFn, DbTableOptionScopes, RawSQL, DynamicRawSQL, DefaultSchemaConfig, DefaultColumnTypes, QueryBeforeHook, QueryAfterHook, AfterHook, WhereResult, MergeQuery } from 'pqb';
2
2
  export * from 'pqb';
3
- import { ColumnsShapeBase, EmptyObject, MaybeArray, RecordUnknown, Simplify, ColumnShapeOutput, DefaultSelectColumns, ColumnShapeInput, ColumnShapeInputPartial, IsQuery, CoreQueryScopes, ColumnSchemaConfig, StaticSQLArgs, QueryColumn, DynamicSQLArg, QueryColumns, QueryReturnType } from 'orchid-core';
3
+ import { ColumnsShapeBase, EmptyObject, MaybeArray, RecordUnknown, ShallowSimplify, ColumnShapeOutput, DefaultSelectColumns, ColumnShapeInput, ColumnShapeInputPartial, IsQuery, CoreQueryScopes, ColumnSchemaConfig, StaticSQLArgs, QueryColumn, DynamicSQLArg, QueryColumns, QueryReturnType } from 'orchid-core';
4
4
  export * from 'orchid-core';
5
5
 
6
6
  interface RelationCommonOptions<Related extends TableClass = TableClass, Scope extends Query = Query> {
@@ -191,6 +191,9 @@ declare function transaction<Result>(this: {
191
191
  declare function ensureTransaction<Result>(this: {
192
192
  $queryBuilder: Db;
193
193
  }, cb: () => Promise<Result>): Promise<Result>;
194
+ declare function isInTransaction(this: {
195
+ $queryBuilder: Db;
196
+ }): boolean;
194
197
 
195
198
  interface FromQuery extends Query {
196
199
  returnType: 'all';
@@ -206,6 +209,10 @@ type OrchidORM<T extends TableClasses = TableClasses> = {
206
209
  * @see import('pqb').Transaction.prototype.ensureTransaction
207
210
  */
208
211
  $ensureTransaction: typeof ensureTransaction;
212
+ /**
213
+ * @see import('pqb').Transaction.prototype.ensureTransaction
214
+ */
215
+ $isInTransaction: typeof isInTransaction;
209
216
  $adapter: Adapter;
210
217
  $queryBuilder: Db;
211
218
  /**
@@ -447,12 +454,12 @@ interface ORMTableInput {
447
454
  readonly softDelete?: true | string;
448
455
  comment?: string;
449
456
  }
450
- type Queryable<T extends ORMTableInput> = Simplify<{
457
+ type Queryable<T extends ORMTableInput> = ShallowSimplify<{
451
458
  [K in keyof T['columns']['shape']]?: T['columns']['shape'][K]['queryType'];
452
459
  }>;
453
- type Selectable<T extends ORMTableInput> = Simplify<Pick<ColumnShapeOutput<T['columns']['shape']>, DefaultSelectColumns<T['columns']['shape']>>>;
454
- type Insertable<T extends ORMTableInput> = Simplify<ColumnShapeInput<T['columns']['shape']>>;
455
- type Updatable<T extends ORMTableInput> = Simplify<ColumnShapeInputPartial<T['columns']['shape']>>;
460
+ type Selectable<T extends ORMTableInput> = ShallowSimplify<Pick<ColumnShapeOutput<T['columns']['shape']>, DefaultSelectColumns<T['columns']['shape']>>>;
461
+ type Insertable<T extends ORMTableInput> = ShallowSimplify<ColumnShapeInput<T['columns']['shape']>>;
462
+ type Updatable<T extends ORMTableInput> = ShallowSimplify<ColumnShapeInputPartial<T['columns']['shape']>>;
456
463
  type BeforeHookMethod = (cb: QueryBeforeHook) => void;
457
464
  type AfterHookMethod = (cb: QueryAfterHook) => void;
458
465
  type AfterSelectableHookMethod = <Shape extends QueryColumns, S extends (keyof Shape)[]>(this: {
package/dist/index.js CHANGED
@@ -1790,6 +1790,9 @@ function transaction(fnOrOptions, fn) {
1790
1790
  function ensureTransaction(cb) {
1791
1791
  return this.$queryBuilder.ensureTransaction(cb);
1792
1792
  }
1793
+ function isInTransaction() {
1794
+ return this.$queryBuilder.isInTransaction();
1795
+ }
1793
1796
 
1794
1797
  var __defProp$1 = Object.defineProperty;
1795
1798
  var __defProps = Object.defineProperties;
@@ -1862,6 +1865,7 @@ const orchidORM = (_a, tables) => {
1862
1865
  const result = {
1863
1866
  $transaction: transaction,
1864
1867
  $ensureTransaction: ensureTransaction,
1868
+ $isInTransaction: isInTransaction,
1865
1869
  $adapter: adapter,
1866
1870
  $queryBuilder: qb,
1867
1871
  $query: (...args) => qb.query(...args),