@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
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { openapiPrimitiveTypes, openapiShorthandPrimitiveTypes } from '../dream/constants.js'
|
|
2
|
+
import DreamSerializer from '../serializer/index.js'
|
|
3
|
+
import { SerializableDreamClassOrViewModelClass } from './dream.js'
|
|
4
|
+
|
|
5
|
+
export type OpenapiSchemaBody =
|
|
6
|
+
| OpenapiSchemaBase
|
|
7
|
+
| OpenapiSchemaPrimitiveGeneric
|
|
8
|
+
| OpenapiSchemaExpressionAnyOf
|
|
9
|
+
| OpenapiSchemaExpressionOneOf
|
|
10
|
+
| OpenapiSchemaExpressionAllOf
|
|
11
|
+
| OpenapiSchemaObject
|
|
12
|
+
| OpenapiSchemaArray
|
|
13
|
+
|
|
14
|
+
export type OpenapiSchemaBodyShorthand =
|
|
15
|
+
| OpenapiSchemaBase
|
|
16
|
+
| OpenapiSchemaShorthandPrimitiveGeneric
|
|
17
|
+
| OpenapiSchemaShorthandExpressionAnyOf
|
|
18
|
+
| OpenapiSchemaShorthandExpressionOneOf
|
|
19
|
+
| OpenapiSchemaShorthandExpressionAllOf
|
|
20
|
+
| OpenapiSchemaObjectShorthand
|
|
21
|
+
| OpenapiSchemaArrayShorthand
|
|
22
|
+
| OpenapiSchemaNull // no shorthand for type: null
|
|
23
|
+
| OpenapiSchemaExpressionRefSchemaShorthand
|
|
24
|
+
| OpenapiSchemaShorthandExpressionSerializerRef
|
|
25
|
+
| OpenapiSchemaShorthandExpressionSerializableRef
|
|
26
|
+
|
|
27
|
+
export type OpenapiSchemaBase =
|
|
28
|
+
| OpenapiSchemaString
|
|
29
|
+
| OpenapiSchemaInteger
|
|
30
|
+
| OpenapiSchemaNumber
|
|
31
|
+
| OpenapiSchemaNull
|
|
32
|
+
| OpenapiSchemaExpressionRef
|
|
33
|
+
|
|
34
|
+
export type OpenapiSchemaShorthandExpressionAnyOf = {
|
|
35
|
+
anyOf: OpenapiSchemaBodyShorthand[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type OpenapiSchemaShorthandExpressionOneOf = {
|
|
39
|
+
oneOf: OpenapiSchemaBodyShorthand[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type OpenapiSchemaShorthandExpressionAllOf = {
|
|
43
|
+
allOf: OpenapiSchemaBodyShorthand[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type OpenapiSchemaShorthandExpressionSerializerRef = {
|
|
47
|
+
$serializer: typeof DreamSerializer
|
|
48
|
+
many?: boolean
|
|
49
|
+
maybeNull?: boolean
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type OpenapiSchemaShorthandExpressionSerializableRef = {
|
|
53
|
+
$serializable: SerializableDreamClassOrViewModelClass
|
|
54
|
+
key?: string
|
|
55
|
+
many?: boolean
|
|
56
|
+
maybeNull?: boolean
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type OpenapiSchemaExpressionRef = {
|
|
60
|
+
$ref: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type OpenapiSchemaExpressionRefSchemaShorthand = {
|
|
64
|
+
$schema: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type OpenapiSchemaExpressionAllOf = {
|
|
68
|
+
allOf: OpenapiSchemaBody[]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type OpenapiSchemaExpressionAnyOf = {
|
|
72
|
+
anyOf: OpenapiSchemaBody[]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type OpenapiSchemaExpressionOneOf = {
|
|
76
|
+
oneOf: OpenapiSchemaBody[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type OpenapiSchemaCommonFields<T> = T & {
|
|
80
|
+
description?: string
|
|
81
|
+
summary?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type OpenapiSchemaString = OpenapiSchemaCommonFields<{
|
|
85
|
+
type: 'string' | ['string', 'null'] | ['null', 'string']
|
|
86
|
+
enum?: (string | null)[] | Readonly<(string | null)[]>
|
|
87
|
+
format?: string
|
|
88
|
+
pattern?: string
|
|
89
|
+
minLength?: number
|
|
90
|
+
maxLength?: number
|
|
91
|
+
}>
|
|
92
|
+
|
|
93
|
+
export type OpenapiSchemaInteger = OpenapiSchemaCommonFields<{
|
|
94
|
+
type: 'integer' | ['integer', 'null'] | ['null', 'integer']
|
|
95
|
+
minimum?: number
|
|
96
|
+
maximum?: number
|
|
97
|
+
}>
|
|
98
|
+
|
|
99
|
+
export type OpenapiSchemaNumber = OpenapiSchemaCommonFields<{
|
|
100
|
+
type: 'number' | ['number', 'null'] | ['null', 'number']
|
|
101
|
+
format?: OpenapiNumberFormats
|
|
102
|
+
multipleOf?: number
|
|
103
|
+
minimum?: number
|
|
104
|
+
maximum?: number
|
|
105
|
+
}>
|
|
106
|
+
|
|
107
|
+
export type OpenapiSchemaNull = {
|
|
108
|
+
type: 'null'
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type OpenapiNumberFormats = 'decimal' | 'double'
|
|
112
|
+
|
|
113
|
+
export type OpenapiSchemaObject =
|
|
114
|
+
| OpenapiSchemaObjectBase
|
|
115
|
+
| OpenapiSchemaObjectOneOf
|
|
116
|
+
| OpenapiSchemaObjectAnyOf
|
|
117
|
+
| OpenapiSchemaObjectAllOf
|
|
118
|
+
|
|
119
|
+
export type OpenapiSchemaObjectBase = CommonOpenapiSchemaObjectFields<{
|
|
120
|
+
minProperties?: number
|
|
121
|
+
maxProperties?: number
|
|
122
|
+
properties?:
|
|
123
|
+
| OpenapiSchemaProperties
|
|
124
|
+
| OpenapiSchemaExpressionOneOf
|
|
125
|
+
| OpenapiSchemaExpressionAnyOf
|
|
126
|
+
| OpenapiSchemaExpressionAllOf
|
|
127
|
+
additionalProperties?:
|
|
128
|
+
| OpenapiSchemaObject
|
|
129
|
+
| OpenapiSchemaExpressionOneOf
|
|
130
|
+
| OpenapiSchemaExpressionAnyOf
|
|
131
|
+
| OpenapiSchemaExpressionAllOf
|
|
132
|
+
}>
|
|
133
|
+
|
|
134
|
+
export type OpenapiSchemaObjectOneOf = CommonOpenapiSchemaObjectFields<{
|
|
135
|
+
oneOf?: OpenapiSchemaBody[]
|
|
136
|
+
}>
|
|
137
|
+
|
|
138
|
+
export type OpenapiSchemaObjectAnyOf = CommonOpenapiSchemaObjectFields<{
|
|
139
|
+
anyOf?: OpenapiSchemaBody[]
|
|
140
|
+
}>
|
|
141
|
+
|
|
142
|
+
export type OpenapiSchemaObjectAllOf = CommonOpenapiSchemaObjectFields<{
|
|
143
|
+
allOf?: OpenapiSchemaBody[]
|
|
144
|
+
}>
|
|
145
|
+
|
|
146
|
+
export type OpenapiSchemaObjectShorthand =
|
|
147
|
+
| OpenapiSchemaObjectBaseShorthand
|
|
148
|
+
| OpenapiSchemaObjectOneOfShorthand
|
|
149
|
+
| OpenapiSchemaObjectAnyOfShorthand
|
|
150
|
+
| OpenapiSchemaObjectAllOfShorthand
|
|
151
|
+
|
|
152
|
+
export type OpenapiSchemaObjectBaseShorthand = CommonOpenapiSchemaObjectFields<{
|
|
153
|
+
minProperties?: number
|
|
154
|
+
maxProperties?: number
|
|
155
|
+
properties?:
|
|
156
|
+
| OpenapiSchemaPropertiesShorthand
|
|
157
|
+
| OpenapiSchemaShorthandExpressionOneOf
|
|
158
|
+
| OpenapiSchemaShorthandExpressionAnyOf
|
|
159
|
+
| OpenapiSchemaShorthandExpressionAllOf
|
|
160
|
+
| OpenapiSchemaShorthandExpressionSerializerRef
|
|
161
|
+
| OpenapiSchemaShorthandExpressionSerializableRef
|
|
162
|
+
additionalProperties?:
|
|
163
|
+
| OpenapiShorthandPrimitiveTypes
|
|
164
|
+
| OpenapiSchemaBodyShorthand
|
|
165
|
+
| OpenapiSchemaShorthandExpressionOneOf
|
|
166
|
+
| OpenapiSchemaShorthandExpressionAnyOf
|
|
167
|
+
| OpenapiSchemaShorthandExpressionAllOf
|
|
168
|
+
| OpenapiSchemaShorthandExpressionSerializerRef
|
|
169
|
+
| OpenapiSchemaShorthandExpressionSerializableRef
|
|
170
|
+
}>
|
|
171
|
+
|
|
172
|
+
export type OpenapiSchemaObjectOneOfShorthand = CommonOpenapiSchemaObjectFields<{
|
|
173
|
+
oneOf?: OpenapiSchemaBodyShorthand[]
|
|
174
|
+
}>
|
|
175
|
+
|
|
176
|
+
export type OpenapiSchemaObjectAnyOfShorthand = CommonOpenapiSchemaObjectFields<{
|
|
177
|
+
anyOf?: OpenapiSchemaBodyShorthand[]
|
|
178
|
+
}>
|
|
179
|
+
|
|
180
|
+
export type OpenapiSchemaObjectAllOfShorthand = CommonOpenapiSchemaObjectFields<{
|
|
181
|
+
allOf?: OpenapiSchemaBodyShorthand[]
|
|
182
|
+
}>
|
|
183
|
+
|
|
184
|
+
export type CommonOpenapiSchemaObjectFields<T> = OpenapiSchemaCommonFields<
|
|
185
|
+
T & {
|
|
186
|
+
type: 'object' | ['object', 'null'] | ['null', 'object']
|
|
187
|
+
required?: string[]
|
|
188
|
+
}
|
|
189
|
+
>
|
|
190
|
+
|
|
191
|
+
export type OpenapiSchemaArray = OpenapiSchemaCommonFields<{
|
|
192
|
+
type: 'array' | ['array', 'null'] | ['null', 'array']
|
|
193
|
+
items:
|
|
194
|
+
| OpenapiSchemaBody
|
|
195
|
+
| OpenapiSchemaExpressionAllOf
|
|
196
|
+
| OpenapiSchemaExpressionAnyOf
|
|
197
|
+
| OpenapiSchemaExpressionOneOf
|
|
198
|
+
}>
|
|
199
|
+
|
|
200
|
+
export type OpenapiSchemaArrayShorthand = OpenapiSchemaCommonFields<{
|
|
201
|
+
type: 'array' | ['array', 'null'] | ['null', 'array']
|
|
202
|
+
items:
|
|
203
|
+
| OpenapiSchemaBodyShorthand
|
|
204
|
+
| OpenapiSchemaShorthandExpressionAllOf
|
|
205
|
+
| OpenapiSchemaShorthandExpressionAnyOf
|
|
206
|
+
| OpenapiSchemaShorthandExpressionOneOf
|
|
207
|
+
| OpenapiSchemaShorthandExpressionSerializerRef
|
|
208
|
+
| OpenapiSchemaShorthandExpressionSerializableRef
|
|
209
|
+
}>
|
|
210
|
+
|
|
211
|
+
export interface OpenapiSchemaProperties {
|
|
212
|
+
[key: string]: OpenapiSchemaBody
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export type OpenapiSchemaPrimitiveGeneric = OpenapiSchemaCommonFields<{
|
|
216
|
+
type: OpenapiPrimitiveTypes
|
|
217
|
+
}>
|
|
218
|
+
|
|
219
|
+
export type OpenapiSchemaShorthandPrimitiveGeneric = OpenapiSchemaCommonFields<{
|
|
220
|
+
type: OpenapiShorthandPrimitiveTypes
|
|
221
|
+
}>
|
|
222
|
+
|
|
223
|
+
export interface OpenapiSchemaPropertiesShorthand {
|
|
224
|
+
[key: string]: OpenapiSchemaBodyShorthand | OpenapiShorthandPrimitiveTypes
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
type OpenapiPrimitiveBaseTypes = (typeof openapiPrimitiveTypes)[number]
|
|
228
|
+
export type OpenapiPrimitiveTypes =
|
|
229
|
+
| OpenapiPrimitiveBaseTypes
|
|
230
|
+
| [OpenapiPrimitiveBaseTypes, 'null']
|
|
231
|
+
| ['null', OpenapiPrimitiveBaseTypes]
|
|
232
|
+
|
|
233
|
+
export type OpenapiShorthandPrimitiveBaseTypes = (typeof openapiShorthandPrimitiveTypes)[number]
|
|
234
|
+
export type OpenapiShorthandPrimitiveTypes =
|
|
235
|
+
| OpenapiShorthandPrimitiveBaseTypes
|
|
236
|
+
| [OpenapiShorthandPrimitiveBaseTypes, 'null']
|
|
237
|
+
| ['null', OpenapiShorthandPrimitiveBaseTypes]
|
|
238
|
+
|
|
239
|
+
type ObjectOrArrayPrimitiveTypes =
|
|
240
|
+
| 'object'
|
|
241
|
+
| 'array'
|
|
242
|
+
| ['object' | 'array', 'null']
|
|
243
|
+
| ['null', 'object' | 'array']
|
|
244
|
+
|
|
245
|
+
export type OpenapiAllTypes = OpenapiPrimitiveTypes | ObjectOrArrayPrimitiveTypes
|
|
246
|
+
|
|
247
|
+
export type OpenapiShorthandAllTypes = OpenapiShorthandPrimitiveTypes | ObjectOrArrayPrimitiveTypes
|
|
248
|
+
|
|
249
|
+
export type OpenapiTypeField = OpenapiPrimitiveTypes | OpenapiTypeFieldObject
|
|
250
|
+
|
|
251
|
+
export interface OpenapiTypeFieldObject {
|
|
252
|
+
[key: string]: OpenapiPrimitiveTypes | OpenapiTypeFieldObject
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export type OpenapiFormats = 'application/json'
|
|
@@ -1,165 +1,57 @@
|
|
|
1
|
-
import { Nullable } from 'kysely'
|
|
2
|
-
import Dream from '../Dream.
|
|
3
|
-
import Query from '../dream/Query.
|
|
4
|
-
import { IdType, TableColumnType } from './dream.js'
|
|
5
|
-
import { FindInterfaceWithValue } from './utils.
|
|
6
|
-
import { JoinedAssociation, QueryTypeOptions } from './variadic.js'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Q['dreamInstance'],
|
|
26
|
-
ExtendQueryType<
|
|
27
|
-
Q['queryTypeOpts'],
|
|
28
|
-
Readonly<{
|
|
29
|
-
joinedAssociations: JoinedAssociations
|
|
30
|
-
allowPreload: false
|
|
31
|
-
}>
|
|
32
|
-
>
|
|
33
|
-
>
|
|
34
|
-
|
|
35
|
-
export type QueryWithJoinedAssociationsTypeAndNoLeftJoinPreload<
|
|
36
|
-
Q extends Query<any, any>,
|
|
37
|
-
JoinedAssociations extends Readonly<JoinedAssociation[]> = Readonly<JoinedAssociation[]>,
|
|
38
|
-
> = Query<
|
|
39
|
-
Q['dreamInstance'],
|
|
40
|
-
ExtendQueryType<
|
|
41
|
-
Q['queryTypeOpts'],
|
|
42
|
-
Readonly<{
|
|
43
|
-
joinedAssociations: JoinedAssociations
|
|
44
|
-
allowLeftJoinPreload: false
|
|
45
|
-
}>
|
|
46
|
-
>
|
|
47
|
-
>
|
|
48
|
-
|
|
49
|
-
export type DefaultQueryTypeOptions<
|
|
50
|
-
TableNameSource extends Dream,
|
|
51
|
-
TableAliasSource extends Dream | string = TableNameSource,
|
|
52
|
-
> = Readonly<{
|
|
53
|
-
joinedAssociations: Readonly<[]>
|
|
54
|
-
rootTableName: TableNameSource['table']
|
|
55
|
-
rootTableAlias: TableAliasSource extends Dream ? TableAliasSource['table'] : TableAliasSource
|
|
56
|
-
allowPreload: true
|
|
57
|
-
allowLeftJoinPreload: true
|
|
58
|
-
}>
|
|
59
|
-
|
|
1
|
+
import { Nullable } from 'kysely';
|
|
2
|
+
import Dream from '../Dream.js';
|
|
3
|
+
import Query from '../dream/Query.js';
|
|
4
|
+
import { IdType, TableColumnType } from './dream.js';
|
|
5
|
+
import { FindInterfaceWithValue } from './utils.js';
|
|
6
|
+
import { JoinedAssociation, QueryTypeOptions } from './variadic.js';
|
|
7
|
+
export type QueryWithJoinedAssociationsType<Q extends Query<any, any>, JoinedAssociations extends Readonly<JoinedAssociation[]>> = Query<Q['dreamInstance'], ExtendQueryType<Q['queryTypeOpts'], Readonly<{
|
|
8
|
+
joinedAssociations: JoinedAssociations;
|
|
9
|
+
}>>>;
|
|
10
|
+
export type QueryWithJoinedAssociationsTypeAndNoPreload<Q extends Query<any, any>, JoinedAssociations extends Readonly<JoinedAssociation[]> = Readonly<JoinedAssociation[]>> = Query<Q['dreamInstance'], ExtendQueryType<Q['queryTypeOpts'], Readonly<{
|
|
11
|
+
joinedAssociations: JoinedAssociations;
|
|
12
|
+
allowPreload: false;
|
|
13
|
+
}>>>;
|
|
14
|
+
export type QueryWithJoinedAssociationsTypeAndNoLeftJoinPreload<Q extends Query<any, any>, JoinedAssociations extends Readonly<JoinedAssociation[]> = Readonly<JoinedAssociation[]>> = Query<Q['dreamInstance'], ExtendQueryType<Q['queryTypeOpts'], Readonly<{
|
|
15
|
+
joinedAssociations: JoinedAssociations;
|
|
16
|
+
allowLeftJoinPreload: false;
|
|
17
|
+
}>>>;
|
|
18
|
+
export type DefaultQueryTypeOptions<TableNameSource extends Dream, TableAliasSource extends Dream | string = TableNameSource> = Readonly<{
|
|
19
|
+
joinedAssociations: Readonly<[]>;
|
|
20
|
+
rootTableName: TableNameSource['table'];
|
|
21
|
+
rootTableAlias: TableAliasSource extends Dream ? TableAliasSource['table'] : TableAliasSource;
|
|
22
|
+
allowPreload: true;
|
|
23
|
+
allowLeftJoinPreload: true;
|
|
24
|
+
}>;
|
|
60
25
|
export interface PreloadedDreamsAndWhatTheyPointTo {
|
|
61
|
-
|
|
62
|
-
|
|
26
|
+
dream: Dream;
|
|
27
|
+
pointsToPrimaryKey: IdType;
|
|
63
28
|
}
|
|
64
|
-
|
|
65
29
|
export interface FindEachOpts {
|
|
66
|
-
|
|
30
|
+
batchSize?: number;
|
|
67
31
|
}
|
|
68
|
-
export type JoinTypes = 'inner' | 'left'
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
export type
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
AssociationName = ColumnName extends `${infer Name extends string}.${string}` ? Name : never,
|
|
95
|
-
RealColumnName = ColumnName extends `${string}.${infer Col extends string}` ? Col : never,
|
|
96
|
-
JoinedAssociation extends FindInterfaceWithValue<
|
|
97
|
-
JoinedAssociationsArr,
|
|
98
|
-
'alias',
|
|
99
|
-
AssociationName
|
|
100
|
-
> = FindInterfaceWithValue<JoinedAssociationsArr, 'alias', AssociationName>,
|
|
101
|
-
JoinedTable = JoinedAssociation['table'] extends never
|
|
102
|
-
? DreamInstance['table']
|
|
103
|
-
: JoinedAssociation['table'],
|
|
104
|
-
ReturnType = TableColumnType<DreamInstance['schema'], JoinedTable, RealColumnName>,
|
|
105
|
-
> = ReturnType
|
|
106
|
-
type NamespacedColumnTypes<ColumnNames, Q extends Query<any, any>, DreamInstance extends Dream> =
|
|
107
|
-
ColumnNames extends Readonly<[infer First, ...infer Rest]>
|
|
108
|
-
? [
|
|
109
|
-
NamespacedColumnType<First, Q, DreamInstance>,
|
|
110
|
-
...NamespacedColumnTypes<Readonly<Rest>, Q, DreamInstance>,
|
|
111
|
-
]
|
|
112
|
-
: []
|
|
113
|
-
|
|
114
|
-
export type BaseModelColumnTypes<ColumnNames, DreamInstance extends Dream> =
|
|
115
|
-
ColumnNames extends Readonly<[infer First, ...infer Rest]>
|
|
116
|
-
? [
|
|
117
|
-
TableColumnType<DreamInstance['schema'], DreamInstance['table'], First>,
|
|
118
|
-
...BaseModelColumnTypes<Readonly<Rest>, DreamInstance>,
|
|
119
|
-
]
|
|
120
|
-
: []
|
|
121
|
-
|
|
122
|
-
export type NamespacedOrBaseModelColumnTypes<
|
|
123
|
-
ColumnNames,
|
|
124
|
-
Q extends Query<any, any>,
|
|
125
|
-
DreamInstance extends Dream,
|
|
126
|
-
> = Q['queryTypeOpts']['joinedAssociations']['length'] extends 0
|
|
127
|
-
? BaseModelColumnTypes<ColumnNames, DreamInstance>
|
|
128
|
-
: NamespacedColumnTypes<ColumnNames, Q, DreamInstance>
|
|
129
|
-
|
|
130
|
-
export type QueryToKyselyTableNamesType<
|
|
131
|
-
Q extends Query<any, any>,
|
|
132
|
-
DreamInstance = Q['dreamInstance'],
|
|
133
|
-
QueryTypeOpts = Q['queryTypeOpts'],
|
|
134
|
-
HasJoinedAssociations = QueryTypeOpts['joinedAssociations']['length'] extends 0 ? false : true,
|
|
135
|
-
JoinedAssociationTables = HasJoinedAssociations extends true
|
|
136
|
-
? QueryTypeOpts['joinedAssociations'][number]['table']
|
|
137
|
-
: null,
|
|
138
|
-
JoinedAssociationAliases = HasJoinedAssociations extends true
|
|
139
|
-
? QueryTypeOpts['joinedAssociations'][number]['alias']
|
|
140
|
-
: null,
|
|
141
|
-
TableNames = HasJoinedAssociations extends true
|
|
142
|
-
? DreamInstance['table'] | JoinedAssociationTables | JoinedAssociationAliases
|
|
143
|
-
: DreamInstance['table'],
|
|
144
|
-
> = TableNames
|
|
145
|
-
|
|
146
|
-
export type QueryToKyselyDBType<
|
|
147
|
-
Q extends Query<any, any>,
|
|
148
|
-
DreamInstance = Q['dreamInstance'],
|
|
149
|
-
AliasToDbMaps = QueryToKyselyAliasMap<Q>,
|
|
150
|
-
DbType = AliasToDbMaps extends null ? DreamInstance['DB'] : DreamInstance['DB'] & AliasToDbMaps,
|
|
151
|
-
> = DbType
|
|
152
|
-
|
|
153
|
-
export type QueryToKyselyAliasMap<
|
|
154
|
-
Q extends Query<any, any>,
|
|
155
|
-
DreamInstance = Q['dreamInstance'],
|
|
156
|
-
QueryTypeOpts = Q['queryTypeOpts'],
|
|
157
|
-
HasJoinedAssociations = QueryTypeOpts['joinedAssociations']['length'] extends 0 ? false : true,
|
|
158
|
-
AliasToDbMaps = HasJoinedAssociations extends true
|
|
159
|
-
? {
|
|
160
|
-
[Key in QueryTypeOpts['joinedAssociations'][number]['alias']]: Nullable<
|
|
161
|
-
DreamInstance['DB'][Extract<QueryTypeOpts['joinedAssociations'][number], { alias: Key }>['table']]
|
|
162
|
-
>
|
|
163
|
-
}
|
|
164
|
-
: null,
|
|
165
|
-
> = AliasToDbMaps
|
|
32
|
+
export type JoinTypes = 'inner' | 'left';
|
|
33
|
+
export type ExtendQueryType<OriginalOpts extends Readonly<QueryTypeOptions>, Opts extends Readonly<Partial<QueryTypeOptions>>> = Readonly<{
|
|
34
|
+
joinedAssociations: Opts['joinedAssociations'] extends Readonly<JoinedAssociation[]> ? Readonly<[...OriginalOpts['joinedAssociations'], ...Opts['joinedAssociations']]> : OriginalOpts['joinedAssociations'];
|
|
35
|
+
rootTableName: OriginalOpts['rootTableName'];
|
|
36
|
+
rootTableAlias: OriginalOpts['rootTableAlias'];
|
|
37
|
+
allowPreload: Opts['allowPreload'] extends false ? false : OriginalOpts['allowPreload'];
|
|
38
|
+
allowLeftJoinPreload: Opts['allowLeftJoinPreload'] extends false ? false : OriginalOpts['allowLeftJoinPreload'];
|
|
39
|
+
}>;
|
|
40
|
+
export type NamespacedColumnType<ColumnName, Q extends Query<any, any>, DreamInstance extends Dream, JoinedAssociationsArr = Q['queryTypeOpts']['joinedAssociations'], AssociationName = ColumnName extends `${infer Name extends string}.${string}` ? Name : never, RealColumnName = ColumnName extends `${string}.${infer Col extends string}` ? Col : never, JoinedAssociation extends FindInterfaceWithValue<JoinedAssociationsArr, 'alias', AssociationName> = FindInterfaceWithValue<JoinedAssociationsArr, 'alias', AssociationName>, JoinedTable = JoinedAssociation['table'] extends never ? DreamInstance['table'] : JoinedAssociation['table'], ReturnType = TableColumnType<DreamInstance['schema'], JoinedTable, RealColumnName>> = ReturnType;
|
|
41
|
+
type NamespacedColumnTypes<ColumnNames, Q extends Query<any, any>, DreamInstance extends Dream> = ColumnNames extends Readonly<[infer First, ...infer Rest]> ? [
|
|
42
|
+
NamespacedColumnType<First, Q, DreamInstance>,
|
|
43
|
+
...NamespacedColumnTypes<Readonly<Rest>, Q, DreamInstance>
|
|
44
|
+
] : [];
|
|
45
|
+
export type BaseModelColumnTypes<ColumnNames, DreamInstance extends Dream> = ColumnNames extends Readonly<[infer First, ...infer Rest]> ? [
|
|
46
|
+
TableColumnType<DreamInstance['schema'], DreamInstance['table'], First>,
|
|
47
|
+
...BaseModelColumnTypes<Readonly<Rest>, DreamInstance>
|
|
48
|
+
] : [];
|
|
49
|
+
export type NamespacedOrBaseModelColumnTypes<ColumnNames, Q extends Query<any, any>, DreamInstance extends Dream> = Q['queryTypeOpts']['joinedAssociations']['length'] extends 0 ? BaseModelColumnTypes<ColumnNames, DreamInstance> : NamespacedColumnTypes<ColumnNames, Q, DreamInstance>;
|
|
50
|
+
export type QueryToKyselyTableNamesType<Q extends Query<any, any>, DreamInstance extends Dream = Q['dreamInstance'], QueryTypeOpts extends Readonly<QueryTypeOptions> = Q['queryTypeOpts'], HasJoinedAssociations = QueryTypeOpts['joinedAssociations']['length'] extends 0 ? false : true, JoinedAssociationTables = HasJoinedAssociations extends true ? QueryTypeOpts['joinedAssociations'][number]['table'] : null, JoinedAssociationAliases = HasJoinedAssociations extends true ? QueryTypeOpts['joinedAssociations'][number]['alias'] : null, TableNames = HasJoinedAssociations extends true ? DreamInstance['table'] | JoinedAssociationTables | JoinedAssociationAliases : DreamInstance['table']> = TableNames;
|
|
51
|
+
export type QueryToKyselyDBType<Q extends Query<any, any>, DreamInstance extends Dream = Q['dreamInstance'], AliasToDbMaps = QueryToKyselyAliasMap<Q>, DbType = AliasToDbMaps extends null ? DreamInstance['DB'] : DreamInstance['DB'] & AliasToDbMaps> = DbType;
|
|
52
|
+
export type QueryToKyselyAliasMap<Q extends Query<any, any>, DreamInstance extends Dream = Q['dreamInstance'], QueryTypeOpts extends Readonly<QueryTypeOptions> = Q['queryTypeOpts'], HasJoinedAssociations = QueryTypeOpts['joinedAssociations']['length'] extends 0 ? false : true, AliasToDbMaps = HasJoinedAssociations extends true ? {
|
|
53
|
+
[Key in QueryTypeOpts['joinedAssociations'][number]['alias']]: Nullable<DreamInstance['DB'][Extract<QueryTypeOpts['joinedAssociations'][number], {
|
|
54
|
+
alias: Key;
|
|
55
|
+
}>['table']]>;
|
|
56
|
+
} : null> = AliasToDbMaps;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { Nullable } from 'kysely'
|
|
2
|
+
import Dream from '../Dream.js'
|
|
3
|
+
import Query from '../dream/Query.js'
|
|
4
|
+
import { IdType, TableColumnType } from './dream.js'
|
|
5
|
+
import { FindInterfaceWithValue } from './utils.js'
|
|
6
|
+
import { JoinedAssociation, QueryTypeOptions } from './variadic.js'
|
|
7
|
+
|
|
8
|
+
export type QueryWithJoinedAssociationsType<
|
|
9
|
+
Q extends Query<any, any>,
|
|
10
|
+
JoinedAssociations extends Readonly<JoinedAssociation[]>,
|
|
11
|
+
> = Query<
|
|
12
|
+
Q['dreamInstance'],
|
|
13
|
+
ExtendQueryType<
|
|
14
|
+
Q['queryTypeOpts'],
|
|
15
|
+
Readonly<{
|
|
16
|
+
joinedAssociations: JoinedAssociations
|
|
17
|
+
}>
|
|
18
|
+
>
|
|
19
|
+
>
|
|
20
|
+
|
|
21
|
+
export type QueryWithJoinedAssociationsTypeAndNoPreload<
|
|
22
|
+
Q extends Query<any, any>,
|
|
23
|
+
JoinedAssociations extends Readonly<JoinedAssociation[]> = Readonly<JoinedAssociation[]>,
|
|
24
|
+
> = Query<
|
|
25
|
+
Q['dreamInstance'],
|
|
26
|
+
ExtendQueryType<
|
|
27
|
+
Q['queryTypeOpts'],
|
|
28
|
+
Readonly<{
|
|
29
|
+
joinedAssociations: JoinedAssociations
|
|
30
|
+
allowPreload: false
|
|
31
|
+
}>
|
|
32
|
+
>
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
export type QueryWithJoinedAssociationsTypeAndNoLeftJoinPreload<
|
|
36
|
+
Q extends Query<any, any>,
|
|
37
|
+
JoinedAssociations extends Readonly<JoinedAssociation[]> = Readonly<JoinedAssociation[]>,
|
|
38
|
+
> = Query<
|
|
39
|
+
Q['dreamInstance'],
|
|
40
|
+
ExtendQueryType<
|
|
41
|
+
Q['queryTypeOpts'],
|
|
42
|
+
Readonly<{
|
|
43
|
+
joinedAssociations: JoinedAssociations
|
|
44
|
+
allowLeftJoinPreload: false
|
|
45
|
+
}>
|
|
46
|
+
>
|
|
47
|
+
>
|
|
48
|
+
|
|
49
|
+
export type DefaultQueryTypeOptions<
|
|
50
|
+
TableNameSource extends Dream,
|
|
51
|
+
TableAliasSource extends Dream | string = TableNameSource,
|
|
52
|
+
> = Readonly<{
|
|
53
|
+
joinedAssociations: Readonly<[]>
|
|
54
|
+
rootTableName: TableNameSource['table']
|
|
55
|
+
rootTableAlias: TableAliasSource extends Dream ? TableAliasSource['table'] : TableAliasSource
|
|
56
|
+
allowPreload: true
|
|
57
|
+
allowLeftJoinPreload: true
|
|
58
|
+
}>
|
|
59
|
+
|
|
60
|
+
export interface PreloadedDreamsAndWhatTheyPointTo {
|
|
61
|
+
dream: Dream
|
|
62
|
+
pointsToPrimaryKey: IdType
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface FindEachOpts {
|
|
66
|
+
batchSize?: number
|
|
67
|
+
}
|
|
68
|
+
export type JoinTypes = 'inner' | 'left'
|
|
69
|
+
|
|
70
|
+
export type ExtendQueryType<
|
|
71
|
+
OriginalOpts extends Readonly<QueryTypeOptions>,
|
|
72
|
+
Opts extends Readonly<Partial<QueryTypeOptions>>,
|
|
73
|
+
> = Readonly<{
|
|
74
|
+
joinedAssociations: Opts['joinedAssociations'] extends Readonly<JoinedAssociation[]>
|
|
75
|
+
? Readonly<[...OriginalOpts['joinedAssociations'], ...Opts['joinedAssociations']]>
|
|
76
|
+
: OriginalOpts['joinedAssociations']
|
|
77
|
+
|
|
78
|
+
rootTableName: OriginalOpts['rootTableName']
|
|
79
|
+
rootTableAlias: OriginalOpts['rootTableAlias']
|
|
80
|
+
|
|
81
|
+
allowPreload: Opts['allowPreload'] extends false ? false : OriginalOpts['allowPreload']
|
|
82
|
+
allowLeftJoinPreload: Opts['allowLeftJoinPreload'] extends false
|
|
83
|
+
? false
|
|
84
|
+
: OriginalOpts['allowLeftJoinPreload']
|
|
85
|
+
}>
|
|
86
|
+
|
|
87
|
+
export type NamespacedColumnType<
|
|
88
|
+
ColumnName,
|
|
89
|
+
Q extends Query<any, any>,
|
|
90
|
+
DreamInstance extends Dream,
|
|
91
|
+
//
|
|
92
|
+
// begin: inferred types
|
|
93
|
+
JoinedAssociationsArr = Q['queryTypeOpts']['joinedAssociations'],
|
|
94
|
+
AssociationName = ColumnName extends `${infer Name extends string}.${string}` ? Name : never,
|
|
95
|
+
RealColumnName = ColumnName extends `${string}.${infer Col extends string}` ? Col : never,
|
|
96
|
+
JoinedAssociation extends FindInterfaceWithValue<
|
|
97
|
+
JoinedAssociationsArr,
|
|
98
|
+
'alias',
|
|
99
|
+
AssociationName
|
|
100
|
+
> = FindInterfaceWithValue<JoinedAssociationsArr, 'alias', AssociationName>,
|
|
101
|
+
JoinedTable = JoinedAssociation['table'] extends never
|
|
102
|
+
? DreamInstance['table']
|
|
103
|
+
: JoinedAssociation['table'],
|
|
104
|
+
ReturnType = TableColumnType<DreamInstance['schema'], JoinedTable, RealColumnName>,
|
|
105
|
+
> = ReturnType
|
|
106
|
+
type NamespacedColumnTypes<ColumnNames, Q extends Query<any, any>, DreamInstance extends Dream> =
|
|
107
|
+
ColumnNames extends Readonly<[infer First, ...infer Rest]>
|
|
108
|
+
? [
|
|
109
|
+
NamespacedColumnType<First, Q, DreamInstance>,
|
|
110
|
+
...NamespacedColumnTypes<Readonly<Rest>, Q, DreamInstance>,
|
|
111
|
+
]
|
|
112
|
+
: []
|
|
113
|
+
|
|
114
|
+
export type BaseModelColumnTypes<ColumnNames, DreamInstance extends Dream> =
|
|
115
|
+
ColumnNames extends Readonly<[infer First, ...infer Rest]>
|
|
116
|
+
? [
|
|
117
|
+
TableColumnType<DreamInstance['schema'], DreamInstance['table'], First>,
|
|
118
|
+
...BaseModelColumnTypes<Readonly<Rest>, DreamInstance>,
|
|
119
|
+
]
|
|
120
|
+
: []
|
|
121
|
+
|
|
122
|
+
export type NamespacedOrBaseModelColumnTypes<
|
|
123
|
+
ColumnNames,
|
|
124
|
+
Q extends Query<any, any>,
|
|
125
|
+
DreamInstance extends Dream,
|
|
126
|
+
> = Q['queryTypeOpts']['joinedAssociations']['length'] extends 0
|
|
127
|
+
? BaseModelColumnTypes<ColumnNames, DreamInstance>
|
|
128
|
+
: NamespacedColumnTypes<ColumnNames, Q, DreamInstance>
|
|
129
|
+
|
|
130
|
+
export type QueryToKyselyTableNamesType<
|
|
131
|
+
Q extends Query<any, any>,
|
|
132
|
+
DreamInstance extends Dream = Q['dreamInstance'],
|
|
133
|
+
QueryTypeOpts extends Readonly<QueryTypeOptions> = Q['queryTypeOpts'],
|
|
134
|
+
HasJoinedAssociations = QueryTypeOpts['joinedAssociations']['length'] extends 0 ? false : true,
|
|
135
|
+
JoinedAssociationTables = HasJoinedAssociations extends true
|
|
136
|
+
? QueryTypeOpts['joinedAssociations'][number]['table']
|
|
137
|
+
: null,
|
|
138
|
+
JoinedAssociationAliases = HasJoinedAssociations extends true
|
|
139
|
+
? QueryTypeOpts['joinedAssociations'][number]['alias']
|
|
140
|
+
: null,
|
|
141
|
+
TableNames = HasJoinedAssociations extends true
|
|
142
|
+
? DreamInstance['table'] | JoinedAssociationTables | JoinedAssociationAliases
|
|
143
|
+
: DreamInstance['table'],
|
|
144
|
+
> = TableNames
|
|
145
|
+
|
|
146
|
+
export type QueryToKyselyDBType<
|
|
147
|
+
Q extends Query<any, any>,
|
|
148
|
+
DreamInstance extends Dream = Q['dreamInstance'],
|
|
149
|
+
AliasToDbMaps = QueryToKyselyAliasMap<Q>,
|
|
150
|
+
DbType = AliasToDbMaps extends null ? DreamInstance['DB'] : DreamInstance['DB'] & AliasToDbMaps,
|
|
151
|
+
> = DbType
|
|
152
|
+
|
|
153
|
+
export type QueryToKyselyAliasMap<
|
|
154
|
+
Q extends Query<any, any>,
|
|
155
|
+
DreamInstance extends Dream = Q['dreamInstance'],
|
|
156
|
+
QueryTypeOpts extends Readonly<QueryTypeOptions> = Q['queryTypeOpts'],
|
|
157
|
+
HasJoinedAssociations = QueryTypeOpts['joinedAssociations']['length'] extends 0 ? false : true,
|
|
158
|
+
AliasToDbMaps = HasJoinedAssociations extends true
|
|
159
|
+
? {
|
|
160
|
+
[Key in QueryTypeOpts['joinedAssociations'][number]['alias']]: Nullable<
|
|
161
|
+
DreamInstance['DB'][Extract<QueryTypeOpts['joinedAssociations'][number], { alias: Key }>['table']]
|
|
162
|
+
>
|
|
163
|
+
}
|
|
164
|
+
: null,
|
|
165
|
+
> = AliasToDbMaps
|