@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
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
AssociatedModelParam,
|
|
10
10
|
AssociationStatement,
|
|
11
11
|
OnStatementForAssociation,
|
|
12
|
-
|
|
12
|
+
InternalWhereStatement,
|
|
13
13
|
} from './associations/shared.js'
|
|
14
14
|
import { AssociationTableNames } from './db.js'
|
|
15
15
|
import { FindEachOpts } from './query.js'
|
|
@@ -393,32 +393,34 @@ export type DreamClassAssociationAndStatement<
|
|
|
393
393
|
AssociationName
|
|
394
394
|
> = RequiredOnClauseKeys<Schema, TableName, AssociationName>,
|
|
395
395
|
Statements extends JoinAndStatements<
|
|
396
|
+
DreamInstance,
|
|
396
397
|
DB,
|
|
397
398
|
Schema,
|
|
398
399
|
AssocTableName,
|
|
399
400
|
RequiredOnClauseKeysForThisAssociation
|
|
400
|
-
> = JoinAndStatements<DB, Schema, AssocTableName, RequiredOnClauseKeysForThisAssociation>,
|
|
401
|
+
> = JoinAndStatements<DreamInstance, DB, Schema, AssocTableName, RequiredOnClauseKeysForThisAssociation>,
|
|
401
402
|
> = Statements
|
|
402
403
|
|
|
403
404
|
export type JoinAndStatements<
|
|
405
|
+
I extends Dream,
|
|
404
406
|
DB,
|
|
405
407
|
Schema,
|
|
406
408
|
TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB,
|
|
407
409
|
RequiredOnClauseKeysForThisAssociation,
|
|
408
410
|
> = RequiredOnClauseKeysForThisAssociation extends null
|
|
409
411
|
? {
|
|
410
|
-
and?:
|
|
411
|
-
andNot?:
|
|
412
|
+
and?: InternalWhereStatement<I, DB, Schema, TableName>
|
|
413
|
+
andNot?: InternalWhereStatement<I, DB, Schema, TableName>
|
|
412
414
|
// andNot?: WhereStatementWithoutSimilarityClauses<DB, Schema, TableName>
|
|
413
|
-
andAny?:
|
|
415
|
+
andAny?: InternalWhereStatement<I, DB, Schema, TableName>[]
|
|
414
416
|
// andAny?: WhereStatementWithoutSimilarityClauses<DB, Schema, TableName>[]
|
|
415
417
|
}
|
|
416
418
|
: RequiredOnClauseKeysForThisAssociation extends string[]
|
|
417
419
|
? {
|
|
418
|
-
and: OnStatementForAssociation<DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>
|
|
419
|
-
andNot?:
|
|
420
|
+
and: OnStatementForAssociation<I, DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>
|
|
421
|
+
andNot?: InternalWhereStatement<I, DB, Schema, TableName>
|
|
420
422
|
// andNot?: WhereStatementWithoutSimilarityClauses<DB, Schema, TableName>
|
|
421
|
-
andAny?:
|
|
423
|
+
andAny?: InternalWhereStatement<I, DB, Schema, TableName>[]
|
|
422
424
|
// andAny?: WhereStatementWithoutSimilarityClauses<DB, Schema, TableName>[]
|
|
423
425
|
}
|
|
424
426
|
: never
|
|
@@ -515,6 +517,30 @@ export type ViewModel = {
|
|
|
515
517
|
}
|
|
516
518
|
export type ViewModelClass = abstract new (...args: any) => ViewModel
|
|
517
519
|
|
|
520
|
+
/**
|
|
521
|
+
* given a Dream model and an association name, this
|
|
522
|
+
* type will return the actual type set for that association,
|
|
523
|
+
* excluding null or arrays.
|
|
524
|
+
*
|
|
525
|
+
* ```ts
|
|
526
|
+
* DreamAssociationNameToAssociatedModel<User, 'compositions'>
|
|
527
|
+
* // Composition
|
|
528
|
+
*
|
|
529
|
+
* DreamAssociationNameToAssociatedModel<User, 'featuredPost'>
|
|
530
|
+
* // Post
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
export type DreamAssociationNameToAssociatedModel<
|
|
534
|
+
I extends Dream,
|
|
535
|
+
AssociationName extends keyof I,
|
|
536
|
+
> = I[AssociationName] extends (infer U extends Dream)[]
|
|
537
|
+
? U
|
|
538
|
+
: I[AssociationName] extends Dream
|
|
539
|
+
? I[AssociationName]
|
|
540
|
+
: I[AssociationName] extends Dream | null
|
|
541
|
+
? Required<I[AssociationName]> & Dream
|
|
542
|
+
: I
|
|
543
|
+
|
|
518
544
|
// preload
|
|
519
545
|
export type DreamModelAssociationNames<
|
|
520
546
|
Schema,
|
|
@@ -555,22 +581,22 @@ export type RelaxedJoinStatement<Depth extends number = 0> = Depth extends 7
|
|
|
555
581
|
? object
|
|
556
582
|
: Record<string, RelaxedJoinStatement<Inc<Depth>>>
|
|
557
583
|
|
|
558
|
-
export type RelaxedPreloadOnStatement<DB, Schema, Depth extends number = 0> = Depth extends 7
|
|
584
|
+
export type RelaxedPreloadOnStatement<I extends Dream, DB, Schema, Depth extends number = 0> = Depth extends 7
|
|
559
585
|
? object
|
|
560
586
|
: {
|
|
561
587
|
[key: string]:
|
|
562
|
-
| RelaxedPreloadOnStatement<DB, Schema, Inc<Depth>>
|
|
563
|
-
| JoinAndStatements<any, any, any, any>
|
|
588
|
+
| RelaxedPreloadOnStatement<I, DB, Schema, Inc<Depth>>
|
|
589
|
+
| JoinAndStatements<I, any, any, any, any>
|
|
564
590
|
| FakeOnClauseValue
|
|
565
591
|
| object
|
|
566
592
|
}
|
|
567
593
|
|
|
568
|
-
export type RelaxedJoinAndStatement<DB, Schema, Depth extends number = 0> = Depth extends 7
|
|
594
|
+
export type RelaxedJoinAndStatement<I extends Dream, DB, Schema, Depth extends number = 0> = Depth extends 7
|
|
569
595
|
? object
|
|
570
596
|
: {
|
|
571
597
|
[key: string]:
|
|
572
|
-
| RelaxedJoinAndStatement<DB, Schema, Inc<Depth>>
|
|
573
|
-
| JoinAndStatements<any, any, any, any>
|
|
598
|
+
| RelaxedJoinAndStatement<I, DB, Schema, Inc<Depth>>
|
|
599
|
+
| JoinAndStatements<I, any, any, any, any>
|
|
574
600
|
| FakeOnClauseValue
|
|
575
601
|
| object
|
|
576
602
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import Dream from '../Dream.js';
|
|
1
2
|
import { Camelized } from '../helpers/stringCasing.js';
|
|
2
3
|
import { AssociationTableNames } from './db.js';
|
|
3
|
-
import { AssociationNamesForTable, AssociationTableName, JoinAndStatements, MAX_VARIADIC_DEPTH, RequiredOnClauseKeys } from './dream.js';
|
|
4
|
+
import { AssociationNamesForTable, AssociationTableName, DreamAssociationNameToAssociatedModel, JoinAndStatements, MAX_VARIADIC_DEPTH, RequiredOnClauseKeys } from './dream.js';
|
|
4
5
|
import { Inc, ReadonlyTail } from './utils.js';
|
|
5
6
|
type VALID = 'valid';
|
|
6
7
|
type INVALID = 'invalid';
|
|
@@ -8,15 +9,15 @@ type IS_ASSOCIATION_ALIAS = 'association_alias';
|
|
|
8
9
|
type IS_ASSOCIATION_NAME = 'association_name';
|
|
9
10
|
type IS_NOT_ASSOCIATION_NAME = 'not_association_name';
|
|
10
11
|
type RecursionTypes = 'load' | 'leftJoinLoad' | 'join';
|
|
11
|
-
export type VariadicLoadArgs<DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], AllowedNextArgValues = (keyof SchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName>> = VariadicCheckThenRecurse<DB, Schema, ConcreteTableName, ConcreteArgs, 'load', ConcreteTableName, 0, null, never, AllowedNextArgValues | Readonly<AllowedNextArgValues[]>>;
|
|
12
|
-
export type VariadicLeftJoinLoadArgs<DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], AllowedNextArgValues = (keyof SchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName>> = VariadicCheckThenRecurse<DB, Schema, ConcreteTableName, ConcreteArgs, 'leftJoinLoad', Camelized<ConcreteTableName>, 0, null, never, AllowedNextArgValues | Readonly<AllowedNextArgValues[]>>;
|
|
13
|
-
export type VariadicJoinsArgs<DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], AllowedNextArgValues = (keyof SchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName>> = VariadicCheckThenRecurse<DB, Schema, ConcreteTableName, ConcreteArgs, 'join', Camelized<ConcreteTableName>, 0, null, never, AllowedNextArgValues>;
|
|
14
|
-
type VariadicCheckThenRecurse<DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], RecursionType extends RecursionTypes, UsedNamespaces, Depth extends number, PreviousConcreteTableName, ConcreteAssociationName, AssociationNamesOrOnClause, SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], NthArgument extends VALID | INVALID = ConcreteArgs['length'] extends 0 ? VALID : ConcreteArgs[0] extends keyof SchemaAssociations & string ? VALID : ConcreteArgs[0] extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? VALID : ConcreteArgs[0] extends JoinAndStatements<DB, Schema, ConcreteTableName, RequiredOnClauseKeys<Schema, PreviousConcreteTableName, ConcreteAssociationName>> ? VALID : INVALID> = NthArgument extends INVALID ? `invalid where clause in argument ${Inc<Depth>}` : ConcreteArgs['length'] extends 0 ? AssociationNamesOrOnClause : VariadicRecurse<DB, Schema, ConcreteTableName, ConcreteArgs, RecursionType, UsedNamespaces, Depth, PreviousConcreteTableName, ConcreteAssociationName>;
|
|
12
|
+
export type VariadicLoadArgs<I extends Dream, DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], AllowedNextArgValues = (keyof SchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName>> = VariadicCheckThenRecurse<I, DB, Schema, ConcreteTableName, ConcreteArgs, 'load', ConcreteTableName, 0, null, never, AllowedNextArgValues | Readonly<AllowedNextArgValues[]>>;
|
|
13
|
+
export type VariadicLeftJoinLoadArgs<I extends Dream, DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], AllowedNextArgValues = (keyof SchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName>> = VariadicCheckThenRecurse<I, DB, Schema, ConcreteTableName, ConcreteArgs, 'leftJoinLoad', Camelized<ConcreteTableName>, 0, null, never, AllowedNextArgValues | Readonly<AllowedNextArgValues[]>>;
|
|
14
|
+
export type VariadicJoinsArgs<I extends Dream, DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], AllowedNextArgValues = (keyof SchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName>> = VariadicCheckThenRecurse<I, DB, Schema, ConcreteTableName, ConcreteArgs, 'join', Camelized<ConcreteTableName>, 0, null, never, AllowedNextArgValues>;
|
|
15
|
+
type VariadicCheckThenRecurse<I extends Dream, DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], RecursionType extends RecursionTypes, UsedNamespaces, Depth extends number, PreviousConcreteTableName, ConcreteAssociationName, AssociationNamesOrOnClause, LastDream extends Dream = I, SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], NthArgument extends VALID | INVALID = ConcreteArgs['length'] extends 0 ? VALID : ConcreteArgs[0] extends keyof SchemaAssociations & string ? VALID : ConcreteArgs[0] extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? VALID : ConcreteArgs[0] extends JoinAndStatements<LastDream, DB, Schema, ConcreteTableName, RequiredOnClauseKeys<Schema, PreviousConcreteTableName, ConcreteAssociationName>> ? VALID : INVALID> = NthArgument extends INVALID ? `invalid where clause in argument ${Inc<Depth>}` : ConcreteArgs['length'] extends 0 ? AssociationNamesOrOnClause : VariadicRecurse<I, DB, Schema, ConcreteTableName, ConcreteArgs, RecursionType, UsedNamespaces, Depth, PreviousConcreteTableName, ConcreteAssociationName, LastDream>;
|
|
15
16
|
export type AliasedSchemaAssociation<Schema, ConcreteTableName extends keyof Schema, SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]]> = `${keyof SchemaAssociations & string} as ${string}`;
|
|
16
|
-
type VariadicRecurse<DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], RecursionType extends RecursionTypes, UsedNamespaces, Depth extends number, PreviousConcreteTableName, ConcreteAssociationName, SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], ConcreteNthArg extends (keyof SchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName> | null = ConcreteArgs[0] extends undefined ? null : ConcreteArgs[0] extends null ? null : ConcreteArgs[0] extends keyof SchemaAssociations & string ? ConcreteArgs[0] & keyof SchemaAssociations & string : ConcreteArgs[0] extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? ConcreteArgs[0] & AliasedSchemaAssociation<Schema, ConcreteTableName> : null, NextUsedNamespaces = ConcreteArgs[0] extends undefined ? never : ConcreteArgs[0] extends null ? never : ConcreteArgs[0] extends keyof SchemaAssociations & string ? UsedNamespaces | ConcreteNthArg : UsedNamespaces, CurrentArgumentType extends IS_ASSOCIATION_NAME | IS_ASSOCIATION_ALIAS | IS_NOT_ASSOCIATION_NAME = ConcreteNthArg extends null ? IS_NOT_ASSOCIATION_NAME : ConcreteNthArg extends keyof SchemaAssociations & string ? IS_ASSOCIATION_NAME : ConcreteNthArg extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? IS_ASSOCIATION_ALIAS : IS_NOT_ASSOCIATION_NAME, NextPreviousConcreteTableName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteTableName : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteTableName : PreviousConcreteTableName, NextUnaliasedAssociationName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteNthArg : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteNthArg extends `${infer AssocName extends string} as ${string}` ? AssocName & keyof SchemaAssociations & string : never : never, NextAliasedAssociationName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteNthArg : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteNthArg extends `${string} as ${infer AssocAlias extends string}` ? AssocAlias & string : ConcreteAssociationName : ConcreteAssociationName, NextTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB = CurrentArgumentType extends IS_ASSOCIATION_NAME ? AssociationTableName<Schema, ConcreteTableName, NextUnaliasedAssociationName> : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? AssociationTableName<Schema, ConcreteTableName, NextUnaliasedAssociationName> : ConcreteTableName & AssociationTableNames<DB, Schema> & keyof DB, AllowedNextArgValues = RecursionType extends 'load' ? AllowedNextArgValuesForLoad<DB, Schema, NextTableName, RequiredOnClauseKeys<Schema, ConcreteTableName, NextAliasedAssociationName>> : RecursionType extends 'leftJoinLoad' ? AllowedNextArgValuesForLeftJoinLoad<DB, Schema, NextTableName, RequiredOnClauseKeys<Schema, ConcreteTableName, NextAliasedAssociationName>, NextUsedNamespaces> : RecursionType extends 'join' ? AllowedNextArgValuesForJoin<DB, Schema, NextTableName, RequiredOnClauseKeys<Schema, ConcreteTableName, NextAliasedAssociationName>, NextUsedNamespaces> : never> = Depth extends MAX_VARIADIC_DEPTH ? never : VariadicCheckThenRecurse<DB, Schema, NextTableName, ReadonlyTail<ConcreteArgs>, RecursionType, NextUsedNamespaces, Inc<Depth>, NextPreviousConcreteTableName, NextAliasedAssociationName, AllowedNextArgValues>;
|
|
17
|
-
type AllowedNextArgValuesForLoad<DB, Schema, TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation> = AssociationNamesForTable<Schema, TableName> | AssociationNamesForTable<Schema, TableName>[] | JoinAndStatements<DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>;
|
|
18
|
-
type AllowedNextArgValuesForLeftJoinLoad<DB, Schema, TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation, UsedNamespaces> = Exclude<AssociationNamesForTable<Schema, TableName>, UsedNamespaces> | Exclude<AssociationNamesForTable<Schema, TableName>, UsedNamespaces>[] | JoinAndStatements<DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>;
|
|
19
|
-
type AllowedNextArgValuesForJoin<DB, Schema, TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation, UsedNamespaces> = Exclude<AssociationNamesForTable<Schema, TableName>, UsedNamespaces> | JoinAndStatements<DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>;
|
|
17
|
+
type VariadicRecurse<I extends Dream, DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], RecursionType extends RecursionTypes, UsedNamespaces, Depth extends number, PreviousConcreteTableName, ConcreteAssociationName, LastDream extends Dream, SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], ConcreteNthArg extends (keyof SchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName> | null = ConcreteArgs[0] extends undefined ? null : ConcreteArgs[0] extends null ? null : ConcreteArgs[0] extends keyof SchemaAssociations & string ? ConcreteArgs[0] & keyof SchemaAssociations & string : ConcreteArgs[0] extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? ConcreteArgs[0] & AliasedSchemaAssociation<Schema, ConcreteTableName> : null, NextUsedNamespaces = ConcreteArgs[0] extends undefined ? never : ConcreteArgs[0] extends null ? never : ConcreteArgs[0] extends keyof SchemaAssociations & string ? UsedNamespaces | ConcreteNthArg : UsedNamespaces, CurrentArgumentType extends IS_ASSOCIATION_NAME | IS_ASSOCIATION_ALIAS | IS_NOT_ASSOCIATION_NAME = ConcreteNthArg extends null ? IS_NOT_ASSOCIATION_NAME : ConcreteNthArg extends keyof SchemaAssociations & string ? IS_ASSOCIATION_NAME : ConcreteNthArg extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? IS_ASSOCIATION_ALIAS : IS_NOT_ASSOCIATION_NAME, NextPreviousConcreteTableName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteTableName : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteTableName : PreviousConcreteTableName, NextUnaliasedAssociationName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteNthArg : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteNthArg extends `${infer AssocName extends string} as ${string}` ? AssocName & keyof SchemaAssociations & string : never : never, NextAliasedAssociationName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteNthArg : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteNthArg extends `${string} as ${infer AssocAlias extends string}` ? AssocAlias & string : ConcreteAssociationName : ConcreteAssociationName, NextTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB = CurrentArgumentType extends IS_ASSOCIATION_NAME ? AssociationTableName<Schema, ConcreteTableName, NextUnaliasedAssociationName> : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? AssociationTableName<Schema, ConcreteTableName, NextUnaliasedAssociationName> : ConcreteTableName & AssociationTableNames<DB, Schema> & keyof DB, AllowedNextArgValues = RecursionType extends 'load' ? AllowedNextArgValuesForLoad<DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>, DB, Schema, NextTableName, RequiredOnClauseKeys<Schema, ConcreteTableName, NextAliasedAssociationName>> : RecursionType extends 'leftJoinLoad' ? AllowedNextArgValuesForLeftJoinLoad<DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>, DB, Schema, NextTableName, RequiredOnClauseKeys<Schema, ConcreteTableName, NextAliasedAssociationName>, NextUsedNamespaces> : RecursionType extends 'join' ? AllowedNextArgValuesForJoin<DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>, DB, Schema, NextTableName, RequiredOnClauseKeys<Schema, ConcreteTableName, NextAliasedAssociationName>, NextUsedNamespaces> : never> = Depth extends MAX_VARIADIC_DEPTH ? never : VariadicCheckThenRecurse<I, DB, Schema, NextTableName, ReadonlyTail<ConcreteArgs>, RecursionType, NextUsedNamespaces, Inc<Depth>, NextPreviousConcreteTableName, NextAliasedAssociationName, AllowedNextArgValues, DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream> extends Dream ? DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream> : LastDream>;
|
|
18
|
+
type AllowedNextArgValuesForLoad<I extends Dream, DB, Schema, TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation> = AssociationNamesForTable<Schema, TableName> | AssociationNamesForTable<Schema, TableName>[] | JoinAndStatements<I, DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>;
|
|
19
|
+
type AllowedNextArgValuesForLeftJoinLoad<I extends Dream, DB, Schema, TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation, UsedNamespaces> = Exclude<AssociationNamesForTable<Schema, TableName>, UsedNamespaces> | Exclude<AssociationNamesForTable<Schema, TableName>, UsedNamespaces>[] | JoinAndStatements<I, DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>;
|
|
20
|
+
type AllowedNextArgValuesForJoin<I extends Dream, DB, Schema, TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation, UsedNamespaces> = Exclude<AssociationNamesForTable<Schema, TableName>, UsedNamespaces> | JoinAndStatements<I, DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>;
|
|
20
21
|
export interface JoinedAssociation {
|
|
21
22
|
table: string;
|
|
22
23
|
alias: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import Dream from '../Dream.js'
|
|
1
2
|
import { Camelized } from '../helpers/stringCasing.js'
|
|
2
3
|
import { AssociationTableNames } from './db.js'
|
|
3
4
|
import {
|
|
4
5
|
AssociationNamesForTable,
|
|
5
6
|
AssociationTableName,
|
|
7
|
+
DreamAssociationNameToAssociatedModel,
|
|
6
8
|
JoinAndStatements,
|
|
7
9
|
MAX_VARIADIC_DEPTH,
|
|
8
10
|
RequiredOnClauseKeys,
|
|
@@ -20,6 +22,7 @@ type RecursionTypes = 'load' | 'leftJoinLoad' | 'join'
|
|
|
20
22
|
///////////////////////////////
|
|
21
23
|
|
|
22
24
|
export type VariadicLoadArgs<
|
|
25
|
+
I extends Dream,
|
|
23
26
|
DB,
|
|
24
27
|
Schema,
|
|
25
28
|
ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB,
|
|
@@ -30,6 +33,7 @@ export type VariadicLoadArgs<
|
|
|
30
33
|
| (keyof SchemaAssociations & string)
|
|
31
34
|
| AliasedSchemaAssociation<Schema, ConcreteTableName>,
|
|
32
35
|
> = VariadicCheckThenRecurse<
|
|
36
|
+
I,
|
|
33
37
|
DB,
|
|
34
38
|
Schema,
|
|
35
39
|
ConcreteTableName,
|
|
@@ -48,6 +52,7 @@ export type VariadicLoadArgs<
|
|
|
48
52
|
// VARIADIC LEFT JOIN LOAD
|
|
49
53
|
///////////////////////////////
|
|
50
54
|
export type VariadicLeftJoinLoadArgs<
|
|
55
|
+
I extends Dream,
|
|
51
56
|
DB,
|
|
52
57
|
Schema,
|
|
53
58
|
ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB,
|
|
@@ -58,6 +63,7 @@ export type VariadicLeftJoinLoadArgs<
|
|
|
58
63
|
| (keyof SchemaAssociations & string)
|
|
59
64
|
| AliasedSchemaAssociation<Schema, ConcreteTableName>,
|
|
60
65
|
> = VariadicCheckThenRecurse<
|
|
66
|
+
I,
|
|
61
67
|
DB,
|
|
62
68
|
Schema,
|
|
63
69
|
ConcreteTableName,
|
|
@@ -81,6 +87,7 @@ export type VariadicLeftJoinLoadArgs<
|
|
|
81
87
|
// VARIADIC JOINS
|
|
82
88
|
///////////////////////////////
|
|
83
89
|
export type VariadicJoinsArgs<
|
|
90
|
+
I extends Dream,
|
|
84
91
|
DB,
|
|
85
92
|
Schema,
|
|
86
93
|
ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB,
|
|
@@ -91,6 +98,7 @@ export type VariadicJoinsArgs<
|
|
|
91
98
|
| (keyof SchemaAssociations & string)
|
|
92
99
|
| AliasedSchemaAssociation<Schema, ConcreteTableName>,
|
|
93
100
|
> = VariadicCheckThenRecurse<
|
|
101
|
+
I,
|
|
94
102
|
DB,
|
|
95
103
|
Schema,
|
|
96
104
|
ConcreteTableName,
|
|
@@ -113,6 +121,7 @@ export type VariadicJoinsArgs<
|
|
|
113
121
|
///////////////////////////////
|
|
114
122
|
|
|
115
123
|
type VariadicCheckThenRecurse<
|
|
124
|
+
I extends Dream,
|
|
116
125
|
DB,
|
|
117
126
|
Schema,
|
|
118
127
|
ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB,
|
|
@@ -125,6 +134,7 @@ type VariadicCheckThenRecurse<
|
|
|
125
134
|
ConcreteAssociationName,
|
|
126
135
|
//
|
|
127
136
|
AssociationNamesOrOnClause,
|
|
137
|
+
LastDream extends Dream = I,
|
|
128
138
|
//
|
|
129
139
|
SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]],
|
|
130
140
|
NthArgument extends VALID | INVALID = ConcreteArgs['length'] extends 0
|
|
@@ -134,6 +144,7 @@ type VariadicCheckThenRecurse<
|
|
|
134
144
|
: ConcreteArgs[0] extends AliasedSchemaAssociation<Schema, ConcreteTableName>
|
|
135
145
|
? VALID
|
|
136
146
|
: ConcreteArgs[0] extends JoinAndStatements<
|
|
147
|
+
LastDream,
|
|
137
148
|
DB,
|
|
138
149
|
Schema,
|
|
139
150
|
ConcreteTableName,
|
|
@@ -146,6 +157,7 @@ type VariadicCheckThenRecurse<
|
|
|
146
157
|
: ConcreteArgs['length'] extends 0
|
|
147
158
|
? AssociationNamesOrOnClause
|
|
148
159
|
: VariadicRecurse<
|
|
160
|
+
I,
|
|
149
161
|
DB,
|
|
150
162
|
Schema,
|
|
151
163
|
ConcreteTableName,
|
|
@@ -154,7 +166,8 @@ type VariadicCheckThenRecurse<
|
|
|
154
166
|
UsedNamespaces,
|
|
155
167
|
Depth,
|
|
156
168
|
PreviousConcreteTableName,
|
|
157
|
-
ConcreteAssociationName
|
|
169
|
+
ConcreteAssociationName,
|
|
170
|
+
LastDream
|
|
158
171
|
>
|
|
159
172
|
|
|
160
173
|
export type AliasedSchemaAssociation<
|
|
@@ -164,6 +177,7 @@ export type AliasedSchemaAssociation<
|
|
|
164
177
|
> = `${keyof SchemaAssociations & string} as ${string}`
|
|
165
178
|
|
|
166
179
|
type VariadicRecurse<
|
|
180
|
+
I extends Dream,
|
|
167
181
|
DB,
|
|
168
182
|
Schema,
|
|
169
183
|
ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB,
|
|
@@ -174,6 +188,7 @@ type VariadicRecurse<
|
|
|
174
188
|
//
|
|
175
189
|
PreviousConcreteTableName,
|
|
176
190
|
ConcreteAssociationName,
|
|
191
|
+
LastDream extends Dream,
|
|
177
192
|
//
|
|
178
193
|
SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]],
|
|
179
194
|
ConcreteNthArg extends
|
|
@@ -239,6 +254,7 @@ type VariadicRecurse<
|
|
|
239
254
|
//
|
|
240
255
|
AllowedNextArgValues = RecursionType extends 'load'
|
|
241
256
|
? AllowedNextArgValuesForLoad<
|
|
257
|
+
DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>,
|
|
242
258
|
DB,
|
|
243
259
|
Schema,
|
|
244
260
|
NextTableName,
|
|
@@ -246,6 +262,7 @@ type VariadicRecurse<
|
|
|
246
262
|
>
|
|
247
263
|
: RecursionType extends 'leftJoinLoad'
|
|
248
264
|
? AllowedNextArgValuesForLeftJoinLoad<
|
|
265
|
+
DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>,
|
|
249
266
|
DB,
|
|
250
267
|
Schema,
|
|
251
268
|
NextTableName,
|
|
@@ -254,6 +271,7 @@ type VariadicRecurse<
|
|
|
254
271
|
>
|
|
255
272
|
: RecursionType extends 'join'
|
|
256
273
|
? AllowedNextArgValuesForJoin<
|
|
274
|
+
DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>,
|
|
257
275
|
DB,
|
|
258
276
|
Schema,
|
|
259
277
|
NextTableName,
|
|
@@ -264,6 +282,7 @@ type VariadicRecurse<
|
|
|
264
282
|
> = Depth extends MAX_VARIADIC_DEPTH
|
|
265
283
|
? never
|
|
266
284
|
: VariadicCheckThenRecurse<
|
|
285
|
+
I,
|
|
267
286
|
DB,
|
|
268
287
|
Schema,
|
|
269
288
|
NextTableName,
|
|
@@ -273,10 +292,14 @@ type VariadicRecurse<
|
|
|
273
292
|
Inc<Depth>,
|
|
274
293
|
NextPreviousConcreteTableName,
|
|
275
294
|
NextAliasedAssociationName,
|
|
276
|
-
AllowedNextArgValues
|
|
295
|
+
AllowedNextArgValues,
|
|
296
|
+
DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream> extends Dream
|
|
297
|
+
? DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>
|
|
298
|
+
: LastDream
|
|
277
299
|
>
|
|
278
300
|
|
|
279
301
|
type AllowedNextArgValuesForLoad<
|
|
302
|
+
I extends Dream,
|
|
280
303
|
DB,
|
|
281
304
|
Schema,
|
|
282
305
|
TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB,
|
|
@@ -284,9 +307,10 @@ type AllowedNextArgValuesForLoad<
|
|
|
284
307
|
> =
|
|
285
308
|
| AssociationNamesForTable<Schema, TableName>
|
|
286
309
|
| AssociationNamesForTable<Schema, TableName>[]
|
|
287
|
-
| JoinAndStatements<DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>
|
|
310
|
+
| JoinAndStatements<I, DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>
|
|
288
311
|
|
|
289
312
|
type AllowedNextArgValuesForLeftJoinLoad<
|
|
313
|
+
I extends Dream,
|
|
290
314
|
DB,
|
|
291
315
|
Schema,
|
|
292
316
|
TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB,
|
|
@@ -295,9 +319,10 @@ type AllowedNextArgValuesForLeftJoinLoad<
|
|
|
295
319
|
> =
|
|
296
320
|
| Exclude<AssociationNamesForTable<Schema, TableName>, UsedNamespaces>
|
|
297
321
|
| Exclude<AssociationNamesForTable<Schema, TableName>, UsedNamespaces>[]
|
|
298
|
-
| JoinAndStatements<DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>
|
|
322
|
+
| JoinAndStatements<I, DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>
|
|
299
323
|
|
|
300
324
|
type AllowedNextArgValuesForJoin<
|
|
325
|
+
I extends Dream,
|
|
301
326
|
DB,
|
|
302
327
|
Schema,
|
|
303
328
|
TableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB,
|
|
@@ -305,7 +330,7 @@ type AllowedNextArgValuesForJoin<
|
|
|
305
330
|
UsedNamespaces,
|
|
306
331
|
> =
|
|
307
332
|
| Exclude<AssociationNamesForTable<Schema, TableName>, UsedNamespaces>
|
|
308
|
-
| JoinAndStatements<DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>
|
|
333
|
+
| JoinAndStatements<I, DB, Schema, TableName, RequiredOnClauseKeysForThisAssociation>
|
|
309
334
|
|
|
310
335
|
export interface JoinedAssociation {
|
|
311
336
|
table: string
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { ClockTimeDiffResult, ClockTimeDurationLikeObject, ClockTimeDurationUnit, ClockTimeUnit, type ClockTimeObject } from '../../types/clocktime.js';
|
|
2
|
+
import { type LocaleOptions } from '../../types/datetime.js';
|
|
3
|
+
import { DateTime } from './DateTime.js';
|
|
4
|
+
export default class BaseClockTime {
|
|
5
|
+
protected dateTime: DateTime;
|
|
6
|
+
protected _toSQL?: string;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
constructor(source?: DateTime | null);
|
|
11
|
+
/**
|
|
12
|
+
* Create a ClockTimeTz from a DateTime instance.
|
|
13
|
+
* @param dateTime - A DateTime instance
|
|
14
|
+
* @returns A ClockTimeTz for the time portion of the DateTime
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* ClockTime/ClockTimeTz.fromDateTime(DateTime.now())
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
static fromDateTime<T extends typeof BaseClockTime>(this: T, dateTime: DateTime): InstanceType<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns true if this ClockTime equals another ClockTime.
|
|
23
|
+
* @param otherClockTime - ClockTime to compare
|
|
24
|
+
* @returns true if times are equal
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const t1 = ClockTime.fromObject({ hour: 14, minute: 30 })
|
|
28
|
+
* const t2 = ClockTime.fromObject({ hour: 14, minute: 30 })
|
|
29
|
+
* t1.equals(t2) // true
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
equals<T extends BaseClockTime>(this: T, otherClockTime: T): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Returns a new ClockTime with the given time units set.
|
|
35
|
+
* @param values - Object with time units to set (hour, minute, second, millisecond, microsecond)
|
|
36
|
+
* @returns A new ClockTime
|
|
37
|
+
* @throws {InvalidClockTime} When the underlying DateTime operation fails
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* ClockTime.fromObject({ hour: 10, minute: 30 }).set({ hour: 14, microsecond: 500 })
|
|
41
|
+
* // hour: 14, minute: 30, microsecond: 500
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
set<T extends BaseClockTime>(this: T, values: Partial<ClockTimeObject>): T;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a new ClockTime at the start of the given period.
|
|
47
|
+
* @param period - Unit to truncate to ('hour', 'minute', or 'second')
|
|
48
|
+
* @returns A ClockTime at the start of the period
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* ClockTime.fromObject({ hour: 14, minute: 30, second: 45 }).startOf('hour')
|
|
52
|
+
* // hour: 14, minute: 0, second: 0
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
startOf<T extends BaseClockTime>(this: T, period: ClockTimeUnit): T;
|
|
56
|
+
/**
|
|
57
|
+
* Returns a new ClockTime at the end of the given period.
|
|
58
|
+
* @param period - Unit to extend to end of ('hour', 'minute', or 'second')
|
|
59
|
+
* @returns A ClockTime at the end of the period
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* ClockTime.fromObject({ hour: 14, minute: 30 }).endOf('hour')
|
|
63
|
+
* // hour: 14, minute: 59, second: 59, millisecond: 999
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
endOf<T extends BaseClockTime>(this: T, period: ClockTimeUnit): T;
|
|
67
|
+
/**
|
|
68
|
+
* Returns the time as an ISO time string (for valueOf() operations).
|
|
69
|
+
* @returns ISO time string
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* ClockTime/ClockTimeTz.now().valueOf()
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
private _valueOf;
|
|
76
|
+
valueOf(): string;
|
|
77
|
+
toISO(opts?: {
|
|
78
|
+
suppressMilliseconds?: boolean;
|
|
79
|
+
suppressSeconds?: boolean;
|
|
80
|
+
format?: 'basic' | 'extended';
|
|
81
|
+
}): string;
|
|
82
|
+
toSQL(): string;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the time as an ISO 8601 time string with timezone offset.
|
|
85
|
+
* Alias for `toISO()`.
|
|
86
|
+
*
|
|
87
|
+
* @param opts - Optional format options
|
|
88
|
+
* @param opts.suppressMilliseconds - If true, omits milliseconds/microseconds when they are zero
|
|
89
|
+
* @param opts.suppressSeconds - If true, omits seconds when they are zero
|
|
90
|
+
* @param opts.format - Format variant: 'basic' (compact) or 'extended' (default, with colons)
|
|
91
|
+
* @returns ISO time string with timezone offset (e.g., '14:30:45.123456-05:00')
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* ClockTime/ClockTimeTz.fromObject({ hour: 14, minute: 30, second: 45 }).toISOTime() // '14:30:45.000000+00:00'
|
|
95
|
+
* ClockTime/ClockTimeTz.fromISO('14:30:45-05:00').toISOTime() // '14:30:45.000000-05:00'
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
toISOTime(opts?: {
|
|
99
|
+
suppressMilliseconds?: boolean;
|
|
100
|
+
suppressSeconds?: boolean;
|
|
101
|
+
format?: 'basic' | 'extended';
|
|
102
|
+
}): string;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the time as an ISO time string for JSON serialization.
|
|
105
|
+
* @returns ISO time string
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* JSON.stringify({ time: ClockTime.now() })
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
toJSON(): string;
|
|
112
|
+
/**
|
|
113
|
+
* Alias of `toSQL`.
|
|
114
|
+
* Returns the SQL time string without timezone offset.
|
|
115
|
+
* Result is memoized for performance.
|
|
116
|
+
*
|
|
117
|
+
* @returns SQL time string without timezone offset (e.g., '14:30:45.123456')
|
|
118
|
+
*/
|
|
119
|
+
toSQLTime(): string;
|
|
120
|
+
/**
|
|
121
|
+
* Returns a localized string representation of the time.
|
|
122
|
+
* @param formatOpts - Intl.DateTimeFormat options for formatting
|
|
123
|
+
* @param opts - Optional locale configuration
|
|
124
|
+
* @param opts.locale - Locale string (e.g., 'en-US', 'fr-FR')
|
|
125
|
+
* @param opts.numberingSystem - Numbering system (e.g., 'arab', 'beng')
|
|
126
|
+
* @param opts.outputCalendar - Calendar system (e.g., 'islamic', 'hebrew')
|
|
127
|
+
* @returns Localized time string
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* ClockTime/ClockTimeTz.now().toLocaleString()
|
|
131
|
+
* ClockTime/ClockTimeTz.now().toLocaleString({ hour: 'numeric', minute: '2-digit' })
|
|
132
|
+
* ClockTime/ClockTimeTz.now().toLocaleString({ hour: '2-digit' }, { locale: 'fr-FR' })
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
toLocaleString(formatOpts?: Intl.DateTimeFormatOptions, opts?: LocaleOptions): string;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the time as an ISO string (same as toISO).
|
|
138
|
+
* @returns ISO datetime string
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* ClockTime.now().toString()
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
toString(): string;
|
|
145
|
+
/**
|
|
146
|
+
* Returns the underlying DateTime instance.
|
|
147
|
+
* @returns A DateTime representing this time with zone
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* const dt = ClockTime/ClockTimeTz.now().toDateTime()
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
toDateTime(): DateTime;
|
|
154
|
+
/**
|
|
155
|
+
* Gets the hour (0-23).
|
|
156
|
+
* @returns The hour number
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* ClockTime/ClockTimeTz.fromObject({ hour: 14, minute: 30 }).hour // 14
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
get hour(): number;
|
|
163
|
+
/**
|
|
164
|
+
* Gets the minute (0-59).
|
|
165
|
+
* @returns The minute number
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* ClockTime/ClockTimeTz.fromObject({ hour: 14, minute: 30 }).minute // 30
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
get minute(): number;
|
|
172
|
+
/**
|
|
173
|
+
* Gets the second (0-59).
|
|
174
|
+
* @returns The second number
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* ClockTime/ClockTimeTz.fromObject({ hour: 14, minute: 30, second: 45 }).second // 45
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
get second(): number;
|
|
181
|
+
/**
|
|
182
|
+
* Gets the millisecond (0-999).
|
|
183
|
+
* @returns The millisecond number
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* ClockTime/ClockTimeTz.fromObject({ hour: 14, minute: 30, millisecond: 123 }).millisecond // 123
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
get millisecond(): number;
|
|
190
|
+
/**
|
|
191
|
+
* Gets the microsecond (0-999).
|
|
192
|
+
* @returns The microsecond number
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* ClockTime/ClockTimeTz.fromISO('14:30:45.123456').microsecond // 456
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
get microsecond(): number;
|
|
199
|
+
/**
|
|
200
|
+
* Returns the earliest ClockTime/ClockTimeTz from the given arguments.
|
|
201
|
+
* @param clockTimes - ClockTime/ClockTimeTz instances to compare
|
|
202
|
+
* @returns The earliest ClockTime/ClockTimeTz
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* ClockTime/ClockTimeTz.min(time1, time2, time3)
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
static min<T extends typeof BaseClockTime>(this: T, ...clockTimes: InstanceType<T>[]): InstanceType<T> | null;
|
|
209
|
+
/**
|
|
210
|
+
* Returns the latest ClockTime/ClockTimeTz from the given arguments.
|
|
211
|
+
* @param clockTimes - ClockTime/ClockTimeTz instances to compare
|
|
212
|
+
* @returns The latest ClockTime/ClockTimeTz
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* ClockTime/ClockTimeTz.max(time1, time2, time3)
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
static max<T extends typeof BaseClockTime>(this: T, ...clockTimes: InstanceType<T>[]): InstanceType<T> | null;
|
|
219
|
+
/**
|
|
220
|
+
* Returns a new ClockTime/ClockTimeTz with the given duration added.
|
|
221
|
+
* @param duration - Duration to add (object with hours, minutes, seconds, etc.)
|
|
222
|
+
* @returns A new ClockTime/ClockTimeTz
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* ClockTime/ClockTimeTz.fromObject({ hour: 14, minute: 30 }).plus({ hours: 2, minutes: 15 })
|
|
226
|
+
* // hour: 16, minute: 45
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
plus<T extends BaseClockTime>(this: T, duration: ClockTimeDurationLikeObject): T;
|
|
230
|
+
/**
|
|
231
|
+
* Returns a new ClockTime/ClockTimeTz with the given duration subtracted.
|
|
232
|
+
* @param duration - Duration to subtract (object with hours, minutes, seconds, etc.)
|
|
233
|
+
* @returns A new ClockTime/ClockTimeTz
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* ClockTime/ClockTimeTz.fromObject({ hour: 14, minute: 30 }).minus({ hours: 2, minutes: 15 })
|
|
237
|
+
* // hour: 12, minute: 15
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
minus<T extends BaseClockTime>(this: T, duration: ClockTimeDurationLikeObject): T;
|
|
241
|
+
/**
|
|
242
|
+
* Returns true if this and other are in the same unit of time.
|
|
243
|
+
* @param otherClockTime - ClockTime to compare against
|
|
244
|
+
* @param period - Unit to check ('hour', 'minute', or 'second')
|
|
245
|
+
* @returns true if same period
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* const t1 = ClockTime.fromObject({ hour: 14, minute: 30 })
|
|
249
|
+
* const t2 = ClockTime.fromObject({ hour: 14, minute: 45 })
|
|
250
|
+
* t1.hasSame(t2, 'hour') // true
|
|
251
|
+
* t1.hasSame(t2, 'minute') // false
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
hasSame<T extends BaseClockTime>(this: T, otherClockTime: T, period: ClockTimeUnit): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Returns the difference between this ClockTime and another in the specified unit.
|
|
257
|
+
* @param otherClockTime - ClockTime to compare against
|
|
258
|
+
* @param duration - Unit for the difference ('hours', 'minutes', 'seconds', etc.)
|
|
259
|
+
* @returns Numeric difference in the specified unit
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const t1 = ClockTime.fromObject({ hour: 14, minute: 30 })
|
|
263
|
+
* const t2 = ClockTime.fromObject({ hour: 10, minute: 15 })
|
|
264
|
+
* t1.diff(t2, 'hours') // 4.25
|
|
265
|
+
* t1.diff(t2, 'minutes') // 255
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
/**
|
|
269
|
+
* Returns the difference between this ClockTime and another in the specified unit(s).
|
|
270
|
+
* Supports microsecond precision when 'microseconds' is included in the unit parameter.
|
|
271
|
+
*
|
|
272
|
+
* @param other - ClockTime to compare against
|
|
273
|
+
* @param unit - Unit or units to return (hours, minutes, seconds, milliseconds, microseconds)
|
|
274
|
+
* @returns Object with only the specified units (or all units if not specified)
|
|
275
|
+
* @example
|
|
276
|
+
* ```ts
|
|
277
|
+
* const t1 = ClockTime.fromObject({ hour: 15, minute: 30 })
|
|
278
|
+
* const t2 = ClockTime.fromObject({ hour: 14, minute: 0 })
|
|
279
|
+
* t1.diff(t2, 'hours') // { hours: 1 }
|
|
280
|
+
* t1.diff(t2, ['hours', 'minutes']) // { hours: 1, minutes: 30 }
|
|
281
|
+
* t1.diff(t2) // { hours: 1, minutes: 30, seconds: 0, milliseconds: 0, microseconds: 0 }
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
diff<T extends BaseClockTime, U extends ClockTimeDurationUnit | ClockTimeDurationUnit[] | undefined = undefined>(this: T, other: T, unit?: U): ClockTimeDiffResult<U>;
|
|
285
|
+
protected static wrapLuxonError<T>(fn: () => T): T;
|
|
286
|
+
protected wrapLuxonError<T>(fn: () => T): T;
|
|
287
|
+
}
|