@rvoh/dream 0.31.1 → 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.
- package/README.md +17 -17
- package/dist/cjs/src/Dream.js +15 -15
- package/dist/cjs/src/bin/helpers/sync.js +9 -2
- package/dist/cjs/src/bin/index.js +18 -19
- package/dist/cjs/src/cli/logger/DreamCliLogger.js +12 -46
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggable.js +1 -3
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableText.js +2 -2
- package/dist/cjs/src/decorators/Decorators.js +28 -28
- package/dist/cjs/src/decorators/field/association/BelongsTo.js +2 -2
- package/dist/cjs/src/decorators/field/association/HasMany.js +2 -2
- package/dist/cjs/src/decorators/field/association/HasOne.js +2 -2
- package/dist/cjs/src/decorators/field/lifecycle/AfterCreateCommit.js +1 -1
- package/dist/cjs/src/decorators/field/lifecycle/AfterDestroyCommit.js +1 -1
- package/dist/cjs/src/decorators/field/lifecycle/AfterSaveCommit.js +1 -1
- package/dist/cjs/src/decorators/field/lifecycle/AfterUpdateCommit.js +1 -1
- package/dist/cjs/src/decorators/field/validation/Validates.js +1 -1
- package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +2 -2
- package/dist/cjs/src/dream/Query.js +2 -2
- package/dist/cjs/src/helpers/cli/generateDreamContent.js +2 -2
- package/dist/cjs/src/helpers/db/runMigration.js +5 -5
- package/dist/cjs/src/helpers/sspawn.js +29 -3
- package/dist/cjs/src/serializer/decorators/associations/RendersMany.js +2 -2
- package/dist/cjs/src/serializer/decorators/associations/RendersOne.js +2 -2
- package/dist/esm/src/Dream.js +15 -15
- package/dist/esm/src/bin/helpers/sync.js +9 -2
- package/dist/esm/src/bin/index.js +18 -19
- package/dist/esm/src/cli/logger/DreamCliLogger.js +12 -46
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggable.js +1 -3
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggableText.js +2 -2
- package/dist/esm/src/decorators/Decorators.js +28 -28
- package/dist/esm/src/decorators/field/association/BelongsTo.js +2 -2
- package/dist/esm/src/decorators/field/association/HasMany.js +2 -2
- package/dist/esm/src/decorators/field/association/HasOne.js +2 -2
- package/dist/esm/src/decorators/field/lifecycle/AfterCreateCommit.js +1 -1
- package/dist/esm/src/decorators/field/lifecycle/AfterDestroyCommit.js +1 -1
- package/dist/esm/src/decorators/field/lifecycle/AfterSaveCommit.js +1 -1
- package/dist/esm/src/decorators/field/lifecycle/AfterUpdateCommit.js +1 -1
- package/dist/esm/src/decorators/field/validation/Validates.js +1 -1
- package/dist/esm/src/dream/DreamClassTransactionBuilder.js +2 -2
- package/dist/esm/src/dream/Query.js +2 -2
- package/dist/esm/src/helpers/cli/generateDreamContent.js +2 -2
- package/dist/esm/src/helpers/db/runMigration.js +5 -5
- package/dist/esm/src/helpers/sspawn.js +29 -3
- package/dist/esm/src/serializer/decorators/associations/RendersMany.js +2 -2
- package/dist/esm/src/serializer/decorators/associations/RendersOne.js +2 -2
- package/dist/types/src/Dream.d.ts +15 -15
- package/dist/types/src/cli/logger/DreamCliLogger.d.ts +4 -8
- package/dist/types/src/cli/logger/loggable/DreamCliLoggable.d.ts +1 -3
- package/dist/types/src/cli/logger/loggable/DreamCliLoggableText.d.ts +1 -2
- package/dist/types/src/decorators/Decorators.d.ts +22 -22
- package/dist/types/src/decorators/field/lifecycle/AfterCreateCommit.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterDestroyCommit.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterSaveCommit.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterUpdateCommit.d.ts +1 -1
- package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +2 -2
- package/dist/types/src/dream/Query.d.ts +2 -2
- package/dist/types/src/helpers/sspawn.d.ts +6 -2
- package/dist/types/src/serializer/decorators/associations/RendersMany.d.ts +2 -2
- package/dist/types/src/serializer/decorators/associations/RendersOne.d.ts +2 -2
- package/dist/types/src/types/logger.d.ts +1 -5
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/Decorators.html +38 -38
- package/docs/classes/Dream.html +138 -138
- package/docs/classes/DreamApplication.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamDbConnection.html +2 -2
- package/docs/classes/DreamGlam.html +2 -2
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializer.html +2 -2
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/Query.html +51 -51
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/Attribute.html +1 -1
- package/docs/functions/RendersMany.html +2 -2
- package/docs/functions/RendersOne.html +2 -2
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/db.html +1 -1
- package/docs/functions/debug.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sort.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/index.html +5 -5
- package/docs/interfaces/AttributeStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
- package/docs/interfaces/DreamApplicationOpts.html +2 -2
- package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
- package/docs/types/SerializableDreamOrViewModel.html +1 -1
- package/docs/types/SerializableTypes.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModelSerializerKey.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +1 -2
- package/dist/cjs/src/cli/logger/helpers/createSpinner.js +0 -14
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableSpinner.js +0 -31
- package/dist/cjs/src/cli/logger/loggable/spinners.js +0 -1185
- package/dist/esm/src/cli/logger/helpers/createSpinner.js +0 -11
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggableSpinner.js +0 -28
- package/dist/esm/src/cli/logger/loggable/spinners.js +0 -1183
- package/dist/types/src/cli/logger/helpers/createSpinner.d.ts +0 -2
- package/dist/types/src/cli/logger/loggable/DreamCliLoggableSpinner.d.ts +0 -21
- package/dist/types/src/cli/logger/loggable/spinners.d.ts +0 -355
|
@@ -29,13 +29,13 @@ class Decorators {
|
|
|
29
29
|
*
|
|
30
30
|
* ```ts
|
|
31
31
|
* class UserSettings extends ApplicationModel {
|
|
32
|
-
* @
|
|
32
|
+
* @deco.BelongsTo('User')
|
|
33
33
|
* public user: User
|
|
34
34
|
* public userId: DreamColumn<UserSettings, 'userId'>
|
|
35
35
|
* }
|
|
36
36
|
*
|
|
37
37
|
* class User extends ApplicationModel {
|
|
38
|
-
* @
|
|
38
|
+
* @deco.HasOne('UserSettings')
|
|
39
39
|
* public userSettings: UserSettings
|
|
40
40
|
* }
|
|
41
41
|
* ```
|
|
@@ -57,12 +57,12 @@ class Decorators {
|
|
|
57
57
|
*
|
|
58
58
|
* ```ts
|
|
59
59
|
* class User extends ApplicationModel {
|
|
60
|
-
* @
|
|
60
|
+
* @deco.HasMany('Post')
|
|
61
61
|
* public posts: Post[]
|
|
62
62
|
* }
|
|
63
63
|
*
|
|
64
64
|
* class Post extends ApplicationModel {
|
|
65
|
-
* @
|
|
65
|
+
* @deco.BelongsTo('User')
|
|
66
66
|
* public user: User
|
|
67
67
|
* public userId: DreamColumn<Post, 'userId'>
|
|
68
68
|
* }
|
|
@@ -82,12 +82,12 @@ class Decorators {
|
|
|
82
82
|
*
|
|
83
83
|
* ```ts
|
|
84
84
|
* class User extends ApplicationModel {
|
|
85
|
-
* @
|
|
85
|
+
* @deco.HasOne('UserSettings')
|
|
86
86
|
* public userSettings: UserSettings
|
|
87
87
|
* }
|
|
88
88
|
*
|
|
89
89
|
* class UserSettings extends ApplicationModel {
|
|
90
|
-
* @
|
|
90
|
+
* @deco.BelongsTo('User')
|
|
91
91
|
* public user: User
|
|
92
92
|
* public userId: DreamColumn<UserSettings, 'userId'>
|
|
93
93
|
* }
|
|
@@ -110,14 +110,14 @@ class Decorators {
|
|
|
110
110
|
*
|
|
111
111
|
* ```ts
|
|
112
112
|
* class User {
|
|
113
|
-
* @
|
|
113
|
+
* @deco.Encrypted()
|
|
114
114
|
* // automatically sets `encryptedSsn` to the encrypted value that
|
|
115
115
|
* // `ssn` is set to in new/create/update, e.g., `await user.update({ ssn })`
|
|
116
116
|
* public ssn: string
|
|
117
117
|
*
|
|
118
118
|
* // automatically sets `myEncryptedPhone` to the encrypted value that
|
|
119
119
|
* // `phone` is set to new/create/update, e.g., `await user.update({ phone })`
|
|
120
|
-
* @
|
|
120
|
+
* @deco.Encrypted('myEncryptedPhone)
|
|
121
121
|
* public phone: string
|
|
122
122
|
* }
|
|
123
123
|
* ```
|
|
@@ -134,7 +134,7 @@ class Decorators {
|
|
|
134
134
|
*
|
|
135
135
|
* ```ts
|
|
136
136
|
* class Collar {
|
|
137
|
-
* @
|
|
137
|
+
* @deco.Scope({ default: true })
|
|
138
138
|
* public static hideHiddenCollars(query: Query<Collar>) {
|
|
139
139
|
* return query.where({ hidden: false })
|
|
140
140
|
* }
|
|
@@ -156,7 +156,7 @@ class Decorators {
|
|
|
156
156
|
*
|
|
157
157
|
* ```ts
|
|
158
158
|
* class Balloon {
|
|
159
|
-
* @
|
|
159
|
+
* @deco.Sortable({ scope: 'user' })
|
|
160
160
|
* public position: DreamColumn<Balloon, 'position'>
|
|
161
161
|
* }
|
|
162
162
|
* ```
|
|
@@ -174,7 +174,7 @@ class Decorators {
|
|
|
174
174
|
*
|
|
175
175
|
* ```ts
|
|
176
176
|
* class Sandbag {
|
|
177
|
-
* @
|
|
177
|
+
* @deco.Validate()
|
|
178
178
|
* public validateWeight(this: Sandbag) {
|
|
179
179
|
* if (!this.weight) return
|
|
180
180
|
*
|
|
@@ -199,7 +199,7 @@ class Decorators {
|
|
|
199
199
|
*
|
|
200
200
|
* ```ts
|
|
201
201
|
* class Balloon {
|
|
202
|
-
* @
|
|
202
|
+
* @deco.Validates('numericality', { min: 0, max: 100 })
|
|
203
203
|
* public volume: DreamColumn<Balloon, 'volume'>
|
|
204
204
|
* }
|
|
205
205
|
* ```
|
|
@@ -233,7 +233,7 @@ class Decorators {
|
|
|
233
233
|
*
|
|
234
234
|
* ```ts
|
|
235
235
|
* class BodyMeasurement {
|
|
236
|
-
* @
|
|
236
|
+
* @deco.Virtual()
|
|
237
237
|
* public get lbs() {
|
|
238
238
|
* const self: User = this
|
|
239
239
|
* return gramsToLbs(self.getAttribute('grams') ?? 0)
|
|
@@ -244,7 +244,7 @@ class Decorators {
|
|
|
244
244
|
* self.setAttribute('grams', lbsToGrams(lbs))
|
|
245
245
|
* }
|
|
246
246
|
*
|
|
247
|
-
* @
|
|
247
|
+
* @deco.Virtual()
|
|
248
248
|
* public get kilograms() {
|
|
249
249
|
* const self: User = this
|
|
250
250
|
* return gramsToKilograms(self.getAttribute('grams') ?? 0)
|
|
@@ -260,10 +260,10 @@ class Decorators {
|
|
|
260
260
|
*
|
|
261
261
|
* ```ts
|
|
262
262
|
* class User {
|
|
263
|
-
* @
|
|
263
|
+
* @deco.Virtual()
|
|
264
264
|
* public password: string
|
|
265
265
|
*
|
|
266
|
-
* @
|
|
266
|
+
* @deco.BeforeSave()
|
|
267
267
|
* public hasPassword() {
|
|
268
268
|
* this.setAttribute('hashedPassword', preferredHashingAlgorithm(this.password))
|
|
269
269
|
* }
|
|
@@ -280,7 +280,7 @@ class Decorators {
|
|
|
280
280
|
*
|
|
281
281
|
* ```ts
|
|
282
282
|
* class User {
|
|
283
|
-
* @
|
|
283
|
+
* @deco.BeforeCreate()
|
|
284
284
|
* public doSomething() {
|
|
285
285
|
* console.log('hi!')
|
|
286
286
|
* }
|
|
@@ -298,7 +298,7 @@ class Decorators {
|
|
|
298
298
|
*
|
|
299
299
|
* ```ts
|
|
300
300
|
* class User {
|
|
301
|
-
* @
|
|
301
|
+
* @deco.BeforeSave()
|
|
302
302
|
* public doSomething() {
|
|
303
303
|
* console.log('hi!')
|
|
304
304
|
* }
|
|
@@ -316,7 +316,7 @@ class Decorators {
|
|
|
316
316
|
*
|
|
317
317
|
* ```ts
|
|
318
318
|
* class User {
|
|
319
|
-
* @
|
|
319
|
+
* @deco.BeforeUpdate()
|
|
320
320
|
* public doSomething() {
|
|
321
321
|
* console.log('hi!')
|
|
322
322
|
* }
|
|
@@ -334,7 +334,7 @@ class Decorators {
|
|
|
334
334
|
*
|
|
335
335
|
* ```ts
|
|
336
336
|
* class User {
|
|
337
|
-
* @
|
|
337
|
+
* @deco.BeforeDestroy()
|
|
338
338
|
* public doSomething() {
|
|
339
339
|
* console.log('hi!')
|
|
340
340
|
* }
|
|
@@ -351,7 +351,7 @@ class Decorators {
|
|
|
351
351
|
*
|
|
352
352
|
* ```ts
|
|
353
353
|
* class User {
|
|
354
|
-
* @
|
|
354
|
+
* @deco.AfterCreate()
|
|
355
355
|
* public doSomething() {
|
|
356
356
|
* console.log('hi!')
|
|
357
357
|
* }
|
|
@@ -369,7 +369,7 @@ class Decorators {
|
|
|
369
369
|
*
|
|
370
370
|
* ```ts
|
|
371
371
|
* class User {
|
|
372
|
-
* @
|
|
372
|
+
* @deco.AfterCreateCommit()
|
|
373
373
|
* public doSomething() {
|
|
374
374
|
* console.log('hi!')
|
|
375
375
|
* }
|
|
@@ -386,7 +386,7 @@ class Decorators {
|
|
|
386
386
|
*
|
|
387
387
|
* ```ts
|
|
388
388
|
* class User {
|
|
389
|
-
* @
|
|
389
|
+
* @deco.AfterSave()
|
|
390
390
|
* public doSomething() {
|
|
391
391
|
* console.log('hi!')
|
|
392
392
|
* }
|
|
@@ -404,7 +404,7 @@ class Decorators {
|
|
|
404
404
|
*
|
|
405
405
|
* ```ts
|
|
406
406
|
* class User {
|
|
407
|
-
* @
|
|
407
|
+
* @deco.AfterSaveCommit()
|
|
408
408
|
* public doSomething() {
|
|
409
409
|
* console.log('hi!')
|
|
410
410
|
* }
|
|
@@ -422,7 +422,7 @@ class Decorators {
|
|
|
422
422
|
*
|
|
423
423
|
* ```ts
|
|
424
424
|
* class User {
|
|
425
|
-
* @
|
|
425
|
+
* @deco.AfterUpdate()
|
|
426
426
|
* public doSomething() {
|
|
427
427
|
* console.log('hi!')
|
|
428
428
|
* }
|
|
@@ -440,7 +440,7 @@ class Decorators {
|
|
|
440
440
|
*
|
|
441
441
|
* ```ts
|
|
442
442
|
* class User {
|
|
443
|
-
* @
|
|
443
|
+
* @deco.AfterUpdateCommit()
|
|
444
444
|
* public doSomething() {
|
|
445
445
|
* console.log('hi!')
|
|
446
446
|
* }
|
|
@@ -458,7 +458,7 @@ class Decorators {
|
|
|
458
458
|
*
|
|
459
459
|
* ```ts
|
|
460
460
|
* class User {
|
|
461
|
-
* @
|
|
461
|
+
* @deco.AfterDestroy()
|
|
462
462
|
* public doSomething() {
|
|
463
463
|
* console.log('hi!')
|
|
464
464
|
* }
|
|
@@ -476,7 +476,7 @@ class Decorators {
|
|
|
476
476
|
*
|
|
477
477
|
* ```ts
|
|
478
478
|
* class User {
|
|
479
|
-
* @
|
|
479
|
+
* @deco.AfterDestroyCommit()
|
|
480
480
|
* public doSomething() {
|
|
481
481
|
* console.log('hi!')
|
|
482
482
|
* }
|
|
@@ -11,13 +11,13 @@ const shared_js_1 = require("./shared.js");
|
|
|
11
11
|
*
|
|
12
12
|
* ```ts
|
|
13
13
|
* class UserSettings extends ApplicationModel {
|
|
14
|
-
* @
|
|
14
|
+
* @deco.BelongsTo('User')
|
|
15
15
|
* public user: User
|
|
16
16
|
* public userId: DreamColumn<UserSettings, 'userId'>
|
|
17
17
|
* }
|
|
18
18
|
*
|
|
19
19
|
* class User extends ApplicationModel {
|
|
20
|
-
* @
|
|
20
|
+
* @deco.HasOne('UserSettings')
|
|
21
21
|
* public userSettings: UserSettings
|
|
22
22
|
* }
|
|
23
23
|
* ```
|
|
@@ -10,12 +10,12 @@ const shared_js_1 = require("./shared.js");
|
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
12
|
* class User extends ApplicationModel {
|
|
13
|
-
* @
|
|
13
|
+
* @deco.HasMany('Post')
|
|
14
14
|
* public posts: Post[]
|
|
15
15
|
* }
|
|
16
16
|
*
|
|
17
17
|
* class Post extends ApplicationModel {
|
|
18
|
-
* @
|
|
18
|
+
* @deco.BelongsTo('User')
|
|
19
19
|
* public user: User
|
|
20
20
|
* public userId: DreamColumn<Post, 'userId'>
|
|
21
21
|
* }
|
|
@@ -10,12 +10,12 @@ const shared_js_1 = require("./shared.js");
|
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
12
|
* class User extends ApplicationModel {
|
|
13
|
-
* @
|
|
13
|
+
* @deco.HasOne('UserSettings')
|
|
14
14
|
* public userSettings: UserSettings
|
|
15
15
|
* }
|
|
16
16
|
*
|
|
17
17
|
* class UserSettings extends ApplicationModel {
|
|
18
|
-
* @
|
|
18
|
+
* @deco.BelongsTo('User')
|
|
19
19
|
* public user: User
|
|
20
20
|
* public userId: DreamColumn<UserSettings, 'userId'>
|
|
21
21
|
* }
|
|
@@ -56,7 +56,7 @@ function extractValidationOptionsFromArgs(type, args) {
|
|
|
56
56
|
When validating using "length", the second argument must be a number representing
|
|
57
57
|
the min length, or else an object expressing both min and max length, like so:
|
|
58
58
|
|
|
59
|
-
@
|
|
59
|
+
@deco.Validates('length', { min: 4, max: 32 })
|
|
60
60
|
`);
|
|
61
61
|
}
|
|
62
62
|
case 'requiredBelongsTo':
|
|
@@ -515,10 +515,10 @@ class DreamClassTransactionBuilder {
|
|
|
515
515
|
*
|
|
516
516
|
* ```ts
|
|
517
517
|
* class Post {
|
|
518
|
-
* @
|
|
518
|
+
* @deco.HasMany('LocalizedText')
|
|
519
519
|
* public localizedTexts: LocalizedText[]
|
|
520
520
|
*
|
|
521
|
-
* @
|
|
521
|
+
* @deco.HasOne('LocalizedText', {
|
|
522
522
|
* where: { locale: DreamConst.passthrough },
|
|
523
523
|
* })
|
|
524
524
|
* public currentLocalizedText: LocalizedText
|
|
@@ -763,10 +763,10 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
763
763
|
*
|
|
764
764
|
* ```ts
|
|
765
765
|
* class Post {
|
|
766
|
-
* @
|
|
766
|
+
* @deco.HasMany('LocalizedText')
|
|
767
767
|
* public localizedTexts: LocalizedText[]
|
|
768
768
|
*
|
|
769
|
-
* @
|
|
769
|
+
* @deco.HasOne('LocalizedText', {
|
|
770
770
|
* on: { locale: DreamConst.passthrough },
|
|
771
771
|
* })
|
|
772
772
|
* public currentLocalizedText: LocalizedText
|
|
@@ -38,7 +38,7 @@ function generateDreamContent({ fullyQualifiedModelName, columnsWithTypes, fully
|
|
|
38
38
|
case 'belongs_to':
|
|
39
39
|
modelImportStatements.push(associationImportStatement);
|
|
40
40
|
return `
|
|
41
|
-
@
|
|
41
|
+
@deco.BelongsTo('${fullyQualifiedAssociatedModelName}'${descriptors.includes('optional') ? ', { optional: true }' : ''})
|
|
42
42
|
public ${associationName}: ${associationModelName}${descriptors.includes('optional') ? ' | null' : ''}
|
|
43
43
|
public ${associationName}Id: DreamColumn<${modelClassName}, '${associationName}Id'>
|
|
44
44
|
`;
|
|
@@ -76,7 +76,7 @@ public ${(0, camelize_js_1.default)(attributeName)}: ${getAttributeType(attribut
|
|
|
76
76
|
return `\
|
|
77
77
|
import { ${(0, uniq_js_1.default)(dreamImports).join(', ')} } from '@rvoh/dream'${(0, uniq_js_1.default)(modelImportStatements).join('')}
|
|
78
78
|
|
|
79
|
-
const
|
|
79
|
+
const deco = new Decorators<InstanceType<typeof ${modelClassName}>>()
|
|
80
80
|
|
|
81
81
|
${isSTI ? `\n@STI(${parentModelClassName})` : ''}
|
|
82
82
|
export default class ${modelClassName} extends ${isSTI ? parentModelClassName : 'ApplicationModel'} {
|
|
@@ -89,14 +89,14 @@ function migratedActionPastTense(mode) {
|
|
|
89
89
|
function logResults(results, mode) {
|
|
90
90
|
results?.forEach(it => {
|
|
91
91
|
if (it.status === 'Success') {
|
|
92
|
-
index_js_3.default.logger.
|
|
93
|
-
` migration "${it.migrationName}" was ${migratedActionPastTense(mode)} successfully`, {
|
|
92
|
+
index_js_3.default.logger.logContinueProgress((0, colorize_js_1.default)(`[db]`, { color: 'cyan' }) +
|
|
93
|
+
` migration "${it.migrationName}" was ${migratedActionPastTense(mode)} successfully`, { logPrefixColor: 'cyan' });
|
|
94
94
|
}
|
|
95
95
|
else if (it.status === 'Error') {
|
|
96
|
-
index_js_3.default.logger.
|
|
97
|
-
index_js_3.default.logger.
|
|
96
|
+
index_js_3.default.logger.logContinueProgress(JSON.stringify(it, null, 2));
|
|
97
|
+
index_js_3.default.logger.logContinueProgress((0, colorize_js_1.default)(`failed to ${migratedActionCurrentTense(mode)} migration "${it.migrationName}"`, {
|
|
98
98
|
color: 'redBright',
|
|
99
|
-
})
|
|
99
|
+
}));
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -7,15 +7,41 @@ function sspawn(command, opts = {}) {
|
|
|
7
7
|
return new Promise((accept, reject) => {
|
|
8
8
|
ssspawn(command, opts).on('close', code => {
|
|
9
9
|
if (code !== 0)
|
|
10
|
-
reject(
|
|
10
|
+
reject(code);
|
|
11
11
|
accept({});
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
function ssspawn(command, opts = {}) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const proc = (0, child_process_1.spawn)(command, {
|
|
17
|
+
// even though github security scans want to remove this,
|
|
18
|
+
// it is necessary to allow the cli util to run as the current
|
|
19
|
+
// user. This is only done to provision a new psychic application,
|
|
20
|
+
// so it is safe from unknown execution contexts.
|
|
18
21
|
shell: true,
|
|
19
22
|
...opts,
|
|
20
23
|
});
|
|
24
|
+
// NOTE: adding this stdout spy so that
|
|
25
|
+
// when this cli utility runs node commands,
|
|
26
|
+
// it can properly hijack the stdout from the command
|
|
27
|
+
proc.stdout.on('data', chunk => {
|
|
28
|
+
const txt = chunk?.toString()?.trim();
|
|
29
|
+
if (typeof txt !== 'string' || !txt)
|
|
30
|
+
return;
|
|
31
|
+
if (opts?.onStdout) {
|
|
32
|
+
opts?.onStdout?.(txt);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.log(txt);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
proc.stdout.on('error', err => {
|
|
39
|
+
console.log('sspawn error!');
|
|
40
|
+
console.error(err);
|
|
41
|
+
});
|
|
42
|
+
proc.on('error', err => {
|
|
43
|
+
console.log('sspawn error!');
|
|
44
|
+
console.error(err);
|
|
45
|
+
});
|
|
46
|
+
return proc;
|
|
21
47
|
}
|
|
@@ -16,12 +16,12 @@ const shared_js_1 = require("./shared.js");
|
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
18
|
* class User extends ApplicationModel {
|
|
19
|
-
* @
|
|
19
|
+
* @deco.HasOne('Settings')
|
|
20
20
|
* public settings: Settings
|
|
21
21
|
* }
|
|
22
22
|
*
|
|
23
23
|
* class Post extends ApplicationModel {
|
|
24
|
-
* @
|
|
24
|
+
* @deco.BelongsTo('User')
|
|
25
25
|
* public user: User
|
|
26
26
|
* }
|
|
27
27
|
*
|
|
@@ -16,12 +16,12 @@ const shared_js_1 = require("./shared.js");
|
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
18
|
* class User extends ApplicationModel {
|
|
19
|
-
* @
|
|
19
|
+
* @deco.HasOne('Settings')
|
|
20
20
|
* public settings: Settings
|
|
21
21
|
* }
|
|
22
22
|
*
|
|
23
23
|
* class Settings extends ApplicationModel {
|
|
24
|
-
* @
|
|
24
|
+
* @deco.BelongsTo('User')
|
|
25
25
|
* public user: User
|
|
26
26
|
* }
|
|
27
27
|
*
|
package/dist/esm/src/Dream.js
CHANGED
|
@@ -161,9 +161,9 @@ export default class Dream {
|
|
|
161
161
|
* @internal
|
|
162
162
|
*
|
|
163
163
|
* Model storage for association metadata, set when using the association decorators like:
|
|
164
|
-
* @
|
|
165
|
-
* @
|
|
166
|
-
* @
|
|
164
|
+
* @deco.HasOne
|
|
165
|
+
* @deco.HasMany
|
|
166
|
+
* @deco.BelongsTo
|
|
167
167
|
*/
|
|
168
168
|
static associationMetadataByType = blankAssociationsFactory(this, {
|
|
169
169
|
freeze: true,
|
|
@@ -1133,7 +1133,7 @@ export default class Dream {
|
|
|
1133
1133
|
*
|
|
1134
1134
|
* ```ts
|
|
1135
1135
|
* class Post extends ApplicationModel {
|
|
1136
|
-
* @
|
|
1136
|
+
* @deco.Sortable({ scope: ['user']})
|
|
1137
1137
|
* public position: DreamColumn<User, 'position'>
|
|
1138
1138
|
* }
|
|
1139
1139
|
*
|
|
@@ -1163,7 +1163,7 @@ export default class Dream {
|
|
|
1163
1163
|
*
|
|
1164
1164
|
* ```ts
|
|
1165
1165
|
* class User extends ApplicationModel {
|
|
1166
|
-
* @
|
|
1166
|
+
* @deco.Scope()
|
|
1167
1167
|
* public visible(query: Query<User>) {
|
|
1168
1168
|
* return query.where({ hidden: false })
|
|
1169
1169
|
* }
|
|
@@ -1288,10 +1288,10 @@ export default class Dream {
|
|
|
1288
1288
|
*
|
|
1289
1289
|
* ```ts
|
|
1290
1290
|
* class Post {
|
|
1291
|
-
* @
|
|
1291
|
+
* @deco.HasMany('LocalizedText')
|
|
1292
1292
|
* public localizedTexts: LocalizedText[]
|
|
1293
1293
|
*
|
|
1294
|
-
* @
|
|
1294
|
+
* @deco.HasOne('LocalizedText', {
|
|
1295
1295
|
* where: { locale: DreamConst.passthrough },
|
|
1296
1296
|
* })
|
|
1297
1297
|
* public currentLocalizedText: LocalizedText
|
|
@@ -1631,7 +1631,7 @@ export default class Dream {
|
|
|
1631
1631
|
*
|
|
1632
1632
|
* ```ts
|
|
1633
1633
|
* class User extends ApplicationModel {
|
|
1634
|
-
* @
|
|
1634
|
+
* @deco.Validates('presence')
|
|
1635
1635
|
* public email: DreamColumn<User, 'email'>
|
|
1636
1636
|
* }
|
|
1637
1637
|
* const user = User.new()
|
|
@@ -1677,7 +1677,7 @@ export default class Dream {
|
|
|
1677
1677
|
*
|
|
1678
1678
|
* ```ts
|
|
1679
1679
|
* class User extends ApplicationModel {
|
|
1680
|
-
* @
|
|
1680
|
+
* @deco.Validates('presence')
|
|
1681
1681
|
* public email: DreamColumn<User, 'email'>
|
|
1682
1682
|
* }
|
|
1683
1683
|
*
|
|
@@ -2068,7 +2068,7 @@ export default class Dream {
|
|
|
2068
2068
|
* ```ts
|
|
2069
2069
|
* class User extends ApplicationModel {
|
|
2070
2070
|
* ...
|
|
2071
|
-
* @
|
|
2071
|
+
* @deco.Validate()
|
|
2072
2072
|
* public async validateName() {
|
|
2073
2073
|
* if (typeof this.name === 'number')
|
|
2074
2074
|
* this.addError('name', 'name cannot be a number')
|
|
@@ -2696,10 +2696,10 @@ export default class Dream {
|
|
|
2696
2696
|
*
|
|
2697
2697
|
* ```ts
|
|
2698
2698
|
* class Post {
|
|
2699
|
-
* @
|
|
2699
|
+
* @deco.HasMany('LocalizedText')
|
|
2700
2700
|
* public localizedTexts: LocalizedText[]
|
|
2701
2701
|
*
|
|
2702
|
-
* @
|
|
2702
|
+
* @deco.HasOne('LocalizedText', {
|
|
2703
2703
|
* where: { locale: DreamConst.passthrough },
|
|
2704
2704
|
* })
|
|
2705
2705
|
* public currentLocalizedText: LocalizedText
|
|
@@ -2996,7 +2996,7 @@ export default class Dream {
|
|
|
2996
2996
|
*
|
|
2997
2997
|
* ```ts
|
|
2998
2998
|
* class User extends ApplicationModel {
|
|
2999
|
-
* @
|
|
2999
|
+
* @deco.BeforeDestroy()
|
|
3000
3000
|
* public softDelete() {
|
|
3001
3001
|
* await this.update({ deletedAt: DateTime.now() })
|
|
3002
3002
|
* this.preventDeletion()
|
|
@@ -3017,13 +3017,13 @@ export default class Dream {
|
|
|
3017
3017
|
*
|
|
3018
3018
|
* ```ts
|
|
3019
3019
|
* class User extends ApplicationModel {
|
|
3020
|
-
* @
|
|
3020
|
+
* @deco.BeforeDestroy()
|
|
3021
3021
|
* public async softDelete() {
|
|
3022
3022
|
* await this.update({ deletedAt: DateTime.now() })
|
|
3023
3023
|
* this.preventDeletion()
|
|
3024
3024
|
* }
|
|
3025
3025
|
*
|
|
3026
|
-
* @
|
|
3026
|
+
* @deco.BeforeDestroy()
|
|
3027
3027
|
* public async undoSoftDelete() {
|
|
3028
3028
|
* await this.update({ deletedAt: null })
|
|
3029
3029
|
* this.unpreventDeletion()
|
|
@@ -9,18 +9,25 @@ import EnvInternal from '../../helpers/EnvInternal.js';
|
|
|
9
9
|
import dreamPath from '../../helpers/path/dreamPath.js';
|
|
10
10
|
import snakeify from '../../helpers/snakeify.js';
|
|
11
11
|
import sspawn from '../../helpers/sspawn.js';
|
|
12
|
+
import DreamCLI from '../../cli/index.js';
|
|
13
|
+
import colorize from '../../cli/logger/loggable/colorize.js';
|
|
12
14
|
export default async function writeSyncFile() {
|
|
13
15
|
const dbConf = new ConnectionConfRetriever().getConnectionConf('primary');
|
|
14
16
|
const dreamApp = DreamApplication.getOrFail();
|
|
15
17
|
const dbSyncFilePath = path.join(dreamPath('types'), 'db.ts');
|
|
16
18
|
const absoluteDbSyncPath = path.join(dreamApp.projectRoot, dbSyncFilePath);
|
|
17
|
-
await sspawn(`kysely-codegen --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}
|
|
19
|
+
await sspawn(`kysely-codegen --dialect=postgres --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}`, {
|
|
20
|
+
onStdout: message => {
|
|
21
|
+
DreamCLI.logger.logContinueProgress(colorize(`[db]`, { color: 'cyan' }) + ' ' + message, {
|
|
22
|
+
logPrefixColor: 'cyan',
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
});
|
|
18
26
|
// intentionally bypassing helpers here, since they often end up referencing
|
|
19
27
|
// from the dist folder, whereas dirname here is pointing to true src folder.
|
|
20
28
|
const file = (await fs.readFile(absoluteDbSyncPath)).toString();
|
|
21
29
|
const enhancedSchema = enhanceSchema(file);
|
|
22
30
|
await fs.writeFile(absoluteDbSyncPath, enhancedSchema);
|
|
23
|
-
DreamApplication.log('done writing dream sync file!');
|
|
24
31
|
}
|
|
25
32
|
// begin: schema helpers
|
|
26
33
|
function enhanceSchema(file) {
|