@rvoh/dream 2.0.0-alpha.3 → 2.0.0-alpha.5

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 (191) hide show
  1. package/dist/cjs/src/Dream.js +0 -101
  2. package/dist/cjs/src/db/migration-helpers/DreamMigrationHelpers.js +4 -1
  3. package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +0 -48
  4. package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +0 -50
  5. package/dist/cjs/src/dream/LeftJoinLoadBuilder.js +0 -49
  6. package/dist/cjs/src/dream/Query.js +0 -57
  7. package/dist/esm/src/Dream.js +0 -101
  8. package/dist/esm/src/db/migration-helpers/DreamMigrationHelpers.js +4 -1
  9. package/dist/esm/src/dream/DreamClassTransactionBuilder.js +0 -48
  10. package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +0 -50
  11. package/dist/esm/src/dream/LeftJoinLoadBuilder.js +0 -49
  12. package/dist/esm/src/dream/Query.js +0 -57
  13. package/dist/types/src/Dream.d.ts +0 -106
  14. package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +0 -55
  15. package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +0 -48
  16. package/dist/types/src/dream/LeftJoinLoadBuilder.d.ts +1 -48
  17. package/dist/types/src/dream/Query.d.ts +0 -54
  18. package/docs/assets/search.js +1 -1
  19. package/docs/classes/db.DreamMigrationHelpers.html +9 -9
  20. package/docs/classes/db.KyselyQueryDriver.html +30 -30
  21. package/docs/classes/db.PostgresQueryDriver.html +31 -31
  22. package/docs/classes/db.QueryDriverBase.html +29 -29
  23. package/docs/classes/errors.CheckConstraintViolation.html +3 -3
  24. package/docs/classes/errors.ColumnOverflow.html +3 -3
  25. package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
  26. package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
  27. package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
  28. package/docs/classes/errors.GlobalNameNotSet.html +3 -3
  29. package/docs/classes/errors.InvalidCalendarDate.html +2 -2
  30. package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
  31. package/docs/classes/errors.NonLoadedAssociation.html +3 -3
  32. package/docs/classes/errors.NotNullViolation.html +3 -3
  33. package/docs/classes/errors.RecordNotFound.html +3 -3
  34. package/docs/classes/errors.ValidationError.html +3 -3
  35. package/docs/classes/index.CalendarDate.html +2 -2
  36. package/docs/classes/index.Decorators.html +19 -19
  37. package/docs/classes/index.Dream.html +188 -229
  38. package/docs/classes/index.DreamApp.html +5 -5
  39. package/docs/classes/index.DreamTransaction.html +2 -2
  40. package/docs/classes/index.Env.html +2 -2
  41. package/docs/classes/index.Query.html +66 -87
  42. package/docs/classes/system.CliFileWriter.html +2 -2
  43. package/docs/classes/system.DreamBin.html +2 -2
  44. package/docs/classes/system.DreamCLI.html +5 -5
  45. package/docs/classes/system.DreamImporter.html +2 -2
  46. package/docs/classes/system.DreamLogos.html +2 -2
  47. package/docs/classes/system.DreamSerializerBuilder.html +8 -8
  48. package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
  49. package/docs/classes/utils.Encrypt.html +2 -2
  50. package/docs/classes/utils.Range.html +2 -2
  51. package/docs/functions/db.closeAllDbConnections.html +1 -1
  52. package/docs/functions/db.dreamDbConnections.html +1 -1
  53. package/docs/functions/db.untypedDb.html +1 -1
  54. package/docs/functions/db.validateColumn.html +1 -1
  55. package/docs/functions/db.validateTable.html +1 -1
  56. package/docs/functions/errors.pgErrorType.html +1 -1
  57. package/docs/functions/index.DreamSerializer.html +1 -1
  58. package/docs/functions/index.ObjectSerializer.html +1 -1
  59. package/docs/functions/index.ReplicaSafe.html +1 -1
  60. package/docs/functions/index.STI.html +1 -1
  61. package/docs/functions/index.SoftDelete.html +1 -1
  62. package/docs/functions/utils.camelize.html +1 -1
  63. package/docs/functions/utils.capitalize.html +1 -1
  64. package/docs/functions/utils.cloneDeepSafe.html +1 -1
  65. package/docs/functions/utils.compact.html +1 -1
  66. package/docs/functions/utils.groupBy.html +1 -1
  67. package/docs/functions/utils.hyphenize.html +1 -1
  68. package/docs/functions/utils.intersection.html +1 -1
  69. package/docs/functions/utils.isEmpty.html +1 -1
  70. package/docs/functions/utils.normalizeUnicode.html +1 -1
  71. package/docs/functions/utils.pascalize.html +1 -1
  72. package/docs/functions/utils.percent.html +1 -1
  73. package/docs/functions/utils.range-1.html +1 -1
  74. package/docs/functions/utils.round.html +1 -1
  75. package/docs/functions/utils.sanitizeString.html +1 -1
  76. package/docs/functions/utils.snakeify.html +1 -1
  77. package/docs/functions/utils.sort.html +1 -1
  78. package/docs/functions/utils.sortBy.html +1 -1
  79. package/docs/functions/utils.sortObjectByKey.html +1 -1
  80. package/docs/functions/utils.sortObjectByValue.html +1 -1
  81. package/docs/functions/utils.uncapitalize.html +1 -1
  82. package/docs/functions/utils.uniq.html +1 -1
  83. package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
  84. package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
  85. package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
  86. package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
  87. package/docs/interfaces/types.BelongsToStatement.html +2 -2
  88. package/docs/interfaces/types.DecoratorContext.html +2 -2
  89. package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
  90. package/docs/interfaces/types.DreamAppOpts.html +2 -2
  91. package/docs/interfaces/types.EncryptOptions.html +2 -2
  92. package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
  93. package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
  94. package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
  95. package/docs/modules/db.html +1 -1
  96. package/docs/modules/errors.html +1 -1
  97. package/docs/modules/index.html +1 -1
  98. package/docs/modules/openapi.html +1 -1
  99. package/docs/modules/system.html +1 -1
  100. package/docs/modules/types.html +1 -1
  101. package/docs/modules/utils.html +1 -1
  102. package/docs/types/index.DateTime.html +1 -1
  103. package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
  104. package/docs/types/openapi.OpenapiAllTypes.html +1 -1
  105. package/docs/types/openapi.OpenapiFormats.html +1 -1
  106. package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
  107. package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
  108. package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
  109. package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
  110. package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
  111. package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
  112. package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
  113. package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
  114. package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
  115. package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +1 -1
  116. package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +1 -1
  117. package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +1 -1
  118. package/docs/types/openapi.OpenapiSchemaExpressionRef.html +1 -1
  119. package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  120. package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
  121. package/docs/types/openapi.OpenapiSchemaNull.html +1 -1
  122. package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
  123. package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
  124. package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
  125. package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
  126. package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
  127. package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  128. package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
  129. package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
  130. package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
  131. package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
  132. package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
  133. package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
  134. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  135. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  136. package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  137. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  138. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  139. package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  140. package/docs/types/openapi.OpenapiSchemaString.html +1 -1
  141. package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
  142. package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
  143. package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
  144. package/docs/types/openapi.OpenapiTypeField.html +1 -1
  145. package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
  146. package/docs/types/types.Camelized.html +1 -1
  147. package/docs/types/types.DbConnectionType.html +1 -1
  148. package/docs/types/types.DbTypes.html +1 -1
  149. package/docs/types/types.DreamAssociationMetadata.html +1 -1
  150. package/docs/types/types.DreamAttributes.html +1 -1
  151. package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
  152. package/docs/types/types.DreamClassColumn.html +1 -1
  153. package/docs/types/types.DreamColumn.html +1 -1
  154. package/docs/types/types.DreamColumnNames.html +1 -1
  155. package/docs/types/types.DreamLogLevel.html +1 -1
  156. package/docs/types/types.DreamLogger.html +1 -1
  157. package/docs/types/types.DreamModelSerializerType.html +1 -1
  158. package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
  159. package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
  160. package/docs/types/types.DreamParamSafeAttributes.html +1 -1
  161. package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
  162. package/docs/types/types.DreamSerializable.html +1 -1
  163. package/docs/types/types.DreamSerializableArray.html +1 -1
  164. package/docs/types/types.DreamSerializerKey.html +1 -1
  165. package/docs/types/types.DreamSerializers.html +1 -1
  166. package/docs/types/types.DreamVirtualColumns.html +1 -1
  167. package/docs/types/types.EncryptAlgorithm.html +1 -1
  168. package/docs/types/types.HasManyStatement.html +1 -1
  169. package/docs/types/types.HasOneStatement.html +1 -1
  170. package/docs/types/types.Hyphenized.html +1 -1
  171. package/docs/types/types.Pascalized.html +1 -1
  172. package/docs/types/types.RoundingPrecision.html +1 -1
  173. package/docs/types/types.SerializerCasing.html +1 -1
  174. package/docs/types/types.SimpleObjectSerializerType.html +1 -1
  175. package/docs/types/types.Snakeified.html +1 -1
  176. package/docs/types/types.UpdateableAssociationProperties.html +1 -1
  177. package/docs/types/types.UpdateableProperties.html +1 -1
  178. package/docs/types/types.ValidationType.html +1 -1
  179. package/docs/types/types.ViewModel.html +1 -1
  180. package/docs/types/types.ViewModelClass.html +1 -1
  181. package/docs/types/types.WhereStatementForDream.html +1 -1
  182. package/docs/types/types.WhereStatementForDreamClass.html +1 -1
  183. package/docs/variables/index.DateTime-1.html +1 -1
  184. package/docs/variables/index.DreamConst.html +1 -1
  185. package/docs/variables/index.ops.html +1 -1
  186. package/docs/variables/openapi.openapiPrimitiveTypes-1.html +1 -1
  187. package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +1 -1
  188. package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
  189. package/docs/variables/types.TRIGRAM_OPERATORS.html +1 -1
  190. package/docs/variables/types.primaryKeyTypes.html +1 -1
  191. package/package.json +1 -1
@@ -1403,56 +1403,6 @@ export default class Dream {
1403
1403
  static preloadFor(serializerKey, modifierFn) {
1404
1404
  return this.query().preloadFor(serializerKey, modifierFn);
1405
1405
  }
1406
- /**
1407
- * Recursively preloads all Dream associations referenced by `rendersOne` and `rendersMany`
1408
- * in a DreamSerializer using left join preloading. This traverses the entire content tree
1409
- * of serializers to automatically load all necessary associations in a single query,
1410
- * eliminating N+1 query problems and removing the need to manually remember which
1411
- * associations to preload for serialization.
1412
- *
1413
- * This method decouples data loading code from data rendering code by having the serializer
1414
- * (rendering code) inform the query (loading code) about which associations are needed.
1415
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
1416
- * modifying existing ones - the loading code automatically adapts without requiring
1417
- * corresponding modifications to left join preload statements.
1418
- *
1419
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
1420
- * automatically left join preloads all associations that will be needed during serialization.
1421
- *
1422
- * Note: Left join preloading loads all data in a single SQL query but has trade-offs compared
1423
- * to regular preloading. See {@link Dream.leftJoinPreload} for details about limitations.
1424
- *
1425
- * ```ts
1426
- * // Instead of manually specifying all associations:
1427
- * await User.leftJoinPreload('posts', 'comments', 'replies').all()
1428
- *
1429
- * // Automatically left join preload everything needed for serialization:
1430
- * await User.leftJoinPreloadFor('summary').all()
1431
- *
1432
- * // Add where conditions to specific associations during left join preloading:
1433
- * await User.leftJoinPreloadFor('detailed', (associationName, dreamClass) => {
1434
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
1435
- * return { and: { published: true } }
1436
- * }
1437
- * }).all()
1438
- *
1439
- * // Skip left join preloading specific associations to handle them manually:
1440
- * await User.leftJoinPreloadFor('summary', (associationName, dreamClass) => {
1441
- * if (dreamClass.typeof(User) && associationName === 'posts') {
1442
- * return 'omit' // Handle posts preloading separately with custom logic
1443
- * }
1444
- * })
1445
- * .preload('posts', { and: { featured: true } }) // Custom preloading instead
1446
- * .all()
1447
- * ```
1448
- *
1449
- * @param serializerKey - The serializer key to use for determining which associations to preload.
1450
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
1451
- * @returns A Query with all serialization associations left join preloaded
1452
- */
1453
- static leftJoinPreloadFor(serializerKey, modifierFn) {
1454
- return this.query().leftJoinPreloadFor(serializerKey, modifierFn);
1455
- }
1456
1406
  /**
1457
1407
  * Returns a new Query instance with the provided
1458
1408
  * inner join statement attached
@@ -3375,57 +3325,6 @@ export default class Dream {
3375
3325
  leftJoinLoad(...args) {
3376
3326
  return new LeftJoinLoadBuilder(this).leftJoinLoad(...args);
3377
3327
  }
3378
- /**
3379
- * Recursively loads all Dream associations referenced by `rendersOne` and `rendersMany`
3380
- * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
3381
- * load all necessary associations, eliminating N+1 query problems and removing the need to
3382
- * manually remember which associations to preload for serialization.
3383
- *
3384
- * This method decouples data loading code from data rendering code by having the serializer
3385
- * (rendering code) inform the query (loading code) about which associations are needed.
3386
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
3387
- * modifying existing ones - the loading code automatically adapts without requiring
3388
- * corresponding modifications to preload statements.
3389
- *
3390
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
3391
- * automatically preloads all associations that will be needed during serialization.
3392
- *
3393
- * Note: Left join loading loads all data in a single SQL query but has trade-offs compared
3394
- * to regular preloading. See {@link Dream.leftJoinPreload} for details about limitations.
3395
- *
3396
- * ```ts
3397
- * // Instead of manually specifying all associations:
3398
- * await User.preload('posts', 'comments', 'replies').all()
3399
- *
3400
- * // Automatically preload everything needed for serialization:
3401
- * await user.leftJoinLoadFor('summary').execute()
3402
- *
3403
- * // Add where conditions to specific associations during preloading:
3404
- * await user.leftJoinLoadFor('detailed', (associationName, dreamClass) => {
3405
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
3406
- * return { and: { published: true } }
3407
- * }
3408
- * })
3409
- * .execute()
3410
- *
3411
- * // Skip preloading specific associations to handle them manually:
3412
- * await user
3413
- * .loadFor('summary', (associationName, dreamClass) => {
3414
- * if (dreamClass.typeof(User) && associationName === 'posts') {
3415
- * return 'omit' // Handle posts preloading separately with custom logic
3416
- * }
3417
- * })
3418
- * .load('posts', { and: { featured: true } }) // Custom preloading
3419
- * .execute()
3420
- * ```
3421
- *
3422
- * @param serializerKey - The serializer key to use for determining which associations to preload.
3423
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
3424
- * @returns A Query with all serialization associations preloaded
3425
- */
3426
- leftJoinLoadFor(serializerKey, modifierFn) {
3427
- return new LeftJoinLoadBuilder(this)['leftJoinLoadFor'](serializerKey, modifierFn);
3428
- }
3429
3328
  /**
3430
3329
  * Returns true if the association specified has
3431
3330
  * been loaded on this instance
@@ -17,7 +17,10 @@ export default class DreamMigrationHelpers {
17
17
  */
18
18
  static async renameTable(db, from, to) {
19
19
  await db.schema.alterTable(from).renameTo(to).execute();
20
- await sql `ALTER SEQUENCE ${from}_id_seq RENAME TO ${to}_id_seq`.execute(db);
20
+ const fromSequenceName = `${from}_id_seq`;
21
+ const toSequenceName = `${to}_id_seq`;
22
+ const sqlStatement = `ALTER SEQUENCE ${fromSequenceName} RENAME TO ${toSequenceName}`;
23
+ await sql.raw(sqlStatement).execute(db);
21
24
  }
22
25
  /**
23
26
  * Unique indexes cannot be populated by the same value even within a transaction,
@@ -362,54 +362,6 @@ export default class DreamClassTransactionBuilder {
362
362
  leftJoinPreload(...args) {
363
363
  return this.queryInstance().leftJoinPreload(...args);
364
364
  }
365
- /**
366
- * Recursively left-join-preloads all Dream associations referenced by `rendersOne` and `rendersMany`
367
- * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
368
- * load all necessary associations, eliminating N+1 query problems and removing the need to
369
- * manually remember which associations to preload for serialization.
370
- *
371
- * This method decouples data loading code from data rendering code by having the serializer
372
- * (rendering code) inform the query (loading code) about which associations are needed.
373
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
374
- * modifying existing ones - the loading code automatically adapts without requiring
375
- * corresponding modifications to preload statements.
376
- *
377
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
378
- * automatically preloads all associations that will be needed during serialization.
379
- *
380
- * ```ts
381
- * await ApplicationModel.transaction(async txn => {
382
- * // Instead of manually specifying all associations:
383
- * await User.txn(txn).preload('posts', 'comments', 'replies').all()
384
- *
385
- * // Automatically preload everything needed for serialization:
386
- * await User.txn(txn).preloadFor('summary').all()
387
- *
388
- * // Add where conditions to specific associations during preloading:
389
- * await User.txn(txn).leftJoinPreloadFor('detailed', (associationName, dreamClass) => {
390
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
391
- * return { and: { published: true } }
392
- * }
393
- * }).all()
394
- *
395
- * // Skip preloading specific associations to handle them manually:
396
- * await User.txn(txn).leftJoinPreloadFor('summary', (associationName, dreamClass) => {
397
- * if (dreamClass.typeof(User) && associationName === 'posts') {
398
- * return 'omit' // Handle posts preloading separately with custom logic
399
- * }
400
- * })
401
- * .preload('posts', { and: { featured: true } }) // Custom preloading
402
- * .all()
403
- * })
404
- * ```
405
- *
406
- * @param serializerKey - The serializer key to use for determining which associations to preload.
407
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
408
- * @returns A Query with all serialization associations preloaded
409
- */
410
- leftJoinPreloadFor(serializerKey, modifierFn) {
411
- return this.queryInstance().leftJoinPreloadFor(serializerKey, modifierFn);
412
- }
413
365
  /**
414
366
  * Applies preload statement to a Query scoped to this model.
415
367
  * Upon instantiating records of this model type,
@@ -143,56 +143,6 @@ export default class DreamInstanceTransactionBuilder {
143
143
  leftJoinLoad(...args) {
144
144
  return new LeftJoinLoadBuilder(this.dreamInstance, this.dreamTransaction).leftJoinLoad(...args);
145
145
  }
146
- /**
147
- * Recursively loads all Dream associations referenced by `rendersOne` and `rendersMany`
148
- * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
149
- * load all necessary associations, eliminating N+1 query problems and removing the need to
150
- * manually remember which associations to preload for serialization.
151
- *
152
- * This method decouples data loading code from data rendering code by having the serializer
153
- * (rendering code) inform the query (loading code) about which associations are needed.
154
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
155
- * modifying existing ones - the loading code automatically adapts without requiring
156
- * corresponding modifications to preload statements.
157
- *
158
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
159
- * automatically preloads all associations that will be needed during serialization.
160
- *
161
- * ```ts
162
- * await ApplicationModel.transaction(async txn => {
163
- * // Instead of manually specifying all associations:
164
- * await User.txn(txn).preload('posts', 'comments', 'replies').all()
165
- *
166
- * // Automatically preload everything needed for serialization:
167
- * await user.txn(txn).leftJoinLoadFor('summary').execute()
168
- *
169
- * // Add where conditions to specific associations during preloading:
170
- * await user.txn(txn).leftJoinLoadFor('detailed', (associationName, dreamClass) => {
171
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
172
- * return { and: { published: true } }
173
- * }
174
- * }).execute()
175
- *
176
- * // Skip preloading specific associations to handle them manually:
177
- * await user
178
- * .txn(txn)
179
- * .leftJoinLoadFor('summary', (associationName, dreamClass) => {
180
- * if (dreamClass.typeof(User) && associationName === 'posts') {
181
- * return 'omit' // Handle posts preloading separately with custom logic
182
- * }
183
- * })
184
- * .load('posts', { and: { featured: true } }) // Custom preloading
185
- * .execute()
186
- * })
187
- * ```
188
- *
189
- * @param serializerKey - The serializer key to use for determining which associations to preload.
190
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
191
- * @returns A Query with all serialization associations preloaded
192
- */
193
- leftJoinLoadFor(serializerKey, modifierFn) {
194
- return new LeftJoinLoadBuilder(this.dreamInstance, this.dreamTransaction)['leftJoinLoadFor'](serializerKey, modifierFn);
195
- }
196
146
  /**
197
147
  * Returns a new Query instance with the provided
198
148
  * inner join statement attached
@@ -38,55 +38,6 @@ export default class LeftJoinLoadBuilder {
38
38
  this.query = this.query.leftJoinPreload(...args);
39
39
  return this;
40
40
  }
41
- /**
42
- * Recursively loads all Dream associations referenced by `rendersOne` and `rendersMany`
43
- * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
44
- * load all necessary associations, eliminating N+1 query problems and removing the need to
45
- * manually remember which associations to preload for serialization.
46
- *
47
- * This method decouples data loading code from data rendering code by having the serializer
48
- * (rendering code) inform the query (loading code) about which associations are needed.
49
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
50
- * modifying existing ones - the loading code automatically adapts without requiring
51
- * corresponding modifications to preload statements.
52
- *
53
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
54
- * automatically preloads all associations that will be needed during serialization.
55
- *
56
- * ```ts
57
- * // Instead of manually specifying all associations:
58
- * await User.preload('posts', 'comments', 'replies').all()
59
- *
60
- * // Automatically preload everything needed for serialization:
61
- * await user.leftJoinLoadFor('summary').execute()
62
- *
63
- * // Add where conditions to specific associations during preloading:
64
- * await user.leftJoinLoadFor('detailed', (associationName, dreamClass) => {
65
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
66
- * return { and: { published: true } }
67
- * }
68
- * })
69
- * .execute()
70
- *
71
- * // Skip preloading specific associations to handle them manually:
72
- * await user
73
- * .leftJoinLoadFor('summary', (associationName, dreamClass) => {
74
- * if (dreamClass.typeof(User) && associationName === 'posts') {
75
- * return 'omit' // Handle posts preloading separately with custom logic
76
- * }
77
- * })
78
- * .load('posts', { and: { featured: true } }) // Custom preloading
79
- * .execute()
80
- * ```
81
- *
82
- * @param serializerKey - The serializer key to use for determining which associations to preload.
83
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
84
- * @returns A Query with all serialization associations preloaded
85
- */
86
- leftJoinLoadFor(serializerKey, modifierFn) {
87
- this.query = this.query.leftJoinPreloadFor(serializerKey, modifierFn);
88
- return this;
89
- }
90
41
  /**
91
42
  * executes a load builder query, binding
92
43
  * all associations to their respective model
@@ -530,63 +530,6 @@ export default class Query {
530
530
  });
531
531
  return query;
532
532
  }
533
- /**
534
- * Recursively preloads all Dream associations referenced by `rendersOne` and `rendersMany`
535
- * in a DreamSerializer using left join preloading. This traverses the entire content tree
536
- * of serializers to automatically load all necessary associations in a single query,
537
- * eliminating N+1 query problems and removing the need to manually remember which
538
- * associations to preload for serialization.
539
- *
540
- * This method decouples data loading code from data rendering code by having the serializer
541
- * (rendering code) inform the query (loading code) about which associations are needed.
542
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
543
- * modifying existing ones - the loading code automatically adapts without requiring
544
- * corresponding modifications to left join preload statements.
545
- *
546
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
547
- * automatically left join preloads all associations that will be needed during serialization.
548
- *
549
- * Note: Left join preloading loads all data in a single SQL query but has trade-offs compared
550
- * to regular preloading. See {@link Dream.leftJoinPreload} for details about limitations.
551
- *
552
- * ```ts
553
- * // Instead of manually specifying all associations:
554
- * await User.leftJoinPreload('posts', 'comments', 'replies').all()
555
- *
556
- * // Automatically left join preload everything needed for serialization:
557
- * await User.leftJoinPreloadFor('summary').all()
558
- *
559
- * // Add where conditions to specific associations during left join preloading:
560
- * await User.leftJoinPreloadFor('detailed', (associationName, dreamClass) => {
561
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
562
- * return { and: { published: true } }
563
- * }
564
- * })
565
- * .all()
566
- *
567
- * // Skip left join preloading specific associations to handle them manually:
568
- * await User.leftJoinPreloadFor('summary', (associationName, dreamClass) => {
569
- * if (dreamClass.typeof(User) && associationName === 'posts') {
570
- * return 'omit' // Handle posts preloading separately with custom logic
571
- * }
572
- * })
573
- * .preload('posts', { and: { featured: true } }) // Custom preloading instead
574
- * .all()
575
- * ```
576
- *
577
- * @param serializerKey - The serializer key to use for determining which associations to preload.
578
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
579
- * @returns A Query with all serialization associations left join preloaded
580
- */
581
- leftJoinPreloadFor(serializerKey, modifierFn) {
582
- const preloadArgs = extractNestedPaths(this.dreamClass['serializationMap'](serializerKey));
583
- let query = this;
584
- const counter = { count: 0 };
585
- preloadArgs.forEach(dreamClassAndAssociationNameTupleArray => {
586
- query = query.leftJoinPreload(...convertDreamClassAndAssociationNameTupleArrayToPreloadArgs(dreamClassAndAssociationNameTupleArray, modifierFn, counter));
587
- });
588
- return query;
589
- }
590
533
  /**
591
534
  * Returns a new Query instance, with the provided
592
535
  * joins statement attached
@@ -1403,56 +1403,6 @@ export default class Dream {
1403
1403
  static preloadFor(serializerKey, modifierFn) {
1404
1404
  return this.query().preloadFor(serializerKey, modifierFn);
1405
1405
  }
1406
- /**
1407
- * Recursively preloads all Dream associations referenced by `rendersOne` and `rendersMany`
1408
- * in a DreamSerializer using left join preloading. This traverses the entire content tree
1409
- * of serializers to automatically load all necessary associations in a single query,
1410
- * eliminating N+1 query problems and removing the need to manually remember which
1411
- * associations to preload for serialization.
1412
- *
1413
- * This method decouples data loading code from data rendering code by having the serializer
1414
- * (rendering code) inform the query (loading code) about which associations are needed.
1415
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
1416
- * modifying existing ones - the loading code automatically adapts without requiring
1417
- * corresponding modifications to left join preload statements.
1418
- *
1419
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
1420
- * automatically left join preloads all associations that will be needed during serialization.
1421
- *
1422
- * Note: Left join preloading loads all data in a single SQL query but has trade-offs compared
1423
- * to regular preloading. See {@link Dream.leftJoinPreload} for details about limitations.
1424
- *
1425
- * ```ts
1426
- * // Instead of manually specifying all associations:
1427
- * await User.leftJoinPreload('posts', 'comments', 'replies').all()
1428
- *
1429
- * // Automatically left join preload everything needed for serialization:
1430
- * await User.leftJoinPreloadFor('summary').all()
1431
- *
1432
- * // Add where conditions to specific associations during left join preloading:
1433
- * await User.leftJoinPreloadFor('detailed', (associationName, dreamClass) => {
1434
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
1435
- * return { and: { published: true } }
1436
- * }
1437
- * }).all()
1438
- *
1439
- * // Skip left join preloading specific associations to handle them manually:
1440
- * await User.leftJoinPreloadFor('summary', (associationName, dreamClass) => {
1441
- * if (dreamClass.typeof(User) && associationName === 'posts') {
1442
- * return 'omit' // Handle posts preloading separately with custom logic
1443
- * }
1444
- * })
1445
- * .preload('posts', { and: { featured: true } }) // Custom preloading instead
1446
- * .all()
1447
- * ```
1448
- *
1449
- * @param serializerKey - The serializer key to use for determining which associations to preload.
1450
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
1451
- * @returns A Query with all serialization associations left join preloaded
1452
- */
1453
- static leftJoinPreloadFor(serializerKey, modifierFn) {
1454
- return this.query().leftJoinPreloadFor(serializerKey, modifierFn);
1455
- }
1456
1406
  /**
1457
1407
  * Returns a new Query instance with the provided
1458
1408
  * inner join statement attached
@@ -3375,57 +3325,6 @@ export default class Dream {
3375
3325
  leftJoinLoad(...args) {
3376
3326
  return new LeftJoinLoadBuilder(this).leftJoinLoad(...args);
3377
3327
  }
3378
- /**
3379
- * Recursively loads all Dream associations referenced by `rendersOne` and `rendersMany`
3380
- * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
3381
- * load all necessary associations, eliminating N+1 query problems and removing the need to
3382
- * manually remember which associations to preload for serialization.
3383
- *
3384
- * This method decouples data loading code from data rendering code by having the serializer
3385
- * (rendering code) inform the query (loading code) about which associations are needed.
3386
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
3387
- * modifying existing ones - the loading code automatically adapts without requiring
3388
- * corresponding modifications to preload statements.
3389
- *
3390
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
3391
- * automatically preloads all associations that will be needed during serialization.
3392
- *
3393
- * Note: Left join loading loads all data in a single SQL query but has trade-offs compared
3394
- * to regular preloading. See {@link Dream.leftJoinPreload} for details about limitations.
3395
- *
3396
- * ```ts
3397
- * // Instead of manually specifying all associations:
3398
- * await User.preload('posts', 'comments', 'replies').all()
3399
- *
3400
- * // Automatically preload everything needed for serialization:
3401
- * await user.leftJoinLoadFor('summary').execute()
3402
- *
3403
- * // Add where conditions to specific associations during preloading:
3404
- * await user.leftJoinLoadFor('detailed', (associationName, dreamClass) => {
3405
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
3406
- * return { and: { published: true } }
3407
- * }
3408
- * })
3409
- * .execute()
3410
- *
3411
- * // Skip preloading specific associations to handle them manually:
3412
- * await user
3413
- * .loadFor('summary', (associationName, dreamClass) => {
3414
- * if (dreamClass.typeof(User) && associationName === 'posts') {
3415
- * return 'omit' // Handle posts preloading separately with custom logic
3416
- * }
3417
- * })
3418
- * .load('posts', { and: { featured: true } }) // Custom preloading
3419
- * .execute()
3420
- * ```
3421
- *
3422
- * @param serializerKey - The serializer key to use for determining which associations to preload.
3423
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
3424
- * @returns A Query with all serialization associations preloaded
3425
- */
3426
- leftJoinLoadFor(serializerKey, modifierFn) {
3427
- return new LeftJoinLoadBuilder(this)['leftJoinLoadFor'](serializerKey, modifierFn);
3428
- }
3429
3328
  /**
3430
3329
  * Returns true if the association specified has
3431
3330
  * been loaded on this instance
@@ -17,7 +17,10 @@ export default class DreamMigrationHelpers {
17
17
  */
18
18
  static async renameTable(db, from, to) {
19
19
  await db.schema.alterTable(from).renameTo(to).execute();
20
- await sql `ALTER SEQUENCE ${from}_id_seq RENAME TO ${to}_id_seq`.execute(db);
20
+ const fromSequenceName = `${from}_id_seq`;
21
+ const toSequenceName = `${to}_id_seq`;
22
+ const sqlStatement = `ALTER SEQUENCE ${fromSequenceName} RENAME TO ${toSequenceName}`;
23
+ await sql.raw(sqlStatement).execute(db);
21
24
  }
22
25
  /**
23
26
  * Unique indexes cannot be populated by the same value even within a transaction,
@@ -362,54 +362,6 @@ export default class DreamClassTransactionBuilder {
362
362
  leftJoinPreload(...args) {
363
363
  return this.queryInstance().leftJoinPreload(...args);
364
364
  }
365
- /**
366
- * Recursively left-join-preloads all Dream associations referenced by `rendersOne` and `rendersMany`
367
- * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
368
- * load all necessary associations, eliminating N+1 query problems and removing the need to
369
- * manually remember which associations to preload for serialization.
370
- *
371
- * This method decouples data loading code from data rendering code by having the serializer
372
- * (rendering code) inform the query (loading code) about which associations are needed.
373
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
374
- * modifying existing ones - the loading code automatically adapts without requiring
375
- * corresponding modifications to preload statements.
376
- *
377
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
378
- * automatically preloads all associations that will be needed during serialization.
379
- *
380
- * ```ts
381
- * await ApplicationModel.transaction(async txn => {
382
- * // Instead of manually specifying all associations:
383
- * await User.txn(txn).preload('posts', 'comments', 'replies').all()
384
- *
385
- * // Automatically preload everything needed for serialization:
386
- * await User.txn(txn).preloadFor('summary').all()
387
- *
388
- * // Add where conditions to specific associations during preloading:
389
- * await User.txn(txn).leftJoinPreloadFor('detailed', (associationName, dreamClass) => {
390
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
391
- * return { and: { published: true } }
392
- * }
393
- * }).all()
394
- *
395
- * // Skip preloading specific associations to handle them manually:
396
- * await User.txn(txn).leftJoinPreloadFor('summary', (associationName, dreamClass) => {
397
- * if (dreamClass.typeof(User) && associationName === 'posts') {
398
- * return 'omit' // Handle posts preloading separately with custom logic
399
- * }
400
- * })
401
- * .preload('posts', { and: { featured: true } }) // Custom preloading
402
- * .all()
403
- * })
404
- * ```
405
- *
406
- * @param serializerKey - The serializer key to use for determining which associations to preload.
407
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
408
- * @returns A Query with all serialization associations preloaded
409
- */
410
- leftJoinPreloadFor(serializerKey, modifierFn) {
411
- return this.queryInstance().leftJoinPreloadFor(serializerKey, modifierFn);
412
- }
413
365
  /**
414
366
  * Applies preload statement to a Query scoped to this model.
415
367
  * Upon instantiating records of this model type,
@@ -143,56 +143,6 @@ export default class DreamInstanceTransactionBuilder {
143
143
  leftJoinLoad(...args) {
144
144
  return new LeftJoinLoadBuilder(this.dreamInstance, this.dreamTransaction).leftJoinLoad(...args);
145
145
  }
146
- /**
147
- * Recursively loads all Dream associations referenced by `rendersOne` and `rendersMany`
148
- * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
149
- * load all necessary associations, eliminating N+1 query problems and removing the need to
150
- * manually remember which associations to preload for serialization.
151
- *
152
- * This method decouples data loading code from data rendering code by having the serializer
153
- * (rendering code) inform the query (loading code) about which associations are needed.
154
- * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
155
- * modifying existing ones - the loading code automatically adapts without requiring
156
- * corresponding modifications to preload statements.
157
- *
158
- * This method analyzes the serializer (specified by `serializerKey` or 'default') and
159
- * automatically preloads all associations that will be needed during serialization.
160
- *
161
- * ```ts
162
- * await ApplicationModel.transaction(async txn => {
163
- * // Instead of manually specifying all associations:
164
- * await User.txn(txn).preload('posts', 'comments', 'replies').all()
165
- *
166
- * // Automatically preload everything needed for serialization:
167
- * await user.txn(txn).leftJoinLoadFor('summary').execute()
168
- *
169
- * // Add where conditions to specific associations during preloading:
170
- * await user.txn(txn).leftJoinLoadFor('detailed', (associationName, dreamClass) => {
171
- * if (dreamClass.typeof(Post) && associationName === 'comments') {
172
- * return { and: { published: true } }
173
- * }
174
- * }).execute()
175
- *
176
- * // Skip preloading specific associations to handle them manually:
177
- * await user
178
- * .txn(txn)
179
- * .leftJoinLoadFor('summary', (associationName, dreamClass) => {
180
- * if (dreamClass.typeof(User) && associationName === 'posts') {
181
- * return 'omit' // Handle posts preloading separately with custom logic
182
- * }
183
- * })
184
- * .load('posts', { and: { featured: true } }) // Custom preloading
185
- * .execute()
186
- * })
187
- * ```
188
- *
189
- * @param serializerKey - The serializer key to use for determining which associations to preload.
190
- * @param modifierFn - Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with `and`, `andAny`, or `andNot` properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading
191
- * @returns A Query with all serialization associations preloaded
192
- */
193
- leftJoinLoadFor(serializerKey, modifierFn) {
194
- return new LeftJoinLoadBuilder(this.dreamInstance, this.dreamTransaction)['leftJoinLoadFor'](serializerKey, modifierFn);
195
- }
196
146
  /**
197
147
  * Returns a new Query instance with the provided
198
148
  * inner join statement attached