@rvoh/dream 0.35.1 → 0.35.3

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.
Files changed (189) hide show
  1. package/dist/cjs/src/Dream.js +7 -18
  2. package/dist/cjs/src/bin/helpers/sync.js +2 -3
  3. package/dist/cjs/src/bin/index.js +17 -17
  4. package/dist/cjs/src/db/DreamDbConnection.js +10 -16
  5. package/dist/cjs/src/dream-application/helpers/importers/importModels.js +3 -3
  6. package/dist/cjs/src/dream-application/index.js +22 -0
  7. package/dist/cjs/src/errors/DreamMissingRequiredOverride.js +15 -0
  8. package/dist/cjs/src/helpers/db/createDb.js +3 -3
  9. package/dist/cjs/src/helpers/db/dropDb.js +8 -5
  10. package/dist/esm/src/Dream.js +7 -18
  11. package/dist/esm/src/bin/helpers/sync.js +2 -3
  12. package/dist/esm/src/bin/index.js +17 -17
  13. package/dist/esm/src/db/DreamDbConnection.js +10 -16
  14. package/dist/esm/src/dream-application/helpers/importers/importModels.js +3 -3
  15. package/dist/esm/src/dream-application/index.js +22 -0
  16. package/dist/esm/src/errors/DreamMissingRequiredOverride.js +12 -0
  17. package/dist/esm/src/helpers/db/createDb.js +3 -3
  18. package/dist/esm/src/helpers/db/dropDb.js +8 -5
  19. package/dist/types/src/Dream.d.ts +3 -3
  20. package/dist/types/src/db/DreamDbConnection.d.ts +1 -0
  21. package/dist/types/src/dream/Query.d.ts +2 -2
  22. package/dist/types/src/dream-application/index.d.ts +5 -0
  23. package/dist/types/src/errors/DreamMissingRequiredOverride.d.ts +7 -0
  24. package/dist/types/src/types/query.d.ts +38 -0
  25. package/docs/assets/icons.js +1 -1
  26. package/docs/assets/icons.svg +1 -1
  27. package/docs/assets/main.js +1 -1
  28. package/docs/assets/navigation.js +1 -1
  29. package/docs/assets/search.js +1 -1
  30. package/docs/assets/style.css +66 -21
  31. package/docs/classes/Benchmark.html +2 -2
  32. package/docs/classes/CalendarDate.html +2 -2
  33. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +6 -5
  34. package/docs/classes/Decorators.html +19 -19
  35. package/docs/classes/Dream.html +132 -132
  36. package/docs/classes/DreamApplication.html +9 -5
  37. package/docs/classes/DreamBin.html +2 -2
  38. package/docs/classes/DreamCLI.html +4 -4
  39. package/docs/classes/DreamImporter.html +2 -2
  40. package/docs/classes/DreamLogos.html +2 -2
  41. package/docs/classes/DreamMigrationHelpers.html +7 -7
  42. package/docs/classes/DreamSerializer.html +2 -2
  43. package/docs/classes/DreamTransaction.html +2 -2
  44. package/docs/classes/Encrypt.html +2 -2
  45. package/docs/classes/Env.html +2 -2
  46. package/docs/classes/GlobalNameNotSet.html +6 -5
  47. package/docs/classes/NonLoadedAssociation.html +6 -5
  48. package/docs/classes/Query.html +51 -51
  49. package/docs/classes/Range.html +2 -2
  50. package/docs/classes/RecordNotFound.html +6 -5
  51. package/docs/classes/ValidationError.html +6 -5
  52. package/docs/functions/Attribute.html +1 -1
  53. package/docs/functions/RendersMany.html +1 -1
  54. package/docs/functions/RendersOne.html +1 -1
  55. package/docs/functions/ReplicaSafe.html +1 -1
  56. package/docs/functions/STI.html +1 -1
  57. package/docs/functions/SoftDelete.html +1 -1
  58. package/docs/functions/camelize.html +1 -1
  59. package/docs/functions/capitalize.html +1 -1
  60. package/docs/functions/closeAllDbConnections.html +1 -1
  61. package/docs/functions/compact.html +1 -1
  62. package/docs/functions/debug.html +1 -1
  63. package/docs/functions/dreamDbConnections.html +1 -1
  64. package/docs/functions/dreamPath.html +1 -1
  65. package/docs/functions/generateDream.html +1 -1
  66. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  67. package/docs/functions/hyphenize.html +1 -1
  68. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
  69. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  70. package/docs/functions/isEmpty.html +1 -1
  71. package/docs/functions/loadRepl.html +1 -1
  72. package/docs/functions/lookupClassByGlobalName.html +1 -1
  73. package/docs/functions/pascalize.html +1 -1
  74. package/docs/functions/pgErrorType.html +1 -1
  75. package/docs/functions/range-1.html +1 -1
  76. package/docs/functions/relativeDreamPath.html +1 -1
  77. package/docs/functions/round.html +1 -1
  78. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  79. package/docs/functions/sharedPathPrefix.html +1 -1
  80. package/docs/functions/snakeify.html +1 -1
  81. package/docs/functions/sort.html +1 -1
  82. package/docs/functions/sortBy.html +1 -1
  83. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  84. package/docs/functions/uncapitalize.html +1 -1
  85. package/docs/functions/uniq.html +1 -1
  86. package/docs/functions/untypedDb.html +1 -1
  87. package/docs/functions/validateColumn.html +1 -1
  88. package/docs/functions/validateTable.html +1 -1
  89. package/docs/index.html +7 -7
  90. package/docs/interfaces/AttributeStatement.html +2 -2
  91. package/docs/interfaces/DecoratorContext.html +2 -2
  92. package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
  93. package/docs/interfaces/DreamApplicationOpts.html +2 -2
  94. package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
  95. package/docs/interfaces/EncryptOptions.html +2 -2
  96. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  97. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  98. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  99. package/docs/modules.html +8 -8
  100. package/docs/types/Camelized.html +1 -1
  101. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  102. package/docs/types/DateTime.html +1 -1
  103. package/docs/types/DbConnectionType.html +1 -1
  104. package/docs/types/DreamAssociationMetadata.html +1 -1
  105. package/docs/types/DreamAttributes.html +1 -1
  106. package/docs/types/DreamClassColumn.html +1 -1
  107. package/docs/types/DreamColumn.html +1 -1
  108. package/docs/types/DreamColumnNames.html +1 -1
  109. package/docs/types/DreamLogLevel.html +1 -1
  110. package/docs/types/DreamLogger.html +1 -1
  111. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  112. package/docs/types/DreamParamSafeAttributes.html +1 -1
  113. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  114. package/docs/types/DreamSerializerKey.html +1 -1
  115. package/docs/types/DreamSerializers.html +1 -1
  116. package/docs/types/DreamTableSchema.html +1 -1
  117. package/docs/types/DreamVirtualColumns.html +1 -1
  118. package/docs/types/EncryptAlgorithm.html +1 -1
  119. package/docs/types/Hyphenized.html +1 -1
  120. package/docs/types/IdType.html +1 -1
  121. package/docs/types/OpenapiAllTypes.html +1 -1
  122. package/docs/types/OpenapiFormats.html +1 -1
  123. package/docs/types/OpenapiNumberFormats.html +1 -1
  124. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  125. package/docs/types/OpenapiSchemaArray.html +1 -1
  126. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  127. package/docs/types/OpenapiSchemaBase.html +1 -1
  128. package/docs/types/OpenapiSchemaBody.html +1 -1
  129. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  130. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  131. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  132. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  133. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  134. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  135. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  136. package/docs/types/OpenapiSchemaInteger.html +1 -1
  137. package/docs/types/OpenapiSchemaNull.html +1 -1
  138. package/docs/types/OpenapiSchemaNumber.html +1 -1
  139. package/docs/types/OpenapiSchemaObject.html +1 -1
  140. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  141. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  142. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  143. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  144. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  145. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  146. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  147. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  148. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  149. package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
  150. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  151. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  152. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  153. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  154. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  155. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  156. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  157. package/docs/types/OpenapiSchemaString.html +1 -1
  158. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  159. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  160. package/docs/types/OpenapiTypeField.html +1 -1
  161. package/docs/types/Pascalized.html +1 -1
  162. package/docs/types/PrimaryKeyType.html +1 -1
  163. package/docs/types/RoundingPrecision.html +1 -1
  164. package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
  165. package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
  166. package/docs/types/SerializableDreamOrViewModel.html +1 -1
  167. package/docs/types/SerializableTypes.html +1 -1
  168. package/docs/types/Snakeified.html +1 -1
  169. package/docs/types/Timestamp.html +1 -1
  170. package/docs/types/UpdateableAssociationProperties.html +1 -1
  171. package/docs/types/UpdateableProperties.html +1 -1
  172. package/docs/types/ValidationType.html +1 -1
  173. package/docs/types/ViewModelSerializerKey.html +1 -1
  174. package/docs/types/WhereStatementForDream.html +1 -1
  175. package/docs/types/WhereStatementForDreamClass.html +1 -1
  176. package/docs/variables/DateTime-1.html +1 -1
  177. package/docs/variables/DreamConst.html +1 -1
  178. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  179. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  180. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  181. package/docs/variables/ops.html +1 -1
  182. package/docs/variables/primaryKeyTypes.html +1 -1
  183. package/package.json +3 -3
  184. package/dist/cjs/src/db/ConnectionConfRetriever.js +0 -22
  185. package/dist/cjs/src/errors/MissingTable.js +0 -27
  186. package/dist/esm/src/db/ConnectionConfRetriever.js +0 -19
  187. package/dist/esm/src/errors/MissingTable.js +0 -24
  188. package/dist/types/src/db/ConnectionConfRetriever.d.ts +0 -6
  189. package/dist/types/src/errors/MissingTable.d.ts +0 -6
@@ -37,8 +37,8 @@ const CannotCallUndestroyOnANonSoftDeleteModel_js_1 = require("./errors/CannotCa
37
37
  const ConstructorOnlyForInternalUse_js_1 = require("./errors/ConstructorOnlyForInternalUse.js");
38
38
  const CreateOrFindByFailedToCreateAndFind_js_1 = require("./errors/CreateOrFindByFailedToCreateAndFind.js");
39
39
  const GlobalNameNotSet_js_1 = require("./errors/dream-application/GlobalNameNotSet.js");
40
+ const DreamMissingRequiredOverride_js_1 = require("./errors/DreamMissingRequiredOverride.js");
40
41
  const MissingSerializersDefinition_js_1 = require("./errors/MissingSerializersDefinition.js");
41
- const MissingTable_js_1 = require("./errors/MissingTable.js");
42
42
  const NonExistentScopeProvidedToResort_js_1 = require("./errors/NonExistentScopeProvidedToResort.js");
43
43
  const CalendarDate_js_1 = require("./helpers/CalendarDate.js");
44
44
  const cloneDeepSafe_js_1 = require("./helpers/cloneDeepSafe.js");
@@ -54,14 +54,14 @@ class Dream {
54
54
  * @internal
55
55
  *
56
56
  * This getter will throw an error when developers use .toEqual instead of
57
- * useToMatchDreamModels or useToMatchDreamModel in a jest spec. This
57
+ * useToMatchDreamModels or useToMatchDreamModel in a vite spec. This
58
58
  * must be the first getter in the class in order for this to work, so don't move it.
59
59
  *
60
60
  */
61
61
  get _useToMatchDreamModels() {
62
62
  throw new Error(`
63
63
  Hi there! It looks like you're trying to compare a Dream model in
64
- a Jest expectation using \`toEqual\`. That won't work.
64
+ a Vite expectation using \`toEqual\`. That won't work.
65
65
  Instead, use \`toMatchDreamModel\` or \`toMatchDreamModels\`.
66
66
 
67
67
  For example, instead of:
@@ -99,10 +99,10 @@ class Dream {
99
99
  */
100
100
  static globallyInitializingDecorators = false;
101
101
  get schema() {
102
- throw new Error('Must define schema getter in ApplicationModel');
102
+ throw new DreamMissingRequiredOverride_js_1.default(this.constructor, 'schema');
103
103
  }
104
104
  get globalSchema() {
105
- throw new Error('Must define schema getter in ApplicationModel');
105
+ throw new DreamMissingRequiredOverride_js_1.default(this.constructor, 'globalSchema');
106
106
  }
107
107
  /**
108
108
  * Shadows #primaryKey, a getter which can be overwritten to customize the id field
@@ -1234,18 +1234,7 @@ class Dream {
1234
1234
  * @returns A Kysely query. Depending on the type passed, it will return either a SelectQueryBuilder, DeleteQueryBuilder, UpdateQueryBuilder, or an InsertQueryBuilder
1235
1235
  */
1236
1236
  static toKysely(type) {
1237
- switch (type) {
1238
- case 'select':
1239
- return this.query().dbFor('select').selectFrom(this.table);
1240
- case 'delete':
1241
- return this.query().dbFor('delete').deleteFrom(this.table);
1242
- case 'update':
1243
- return this.query().dbFor('update').updateTable(this.table);
1244
- case 'insert':
1245
- return this.query().dbFor('insert').insertInto(this.table);
1246
- default:
1247
- throw new Error('never');
1248
- }
1237
+ return this.query().toKysely(type);
1249
1238
  }
1250
1239
  /**
1251
1240
  * Applies transaction to a new Query scoped
@@ -1748,7 +1737,7 @@ class Dream {
1748
1737
  * @returns The table name for this model
1749
1738
  */
1750
1739
  get table() {
1751
- throw new MissingTable_js_1.default(this.constructor);
1740
+ throw new DreamMissingRequiredOverride_js_1.default(this.constructor, 'table');
1752
1741
  }
1753
1742
  /**
1754
1743
  * @internal
@@ -5,17 +5,16 @@ const fs = require("fs/promises");
5
5
  const path = require("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 ConnectionConfRetriever_js_1 = require("../../db/ConnectionConfRetriever.js");
9
8
  const index_js_2 = require("../../dream-application/index.js");
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");
12
12
  const dreamPath_js_1 = require("../../helpers/path/dreamPath.js");
13
13
  const snakeify_js_1 = require("../../helpers/snakeify.js");
14
14
  const sspawn_js_1 = require("../../helpers/sspawn.js");
15
- const autoGeneratedFileDisclaimer_js_1 = require("../../helpers/cli/autoGeneratedFileDisclaimer.js");
16
15
  async function writeSyncFile() {
17
- const dbConf = new ConnectionConfRetriever_js_1.default().getConnectionConf('primary');
18
16
  const dreamApp = index_js_2.default.getOrFail();
17
+ const dbConf = dreamApp.dbConnectionConfig('primary');
19
18
  const dbSyncFilePath = path.join((0, dreamPath_js_1.default)('types'), 'db.ts');
20
19
  const absoluteDbSyncPath = path.join(dreamApp.projectRoot, dbSyncFilePath);
21
20
  await (0, sspawn_js_1.default)(`kysely-codegen --dialect=postgres --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}`, {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const index_js_1 = require("../cli/index.js");
4
- const ConnectionConfRetriever_js_1 = require("../db/ConnectionConfRetriever.js");
5
4
  const index_js_2 = require("../dream-application/index.js");
6
5
  const EnvInternal_js_1 = require("../helpers/EnvInternal.js");
7
6
  const SchemaBuilder_js_1 = require("../helpers/cli/SchemaBuilder.js");
@@ -29,8 +28,8 @@ class DreamBin {
29
28
  await new SchemaBuilder_js_1.default().build();
30
29
  }
31
30
  static async dbCreate() {
32
- const connectionRetriever = new ConnectionConfRetriever_js_1.default();
33
- const primaryDbConf = connectionRetriever.getConnectionConf('primary');
31
+ const dreamApp = index_js_2.default.getOrFail();
32
+ const primaryDbConf = dreamApp.dbConnectionConfig('primary');
34
33
  index_js_1.default.logger.logStartProgress(`creating ${primaryDbConf.name}...`);
35
34
  await (0, createDb_js_1.default)('primary');
36
35
  index_js_1.default.logger.logEndProgress();
@@ -44,8 +43,8 @@ class DreamBin {
44
43
  // }
45
44
  }
46
45
  static async dbDrop() {
47
- const connectionRetriever = new ConnectionConfRetriever_js_1.default();
48
- const primaryDbConf = connectionRetriever.getConnectionConf('primary');
46
+ const dreamApp = index_js_2.default.getOrFail();
47
+ const primaryDbConf = dreamApp.dbConnectionConfig('primary');
49
48
  index_js_1.default.logger.logStartProgress(`dropping ${primaryDbConf.name}...`);
50
49
  await (0, dropDb_js_1.default)('primary');
51
50
  index_js_1.default.logger.logEndProgress();
@@ -59,24 +58,24 @@ class DreamBin {
59
58
  // }
60
59
  }
61
60
  static async dbMigrate() {
62
- const connectionRetriever = new ConnectionConfRetriever_js_1.default();
63
- const primaryDbConf = connectionRetriever.getConnectionConf('primary');
61
+ const dreamApp = index_js_2.default.getOrFail();
62
+ const primaryDbConf = dreamApp.dbConnectionConfig('primary');
64
63
  index_js_1.default.logger.logStartProgress(`migrating ${primaryDbConf.name}...`);
65
64
  await (0, runMigration_js_1.default)({ mode: 'migrate' });
66
- await this.duplicateDatabase();
67
65
  index_js_1.default.logger.logEndProgress();
66
+ await this.duplicateDatabase();
68
67
  }
69
68
  static async dbRollback(opts) {
70
- const connectionRetriever = new ConnectionConfRetriever_js_1.default();
71
- const primaryDbConf = connectionRetriever.getConnectionConf('primary');
69
+ const dreamApp = index_js_2.default.getOrFail();
70
+ const primaryDbConf = dreamApp.dbConnectionConfig('primary');
72
71
  index_js_1.default.logger.logStartProgress(`rolling back ${primaryDbConf.name}...`);
73
72
  let step = opts.steps;
74
73
  while (step > 0) {
75
74
  await (0, runMigration_js_1.default)({ mode: 'rollback' });
76
75
  step -= 1;
77
76
  }
78
- await this.duplicateDatabase();
79
77
  index_js_1.default.logger.logEndProgress();
78
+ await this.duplicateDatabase();
80
79
  }
81
80
  static async generateDream(fullyQualifiedModelName, columnsWithTypes, options) {
82
81
  await (0, generateDream_js_1.default)({ fullyQualifiedModelName, columnsWithTypes, options });
@@ -96,26 +95,27 @@ class DreamBin {
96
95
  index_js_1.default.logger.logEndProgress();
97
96
  }
98
97
  static async duplicateDatabase() {
99
- const parallelTests = index_js_2.default.getOrFail().parallelTests;
98
+ const dreamApp = index_js_2.default.getOrFail();
99
+ const parallelTests = dreamApp.parallelTests;
100
100
  if (!parallelTests)
101
101
  return;
102
- const connectionRetriever = new ConnectionConfRetriever_js_1.default();
103
- const dbConf = connectionRetriever.getConnectionConf('primary');
102
+ index_js_1.default.logger.logStartProgress(`duplicating db for parallel tests...`);
103
+ const dbConf = dreamApp.dbConnectionConfig('primary');
104
104
  const client = await (0, loadPgClient_js_1.default)({ useSystemDb: true });
105
105
  if (EnvInternal_js_1.default.boolean('DREAM_CORE_DEVELOPMENT')) {
106
106
  const replicaTestWorkerDatabaseName = `replica_test_${dbConf.name}`;
107
- index_js_1.default.logger.logContinueProgress(`creating fake replica test database ${replicaTestWorkerDatabaseName}...`);
107
+ index_js_1.default.logger.logContinueProgress(`creating fake replica test database ${replicaTestWorkerDatabaseName}...`, { logPrefix: ' ├ [db]', logPrefixColor: 'cyan' });
108
108
  await client.query(`DROP DATABASE IF EXISTS ${replicaTestWorkerDatabaseName};`);
109
109
  await client.query(`CREATE DATABASE ${replicaTestWorkerDatabaseName} TEMPLATE ${dbConf.name};`);
110
110
  }
111
111
  for (let i = 2; i <= parallelTests; i++) {
112
112
  const workerDatabaseName = `${dbConf.name}_${i}`;
113
- console.log(`creating duplicate test database ${workerDatabaseName} for concurrent tests`);
114
- index_js_1.default.logger.logContinueProgress(`creating duplicate test database ${workerDatabaseName} for concurrent tests...`);
113
+ index_js_1.default.logger.logContinueProgress(`creating duplicate test database ${workerDatabaseName} for concurrent tests...`, { logPrefix: ' ├ [db]', logPrefixColor: 'cyan' });
115
114
  await client.query(`DROP DATABASE IF EXISTS ${workerDatabaseName};`);
116
115
  await client.query(`CREATE DATABASE ${workerDatabaseName} TEMPLATE ${dbConf.name};`);
117
116
  }
118
117
  await client.end();
118
+ index_js_1.default.logger.logEndProgress();
119
119
  }
120
120
  }
121
121
  exports.default = DreamBin;
@@ -13,16 +13,16 @@ exports.closeAllDbConnections = closeAllDbConnections;
13
13
  const pg_1 = require("pg");
14
14
  const kysely_1 = require("kysely");
15
15
  const index_js_1 = require("../dream-application/index.js");
16
- const ConnectionConfRetriever_js_1 = require("./ConnectionConfRetriever.js");
17
16
  let connections = {};
18
17
  class DreamDbConnection {
19
18
  static getConnection(connectionType) {
20
- const connectionName = getConnectionTypeName(connectionType);
19
+ const dreamApp = index_js_1.default.getOrFail();
20
+ const connectionName = this.getConnectionTypeName(connectionType);
21
21
  const connection = connections[connectionName];
22
22
  if (connection) {
23
23
  return connection;
24
24
  }
25
- const connectionConf = new ConnectionConfRetriever_js_1.default().getConnectionConf(connectionType);
25
+ const connectionConf = dreamApp.dbConnectionConfig(connectionType);
26
26
  const dbConn = new kysely_1.Kysely({
27
27
  log(event) {
28
28
  const dreamApp = index_js_1.default.getOrFail();
@@ -34,7 +34,7 @@ class DreamDbConnection {
34
34
  pool: new pg_1.default.Pool({
35
35
  user: connectionConf.user || '',
36
36
  password: connectionConf.password || '',
37
- database: getDatabaseName(connectionConf.name),
37
+ database: dreamApp.dbName(connectionType),
38
38
  host: connectionConf.host || 'localhost',
39
39
  port: connectionConf.port || 5432,
40
40
  ssl: connectionConf.useSsl ? sslConfig(connectionConf) : false,
@@ -42,7 +42,7 @@ class DreamDbConnection {
42
42
  }),
43
43
  plugins: [new kysely_1.CamelCasePlugin({ underscoreBetweenUppercaseLetters: true })],
44
44
  });
45
- connections[getConnectionTypeName(connectionType)] = dbConn;
45
+ connections[this.getConnectionTypeName(connectionType)] = dbConn;
46
46
  return dbConn;
47
47
  }
48
48
  static async dropAllConnections() {
@@ -51,19 +51,13 @@ class DreamDbConnection {
51
51
  delete connections[key];
52
52
  }
53
53
  }
54
+ static getConnectionTypeName(connectionType) {
55
+ return index_js_1.default.getOrFail().parallelDatabasesEnabled
56
+ ? `${connectionType}_${process.env.VITEST_POOL_ID}`
57
+ : connectionType;
58
+ }
54
59
  }
55
60
  exports.default = DreamDbConnection;
56
- function getConnectionTypeName(connectionType) {
57
- return parallelDatabasesEnabled() ? `${connectionType}_${process.env.JEST_WORKER_ID}` : connectionType;
58
- }
59
- function getDatabaseName(dbName) {
60
- return parallelDatabasesEnabled() ? `${dbName}_${process.env.JEST_WORKER_ID}` : dbName;
61
- }
62
- function parallelDatabasesEnabled() {
63
- return (!!index_js_1.default.getOrFail().parallelTests &&
64
- !Number.isNaN(Number(process.env.JEST_WORKER_ID)) &&
65
- Number(process.env.JEST_WORKER_ID) > 1);
66
- }
67
61
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
68
62
  function sslConfig(connectionConf) {
69
63
  // TODO: properly configure (https://rvohealth.atlassian.net/browse/PDTC-2914)
@@ -5,7 +5,7 @@ exports.setCachedModels = setCachedModels;
5
5
  exports.getModelsOrFail = getModelsOrFail;
6
6
  exports.getModelsOrBlank = getModelsOrBlank;
7
7
  const Dream_js_1 = require("../../../Dream.js");
8
- const MissingTable_js_1 = require("../../../errors/MissingTable.js");
8
+ const DreamMissingRequiredOverride_js_1 = require("../../../errors/DreamMissingRequiredOverride.js");
9
9
  const DreamImporter_js_1 = require("../DreamImporter.js");
10
10
  const globalModelKeyFromPath_js_1 = require("../globalModelKeyFromPath.js");
11
11
  let _models;
@@ -35,7 +35,7 @@ async function importModels(modelsPath, modelImportCb) {
35
35
  catch (error) {
36
36
  // ApplicationModel will automatically raise an exception here,
37
37
  // since it does not have a table.
38
- if (!(error instanceof MissingTable_js_1.default))
38
+ if (!(error instanceof DreamMissingRequiredOverride_js_1.default))
39
39
  throw error;
40
40
  }
41
41
  }
@@ -54,7 +54,7 @@ async function importModels(modelsPath, modelImportCb) {
54
54
  catch (error) {
55
55
  // ApplicationModel will automatically raise an exception here,
56
56
  // since it does not have a table.
57
- if (!(error instanceof MissingTable_js_1.default))
57
+ if (!(error instanceof DreamMissingRequiredOverride_js_1.default))
58
58
  throw error;
59
59
  }
60
60
  }
@@ -228,6 +228,28 @@ Try setting it to something valid, like:
228
228
  get serializers() {
229
229
  return (0, importSerializers_js_1.getSerializersOrFail)();
230
230
  }
231
+ dbName(connection) {
232
+ const conf = this.dbConnectionConfig(connection);
233
+ return this.parallelDatabasesEnabled ? `${conf.name}_${process.env.VITEST_POOL_ID}` : conf.name;
234
+ }
235
+ dbConnectionConfig(connection) {
236
+ const conf = this.dbCredentials?.[connection] || this.dbCredentials?.primary;
237
+ if (!conf)
238
+ throw new Error(`
239
+ Cannot find a connection config given the following connection and node environment:
240
+ connection: ${connection}
241
+ NODE_ENV: ${EnvInternal_js_1.default.nodeEnv}
242
+ `);
243
+ return conf;
244
+ }
245
+ get hasReplicaConfig() {
246
+ return !!this.dbCredentials.replica;
247
+ }
248
+ get parallelDatabasesEnabled() {
249
+ return (!!this.parallelTests &&
250
+ !Number.isNaN(Number(process.env.VITEST_POOL_ID)) &&
251
+ Number(process.env.VITEST_POOL_ID) > 1);
252
+ }
231
253
  async load(resourceType, resourcePath, importCb) {
232
254
  switch (resourceType) {
233
255
  case 'models':
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class DreamMissingRequiredOverride extends Error {
4
+ dreamClass;
5
+ methodName;
6
+ constructor(dreamClass, methodName) {
7
+ super();
8
+ this.dreamClass = dreamClass;
9
+ this.methodName = methodName;
10
+ }
11
+ get message() {
12
+ return `Dream class ${this.dreamClass.sanitizedName} missing required ${this.methodName} override.`;
13
+ }
14
+ }
15
+ exports.default = DreamMissingRequiredOverride;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = createDb;
4
- const ConnectionConfRetriever_js_1 = require("../../db/ConnectionConfRetriever.js");
4
+ const index_js_1 = require("../../dream-application/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) {
@@ -9,8 +9,8 @@ async function createDb(connection, dbName) {
9
9
  // so there is no way to drop in production
10
10
  if (EnvInternal_js_1.default.isProduction)
11
11
  return false;
12
- const connectionRetriever = new ConnectionConfRetriever_js_1.default();
13
- const dbConf = connectionRetriever.getConnectionConf(connection);
12
+ const dreamApp = index_js_1.default.getOrFail();
13
+ const dbConf = dreamApp.dbConnectionConfig(connection);
14
14
  dbName ||= dbConf.name || null;
15
15
  if (!dbName)
16
16
  throw new Error('Must either pass a dbName to the create function, or else ensure that DB_NAME is set in the env');
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = dropDb;
4
- const ConnectionConfRetriever_js_1 = require("../../db/ConnectionConfRetriever.js");
5
4
  const index_js_1 = require("../../dream-application/index.js");
6
5
  const EnvInternal_js_1 = require("../EnvInternal.js");
7
6
  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 connectionRetriever = new ConnectionConfRetriever_js_1.default();
14
- const dbConf = connectionRetriever.getConnectionConf(connection);
13
+ const dreamApp = index_js_1.default.getOrFail();
14
+ const dbConf = dreamApp.dbConnectionConfig(connection);
15
15
  dbName ||= dbConf.name || null;
16
16
  if (!dbName)
17
17
  throw new Error('Must either pass a dbName to the drop function, or else ensure that DB_NAME is set in the env');
@@ -25,12 +25,15 @@ async function maybeDropDuplicateDatabases(client, dbName) {
25
25
  return;
26
26
  if (EnvInternal_js_1.default.boolean('DREAM_CORE_DEVELOPMENT')) {
27
27
  const replicaTestWorkerDatabaseName = `replica_test_${dbName}`;
28
- console.log(`dropping fake replica test database ${replicaTestWorkerDatabaseName}`);
28
+ index_js_2.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
- console.log(`dropping duplicate test database ${workerDatabaseName}`);
33
+ index_js_2.default.logger.logContinueProgress(`dropping duplicate test database ${workerDatabaseName}`, {
34
+ logPrefix: ' ├ [db]',
35
+ logPrefixColor: 'cyan',
36
+ });
34
37
  await client.query(`DROP DATABASE IF EXISTS ${workerDatabaseName};`);
35
38
  }
36
39
  }
@@ -35,8 +35,8 @@ import CannotCallUndestroyOnANonSoftDeleteModel from './errors/CannotCallUndestr
35
35
  import ConstructorOnlyForInternalUse from './errors/ConstructorOnlyForInternalUse.js';
36
36
  import CreateOrFindByFailedToCreateAndFind from './errors/CreateOrFindByFailedToCreateAndFind.js';
37
37
  import GlobalNameNotSet from './errors/dream-application/GlobalNameNotSet.js';
38
+ import DreamMissingRequiredOverride from './errors/DreamMissingRequiredOverride.js';
38
39
  import MissingSerializer from './errors/MissingSerializersDefinition.js';
39
- import MissingTable from './errors/MissingTable.js';
40
40
  import NonExistentScopeProvidedToResort from './errors/NonExistentScopeProvidedToResort.js';
41
41
  import CalendarDate from './helpers/CalendarDate.js';
42
42
  import cloneDeepSafe from './helpers/cloneDeepSafe.js';
@@ -52,14 +52,14 @@ export default class Dream {
52
52
  * @internal
53
53
  *
54
54
  * This getter will throw an error when developers use .toEqual instead of
55
- * useToMatchDreamModels or useToMatchDreamModel in a jest spec. This
55
+ * useToMatchDreamModels or useToMatchDreamModel in a vite spec. This
56
56
  * must be the first getter in the class in order for this to work, so don't move it.
57
57
  *
58
58
  */
59
59
  get _useToMatchDreamModels() {
60
60
  throw new Error(`
61
61
  Hi there! It looks like you're trying to compare a Dream model in
62
- a Jest expectation using \`toEqual\`. That won't work.
62
+ a Vite expectation using \`toEqual\`. That won't work.
63
63
  Instead, use \`toMatchDreamModel\` or \`toMatchDreamModels\`.
64
64
 
65
65
  For example, instead of:
@@ -97,10 +97,10 @@ export default class Dream {
97
97
  */
98
98
  static globallyInitializingDecorators = false;
99
99
  get schema() {
100
- throw new Error('Must define schema getter in ApplicationModel');
100
+ throw new DreamMissingRequiredOverride(this.constructor, 'schema');
101
101
  }
102
102
  get globalSchema() {
103
- throw new Error('Must define schema getter in ApplicationModel');
103
+ throw new DreamMissingRequiredOverride(this.constructor, 'globalSchema');
104
104
  }
105
105
  /**
106
106
  * Shadows #primaryKey, a getter which can be overwritten to customize the id field
@@ -1232,18 +1232,7 @@ export default class Dream {
1232
1232
  * @returns A Kysely query. Depending on the type passed, it will return either a SelectQueryBuilder, DeleteQueryBuilder, UpdateQueryBuilder, or an InsertQueryBuilder
1233
1233
  */
1234
1234
  static toKysely(type) {
1235
- switch (type) {
1236
- case 'select':
1237
- return this.query().dbFor('select').selectFrom(this.table);
1238
- case 'delete':
1239
- return this.query().dbFor('delete').deleteFrom(this.table);
1240
- case 'update':
1241
- return this.query().dbFor('update').updateTable(this.table);
1242
- case 'insert':
1243
- return this.query().dbFor('insert').insertInto(this.table);
1244
- default:
1245
- throw new Error('never');
1246
- }
1235
+ return this.query().toKysely(type);
1247
1236
  }
1248
1237
  /**
1249
1238
  * Applies transaction to a new Query scoped
@@ -1746,7 +1735,7 @@ export default class Dream {
1746
1735
  * @returns The table name for this model
1747
1736
  */
1748
1737
  get table() {
1749
- throw new MissingTable(this.constructor);
1738
+ throw new DreamMissingRequiredOverride(this.constructor, 'table');
1750
1739
  }
1751
1740
  /**
1752
1741
  * @internal
@@ -2,17 +2,16 @@ import * as fs from 'fs/promises';
2
2
  import * as path from 'path';
3
3
  import DreamCLI from '../../cli/index.js';
4
4
  import colorize from '../../cli/logger/loggable/colorize.js';
5
- import ConnectionConfRetriever from '../../db/ConnectionConfRetriever.js';
6
5
  import DreamApplication from '../../dream-application/index.js';
6
+ import autogeneratedFileDisclaimer from '../../helpers/cli/autoGeneratedFileDisclaimer.js';
7
7
  import compact from '../../helpers/compact.js';
8
8
  import EnvInternal from '../../helpers/EnvInternal.js';
9
9
  import dreamPath from '../../helpers/path/dreamPath.js';
10
10
  import snakeify from '../../helpers/snakeify.js';
11
11
  import sspawn from '../../helpers/sspawn.js';
12
- import autogeneratedFileDisclaimer from '../../helpers/cli/autoGeneratedFileDisclaimer.js';
13
12
  export default async function writeSyncFile() {
14
- const dbConf = new ConnectionConfRetriever().getConnectionConf('primary');
15
13
  const dreamApp = DreamApplication.getOrFail();
14
+ const dbConf = dreamApp.dbConnectionConfig('primary');
16
15
  const dbSyncFilePath = path.join(dreamPath('types'), 'db.ts');
17
16
  const absoluteDbSyncPath = path.join(dreamApp.projectRoot, dbSyncFilePath);
18
17
  await sspawn(`kysely-codegen --dialect=postgres --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}`, {
@@ -1,5 +1,4 @@
1
1
  import DreamCLI from '../cli/index.js';
2
- import ConnectionConfRetriever from '../db/ConnectionConfRetriever.js';
3
2
  import DreamApplication from '../dream-application/index.js';
4
3
  import EnvInternal from '../helpers/EnvInternal.js';
5
4
  import SchemaBuilder from '../helpers/cli/SchemaBuilder.js';
@@ -27,8 +26,8 @@ export default class DreamBin {
27
26
  await new SchemaBuilder().build();
28
27
  }
29
28
  static async dbCreate() {
30
- const connectionRetriever = new ConnectionConfRetriever();
31
- const primaryDbConf = connectionRetriever.getConnectionConf('primary');
29
+ const dreamApp = DreamApplication.getOrFail();
30
+ const primaryDbConf = dreamApp.dbConnectionConfig('primary');
32
31
  DreamCLI.logger.logStartProgress(`creating ${primaryDbConf.name}...`);
33
32
  await createDb('primary');
34
33
  DreamCLI.logger.logEndProgress();
@@ -42,8 +41,8 @@ export default class DreamBin {
42
41
  // }
43
42
  }
44
43
  static async dbDrop() {
45
- const connectionRetriever = new ConnectionConfRetriever();
46
- const primaryDbConf = connectionRetriever.getConnectionConf('primary');
44
+ const dreamApp = DreamApplication.getOrFail();
45
+ const primaryDbConf = dreamApp.dbConnectionConfig('primary');
47
46
  DreamCLI.logger.logStartProgress(`dropping ${primaryDbConf.name}...`);
48
47
  await _dropDb('primary');
49
48
  DreamCLI.logger.logEndProgress();
@@ -57,24 +56,24 @@ export default class DreamBin {
57
56
  // }
58
57
  }
59
58
  static async dbMigrate() {
60
- const connectionRetriever = new ConnectionConfRetriever();
61
- const primaryDbConf = connectionRetriever.getConnectionConf('primary');
59
+ const dreamApp = DreamApplication.getOrFail();
60
+ const primaryDbConf = dreamApp.dbConnectionConfig('primary');
62
61
  DreamCLI.logger.logStartProgress(`migrating ${primaryDbConf.name}...`);
63
62
  await runMigration({ mode: 'migrate' });
64
- await this.duplicateDatabase();
65
63
  DreamCLI.logger.logEndProgress();
64
+ await this.duplicateDatabase();
66
65
  }
67
66
  static async dbRollback(opts) {
68
- const connectionRetriever = new ConnectionConfRetriever();
69
- const primaryDbConf = connectionRetriever.getConnectionConf('primary');
67
+ const dreamApp = DreamApplication.getOrFail();
68
+ const primaryDbConf = dreamApp.dbConnectionConfig('primary');
70
69
  DreamCLI.logger.logStartProgress(`rolling back ${primaryDbConf.name}...`);
71
70
  let step = opts.steps;
72
71
  while (step > 0) {
73
72
  await runMigration({ mode: 'rollback' });
74
73
  step -= 1;
75
74
  }
76
- await this.duplicateDatabase();
77
75
  DreamCLI.logger.logEndProgress();
76
+ await this.duplicateDatabase();
78
77
  }
79
78
  static async generateDream(fullyQualifiedModelName, columnsWithTypes, options) {
80
79
  await generateDream({ fullyQualifiedModelName, columnsWithTypes, options });
@@ -94,25 +93,26 @@ export default class DreamBin {
94
93
  DreamCLI.logger.logEndProgress();
95
94
  }
96
95
  static async duplicateDatabase() {
97
- const parallelTests = DreamApplication.getOrFail().parallelTests;
96
+ const dreamApp = DreamApplication.getOrFail();
97
+ const parallelTests = dreamApp.parallelTests;
98
98
  if (!parallelTests)
99
99
  return;
100
- const connectionRetriever = new ConnectionConfRetriever();
101
- const dbConf = connectionRetriever.getConnectionConf('primary');
100
+ DreamCLI.logger.logStartProgress(`duplicating db for parallel tests...`);
101
+ const dbConf = dreamApp.dbConnectionConfig('primary');
102
102
  const client = await loadPgClient({ useSystemDb: true });
103
103
  if (EnvInternal.boolean('DREAM_CORE_DEVELOPMENT')) {
104
104
  const replicaTestWorkerDatabaseName = `replica_test_${dbConf.name}`;
105
- DreamCLI.logger.logContinueProgress(`creating fake replica test database ${replicaTestWorkerDatabaseName}...`);
105
+ DreamCLI.logger.logContinueProgress(`creating fake replica test database ${replicaTestWorkerDatabaseName}...`, { logPrefix: ' ├ [db]', logPrefixColor: 'cyan' });
106
106
  await client.query(`DROP DATABASE IF EXISTS ${replicaTestWorkerDatabaseName};`);
107
107
  await client.query(`CREATE DATABASE ${replicaTestWorkerDatabaseName} TEMPLATE ${dbConf.name};`);
108
108
  }
109
109
  for (let i = 2; i <= parallelTests; i++) {
110
110
  const workerDatabaseName = `${dbConf.name}_${i}`;
111
- console.log(`creating duplicate test database ${workerDatabaseName} for concurrent tests`);
112
- DreamCLI.logger.logContinueProgress(`creating duplicate test database ${workerDatabaseName} for concurrent tests...`);
111
+ DreamCLI.logger.logContinueProgress(`creating duplicate test database ${workerDatabaseName} for concurrent tests...`, { logPrefix: ' ├ [db]', logPrefixColor: 'cyan' });
113
112
  await client.query(`DROP DATABASE IF EXISTS ${workerDatabaseName};`);
114
113
  await client.query(`CREATE DATABASE ${workerDatabaseName} TEMPLATE ${dbConf.name};`);
115
114
  }
116
115
  await client.end();
116
+ DreamCLI.logger.logEndProgress();
117
117
  }
118
118
  }
@@ -9,16 +9,16 @@
9
9
  import pg from 'pg';
10
10
  import { CamelCasePlugin, Kysely, PostgresDialect } from 'kysely';
11
11
  import DreamApplication from '../dream-application/index.js';
12
- import ConnectionConfRetriever from './ConnectionConfRetriever.js';
13
12
  let connections = {};
14
13
  export default class DreamDbConnection {
15
14
  static getConnection(connectionType) {
16
- const connectionName = getConnectionTypeName(connectionType);
15
+ const dreamApp = DreamApplication.getOrFail();
16
+ const connectionName = this.getConnectionTypeName(connectionType);
17
17
  const connection = connections[connectionName];
18
18
  if (connection) {
19
19
  return connection;
20
20
  }
21
- const connectionConf = new ConnectionConfRetriever().getConnectionConf(connectionType);
21
+ const connectionConf = dreamApp.dbConnectionConfig(connectionType);
22
22
  const dbConn = new Kysely({
23
23
  log(event) {
24
24
  const dreamApp = DreamApplication.getOrFail();
@@ -30,7 +30,7 @@ export default class DreamDbConnection {
30
30
  pool: new pg.Pool({
31
31
  user: connectionConf.user || '',
32
32
  password: connectionConf.password || '',
33
- database: getDatabaseName(connectionConf.name),
33
+ database: dreamApp.dbName(connectionType),
34
34
  host: connectionConf.host || 'localhost',
35
35
  port: connectionConf.port || 5432,
36
36
  ssl: connectionConf.useSsl ? sslConfig(connectionConf) : false,
@@ -38,7 +38,7 @@ export default class DreamDbConnection {
38
38
  }),
39
39
  plugins: [new CamelCasePlugin({ underscoreBetweenUppercaseLetters: true })],
40
40
  });
41
- connections[getConnectionTypeName(connectionType)] = dbConn;
41
+ connections[this.getConnectionTypeName(connectionType)] = dbConn;
42
42
  return dbConn;
43
43
  }
44
44
  static async dropAllConnections() {
@@ -47,17 +47,11 @@ export default class DreamDbConnection {
47
47
  delete connections[key];
48
48
  }
49
49
  }
50
- }
51
- function getConnectionTypeName(connectionType) {
52
- return parallelDatabasesEnabled() ? `${connectionType}_${process.env.JEST_WORKER_ID}` : connectionType;
53
- }
54
- function getDatabaseName(dbName) {
55
- return parallelDatabasesEnabled() ? `${dbName}_${process.env.JEST_WORKER_ID}` : dbName;
56
- }
57
- function parallelDatabasesEnabled() {
58
- return (!!DreamApplication.getOrFail().parallelTests &&
59
- !Number.isNaN(Number(process.env.JEST_WORKER_ID)) &&
60
- Number(process.env.JEST_WORKER_ID) > 1);
50
+ static getConnectionTypeName(connectionType) {
51
+ return DreamApplication.getOrFail().parallelDatabasesEnabled
52
+ ? `${connectionType}_${process.env.VITEST_POOL_ID}`
53
+ : connectionType;
54
+ }
61
55
  }
62
56
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
63
57
  function sslConfig(connectionConf) {
@@ -1,5 +1,5 @@
1
1
  import Dream from '../../../Dream.js';
2
- import MissingTable from '../../../errors/MissingTable.js';
2
+ import DreamMissingRequiredOverride from '../../../errors/DreamMissingRequiredOverride.js';
3
3
  import DreamImporter from '../DreamImporter.js';
4
4
  import globalModelKeyFromPath from '../globalModelKeyFromPath.js';
5
5
  let _models;
@@ -29,7 +29,7 @@ export default async function importModels(modelsPath, modelImportCb) {
29
29
  catch (error) {
30
30
  // ApplicationModel will automatically raise an exception here,
31
31
  // since it does not have a table.
32
- if (!(error instanceof MissingTable))
32
+ if (!(error instanceof DreamMissingRequiredOverride))
33
33
  throw error;
34
34
  }
35
35
  }
@@ -48,7 +48,7 @@ export default async function importModels(modelsPath, modelImportCb) {
48
48
  catch (error) {
49
49
  // ApplicationModel will automatically raise an exception here,
50
50
  // since it does not have a table.
51
- if (!(error instanceof MissingTable))
51
+ if (!(error instanceof DreamMissingRequiredOverride))
52
52
  throw error;
53
53
  }
54
54
  }