@rvoh/dream 0.29.7 → 0.29.10
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/boilerplate/app/models/ApplicationModel.ts +2 -2
- package/boilerplate/cli/helpers/initializeDreamApplication.ts +1 -1
- package/boilerplate/cli/index.ts +3 -3
- package/boilerplate/conf/repl.ts +1 -1
- package/dist/cjs/src/Dream.js +10 -6
- package/dist/cjs/src/bin/helpers/sync.js +3 -5
- package/dist/cjs/src/dream/Query.js +3 -3
- package/dist/cjs/src/dream/internal/saveDream.js +2 -2
- package/dist/cjs/src/dream/internal/softDeleteDream.js +2 -2
- package/dist/cjs/src/dream-application/helpers/DreamImporter.js +5 -2
- package/dist/cjs/src/encrypt/InternalEncrypt.js +6 -6
- package/dist/cjs/src/global-cli/file-builders/DreamtsBuilder.js +1 -1
- package/dist/cjs/src/helpers/CalendarDate.js +12 -12
- package/dist/cjs/src/helpers/DateTime.js +4 -0
- package/dist/cjs/src/helpers/benchmark.js +3 -3
- package/dist/cjs/src/helpers/cli/SchemaBuilder.js +3 -4
- package/dist/cjs/src/helpers/cloneDeepSafe.js +2 -2
- package/dist/cjs/src/helpers/customPgParsers.js +2 -2
- package/dist/cjs/src/helpers/hyphenize.js +1 -1
- package/dist/cjs/src/helpers/loadEnv.js +1 -1
- package/dist/cjs/src/helpers/loadRepl.js +2 -2
- package/dist/cjs/src/helpers/pascalize.js +1 -1
- package/dist/cjs/src/helpers/path/relativeDreamPath.js +3 -3
- package/dist/cjs/src/helpers/snakeify.js +1 -1
- package/dist/cjs/src/helpers/sqlAttributes.js +3 -3
- package/dist/cjs/src/helpers/stringCasing.js +3 -3
- package/dist/cjs/src/index.js +5 -4
- package/dist/cjs/src/serializer/index.js +2 -2
- package/dist/esm/src/Dream.js +6 -2
- package/dist/esm/src/bin/helpers/sync.js +3 -5
- package/dist/esm/src/dream/Query.js +1 -1
- package/dist/esm/src/dream/internal/saveDream.js +1 -1
- package/dist/esm/src/dream/internal/softDeleteDream.js +1 -1
- package/dist/esm/src/dream-application/helpers/DreamImporter.js +5 -2
- package/dist/esm/src/encrypt/InternalEncrypt.js +1 -1
- package/dist/esm/src/global-cli/file-builders/DreamtsBuilder.js +1 -1
- package/dist/esm/src/helpers/CalendarDate.js +1 -1
- package/dist/esm/src/helpers/DateTime.js +2 -0
- package/dist/esm/src/helpers/benchmark.js +1 -1
- package/dist/esm/src/helpers/cli/SchemaBuilder.js +3 -4
- package/dist/esm/src/helpers/cloneDeepSafe.js +1 -1
- package/dist/esm/src/helpers/customPgParsers.js +1 -1
- package/dist/esm/src/helpers/hyphenize.js +1 -1
- package/dist/esm/src/helpers/loadEnv.js +1 -1
- package/dist/esm/src/helpers/loadRepl.js +1 -1
- package/dist/esm/src/helpers/pascalize.js +1 -1
- package/dist/esm/src/helpers/path/relativeDreamPath.js +3 -3
- package/dist/esm/src/helpers/snakeify.js +1 -1
- package/dist/esm/src/helpers/sqlAttributes.js +1 -1
- package/dist/esm/src/helpers/stringCasing.js +2 -2
- package/dist/esm/src/index.js +2 -2
- package/dist/esm/src/serializer/index.js +1 -1
- package/dist/types/src/decorators/DecoratorContextType.d.ts +1 -1
- package/dist/types/src/decorators/associations/shared.d.ts +1 -1
- package/dist/types/src/decorators/sortable/helpers/setPosition.d.ts +1 -1
- package/dist/types/src/dream/internal/reload.d.ts +1 -1
- package/dist/types/src/dream/types.d.ts +1 -1
- package/dist/types/src/dream-application/helpers/DreamImporter.d.ts +2 -2
- package/dist/types/src/helpers/CalendarDate.d.ts +2 -1
- package/dist/types/src/helpers/DateTime.d.ts +2 -0
- package/dist/types/src/helpers/customPgParsers.d.ts +1 -1
- package/dist/types/src/helpers/stringCasing.d.ts +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/DateTime.html +863 -0
- package/docs/classes/Decorators.html +14 -14
- package/docs/classes/Dream.html +131 -131
- package/docs/classes/DreamApplication.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +3 -3
- package/docs/classes/DreamDbConnection.html +2 -2
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializer.html +2 -2
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/Query.html +52 -52
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/Attribute.html +1 -1
- package/docs/functions/RendersMany.html +1 -1
- package/docs/functions/RendersOne.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/Scope.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/Validate.html +1 -1
- package/docs/functions/Validates.html +1 -1
- package/docs/functions/Virtual.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/db.html +1 -1
- package/docs/functions/debug.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/interfaces/AttributeStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
- package/docs/interfaces/DreamApplicationOpts.html +2 -2
- package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/modules.html +1 -0
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
- package/docs/types/SerializableDreamOrViewModel.html +1 -1
- package/docs/types/SerializableTypes.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModelSerializerKey.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dream } from '@rvoh/dream'
|
|
2
|
-
import { globalSchema, schema } from '../../db/schema'
|
|
3
|
-
import { DBClass } from '../../db/sync'
|
|
2
|
+
import { globalSchema, schema } from '../../db/schema.js'
|
|
3
|
+
import { DBClass } from '../../db/sync.js'
|
|
4
4
|
|
|
5
5
|
export default class ApplicationModel extends Dream {
|
|
6
6
|
public DB: DBClass
|
package/boilerplate/cli/index.ts
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
// commanderjs docs:
|
|
6
6
|
// https://github.com/tj/commander.js#quick-start
|
|
7
7
|
|
|
8
|
-
import '../conf/loadEnv'
|
|
8
|
+
import '../conf/loadEnv.js'
|
|
9
9
|
|
|
10
10
|
import { DreamCLI } from '@rvoh/dream'
|
|
11
11
|
import { Command } from 'commander'
|
|
12
|
-
import seedDb from '../db/seed'
|
|
13
|
-
import initializeDreamApplication from './helpers/initializeDreamApplication'
|
|
12
|
+
import seedDb from '../db/seed.js'
|
|
13
|
+
import initializeDreamApplication from './helpers/initializeDreamApplication.js'
|
|
14
14
|
|
|
15
15
|
const program = new Command()
|
|
16
16
|
|
package/boilerplate/conf/repl.ts
CHANGED
|
@@ -2,7 +2,7 @@ import './loadEnv.js'
|
|
|
2
2
|
|
|
3
3
|
import { loadRepl } from '@rvoh/dream'
|
|
4
4
|
import * as repl from 'node:repl'
|
|
5
|
-
import initializePsychicApplication from '../cli/helpers/initializePsychicApplication'
|
|
5
|
+
import initializePsychicApplication from '../cli/helpers/initializePsychicApplication.js'
|
|
6
6
|
|
|
7
7
|
const replServer = repl.start('> ')
|
|
8
8
|
export default (async function () {
|
package/dist/cjs/src/Dream.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const luxon_1 = require("luxon");
|
|
4
3
|
const errors_js_1 = require("./db/errors.js");
|
|
5
4
|
const index_js_1 = require("./db/index.js");
|
|
6
5
|
const associationToGetterSetterProp_js_1 = require("./decorators/associations/associationToGetterSetterProp.js");
|
|
@@ -39,6 +38,7 @@ const MissingTable_js_1 = require("./errors/MissingTable.js");
|
|
|
39
38
|
const NonExistentScopeProvidedToResort_js_1 = require("./errors/NonExistentScopeProvidedToResort.js");
|
|
40
39
|
const CalendarDate_js_1 = require("./helpers/CalendarDate.js");
|
|
41
40
|
const cloneDeepSafe_js_1 = require("./helpers/cloneDeepSafe.js");
|
|
41
|
+
const DateTime_js_1 = require("./helpers/DateTime.js");
|
|
42
42
|
const cachedTypeForAttribute_js_1 = require("./helpers/db/cachedTypeForAttribute.js");
|
|
43
43
|
const isJsonColumn_js_1 = require("./helpers/db/types/isJsonColumn.js");
|
|
44
44
|
const inferSerializerFromDreamOrViewModel_js_1 = require("./helpers/inferSerializerFromDreamOrViewModel.js");
|
|
@@ -447,8 +447,12 @@ class Dream {
|
|
|
447
447
|
* @returns A subset of columns for the given dream class
|
|
448
448
|
*/
|
|
449
449
|
static paramSafeColumnsOrFallback() {
|
|
450
|
-
|
|
450
|
+
let defaultParams = this.defaultParamSafeColumns();
|
|
451
451
|
const userDefinedParams = this.prototype.paramSafeColumns;
|
|
452
|
+
const userDefinedUnsafeParams = this.prototype.paramUnsafeColumns;
|
|
453
|
+
if (Array.isArray(userDefinedUnsafeParams)) {
|
|
454
|
+
defaultParams = defaultParams.filter(param => !userDefinedUnsafeParams.includes(param));
|
|
455
|
+
}
|
|
452
456
|
if (Array.isArray(userDefinedParams)) {
|
|
453
457
|
return userDefinedParams.filter(param => defaultParams.includes(param));
|
|
454
458
|
}
|
|
@@ -2364,7 +2368,7 @@ class Dream {
|
|
|
2364
2368
|
const currentValue = this.getAttributes()[attribute];
|
|
2365
2369
|
if (this.isNewRecord)
|
|
2366
2370
|
return true;
|
|
2367
|
-
if (frozenValue instanceof
|
|
2371
|
+
if (frozenValue instanceof DateTime_js_1.default) {
|
|
2368
2372
|
return frozenValue.toMillis() !== this.unknownValueToMillis(currentValue);
|
|
2369
2373
|
}
|
|
2370
2374
|
else if (frozenValue instanceof CalendarDate_js_1.default) {
|
|
@@ -2381,10 +2385,10 @@ class Dream {
|
|
|
2381
2385
|
if (!currentValue)
|
|
2382
2386
|
return;
|
|
2383
2387
|
if ((0, typechecks_js_1.isString)(currentValue))
|
|
2384
|
-
currentValue =
|
|
2388
|
+
currentValue = DateTime_js_1.default.fromISO(currentValue);
|
|
2385
2389
|
if (currentValue instanceof CalendarDate_js_1.default)
|
|
2386
2390
|
currentValue = currentValue.toDateTime();
|
|
2387
|
-
if (currentValue instanceof
|
|
2391
|
+
if (currentValue instanceof DateTime_js_1.default && currentValue.isValid)
|
|
2388
2392
|
return currentValue.toMillis();
|
|
2389
2393
|
}
|
|
2390
2394
|
/**
|
|
@@ -2395,7 +2399,7 @@ class Dream {
|
|
|
2395
2399
|
return;
|
|
2396
2400
|
if ((0, typechecks_js_1.isString)(currentValue))
|
|
2397
2401
|
currentValue = CalendarDate_js_1.default.fromISO(currentValue);
|
|
2398
|
-
if (currentValue instanceof
|
|
2402
|
+
if (currentValue instanceof DateTime_js_1.default)
|
|
2399
2403
|
currentValue = CalendarDate_js_1.default.fromDateTime(currentValue);
|
|
2400
2404
|
if (currentValue instanceof CalendarDate_js_1.default && currentValue.isValid)
|
|
2401
2405
|
return currentValue.toISO();
|
|
@@ -57,11 +57,9 @@ function removeUnwantedExports(file) {
|
|
|
57
57
|
export type Timestamp = ColumnType<DateTime | CalendarDate>`);
|
|
58
58
|
}
|
|
59
59
|
function addCustomImports(file) {
|
|
60
|
-
const
|
|
61
|
-
? "import CalendarDate from '../../src/helpers/CalendarDate'"
|
|
62
|
-
: "import { CalendarDate } from '@rvoh/dream'";
|
|
63
|
-
const customImports = `${calendarDateImportStatement}
|
|
64
|
-
import { DateTime } from 'luxon'`;
|
|
60
|
+
const customImports = EnvInternal_js_1.default.boolean('DREAM_CORE_DEVELOPMENT')
|
|
61
|
+
? "import CalendarDate from '../../src/helpers/CalendarDate.js'\nimport DateTime from '../../src/helpers/DateTime.js'"
|
|
62
|
+
: "import { CalendarDate, DateTime } from '@rvoh/dream'";
|
|
65
63
|
return `${(0, autogeneratedFileMessage_js_1.default)()}${customImports}
|
|
66
64
|
${file}`;
|
|
67
65
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const kysely_1 = require("kysely");
|
|
4
|
-
const luxon_1 = require("luxon");
|
|
5
4
|
const pluralize_esm_1 = require("pluralize-esm");
|
|
6
5
|
const ConnectedToDB_js_1 = require("../db/ConnectedToDB.js");
|
|
7
6
|
const associationToGetterSetterProp_js_1 = require("../decorators/associations/associationToGetterSetterProp.js");
|
|
@@ -26,6 +25,7 @@ const CalendarDate_js_1 = require("../helpers/CalendarDate.js");
|
|
|
26
25
|
const camelize_js_1 = require("../helpers/camelize.js");
|
|
27
26
|
const cloneDeepSafe_js_1 = require("../helpers/cloneDeepSafe.js");
|
|
28
27
|
const compact_js_1 = require("../helpers/compact.js");
|
|
28
|
+
const DateTime_js_1 = require("../helpers/DateTime.js");
|
|
29
29
|
const isEmpty_js_1 = require("../helpers/isEmpty.js");
|
|
30
30
|
const namespaceColumn_js_1 = require("../helpers/namespaceColumn.js");
|
|
31
31
|
const objectPathsToArrays_js_1 = require("../helpers/objectPathsToArrays.js");
|
|
@@ -2420,9 +2420,9 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
2420
2420
|
b = '=';
|
|
2421
2421
|
c = val;
|
|
2422
2422
|
}
|
|
2423
|
-
if (c instanceof
|
|
2423
|
+
if (c instanceof DateTime_js_1.default || c instanceof CalendarDate_js_1.default)
|
|
2424
2424
|
c = c.toJSDate();
|
|
2425
|
-
if (c2 instanceof
|
|
2425
|
+
if (c2 instanceof DateTime_js_1.default || c2 instanceof CalendarDate_js_1.default)
|
|
2426
2426
|
c2 = c2.toJSDate();
|
|
2427
2427
|
if (a && c === undefined)
|
|
2428
2428
|
throw new CannotPassUndefinedAsAValueToAWhereClause_js_1.default(this.dreamClass, a);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = saveDream;
|
|
4
|
-
const luxon_1 = require("luxon");
|
|
5
4
|
const index_js_1 = require("../../db/index.js");
|
|
6
5
|
const ValidationError_js_1 = require("../../errors/ValidationError.js");
|
|
6
|
+
const DateTime_js_1 = require("../../helpers/DateTime.js");
|
|
7
7
|
const namespaceColumn_js_1 = require("../../helpers/namespaceColumn.js");
|
|
8
8
|
const sqlAttributes_js_1 = require("../../helpers/sqlAttributes.js");
|
|
9
9
|
const executeDatabaseQuery_js_1 = require("./executeDatabaseQuery.js");
|
|
@@ -27,7 +27,7 @@ async function saveDream(dream, txn = null, { skipHooks = false } = {}) {
|
|
|
27
27
|
if (alreadyPersisted && !dream.isDirty)
|
|
28
28
|
return dream;
|
|
29
29
|
let query;
|
|
30
|
-
const now =
|
|
30
|
+
const now = DateTime_js_1.default.now();
|
|
31
31
|
if (!alreadyPersisted && !dream.createdAt && dream.columns().has('createdAt'))
|
|
32
32
|
dream.createdAt = now;
|
|
33
33
|
if (!dream.dirtyAttributes().updatedAt && dream.columns().has('updatedAt'))
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = softDeleteDream;
|
|
4
|
-
const luxon_1 = require("luxon");
|
|
5
4
|
const MissingDeletedAtFieldForSoftDelete_js_1 = require("../../errors/MissingDeletedAtFieldForSoftDelete.js");
|
|
5
|
+
const DateTime_js_1 = require("../../helpers/DateTime.js");
|
|
6
6
|
const isDateTimeColumn_js_1 = require("../../helpers/db/types/isDateTimeColumn.js");
|
|
7
7
|
async function softDeleteDream(dream, txn) {
|
|
8
8
|
const deletedAtField = dream.deletedAtField;
|
|
@@ -13,7 +13,7 @@ async function softDeleteDream(dream, txn) {
|
|
|
13
13
|
let query = txn.kyselyTransaction
|
|
14
14
|
.updateTable(dream.table)
|
|
15
15
|
.where(dream.primaryKey, '=', dream.primaryKeyValue)
|
|
16
|
-
.set(dream.deletedAtField,
|
|
16
|
+
.set(dream.deletedAtField, DateTime_js_1.default.now());
|
|
17
17
|
dreamClass['sortableFields']?.forEach(sortableFieldMetadata => {
|
|
18
18
|
const positionColumn = sortableFieldMetadata.positionField;
|
|
19
19
|
query = query.set(positionColumn, null);
|
|
@@ -9,8 +9,11 @@ class DreamImporter {
|
|
|
9
9
|
const files = await Promise.all(dirents
|
|
10
10
|
.map(dirent => {
|
|
11
11
|
const res = path.resolve(dir, dirent.name);
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
return dirent.isDirectory()
|
|
13
|
+
? this.ls(res)
|
|
14
|
+
: ['.js', '.ts'].includes(path.extname(res))
|
|
15
|
+
? res
|
|
16
|
+
: null;
|
|
14
17
|
})
|
|
15
18
|
.filter(ent => ent !== null));
|
|
16
19
|
return Array.prototype.concat(...files);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_js_1 = require("
|
|
4
|
-
const index_js_2 = require("../dream-application/index.js");
|
|
3
|
+
const index_js_1 = require("../dream-application/index.js");
|
|
5
4
|
const MissingColumnEncryptionOpts_js_1 = require("../errors/encrypt/MissingColumnEncryptionOpts.js");
|
|
5
|
+
const index_js_2 = require("./index.js");
|
|
6
6
|
class InternalEncrypt {
|
|
7
7
|
static encryptColumn(data) {
|
|
8
|
-
const dreamApp =
|
|
8
|
+
const dreamApp = index_js_1.default.getOrFail();
|
|
9
9
|
const encryptOpts = dreamApp.encryption?.columns;
|
|
10
10
|
if (!encryptOpts)
|
|
11
11
|
throw new MissingColumnEncryptionOpts_js_1.default();
|
|
@@ -14,7 +14,7 @@ class InternalEncrypt {
|
|
|
14
14
|
return this.doEncryption(data, encryptOpts.current);
|
|
15
15
|
}
|
|
16
16
|
static decryptColumn(data) {
|
|
17
|
-
const dreamApp =
|
|
17
|
+
const dreamApp = index_js_1.default.getOrFail();
|
|
18
18
|
const encryptOpts = dreamApp.encryption?.columns;
|
|
19
19
|
if (!encryptOpts)
|
|
20
20
|
throw new MissingColumnEncryptionOpts_js_1.default();
|
|
@@ -23,10 +23,10 @@ class InternalEncrypt {
|
|
|
23
23
|
return this.doDecryption(data, encryptOpts.current, encryptOpts.legacy);
|
|
24
24
|
}
|
|
25
25
|
static doEncryption(data, encryptionOpts) {
|
|
26
|
-
return
|
|
26
|
+
return index_js_2.default.encrypt(data, encryptionOpts);
|
|
27
27
|
}
|
|
28
28
|
static doDecryption(data, encryptionOpts, legacyEncryptionOpts) {
|
|
29
|
-
return
|
|
29
|
+
return index_js_2.default.decrypt(data, encryptionOpts, legacyEncryptionOpts);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.default = InternalEncrypt;
|
|
@@ -6,7 +6,7 @@ class DreamtsBuilder {
|
|
|
6
6
|
return `\
|
|
7
7
|
import * as path from 'path'
|
|
8
8
|
import { DreamApplication } from '@rvoh/dream'
|
|
9
|
-
import inflections from './inflections'
|
|
9
|
+
import inflections from './inflections.js'
|
|
10
10
|
|
|
11
11
|
export default async function (app: DreamApplication) {
|
|
12
12
|
await app.load('models', path.join(__dirname, '..', 'models'))
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const DateTime_js_1 = require("./DateTime.js");
|
|
4
4
|
class CalendarDate {
|
|
5
5
|
luxonDateTime;
|
|
6
6
|
constructor(source, month = 1, day = 1) {
|
|
7
|
-
if (source instanceof
|
|
7
|
+
if (source instanceof DateTime_js_1.default && source.isValid) {
|
|
8
8
|
const isoDate = source.toISODate();
|
|
9
|
-
this.luxonDateTime =
|
|
9
|
+
this.luxonDateTime = DateTime_js_1.default.fromISO(isoDate, { zone: 'UTC' });
|
|
10
10
|
}
|
|
11
11
|
else if (typeof source === 'number') {
|
|
12
|
-
const dateTime =
|
|
12
|
+
const dateTime = DateTime_js_1.default.utc(source, month, day);
|
|
13
13
|
this.luxonDateTime = dateTime.isValid ? dateTime : null;
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
@@ -20,25 +20,25 @@ class CalendarDate {
|
|
|
20
20
|
return new CalendarDate(dateTime);
|
|
21
21
|
}
|
|
22
22
|
static fromJSDate(javascriptDate, { zone } = {}) {
|
|
23
|
-
return new CalendarDate(
|
|
23
|
+
return new CalendarDate(DateTime_js_1.default.fromJSDate(javascriptDate, { zone }));
|
|
24
24
|
}
|
|
25
25
|
static newInvalidDate() {
|
|
26
26
|
return new CalendarDate(null);
|
|
27
27
|
}
|
|
28
28
|
static fromISO(str, { zone } = {}) {
|
|
29
29
|
if (zone)
|
|
30
|
-
return new CalendarDate(
|
|
30
|
+
return new CalendarDate(DateTime_js_1.default.fromISO(str, { zone }));
|
|
31
31
|
else
|
|
32
|
-
return new CalendarDate(
|
|
32
|
+
return new CalendarDate(DateTime_js_1.default.fromISO(str, { setZone: true }));
|
|
33
33
|
}
|
|
34
34
|
static fromSQL(str) {
|
|
35
|
-
return new CalendarDate(
|
|
35
|
+
return new CalendarDate(DateTime_js_1.default.fromSQL(str, { zone: 'UTC' }));
|
|
36
36
|
}
|
|
37
37
|
static fromObject(obj, opts) {
|
|
38
|
-
return new CalendarDate(
|
|
38
|
+
return new CalendarDate(DateTime_js_1.default.fromObject(obj, opts));
|
|
39
39
|
}
|
|
40
40
|
static today({ zone = 'UTC' } = {}) {
|
|
41
|
-
return new CalendarDate(
|
|
41
|
+
return new CalendarDate(DateTime_js_1.default.now().setZone(zone));
|
|
42
42
|
}
|
|
43
43
|
static tomorrow(options = {}) {
|
|
44
44
|
return CalendarDate.today(options).plus({ day: 1 });
|
|
@@ -128,7 +128,7 @@ class CalendarDate {
|
|
|
128
128
|
const otherDateTime = otherCalendarDate.toDateTime();
|
|
129
129
|
if (otherDateTime === null)
|
|
130
130
|
return CalendarDate.newInvalidDate();
|
|
131
|
-
return new CalendarDate(
|
|
131
|
+
return new CalendarDate(DateTime_js_1.default.max(dateTime, otherDateTime));
|
|
132
132
|
}
|
|
133
133
|
static min(calendarDate, otherCalendarDate) {
|
|
134
134
|
const dateTime = calendarDate.toDateTime();
|
|
@@ -137,7 +137,7 @@ class CalendarDate {
|
|
|
137
137
|
const otherDateTime = otherCalendarDate.toDateTime();
|
|
138
138
|
if (otherDateTime === null)
|
|
139
139
|
return CalendarDate.newInvalidDate();
|
|
140
|
-
return new CalendarDate(
|
|
140
|
+
return new CalendarDate(DateTime_js_1.default.min(dateTime, otherDateTime));
|
|
141
141
|
}
|
|
142
142
|
hasSame(otherCalendarDate, period) {
|
|
143
143
|
if (this.luxonDateTime === null)
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const DateTime_js_1 = require("./DateTime.js");
|
|
4
4
|
const EnvInternal_js_1 = require("./EnvInternal.js");
|
|
5
5
|
class Benchmark {
|
|
6
6
|
_start;
|
|
7
7
|
start() {
|
|
8
|
-
this._start =
|
|
8
|
+
this._start = DateTime_js_1.default.now();
|
|
9
9
|
}
|
|
10
10
|
mark(message, level = 'log') {
|
|
11
11
|
if (EnvInternal_js_1.default.isTest && !EnvInternal_js_1.default.boolean('ALLOW_BENCHMARKS'))
|
|
12
12
|
return;
|
|
13
13
|
if (!this._start)
|
|
14
14
|
this.start();
|
|
15
|
-
console[level](message,
|
|
15
|
+
console[level](message, DateTime_js_1.default.now().diff(this._start, 'milliseconds').milliseconds);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.default = Benchmark;
|
|
@@ -22,16 +22,15 @@ class SchemaBuilder {
|
|
|
22
22
|
? `\
|
|
23
23
|
import {
|
|
24
24
|
${imports.sort().join(',\n ')}
|
|
25
|
-
} from './db'`
|
|
25
|
+
} from './db.js'`
|
|
26
26
|
: '';
|
|
27
27
|
const calendarDateImportStatement = EnvInternal_js_1.default.boolean('DREAM_CORE_DEVELOPMENT')
|
|
28
|
-
? "import CalendarDate from '../../src/helpers/CalendarDate'"
|
|
29
|
-
: "import { CalendarDate } from '@rvoh/dream'";
|
|
28
|
+
? "import CalendarDate from '../../src/helpers/CalendarDate.js'\nimport DateTime from '../../src/helpers/DateTime.js'"
|
|
29
|
+
: "import { CalendarDate, DateTime } from '@rvoh/dream'";
|
|
30
30
|
const dreamApp = index_js_2.default.getOrFail();
|
|
31
31
|
const newSchemaFileContents = `\
|
|
32
32
|
${(0, autogeneratedFileMessage_js_1.default)()}
|
|
33
33
|
${calendarDateImportStatement}
|
|
34
|
-
import { DateTime } from 'luxon'
|
|
35
34
|
${importStr}
|
|
36
35
|
|
|
37
36
|
${schemaConstContent}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeUnsupportedByClone = void 0;
|
|
4
4
|
exports.default = cloneDeepSafe;
|
|
5
|
-
const luxon_1 = require("luxon");
|
|
6
5
|
const ops_statement_js_1 = require("../ops/ops-statement.js");
|
|
7
6
|
const CalendarDate_js_1 = require("./CalendarDate.js");
|
|
7
|
+
const DateTime_js_1 = require("./DateTime.js");
|
|
8
8
|
const range_js_1 = require("./range.js");
|
|
9
9
|
const typechecks_js_1 = require("./typechecks.js");
|
|
10
10
|
/**
|
|
@@ -28,7 +28,7 @@ function cloneDeepSafe(original) {
|
|
|
28
28
|
return original;
|
|
29
29
|
if (['number', 'boolean', 'bigint', 'symbol'].includes(typeof original))
|
|
30
30
|
return original;
|
|
31
|
-
if (original instanceof
|
|
31
|
+
if (original instanceof DateTime_js_1.default)
|
|
32
32
|
return original;
|
|
33
33
|
if (original instanceof CalendarDate_js_1.default)
|
|
34
34
|
return original;
|
|
@@ -6,8 +6,8 @@ exports.findCorrespondingArrayOid = findCorrespondingArrayOid;
|
|
|
6
6
|
exports.parsePostgresDate = parsePostgresDate;
|
|
7
7
|
exports.parsePostgresDatetime = parsePostgresDatetime;
|
|
8
8
|
exports.parsePostgresDecimal = parsePostgresDecimal;
|
|
9
|
-
const luxon_1 = require("luxon");
|
|
10
9
|
const CalendarDate_js_1 = require("./CalendarDate.js");
|
|
10
|
+
const DateTime_js_1 = require("./DateTime.js");
|
|
11
11
|
async function findEnumArrayOids(kyselyDb) {
|
|
12
12
|
const result = await kyselyDb.selectFrom('pg_type').select('typarray').where('typtype', '=', 'e').execute();
|
|
13
13
|
return result.map(values => values.typarray);
|
|
@@ -32,7 +32,7 @@ function parsePostgresDate(dateString) {
|
|
|
32
32
|
return dateString ? CalendarDate_js_1.default.fromSQL(dateString) : dateString;
|
|
33
33
|
}
|
|
34
34
|
function parsePostgresDatetime(datetimeString) {
|
|
35
|
-
return datetimeString ?
|
|
35
|
+
return datetimeString ? DateTime_js_1.default.fromSQL(datetimeString, { zone: 'UTC' }) : datetimeString;
|
|
36
36
|
}
|
|
37
37
|
function parsePostgresDecimal(numberString) {
|
|
38
38
|
return numberString ? parseFloat(numberString) : numberString;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = hyphenize;
|
|
4
|
-
const stringCasing_js_1 = require("./stringCasing.js");
|
|
5
4
|
const snakeify_js_1 = require("./snakeify.js");
|
|
5
|
+
const stringCasing_js_1 = require("./stringCasing.js");
|
|
6
6
|
function hyphenize(target) {
|
|
7
7
|
return (0, stringCasing_js_1.default)(target, hyphenizeString);
|
|
8
8
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const dotenv = require("dotenv");
|
|
4
4
|
const EnvInternal_js_1 = require("./EnvInternal.js");
|
|
5
|
-
const node_url_1 = require("node:url");
|
|
6
5
|
const node_path_1 = require("node:path");
|
|
6
|
+
const node_url_1 = require("node:url");
|
|
7
7
|
let finalDirname;
|
|
8
8
|
if (typeof importMeta !== 'undefined') {
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = loadRepl;
|
|
4
4
|
require("./loadEnv.js");
|
|
5
|
-
const luxon_1 = require("luxon");
|
|
6
5
|
const index_js_1 = require("../dream-application/index.js");
|
|
7
6
|
const index_js_2 = require("../encrypt/index.js");
|
|
8
7
|
const index_js_3 = require("../ops/index.js");
|
|
9
8
|
const CalendarDate_js_1 = require("./CalendarDate.js");
|
|
9
|
+
const DateTime_js_1 = require("./DateTime.js");
|
|
10
10
|
const pascalizePath_js_1 = require("./pascalizePath.js");
|
|
11
11
|
function loadRepl(context) {
|
|
12
12
|
const dreamApp = index_js_1.default.getOrFail();
|
|
13
|
-
context.DateTime =
|
|
13
|
+
context.DateTime = DateTime_js_1.default;
|
|
14
14
|
context.CalendarDate = CalendarDate_js_1.default;
|
|
15
15
|
context.Encrypt = index_js_2.default;
|
|
16
16
|
context.ops = index_js_3.default;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = pascalize;
|
|
4
|
-
const stringCasing_js_1 = require("./stringCasing.js");
|
|
5
4
|
const camelize_js_1 = require("./camelize.js");
|
|
6
5
|
const capitalize_js_1 = require("./capitalize.js");
|
|
6
|
+
const stringCasing_js_1 = require("./stringCasing.js");
|
|
7
7
|
function pascalize(target) {
|
|
8
8
|
return (0, stringCasing_js_1.default)(target, pascalizeString);
|
|
9
9
|
}
|
|
@@ -28,11 +28,11 @@ function default_1(originDreamPathType, destinationDreamPathType, fullyQualified
|
|
|
28
28
|
case 'db':
|
|
29
29
|
return destinationPath;
|
|
30
30
|
case 'factories':
|
|
31
|
-
return `${destinationPath}${fullyQualifiedDestinationModelName}Factory`;
|
|
31
|
+
return `${destinationPath}${fullyQualifiedDestinationModelName}Factory.js`;
|
|
32
32
|
case 'serializers':
|
|
33
|
-
return `${destinationPath}${fullyQualifiedDestinationModelName}Serializer`;
|
|
33
|
+
return `${destinationPath}${fullyQualifiedDestinationModelName}Serializer.js`;
|
|
34
34
|
default:
|
|
35
|
-
return `${destinationPath}${fullyQualifiedDestinationModelName}`;
|
|
35
|
+
return `${destinationPath}${fullyQualifiedDestinationModelName}.js`;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
function dreamPathTypeRelativePath(originDreamPathType, destinationDreamPathType) {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = snakeify;
|
|
4
4
|
exports.snakeifyString = snakeifyString;
|
|
5
|
-
const stringCasing_js_1 = require("./stringCasing.js");
|
|
6
5
|
const camelize_js_1 = require("./camelize.js");
|
|
6
|
+
const stringCasing_js_1 = require("./stringCasing.js");
|
|
7
7
|
function snakeify(target) {
|
|
8
8
|
return (0, stringCasing_js_1.default)(target, snakeifyString);
|
|
9
9
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = sqlAttributes;
|
|
4
|
-
const luxon_1 = require("luxon");
|
|
5
4
|
const CalendarDate_js_1 = require("./CalendarDate.js");
|
|
5
|
+
const DateTime_js_1 = require("./DateTime.js");
|
|
6
6
|
const isDateTimeColumn_js_1 = require("./db/types/isDateTimeColumn.js");
|
|
7
7
|
const typechecks_js_1 = require("./typechecks.js");
|
|
8
8
|
function sqlAttributes(dream) {
|
|
@@ -10,8 +10,8 @@ function sqlAttributes(dream) {
|
|
|
10
10
|
return Object.keys(attributes).reduce((result, key) => {
|
|
11
11
|
let val = attributes[key];
|
|
12
12
|
if ((0, typechecks_js_1.isString)(val) && (0, isDateTimeColumn_js_1.default)(dream.constructor, key))
|
|
13
|
-
val =
|
|
14
|
-
if (val instanceof
|
|
13
|
+
val = DateTime_js_1.default.fromISO(val, { zone: 'UTC' });
|
|
14
|
+
if (val instanceof DateTime_js_1.default || val instanceof CalendarDate_js_1.default) {
|
|
15
15
|
// Converting toJSDate resulted in the correct timezone, but even with process.env.TZ=UTC,
|
|
16
16
|
// Kysely inserted into the database with the machine timezone, which can shift the date
|
|
17
17
|
// (e.g., toJSDate resulted in a JS Date that formats as "1987-04-07T00:00:00.000Z", but
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = stringCase;
|
|
4
|
-
const luxon_1 = require("luxon");
|
|
5
|
-
const typechecks_js_1 = require("./typechecks.js");
|
|
6
4
|
const CalendarDate_js_1 = require("./CalendarDate.js");
|
|
5
|
+
const DateTime_js_1 = require("./DateTime.js");
|
|
6
|
+
const typechecks_js_1 = require("./typechecks.js");
|
|
7
7
|
function stringCase(target, stringCaser) {
|
|
8
8
|
if ((0, typechecks_js_1.isString)(target))
|
|
9
9
|
return stringCaser(target);
|
|
@@ -19,7 +19,7 @@ function recursiveStringCase(target, stringCaser) {
|
|
|
19
19
|
if (Array.isArray(target))
|
|
20
20
|
return target.map(s => recursiveStringCase(s, stringCaser));
|
|
21
21
|
if ((0, typechecks_js_1.isObject)(target)) {
|
|
22
|
-
if (target instanceof
|
|
22
|
+
if (target instanceof DateTime_js_1.default)
|
|
23
23
|
return target;
|
|
24
24
|
if (target instanceof CalendarDate_js_1.default)
|
|
25
25
|
return target;
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.DreamSerializer = exports.Attribute = exports.RendersOne = exports.RendersMany = exports.ops = exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = exports.uniq = exports.uncapitalize = exports.standardizeFullyQualifiedModelName = exports.sortBy = exports.snakeify = exports.serializerNameFromFullyQualifiedModelName = exports.round = exports.range = void 0;
|
|
3
|
+
exports.sharedPathPrefix = exports.relativeDreamPath = exports.dreamPath = exports.pascalize = exports.loadRepl = exports.isEmpty = exports.inferSerializerFromDreamOrViewModel = exports.inferSerializerFromDreamClassOrViewModelClass = exports.hyphenize = exports.globalClassNameFromFullyQualifiedModelName = exports.Env = exports.debug = exports.DateTime = exports.compact = exports.generateDream = exports.capitalize = exports.camelize = exports.CalendarDate = exports.Benchmark = exports.ValidationError = exports.RecordNotFound = exports.GlobalNameNotSet = exports.CreateOrFindByFailedToCreateAndFind = exports.NonLoadedAssociation = exports.Encrypt = exports.DreamConst = exports.Query = exports.DreamTransaction = exports.Dream = exports.DreamApplication = exports.lookupClassByGlobalName = exports.DreamImporter = exports.Virtual = exports.Validates = exports.Validate = exports.STI = exports.SoftDelete = exports.Scope = exports.ReplicaSafe = exports.Decorators = exports.validateTable = exports.validateColumn = exports.DreamMigrationHelpers = exports.db = exports.pgErrorType = exports.dreamDbConnections = exports.DreamDbConnection = exports.closeAllDbConnections = exports.DreamCLI = exports.DreamBin = void 0;
|
|
4
|
+
exports.DreamSerializer = exports.Attribute = exports.RendersOne = exports.RendersMany = exports.ops = exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = exports.uniq = exports.uncapitalize = exports.standardizeFullyQualifiedModelName = exports.sortBy = exports.snakeify = exports.serializerNameFromFullyQualifiedModelName = exports.round = exports.range = exports.Range = void 0;
|
|
5
5
|
var index_js_1 = require("./bin/index.js");
|
|
6
6
|
Object.defineProperty(exports, "DreamBin", { enumerable: true, get: function () { return index_js_1.default; } });
|
|
7
7
|
var index_js_2 = require("./cli/index.js");
|
|
8
8
|
Object.defineProperty(exports, "DreamCLI", { enumerable: true, get: function () { return index_js_2.default; } });
|
|
9
9
|
var DreamDbConnection_js_1 = require("./db/DreamDbConnection.js");
|
|
10
10
|
Object.defineProperty(exports, "closeAllDbConnections", { enumerable: true, get: function () { return DreamDbConnection_js_1.closeAllDbConnections; } });
|
|
11
|
+
Object.defineProperty(exports, "DreamDbConnection", { enumerable: true, get: function () { return DreamDbConnection_js_1.default; } });
|
|
11
12
|
Object.defineProperty(exports, "dreamDbConnections", { enumerable: true, get: function () { return DreamDbConnection_js_1.dreamDbConnections; } });
|
|
12
13
|
var errors_js_1 = require("./db/errors.js");
|
|
13
14
|
Object.defineProperty(exports, "pgErrorType", { enumerable: true, get: function () { return errors_js_1.pgErrorType; } });
|
|
@@ -19,8 +20,6 @@ var validateColumn_js_1 = require("./db/validators/validateColumn.js");
|
|
|
19
20
|
Object.defineProperty(exports, "validateColumn", { enumerable: true, get: function () { return validateColumn_js_1.default; } });
|
|
20
21
|
var validateTable_js_1 = require("./db/validators/validateTable.js");
|
|
21
22
|
Object.defineProperty(exports, "validateTable", { enumerable: true, get: function () { return validateTable_js_1.default; } });
|
|
22
|
-
var DreamDbConnection_js_2 = require("./db/DreamDbConnection.js");
|
|
23
|
-
Object.defineProperty(exports, "DreamDbConnection", { enumerable: true, get: function () { return DreamDbConnection_js_2.default; } });
|
|
24
23
|
var Decorators_js_1 = require("./decorators/Decorators.js");
|
|
25
24
|
Object.defineProperty(exports, "Decorators", { enumerable: true, get: function () { return Decorators_js_1.default; } });
|
|
26
25
|
var ReplicaSafe_js_1 = require("./decorators/ReplicaSafe.js");
|
|
@@ -75,6 +74,8 @@ var generateDream_js_1 = require("./helpers/cli/generateDream.js");
|
|
|
75
74
|
Object.defineProperty(exports, "generateDream", { enumerable: true, get: function () { return generateDream_js_1.default; } });
|
|
76
75
|
var compact_js_1 = require("./helpers/compact.js");
|
|
77
76
|
Object.defineProperty(exports, "compact", { enumerable: true, get: function () { return compact_js_1.default; } });
|
|
77
|
+
var DateTime_js_1 = require("./helpers/DateTime.js");
|
|
78
|
+
Object.defineProperty(exports, "DateTime", { enumerable: true, get: function () { return DateTime_js_1.default; } });
|
|
78
79
|
var debug_js_1 = require("./helpers/debug.js");
|
|
79
80
|
Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return debug_js_1.default; } });
|
|
80
81
|
var Env_js_1 = require("./helpers/Env.js");
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const luxon_1 = require("luxon");
|
|
4
3
|
const index_js_1 = require("../dream-application/index.js");
|
|
5
4
|
const types_js_1 = require("../dream/types.js");
|
|
6
5
|
const GlobalNameNotSet_js_1 = require("../errors/dream-application/GlobalNameNotSet.js");
|
|
@@ -8,6 +7,7 @@ const MissingSerializersDefinition_js_1 = require("../errors/MissingSerializersD
|
|
|
8
7
|
const FailedToRenderThroughAssociationForSerializer_js_1 = require("../errors/serializers/FailedToRenderThroughAssociationForSerializer.js");
|
|
9
8
|
const camelize_js_1 = require("../helpers/camelize.js");
|
|
10
9
|
const compact_js_1 = require("../helpers/compact.js");
|
|
10
|
+
const DateTime_js_1 = require("../helpers/DateTime.js");
|
|
11
11
|
const inferSerializerFromDreamOrViewModel_js_1 = require("../helpers/inferSerializerFromDreamOrViewModel.js");
|
|
12
12
|
const round_js_1 = require("../helpers/round.js");
|
|
13
13
|
const snakeify_js_1 = require("../helpers/snakeify.js");
|
|
@@ -153,7 +153,7 @@ class DreamSerializer {
|
|
|
153
153
|
case 'date-time':
|
|
154
154
|
dateValue = this.getAttributeValue(attributeStatement);
|
|
155
155
|
returnObj[fieldWithCasing] = dateValue?.toISO()
|
|
156
|
-
?
|
|
156
|
+
? DateTime_js_1.default.fromISO(dateValue.toISO()).toISO()
|
|
157
157
|
: null;
|
|
158
158
|
break;
|
|
159
159
|
case 'decimal':
|
package/dist/esm/src/Dream.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
2
1
|
import { pgErrorType } from './db/errors.js';
|
|
3
2
|
import db from './db/index.js';
|
|
4
3
|
import associationToGetterSetterProp from './decorators/associations/associationToGetterSetterProp.js';
|
|
@@ -37,6 +36,7 @@ import MissingTable from './errors/MissingTable.js';
|
|
|
37
36
|
import NonExistentScopeProvidedToResort from './errors/NonExistentScopeProvidedToResort.js';
|
|
38
37
|
import CalendarDate from './helpers/CalendarDate.js';
|
|
39
38
|
import cloneDeepSafe from './helpers/cloneDeepSafe.js';
|
|
39
|
+
import DateTime from './helpers/DateTime.js';
|
|
40
40
|
import cachedTypeForAttribute from './helpers/db/cachedTypeForAttribute.js';
|
|
41
41
|
import isJsonColumn from './helpers/db/types/isJsonColumn.js';
|
|
42
42
|
import inferSerializerFromDreamOrViewModel from './helpers/inferSerializerFromDreamOrViewModel.js';
|
|
@@ -445,8 +445,12 @@ export default class Dream {
|
|
|
445
445
|
* @returns A subset of columns for the given dream class
|
|
446
446
|
*/
|
|
447
447
|
static paramSafeColumnsOrFallback() {
|
|
448
|
-
|
|
448
|
+
let defaultParams = this.defaultParamSafeColumns();
|
|
449
449
|
const userDefinedParams = this.prototype.paramSafeColumns;
|
|
450
|
+
const userDefinedUnsafeParams = this.prototype.paramUnsafeColumns;
|
|
451
|
+
if (Array.isArray(userDefinedUnsafeParams)) {
|
|
452
|
+
defaultParams = defaultParams.filter(param => !userDefinedUnsafeParams.includes(param));
|
|
453
|
+
}
|
|
450
454
|
if (Array.isArray(userDefinedParams)) {
|
|
451
455
|
return userDefinedParams.filter(param => defaultParams.includes(param));
|
|
452
456
|
}
|