@rvoh/dream 2.3.0-alpha.7 → 2.3.0-alpha.9
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-app/index.js +9 -7
- package/dist/cjs/src/helpers/db/normalizeDataForDb.js +4 -4
- package/dist/cjs/src/utils/datetime/DateTime.js +11 -13
- package/dist/esm/src/dream-app/index.js +9 -7
- package/dist/esm/src/helpers/db/normalizeDataForDb.js +4 -4
- package/dist/esm/src/utils/datetime/DateTime.js +11 -13
- package/dist/types/src/dream-app/index.d.ts +1 -1
- package/dist/types/src/utils/datetime/DateTime.d.ts +8 -7
- package/docs/classes/db.DreamMigrationHelpers.html +9 -9
- package/docs/classes/db.KyselyQueryDriver.html +32 -32
- package/docs/classes/db.PostgresQueryDriver.html +33 -33
- package/docs/classes/db.QueryDriverBase.html +31 -31
- package/docs/classes/errors.CheckConstraintViolation.html +3 -3
- package/docs/classes/errors.ColumnOverflow.html +3 -3
- package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
- package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
- package/docs/classes/errors.GlobalNameNotSet.html +3 -3
- package/docs/classes/errors.InvalidCalendarDate.html +2 -2
- package/docs/classes/errors.InvalidClockTime.html +2 -2
- package/docs/classes/errors.InvalidClockTimeTz.html +2 -2
- 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 +3 -3
- package/docs/classes/errors.RecordNotFound.html +3 -3
- package/docs/classes/errors.ValidationError.html +3 -3
- package/docs/classes/index.CalendarDate.html +33 -33
- package/docs/classes/index.ClockTime.html +32 -32
- package/docs/classes/index.ClockTimeTz.html +35 -35
- package/docs/classes/index.DateTime.html +78 -77
- package/docs/classes/index.Decorators.html +19 -19
- package/docs/classes/index.Dream.html +116 -116
- 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 +56 -56
- 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 +2 -2
- 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 +1 -1
- package/docs/modules/index.html +1 -1
- package/docs/modules/openapi.html +1 -1
- package/docs/modules/system.html +1 -1
- package/docs/modules/types.html +1 -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 +1 -1
- package/docs/types/types.Camelized.html +1 -1
- package/docs/types/types.ClockTimeObject.html +1 -1
- 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 +1 -1
- 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 +1 -1
|
@@ -16,6 +16,7 @@ import expandStiClasses from '../helpers/sti/expandStiClasses.js';
|
|
|
16
16
|
import inferSerializerFromDreamOrViewModel, { inferSerializersFromDreamClassOrViewModelClass, } from '../serializer/helpers/inferSerializerFromDreamOrViewModel.js';
|
|
17
17
|
import isDreamSerializer from '../serializer/helpers/isDreamSerializer.js';
|
|
18
18
|
import serializerNameFromFullyQualifiedModelName from '../serializer/helpers/serializerNameFromFullyQualifiedModelName.js';
|
|
19
|
+
import BaseClockTime from '../utils/datetime/BaseClockTime.js';
|
|
19
20
|
import CalendarDate from '../utils/datetime/CalendarDate.js';
|
|
20
21
|
import { DateTime, Settings } from '../utils/datetime/DateTime.js';
|
|
21
22
|
import { cacheDreamApp, getCachedDreamAppOrFail } from './cache.js';
|
|
@@ -164,13 +165,13 @@ Try setting it to something valid, like:
|
|
|
164
165
|
return getCachedDreamAppOrFail();
|
|
165
166
|
}
|
|
166
167
|
static log(...args) {
|
|
167
|
-
this.getOrFail().logger.info(this.
|
|
168
|
+
this.getOrFail().logger.info(this.loggerArgsToString(args));
|
|
168
169
|
}
|
|
169
170
|
static logWithLevel(level, ...args) {
|
|
170
|
-
this.getOrFail().logger[level](this.
|
|
171
|
+
this.getOrFail().logger[level](this.loggerArgsToString(args));
|
|
171
172
|
}
|
|
172
|
-
static
|
|
173
|
-
return args.map(
|
|
173
|
+
static loggerArgsToString(args) {
|
|
174
|
+
return args.map(loggerArgToString).join(' ');
|
|
174
175
|
}
|
|
175
176
|
_specialHooks = {
|
|
176
177
|
dbLog: [],
|
|
@@ -404,16 +405,17 @@ Try setting it to something valid, like:
|
|
|
404
405
|
}
|
|
405
406
|
}
|
|
406
407
|
}
|
|
407
|
-
function
|
|
408
|
+
function loggerArgToString(arg) {
|
|
408
409
|
if (typeof arg === 'string')
|
|
409
410
|
return arg;
|
|
410
411
|
if (typeof arg === 'number')
|
|
411
412
|
return arg;
|
|
412
413
|
if (typeof arg === 'boolean')
|
|
413
414
|
return arg;
|
|
414
|
-
if (arg instanceof DateTime || arg instanceof CalendarDate)
|
|
415
|
+
if (arg instanceof DateTime || arg instanceof CalendarDate || arg instanceof BaseClockTime) {
|
|
415
416
|
return arg.toISO();
|
|
416
|
-
|
|
417
|
+
}
|
|
418
|
+
return JSON.stringify(util.inspect(arg, { depth: 6 }));
|
|
417
419
|
}
|
|
418
420
|
export const DreamAppAllowedPackageManagersEnumValues = ['pnpm', 'yarn', 'npm'];
|
|
419
421
|
// GeneratorImportStyles are used by CLI generators to determine how
|
|
@@ -38,10 +38,10 @@ function normalizedString(_val) {
|
|
|
38
38
|
return alreadyAnArray ? normalizedValueArray : normalizedValueArray[0];
|
|
39
39
|
}
|
|
40
40
|
function dateTimeOrDateToSql(dateClass, _val) {
|
|
41
|
-
if (_val === null || _val === undefined)
|
|
42
|
-
return _val;
|
|
43
41
|
const alreadyAnArray = Array.isArray(_val);
|
|
44
42
|
const normalizedValueArray = (alreadyAnArray ? _val : [_val]).map(val => {
|
|
43
|
+
if (val === null || val === undefined)
|
|
44
|
+
return val;
|
|
45
45
|
if (val instanceof DateTime || val instanceof CalendarDate)
|
|
46
46
|
return val.toSQL();
|
|
47
47
|
try {
|
|
@@ -59,10 +59,10 @@ function dateTimeOrDateToSql(dateClass, _val) {
|
|
|
59
59
|
return alreadyAnArray ? normalizedValueArray : normalizedValueArray[0];
|
|
60
60
|
}
|
|
61
61
|
function clockTimeOrClockTimeTzToSql(clockTimeClass, _val) {
|
|
62
|
-
if (_val === null || _val === undefined)
|
|
63
|
-
return _val;
|
|
64
62
|
const alreadyAnArray = Array.isArray(_val);
|
|
65
63
|
const normalizedValueArray = (alreadyAnArray ? _val : [_val]).map(val => {
|
|
64
|
+
if (val === null || val === undefined)
|
|
65
|
+
return val;
|
|
66
66
|
if (val instanceof BaseClockTime)
|
|
67
67
|
return val.toSQL();
|
|
68
68
|
try {
|
|
@@ -13,8 +13,9 @@ export const BASE_DATE_OBJECT = {
|
|
|
13
13
|
* DateTime wraps Luxon DateTime with microsecond precision (0-999).
|
|
14
14
|
* The decimal part in ISO/SQL is 6 digits: first 3 = milliseconds, next 3 = microseconds.
|
|
15
15
|
*
|
|
16
|
-
* Full datetime output
|
|
16
|
+
* Full datetime output with toSQL() is normalized to UTC.
|
|
17
17
|
* Time-only output (toISOTime, toSQLTime) omits timezone offset by default.
|
|
18
|
+
* toISO() preserves the timezone of the DateTime instance.
|
|
18
19
|
*/
|
|
19
20
|
export class DateTime {
|
|
20
21
|
luxonDatetime;
|
|
@@ -568,7 +569,7 @@ export class DateTime {
|
|
|
568
569
|
/**
|
|
569
570
|
* Returns an ISO 8601 string with 6 fractional second digits (milliseconds + microseconds).
|
|
570
571
|
*
|
|
571
|
-
*
|
|
572
|
+
* Preserves the timezone of the DateTime instance.
|
|
572
573
|
*
|
|
573
574
|
* @param opts - Optional format options
|
|
574
575
|
* @param opts.suppressMilliseconds - If true, omits fractional seconds when they are zero
|
|
@@ -578,12 +579,11 @@ export class DateTime {
|
|
|
578
579
|
* @returns ISO string (e.g. "2024-03-15T10:30:45.123456-05:00" or "2024-03-15T10:30:45.123456Z")
|
|
579
580
|
* @example
|
|
580
581
|
* ```ts
|
|
581
|
-
* DateTime.fromISO('2024-03-15T10:30:45.123456').toISO() //
|
|
582
|
+
* DateTime.fromISO('2024-03-15T10:30:45.123456-05:00').toISO() // '2024-03-15T10:30:45.123456-05:00'
|
|
582
583
|
* ```
|
|
583
584
|
*/
|
|
584
585
|
toISO(opts) {
|
|
585
|
-
|
|
586
|
-
return replaceISOMicroseconds(dt, dt.luxonDatetime.toISO(opts), opts);
|
|
586
|
+
return replaceISOMicroseconds(this, this.luxonDatetime.toISO(opts), opts);
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
589
589
|
* Returns an ISO date string (date only, no time).
|
|
@@ -681,12 +681,12 @@ export class DateTime {
|
|
|
681
681
|
/**
|
|
682
682
|
* Returns an ISO 8601 string representation (for valueOf() operations).
|
|
683
683
|
*
|
|
684
|
-
*
|
|
684
|
+
* Preserves the timezone of the DateTime instance.
|
|
685
685
|
*
|
|
686
686
|
* @returns ISO datetime string with microsecond precision
|
|
687
687
|
* @example
|
|
688
688
|
* ```ts
|
|
689
|
-
* DateTime.local(2017, 3, 12).valueOf() //
|
|
689
|
+
* DateTime.local(2017, 3, 12).valueOf() // Preserves local timezone
|
|
690
690
|
* DateTime.fromISO('2026-02-07T09:03:44.123456Z').valueOf() // '2026-02-07T09:03:44.123456Z'
|
|
691
691
|
* ```
|
|
692
692
|
*/
|
|
@@ -701,7 +701,7 @@ export class DateTime {
|
|
|
701
701
|
* Returns an ISO 8601 formatted string for JSON serialization.
|
|
702
702
|
* This ensures DateTime objects are properly serialized to ISO format.
|
|
703
703
|
*
|
|
704
|
-
*
|
|
704
|
+
* Preserves the timezone of the DateTime instance.
|
|
705
705
|
*
|
|
706
706
|
* @returns ISO datetime string with microsecond precision
|
|
707
707
|
* @example
|
|
@@ -717,7 +717,7 @@ export class DateTime {
|
|
|
717
717
|
* Returns an ISO 8601 formatted string representation.
|
|
718
718
|
* Alias for toISO().
|
|
719
719
|
*
|
|
720
|
-
*
|
|
720
|
+
* Preserves the timezone of the DateTime instance.
|
|
721
721
|
*
|
|
722
722
|
* @returns ISO datetime string with microsecond precision
|
|
723
723
|
* @example
|
|
@@ -1015,8 +1015,7 @@ export class DateTime {
|
|
|
1015
1015
|
*/
|
|
1016
1016
|
startOf(unit, opts) {
|
|
1017
1017
|
const luxonDatetime = this.luxonDatetime.startOf(unit, opts);
|
|
1018
|
-
|
|
1019
|
-
return new DateTime(luxonDatetime, microseconds);
|
|
1018
|
+
return new DateTime(luxonDatetime, 0);
|
|
1020
1019
|
}
|
|
1021
1020
|
/**
|
|
1022
1021
|
* Returns a new DateTime at the end of the given unit.
|
|
@@ -1032,8 +1031,7 @@ export class DateTime {
|
|
|
1032
1031
|
*/
|
|
1033
1032
|
endOf(unit, opts) {
|
|
1034
1033
|
const luxonDatetime = this.luxonDatetime.endOf(unit, opts);
|
|
1035
|
-
|
|
1036
|
-
return new DateTime(luxonDatetime, microseconds);
|
|
1034
|
+
return new DateTime(luxonDatetime, 999);
|
|
1037
1035
|
}
|
|
1038
1036
|
/**
|
|
1039
1037
|
* Returns a new DateTime with the given locale/zone options. Microsecond is preserved.
|
|
@@ -16,6 +16,7 @@ import expandStiClasses from '../helpers/sti/expandStiClasses.js';
|
|
|
16
16
|
import inferSerializerFromDreamOrViewModel, { inferSerializersFromDreamClassOrViewModelClass, } from '../serializer/helpers/inferSerializerFromDreamOrViewModel.js';
|
|
17
17
|
import isDreamSerializer from '../serializer/helpers/isDreamSerializer.js';
|
|
18
18
|
import serializerNameFromFullyQualifiedModelName from '../serializer/helpers/serializerNameFromFullyQualifiedModelName.js';
|
|
19
|
+
import BaseClockTime from '../utils/datetime/BaseClockTime.js';
|
|
19
20
|
import CalendarDate from '../utils/datetime/CalendarDate.js';
|
|
20
21
|
import { DateTime, Settings } from '../utils/datetime/DateTime.js';
|
|
21
22
|
import { cacheDreamApp, getCachedDreamAppOrFail } from './cache.js';
|
|
@@ -164,13 +165,13 @@ Try setting it to something valid, like:
|
|
|
164
165
|
return getCachedDreamAppOrFail();
|
|
165
166
|
}
|
|
166
167
|
static log(...args) {
|
|
167
|
-
this.getOrFail().logger.info(this.
|
|
168
|
+
this.getOrFail().logger.info(this.loggerArgsToString(args));
|
|
168
169
|
}
|
|
169
170
|
static logWithLevel(level, ...args) {
|
|
170
|
-
this.getOrFail().logger[level](this.
|
|
171
|
+
this.getOrFail().logger[level](this.loggerArgsToString(args));
|
|
171
172
|
}
|
|
172
|
-
static
|
|
173
|
-
return args.map(
|
|
173
|
+
static loggerArgsToString(args) {
|
|
174
|
+
return args.map(loggerArgToString).join(' ');
|
|
174
175
|
}
|
|
175
176
|
_specialHooks = {
|
|
176
177
|
dbLog: [],
|
|
@@ -404,16 +405,17 @@ Try setting it to something valid, like:
|
|
|
404
405
|
}
|
|
405
406
|
}
|
|
406
407
|
}
|
|
407
|
-
function
|
|
408
|
+
function loggerArgToString(arg) {
|
|
408
409
|
if (typeof arg === 'string')
|
|
409
410
|
return arg;
|
|
410
411
|
if (typeof arg === 'number')
|
|
411
412
|
return arg;
|
|
412
413
|
if (typeof arg === 'boolean')
|
|
413
414
|
return arg;
|
|
414
|
-
if (arg instanceof DateTime || arg instanceof CalendarDate)
|
|
415
|
+
if (arg instanceof DateTime || arg instanceof CalendarDate || arg instanceof BaseClockTime) {
|
|
415
416
|
return arg.toISO();
|
|
416
|
-
|
|
417
|
+
}
|
|
418
|
+
return JSON.stringify(util.inspect(arg, { depth: 6 }));
|
|
417
419
|
}
|
|
418
420
|
export const DreamAppAllowedPackageManagersEnumValues = ['pnpm', 'yarn', 'npm'];
|
|
419
421
|
// GeneratorImportStyles are used by CLI generators to determine how
|
|
@@ -38,10 +38,10 @@ function normalizedString(_val) {
|
|
|
38
38
|
return alreadyAnArray ? normalizedValueArray : normalizedValueArray[0];
|
|
39
39
|
}
|
|
40
40
|
function dateTimeOrDateToSql(dateClass, _val) {
|
|
41
|
-
if (_val === null || _val === undefined)
|
|
42
|
-
return _val;
|
|
43
41
|
const alreadyAnArray = Array.isArray(_val);
|
|
44
42
|
const normalizedValueArray = (alreadyAnArray ? _val : [_val]).map(val => {
|
|
43
|
+
if (val === null || val === undefined)
|
|
44
|
+
return val;
|
|
45
45
|
if (val instanceof DateTime || val instanceof CalendarDate)
|
|
46
46
|
return val.toSQL();
|
|
47
47
|
try {
|
|
@@ -59,10 +59,10 @@ function dateTimeOrDateToSql(dateClass, _val) {
|
|
|
59
59
|
return alreadyAnArray ? normalizedValueArray : normalizedValueArray[0];
|
|
60
60
|
}
|
|
61
61
|
function clockTimeOrClockTimeTzToSql(clockTimeClass, _val) {
|
|
62
|
-
if (_val === null || _val === undefined)
|
|
63
|
-
return _val;
|
|
64
62
|
const alreadyAnArray = Array.isArray(_val);
|
|
65
63
|
const normalizedValueArray = (alreadyAnArray ? _val : [_val]).map(val => {
|
|
64
|
+
if (val === null || val === undefined)
|
|
65
|
+
return val;
|
|
66
66
|
if (val instanceof BaseClockTime)
|
|
67
67
|
return val.toSQL();
|
|
68
68
|
try {
|
|
@@ -13,8 +13,9 @@ export const BASE_DATE_OBJECT = {
|
|
|
13
13
|
* DateTime wraps Luxon DateTime with microsecond precision (0-999).
|
|
14
14
|
* The decimal part in ISO/SQL is 6 digits: first 3 = milliseconds, next 3 = microseconds.
|
|
15
15
|
*
|
|
16
|
-
* Full datetime output
|
|
16
|
+
* Full datetime output with toSQL() is normalized to UTC.
|
|
17
17
|
* Time-only output (toISOTime, toSQLTime) omits timezone offset by default.
|
|
18
|
+
* toISO() preserves the timezone of the DateTime instance.
|
|
18
19
|
*/
|
|
19
20
|
export class DateTime {
|
|
20
21
|
luxonDatetime;
|
|
@@ -568,7 +569,7 @@ export class DateTime {
|
|
|
568
569
|
/**
|
|
569
570
|
* Returns an ISO 8601 string with 6 fractional second digits (milliseconds + microseconds).
|
|
570
571
|
*
|
|
571
|
-
*
|
|
572
|
+
* Preserves the timezone of the DateTime instance.
|
|
572
573
|
*
|
|
573
574
|
* @param opts - Optional format options
|
|
574
575
|
* @param opts.suppressMilliseconds - If true, omits fractional seconds when they are zero
|
|
@@ -578,12 +579,11 @@ export class DateTime {
|
|
|
578
579
|
* @returns ISO string (e.g. "2024-03-15T10:30:45.123456-05:00" or "2024-03-15T10:30:45.123456Z")
|
|
579
580
|
* @example
|
|
580
581
|
* ```ts
|
|
581
|
-
* DateTime.fromISO('2024-03-15T10:30:45.123456').toISO() //
|
|
582
|
+
* DateTime.fromISO('2024-03-15T10:30:45.123456-05:00').toISO() // '2024-03-15T10:30:45.123456-05:00'
|
|
582
583
|
* ```
|
|
583
584
|
*/
|
|
584
585
|
toISO(opts) {
|
|
585
|
-
|
|
586
|
-
return replaceISOMicroseconds(dt, dt.luxonDatetime.toISO(opts), opts);
|
|
586
|
+
return replaceISOMicroseconds(this, this.luxonDatetime.toISO(opts), opts);
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
589
589
|
* Returns an ISO date string (date only, no time).
|
|
@@ -681,12 +681,12 @@ export class DateTime {
|
|
|
681
681
|
/**
|
|
682
682
|
* Returns an ISO 8601 string representation (for valueOf() operations).
|
|
683
683
|
*
|
|
684
|
-
*
|
|
684
|
+
* Preserves the timezone of the DateTime instance.
|
|
685
685
|
*
|
|
686
686
|
* @returns ISO datetime string with microsecond precision
|
|
687
687
|
* @example
|
|
688
688
|
* ```ts
|
|
689
|
-
* DateTime.local(2017, 3, 12).valueOf() //
|
|
689
|
+
* DateTime.local(2017, 3, 12).valueOf() // Preserves local timezone
|
|
690
690
|
* DateTime.fromISO('2026-02-07T09:03:44.123456Z').valueOf() // '2026-02-07T09:03:44.123456Z'
|
|
691
691
|
* ```
|
|
692
692
|
*/
|
|
@@ -701,7 +701,7 @@ export class DateTime {
|
|
|
701
701
|
* Returns an ISO 8601 formatted string for JSON serialization.
|
|
702
702
|
* This ensures DateTime objects are properly serialized to ISO format.
|
|
703
703
|
*
|
|
704
|
-
*
|
|
704
|
+
* Preserves the timezone of the DateTime instance.
|
|
705
705
|
*
|
|
706
706
|
* @returns ISO datetime string with microsecond precision
|
|
707
707
|
* @example
|
|
@@ -717,7 +717,7 @@ export class DateTime {
|
|
|
717
717
|
* Returns an ISO 8601 formatted string representation.
|
|
718
718
|
* Alias for toISO().
|
|
719
719
|
*
|
|
720
|
-
*
|
|
720
|
+
* Preserves the timezone of the DateTime instance.
|
|
721
721
|
*
|
|
722
722
|
* @returns ISO datetime string with microsecond precision
|
|
723
723
|
* @example
|
|
@@ -1015,8 +1015,7 @@ export class DateTime {
|
|
|
1015
1015
|
*/
|
|
1016
1016
|
startOf(unit, opts) {
|
|
1017
1017
|
const luxonDatetime = this.luxonDatetime.startOf(unit, opts);
|
|
1018
|
-
|
|
1019
|
-
return new DateTime(luxonDatetime, microseconds);
|
|
1018
|
+
return new DateTime(luxonDatetime, 0);
|
|
1020
1019
|
}
|
|
1021
1020
|
/**
|
|
1022
1021
|
* Returns a new DateTime at the end of the given unit.
|
|
@@ -1032,8 +1031,7 @@ export class DateTime {
|
|
|
1032
1031
|
*/
|
|
1033
1032
|
endOf(unit, opts) {
|
|
1034
1033
|
const luxonDatetime = this.luxonDatetime.endOf(unit, opts);
|
|
1035
|
-
|
|
1036
|
-
return new DateTime(luxonDatetime, microseconds);
|
|
1034
|
+
return new DateTime(luxonDatetime, 999);
|
|
1037
1035
|
}
|
|
1038
1036
|
/**
|
|
1039
1037
|
* Returns a new DateTime with the given locale/zone options. Microsecond is preserved.
|
|
@@ -100,7 +100,7 @@ export default class DreamApp {
|
|
|
100
100
|
static getOrFail(): DreamApp;
|
|
101
101
|
static log(...args: any[]): void;
|
|
102
102
|
static logWithLevel(level: DreamLogLevel, ...args: any[]): void;
|
|
103
|
-
private static
|
|
103
|
+
private static loggerArgsToString;
|
|
104
104
|
private _specialHooks;
|
|
105
105
|
get specialHooks(): DreamAppSpecialHooks;
|
|
106
106
|
private _dbCredentials;
|
|
@@ -10,8 +10,9 @@ export declare const BASE_DATE_OBJECT: {
|
|
|
10
10
|
* DateTime wraps Luxon DateTime with microsecond precision (0-999).
|
|
11
11
|
* The decimal part in ISO/SQL is 6 digits: first 3 = milliseconds, next 3 = microseconds.
|
|
12
12
|
*
|
|
13
|
-
* Full datetime output
|
|
13
|
+
* Full datetime output with toSQL() is normalized to UTC.
|
|
14
14
|
* Time-only output (toISOTime, toSQLTime) omits timezone offset by default.
|
|
15
|
+
* toISO() preserves the timezone of the DateTime instance.
|
|
15
16
|
*/
|
|
16
17
|
export declare class DateTime {
|
|
17
18
|
protected readonly luxonDatetime: LuxonDateTime;
|
|
@@ -456,7 +457,7 @@ export declare class DateTime {
|
|
|
456
457
|
/**
|
|
457
458
|
* Returns an ISO 8601 string with 6 fractional second digits (milliseconds + microseconds).
|
|
458
459
|
*
|
|
459
|
-
*
|
|
460
|
+
* Preserves the timezone of the DateTime instance.
|
|
460
461
|
*
|
|
461
462
|
* @param opts - Optional format options
|
|
462
463
|
* @param opts.suppressMilliseconds - If true, omits fractional seconds when they are zero
|
|
@@ -466,7 +467,7 @@ export declare class DateTime {
|
|
|
466
467
|
* @returns ISO string (e.g. "2024-03-15T10:30:45.123456-05:00" or "2024-03-15T10:30:45.123456Z")
|
|
467
468
|
* @example
|
|
468
469
|
* ```ts
|
|
469
|
-
* DateTime.fromISO('2024-03-15T10:30:45.123456').toISO() //
|
|
470
|
+
* DateTime.fromISO('2024-03-15T10:30:45.123456-05:00').toISO() // '2024-03-15T10:30:45.123456-05:00'
|
|
470
471
|
* ```
|
|
471
472
|
*/
|
|
472
473
|
toISO(opts?: ToISOTimeOptions): string;
|
|
@@ -547,12 +548,12 @@ export declare class DateTime {
|
|
|
547
548
|
/**
|
|
548
549
|
* Returns an ISO 8601 string representation (for valueOf() operations).
|
|
549
550
|
*
|
|
550
|
-
*
|
|
551
|
+
* Preserves the timezone of the DateTime instance.
|
|
551
552
|
*
|
|
552
553
|
* @returns ISO datetime string with microsecond precision
|
|
553
554
|
* @example
|
|
554
555
|
* ```ts
|
|
555
|
-
* DateTime.local(2017, 3, 12).valueOf() //
|
|
556
|
+
* DateTime.local(2017, 3, 12).valueOf() // Preserves local timezone
|
|
556
557
|
* DateTime.fromISO('2026-02-07T09:03:44.123456Z').valueOf() // '2026-02-07T09:03:44.123456Z'
|
|
557
558
|
* ```
|
|
558
559
|
*/
|
|
@@ -562,7 +563,7 @@ export declare class DateTime {
|
|
|
562
563
|
* Returns an ISO 8601 formatted string for JSON serialization.
|
|
563
564
|
* This ensures DateTime objects are properly serialized to ISO format.
|
|
564
565
|
*
|
|
565
|
-
*
|
|
566
|
+
* Preserves the timezone of the DateTime instance.
|
|
566
567
|
*
|
|
567
568
|
* @returns ISO datetime string with microsecond precision
|
|
568
569
|
* @example
|
|
@@ -576,7 +577,7 @@ export declare class DateTime {
|
|
|
576
577
|
* Returns an ISO 8601 formatted string representation.
|
|
577
578
|
* Alias for toISO().
|
|
578
579
|
*
|
|
579
|
-
*
|
|
580
|
+
* Preserves the timezone of the DateTime instance.
|
|
580
581
|
*
|
|
581
582
|
* @returns ISO datetime string with microsecond precision
|
|
582
583
|
* @example
|