@rvoh/dream 2.1.2 → 2.1.4-alpha.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 (253) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/src/Dream.js +35 -0
  3. package/dist/cjs/src/bin/index.js +1 -1
  4. package/dist/cjs/src/cli/index.js +5 -1
  5. package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableText.js +1 -0
  6. package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +30 -0
  7. package/dist/cjs/src/dream/Query.js +30 -0
  8. package/dist/cjs/src/dream/QueryDriver/Base.js +32 -0
  9. package/dist/cjs/src/dream/QueryDriver/Kysely.js +52 -6
  10. package/dist/cjs/src/dream/QueryDriver/helpers/kysely/foreignKeyTypeFromPrimaryKey.js +3 -0
  11. package/dist/cjs/src/dream/constants.js +1 -1
  12. package/dist/cjs/src/dream/internal/printSerializerHierarchyLevel.js +2 -0
  13. package/dist/cjs/src/dream-app/helpers/DreamImporter.js +3 -1
  14. package/dist/cjs/src/dream-app/index.js +2 -1
  15. package/dist/cjs/src/helpers/Env.js +2 -0
  16. package/dist/cjs/src/helpers/cli/ASTConnectionBuilder.js +1 -1
  17. package/dist/cjs/src/helpers/cli/DBClassDeprecation.js +2 -0
  18. package/dist/cjs/src/helpers/cli/generateDream.js +2 -1
  19. package/dist/cjs/src/helpers/cli/generateFactory.js +2 -1
  20. package/dist/cjs/src/helpers/cli/generateFactoryContent.js +13 -3
  21. package/dist/cjs/src/helpers/cli/generateMigration.js +2 -1
  22. package/dist/cjs/src/helpers/cli/generateMigrationContent.js +18 -4
  23. package/dist/cjs/src/helpers/cli/generateSerializer.js +2 -1
  24. package/dist/cjs/src/helpers/cli/generateUnitSpec.js +2 -1
  25. package/dist/cjs/src/helpers/getFiles.js +3 -1
  26. package/dist/cjs/src/helpers/sspawn.js +2 -0
  27. package/dist/cjs/src/package-exports/system.js +1 -0
  28. package/dist/esm/src/Dream.js +35 -0
  29. package/dist/esm/src/bin/index.js +1 -1
  30. package/dist/esm/src/cli/index.js +5 -1
  31. package/dist/esm/src/cli/logger/loggable/DreamCliLoggableText.js +1 -0
  32. package/dist/esm/src/dream/DreamClassTransactionBuilder.js +30 -0
  33. package/dist/esm/src/dream/Query.js +30 -0
  34. package/dist/esm/src/dream/QueryDriver/Base.js +32 -0
  35. package/dist/esm/src/dream/QueryDriver/Kysely.js +52 -6
  36. package/dist/esm/src/dream/QueryDriver/helpers/kysely/foreignKeyTypeFromPrimaryKey.js +3 -0
  37. package/dist/esm/src/dream/constants.js +1 -1
  38. package/dist/esm/src/dream/internal/printSerializerHierarchyLevel.js +2 -0
  39. package/dist/esm/src/dream-app/helpers/DreamImporter.js +3 -1
  40. package/dist/esm/src/dream-app/index.js +2 -1
  41. package/dist/esm/src/helpers/Env.js +2 -0
  42. package/dist/esm/src/helpers/cli/ASTConnectionBuilder.js +1 -1
  43. package/dist/esm/src/helpers/cli/DBClassDeprecation.js +2 -0
  44. package/dist/esm/src/helpers/cli/generateDream.js +2 -1
  45. package/dist/esm/src/helpers/cli/generateFactory.js +2 -1
  46. package/dist/esm/src/helpers/cli/generateFactoryContent.js +13 -3
  47. package/dist/esm/src/helpers/cli/generateMigration.js +2 -1
  48. package/dist/esm/src/helpers/cli/generateMigrationContent.js +18 -4
  49. package/dist/esm/src/helpers/cli/generateSerializer.js +2 -1
  50. package/dist/esm/src/helpers/cli/generateUnitSpec.js +2 -1
  51. package/dist/esm/src/helpers/getFiles.js +3 -1
  52. package/dist/esm/src/helpers/sspawn.js +2 -0
  53. package/dist/esm/src/package-exports/system.js +1 -0
  54. package/dist/types/src/Dream.d.ts +42 -0
  55. package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +26 -0
  56. package/dist/types/src/dream/Query.d.ts +26 -0
  57. package/dist/types/src/dream/QueryDriver/Base.d.ts +29 -3
  58. package/dist/types/src/dream/QueryDriver/Kysely.d.ts +30 -4
  59. package/dist/types/src/dream/QueryDriver/helpers/kysely/foreignKeyTypeFromPrimaryKey.d.ts +2 -2
  60. package/dist/types/src/dream/constants.d.ts +1 -1
  61. package/dist/types/src/dream-app/helpers/PackageManager.d.ts +1 -1
  62. package/dist/types/src/dream-app/index.d.ts +6 -7
  63. package/dist/types/src/helpers/cli/generateMigrationContent.d.ts +1 -1
  64. package/dist/types/src/helpers/cli/generateStiMigrationContent.d.ts +1 -1
  65. package/dist/types/src/package-exports/system.d.ts +1 -0
  66. package/dist/types/src/package-exports/types.d.ts +1 -1
  67. package/dist/types/src/types/associations/belongsTo.d.ts +1 -1
  68. package/dist/types/src/types/associations/belongsTo.ts +1 -1
  69. package/dist/types/src/types/db.d.ts +2 -0
  70. package/dist/types/src/types/db.ts +2 -0
  71. package/dist/types/src/types/dream.d.ts +1 -2
  72. package/dist/types/src/types/dream.ts +1 -3
  73. package/dist/types/src/types/serializer.ts +2 -2
  74. package/docs/assets/navigation.js +1 -1
  75. package/docs/assets/search.js +1 -1
  76. package/docs/classes/db.DreamMigrationHelpers.html +9 -9
  77. package/docs/classes/db.KyselyQueryDriver.html +47 -31
  78. package/docs/classes/db.PostgresQueryDriver.html +48 -32
  79. package/docs/classes/db.QueryDriverBase.html +46 -30
  80. package/docs/classes/errors.CheckConstraintViolation.html +4 -4
  81. package/docs/classes/errors.ColumnOverflow.html +4 -4
  82. package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +4 -4
  83. package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +4 -4
  84. package/docs/classes/errors.DataTypeColumnTypeMismatch.html +4 -4
  85. package/docs/classes/errors.GlobalNameNotSet.html +4 -4
  86. package/docs/classes/errors.InvalidCalendarDate.html +4 -4
  87. package/docs/classes/errors.MissingSerializersDefinition.html +4 -4
  88. package/docs/classes/errors.NonLoadedAssociation.html +4 -4
  89. package/docs/classes/errors.NotNullViolation.html +4 -4
  90. package/docs/classes/errors.RecordNotFound.html +4 -4
  91. package/docs/classes/errors.ValidationError.html +4 -4
  92. package/docs/classes/index.CalendarDate.html +2 -2
  93. package/docs/classes/index.Decorators.html +19 -19
  94. package/docs/classes/index.Dream.html +227 -201
  95. package/docs/classes/index.DreamApp.html +5 -5
  96. package/docs/classes/index.DreamTransaction.html +2 -2
  97. package/docs/classes/index.Env.html +2 -2
  98. package/docs/classes/index.Query.html +91 -75
  99. package/docs/classes/system.CliFileWriter.html +2 -2
  100. package/docs/classes/system.DreamBin.html +2 -2
  101. package/docs/classes/system.DreamCLI.html +5 -5
  102. package/docs/classes/system.DreamImporter.html +2 -2
  103. package/docs/classes/system.DreamLogos.html +2 -2
  104. package/docs/classes/system.DreamSerializerBuilder.html +8 -8
  105. package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
  106. package/docs/classes/utils.Encrypt.html +2 -2
  107. package/docs/classes/utils.Range.html +2 -2
  108. package/docs/functions/db.closeAllDbConnections.html +1 -1
  109. package/docs/functions/db.dreamDbConnections.html +1 -1
  110. package/docs/functions/db.untypedDb.html +1 -1
  111. package/docs/functions/db.validateColumn.html +1 -1
  112. package/docs/functions/db.validateTable.html +1 -1
  113. package/docs/functions/errors.pgErrorType.html +1 -1
  114. package/docs/functions/index.DreamSerializer.html +1 -1
  115. package/docs/functions/index.ObjectSerializer.html +1 -1
  116. package/docs/functions/index.ReplicaSafe.html +1 -1
  117. package/docs/functions/index.STI.html +1 -1
  118. package/docs/functions/index.SoftDelete.html +1 -1
  119. package/docs/functions/utils.camelize.html +1 -1
  120. package/docs/functions/utils.capitalize.html +1 -1
  121. package/docs/functions/utils.cloneDeepSafe.html +1 -1
  122. package/docs/functions/utils.compact.html +1 -1
  123. package/docs/functions/utils.groupBy.html +1 -1
  124. package/docs/functions/utils.hyphenize.html +1 -1
  125. package/docs/functions/utils.intersection.html +1 -1
  126. package/docs/functions/utils.isEmpty.html +1 -1
  127. package/docs/functions/utils.normalizeUnicode.html +1 -1
  128. package/docs/functions/utils.pascalize.html +1 -1
  129. package/docs/functions/utils.percent.html +1 -1
  130. package/docs/functions/utils.range-1.html +1 -1
  131. package/docs/functions/utils.round.html +1 -1
  132. package/docs/functions/utils.sanitizeString.html +1 -1
  133. package/docs/functions/utils.snakeify.html +1 -1
  134. package/docs/functions/utils.sort.html +1 -1
  135. package/docs/functions/utils.sortBy.html +1 -1
  136. package/docs/functions/utils.sortObjectByKey.html +1 -1
  137. package/docs/functions/utils.sortObjectByValue.html +1 -1
  138. package/docs/functions/utils.uncapitalize.html +1 -1
  139. package/docs/functions/utils.uniq.html +1 -1
  140. package/docs/index.html +4 -4
  141. package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
  142. package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
  143. package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
  144. package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
  145. package/docs/interfaces/types.BelongsToStatement.html +2 -2
  146. package/docs/interfaces/types.DecoratorContext.html +2 -2
  147. package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
  148. package/docs/interfaces/types.DreamAppOpts.html +2 -2
  149. package/docs/interfaces/types.EncryptOptions.html +2 -2
  150. package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
  151. package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
  152. package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
  153. package/docs/modules/db.html +1 -1
  154. package/docs/modules/errors.html +1 -1
  155. package/docs/modules/index.html +1 -1
  156. package/docs/modules/openapi.html +1 -1
  157. package/docs/modules/system.html +2 -1
  158. package/docs/modules/types.html +4 -3
  159. package/docs/modules/utils.html +1 -1
  160. package/docs/types/index.DateTime.html +1 -1
  161. package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
  162. package/docs/types/openapi.OpenapiAllTypes.html +1 -1
  163. package/docs/types/openapi.OpenapiFormats.html +1 -1
  164. package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
  165. package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
  166. package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
  167. package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
  168. package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
  169. package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
  170. package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
  171. package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
  172. package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
  173. package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +1 -1
  174. package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +1 -1
  175. package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +1 -1
  176. package/docs/types/openapi.OpenapiSchemaExpressionRef.html +1 -1
  177. package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  178. package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
  179. package/docs/types/openapi.OpenapiSchemaNull.html +1 -1
  180. package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
  181. package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
  182. package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
  183. package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
  184. package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
  185. package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  186. package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
  187. package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
  188. package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
  189. package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
  190. package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
  191. package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
  192. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  193. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  194. package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  195. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  196. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  197. package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  198. package/docs/types/openapi.OpenapiSchemaString.html +1 -1
  199. package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
  200. package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
  201. package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
  202. package/docs/types/openapi.OpenapiTypeField.html +1 -1
  203. package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
  204. package/docs/types/types.Camelized.html +1 -1
  205. package/docs/types/types.DbConnectionType.html +1 -1
  206. package/docs/types/types.DbTypes.html +1 -1
  207. package/docs/types/types.DreamAssociationMetadata.html +1 -1
  208. package/docs/types/types.DreamAttributes.html +1 -1
  209. package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
  210. package/docs/types/types.DreamClassColumn.html +1 -1
  211. package/docs/types/types.DreamColumn.html +1 -1
  212. package/docs/types/types.DreamColumnNames.html +1 -1
  213. package/docs/types/types.DreamLogLevel.html +1 -1
  214. package/docs/types/types.DreamLogger.html +1 -1
  215. package/docs/types/types.DreamModelSerializerType.html +1 -1
  216. package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
  217. package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
  218. package/docs/types/types.DreamParamSafeAttributes.html +1 -1
  219. package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
  220. package/docs/types/types.DreamSerializable.html +1 -1
  221. package/docs/types/types.DreamSerializableArray.html +1 -1
  222. package/docs/types/types.DreamSerializerKey.html +1 -1
  223. package/docs/types/types.DreamSerializers.html +1 -1
  224. package/docs/types/types.DreamVirtualColumns.html +1 -1
  225. package/docs/types/types.EncryptAlgorithm.html +1 -1
  226. package/docs/types/types.HasManyStatement.html +1 -1
  227. package/docs/types/types.HasOneStatement.html +1 -1
  228. package/docs/types/types.Hyphenized.html +1 -1
  229. package/docs/types/types.Pascalized.html +1 -1
  230. package/docs/types/types.PrimaryKeyType.html +1 -0
  231. package/docs/types/types.RoundingPrecision.html +1 -1
  232. package/docs/types/types.SerializerCasing.html +1 -1
  233. package/docs/types/types.SimpleObjectSerializerType.html +1 -1
  234. package/docs/types/types.Snakeified.html +1 -1
  235. package/docs/types/types.StrictInterface.html +1 -1
  236. package/docs/types/types.UpdateableAssociationProperties.html +1 -1
  237. package/docs/types/types.UpdateableProperties.html +1 -1
  238. package/docs/types/types.ValidationType.html +1 -1
  239. package/docs/types/types.ViewModel.html +1 -1
  240. package/docs/types/types.ViewModelClass.html +1 -1
  241. package/docs/types/types.WhereStatementForDream.html +1 -1
  242. package/docs/types/types.WhereStatementForDreamClass.html +1 -1
  243. package/docs/variables/index.DateTime-1.html +1 -1
  244. package/docs/variables/index.DreamConst.html +1 -1
  245. package/docs/variables/index.ops.html +1 -1
  246. package/docs/variables/openapi.openapiPrimitiveTypes-1.html +1 -1
  247. package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +1 -1
  248. package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
  249. package/docs/variables/system.primaryKeyTypes.html +1 -0
  250. package/docs/variables/types.TRIGRAM_OPERATORS.html +1 -1
  251. package/package.json +17 -17
  252. package/CHANGELOG.md +0 -332
  253. package/docs/variables/types.primaryKeyTypes.html +0 -1
@@ -3,6 +3,7 @@ export { CliFileWriter } from '../cli/CliFileWriter.js';
3
3
  export { default as DreamCLI } from '../cli/index.js';
4
4
  export { default as DreamImporter } from '../dream-app/helpers/DreamImporter.js';
5
5
  export { DreamAppAllowedPackageManagersEnumValues, } from '../dream-app/index.js';
6
+ export { primaryKeyTypes } from '../dream/constants.js';
6
7
  export { default as DreamLogos } from '../helpers/DreamLogos/DreamLogos.js';
7
8
  export { default as DreamSerializerBuilder } from '../serializer/builders/DreamSerializerBuilder.js';
8
9
  export { default as ObjectSerializerBuilder } from '../serializer/builders/ObjectSerializerBuilder.js';
@@ -707,6 +707,34 @@ export default class Dream {
707
707
  * @returns the min value of the specified column for this model's records
708
708
  */
709
709
  static min<T extends typeof Dream, ColumnName extends DreamColumnNames<InstanceType<T>>>(this: T, columnName: ColumnName): Promise<InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]["coercedType" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]]>;
710
+ /**
711
+ * Retrieves the sum for all values of the specified column
712
+ * for this model's records.
713
+ *
714
+ *
715
+ * ```ts
716
+ * await Game.sum('score')
717
+ * // 100
718
+ * ```
719
+ *
720
+ * @param columnName - a column name on the model
721
+ * @returns the sum for all values of the specified column for this model's records
722
+ */
723
+ static sum<T extends typeof Dream, ColumnName extends DreamColumnNames<InstanceType<T>>>(this: T, columnName: ColumnName): Promise<InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]["coercedType" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]]>;
724
+ /**
725
+ * Retrieves the average for all values of the specified column
726
+ * for this model's records.
727
+ *
728
+ *
729
+ * ```ts
730
+ * await Game.avg('score')
731
+ * // 100
732
+ * ```
733
+ *
734
+ * @param columnName - a column name on the model
735
+ * @returns the average for all values of the specified column for this model's records
736
+ */
737
+ static avg<T extends typeof Dream, ColumnName extends DreamColumnNames<InstanceType<T>>>(this: T, columnName: ColumnName): Promise<InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]["coercedType" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]]>;
710
738
  /**
711
739
  * Persists a new record, setting the provided attributes.
712
740
  * Automatically sets createdAt and updatedAt timestamps.
@@ -2349,6 +2377,13 @@ export default class Dream {
2349
2377
  * For HasMany associations, returns an array (empty if no records). For BelongsTo/HasOne
2350
2378
  * associations, returns the associated model or null if not found.
2351
2379
  *
2380
+ * @remarks
2381
+ * **Warning:** Using `association` in loops or when processing multiple records can lead to the
2382
+ * [N+1 query problem](https://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations).
2383
+ * Each call to `association` on an unloaded association will trigger a separate database query.
2384
+ * To avoid this, use {@link Dream.load | `load`} or {@link Dream.preload | `preload`} to eager load
2385
+ * associations before accessing them.
2386
+ *
2352
2387
  * ```ts
2353
2388
  * // Basic association loading
2354
2389
  * const user = await post.association('user')
@@ -2401,6 +2436,13 @@ export default class Dream {
2401
2436
  * For HasMany associations, returns an array (empty if no records). For BelongsTo/HasOne
2402
2437
  * associations, returns the associated model or throws RecordNotFound if not found.
2403
2438
  *
2439
+ * @remarks
2440
+ * **Warning:** Using `associationOrFail` in loops or when processing multiple records can lead to the
2441
+ * [N+1 query problem](https://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations).
2442
+ * Each call to `associationOrFail` on an unloaded association will trigger a separate database query.
2443
+ * To avoid this, use {@link Dream.load | `load`} or {@link Dream.preload | `preload`} to eager load
2444
+ * associations before accessing them.
2445
+ *
2404
2446
  * ```ts
2405
2447
  * // Basic association loading - throws RecordNotFound if user doesn't exist
2406
2448
  * const user = await post.associationOrFail('user')
@@ -115,6 +115,32 @@ export default class DreamClassTransactionBuilder<DreamClass extends typeof Drea
115
115
  * @returns The min value of the specified column for this model's records
116
116
  */
117
117
  min<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>, T extends DreamColumnNames<DreamInstance>>(this: I, columnName: T): Promise<DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]["coercedType" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]]>;
118
+ /**
119
+ * Retrieves the sum value of the specified column
120
+ * for this Query
121
+ *
122
+ * ```ts
123
+ * await Game.txn(txn).sum('score')
124
+ * // 1
125
+ * ```
126
+ *
127
+ * @param columnName - a column name on the model
128
+ * @returns the sum of the values of the specified column for this Query
129
+ */
130
+ sum<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>, T extends DreamColumnNames<DreamInstance>>(this: I, columnName: T): Promise<DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]["coercedType" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]]>;
131
+ /**
132
+ * Retrieves the average value of the specified column
133
+ * for this Query
134
+ *
135
+ * ```ts
136
+ * await Game.txn(txn).avg('score')
137
+ * // 1
138
+ * ```
139
+ *
140
+ * @param columnName - a column name on the model
141
+ * @returns the average of the values of the specified column for this Query
142
+ */
143
+ avg<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>, T extends DreamColumnNames<DreamInstance>>(this: I, columnName: T): Promise<DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]["coercedType" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]]>;
118
144
  /**
119
145
  * Persists a new record, setting the provided attributes.
120
146
  * Automatically sets createdAt and updatedAt timestamps.
@@ -752,6 +752,32 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
752
752
  * @returns the min value of the specified column for this Query
753
753
  */
754
754
  min<Q extends Query<DreamInstance, QueryTypeOpts>, DB extends DreamInstance['DB'], ColumnName extends ColumnNamesAccountingForJoinedAssociations<Q['queryTypeOpts']['joinedAssociations'], DB, QueryTypeOpts['rootTableName'], QueryTypeOpts['rootTableAlias']>, ReturnType extends NamespacedOrBaseModelColumnTypes<[ColumnName], Q, DreamInstance>[0]>(columnName: ColumnName): Promise<ReturnType>;
755
+ /**
756
+ * Retrieves the sum value of the specified column
757
+ * for this Query
758
+ *
759
+ * ```ts
760
+ * await Game.query().sum('score')
761
+ * // 1
762
+ * ```
763
+ *
764
+ * @param columnName - a column name on the model
765
+ * @returns the sum of the values of the specified column for this Query
766
+ */
767
+ sum<Q extends Query<DreamInstance, QueryTypeOpts>, DB extends DreamInstance['DB'], ColumnName extends ColumnNamesAccountingForJoinedAssociations<Q['queryTypeOpts']['joinedAssociations'], DB, QueryTypeOpts['rootTableName'], QueryTypeOpts['rootTableAlias']>, ReturnType extends NamespacedOrBaseModelColumnTypes<[ColumnName], Q, DreamInstance>[0]>(columnName: ColumnName): Promise<ReturnType>;
768
+ /**
769
+ * Retrieves the average value of the specified column
770
+ * for this Query
771
+ *
772
+ * ```ts
773
+ * await Game.query().avg('score')
774
+ * // 1
775
+ * ```
776
+ *
777
+ * @param columnName - a column name on the model
778
+ * @returns the average of the values of the specified column for this Query
779
+ */
780
+ avg<Q extends Query<DreamInstance, QueryTypeOpts>, DB extends DreamInstance['DB'], ColumnName extends ColumnNamesAccountingForJoinedAssociations<Q['queryTypeOpts']['joinedAssociations'], DB, QueryTypeOpts['rootTableName'], QueryTypeOpts['rootTableAlias']>, ReturnType extends NamespacedOrBaseModelColumnTypes<[ColumnName], Q, DreamInstance>[0]>(columnName: ColumnName): Promise<ReturnType>;
755
781
  /**
756
782
  * Plucks the provided fields from the given dream class table
757
783
  *
@@ -1,12 +1,12 @@
1
1
  import { CompiledQuery, DeleteQueryBuilder, SelectQueryBuilder, UpdateQueryBuilder } from 'kysely';
2
2
  import Dream from '../../Dream.js';
3
+ import { SchemaBuilderAssociationData, SchemaBuilderColumnData } from '../../helpers/cli/ASTBuilder.js';
3
4
  import { AssociationStatement } from '../../types/associations/shared.js';
4
- import { DbConnectionType } from '../../types/db.js';
5
- import { DreamColumnNames, DreamConstructorType, DreamTableSchema, PrimaryKeyType } from '../../types/dream.js';
5
+ import { DbConnectionType, PrimaryKeyType } from '../../types/db.js';
6
+ import { DreamColumnNames, DreamConstructorType, DreamTableSchema } from '../../types/dream.js';
6
7
  import { PreloadedDreamsAndWhatTheyPointTo, QueryToKyselyDBType, QueryToKyselyTableNamesType } from '../../types/query.js';
7
8
  import DreamTransaction from '../DreamTransaction.js';
8
9
  import Query from '../Query.js';
9
- import { SchemaBuilderAssociationData, SchemaBuilderColumnData } from '../../helpers/cli/ASTBuilder.js';
10
10
  export default class QueryDriverBase<DreamInstance extends Dream> {
11
11
  query: Query<DreamInstance, any>;
12
12
  protected readonly dreamClass: DreamConstructorType<DreamInstance>;
@@ -195,6 +195,32 @@ export default class QueryDriverBase<DreamInstance extends Dream> {
195
195
  * @returns the min value of the specified column for this Query
196
196
  */
197
197
  min(columnName: string): Promise<any>;
198
+ /**
199
+ * Retrieves the sum value of the specified column
200
+ * for this Query
201
+ *
202
+ * ```ts
203
+ * await Game.query().sum('score')
204
+ * // 1
205
+ * ```
206
+ *
207
+ * @param columnName - a column name on the model
208
+ * @returns the sum of the values of the specified column for this Query
209
+ */
210
+ sum(columnName: string): Promise<any>;
211
+ /**
212
+ * Retrieves the average value of the specified column
213
+ * for this Query
214
+ *
215
+ * ```ts
216
+ * await Game.query().avg('score')
217
+ * // 1
218
+ * ```
219
+ *
220
+ * @param columnName - a column name on the model
221
+ * @returns the average of the values of the specified column for this Query
222
+ */
223
+ avg(columnName: string): Promise<any>;
198
224
  /**
199
225
  * Retrieves the number of records in the database
200
226
  *
@@ -3,8 +3,8 @@ import { DialectProviderCb } from '../../db/DreamDbConnection.js';
3
3
  import Dream from '../../Dream.js';
4
4
  import { SchemaBuilderInformationSchemaRow } from '../../helpers/cli/ASTBuilder.js';
5
5
  import { AssociationStatement } from '../../types/associations/shared.js';
6
- import { DbConnectionType } from '../../types/db.js';
7
- import { DreamColumnNames, DreamTableSchema, OrderDir, PrimaryKeyType, SqlCommandType } from '../../types/dream.js';
6
+ import { DbConnectionType, PrimaryKeyType } from '../../types/db.js';
7
+ import { DreamColumnNames, DreamTableSchema, OrderDir, SqlCommandType } from '../../types/dream.js';
8
8
  import { PreloadedDreamsAndWhatTheyPointTo, QueryToKyselyDBType, QueryToKyselyTableNamesType } from '../../types/query.js';
9
9
  import DreamTransaction from '../DreamTransaction.js';
10
10
  import Query from '../Query.js';
@@ -48,14 +48,14 @@ export default class KyselyQueryDriver<DreamInstance extends Dream> extends Quer
48
48
  * returns the foreign key type based on the primary key received.
49
49
  * gives the driver the opportunity to switch i.e. bigserial to bigint.
50
50
  */
51
- static foreignKeyTypeFromPrimaryKey(primaryKey: PrimaryKeyType): "bigint" | "uuid" | "integer";
51
+ static foreignKeyTypeFromPrimaryKey(primaryKey: PrimaryKeyType): "bigint" | "integer" | "uuid";
52
52
  /**
53
53
  * @internal
54
54
  *
55
55
  * used to return the computed primary key type based
56
56
  * on the primaryKeyType set in the DreamApp class.
57
57
  */
58
- static primaryKeyType(): "bigint" | "bigserial" | "uuid" | "integer";
58
+ static primaryKeyType(): PrimaryKeyType;
59
59
  /**
60
60
  * destroys a dream, possibly implementing soft delete if reallyDestroy is false
61
61
  * and the record being deleted implements soft delete.
@@ -168,6 +168,32 @@ export default class KyselyQueryDriver<DreamInstance extends Dream> extends Quer
168
168
  * @returns the min value of the specified column for this Query
169
169
  */
170
170
  min(columnName: string): Promise<any>;
171
+ /**
172
+ * Retrieves the sum value of the specified column
173
+ * for this Query
174
+ *
175
+ * ```ts
176
+ * await Game.query().sum('score')
177
+ * // 1
178
+ * ```
179
+ *
180
+ * @param columnName - a column name on the model
181
+ * @returns the sum of the values of the specified column for this Query
182
+ */
183
+ sum(columnName: string): Promise<any>;
184
+ /**
185
+ * Retrieves the average value of the specified column
186
+ * for this Query
187
+ *
188
+ * ```ts
189
+ * await Game.query().avg('score')
190
+ * // 1
191
+ * ```
192
+ *
193
+ * @param columnName - a column name on the model
194
+ * @returns the average of the values of the specified column for this Query
195
+ */
196
+ avg(columnName: string): Promise<any>;
171
197
  /**
172
198
  * Retrieves the number of records in the database
173
199
  *
@@ -1,2 +1,2 @@
1
- import { PrimaryKeyType } from '../../../../types/dream.js';
2
- export default function foreignKeyTypeFromPrimaryKey(primaryKey: PrimaryKeyType): "bigint" | "uuid" | "integer";
1
+ import { PrimaryKeyType } from '../../../../types/db.js';
2
+ export default function foreignKeyTypeFromPrimaryKey(primaryKey: PrimaryKeyType): "bigint" | "integer" | "uuid";
@@ -1,4 +1,4 @@
1
- export declare const primaryKeyTypes: readonly ["bigserial", "bigint", "uuid", "integer"];
1
+ export declare const primaryKeyTypes: readonly ["uuid7", "uuid4", "bigserial", "bigint", "integer"];
2
2
  export declare const TRIGRAM_OPERATORS: readonly ["%", "<%", "<<%"];
3
3
  declare class RequiredAttribute {
4
4
  constructor();
@@ -1,5 +1,5 @@
1
1
  export default class PackageManager {
2
- static get packageManager(): "yarn" | "npm" | "pnpm";
2
+ static get packageManager(): "pnpm" | "yarn" | "npm";
3
3
  static add(dependencyOrDependencies: string | string[], { dev }?: {
4
4
  dev?: boolean;
5
5
  }): string;
@@ -1,7 +1,6 @@
1
1
  import { CompiledQuery } from 'kysely';
2
2
  import { Context } from 'node:vm';
3
3
  import Dream from '../Dream.js';
4
- import { primaryKeyTypes } from '../dream/constants.js';
5
4
  import QueryDriverBase from '../dream/QueryDriver/Base.js';
6
5
  import { EncryptOptions } from '../encrypt/index.js';
7
6
  import autogeneratedFileDisclaimer from '../helpers/cli/autoGeneratedFileDisclaimer.js';
@@ -13,7 +12,7 @@ import expandStiClasses from '../helpers/sti/expandStiClasses.js';
13
12
  import inferSerializerFromDreamOrViewModel, { inferSerializersFromDreamClassOrViewModelClass } from '../serializer/helpers/inferSerializerFromDreamOrViewModel.js';
14
13
  import isDreamSerializer from '../serializer/helpers/isDreamSerializer.js';
15
14
  import serializerNameFromFullyQualifiedModelName from '../serializer/helpers/serializerNameFromFullyQualifiedModelName.js';
16
- import { DbConnectionType } from '../types/db.js';
15
+ import { DbConnectionType, PrimaryKeyType } from '../types/db.js';
17
16
  import { DreamModelSerializerType, SimpleObjectSerializerType } from '../types/serializer.js';
18
17
  export default class DreamApp {
19
18
  /**
@@ -116,7 +115,7 @@ export default class DreamApp {
116
115
  private _paginationPageSize;
117
116
  get paginationPageSize(): number;
118
117
  private _primaryKeyType;
119
- get primaryKeyType(): "bigint" | "bigserial" | "uuid" | "integer";
118
+ get primaryKeyType(): PrimaryKeyType;
120
119
  private _projectRoot;
121
120
  get projectRoot(): string;
122
121
  private _paths;
@@ -130,7 +129,7 @@ export default class DreamApp {
130
129
  private _plugins;
131
130
  get plugins(): ((app: DreamApp) => void | Promise<void>)[];
132
131
  private _packageManager;
133
- get packageManager(): "yarn" | "npm" | "pnpm";
132
+ get packageManager(): "pnpm" | "yarn" | "npm";
134
133
  private _importExtension;
135
134
  get importExtension(): ".js" | ".ts" | "none";
136
135
  /**
@@ -153,13 +152,13 @@ export default class DreamApp {
153
152
  get parallelDatabasesEnabled(): boolean;
154
153
  load<RT extends 'models' | 'serializers'>(resourceType: RT, resourcePath: string, importCb: (path: string) => Promise<any>): Promise<void>;
155
154
  plugin(cb: (app: DreamApp) => void | Promise<void>): void;
156
- set<ApplyOpt extends DreamAppSetOption>(applyOption: ApplyOpt, options: ApplyOpt extends 'bypassDeprecationChecks' ? boolean : ApplyOpt extends 'db' ? DreamDbCredentialOptions | string : ApplyOpt extends 'encryption' ? DreamAppEncryptionOptions : ApplyOpt extends 'primaryKeyType' ? (typeof primaryKeyTypes)[number] : ApplyOpt extends 'importExtension' ? GeneratorImportStyle : ApplyOpt extends 'logger' ? DreamLogger : ApplyOpt extends 'projectRoot' ? string : ApplyOpt extends 'inflections' ? () => void | Promise<void> : ApplyOpt extends 'packageManager' ? DreamAppAllowedPackageManagersEnum : ApplyOpt extends 'paths' ? DreamDirectoryPaths : ApplyOpt extends 'parallelTests' ? number : ApplyOpt extends 'unicodeNormalization' ? UnicodeNormalizationForm : ApplyOpt extends 'paginationPageSize' ? number : never, secondaryOptions?: ApplyOpt extends 'db' ? DreamDbCredentialOptions : never): void;
155
+ set<ApplyOpt extends DreamAppSetOption>(applyOption: ApplyOpt, options: ApplyOpt extends 'bypassDeprecationChecks' ? boolean : ApplyOpt extends 'db' ? DreamDbCredentialOptions | string : ApplyOpt extends 'encryption' ? DreamAppEncryptionOptions : ApplyOpt extends 'primaryKeyType' ? PrimaryKeyType : ApplyOpt extends 'importExtension' ? GeneratorImportStyle : ApplyOpt extends 'logger' ? DreamLogger : ApplyOpt extends 'projectRoot' ? string : ApplyOpt extends 'inflections' ? () => void | Promise<void> : ApplyOpt extends 'packageManager' ? DreamAppAllowedPackageManagersEnum : ApplyOpt extends 'paths' ? DreamDirectoryPaths : ApplyOpt extends 'parallelTests' ? number : ApplyOpt extends 'unicodeNormalization' ? UnicodeNormalizationForm : ApplyOpt extends 'paginationPageSize' ? number : never, secondaryOptions?: ApplyOpt extends 'db' ? DreamDbCredentialOptions : never): void;
157
156
  on<T extends DreamHookEventType>(hookEventType: T, cb: T extends 'db:log' ? (event: KyselyLogEvent) => void : T extends 'repl:start' ? (context: Context) => void | Promise<void> : never): void;
158
157
  }
159
158
  export type DreamHookEventType = 'db:log' | 'repl:start';
160
159
  export interface DreamAppOpts {
161
160
  projectRoot: string;
162
- primaryKeyType: (typeof primaryKeyTypes)[number];
161
+ primaryKeyType: PrimaryKeyType;
163
162
  db: DreamDbCredentialOptions;
164
163
  inflections?: () => void | Promise<void>;
165
164
  paths?: DreamDirectoryPaths;
@@ -219,7 +218,7 @@ export interface KyselyLogEvent {
219
218
  queryDurationMillis: number;
220
219
  error: unknown;
221
220
  }
222
- export declare const DreamAppAllowedPackageManagersEnumValues: readonly ["yarn", "npm", "pnpm"];
221
+ export declare const DreamAppAllowedPackageManagersEnumValues: readonly ["pnpm", "yarn", "npm"];
223
222
  export type DreamAppAllowedPackageManagersEnum = (typeof DreamAppAllowedPackageManagersEnumValues)[number];
224
223
  export declare const GeneratorImportStyles: readonly [".js", ".ts", "none"];
225
224
  export type GeneratorImportStyle = (typeof GeneratorImportStyles)[number];
@@ -1,4 +1,4 @@
1
- import { PrimaryKeyType } from '../../types/dream.js';
1
+ import { PrimaryKeyType } from '../../types/db.js';
2
2
  export default function generateMigrationContent({ connectionName, table, columnsWithTypes, primaryKeyType, createOrAlter, stiChildClassName, }?: {
3
3
  connectionName?: string;
4
4
  table?: string | undefined;
@@ -1,4 +1,4 @@
1
- import { PrimaryKeyType } from '../../types/dream.js';
1
+ import { PrimaryKeyType } from '../../types/db.js';
2
2
  export default function generateStiMigrationContent({ table, columnsWithTypes, primaryKeyType, stiChildClassName, }: {
3
3
  table?: string;
4
4
  columnsWithTypes?: string[];
@@ -3,6 +3,7 @@ export { CliFileWriter } from '../cli/CliFileWriter.js';
3
3
  export { default as DreamCLI } from '../cli/index.js';
4
4
  export { default as DreamImporter } from '../dream-app/helpers/DreamImporter.js';
5
5
  export { DreamAppAllowedPackageManagersEnumValues, type DreamAppAllowedPackageManagersEnum, } from '../dream-app/index.js';
6
+ export { primaryKeyTypes } from '../dream/constants.js';
6
7
  export { default as DreamLogos } from '../helpers/DreamLogos/DreamLogos.js';
7
8
  export { default as DreamSerializerBuilder } from '../serializer/builders/DreamSerializerBuilder.js';
8
9
  export { default as ObjectSerializerBuilder } from '../serializer/builders/ObjectSerializerBuilder.js';
@@ -7,7 +7,7 @@ export { type SerializerRendererOpts } from '../serializer/SerializerRenderer.js
7
7
  export { type BelongsToStatement } from '../types/associations/belongsTo.js';
8
8
  export { type HasManyStatement } from '../types/associations/hasMany.js';
9
9
  export { type HasOneStatement } from '../types/associations/hasOne.js';
10
- export { type DbConnectionType, type DbTypes } from '../types/db.js';
10
+ export { type DbConnectionType, type DbTypes, type PrimaryKeyType } from '../types/db.js';
11
11
  export { type StrictInterface } from '../types/utils.js';
12
12
  export { type DreamAssociationMetadata, type DreamAttributes, type DreamClassAssociationAndStatement, type DreamClassColumn, type DreamColumn, type DreamColumnNames, type DreamOrViewModelClassSerializerKey, type DreamOrViewModelSerializerKey, type DreamParamSafeAttributes, type DreamParamSafeColumnNames, type DreamSerializable, type DreamSerializableArray, type DreamSerializerKey, type DreamSerializers, type DreamVirtualColumns, type UpdateableAssociationProperties, type UpdateableProperties, type ViewModel, type ViewModelClass, } from '../types/dream.js';
13
13
  export { type DreamModelSerializerType, type InternalAnyTypedSerializerRendersMany, type InternalAnyTypedSerializerRendersOne, type SerializerCasing, type SimpleObjectSerializerType, } from '../types/serializer.js';
@@ -6,7 +6,7 @@ export interface BelongsToStatement<BaseInstance extends Dream, DB, Schema, Tabl
6
6
  globalAssociationNameOrNames: string[];
7
7
  type: 'BelongsTo';
8
8
  as: string;
9
- primaryKey: (associationInstance?: Dream | undefined, opts?: {
9
+ primaryKey: (associationInstance?: Dream, opts?: {
10
10
  associatedClassOverride?: typeof Dream | undefined;
11
11
  }) => keyof DB[TableName] & string;
12
12
  primaryKeyValue: (associationInstance: Dream | null) => any;
@@ -20,7 +20,7 @@ export interface BelongsToStatement<
20
20
  type: 'BelongsTo'
21
21
  as: string
22
22
  primaryKey: (
23
- associationInstance?: Dream | undefined,
23
+ associationInstance?: Dream,
24
24
  opts?: { associatedClassOverride?: typeof Dream | undefined }
25
25
  ) => keyof DB[TableName] & string
26
26
  primaryKeyValue: (associationInstance: Dream | null) => any
@@ -1,4 +1,5 @@
1
1
  import { postgresDatatypes } from '../db/dataTypes.js';
2
+ import { primaryKeyTypes } from '../dream/constants.js';
2
3
  export type DbConnectionType = 'primary' | 'replica';
3
4
  export type AssociationTableNames<DB, Schema> = keyof DB & keyof Schema extends never ? unknown : keyof DB & keyof Schema & string;
4
5
  export type Tables<DB> = keyof DB;
@@ -6,4 +7,5 @@ export type TableInterfaces<DB> = valueof<DB>;
6
7
  type valueof<T> = T[keyof T];
7
8
  export type NonArrayDbTypes = (typeof postgresDatatypes)[number];
8
9
  export type DbTypes = NonArrayDbTypes | `${NonArrayDbTypes}[]`;
10
+ export type PrimaryKeyType = (typeof primaryKeyTypes)[number] | 'uuid';
9
11
  export {};
@@ -1,4 +1,5 @@
1
1
  import { postgresDatatypes } from '../db/dataTypes.js'
2
+ import { primaryKeyTypes } from '../dream/constants.js'
2
3
 
3
4
  export type DbConnectionType = 'primary' | 'replica'
4
5
 
@@ -12,3 +13,4 @@ type valueof<T> = T[keyof T]
12
13
 
13
14
  export type NonArrayDbTypes = (typeof postgresDatatypes)[number]
14
15
  export type DbTypes = NonArrayDbTypes | `${NonArrayDbTypes}[]`
16
+ export type PrimaryKeyType = (typeof primaryKeyTypes)[number] | 'uuid'
@@ -1,7 +1,7 @@
1
1
  import { ColumnType, Updateable } from 'kysely';
2
2
  import { STI_SCOPE_NAME } from '../decorators/class/STI.js';
3
3
  import Dream from '../Dream.js';
4
- import { primaryKeyTypes, TRIGRAM_OPERATORS } from '../dream/constants.js';
4
+ import { TRIGRAM_OPERATORS } from '../dream/constants.js';
5
5
  import CalendarDate from '../helpers/CalendarDate.js';
6
6
  import { DateTime } from '../helpers/DateTime.js';
7
7
  import OpsStatement from '../ops/ops-statement.js';
@@ -11,7 +11,6 @@ import { FindEachOpts } from './query.js';
11
11
  import { DreamModelSerializerType, SimpleObjectSerializerType } from './serializer.js';
12
12
  import { FilterInterface, Inc, RejectInterface } from './utils.js';
13
13
  import { AliasedSchemaAssociation } from './variadic.js';
14
- export type PrimaryKeyType = (typeof primaryKeyTypes)[number];
15
14
  export type DreamPrimaryKeyType<I extends Dream, Schema extends I['schema'] = I['schema'], TableName extends keyof Schema = I['table'] & keyof Schema, PrimaryKey extends I['primaryKey' & keyof I] extends undefined ? 'id' : I['primaryKey' & keyof I] = I['primaryKey' & keyof I] extends undefined ? 'id' : I['primaryKey' & keyof I]> = Schema[TableName]['columns'][PrimaryKey & keyof Schema[TableName]['columns']]['coercedType'];
16
15
  export type Timestamp = ColumnType<DateTime | CalendarDate>;
17
16
  export type MAX_VARIADIC_DEPTH = 25;
@@ -1,7 +1,7 @@
1
1
  import { ColumnType, Updateable } from 'kysely'
2
2
  import { STI_SCOPE_NAME } from '../decorators/class/STI.js'
3
3
  import Dream from '../Dream.js'
4
- import { primaryKeyTypes, TRIGRAM_OPERATORS } from '../dream/constants.js'
4
+ import { TRIGRAM_OPERATORS } from '../dream/constants.js'
5
5
  import CalendarDate from '../helpers/CalendarDate.js'
6
6
  import { DateTime } from '../helpers/DateTime.js'
7
7
  import OpsStatement from '../ops/ops-statement.js'
@@ -17,8 +17,6 @@ import { DreamModelSerializerType, SimpleObjectSerializerType } from './serializ
17
17
  import { FilterInterface, Inc, RejectInterface } from './utils.js'
18
18
  import { AliasedSchemaAssociation } from './variadic.js'
19
19
 
20
- export type PrimaryKeyType = (typeof primaryKeyTypes)[number]
21
-
22
20
  export type DreamPrimaryKeyType<
23
21
  I extends Dream,
24
22
  Schema extends I['schema'] = I['schema'],
@@ -13,13 +13,13 @@ import {
13
13
  export type SerializerCasing = 'camel' | 'snake'
14
14
  export type DreamsOrSerializersOrViewModels = DreamSerializable | DreamSerializableArray
15
15
 
16
- export interface InternalAnyTypedSerializerAttribute<> {
16
+ export interface InternalAnyTypedSerializerAttribute {
17
17
  type: 'attribute'
18
18
  name: string
19
19
  options: Partial<NonAutomaticSerializerAttributeOptionsWithPossibleDecimalRenderOption>
20
20
  }
21
21
 
22
- export interface InternalAnyTypedSerializerDelegatedAttribute<> {
22
+ export interface InternalAnyTypedSerializerDelegatedAttribute {
23
23
  type: 'delegatedAttribute'
24
24
  targetName: string
25
25
  name: string
@@ -1 +1 @@
1
- window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE62b23LbthaG30XX6W6T3WPuZMlONbEtV1Kdi05mD0QuS2hAgAUgJ0qn774HPIggCCyAdO80xL++HyRx4gL0x98zDV/07O0s389ezUqij7O3s0LkJwbq23z/n6Mu2OzV7BPl+eztm1ez7EhZLoHP3v5xCV1KIMUdPUiiqeC/AitBqo6WMaJUTfMq+x6v3/z8z6sL+v1ZATv/dgJ5Xkr6DNKLHagw5INQ+iBBxaAeHYa1ZFdEgRfpaDBcxoSCOWPL/UJwDpl5XtYzfTrx+pLBerV9+I/fW+zcvIUU8FCIUE9cn0vIl/sA7FKOMJ4JoznRsBDsVPAAqC9KoO3InkEEVmkGrI8WDaQUdrNuO0l9PamjLI6QfVoIrrQklOtHKljVEYaNpYGGArCWUz+W9TPIJyY+h9E9GQqUQDSs5Q3l+dX5hlAG+U7UV+c8N5fDLvFYzHpJNFnxTBQl0XTP4APVR3NtTxTcUGBh42hkzHZ3LpsWZn7dUVUQnR1RP38IZvSOiT1h96SAe6G3oIN4V4hBV7xq1AvCgOdELon2jEYN16PF0HdUKcoPW5CUMPoVpFrCE+UUbcRYEGZ2L/itIDnkc6VERvGe4hPjcH1/YizeBV0hBt1AJmR+L/SNOCGdoi/DgI/16EQFvzahQaKjw5DloZKYFuobEhugpUIHRcpz+DIcE6vLaUMi2kprTmrrXJrnSrT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V9zIXh1KQx2pSi2eW4rTvW6dE4KDclDdQp8XeoUqpFhuGueyXOZUM2+EEOaTInkhM352YzNub0q4jlIdUf4GXFKin9RBdYcXuK/5u5nbM/e1YOMvCt/ALpXQwowAYOpvwZeiqODhHVIrX+0wca5qjjVu/hpYUlrnLr9dodS7kCTnGgSgAbUaS5aS7o/6WCN+6Ik5sJMHVaF5jz3DF8DFyws3dc9Bui38Z0DDFGjwLEscyQLe9yWKol6Kw638AyDbKuFbCWpPE9iuE9LyAbXB3dFDqzr40g/C6iTXNbykcLnKrp6vR3iPQy2liw/NG6s8wTT8X4PRJLCnJxI6rge9TiXtAbrkyf52HkMhG/LRnO9O7ABeNIerLPYxl/2+DdsnXlM4qY96Ucq9Ymw+gVh4L4wxm4WRnN2EJLq42BF31s+XVQx6q+kWuZEJg1XlUBdc4hDbVGUeS6PwMOLka48RnogKiPIsqYrj5E25oQo5YcHCRlVvcNGNnAgi3G7JrcgypMsc9dztSpKpUXJwP28DM8TYX3UiZNPQJ9o6Al35VGSljTTq3YpG8D1RTHm76X5S0E1CHVLIN9xLtsjEpTumW6UTu8OGIffZl8TJbbzZgDWFidzqkk/Aqs0MeKHI8hu1LgR0jkPbJP92mkOyA0gATGv3Wb1bjO/+9/64Xoz3603W1+epHYZSJH8ZylpQeT5PZyDCc8a6gjRFMtJU+ZJsVSXk1IszeQ0zHzViKYYS3RtCD94DqLX8VUhFp0136u+o6o1olUgJ14zUlJNYphWg4GY4LAEKENHeBuWLcNw5s809mmKAagWIIiDFKfy6hxGNAIEcWxn4TDkIkEwVe5CgXO63iXZKgymrotSI7fVCBAEN2crzfv8ndNM5MjduUoEWrbrjDDtIsEwILPeImsAqQUIQva7lQuoit2tjz6g/4+aAWD4T5peuCLm/0Zfwd0adDl9HQasFxjIO28VGERI5Kma0kgw1pXq8gigOWBy7n34+EiWMBFZpdTToJUUwZ54yphoq1AY/QuD0L8GwR//+fh/b6EHfik9AAA="
1
+ window.navigationData = "data:application/octet-stream;base64,H4s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