orchid-orm 1.31.3 → 1.31.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 +17 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -189,7 +189,7 @@ interface FromQuery extends Query {
|
|
|
189
189
|
returnType: 'all';
|
|
190
190
|
}
|
|
191
191
|
type OrchidORM<T extends TableClasses = TableClasses> = {
|
|
192
|
-
[K in keyof T]:
|
|
192
|
+
[K in keyof T]: ORMTableInputToQueryBuilder<InstanceType<T[K]>>;
|
|
193
193
|
} & {
|
|
194
194
|
$transaction: typeof transaction;
|
|
195
195
|
$adapter: Adapter;
|
|
@@ -370,7 +370,7 @@ type RelationThunk = BelongsTo | HasOne | HasMany | HasAndBelongsToMany;
|
|
|
370
370
|
interface RelationThunks {
|
|
371
371
|
[K: string]: RelationThunk;
|
|
372
372
|
}
|
|
373
|
-
type RelationScopeOrTable<Relation extends RelationThunkBase> = Relation['options']['scope'] extends (q: Query) => Query ? ReturnType<Relation['options']['scope']> :
|
|
373
|
+
type RelationScopeOrTable<Relation extends RelationThunkBase> = Relation['options']['scope'] extends (q: Query) => Query ? ReturnType<Relation['options']['scope']> : ORMTableInputToQueryBuilder<InstanceType<ReturnType<Relation['fn']>>>;
|
|
374
374
|
interface RelationConfigSelf {
|
|
375
375
|
columns: {
|
|
376
376
|
shape: ColumnsShapeBase;
|
|
@@ -383,23 +383,27 @@ type MapRelations<T> = T extends RelationConfigSelf ? {
|
|
|
383
383
|
[K in keyof T['relations'] & string]: MapRelation<T, K, RelationScopeOrTable<T['relations'][K]>>;
|
|
384
384
|
} : EmptyObject;
|
|
385
385
|
|
|
386
|
-
interface TableClass<T extends
|
|
386
|
+
interface TableClass<T extends ORMTableInput = ORMTableInput> {
|
|
387
387
|
new (): T;
|
|
388
388
|
instance(): T;
|
|
389
389
|
}
|
|
390
390
|
interface TableClasses {
|
|
391
391
|
[K: string]: TableClass;
|
|
392
392
|
}
|
|
393
|
-
interface
|
|
394
|
-
relations: Relations;
|
|
393
|
+
interface TableInfo {
|
|
395
394
|
definedAs: string;
|
|
396
395
|
db: OrchidORM;
|
|
397
396
|
getFilePath(): string;
|
|
398
397
|
name: string;
|
|
399
398
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
interface
|
|
399
|
+
interface Table extends Query, TableInfo {
|
|
400
|
+
}
|
|
401
|
+
interface TableToDb<T extends ORMTableInput, Relations extends RelationsBase> extends TableInfo, Db<T['table'], T['columns']['shape'], keyof ShapeColumnPrimaryKeys<T['columns']['shape']> extends never ? never : ShapeColumnPrimaryKeys<T['columns']['shape']>, ShapeUniqueColumns<T['columns']['shape']> | TableDataItemsUniqueColumns<T['columns']['shape'], T['columns']['data']>, TableDataItemsUniqueColumnTuples<T['columns']['shape'], T['columns']['data']>, UniqueConstraints<T['columns']['shape']> | TableDataItemsUniqueConstraints<T['columns']['data']>, T['types'], T['columns']['shape'] & ComputedColumnsFromOptions<T['computed']>, MapTableScopesOption<T>> {
|
|
402
|
+
relations: Relations;
|
|
403
|
+
}
|
|
404
|
+
type ORMTableInputToQueryBuilder<T extends ORMTableInput> = T extends RelationConfigSelf ? TableToDb<T, MapRelations<T>> & MapRelations<T> : TableToDb<T, RelationsBase>;
|
|
405
|
+
type ScopeFn<Related extends TableClass, Scope extends Query> = (q: ORMTableInputToQueryBuilder<InstanceType<Related>>) => Scope;
|
|
406
|
+
interface ORMTableInput {
|
|
403
407
|
table: string;
|
|
404
408
|
columns: {
|
|
405
409
|
shape: ColumnsShapeBase;
|
|
@@ -418,12 +422,12 @@ interface Table {
|
|
|
418
422
|
readonly softDelete?: true | string;
|
|
419
423
|
comment?: string;
|
|
420
424
|
}
|
|
421
|
-
type Queryable<T extends
|
|
425
|
+
type Queryable<T extends ORMTableInput> = Simplify<{
|
|
422
426
|
[K in keyof T['columns']['shape']]?: T['columns']['shape'][K]['queryType'];
|
|
423
427
|
}>;
|
|
424
|
-
type Selectable<T extends
|
|
425
|
-
type Insertable<T extends
|
|
426
|
-
type Updatable<T extends
|
|
428
|
+
type Selectable<T extends ORMTableInput> = Simplify<ColumnShapeOutput<T['columns']['shape']>>;
|
|
429
|
+
type Insertable<T extends ORMTableInput> = Simplify<ColumnShapeInput<T['columns']['shape']>>;
|
|
430
|
+
type Updatable<T extends ORMTableInput> = Simplify<ColumnShapeInputPartial<T['columns']['shape']>>;
|
|
427
431
|
type BeforeHookMethod = (cb: QueryBeforeHook) => void;
|
|
428
432
|
type AfterHookMethod = (cb: QueryAfterHook) => void;
|
|
429
433
|
type AfterSelectableHookMethod = <Shape extends QueryColumns, S extends (keyof Shape)[]>(this: {
|
|
@@ -649,4 +653,4 @@ type Repo<T extends Query, Methods extends MethodsBase<T>> = (<Q extends {
|
|
|
649
653
|
}>(q: Q) => Query & Q & MapMethods<T, Methods>) & T & MapMethods<T, Methods>;
|
|
650
654
|
declare const createRepo: <T extends Query, Methods extends MethodsBase<T>>(table: T, methods: Methods) => Repo<T, Methods>;
|
|
651
655
|
|
|
652
|
-
export { BaseTableClass, BaseTableInstance,
|
|
656
|
+
export { BaseTableClass, BaseTableInstance, Insertable, MapMethods, MapQueryMethods, MethodsBase, ORMTableInput, ORMTableInputToQueryBuilder, OrchidORM, Queryable, Repo, ScopeFn, Selectable, SetColumnsResult, Table, TableClass, TableClasses, TableInfo, TableToDb, Updatable, createBaseTable, createRepo, orchidORM };
|