orchid-orm 1.68.4 → 1.68.6
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 +7 -2
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/dist/index.mjs.map +1 -1
- package/dist/migrations/index.js +59 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/index.mjs +59 -2
- package/dist/migrations/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Adapter, AfterCommitStandaloneHook, AfterHook, Column, ColumnSchemaConfig, ColumnsShape, ComputedColumnsFromOptions, ComputedOptionsConfig, ComputedOptionsFactory, CreateData, CreateManyMethodsNames, CreateMethodsNames, DbSharedOptions, DbSqlMethod, DbTableOptionScopes, DefaultColumnTypes, DefaultSchemaConfig, DeleteMethodsNames, EmptyObject, FromArg, FromResult, IsQuery, IsolationLevel, JoinQueryMethod, MapTableScopesOption, MaybeArray, MergeQuery, QueryAfterHook, QueryBeforeActionHook, QueryBeforeHook, QueryData, QueryHasWhere, QueryManyTake, QueryManyTakeOptional, QueryOrExpression, QueryReturnType, QuerySchema, QueryScopes, RecordUnknown, RelationConfigBase, SelectableFromShape, ShallowSimplify, ShapeColumnPrimaryKeys, ShapeUniqueColumns, StorageOptions, TableData, TableDataFn, TableDataItem, TableDataItemsUniqueColumnTuples, TableDataItemsUniqueColumns, TableDataItemsUniqueConstraints, TransactionOptions, UniqueConstraints, UpdateData, WhereArg } from "pqb/internal";
|
|
1
|
+
import { Adapter, AfterCommitStandaloneHook, AfterHook, Column, ColumnSchemaConfig, ColumnsShape, ComputedColumnsFromOptions, ComputedOptionsConfig, ComputedOptionsFactory, CreateData, CreateManyMethodsNames, CreateMethodsNames, DbSharedOptions, DbSqlMethod, DbTableOptionScopes, DefaultColumnTypes, DefaultSchemaConfig, DeleteMethodsNames, EmptyObject, FromArg, FromResult, IsQuery, IsolationLevel, JoinQueryMethod, MapTableScopesOption, MaybeArray, MergeQuery, QueryAfterHook, QueryBeforeActionHook, QueryBeforeHook, QueryData, QueryHasWhere, QueryManyTake, QueryManyTakeOptional, QueryOrExpression, QueryReturnType, QuerySchema, QueryScopes, RecordUnknown, RelationConfigBase, SelectableFromShape, ShallowSimplify, ShapeColumnPrimaryKeys, ShapeUniqueColumns, StorageOptions, TableData, TableDataFn, TableDataItem, TableDataItemsUniqueColumnTuples, TableDataItemsUniqueColumns, TableDataItemsUniqueConstraints, TableRlsConfig, TransactionOptions, UniqueConstraints, UpdateData, WhereArg } from "pqb/internal";
|
|
2
2
|
import { Db, Query } from "pqb";
|
|
3
3
|
export * from "pqb";
|
|
4
4
|
interface RelationRefsOptions<Column extends PropertyKey = string, Shape extends Column.Shape.QueryInit = Column.Shape.QueryInit> {
|
|
@@ -177,6 +177,10 @@ interface FromQuery extends Query {
|
|
|
177
177
|
type OrchidORM<T extends TableClasses = TableClasses> = { [K in keyof T]: T[K] extends {
|
|
178
178
|
new (): infer R extends ORMTableInput;
|
|
179
179
|
} ? TableToDb<R> : never } & OrchidORMMethods;
|
|
180
|
+
/**
|
|
181
|
+
* Identity helper for table row-level security configuration.
|
|
182
|
+
*/
|
|
183
|
+
declare const defineRls: <T extends TableRlsConfig>(rls: T) => T;
|
|
180
184
|
interface OrchidORMMethods {
|
|
181
185
|
/**
|
|
182
186
|
* @see import('pqb').QueryTransaction.prototype.transaction
|
|
@@ -482,6 +486,7 @@ interface ORMTableInput {
|
|
|
482
486
|
scopes?: RecordUnknown;
|
|
483
487
|
readonly softDelete?: true | string;
|
|
484
488
|
comment?: string;
|
|
489
|
+
rls?: TableRlsConfig;
|
|
485
490
|
autoForeignKeys?: TableData.References.BaseOptions | boolean;
|
|
486
491
|
}
|
|
487
492
|
type Queryable<T extends ORMTableInput> = ShallowSimplify<{ [K in keyof T['columns']['shape']]?: T['columns']['shape'][K]['queryType'] }>;
|
|
@@ -755,4 +760,4 @@ declare const createRepo: <T extends Query, Methods extends MethodsBase<T>>(tabl
|
|
|
755
760
|
table: T["table"];
|
|
756
761
|
shape: T["shape"];
|
|
757
762
|
}>(q: Q) => Query & Q & MapMethods<T, Methods>) & T, Methods>;
|
|
758
|
-
export { BaseTableClass, BaseTableInstance, DefaultSelect, FromQuery, Insertable, MapMethods, MapQueryMethods, MethodsBase, ORMTableInput, OrchidORM, OrchidOrmParam, Queryable, Repo, Selectable, SetColumnsResult, Table, TableClass, TableClasses, TableInfo, TableToDb, Updatable, createBaseTable, createRepo, orchidORMWithAdapter };
|
|
763
|
+
export { BaseTableClass, BaseTableInstance, DefaultSelect, FromQuery, Insertable, MapMethods, MapQueryMethods, MethodsBase, ORMTableInput, OrchidORM, OrchidOrmParam, Queryable, Repo, Selectable, SetColumnsResult, Table, TableClass, TableClasses, TableInfo, TableToDb, Updatable, createBaseTable, createRepo, defineRls, orchidORMWithAdapter };
|
package/dist/index.js
CHANGED
|
@@ -1371,6 +1371,10 @@ function isInTransaction() {
|
|
|
1371
1371
|
function afterCommit(hook) {
|
|
1372
1372
|
this.$qb.afterCommit(hook);
|
|
1373
1373
|
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Identity helper for table row-level security configuration.
|
|
1376
|
+
*/
|
|
1377
|
+
const defineRls = (rls) => rls;
|
|
1374
1378
|
const orchidORMWithAdapter = ({ log, logger, autoPreparedStatements, noPrimaryKey = "error", schema, ...options }, tables) => {
|
|
1375
1379
|
const commonOptions = {
|
|
1376
1380
|
log,
|
|
@@ -1390,6 +1394,7 @@ const orchidORMWithAdapter = ({ log, logger, autoPreparedStatements, noPrimaryKe
|
|
|
1390
1394
|
asyncStorage = new node_async_hooks.AsyncLocalStorage();
|
|
1391
1395
|
qb = (0, pqb_internal._initQueryBuilder)(adapter, (0, pqb_internal.makeColumnTypes)(pqb_internal.defaultSchemaConfig), asyncStorage, commonOptions, options);
|
|
1392
1396
|
}
|
|
1397
|
+
qb.internal.rls = options.rls;
|
|
1393
1398
|
const result = {
|
|
1394
1399
|
$transaction: transaction,
|
|
1395
1400
|
$ensureTransaction: ensureTransaction,
|
|
@@ -1432,6 +1437,7 @@ const orchidORMWithAdapter = ({ log, logger, autoPreparedStatements, noPrimaryKe
|
|
|
1432
1437
|
dbTable.db = result;
|
|
1433
1438
|
dbTable.filePath = table.filePath;
|
|
1434
1439
|
dbTable.name = table.constructor.name;
|
|
1440
|
+
dbTable.internal.tableRls = table.rls;
|
|
1435
1441
|
result[key] = dbTable;
|
|
1436
1442
|
}
|
|
1437
1443
|
applyRelations(qb, tableInstances, result, schema);
|
|
@@ -1476,6 +1482,7 @@ const createRepo = (table, methods) => {
|
|
|
1476
1482
|
};
|
|
1477
1483
|
exports.createBaseTable = createBaseTable;
|
|
1478
1484
|
exports.createRepo = createRepo;
|
|
1485
|
+
exports.defineRls = defineRls;
|
|
1479
1486
|
exports.orchidORMWithAdapter = orchidORMWithAdapter;
|
|
1480
1487
|
Object.keys(pqb).forEach(function(k) {
|
|
1481
1488
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|