@rvoh/dream 2.29.0 → 2.31.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 (237) hide show
  1. package/dist/cjs/src/Dream.js +1 -1
  2. package/dist/cjs/src/decorators/Decorators.js +81 -6
  3. package/dist/cjs/src/decorators/field/sortable/Sortable.js +4 -31
  4. package/dist/cjs/src/decorators/field/sortable/helpers/setPosition.js +11 -2
  5. package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +1 -1
  6. package/dist/cjs/src/dream/Query.js +37 -13
  7. package/dist/cjs/src/dream/QueryDriver/Kysely.js +73 -33
  8. package/dist/cjs/src/dream/internal/associations/loadedOrLoadAssociation.js +2 -0
  9. package/dist/cjs/src/dream/internal/installPersistedAttribute.js +9 -0
  10. package/dist/cjs/src/dream/internal/instanceMutationOptions.js +1 -0
  11. package/dist/cjs/src/dream/internal/saveDream.js +9 -0
  12. package/dist/cjs/src/errors/CannotSaveMissingDream.js +24 -0
  13. package/dist/cjs/src/errors/SortableBatchRequiresTooManyScopeLocks.js +7 -0
  14. package/dist/cjs/src/errors/associations/IncompatibleThroughAssociationTarget.js +11 -0
  15. package/dist/cjs/src/errors/associations/MissingRequiredBelongsToAssociation.js +8 -3
  16. package/dist/cjs/src/package-exports/errors.js +10 -1
  17. package/dist/esm/src/Dream.js +1 -1
  18. package/dist/esm/src/decorators/Decorators.js +81 -6
  19. package/dist/esm/src/decorators/field/sortable/Sortable.js +4 -31
  20. package/dist/esm/src/decorators/field/sortable/helpers/setPosition.js +11 -2
  21. package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +1 -1
  22. package/dist/esm/src/dream/Query.js +37 -13
  23. package/dist/esm/src/dream/QueryDriver/Kysely.js +73 -33
  24. package/dist/esm/src/dream/internal/associations/loadedOrLoadAssociation.js +2 -0
  25. package/dist/esm/src/dream/internal/installPersistedAttribute.js +9 -0
  26. package/dist/esm/src/dream/internal/instanceMutationOptions.js +1 -0
  27. package/dist/esm/src/dream/internal/saveDream.js +9 -0
  28. package/dist/esm/src/errors/CannotSaveMissingDream.js +24 -0
  29. package/dist/esm/src/errors/SortableBatchRequiresTooManyScopeLocks.js +7 -0
  30. package/dist/esm/src/errors/associations/IncompatibleThroughAssociationTarget.js +11 -0
  31. package/dist/esm/src/errors/associations/MissingRequiredBelongsToAssociation.js +8 -3
  32. package/dist/esm/src/package-exports/errors.js +10 -1
  33. package/dist/types/src/Dream.d.ts +36 -24
  34. package/dist/types/src/decorators/Decorators.d.ts +81 -6
  35. package/dist/types/src/decorators/field/sortable/Sortable.d.ts +4 -31
  36. package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +14 -20
  37. package/dist/types/src/dream/Query.d.ts +37 -13
  38. package/dist/types/src/dream/QueryDriver/Kysely.d.ts +1 -1
  39. package/dist/types/src/dream/internal/associations/loadedOrLoadAssociation.d.ts +2 -0
  40. package/dist/types/src/dream/internal/installPersistedAttribute.d.ts +6 -0
  41. package/dist/types/src/dream/internal/instanceMutationOptions.d.ts +13 -0
  42. package/dist/types/src/errors/CannotSaveMissingDream.d.ts +23 -0
  43. package/dist/types/src/errors/SortableBatchRequiresTooManyScopeLocks.d.ts +7 -0
  44. package/dist/types/src/errors/associations/IncompatibleThroughAssociationTarget.d.ts +9 -0
  45. package/dist/types/src/errors/associations/MissingRequiredBelongsToAssociation.d.ts +1 -0
  46. package/dist/types/src/package-exports/errors.d.ts +1 -1
  47. package/docs/assets/hierarchy.js +1 -1
  48. package/docs/assets/navigation.js +1 -1
  49. package/docs/assets/search.js +1 -1
  50. package/docs/classes/db.DreamMigrationHelpers.html +11 -11
  51. package/docs/classes/db.KyselyQueryDriver.html +43 -43
  52. package/docs/classes/db.PostgresQueryDriver.html +44 -44
  53. package/docs/classes/db.QueryDriverBase.html +42 -42
  54. package/docs/classes/errors.CannotSaveMissingDream.html +47 -0
  55. package/docs/classes/errors.CheckConstraintViolation.html +3 -3
  56. package/docs/classes/errors.ColumnOverflow.html +3 -3
  57. package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
  58. package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
  59. package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
  60. package/docs/classes/errors.DecryptionError.html +2 -2
  61. package/docs/classes/errors.DecryptionParseError.html +2 -2
  62. package/docs/classes/errors.DecryptionRotationError.html +3 -3
  63. package/docs/classes/errors.GlobalNameNotSet.html +3 -3
  64. package/docs/classes/errors.InvalidCalendarDate.html +2 -2
  65. package/docs/classes/errors.InvalidClockTime.html +2 -2
  66. package/docs/classes/errors.InvalidClockTimeTz.html +2 -2
  67. package/docs/classes/errors.InvalidDateTime.html +2 -2
  68. package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
  69. package/docs/classes/errors.NonLoadedAssociation.html +3 -3
  70. package/docs/classes/errors.NotNullViolation.html +3 -3
  71. package/docs/classes/errors.RecordNotFound.html +3 -3
  72. package/docs/classes/errors.SortableScopeDidNotStabilize.html +3 -3
  73. package/docs/classes/errors.SortableScopeLockWaitTimedOut.html +3 -3
  74. package/docs/classes/errors.ValidationError.html +3 -3
  75. package/docs/classes/index.CalendarDate.html +33 -33
  76. package/docs/classes/index.ClockTime.html +32 -32
  77. package/docs/classes/index.ClockTimeTz.html +35 -35
  78. package/docs/classes/index.DateTime.html +86 -86
  79. package/docs/classes/index.Decorators.html +63 -22
  80. package/docs/classes/index.Dream.html +145 -141
  81. package/docs/classes/index.DreamApp.html +10 -10
  82. package/docs/classes/index.DreamTransaction.html +2 -2
  83. package/docs/classes/index.Env.html +2 -2
  84. package/docs/classes/index.Query.html +88 -67
  85. package/docs/classes/system.CliFileWriter.html +4 -4
  86. package/docs/classes/system.DreamBin.html +2 -2
  87. package/docs/classes/system.DreamCLI.html +7 -7
  88. package/docs/classes/system.DreamImporter.html +2 -2
  89. package/docs/classes/system.DreamLogos.html +2 -2
  90. package/docs/classes/system.DreamSerializerBuilder.html +11 -11
  91. package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
  92. package/docs/classes/system.PathHelpers.html +3 -3
  93. package/docs/classes/utils.Encrypt.html +3 -3
  94. package/docs/classes/utils.Range.html +2 -2
  95. package/docs/functions/db.closeAllDbConnections.html +1 -1
  96. package/docs/functions/db.dreamDbConnections.html +1 -1
  97. package/docs/functions/db.untypedDb.html +1 -1
  98. package/docs/functions/db.validateColumn.html +1 -1
  99. package/docs/functions/db.validateTable.html +1 -1
  100. package/docs/functions/errors.pgErrorType.html +1 -1
  101. package/docs/functions/index.DreamSerializer.html +1 -1
  102. package/docs/functions/index.ObjectSerializer.html +1 -1
  103. package/docs/functions/index.ReplicaSafe.html +1 -1
  104. package/docs/functions/index.STI.html +1 -1
  105. package/docs/functions/index.SoftDelete.html +1 -1
  106. package/docs/functions/utils.camelize.html +1 -1
  107. package/docs/functions/utils.capitalize.html +1 -1
  108. package/docs/functions/utils.cloneDeepSafe.html +1 -1
  109. package/docs/functions/utils.compact.html +1 -1
  110. package/docs/functions/utils.groupBy.html +1 -1
  111. package/docs/functions/utils.hyphenize.html +1 -1
  112. package/docs/functions/utils.intersection.html +1 -1
  113. package/docs/functions/utils.isEmpty.html +1 -1
  114. package/docs/functions/utils.normalizeUnicode.html +1 -1
  115. package/docs/functions/utils.pascalize.html +1 -1
  116. package/docs/functions/utils.percent.html +1 -1
  117. package/docs/functions/utils.range.html +1 -1
  118. package/docs/functions/utils.round.html +1 -1
  119. package/docs/functions/utils.sanitizeString.html +1 -1
  120. package/docs/functions/utils.snakeify.html +1 -1
  121. package/docs/functions/utils.sort.html +1 -1
  122. package/docs/functions/utils.sortBy.html +1 -1
  123. package/docs/functions/utils.sortObjectByKey.html +1 -1
  124. package/docs/functions/utils.sortObjectByValue.html +1 -1
  125. package/docs/functions/utils.uncapitalize.html +1 -1
  126. package/docs/functions/utils.uniq.html +1 -1
  127. package/docs/hierarchy.html +1 -1
  128. package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
  129. package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
  130. package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
  131. package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
  132. package/docs/interfaces/types.BelongsToStatement.html +2 -2
  133. package/docs/interfaces/types.DecoratorContext.html +2 -2
  134. package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
  135. package/docs/interfaces/types.DreamAppOpts.html +2 -2
  136. package/docs/interfaces/types.DreamDbConfig.html +5 -5
  137. package/docs/interfaces/types.DurationObject.html +2 -2
  138. package/docs/interfaces/types.EncryptOptions.html +2 -2
  139. package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
  140. package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
  141. package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
  142. package/docs/modules/errors.html +1 -1
  143. package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
  144. package/docs/types/openapi.OpenapiAllTypes.html +1 -1
  145. package/docs/types/openapi.OpenapiFormats.html +1 -1
  146. package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
  147. package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
  148. package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
  149. package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
  150. package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
  151. package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
  152. package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
  153. package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
  154. package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
  155. package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +2 -2
  156. package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +2 -2
  157. package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +2 -2
  158. package/docs/types/openapi.OpenapiSchemaExpressionRef.html +2 -2
  159. package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +2 -2
  160. package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
  161. package/docs/types/openapi.OpenapiSchemaNull.html +2 -2
  162. package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
  163. package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
  164. package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
  165. package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
  166. package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
  167. package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  168. package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
  169. package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
  170. package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
  171. package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
  172. package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
  173. package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
  174. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +2 -2
  175. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +2 -2
  176. package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +2 -2
  177. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +2 -2
  178. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +2 -2
  179. package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  180. package/docs/types/openapi.OpenapiSchemaString.html +1 -1
  181. package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
  182. package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
  183. package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
  184. package/docs/types/openapi.OpenapiTypeField.html +1 -1
  185. package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
  186. package/docs/types/types.CalendarDateDurationUnit.html +1 -1
  187. package/docs/types/types.CalendarDateObject.html +1 -1
  188. package/docs/types/types.Camelized.html +1 -1
  189. package/docs/types/types.ClockTimeObject.html +1 -1
  190. package/docs/types/types.DbConnectionType.html +1 -1
  191. package/docs/types/types.DbTypes.html +1 -1
  192. package/docs/types/types.DreamAssociationMetadata.html +1 -1
  193. package/docs/types/types.DreamAttributes.html +1 -1
  194. package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
  195. package/docs/types/types.DreamClassColumn.html +1 -1
  196. package/docs/types/types.DreamColumn.html +1 -1
  197. package/docs/types/types.DreamColumnNames.html +1 -1
  198. package/docs/types/types.DreamLogLevel.html +1 -1
  199. package/docs/types/types.DreamLogger.html +2 -2
  200. package/docs/types/types.DreamModelSerializerType.html +1 -1
  201. package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
  202. package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
  203. package/docs/types/types.DreamParamSafeAttributes.html +1 -1
  204. package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
  205. package/docs/types/types.DreamSerializable.html +1 -1
  206. package/docs/types/types.DreamSerializableArray.html +1 -1
  207. package/docs/types/types.DreamSerializerKey.html +1 -1
  208. package/docs/types/types.DreamSerializers.html +1 -1
  209. package/docs/types/types.DreamVirtualColumns.html +1 -1
  210. package/docs/types/types.DurationUnit.html +1 -1
  211. package/docs/types/types.EncryptAlgorithm.html +1 -1
  212. package/docs/types/types.HasManyStatement.html +1 -1
  213. package/docs/types/types.HasOneStatement.html +1 -1
  214. package/docs/types/types.Hyphenized.html +1 -1
  215. package/docs/types/types.Pascalized.html +1 -1
  216. package/docs/types/types.PrimaryKeyType.html +1 -1
  217. package/docs/types/types.RoundingPrecision.html +1 -1
  218. package/docs/types/types.SerializerCasing.html +1 -1
  219. package/docs/types/types.SimpleObjectSerializerType.html +1 -1
  220. package/docs/types/types.Snakeified.html +1 -1
  221. package/docs/types/types.StrictInterface.html +1 -1
  222. package/docs/types/types.UpdateableAssociationProperties.html +1 -1
  223. package/docs/types/types.UpdateableProperties.html +1 -1
  224. package/docs/types/types.ValidationType.html +1 -1
  225. package/docs/types/types.ViewModel.html +2 -2
  226. package/docs/types/types.ViewModelClass.html +1 -1
  227. package/docs/types/types.WeekdayName.html +1 -1
  228. package/docs/types/types.WhereStatementForDream.html +1 -1
  229. package/docs/types/types.WhereStatementForDreamClass.html +1 -1
  230. package/docs/variables/index.DreamConst.html +1 -1
  231. package/docs/variables/index.ops.html +1 -1
  232. package/docs/variables/openapi.openapiPrimitiveTypes.html +1 -1
  233. package/docs/variables/openapi.openapiShorthandPrimitiveTypes.html +1 -1
  234. package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
  235. package/docs/variables/system.primaryKeyTypes.html +1 -1
  236. package/package.json +1 -1
  237. package/docs/classes/errors.SortableBatchRequiresTooManyScopeLocks.html +0 -61
@@ -3,6 +3,7 @@ import { clearSortableSaveState } from '../../decorators/field/sortable/helpers/
3
3
  import performSortablePositionWork from '../../decorators/field/sortable/helpers/performSortablePositionWork.js';
4
4
  import prepareSortableFieldsForSave from '../../decorators/field/sortable/helpers/prepareSortableFieldsForSave.js';
5
5
  import { cacheSortableSnapshots } from '../../decorators/field/sortable/helpers/sortableSnapshot.js';
6
+ import CannotSaveMissingDream from '../../errors/CannotSaveMissingDream.js';
6
7
  import ValidationError from '../../errors/ValidationError.js';
7
8
  import sqlAttributes from '../../helpers/sqlAttributes.js';
8
9
  import { DateTime } from '../../utils/datetime/DateTime.js';
@@ -114,6 +115,14 @@ async function writeDream(dream, txn, { alreadyPersisted, sortableFieldConfigs,
114
115
  dream.createdAt = now;
115
116
  if (!dream.dirtyAttributes().updatedAt && dream.columns().has('updatedAt'))
116
117
  dream.updatedAt = now;
118
+ // The scope-lock read above positively found the row gone, so there is
119
+ // nothing to update. Raised here rather than after the write because the
120
+ // write below would not reach the database at all on a position-only save,
121
+ // whose attributes Sortable has already cleared; a save that does carry data
122
+ // raises the equivalent diagnostic from the driver, which sees the update
123
+ // match no row.
124
+ if (alreadyPersisted && !rowFoundBeforeWrite)
125
+ throw new CannotSaveMissingDream(dream);
117
126
  const hasUnsavedData = !!Object.keys(sqlAttributes(dream)).length;
118
127
  // BeforeSave/Update actions may clear all the data that we intended to save, leaving us with
119
128
  // an invalid update command. The Sortable decorator is an example of this.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Raised when saving a persisted instance whose database row no longer exists —
3
+ * the row was deleted between the moment the instance was loaded and the moment
4
+ * the save reached the database.
5
+ *
6
+ * This is the write-side counterpart of `RecordNotFound`, and applications catch
7
+ * it for the same reasons: a request updating a record another request has since
8
+ * deleted should answer 404 or 409 rather than 500, and a background job holding
9
+ * a stale instance should usually drop the work rather than fail loudly. Nothing
10
+ * is written when it is raised.
11
+ *
12
+ * It does not mean the save was rejected — a save that fails validation raises
13
+ * `ValidationError`, and a constraint violation raises its own error. It means
14
+ * the row that the instance stands for is gone.
15
+ *
16
+ * Dream raises it from the query driver, so a custom driver overriding
17
+ * `saveDream` translates its own adapter's empty-result error the same way, as
18
+ * the test-app MySQL driver does.
19
+ */
20
+ export default class CannotSaveMissingDream extends Error {
21
+ constructor(dream) {
22
+ super(`Cannot save ${dream.sanitizedConstructorName} with primary key ${String(dream.primaryKeyValue())} because its persisted database row no longer exists.`);
23
+ }
24
+ }
@@ -1,4 +1,6 @@
1
1
  /**
2
+ * @internal
3
+ *
2
4
  * Raised when a batch of a locked `Query#destroy` or `Query#update` on a
3
5
  * sortable model would carry its transaction past the number of advisory
4
6
  * sort-scope locks Dream is willing to hold at once.
@@ -27,6 +29,11 @@
27
29
  * — a long multi-batch run inside a transaction you opened — either let Dream
28
30
  * open a transaction per batch (do not pass a transaction of your own) or
29
31
  * commit between runs, which is what releases the locks as it goes.
32
+ *
33
+ * Not exported from `@rvoh/dream/errors`. Exceeding the bound is a sizing
34
+ * mistake in the calling code, not a runtime condition an application can
35
+ * recover from, so there is nothing for a consumer to catch: the fix is a
36
+ * smaller batch or a narrower transaction, never a retry.
30
37
  */
31
38
  export default class SortableBatchRequiresTooManyScopeLocks extends Error {
32
39
  dreamClassName;
@@ -0,0 +1,11 @@
1
+ export default class IncompatibleThroughAssociationTarget extends Error {
2
+ constructor({ outermostAssociation, outermostTargetModelClass, sourceAssociation, }) {
3
+ super(`Through association \`${outermostAssociation.as}\` targets \`${outermostTargetModelClass.sanitizedName}\`, but source association \`${sourceAssociation.as}\` targets ${targetDescription(sourceAssociation)}. ` +
4
+ `The through association's target must be the same as or a subclass of a source target.`);
5
+ }
6
+ }
7
+ function targetDescription(association) {
8
+ const targetModelClassOrClasses = association.modelCB();
9
+ const targetNames = (Array.isArray(targetModelClassOrClasses) ? targetModelClassOrClasses : [targetModelClassOrClasses]).map(targetModelClass => `\`${targetModelClass.sanitizedName}\``);
10
+ return targetNames.join(', ');
11
+ }
@@ -48,10 +48,15 @@ export default class MissingRequiredBelongsToAssociation extends Error {
48
48
  Attempting to access required BelongsTo association \`${this.associationName}\` on an instance of \`${this.dreamClass.sanitizedName}\`,
49
49
  but the loaded association is null.
50
50
 
51
- ${this.foreignKeyMessage}
52
-
53
- If the associated record was deleted, check whether the inverse HasOne/HasMany association should specify dependent: 'destroy'.
51
+ ${this.foreignKeyMessage}${this.populatedForeignKeyDiagnosticMessage}
54
52
  `;
53
+ }
54
+ get populatedForeignKeyDiagnosticMessage() {
55
+ if (this.foreignKeyValue === null || this.foreignKeyValue === undefined)
56
+ return '';
57
+ return `
58
+
59
+ The associated record may have been deleted (including soft-deleted), or it may not match this association’s target—for example, its STI type may differ from the targeted STI child. If the record was deleted unexpectedly, check whether the inverse HasOne/HasMany association should specify \`dependent: 'destroy'\`.`;
55
60
  }
56
61
  get foreignKeyMessage() {
57
62
  if (this.foreignKeyValue === null || this.foreignKeyValue === undefined) {
@@ -1,18 +1,27 @@
1
1
  export { pgErrorType } from '../db/errors.js';
2
2
  export { default as NonLoadedAssociation } from '../errors/associations/NonLoadedAssociation.js';
3
+ export { default as CannotSaveMissingDream } from '../errors/CannotSaveMissingDream.js';
3
4
  export { default as CreateOrFindByFailedToCreateAndFind } from '../errors/CreateOrFindByFailedToCreateAndFind.js';
4
5
  export { default as CheckConstraintViolation } from '../errors/db/CheckConstraintViolation.js';
5
6
  export { default as ColumnOverflow } from '../errors/db/ColumnOverflow.js';
6
7
  export { default as DataIncompatibleWithDatabaseField } from '../errors/db/DataIncompatibleWithDatabaseField.js';
7
8
  export { default as DataTypeColumnTypeMismatch } from '../errors/db/DataTypeColumnTypeMismatch.js';
8
9
  export { default as NotNullViolation } from '../errors/db/NotNullViolation.js';
10
+ // Raised by the framework packages layered on Dream, not only by Dream: psychic
11
+ // (`src/controller/index.ts`) raises it for a controller's global name, and
12
+ // psychic-workers (`src/background/BaseBackgroundedService.ts`,
13
+ // `src/background/BaseScheduledService.ts`) for service global names. Both reach it
14
+ // through this entry point, so unexporting it breaks the build of every application
15
+ // that installs either package.
9
16
  export { default as GlobalNameNotSet } from '../errors/dream-app/GlobalNameNotSet.js';
10
17
  export { default as DecryptionError } from '../errors/encrypt/DecryptionError.js';
11
18
  export { default as DecryptionParseError } from '../errors/encrypt/DecryptionParseError.js';
12
19
  export { default as DecryptionRotationError } from '../errors/encrypt/DecryptionRotationError.js';
13
20
  export { default as RecordNotFound } from '../errors/RecordNotFound.js';
21
+ // Caught through this entry point by psychic
22
+ // (`test-app/src/app/controllers/SerializerTestsController.ts`), which distinguishes it
23
+ // to prove a controller can render a missing-serializers failure as a response.
14
24
  export { default as MissingSerializersDefinition } from '../errors/serializers/MissingSerializersDefinition.js';
15
- export { default as SortableBatchRequiresTooManyScopeLocks } from '../errors/SortableBatchRequiresTooManyScopeLocks.js';
16
25
  export { default as SortableScopeDidNotStabilize } from '../errors/SortableScopeDidNotStabilize.js';
17
26
  export { default as SortableScopeLockWaitTimedOut } from '../errors/SortableScopeLockWaitTimedOut.js';
18
27
  export { default as ValidationError } from '../errors/ValidationError.js';
@@ -2,7 +2,7 @@ import { CompiledQuery, Selectable } from 'kysely';
2
2
  import DreamClassTransactionBuilder from './dream/DreamClassTransactionBuilder.js';
3
3
  import DreamInstanceTransactionBuilder from './dream/DreamInstanceTransactionBuilder.js';
4
4
  import DreamTransaction from './dream/DreamTransaction.js';
5
- import { DestroyOptions } from './dream/internal/destroyOptions.js';
5
+ import type { InstanceDestroyOptions, InstanceUpdateOptions } from './dream/internal/instanceMutationOptions.js';
6
6
  import LeftJoinLoadBuilder from './dream/LeftJoinLoadBuilder.js';
7
7
  import LoadBuilder from './dream/LoadBuilder.js';
8
8
  import Query from './dream/Query.js';
@@ -2478,7 +2478,7 @@ export default class Dream {
2478
2478
  * @param options.defaultScopesToBypass - An array of default scope names to bypass when cascade destroying. Defaults to an empty array
2479
2479
  * @returns The instance that was destroyed
2480
2480
  */
2481
- destroy<I extends Dream>(this: I, options?: DestroyOptions<I>): Promise<I>;
2481
+ destroy<I extends Dream>(this: I, options?: InstanceDestroyOptions<I>): Promise<I>;
2482
2482
  /**
2483
2483
  * Deletes the record represented by this instance
2484
2484
  * from the database, calling any destroy
@@ -2501,7 +2501,7 @@ export default class Dream {
2501
2501
  * @param options.defaultScopesToBypass - An array of default scope names to bypass when cascade destroying. Defaults to an empty array
2502
2502
  * @returns The instance that was destroyed
2503
2503
  */
2504
- reallyDestroy<I extends Dream>(this: I, options?: DestroyOptions<I>): Promise<I>;
2504
+ reallyDestroy<I extends Dream>(this: I, options?: InstanceDestroyOptions<I>): Promise<I>;
2505
2505
  /**
2506
2506
  * Undestroys a SoftDelete model, unsetting
2507
2507
  * the `deletedAt` field in the database.
@@ -2521,7 +2521,7 @@ export default class Dream {
2521
2521
  * @param options.defaultScopesToBypass - An array of default scope names to bypass when cascade undestroying (soft delete is always bypassed). Defaults to an empty array
2522
2522
  * @returns The undestroyed record
2523
2523
  */
2524
- undestroy<I extends Dream>(this: I, options?: DestroyOptions<I>): Promise<I>;
2524
+ undestroy<I extends Dream>(this: I, options?: InstanceDestroyOptions<I>): Promise<I>;
2525
2525
  /**
2526
2526
  * Returns true if the argument is the same Dream class
2527
2527
  * with the same primary key value.
@@ -2565,23 +2565,21 @@ export default class Dream {
2565
2565
  * @returns The created association
2566
2566
  */
2567
2567
  createAssociation<I extends Dream, AssociationName extends DreamAssociationNames<I>, PossibleArrayAssociationType extends I[AssociationName & keyof I], AssociationType extends PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, attributes?: UpdateableAssociationProperties<I, RestrictedAssociationType>): Promise<NonNullable<AssociationType>>;
2568
- destroyAssociation<I extends Dream, DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: DestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
2569
- destroyAssociation<I extends Dream, DB extends I['DB'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<I>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: DestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, null>): Promise<number>;
2570
- reallyDestroyAssociation<I extends Dream, DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: DestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
2571
- reallyDestroyAssociation<I extends Dream, DB extends I['DB'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<I>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: DestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, null>): Promise<number>;
2572
- undestroyAssociation<I extends Dream, DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: DestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
2573
- undestroyAssociation<I extends Dream, DB extends I['DB'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<I>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: DestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, null>): Promise<number>;
2568
+ destroyAssociation<I extends Dream, DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: InstanceDestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
2569
+ destroyAssociation<I extends Dream, DB extends I['DB'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<I>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: InstanceDestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, null>): Promise<number>;
2570
+ reallyDestroyAssociation<I extends Dream, DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: InstanceDestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
2571
+ reallyDestroyAssociation<I extends Dream, DB extends I['DB'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<I>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: InstanceDestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, null>): Promise<number>;
2572
+ undestroyAssociation<I extends Dream, DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: InstanceDestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
2573
+ undestroyAssociation<I extends Dream, DB extends I['DB'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<I>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: InstanceDestroyOptions<I> & JoinAndStatements<I, DB, Schema, AssociationTableName, null>): Promise<number>;
2574
2574
  associationQuery<I extends Dream, DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, joinAndStatements: JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Query<AssociationDream, DefaultQueryTypeOptions<AssociationDream, AssociationName & string>>;
2575
2575
  associationQuery<I extends Dream, DB extends I['DB'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<I>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, joinAndStatements?: JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, null>): Query<AssociationDream, DefaultQueryTypeOptions<AssociationDream, AssociationName & string>>;
2576
- updateAssociation<I extends Dream, DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table'], PossibleArrayAssociationType extends I[AssociationName & keyof I], AssociationType extends PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, attributes: UpdateableAssociationProperties<I, RestrictedAssociationType>, updateAssociationOptions: {
2576
+ updateAssociation<I extends Dream, DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table'], PossibleArrayAssociationType extends I[AssociationName & keyof I], AssociationType extends PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, attributes: UpdateableAssociationProperties<I, RestrictedAssociationType>, updateAssociationOptions: InstanceUpdateOptions & {
2577
2577
  bypassAllDefaultScopes?: boolean;
2578
2578
  defaultScopesToBypass?: AllDefaultScopeNames<I>[];
2579
- skipHooks?: boolean;
2580
2579
  } & JoinAndStatements<I, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
2581
- updateAssociation<I extends Dream, DB extends I['DB'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<I>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table'], PossibleArrayAssociationType extends I[AssociationName & keyof I], AssociationType extends PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, attributes: UpdateableAssociationProperties<I, RestrictedAssociationType>, updateAssociationOptions?: {
2580
+ updateAssociation<I extends Dream, DB extends I['DB'], Schema extends I['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<I>, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table'], PossibleArrayAssociationType extends I[AssociationName & keyof I], AssociationType extends PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, attributes: UpdateableAssociationProperties<I, RestrictedAssociationType>, updateAssociationOptions?: InstanceUpdateOptions & {
2582
2581
  bypassAllDefaultScopes?: boolean;
2583
2582
  defaultScopesToBypass?: AllDefaultScopeNames<I>[];
2584
- skipHooks?: boolean;
2585
2583
  } & JoinAndStatements<I, DB, Schema, AssociationTableName, null>): Promise<number>;
2586
2584
  /**
2587
2585
  * Sends data through for use as passthrough data
@@ -2683,23 +2681,32 @@ export default class Dream {
2683
2681
  * passthrough: { name: 'My Composition' },
2684
2682
  * required: { locale: 'de-DE' }
2685
2683
  * })
2684
+ *
2685
+ * // With a specific database connection
2686
+ * const comments = await post.association('comments', { connection: 'replica' })
2686
2687
  * ```
2687
2688
  *
2688
2689
  * @param associationName - The name of the BelongsTo, HasOne, or HasMany association
2689
- * @param options - Optional configuration for required and passthrough clauses
2690
+ * @param options - Optional configuration for required and passthrough clauses and the database connection
2690
2691
  * @param options.required - for associations with DreamConst.required `and` clauses
2691
2692
  * @param options.passthrough - for associations with DreamConst.passthrough `and` clauses
2693
+ * @param options.connection - the database connection to use when loading the association ('primary' or 'replica')
2692
2694
  * @returns The associated model instance(s) or null/empty array if not found
2693
2695
  */
2694
2696
  association<I extends Dream, MaybeAssociationName extends DreamBelongsToAssociationNames<I> | DreamHasOneAssociationNames<I> | DreamHasManyAssociationNames<I>, AssociationName extends MaybeAssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> | DreamAssociationNamesWithRequiredOnClauses<I> ? MaybeAssociationName : never, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table'], DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], PassthroughOnStatement extends Required<OnStatementForSpecificColumns<I, DB, Schema, AssociationTableName, PassthroughOnClauseKeys<Schema, TableName, AssociationName> & string[]>>, RequiredOnStatement extends Required<OnStatementForSpecificColumns<I, DB, Schema, AssociationTableName, RequiredOnClauseKeys<Schema, TableName, AssociationName> & string[]>>, Opts extends AssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> & DreamAssociationNamesWithRequiredOnClauses<I> ? {
2695
2697
  passthrough: PassthroughOnStatement;
2696
2698
  required: RequiredOnStatement;
2699
+ connection?: DbConnectionType;
2697
2700
  } : AssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> ? {
2698
2701
  passthrough: PassthroughOnStatement;
2702
+ connection?: DbConnectionType;
2699
2703
  } : AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I> ? {
2700
2704
  required: RequiredOnStatement;
2705
+ connection?: DbConnectionType;
2701
2706
  } : never, ReturnType extends AssociationName extends DreamHasManyAssociationNames<I> ? AssociationNameToDream<I, AssociationName>[] : AssociationNameToDream<I, AssociationName> | null>(this: I, associationName: AssociationName, options: Opts): Promise<ReturnType>;
2702
- association<I extends Dream, MaybeAssociationName extends DreamBelongsToAssociationNames<I> | DreamHasOneAssociationNames<I> | DreamHasManyAssociationNames<I>, AssociationName extends MaybeAssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> | DreamAssociationNamesWithRequiredOnClauses<I> ? never : MaybeAssociationName, ReturnType extends AssociationName extends DreamHasManyAssociationNames<I> ? AssociationNameToDream<I, AssociationName>[] : AssociationNameToDream<I, AssociationName> | null>(this: I, associationName: AssociationName): Promise<ReturnType>;
2707
+ association<I extends Dream, MaybeAssociationName extends DreamBelongsToAssociationNames<I> | DreamHasOneAssociationNames<I> | DreamHasManyAssociationNames<I>, AssociationName extends MaybeAssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> | DreamAssociationNamesWithRequiredOnClauses<I> ? never : MaybeAssociationName, ReturnType extends AssociationName extends DreamHasManyAssociationNames<I> ? AssociationNameToDream<I, AssociationName>[] : AssociationNameToDream<I, AssociationName> | null>(this: I, associationName: AssociationName, options?: {
2708
+ connection?: DbConnectionType;
2709
+ }): Promise<ReturnType>;
2703
2710
  /**
2704
2711
  * If the association is already loaded on the instance, it returns the loaded value
2705
2712
  * immediately without making a database query. If the association is not loaded,
@@ -2744,24 +2751,33 @@ export default class Dream {
2744
2751
  * passthrough: { name: 'My Composition' },
2745
2752
  * required: { locale: 'de-DE' }
2746
2753
  * })
2754
+ *
2755
+ * // With a specific database connection
2756
+ * const comments = await post.associationOrFail('comments', { connection: 'replica' })
2747
2757
  * ```
2748
2758
  *
2749
2759
  * @param associationName - The name of the BelongsTo, HasOne, or HasMany association
2750
- * @param options - Optional configuration for required and passthrough clauses
2760
+ * @param options - Optional configuration for required and passthrough clauses and the database connection
2751
2761
  * @param options.required - for associations with DreamConst.required `and` clauses
2752
2762
  * @param options.passthrough - for associations with DreamConst.passthrough `and` clauses
2763
+ * @param options.connection - the database connection to use when loading the association ('primary' or 'replica')
2753
2764
  * @returns The associated model instance(s) (never null for BelongsTo/HasOne)
2754
2765
  * @throws RecordNotFound if no associated record exists (BelongsTo/HasOne only)
2755
2766
  */
2756
2767
  associationOrFail<I extends Dream, MaybeAssociationName extends DreamBelongsToAssociationNames<I> | DreamHasOneAssociationNames<I> | DreamHasManyAssociationNames<I>, AssociationName extends MaybeAssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> | DreamAssociationNamesWithRequiredOnClauses<I> ? MaybeAssociationName : never, AssociationDream extends AssociationNameToDream<I, AssociationName>, AssociationTableName extends AssociationDream['table'], DB extends I['DB'], TableName extends I['table'], Schema extends I['schema'], PassthroughOnStatement extends Required<OnStatementForSpecificColumns<I, DB, Schema, AssociationTableName, PassthroughOnClauseKeys<Schema, TableName, AssociationName> & string[]>>, RequiredOnStatement extends Required<OnStatementForSpecificColumns<I, DB, Schema, AssociationTableName, RequiredOnClauseKeys<Schema, TableName, AssociationName> & string[]>>, Opts extends AssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> & DreamAssociationNamesWithRequiredOnClauses<I> ? {
2757
2768
  passthrough: PassthroughOnStatement;
2758
2769
  required: RequiredOnStatement;
2770
+ connection?: DbConnectionType;
2759
2771
  } : AssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> ? {
2760
2772
  passthrough: PassthroughOnStatement;
2773
+ connection?: DbConnectionType;
2761
2774
  } : AssociationName extends DreamAssociationNamesWithRequiredOnClauses<I> ? {
2762
2775
  required: RequiredOnStatement;
2776
+ connection?: DbConnectionType;
2763
2777
  } : never, ReturnType extends AssociationName extends DreamHasManyAssociationNames<I> ? AssociationNameToDream<I, AssociationName>[] : AssociationNameToDream<I, AssociationName>>(this: I, associationName: AssociationName, options: Opts): Promise<ReturnType>;
2764
- associationOrFail<I extends Dream, MaybeAssociationName extends DreamBelongsToAssociationNames<I> | DreamHasOneAssociationNames<I> | DreamHasManyAssociationNames<I>, AssociationName extends MaybeAssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> | DreamAssociationNamesWithRequiredOnClauses<I> ? never : MaybeAssociationName, ReturnType extends AssociationName extends DreamHasManyAssociationNames<I> ? AssociationNameToDream<I, AssociationName>[] : AssociationNameToDream<I, AssociationName>>(this: I, associationName: AssociationName): Promise<ReturnType>;
2778
+ associationOrFail<I extends Dream, MaybeAssociationName extends DreamBelongsToAssociationNames<I> | DreamHasOneAssociationNames<I> | DreamHasManyAssociationNames<I>, AssociationName extends MaybeAssociationName extends DreamAssociationNamesWithPassthroughOnClauses<I> | DreamAssociationNamesWithRequiredOnClauses<I> ? never : MaybeAssociationName, ReturnType extends AssociationName extends DreamHasManyAssociationNames<I> ? AssociationNameToDream<I, AssociationName>[] : AssociationNameToDream<I, AssociationName>>(this: I, associationName: AssociationName, options?: {
2779
+ connection?: DbConnectionType;
2780
+ }): Promise<ReturnType>;
2765
2781
  /**
2766
2782
  * Recursively loads all Dream associations referenced by `rendersOne` and `rendersMany`
2767
2783
  * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
@@ -2986,9 +3002,7 @@ export default class Dream {
2986
3002
  * @param __namedParameters.skipHooks - if true, will skip applying model hooks. Defaults to false
2987
3003
  * @returns void
2988
3004
  */
2989
- update<I extends Dream>(this: I, attributes: UpdateableProperties<I>, { skipHooks }?: {
2990
- skipHooks?: boolean;
2991
- }): Promise<void>;
3005
+ update<I extends Dream>(this: I, attributes: UpdateableProperties<I>, { skipHooks }?: InstanceUpdateOptions): Promise<void>;
2992
3006
  /**
2993
3007
  * Applies all attribute changes passed to the dream,
2994
3008
  * bypassing any custom-defined setters,
@@ -3012,9 +3026,7 @@ export default class Dream {
3012
3026
  * @param __namedParameters.skipHooks - if true, will skip applying model hooks. Defaults to false
3013
3027
  * @returns - void
3014
3028
  */
3015
- updateAttributes<I extends Dream>(this: I, attributes: UpdateableProperties<I>, { skipHooks }?: {
3016
- skipHooks?: boolean;
3017
- }): Promise<void>;
3029
+ updateAttributes<I extends Dream>(this: I, attributes: UpdateableProperties<I>, { skipHooks }?: InstanceUpdateOptions): Promise<void>;
3018
3030
  /**
3019
3031
  * Flags a dream model so that it does not
3020
3032
  * actually destroy when in a destroy phase.
@@ -63,18 +63,93 @@ export default class Decorators<TD extends typeof Dream, T extends Dream = Insta
63
63
  default?: boolean;
64
64
  }): any;
65
65
  /**
66
- * The Sortable decorator automatically adjusts the value of the columns
67
- * corresponding to the decorated field.
68
- *
69
- * NOTE: the Sortable decorator may not be used in STI child models (it may be used in the STI base class)
66
+ * Marks an integer column as a sortable position: Dream keeps the positions of
67
+ * every record in a sort scope contiguous, starting at 1, as records are
68
+ * created, moved, destroyed and undestroyed.
70
69
  *
71
70
  * ```ts
72
- * class Balloon {
71
+ * class Post extends ApplicationModel {
73
72
  * @deco.Sortable({ scope: 'user' })
74
- * public position: DreamColumn<Balloon, 'position'>
73
+ * public position: number
74
+ * }
75
+ *
76
+ * await post.update({ position: 2 }) // the records at 2 and above shift up
77
+ * ```
78
+ *
79
+ * A position past the end of the scope is clamped to the end, and a position
80
+ * below 1 — or none at all — lands the record at the end.
81
+ *
82
+ * **A save that changes the sort scope ignores a position given alongside it.**
83
+ * The record lands at the end of the scope it moves into, whatever position the
84
+ * same `update` supplied:
85
+ *
86
+ * ```ts
87
+ * await post.update({ user: otherUser, position: 1 })
88
+ * // post is now the last record in otherUser's scope, not the first
89
+ * ```
90
+ *
91
+ * Move it in two saves to place it: `await post.update({ user: otherUser })`,
92
+ * then `await post.update({ position: 1 })`.
93
+ *
94
+ * Sortable requires a query driver that supports advisory transaction locks —
95
+ * the `PostgresQueryDriver` does — since every position write serializes the
96
+ * writers of its sort scope on one. This concurrency guarantee first shipped
97
+ * in Dream 2.28.0 and begins only after every writer is running a lock-aware
98
+ * release. During the first rolling deployment, older processes take no
99
+ * advisory locks and can still race the upgraded processes.
100
+ *
101
+ * All participating Dream writers of one hot scope serialize. Ordinary saves
102
+ * and destroys with `skipHooks`, direct query writes, raw SQL, and older
103
+ * pre-lock Dream processes bypass Sortable maintenance and do not participate
104
+ * in its locking protocol. Undestroy still performs stabilized Sortable
105
+ * maintenance and acquires scope locks with `skipHooks: true`; locked query
106
+ * batches likewise acquire their scope locks during preflight, before any
107
+ * per-record callbacks, even when those callbacks skip hooks. A waiter that
108
+ * enters the protocol holds a pooled connection until the holder finishes or
109
+ * `sortableScopeLockTimeout` expires; sustained contention can therefore
110
+ * produce latency waves, timeouts, and pool starvation. Keep database work
111
+ * inside the lock window short, and avoid cross-region database latency for
112
+ * hot scopes.
113
+ *
114
+ * `SortableScopeDidNotStabilize` and `SortableScopeLockWaitTimedOut` are the
115
+ * expected Dream errors an application may choose to retry. Database deadlocks
116
+ * remain native adapter errors (for example PostgreSQL code `40P01` or MySQL
117
+ * errno `1213`) so their driver fields and stacks remain intact. A database
118
+ * deadlock aborts the whole transaction: retry by starting the transaction
119
+ * again from the beginning, never by continuing it or retrying only the failed
120
+ * statement. Recurrent deadlocks call for shorter transactions or a consistent
121
+ * multi-resource acquisition order; they do not by themselves prove Sortable
122
+ * caused the cycle.
123
+ *
124
+ * ```ts
125
+ * import {
126
+ * SortableScopeDidNotStabilize,
127
+ * SortableScopeLockWaitTimedOut,
128
+ * } from '@rvoh/dream/errors'
129
+ *
130
+ * const runTransaction = async () =>
131
+ * await ApplicationModel.transaction(async txn => {
132
+ * // bind every operation in the attempt to txn
133
+ * })
134
+ *
135
+ * try {
136
+ * await runTransaction()
137
+ * } catch (error) {
138
+ * const adapterDeadlock =
139
+ * (error as { code?: string }).code === '40P01' ||
140
+ * (error as { errno?: number }).errno === 1213
141
+ * const retryable =
142
+ * error instanceof SortableScopeDidNotStabilize ||
143
+ * error instanceof SortableScopeLockWaitTimedOut ||
144
+ * adapterDeadlock
145
+ * if (!retryable) throw error
146
+ *
147
+ * await runTransaction() // one whole-transaction retry
75
148
  * }
76
149
  * ```
77
150
  *
151
+ * NOTE: the Sortable decorator may not be used in STI child models (it may be used in the STI base class)
152
+ *
78
153
  * @param opts - Configuration options for the sortable decorator
79
154
  * @param opts.scope - The column, association, or combination thereof which you would like to restrict the incrementing logic to. Can be a single column name, a single belongs-to association name, or an array of column/association names
80
155
  * @returns A Sortable decorator
@@ -1,35 +1,8 @@
1
1
  /**
2
- * Marks an integer column as a sortable position: Dream keeps the positions of
3
- * every record in a sort scope contiguous, starting at 1, as records are
4
- * created, moved, destroyed and undestroyed.
5
- *
6
- * ```ts
7
- * class Post extends ApplicationModel {
8
- * @deco.Sortable({ scope: 'user' })
9
- * public position: number
10
- * }
11
- *
12
- * await post.update({ position: 2 }) // the records at 2 and above shift up
13
- * ```
14
- *
15
- * A position past the end of the scope is clamped to the end, and a position
16
- * below 1 — or none at all — lands the record at the end.
17
- *
18
- * **A save that changes the sort scope ignores a position given alongside it.**
19
- * The record lands at the end of the scope it moves into, whatever position the
20
- * same `update` supplied:
21
- *
22
- * ```ts
23
- * await post.update({ user: otherUser, position: 1 })
24
- * // post is now the last record in otherUser's scope, not the first
25
- * ```
26
- *
27
- * Move it in two saves to place it: `await post.update({ user: otherUser })`,
28
- * then `await post.update({ position: 1 })`.
29
- *
30
- * Sortable requires a query driver that supports advisory transaction locks —
31
- * the `PostgresQueryDriver` does — since every position write serializes the
32
- * writers of its sort scope on one.
2
+ * The implementation behind `@deco.Sortable`. The decorator's semantics —
3
+ * position clamping, what a scope-changing save does with a position given
4
+ * alongside it, and the advisory-lock concurrency protocol — are documented on
5
+ * `Decorators#Sortable`, which is where a consumer reads them.
33
6
  */
34
7
  export default function Sortable(opts?: SortableOpts): any;
35
8
  interface SortableOpts {
@@ -4,7 +4,7 @@ import { AllDefaultScopeNames, AssociationNameToDream, DreamAssociationNames, Dr
4
4
  import { DefaultQueryTypeOptions, LoadForModifierFn, QueryWithJoinedAssociationsType } from '../types/query.js';
5
5
  import { JoinedAssociation, JoinedAssociationsTypeFromAssociations, VariadicJoinsArgs, VariadicLeftJoinLoadArgs, VariadicLoadArgs } from '../types/variadic.js';
6
6
  import DreamTransaction from './DreamTransaction.js';
7
- import { DestroyOptions } from './internal/destroyOptions.js';
7
+ import type { InstanceDestroyOptions, InstanceUpdateOptions } from './internal/instanceMutationOptions.js';
8
8
  import LeftJoinLoadBuilder from './LeftJoinLoadBuilder.js';
9
9
  import LoadBuilder from './LoadBuilder.js';
10
10
  import Query from './Query.js';
@@ -178,7 +178,7 @@ export default class DreamInstanceTransactionBuilder<DreamInstance extends Dream
178
178
  * @param options.defaultScopesToBypass - An array of default scope names to bypass when cascade destroying. Defaults to an empty array
179
179
  * @returns The instance that was destroyed
180
180
  */
181
- destroy<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, options?: DestroyOptions<DreamInstance>): Promise<DreamInstance>;
181
+ destroy<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, options?: InstanceDestroyOptions<DreamInstance>): Promise<DreamInstance>;
182
182
  /**
183
183
  * Deletes the record represented by this instance
184
184
  * from the database, calling any destroy
@@ -198,7 +198,7 @@ export default class DreamInstanceTransactionBuilder<DreamInstance extends Dream
198
198
  * @param options.defaultScopesToBypass - An array of default scope names to bypass when cascade destroying. Defaults to an empty array
199
199
  * @returns The instance that was destroyed
200
200
  */
201
- reallyDestroy<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, options?: DestroyOptions<DreamInstance>): Promise<DreamInstance>;
201
+ reallyDestroy<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, options?: InstanceDestroyOptions<DreamInstance>): Promise<DreamInstance>;
202
202
  /**
203
203
  * Undestroys a SoftDelete model, unsetting
204
204
  * the `deletedAt` field in the database.
@@ -218,7 +218,7 @@ export default class DreamInstanceTransactionBuilder<DreamInstance extends Dream
218
218
  * @param options.defaultScopesToBypass - An array of default scope names to bypass when cascade undestroying (soft delete is always bypassed). Defaults to an empty array
219
219
  * @returns The undestroyed instance
220
220
  */
221
- undestroy<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, options?: DestroyOptions<DreamInstance>): Promise<DreamInstance>;
221
+ undestroy<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, options?: InstanceDestroyOptions<DreamInstance>): Promise<DreamInstance>;
222
222
  /**
223
223
  * Applies all attribute changes passed to the Dream
224
224
  * instance, leveraging any custom-defined setters,
@@ -242,9 +242,7 @@ export default class DreamInstanceTransactionBuilder<DreamInstance extends Dream
242
242
  * @param opts.skipHooks - if true, will skip applying model hooks. Defaults to false
243
243
  * @returns void
244
244
  */
245
- update<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, attributes: UpdateableProperties<DreamInstance>, { skipHooks }?: {
246
- skipHooks?: boolean;
247
- }): Promise<void>;
245
+ update<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, attributes: UpdateableProperties<DreamInstance>, { skipHooks }?: InstanceUpdateOptions): Promise<void>;
248
246
  /**
249
247
  * Applies all attribute changes passed to the dream,
250
248
  * bypassing any custom-defined setters,
@@ -269,9 +267,7 @@ export default class DreamInstanceTransactionBuilder<DreamInstance extends Dream
269
267
  * @param opts.skipHooks - if true, will skip applying model hooks. Defaults to false
270
268
  * @returns - void
271
269
  */
272
- updateAttributes<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, attributes: UpdateableProperties<DreamInstance>, { skipHooks }?: {
273
- skipHooks?: boolean;
274
- }): Promise<void>;
270
+ updateAttributes<I extends DreamInstanceTransactionBuilder<DreamInstance>>(this: I, attributes: UpdateableProperties<DreamInstance>, { skipHooks }?: InstanceUpdateOptions): Promise<void>;
275
271
  /**
276
272
  * Reloads an instance, refreshing all it's attribute values
277
273
  * to those in the database.
@@ -432,15 +428,13 @@ export default class DreamInstanceTransactionBuilder<DreamInstance extends Dream
432
428
  associationOrFail<I extends DreamInstanceTransactionBuilder<DreamInstance>, MaybeAssociationName extends DreamBelongsToAssociationNames<DreamInstance> | DreamHasOneAssociationNames<DreamInstance> | DreamHasManyAssociationNames<DreamInstance>, AssociationName extends MaybeAssociationName extends DreamAssociationNamesWithPassthroughOnClauses<DreamInstance> | DreamAssociationNamesWithRequiredOnClauses<DreamInstance> ? never : MaybeAssociationName, ReturnType extends AssociationName extends DreamHasManyAssociationNames<DreamInstance> ? AssociationNameToDream<DreamInstance, AssociationName>[] : AssociationNameToDream<DreamInstance, AssociationName>>(this: I, associationName: AssociationName): Promise<ReturnType>;
433
429
  associationQuery<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<DreamInstance>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, joinAndStatements: JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Query<AssociationDream, DefaultQueryTypeOptions<AssociationDream, AssociationName & string>>;
434
430
  associationQuery<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<DreamInstance>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, joinAndStatements?: JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, null>): Query<AssociationDream, DefaultQueryTypeOptions<AssociationDream, AssociationName & string>>;
435
- updateAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<DreamInstance>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table'], PossibleArrayAssociationType = DreamInstance[AssociationName & keyof DreamInstance], AssociationType = PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never = AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, attributes: UpdateableAssociationProperties<DreamInstance, RestrictedAssociationType>, updateAssociationOptions: {
431
+ updateAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<DreamInstance>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table'], PossibleArrayAssociationType = DreamInstance[AssociationName & keyof DreamInstance], AssociationType = PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never = AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, attributes: UpdateableAssociationProperties<DreamInstance, RestrictedAssociationType>, updateAssociationOptions: InstanceUpdateOptions & {
436
432
  bypassAllDefaultScopes?: boolean;
437
433
  defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[];
438
- skipHooks?: boolean;
439
434
  } & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
440
- updateAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<DreamInstance>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table'], PossibleArrayAssociationType = DreamInstance[AssociationName & keyof DreamInstance], AssociationType = PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never = AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, attributes: UpdateableAssociationProperties<DreamInstance, RestrictedAssociationType>, updateAssociationOptions?: {
435
+ updateAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<DreamInstance>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table'], PossibleArrayAssociationType = DreamInstance[AssociationName & keyof DreamInstance], AssociationType = PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never = AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, attributes: UpdateableAssociationProperties<DreamInstance, RestrictedAssociationType>, updateAssociationOptions?: InstanceUpdateOptions & {
441
436
  bypassAllDefaultScopes?: boolean;
442
437
  defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[];
443
- skipHooks?: boolean;
444
438
  } & JoinAndStatements<DreamInstance, DB, Schema, AssociationTableName, null>): Promise<number>;
445
439
  /**
446
440
  * Creates an association for an instance. Automatically
@@ -458,12 +452,12 @@ export default class DreamInstanceTransactionBuilder<DreamInstance extends Dream
458
452
  * @returns The created association
459
453
  */
460
454
  createAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, AssociationName extends DreamAssociationNames<DreamInstance>, PossibleArrayAssociationType = DreamInstance[AssociationName & keyof DreamInstance], AssociationType = PossibleArrayAssociationType extends (infer ElementType)[] ? ElementType : PossibleArrayAssociationType, RestrictedAssociationType extends AssociationType extends Dream ? AssociationType : never = AssociationType extends Dream ? AssociationType : never>(this: I, associationName: AssociationName, opts?: UpdateableAssociationProperties<DreamInstance, RestrictedAssociationType>): Promise<NonNullable<AssociationType>>;
461
- destroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<DreamInstance>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: DestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
462
- destroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<DreamInstance>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: DestroyOptions<DreamInstance> & JoinAndStatements<DreamInstance, DB, Schema, AssociationTableName, null>): Promise<number>;
463
- reallyDestroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<DreamInstance>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: DestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
464
- reallyDestroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<DreamInstance>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: DestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, null>): Promise<number>;
465
- undestroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<DreamInstance>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: DestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
466
- undestroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<DreamInstance>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: DestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, null>): Promise<number>;
455
+ destroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<DreamInstance>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: InstanceDestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
456
+ destroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<DreamInstance>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: InstanceDestroyOptions<DreamInstance> & JoinAndStatements<DreamInstance, DB, Schema, AssociationTableName, null>): Promise<number>;
457
+ reallyDestroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<DreamInstance>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: InstanceDestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
458
+ reallyDestroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<DreamInstance>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: InstanceDestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, null>): Promise<number>;
459
+ undestroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithRequiredOnClauses<DreamInstance>, RequiredOnClauseKeysForThisAssociation extends RequiredOnClauseKeys<Schema, TableName, AssociationName>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options: InstanceDestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, RequiredOnClauseKeysForThisAssociation>): Promise<number>;
460
+ undestroyAssociation<I extends DreamInstanceTransactionBuilder<DreamInstance>, DB extends DreamInstance['DB'], Schema extends DreamInstance['schema'], AssociationName extends DreamAssociationNamesWithoutRequiredOnClauses<DreamInstance>, AssociationDream extends AssociationNameToDream<DreamInstance, AssociationName>, AssociationTableName extends AssociationDream['table']>(this: I, associationName: AssociationName, options?: InstanceDestroyOptions<DreamInstance> & JoinAndStatements<AssociationDream, DB, Schema, AssociationTableName, null>): Promise<number>;
467
461
  /**
468
462
  * @internal
469
463
  *