@rvoh/dream 0.44.9 → 0.45.1

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 (227) hide show
  1. package/dist/cjs/src/Dream.js +328 -23
  2. package/dist/cjs/src/cli/index.js +16 -0
  3. package/dist/cjs/src/db/migration-helpers/DreamMigrationHelpers.js +18 -14
  4. package/dist/cjs/src/decorators/Decorators.js +2 -1
  5. package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +92 -0
  6. package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +98 -0
  7. package/dist/cjs/src/dream/LeftJoinLoadBuilder.js +52 -1
  8. package/dist/cjs/src/dream/LoadBuilder.js +49 -0
  9. package/dist/cjs/src/dream/Query.js +136 -24
  10. package/dist/cjs/src/dream/internal/convertDreamClassAndAssociationNameTupleArrayToPreloadArgs.js +18 -0
  11. package/dist/cjs/src/dream/internal/extractNestedPaths.js +37 -0
  12. package/dist/cjs/src/dream/internal/unaliasTableName.js +7 -0
  13. package/dist/cjs/src/helpers/indent.js +18 -0
  14. package/dist/cjs/src/serializer/SerializerRenderer.js +2 -17
  15. package/dist/cjs/src/serializer/builders/DreamSerializerBuilder.js +139 -3
  16. package/dist/cjs/src/serializer/builders/ObjectSerializerBuilder.js +176 -3
  17. package/dist/cjs/src/serializer/helpers/serializerForAssociatedClass.js +20 -0
  18. package/dist/esm/src/Dream.js +328 -23
  19. package/dist/esm/src/cli/index.js +16 -0
  20. package/dist/esm/src/db/migration-helpers/DreamMigrationHelpers.js +18 -14
  21. package/dist/esm/src/decorators/Decorators.js +2 -1
  22. package/dist/esm/src/dream/DreamClassTransactionBuilder.js +92 -0
  23. package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +98 -0
  24. package/dist/esm/src/dream/LeftJoinLoadBuilder.js +52 -1
  25. package/dist/esm/src/dream/LoadBuilder.js +49 -0
  26. package/dist/esm/src/dream/Query.js +136 -24
  27. package/dist/esm/src/dream/internal/convertDreamClassAndAssociationNameTupleArrayToPreloadArgs.js +15 -0
  28. package/dist/esm/src/dream/internal/extractNestedPaths.js +34 -0
  29. package/dist/esm/src/dream/internal/unaliasTableName.js +4 -0
  30. package/dist/esm/src/helpers/indent.js +15 -0
  31. package/dist/esm/src/serializer/SerializerRenderer.js +2 -17
  32. package/dist/esm/src/serializer/builders/DreamSerializerBuilder.js +139 -3
  33. package/dist/esm/src/serializer/builders/ObjectSerializerBuilder.js +176 -3
  34. package/dist/esm/src/serializer/helpers/serializerForAssociatedClass.js +17 -0
  35. package/dist/types/src/Dream.d.ts +283 -25
  36. package/dist/types/src/db/migration-helpers/DreamMigrationHelpers.d.ts +18 -14
  37. package/dist/types/src/decorators/Decorators.d.ts +2 -1
  38. package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +108 -2
  39. package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +96 -2
  40. package/dist/types/src/dream/LeftJoinLoadBuilder.d.ts +48 -1
  41. package/dist/types/src/dream/LoadBuilder.d.ts +48 -1
  42. package/dist/types/src/dream/Query.d.ts +128 -26
  43. package/dist/types/src/dream/internal/convertDreamClassAndAssociationNameTupleArrayToPreloadArgs.d.ts +9 -0
  44. package/dist/types/src/dream/internal/extractNestedPaths.d.ts +21 -0
  45. package/dist/types/src/dream/internal/unaliasTableName.d.ts +1 -0
  46. package/dist/types/src/helpers/indent.d.ts +3 -0
  47. package/dist/types/src/index.d.ts +1 -1
  48. package/dist/types/src/serializer/builders/DreamSerializerBuilder.d.ts +176 -5
  49. package/dist/types/src/serializer/builders/ObjectSerializerBuilder.d.ts +176 -3
  50. package/dist/types/src/serializer/helpers/serializerForAssociatedClass.d.ts +9 -0
  51. package/dist/types/src/types/dream.d.ts +2 -1
  52. package/dist/types/src/types/dream.ts +26 -1
  53. package/dist/types/src/types/query.d.ts +5 -0
  54. package/dist/types/src/types/query.ts +5 -0
  55. package/docs/assets/highlight.css +7 -0
  56. package/docs/assets/navigation.js +1 -1
  57. package/docs/assets/search.js +1 -1
  58. package/docs/classes/Benchmark.html +2 -2
  59. package/docs/classes/CalendarDate.html +2 -2
  60. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
  61. package/docs/classes/Decorators.html +21 -20
  62. package/docs/classes/Dream.html +339 -226
  63. package/docs/classes/DreamApp.html +4 -4
  64. package/docs/classes/DreamBin.html +2 -2
  65. package/docs/classes/DreamCLI.html +4 -4
  66. package/docs/classes/DreamImporter.html +2 -2
  67. package/docs/classes/DreamLogos.html +2 -2
  68. package/docs/classes/DreamMigrationHelpers.html +21 -8
  69. package/docs/classes/DreamSerializerBuilder.html +66 -2
  70. package/docs/classes/DreamTransaction.html +2 -2
  71. package/docs/classes/Encrypt.html +2 -2
  72. package/docs/classes/Env.html +2 -2
  73. package/docs/classes/GlobalNameNotSet.html +3 -3
  74. package/docs/classes/NonLoadedAssociation.html +3 -3
  75. package/docs/classes/ObjectSerializerBuilder.html +66 -2
  76. package/docs/classes/Query.html +122 -78
  77. package/docs/classes/Range.html +2 -2
  78. package/docs/classes/RecordNotFound.html +3 -3
  79. package/docs/classes/ValidationError.html +3 -3
  80. package/docs/functions/DreamSerializer.html +1 -1
  81. package/docs/functions/ObjectSerializer.html +1 -1
  82. package/docs/functions/ReplicaSafe.html +1 -1
  83. package/docs/functions/STI.html +1 -1
  84. package/docs/functions/SoftDelete.html +1 -1
  85. package/docs/functions/camelize.html +1 -1
  86. package/docs/functions/capitalize.html +1 -1
  87. package/docs/functions/cloneDeepSafe.html +1 -1
  88. package/docs/functions/closeAllDbConnections.html +1 -1
  89. package/docs/functions/compact.html +1 -1
  90. package/docs/functions/dreamDbConnections.html +1 -1
  91. package/docs/functions/dreamPath.html +1 -1
  92. package/docs/functions/expandStiClasses.html +1 -1
  93. package/docs/functions/generateDream.html +1 -1
  94. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  95. package/docs/functions/groupBy.html +1 -1
  96. package/docs/functions/hyphenize.html +1 -1
  97. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  98. package/docs/functions/inferSerializersFromDreamClassOrViewModelClass.html +1 -1
  99. package/docs/functions/intersection.html +1 -1
  100. package/docs/functions/isDreamSerializer.html +1 -1
  101. package/docs/functions/isEmpty.html +1 -1
  102. package/docs/functions/loadRepl.html +1 -1
  103. package/docs/functions/lookupClassByGlobalName.html +1 -1
  104. package/docs/functions/normalizeUnicode.html +1 -1
  105. package/docs/functions/pascalize.html +1 -1
  106. package/docs/functions/pgErrorType.html +1 -1
  107. package/docs/functions/range-1.html +1 -1
  108. package/docs/functions/relativeDreamPath.html +1 -1
  109. package/docs/functions/round.html +1 -1
  110. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  111. package/docs/functions/sharedPathPrefix.html +1 -1
  112. package/docs/functions/snakeify.html +1 -1
  113. package/docs/functions/sort.html +1 -1
  114. package/docs/functions/sortBy.html +1 -1
  115. package/docs/functions/sortObjectByKey.html +1 -1
  116. package/docs/functions/sortObjectByValue.html +1 -1
  117. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  118. package/docs/functions/uncapitalize.html +1 -1
  119. package/docs/functions/uniq.html +1 -1
  120. package/docs/functions/untypedDb.html +1 -1
  121. package/docs/functions/validateColumn.html +1 -1
  122. package/docs/functions/validateTable.html +1 -1
  123. package/docs/interfaces/BelongsToStatement.html +2 -2
  124. package/docs/interfaces/DecoratorContext.html +2 -2
  125. package/docs/interfaces/DreamAppInitOptions.html +2 -2
  126. package/docs/interfaces/DreamAppOpts.html +2 -2
  127. package/docs/interfaces/EncryptOptions.html +2 -2
  128. package/docs/interfaces/InternalAnyTypedSerializerRendersMany.html +2 -2
  129. package/docs/interfaces/InternalAnyTypedSerializerRendersOne.html +2 -2
  130. package/docs/interfaces/OpenapiDescription.html +2 -2
  131. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  132. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  133. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  134. package/docs/interfaces/SerializerRendererOpts.html +2 -2
  135. package/docs/modules.html +1 -0
  136. package/docs/types/Camelized.html +1 -1
  137. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  138. package/docs/types/DateTime.html +1 -1
  139. package/docs/types/DbConnectionType.html +1 -1
  140. package/docs/types/DbTypes.html +1 -1
  141. package/docs/types/DreamAssociationMetadata.html +1 -1
  142. package/docs/types/DreamAttributes.html +1 -1
  143. package/docs/types/DreamClassAssociationAndStatement.html +1 -0
  144. package/docs/types/DreamClassColumn.html +1 -1
  145. package/docs/types/DreamColumn.html +1 -1
  146. package/docs/types/DreamColumnNames.html +1 -1
  147. package/docs/types/DreamLogLevel.html +1 -1
  148. package/docs/types/DreamLogger.html +1 -1
  149. package/docs/types/DreamModelSerializerType.html +1 -1
  150. package/docs/types/DreamOrViewModelClassSerializerKey.html +1 -1
  151. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  152. package/docs/types/DreamParamSafeAttributes.html +1 -1
  153. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  154. package/docs/types/DreamSerializable.html +1 -1
  155. package/docs/types/DreamSerializableArray.html +1 -1
  156. package/docs/types/DreamSerializerKey.html +1 -1
  157. package/docs/types/DreamSerializers.html +1 -1
  158. package/docs/types/DreamTableSchema.html +1 -1
  159. package/docs/types/DreamVirtualColumns.html +1 -1
  160. package/docs/types/EncryptAlgorithm.html +1 -1
  161. package/docs/types/HasManyStatement.html +1 -1
  162. package/docs/types/HasOneStatement.html +1 -1
  163. package/docs/types/Hyphenized.html +1 -1
  164. package/docs/types/IdType.html +1 -1
  165. package/docs/types/OpenapiAllTypes.html +1 -1
  166. package/docs/types/OpenapiFormats.html +1 -1
  167. package/docs/types/OpenapiNumberFormats.html +1 -1
  168. package/docs/types/OpenapiPrimitiveBaseTypes.html +1 -1
  169. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  170. package/docs/types/OpenapiSchemaArray.html +1 -1
  171. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  172. package/docs/types/OpenapiSchemaBase.html +1 -1
  173. package/docs/types/OpenapiSchemaBody.html +1 -1
  174. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  175. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  176. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  177. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  178. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  179. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  180. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  181. package/docs/types/OpenapiSchemaInteger.html +1 -1
  182. package/docs/types/OpenapiSchemaNull.html +1 -1
  183. package/docs/types/OpenapiSchemaNumber.html +1 -1
  184. package/docs/types/OpenapiSchemaObject.html +1 -1
  185. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  186. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  187. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  188. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  189. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  190. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  191. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  192. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  193. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  194. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  195. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  196. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  197. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  198. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  199. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  200. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  201. package/docs/types/OpenapiSchemaString.html +1 -1
  202. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  203. package/docs/types/OpenapiShorthandPrimitiveBaseTypes.html +1 -1
  204. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  205. package/docs/types/OpenapiTypeField.html +1 -1
  206. package/docs/types/Pascalized.html +1 -1
  207. package/docs/types/PrimaryKeyType.html +1 -1
  208. package/docs/types/RoundingPrecision.html +1 -1
  209. package/docs/types/SerializerCasing.html +1 -1
  210. package/docs/types/SimpleObjectSerializerType.html +1 -1
  211. package/docs/types/Snakeified.html +1 -1
  212. package/docs/types/Timestamp.html +1 -1
  213. package/docs/types/UpdateableAssociationProperties.html +1 -1
  214. package/docs/types/UpdateableProperties.html +1 -1
  215. package/docs/types/ValidationType.html +1 -1
  216. package/docs/types/ViewModel.html +1 -1
  217. package/docs/types/ViewModelClass.html +1 -1
  218. package/docs/types/WhereStatementForDream.html +1 -1
  219. package/docs/types/WhereStatementForDreamClass.html +1 -1
  220. package/docs/variables/DateTime-1.html +1 -1
  221. package/docs/variables/DreamConst.html +1 -1
  222. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  223. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  224. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  225. package/docs/variables/ops.html +1 -1
  226. package/docs/variables/primaryKeyTypes.html +1 -1
  227. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const yoctocolors_1 = require("yoctocolors");
3
4
  const errors_js_1 = require("./db/errors.js");
4
5
  const index_js_1 = require("./db/index.js");
5
6
  const associationToGetterSetterProp_js_1 = require("./decorators/field/association/associationToGetterSetterProp.js");
@@ -47,7 +48,10 @@ const cloneDeepSafe_js_1 = require("./helpers/cloneDeepSafe.js");
47
48
  const DateTime_js_1 = require("./helpers/DateTime.js");
48
49
  const cachedTypeForAttribute_js_1 = require("./helpers/db/cachedTypeForAttribute.js");
49
50
  const isJsonColumn_js_1 = require("./helpers/db/types/isJsonColumn.js");
51
+ const indent_js_1 = require("./helpers/indent.js");
50
52
  const notEqual_js_1 = require("./helpers/notEqual.js");
53
+ const inferSerializerFromDreamOrViewModel_js_1 = require("./serializer/helpers/inferSerializerFromDreamOrViewModel.js");
54
+ const serializerForAssociatedClass_js_1 = require("./serializer/helpers/serializerForAssociatedClass.js");
51
55
  class Dream {
52
56
  DB;
53
57
  /**
@@ -104,6 +108,46 @@ class Dream {
104
108
  get globalSchema() {
105
109
  throw new DreamMissingRequiredOverride_js_1.default(this.constructor, 'globalSchema');
106
110
  }
111
+ /**
112
+ * Determines if the provided Dream class is the same as or a subclass of this Dream class.
113
+ * This method is particularly useful for runtime type checking and works with STI (Single Table Inheritance) classes.
114
+ *
115
+ * For regular Dream classes, this checks if the provided class is exactly the same class.
116
+ * For STI classes, this checks inheritance relationships - a child STI class will return true
117
+ * when compared against its parent class.
118
+ *
119
+ * ```ts
120
+ * // Regular class comparison
121
+ * User.typeof(User) // true
122
+ * User.typeof(Pet) // false
123
+ *
124
+ * // STI inheritance checking
125
+ * class Balloon extends ApplicationModel {
126
+ * // base STI class
127
+ * }
128
+ *
129
+ * class Mylar extends Balloon {
130
+ * // STI child class
131
+ * }
132
+ *
133
+ * Balloon.typeof(Balloon) // true
134
+ * Balloon.typeof(Mylar) // false
135
+ * Mylar.typeof(Balloon) // true (child recognizes parent)
136
+ * Mylar.typeof(Mylar) // true
137
+ *
138
+ * // Runtime type checking with variables
139
+ * const dreamClass: typeof Dream = getRandomDreamClass()
140
+ * if (dreamClass.typeof(Pet)) {
141
+ * // dreamClass is Pet or a subclass of Pet
142
+ * }
143
+ * ```
144
+ *
145
+ * @param dreamClass - The Dream class to compare against this class
146
+ * @returns `true` if the provided class is the same as this class or if this class is a subclass of the provided class (STI inheritance), `false` otherwise
147
+ */
148
+ static typeof(dreamClass) {
149
+ return this.new() instanceof dreamClass;
150
+ }
107
151
  /**
108
152
  * Shadows #primaryKey, a getter which can be overwritten to customize the id field
109
153
  * for a given model.
@@ -423,6 +467,65 @@ class Dream {
423
467
  static setGlobalName(globalName) {
424
468
  this._globalName = globalName;
425
469
  }
470
+ static serializationMap(serializerKey) {
471
+ const key = serializerKey || 'default';
472
+ const serializer = (0, inferSerializerFromDreamOrViewModel_js_1.inferSerializersFromDreamClassOrViewModelClass)(this, key)[0] ?? null;
473
+ if (!serializer)
474
+ throw new Error(`unable to find serializer with key: ${key}`);
475
+ return this.recursiveSerializationMap(serializer);
476
+ }
477
+ static displaySerialization(serializerKey) {
478
+ const key = serializerKey || 'default';
479
+ const serializer = (0, inferSerializerFromDreamOrViewModel_js_1.inferSerializersFromDreamClassOrViewModelClass)(this, key)[0] ?? null;
480
+ if (!serializer)
481
+ throw new Error(`unable to find serializer with key: ${key}`);
482
+ console.log(yoctocolors_1.default.cyan(this.sanitizedName));
483
+ console.log(yoctocolors_1.default.gray(serializer.globalName));
484
+ return this.recursiveSerializationMap(serializer, {
485
+ forDisplay: true,
486
+ });
487
+ }
488
+ static recursiveSerializationMap(serializer, { forDisplay = false, forDisplayDepth = 0, } = {}) {
489
+ const serializerBuilder = serializer(undefined, undefined);
490
+ const serializerAssociations = serializerBuilder['attributes'].filter(attribute => ['rendersOne', 'rendersMany', 'delegatedAttribute'].includes(attribute.type));
491
+ return serializerAssociations.reduce((acc, serializerAssociation) => {
492
+ const serializerAssociationName = serializerAssociation.targetName ??
493
+ serializerAssociation.name;
494
+ const serializerAssociationType = serializerAssociation.type;
495
+ const association = this['getAssociationMetadata'](serializerAssociationName);
496
+ if (!association)
497
+ return acc;
498
+ const associatedClasses = association.modelCB();
499
+ const associatedClass = Array.isArray(associatedClasses) ? associatedClasses[0] : associatedClasses;
500
+ if (!associatedClass)
501
+ throw new Error(`No class defined on ${serializerAssociationName} association on ${this.sanitizedName}`);
502
+ const associationSerializer = (0, serializerForAssociatedClass_js_1.serializerForAssociatedClass)(this.prototype, serializerAssociationName, serializerAssociation.options);
503
+ if (!associationSerializer)
504
+ throw new Error(`No serializer found to render ${serializerAssociationName} on ${this.sanitizedName}`);
505
+ if (forDisplay && serializerAssociationType !== 'delegatedAttribute') {
506
+ const hierarchyLine = '└───';
507
+ const indentation = (0, indent_js_1.indent)((hierarchyLine.length + 1) * forDisplayDepth, {
508
+ tabWidth: 1,
509
+ });
510
+ const prefix = `${hierarchyLine} `;
511
+ const nestedAssociationDisplay = indentation + `${prefix}${serializerAssociationType} ${yoctocolors_1.default.cyan(serializerAssociationName)}`;
512
+ console.log(nestedAssociationDisplay);
513
+ console.log(yoctocolors_1.default.gray(indentation +
514
+ (0, indent_js_1.indent)(prefix.length, { tabWidth: 1 }) +
515
+ associationSerializer.globalName));
516
+ }
517
+ acc[association.as] = {
518
+ parentDreamClass: this,
519
+ nestedSerializerInfo: serializerAssociation.type === 'delegatedAttribute'
520
+ ? {}
521
+ : associatedClass['recursiveSerializationMap'](associationSerializer, {
522
+ forDisplay,
523
+ forDisplayDepth: forDisplayDepth + 1,
524
+ }),
525
+ };
526
+ return acc;
527
+ }, {});
528
+ }
426
529
  /**
427
530
  * Returns the column names for the given model
428
531
  *
@@ -624,12 +727,14 @@ class Dream {
624
727
  * // 2
625
728
  * ```
626
729
  *
730
+ * @param opts - Pagination options
627
731
  * @param opts.page - the page number that you want to fetch results for
628
732
  * @param opts.pageSize - the number of results per page (optional)
629
- * @returns results.recordCount - A number representing the total number of records matching your query
630
- * @returns results.pageCount - The number of pages needed to encapsulate all the matching records
631
- * @returns results.currentPage - The current page (same as what is provided in the paginate args)
632
- * @returns results.results - An array of records matching the current record
733
+ * @returns A paginated result object containing:
734
+ * - `recordCount` - A number representing the total number of records matching your query
735
+ * - `pageCount` - The number of pages needed to encapsulate all the matching records
736
+ * - `currentPage` - The current page (same as what is provided in the paginate args)
737
+ * - `results` - An array of records matching the current record
633
738
  */
634
739
  static async paginate(opts) {
635
740
  return await this.query().paginate(opts);
@@ -697,7 +802,8 @@ class Dream {
697
802
  * ```
698
803
  *
699
804
  * @param attributes - attributes or belongs to associations you wish to set on this model before persisting
700
- * @param opts.skipHooks - if true, will skip applying model hooks. Defaults to false
805
+ * @param __namedParameters - optional parameters
806
+ * @param __namedParameters.skipHooks - if true, will skip applying model hooks. Defaults to false
701
807
  * @returns A newly persisted dream instance
702
808
  */
703
809
  static async create(attributes, { skipHooks } = {}) {
@@ -721,6 +827,7 @@ class Dream {
721
827
  * ```
722
828
  *
723
829
  * @param attributes - The base attributes to persist, but also the attributes to use to find when create fails
830
+ * @param extraOpts - Additional options
724
831
  * @param extraOpts.createWith - additional attributes to persist when creating, but not used for finding
725
832
  * @returns A dream instance
726
833
  */
@@ -753,6 +860,7 @@ class Dream {
753
860
  * ```
754
861
  *
755
862
  * @param attributes - The base attributes for finding which record to update, also used when creating
863
+ * @param extraOpts - Additional options
756
864
  * @param extraOpts.with - additional attributes to persist when updating and creating, but not used for finding
757
865
  * @param extraOpts.skipHooks - if true, will skip applying model hooks. Defaults to false
758
866
  * @returns A dream instance
@@ -773,6 +881,7 @@ class Dream {
773
881
  * at least one of the provided attributes
774
882
  *
775
883
  * @param attributes - The base attributes for finding which record to update, also used when creating
884
+ * @param extraOpts - Additional options
776
885
  * @param extraOpts.with - additional attributes to persist when updating and creating, but not used for finding
777
886
  * @param extraOpts.skipHooks - if true, will skip applying model hooks. Defaults to false
778
887
  * @returns A dream instance
@@ -862,6 +971,7 @@ class Dream {
862
971
  * ```
863
972
  *
864
973
  * @param cb - The callback to call for each found record
974
+ * @param opts - Optional parameters for batch processing
865
975
  * @param opts.batchSize - the batch size you wish to collect records in. If not provided, it will default to 1000
866
976
  * @returns void
867
977
  */
@@ -946,6 +1056,7 @@ class Dream {
946
1056
  * ```
947
1057
  *
948
1058
  * @param attributes - The base attributes for finding, but also the attributes to use when creating
1059
+ * @param extraOpts - Additional options
949
1060
  * @param extraOpts.createWith - additional attributes to persist when creating, but not used for finding
950
1061
  * @returns A dream instance
951
1062
  */
@@ -973,10 +1084,10 @@ class Dream {
973
1084
  }
974
1085
  /**
975
1086
  * Load each specified association using a single SQL query.
976
- * See {@link #preload} for preloading in separate queries.
1087
+ * See {@link Dream.preload} for preloading in separate queries.
977
1088
  *
978
1089
  * Note: since leftJoinPreload loads via single query, it has
979
- * some downsides and that may be avoided using {@link #preload}:
1090
+ * some downsides and that may be avoided using {@link Dream.preload}:
980
1091
  * 1. `limit` and `offset` will be automatically removed
981
1092
  * 2. `through` associations will bring additional namespaces into the query that can conflict with through associations from other associations, creating an invalid query
982
1093
  * 3. each nested association will result in an additional record which duplicates data from the outer record. E.g., given `.leftJoinPreload('a', 'b', 'c')`, if each `a` has 10 `b` and each `b` has 10 `c`, then for one `a`, 100 records will be returned, each of which has all of the columns of `a`. `.preload('a', 'b', 'c')` would perform three separate SQL queries, but the data for a single `a` would only be returned once.
@@ -1017,6 +1128,102 @@ class Dream {
1017
1128
  static preload(...args) {
1018
1129
  return this.query().preload(...args);
1019
1130
  }
1131
+ /**
1132
+ * Recursively preloads all Dream associations referenced by `rendersOne` and `rendersMany`
1133
+ * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
1134
+ * load all necessary associations, eliminating N+1 query problems and removing the need to
1135
+ * manually remember which associations to preload for serialization.
1136
+ *
1137
+ * This method decouples data loading code from data rendering code by having the serializer
1138
+ * (rendering code) inform the query (loading code) about which associations are needed.
1139
+ * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
1140
+ * modifying existing ones - the loading code automatically adapts without requiring
1141
+ * corresponding modifications to preload statements.
1142
+ *
1143
+ * This method analyzes the serializer (specified by `serializerKey` or 'default') and
1144
+ * automatically preloads all associations that will be needed during serialization.
1145
+ *
1146
+ * ```ts
1147
+ * // Instead of manually specifying all associations:
1148
+ * await User.preload('posts', 'comments', 'replies').all()
1149
+ *
1150
+ * // Automatically preload everything needed for serialization:
1151
+ * await User.preloadFor('summary').all()
1152
+ *
1153
+ * // Add where conditions to specific associations during preloading:
1154
+ * await User.preloadFor('default', (dreamClass, associationName) => {
1155
+ * if (dreamClass.typeof(Post) && associationName === 'comments') {
1156
+ * return { and: { published: true } }
1157
+ * }
1158
+ * }).all()
1159
+ *
1160
+ * // Skip preloading specific associations to handle them manually:
1161
+ * await User.preloadFor('summary', (dreamClass, associationName) => {
1162
+ * if (dreamClass.typeof(User) && associationName === 'posts') {
1163
+ * return 'omit' // Handle posts preloading separately with custom logic
1164
+ * }
1165
+ * })
1166
+ * .preload('posts', { and: { featured: true } }) // Custom preloading
1167
+ * .all()
1168
+ * ```
1169
+ *
1170
+ * @param serializerKey - The serializer key to use for determining which associations to preload.
1171
+ * @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
1172
+ * @returns A Query with all serialization associations preloaded
1173
+ */
1174
+ static preloadFor(serializerKey, modifierFn) {
1175
+ return this.query().preloadFor(serializerKey, modifierFn);
1176
+ }
1177
+ /**
1178
+ * Recursively preloads all Dream associations referenced by `rendersOne` and `rendersMany`
1179
+ * in a DreamSerializer using left join preloading. This traverses the entire content tree
1180
+ * of serializers to automatically load all necessary associations in a single query,
1181
+ * eliminating N+1 query problems and removing the need to manually remember which
1182
+ * associations to preload for serialization.
1183
+ *
1184
+ * This method decouples data loading code from data rendering code by having the serializer
1185
+ * (rendering code) inform the query (loading code) about which associations are needed.
1186
+ * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
1187
+ * modifying existing ones - the loading code automatically adapts without requiring
1188
+ * corresponding modifications to left join preload statements.
1189
+ *
1190
+ * This method analyzes the serializer (specified by `serializerKey` or 'default') and
1191
+ * automatically left join preloads all associations that will be needed during serialization.
1192
+ *
1193
+ * Note: Left join preloading loads all data in a single SQL query but has trade-offs compared
1194
+ * to regular preloading. See {@link Dream.leftJoinPreload} for details about limitations.
1195
+ *
1196
+ * ```ts
1197
+ * // Instead of manually specifying all associations:
1198
+ * await User.leftJoinPreload('posts', 'comments', 'replies').all()
1199
+ *
1200
+ * // Automatically left join preload everything needed for serialization:
1201
+ * await User.leftJoinPreloadFor('summary').all()
1202
+ *
1203
+ * // Add where conditions to specific associations during left join preloading:
1204
+ * await User.leftJoinPreloadFor('detailed', (dreamClass, associationName) => {
1205
+ * if (dreamClass.typeof(Post) && associationName === 'comments') {
1206
+ * return { and: { published: true } }
1207
+ * }
1208
+ * }).all()
1209
+ *
1210
+ * // Skip left join preloading specific associations to handle them manually:
1211
+ * await User.leftJoinPreloadFor('summary', (dreamClass, associationName) => {
1212
+ * if (dreamClass.typeof(User) && associationName === 'posts') {
1213
+ * return 'omit' // Handle posts preloading separately with custom logic
1214
+ * }
1215
+ * })
1216
+ * .preload('posts', { and: { featured: true } }) // Custom preloading instead
1217
+ * .all()
1218
+ * ```
1219
+ *
1220
+ * @param serializerKey - The serializer key to use for determining which associations to preload.
1221
+ * @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
1222
+ * @returns A Query with all serialization associations left join preloaded
1223
+ */
1224
+ static leftJoinPreloadFor(serializerKey, modifierFn) {
1225
+ return this.query().leftJoinPreloadFor(serializerKey, modifierFn);
1226
+ }
1020
1227
  /**
1021
1228
  * Returns a new Query instance with the provided
1022
1229
  * inner join statement attached
@@ -1213,7 +1420,7 @@ class Dream {
1213
1420
  * // 3
1214
1421
  * ```
1215
1422
  *
1216
- * @param fields - a list of fields to pluck, followed by a callback function to call for each set of found fields
1423
+ * @param args - a list of fields to pluck, followed by a callback function to call for each set of found fields
1217
1424
  * @returns void
1218
1425
  */
1219
1426
  static async pluckEach(...args) {
@@ -1422,7 +1629,7 @@ class Dream {
1422
1629
  * // [User{email: 'how@yadoin'}, User{name: 'fred'}, User{name: 'fred'}]
1423
1630
  * ```
1424
1631
  *
1425
- * @param whereStatements - a list of where statements to `OR` together
1632
+ * @param statements - a list of where statements to `OR` together
1426
1633
  * @returns A Query for this model with the whereAny clause applied
1427
1634
  */
1428
1635
  static whereAny(statements) {
@@ -1437,7 +1644,7 @@ class Dream {
1437
1644
  * // User{email: 'hello@world'}
1438
1645
  * ```
1439
1646
  *
1440
- * @param whereStatement - A where statement to negate and apply to the Query
1647
+ * @param attributes - A where statement to negate and apply to the Query
1441
1648
  * @returns A Query for this model with the whereNot clause applied
1442
1649
  */
1443
1650
  static whereNot(attributes) {
@@ -2377,7 +2584,7 @@ class Dream {
2377
2584
  * // 'dog'
2378
2585
  * ```
2379
2586
  *
2380
- * @param columName - The column name you want the previous value for
2587
+ * @param columnName - The column name you want the previous value for
2381
2588
  * @returns Returns the previous value for an attribute
2382
2589
  */
2383
2590
  previousValueForAttribute(columnName) {
@@ -2403,7 +2610,7 @@ class Dream {
2403
2610
  * Returns true if the columnName provided has
2404
2611
  * changes that have not yet been persisted.
2405
2612
  *
2406
- * @param columnName - the column name to check
2613
+ * @param attribute - the column name to check
2407
2614
  * @returns A boolean
2408
2615
  */
2409
2616
  willSaveChangeToAttribute(attribute) {
@@ -2840,7 +3047,7 @@ class Dream {
2840
3047
  /**
2841
3048
  * Loads the requested associations upon execution
2842
3049
  *
2843
- * NOTE: {@link #preload} is often a preferrable way of achieving the
3050
+ * NOTE: {@link Dream.preload} is often a preferrable way of achieving the
2844
3051
  * same goal.
2845
3052
  *
2846
3053
  * ```ts
@@ -2862,20 +3069,67 @@ class Dream {
2862
3069
  load(...args) {
2863
3070
  return new LoadBuilder_js_1.default(this).load(...args);
2864
3071
  }
3072
+ /**
3073
+ * Recursively loads all Dream associations referenced by `rendersOne` and `rendersMany`
3074
+ * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
3075
+ * load all necessary associations, eliminating N+1 query problems and removing the need to
3076
+ * manually remember which associations to preload for serialization.
3077
+ *
3078
+ * This method decouples data loading code from data rendering code by having the serializer
3079
+ * (rendering code) inform the query (loading code) about which associations are needed.
3080
+ * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
3081
+ * modifying existing ones - the loading code automatically adapts without requiring
3082
+ * corresponding modifications to preload statements.
3083
+ *
3084
+ * This method analyzes the serializer (specified by `serializerKey` or 'default') and
3085
+ * automatically preloads all associations that will be needed during serialization.
3086
+ *
3087
+ * ```ts
3088
+ * // Instead of manually specifying all associations:
3089
+ * await User.preload('posts', 'comments', 'replies').all()
3090
+ *
3091
+ * // Automatically preload everything needed for serialization:
3092
+ * await user.loadFor('summary').execute()
3093
+ *
3094
+ * // Add where conditions to specific associations during preloading:
3095
+ * await user.loadFor('detailed', (dreamClass, associationName) => {
3096
+ * if (dreamClass.typeof(Post) && associationName === 'comments') {
3097
+ * return { and: { published: true } }
3098
+ * }
3099
+ * })
3100
+ * .execute()
3101
+ *
3102
+ * // Skip preloading specific associations to handle them manually:
3103
+ * await user
3104
+ * .loadFor('summary', (dreamClass, associationName) => {
3105
+ * if (dreamClass.typeof(User) && associationName === 'posts') {
3106
+ * return 'omit' // Handle posts preloading separately with custom logic
3107
+ * }
3108
+ * })
3109
+ * .load('posts', { and: { featured: true } }) // Custom preloading
3110
+ * .execute()
3111
+ * ```
3112
+ *
3113
+ * @param serializerKey - The serializer key to use for determining which associations to preload.
3114
+ * @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
3115
+ * @returns A Query with all serialization associations preloaded
3116
+ */
3117
+ loadFor(serializerKey, modifierFn) {
3118
+ return new LoadBuilder_js_1.default(this)['loadFor'](serializerKey, modifierFn);
3119
+ }
2865
3120
  /**
2866
3121
  * Load each specified association using a single SQL query.
2867
- * See {@link #load} for loading in separate queries.
3122
+ * See {@link Dream.load} for loading in separate queries.
2868
3123
  *
2869
- * Note: since leftJoinPreload loads via single query, it has
2870
- * some downsides and that may be avoided using {@link #load}:
3124
+ * Note: since leftJoinLoad loads via single query, it has
3125
+ * some downsides and that may be avoided using {@link Dream.load}:
2871
3126
  * 1. `limit` and `offset` will be automatically removed
2872
3127
  * 2. `through` associations will bring additional namespaces into the query that can conflict with through associations from other associations, creating an invalid query
2873
- * 3. each nested association will result in an additional record which duplicates data from the outer record. E.g., given `.leftJoinPreload('a', 'b', 'c')`, if each `a` has 10 `b` and each `b` has 10 `c`, then for one `a`, 100 records will be returned, each of which has all of the columns of `a`. `.load('a', 'b', 'c')` would perform three separate SQL queries, but the data for a single `a` would only be returned once.
3128
+ * 3. each nested association will result in an additional record which duplicates data from the outer record. E.g., given `.leftJoinLoad('a', 'b', 'c')`, if each `a` has 10 `b` and each `b` has 10 `c`, then for one `a`, 100 records will be returned, each of which has all of the columns of `a`. `.load('a', 'b', 'c')` would perform three separate SQL queries, but the data for a single `a` would only be returned once.
2874
3129
  * 4. the individual query becomes more complex the more associations are included
2875
3130
  * 5. associations loading associations loading associations could result in exponential amounts of data; in those cases, `.load(...).findEach(...)` avoids instantiating massive amounts of data at once
2876
- * Loads the requested associations upon execution
2877
3131
  *
2878
- * NOTE: {@link #leftJoinPreload} is often a preferrable way of achieving the
3132
+ * NOTE: {@link Dream.leftJoinPreload} is often a preferrable way of achieving the
2879
3133
  * same goal.
2880
3134
  *
2881
3135
  * ```ts
@@ -2897,6 +3151,54 @@ class Dream {
2897
3151
  leftJoinLoad(...args) {
2898
3152
  return new LeftJoinLoadBuilder_js_1.default(this).leftJoinLoad(...args);
2899
3153
  }
3154
+ /**
3155
+ * Recursively loads all Dream associations referenced by `rendersOne` and `rendersMany`
3156
+ * in a DreamSerializer. This traverses the entire content tree of serializers to automatically
3157
+ * load all necessary associations, eliminating N+1 query problems and removing the need to
3158
+ * manually remember which associations to preload for serialization.
3159
+ *
3160
+ * This method decouples data loading code from data rendering code by having the serializer
3161
+ * (rendering code) inform the query (loading code) about which associations are needed.
3162
+ * As serializers evolve over time - adding new `rendersOne` and `rendersMany` calls or
3163
+ * modifying existing ones - the loading code automatically adapts without requiring
3164
+ * corresponding modifications to preload statements.
3165
+ *
3166
+ * This method analyzes the serializer (specified by `serializerKey` or 'default') and
3167
+ * automatically preloads all associations that will be needed during serialization.
3168
+ *
3169
+ * ```ts
3170
+ * // Instead of manually specifying all associations:
3171
+ * await User.preload('posts', 'comments', 'replies').all()
3172
+ *
3173
+ * // Automatically preload everything needed for serialization:
3174
+ * await user.leftJoinLoadFor('summary').execute()
3175
+ *
3176
+ * // Add where conditions to specific associations during preloading:
3177
+ * await user.leftJoinLoadFor('detailed', (dreamClass, associationName) => {
3178
+ * if (dreamClass.typeof(Post) && associationName === 'comments') {
3179
+ * return { and: { published: true } }
3180
+ * }
3181
+ * })
3182
+ * .execute()
3183
+ *
3184
+ * // Skip preloading specific associations to handle them manually:
3185
+ * await user
3186
+ * .loadFor('summary', (dreamClass, associationName) => {
3187
+ * if (dreamClass.typeof(User) && associationName === 'posts') {
3188
+ * return 'omit' // Handle posts preloading separately with custom logic
3189
+ * }
3190
+ * })
3191
+ * .load('posts', { and: { featured: true } }) // Custom preloading
3192
+ * .execute()
3193
+ * ```
3194
+ *
3195
+ * @param serializerKey - The serializer key to use for determining which associations to preload.
3196
+ * @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
3197
+ * @returns A Query with all serialization associations preloaded
3198
+ */
3199
+ leftJoinLoadFor(serializerKey, modifierFn) {
3200
+ return new LeftJoinLoadBuilder_js_1.default(this)['leftJoinLoadFor'](serializerKey, modifierFn);
3201
+ }
2900
3202
  /**
2901
3203
  * Returns true if the association specified has
2902
3204
  * been loaded on this instance
@@ -3009,7 +3311,8 @@ class Dream {
3009
3311
  * user.type // 'User'
3010
3312
  * ```
3011
3313
  *
3012
- * @param opts.skipHooks - if true, will skip applying model hooks. Defaults to false
3314
+ * @param __namedParameters - optional parameters
3315
+ * @param __namedParameters.skipHooks - if true, will skip applying model hooks. Defaults to false
3013
3316
  * @returns void
3014
3317
  */
3015
3318
  async save({ skipHooks } = {}) {
@@ -3049,7 +3352,8 @@ class Dream {
3049
3352
  * ```
3050
3353
  *
3051
3354
  * @param attributes - the attributes to set on the model
3052
- * @param opts.skipHooks - if true, will skip applying model hooks. Defaults to false
3355
+ * @param __namedParameters - optional parameters
3356
+ * @param __namedParameters.skipHooks - if true, will skip applying model hooks. Defaults to false
3053
3357
  * @returns void
3054
3358
  */
3055
3359
  async update(attributes, { skipHooks } = {}) {
@@ -3076,7 +3380,8 @@ class Dream {
3076
3380
  * ```
3077
3381
  *
3078
3382
  * @param attributes - The attributes to update on this instance
3079
- * @param opts.skipHooks - if true, will skip applying model hooks. Defaults to false
3383
+ * @param __namedParameters - optional parameters
3384
+ * @param __namedParameters.skipHooks - if true, will skip applying model hooks. Defaults to false
3080
3385
  * @returns - void
3081
3386
  */
3082
3387
  async updateAttributes(attributes, { skipHooks } = {}) {
@@ -3109,7 +3414,7 @@ class Dream {
3109
3414
  * Flags a dream model so that it allows
3110
3415
  * deletion once again.
3111
3416
  *
3112
- * Undoes {@link Dream.(preventDeletion:instance) | preventDeletion}
3417
+ * Undoes {@link Dream.preventDeletion}
3113
3418
  *
3114
3419
  * ```ts
3115
3420
  * class User extends ApplicationModel {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const commander_1 = require("commander");
4
4
  const index_js_1 = require("../bin/index.js");
5
+ const index_js_2 = require("../dream-app/index.js");
5
6
  const EnvInternal_js_1 = require("../helpers/EnvInternal.js");
6
7
  const sspawn_js_1 = require("../helpers/sspawn.js");
7
8
  const DreamCliLogger_js_1 = require("./logger/DreamCliLogger.js");
@@ -141,6 +142,21 @@ class DreamCLI {
141
142
  await seedDb();
142
143
  process.exit();
143
144
  });
145
+ program
146
+ .command('inspect:serialization')
147
+ .alias('i:serialization')
148
+ .description('displays a serialization map to help understand the rendering logic for a particular model')
149
+ .argument('<globalName>', 'the global name of the model you want to look up')
150
+ .argument('[serializerKey]', 'the serializer key you wish to use')
151
+ .action(async (globalName, serializerKey) => {
152
+ await initializeDreamApp();
153
+ const dreamApp = index_js_2.default.getOrFail();
154
+ const modelClass = dreamApp.models[globalName];
155
+ if (!modelClass)
156
+ throw new Error(`failed to locate model by global name: ${globalName}`);
157
+ modelClass['displaySerialization'](serializerKey);
158
+ process.exit();
159
+ });
144
160
  }
145
161
  /*
146
162
  * the default spawn provided by node:child_process is incompatible
@@ -11,8 +11,9 @@ class DreamMigrationHelpers {
11
11
  *
12
12
  * @param db - The Kysely database object passed into the migration up/down function
13
13
  * @param constraintName - The name of the constraint to create
14
- * @param opts.table - The name of the table
15
- * @param opts.columns[] - The names of the columns to include in the constraint
14
+ * @param options - Configuration options
15
+ * @param options.table - The name of the table
16
+ * @param options.columns - The names of the columns to include in the constraint
16
17
  *
17
18
  */
18
19
  static async addDeferrableUniqueConstraint(db, constraintName, { table, columns, }) {
@@ -30,9 +31,9 @@ class DreamMigrationHelpers {
30
31
  * Note that this always includes "IF NOT EXISTS", so is safe to re-run multiple times.
31
32
  *
32
33
  * @param db - The Kysely database object passed into the migration up/down function
33
- * @param opt.enumName - The name of the enum to modify
34
- * @param opt.value - The name of the value to add to the enum
35
- *
34
+ * @param __namedParameters - The options for adding the enum value
35
+ * @param __namedParameters.enumName - The name of the enum to modify
36
+ * @param __namedParameters.value - The name of the value to add to the enum
36
37
  */
37
38
  static async addEnumValue(db, { enumName, value }) {
38
39
  await (0, kysely_1.sql) `ALTER TYPE ${kysely_1.sql.raw(enumName)} ADD VALUE IF NOT EXISTS '${kysely_1.sql.raw(value)}';`.execute(db);
@@ -50,8 +51,9 @@ class DreamMigrationHelpers {
50
51
  *
51
52
  * @param db - The Kysely database object passed into the migration up/down function
52
53
  * @param extensionName - The name of the database extension to add
53
- * @param opt.ifNotExists - Only add the extension if it doesn't already exist
54
- * @param opt.publicSchema - Create using the public schema
54
+ * @param options - Configuration options
55
+ * @param options.ifNotExists - Only add the extension if it doesn't already exist
56
+ * @param options.publicSchema - Create using the public schema
55
57
  *
56
58
  */
57
59
  static async createExtension(db, extensionName, { ifNotExists = true, publicSchema = true } = {}) {
@@ -66,8 +68,9 @@ class DreamMigrationHelpers {
66
68
  *
67
69
  * @param db - The Kysely database object passed into the migration up/down function
68
70
  * @param indexName - The name of the constraint to create
69
- * @param opts.table - The name of the table
70
- * @param opts.column - The name of the column to index
71
+ * @param options - Configuration options
72
+ * @param options.table - The name of the table
73
+ * @param options.column - The name of the column to index
71
74
  *
72
75
  */
73
76
  static async createGinIndex(db, indexName, { table, column }) {
@@ -82,7 +85,8 @@ class DreamMigrationHelpers {
82
85
  *
83
86
  * @param db - The Kysely database object passed into the migration up/down function
84
87
  * @param constraintName - The name of the constraint to create
85
- * @param opts.table - The name of the table
88
+ * @param options - Configuration options
89
+ * @param options.table - The name of the table
86
90
  *
87
91
  */
88
92
  static async dropConstraint(db, constraintName, { table }) {
@@ -94,10 +98,10 @@ class DreamMigrationHelpers {
94
98
  * Drop a value from an enum and replace it (or optionally remove it from array columns)
95
99
  *
96
100
  * @param db - The Kysely database object passed into the migration up/down function
97
- * @param opt.enumName - The name of the enum to modify
98
- * @param opt.value - The name of the value to drop from the enum
99
- * @param opt.replacements[] - Details about which table and column to change and which value to replace the dropped value with (or remove it if the column is an array)
100
- *
101
+ * @param __namedParameters - The options for dropping the enum value
102
+ * @param __namedParameters.enumName - The name of the enum to modify
103
+ * @param __namedParameters.value - The name of the value to drop from the enum
104
+ * @param __namedParameters.replacements - Details about which table and column to change and which value to replace the dropped value with (or remove it if the column is an array)
101
105
  */
102
106
  static async dropEnumValue(db, { enumName, value, replacements }) {
103
107
  // temporarily set all table columns depending on this enum to an acceptable alternate type
@@ -161,7 +161,8 @@ class Decorators {
161
161
  * }
162
162
  * ```
163
163
  *
164
- * @param scope - The column, association, or combination there-of which you would like to restrict the incrementing logic to
164
+ * @param opts - Configuration options for the sortable decorator
165
+ * @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
165
166
  * @returns A Sortable decorator
166
167
  */
167
168
  Sortable(opts) {