pqb 0.65.3 → 0.65.5
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 +23 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4380,6 +4380,13 @@ declare class SoftDeleteMethods {
|
|
|
4380
4380
|
interface QueryInternalColumnNameToKey {
|
|
4381
4381
|
columnNameToKeyMap?: Map<string, string>;
|
|
4382
4382
|
}
|
|
4383
|
+
interface TableRlsConfig {
|
|
4384
|
+
enable?: boolean;
|
|
4385
|
+
force?: boolean;
|
|
4386
|
+
}
|
|
4387
|
+
interface DbRlsOptions {
|
|
4388
|
+
tableRlsDefaults?: TableRlsConfig;
|
|
4389
|
+
}
|
|
4383
4390
|
declare namespace DefaultPrivileges {
|
|
4384
4391
|
export type ObjectType = (typeof DEFAULT_PRIVILEGE.OBJECT_TYPES)[number];
|
|
4385
4392
|
export interface Privilege {
|
|
@@ -4473,6 +4480,8 @@ interface QueryInternal<SinglePrimaryKey = any, UniqueColumns = any, UniqueColum
|
|
|
4473
4480
|
domains?: DbDomainArgRecord;
|
|
4474
4481
|
generatorIgnore?: GeneratorIgnore;
|
|
4475
4482
|
roles?: DbRole[];
|
|
4483
|
+
rls?: DbRlsOptions;
|
|
4484
|
+
tableRls?: TableRlsConfig;
|
|
4476
4485
|
managedRolesSql?: string;
|
|
4477
4486
|
tableData: TableData;
|
|
4478
4487
|
nowSQL?: string;
|
|
@@ -4490,6 +4499,7 @@ type NoPrimaryKeyOption = 'error' | 'warning' | 'ignore';
|
|
|
4490
4499
|
interface DbSharedOptions extends QueryLogOptions {
|
|
4491
4500
|
autoPreparedStatements?: boolean;
|
|
4492
4501
|
noPrimaryKey?: NoPrimaryKeyOption;
|
|
4502
|
+
rls?: DbRlsOptions;
|
|
4493
4503
|
extensions?: (string | RecordString)[];
|
|
4494
4504
|
domains?: {
|
|
4495
4505
|
[K: string]: DbDomainArg<DefaultColumnTypes<DefaultSchemaConfig>>;
|
|
@@ -7284,10 +7294,11 @@ declare class QueryCreateFrom {
|
|
|
7284
7294
|
interface CreateSelf extends IsQuery, PickQueryHasSelect, PickQueryDefaults, PickQueryResult, PickQueryRelations, PickQueryWithData, PickQueryReturnType, PickQueryShape, PickQueryUniqueProperties, PickQueryInputType {}
|
|
7285
7295
|
type CreateData<T extends CreateSelf> = EmptyObject extends T['relations'] ? CreateDataWithDefaults<T, keyof T['__defaults']> : CreateRelationsData<T>;
|
|
7286
7296
|
type CreateDataWithDefaults<T extends CreateSelf, Defaults extends PropertyKey> = { [K in keyof T['inputType'] as K extends Defaults ? never : K]: K extends Defaults ? never : CreateColumn<T, K> } & { [K in Defaults]?: K extends keyof T['inputType'] ? CreateColumn<T, K> : never };
|
|
7287
|
-
type CreateDataWithDefaultsForRelations<T extends CreateSelf, Defaults extends keyof T['inputType'], OmitFKeys extends PropertyKey> = { [K in keyof T['inputType'] as K extends Defaults | OmitFKeys ? never : K]: K extends Defaults | OmitFKeys ? never : CreateColumn<T, K> } & { [K in
|
|
7297
|
+
type CreateDataWithDefaultsForRelations<T extends CreateSelf, Defaults extends keyof T['inputType'], OmitFKeys extends PropertyKey> = { [K in keyof T['inputType'] as K extends Defaults | OmitFKeys ? never : K]: K extends Defaults | OmitFKeys ? never : CreateColumn<T, K> } & { [K in Defaults as K extends OmitFKeys ? never : K]?: CreateColumn<T, K> };
|
|
7288
7298
|
type CreateColumn<T extends CreateSelf, K extends keyof T['inputType']> = T['inputType'][K] | ((q: T) => QueryOrExpression<T['inputType'][K]>);
|
|
7289
|
-
type CreateRelationsData<T extends CreateSelf> = CreateDataWithDefaultsForRelations<T, keyof T['__defaults'], T['relations'][keyof T['relations']]['
|
|
7290
|
-
type CreateBelongsToData<T extends CreateSelf> = [T['relations'][keyof T['relations']]['dataForCreate']] extends [never] ? EmptyObject : T['relations'][keyof T['relations']]['dataForCreate']
|
|
7299
|
+
type CreateRelationsData<T extends CreateSelf> = CreateDataWithDefaultsForRelations<T, keyof T['__defaults'], T['relations'][keyof T['relations']]['omitForeignKeyInCreate']> & CreateBelongsToData<T> & T['relations'][keyof T['relations']]['optionalDataForCreate'];
|
|
7300
|
+
type CreateBelongsToData<T extends CreateSelf> = [T['relations'][keyof T['relations']]['dataForCreate']] extends [never] ? EmptyObject : CreateRelationsDataOmittingFKeys<T, T['relations'][keyof T['relations']]['dataForCreate']>;
|
|
7301
|
+
type CreateRelationsDataOmittingFKeys<T extends CreateSelf, Union> = (Union extends RelationConfigDataForCreate ? (u: Union['columns'] extends keyof T['__defaults'] ? { [P in Exclude<Union['columns'] & keyof T['inputType'], keyof T['__defaults']>]: CreateColumn<T, P> } & { [P in keyof T['__defaults'] & Union['columns']]?: CreateColumn<T, P> } & Partial<Union['nested']> : { [P in Union['columns'] & keyof T['inputType']]: CreateColumn<T, P> } | Union['nested']) => void : never) extends ((u: infer Obj) => void) ? Obj : never;
|
|
7291
7302
|
type CreateResult<T extends CreateSelf, Data> = T extends {
|
|
7292
7303
|
isCount: true;
|
|
7293
7304
|
} ? T : T['returnType'] extends undefined | 'all' ? SetQueryReturnsOneResult<T, NarrowCreateResult<T, Data>> : T['returnType'] extends 'pluck' ? SetQueryReturnsColumnResult<T, NarrowCreateResult<T, Data>> : SetQueryResult<T, NarrowCreateResult<T, Data>>;
|
|
@@ -7302,7 +7313,7 @@ type InsertManyResult<T extends CreateSelf> = T['__hasSelect'] extends true ? T[
|
|
|
7302
7313
|
*
|
|
7303
7314
|
* The same should work as well with any non-null columns passed to `create`, but it's to be implemented later.
|
|
7304
7315
|
*/
|
|
7305
|
-
type NarrowCreateResult<T extends CreateSelf, Data> = EmptyObject extends T['relations'] ? T['result'] : { [K in keyof T['result']]: true extends { [R in keyof T['relations']]: K extends T['relations'][R]['
|
|
7316
|
+
type NarrowCreateResult<T extends CreateSelf, Data> = EmptyObject extends T['relations'] ? T['result'] : { [K in keyof T['result']]: true extends { [R in keyof T['relations']]: K extends T['relations'][R]['omitForeignKeyInCreate'] ? R extends keyof Data ? true : T['relations'][R]['omitForeignKeyInCreate'] extends keyof Data ? null | undefined extends Data[T['relations'][R]['omitForeignKeyInCreate']] ? never : true : never : never }[keyof T['relations']] ? Column.Pick.QueryColumnOfTypeAndOps<string, Exclude<T['result'][K]['outputType'], null>, T['result'][K]['operators']> : T['result'][K] };
|
|
7306
7317
|
type IgnoreResult<T extends CreateSelf> = T['returnType'] extends 'oneOrThrow' ? QueryTakeOptional<T> : T['returnType'] extends 'valueOrThrow' ? SetQueryReturnsColumnOptional<T, T['result']['value']> : T;
|
|
7307
7318
|
type OnConflictArg<T extends PickQueryUniqueProperties> = T['internal']['uniqueColumnNames'] | T['internal']['uniqueColumnTuples'] | Expression | {
|
|
7308
7319
|
constraint: T['internal']['uniqueConstraints'];
|
|
@@ -7329,8 +7340,7 @@ declare const _queryDefaults: <T extends CreateSelf, Data extends Partial<Create
|
|
|
7329
7340
|
*/
|
|
7330
7341
|
type CreateMethodsNames = 'create' | 'insert' | 'createMany' | 'insertMany' | CreateFromMethodNames;
|
|
7331
7342
|
type CreateManyMethodsNames = 'createMany' | 'insertMany' | CreateManyFromMethodNames;
|
|
7332
|
-
type
|
|
7333
|
-
type ExtraPropertiesAreNotAllowed<T extends CreateSelf, Data> = keyof Data extends keyof T['inputType'] | keyof T['relations'] ? CollectMissingColumns<T, Data> extends false ? Data : `Missing ${CollectMissingColumns<T, Data> & string}` : `Extra properties are not allowed: ${Exclude<keyof Data, keyof T['inputType'] | keyof T['relations']> & string}`;
|
|
7343
|
+
type ExtraPropertiesAreNotAllowed<T extends CreateSelf, Data> = keyof Data extends keyof T['inputType'] | keyof T['relations'] ? Data : `Extra properties are not allowed: ${Exclude<keyof Data, keyof T['inputType'] | keyof T['relations']> & string}`;
|
|
7334
7344
|
declare class QueryCreate {
|
|
7335
7345
|
/**
|
|
7336
7346
|
* `create` and `insert` create a single record.
|
|
@@ -10142,13 +10152,17 @@ interface RelationConfigBase extends IsQuery {
|
|
|
10142
10152
|
queryRelated(params: unknown): unknown;
|
|
10143
10153
|
modifyRelatedQuery?(relatedQuery: IsQuery): (query: IsQuery) => void;
|
|
10144
10154
|
maybeSingle: PickQuerySelectableReturnType;
|
|
10145
|
-
|
|
10146
|
-
dataForCreate
|
|
10155
|
+
omitForeignKeyInCreate: PropertyKey;
|
|
10156
|
+
dataForCreate?: RelationConfigDataForCreate;
|
|
10147
10157
|
optionalDataForCreate: unknown;
|
|
10148
10158
|
dataForUpdate: unknown;
|
|
10149
10159
|
dataForUpdateOne: unknown;
|
|
10150
10160
|
primaryKeys: string[];
|
|
10151
10161
|
}
|
|
10162
|
+
interface RelationConfigDataForCreate {
|
|
10163
|
+
columns: PropertyKey;
|
|
10164
|
+
nested: RecordUnknown;
|
|
10165
|
+
}
|
|
10152
10166
|
interface RelationsBase {
|
|
10153
10167
|
[K: string]: RelationConfigBase;
|
|
10154
10168
|
}
|
|
@@ -10457,4 +10471,4 @@ declare const testTransaction: {
|
|
|
10457
10471
|
*/
|
|
10458
10472
|
close(arg: Arg$1): Promise<void>;
|
|
10459
10473
|
};
|
|
10460
|
-
export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type FromArg, type FromResult, type GeneratorIgnore, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinQueryMethod, type JoinedShapes, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, OrchidOrmInternalError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type Query, type QueryAfterHook, type QueryArraysResult, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, QueryError, type QueryHasWhere, type QueryHelperResult, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, snakeCaseKey, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
|
|
10474
|
+
export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbRlsOptions, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type FromArg, type FromResult, type GeneratorIgnore, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinQueryMethod, type JoinedShapes, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, OrchidOrmInternalError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type Query, type QueryAfterHook, type QueryArraysResult, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, QueryError, type QueryHasWhere, type QueryHelperResult, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TableRlsConfig, type TemplateLiteralArgs, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, snakeCaseKey, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
|