@rvoh/dream 0.42.3 → 0.43.0-beta.10

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 (369) hide show
  1. package/dist/cjs/src/Dream.js +28 -36
  2. package/dist/cjs/src/bin/index.js +6 -1
  3. package/dist/cjs/src/cli/index.js +1 -0
  4. package/dist/cjs/src/decorators/field/validation/Validates.js +5 -2
  5. package/dist/cjs/src/dream/Query.js +34 -27
  6. package/dist/cjs/src/dream/constants.js +7 -9
  7. package/dist/cjs/src/dream/internal/checkSingleValidation.js +5 -2
  8. package/dist/cjs/src/dream/internal/findOrCreateBy.js +1 -1
  9. package/dist/cjs/src/dream/internal/orderByDirection.js +5 -2
  10. package/dist/cjs/src/dream/internal/similarity/SimilarityBuilder.js +3 -3
  11. package/dist/cjs/src/dream/internal/updateOrCreateBy.js +1 -1
  12. package/dist/cjs/src/dream-app/helpers/DreamImporter.js +2 -2
  13. package/dist/cjs/src/dream-app/helpers/globalSerializerKeyFromPath.js +2 -2
  14. package/dist/cjs/src/dream-app/helpers/importers/importModels.js +1 -1
  15. package/dist/cjs/src/dream-app/helpers/importers/importSerializers.js +8 -26
  16. package/dist/cjs/src/dream-app/helpers/serializerOpenapiNameFromPath.js +18 -0
  17. package/dist/cjs/src/dream-app/index.js +5 -2
  18. package/dist/cjs/src/encrypt/index.js +20 -8
  19. package/dist/cjs/src/errors/serializers/DelegationTargetDoesNotExist.js +13 -0
  20. package/dist/cjs/src/errors/serializers/MissingSerializersDefinition.js +26 -0
  21. package/dist/cjs/src/errors/serializers/MissingSerializersDefinitionForKey.js +30 -0
  22. package/dist/cjs/src/errors/serializers/NoGlobalSerializerForSpecifiedKey.js +21 -0
  23. package/dist/cjs/src/errors/serializers/NonDreamSerializerDerivedFromGlobalSerializerForSpecifiedKey.js +26 -0
  24. package/dist/cjs/src/errors/serializers/RendersManyMustReceiveArray.js +18 -0
  25. package/dist/cjs/src/helpers/allNestedObjectKeys.js +2 -2
  26. package/dist/cjs/src/helpers/cli/generateDream.js +7 -2
  27. package/dist/cjs/src/helpers/cli/generateDreamContent.js +14 -7
  28. package/dist/cjs/src/helpers/cli/generateFactoryContent.js +1 -1
  29. package/dist/cjs/src/helpers/cli/generateSerializer.js +7 -2
  30. package/dist/cjs/src/helpers/cli/generateSerializerContent.js +43 -66
  31. package/dist/cjs/src/helpers/cloneDeepSafe.js +15 -14
  32. package/dist/cjs/src/helpers/compact.js +2 -2
  33. package/dist/cjs/src/helpers/db/primaryKeyType.js +5 -2
  34. package/dist/cjs/src/helpers/groupBy.js +11 -0
  35. package/dist/cjs/src/helpers/{typechecks.js → isObject.js} +2 -7
  36. package/dist/cjs/src/helpers/normalizeUnicode.js +40 -0
  37. package/dist/cjs/src/helpers/sortObjectByKey.js +11 -0
  38. package/dist/cjs/src/helpers/sortObjectByValue.js +16 -0
  39. package/dist/cjs/src/helpers/sqlAttributes.js +4 -5
  40. package/dist/cjs/src/helpers/standardizeFullyQualifiedModelName.js +2 -2
  41. package/dist/cjs/src/helpers/sti/expandStiClasses.js +17 -0
  42. package/dist/cjs/src/helpers/stringCasing.js +4 -4
  43. package/dist/cjs/src/index.js +29 -15
  44. package/dist/cjs/src/serializer/DreamSerializer.js +7 -0
  45. package/dist/cjs/src/serializer/ObjectSerializer.js +7 -0
  46. package/dist/cjs/src/serializer/SerializerRenderer.js +218 -0
  47. package/dist/cjs/src/serializer/builders/DreamSerializerBuilder.js +71 -0
  48. package/dist/cjs/src/serializer/builders/ObjectSerializerBuilder.js +69 -0
  49. package/dist/cjs/src/serializer/helpers/inferSerializerFromDreamOrViewModel.js +42 -0
  50. package/dist/cjs/src/serializer/helpers/isDreamSerializer.js +19 -0
  51. package/dist/cjs/src/{helpers/serializerNameFromFullyQualifiedModelName.js → serializer/helpers/serializerGlobalNameFromFullyQualifiedModelName.js} +3 -3
  52. package/dist/cjs/src/serializer/helpers/serializerNameFromFullyQualifiedModelName.js +12 -0
  53. package/dist/cjs/src/serializer/index.js +0 -282
  54. package/dist/cjs/src/types/serializer.js +2 -0
  55. package/dist/esm/src/Dream.js +28 -36
  56. package/dist/esm/src/bin/index.js +6 -1
  57. package/dist/esm/src/cli/index.js +1 -0
  58. package/dist/esm/src/decorators/field/validation/Validates.js +5 -2
  59. package/dist/esm/src/dream/Query.js +27 -20
  60. package/dist/esm/src/dream/constants.js +7 -9
  61. package/dist/esm/src/dream/internal/checkSingleValidation.js +5 -2
  62. package/dist/esm/src/dream/internal/findOrCreateBy.js +1 -1
  63. package/dist/esm/src/dream/internal/orderByDirection.js +5 -2
  64. package/dist/esm/src/dream/internal/similarity/SimilarityBuilder.js +1 -1
  65. package/dist/esm/src/dream/internal/updateOrCreateBy.js +1 -1
  66. package/dist/esm/src/dream-app/helpers/DreamImporter.js +2 -2
  67. package/dist/esm/src/dream-app/helpers/globalSerializerKeyFromPath.js +1 -1
  68. package/dist/esm/src/dream-app/helpers/importers/importModels.js +1 -1
  69. package/dist/esm/src/dream-app/helpers/importers/importSerializers.js +8 -26
  70. package/dist/esm/src/dream-app/helpers/serializerOpenapiNameFromPath.js +15 -0
  71. package/dist/esm/src/dream-app/index.js +5 -2
  72. package/dist/esm/src/encrypt/index.js +20 -8
  73. package/dist/esm/src/errors/serializers/DelegationTargetDoesNotExist.js +10 -0
  74. package/dist/esm/src/errors/serializers/MissingSerializersDefinition.js +23 -0
  75. package/dist/esm/src/errors/serializers/MissingSerializersDefinitionForKey.js +27 -0
  76. package/dist/esm/src/errors/serializers/NoGlobalSerializerForSpecifiedKey.js +18 -0
  77. package/dist/esm/src/errors/serializers/NonDreamSerializerDerivedFromGlobalSerializerForSpecifiedKey.js +23 -0
  78. package/dist/esm/src/errors/serializers/RendersManyMustReceiveArray.js +15 -0
  79. package/dist/esm/src/helpers/allNestedObjectKeys.js +1 -1
  80. package/dist/esm/src/helpers/cli/generateDream.js +7 -2
  81. package/dist/esm/src/helpers/cli/generateDreamContent.js +14 -7
  82. package/dist/esm/src/helpers/cli/generateFactoryContent.js +1 -1
  83. package/dist/esm/src/helpers/cli/generateSerializer.js +7 -2
  84. package/dist/esm/src/helpers/cli/generateSerializerContent.js +43 -67
  85. package/dist/esm/src/helpers/cloneDeepSafe.js +14 -13
  86. package/dist/esm/src/helpers/compact.js +2 -2
  87. package/dist/esm/src/helpers/db/primaryKeyType.js +5 -2
  88. package/dist/esm/src/helpers/groupBy.js +8 -0
  89. package/dist/esm/src/helpers/isObject.js +8 -0
  90. package/dist/esm/src/helpers/normalizeUnicode.js +37 -0
  91. package/dist/esm/src/helpers/sortObjectByKey.js +8 -0
  92. package/dist/esm/src/helpers/sortObjectByValue.js +13 -0
  93. package/dist/esm/src/helpers/sqlAttributes.js +4 -5
  94. package/dist/esm/src/helpers/standardizeFullyQualifiedModelName.js +1 -1
  95. package/dist/esm/src/helpers/sti/expandStiClasses.js +14 -0
  96. package/dist/esm/src/helpers/stringCasing.js +3 -3
  97. package/dist/esm/src/index.js +13 -6
  98. package/dist/esm/src/serializer/DreamSerializer.js +4 -0
  99. package/dist/esm/src/serializer/ObjectSerializer.js +4 -0
  100. package/dist/esm/src/serializer/SerializerRenderer.js +215 -0
  101. package/dist/esm/src/serializer/builders/DreamSerializerBuilder.js +68 -0
  102. package/dist/esm/src/serializer/builders/ObjectSerializerBuilder.js +66 -0
  103. package/dist/esm/src/serializer/helpers/inferSerializerFromDreamOrViewModel.js +37 -0
  104. package/dist/esm/src/serializer/helpers/isDreamSerializer.js +16 -0
  105. package/dist/esm/src/{helpers/serializerNameFromFullyQualifiedModelName.js → serializer/helpers/serializerGlobalNameFromFullyQualifiedModelName.js} +2 -2
  106. package/dist/esm/src/serializer/helpers/serializerNameFromFullyQualifiedModelName.js +9 -0
  107. package/dist/esm/src/serializer/index.js +1 -280
  108. package/dist/esm/src/types/serializer.js +1 -0
  109. package/dist/types/src/Dream.d.ts +19 -20
  110. package/dist/types/src/bin/index.d.ts +1 -0
  111. package/dist/types/src/decorators/Decorators.d.ts +2 -2
  112. package/dist/types/src/decorators/field-or-getter/Virtual.d.ts +3 -3
  113. package/dist/types/src/dream/constants.d.ts +2 -2
  114. package/dist/types/src/dream-app/helpers/DreamImporter.d.ts +2 -2
  115. package/dist/types/src/dream-app/helpers/globalSerializerKeyFromPath.d.ts +1 -1
  116. package/dist/types/src/dream-app/helpers/importers/importSerializers.d.ts +5 -5
  117. package/dist/types/src/dream-app/helpers/serializerOpenapiNameFromPath.d.ts +1 -0
  118. package/dist/types/src/dream-app/index.d.ts +2 -2
  119. package/dist/types/src/errors/serializers/DelegationTargetDoesNotExist.d.ts +5 -0
  120. package/dist/types/src/errors/serializers/FailedToRenderThroughAssociationForSerializer.d.ts +2 -2
  121. package/dist/types/src/errors/serializers/MissingSerializersDefinition.d.ts +7 -0
  122. package/dist/types/src/errors/serializers/MissingSerializersDefinitionForKey.d.ts +8 -0
  123. package/dist/types/src/errors/serializers/NoGlobalSerializerForSpecifiedKey.d.ts +9 -0
  124. package/dist/types/src/errors/serializers/NonDreamSerializerDerivedFromGlobalSerializerForSpecifiedKey.d.ts +10 -0
  125. package/dist/types/src/errors/serializers/RendersManyMustReceiveArray.d.ts +7 -0
  126. package/dist/types/src/helpers/cli/generateDream.d.ts +1 -0
  127. package/dist/types/src/helpers/cli/generateSerializer.d.ts +2 -1
  128. package/dist/types/src/helpers/cli/generateSerializerContent.d.ts +3 -1
  129. package/dist/types/src/helpers/cloneDeepSafe.d.ts +9 -10
  130. package/dist/types/src/helpers/groupBy.d.ts +1 -0
  131. package/dist/types/src/helpers/isObject.d.ts +1 -0
  132. package/dist/types/src/helpers/normalizeUnicode.d.ts +31 -0
  133. package/dist/types/src/helpers/sortObjectByKey.d.ts +1 -0
  134. package/dist/types/src/helpers/sortObjectByValue.d.ts +3 -0
  135. package/dist/types/src/helpers/standardizeFullyQualifiedModelName.d.ts +1 -1
  136. package/dist/types/src/helpers/sti/expandStiClasses.d.ts +3 -0
  137. package/dist/types/src/index.d.ts +21 -10
  138. package/dist/types/src/serializer/DreamSerializer.d.ts +3 -0
  139. package/dist/types/src/serializer/ObjectSerializer.d.ts +2 -0
  140. package/dist/types/src/serializer/SerializerRenderer.d.ts +14 -0
  141. package/dist/types/src/serializer/builders/DreamSerializerBuilder.d.ts +50 -0
  142. package/dist/types/src/serializer/builders/ObjectSerializerBuilder.d.ts +50 -0
  143. package/dist/types/src/serializer/helpers/inferSerializerFromDreamOrViewModel.d.ts +6 -0
  144. package/dist/types/src/serializer/helpers/isDreamSerializer.d.ts +1 -0
  145. package/dist/types/src/serializer/helpers/serializerGlobalNameFromFullyQualifiedModelName.d.ts +1 -0
  146. package/dist/types/src/serializer/helpers/serializerNameFromFullyQualifiedModelName.d.ts +1 -0
  147. package/dist/types/src/serializer/index.d.ts +1 -54
  148. package/dist/types/src/types/dream.d.ts +3 -8
  149. package/dist/types/src/types/dream.ts +16 -23
  150. package/dist/types/src/types/openapi.d.ts +11 -4
  151. package/dist/types/src/types/openapi.ts +19 -4
  152. package/dist/types/src/types/serializer.d.ts +62 -0
  153. package/dist/types/src/types/serializer.ts +103 -0
  154. package/dist/types/src/types/utils.d.ts +6 -0
  155. package/dist/types/src/types/utils.ts +8 -0
  156. package/docs/assets/navigation.js +1 -1
  157. package/docs/assets/search.js +1 -1
  158. package/docs/classes/Benchmark.html +2 -2
  159. package/docs/classes/CalendarDate.html +2 -2
  160. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
  161. package/docs/classes/Decorators.html +20 -20
  162. package/docs/classes/Dream.html +214 -213
  163. package/docs/classes/DreamApp.html +4 -4
  164. package/docs/classes/DreamBin.html +2 -2
  165. package/docs/classes/DreamCLI.html +4 -4
  166. package/docs/classes/DreamImporter.html +2 -2
  167. package/docs/classes/DreamLogos.html +2 -2
  168. package/docs/classes/DreamMigrationHelpers.html +7 -7
  169. package/docs/classes/DreamSerializerBuilder.html +14 -0
  170. package/docs/classes/DreamTransaction.html +2 -2
  171. package/docs/classes/Encrypt.html +2 -2
  172. package/docs/classes/Env.html +2 -2
  173. package/docs/classes/GlobalNameNotSet.html +3 -3
  174. package/docs/classes/NonLoadedAssociation.html +3 -3
  175. package/docs/classes/ObjectSerializerBuilder.html +13 -0
  176. package/docs/classes/Query.html +51 -51
  177. package/docs/classes/Range.html +2 -2
  178. package/docs/classes/RecordNotFound.html +3 -3
  179. package/docs/classes/ValidationError.html +3 -3
  180. package/docs/functions/DreamSerializer.html +1 -0
  181. package/docs/functions/ObjectSerializer.html +1 -0
  182. package/docs/functions/ReplicaSafe.html +1 -1
  183. package/docs/functions/STI.html +1 -1
  184. package/docs/functions/SoftDelete.html +1 -1
  185. package/docs/functions/camelize.html +1 -1
  186. package/docs/functions/capitalize.html +1 -1
  187. package/docs/functions/cloneDeepSafe.html +9 -0
  188. package/docs/functions/closeAllDbConnections.html +1 -1
  189. package/docs/functions/compact.html +1 -1
  190. package/docs/functions/dreamDbConnections.html +1 -1
  191. package/docs/functions/dreamPath.html +1 -1
  192. package/docs/functions/expandStiClasses.html +1 -0
  193. package/docs/functions/generateDream.html +1 -1
  194. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  195. package/docs/functions/groupBy.html +1 -0
  196. package/docs/functions/hyphenize.html +1 -1
  197. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  198. package/docs/functions/inferSerializersFromDreamClassOrViewModelClass.html +1 -0
  199. package/docs/functions/intersection.html +1 -1
  200. package/docs/functions/isDreamSerializer.html +1 -0
  201. package/docs/functions/isEmpty.html +1 -1
  202. package/docs/functions/loadRepl.html +1 -1
  203. package/docs/functions/lookupClassByGlobalName.html +1 -1
  204. package/docs/functions/normalizeUnicode.html +20 -0
  205. package/docs/functions/pascalize.html +1 -1
  206. package/docs/functions/pgErrorType.html +1 -1
  207. package/docs/functions/range-1.html +1 -1
  208. package/docs/functions/relativeDreamPath.html +1 -1
  209. package/docs/functions/round.html +1 -1
  210. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  211. package/docs/functions/sharedPathPrefix.html +1 -1
  212. package/docs/functions/snakeify.html +1 -1
  213. package/docs/functions/sort.html +1 -1
  214. package/docs/functions/sortBy.html +1 -1
  215. package/docs/functions/sortObjectByKey.html +1 -0
  216. package/docs/functions/sortObjectByValue.html +1 -0
  217. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  218. package/docs/functions/uncapitalize.html +1 -1
  219. package/docs/functions/uniq.html +1 -1
  220. package/docs/functions/untypedDb.html +1 -1
  221. package/docs/functions/validateColumn.html +1 -1
  222. package/docs/functions/validateTable.html +1 -1
  223. package/docs/interfaces/BelongsToStatement.html +14 -0
  224. package/docs/interfaces/DecoratorContext.html +2 -2
  225. package/docs/interfaces/DreamAppInitOptions.html +2 -2
  226. package/docs/interfaces/DreamAppOpts.html +2 -2
  227. package/docs/interfaces/EncryptOptions.html +2 -2
  228. package/docs/interfaces/InternalAnyTypedSerializerRendersMany.html +4 -0
  229. package/docs/interfaces/InternalAnyTypedSerializerRendersOne.html +4 -0
  230. package/docs/interfaces/OpenapiDescription.html +2 -0
  231. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  232. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  233. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  234. package/docs/interfaces/SerializerRendererOpts.html +2 -0
  235. package/docs/modules.html +25 -10
  236. package/docs/types/Camelized.html +1 -1
  237. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  238. package/docs/types/DateTime.html +1 -1
  239. package/docs/types/DbConnectionType.html +1 -1
  240. package/docs/types/DbTypes.html +1 -0
  241. package/docs/types/DreamAssociationMetadata.html +1 -1
  242. package/docs/types/DreamAttributes.html +1 -1
  243. package/docs/types/DreamClassColumn.html +1 -1
  244. package/docs/types/DreamColumn.html +1 -1
  245. package/docs/types/DreamColumnNames.html +1 -1
  246. package/docs/types/DreamLogLevel.html +1 -1
  247. package/docs/types/DreamLogger.html +1 -1
  248. package/docs/types/DreamModelSerializerType.html +1 -0
  249. package/docs/types/DreamOrViewModelClassSerializerKey.html +1 -1
  250. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  251. package/docs/types/DreamParamSafeAttributes.html +1 -1
  252. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  253. package/docs/types/DreamSerializable.html +1 -1
  254. package/docs/types/DreamSerializableArray.html +1 -1
  255. package/docs/types/DreamSerializerKey.html +1 -1
  256. package/docs/types/DreamSerializers.html +1 -1
  257. package/docs/types/DreamTableSchema.html +1 -1
  258. package/docs/types/DreamVirtualColumns.html +1 -1
  259. package/docs/types/EncryptAlgorithm.html +1 -1
  260. package/docs/types/HasManyStatement.html +1 -0
  261. package/docs/types/HasOneStatement.html +1 -0
  262. package/docs/types/Hyphenized.html +1 -1
  263. package/docs/types/IdType.html +1 -1
  264. package/docs/types/OpenapiAllTypes.html +1 -1
  265. package/docs/types/OpenapiFormats.html +1 -1
  266. package/docs/types/OpenapiNumberFormats.html +1 -1
  267. package/docs/types/OpenapiPrimitiveBaseTypes.html +1 -0
  268. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  269. package/docs/types/OpenapiSchemaArray.html +1 -1
  270. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  271. package/docs/types/OpenapiSchemaBase.html +1 -1
  272. package/docs/types/OpenapiSchemaBody.html +1 -1
  273. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  274. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  275. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  276. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  277. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  278. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  279. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  280. package/docs/types/OpenapiSchemaInteger.html +1 -1
  281. package/docs/types/OpenapiSchemaNull.html +1 -1
  282. package/docs/types/OpenapiSchemaNumber.html +1 -1
  283. package/docs/types/OpenapiSchemaObject.html +1 -1
  284. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  285. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  286. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  287. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  288. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  289. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  290. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  291. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  292. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  293. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  294. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  295. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  296. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  297. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  298. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  299. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  300. package/docs/types/OpenapiSchemaString.html +1 -1
  301. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  302. package/docs/types/OpenapiShorthandPrimitiveBaseTypes.html +1 -0
  303. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  304. package/docs/types/OpenapiTypeField.html +1 -1
  305. package/docs/types/Pascalized.html +1 -1
  306. package/docs/types/PrimaryKeyType.html +1 -1
  307. package/docs/types/RoundingPrecision.html +1 -1
  308. package/docs/types/SerializerCasing.html +1 -0
  309. package/docs/types/SimpleObjectSerializerType.html +1 -0
  310. package/docs/types/Snakeified.html +1 -1
  311. package/docs/types/Timestamp.html +1 -1
  312. package/docs/types/UpdateableAssociationProperties.html +1 -1
  313. package/docs/types/UpdateableProperties.html +1 -1
  314. package/docs/types/ValidationType.html +1 -1
  315. package/docs/types/ViewModel.html +1 -1
  316. package/docs/types/ViewModelClass.html +1 -1
  317. package/docs/types/WhereStatementForDream.html +1 -1
  318. package/docs/types/WhereStatementForDreamClass.html +1 -1
  319. package/docs/variables/DateTime-1.html +1 -1
  320. package/docs/variables/DreamConst.html +1 -1
  321. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  322. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  323. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  324. package/docs/variables/ops.html +1 -1
  325. package/docs/variables/primaryKeyTypes.html +1 -1
  326. package/package.json +3 -4
  327. package/dist/cjs/src/errors/MissingSerializersDefinition.js +0 -26
  328. package/dist/cjs/src/helpers/inferSerializerFromDreamOrViewModel.js +0 -16
  329. package/dist/cjs/src/helpers/normalizeString.js +0 -11
  330. package/dist/cjs/src/serializer/decorators/associations/RendersMany.js +0 -84
  331. package/dist/cjs/src/serializer/decorators/associations/RendersOne.js +0 -87
  332. package/dist/cjs/src/serializer/decorators/associations/shared.js +0 -10
  333. package/dist/cjs/src/serializer/decorators/attribute.js +0 -167
  334. package/dist/cjs/src/serializer/decorators/helpers/dreamAttributeOpenapiShape.js +0 -74
  335. package/dist/cjs/src/serializer/decorators/helpers/hasSerializersGetter.js +0 -11
  336. package/dist/cjs/src/serializer/decorators/helpers/maybeSerializableToDreamSerializerCallbackFunction.js +0 -20
  337. package/dist/esm/src/errors/MissingSerializersDefinition.js +0 -23
  338. package/dist/esm/src/helpers/inferSerializerFromDreamOrViewModel.js +0 -12
  339. package/dist/esm/src/helpers/normalizeString.js +0 -8
  340. package/dist/esm/src/helpers/typechecks.js +0 -12
  341. package/dist/esm/src/serializer/decorators/associations/RendersMany.js +0 -81
  342. package/dist/esm/src/serializer/decorators/associations/RendersOne.js +0 -84
  343. package/dist/esm/src/serializer/decorators/associations/shared.js +0 -7
  344. package/dist/esm/src/serializer/decorators/attribute.js +0 -164
  345. package/dist/esm/src/serializer/decorators/helpers/dreamAttributeOpenapiShape.js +0 -69
  346. package/dist/esm/src/serializer/decorators/helpers/hasSerializersGetter.js +0 -8
  347. package/dist/esm/src/serializer/decorators/helpers/maybeSerializableToDreamSerializerCallbackFunction.js +0 -17
  348. package/dist/types/src/errors/MissingSerializersDefinition.d.ts +0 -6
  349. package/dist/types/src/helpers/inferSerializerFromDreamOrViewModel.d.ts +0 -4
  350. package/dist/types/src/helpers/normalizeString.d.ts +0 -1
  351. package/dist/types/src/helpers/serializerNameFromFullyQualifiedModelName.d.ts +0 -1
  352. package/dist/types/src/helpers/typechecks.d.ts +0 -2
  353. package/dist/types/src/serializer/decorators/associations/RendersMany.d.ts +0 -42
  354. package/dist/types/src/serializer/decorators/associations/RendersOne.d.ts +0 -46
  355. package/dist/types/src/serializer/decorators/associations/shared.d.ts +0 -24
  356. package/dist/types/src/serializer/decorators/attribute.d.ts +0 -28
  357. package/dist/types/src/serializer/decorators/helpers/dreamAttributeOpenapiShape.d.ts +0 -7
  358. package/dist/types/src/serializer/decorators/helpers/hasSerializersGetter.d.ts +0 -2
  359. package/dist/types/src/serializer/decorators/helpers/maybeSerializableToDreamSerializerCallbackFunction.d.ts +0 -2
  360. package/docs/classes/DreamSerializer.html +0 -19
  361. package/docs/functions/Attribute.html +0 -1
  362. package/docs/functions/RendersMany.html +0 -16
  363. package/docs/functions/RendersOne.html +0 -16
  364. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +0 -1
  365. package/docs/interfaces/AttributeStatement.html +0 -6
  366. package/docs/interfaces/DreamSerializerAssociationStatement.html +0 -11
  367. package/docs/types/DreamOrViewModelClassSerializerArrayKeys.html +0 -1
  368. package/docs/types/SerializableClassOrSerializerCallback.html +0 -1
  369. package/docs/types/SerializableTypes.html +0 -1
@@ -41,16 +41,13 @@ const CreateOrFindByFailedToCreateAndFind_js_1 = require("./errors/CreateOrFindB
41
41
  const CreateOrUpdateByFailedToCreateAndUpdate_js_1 = require("./errors/CreateOrUpdateByFailedToCreateAndUpdate.js");
42
42
  const GlobalNameNotSet_js_1 = require("./errors/dream-app/GlobalNameNotSet.js");
43
43
  const DreamMissingRequiredOverride_js_1 = require("./errors/DreamMissingRequiredOverride.js");
44
- const MissingSerializersDefinition_js_1 = require("./errors/MissingSerializersDefinition.js");
45
44
  const NonExistentScopeProvidedToResort_js_1 = require("./errors/NonExistentScopeProvidedToResort.js");
46
45
  const CalendarDate_js_1 = require("./helpers/CalendarDate.js");
47
46
  const cloneDeepSafe_js_1 = require("./helpers/cloneDeepSafe.js");
48
47
  const DateTime_js_1 = require("./helpers/DateTime.js");
49
48
  const cachedTypeForAttribute_js_1 = require("./helpers/db/cachedTypeForAttribute.js");
50
49
  const isJsonColumn_js_1 = require("./helpers/db/types/isJsonColumn.js");
51
- const inferSerializerFromDreamOrViewModel_js_1 = require("./helpers/inferSerializerFromDreamOrViewModel.js");
52
50
  const notEqual_js_1 = require("./helpers/notEqual.js");
53
- const typechecks_js_1 = require("./helpers/typechecks.js");
54
51
  class Dream {
55
52
  DB;
56
53
  /**
@@ -489,6 +486,17 @@ class Dream {
489
486
  ...new Set([...columns, ...this.virtualAttributes.map(attr => attr.property)]),
490
487
  ];
491
488
  }
489
+ /**
490
+ * @internal
491
+ *
492
+ * Returns true if the column is a column in the database
493
+ *
494
+ * @param columnName - the name of the property you are checking for
495
+ * @returns boolean
496
+ */
497
+ static isColumn(columnName) {
498
+ return this.prototype.isColumn(columnName);
499
+ }
492
500
  /**
493
501
  * @internal
494
502
  *
@@ -720,7 +728,7 @@ class Dream {
720
728
  try {
721
729
  const dreamModel = this.new({
722
730
  ...attributes,
723
- ...(extraOpts?.createWith || {}),
731
+ ...extraOpts?.createWith,
724
732
  });
725
733
  await dreamModel.save();
726
734
  return dreamModel;
@@ -774,7 +782,7 @@ class Dream {
774
782
  try {
775
783
  return await this.create({
776
784
  ...attributes,
777
- ...(extraOpts?.with || {}),
785
+ ...extraOpts?.with,
778
786
  }, skipHooks ? { skipHooks } : undefined);
779
787
  }
780
788
  catch (err) {
@@ -2068,7 +2076,7 @@ class Dream {
2068
2076
  ? null
2069
2077
  : val === undefined
2070
2078
  ? undefined
2071
- : (0, typechecks_js_1.isString)(val)
2079
+ : typeof val === 'string'
2072
2080
  ? val
2073
2081
  : JSON.stringify(val));
2074
2082
  },
@@ -2142,6 +2150,17 @@ class Dream {
2142
2150
  */
2143
2151
  this.unshadowColumnPropertyPrototypeAccessors();
2144
2152
  }
2153
+ /**
2154
+ * @internal
2155
+ *
2156
+ * Returns true if the column is a column in the database
2157
+ *
2158
+ * @param columnName - the name of the property you are checking for
2159
+ * @returns boolean
2160
+ */
2161
+ isColumn(columnName) {
2162
+ return this.columns().has(columnName);
2163
+ }
2145
2164
  /**
2146
2165
  * Returns true if the columnName passed is marked by a
2147
2166
  * Virtual attribute decorator
@@ -2150,9 +2169,7 @@ class Dream {
2150
2169
  * @returns A boolean
2151
2170
  */
2152
2171
  isVirtualColumn(columnName) {
2153
- return this.constructor.virtualAttributes
2154
- .map(attr => attr.property)
2155
- .includes(columnName);
2172
+ return !!this.constructor.virtualAttributes.find(attr => attr.property === columnName);
2156
2173
  }
2157
2174
  /**
2158
2175
  * Returns an object with column names for keys, and an
@@ -2462,7 +2479,7 @@ class Dream {
2462
2479
  unknownValueToMillis(currentValue) {
2463
2480
  if (!currentValue)
2464
2481
  return;
2465
- if ((0, typechecks_js_1.isString)(currentValue))
2482
+ if (typeof currentValue === 'string')
2466
2483
  currentValue = DateTime_js_1.DateTime.fromISO(currentValue);
2467
2484
  if (currentValue instanceof CalendarDate_js_1.default)
2468
2485
  currentValue = currentValue.toDateTime();
@@ -2475,7 +2492,7 @@ class Dream {
2475
2492
  unknownValueToDateString(currentValue) {
2476
2493
  if (!currentValue)
2477
2494
  return;
2478
- if ((0, typechecks_js_1.isString)(currentValue))
2495
+ if (typeof currentValue === 'string')
2479
2496
  currentValue = CalendarDate_js_1.default.fromISO(currentValue);
2480
2497
  if (currentValue instanceof DateTime_js_1.DateTime)
2481
2498
  currentValue = CalendarDate_js_1.default.fromDateTime(currentValue);
@@ -2926,31 +2943,6 @@ class Dream {
2926
2943
  async reload() {
2927
2944
  await (0, reload_js_1.default)(this);
2928
2945
  }
2929
- /**
2930
- * Serializes an instance. You can specify a serializer key,
2931
- * or else the default will be used
2932
- *
2933
- * ```ts
2934
- * // uses the default serializer provided in the model's `serializers` getter
2935
- * await user.serialize()
2936
- *
2937
- * // uses the summary serializer provided in the model's `serializers` getter
2938
- * await user.serialize({ serializerKey: 'summary' })
2939
- * ```
2940
- *
2941
- * @param args.casing - Which casing to use when serializing (camel or snake, default camel)
2942
- * @param args.serializerKey - The key to use when referencing the object returned by the `serializers` getter on the given model instance (defaults to "default")
2943
- * @returns A serialized representation of the model
2944
- */
2945
- serialize({ casing = null, serializerKey } = {}) {
2946
- const serializerClass = (0, inferSerializerFromDreamOrViewModel_js_1.default)(this, serializerKey?.toString());
2947
- if (!serializerClass)
2948
- throw new MissingSerializersDefinition_js_1.default(this.constructor);
2949
- const serializer = new serializerClass(this);
2950
- if (casing)
2951
- serializer.casing(casing);
2952
- return serializer.render();
2953
- }
2954
2946
  /**
2955
2947
  * Takes the attributes passed in and sets their values,
2956
2948
  * leveraging any custom setters defined for these attributes.
@@ -81,7 +81,12 @@ class DreamBin {
81
81
  await (0, generateDream_js_1.default)({ fullyQualifiedModelName, columnsWithTypes, options });
82
82
  }
83
83
  static async generateStiChild(fullyQualifiedModelName, fullyQualifiedParentName, columnsWithTypes, options) {
84
- await (0, generateDream_js_1.default)({ fullyQualifiedModelName, columnsWithTypes, options, fullyQualifiedParentName });
84
+ await (0, generateDream_js_1.default)({
85
+ fullyQualifiedModelName,
86
+ columnsWithTypes,
87
+ options: { ...options, stiBaseSerializer: false },
88
+ fullyQualifiedParentName,
89
+ });
85
90
  }
86
91
  static async generateMigration(migrationName, columnsWithTypes) {
87
92
  await (0, generateMigration_js_1.default)({ migrationName, columnsWithTypes });
@@ -46,6 +46,7 @@ class DreamCLI {
46
46
  .alias('generate:dream')
47
47
  .alias('g:dream')
48
48
  .option('--no-serializer')
49
+ .option('--sti-base-serializer', 'Omits the serializer from the dream model, but does create the serializer so it can be extended by STI children')
49
50
  .description('create a new Dream model')
50
51
  .argument('<modelName>', 'the name of the model to create, e.g. Post or Settings/CommunicationPreferences')
51
52
  .argument('[columnsWithTypes...]', 'properties of the model property1:text/string/enum/etc. property2:text/string/enum/etc. ... propertyN:text/string/enum/etc.')
@@ -61,8 +61,11 @@ function extractValidationOptionsFromArgs(type, args) {
61
61
  }
62
62
  case 'requiredBelongsTo':
63
63
  return {};
64
- default:
65
- throw new Error(`Unhandled validation type when caching options: ${type}`);
64
+ default: {
65
+ // protection so that if a new ValidationType is ever added, this will throw a type error at build time
66
+ const _never = type;
67
+ throw new Error(`Unhandled ValidationType: ${_never}`);
68
+ }
66
69
  }
67
70
  }
68
71
  class ValidationInstantiationError extends Error {
@@ -5,6 +5,7 @@ const pluralize_esm_1 = require("pluralize-esm");
5
5
  const ConnectedToDB_js_1 = require("../db/ConnectedToDB.js");
6
6
  const SoftDelete_js_1 = require("../decorators/class/SoftDelete.js");
7
7
  const associationToGetterSetterProp_js_1 = require("../decorators/field/association/associationToGetterSetterProp.js");
8
+ const index_js_1 = require("../dream-app/index.js");
8
9
  const AssociationDeclaredWithoutAssociatedDreamClass_js_1 = require("../errors/associations/AssociationDeclaredWithoutAssociatedDreamClass.js");
9
10
  const CannotAssociateThroughPolymorphic_js_1 = require("../errors/associations/CannotAssociateThroughPolymorphic.js");
10
11
  const CannotJoinPolymorphicBelongsToError_js_1 = require("../errors/associations/CannotJoinPolymorphicBelongsToError.js");
@@ -21,6 +22,8 @@ const LeftJoinPreloadIncompatibleWithFindEach_js_1 = require("../errors/LeftJoin
21
22
  const MissingRequiredCallbackFunctionToPluckEach_js_1 = require("../errors/MissingRequiredCallbackFunctionToPluckEach.js");
22
23
  const NoUpdateAllOnJoins_js_1 = require("../errors/NoUpdateAllOnJoins.js");
23
24
  const NoUpdateOnAssociationQuery_js_1 = require("../errors/NoUpdateOnAssociationQuery.js");
25
+ const CannotPaginateWithLimit_js_1 = require("../errors/pagination/CannotPaginateWithLimit.js");
26
+ const CannotPaginateWithOffset_js_1 = require("../errors/pagination/CannotPaginateWithOffset.js");
24
27
  const RecordNotFound_js_1 = require("../errors/RecordNotFound.js");
25
28
  const UnexpectedUndefined_js_1 = require("../errors/UnexpectedUndefined.js");
26
29
  const CalendarDate_js_1 = require("../helpers/CalendarDate.js");
@@ -29,28 +32,25 @@ const cloneDeepSafe_js_1 = require("../helpers/cloneDeepSafe.js");
29
32
  const compact_js_1 = require("../helpers/compact.js");
30
33
  const DateTime_js_1 = require("../helpers/DateTime.js");
31
34
  const isEmpty_js_1 = require("../helpers/isEmpty.js");
35
+ const isObject_js_1 = require("../helpers/isObject.js");
32
36
  const namespaceColumn_js_1 = require("../helpers/namespaceColumn.js");
33
- const normalizeString_js_1 = require("../helpers/normalizeString.js");
37
+ const normalizeUnicode_js_1 = require("../helpers/normalizeUnicode.js");
34
38
  const objectPathsToArrays_js_1 = require("../helpers/objectPathsToArrays.js");
35
39
  const protectAgainstPollutingAssignment_js_1 = require("../helpers/protectAgainstPollutingAssignment.js");
36
40
  const range_js_1 = require("../helpers/range.js");
37
41
  const snakeify_js_1 = require("../helpers/snakeify.js");
38
- const typechecks_js_1 = require("../helpers/typechecks.js");
39
42
  const uniq_js_1 = require("../helpers/uniq.js");
40
43
  const curried_ops_statement_js_1 = require("../ops/curried-ops-statement.js");
41
- const index_js_1 = require("../ops/index.js");
44
+ const index_js_2 = require("../ops/index.js");
42
45
  const ops_statement_js_1 = require("../ops/ops-statement.js");
43
46
  const constants_js_1 = require("./constants.js");
47
+ const computedPaginatePage_js_1 = require("./internal/computedPaginatePage.js");
44
48
  const executeDatabaseQuery_js_1 = require("./internal/executeDatabaseQuery.js");
45
49
  const extractAssociationMetadataFromAssociationName_js_1 = require("./internal/extractAssociationMetadataFromAssociationName.js");
46
50
  const orderByDirection_js_1 = require("./internal/orderByDirection.js");
47
51
  const shouldBypassDefaultScope_js_1 = require("./internal/shouldBypassDefaultScope.js");
48
52
  const SimilarityBuilder_js_1 = require("./internal/similarity/SimilarityBuilder.js");
49
53
  const sqlResultToDreamInstance_js_1 = require("./internal/sqlResultToDreamInstance.js");
50
- const index_js_2 = require("../dream-app/index.js");
51
- const CannotPaginateWithLimit_js_1 = require("../errors/pagination/CannotPaginateWithLimit.js");
52
- const CannotPaginateWithOffset_js_1 = require("../errors/pagination/CannotPaginateWithOffset.js");
53
- const computedPaginatePage_js_1 = require("./internal/computedPaginatePage.js");
54
54
  class Query extends ConnectedToDB_js_1.default {
55
55
  /**
56
56
  * @internal
@@ -301,7 +301,7 @@ class Query extends ConnectedToDB_js_1.default {
301
301
  baseSelectQuery: opts.baseSelectQuery || this.baseSelectQuery,
302
302
  passthroughOnStatement: {
303
303
  ...this.passthroughOnStatement,
304
- ...(opts.passthroughOnStatement || {}),
304
+ ...opts.passthroughOnStatement,
305
305
  },
306
306
  where: opts.where === null ? [] : [...this.whereStatements, ...(opts.where || [])],
307
307
  whereNot: opts.whereNot === null ? [] : [...this.whereNotStatements, ...(opts.whereNot || [])],
@@ -442,13 +442,13 @@ class Query extends ConnectedToDB_js_1.default {
442
442
  let lastId = null;
443
443
  do {
444
444
  if (lastId)
445
- records = await query.where({ [this.dreamInstance.primaryKey]: index_js_1.default.greaterThan(lastId) }).all();
445
+ records = await query.where({ [this.dreamInstance.primaryKey]: index_js_2.default.greaterThan(lastId) }).all();
446
446
  else
447
447
  records = await query.all();
448
448
  for (const record of records) {
449
449
  await cb(record);
450
450
  }
451
- lastId = records[records.length - 1]?.primaryKeyValue;
451
+ lastId = records.at(-1)?.primaryKeyValue;
452
452
  } while (records.length > 0 && records.length === batchSize);
453
453
  }
454
454
  /**
@@ -551,7 +551,7 @@ class Query extends ConnectedToDB_js_1.default {
551
551
  if (nextAssociationStatement === undefined) {
552
552
  // just satisfying typing
553
553
  }
554
- else if ((0, typechecks_js_1.isString)(nextAssociationStatement)) {
554
+ else if (typeof nextAssociationStatement === 'string') {
555
555
  const nextStatement = nextAssociationStatement;
556
556
  if (!joinStatements[nextStatement])
557
557
  joinStatements[(0, protectAgainstPollutingAssignment_js_1.default)(nextStatement)] = {};
@@ -573,7 +573,7 @@ class Query extends ConnectedToDB_js_1.default {
573
573
  });
574
574
  //
575
575
  }
576
- else if ((0, typechecks_js_1.isObject)(nextAssociationStatement) && previousAssociationName) {
576
+ else if ((0, isObject_js_1.default)(nextAssociationStatement) && previousAssociationName) {
577
577
  const clonedNextAssociationStatement = (0, cloneDeepSafe_js_1.default)(nextAssociationStatement);
578
578
  const keys = Object.keys(clonedNextAssociationStatement);
579
579
  keys.forEach((key) => {
@@ -908,7 +908,7 @@ class Query extends ConnectedToDB_js_1.default {
908
908
  order(arg) {
909
909
  if (arg === null)
910
910
  return this.clone({ order: null });
911
- if ((0, typechecks_js_1.isString)(arg))
911
+ if (typeof arg === 'string')
912
912
  return this.clone({ order: [{ column: arg, direction: 'asc' }] });
913
913
  let query = this.clone();
914
914
  Object.keys(arg).forEach(key => {
@@ -1003,8 +1003,11 @@ class Query extends ConnectedToDB_js_1.default {
1003
1003
  return this.buildUpdate({});
1004
1004
  // TODO: in the future, we should support insert type, but don't yet, since inserts are done outside
1005
1005
  // the query class for some reason.
1006
- default:
1007
- throw new Error('never');
1006
+ default: {
1007
+ // protection so that if a new QueryType is ever added, this will throw a type error at build time
1008
+ const _never = type;
1009
+ throw new Error(`Unhandled QueryType: ${_never}`);
1010
+ }
1008
1011
  }
1009
1012
  }
1010
1013
  /**
@@ -1187,7 +1190,7 @@ class Query extends ConnectedToDB_js_1.default {
1187
1190
  kyselyQuery = kyselyQuery.select(`${this.namespaceColumn(dbColumnName, association.through)} as ${columnAlias}`);
1188
1191
  };
1189
1192
  if (association.through && association.preloadThroughColumns) {
1190
- if ((0, typechecks_js_1.isObject)(association.preloadThroughColumns)) {
1193
+ if ((0, isObject_js_1.default)(association.preloadThroughColumns)) {
1191
1194
  const preloadMap = association.preloadThroughColumns;
1192
1195
  Object.keys(preloadMap).forEach(columnName => setupPreloadData(columnName));
1193
1196
  }
@@ -1299,7 +1302,7 @@ class Query extends ConnectedToDB_js_1.default {
1299
1302
  return;
1300
1303
  let columnNames = [];
1301
1304
  const columnNameToPreloadedThroughColumnNameMap = {};
1302
- if ((0, typechecks_js_1.isObject)(association.preloadThroughColumns)) {
1305
+ if ((0, isObject_js_1.default)(association.preloadThroughColumns)) {
1303
1306
  const preloadMap = association.preloadThroughColumns;
1304
1307
  columnNames = Object.keys(preloadMap).map(columnName => {
1305
1308
  columnNameToPreloadedThroughColumnNameMap[columnName] = preloadMap[columnName];
@@ -1452,7 +1455,7 @@ class Query extends ConnectedToDB_js_1.default {
1452
1455
  throw new CannotPaginateWithOffset_js_1.default();
1453
1456
  const page = (0, computedPaginatePage_js_1.default)(opts.page);
1454
1457
  const recordCount = await this.count();
1455
- const pageSize = opts.pageSize || index_js_2.default.getOrFail().paginationPageSize;
1458
+ const pageSize = opts.pageSize || index_js_1.default.getOrFail().paginationPageSize;
1456
1459
  const pageCount = Math.ceil(recordCount / pageSize);
1457
1460
  const results = await this.limit(pageSize)
1458
1461
  .offset((page - 1) * pageSize)
@@ -1932,7 +1935,7 @@ class Query extends ConnectedToDB_js_1.default {
1932
1935
  const columnsToPluck = dreamClassToHydrateColumns.map(column => this.namespaceColumn(column.toString(), alias));
1933
1936
  const asHasAssociation = association;
1934
1937
  if (asHasAssociation.through && asHasAssociation.preloadThroughColumns) {
1935
- if ((0, typechecks_js_1.isObject)(asHasAssociation.preloadThroughColumns)) {
1938
+ if ((0, isObject_js_1.default)(asHasAssociation.preloadThroughColumns)) {
1936
1939
  const preloadMap = asHasAssociation.preloadThroughColumns;
1937
1940
  Object.keys(preloadMap).forEach(preloadThroughColumn => {
1938
1941
  throughColumnsToHydrate.push(preloadMap[preloadThroughColumn]);
@@ -1974,7 +1977,7 @@ class Query extends ConnectedToDB_js_1.default {
1974
1977
  pluckedData[dreamClassToHydrateColumns.length + index]));
1975
1978
  return {
1976
1979
  dream: hydratedDream,
1977
- pointsToPrimaryKey: pluckedData[pluckedData.length - 1],
1980
+ pointsToPrimaryKey: pluckedData.at(-1),
1978
1981
  };
1979
1982
  });
1980
1983
  this.hydrateAssociation(dreams, association, preloadedDreamsAndWhatTheyPointTo);
@@ -2361,7 +2364,7 @@ class Query extends ConnectedToDB_js_1.default {
2361
2364
  return query;
2362
2365
  let selectQuery = query;
2363
2366
  const orderStatement = association.order;
2364
- if ((0, typechecks_js_1.isString)(orderStatement)) {
2367
+ if (typeof orderStatement === 'string') {
2365
2368
  selectQuery = selectQuery.orderBy(this.namespaceColumn(orderStatement, tableNameOrAlias), 'asc');
2366
2369
  }
2367
2370
  else {
@@ -2480,7 +2483,7 @@ class Query extends ConnectedToDB_js_1.default {
2480
2483
  val = val();
2481
2484
  }
2482
2485
  else if (val === constants_js_1.DreamConst.passthrough) {
2483
- const column = attr.split('.').pop();
2486
+ const column = attr.split('.').at(-1);
2484
2487
  if (this.passthroughOnStatement[column] === undefined)
2485
2488
  throw new MissingRequiredPassthroughForAssociationAndClause_js_1.default(column);
2486
2489
  val = this.passthroughOnStatement[column];
@@ -2498,7 +2501,11 @@ class Query extends ConnectedToDB_js_1.default {
2498
2501
  else if (Array.isArray(val)) {
2499
2502
  a = attr;
2500
2503
  b = 'in';
2501
- c = val.map(v => v instanceof DateTime_js_1.DateTime || v instanceof CalendarDate_js_1.default ? v.toSQL() : (0, typechecks_js_1.isString)(v) ? (0, normalizeString_js_1.default)(v) : v);
2504
+ c = val.map(v => v instanceof DateTime_js_1.DateTime || v instanceof CalendarDate_js_1.default
2505
+ ? v.toSQL()
2506
+ : typeof v === 'string'
2507
+ ? (0, normalizeUnicode_js_1.default)(v)
2508
+ : v);
2502
2509
  }
2503
2510
  else if (val instanceof curried_ops_statement_js_1.default) {
2504
2511
  val = val.toOpsStatement(this.dreamClass, attr);
@@ -2541,12 +2548,12 @@ class Query extends ConnectedToDB_js_1.default {
2541
2548
  }
2542
2549
  if (c instanceof DateTime_js_1.DateTime || c instanceof CalendarDate_js_1.default)
2543
2550
  c = c.toSQL();
2544
- else if ((0, typechecks_js_1.isString)(c))
2545
- c = (0, normalizeString_js_1.default)(c);
2551
+ else if (typeof c === 'string')
2552
+ c = (0, normalizeUnicode_js_1.default)(c);
2546
2553
  if (c2 instanceof DateTime_js_1.DateTime || c2 instanceof CalendarDate_js_1.default)
2547
2554
  c2 = c2.toSQL();
2548
- else if ((0, typechecks_js_1.isString)(c2))
2549
- c2 = (0, normalizeString_js_1.default)(c2);
2555
+ else if (typeof c2 === 'string')
2556
+ c2 = (0, normalizeUnicode_js_1.default)(c2);
2550
2557
  if (a && c === undefined)
2551
2558
  throw new CannotPassUndefinedAsAValueToAWhereClause_js_1.default(this.dreamClass, a);
2552
2559
  if (a2 && c2 === undefined)
@@ -14,25 +14,23 @@ exports.DreamConst = {
14
14
  required: RequiredAttribute,
15
15
  };
16
16
  exports.openapiPrimitiveTypes = [
17
- 'string',
18
17
  'boolean',
19
- 'number',
20
- 'date',
21
18
  'date-time',
22
- 'double',
19
+ 'date',
23
20
  'integer',
24
21
  'null',
22
+ 'number',
23
+ 'string',
25
24
  ];
26
25
  exports.openapiShorthandPrimitiveTypes = [
27
26
  ...exports.openapiPrimitiveTypes,
28
- 'decimal',
29
- 'string[]',
30
27
  'boolean[]',
31
- 'number[]',
32
- 'date[]',
33
28
  'date-time[]',
29
+ 'date[]',
30
+ 'decimal',
34
31
  'decimal[]',
35
- 'double[]',
36
32
  'integer[]',
37
33
  'json',
34
+ 'number[]',
35
+ 'string[]',
38
36
  ];
@@ -50,8 +50,11 @@ function checkSingleValidation(dream, validation) {
50
50
  if (associationMetadata === undefined)
51
51
  throw new UnexpectedUndefined_js_1.default();
52
52
  return !!(value || dream[associationMetadata.foreignKey()]);
53
- default:
54
- throw new Error(`Unhandled validation type found while running validations: ${validation.type}`);
53
+ default: {
54
+ // protection so that if a new ValidationType is ever added, this will throw a type error at build time
55
+ const _never = validation.type;
56
+ throw new Error(`Unhandled ValidationType: ${_never}`);
57
+ }
55
58
  }
56
59
  }
57
60
  function isBlank(value) {
@@ -9,7 +9,7 @@ async function findOrCreateBy(dreamClass, txn = null, attributes, extraOpts = {}
9
9
  return existingRecord;
10
10
  const dreamModel = dreamClass.new({
11
11
  ...attributes,
12
- ...(extraOpts?.createWith || {}),
12
+ ...extraOpts?.createWith,
13
13
  });
14
14
  await dreamModel.txn(txn).save();
15
15
  return dreamModel;
@@ -9,7 +9,10 @@ function orderByDirection(dir) {
9
9
  return (0, kysely_1.sql) `asc nulls first`;
10
10
  case 'desc':
11
11
  return (0, kysely_1.sql) `desc nulls last`;
12
- default:
13
- throw new Error(`Unrecognized orderBy direction: ${dir}`);
12
+ default: {
13
+ // protection so that if a new OrderDir is ever added, this will throw a type error at build time
14
+ const _never = dir;
15
+ throw new Error(`Unhandled OrderDir: ${_never}`);
16
+ }
14
17
  }
15
18
  }
@@ -6,8 +6,8 @@ const ConnectedToDB_js_1 = require("../../../db/ConnectedToDB.js");
6
6
  const validateColumn_js_1 = require("../../../db/validators/validateColumn.js");
7
7
  const validateTable_js_1 = require("../../../db/validators/validateTable.js");
8
8
  const validateTableAlias_js_1 = require("../../../db/validators/validateTableAlias.js");
9
+ const isObject_js_1 = require("../../../helpers/isObject.js");
9
10
  const namespaceColumn_js_1 = require("../../../helpers/namespaceColumn.js");
10
- const typechecks_js_1 = require("../../../helpers/typechecks.js");
11
11
  const constants_js_1 = require("../../constants.js");
12
12
  const similaritySelectSql_js_1 = require("./similaritySelectSql.js");
13
13
  const similarityWhereSql_js_1 = require("./similarityWhereSql.js");
@@ -193,7 +193,7 @@ class SimilarityBuilder extends ConnectedToDB_js_1.default {
193
193
  opsStatement: statementOrValueOrNestedObject,
194
194
  });
195
195
  }
196
- else if ((0, typechecks_js_1.isObject)(statementOrValueOrNestedObject) &&
196
+ else if ((0, isObject_js_1.default)(statementOrValueOrNestedObject) &&
197
197
  !statementOrValueOrNestedObject?.isOpsStatement) {
198
198
  // if it is an object, but not an array, it is likely a nested joins statement,
199
199
  // since joinsWhere objects can take a recursive shape, like:
@@ -319,7 +319,7 @@ function removeJoinAndFromObjectHierarchy(obj) {
319
319
  const result = {};
320
320
  for (const key in obj) {
321
321
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
322
- if ((0, typechecks_js_1.isObject)(obj[key])) {
322
+ if ((0, isObject_js_1.default)(obj[key])) {
323
323
  result[key] = removeJoinAndFromObjectHierarchy(obj[key].and || obj[key]);
324
324
  }
325
325
  else {
@@ -13,6 +13,6 @@ async function updateOrCreateBy(dreamClass, txn = null, attributes, extraOpts =
13
13
  }
14
14
  return await dreamClass.txn(txn).create({
15
15
  ...attributes,
16
- ...(extraOpts?.with || {}),
16
+ ...extraOpts?.with,
17
17
  }, skipHooks ? { skipHooks } : undefined);
18
18
  }
@@ -31,11 +31,11 @@ class DreamImporter {
31
31
  }
32
32
  static async importSerializers(pathToSerializers, importCb) {
33
33
  const serializerPaths = await DreamImporter.ls(pathToSerializers);
34
- const serializerClasses = (await Promise.all(serializerPaths.map(serializerPath => importCb(serializerPath).then(serializerClass => [
34
+ const pathsNamesAndSerializers = (await Promise.all(serializerPaths.map(serializerPath => importCb(serializerPath).then(serializerClass => [
35
35
  serializerPath,
36
36
  serializerClass,
37
37
  ]))));
38
- return serializerClasses;
38
+ return pathsNamesAndSerializers;
39
39
  }
40
40
  }
41
41
  exports.default = DreamImporter;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- function default_1(filepath, dirPath, exportKey = 'default') {
3
+ exports.default = globalSerializerKeyFromPath;
4
+ function globalSerializerKeyFromPath(filepath, dirPath, exportKey = 'default') {
5
5
  const prefixPath = dirPath;
6
6
  const defaultExport = filepath
7
7
  .replace(prefixPath, '')
@@ -73,7 +73,7 @@ function setCachedModels(models) {
73
73
  }
74
74
  function getModelsOrFail() {
75
75
  if (!_models)
76
- throw new Error('Must call loadModels before calling getModelsOrFail');
76
+ throw new Error('Must call importModels before calling getModelsOrFail');
77
77
  return _models;
78
78
  }
79
79
  function getModelsOrBlank() {
@@ -5,49 +5,31 @@ exports.setCachedSerializers = setCachedSerializers;
5
5
  exports.getSerializersOrFail = getSerializersOrFail;
6
6
  exports.getSerializersOrBlank = getSerializersOrBlank;
7
7
  const SerializerNameConflict_js_1 = require("../../../errors/dream-app/SerializerNameConflict.js");
8
- const index_js_1 = require("../../../serializer/index.js");
8
+ const isDreamSerializer_js_1 = require("../../../serializer/helpers/isDreamSerializer.js");
9
9
  const DreamImporter_js_1 = require("../DreamImporter.js");
10
10
  const globalSerializerKeyFromPath_js_1 = require("../globalSerializerKeyFromPath.js");
11
+ const serializerOpenapiNameFromPath_js_1 = require("../serializerOpenapiNameFromPath.js");
11
12
  let _serializers;
12
13
  async function importSerializers(serializersPath, serializerImportCb) {
13
14
  if (_serializers)
14
15
  return _serializers;
15
16
  const serializerClasses = await DreamImporter_js_1.default.importSerializers(serializersPath, serializerImportCb);
16
- /**
17
- * Certain features (e.g. building OpenAPI specs from Attribute and RendersOne/Many decorators)
18
- * need static access to things set up by decorators. Stage 3 Decorators change the context that is available
19
- * at decoration time such that the class of a property being decorated is only avilable during instance instantiation. In order
20
- * to only apply static values once, on boot, `globallyInitializingDecorators` is set to true on DreamSerializer, and all serializers are instantiated.
21
- */
22
- index_js_1.default['globallyInitializingDecorators'] = true;
23
17
  _serializers = {};
24
18
  for (const [serializerPath, allSerializers] of serializerClasses) {
25
19
  Object.keys(allSerializers).forEach(key => {
26
20
  const potentialSerializer = allSerializers[key];
27
- if (potentialSerializer?.isDreamSerializer) {
21
+ if (potentialSerializer && (0, isDreamSerializer_js_1.default)(potentialSerializer)) {
28
22
  const serializerKey = (0, globalSerializerKeyFromPath_js_1.default)(serializerPath, serializersPath, key);
23
+ const serializerOpenapiName = (0, serializerOpenapiNameFromPath_js_1.default)(serializerPath, serializersPath, key);
29
24
  if (_serializers[serializerKey])
30
25
  throw new SerializerNameConflict_js_1.default(serializerKey);
31
- const serializerClass = potentialSerializer;
32
- serializerClass['setGlobalName'](serializerKey);
33
- /**
34
- * Certain features (e.g. building OpenAPI specs from Attribute and RendersOne/Many decorators)
35
- * need static access to things set up by decorators. Stage 3 Decorators change the context that is available
36
- * at decoration time such that the class of a property being decorated is only avilable during instance instantiation. In order
37
- * to only apply static values once, on boot, `globallyInitializingDecorators` is set to true on DreamSerializer, and all serializers are instantiated.
38
- */
39
- new serializerClass({});
26
+ const serializer = potentialSerializer;
27
+ serializer['globalName'] = serializerKey;
28
+ serializer['openapiName'] = serializerOpenapiName;
40
29
  _serializers[serializerKey] = potentialSerializer;
41
30
  }
42
31
  });
43
32
  }
44
- /**
45
- * Certain features (e.g. building OpenAPI specs from Attribute and RendersOne/Many decorators)
46
- * need static access to things set up by decorators. Stage 3 Decorators change the context that is available
47
- * at decoration time such that the class of a property being decorated is only avilable during instance instantiation. In order
48
- * to only apply static values once, on boot, `globallyInitializingDecorators` is set to true on DreamSerializer, and all serializers are instantiated.
49
- */
50
- index_js_1.default['globallyInitializingDecorators'] = false;
51
33
  return _serializers;
52
34
  }
53
35
  function setCachedSerializers(serializers) {
@@ -55,7 +37,7 @@ function setCachedSerializers(serializers) {
55
37
  }
56
38
  function getSerializersOrFail() {
57
39
  if (!_serializers)
58
- throw new Error('Must call loadSerializers before calling getSerializersOrFail');
40
+ throw new Error('Must call importSerializers before calling getSerializersOrFail');
59
41
  return _serializers;
60
42
  }
61
43
  function getSerializersOrBlank() {
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = serializerOpenapiNameFromPath;
4
+ function serializerOpenapiNameFromPath(filepath, dirPath, exportKey = 'default') {
5
+ return _serializerOpenapiNameFromPath(filepath, dirPath, exportKey).replace(/Serializer$/, '');
6
+ }
7
+ function _serializerOpenapiNameFromPath(filepath, dirPath, exportKey = 'default') {
8
+ if (exportKey === 'default') {
9
+ const defaultExport = filepath
10
+ .replace(dirPath, '')
11
+ .replace(/\.[jt]s$/, '')
12
+ .replace(/\//g, '');
13
+ return defaultExport;
14
+ }
15
+ else {
16
+ return exportKey;
17
+ }
18
+ }
@@ -317,8 +317,11 @@ Try setting it to something valid, like:
317
317
  case 'paginationPageSize':
318
318
  this._paginationPageSize = options;
319
319
  break;
320
- default:
321
- throw new Error(`Unhandled applyOption encountered in Dreamconf: ${applyOption}`);
320
+ default: {
321
+ // protection so that if a new ApplyOpt is ever added, this will throw a type error at build time
322
+ const _never = applyOption;
323
+ throw new Error(`Unhandled ApplyOpt: ${_never}`);
324
+ }
322
325
  }
323
326
  }
324
327
  on(hookEventType, cb) {