@rvoh/dream 0.33.0 → 0.35.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.
Files changed (212) hide show
  1. package/dist/cjs/src/Dream.js +14 -0
  2. package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +14 -0
  3. package/dist/cjs/src/dream/internal/destroyDream.js +1 -2
  4. package/dist/cjs/src/dream/internal/runHooksFor.js +66 -28
  5. package/dist/cjs/src/dream/internal/saveDream.js +2 -4
  6. package/dist/cjs/src/dream/internal/undestroyDream.js +1 -2
  7. package/dist/cjs/src/errors/associations/CannotAssociationQueryOnUnpersistedDream.js +18 -0
  8. package/dist/cjs/src/errors/associations/CannotCreateAssociationOnUnpersistedDream.js +18 -0
  9. package/dist/cjs/src/errors/associations/CannotDestroyAssociationOnUnpersistedDream.js +18 -0
  10. package/dist/cjs/src/errors/associations/CannotUpdateAssociationOnUnpersistedDream.js +18 -0
  11. package/dist/cjs/src/helpers/DreamLogos/DreamLogos.js +12 -0
  12. package/dist/cjs/src/helpers/{DreamGlam/howyadoins/whaaaaaaaaaaok.js → DreamLogos/logos.js} +2 -2
  13. package/dist/cjs/src/helpers/cli/autoGeneratedFileDisclaimer.js +2 -2
  14. package/dist/cjs/src/helpers/cli/generateDreamContent.js +2 -2
  15. package/dist/cjs/src/helpers/cli/generateSerializerContent.js +14 -6
  16. package/dist/cjs/src/index.js +5 -6
  17. package/dist/esm/src/Dream.js +14 -0
  18. package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +14 -0
  19. package/dist/esm/src/dream/internal/destroyDream.js +1 -2
  20. package/dist/esm/src/dream/internal/runHooksFor.js +66 -28
  21. package/dist/esm/src/dream/internal/saveDream.js +2 -4
  22. package/dist/esm/src/dream/internal/undestroyDream.js +1 -2
  23. package/dist/esm/src/errors/associations/CannotAssociationQueryOnUnpersistedDream.js +15 -0
  24. package/dist/esm/src/errors/associations/CannotCreateAssociationOnUnpersistedDream.js +15 -0
  25. package/dist/esm/src/errors/associations/CannotDestroyAssociationOnUnpersistedDream.js +15 -0
  26. package/dist/esm/src/errors/associations/CannotUpdateAssociationOnUnpersistedDream.js +15 -0
  27. package/dist/esm/src/helpers/DreamLogos/DreamLogos.js +9 -0
  28. package/dist/esm/src/helpers/{DreamGlam/howyadoins/whaaaaaaaaaaok.js → DreamLogos/logos.js} +1 -1
  29. package/dist/esm/src/helpers/cli/autoGeneratedFileDisclaimer.js +2 -2
  30. package/dist/esm/src/helpers/cli/generateDreamContent.js +2 -2
  31. package/dist/esm/src/helpers/cli/generateSerializerContent.js +14 -6
  32. package/dist/esm/src/index.js +3 -3
  33. package/dist/types/src/decorators/Decorators.d.ts +27 -27
  34. package/dist/types/src/errors/associations/CannotAssociationQueryOnUnpersistedDream.d.ts +7 -0
  35. package/dist/types/src/errors/associations/CannotCreateAssociationOnUnpersistedDream.d.ts +7 -0
  36. package/dist/types/src/errors/associations/CannotDestroyAssociationOnUnpersistedDream.d.ts +7 -0
  37. package/dist/types/src/errors/associations/CannotUpdateAssociationOnUnpersistedDream.d.ts +7 -0
  38. package/dist/types/src/helpers/DreamLogos/DreamLogos.d.ts +4 -0
  39. package/dist/types/src/helpers/DreamLogos/logos.d.ts +2 -0
  40. package/dist/types/src/index.d.ts +4 -3
  41. package/docs/assets/icons.js +1 -1
  42. package/docs/assets/icons.svg +1 -1
  43. package/docs/assets/main.js +1 -1
  44. package/docs/assets/navigation.js +1 -1
  45. package/docs/assets/search.js +1 -1
  46. package/docs/assets/style.css +66 -21
  47. package/docs/classes/Benchmark.html +2 -2
  48. package/docs/classes/CalendarDate.html +2 -2
  49. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +6 -5
  50. package/docs/classes/Decorators.html +38 -38
  51. package/docs/classes/Dream.html +131 -131
  52. package/docs/classes/DreamApplication.html +4 -4
  53. package/docs/classes/DreamBin.html +2 -2
  54. package/docs/classes/DreamCLI.html +4 -4
  55. package/docs/classes/DreamImporter.html +2 -2
  56. package/docs/classes/DreamLogos.html +4 -0
  57. package/docs/classes/DreamMigrationHelpers.html +7 -7
  58. package/docs/classes/DreamSerializer.html +2 -2
  59. package/docs/classes/DreamTransaction.html +2 -2
  60. package/docs/classes/Encrypt.html +2 -2
  61. package/docs/classes/Env.html +2 -2
  62. package/docs/classes/GlobalNameNotSet.html +6 -5
  63. package/docs/classes/NonLoadedAssociation.html +6 -5
  64. package/docs/classes/Query.html +51 -51
  65. package/docs/classes/Range.html +2 -2
  66. package/docs/classes/RecordNotFound.html +6 -5
  67. package/docs/classes/ValidationError.html +6 -5
  68. package/docs/functions/Attribute.html +1 -1
  69. package/docs/functions/RendersMany.html +1 -1
  70. package/docs/functions/RendersOne.html +1 -1
  71. package/docs/functions/ReplicaSafe.html +1 -1
  72. package/docs/functions/STI.html +1 -1
  73. package/docs/functions/SoftDelete.html +1 -1
  74. package/docs/functions/camelize.html +1 -1
  75. package/docs/functions/capitalize.html +1 -1
  76. package/docs/functions/closeAllDbConnections.html +1 -1
  77. package/docs/functions/compact.html +1 -1
  78. package/docs/functions/debug.html +1 -1
  79. package/docs/functions/dreamDbConnections.html +1 -1
  80. package/docs/functions/dreamPath.html +1 -1
  81. package/docs/functions/generateDream.html +1 -1
  82. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  83. package/docs/functions/hyphenize.html +1 -1
  84. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
  85. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  86. package/docs/functions/isEmpty.html +1 -1
  87. package/docs/functions/loadRepl.html +1 -1
  88. package/docs/functions/lookupClassByGlobalName.html +1 -1
  89. package/docs/functions/pascalize.html +1 -1
  90. package/docs/functions/pgErrorType.html +1 -1
  91. package/docs/functions/range-1.html +1 -1
  92. package/docs/functions/relativeDreamPath.html +1 -1
  93. package/docs/functions/round.html +1 -1
  94. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  95. package/docs/functions/sharedPathPrefix.html +1 -1
  96. package/docs/functions/snakeify.html +1 -1
  97. package/docs/functions/sort.html +1 -1
  98. package/docs/functions/sortBy.html +1 -1
  99. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  100. package/docs/functions/uncapitalize.html +1 -1
  101. package/docs/functions/uniq.html +1 -1
  102. package/docs/functions/untypedDb.html +1 -0
  103. package/docs/functions/validateColumn.html +1 -1
  104. package/docs/functions/validateTable.html +1 -1
  105. package/docs/index.html +7 -7
  106. package/docs/interfaces/AttributeStatement.html +2 -2
  107. package/docs/interfaces/DecoratorContext.html +2 -2
  108. package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
  109. package/docs/interfaces/DreamApplicationOpts.html +2 -2
  110. package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
  111. package/docs/interfaces/EncryptOptions.html +2 -2
  112. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  113. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  114. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  115. package/docs/modules.html +11 -11
  116. package/docs/types/Camelized.html +1 -1
  117. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  118. package/docs/types/DateTime.html +1 -1
  119. package/docs/types/DbConnectionType.html +1 -0
  120. package/docs/types/DreamAssociationMetadata.html +1 -1
  121. package/docs/types/DreamAttributes.html +1 -1
  122. package/docs/types/DreamClassColumn.html +1 -1
  123. package/docs/types/DreamColumn.html +1 -1
  124. package/docs/types/DreamColumnNames.html +1 -1
  125. package/docs/types/DreamLogLevel.html +1 -1
  126. package/docs/types/DreamLogger.html +1 -1
  127. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  128. package/docs/types/DreamParamSafeAttributes.html +1 -1
  129. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  130. package/docs/types/DreamSerializerKey.html +1 -1
  131. package/docs/types/DreamSerializers.html +1 -1
  132. package/docs/types/DreamTableSchema.html +1 -1
  133. package/docs/types/DreamVirtualColumns.html +1 -1
  134. package/docs/types/EncryptAlgorithm.html +1 -1
  135. package/docs/types/Hyphenized.html +1 -1
  136. package/docs/types/IdType.html +1 -1
  137. package/docs/types/OpenapiAllTypes.html +1 -1
  138. package/docs/types/OpenapiFormats.html +1 -1
  139. package/docs/types/OpenapiNumberFormats.html +1 -1
  140. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  141. package/docs/types/OpenapiSchemaArray.html +1 -1
  142. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  143. package/docs/types/OpenapiSchemaBase.html +1 -1
  144. package/docs/types/OpenapiSchemaBody.html +1 -1
  145. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  146. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  147. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  148. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  149. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  150. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  151. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  152. package/docs/types/OpenapiSchemaInteger.html +1 -1
  153. package/docs/types/OpenapiSchemaNull.html +1 -1
  154. package/docs/types/OpenapiSchemaNumber.html +1 -1
  155. package/docs/types/OpenapiSchemaObject.html +1 -1
  156. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  157. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  158. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  159. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  160. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  161. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  162. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  163. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  164. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  165. package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
  166. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  167. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  168. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  169. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  170. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  171. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  172. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  173. package/docs/types/OpenapiSchemaString.html +1 -1
  174. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  175. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  176. package/docs/types/OpenapiTypeField.html +1 -1
  177. package/docs/types/Pascalized.html +1 -1
  178. package/docs/types/PrimaryKeyType.html +1 -1
  179. package/docs/types/RoundingPrecision.html +1 -1
  180. package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
  181. package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
  182. package/docs/types/SerializableDreamOrViewModel.html +1 -1
  183. package/docs/types/SerializableTypes.html +1 -1
  184. package/docs/types/Snakeified.html +1 -1
  185. package/docs/types/Timestamp.html +1 -1
  186. package/docs/types/UpdateableAssociationProperties.html +1 -1
  187. package/docs/types/UpdateableProperties.html +1 -1
  188. package/docs/types/ValidationType.html +1 -1
  189. package/docs/types/ViewModelSerializerKey.html +1 -1
  190. package/docs/types/WhereStatementForDream.html +1 -1
  191. package/docs/types/WhereStatementForDreamClass.html +1 -1
  192. package/docs/variables/DateTime-1.html +1 -1
  193. package/docs/variables/DreamConst.html +1 -1
  194. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  195. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  196. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  197. package/docs/variables/ops.html +1 -1
  198. package/docs/variables/primaryKeyTypes.html +1 -1
  199. package/package.json +5 -5
  200. package/dist/cjs/src/dream/internal/safelyRunCommitHooks.js +0 -15
  201. package/dist/cjs/src/helpers/DreamGlam/DreamGlam.js +0 -16
  202. package/dist/cjs/src/helpers/DreamGlam/howyadoins/fluffstopherwalkin.js +0 -42
  203. package/dist/esm/src/dream/internal/safelyRunCommitHooks.js +0 -12
  204. package/dist/esm/src/helpers/DreamGlam/DreamGlam.js +0 -13
  205. package/dist/esm/src/helpers/DreamGlam/howyadoins/fluffstopherwalkin.js +0 -39
  206. package/dist/types/src/dream/internal/safelyRunCommitHooks.d.ts +0 -7
  207. package/dist/types/src/helpers/DreamGlam/DreamGlam.d.ts +0 -5
  208. package/dist/types/src/helpers/DreamGlam/howyadoins/fluffstopherwalkin.d.ts +0 -1
  209. package/dist/types/src/helpers/DreamGlam/howyadoins/whaaaaaaaaaaok.d.ts +0 -2
  210. package/docs/classes/DreamDbConnection.html +0 -4
  211. package/docs/classes/DreamGlam.html +0 -5
  212. package/docs/functions/db.html +0 -1
@@ -1,3 +1,7 @@
1
+ import CannotAssociationQueryOnUnpersistedDream from '../errors/associations/CannotAssociationQueryOnUnpersistedDream.js';
2
+ import CannotCreateAssociationOnUnpersistedDream from '../errors/associations/CannotCreateAssociationOnUnpersistedDream.js';
3
+ import CannotDestroyAssociationOnUnpersistedDream from '../errors/associations/CannotDestroyAssociationOnUnpersistedDream.js';
4
+ import CannotUpdateAssociationOnUnpersistedDream from '../errors/associations/CannotUpdateAssociationOnUnpersistedDream.js';
1
5
  import associationQuery from './internal/associations/associationQuery.js';
2
6
  import associationUpdateQuery from './internal/associations/associationUpdateQuery.js';
3
7
  import createAssociation from './internal/associations/createAssociation.js';
@@ -308,6 +312,8 @@ export default class DreamInstanceTransactionBuilder {
308
312
  * @returns A Query scoped to the specified association on the current instance
309
313
  */
310
314
  associationQuery(associationName, joinOnStatements) {
315
+ if (this.dreamInstance.isNewRecord)
316
+ throw new CannotAssociationQueryOnUnpersistedDream(this.dreamInstance, associationName);
311
317
  return associationQuery(this.dreamInstance, this.dreamTransaction, associationName, {
312
318
  joinOnStatements: joinOnStatements,
313
319
  bypassAllDefaultScopes: DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
@@ -339,6 +345,8 @@ export default class DreamInstanceTransactionBuilder {
339
345
  * @returns The number of updated records
340
346
  */
341
347
  async updateAssociation(associationName, attributes, updateAssociationOptions) {
348
+ if (this.dreamInstance.isNewRecord)
349
+ throw new CannotUpdateAssociationOnUnpersistedDream(this.dreamInstance, associationName);
342
350
  return await associationUpdateQuery(this.dreamInstance, this.dreamTransaction, associationName, {
343
351
  joinOnStatements: {
344
352
  on: updateAssociationOptions?.on,
@@ -365,6 +373,8 @@ export default class DreamInstanceTransactionBuilder {
365
373
  * @returns The created association
366
374
  */
367
375
  async createAssociation(associationName, opts = {}) {
376
+ if (this.dreamInstance.isNewRecord)
377
+ throw new CannotCreateAssociationOnUnpersistedDream(this.dreamInstance, associationName);
368
378
  return await createAssociation(this.dreamInstance, this.dreamTransaction, associationName, opts);
369
379
  }
370
380
  /**
@@ -387,6 +397,8 @@ export default class DreamInstanceTransactionBuilder {
387
397
  * @returns The number of records deleted
388
398
  */
389
399
  async destroyAssociation(associationName, options) {
400
+ if (this.dreamInstance.isNewRecord)
401
+ throw new CannotDestroyAssociationOnUnpersistedDream(this.dreamInstance, associationName);
390
402
  return await destroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
391
403
  ...destroyOptions(options),
392
404
  joinOnStatements: {
@@ -421,6 +433,8 @@ export default class DreamInstanceTransactionBuilder {
421
433
  * @returns The number of records deleted
422
434
  */
423
435
  async reallyDestroyAssociation(associationName, options) {
436
+ if (this.dreamInstance.isNewRecord)
437
+ throw new CannotDestroyAssociationOnUnpersistedDream(this.dreamInstance, associationName);
424
438
  return await destroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
425
439
  ...reallyDestroyOptions(options),
426
440
  joinOnStatements: {
@@ -1,6 +1,5 @@
1
1
  import destroyAssociatedRecords from './destroyAssociatedRecords.js';
2
2
  import runHooksFor from './runHooksFor.js';
3
- import safelyRunCommitHooks from './safelyRunCommitHooks.js';
4
3
  import softDeleteDream from './softDeleteDream.js';
5
4
  /**
6
5
  * @internal
@@ -39,7 +38,7 @@ async function destroyDreamWithTransaction(dream, txn, options) {
39
38
  await maybeDestroyDream(dream, txn, reallyDestroy);
40
39
  if (!skipHooks) {
41
40
  await runHooksFor('afterDestroy', dream, true, null, txn || undefined);
42
- await safelyRunCommitHooks(dream, 'afterDestroyCommit', true, null, txn);
41
+ await runHooksFor('afterDestroyCommit', dream, true, null, txn);
43
42
  }
44
43
  if (shouldSoftDelete(dream, reallyDestroy)) {
45
44
  await dream.txn(txn).reload();
@@ -1,47 +1,89 @@
1
1
  export default async function runHooksFor(key, dream, alreadyPersisted, beforeSaveChanges, txn) {
2
2
  const Base = dream.constructor;
3
- for (const statement of Base['hooks'][key]) {
4
- if (statement.ifChanging?.length) {
3
+ for (const hook of Base['hooks'][key]) {
4
+ if (hook.ifChanging?.length) {
5
5
  switch (key) {
6
6
  case 'beforeCreate':
7
- await runConditionalBeforeHooksForCreate(dream, statement, txn);
7
+ if (shouldRunBeforeCreateHook(dream, hook)) {
8
+ await runHook(hook, dream, txn);
9
+ }
8
10
  break;
9
11
  case 'beforeSave':
10
- if (alreadyPersisted)
11
- await runConditionalBeforeHooksForUpdate(dream, statement, txn);
12
- else
13
- await runConditionalBeforeHooksForCreate(dream, statement, txn);
12
+ if ((alreadyPersisted && shouldRunBeforeUpdateHook(dream, hook)) ||
13
+ (!alreadyPersisted && shouldRunBeforeCreateHook(dream, hook))) {
14
+ await runHook(hook, dream, txn);
15
+ }
14
16
  break;
15
17
  case 'beforeUpdate':
16
- await runConditionalBeforeHooksForUpdate(dream, statement, txn);
18
+ if (shouldRunBeforeUpdateHook(dream, hook)) {
19
+ await runHook(hook, dream, txn);
20
+ }
17
21
  break;
18
22
  default:
19
23
  throw new Error(`Unexpected statement key detected with ifChanging clause: ${key}`);
20
24
  }
21
25
  }
22
- else if (statement.ifChanged?.length) {
26
+ else if (hook.ifChanged?.length) {
23
27
  switch (key) {
24
28
  case 'afterCreate':
29
+ if (shouldRunAfterCreateHook(dream, hook, beforeSaveChanges)) {
30
+ await runHook(hook, dream, txn);
31
+ }
32
+ break;
25
33
  case 'afterCreateCommit':
26
- await runConditionalAfterHooksForCreate(dream, statement, beforeSaveChanges, txn);
34
+ if (shouldRunAfterCreateHook(dream, hook, beforeSaveChanges)) {
35
+ if (txn)
36
+ txn.addCommitHook(hook, dream);
37
+ else
38
+ await runHook(hook, dream);
39
+ }
27
40
  break;
28
41
  case 'afterSave':
42
+ if ((alreadyPersisted && shouldRunAfterUpdateHook(dream, hook)) ||
43
+ (!alreadyPersisted && shouldRunAfterCreateHook(dream, hook, beforeSaveChanges))) {
44
+ await runHook(hook, dream, txn);
45
+ }
46
+ break;
29
47
  case 'afterSaveCommit':
30
- if (alreadyPersisted)
31
- await runConditionalAfterHooksForUpdate(dream, statement, txn);
32
- else
33
- await runConditionalAfterHooksForCreate(dream, statement, beforeSaveChanges, txn);
48
+ if ((alreadyPersisted && shouldRunAfterUpdateHook(dream, hook)) ||
49
+ (!alreadyPersisted && shouldRunAfterCreateHook(dream, hook, beforeSaveChanges))) {
50
+ if (txn)
51
+ txn.addCommitHook(hook, dream);
52
+ else
53
+ await runHook(hook, dream);
54
+ }
34
55
  break;
35
56
  case 'afterUpdate':
57
+ if (shouldRunAfterUpdateHook(dream, hook)) {
58
+ await runHook(hook, dream, txn);
59
+ }
60
+ break;
36
61
  case 'afterUpdateCommit':
37
- await runConditionalAfterHooksForUpdate(dream, statement, txn);
62
+ if (shouldRunAfterUpdateHook(dream, hook)) {
63
+ if (txn)
64
+ txn.addCommitHook(hook, dream);
65
+ else
66
+ await runHook(hook, dream);
67
+ }
38
68
  break;
39
69
  default:
40
70
  throw new Error(`Unexpected statement key detected with ifChanged clause: ${key}`);
41
71
  }
42
72
  }
43
73
  else {
44
- await runHook(statement, dream, txn);
74
+ switch (key) {
75
+ case 'afterCreateCommit':
76
+ case 'afterSaveCommit':
77
+ case 'afterUpdateCommit':
78
+ case 'afterDestroyCommit':
79
+ if (txn)
80
+ txn.addCommitHook(hook, dream);
81
+ else
82
+ await runHook(hook, dream);
83
+ break;
84
+ default:
85
+ await runHook(hook, dream, txn);
86
+ }
45
87
  }
46
88
  }
47
89
  }
@@ -56,40 +98,36 @@ Please make sure "${statement.method}" is defined on ${dream['sanitizedConstruct
56
98
  }
57
99
  await dream[statement.method](txn);
58
100
  }
59
- async function runConditionalBeforeHooksForCreate(dream, statement, txn) {
101
+ function shouldRunBeforeCreateHook(dream, statement) {
60
102
  let shouldRun = false;
61
103
  for (const attribute of statement.ifChanging) {
62
104
  if (dream[attribute] !== undefined)
63
105
  shouldRun = true;
64
106
  }
65
- if (shouldRun)
66
- await runHook(statement, dream, txn);
107
+ return shouldRun;
67
108
  }
68
- async function runConditionalAfterHooksForCreate(dream, statement, beforeSaveChanges, txn) {
109
+ function shouldRunAfterCreateHook(dream, statement, beforeSaveChanges) {
69
110
  let shouldRun = false;
70
111
  for (const attribute of statement.ifChanged) {
71
112
  if (beforeSaveChanges?.[attribute] &&
72
113
  beforeSaveChanges[attribute].was !== beforeSaveChanges[attribute].now)
73
114
  shouldRun = true;
74
115
  }
75
- if (shouldRun)
76
- await runHook(statement, dream, txn);
116
+ return shouldRun;
77
117
  }
78
- async function runConditionalBeforeHooksForUpdate(dream, statement, txn) {
118
+ function shouldRunBeforeUpdateHook(dream, statement) {
79
119
  let shouldRun = false;
80
120
  for (const attribute of statement.ifChanging) {
81
121
  if (dream.willSaveChangeToAttribute(attribute))
82
122
  shouldRun = true;
83
123
  }
84
- if (shouldRun)
85
- await runHook(statement, dream, txn);
124
+ return shouldRun;
86
125
  }
87
- async function runConditionalAfterHooksForUpdate(dream, statement, txn) {
126
+ function shouldRunAfterUpdateHook(dream, statement) {
88
127
  let shouldRun = false;
89
128
  for (const attribute of statement.ifChanged) {
90
129
  if (dream.savedChangeToAttribute(attribute))
91
130
  shouldRun = true;
92
131
  }
93
- if (shouldRun)
94
- await runHook(statement, dream, txn);
132
+ return shouldRun;
95
133
  }
@@ -5,7 +5,6 @@ import namespaceColumn from '../../helpers/namespaceColumn.js';
5
5
  import sqlAttributes from '../../helpers/sqlAttributes.js';
6
6
  import executeDatabaseQuery from './executeDatabaseQuery.js';
7
7
  import runHooksFor from './runHooksFor.js';
8
- import safelyRunCommitHooks from './safelyRunCommitHooks.js';
9
8
  export default async function saveDream(dream, txn = null, { skipHooks = false } = {}) {
10
9
  const db = txn?.kyselyTransaction || _db('primary');
11
10
  const alreadyPersisted = dream.isPersisted;
@@ -56,9 +55,8 @@ export default async function saveDream(dream, txn = null, { skipHooks = false }
56
55
  await runHooksFor('afterUpdate', dream, alreadyPersisted, beforeSaveChanges, txn);
57
56
  else
58
57
  await runHooksFor('afterCreate', dream, alreadyPersisted, beforeSaveChanges, txn);
59
- const commitHookType = alreadyPersisted ? 'afterUpdateCommit' : 'afterCreateCommit';
60
- await safelyRunCommitHooks(dream, commitHookType, alreadyPersisted, beforeSaveChanges, txn);
61
- await safelyRunCommitHooks(dream, 'afterSaveCommit', alreadyPersisted, beforeSaveChanges, txn);
58
+ await runHooksFor(alreadyPersisted ? 'afterUpdateCommit' : 'afterCreateCommit', dream, alreadyPersisted, beforeSaveChanges, txn);
59
+ await runHooksFor('afterSaveCommit', dream, alreadyPersisted, beforeSaveChanges, txn);
62
60
  }
63
61
  return dream;
64
62
  }
@@ -1,6 +1,5 @@
1
1
  import { applySortableScopesToQuery } from '../../decorators/field/sortable/helpers/setPosition.js';
2
2
  import runHooksFor from './runHooksFor.js';
3
- import safelyRunCommitHooks from './safelyRunCommitHooks.js';
4
3
  /**
5
4
  * @internal
6
5
  *
@@ -38,7 +37,7 @@ async function undestroyDreamWithTransaction(dream, txn, options) {
38
37
  }
39
38
  if (!skipHooks) {
40
39
  await runHooksFor('afterUpdate', dream, true, null, txn);
41
- await safelyRunCommitHooks(dream, 'afterUpdateCommit', true, null, txn);
40
+ await runHooksFor('afterUpdateCommit', dream, true, null, txn);
42
41
  }
43
42
  await dream.txn(txn).reload();
44
43
  return dream;
@@ -0,0 +1,15 @@
1
+ export default class CannotAssociationQueryOnUnpersistedDream extends Error {
2
+ dream;
3
+ associationName;
4
+ constructor(dream, associationName) {
5
+ super();
6
+ this.dream = dream;
7
+ this.associationName = associationName;
8
+ }
9
+ get message() {
10
+ return `Cannot perform associationQuery on an unpersisted Dream.
11
+ Dream class: ${this.dream.sanitizedConstructorName}
12
+ Association: ${this.associationName.toString()}
13
+ `;
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ export default class CannotCreateAssociationOnUnpersistedDream extends Error {
2
+ dream;
3
+ associationName;
4
+ constructor(dream, associationName) {
5
+ super();
6
+ this.dream = dream;
7
+ this.associationName = associationName;
8
+ }
9
+ get message() {
10
+ return `Cannot perform createAssociation on an unpersisted Dream.
11
+ Dream class: ${this.dream.sanitizedConstructorName}
12
+ Association: ${this.associationName.toString()}
13
+ `;
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ export default class CannotDestroyAssociationOnUnpersistedDream extends Error {
2
+ dream;
3
+ associationName;
4
+ constructor(dream, associationName) {
5
+ super();
6
+ this.dream = dream;
7
+ this.associationName = associationName;
8
+ }
9
+ get message() {
10
+ return `Cannot perform destroyAssociation on an unpersisted Dream.
11
+ Dream class: ${this.dream.sanitizedConstructorName}
12
+ Association: ${this.associationName.toString()}
13
+ `;
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ export default class CannotUpdateAssociationOnUnpersistedDream extends Error {
2
+ dream;
3
+ associationName;
4
+ constructor(dream, associationName) {
5
+ super();
6
+ this.dream = dream;
7
+ this.associationName = associationName;
8
+ }
9
+ get message() {
10
+ return `Cannot perform updateAssociation on an unpersisted Dream.
11
+ Dream class: ${this.dream.sanitizedConstructorName}
12
+ Association: ${this.associationName.toString()}
13
+ `;
14
+ }
15
+ }
@@ -0,0 +1,9 @@
1
+ import colorfulLogo, { monochromeLogo } from './logos.js';
2
+ export default class DreamLogos {
3
+ static colorful() {
4
+ return colorfulLogo();
5
+ }
6
+ static monochrome() {
7
+ return monochromeLogo();
8
+ }
9
+ }
@@ -41,7 +41,7 @@ export default function whaaaaaaaaaaok() {
41
41
 
42
42
  `)));
43
43
  }
44
- export function whaaaaaaaaaaokBasic() {
44
+ export function monochromeLogo() {
45
45
  return `
46
46
  ,▄█▄
47
47
  ]█▄▄ ╓█████▌
@@ -1,8 +1,8 @@
1
- import DreamGlam from '../DreamGlam/DreamGlam.js';
1
+ import DreamLogos from '../DreamLogos/DreamLogos.js';
2
2
  export default function autogeneratedFileDisclaimer(startComment = '\n/*', endComment = '\n*/') {
3
3
  return `\
4
4
  ${startComment}
5
- ${DreamGlam.whaaaaaaaaaaokBasic()}
5
+ ${DreamLogos.monochrome()}
6
6
 
7
7
  This file was automatically generated by my cat, Aster.
8
8
  He does not want you mucking about with his files,
@@ -75,7 +75,7 @@ public ${camelize(attributeName)}: ${getAttributeType(attribute, modelClassName)
75
75
  return `\
76
76
  import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'${uniq(modelImportStatements).join('')}
77
77
 
78
- const deco = new Decorators<InstanceType<typeof ${modelClassName}>>()
78
+ const deco = new Decorators<typeof ${modelClassName}>()
79
79
 
80
80
  ${isSTI ? `\n@STI(${parentModelClassName})` : ''}
81
81
  export default class ${modelClassName} extends ${isSTI ? parentModelClassName : 'ApplicationModel'} {
@@ -86,7 +86,7 @@ ${isSTI
86
86
  }
87
87
 
88
88
  `}${serializer
89
- ? ` public get serializers(): DreamSerializers<${modelClassName}> {
89
+ ? ` public ${isSTI ? 'override ' : ''}get serializers(): DreamSerializers<${modelClassName}> {
90
90
  return {
91
91
  default: '${serializerNameFromFullyQualifiedModelName(fullyQualifiedModelName)}',
92
92
  summary: '${serializerNameFromFullyQualifiedModelName(fullyQualifiedModelName, 'summary')}',
@@ -29,13 +29,13 @@ export default function generateSerializerContent({ fullyQualifiedModelName, col
29
29
  Passthrough extends object,
30
30
  >`;
31
31
  dreamSerializerTypeArgs = `<DataType, Passthrough>`;
32
- const defaultSerialzerClassName = globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(fullyQualifiedModelName));
33
- const summarySerialzerClassName = globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(fullyQualifiedModelName, 'summary'));
32
+ const defaultSerialzerClassName = serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName));
33
+ const summarySerialzerClassName = serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName), 'summary');
34
34
  const defaultSerialzerExtends = isSTI
35
- ? globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(fullyQualifiedParentName))
35
+ ? serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedParentName))
36
36
  : summarySerialzerClassName;
37
37
  const summarySerialzerExtends = isSTI
38
- ? globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(fullyQualifiedParentName, 'summary'))
38
+ ? serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedParentName), 'summary')
39
39
  : 'DreamSerializer';
40
40
  const additionalModelImports = [];
41
41
  columnsWithTypes.forEach(attr => {
@@ -98,8 +98,16 @@ function attributeOptionsSpecifier(type, attr) {
98
98
  }
99
99
  }
100
100
  function importStatementForSerializer(originModelName, destinationModelName) {
101
- return `\nimport ${globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(destinationModelName))}, { ${globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(destinationModelName, 'summary'))} } from '${relativeDreamPath('serializers', 'serializers', originModelName, destinationModelName)}'`;
101
+ const defaultSerializer = globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(destinationModelName)));
102
+ const summarySerializer = globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(destinationModelName), 'summary'));
103
+ const importFrom = relativeDreamPath('serializers', 'serializers', originModelName, destinationModelName);
104
+ return `\nimport ${defaultSerializer}, { ${summarySerializer} } from '${importFrom}'`;
102
105
  }
103
106
  function importStatementForModel(originModelName, destinationModelName = originModelName) {
104
- return `\nimport ${globalClassNameFromFullyQualifiedModelName(destinationModelName)} from '${relativeDreamPath('serializers', 'models', originModelName, destinationModelName)}'`;
107
+ const modelName = globalClassNameFromFullyQualifiedModelName(destinationModelName);
108
+ const importFrom = relativeDreamPath('serializers', 'models', originModelName, destinationModelName);
109
+ return `\nimport ${modelName} from '${importFrom}'`;
110
+ }
111
+ function fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName) {
112
+ return fullyQualifiedModelName.split('/').pop() ?? '';
105
113
  }
@@ -1,8 +1,8 @@
1
1
  export { default as DreamBin } from './bin/index.js';
2
2
  export { default as DreamCLI } from './cli/index.js';
3
- export { closeAllDbConnections, default as DreamDbConnection, dreamDbConnections, } from './db/DreamDbConnection.js';
3
+ export { closeAllDbConnections, dreamDbConnections } from './db/DreamDbConnection.js';
4
4
  export { pgErrorType } from './db/errors.js';
5
- export { default as db } from './db/index.js';
5
+ export { default as untypedDb } from './db/index.js';
6
6
  export { default as DreamMigrationHelpers } from './db/migration-helpers/DreamMigrationHelpers.js';
7
7
  export { default as validateColumn } from './db/validators/validateColumn.js';
8
8
  export { default as validateTable } from './db/validators/validateTable.js';
@@ -31,7 +31,7 @@ export { default as generateDream } from './helpers/cli/generateDream.js';
31
31
  export { default as compact } from './helpers/compact.js';
32
32
  export { DateTime } from './helpers/DateTime.js';
33
33
  export { default as debug } from './helpers/debug.js';
34
- export { default as DreamGlam } from './helpers/DreamGlam/DreamGlam.js';
34
+ export { default as DreamLogos } from './helpers/DreamLogos/DreamLogos.js';
35
35
  export { default as Env } from './helpers/Env.js';
36
36
  export { default as globalClassNameFromFullyQualifiedModelName } from './helpers/globalClassNameFromFullyQualifiedModelName.js';
37
37
  export { default as hyphenize } from './helpers/hyphenize.js';
@@ -6,15 +6,15 @@ import { HasOneOptions, HasOneThroughOptions, PolymorphicHasOneOptions } from '.
6
6
  import { DreamColumnNames, GlobalModelNameTableMap, SortableOptions } from '../types/dream.js';
7
7
  import { AfterHookOpts, BeforeHookOpts } from '../types/lifecycle.js';
8
8
  import { ValidationType } from '../types/validation.js';
9
- export default class Decorators<T extends Dream> {
10
- BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalNameOrNames, options?: NonPolymorphicBelongsToOptions<T, AssociationGlobalNameOrNames>): any;
11
- BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalNameOrNames, options?: PolymorphicBelongsToOptions<T, AssociationGlobalNameOrNames>): any;
12
- HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasManyOptions<T, AssociationGlobalName>): any;
13
- HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasManyThroughOptions<T, AssociationGlobalName>): any;
14
- HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalName, options?: PolymorphicHasManyOptions<T, AssociationGlobalName>): any;
15
- HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasOneOptions<T, AssociationGlobalName>): any;
16
- HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasOneThroughOptions<T, AssociationGlobalName>): any;
17
- HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalName, options?: PolymorphicHasOneOptions<T, AssociationGlobalName>): any;
9
+ export default class Decorators<TD extends typeof Dream, T extends Dream = InstanceType<TD>> {
10
+ BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalNameOrNames, options?: NonPolymorphicBelongsToOptions<T, AssociationGlobalNameOrNames>): any;
11
+ BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalNameOrNames, options?: PolymorphicBelongsToOptions<T, AssociationGlobalNameOrNames>): any;
12
+ HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasManyOptions<T, AssociationGlobalName>): any;
13
+ HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasManyThroughOptions<T, AssociationGlobalName>): any;
14
+ HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: PolymorphicHasManyOptions<T, AssociationGlobalName>): any;
15
+ HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasOneOptions<T, AssociationGlobalName>): any;
16
+ HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasOneThroughOptions<T, AssociationGlobalName>): any;
17
+ HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: PolymorphicHasOneOptions<T, AssociationGlobalName>): any;
18
18
  /**
19
19
  * The Encrypted decorator automatically encrypts (upon setting)
20
20
  * and decrypts (upon getting) so that the encrypted value is
@@ -37,7 +37,7 @@ export default class Decorators<T extends Dream> {
37
37
  * @param column — if omitted, then 'encrypted' is prepended to the Pascal cased version of the decorated field
38
38
  * @returns An Encrypted decorator
39
39
  */
40
- Encrypted(this: Decorators<T>, column?: DreamColumnNames<T>): any;
40
+ Encrypted(this: Decorators<TD>, column?: DreamColumnNames<T>): any;
41
41
  /**
42
42
  * The Scope decorator decorates a static method that accepts
43
43
  * and returns a Dream Query.
@@ -55,7 +55,7 @@ export default class Decorators<T extends Dream> {
55
55
  * @param opts.default - boolean: if true, then this scope will be applied to all queries involving this model
56
56
  * @returns A Scope decorator
57
57
  */
58
- Scope(this: Decorators<T>, opts?: {
58
+ Scope(this: Decorators<TD>, opts?: {
59
59
  default?: boolean;
60
60
  }): any;
61
61
  /**
@@ -74,7 +74,7 @@ export default class Decorators<T extends Dream> {
74
74
  * @param scope - The column, association, or combination there-of which you would like to restrict the incrementing logic to
75
75
  * @returns A Sortable decorator
76
76
  */
77
- Sortable(this: Decorators<T>, opts?: SortableOptions<T>): any;
77
+ Sortable(this: Decorators<TD>, opts?: SortableOptions<T>): any;
78
78
  /**
79
79
  * The Validate decorator decorates a method to run
80
80
  * before saving a model to the database.
@@ -97,7 +97,7 @@ export default class Decorators<T extends Dream> {
97
97
  *
98
98
  * @returns A Validate decorator
99
99
  */
100
- Validate(this: Decorators<T>): any;
100
+ Validate(this: Decorators<TD>): any;
101
101
  /**
102
102
  * The Validates decorator decorates a field to validate
103
103
  * according to the specified validator and options.
@@ -120,7 +120,7 @@ export default class Decorators<T extends Dream> {
120
120
  } : VT extends 'length' ? {
121
121
  min: number;
122
122
  max?: number;
123
- } : VT extends 'contains' ? string | RegExp : never>(this: Decorators<T>, type: VT, args?: VTArgs): any;
123
+ } : VT extends 'contains' ? string | RegExp : never>(this: Decorators<TD>, type: VT, args?: VTArgs): any;
124
124
  /**
125
125
  * The Virtual decorator enables setting of fields as if they
126
126
  * corresponded to columns in the model's table so they can
@@ -182,7 +182,7 @@ export default class Decorators<T extends Dream> {
182
182
  *
183
183
  * @returns An Virtual decorator
184
184
  */
185
- Virtual(this: Decorators<T>, type?: SerializableTypes): any;
185
+ Virtual(this: Decorators<TD>, type?: SerializableTypes): any;
186
186
  /**
187
187
  * BeforeCreate decorator
188
188
  *
@@ -198,7 +198,7 @@ export default class Decorators<T extends Dream> {
198
198
  * @returns The BeforeCreate decorator
199
199
  *
200
200
  */
201
- BeforeCreate(this: Decorators<T>, opts?: BeforeHookOpts<T>): any;
201
+ BeforeCreate(this: Decorators<TD>, opts?: BeforeHookOpts<T>): any;
202
202
  /**
203
203
  * BeforeSave decorator
204
204
  *
@@ -214,7 +214,7 @@ export default class Decorators<T extends Dream> {
214
214
  * @returns The BeforeSave decorator
215
215
  *
216
216
  */
217
- BeforeSave(this: Decorators<T>, opts?: BeforeHookOpts<T>): any;
217
+ BeforeSave(this: Decorators<TD>, opts?: BeforeHookOpts<T>): any;
218
218
  /**
219
219
  * BeforeUpdate decorator
220
220
  *
@@ -230,7 +230,7 @@ export default class Decorators<T extends Dream> {
230
230
  * @returns The BeforeUpdate decorator
231
231
  *
232
232
  */
233
- BeforeUpdate(this: Decorators<T>, opts?: BeforeHookOpts<T>): any;
233
+ BeforeUpdate(this: Decorators<TD>, opts?: BeforeHookOpts<T>): any;
234
234
  /**
235
235
  * BeforeDestroy decorator
236
236
  *
@@ -245,7 +245,7 @@ export default class Decorators<T extends Dream> {
245
245
  *
246
246
  * @returns The BeforeDestroy decorator
247
247
  */
248
- BeforeDestroy(this: Decorators<T>): any;
248
+ BeforeDestroy(this: Decorators<TD>): any;
249
249
  /**
250
250
  * AfterCreate decorator
251
251
  *
@@ -261,7 +261,7 @@ export default class Decorators<T extends Dream> {
261
261
  * @returns The AfterCreate decorator
262
262
  *
263
263
  */
264
- AfterCreate(this: Decorators<T>, opts?: AfterHookOpts<T>): any;
264
+ AfterCreate(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
265
265
  /**
266
266
  * AfterCreateCommit decorator
267
267
  *
@@ -276,7 +276,7 @@ export default class Decorators<T extends Dream> {
276
276
  *
277
277
  * @returns The AfterCreateCommit decorator
278
278
  */
279
- AfterCreateCommit(this: Decorators<T>, opts?: AfterHookOpts<T>): any;
279
+ AfterCreateCommit(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
280
280
  /**
281
281
  * AfterSave decorator
282
282
  *
@@ -292,7 +292,7 @@ export default class Decorators<T extends Dream> {
292
292
  * @returns The AfterSave decorator
293
293
  *
294
294
  */
295
- AfterSave(this: Decorators<T>, opts?: AfterHookOpts<T>): any;
295
+ AfterSave(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
296
296
  /**
297
297
  * AfterSaveCommit decorator
298
298
  *
@@ -308,7 +308,7 @@ export default class Decorators<T extends Dream> {
308
308
  * @returns The AfterSaveCommit decorator
309
309
  *
310
310
  */
311
- AfterSaveCommit(this: Decorators<T>, opts?: AfterHookOpts<T>): any;
311
+ AfterSaveCommit(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
312
312
  /**
313
313
  * AfterUpdate decorator
314
314
  *
@@ -324,7 +324,7 @@ export default class Decorators<T extends Dream> {
324
324
  * @returns The AfterUpdate decorator
325
325
  *
326
326
  */
327
- AfterUpdate(this: Decorators<T>, opts?: AfterHookOpts<T>): any;
327
+ AfterUpdate(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
328
328
  /**
329
329
  * AfterUpdateCommit decorator
330
330
  *
@@ -340,7 +340,7 @@ export default class Decorators<T extends Dream> {
340
340
  * @returns The AfterUpdateCommit decorator
341
341
  *
342
342
  */
343
- AfterUpdateCommit(this: Decorators<T>, opts?: AfterHookOpts<T>): any;
343
+ AfterUpdateCommit(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
344
344
  /**
345
345
  * AfterDestroy decorator
346
346
  *
@@ -356,7 +356,7 @@ export default class Decorators<T extends Dream> {
356
356
  * @returns The AfterDestroy decorator
357
357
  *
358
358
  */
359
- AfterDestroy(this: Decorators<T>): any;
359
+ AfterDestroy(this: Decorators<TD>): any;
360
360
  /**
361
361
  * AfterDestroyCommit decorator
362
362
  *
@@ -372,5 +372,5 @@ export default class Decorators<T extends Dream> {
372
372
  * @returns The AfterDestroyCommit decorator
373
373
  *
374
374
  */
375
- AfterDestroyCommit(this: Decorators<T>): any;
375
+ AfterDestroyCommit(this: Decorators<TD>): any;
376
376
  }
@@ -0,0 +1,7 @@
1
+ import Dream from '../../Dream.js';
2
+ export default class CannotAssociationQueryOnUnpersistedDream extends Error {
3
+ dream: Dream;
4
+ associationName: string | number | symbol;
5
+ constructor(dream: Dream, associationName: string | number | symbol);
6
+ get message(): string;
7
+ }
@@ -0,0 +1,7 @@
1
+ import Dream from '../../Dream.js';
2
+ export default class CannotCreateAssociationOnUnpersistedDream extends Error {
3
+ dream: Dream;
4
+ associationName: string | number | symbol;
5
+ constructor(dream: Dream, associationName: string | number | symbol);
6
+ get message(): string;
7
+ }