orchid-orm 1.24.6 → 1.25.0
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 +5 -7
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -12
- package/dist/index.mjs.map +1 -1
- package/dist/migrations.d.ts +16 -0
- package/dist/migrations.js +2847 -0
- package/dist/migrations.js.map +1 -0
- package/dist/migrations.mjs +2839 -0
- package/dist/migrations.mjs.map +1 -0
- package/package.json +10 -5
- package/codegen/index.d.ts +0 -41
- package/codegen/index.js +0 -1460
- package/codegen/index.js.map +0 -1
- package/codegen/index.mjs +0 -1439
- package/codegen/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Query, SelectableFromShape, CreateMethodsNames, AddQueryDefaults, SetQueryReturnsOne, SetQueryReturnsOneOptional, RelationJoinQuery, UpdateData, WhereArg, CreateData, JoinQueryMethod, DeleteMethodsNames, Db, IsolationLevel, TransactionOptions, Adapter, FromArg, FromArgOptions, FromResult, AdapterOptions,
|
|
1
|
+
import { Query, SelectableFromShape, CreateMethodsNames, AddQueryDefaults, SetQueryReturnsOne, SetQueryReturnsOneOptional, RelationJoinQuery, UpdateData, WhereArg, CreateData, JoinQueryMethod, DeleteMethodsNames, Db, IsolationLevel, TransactionOptions, Adapter, FromArg, FromArgOptions, FromResult, AdapterOptions, DbSharedOptions, RelationQuery, MapTableScopesOption, ComputedColumnsBase, QueryData, QueryBase, DbTableOptionScopes, DefaultSchemaConfig, DefaultColumnTypes, RelationQueryBase, QueryBeforeHook, QueryAfterHook, AfterHook, WhereResult, MergeQuery } from 'pqb';
|
|
2
2
|
export * from 'pqb';
|
|
3
3
|
import { ColumnsShapeBase, EmptyObject, MaybeArray, RecordUnknown, CoreQueryScopes, ColumnShapeOutput, ColumnShapeInput, ColumnShapeInputPartial, ColumnSchemaConfig, QueryReturnType } from 'orchid-core';
|
|
4
4
|
export * from 'orchid-core';
|
|
@@ -257,10 +257,7 @@ type OrchidOrmArg = true | null extends true ? 'Set strict: true to tsconfig' :
|
|
|
257
257
|
db: Query;
|
|
258
258
|
} | {
|
|
259
259
|
adapter: Adapter;
|
|
260
|
-
} | Omit<AdapterOptions, 'log'>) &
|
|
261
|
-
autoPreparedStatements?: boolean;
|
|
262
|
-
noPrimaryKey?: NoPrimaryKeyOption;
|
|
263
|
-
};
|
|
260
|
+
} | Omit<AdapterOptions, 'log'>) & DbSharedOptions;
|
|
264
261
|
declare const orchidORM: <T extends TableClasses>({ log, logger, autoPreparedStatements, noPrimaryKey, ...options }: OrchidOrmArg, tables: T) => OrchidORM<T>;
|
|
265
262
|
|
|
266
263
|
interface HasAndBelongsToMany extends RelationThunkBase {
|
|
@@ -424,13 +421,14 @@ interface Table {
|
|
|
424
421
|
computed?: ComputedColumnsBase<never>;
|
|
425
422
|
scopes?: CoreQueryScopes;
|
|
426
423
|
readonly softDelete?: true | string;
|
|
424
|
+
comment?: string;
|
|
427
425
|
}
|
|
428
426
|
type Queryable<T extends Table> = {
|
|
429
427
|
[K in keyof T['columns']]?: T['columns'][K]['queryType'];
|
|
430
428
|
};
|
|
431
429
|
type Selectable<T extends Table> = ColumnShapeOutput<T['columns']>;
|
|
432
430
|
type Insertable<T extends Table> = ColumnShapeInput<T['columns']>;
|
|
433
|
-
type
|
|
431
|
+
type Updatable<T extends Table> = ColumnShapeInputPartial<T['columns']>;
|
|
434
432
|
type BeforeHookMethod = <T extends Table>(cb: QueryBeforeHook) => T;
|
|
435
433
|
type AfterHookMethod = <T extends Table>(cb: QueryAfterHook) => T;
|
|
436
434
|
type AfterSelectableHookMethod = <T extends Table, S extends (keyof T['columns'])[]>(this: T, select: S, cb: AfterHook<S, T['columns']>) => T;
|
|
@@ -631,4 +629,4 @@ type Repo<T extends Query, Methods extends MethodsBase<T>> = (<Q extends {
|
|
|
631
629
|
}>(q: Q) => Query & Q & MapMethods<T, Methods>) & T & MapMethods<T, Methods>;
|
|
632
630
|
declare const createRepo: <T extends Query, Methods extends MethodsBase<T>>(table: T, methods: Methods) => Repo<T, Methods>;
|
|
633
631
|
|
|
634
|
-
export { BaseTableClass, BaseTableInstance, DbTable, Insertable, MapMethods, MapQueryMethods, MethodsBase, OrchidORM, Queryable, Repo, ScopeFn, Selectable, Table, TableClass, TableClasses, TableToDb,
|
|
632
|
+
export { BaseTableClass, BaseTableInstance, DbTable, Insertable, MapMethods, MapQueryMethods, MethodsBase, OrchidORM, Queryable, Repo, ScopeFn, Selectable, Table, TableClass, TableClasses, TableToDb, Updatable, createBaseTable, createRepo, orchidORM };
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,7 @@ function createBaseTable({
|
|
|
74
74
|
setColumns(fn) {
|
|
75
75
|
columnTypes[orchidCore.snakeCaseKey] = this.snakeCase;
|
|
76
76
|
const shape = pqb.getColumnTypes(columnTypes, fn, nowSQL, this.language);
|
|
77
|
+
this.constructor.prototype.tableData = pqb.getTableData();
|
|
77
78
|
if (this.snakeCase) {
|
|
78
79
|
for (const key in shape) {
|
|
79
80
|
const column = shape[key];
|
|
@@ -1085,8 +1086,9 @@ var __spreadValues$3 = (a, b) => {
|
|
|
1085
1086
|
};
|
|
1086
1087
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
1087
1088
|
class HasAndBelongsToManyVirtualColumn extends pqb.VirtualColumn {
|
|
1088
|
-
constructor(schema, key, state) {
|
|
1089
|
+
constructor(joinTable, schema, key, state) {
|
|
1089
1090
|
super(schema);
|
|
1091
|
+
this.joinTable = joinTable;
|
|
1090
1092
|
this.key = key;
|
|
1091
1093
|
this.state = state;
|
|
1092
1094
|
this.nestedInsert = nestedInsert(state);
|
|
@@ -1235,6 +1237,7 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
|
|
|
1235
1237
|
});
|
|
1236
1238
|
},
|
|
1237
1239
|
virtualColumn: new HasAndBelongsToManyVirtualColumn(
|
|
1240
|
+
subQuery,
|
|
1238
1241
|
pqb.defaultSchemaConfig,
|
|
1239
1242
|
relationName,
|
|
1240
1243
|
state
|
|
@@ -1813,6 +1816,7 @@ const orchidORM = (_a, tables) => {
|
|
|
1813
1816
|
"autoPreparedStatements",
|
|
1814
1817
|
"noPrimaryKey"
|
|
1815
1818
|
]);
|
|
1819
|
+
var _a2;
|
|
1816
1820
|
const commonOptions = {
|
|
1817
1821
|
log,
|
|
1818
1822
|
logger,
|
|
@@ -1829,16 +1833,13 @@ const orchidORM = (_a, tables) => {
|
|
|
1829
1833
|
} else {
|
|
1830
1834
|
adapter = "adapter" in options ? options.adapter : new pqb.Adapter(options);
|
|
1831
1835
|
transactionStorage = new node_async_hooks.AsyncLocalStorage();
|
|
1832
|
-
qb =
|
|
1836
|
+
qb = pqb._initQueryBuilder(
|
|
1833
1837
|
adapter,
|
|
1834
|
-
void 0,
|
|
1835
|
-
void 0,
|
|
1836
|
-
pqb.anyShape,
|
|
1837
1838
|
pqb.makeColumnTypes(pqb.defaultSchemaConfig),
|
|
1838
1839
|
transactionStorage,
|
|
1839
|
-
commonOptions
|
|
1840
|
+
commonOptions,
|
|
1841
|
+
options
|
|
1840
1842
|
);
|
|
1841
|
-
qb.queryBuilder = qb;
|
|
1842
1843
|
}
|
|
1843
1844
|
const result = {
|
|
1844
1845
|
$transaction: transaction,
|
|
@@ -1861,10 +1862,10 @@ const orchidORM = (_a, tables) => {
|
|
|
1861
1862
|
language: table.language,
|
|
1862
1863
|
scopes: table.scopes,
|
|
1863
1864
|
softDelete: table.softDelete,
|
|
1864
|
-
snakeCase: table.snakeCase
|
|
1865
|
+
snakeCase: table.snakeCase,
|
|
1866
|
+
comment: table.comment,
|
|
1867
|
+
noPrimaryKey: table.noPrimaryKey ? "ignore" : void 0
|
|
1865
1868
|
});
|
|
1866
|
-
if (table.noPrimaryKey)
|
|
1867
|
-
options2.noPrimaryKey = "ignore";
|
|
1868
1869
|
const dbTable = new pqb.Db(
|
|
1869
1870
|
adapter,
|
|
1870
1871
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1873,7 +1874,8 @@ const orchidORM = (_a, tables) => {
|
|
|
1873
1874
|
table.columns,
|
|
1874
1875
|
table.types,
|
|
1875
1876
|
transactionStorage,
|
|
1876
|
-
options2
|
|
1877
|
+
options2,
|
|
1878
|
+
(_a2 = table.constructor.prototype.tableData) != null ? _a2 : {}
|
|
1877
1879
|
);
|
|
1878
1880
|
dbTable.definedAs = key;
|
|
1879
1881
|
dbTable.db = result;
|
|
@@ -1945,13 +1947,13 @@ exports.createBaseTable = createBaseTable;
|
|
|
1945
1947
|
exports.createRepo = createRepo;
|
|
1946
1948
|
exports.orchidORM = orchidORM;
|
|
1947
1949
|
Object.keys(pqb).forEach(function (k) {
|
|
1948
|
-
if (k !== 'default' && !
|
|
1950
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1949
1951
|
enumerable: true,
|
|
1950
1952
|
get: function () { return pqb[k]; }
|
|
1951
1953
|
});
|
|
1952
1954
|
});
|
|
1953
1955
|
Object.keys(orchidCore).forEach(function (k) {
|
|
1954
|
-
if (k !== 'default' && !
|
|
1956
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1955
1957
|
enumerable: true,
|
|
1956
1958
|
get: function () { return orchidCore[k]; }
|
|
1957
1959
|
});
|