@rvoh/dream 0.40.2 → 0.40.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/cjs/src/helpers/cli/generateFactoryContent.js +6 -4
- package/dist/cjs/src/types/associations/belongsTo.js +2 -0
- package/dist/cjs/src/types/associations/hasMany.js +2 -0
- package/dist/cjs/src/types/associations/hasOne.js +2 -0
- package/dist/cjs/src/types/associations/shared.js +2 -0
- package/dist/cjs/src/types/db.js +2 -0
- package/dist/cjs/src/types/dream.js +2 -0
- package/dist/cjs/src/types/lifecycle.js +2 -0
- package/dist/cjs/src/types/logger.js +2 -0
- package/dist/cjs/src/types/openapi.js +2 -0
- package/dist/cjs/src/types/query.js +2 -0
- package/dist/cjs/src/types/utils.js +2 -0
- package/dist/cjs/src/types/validation.js +2 -0
- package/dist/cjs/src/types/variadic.js +2 -0
- package/dist/esm/src/helpers/cli/generateFactoryContent.js +6 -4
- package/dist/esm/src/types/associations/belongsTo.js +1 -0
- package/dist/esm/src/types/associations/hasMany.js +1 -0
- package/dist/esm/src/types/associations/hasOne.js +1 -0
- package/dist/esm/src/types/associations/shared.js +1 -0
- package/dist/esm/src/types/db.js +1 -0
- package/dist/esm/src/types/dream.js +1 -0
- package/dist/esm/src/types/lifecycle.js +1 -0
- package/dist/esm/src/types/logger.js +1 -0
- package/dist/esm/src/types/openapi.js +1 -0
- package/dist/esm/src/types/query.js +1 -0
- package/dist/esm/src/types/utils.js +1 -0
- package/dist/esm/src/types/validation.js +1 -0
- package/dist/esm/src/types/variadic.js +1 -0
- package/dist/types/src/types/associations/belongsTo.d.ts +28 -73
- package/dist/types/src/types/associations/belongsTo.ts +76 -0
- package/dist/types/src/types/associations/hasMany.d.ts +15 -79
- package/dist/types/src/types/associations/hasMany.ts +80 -0
- package/dist/types/src/types/associations/hasOne.d.ts +8 -26
- package/dist/types/src/types/associations/hasOne.ts +26 -0
- package/dist/types/src/types/associations/shared.d.ts +98 -444
- package/dist/types/src/types/associations/shared.ts +450 -0
- package/dist/types/src/types/db.d.ts +9 -14
- package/dist/types/src/types/db.ts +14 -0
- package/dist/types/src/types/dream.d.ts +124 -510
- package/dist/types/src/types/dream.ts +521 -0
- package/dist/types/src/types/lifecycle.d.ts +23 -42
- package/dist/types/src/types/lifecycle.ts +50 -0
- package/dist/types/src/types/logger.d.ts +6 -40
- package/dist/types/src/types/logger.ts +42 -0
- package/dist/types/src/types/openapi.d.ts +105 -222
- package/dist/types/src/types/openapi.ts +255 -0
- package/dist/types/src/types/query.d.ts +53 -161
- package/dist/types/src/types/query.ts +165 -0
- package/dist/types/src/types/utils.d.ts +83 -141
- package/dist/types/src/types/utils.ts +173 -0
- package/dist/types/src/types/validation.d.ts +17 -18
- package/dist/types/src/types/validation.ts +20 -0
- package/dist/types/src/types/variadic.d.ts +42 -444
- package/dist/types/src/types/variadic.ts +447 -0
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/Decorators.html +19 -19
- package/docs/classes/Dream.html +132 -132
- package/docs/classes/DreamApp.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamLogos.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializer.html +2 -2
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/Query.html +52 -52
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/Attribute.html +1 -1
- package/docs/functions/RendersMany.html +1 -1
- package/docs/functions/RendersOne.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sort.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/untypedDb.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/interfaces/AttributeStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamAppInitOptions.html +2 -2
- package/docs/interfaces/DreamAppOpts.html +2 -2
- package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DbConnectionType.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
- package/docs/types/SerializableDreamOrViewModel.html +1 -1
- package/docs/types/SerializableTypes.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModelSerializerKey.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +1 -1
|
@@ -1,450 +1,104 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from '
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
TableColumnNames,
|
|
24
|
-
TableColumnType,
|
|
25
|
-
TableNameForGlobalModelName,
|
|
26
|
-
TrigramOperator,
|
|
27
|
-
} from '../dream.js'
|
|
28
|
-
import { Inc, MergeUnionOfRecordTypes, ReadonlyTail, UnionToIntersection } from '../utils.ts'
|
|
29
|
-
import { JoinedAssociation } from '../variadic.js'
|
|
30
|
-
import { BelongsToStatement } from './belongsTo.ts'
|
|
31
|
-
import { HasManyStatement } from './hasMany.ts'
|
|
32
|
-
import { HasOneStatement } from './hasOne.ts'
|
|
33
|
-
|
|
34
|
-
export type MAX_JOINED_TABLES_DEPTH = 25
|
|
35
|
-
|
|
36
|
-
export type AssociationMetadataMap = Record<string, AssociationStatement>
|
|
37
|
-
|
|
38
|
-
export type AssociatedBelongsToModelType<
|
|
39
|
-
I extends Dream,
|
|
40
|
-
AssociationName extends keyof DreamBelongsToAssociationMetadata<I>,
|
|
41
|
-
PossibleArrayAssociationType extends I[AssociationName & keyof I] = I[AssociationName & keyof I],
|
|
42
|
-
AssociationType extends PossibleArrayAssociationType extends (infer ElementType)[]
|
|
43
|
-
? ElementType
|
|
44
|
-
: PossibleArrayAssociationType = PossibleArrayAssociationType extends (infer ElementType)[]
|
|
45
|
-
? ElementType
|
|
46
|
-
: PossibleArrayAssociationType,
|
|
47
|
-
> = AssociationType
|
|
48
|
-
|
|
49
|
-
// For sending a BelongsTo model into a statement such as `await Post.create({ user })`
|
|
50
|
-
|
|
51
|
-
export type AssociatedModelParam<
|
|
52
|
-
I extends Dream,
|
|
53
|
-
AssociationExists = keyof DreamBelongsToAssociationMetadata<I> extends never ? false : true,
|
|
54
|
-
AssociationName = AssociationExists extends false
|
|
55
|
-
? never
|
|
56
|
-
: keyof DreamBelongsToAssociationMetadata<I> & string,
|
|
57
|
-
RetObj = AssociationExists extends false
|
|
58
|
-
? never
|
|
59
|
-
: AssociationName extends never
|
|
60
|
-
? never
|
|
61
|
-
: {
|
|
62
|
-
[K in AssociationName &
|
|
63
|
-
keyof DreamBelongsToAssociationMetadata<I> &
|
|
64
|
-
string]: AssociatedBelongsToModelType<I, K> | null
|
|
65
|
-
},
|
|
66
|
-
> = Partial<UnionToIntersection<RetObj>>
|
|
67
|
-
|
|
68
|
-
export type PassthroughOnClause<PassthroughColumns extends string[]> = Partial<
|
|
69
|
-
Record<PassthroughColumns[number], any>
|
|
70
|
-
>
|
|
1
|
+
import { ComparisonOperatorExpression as KyselyComparisonOperatorExpression, SelectQueryBuilder, Updateable } from 'kysely';
|
|
2
|
+
import Dream from '../../Dream.js';
|
|
3
|
+
import { DreamConst } from '../../dream/constants.js';
|
|
4
|
+
import CalendarDate from '../../helpers/CalendarDate.js';
|
|
5
|
+
import { DateTime } from '../../helpers/DateTime.js';
|
|
6
|
+
import { Range } from '../../helpers/range.js';
|
|
7
|
+
import CurriedOpsStatement from '../../ops/curried-ops-statement.js';
|
|
8
|
+
import OpsStatement, { ExtraSimilarityArgs } from '../../ops/ops-statement.js';
|
|
9
|
+
import { AssociationTableNames } from '../db.js';
|
|
10
|
+
import { DefaultScopeName, DefaultScopeNameForTable, DreamBelongsToAssociationMetadata, DreamColumnNames, GlobalModelNameTableMap, IdType, OrderDir, TableColumnEnumTypeArray, TableColumnNames, TableColumnType, TableNameForGlobalModelName, TrigramOperator } from '../dream.js';
|
|
11
|
+
import { Inc, MergeUnionOfRecordTypes, ReadonlyTail, UnionToIntersection } from '../utils.js';
|
|
12
|
+
import { JoinedAssociation } from '../variadic.js';
|
|
13
|
+
import { BelongsToStatement } from './belongsTo.js';
|
|
14
|
+
import { HasManyStatement } from './hasMany.js';
|
|
15
|
+
import { HasOneStatement } from './hasOne.js';
|
|
16
|
+
export type MAX_JOINED_TABLES_DEPTH = 25;
|
|
17
|
+
export type AssociationMetadataMap = Record<string, AssociationStatement>;
|
|
18
|
+
export type AssociatedBelongsToModelType<I extends Dream, AssociationName extends keyof DreamBelongsToAssociationMetadata<I>, PossibleArrayAssociationType extends I[AssociationName & keyof I] = I[AssociationName & keyof I], AssociationType extends PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType = PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType> = AssociationType;
|
|
19
|
+
export type AssociatedModelParam<I extends Dream, AssociationExists = keyof DreamBelongsToAssociationMetadata<I> extends never ? false : true, AssociationName = AssociationExists extends false ? never : keyof DreamBelongsToAssociationMetadata<I> & string, RetObj = AssociationExists extends false ? never : AssociationName extends never ? never : {
|
|
20
|
+
[K in AssociationName & keyof DreamBelongsToAssociationMetadata<I> & string]: AssociatedBelongsToModelType<I, K> | null;
|
|
21
|
+
}> = Partial<UnionToIntersection<RetObj>>;
|
|
22
|
+
export type PassthroughOnClause<PassthroughColumns extends string[]> = Partial<Record<PassthroughColumns[number], any>>;
|
|
71
23
|
type DreamSelectable<DB, Schema, TableName extends AssociationTableNames<DB, Schema> & keyof DB> = Partial<{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
type
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
| DateTime[]
|
|
94
|
-
| Range<DateTime>
|
|
95
|
-
| (() => Range<DateTime>)
|
|
96
|
-
| Range<CalendarDate>
|
|
97
|
-
| (() => Range<CalendarDate>)
|
|
98
|
-
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
99
|
-
: ColumnType extends CalendarDate
|
|
100
|
-
?
|
|
101
|
-
| CalendarDate[]
|
|
102
|
-
| Range<CalendarDate>
|
|
103
|
-
| (() => Range<CalendarDate>)
|
|
104
|
-
| Range<DateTime>
|
|
105
|
-
| (() => Range<DateTime>)
|
|
106
|
-
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType>
|
|
107
|
-
: ColumnType extends number
|
|
108
|
-
?
|
|
109
|
-
| (number | bigint)[]
|
|
110
|
-
| Range<number>
|
|
111
|
-
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
112
|
-
: ColumnType extends string
|
|
113
|
-
?
|
|
114
|
-
| string[]
|
|
115
|
-
| OpsStatement<KyselyComparisonOperatorExpression, string, any>
|
|
116
|
-
| OpsStatement<TrigramOperator, OpsValType, ExtraSimilarityArgs>
|
|
117
|
-
: ColumnType extends IdType
|
|
118
|
-
? IdType[] | OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
119
|
-
: never
|
|
120
|
-
: EnumTypeArray extends string[]
|
|
121
|
-
? EnumTypeArray | OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
122
|
-
: never,
|
|
123
|
-
> = PartialTypes extends never
|
|
124
|
-
?
|
|
125
|
-
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
126
|
-
| CurriedOpsStatement<any, any, any, OpsValType>
|
|
127
|
-
| SelectQueryBuilder<DB, keyof DB, any>
|
|
128
|
-
: PartialTypes | CurriedOpsStatement<any, any, any, OpsValType> | SelectQueryBuilder<DB, keyof DB, any>
|
|
129
|
-
|
|
130
|
-
export type WhereStatementForDreamClass<DreamClass extends typeof Dream> = WhereStatement<
|
|
131
|
-
InstanceType<DreamClass>['DB'],
|
|
132
|
-
InstanceType<DreamClass>['schema'],
|
|
133
|
-
InstanceType<DreamClass>['table']
|
|
134
|
-
>
|
|
135
|
-
|
|
136
|
-
export type WhereStatementForDream<DreamInstance extends Dream> = WhereStatement<
|
|
137
|
-
DreamInstance['DB'],
|
|
138
|
-
DreamInstance['schema'],
|
|
139
|
-
DreamInstance['table']
|
|
140
|
-
>
|
|
141
|
-
type AssociationNameToDotReferencedColumns<
|
|
142
|
-
DB,
|
|
143
|
-
TableName extends keyof DB,
|
|
144
|
-
AssociationName,
|
|
145
|
-
> = `${AssociationName & string}.${TableColumnNames<DB, TableName>}`
|
|
146
|
-
|
|
147
|
-
export type ColumnNamesAccountingForJoinedAssociations<
|
|
148
|
-
JoinedAssociations extends Readonly<JoinedAssociation[]>,
|
|
149
|
-
DB,
|
|
150
|
-
RootTableName extends keyof DB,
|
|
151
|
-
RootTableAlias extends string,
|
|
152
|
-
> = JoinedAssociations['length'] extends 0
|
|
153
|
-
? TableColumnNames<DB, RootTableName> // no associations; simply return the un-namespaced columns for the root table
|
|
154
|
-
: JoinedAssociationColumnNames<
|
|
155
|
-
JoinedAssociations,
|
|
156
|
-
DB,
|
|
157
|
-
// namespace columns for the root table
|
|
158
|
-
AssociationNameToDotReferencedColumns<DB, RootTableName & keyof DB, RootTableAlias>
|
|
159
|
-
>
|
|
160
|
-
type JoinedAssociationColumnNames<
|
|
161
|
-
JoinedAssociations extends Readonly<JoinedAssociation[]>,
|
|
162
|
-
DB,
|
|
163
|
-
AllColumnNames,
|
|
164
|
-
Depth extends number = 0,
|
|
165
|
-
CurrentJoinedAssociation = Readonly<JoinedAssociations[0]>,
|
|
166
|
-
NextTableName = CurrentJoinedAssociation extends Readonly<JoinedAssociation>
|
|
167
|
-
? CurrentJoinedAssociation['table']
|
|
168
|
-
: never,
|
|
169
|
-
NextAssociationName = CurrentJoinedAssociation extends Readonly<JoinedAssociation>
|
|
170
|
-
? CurrentJoinedAssociation['alias']
|
|
171
|
-
: never,
|
|
172
|
-
> = JoinedAssociations['length'] extends 0
|
|
173
|
-
? AllColumnNames
|
|
174
|
-
: Depth extends MAX_JOINED_TABLES_DEPTH
|
|
175
|
-
? AllColumnNames
|
|
176
|
-
: JoinedAssociationColumnNames<
|
|
177
|
-
ReadonlyTail<JoinedAssociations>,
|
|
178
|
-
DB,
|
|
179
|
-
| AllColumnNames
|
|
180
|
-
| AssociationNameToDotReferencedColumns<DB, NextTableName & keyof DB, NextAssociationName>,
|
|
181
|
-
Inc<Depth>
|
|
182
|
-
>
|
|
183
|
-
|
|
184
|
-
export type WhereStatement<
|
|
185
|
-
DB,
|
|
186
|
-
Schema,
|
|
187
|
-
TableName extends AssociationTableNames<DB, Schema> & keyof DB,
|
|
188
|
-
> = Partial<MergeUnionOfRecordTypes<Updateable<DB[TableName]> | DreamSelectable<DB, Schema, TableName>>>
|
|
189
|
-
|
|
190
|
-
export type OnStatementForAssociation<
|
|
191
|
-
DB,
|
|
192
|
-
Schema,
|
|
193
|
-
TableName extends AssociationTableNames<DB, Schema> & keyof DB,
|
|
194
|
-
RequiredOnClauseKeysForThisAssociation,
|
|
195
|
-
OnStatement extends WhereStatement<DB, Schema, TableName> = WhereStatement<DB, Schema, TableName>,
|
|
196
|
-
> = RequiredOnClauseKeysForThisAssociation extends null
|
|
197
|
-
? WhereStatement<DB, Schema, TableName>
|
|
198
|
-
: RequiredOnClauseKeysForThisAssociation extends string[]
|
|
199
|
-
? Required<Pick<OnStatement, RequiredOnClauseKeysForThisAssociation[number] & keyof OnStatement>> &
|
|
200
|
-
Partial<Omit<OnStatement, RequiredOnClauseKeysForThisAssociation[number] & keyof OnStatement>>
|
|
201
|
-
: never
|
|
202
|
-
// on statement on an association definition
|
|
203
|
-
type OnStatementForAssociationDefinition<
|
|
204
|
-
DB,
|
|
205
|
-
Schema,
|
|
206
|
-
TableName extends AssociationTableNames<DB, Schema> & keyof DB,
|
|
207
|
-
> = Partial<
|
|
208
|
-
MergeUnionOfRecordTypes<
|
|
209
|
-
| Updateable<DB[TableName]>
|
|
210
|
-
| Partial<{
|
|
211
|
-
[ColumnName in keyof DB[TableName]]:
|
|
212
|
-
| NonKyselySupportedSupplementalWhereClauseValues<DB, Schema, TableName, ColumnName>
|
|
213
|
-
| typeof DreamConst.passthrough
|
|
214
|
-
| typeof DreamConst.required
|
|
215
|
-
}>
|
|
216
|
-
>
|
|
217
|
-
>
|
|
218
|
-
|
|
219
|
-
export type SelfOnStatement<
|
|
220
|
-
BaseInstance extends Dream,
|
|
221
|
-
DB,
|
|
222
|
-
Schema,
|
|
223
|
-
TableName extends AssociationTableNames<DB, Schema> & keyof DB,
|
|
224
|
-
> = Partial<Record<keyof DB[TableName], DreamColumnNames<BaseInstance>>>
|
|
225
|
-
|
|
226
|
-
export type WhereStatementForJoinedAssociation<
|
|
227
|
-
JoinedAssociations extends Readonly<JoinedAssociation[]>,
|
|
228
|
-
DB,
|
|
229
|
-
Schema,
|
|
230
|
-
TableName extends AssociationTableNames<DB, Schema> & keyof DB,
|
|
231
|
-
> = RecursiveWhereStatementForJoinedAssociation<
|
|
232
|
-
JoinedAssociations,
|
|
233
|
-
DB,
|
|
234
|
-
Schema,
|
|
235
|
-
WhereStatement<DB, Schema, TableName>
|
|
236
|
-
>
|
|
237
|
-
type RecursiveWhereStatementForJoinedAssociation<
|
|
238
|
-
JoinedAssociations extends Readonly<JoinedAssociation[]>,
|
|
239
|
-
DB,
|
|
240
|
-
Schema,
|
|
241
|
-
OriginalOnStatement,
|
|
242
|
-
Depth extends number = 0,
|
|
243
|
-
CurrentJoinedAssociation = JoinedAssociations[0],
|
|
244
|
-
TableName = CurrentJoinedAssociation extends JoinedAssociation ? CurrentJoinedAssociation['table'] : never,
|
|
245
|
-
AssociationName = CurrentJoinedAssociation extends JoinedAssociation
|
|
246
|
-
? CurrentJoinedAssociation['alias']
|
|
247
|
-
: never,
|
|
248
|
-
NonNamespacedAssociationOnStatement = TableName extends never
|
|
249
|
-
? never
|
|
250
|
-
: AssociationName extends never
|
|
251
|
-
? never
|
|
252
|
-
: WhereStatement<DB, Schema, TableName & AssociationTableNames<DB, Schema> & keyof DB>,
|
|
253
|
-
NextOnStatement = NonNamespacedAssociationOnStatement extends never
|
|
254
|
-
? OriginalOnStatement
|
|
255
|
-
: OriginalOnStatement & {
|
|
256
|
-
[K in keyof NonNamespacedAssociationOnStatement as `${AssociationName & string}.${K & string}`]: NonNamespacedAssociationOnStatement[K &
|
|
257
|
-
keyof NonNamespacedAssociationOnStatement]
|
|
258
|
-
},
|
|
259
|
-
> = JoinedAssociations['length'] extends 0
|
|
260
|
-
? OriginalOnStatement
|
|
261
|
-
: Depth extends MAX_JOINED_TABLES_DEPTH
|
|
262
|
-
? OriginalOnStatement
|
|
263
|
-
: TableName extends never
|
|
264
|
-
? OriginalOnStatement
|
|
265
|
-
: RecursiveWhereStatementForJoinedAssociation<
|
|
266
|
-
ReadonlyTail<JoinedAssociations>,
|
|
267
|
-
DB,
|
|
268
|
-
Schema,
|
|
269
|
-
NextOnStatement,
|
|
270
|
-
Inc<Depth>
|
|
271
|
-
>
|
|
272
|
-
|
|
273
|
-
export type OrderStatement<DB, Schema, TableName extends AssociationTableNames<DB, Schema> & keyof DB> =
|
|
274
|
-
| TableColumnNames<DB, TableName>
|
|
275
|
-
| Partial<Record<TableColumnNames<DB, TableName>, OrderDir>>
|
|
276
|
-
|
|
277
|
-
export type LimitStatement = number
|
|
278
|
-
export type OffsetStatement = number
|
|
279
|
-
|
|
24
|
+
[ColumnName in keyof DB[TableName]]: NonKyselySupportedSupplementalWhereClauseValues<DB, Schema, TableName, ColumnName>;
|
|
25
|
+
}>;
|
|
26
|
+
type NonKyselySupportedSupplementalWhereClauseValues<DB, Schema, TableName, Column, ColumnType = TableColumnType<Schema, TableName, Column>, EnumTypeArray extends string[] | null = TableColumnEnumTypeArray<Schema, TableName, Column>, PermanentOpsValTypes = null | readonly [], OpsValType = EnumTypeArray extends string[] ? EnumTypeArray[number] | PermanentOpsValTypes : ColumnType | PermanentOpsValTypes, PartialTypes = EnumTypeArray extends null ? ColumnType extends DateTime ? DateTime[] | Range<DateTime> | (() => Range<DateTime>) | Range<CalendarDate> | (() => Range<CalendarDate>) | OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any> : ColumnType extends CalendarDate ? CalendarDate[] | Range<CalendarDate> | (() => Range<CalendarDate>) | Range<DateTime> | (() => Range<DateTime>) | OpsStatement<KyselyComparisonOperatorExpression, OpsValType> : ColumnType extends number ? (number | bigint)[] | Range<number> | OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any> : ColumnType extends string ? string[] | OpsStatement<KyselyComparisonOperatorExpression, string, any> | OpsStatement<TrigramOperator, OpsValType, ExtraSimilarityArgs> : ColumnType extends IdType ? IdType[] | OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any> : never : EnumTypeArray extends string[] ? EnumTypeArray | OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any> : never> = PartialTypes extends never ? OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any> | CurriedOpsStatement<any, any, any, OpsValType> | SelectQueryBuilder<DB, keyof DB, any> : PartialTypes | CurriedOpsStatement<any, any, any, OpsValType> | SelectQueryBuilder<DB, keyof DB, any>;
|
|
27
|
+
export type WhereStatementForDreamClass<DreamClass extends typeof Dream> = WhereStatement<InstanceType<DreamClass>['DB'], InstanceType<DreamClass>['schema'], InstanceType<DreamClass>['table']>;
|
|
28
|
+
export type WhereStatementForDream<DreamInstance extends Dream> = WhereStatement<DreamInstance['DB'], DreamInstance['schema'], DreamInstance['table']>;
|
|
29
|
+
type AssociationNameToDotReferencedColumns<DB, TableName extends keyof DB, AssociationName> = `${AssociationName & string}.${TableColumnNames<DB, TableName>}`;
|
|
30
|
+
export type ColumnNamesAccountingForJoinedAssociations<JoinedAssociations extends Readonly<JoinedAssociation[]>, DB, RootTableName extends keyof DB, RootTableAlias extends string> = JoinedAssociations['length'] extends 0 ? TableColumnNames<DB, RootTableName> : JoinedAssociationColumnNames<JoinedAssociations, DB, AssociationNameToDotReferencedColumns<DB, RootTableName & keyof DB, RootTableAlias>>;
|
|
31
|
+
type JoinedAssociationColumnNames<JoinedAssociations extends Readonly<JoinedAssociation[]>, DB, AllColumnNames, Depth extends number = 0, CurrentJoinedAssociation = Readonly<JoinedAssociations[0]>, NextTableName = CurrentJoinedAssociation extends Readonly<JoinedAssociation> ? CurrentJoinedAssociation['table'] : never, NextAssociationName = CurrentJoinedAssociation extends Readonly<JoinedAssociation> ? CurrentJoinedAssociation['alias'] : never> = JoinedAssociations['length'] extends 0 ? AllColumnNames : Depth extends MAX_JOINED_TABLES_DEPTH ? AllColumnNames : JoinedAssociationColumnNames<ReadonlyTail<JoinedAssociations>, DB, AllColumnNames | AssociationNameToDotReferencedColumns<DB, NextTableName & keyof DB, NextAssociationName>, Inc<Depth>>;
|
|
32
|
+
export type WhereStatement<DB, Schema, TableName extends AssociationTableNames<DB, Schema> & keyof DB> = Partial<MergeUnionOfRecordTypes<Updateable<DB[TableName]> | DreamSelectable<DB, Schema, TableName>>>;
|
|
33
|
+
export type OnStatementForAssociation<DB, Schema, TableName extends AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation, OnStatement extends WhereStatement<DB, Schema, TableName> = WhereStatement<DB, Schema, TableName>> = RequiredOnClauseKeysForThisAssociation extends null ? WhereStatement<DB, Schema, TableName> : RequiredOnClauseKeysForThisAssociation extends string[] ? Required<Pick<OnStatement, RequiredOnClauseKeysForThisAssociation[number] & keyof OnStatement>> & Partial<Omit<OnStatement, RequiredOnClauseKeysForThisAssociation[number] & keyof OnStatement>> : never;
|
|
34
|
+
type OnStatementForAssociationDefinition<DB, Schema, TableName extends AssociationTableNames<DB, Schema> & keyof DB> = Partial<MergeUnionOfRecordTypes<Updateable<DB[TableName]> | Partial<{
|
|
35
|
+
[ColumnName in keyof DB[TableName]]: NonKyselySupportedSupplementalWhereClauseValues<DB, Schema, TableName, ColumnName> | typeof DreamConst.passthrough | typeof DreamConst.required;
|
|
36
|
+
}>>>;
|
|
37
|
+
export type SelfOnStatement<BaseInstance extends Dream, DB, Schema, TableName extends AssociationTableNames<DB, Schema> & keyof DB> = Partial<Record<keyof DB[TableName], DreamColumnNames<BaseInstance>>>;
|
|
38
|
+
export type WhereStatementForJoinedAssociation<JoinedAssociations extends Readonly<JoinedAssociation[]>, DB, Schema, TableName extends AssociationTableNames<DB, Schema> & keyof DB> = RecursiveWhereStatementForJoinedAssociation<JoinedAssociations, DB, Schema, WhereStatement<DB, Schema, TableName>>;
|
|
39
|
+
type RecursiveWhereStatementForJoinedAssociation<JoinedAssociations extends Readonly<JoinedAssociation[]>, DB, Schema, OriginalOnStatement, Depth extends number = 0, CurrentJoinedAssociation = JoinedAssociations[0], TableName = CurrentJoinedAssociation extends JoinedAssociation ? CurrentJoinedAssociation['table'] : never, AssociationName = CurrentJoinedAssociation extends JoinedAssociation ? CurrentJoinedAssociation['alias'] : never, NonNamespacedAssociationOnStatement = TableName extends never ? never : AssociationName extends never ? never : WhereStatement<DB, Schema, TableName & AssociationTableNames<DB, Schema> & keyof DB>, NextOnStatement = NonNamespacedAssociationOnStatement extends never ? OriginalOnStatement : OriginalOnStatement & {
|
|
40
|
+
[K in keyof NonNamespacedAssociationOnStatement as `${AssociationName & string}.${K & string}`]: NonNamespacedAssociationOnStatement[K & keyof NonNamespacedAssociationOnStatement];
|
|
41
|
+
}> = JoinedAssociations['length'] extends 0 ? OriginalOnStatement : Depth extends MAX_JOINED_TABLES_DEPTH ? OriginalOnStatement : TableName extends never ? OriginalOnStatement : RecursiveWhereStatementForJoinedAssociation<ReadonlyTail<JoinedAssociations>, DB, Schema, NextOnStatement, Inc<Depth>>;
|
|
42
|
+
export type OrderStatement<DB, Schema, TableName extends AssociationTableNames<DB, Schema> & keyof DB> = TableColumnNames<DB, TableName> | Partial<Record<TableColumnNames<DB, TableName>, OrderDir>>;
|
|
43
|
+
export type LimitStatement = number;
|
|
44
|
+
export type OffsetStatement = number;
|
|
280
45
|
export type OrderQueryStatement<ColumnType> = {
|
|
281
|
-
|
|
282
|
-
|
|
46
|
+
column: ColumnType & string;
|
|
47
|
+
direction: OrderDir;
|
|
48
|
+
};
|
|
49
|
+
export interface HasStatement<BaseInstance extends Dream, DB, Schema, ForeignTableName extends AssociationTableNames<DB, Schema> & keyof DB, HasType extends 'HasOne' | 'HasMany'> {
|
|
50
|
+
modelCB: () => typeof Dream;
|
|
51
|
+
as: string;
|
|
52
|
+
dependent?: DependentOptions;
|
|
53
|
+
foreignKey: () => keyof DB[ForeignTableName] & string;
|
|
54
|
+
foreignKeyTypeField: () => keyof DB[ForeignTableName] & string;
|
|
55
|
+
globalAssociationNameOrNames: string[];
|
|
56
|
+
and?: OnStatementForAssociationDefinition<DB, Schema, ForeignTableName>;
|
|
57
|
+
andNot?: WhereStatement<DB, Schema, ForeignTableName>;
|
|
58
|
+
andAny?: WhereStatement<DB, Schema, ForeignTableName>[];
|
|
59
|
+
polymorphic: boolean;
|
|
60
|
+
preloadThroughColumns?: string[] | Record<string, string>;
|
|
61
|
+
primaryKey: (associationInstance?: Dream) => DreamColumnNames<BaseInstance>;
|
|
62
|
+
primaryKeyOverride?: DreamColumnNames<BaseInstance> | null;
|
|
63
|
+
primaryKeyValue: (associationInstance: Dream) => any;
|
|
64
|
+
selfAnd?: SelfOnStatement<BaseInstance, DB, Schema, ForeignTableName>;
|
|
65
|
+
selfAndNot?: SelfOnStatement<BaseInstance, DB, Schema, ForeignTableName>;
|
|
66
|
+
source: string;
|
|
67
|
+
through?: string;
|
|
68
|
+
type: HasType;
|
|
69
|
+
withoutDefaultScopes?: DefaultScopeName<BaseInstance>[];
|
|
283
70
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
and?: OnStatementForAssociationDefinition<DB, Schema, ForeignTableName>
|
|
299
|
-
andNot?: WhereStatement<DB, Schema, ForeignTableName>
|
|
300
|
-
andAny?: WhereStatement<DB, Schema, ForeignTableName>[]
|
|
301
|
-
// ATTENTION
|
|
302
|
-
//
|
|
303
|
-
// Using `order` with HasOne is tempting as an elegant API
|
|
304
|
-
// (e.g. a `currentXyz` variant of a `currentXyzs` HasMany
|
|
305
|
-
// association by ordering on `createdAt`); however, it
|
|
306
|
-
// creates a fundamental problem when querying through the
|
|
307
|
-
// HasMany association: we can't `limit(1)` as part of the
|
|
308
|
-
// query because multiple records may match the HasMany
|
|
309
|
-
// association, each of which may HaveOne of the subsequent
|
|
310
|
-
// association
|
|
311
|
-
polymorphic: boolean
|
|
312
|
-
preloadThroughColumns?: string[] | Record<string, string>
|
|
313
|
-
primaryKey: (associationInstance?: Dream) => DreamColumnNames<BaseInstance>
|
|
314
|
-
primaryKeyOverride?: DreamColumnNames<BaseInstance> | null
|
|
315
|
-
primaryKeyValue: (associationInstance: Dream) => any
|
|
316
|
-
selfAnd?: SelfOnStatement<BaseInstance, DB, Schema, ForeignTableName>
|
|
317
|
-
selfAndNot?: SelfOnStatement<BaseInstance, DB, Schema, ForeignTableName>
|
|
318
|
-
source: string
|
|
319
|
-
through?: string
|
|
320
|
-
type: HasType
|
|
321
|
-
withoutDefaultScopes?: DefaultScopeName<BaseInstance>[]
|
|
71
|
+
interface HasOptionsBase<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>, AssociationTableName = TableNameForGlobalModelName<BaseInstance, AssociationGlobalName & keyof GlobalModelNameTableMap<BaseInstance>>> {
|
|
72
|
+
dependent?: DependentOptions;
|
|
73
|
+
foreignKey?: TableColumnNames<BaseInstance['DB'], AssociationTableName & keyof BaseInstance['DB']>;
|
|
74
|
+
and?: OnStatementForAssociationDefinition<BaseInstance['DB'], BaseInstance['schema'], AssociationTableName & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']>;
|
|
75
|
+
andNot?: WhereStatement<BaseInstance['DB'], BaseInstance['schema'], AssociationTableName & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']>;
|
|
76
|
+
andAny?: WhereStatement<BaseInstance['DB'], BaseInstance['schema'], AssociationTableName & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']>[];
|
|
77
|
+
polymorphic?: boolean;
|
|
78
|
+
preloadThroughColumns?: string[] | Record<string, string>;
|
|
79
|
+
primaryKeyOverride?: DreamColumnNames<BaseInstance> | null;
|
|
80
|
+
selfAnd?: SelfOnStatement<BaseInstance, BaseInstance['DB'], BaseInstance['schema'], AssociationTableName & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']>;
|
|
81
|
+
selfAndNot?: SelfOnStatement<BaseInstance, BaseInstance['DB'], BaseInstance['schema'], AssociationTableName & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']>;
|
|
82
|
+
source?: string;
|
|
83
|
+
through?: keyof BaseInstance['schema'][BaseInstance['table']]['associations'];
|
|
84
|
+
withoutDefaultScopes?: DefaultScopeNameForTable<BaseInstance['schema'], AssociationTableName & keyof BaseInstance['DB']>[];
|
|
322
85
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
>,
|
|
331
|
-
> {
|
|
332
|
-
dependent?: DependentOptions
|
|
333
|
-
foreignKey?: TableColumnNames<BaseInstance['DB'], AssociationTableName & keyof BaseInstance['DB']>
|
|
334
|
-
|
|
335
|
-
and?: OnStatementForAssociationDefinition<
|
|
336
|
-
BaseInstance['DB'],
|
|
337
|
-
BaseInstance['schema'],
|
|
338
|
-
AssociationTableName &
|
|
339
|
-
AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> &
|
|
340
|
-
keyof BaseInstance['DB']
|
|
341
|
-
>
|
|
342
|
-
|
|
343
|
-
andNot?: WhereStatement<
|
|
344
|
-
BaseInstance['DB'],
|
|
345
|
-
BaseInstance['schema'],
|
|
346
|
-
AssociationTableName &
|
|
347
|
-
AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> &
|
|
348
|
-
keyof BaseInstance['DB']
|
|
349
|
-
>
|
|
350
|
-
|
|
351
|
-
andAny?: WhereStatement<
|
|
352
|
-
BaseInstance['DB'],
|
|
353
|
-
BaseInstance['schema'],
|
|
354
|
-
AssociationTableName &
|
|
355
|
-
AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> &
|
|
356
|
-
keyof BaseInstance['DB']
|
|
357
|
-
>[]
|
|
358
|
-
|
|
359
|
-
polymorphic?: boolean
|
|
360
|
-
preloadThroughColumns?: string[] | Record<string, string>
|
|
361
|
-
primaryKeyOverride?: DreamColumnNames<BaseInstance> | null
|
|
362
|
-
|
|
363
|
-
selfAnd?: SelfOnStatement<
|
|
364
|
-
BaseInstance,
|
|
365
|
-
BaseInstance['DB'],
|
|
366
|
-
BaseInstance['schema'],
|
|
367
|
-
AssociationTableName &
|
|
368
|
-
AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> &
|
|
369
|
-
keyof BaseInstance['DB']
|
|
370
|
-
>
|
|
371
|
-
|
|
372
|
-
selfAndNot?: SelfOnStatement<
|
|
373
|
-
BaseInstance,
|
|
374
|
-
BaseInstance['DB'],
|
|
375
|
-
BaseInstance['schema'],
|
|
376
|
-
AssociationTableName &
|
|
377
|
-
AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> &
|
|
378
|
-
keyof BaseInstance['DB']
|
|
379
|
-
>
|
|
380
|
-
|
|
381
|
-
source?: string
|
|
382
|
-
through?: keyof BaseInstance['schema'][BaseInstance['table']]['associations']
|
|
383
|
-
|
|
384
|
-
withoutDefaultScopes?: DefaultScopeNameForTable<
|
|
385
|
-
BaseInstance['schema'],
|
|
386
|
-
AssociationTableName & keyof BaseInstance['DB']
|
|
387
|
-
>[]
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
export type PolymorphicOption = 'polymorphic'
|
|
391
|
-
export type ForeignKeyOption = 'foreignKey'
|
|
392
|
-
type ThroughIncompatibleOptions =
|
|
393
|
-
| 'dependent'
|
|
394
|
-
| 'primaryKeyOverride'
|
|
395
|
-
| 'withoutDefaultScopes'
|
|
396
|
-
| ForeignKeyOption
|
|
397
|
-
| PolymorphicOption
|
|
398
|
-
type ThroughOnlyOptions = 'through' | 'source' | 'preloadThroughColumns'
|
|
399
|
-
|
|
400
|
-
export type HasOptions<
|
|
401
|
-
BaseInstance extends Dream,
|
|
402
|
-
AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>,
|
|
403
|
-
> = Omit<HasOptionsBase<BaseInstance, AssociationGlobalName>, ThroughOnlyOptions | PolymorphicOption>
|
|
404
|
-
|
|
405
|
-
export type PolymorphicHasOptions<
|
|
406
|
-
BaseInstance extends Dream,
|
|
407
|
-
AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>,
|
|
408
|
-
> = HasOptionsBase<BaseInstance, AssociationGlobalName> &
|
|
409
|
-
Required<Pick<HasOptionsBase<BaseInstance, AssociationGlobalName>, PolymorphicOption | ForeignKeyOption>>
|
|
410
|
-
|
|
411
|
-
export type HasThroughOptions<
|
|
412
|
-
BaseInstance extends Dream,
|
|
413
|
-
AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>,
|
|
414
|
-
> = Omit<HasOptionsBase<BaseInstance, AssociationGlobalName>, ThroughIncompatibleOptions>
|
|
415
|
-
|
|
86
|
+
export type PolymorphicOption = 'polymorphic';
|
|
87
|
+
export type ForeignKeyOption = 'foreignKey';
|
|
88
|
+
type ThroughIncompatibleOptions = 'dependent' | 'primaryKeyOverride' | 'withoutDefaultScopes' | ForeignKeyOption | PolymorphicOption;
|
|
89
|
+
type ThroughOnlyOptions = 'through' | 'source' | 'preloadThroughColumns';
|
|
90
|
+
export type HasOptions<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>> = Omit<HasOptionsBase<BaseInstance, AssociationGlobalName>, ThroughOnlyOptions | PolymorphicOption>;
|
|
91
|
+
export type PolymorphicHasOptions<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>> = HasOptionsBase<BaseInstance, AssociationGlobalName> & Required<Pick<HasOptionsBase<BaseInstance, AssociationGlobalName>, PolymorphicOption | ForeignKeyOption>>;
|
|
92
|
+
export type HasThroughOptions<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>> = Omit<HasOptionsBase<BaseInstance, AssociationGlobalName>, ThroughIncompatibleOptions>;
|
|
416
93
|
export interface AssociationStatementsMap {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
94
|
+
belongsTo: readonly BelongsToStatement<any, any, any, any>[] | BelongsToStatement<any, any, any, any>[];
|
|
95
|
+
hasMany: readonly HasManyStatement<any, any, any, any>[] | HasManyStatement<any, any, any, any>[];
|
|
96
|
+
hasOne: readonly HasOneStatement<any, any, any, any>[] | HasOneStatement<any, any, any, any>[];
|
|
420
97
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
type
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
| 'primaryKey'
|
|
429
|
-
| 'primaryKeyValue'
|
|
430
|
-
| 'primaryKeyOverride'
|
|
431
|
-
type hasOneManySpecificFields =
|
|
432
|
-
| 'source'
|
|
433
|
-
| 'through'
|
|
434
|
-
| 'preloadThroughColumns'
|
|
435
|
-
| 'and'
|
|
436
|
-
| 'andNot'
|
|
437
|
-
| 'andAny'
|
|
438
|
-
| 'selfAnd'
|
|
439
|
-
| 'selfAndNot'
|
|
440
|
-
type belongsToSpecificFields = 'optional'
|
|
441
|
-
|
|
442
|
-
export type PartialAssociationStatement =
|
|
443
|
-
| Pick<HasManyStatement<any, any, any, any>, partialTypeFields | hasOneManySpecificFields>
|
|
444
|
-
| Pick<HasOneStatement<any, any, any, any>, partialTypeFields | hasOneManySpecificFields>
|
|
445
|
-
| Pick<BelongsToStatement<any, any, any, any>, partialTypeFields | belongsToSpecificFields>
|
|
446
|
-
|
|
447
|
-
export type AssociationStatement =
|
|
448
|
-
| HasManyStatement<any, any, any, any>
|
|
449
|
-
| HasOneStatement<any, any, any, any>
|
|
450
|
-
| BelongsToStatement<any, any, any, any>
|
|
98
|
+
export type DependentOptions = 'destroy';
|
|
99
|
+
type partialTypeFields = 'modelCB' | 'type' | 'polymorphic' | 'as' | 'primaryKey' | 'primaryKeyValue' | 'primaryKeyOverride';
|
|
100
|
+
type hasOneManySpecificFields = 'source' | 'through' | 'preloadThroughColumns' | 'and' | 'andNot' | 'andAny' | 'selfAnd' | 'selfAndNot';
|
|
101
|
+
type belongsToSpecificFields = 'optional';
|
|
102
|
+
export type PartialAssociationStatement = Pick<HasManyStatement<any, any, any, any>, partialTypeFields | hasOneManySpecificFields> | Pick<HasOneStatement<any, any, any, any>, partialTypeFields | hasOneManySpecificFields> | Pick<BelongsToStatement<any, any, any, any>, partialTypeFields | belongsToSpecificFields>;
|
|
103
|
+
export type AssociationStatement = HasManyStatement<any, any, any, any> | HasOneStatement<any, any, any, any> | BelongsToStatement<any, any, any, any>;
|
|
104
|
+
export {};
|