@rvoh/dream 0.31.0 → 0.31.2

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 (348) hide show
  1. package/README.md +17 -17
  2. package/dist/cjs/src/Dream.js +17 -18
  3. package/dist/cjs/src/bin/helpers/sync.js +11 -4
  4. package/dist/cjs/src/bin/index.js +18 -19
  5. package/dist/cjs/src/cli/logger/DreamCliLogger.js +12 -46
  6. package/dist/cjs/src/cli/logger/loggable/DreamCliLoggable.js +1 -3
  7. package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableText.js +2 -2
  8. package/dist/cjs/src/decorators/Decorators.js +28 -28
  9. package/dist/cjs/src/decorators/field/association/BelongsTo.js +2 -2
  10. package/dist/cjs/src/decorators/field/association/HasMany.js +2 -2
  11. package/dist/cjs/src/decorators/field/association/HasOne.js +2 -2
  12. package/dist/cjs/src/decorators/field/association/shared.js +8 -8
  13. package/dist/cjs/src/decorators/field/lifecycle/AfterCreateCommit.js +1 -1
  14. package/dist/cjs/src/decorators/field/lifecycle/AfterDestroyCommit.js +1 -1
  15. package/dist/cjs/src/decorators/field/lifecycle/AfterSaveCommit.js +1 -1
  16. package/dist/cjs/src/decorators/field/lifecycle/AfterUpdateCommit.js +1 -1
  17. package/dist/cjs/src/decorators/field/validation/Validates.js +1 -1
  18. package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +2 -2
  19. package/dist/cjs/src/dream/Query.js +7 -7
  20. package/dist/cjs/src/{openapi/types.js → dream/constants.js} +13 -1
  21. package/dist/cjs/src/dream/internal/similarity/SimilarityBuilder.js +3 -3
  22. package/dist/cjs/src/helpers/cli/SchemaBuilder.js +5 -5
  23. package/dist/cjs/src/helpers/cli/generateDream.js +1 -1
  24. package/dist/cjs/src/helpers/cli/generateDreamContent.js +2 -2
  25. package/dist/cjs/src/helpers/db/primaryKeyType.js +2 -2
  26. package/dist/cjs/src/helpers/db/runMigration.js +5 -5
  27. package/dist/cjs/src/helpers/isEmpty.js +2 -0
  28. package/dist/cjs/src/helpers/sort.js +24 -0
  29. package/dist/cjs/src/helpers/sortBy.js +19 -2
  30. package/dist/cjs/src/helpers/sspawn.js +29 -3
  31. package/dist/cjs/src/helpers/uniq.js +6 -5
  32. package/dist/cjs/src/index.js +8 -7
  33. package/dist/cjs/src/ops/ops-statement.js +3 -3
  34. package/dist/cjs/src/serializer/decorators/associations/RendersMany.js +2 -2
  35. package/dist/cjs/src/serializer/decorators/associations/RendersOne.js +2 -2
  36. package/dist/cjs/src/serializer/index.js +2 -2
  37. package/dist/esm/src/Dream.js +18 -19
  38. package/dist/esm/src/bin/helpers/sync.js +11 -4
  39. package/dist/esm/src/bin/index.js +18 -19
  40. package/dist/esm/src/cli/logger/DreamCliLogger.js +12 -46
  41. package/dist/esm/src/cli/logger/loggable/DreamCliLoggable.js +1 -3
  42. package/dist/esm/src/cli/logger/loggable/DreamCliLoggableText.js +2 -2
  43. package/dist/esm/src/decorators/Decorators.js +28 -28
  44. package/dist/esm/src/decorators/field/association/BelongsTo.js +2 -2
  45. package/dist/esm/src/decorators/field/association/HasMany.js +2 -2
  46. package/dist/esm/src/decorators/field/association/HasOne.js +2 -2
  47. package/dist/esm/src/decorators/field/association/shared.js +6 -6
  48. package/dist/esm/src/decorators/field/lifecycle/AfterCreateCommit.js +1 -1
  49. package/dist/esm/src/decorators/field/lifecycle/AfterDestroyCommit.js +1 -1
  50. package/dist/esm/src/decorators/field/lifecycle/AfterSaveCommit.js +1 -1
  51. package/dist/esm/src/decorators/field/lifecycle/AfterUpdateCommit.js +1 -1
  52. package/dist/esm/src/decorators/field/validation/Validates.js +1 -1
  53. package/dist/esm/src/dream/DreamClassTransactionBuilder.js +2 -2
  54. package/dist/esm/src/dream/Query.js +3 -3
  55. package/dist/esm/src/{openapi/types.js → dream/constants.js} +12 -0
  56. package/dist/esm/src/dream/internal/similarity/SimilarityBuilder.js +1 -1
  57. package/dist/esm/src/errors/associations/InvalidComputedForeignKey.js +1 -1
  58. package/dist/esm/src/helpers/cli/SchemaBuilder.js +3 -3
  59. package/dist/esm/src/helpers/cli/generateDream.js +1 -1
  60. package/dist/esm/src/helpers/cli/generateDreamContent.js +2 -2
  61. package/dist/esm/src/helpers/db/primaryKeyType.js +1 -1
  62. package/dist/esm/src/helpers/db/runMigration.js +5 -5
  63. package/dist/esm/src/helpers/isEmpty.js +2 -0
  64. package/dist/esm/src/helpers/sort.js +21 -0
  65. package/dist/esm/src/helpers/sortBy.js +19 -2
  66. package/dist/esm/src/helpers/sspawn.js +29 -3
  67. package/dist/esm/src/helpers/uniq.js +6 -5
  68. package/dist/esm/src/index.js +2 -2
  69. package/dist/esm/src/ops/ops-statement.js +1 -1
  70. package/dist/esm/src/serializer/decorators/associations/RendersMany.js +2 -2
  71. package/dist/esm/src/serializer/decorators/associations/RendersOne.js +2 -2
  72. package/dist/esm/src/serializer/index.js +1 -1
  73. package/dist/types/src/Dream.d.ts +28 -28
  74. package/dist/types/src/cli/logger/DreamCliLogger.d.ts +5 -20
  75. package/dist/types/src/cli/logger/loggable/DreamCliLoggable.d.ts +2 -4
  76. package/dist/types/src/cli/logger/loggable/DreamCliLoggableText.d.ts +2 -3
  77. package/dist/types/src/cli/logger/loggable/colorize.d.ts +1 -1
  78. package/dist/types/src/db/ConnectedToDB.d.ts +2 -2
  79. package/dist/types/src/db/ConnectionConfRetriever.d.ts +1 -1
  80. package/dist/types/src/db/DreamDbConnection.d.ts +1 -1
  81. package/dist/types/src/db/dataTypes.d.ts +0 -3
  82. package/dist/types/src/db/index.d.ts +1 -1
  83. package/dist/types/src/decorators/Decorators.d.ts +28 -28
  84. package/dist/types/src/decorators/field/association/BelongsTo.d.ts +2 -30
  85. package/dist/types/src/decorators/field/association/HasMany.d.ts +2 -15
  86. package/dist/types/src/decorators/field/association/HasOne.d.ts +2 -7
  87. package/dist/types/src/decorators/field/association/associationToGetterSetterProp.d.ts +4 -4
  88. package/dist/types/src/decorators/field/association/shared.d.ts +1 -100
  89. package/dist/types/src/decorators/field/lifecycle/AfterCreate.d.ts +1 -1
  90. package/dist/types/src/decorators/field/lifecycle/AfterCreateCommit.d.ts +2 -2
  91. package/dist/types/src/decorators/field/lifecycle/AfterDestroyCommit.d.ts +1 -1
  92. package/dist/types/src/decorators/field/lifecycle/AfterSave.d.ts +1 -1
  93. package/dist/types/src/decorators/field/lifecycle/AfterSaveCommit.d.ts +2 -2
  94. package/dist/types/src/decorators/field/lifecycle/AfterUpdate.d.ts +1 -1
  95. package/dist/types/src/decorators/field/lifecycle/AfterUpdateCommit.d.ts +2 -2
  96. package/dist/types/src/decorators/field/lifecycle/BeforeCreate.d.ts +1 -1
  97. package/dist/types/src/decorators/field/lifecycle/BeforeSave.d.ts +1 -1
  98. package/dist/types/src/decorators/field/lifecycle/BeforeUpdate.d.ts +1 -1
  99. package/dist/types/src/decorators/field/lifecycle/shared.d.ts +1 -30
  100. package/dist/types/src/decorators/field/validation/Validates.d.ts +1 -1
  101. package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +8 -6
  102. package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +4 -2
  103. package/dist/types/src/dream/DreamTransaction.d.ts +1 -1
  104. package/dist/types/src/dream/LeftJoinLoadBuilder.d.ts +3 -2
  105. package/dist/types/src/dream/LoadBuilder.d.ts +3 -2
  106. package/dist/types/src/dream/Query.d.ts +7 -49
  107. package/dist/types/src/dream/constants.d.ts +15 -0
  108. package/dist/types/src/dream/internal/applyScopeBypassingSettingsToQuery.d.ts +1 -1
  109. package/dist/types/src/dream/internal/associations/associationQuery.d.ts +1 -1
  110. package/dist/types/src/dream/internal/associations/associationUpdateQuery.d.ts +1 -1
  111. package/dist/types/src/dream/internal/associations/createAssociation.d.ts +1 -1
  112. package/dist/types/src/dream/internal/associations/destroyAssociation.d.ts +1 -1
  113. package/dist/types/src/dream/internal/associations/undestroyAssociation.d.ts +1 -1
  114. package/dist/types/src/dream/internal/checkSingleValidation.d.ts +1 -1
  115. package/dist/types/src/dream/internal/destroyOptions.d.ts +1 -1
  116. package/dist/types/src/dream/internal/orderByDirection.d.ts +1 -1
  117. package/dist/types/src/dream/internal/runHooksFor.d.ts +1 -1
  118. package/dist/types/src/dream/internal/safelyRunCommitHooks.d.ts +1 -1
  119. package/dist/types/src/dream/internal/scopeHelpers.d.ts +1 -1
  120. package/dist/types/src/dream/internal/similarity/SimilarityBuilder.d.ts +3 -3
  121. package/dist/types/src/dream/internal/sqlResultToDreamInstance.d.ts +1 -1
  122. package/dist/types/src/dream-application/index.d.ts +1 -1
  123. package/dist/types/src/errors/ValidationError.d.ts +1 -1
  124. package/dist/types/src/errors/associations/CanOnlyPassBelongsToModelParam.d.ts +2 -2
  125. package/dist/types/src/errors/associations/CannotAssociateThroughPolymorphic.d.ts +2 -2
  126. package/dist/types/src/errors/associations/CannotCreateAssociationWithThroughContext.d.ts +2 -2
  127. package/dist/types/src/errors/associations/CannotJoinPolymorphicBelongsToError.d.ts +1 -1
  128. package/dist/types/src/errors/associations/CannotPassNullOrUndefinedToRequiredBelongsTo.d.ts +1 -1
  129. package/dist/types/src/errors/associations/InvalidComputedForeignKey.d.ts +1 -1
  130. package/dist/types/src/errors/associations/MissingRequiredAssociationOnClause.d.ts +2 -2
  131. package/dist/types/src/errors/associations/MissingThroughAssociation.d.ts +2 -2
  132. package/dist/types/src/errors/associations/MissingThroughAssociationSource.d.ts +2 -2
  133. package/dist/types/src/helpers/cli/generateMigrationContent.d.ts +1 -1
  134. package/dist/types/src/helpers/cli/generateStiMigrationContent.d.ts +1 -1
  135. package/dist/types/src/helpers/db/createDb.d.ts +1 -1
  136. package/dist/types/src/helpers/db/dropDb.d.ts +1 -1
  137. package/dist/types/src/helpers/db/foreignKeyTypeFromPrimaryKey.d.ts +1 -1
  138. package/dist/types/src/helpers/inferSerializerFromDreamOrViewModel.d.ts +1 -1
  139. package/dist/types/src/helpers/isEmpty.d.ts +1 -1
  140. package/dist/types/src/helpers/objectPathsToArrays.d.ts +1 -1
  141. package/dist/types/src/helpers/sort.d.ts +15 -0
  142. package/dist/types/src/helpers/sortBy.d.ts +2 -2
  143. package/dist/types/src/helpers/sspawn.d.ts +6 -2
  144. package/dist/types/src/helpers/stringCasing.d.ts +1 -1
  145. package/dist/types/src/helpers/uniq.d.ts +1 -1
  146. package/dist/types/src/index.d.ts +6 -4
  147. package/dist/types/src/ops/index.d.ts +1 -1
  148. package/dist/types/src/ops/ops-statement.d.ts +1 -1
  149. package/dist/types/src/serializer/decorators/associations/RendersMany.d.ts +3 -3
  150. package/dist/types/src/serializer/decorators/associations/RendersOne.d.ts +3 -3
  151. package/dist/types/src/serializer/decorators/associations/shared.d.ts +2 -1
  152. package/dist/types/src/serializer/decorators/attribute.d.ts +1 -1
  153. package/dist/types/src/serializer/decorators/helpers/dreamAttributeOpenapiShape.d.ts +2 -2
  154. package/dist/types/src/serializer/decorators/helpers/hasSerializersGetter.d.ts +1 -1
  155. package/dist/types/src/serializer/decorators/helpers/maybeSerializableToDreamSerializerCallbackFunction.d.ts +1 -1
  156. package/dist/types/src/types/associations/belongsTo.d.ts +76 -0
  157. package/dist/types/src/types/associations/hasMany.d.ts +80 -0
  158. package/dist/types/src/types/associations/hasOne.d.ts +26 -0
  159. package/dist/types/src/types/associations/shared.d.ts +453 -0
  160. package/dist/types/src/types/db.d.ts +14 -0
  161. package/dist/types/src/types/dream.d.ts +527 -0
  162. package/dist/types/src/types/lifecycle.d.ts +50 -0
  163. package/dist/types/src/types/logger.d.ts +42 -0
  164. package/dist/types/src/types/openapi.d.ts +243 -0
  165. package/dist/types/src/types/query.d.ts +127 -0
  166. package/dist/types/src/types/utils.d.ts +173 -0
  167. package/dist/types/src/types/validation.d.ts +20 -0
  168. package/dist/types/src/types/variadic.d.ts +447 -0
  169. package/docs/assets/navigation.js +1 -1
  170. package/docs/assets/search.js +1 -1
  171. package/docs/classes/Benchmark.html +2 -2
  172. package/docs/classes/CalendarDate.html +2 -2
  173. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
  174. package/docs/classes/Decorators.html +38 -38
  175. package/docs/classes/Dream.html +140 -139
  176. package/docs/classes/DreamApplication.html +4 -4
  177. package/docs/classes/DreamBin.html +2 -2
  178. package/docs/classes/DreamCLI.html +4 -4
  179. package/docs/classes/DreamDbConnection.html +2 -2
  180. package/docs/classes/DreamGlam.html +2 -2
  181. package/docs/classes/DreamImporter.html +2 -2
  182. package/docs/classes/DreamMigrationHelpers.html +7 -7
  183. package/docs/classes/DreamSerializer.html +2 -2
  184. package/docs/classes/DreamTransaction.html +2 -2
  185. package/docs/classes/Encrypt.html +2 -2
  186. package/docs/classes/Env.html +2 -2
  187. package/docs/classes/GlobalNameNotSet.html +3 -3
  188. package/docs/classes/NonLoadedAssociation.html +3 -3
  189. package/docs/classes/Query.html +51 -51
  190. package/docs/classes/Range.html +2 -2
  191. package/docs/classes/RecordNotFound.html +3 -3
  192. package/docs/classes/ValidationError.html +3 -3
  193. package/docs/functions/Attribute.html +1 -1
  194. package/docs/functions/RendersMany.html +2 -2
  195. package/docs/functions/RendersOne.html +2 -2
  196. package/docs/functions/ReplicaSafe.html +1 -1
  197. package/docs/functions/STI.html +1 -1
  198. package/docs/functions/SoftDelete.html +1 -1
  199. package/docs/functions/camelize.html +1 -1
  200. package/docs/functions/capitalize.html +1 -1
  201. package/docs/functions/closeAllDbConnections.html +1 -1
  202. package/docs/functions/compact.html +1 -1
  203. package/docs/functions/db.html +1 -1
  204. package/docs/functions/debug.html +1 -1
  205. package/docs/functions/dreamDbConnections.html +1 -1
  206. package/docs/functions/dreamPath.html +1 -1
  207. package/docs/functions/generateDream.html +1 -1
  208. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  209. package/docs/functions/hyphenize.html +1 -1
  210. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
  211. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  212. package/docs/functions/isEmpty.html +1 -1
  213. package/docs/functions/loadRepl.html +1 -1
  214. package/docs/functions/lookupClassByGlobalName.html +1 -1
  215. package/docs/functions/pascalize.html +1 -1
  216. package/docs/functions/pgErrorType.html +1 -1
  217. package/docs/functions/range-1.html +1 -1
  218. package/docs/functions/relativeDreamPath.html +1 -1
  219. package/docs/functions/round.html +1 -1
  220. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  221. package/docs/functions/sharedPathPrefix.html +1 -1
  222. package/docs/functions/snakeify.html +1 -1
  223. package/docs/functions/sort.html +6 -0
  224. package/docs/functions/sortBy.html +6 -1
  225. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  226. package/docs/functions/uncapitalize.html +1 -1
  227. package/docs/functions/uniq.html +1 -1
  228. package/docs/functions/validateColumn.html +1 -1
  229. package/docs/functions/validateTable.html +1 -1
  230. package/docs/index.html +5 -5
  231. package/docs/interfaces/AttributeStatement.html +2 -2
  232. package/docs/interfaces/DecoratorContext.html +2 -2
  233. package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
  234. package/docs/interfaces/DreamApplicationOpts.html +2 -2
  235. package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
  236. package/docs/interfaces/EncryptOptions.html +2 -2
  237. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  238. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  239. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  240. package/docs/modules.html +1 -0
  241. package/docs/types/Camelized.html +1 -1
  242. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  243. package/docs/types/DateTime.html +1 -1
  244. package/docs/types/DreamAssociationMetadata.html +1 -1
  245. package/docs/types/DreamAttributes.html +1 -1
  246. package/docs/types/DreamClassColumn.html +1 -1
  247. package/docs/types/DreamColumn.html +1 -1
  248. package/docs/types/DreamColumnNames.html +1 -1
  249. package/docs/types/DreamLogLevel.html +1 -1
  250. package/docs/types/DreamLogger.html +1 -1
  251. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  252. package/docs/types/DreamParamSafeAttributes.html +1 -1
  253. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  254. package/docs/types/DreamSerializerKey.html +1 -1
  255. package/docs/types/DreamSerializers.html +1 -1
  256. package/docs/types/DreamTableSchema.html +1 -1
  257. package/docs/types/DreamVirtualColumns.html +1 -1
  258. package/docs/types/EncryptAlgorithm.html +1 -1
  259. package/docs/types/Hyphenized.html +1 -1
  260. package/docs/types/IdType.html +1 -1
  261. package/docs/types/OpenapiAllTypes.html +1 -1
  262. package/docs/types/OpenapiFormats.html +1 -1
  263. package/docs/types/OpenapiNumberFormats.html +1 -1
  264. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  265. package/docs/types/OpenapiSchemaArray.html +1 -1
  266. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  267. package/docs/types/OpenapiSchemaBase.html +1 -1
  268. package/docs/types/OpenapiSchemaBody.html +1 -1
  269. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  270. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  271. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  272. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  273. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  274. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  275. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  276. package/docs/types/OpenapiSchemaInteger.html +1 -1
  277. package/docs/types/OpenapiSchemaNull.html +1 -1
  278. package/docs/types/OpenapiSchemaNumber.html +1 -1
  279. package/docs/types/OpenapiSchemaObject.html +1 -1
  280. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  281. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  282. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  283. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  284. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  285. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  286. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  287. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  288. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  289. package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
  290. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  291. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  292. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  293. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  294. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  295. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  296. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  297. package/docs/types/OpenapiSchemaString.html +1 -1
  298. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  299. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  300. package/docs/types/OpenapiTypeField.html +1 -1
  301. package/docs/types/Pascalized.html +1 -1
  302. package/docs/types/PrimaryKeyType.html +1 -1
  303. package/docs/types/RoundingPrecision.html +1 -1
  304. package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
  305. package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
  306. package/docs/types/SerializableDreamOrViewModel.html +1 -1
  307. package/docs/types/SerializableTypes.html +1 -1
  308. package/docs/types/Snakeified.html +1 -1
  309. package/docs/types/Timestamp.html +1 -1
  310. package/docs/types/UpdateableAssociationProperties.html +1 -1
  311. package/docs/types/UpdateableProperties.html +1 -1
  312. package/docs/types/ValidationType.html +1 -1
  313. package/docs/types/ViewModelSerializerKey.html +1 -1
  314. package/docs/types/WhereStatementForDream.html +1 -1
  315. package/docs/types/WhereStatementForDreamClass.html +1 -1
  316. package/docs/variables/DateTime-1.html +1 -1
  317. package/docs/variables/DreamConst.html +1 -1
  318. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  319. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  320. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  321. package/docs/variables/ops.html +1 -1
  322. package/docs/variables/primaryKeyTypes.html +1 -1
  323. package/package.json +2 -3
  324. package/dist/cjs/src/cli/logger/helpers/createSpinner.js +0 -14
  325. package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableSpinner.js +0 -31
  326. package/dist/cjs/src/cli/logger/loggable/spinners.js +0 -1185
  327. package/dist/cjs/src/db/reflections.js +0 -2
  328. package/dist/cjs/src/db/types.js +0 -2
  329. package/dist/cjs/src/decorators/field/validation/shared.js +0 -2
  330. package/dist/cjs/src/dream/types.js +0 -98
  331. package/dist/cjs/src/helpers/typeutils.js +0 -2
  332. package/dist/esm/src/cli/logger/helpers/createSpinner.js +0 -11
  333. package/dist/esm/src/cli/logger/loggable/DreamCliLoggableSpinner.js +0 -28
  334. package/dist/esm/src/cli/logger/loggable/spinners.js +0 -1183
  335. package/dist/esm/src/db/reflections.js +0 -1
  336. package/dist/esm/src/db/types.js +0 -1
  337. package/dist/esm/src/decorators/field/validation/shared.js +0 -1
  338. package/dist/esm/src/dream/types.js +0 -95
  339. package/dist/esm/src/helpers/typeutils.js +0 -1
  340. package/dist/types/src/cli/logger/helpers/createSpinner.d.ts +0 -2
  341. package/dist/types/src/cli/logger/loggable/DreamCliLoggableSpinner.d.ts +0 -21
  342. package/dist/types/src/cli/logger/loggable/spinners.d.ts +0 -355
  343. package/dist/types/src/db/reflections.d.ts +0 -5
  344. package/dist/types/src/db/types.d.ts +0 -1
  345. package/dist/types/src/decorators/field/validation/shared.d.ts +0 -19
  346. package/dist/types/src/dream/types.d.ts +0 -184
  347. package/dist/types/src/helpers/typeutils.d.ts +0 -115
  348. package/dist/types/src/openapi/types.d.ts +0 -139
@@ -27,13 +27,13 @@ export default class Decorators {
27
27
  *
28
28
  * ```ts
29
29
  * class UserSettings extends ApplicationModel {
30
- * @Deco.BelongsTo('User')
30
+ * @deco.BelongsTo('User')
31
31
  * public user: User
32
32
  * public userId: DreamColumn<UserSettings, 'userId'>
33
33
  * }
34
34
  *
35
35
  * class User extends ApplicationModel {
36
- * @Deco.HasOne('UserSettings')
36
+ * @deco.HasOne('UserSettings')
37
37
  * public userSettings: UserSettings
38
38
  * }
39
39
  * ```
@@ -55,12 +55,12 @@ export default class Decorators {
55
55
  *
56
56
  * ```ts
57
57
  * class User extends ApplicationModel {
58
- * @Deco.HasMany('Post')
58
+ * @deco.HasMany('Post')
59
59
  * public posts: Post[]
60
60
  * }
61
61
  *
62
62
  * class Post extends ApplicationModel {
63
- * @Deco.BelongsTo('User')
63
+ * @deco.BelongsTo('User')
64
64
  * public user: User
65
65
  * public userId: DreamColumn<Post, 'userId'>
66
66
  * }
@@ -80,12 +80,12 @@ export default class Decorators {
80
80
  *
81
81
  * ```ts
82
82
  * class User extends ApplicationModel {
83
- * @Deco.HasOne('UserSettings')
83
+ * @deco.HasOne('UserSettings')
84
84
  * public userSettings: UserSettings
85
85
  * }
86
86
  *
87
87
  * class UserSettings extends ApplicationModel {
88
- * @Deco.BelongsTo('User')
88
+ * @deco.BelongsTo('User')
89
89
  * public user: User
90
90
  * public userId: DreamColumn<UserSettings, 'userId'>
91
91
  * }
@@ -108,14 +108,14 @@ export default class Decorators {
108
108
  *
109
109
  * ```ts
110
110
  * class User {
111
- * @Deco.Encrypted()
111
+ * @deco.Encrypted()
112
112
  * // automatically sets `encryptedSsn` to the encrypted value that
113
113
  * // `ssn` is set to in new/create/update, e.g., `await user.update({ ssn })`
114
114
  * public ssn: string
115
115
  *
116
116
  * // automatically sets `myEncryptedPhone` to the encrypted value that
117
117
  * // `phone` is set to new/create/update, e.g., `await user.update({ phone })`
118
- * @Deco.Encrypted('myEncryptedPhone)
118
+ * @deco.Encrypted('myEncryptedPhone)
119
119
  * public phone: string
120
120
  * }
121
121
  * ```
@@ -132,7 +132,7 @@ export default class Decorators {
132
132
  *
133
133
  * ```ts
134
134
  * class Collar {
135
- * @Deco.Scope({ default: true })
135
+ * @deco.Scope({ default: true })
136
136
  * public static hideHiddenCollars(query: Query<Collar>) {
137
137
  * return query.where({ hidden: false })
138
138
  * }
@@ -154,7 +154,7 @@ export default class Decorators {
154
154
  *
155
155
  * ```ts
156
156
  * class Balloon {
157
- * @Deco.Sortable({ scope: 'user' })
157
+ * @deco.Sortable({ scope: 'user' })
158
158
  * public position: DreamColumn<Balloon, 'position'>
159
159
  * }
160
160
  * ```
@@ -172,7 +172,7 @@ export default class Decorators {
172
172
  *
173
173
  * ```ts
174
174
  * class Sandbag {
175
- * @Deco.Validate()
175
+ * @deco.Validate()
176
176
  * public validateWeight(this: Sandbag) {
177
177
  * if (!this.weight) return
178
178
  *
@@ -197,7 +197,7 @@ export default class Decorators {
197
197
  *
198
198
  * ```ts
199
199
  * class Balloon {
200
- * @Deco.Validates('numericality', { min: 0, max: 100 })
200
+ * @deco.Validates('numericality', { min: 0, max: 100 })
201
201
  * public volume: DreamColumn<Balloon, 'volume'>
202
202
  * }
203
203
  * ```
@@ -231,7 +231,7 @@ export default class Decorators {
231
231
  *
232
232
  * ```ts
233
233
  * class BodyMeasurement {
234
- * @Deco.Virtual()
234
+ * @deco.Virtual()
235
235
  * public get lbs() {
236
236
  * const self: User = this
237
237
  * return gramsToLbs(self.getAttribute('grams') ?? 0)
@@ -242,7 +242,7 @@ export default class Decorators {
242
242
  * self.setAttribute('grams', lbsToGrams(lbs))
243
243
  * }
244
244
  *
245
- * @Deco.Virtual()
245
+ * @deco.Virtual()
246
246
  * public get kilograms() {
247
247
  * const self: User = this
248
248
  * return gramsToKilograms(self.getAttribute('grams') ?? 0)
@@ -258,10 +258,10 @@ export default class Decorators {
258
258
  *
259
259
  * ```ts
260
260
  * class User {
261
- * @Deco.Virtual()
261
+ * @deco.Virtual()
262
262
  * public password: string
263
263
  *
264
- * @Deco.BeforeSave()
264
+ * @deco.BeforeSave()
265
265
  * public hasPassword() {
266
266
  * this.setAttribute('hashedPassword', preferredHashingAlgorithm(this.password))
267
267
  * }
@@ -278,7 +278,7 @@ export default class Decorators {
278
278
  *
279
279
  * ```ts
280
280
  * class User {
281
- * @Deco.BeforeCreate()
281
+ * @deco.BeforeCreate()
282
282
  * public doSomething() {
283
283
  * console.log('hi!')
284
284
  * }
@@ -296,7 +296,7 @@ export default class Decorators {
296
296
  *
297
297
  * ```ts
298
298
  * class User {
299
- * @Deco.BeforeSave()
299
+ * @deco.BeforeSave()
300
300
  * public doSomething() {
301
301
  * console.log('hi!')
302
302
  * }
@@ -314,7 +314,7 @@ export default class Decorators {
314
314
  *
315
315
  * ```ts
316
316
  * class User {
317
- * @Deco.BeforeUpdate()
317
+ * @deco.BeforeUpdate()
318
318
  * public doSomething() {
319
319
  * console.log('hi!')
320
320
  * }
@@ -332,7 +332,7 @@ export default class Decorators {
332
332
  *
333
333
  * ```ts
334
334
  * class User {
335
- * @Deco.BeforeDestroy()
335
+ * @deco.BeforeDestroy()
336
336
  * public doSomething() {
337
337
  * console.log('hi!')
338
338
  * }
@@ -349,7 +349,7 @@ export default class Decorators {
349
349
  *
350
350
  * ```ts
351
351
  * class User {
352
- * @Deco.AfterCreate()
352
+ * @deco.AfterCreate()
353
353
  * public doSomething() {
354
354
  * console.log('hi!')
355
355
  * }
@@ -367,7 +367,7 @@ export default class Decorators {
367
367
  *
368
368
  * ```ts
369
369
  * class User {
370
- * @Deco.AfterCreateCommit()
370
+ * @deco.AfterCreateCommit()
371
371
  * public doSomething() {
372
372
  * console.log('hi!')
373
373
  * }
@@ -384,7 +384,7 @@ export default class Decorators {
384
384
  *
385
385
  * ```ts
386
386
  * class User {
387
- * @Deco.AfterSave()
387
+ * @deco.AfterSave()
388
388
  * public doSomething() {
389
389
  * console.log('hi!')
390
390
  * }
@@ -402,7 +402,7 @@ export default class Decorators {
402
402
  *
403
403
  * ```ts
404
404
  * class User {
405
- * @Deco.AfterSaveCommit()
405
+ * @deco.AfterSaveCommit()
406
406
  * public doSomething() {
407
407
  * console.log('hi!')
408
408
  * }
@@ -420,7 +420,7 @@ export default class Decorators {
420
420
  *
421
421
  * ```ts
422
422
  * class User {
423
- * @Deco.AfterUpdate()
423
+ * @deco.AfterUpdate()
424
424
  * public doSomething() {
425
425
  * console.log('hi!')
426
426
  * }
@@ -438,7 +438,7 @@ export default class Decorators {
438
438
  *
439
439
  * ```ts
440
440
  * class User {
441
- * @Deco.AfterUpdateCommit()
441
+ * @deco.AfterUpdateCommit()
442
442
  * public doSomething() {
443
443
  * console.log('hi!')
444
444
  * }
@@ -456,7 +456,7 @@ export default class Decorators {
456
456
  *
457
457
  * ```ts
458
458
  * class User {
459
- * @Deco.AfterDestroy()
459
+ * @deco.AfterDestroy()
460
460
  * public doSomething() {
461
461
  * console.log('hi!')
462
462
  * }
@@ -474,7 +474,7 @@ export default class Decorators {
474
474
  *
475
475
  * ```ts
476
476
  * class User {
477
- * @Deco.AfterDestroyCommit()
477
+ * @deco.AfterDestroyCommit()
478
478
  * public doSomething() {
479
479
  * console.log('hi!')
480
480
  * }
@@ -8,13 +8,13 @@ import { applyGetterAndSetter, associationPrimaryKeyAccessors, blankAssociations
8
8
  *
9
9
  * ```ts
10
10
  * class UserSettings extends ApplicationModel {
11
- * @Deco.BelongsTo('User')
11
+ * @deco.BelongsTo('User')
12
12
  * public user: User
13
13
  * public userId: DreamColumn<UserSettings, 'userId'>
14
14
  * }
15
15
  *
16
16
  * class User extends ApplicationModel {
17
- * @Deco.HasOne('UserSettings')
17
+ * @deco.HasOne('UserSettings')
18
18
  * public userSettings: UserSettings
19
19
  * }
20
20
  * ```
@@ -7,12 +7,12 @@ import { applyGetterAndSetter, associationPrimaryKeyAccessors, blankAssociations
7
7
  *
8
8
  * ```ts
9
9
  * class User extends ApplicationModel {
10
- * @Deco.HasMany('Post')
10
+ * @deco.HasMany('Post')
11
11
  * public posts: Post[]
12
12
  * }
13
13
  *
14
14
  * class Post extends ApplicationModel {
15
- * @Deco.BelongsTo('User')
15
+ * @deco.BelongsTo('User')
16
16
  * public user: User
17
17
  * public userId: DreamColumn<Post, 'userId'>
18
18
  * }
@@ -7,12 +7,12 @@ import { applyGetterAndSetter, associationPrimaryKeyAccessors, blankAssociations
7
7
  *
8
8
  * ```ts
9
9
  * class User extends ApplicationModel {
10
- * @Deco.HasOne('UserSettings')
10
+ * @deco.HasOne('UserSettings')
11
11
  * public userSettings: UserSettings
12
12
  * }
13
13
  *
14
14
  * class UserSettings extends ApplicationModel {
15
- * @Deco.BelongsTo('User')
15
+ * @deco.BelongsTo('User')
16
16
  * public user: User
17
17
  * public userId: DreamColumn<UserSettings, 'userId'>
18
18
  * }
@@ -1,5 +1,5 @@
1
1
  import pluralize from 'pluralize-esm';
2
- import { DreamConst, } from '../../../dream/types.js';
2
+ import { DreamConst } from '../../../dream/constants.js';
3
3
  import { checkForeignKey } from '../../../errors/associations/InvalidComputedForeignKey.js';
4
4
  import NonLoadedAssociation from '../../../errors/associations/NonLoadedAssociation.js';
5
5
  import CannotDefineAssociationWithBothDependentAndPassthrough from '../../../errors/CannotDefineAssociationWithBothDependentAndPassthrough.js';
@@ -21,6 +21,11 @@ export function blankAssociationsFactory(dreamClass, { freeze = false, } = {}) {
21
21
  return freezeBaseClassArrayMap(associationsMap);
22
22
  return associationsMap;
23
23
  }
24
+ // function hydratedSourceValue(dream: Dream | typeof Dream | undefined, sourceName: string) {
25
+ // if (!dream) return
26
+ // if (!sourceName) return
27
+ // return (dream as any)[sourceName] || (dream as any)[singular(sourceName)]
28
+ // }
24
29
  export function finalForeignKey(foreignKey, dreamClass, partialAssociation) {
25
30
  let computedForeignKey = foreignKey;
26
31
  if (!computedForeignKey) {
@@ -116,8 +121,3 @@ export function validateHasStatementArgs({ dreamClass, dependent, methodName, on
116
121
  if (dependent && hasRequiredOn)
117
122
  throw new CannotDefineAssociationWithBothDependentAndRequiredOnClause(dreamClass, methodName);
118
123
  }
119
- // function hydratedSourceValue(dream: Dream | typeof Dream | undefined, sourceName: string) {
120
- // if (!dream) return
121
- // if (!sourceName) return
122
- // return (dream as any)[sourceName] || (dream as any)[singular(sourceName)]
123
- // }
@@ -8,7 +8,7 @@ import { blankHooksFactory } from './shared.js';
8
8
  * is complete.
9
9
  *
10
10
  * class User extends ApplicationModel {
11
- * @Deco.AfterCreateCommit()
11
+ * @deco.AfterCreateCommit()
12
12
  * public doSomething() {
13
13
  * ...
14
14
  * }
@@ -8,7 +8,7 @@ import { blankHooksFactory } from './shared.js';
8
8
  * is complete.
9
9
  *
10
10
  * class User extends ApplicationModel {
11
- * @Deco.AfterDestroyCommit()
11
+ * @deco.AfterDestroyCommit()
12
12
  * public doSomething() {
13
13
  * ...
14
14
  * }
@@ -8,7 +8,7 @@ import { blankHooksFactory } from './shared.js';
8
8
  * is complete.
9
9
  *
10
10
  * class User extends ApplicationModel {
11
- * @Deco.AfterSaveCommit()
11
+ * @deco.AfterSaveCommit()
12
12
  * public doSomething() {
13
13
  * ...
14
14
  * }
@@ -8,7 +8,7 @@ import { blankHooksFactory } from './shared.js';
8
8
  * is complete.
9
9
  *
10
10
  * class User extends ApplicationModel {
11
- * @Deco.AfterUpdateCommit()
11
+ * @deco.AfterUpdateCommit()
12
12
  * public doSomething() {
13
13
  * ...
14
14
  * }
@@ -51,7 +51,7 @@ function extractValidationOptionsFromArgs(type, args) {
51
51
  When validating using "length", the second argument must be a number representing
52
52
  the min length, or else an object expressing both min and max length, like so:
53
53
 
54
- @Deco.Validates('length', { min: 4, max: 32 })
54
+ @deco.Validates('length', { min: 4, max: 32 })
55
55
  `);
56
56
  }
57
57
  case 'requiredBelongsTo':
@@ -513,10 +513,10 @@ export default class DreamClassTransactionBuilder {
513
513
  *
514
514
  * ```ts
515
515
  * class Post {
516
- * @Deco.HasMany('LocalizedText')
516
+ * @deco.HasMany('LocalizedText')
517
517
  * public localizedTexts: LocalizedText[]
518
518
  *
519
- * @Deco.HasOne('LocalizedText', {
519
+ * @deco.HasOne('LocalizedText', {
520
520
  * where: { locale: DreamConst.passthrough },
521
521
  * })
522
522
  * public currentLocalizedText: LocalizedText
@@ -35,13 +35,13 @@ import uniq from '../helpers/uniq.js';
35
35
  import CurriedOpsStatement from '../ops/curried-ops-statement.js';
36
36
  import ops from '../ops/index.js';
37
37
  import OpsStatement from '../ops/ops-statement.js';
38
+ import { DreamConst } from './constants.js';
38
39
  import executeDatabaseQuery from './internal/executeDatabaseQuery.js';
39
40
  import extractAssociationMetadataFromAssociationName from './internal/extractAssociationMetadataFromAssociationName.js';
40
41
  import orderByDirection from './internal/orderByDirection.js';
41
42
  import shouldBypassDefaultScope from './internal/shouldBypassDefaultScope.js';
42
43
  import SimilarityBuilder from './internal/similarity/SimilarityBuilder.js';
43
44
  import sqlResultToDreamInstance from './internal/sqlResultToDreamInstance.js';
44
- import { DreamConst, } from './types.js';
45
45
  export default class Query extends ConnectedToDB {
46
46
  /**
47
47
  * @internal
@@ -761,10 +761,10 @@ export default class Query extends ConnectedToDB {
761
761
  *
762
762
  * ```ts
763
763
  * class Post {
764
- * @Deco.HasMany('LocalizedText')
764
+ * @deco.HasMany('LocalizedText')
765
765
  * public localizedTexts: LocalizedText[]
766
766
  *
767
- * @Deco.HasOne('LocalizedText', {
767
+ * @deco.HasOne('LocalizedText', {
768
768
  * on: { locale: DreamConst.passthrough },
769
769
  * })
770
770
  * public currentLocalizedText: LocalizedText
@@ -1,3 +1,15 @@
1
+ export const primaryKeyTypes = ['bigserial', 'bigint', 'uuid', 'integer'];
2
+ export const TRIGRAM_OPERATORS = ['%', '<%', '<<%'];
3
+ class RequiredAttribute {
4
+ constructor() { }
5
+ }
6
+ class PassthroughAttribute {
7
+ constructor() { }
8
+ }
9
+ export const DreamConst = {
10
+ passthrough: PassthroughAttribute,
11
+ required: RequiredAttribute,
12
+ };
1
13
  export const openapiPrimitiveTypes = [
2
14
  'string',
3
15
  'boolean',
@@ -5,7 +5,7 @@ import validateTable from '../../../db/validators/validateTable.js';
5
5
  import validateTableAlias from '../../../db/validators/validateTableAlias.js';
6
6
  import namespaceColumn from '../../../helpers/namespaceColumn.js';
7
7
  import { isObject } from '../../../helpers/typechecks.js';
8
- import { TRIGRAM_OPERATORS, } from '../../types.js';
8
+ import { TRIGRAM_OPERATORS } from '../../constants.js';
9
9
  import similaritySelectSql from './similaritySelectSql.js';
10
10
  import similarityWhereSql from './similarityWhereSql.js';
11
11
  export default class SimilarityBuilder extends ConnectedToDB {
@@ -1,4 +1,4 @@
1
- import { modelCBtoSingleDreamClass, } from '../../decorators/field/association/shared.js';
1
+ import { modelCBtoSingleDreamClass } from '../../decorators/field/association/shared.js';
2
2
  export class InvalidComputedForeignKey extends Error {
3
3
  dreamClass;
4
4
  partialAssociation;
@@ -4,7 +4,7 @@ import * as path from 'path';
4
4
  import { isPrimitiveDataType } from '../../db/dataTypes.js';
5
5
  import _db from '../../db/index.js';
6
6
  import DreamApplication from '../../dream-application/index.js';
7
- import { DreamConst } from '../../dream/types.js';
7
+ import { DreamConst } from '../../dream/constants.js';
8
8
  import FailedToIdentifyAssociation from '../../errors/schema-builder/FailedToIdentifyAssociation.js';
9
9
  import autogeneratedFileDisclaimer from '../../global-cli/helpers/autogeneratedFileMessage.js';
10
10
  import camelize from '../camelize.js';
@@ -23,8 +23,8 @@ import {
23
23
  } from './db.js'`
24
24
  : '';
25
25
  const calendarDateImportStatement = EnvInternal.boolean('DREAM_CORE_DEVELOPMENT')
26
- ? "import CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { DateTime } from '../../src/helpers/DateTime.js'"
27
- : "import { CalendarDate, DateTime } from '@rvoh/dream'";
26
+ ? "import type CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { type DateTime } from '../../src/helpers/DateTime.js'"
27
+ : "import { type CalendarDate, type DateTime } from '@rvoh/dream'";
28
28
  const dreamApp = DreamApplication.getOrFail();
29
29
  const newSchemaFileContents = `\
30
30
  ${autogeneratedFileDisclaimer()}
@@ -36,7 +36,7 @@ export default async function generateDream({ fullyQualifiedModelName, columnsWi
36
36
  const isSTI = !!fullyQualifiedParentName;
37
37
  if (columnsWithTypes.length || !isSTI) {
38
38
  await generateMigration({
39
- migrationName: fullyQualifiedModelName,
39
+ migrationName: `Create${fullyQualifiedModelName}`,
40
40
  columnsWithTypes,
41
41
  fullyQualifiedModelName,
42
42
  fullyQualifiedParentName,
@@ -35,7 +35,7 @@ export default function generateDreamContent({ fullyQualifiedModelName, columnsW
35
35
  case 'belongs_to':
36
36
  modelImportStatements.push(associationImportStatement);
37
37
  return `
38
- @Deco.BelongsTo('${fullyQualifiedAssociatedModelName}'${descriptors.includes('optional') ? ', { optional: true }' : ''})
38
+ @deco.BelongsTo('${fullyQualifiedAssociatedModelName}'${descriptors.includes('optional') ? ', { optional: true }' : ''})
39
39
  public ${associationName}: ${associationModelName}${descriptors.includes('optional') ? ' | null' : ''}
40
40
  public ${associationName}Id: DreamColumn<${modelClassName}, '${associationName}Id'>
41
41
  `;
@@ -73,7 +73,7 @@ public ${camelize(attributeName)}: ${getAttributeType(attribute, modelClassName)
73
73
  return `\
74
74
  import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'${uniq(modelImportStatements).join('')}
75
75
 
76
- const Deco = new Decorators<InstanceType<typeof ${modelClassName}>>()
76
+ const deco = new Decorators<InstanceType<typeof ${modelClassName}>>()
77
77
 
78
78
  ${isSTI ? `\n@STI(${parentModelClassName})` : ''}
79
79
  export default class ${modelClassName} extends ${isSTI ? parentModelClassName : 'ApplicationModel'} {
@@ -1,5 +1,5 @@
1
1
  import DreamApplication from '../../dream-application/index.js';
2
- import { primaryKeyTypes } from '../../dream/types.js';
2
+ import { primaryKeyTypes } from '../../dream/constants.js';
3
3
  export default function primaryKeyType() {
4
4
  const dreamconf = DreamApplication.getOrFail();
5
5
  switch (dreamconf.primaryKeyType) {
@@ -86,14 +86,14 @@ function migratedActionPastTense(mode) {
86
86
  function logResults(results, mode) {
87
87
  results?.forEach(it => {
88
88
  if (it.status === 'Success') {
89
- DreamCLI.logger.log(colorize(`[db]`, { color: 'cyan' }) +
90
- ` migration "${it.migrationName}" was ${migratedActionPastTense(mode)} successfully`, { permanent: true, logPrefix: '├', logPrefixColor: 'cyan' });
89
+ DreamCLI.logger.logContinueProgress(colorize(`[db]`, { color: 'cyan' }) +
90
+ ` migration "${it.migrationName}" was ${migratedActionPastTense(mode)} successfully`, { logPrefixColor: 'cyan' });
91
91
  }
92
92
  else if (it.status === 'Error') {
93
- DreamCLI.logger.log(JSON.stringify(it, null, 2), { permanent: true });
94
- DreamCLI.logger.log(colorize(`failed to ${migratedActionCurrentTense(mode)} migration "${it.migrationName}"`, {
93
+ DreamCLI.logger.logContinueProgress(JSON.stringify(it, null, 2));
94
+ DreamCLI.logger.logContinueProgress(colorize(`failed to ${migratedActionCurrentTense(mode)} migration "${it.migrationName}"`, {
95
95
  color: 'redBright',
96
- }), { permanent: true });
96
+ }));
97
97
  }
98
98
  });
99
99
  }
@@ -1,5 +1,7 @@
1
1
  export default function isEmpty(value) {
2
2
  if (Array.isArray(value))
3
3
  return value.length === 0;
4
+ if (value instanceof Map || value instanceof Set)
5
+ return value.size === 0;
4
6
  return Object.keys(value).length === 0;
5
7
  }
@@ -0,0 +1,21 @@
1
+ import sortBy from './sortBy.js';
2
+ /**
3
+ * Returns a copy of array containing strings, numbers, bigints, and/or IdTypes, sorted in ascending order.
4
+ * To sort other types use {@link sortBy}.
5
+ *
6
+ * ```ts
7
+ * import { sort } from '@rvoh/dream'
8
+ *
9
+ * sort([2, 1, 3])
10
+ * // [1, 2, 3]
11
+ *
12
+ * sort(['world', 'Hello', 'hello', 'World'])
13
+ * // ['hello', 'Hello', 'world', 'World']
14
+ * ```
15
+ */
16
+ export default function sort(array) {
17
+ if (typeof array[0] === 'bigint') {
18
+ return sortBy(array, a => String(a));
19
+ }
20
+ return sortBy(array, a => a);
21
+ }
@@ -1,3 +1,22 @@
1
+ /**
2
+ * Returns a copy of the array, sorted by the value returned by calling the function in the second argument on each element in the array
3
+ * Returns a copy of the array sorted by the return value of the function passed as the second argument.
4
+ * ```ts
5
+ * import { sortBy } from '@rvoh/dream'
6
+ *
7
+ * sortBy(['aaa', 'a', 'aa'], (str: string) => str.length)
8
+ * // ['a', 'aa', 'aaa']
9
+ *
10
+ * sortBy(['aaa', 'a', 'aa'], (str: string) => -str.length)
11
+ * // ['aaa', 'aa', 'a']
12
+ *
13
+ * sortBy([5, 3, 7], (num: number) => num)
14
+ * // [3, 5, 7]
15
+ *
16
+ * sortBy([5, 3, 7], (num: number) => -num)
17
+ * // [7, 5, 3]
18
+ * ```
19
+ */
1
20
  export default function sortBy(array, valueToCompare) {
2
21
  const arrayClone = [...array];
3
22
  return arrayClone.sort((a, b) => {
@@ -7,8 +26,6 @@ export default function sortBy(array, valueToCompare) {
7
26
  return aPrime.localeCompare(bPrime);
8
27
  if (typeof aPrime === 'number' && typeof bPrime === 'number')
9
28
  return aPrime - bPrime;
10
- if (typeof aPrime === 'bigint' && typeof bPrime === 'bigint')
11
- return aPrime.toString().localeCompare(bPrime.toString());
12
29
  throw new UnsupportedValueFromComparisonFunction(aPrime, bPrime);
13
30
  });
14
31
  }
@@ -3,15 +3,41 @@ export default function sspawn(command, opts = {}) {
3
3
  return new Promise((accept, reject) => {
4
4
  ssspawn(command, opts).on('close', code => {
5
5
  if (code !== 0)
6
- reject(new Error(code?.toString()));
6
+ reject(code);
7
7
  accept({});
8
8
  });
9
9
  });
10
10
  }
11
11
  export function ssspawn(command, opts = {}) {
12
- return spawn(command, {
13
- stdio: 'inherit',
12
+ const proc = spawn(command, {
13
+ // even though github security scans want to remove this,
14
+ // it is necessary to allow the cli util to run as the current
15
+ // user. This is only done to provision a new psychic application,
16
+ // so it is safe from unknown execution contexts.
14
17
  shell: true,
15
18
  ...opts,
16
19
  });
20
+ // NOTE: adding this stdout spy so that
21
+ // when this cli utility runs node commands,
22
+ // it can properly hijack the stdout from the command
23
+ proc.stdout.on('data', chunk => {
24
+ const txt = chunk?.toString()?.trim();
25
+ if (typeof txt !== 'string' || !txt)
26
+ return;
27
+ if (opts?.onStdout) {
28
+ opts?.onStdout?.(txt);
29
+ }
30
+ else {
31
+ console.log(txt);
32
+ }
33
+ });
34
+ proc.stdout.on('error', err => {
35
+ console.log('sspawn error!');
36
+ console.error(err);
37
+ });
38
+ proc.on('error', err => {
39
+ console.log('sspawn error!');
40
+ console.error(err);
41
+ });
42
+ return proc;
17
43
  }
@@ -1,17 +1,18 @@
1
1
  export default function uniq(arr, toKey = undefined) {
2
2
  if (toKey)
3
3
  return uniqWith(arr, toKey);
4
- else if (arr[0]?.isDreamInstance)
5
- return uniqWith(arr, dreamKey);
6
- else
7
- return Array.from(new Set(arr));
4
+ return uniqWith(arr, a => String(a));
8
5
  }
9
6
  function dreamKey(dream) {
10
7
  return `${dream.constructor.globalName}:${dream.primaryKeyValue}`;
11
8
  }
12
9
  function uniqWith(arr, toKey) {
13
10
  const map = arr.reduce((acc, val) => {
14
- acc[toKey(val)] ||= val;
11
+ // Prefix with underscore to ensure that the values cannot be interpreted as integers.
12
+ // If they can be interpreted as integers, then the keys are ordered not by the
13
+ // order in which they were added, but in ascending numerical order.
14
+ const key = val?.isDreamInstance ? dreamKey(val) : `_${toKey(val)}`;
15
+ acc[key] ||= val;
15
16
  return acc;
16
17
  }, {});
17
18
  return Object.values(map);