@rvoh/dream 2.3.0-alpha.6 → 2.3.0-alpha.8
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/Dream.js +2 -40
- package/dist/cjs/src/cli/index.js +4 -0
- package/dist/cjs/src/dream/Query.js +14 -11
- package/dist/cjs/src/dream/QueryDriver/Base.js +0 -14
- package/dist/cjs/src/dream/QueryDriver/Kysely.js +86 -74
- package/dist/cjs/src/dream/QueryDriver/Postgres.js +10 -2
- package/dist/cjs/src/dream/internal/extractAssignableAssociationAttributes.js +9 -0
- package/dist/cjs/src/errors/db/DataIncompatibleWithDatabaseField.js +1 -3
- package/dist/cjs/src/helpers/areEqual.js +5 -0
- package/dist/cjs/src/helpers/cli/ASTBuilder.js +54 -2
- package/dist/cjs/src/helpers/cli/ASTKyselyCodegenEnhancer.js +84 -0
- package/dist/cjs/src/helpers/cli/ASTSchemaBuilder.js +17 -1
- package/dist/cjs/src/helpers/cli/generateFactoryContent.js +16 -0
- package/dist/cjs/src/helpers/cloneDeepSafe.js +21 -10
- package/dist/cjs/src/helpers/customPgParsers.js +18 -1
- package/dist/cjs/src/helpers/db/normalizeDataForDb.js +81 -0
- package/dist/cjs/src/helpers/db/types/helpers.js +5 -0
- package/dist/cjs/src/helpers/db/types/isDatetimeOrDatetimeArrayColumn.js +2 -1
- package/dist/cjs/src/helpers/sortBy.js +7 -5
- package/dist/cjs/src/helpers/sqlAttributes.js +4 -53
- package/dist/cjs/src/helpers/stringCasing.js +6 -5
- package/dist/cjs/src/helpers/toSafeObject.js +17 -0
- package/dist/cjs/src/package-exports/errors.js +2 -0
- package/dist/cjs/src/package-exports/index.js +2 -0
- package/dist/cjs/src/serializer/SerializerRenderer.js +11 -11
- package/dist/cjs/src/types/clocktime.js +1 -0
- package/dist/cjs/src/utils/datetime/BaseClockTime.js +363 -0
- package/dist/cjs/src/utils/datetime/CalendarDate.js +110 -119
- package/dist/cjs/src/utils/datetime/ClockTime.js +173 -0
- package/dist/cjs/src/utils/datetime/ClockTimeTz.js +232 -0
- package/dist/cjs/src/utils/datetime/DateTime.js +288 -193
- package/dist/cjs/src/utils/datetime/helpers/isoTimeDecimalString.js +1 -1
- package/dist/esm/src/Dream.js +2 -40
- package/dist/esm/src/cli/index.js +4 -0
- package/dist/esm/src/dream/Query.js +14 -11
- package/dist/esm/src/dream/QueryDriver/Base.js +0 -14
- package/dist/esm/src/dream/QueryDriver/Kysely.js +86 -74
- package/dist/esm/src/dream/QueryDriver/Postgres.js +10 -2
- package/dist/esm/src/dream/internal/extractAssignableAssociationAttributes.js +9 -0
- package/dist/esm/src/errors/db/DataIncompatibleWithDatabaseField.js +1 -3
- package/dist/esm/src/helpers/areEqual.js +5 -0
- package/dist/esm/src/helpers/cli/ASTBuilder.js +54 -2
- package/dist/esm/src/helpers/cli/ASTKyselyCodegenEnhancer.js +84 -0
- package/dist/esm/src/helpers/cli/ASTSchemaBuilder.js +17 -1
- package/dist/esm/src/helpers/cli/generateFactoryContent.js +16 -0
- package/dist/esm/src/helpers/cloneDeepSafe.js +21 -10
- package/dist/esm/src/helpers/customPgParsers.js +18 -1
- package/dist/esm/src/helpers/db/normalizeDataForDb.js +81 -0
- package/dist/esm/src/helpers/db/types/helpers.js +5 -0
- package/dist/esm/src/helpers/db/types/isDatetimeOrDatetimeArrayColumn.js +2 -1
- package/dist/esm/src/helpers/sortBy.js +7 -5
- package/dist/esm/src/helpers/sqlAttributes.js +4 -53
- package/dist/esm/src/helpers/stringCasing.js +6 -5
- package/dist/esm/src/helpers/toSafeObject.js +17 -0
- package/dist/esm/src/package-exports/errors.js +2 -0
- package/dist/esm/src/package-exports/index.js +2 -0
- package/dist/esm/src/serializer/SerializerRenderer.js +11 -11
- package/dist/esm/src/types/clocktime.js +1 -0
- package/dist/esm/src/utils/datetime/BaseClockTime.js +363 -0
- package/dist/esm/src/utils/datetime/CalendarDate.js +110 -119
- package/dist/esm/src/utils/datetime/ClockTime.js +173 -0
- package/dist/esm/src/utils/datetime/ClockTimeTz.js +232 -0
- package/dist/esm/src/utils/datetime/DateTime.js +288 -193
- package/dist/esm/src/utils/datetime/helpers/isoTimeDecimalString.js +1 -1
- package/dist/types/src/Dream.d.ts +29 -33
- package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +9 -10
- package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +16 -16
- package/dist/types/src/dream/LeftJoinLoadBuilder.d.ts +1 -1
- package/dist/types/src/dream/LoadBuilder.d.ts +1 -1
- package/dist/types/src/dream/Query.d.ts +16 -16
- package/dist/types/src/dream/QueryDriver/Base.d.ts +0 -1
- package/dist/types/src/dream/QueryDriver/Kysely.d.ts +1 -0
- package/dist/types/src/dream/internal/associations/associationQuery.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/associationUpdateQuery.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/destroyAssociation.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/throughAssociationHasOptionsBesidesThroughAndSource.d.ts +4 -2
- package/dist/types/src/dream/internal/associations/undestroyAssociation.d.ts +1 -1
- package/dist/types/src/dream/internal/extractAssignableAssociationAttributes.d.ts +3 -0
- package/dist/types/src/dream/internal/similarity/SimilarityBuilder.d.ts +7 -7
- package/dist/types/src/errors/db/DataIncompatibleWithDatabaseField.d.ts +2 -7
- package/dist/types/src/helpers/cli/ASTBuilder.d.ts +31 -0
- package/dist/types/src/helpers/cli/ASTKyselyCodegenEnhancer.d.ts +13 -0
- package/dist/types/src/helpers/customPgParsers.d.ts +5 -0
- package/dist/types/src/helpers/db/normalizeDataForDb.d.ts +6 -0
- package/dist/types/src/helpers/db/types/helpers.d.ts +5 -0
- package/dist/types/src/helpers/sort.d.ts +2 -1
- package/dist/types/src/helpers/sortBy.d.ts +3 -0
- package/dist/types/src/helpers/toSafeObject.d.ts +8 -0
- package/dist/types/src/package-exports/errors.d.ts +2 -0
- package/dist/types/src/package-exports/index.d.ts +2 -0
- package/dist/types/src/package-exports/types.d.ts +2 -1
- package/dist/types/src/types/associations/shared.d.ts +15 -13
- package/dist/types/src/types/associations/shared.ts +81 -41
- package/dist/types/src/types/calendardate.d.ts +22 -1
- package/dist/types/src/types/calendardate.ts +33 -1
- package/dist/types/src/types/clocktime.d.ts +22 -0
- package/dist/types/src/types/clocktime.ts +59 -0
- package/dist/types/src/types/datetime.d.ts +11 -18
- package/dist/types/src/types/datetime.ts +16 -21
- package/dist/types/src/types/dream.d.ts +27 -13
- package/dist/types/src/types/dream.ts +40 -14
- package/dist/types/src/types/variadic.d.ts +10 -9
- package/dist/types/src/types/variadic.ts +30 -5
- package/dist/types/src/utils/datetime/BaseClockTime.d.ts +287 -0
- package/dist/types/src/utils/datetime/CalendarDate.d.ts +65 -47
- package/dist/types/src/utils/datetime/ClockTime.d.ts +138 -0
- package/dist/types/src/utils/datetime/ClockTimeTz.d.ts +194 -0
- package/dist/types/src/utils/datetime/DateTime.d.ts +142 -56
- package/dist/types/src/utils/datetime/helpers/isoTimeDecimalString.d.ts +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/db.DreamMigrationHelpers.html +9 -9
- package/docs/classes/db.KyselyQueryDriver.html +33 -34
- package/docs/classes/db.PostgresQueryDriver.html +34 -35
- package/docs/classes/db.QueryDriverBase.html +32 -33
- package/docs/classes/errors.CheckConstraintViolation.html +4 -6
- package/docs/classes/errors.ColumnOverflow.html +4 -6
- package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +4 -6
- package/docs/classes/errors.DataTypeColumnTypeMismatch.html +4 -6
- package/docs/classes/errors.GlobalNameNotSet.html +3 -3
- package/docs/classes/errors.InvalidCalendarDate.html +2 -2
- package/docs/classes/errors.InvalidClockTime.html +17 -0
- package/docs/classes/errors.InvalidClockTimeTz.html +17 -0
- package/docs/classes/errors.InvalidDateTime.html +2 -2
- package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
- package/docs/classes/errors.NonLoadedAssociation.html +3 -3
- package/docs/classes/errors.NotNullViolation.html +4 -6
- package/docs/classes/errors.RecordNotFound.html +3 -3
- package/docs/classes/errors.ValidationError.html +3 -3
- package/docs/classes/index.CalendarDate.html +80 -92
- package/docs/classes/index.ClockTime.html +232 -0
- package/docs/classes/index.ClockTimeTz.html +253 -0
- package/docs/classes/index.DateTime.html +123 -129
- package/docs/classes/index.Decorators.html +19 -19
- package/docs/classes/index.Dream.html +127 -127
- package/docs/classes/index.DreamApp.html +5 -5
- package/docs/classes/index.DreamTransaction.html +2 -2
- package/docs/classes/index.Env.html +2 -2
- package/docs/classes/index.Query.html +71 -71
- package/docs/classes/system.CliFileWriter.html +2 -2
- package/docs/classes/system.DreamBin.html +2 -2
- package/docs/classes/system.DreamCLI.html +5 -5
- package/docs/classes/system.DreamImporter.html +2 -2
- package/docs/classes/system.DreamLogos.html +2 -2
- package/docs/classes/system.DreamSerializerBuilder.html +8 -8
- package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
- package/docs/classes/system.PathHelpers.html +3 -3
- package/docs/classes/utils.Encrypt.html +2 -2
- package/docs/classes/utils.Range.html +2 -2
- package/docs/functions/db.closeAllDbConnections.html +1 -1
- package/docs/functions/db.dreamDbConnections.html +1 -1
- package/docs/functions/db.untypedDb.html +1 -1
- package/docs/functions/db.validateColumn.html +1 -1
- package/docs/functions/db.validateTable.html +1 -1
- package/docs/functions/errors.pgErrorType.html +1 -1
- package/docs/functions/index.DreamSerializer.html +1 -1
- package/docs/functions/index.ObjectSerializer.html +1 -1
- package/docs/functions/index.ReplicaSafe.html +1 -1
- package/docs/functions/index.STI.html +1 -1
- package/docs/functions/index.SoftDelete.html +1 -1
- package/docs/functions/utils.camelize.html +1 -1
- package/docs/functions/utils.capitalize.html +1 -1
- package/docs/functions/utils.cloneDeepSafe.html +1 -1
- package/docs/functions/utils.compact.html +1 -1
- package/docs/functions/utils.groupBy.html +1 -1
- package/docs/functions/utils.hyphenize.html +1 -1
- package/docs/functions/utils.intersection.html +1 -1
- package/docs/functions/utils.isEmpty.html +1 -1
- package/docs/functions/utils.normalizeUnicode.html +1 -1
- package/docs/functions/utils.pascalize.html +1 -1
- package/docs/functions/utils.percent.html +1 -1
- package/docs/functions/utils.range-1.html +1 -1
- package/docs/functions/utils.round.html +1 -1
- package/docs/functions/utils.sanitizeString.html +1 -1
- package/docs/functions/utils.snakeify.html +1 -1
- package/docs/functions/utils.sort.html +1 -1
- package/docs/functions/utils.sortBy.html +1 -1
- package/docs/functions/utils.sortObjectByKey.html +1 -1
- package/docs/functions/utils.sortObjectByValue.html +1 -1
- package/docs/functions/utils.uncapitalize.html +1 -1
- package/docs/functions/utils.uniq.html +1 -1
- package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
- package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
- package/docs/interfaces/types.BelongsToStatement.html +2 -2
- package/docs/interfaces/types.DecoratorContext.html +2 -2
- package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
- package/docs/interfaces/types.DreamAppOpts.html +2 -2
- package/docs/interfaces/types.DurationObject.html +5 -5
- package/docs/interfaces/types.EncryptOptions.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
- package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
- package/docs/modules/db.html +1 -1
- package/docs/modules/errors.html +3 -1
- package/docs/modules/index.html +3 -1
- package/docs/modules/openapi.html +1 -1
- package/docs/modules/system.html +1 -1
- package/docs/modules/types.html +3 -1
- package/docs/modules/utils.html +1 -1
- package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/openapi.OpenapiAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiFormats.html +1 -1
- package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNull.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaString.html +1 -1
- package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiTypeField.html +1 -1
- package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
- package/docs/types/types.CalendarDateDurationUnit.html +1 -1
- package/docs/types/types.CalendarDateObject.html +2 -0
- package/docs/types/types.Camelized.html +1 -1
- package/docs/types/types.ClockTimeObject.html +2 -0
- package/docs/types/types.DbConnectionType.html +1 -1
- package/docs/types/types.DbTypes.html +1 -1
- package/docs/types/types.DreamAssociationMetadata.html +1 -1
- package/docs/types/types.DreamAttributes.html +1 -1
- package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
- package/docs/types/types.DreamClassColumn.html +1 -1
- package/docs/types/types.DreamColumn.html +1 -1
- package/docs/types/types.DreamColumnNames.html +1 -1
- package/docs/types/types.DreamLogLevel.html +1 -1
- package/docs/types/types.DreamLogger.html +1 -1
- package/docs/types/types.DreamModelSerializerType.html +1 -1
- package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
- package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/types.DreamParamSafeAttributes.html +1 -1
- package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
- package/docs/types/types.DreamSerializable.html +1 -1
- package/docs/types/types.DreamSerializableArray.html +1 -1
- package/docs/types/types.DreamSerializerKey.html +1 -1
- package/docs/types/types.DreamSerializers.html +1 -1
- package/docs/types/types.DreamVirtualColumns.html +1 -1
- package/docs/types/types.DurationUnit.html +2 -4
- package/docs/types/types.EncryptAlgorithm.html +1 -1
- package/docs/types/types.HasManyStatement.html +1 -1
- package/docs/types/types.HasOneStatement.html +1 -1
- package/docs/types/types.Hyphenized.html +1 -1
- package/docs/types/types.Pascalized.html +1 -1
- package/docs/types/types.PrimaryKeyType.html +1 -1
- package/docs/types/types.RoundingPrecision.html +1 -1
- package/docs/types/types.SerializerCasing.html +1 -1
- package/docs/types/types.SimpleObjectSerializerType.html +1 -1
- package/docs/types/types.Snakeified.html +1 -1
- package/docs/types/types.StrictInterface.html +1 -1
- package/docs/types/types.UpdateableAssociationProperties.html +1 -1
- package/docs/types/types.UpdateableProperties.html +1 -1
- package/docs/types/types.ValidationType.html +1 -1
- package/docs/types/types.ViewModel.html +1 -1
- package/docs/types/types.ViewModelClass.html +1 -1
- package/docs/types/types.WeekdayName.html +1 -1
- package/docs/types/types.WhereStatementForDream.html +1 -1
- package/docs/types/types.WhereStatementForDreamClass.html +1 -1
- package/docs/variables/index.DreamConst.html +1 -1
- package/docs/variables/index.ops.html +1 -1
- package/docs/variables/openapi.openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
- package/docs/variables/system.primaryKeyTypes.html +1 -1
- package/package.json +2 -2
- package/dist/cjs/src/helpers/db/types/isDateOrDateArrayColumn.js +0 -3
- package/dist/cjs/src/helpers/db/types/isTextOrTextArrayColumn.js +0 -3
- package/dist/esm/src/helpers/db/types/isDateOrDateArrayColumn.js +0 -3
- package/dist/esm/src/helpers/db/types/isTextOrTextArrayColumn.js +0 -3
- package/dist/types/src/helpers/db/types/isDateOrDateArrayColumn.d.ts +0 -2
- package/dist/types/src/helpers/db/types/isTextOrTextArrayColumn.d.ts +0 -2
|
@@ -8,6 +8,7 @@ import { DreamConst } from '../../dream/constants.js'
|
|
|
8
8
|
import { Range } from '../../helpers/range.js'
|
|
9
9
|
import CurriedOpsStatement from '../../ops/curried-ops-statement.js'
|
|
10
10
|
import OpsStatement, { ExtraSimilarityArgs } from '../../ops/ops-statement.js'
|
|
11
|
+
import { ClockTime, ClockTimeTz } from '../../package-exports/index.js'
|
|
11
12
|
import CalendarDate from '../../utils/datetime/CalendarDate.js'
|
|
12
13
|
import { DateTime } from '../../utils/datetime/DateTime.js'
|
|
13
14
|
import { AssociationTableNames } from '../db.js'
|
|
@@ -93,9 +94,13 @@ type NonKyselySupportedSupplementalWhereClauseValues<
|
|
|
93
94
|
? TypesAllowedForBigintAgainstTheDb | PermanentOpsValTypes
|
|
94
95
|
: ModelPropertyType extends DateTime | CalendarDate
|
|
95
96
|
? DateTime | CalendarDate | null
|
|
96
|
-
: ModelPropertyType extends
|
|
97
|
-
?
|
|
98
|
-
:
|
|
97
|
+
: ModelPropertyType extends ClockTime
|
|
98
|
+
? ClockTime | null
|
|
99
|
+
: ModelPropertyType extends ClockTimeTz
|
|
100
|
+
? ClockTimeTz | null
|
|
101
|
+
: ModelPropertyType extends number | string
|
|
102
|
+
? ModelPropertyType | PermanentOpsValTypes
|
|
103
|
+
: never
|
|
99
104
|
: EnumTypeArray extends string[]
|
|
100
105
|
? EnumTypeArray[number] | PermanentOpsValTypes
|
|
101
106
|
: never,
|
|
@@ -108,30 +113,44 @@ type NonKyselySupportedSupplementalWhereClauseValues<
|
|
|
108
113
|
| (() => Range<DateTime | CalendarDate>)
|
|
109
114
|
| (() => Range<null, DateTime | CalendarDate>)
|
|
110
115
|
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
111
|
-
: ModelPropertyType extends
|
|
116
|
+
: ModelPropertyType extends ClockTime
|
|
112
117
|
?
|
|
113
|
-
| Range<
|
|
114
|
-
| Range<null,
|
|
115
|
-
| (() => Range<
|
|
116
|
-
| (() => Range<null,
|
|
117
|
-
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType>
|
|
118
|
-
:
|
|
118
|
+
| Range<ClockTime>
|
|
119
|
+
| Range<null, ClockTime>
|
|
120
|
+
| (() => Range<ClockTime>)
|
|
121
|
+
| (() => Range<null, ClockTime>)
|
|
122
|
+
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
123
|
+
: ModelPropertyType extends ClockTimeTz
|
|
119
124
|
?
|
|
120
|
-
| Range<
|
|
121
|
-
| Range<null,
|
|
125
|
+
| Range<ClockTimeTz>
|
|
126
|
+
| Range<null, ClockTimeTz>
|
|
127
|
+
| (() => Range<ClockTimeTz>)
|
|
128
|
+
| (() => Range<null, ClockTimeTz>)
|
|
122
129
|
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
123
|
-
: ModelPropertyType extends
|
|
130
|
+
: ModelPropertyType extends CalendarDate
|
|
124
131
|
?
|
|
125
|
-
| Range<
|
|
126
|
-
| Range<null,
|
|
127
|
-
|
|
|
128
|
-
|
|
132
|
+
| Range<DateTime | CalendarDate>
|
|
133
|
+
| Range<null, DateTime | CalendarDate>
|
|
134
|
+
| (() => Range<DateTime | CalendarDate>)
|
|
135
|
+
| (() => Range<null, DateTime | CalendarDate>)
|
|
136
|
+
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType>
|
|
137
|
+
: ColumnType extends 'bigint'
|
|
129
138
|
?
|
|
130
|
-
| Range<
|
|
131
|
-
| Range<null,
|
|
132
|
-
| OpsStatement<KyselyComparisonOperatorExpression,
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
| Range<TypesAllowedForBigintAgainstTheDb>
|
|
140
|
+
| Range<null, TypesAllowedForBigintAgainstTheDb>
|
|
141
|
+
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
142
|
+
: ModelPropertyType extends number
|
|
143
|
+
?
|
|
144
|
+
| Range<ModelPropertyType>
|
|
145
|
+
| Range<null, ModelPropertyType>
|
|
146
|
+
| OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
147
|
+
: ModelPropertyType extends string
|
|
148
|
+
?
|
|
149
|
+
| Range<string>
|
|
150
|
+
| Range<null, string>
|
|
151
|
+
| OpsStatement<KyselyComparisonOperatorExpression, string, any>
|
|
152
|
+
| OpsStatement<TrigramOperator, OpsValType, ExtraSimilarityArgs>
|
|
153
|
+
: never
|
|
135
154
|
: EnumTypeArray extends string[]
|
|
136
155
|
? EnumTypeArray | OpsStatement<KyselyComparisonOperatorExpression, OpsValType, any>
|
|
137
156
|
: never,
|
|
@@ -143,16 +162,12 @@ type NonKyselySupportedSupplementalWhereClauseValues<
|
|
|
143
162
|
: PartialTypes | CurriedOpsStatement<any, any, any, OpsValType> | SelectQueryBuilder<DB, keyof DB, any>
|
|
144
163
|
|
|
145
164
|
export type WhereStatementForDreamClass<DreamClass extends typeof Dream> = WhereStatement<
|
|
146
|
-
InstanceType<DreamClass>
|
|
147
|
-
InstanceType<DreamClass>['schema'],
|
|
148
|
-
InstanceType<DreamClass>['table']
|
|
165
|
+
InstanceType<DreamClass>
|
|
149
166
|
>
|
|
150
167
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
DreamInstance['table']
|
|
155
|
-
>
|
|
168
|
+
// TODO: deprecate, since this is now the same as WhereStatement? it is not used internally, only exported.
|
|
169
|
+
export type WhereStatementForDream<DreamInstance extends Dream> = WhereStatement<DreamInstance>
|
|
170
|
+
|
|
156
171
|
type AssociationNameToDotReferencedColumns<
|
|
157
172
|
DB,
|
|
158
173
|
TableName extends keyof DB,
|
|
@@ -200,31 +215,50 @@ type Whereable<R> = {
|
|
|
200
215
|
[K in keyof Selectable<R>]?: Selectable<R>[K] | Selectable<R>[K][]
|
|
201
216
|
}
|
|
202
217
|
|
|
203
|
-
export type WhereStatement<
|
|
218
|
+
export type WhereStatement<I extends Dream> = InternalWhereStatement<I, I['DB'], I['schema'], I['table']>
|
|
219
|
+
|
|
220
|
+
export type InternalWhereStatement<
|
|
221
|
+
I extends Dream,
|
|
204
222
|
DB,
|
|
205
223
|
Schema,
|
|
206
224
|
TableName extends AssociationTableNames<DB, Schema> & keyof DB,
|
|
207
|
-
> = Partial<
|
|
225
|
+
> = Partial<
|
|
226
|
+
MergeUnionOfRecordTypes<
|
|
227
|
+
Whereable<DB[TableName]> | DreamSelectable<DB, Schema, TableName> | AssociatedModelParam<I>
|
|
228
|
+
>
|
|
229
|
+
>
|
|
208
230
|
|
|
209
231
|
export type OnStatementForAssociation<
|
|
232
|
+
I extends Dream,
|
|
210
233
|
DB,
|
|
211
234
|
Schema,
|
|
212
235
|
TableName extends AssociationTableNames<DB, Schema> & keyof DB,
|
|
213
236
|
RequiredOnClauseKeysForThisAssociation,
|
|
214
|
-
OnStatement extends
|
|
237
|
+
OnStatement extends InternalWhereStatement<I, DB, Schema, TableName> = InternalWhereStatement<
|
|
238
|
+
I,
|
|
239
|
+
DB,
|
|
240
|
+
Schema,
|
|
241
|
+
TableName
|
|
242
|
+
>,
|
|
215
243
|
> = RequiredOnClauseKeysForThisAssociation extends null
|
|
216
|
-
?
|
|
244
|
+
? InternalWhereStatement<I, DB, Schema, TableName>
|
|
217
245
|
: RequiredOnClauseKeysForThisAssociation extends string[]
|
|
218
246
|
? Required<Pick<OnStatement, RequiredOnClauseKeysForThisAssociation[number] & keyof OnStatement>> &
|
|
219
247
|
Partial<Omit<OnStatement, RequiredOnClauseKeysForThisAssociation[number] & keyof OnStatement>>
|
|
220
248
|
: never
|
|
221
249
|
|
|
222
250
|
export type OnStatementForSpecificColumns<
|
|
251
|
+
I extends Dream,
|
|
223
252
|
DB,
|
|
224
253
|
Schema,
|
|
225
254
|
TableName extends AssociationTableNames<DB, Schema> & keyof DB,
|
|
226
255
|
Columns extends string[],
|
|
227
|
-
OnStatement extends
|
|
256
|
+
OnStatement extends InternalWhereStatement<I, DB, Schema, TableName> = InternalWhereStatement<
|
|
257
|
+
I,
|
|
258
|
+
DB,
|
|
259
|
+
Schema,
|
|
260
|
+
TableName
|
|
261
|
+
>,
|
|
228
262
|
> = Pick<OnStatement, Columns[number] & keyof OnStatement>
|
|
229
263
|
|
|
230
264
|
// on statement on an association definition
|
|
@@ -252,17 +286,20 @@ export type SelfOnStatement<
|
|
|
252
286
|
> = Partial<Record<keyof DB[TableName], DreamColumnNames<BaseInstance>>>
|
|
253
287
|
|
|
254
288
|
export type WhereStatementForJoinedAssociation<
|
|
289
|
+
I extends Dream,
|
|
255
290
|
JoinedAssociations extends Readonly<JoinedAssociation[]>,
|
|
256
291
|
DB,
|
|
257
292
|
Schema,
|
|
258
293
|
TableName extends AssociationTableNames<DB, Schema> & keyof DB,
|
|
259
294
|
> = RecursiveWhereStatementForJoinedAssociation<
|
|
295
|
+
I,
|
|
260
296
|
JoinedAssociations,
|
|
261
297
|
DB,
|
|
262
298
|
Schema,
|
|
263
|
-
|
|
299
|
+
InternalWhereStatement<I, DB, Schema, TableName>
|
|
264
300
|
>
|
|
265
301
|
type RecursiveWhereStatementForJoinedAssociation<
|
|
302
|
+
I extends Dream,
|
|
266
303
|
JoinedAssociations extends Readonly<JoinedAssociation[]>,
|
|
267
304
|
DB,
|
|
268
305
|
Schema,
|
|
@@ -277,7 +314,7 @@ type RecursiveWhereStatementForJoinedAssociation<
|
|
|
277
314
|
? never
|
|
278
315
|
: AssociationName extends never
|
|
279
316
|
? never
|
|
280
|
-
:
|
|
317
|
+
: InternalWhereStatement<I, DB, Schema, TableName & AssociationTableNames<DB, Schema> & keyof DB>,
|
|
281
318
|
NextOnStatement = NonNamespacedAssociationOnStatement extends never
|
|
282
319
|
? OriginalOnStatement
|
|
283
320
|
: OriginalOnStatement & {
|
|
@@ -293,6 +330,7 @@ type RecursiveWhereStatementForJoinedAssociation<
|
|
|
293
330
|
: TableName extends never
|
|
294
331
|
? OriginalOnStatement
|
|
295
332
|
: RecursiveWhereStatementForJoinedAssociation<
|
|
333
|
+
I,
|
|
296
334
|
ReadonlyTail<JoinedAssociations>,
|
|
297
335
|
DB,
|
|
298
336
|
Schema,
|
|
@@ -326,8 +364,8 @@ export interface HasStatement<
|
|
|
326
364
|
foreignKeyTypeField: () => keyof DB[ForeignTableName] & string
|
|
327
365
|
globalAssociationNameOrNames: string[]
|
|
328
366
|
and?: OnStatementForAssociationDefinition<DB, Schema, ForeignTableName>
|
|
329
|
-
andNot?:
|
|
330
|
-
andAny?:
|
|
367
|
+
andNot?: InternalWhereStatement<BaseInstance, DB, Schema, ForeignTableName>
|
|
368
|
+
andAny?: InternalWhereStatement<BaseInstance, DB, Schema, ForeignTableName>[]
|
|
331
369
|
// ATTENTION
|
|
332
370
|
//
|
|
333
371
|
// Using `order` with HasOne is tempting as an elegant API
|
|
@@ -372,7 +410,8 @@ interface HasOptionsBase<
|
|
|
372
410
|
keyof BaseInstance['DB']
|
|
373
411
|
>
|
|
374
412
|
|
|
375
|
-
andNot?:
|
|
413
|
+
andNot?: InternalWhereStatement<
|
|
414
|
+
BaseInstance,
|
|
376
415
|
BaseInstance['DB'],
|
|
377
416
|
BaseInstance['schema'],
|
|
378
417
|
AssociationTableName &
|
|
@@ -380,7 +419,8 @@ interface HasOptionsBase<
|
|
|
380
419
|
keyof BaseInstance['DB']
|
|
381
420
|
>
|
|
382
421
|
|
|
383
|
-
andAny?:
|
|
422
|
+
andAny?: InternalWhereStatement<
|
|
423
|
+
BaseInstance,
|
|
384
424
|
BaseInstance['DB'],
|
|
385
425
|
BaseInstance['schema'],
|
|
386
426
|
AssociationTableName &
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
import type { DateTimeUnit, DurationLikeObject } from './datetime.js';
|
|
1
|
+
import type { DateTimeObject, DateTimeUnit, DurationLikeObject } from './datetime.js';
|
|
2
2
|
export type CalendarDateDurationLike = Pick<DurationLikeObject, 'year' | 'years' | 'quarter' | 'quarters' | 'month' | 'months' | 'week' | 'weeks' | 'day' | 'days'>;
|
|
3
3
|
export type CalendarDateDurationUnit = 'years' | 'quarters' | 'months' | 'weeks' | 'days';
|
|
4
4
|
export type CalendarDateUnit = Extract<DateTimeUnit, 'year' | 'quarter' | 'month' | 'week' | 'day'>;
|
|
5
|
+
/**
|
|
6
|
+
* Date-only object for CalendarDate (year, month, day).
|
|
7
|
+
*/
|
|
8
|
+
export type CalendarDateObject = Pick<DateTimeObject, 'year' | 'month' | 'day'>;
|
|
9
|
+
/**
|
|
10
|
+
* Complete duration object with all possible calendar date units.
|
|
11
|
+
*/
|
|
12
|
+
export interface CalendarDateDurationObject {
|
|
13
|
+
years?: number;
|
|
14
|
+
quarters?: number;
|
|
15
|
+
months?: number;
|
|
16
|
+
weeks?: number;
|
|
17
|
+
days?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Helper type to extract only the units specified in the unit parameter for CalendarDate.diff().
|
|
21
|
+
* If unit is a single string, returns an object with just that key.
|
|
22
|
+
* If unit is an array, returns an object with keys for each unit in the array.
|
|
23
|
+
* If unit is undefined, returns the full CalendarDateDurationObject.
|
|
24
|
+
*/
|
|
25
|
+
export type CalendarDateDiffResult<U extends CalendarDateDurationUnit | readonly CalendarDateDurationUnit[] | undefined> = U extends undefined ? CalendarDateDurationObject : U extends CalendarDateDurationUnit ? Pick<Required<CalendarDateDurationObject>, U> : U extends readonly CalendarDateDurationUnit[] ? Pick<Required<CalendarDateDurationObject>, U[number]> : never;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DateTimeUnit, DurationLikeObject } from './datetime.js'
|
|
1
|
+
import type { DateTimeObject, DateTimeUnit, DurationLikeObject } from './datetime.js'
|
|
2
2
|
|
|
3
3
|
export type CalendarDateDurationLike = Pick<
|
|
4
4
|
DurationLikeObject,
|
|
@@ -6,3 +6,35 @@ export type CalendarDateDurationLike = Pick<
|
|
|
6
6
|
>
|
|
7
7
|
export type CalendarDateDurationUnit = 'years' | 'quarters' | 'months' | 'weeks' | 'days'
|
|
8
8
|
export type CalendarDateUnit = Extract<DateTimeUnit, 'year' | 'quarter' | 'month' | 'week' | 'day'>
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Date-only object for CalendarDate (year, month, day).
|
|
12
|
+
*/
|
|
13
|
+
export type CalendarDateObject = Pick<DateTimeObject, 'year' | 'month' | 'day'>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Complete duration object with all possible calendar date units.
|
|
17
|
+
*/
|
|
18
|
+
export interface CalendarDateDurationObject {
|
|
19
|
+
years?: number
|
|
20
|
+
quarters?: number
|
|
21
|
+
months?: number
|
|
22
|
+
weeks?: number
|
|
23
|
+
days?: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Helper type to extract only the units specified in the unit parameter for CalendarDate.diff().
|
|
28
|
+
* If unit is a single string, returns an object with just that key.
|
|
29
|
+
* If unit is an array, returns an object with keys for each unit in the array.
|
|
30
|
+
* If unit is undefined, returns the full CalendarDateDurationObject.
|
|
31
|
+
*/
|
|
32
|
+
export type CalendarDateDiffResult<
|
|
33
|
+
U extends CalendarDateDurationUnit | readonly CalendarDateDurationUnit[] | undefined,
|
|
34
|
+
> = U extends undefined
|
|
35
|
+
? CalendarDateDurationObject
|
|
36
|
+
: U extends CalendarDateDurationUnit
|
|
37
|
+
? Pick<Required<CalendarDateDurationObject>, U>
|
|
38
|
+
: U extends readonly CalendarDateDurationUnit[]
|
|
39
|
+
? Pick<Required<CalendarDateDurationObject>, U[number]>
|
|
40
|
+
: never
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DateTimeObject, DateTimeUnit, DurationLikeObject, DurationObject, DurationUnit } from './datetime.js';
|
|
2
|
+
/**
|
|
3
|
+
* Time-only object for ClockTime (hour, minute, second, millisecond, microsecond).
|
|
4
|
+
*/
|
|
5
|
+
export type ClockTimeObject = Pick<DateTimeObject, 'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond'>;
|
|
6
|
+
/**
|
|
7
|
+
* Time-only duration units for ClockTime.
|
|
8
|
+
*/
|
|
9
|
+
export type ClockTimeDurationUnit = Extract<DurationUnit, 'hours' | 'minutes' | 'seconds' | 'milliseconds' | 'microseconds'>;
|
|
10
|
+
export type ClockTimeUnit = Extract<DateTimeUnit, 'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond'>;
|
|
11
|
+
/**
|
|
12
|
+
* Complete duration object with all possible clock time units.
|
|
13
|
+
*/
|
|
14
|
+
export type ClockTimeDurationObject = Pick<DurationObject, 'hours' | 'minutes' | 'seconds' | 'milliseconds' | 'microseconds'>;
|
|
15
|
+
/**
|
|
16
|
+
* Helper type to extract only the units specified in the unit parameter for ClockTime.diff().
|
|
17
|
+
* If unit is a single string, returns an object with just that key.
|
|
18
|
+
* If unit is an array, returns an object with keys for each unit in the array.
|
|
19
|
+
* If unit is undefined, returns the full ClockTimeDurationObject.
|
|
20
|
+
*/
|
|
21
|
+
export type ClockTimeDiffResult<U extends ClockTimeDurationUnit | readonly ClockTimeDurationUnit[] | undefined> = U extends undefined ? ClockTimeDurationObject : U extends ClockTimeDurationUnit ? Pick<Required<ClockTimeDurationObject>, U> : U extends readonly ClockTimeDurationUnit[] ? Pick<Required<ClockTimeDurationObject>, U[number]> : never;
|
|
22
|
+
export type ClockTimeDurationLikeObject = Pick<DurationLikeObject, 'hour' | 'hours' | 'minute' | 'minutes' | 'second' | 'seconds' | 'millisecond' | 'milliseconds' | 'microsecond' | 'microseconds'>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DateTimeObject, DateTimeUnit, DurationLikeObject, DurationObject, DurationUnit } from './datetime.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Time-only object for ClockTime (hour, minute, second, millisecond, microsecond).
|
|
5
|
+
*/
|
|
6
|
+
export type ClockTimeObject = Pick<
|
|
7
|
+
DateTimeObject,
|
|
8
|
+
'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond'
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Time-only duration units for ClockTime.
|
|
13
|
+
*/
|
|
14
|
+
export type ClockTimeDurationUnit = Extract<
|
|
15
|
+
DurationUnit,
|
|
16
|
+
'hours' | 'minutes' | 'seconds' | 'milliseconds' | 'microseconds'
|
|
17
|
+
>
|
|
18
|
+
export type ClockTimeUnit = Extract<
|
|
19
|
+
DateTimeUnit,
|
|
20
|
+
'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond'
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Complete duration object with all possible clock time units.
|
|
25
|
+
*/
|
|
26
|
+
export type ClockTimeDurationObject = Pick<
|
|
27
|
+
DurationObject,
|
|
28
|
+
'hours' | 'minutes' | 'seconds' | 'milliseconds' | 'microseconds'
|
|
29
|
+
>
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Helper type to extract only the units specified in the unit parameter for ClockTime.diff().
|
|
33
|
+
* If unit is a single string, returns an object with just that key.
|
|
34
|
+
* If unit is an array, returns an object with keys for each unit in the array.
|
|
35
|
+
* If unit is undefined, returns the full ClockTimeDurationObject.
|
|
36
|
+
*/
|
|
37
|
+
export type ClockTimeDiffResult<
|
|
38
|
+
U extends ClockTimeDurationUnit | readonly ClockTimeDurationUnit[] | undefined,
|
|
39
|
+
> = U extends undefined
|
|
40
|
+
? ClockTimeDurationObject
|
|
41
|
+
: U extends ClockTimeDurationUnit
|
|
42
|
+
? Pick<Required<ClockTimeDurationObject>, U>
|
|
43
|
+
: U extends readonly ClockTimeDurationUnit[]
|
|
44
|
+
? Pick<Required<ClockTimeDurationObject>, U[number]>
|
|
45
|
+
: never
|
|
46
|
+
|
|
47
|
+
export type ClockTimeDurationLikeObject = Pick<
|
|
48
|
+
DurationLikeObject,
|
|
49
|
+
| 'hour'
|
|
50
|
+
| 'hours'
|
|
51
|
+
| 'minute'
|
|
52
|
+
| 'minutes'
|
|
53
|
+
| 'second'
|
|
54
|
+
| 'seconds'
|
|
55
|
+
| 'millisecond'
|
|
56
|
+
| 'milliseconds'
|
|
57
|
+
| 'microsecond'
|
|
58
|
+
| 'microseconds'
|
|
59
|
+
>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export interface DateTimeOptions {
|
|
2
2
|
zone?: string | Zone;
|
|
3
|
-
setZone?: boolean;
|
|
4
3
|
locale?: string;
|
|
5
4
|
}
|
|
6
5
|
export interface DateTimeJSOptions {
|
|
@@ -15,18 +14,14 @@ export interface LocaleOptions {
|
|
|
15
14
|
numberingSystem?: string;
|
|
16
15
|
}
|
|
17
16
|
export interface DateTimeObject {
|
|
18
|
-
year
|
|
19
|
-
month
|
|
20
|
-
day
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
minute?: number;
|
|
27
|
-
second?: number;
|
|
28
|
-
millisecond?: number;
|
|
29
|
-
microsecond?: number;
|
|
17
|
+
year: number;
|
|
18
|
+
month: number;
|
|
19
|
+
day: number;
|
|
20
|
+
hour: number;
|
|
21
|
+
minute: number;
|
|
22
|
+
second: number;
|
|
23
|
+
millisecond: number;
|
|
24
|
+
microsecond: number;
|
|
30
25
|
}
|
|
31
26
|
export interface ToISOTimeOptions {
|
|
32
27
|
suppressMilliseconds?: boolean;
|
|
@@ -96,17 +91,15 @@ export interface Zone {
|
|
|
96
91
|
}
|
|
97
92
|
/**
|
|
98
93
|
* Duration units that can be used in diff operations.
|
|
99
|
-
* Note: quarters and months are excluded because they don't have fixed relationships
|
|
100
|
-
* with other time units (months vary from 28-31 days).
|
|
101
94
|
*/
|
|
102
|
-
export type DurationUnit = 'years' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds' | 'microseconds';
|
|
95
|
+
export type DurationUnit = 'years' | 'quarters' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds' | 'microseconds';
|
|
103
96
|
/**
|
|
104
97
|
* Complete duration object with all possible units returned by diff.
|
|
105
|
-
* Note: quarters and months are excluded because they don't have fixed relationships
|
|
106
|
-
* with other time units (months vary from 28-31 days).
|
|
107
98
|
*/
|
|
108
99
|
export interface DurationObject {
|
|
109
100
|
years?: number;
|
|
101
|
+
quarters?: number;
|
|
102
|
+
months?: number;
|
|
110
103
|
weeks?: number;
|
|
111
104
|
days?: number;
|
|
112
105
|
hours?: number;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
export interface DateTimeOptions {
|
|
4
4
|
zone?: string | Zone
|
|
5
|
-
setZone?: boolean
|
|
6
5
|
locale?: string
|
|
7
6
|
}
|
|
8
7
|
|
|
@@ -20,18 +19,14 @@ export interface LocaleOptions {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export interface DateTimeObject {
|
|
23
|
-
year
|
|
24
|
-
month
|
|
25
|
-
day
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
minute?: number
|
|
32
|
-
second?: number
|
|
33
|
-
millisecond?: number
|
|
34
|
-
microsecond?: number
|
|
22
|
+
year: number
|
|
23
|
+
month: number
|
|
24
|
+
day: number
|
|
25
|
+
hour: number
|
|
26
|
+
minute: number
|
|
27
|
+
second: number
|
|
28
|
+
millisecond: number
|
|
29
|
+
microsecond: number
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
export interface ToISOTimeOptions {
|
|
@@ -60,10 +55,10 @@ export type DateTimeUnit =
|
|
|
60
55
|
| 'minute'
|
|
61
56
|
| 'second'
|
|
62
57
|
| 'millisecond'
|
|
58
|
+
|
|
63
59
|
/**
|
|
64
60
|
* Weekday name type (lowercase).
|
|
65
61
|
*/
|
|
66
|
-
|
|
67
62
|
export type WeekdayName = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday'
|
|
68
63
|
|
|
69
64
|
/**
|
|
@@ -117,14 +112,14 @@ export interface Zone {
|
|
|
117
112
|
*/
|
|
118
113
|
readonly isValid: boolean
|
|
119
114
|
}
|
|
115
|
+
|
|
120
116
|
/**
|
|
121
117
|
* Duration units that can be used in diff operations.
|
|
122
|
-
* Note: quarters and months are excluded because they don't have fixed relationships
|
|
123
|
-
* with other time units (months vary from 28-31 days).
|
|
124
118
|
*/
|
|
125
|
-
|
|
126
119
|
export type DurationUnit =
|
|
127
120
|
| 'years'
|
|
121
|
+
| 'quarters'
|
|
122
|
+
| 'months'
|
|
128
123
|
| 'weeks'
|
|
129
124
|
| 'days'
|
|
130
125
|
| 'hours'
|
|
@@ -132,14 +127,14 @@ export type DurationUnit =
|
|
|
132
127
|
| 'seconds'
|
|
133
128
|
| 'milliseconds'
|
|
134
129
|
| 'microseconds'
|
|
130
|
+
|
|
135
131
|
/**
|
|
136
132
|
* Complete duration object with all possible units returned by diff.
|
|
137
|
-
* Note: quarters and months are excluded because they don't have fixed relationships
|
|
138
|
-
* with other time units (months vary from 28-31 days).
|
|
139
133
|
*/
|
|
140
|
-
|
|
141
134
|
export interface DurationObject {
|
|
142
135
|
years?: number
|
|
136
|
+
quarters?: number
|
|
137
|
+
months?: number
|
|
143
138
|
weeks?: number
|
|
144
139
|
days?: number
|
|
145
140
|
hours?: number
|
|
@@ -148,13 +143,13 @@ export interface DurationObject {
|
|
|
148
143
|
milliseconds?: number
|
|
149
144
|
microseconds?: number
|
|
150
145
|
}
|
|
146
|
+
|
|
151
147
|
/**
|
|
152
148
|
* Helper type to extract only the units specified in the unit parameter.
|
|
153
149
|
* If unit is a single string, returns an object with just that key.
|
|
154
150
|
* If unit is an array, returns an object with keys for each unit in the array.
|
|
155
151
|
* If unit is undefined, returns the full DurationObject.
|
|
156
152
|
*/
|
|
157
|
-
|
|
158
153
|
export type DiffResult<U extends DurationUnit | readonly DurationUnit[] | undefined> = U extends undefined
|
|
159
154
|
? DurationObject
|
|
160
155
|
: U extends DurationUnit
|
|
@@ -5,7 +5,7 @@ import { TRIGRAM_OPERATORS } from '../dream/constants.js';
|
|
|
5
5
|
import OpsStatement from '../ops/ops-statement.js';
|
|
6
6
|
import CalendarDate from '../utils/datetime/CalendarDate.js';
|
|
7
7
|
import { DateTime } from '../utils/datetime/DateTime.js';
|
|
8
|
-
import { AssociatedModelParam, AssociationStatement, OnStatementForAssociation,
|
|
8
|
+
import { AssociatedModelParam, AssociationStatement, OnStatementForAssociation, InternalWhereStatement } from './associations/shared.js';
|
|
9
9
|
import { AssociationTableNames } from './db.js';
|
|
10
10
|
import { FindEachOpts } from './query.js';
|
|
11
11
|
import { DreamModelSerializerType, SimpleObjectSerializerType } from './serializer.js';
|
|
@@ -80,15 +80,15 @@ type AssociationMetadataForTable<Schema, TableName extends keyof Schema> = Schem
|
|
|
80
80
|
export type AssociationNamesForTable<Schema, TableName extends keyof Schema> = keyof AssociationMetadataForTable<Schema, TableName> | AliasedSchemaAssociation<Schema, TableName>;
|
|
81
81
|
type MetadataForAssociation<Schema, TableName extends keyof Schema, AssociationName, AssociationMetadata = AssociationMetadataForTable<Schema, TableName>> = AssociationMetadata[AssociationName & keyof AssociationMetadata];
|
|
82
82
|
export type AssociationTableName<Schema, TableName extends keyof Schema, AssociationName, AssociationData = MetadataForAssociation<Schema, TableName, AssociationName>> = (AssociationData['tables' & keyof AssociationData] & any[])[0] & keyof Schema;
|
|
83
|
-
export type DreamClassAssociationAndStatement<DreamClass extends typeof Dream, AssociationName, DreamInstance extends InstanceType<DreamClass> = InstanceType<DreamClass>, DB extends DreamInstance['DB'] = DreamInstance['DB'], Schema extends DreamInstance['schema'] = DreamInstance['schema'], TableName extends DreamInstance['table'] = DreamInstance['table'], AssocTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB = AssociationTableName<Schema, TableName, AssociationName>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName> = RequiredOnClauseKeys<Schema, TableName, AssociationName>, Statements extends JoinAndStatements<DB, Schema, AssocTableName, RequiredOnClauseKeysForThisAssociation> = JoinAndStatements<DB, Schema, AssocTableName, RequiredOnClauseKeysForThisAssociation>> = Statements;
|
|
84
|
-
export type JoinAndStatements<DB, Schema, TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation> = RequiredOnClauseKeysForThisAssociation extends null ? {
|
|
85
|
-
and?:
|
|
86
|
-
andNot?:
|
|
87
|
-
andAny?:
|
|
83
|
+
export type DreamClassAssociationAndStatement<DreamClass extends typeof Dream, AssociationName, DreamInstance extends InstanceType<DreamClass> = InstanceType<DreamClass>, DB extends DreamInstance['DB'] = DreamInstance['DB'], Schema extends DreamInstance['schema'] = DreamInstance['schema'], TableName extends DreamInstance['table'] = DreamInstance['table'], AssocTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB = AssociationTableName<Schema, TableName, AssociationName>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName> = RequiredOnClauseKeys<Schema, TableName, AssociationName>, Statements extends JoinAndStatements<DreamInstance, DB, Schema, AssocTableName, RequiredOnClauseKeysForThisAssociation> = JoinAndStatements<DreamInstance, DB, Schema, AssocTableName, RequiredOnClauseKeysForThisAssociation>> = Statements;
|
|
84
|
+
export type JoinAndStatements<I extends Dream, DB, Schema, TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation> = RequiredOnClauseKeysForThisAssociation extends null ? {
|
|
85
|
+
and?: InternalWhereStatement<I, DB, Schema, TableName>;
|
|
86
|
+
andNot?: InternalWhereStatement<I, DB, Schema, TableName>;
|
|
87
|
+
andAny?: InternalWhereStatement<I, DB, Schema, TableName>[];
|
|
88
88
|
} : RequiredOnClauseKeysForThisAssociation extends string[] ? {
|
|
89
|
-
and: OnStatementForAssociation<DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>;
|
|
90
|
-
andNot?:
|
|
91
|
-
andAny?:
|
|
89
|
+
and: OnStatementForAssociation<I, DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>;
|
|
90
|
+
andNot?: InternalWhereStatement<I, DB, Schema, TableName>;
|
|
91
|
+
andAny?: InternalWhereStatement<I, DB, Schema, TableName>[];
|
|
92
92
|
} : never;
|
|
93
93
|
export type UpdateablePropertiesForClass<DreamClass extends typeof Dream, TableName extends AssociationTableNames<InstanceType<DreamClass>['DB'], InstanceType<DreamClass>['schema']> & InstanceType<DreamClass>['table'] = InstanceType<DreamClass>['table'], VirtualColumns = DreamVirtualColumns<InstanceType<DreamClass>>> = Partial<Updateable<InstanceType<DreamClass>['DB'][TableName]> & (VirtualColumns extends readonly any[] ? Record<VirtualColumns[number], any> : object) & (AssociatedModelParam<InstanceType<DreamClass>> extends never ? object : AssociatedModelParam<InstanceType<DreamClass>>)>;
|
|
94
94
|
export type UpdateableAssociationProperties<DreamInstance extends Dream, AssociationClass extends Dream, Schema = DreamInstance['schema'], AssociationTableName extends AssociationTableNames<DreamInstance['DB'], DreamInstance['schema']> & keyof DreamInstance['DB'] = AssociationClass['table'], VirtualColumns = VirtualColumnsForTable<Schema, AssociationTableName>> = Partial<Updateable<DreamInstance['DB'][AssociationTableName]> & (VirtualColumns extends readonly any[] ? Record<VirtualColumns[number], any> : object) & (AssociatedModelParam<AssociationClass> extends never ? object : AssociatedModelParam<AssociationClass>)>;
|
|
@@ -112,6 +112,20 @@ export type ViewModel = {
|
|
|
112
112
|
serializers: Record<string, DreamModelSerializerType | SimpleObjectSerializerType | string>;
|
|
113
113
|
};
|
|
114
114
|
export type ViewModelClass = abstract new (...args: any) => ViewModel;
|
|
115
|
+
/**
|
|
116
|
+
* given a Dream model and an association name, this
|
|
117
|
+
* type will return the actual type set for that association,
|
|
118
|
+
* excluding null or arrays.
|
|
119
|
+
*
|
|
120
|
+
* ```ts
|
|
121
|
+
* DreamAssociationNameToAssociatedModel<User, 'compositions'>
|
|
122
|
+
* // Composition
|
|
123
|
+
*
|
|
124
|
+
* DreamAssociationNameToAssociatedModel<User, 'featuredPost'>
|
|
125
|
+
* // Post
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export type DreamAssociationNameToAssociatedModel<I extends Dream, AssociationName extends keyof I> = I[AssociationName] extends (infer U extends Dream)[] ? U : I[AssociationName] extends Dream ? I[AssociationName] : I[AssociationName] extends Dream | null ? Required<I[AssociationName]> & Dream : I;
|
|
115
129
|
export type DreamModelAssociationNames<Schema, TableName, SchemaAssociations = Schema[TableName & keyof Schema]['associations' & keyof Schema[TableName & keyof Schema]]> = (keyof SchemaAssociations & string) | (keyof SchemaAssociations & string)[];
|
|
116
130
|
export type PreloadArgumentTypeAssociatedTableNames<Schema, PreviousTableNames, ArgumentType, PreviousSchemaAssociations = PreviousTableNames extends undefined ? undefined : Schema[PreviousTableNames & keyof Schema]> = ArgumentType extends string[] ? undefined : (PreviousSchemaAssociations[ArgumentType & (keyof PreviousSchemaAssociations & string)] & string[])[number];
|
|
117
131
|
export type AssociationNameToDreamClassMap = Record<string, typeof Dream>;
|
|
@@ -124,11 +138,11 @@ type IdToDreamMap = Map<string | number, Dream>;
|
|
|
124
138
|
export type AliasToDreamIdMap = Record<string, IdToDreamMap>;
|
|
125
139
|
export type RelaxedPreloadStatement<Depth extends number = 0> = RelaxedJoinStatement<Depth>;
|
|
126
140
|
export type RelaxedJoinStatement<Depth extends number = 0> = Depth extends 7 ? object : Record<string, RelaxedJoinStatement<Inc<Depth>>>;
|
|
127
|
-
export type RelaxedPreloadOnStatement<DB, Schema, Depth extends number = 0> = Depth extends 7 ? object : {
|
|
128
|
-
[key: string]: RelaxedPreloadOnStatement<DB, Schema, Inc<Depth>> | JoinAndStatements<any, any, any, any> | FakeOnClauseValue | object;
|
|
141
|
+
export type RelaxedPreloadOnStatement<I extends Dream, DB, Schema, Depth extends number = 0> = Depth extends 7 ? object : {
|
|
142
|
+
[key: string]: RelaxedPreloadOnStatement<I, DB, Schema, Inc<Depth>> | JoinAndStatements<I, any, any, any, any> | FakeOnClauseValue | object;
|
|
129
143
|
};
|
|
130
|
-
export type RelaxedJoinAndStatement<DB, Schema, Depth extends number = 0> = Depth extends 7 ? object : {
|
|
131
|
-
[key: string]: RelaxedJoinAndStatement<DB, Schema, Inc<Depth>> | JoinAndStatements<any, any, any, any> | FakeOnClauseValue | object;
|
|
144
|
+
export type RelaxedJoinAndStatement<I extends Dream, DB, Schema, Depth extends number = 0> = Depth extends 7 ? object : {
|
|
145
|
+
[key: string]: RelaxedJoinAndStatement<I, DB, Schema, Inc<Depth>> | JoinAndStatements<I, any, any, any, any> | FakeOnClauseValue | object;
|
|
132
146
|
};
|
|
133
147
|
type FakeOnClauseValue = string | string[] | number | number[] | null;
|
|
134
148
|
export type TableOrAssociationName<Schema> = (keyof Schema & string) | (keyof Schema[keyof Schema] & string);
|