orchid-orm 1.65.0 → 1.65.1

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,4 +1,4 @@
1
- import { Column, TableData, ColumnsShape, Query, SelectableFromShape, CreateManyMethodsNames, QueryHasWhere, RelationConfigBase, QueryManyTake, QueryManyTakeOptional, EmptyObject, CreateData, UpdateData, WhereArg, CreateMethodsNames, MaybeArray, JoinQueryMethod, DeleteMethodsNames, Db, IsolationLevel, TransactionOptions, AfterCommitStandaloneHook, AdapterBase, FromArg, FromResult, StorageOptions, DbSharedOptions, QuerySchema, ShapeColumnPrimaryKeys, ShapeUniqueColumns, TableDataItemsUniqueColumns, TableDataItemsUniqueColumnTuples, UniqueConstraints, TableDataItemsUniqueConstraints, ComputedColumnsFromOptions, MapTableScopesOption, TableDataItem, ComputedOptionsFactory, RecordUnknown, ShallowSimplify, ComputedOptionsConfig, QueryOrExpression, QueryData, IsQuery, TableDataFn, DbTableOptionScopes, QueryScopes, ColumnSchemaConfig, DbSqlMethod, DefaultSchemaConfig, DefaultColumnTypes, QueryBeforeHook, QueryBeforeActionHook, QueryAfterHook, AfterHook, MergeQuery, QueryReturnType } from 'pqb/internal';
1
+ import { Column, TableData, ColumnsShape, Query, RelationConfigBase, QueryManyTake, QueryManyTakeOptional, EmptyObject, CreateData, UpdateData, WhereArg, SelectableFromShape, CreateManyMethodsNames, QueryHasWhere, CreateMethodsNames, MaybeArray, JoinQueryMethod, DeleteMethodsNames, Db, IsolationLevel, TransactionOptions, AfterCommitStandaloneHook, AdapterBase, FromArg, FromResult, StorageOptions, DbSharedOptions, QuerySchema, ColumnSchemaConfig, DbSqlMethod, TableDataItem, QueryData, IsQuery, TableDataFn, ComputedOptionsFactory, DbTableOptionScopes, QueryScopes, RecordUnknown, QueryBeforeHook, QueryAfterHook, QueryBeforeActionHook, AfterHook, ShallowSimplify, ShapeColumnPrimaryKeys, ShapeUniqueColumns, TableDataItemsUniqueColumns, TableDataItemsUniqueColumnTuples, UniqueConstraints, TableDataItemsUniqueConstraints, ComputedColumnsFromOptions, MapTableScopesOption, ComputedOptionsConfig, QueryOrExpression, DefaultSchemaConfig, DefaultColumnTypes, QueryReturnType, MergeQuery } from 'pqb/internal';
2
2
  export * from 'pqb';
3
3
 
4
4
  interface RelationRefsOptions<Column extends PropertyKey = string, Shape extends Column.Shape.QueryInit = Column.Shape.QueryInit> {
@@ -750,8 +750,9 @@ type MapMethods<T extends Query, Methods extends MethodsBase<T>> = {
750
750
  };
751
751
  type Repo<T extends Query, Methods extends MethodsBase<T>> = T & MapMethods<T, Methods>;
752
752
  declare const createRepo: <T extends Query, Methods extends MethodsBase<T>>(table: T, methods: Methods) => Repo<(<Q extends {
753
- table: T['table'];
754
- shape: T['shape'];
753
+ table: T["table"];
754
+ shape: T["shape"];
755
755
  }>(q: Q) => Query & Q & MapMethods<T, Methods>) & T, Methods>;
756
756
 
757
- export { type BaseTableClass, type BaseTableInstance, type DefaultSelect, type Insertable, type MapMethods, type MapQueryMethods, type MethodsBase, type ORMTableInput, type OrchidORM, type OrchidOrmParam, type Queryable, type Repo, type Selectable, type SetColumnsResult, type Table, type TableClass, type TableClasses, type TableInfo, type TableToDb, type Updatable, createBaseTable, createRepo, orchidORMWithAdapter };
757
+ export { createBaseTable, createRepo, orchidORMWithAdapter };
758
+ export type { BaseTableClass, BaseTableInstance, DefaultSelect, FromQuery, Insertable, MapMethods, MapQueryMethods, MethodsBase, ORMTableInput, OrchidORM, OrchidOrmParam, Queryable, Repo, Selectable, SetColumnsResult, Table, TableClass, TableClasses, TableInfo, TableToDb, Updatable };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var internal = require('pqb/internal');
4
- var node_async_hooks = require('node:async_hooks');
5
4
  var pqb = require('pqb');
5
+ var node_async_hooks = require('node:async_hooks');
6
6
 
7
7
  function createBaseTable({
8
8
  schemaConfig = internal.defaultSchemaConfig,
@@ -417,7 +417,7 @@ class BelongsToVirtualColumn extends internal.VirtualColumn {
417
417
  var _a;
418
418
  const value = item[key];
419
419
  const kind = value.create ? "create" : value.connect ? "connect" : "connectOrCreate";
420
- if (kind) {
420
+ {
421
421
  const nestedCreateItem = (_a = nestedCreateItems ?? (nestedCreateItems = {}))[kind] ?? (_a[kind] = {
422
422
  items: [],
423
423
  values: []
@@ -725,7 +725,7 @@ class HasOneVirtualColumn extends internal.VirtualColumn {
725
725
  var _a;
726
726
  const value = item[this.key];
727
727
  const kind = value.create ? "create" : value.connect ? "connect" : "connectOrCreate";
728
- if (kind) {
728
+ {
729
729
  const nestedCreateItem = (_a = nestedCreateItems ?? (nestedCreateItems = {}))[kind] ?? (_a[kind] = {
730
730
  indexes: [],
731
731
  items: [],
@@ -1443,7 +1443,7 @@ const nestedUpdate$1 = ({ query, primaryKeys, foreignKeys }) => {
1443
1443
  }
1444
1444
  if (params.add) {
1445
1445
  if (data.length > 1) {
1446
- throw new internal.OrchidOrmInternalError(
1446
+ throw new pqb.OrchidOrmInternalError(
1447
1447
  query,
1448
1448
  "`connect` is not available when updating multiple records, it is only applicable for a single record update"
1449
1449
  );
@@ -1458,7 +1458,7 @@ const nestedUpdate$1 = ({ query, primaryKeys, foreignKeys }) => {
1458
1458
  obj
1459
1459
  );
1460
1460
  if (count < relatedWheres.length) {
1461
- throw new internal.OrchidOrmInternalError(
1461
+ throw new pqb.OrchidOrmInternalError(
1462
1462
  query,
1463
1463
  `Expected to find at least ${relatedWheres.length} record(s) based on \`add\` conditions, but found ${count}`
1464
1464
  );
@@ -1726,7 +1726,7 @@ const makeHasAndBelongsToManyMethod = (tableConfig, table, qb, relation, relatio
1726
1726
  data
1727
1727
  );
1728
1728
  if (createdCount === 0) {
1729
- throw new internal.NotFoundError(baseQuery2);
1729
+ throw new pqb.NotFoundError(baseQuery2);
1730
1730
  }
1731
1731
  }
1732
1732
  );
@@ -2023,14 +2023,14 @@ const nestedUpdate = (state) => {
2023
2023
  )
2024
2024
  ).onConflict(joinTableColumns).merge([state.foreignKeys[0]]);
2025
2025
  if (count < data.length * relatedWheres.length) {
2026
- throw new internal.OrchidOrmInternalError(
2026
+ throw new pqb.OrchidOrmInternalError(
2027
2027
  query,
2028
2028
  `Expected to find at least ${relatedWheres.length} record(s) based on \`add\` conditions, but found ${count / data.length}`
2029
2029
  );
2030
2030
  }
2031
2031
  } catch (err) {
2032
2032
  if (err.code === "42P10") {
2033
- throw new internal.OrchidOrmInternalError(
2033
+ throw new pqb.OrchidOrmInternalError(
2034
2034
  query,
2035
2035
  `"${state.joinTableQuery.table}" must have a primary key or a unique index on columns (${joinTableColumns.join(
2036
2036
  ", "