@rvoh/dream 0.37.4 → 0.39.0
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 +15 -11
- package/dist/cjs/src/bin/helpers/sync.js +3 -3
- package/dist/cjs/src/bin/index.js +1 -1
- package/dist/cjs/src/cli/index.js +18 -14
- package/dist/cjs/src/db/DreamDbConnection.js +1 -1
- package/dist/cjs/src/decorators/field/association/BelongsTo.js +1 -1
- package/dist/cjs/src/decorators/field/association/HasMany.js +1 -1
- package/dist/cjs/src/decorators/field/association/HasOne.js +1 -1
- package/dist/cjs/src/dream/Query.js +1 -1
- package/dist/cjs/src/dream/internal/executeDatabaseQuery.js +1 -1
- package/dist/cjs/src/dream-app/cache.js +13 -0
- package/dist/cjs/src/{dream-application → dream-app}/helpers/DreamImporter.js +2 -2
- package/dist/cjs/src/{dream-application → dream-app}/helpers/importers/importSerializers.js +1 -1
- package/dist/cjs/src/{dream-application → dream-app}/index.js +20 -17
- package/dist/cjs/src/encrypt/InternalEncrypt.js +1 -1
- package/dist/cjs/src/errors/{dream-application/DreamApplicationInitMissingCallToLoadModels.js → dream-app/DreamAppInitMissingCallToLoadModels.js} +4 -4
- package/dist/cjs/src/errors/{dream-application/DreamApplicationInitMissingMissingProjectRoot.js → dream-app/DreamAppInitMissingMissingProjectRoot.js} +4 -4
- package/dist/cjs/src/errors/encrypt/MissingColumnEncryptionOpts.js +1 -1
- package/dist/cjs/src/errors/schema-builder/FailedToIdentifyAssociation.js +1 -1
- package/dist/cjs/src/helpers/cli/SchemaBuilder.js +3 -3
- package/dist/cjs/src/helpers/cli/generateDream.js +1 -1
- package/dist/cjs/src/helpers/cli/generateFactory.js +1 -1
- package/dist/cjs/src/helpers/cli/generateMigration.js +2 -2
- package/dist/cjs/src/helpers/cli/generateSerializer.js +1 -1
- package/dist/cjs/src/helpers/cli/generateUnitSpec.js +1 -1
- package/dist/cjs/src/helpers/db/createDb.js +1 -1
- package/dist/cjs/src/helpers/db/dropDb.js +6 -6
- package/dist/cjs/src/helpers/db/loadPgClient.js +1 -1
- package/dist/cjs/src/helpers/db/primaryKeyType.js +1 -1
- package/dist/cjs/src/helpers/db/runMigration.js +13 -13
- package/dist/cjs/src/helpers/getFiles.js +2 -2
- package/dist/cjs/src/helpers/inferSerializerFromDreamOrViewModel.js +1 -1
- package/dist/cjs/src/helpers/loadRepl.js +1 -1
- package/dist/cjs/src/helpers/path/dreamFileAndDirPaths.js +2 -2
- package/dist/cjs/src/helpers/path/dreamPath.js +1 -1
- package/dist/cjs/src/index.js +6 -6
- package/dist/cjs/src/serializer/index.js +2 -2
- package/dist/esm/src/Dream.js +15 -11
- package/dist/esm/src/bin/helpers/sync.js +4 -4
- package/dist/esm/src/bin/index.js +6 -6
- package/dist/esm/src/cli/index.js +18 -14
- package/dist/esm/src/db/DreamDbConnection.js +4 -4
- package/dist/esm/src/decorators/field/association/BelongsTo.js +1 -1
- package/dist/esm/src/decorators/field/association/HasMany.js +1 -1
- package/dist/esm/src/decorators/field/association/HasOne.js +1 -1
- package/dist/esm/src/dream/Query.js +1 -1
- package/dist/esm/src/dream/internal/executeDatabaseQuery.js +2 -2
- package/dist/esm/src/dream-app/cache.js +9 -0
- package/dist/esm/src/{dream-application → dream-app}/helpers/DreamImporter.js +2 -2
- package/dist/esm/src/{dream-application → dream-app}/helpers/importers/importSerializers.js +1 -1
- package/dist/esm/src/{dream-application → dream-app}/index.js +20 -17
- package/dist/esm/src/encrypt/InternalEncrypt.js +3 -3
- package/dist/esm/src/errors/{dream-application/DreamApplicationInitMissingCallToLoadModels.js → dream-app/DreamAppInitMissingCallToLoadModels.js} +3 -3
- package/dist/esm/src/errors/{dream-application/DreamApplicationInitMissingMissingProjectRoot.js → dream-app/DreamAppInitMissingMissingProjectRoot.js} +3 -3
- package/dist/esm/src/errors/encrypt/MissingColumnEncryptionOpts.js +1 -1
- package/dist/esm/src/errors/schema-builder/FailedToIdentifyAssociation.js +2 -2
- package/dist/esm/src/helpers/cli/SchemaBuilder.js +9 -9
- package/dist/esm/src/helpers/cli/generateDream.js +1 -1
- package/dist/esm/src/helpers/cli/generateFactory.js +1 -1
- package/dist/esm/src/helpers/cli/generateMigration.js +2 -2
- package/dist/esm/src/helpers/cli/generateSerializer.js +1 -1
- package/dist/esm/src/helpers/cli/generateUnitSpec.js +1 -1
- package/dist/esm/src/helpers/db/createDb.js +2 -2
- package/dist/esm/src/helpers/db/dropDb.js +4 -4
- package/dist/esm/src/helpers/db/loadPgClient.js +2 -2
- package/dist/esm/src/helpers/db/primaryKeyType.js +2 -2
- package/dist/esm/src/helpers/db/runMigration.js +8 -8
- package/dist/esm/src/helpers/getFiles.js +2 -2
- package/dist/esm/src/helpers/inferSerializerFromDreamOrViewModel.js +2 -2
- package/dist/esm/src/helpers/loadRepl.js +2 -2
- package/dist/esm/src/helpers/path/dreamFileAndDirPaths.js +3 -3
- package/dist/esm/src/helpers/path/dreamPath.js +2 -2
- package/dist/esm/src/index.js +4 -4
- package/dist/esm/src/serializer/index.js +3 -3
- package/dist/types/src/Dream.d.ts +15 -11
- package/dist/types/src/cli/index.d.ts +5 -5
- package/dist/types/src/dream/Query.d.ts +1 -1
- package/dist/types/src/dream-app/cache.d.ts +3 -0
- package/dist/types/src/{dream-application → dream-app}/index.d.ts +19 -18
- package/dist/types/src/errors/dream-app/DreamAppInitMissingCallToLoadModels.d.ts +3 -0
- package/dist/types/src/errors/dream-app/DreamAppInitMissingMissingProjectRoot.d.ts +3 -0
- package/dist/types/src/helpers/path/dreamPath.d.ts +1 -1
- package/dist/types/src/index.d.ts +4 -4
- 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/Decorators.html +19 -19
- package/docs/classes/Dream.html +170 -163
- package/docs/classes/DreamApp.html +42 -0
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamLogos.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializer.html +2 -2
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/Query.html +51 -51
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/Attribute.html +1 -1
- package/docs/functions/RendersMany.html +1 -1
- package/docs/functions/RendersOne.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/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/sort.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/untypedDb.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/interfaces/AttributeStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamAppInitOptions.html +2 -0
- package/docs/interfaces/DreamAppOpts.html +8 -0
- 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 +3 -3
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DbConnectionType.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
- package/docs/types/SerializableDreamOrViewModel.html +1 -1
- package/docs/types/SerializableTypes.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModelSerializerKey.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +1 -1
- package/dist/cjs/src/dream-application/cache.js +0 -13
- package/dist/esm/src/dream-application/cache.js +0 -9
- package/dist/types/src/dream-application/cache.d.ts +0 -3
- package/dist/types/src/errors/dream-application/DreamApplicationInitMissingCallToLoadModels.d.ts +0 -3
- package/dist/types/src/errors/dream-application/DreamApplicationInitMissingMissingProjectRoot.d.ts +0 -3
- package/docs/classes/DreamApplication.html +0 -42
- package/docs/interfaces/DreamApplicationInitOptions.html +0 -2
- package/docs/interfaces/DreamApplicationOpts.html +0 -8
- /package/dist/cjs/src/{dream-application → dream-app}/helpers/globalModelKeyFromPath.js +0 -0
- /package/dist/cjs/src/{dream-application → dream-app}/helpers/globalSerializerKeyFromPath.js +0 -0
- /package/dist/cjs/src/{dream-application → dream-app}/helpers/importers/importModels.js +0 -0
- /package/dist/cjs/src/{dream-application → dream-app}/helpers/lookupClassByGlobalName.js +0 -0
- /package/dist/cjs/src/{dream-application → dream-app}/helpers/lookupModelByGlobalName.js +0 -0
- /package/dist/cjs/src/{dream-application → dream-app}/helpers/lookupModelByGlobalNameOrNames.js +0 -0
- /package/dist/cjs/src/errors/{dream-application → dream-app}/GlobalNameNotSet.js +0 -0
- /package/dist/cjs/src/errors/{dream-application → dream-app}/SerializerNameConflict.js +0 -0
- /package/dist/esm/src/{dream-application → dream-app}/helpers/globalModelKeyFromPath.js +0 -0
- /package/dist/esm/src/{dream-application → dream-app}/helpers/globalSerializerKeyFromPath.js +0 -0
- /package/dist/esm/src/{dream-application → dream-app}/helpers/importers/importModels.js +0 -0
- /package/dist/esm/src/{dream-application → dream-app}/helpers/lookupClassByGlobalName.js +0 -0
- /package/dist/esm/src/{dream-application → dream-app}/helpers/lookupModelByGlobalName.js +0 -0
- /package/dist/esm/src/{dream-application → dream-app}/helpers/lookupModelByGlobalNameOrNames.js +0 -0
- /package/dist/esm/src/errors/{dream-application → dream-app}/GlobalNameNotSet.js +0 -0
- /package/dist/esm/src/errors/{dream-application → dream-app}/SerializerNameConflict.js +0 -0
- /package/dist/types/src/{dream-application → dream-app}/helpers/DreamImporter.d.ts +0 -0
- /package/dist/types/src/{dream-application → dream-app}/helpers/globalModelKeyFromPath.d.ts +0 -0
- /package/dist/types/src/{dream-application → dream-app}/helpers/globalSerializerKeyFromPath.d.ts +0 -0
- /package/dist/types/src/{dream-application → dream-app}/helpers/importers/importModels.d.ts +0 -0
- /package/dist/types/src/{dream-application → dream-app}/helpers/importers/importSerializers.d.ts +0 -0
- /package/dist/types/src/{dream-application → dream-app}/helpers/lookupClassByGlobalName.d.ts +0 -0
- /package/dist/types/src/{dream-application → dream-app}/helpers/lookupModelByGlobalName.d.ts +0 -0
- /package/dist/types/src/{dream-application → dream-app}/helpers/lookupModelByGlobalNameOrNames.d.ts +0 -0
- /package/dist/types/src/errors/{dream-application → dream-app}/GlobalNameNotSet.d.ts +0 -0
- /package/dist/types/src/errors/{dream-application → dream-app}/SerializerNameConflict.d.ts +0 -0
package/dist/cjs/src/Dream.js
CHANGED
|
@@ -36,7 +36,7 @@ const NonLoadedAssociation_js_1 = require("./errors/associations/NonLoadedAssoci
|
|
|
36
36
|
const CannotCallUndestroyOnANonSoftDeleteModel_js_1 = require("./errors/CannotCallUndestroyOnANonSoftDeleteModel.js");
|
|
37
37
|
const ConstructorOnlyForInternalUse_js_1 = require("./errors/ConstructorOnlyForInternalUse.js");
|
|
38
38
|
const CreateOrFindByFailedToCreateAndFind_js_1 = require("./errors/CreateOrFindByFailedToCreateAndFind.js");
|
|
39
|
-
const GlobalNameNotSet_js_1 = require("./errors/dream-
|
|
39
|
+
const GlobalNameNotSet_js_1 = require("./errors/dream-app/GlobalNameNotSet.js");
|
|
40
40
|
const DreamMissingRequiredOverride_js_1 = require("./errors/DreamMissingRequiredOverride.js");
|
|
41
41
|
const MissingSerializersDefinition_js_1 = require("./errors/MissingSerializersDefinition.js");
|
|
42
42
|
const NonExistentScopeProvidedToResort_js_1 = require("./errors/NonExistentScopeProvidedToResort.js");
|
|
@@ -415,7 +415,7 @@ class Dream {
|
|
|
415
415
|
/**
|
|
416
416
|
* @internal
|
|
417
417
|
*
|
|
418
|
-
* Used by
|
|
418
|
+
* Used by DreamApp during the load process
|
|
419
419
|
* for models and serializers to assign
|
|
420
420
|
* unique global names to each model based on the file
|
|
421
421
|
* name of that model.
|
|
@@ -772,11 +772,14 @@ class Dream {
|
|
|
772
772
|
}
|
|
773
773
|
/**
|
|
774
774
|
* Returns a new instance of Query scoped to the given
|
|
775
|
-
* model class
|
|
775
|
+
* model class. Especially useful with {@link Query#toKysely}.
|
|
776
776
|
*
|
|
777
777
|
* ```ts
|
|
778
|
-
*
|
|
779
|
-
*
|
|
778
|
+
* await Balloon.query().toKysely('update').
|
|
779
|
+
* .set({
|
|
780
|
+
* multicolor: sql`array_remove(multicolor, ${colorToRemoveFromAllBalloons})`,
|
|
781
|
+
* })
|
|
782
|
+
* .execute()
|
|
780
783
|
* ```
|
|
781
784
|
*
|
|
782
785
|
* @returns A new Query instance scoped to this Dream class
|
|
@@ -786,17 +789,18 @@ class Dream {
|
|
|
786
789
|
return new Query_js_1.default(this.prototype);
|
|
787
790
|
}
|
|
788
791
|
/**
|
|
789
|
-
* @internal
|
|
790
|
-
*
|
|
791
792
|
* Returns a new instance of Query scoped to the given
|
|
792
|
-
*
|
|
793
|
+
* model class. Especially useful with {@link Query#toKysely}.
|
|
793
794
|
*
|
|
794
795
|
* ```ts
|
|
795
|
-
*
|
|
796
|
-
*
|
|
796
|
+
* await balloon.query().toKysely('update')
|
|
797
|
+
* .set({
|
|
798
|
+
* multicolor: sql`array_append(multicolor, 'red')`,
|
|
799
|
+
* })
|
|
800
|
+
* .execute()
|
|
797
801
|
* ```
|
|
798
802
|
*
|
|
799
|
-
* @returns A new Query instance scoped to this Dream
|
|
803
|
+
* @returns A new Query instance scoped to this Dream class
|
|
800
804
|
*
|
|
801
805
|
*/
|
|
802
806
|
query() {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = writeSyncFile;
|
|
4
|
-
const fs = require("fs/promises");
|
|
5
|
-
const path = require("path");
|
|
4
|
+
const fs = require("node:fs/promises");
|
|
5
|
+
const path = require("node:path");
|
|
6
6
|
const index_js_1 = require("../../cli/index.js");
|
|
7
7
|
const colorize_js_1 = require("../../cli/logger/loggable/colorize.js");
|
|
8
|
-
const index_js_2 = require("../../dream-
|
|
8
|
+
const index_js_2 = require("../../dream-app/index.js");
|
|
9
9
|
const autoGeneratedFileDisclaimer_js_1 = require("../../helpers/cli/autoGeneratedFileDisclaimer.js");
|
|
10
10
|
const compact_js_1 = require("../../helpers/compact.js");
|
|
11
11
|
const EnvInternal_js_1 = require("../../helpers/EnvInternal.js");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const index_js_1 = require("../cli/index.js");
|
|
4
|
-
const index_js_2 = require("../dream-
|
|
4
|
+
const index_js_2 = require("../dream-app/index.js");
|
|
5
5
|
const EnvInternal_js_1 = require("../helpers/EnvInternal.js");
|
|
6
6
|
const SchemaBuilder_js_1 = require("../helpers/cli/SchemaBuilder.js");
|
|
7
7
|
const generateDream_js_1 = require("../helpers/cli/generateDream.js");
|
|
@@ -10,21 +10,25 @@ class DreamCLI {
|
|
|
10
10
|
* use this method for initializing a standalone dream application. If using Psychic and Dream together,
|
|
11
11
|
* a different pattern is used, which leverages the `generateDreamCli` method instead.
|
|
12
12
|
*/
|
|
13
|
-
static provide(program, {
|
|
13
|
+
static provide(program, { initializeDreamApp, seedDb, }) {
|
|
14
14
|
program
|
|
15
15
|
.command('sync')
|
|
16
16
|
.description('sync introspects your database, updating your schema to reflect, and then syncs the new schema with the installed dream node module, allowing it provide your schema to the underlying kysely integration')
|
|
17
17
|
.action(async () => {
|
|
18
|
-
await
|
|
18
|
+
await initializeDreamApp();
|
|
19
19
|
await index_js_1.default.sync(() => { });
|
|
20
20
|
process.exit();
|
|
21
21
|
});
|
|
22
|
-
this.generateDreamCli(program, {
|
|
22
|
+
this.generateDreamCli(program, {
|
|
23
|
+
initializeDreamApp,
|
|
24
|
+
seedDb,
|
|
25
|
+
onSync: () => { },
|
|
26
|
+
});
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
29
|
* called under the hood when provisioning both psychic and dream applications.
|
|
26
30
|
*/
|
|
27
|
-
static generateDreamCli(program, {
|
|
31
|
+
static generateDreamCli(program, { initializeDreamApp, seedDb, onSync, }) {
|
|
28
32
|
program
|
|
29
33
|
.command('generate:migration')
|
|
30
34
|
.alias('g:migration')
|
|
@@ -32,7 +36,7 @@ class DreamCLI {
|
|
|
32
36
|
.argument('<migrationName>', 'end with -to-table-name to prepopulate with an alterTable command')
|
|
33
37
|
.argument('[columnsWithTypes...]', 'properties of the model column1:text/string/enum/etc. column2:text/string/enum/etc. ... columnN:text/string/enum/etc.')
|
|
34
38
|
.action(async (migrationName, columnsWithTypes) => {
|
|
35
|
-
await
|
|
39
|
+
await initializeDreamApp();
|
|
36
40
|
await index_js_1.default.generateMigration(migrationName, columnsWithTypes);
|
|
37
41
|
process.exit();
|
|
38
42
|
});
|
|
@@ -46,7 +50,7 @@ class DreamCLI {
|
|
|
46
50
|
.argument('<modelName>', 'the name of the model to create, e.g. Post or Settings/CommunicationPreferences')
|
|
47
51
|
.argument('[columnsWithTypes...]', 'properties of the model property1:text/string/enum/etc. property2:text/string/enum/etc. ... propertyN:text/string/enum/etc.')
|
|
48
52
|
.action(async (modelName, columnsWithTypes, options) => {
|
|
49
|
-
await
|
|
53
|
+
await initializeDreamApp();
|
|
50
54
|
await index_js_1.default.generateDream(modelName, columnsWithTypes, options);
|
|
51
55
|
process.exit();
|
|
52
56
|
});
|
|
@@ -60,7 +64,7 @@ class DreamCLI {
|
|
|
60
64
|
.argument('<parentModelName>', 'name of the parent model')
|
|
61
65
|
.argument('[columnsWithTypes...]', 'properties of the model property1:text/string/enum/etc. property2:text/string/enum/etc. ... propertyN:text/string/enum/etc.')
|
|
62
66
|
.action(async (childModelName, extendsWord, parentModelName, columnsWithTypes, options) => {
|
|
63
|
-
await
|
|
67
|
+
await initializeDreamApp();
|
|
64
68
|
if (extendsWord !== 'extends')
|
|
65
69
|
throw new Error('Expecting: `<child-name> extends <parent-name> <columns-and-types>');
|
|
66
70
|
await index_js_1.default.generateStiChild(childModelName, parentModelName, columnsWithTypes, options);
|
|
@@ -71,7 +75,7 @@ class DreamCLI {
|
|
|
71
75
|
.description('creates a new database, seeding from local .env or .env.test if NODE_ENV=test is set for env vars')
|
|
72
76
|
.action(async () => {
|
|
73
77
|
EnvInternal_js_1.default.setBoolean('BYPASS_DB_CONNECTIONS_DURING_INIT');
|
|
74
|
-
await
|
|
78
|
+
await initializeDreamApp({ bypassModelIntegrityCheck: true });
|
|
75
79
|
await index_js_1.default.dbCreate();
|
|
76
80
|
process.exit();
|
|
77
81
|
});
|
|
@@ -80,7 +84,7 @@ class DreamCLI {
|
|
|
80
84
|
.description('db:migrate runs any outstanding database migrations')
|
|
81
85
|
.option('--skip-sync', 'skips syncing local schema after running migrations')
|
|
82
86
|
.action(async ({ skipSync }) => {
|
|
83
|
-
await
|
|
87
|
+
await initializeDreamApp({ bypassModelIntegrityCheck: true });
|
|
84
88
|
await index_js_1.default.dbMigrate();
|
|
85
89
|
if (EnvInternal_js_1.default.isDevelopmentOrTest && !skipSync) {
|
|
86
90
|
await index_js_1.default.sync(onSync);
|
|
@@ -93,7 +97,7 @@ class DreamCLI {
|
|
|
93
97
|
.option('--steps <number>', 'number of steps back to travel', myParseInt, 1)
|
|
94
98
|
.option('--skip-sync', 'skips syncing local schema after running migrations')
|
|
95
99
|
.action(async ({ steps, skipSync }) => {
|
|
96
|
-
await
|
|
100
|
+
await initializeDreamApp({ bypassModelIntegrityCheck: true });
|
|
97
101
|
await index_js_1.default.dbRollback({ steps });
|
|
98
102
|
if (EnvInternal_js_1.default.isDevelopmentOrTest && !skipSync) {
|
|
99
103
|
await index_js_1.default.sync(onSync);
|
|
@@ -105,7 +109,7 @@ class DreamCLI {
|
|
|
105
109
|
.description('drops the database, seeding from local .env or .env.test if NODE_ENV=test is set for env vars')
|
|
106
110
|
.action(async () => {
|
|
107
111
|
EnvInternal_js_1.default.setBoolean('BYPASS_DB_CONNECTIONS_DURING_INIT');
|
|
108
|
-
await
|
|
112
|
+
await initializeDreamApp({ bypassModelIntegrityCheck: true });
|
|
109
113
|
await index_js_1.default.dbDrop();
|
|
110
114
|
process.exit();
|
|
111
115
|
});
|
|
@@ -114,11 +118,11 @@ class DreamCLI {
|
|
|
114
118
|
.description('runs db:drop (safely), then db:create, db:migrate, and db:seed')
|
|
115
119
|
.action(async () => {
|
|
116
120
|
EnvInternal_js_1.default.setBoolean('BYPASS_DB_CONNECTIONS_DURING_INIT');
|
|
117
|
-
await
|
|
121
|
+
await initializeDreamApp({ bypassModelIntegrityCheck: true });
|
|
118
122
|
await index_js_1.default.dbDrop();
|
|
119
123
|
await index_js_1.default.dbCreate();
|
|
120
124
|
EnvInternal_js_1.default.unsetBoolean('BYPASS_DB_CONNECTIONS_DURING_INIT');
|
|
121
|
-
await
|
|
125
|
+
await initializeDreamApp({ bypassModelIntegrityCheck: true });
|
|
122
126
|
await index_js_1.default.dbMigrate();
|
|
123
127
|
await index_js_1.default.sync(onSync);
|
|
124
128
|
await seedDb();
|
|
@@ -132,7 +136,7 @@ class DreamCLI {
|
|
|
132
136
|
console.log('skipping db seed for test env. To really seed for test, add DREAM_SEED_DB_IN_TEST=1');
|
|
133
137
|
return;
|
|
134
138
|
}
|
|
135
|
-
await
|
|
139
|
+
await initializeDreamApp();
|
|
136
140
|
await seedDb();
|
|
137
141
|
process.exit();
|
|
138
142
|
});
|
|
@@ -12,7 +12,7 @@ exports.closeAllDbConnections = closeAllDbConnections;
|
|
|
12
12
|
// @ts-ignore
|
|
13
13
|
const pg_1 = require("pg");
|
|
14
14
|
const kysely_1 = require("kysely");
|
|
15
|
-
const index_js_1 = require("../dream-
|
|
15
|
+
const index_js_1 = require("../dream-app/index.js");
|
|
16
16
|
let connections = {};
|
|
17
17
|
class DreamDbConnection {
|
|
18
18
|
static getConnection(connectionType) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = BelongsTo;
|
|
4
|
-
const lookupModelByGlobalNameOrNames_js_1 = require("../../../dream-
|
|
4
|
+
const lookupModelByGlobalNameOrNames_js_1 = require("../../../dream-app/helpers/lookupModelByGlobalNameOrNames.js");
|
|
5
5
|
const Validates_js_1 = require("../validation/Validates.js");
|
|
6
6
|
const shared_js_1 = require("./shared.js");
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = HasMany;
|
|
4
|
-
const lookupModelByGlobalNameOrNames_js_1 = require("../../../dream-
|
|
4
|
+
const lookupModelByGlobalNameOrNames_js_1 = require("../../../dream-app/helpers/lookupModelByGlobalNameOrNames.js");
|
|
5
5
|
const shared_js_1 = require("./shared.js");
|
|
6
6
|
/**
|
|
7
7
|
* Establishes a "HasMany" association between the base dream
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = HasOne;
|
|
4
|
-
const lookupModelByGlobalNameOrNames_js_1 = require("../../../dream-
|
|
4
|
+
const lookupModelByGlobalNameOrNames_js_1 = require("../../../dream-app/helpers/lookupModelByGlobalNameOrNames.js");
|
|
5
5
|
const shared_js_1 = require("./shared.js");
|
|
6
6
|
/**
|
|
7
7
|
* Establishes a "HasOne" association between the base dream
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = executeDatabaseQuery;
|
|
4
|
-
const index_js_1 = require("../../dream-
|
|
4
|
+
const index_js_1 = require("../../dream-app/index.js");
|
|
5
5
|
const EnvInternal_js_1 = require("../../helpers/EnvInternal.js");
|
|
6
6
|
async function executeDatabaseQuery(kyselyQuery, command) {
|
|
7
7
|
try {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cacheDreamApp = cacheDreamApp;
|
|
4
|
+
exports.getCachedDreamAppOrFail = getCachedDreamAppOrFail;
|
|
5
|
+
let _dreamApp = undefined;
|
|
6
|
+
function cacheDreamApp(dreamconf) {
|
|
7
|
+
_dreamApp = dreamconf;
|
|
8
|
+
}
|
|
9
|
+
function getCachedDreamAppOrFail() {
|
|
10
|
+
if (!_dreamApp)
|
|
11
|
+
throw new Error('Must call `initializeDreamApp` or `initializePsychicApp` before loading cached DreamApp.getOrFail()');
|
|
12
|
+
return _dreamApp;
|
|
13
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs = require("fs/promises");
|
|
4
|
-
const path = require("path");
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
const path = require("node:path");
|
|
5
5
|
class DreamImporter {
|
|
6
6
|
static async ls(dir) {
|
|
7
7
|
try {
|
|
@@ -4,7 +4,7 @@ exports.default = importSerializers;
|
|
|
4
4
|
exports.setCachedSerializers = setCachedSerializers;
|
|
5
5
|
exports.getSerializersOrFail = getSerializersOrFail;
|
|
6
6
|
exports.getSerializersOrBlank = getSerializersOrBlank;
|
|
7
|
-
const SerializerNameConflict_js_1 = require("../../../errors/dream-
|
|
7
|
+
const SerializerNameConflict_js_1 = require("../../../errors/dream-app/SerializerNameConflict.js");
|
|
8
8
|
const index_js_1 = require("../../../serializer/index.js");
|
|
9
9
|
const DreamImporter_js_1 = require("../DreamImporter.js");
|
|
10
10
|
const globalSerializerKeyFromPath_js_1 = require("../globalSerializerKeyFromPath.js");
|
|
@@ -12,8 +12,8 @@ const pg_1 = require("pg");
|
|
|
12
12
|
const index_js_1 = require("../db/index.js");
|
|
13
13
|
const validateTable_js_1 = require("../db/validators/validateTable.js");
|
|
14
14
|
const index_js_2 = require("../encrypt/index.js");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const DreamAppInitMissingCallToLoadModels_js_1 = require("../errors/dream-app/DreamAppInitMissingCallToLoadModels.js");
|
|
16
|
+
const DreamAppInitMissingMissingProjectRoot_js_1 = require("../errors/dream-app/DreamAppInitMissingMissingProjectRoot.js");
|
|
17
17
|
const customPgParsers_js_1 = require("../helpers/customPgParsers.js");
|
|
18
18
|
const DateTime_js_1 = require("../helpers/DateTime.js");
|
|
19
19
|
const EnvInternal_js_1 = require("../helpers/EnvInternal.js");
|
|
@@ -23,7 +23,7 @@ const importSerializers_js_1 = require("./helpers/importers/importSerializers.js
|
|
|
23
23
|
const pgTypes = pg_1.default.types;
|
|
24
24
|
// this needs to be done top-level to ensure proper configuration
|
|
25
25
|
DateTime_js_1.Settings.defaultZone = 'UTC';
|
|
26
|
-
class
|
|
26
|
+
class DreamApp {
|
|
27
27
|
/**
|
|
28
28
|
* initializes a new dream application and caches it for use
|
|
29
29
|
* within this processes lifecycle.
|
|
@@ -32,24 +32,24 @@ class DreamApplication {
|
|
|
32
32
|
* to be able to serve routes, perform serializer lookups,
|
|
33
33
|
* generate files, connect to the database, etc...
|
|
34
34
|
*
|
|
35
|
-
* In order for this to work properly, the
|
|
35
|
+
* In order for this to work properly, the DreamApp#init
|
|
36
36
|
* function must be called before anything else is called within
|
|
37
37
|
* Dream.
|
|
38
38
|
*/
|
|
39
39
|
static async init(cb, opts = {}, deferCb) {
|
|
40
|
-
const dreamApp = new
|
|
40
|
+
const dreamApp = new DreamApp(opts);
|
|
41
41
|
await cb(dreamApp);
|
|
42
42
|
await dreamApp.inflections?.();
|
|
43
43
|
await deferCb?.(dreamApp);
|
|
44
44
|
for (const plugin of dreamApp.plugins) {
|
|
45
45
|
await plugin(dreamApp);
|
|
46
46
|
}
|
|
47
|
-
dreamApp.
|
|
47
|
+
dreamApp.validateAppBuildIntegrity({
|
|
48
48
|
bypassModelIntegrityCheck: opts.bypassModelIntegrityCheck || false,
|
|
49
49
|
});
|
|
50
50
|
if (!dreamApp.serializers)
|
|
51
51
|
(0, importSerializers_js_1.setCachedSerializers)({});
|
|
52
|
-
(0, cache_js_1.
|
|
52
|
+
(0, cache_js_1.cacheDreamApp)(dreamApp);
|
|
53
53
|
if (!EnvInternal_js_1.default.boolean('BYPASS_DB_CONNECTIONS_DURING_INIT'))
|
|
54
54
|
await this.setDatabaseTypeParsers();
|
|
55
55
|
return dreamApp;
|
|
@@ -61,13 +61,13 @@ class DreamApplication {
|
|
|
61
61
|
* that would render it in an invalid state
|
|
62
62
|
*
|
|
63
63
|
*/
|
|
64
|
-
|
|
64
|
+
validateAppBuildIntegrity({ bypassModelIntegrityCheck }) {
|
|
65
65
|
if (!this.projectRoot)
|
|
66
|
-
throw new
|
|
66
|
+
throw new DreamAppInitMissingMissingProjectRoot_js_1.default();
|
|
67
67
|
if (!this.loadedModels)
|
|
68
|
-
throw new
|
|
68
|
+
throw new DreamAppInitMissingCallToLoadModels_js_1.default();
|
|
69
69
|
if (this.encryption?.columns?.current)
|
|
70
|
-
|
|
70
|
+
DreamApp.checkKey('columns', this.encryption.columns.current.key, this.encryption.columns.current.algorithm);
|
|
71
71
|
if (!bypassModelIntegrityCheck)
|
|
72
72
|
this.validateApplicationModels();
|
|
73
73
|
}
|
|
@@ -137,19 +137,22 @@ Try setting it to something valid, like:
|
|
|
137
137
|
* Returns the cached dream application if it has been set.
|
|
138
138
|
* If it has not been set, an exception is raised.
|
|
139
139
|
*
|
|
140
|
-
* The dream application can be set by calling
|
|
140
|
+
* The dream application can be set by calling DreamApp#init,
|
|
141
141
|
* or alternatively, if you are using Psychic along with Dream,
|
|
142
|
-
* it can be set during
|
|
142
|
+
* it can be set during PsychicApp#init, which will set caches
|
|
143
143
|
* for both the dream and psychic applications at once.
|
|
144
144
|
*/
|
|
145
145
|
static getOrFail() {
|
|
146
|
-
return (0, cache_js_1.
|
|
146
|
+
return (0, cache_js_1.getCachedDreamAppOrFail)();
|
|
147
147
|
}
|
|
148
148
|
static log(...args) {
|
|
149
|
-
this.getOrFail().logger.info(
|
|
149
|
+
this.getOrFail().logger.info(this.argsToString(args));
|
|
150
150
|
}
|
|
151
151
|
static logWithLevel(level, ...args) {
|
|
152
|
-
this.getOrFail().logger[level](
|
|
152
|
+
this.getOrFail().logger[level](this.argsToString(args));
|
|
153
|
+
}
|
|
154
|
+
static argsToString(args) {
|
|
155
|
+
return args.map(str => `${str}`).join(' ');
|
|
153
156
|
}
|
|
154
157
|
_specialHooks = {
|
|
155
158
|
dbLog: [],
|
|
@@ -313,4 +316,4 @@ Try setting it to something valid, like:
|
|
|
313
316
|
}
|
|
314
317
|
}
|
|
315
318
|
}
|
|
316
|
-
exports.default =
|
|
319
|
+
exports.default = DreamApp;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_js_1 = require("../dream-
|
|
3
|
+
const index_js_1 = require("../dream-app/index.js");
|
|
4
4
|
const MissingColumnEncryptionOpts_js_1 = require("../errors/encrypt/MissingColumnEncryptionOpts.js");
|
|
5
5
|
const index_js_2 = require("./index.js");
|
|
6
6
|
class InternalEncrypt {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class
|
|
3
|
+
class DreamAppInitMissingCallToLoadModels extends Error {
|
|
4
4
|
get message() {
|
|
5
5
|
return `
|
|
6
|
-
must load models when initializing a new
|
|
6
|
+
must load models when initializing a new DreamApp.
|
|
7
7
|
|
|
8
8
|
within conf/dream.ts, you must have a call to "#load('models', pathToModels)", i.e.
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
// conf/dream.ts
|
|
12
|
-
export default async (app:
|
|
12
|
+
export default async (app: DreamApp) => {
|
|
13
13
|
await app.load('models', path.join(__dirname, '..', 'app', 'models')
|
|
14
14
|
}
|
|
15
15
|
`;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
exports.default =
|
|
18
|
+
exports.default = DreamAppInitMissingCallToLoadModels;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class
|
|
3
|
+
class DreamAppInitMissingMissingProjectRoot extends Error {
|
|
4
4
|
get message() {
|
|
5
5
|
return `
|
|
6
|
-
must set app root when initializing a new
|
|
6
|
+
must set app root when initializing a new DreamApp.
|
|
7
7
|
|
|
8
8
|
within conf/dream.ts, you must have a call to "#set('projectRoot', pathToAppRoot), i.e.
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
// conf/dream.ts
|
|
12
|
-
export default async (app:
|
|
12
|
+
export default async (app: DreamApp) => {
|
|
13
13
|
// this should be the absolute path to the "src" folder.
|
|
14
14
|
app.set('projectRoot', path.join(__dirname, '..')
|
|
15
15
|
}
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
exports.default =
|
|
19
|
+
exports.default = DreamAppInitMissingMissingProjectRoot;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_js_1 = require("../../dream-
|
|
3
|
+
const index_js_1 = require("../../dream-app/index.js");
|
|
4
4
|
class FailedToIdentifyAssociation extends Error {
|
|
5
5
|
modelClass;
|
|
6
6
|
associationType;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs = require("fs/promises");
|
|
4
3
|
const kysely_1 = require("kysely");
|
|
5
|
-
const
|
|
4
|
+
const fs = require("node:fs/promises");
|
|
5
|
+
const path = require("node:path");
|
|
6
6
|
const dataTypes_js_1 = require("../../db/dataTypes.js");
|
|
7
7
|
const index_js_1 = require("../../db/index.js");
|
|
8
|
-
const index_js_2 = require("../../dream-
|
|
8
|
+
const index_js_2 = require("../../dream-app/index.js");
|
|
9
9
|
const constants_js_1 = require("../../dream/constants.js");
|
|
10
10
|
const FailedToIdentifyAssociation_js_1 = require("../../errors/schema-builder/FailedToIdentifyAssociation.js");
|
|
11
11
|
const camelize_js_1 = require("../camelize.js");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = generateDream;
|
|
4
|
-
const fs = require("fs/promises");
|
|
4
|
+
const fs = require("node:fs/promises");
|
|
5
5
|
const dreamFileAndDirPaths_js_1 = require("../path/dreamFileAndDirPaths.js");
|
|
6
6
|
const dreamPath_js_1 = require("../path/dreamPath.js");
|
|
7
7
|
const standardizeFullyQualifiedModelName_js_1 = require("../standardizeFullyQualifiedModelName.js");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = generateFactory;
|
|
4
|
-
const fs = require("fs/promises");
|
|
4
|
+
const fs = require("node:fs/promises");
|
|
5
5
|
const dreamFileAndDirPaths_js_1 = require("../path/dreamFileAndDirPaths.js");
|
|
6
6
|
const dreamPath_js_1 = require("../path/dreamPath.js");
|
|
7
7
|
const standardizeFullyQualifiedModelName_js_1 = require("../standardizeFullyQualifiedModelName.js");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = generateMigration;
|
|
4
|
-
const fs = require("fs/promises");
|
|
5
|
-
const path = require("path");
|
|
4
|
+
const fs = require("node:fs/promises");
|
|
5
|
+
const path = require("node:path");
|
|
6
6
|
const pluralize_esm_1 = require("pluralize-esm");
|
|
7
7
|
const generateMigrationContent_js_1 = require("../cli/generateMigrationContent.js");
|
|
8
8
|
const primaryKeyType_js_1 = require("../db/primaryKeyType.js");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = generateSerializer;
|
|
4
|
-
const fs = require("fs/promises");
|
|
4
|
+
const fs = require("node:fs/promises");
|
|
5
5
|
const dreamFileAndDirPaths_js_1 = require("../path/dreamFileAndDirPaths.js");
|
|
6
6
|
const dreamPath_js_1 = require("../path/dreamPath.js");
|
|
7
7
|
const standardizeFullyQualifiedModelName_js_1 = require("../standardizeFullyQualifiedModelName.js");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = generateUnitSpec;
|
|
4
|
-
const fs = require("fs/promises");
|
|
4
|
+
const fs = require("node:fs/promises");
|
|
5
5
|
const dreamFileAndDirPaths_js_1 = require("../path/dreamFileAndDirPaths.js");
|
|
6
6
|
const dreamPath_js_1 = require("../path/dreamPath.js");
|
|
7
7
|
const standardizeFullyQualifiedModelName_js_1 = require("../standardizeFullyQualifiedModelName.js");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = createDb;
|
|
4
|
-
const index_js_1 = require("../../dream-
|
|
4
|
+
const index_js_1 = require("../../dream-app/index.js");
|
|
5
5
|
const EnvInternal_js_1 = require("../EnvInternal.js");
|
|
6
6
|
const loadPgClient_js_1 = require("./loadPgClient.js");
|
|
7
7
|
async function createDb(connection, dbName) {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = dropDb;
|
|
4
|
-
const index_js_1 = require("../../
|
|
4
|
+
const index_js_1 = require("../../cli/index.js");
|
|
5
|
+
const index_js_2 = require("../../dream-app/index.js");
|
|
5
6
|
const EnvInternal_js_1 = require("../EnvInternal.js");
|
|
6
7
|
const loadPgClient_js_1 = require("./loadPgClient.js");
|
|
7
|
-
const index_js_2 = require("../../cli/index.js");
|
|
8
8
|
async function dropDb(connection, dbName) {
|
|
9
9
|
// this was only ever written to clear the db between tests or in development,
|
|
10
10
|
// so there is no way to drop in production
|
|
11
11
|
if (EnvInternal_js_1.default.isProduction)
|
|
12
12
|
return false;
|
|
13
|
-
const dreamApp =
|
|
13
|
+
const dreamApp = index_js_2.default.getOrFail();
|
|
14
14
|
const dbConf = dreamApp.dbConnectionConfig(connection);
|
|
15
15
|
dbName ||= dbConf.name || null;
|
|
16
16
|
if (!dbName)
|
|
@@ -20,17 +20,17 @@ async function dropDb(connection, dbName) {
|
|
|
20
20
|
await client.query(`DROP DATABASE IF EXISTS ${dbName};`);
|
|
21
21
|
}
|
|
22
22
|
async function maybeDropDuplicateDatabases(client, dbName) {
|
|
23
|
-
const parallelTests =
|
|
23
|
+
const parallelTests = index_js_2.default.getOrFail().parallelTests;
|
|
24
24
|
if (!parallelTests)
|
|
25
25
|
return;
|
|
26
26
|
if (EnvInternal_js_1.default.boolean('DREAM_CORE_DEVELOPMENT')) {
|
|
27
27
|
const replicaTestWorkerDatabaseName = `replica_test_${dbName}`;
|
|
28
|
-
|
|
28
|
+
index_js_1.default.logger.logContinueProgress(`dropping fake replica test database ${replicaTestWorkerDatabaseName}`, { logPrefix: ' ├ [db]', logPrefixColor: 'cyan' });
|
|
29
29
|
await client.query(`DROP DATABASE IF EXISTS ${replicaTestWorkerDatabaseName};`);
|
|
30
30
|
}
|
|
31
31
|
for (let i = 2; i <= parallelTests; i++) {
|
|
32
32
|
const workerDatabaseName = `${dbName}_${i}`;
|
|
33
|
-
|
|
33
|
+
index_js_1.default.logger.logContinueProgress(`dropping duplicate test database ${workerDatabaseName}`, {
|
|
34
34
|
logPrefix: ' ├ [db]',
|
|
35
35
|
logPrefixColor: 'cyan',
|
|
36
36
|
});
|
|
@@ -10,7 +10,7 @@ exports.default = loadPgClient;
|
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
11
|
// @ts-ignore
|
|
12
12
|
const pg_1 = require("pg");
|
|
13
|
-
const index_js_1 = require("../../dream-
|
|
13
|
+
const index_js_1 = require("../../dream-app/index.js");
|
|
14
14
|
async function loadPgClient({ useSystemDb } = {}) {
|
|
15
15
|
const dreamconf = index_js_1.default.getOrFail();
|
|
16
16
|
const creds = dreamconf.dbCredentials.primary;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = primaryKeyType;
|
|
4
|
-
const index_js_1 = require("../../dream-
|
|
4
|
+
const index_js_1 = require("../../dream-app/index.js");
|
|
5
5
|
const constants_js_1 = require("../../dream/constants.js");
|
|
6
6
|
function primaryKeyType() {
|
|
7
7
|
const dreamconf = index_js_1.default.getOrFail();
|