@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
package/README.md
CHANGED
|
@@ -42,22 +42,22 @@ const user = await User.where({ email: ops.like('%fred@%') })
|
|
|
42
42
|
|
|
43
43
|
class Composition {
|
|
44
44
|
...
|
|
45
|
-
@
|
|
45
|
+
@deco.BeforeCreate()
|
|
46
46
|
public setDefaultContent() {
|
|
47
47
|
if (!this.content) this.content = 'default content'
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
@
|
|
50
|
+
@deco.AfterCreate()
|
|
51
51
|
public conditionallyChangeContentOnCreate() {
|
|
52
52
|
if (this.content === 'change me after create') this.content = 'changed after create'
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
@
|
|
55
|
+
@deco.AfterUpdate()
|
|
56
56
|
public conditionallyChangeContentOnUpdate() {
|
|
57
57
|
if (this.content === 'change me after update') this.content = 'changed after update'
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
@
|
|
60
|
+
@deco.AfterSave()
|
|
61
61
|
public conditionallyChangeContentOnSave() {
|
|
62
62
|
if (this.content === 'change me after save') this.content = 'changed after save'
|
|
63
63
|
}
|
|
@@ -73,11 +73,11 @@ class Composition {
|
|
|
73
73
|
```ts
|
|
74
74
|
export default class User extends Dream {
|
|
75
75
|
...
|
|
76
|
-
@
|
|
77
|
-
@
|
|
76
|
+
@deco.Validates('contains', '@')
|
|
77
|
+
@deco.Validates('presence')
|
|
78
78
|
public email: string
|
|
79
79
|
|
|
80
|
-
@
|
|
80
|
+
@deco.Validates('length', { min: 4, max: 18 })
|
|
81
81
|
public password: string
|
|
82
82
|
...
|
|
83
83
|
}
|
|
@@ -97,13 +97,13 @@ export default class User extends Dream {
|
|
|
97
97
|
// models/user.ts
|
|
98
98
|
class User {
|
|
99
99
|
...
|
|
100
|
-
@
|
|
100
|
+
@deco.HasMany('Composition')
|
|
101
101
|
public compositions: Composition[]
|
|
102
102
|
|
|
103
|
-
@
|
|
103
|
+
@deco.HasOne('Composition')
|
|
104
104
|
public mainComposition: Composition
|
|
105
105
|
|
|
106
|
-
@
|
|
106
|
+
@deco.HasMany('CompositionAsset', {
|
|
107
107
|
through: 'compositions',
|
|
108
108
|
})
|
|
109
109
|
public compositionAssets: CompositionAsset[]
|
|
@@ -112,14 +112,14 @@ class User {
|
|
|
112
112
|
// models/composition.ts
|
|
113
113
|
export default class Composition extends Dream {
|
|
114
114
|
...
|
|
115
|
-
@
|
|
115
|
+
@deco.BelongsTo('User')
|
|
116
116
|
public user: User
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// models/composition-asset.ts
|
|
120
120
|
export default class CompositionAsset extends Dream {
|
|
121
121
|
...
|
|
122
|
-
@
|
|
122
|
+
@deco.BelongsTo('Composition')
|
|
123
123
|
public composition: Composition
|
|
124
124
|
...
|
|
125
125
|
}
|
|
@@ -136,13 +136,13 @@ export default class CompositionAsset extends Dream {
|
|
|
136
136
|
|
|
137
137
|
```ts
|
|
138
138
|
class User {
|
|
139
|
-
@
|
|
139
|
+
@deco.Scope()
|
|
140
140
|
public static withFunnyName(query: Query<User>) {
|
|
141
141
|
return query.where({ name: 'Chalupas jr' })
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// this will always fire whenever queries are run against the model
|
|
145
|
-
@
|
|
145
|
+
@deco.Scope({ default: true })
|
|
146
146
|
public static hideDeleted(query: Query<User>) {
|
|
147
147
|
return query.where({ deleted_at: null })
|
|
148
148
|
}
|
|
@@ -354,18 +354,18 @@ const pets = await user
|
|
|
354
354
|
```ts
|
|
355
355
|
@STI(A)
|
|
356
356
|
class B extends A {
|
|
357
|
-
@
|
|
357
|
+
@deco.HasMany('X')
|
|
358
358
|
public xx: X[]
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
@STI(A)
|
|
362
362
|
class C extends A {
|
|
363
|
-
@
|
|
363
|
+
@deco.HasMany('X', { on: { something: true } })
|
|
364
364
|
public xx: X[]
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
class Z extends Dream {
|
|
368
|
-
@
|
|
368
|
+
@deco.HasMany('A')
|
|
369
369
|
public aa: A[]
|
|
370
370
|
}
|
|
371
371
|
|
package/dist/cjs/src/Dream.js
CHANGED
|
@@ -163,9 +163,9 @@ class Dream {
|
|
|
163
163
|
* @internal
|
|
164
164
|
*
|
|
165
165
|
* Model storage for association metadata, set when using the association decorators like:
|
|
166
|
-
* @
|
|
167
|
-
* @
|
|
168
|
-
* @
|
|
166
|
+
* @deco.HasOne
|
|
167
|
+
* @deco.HasMany
|
|
168
|
+
* @deco.BelongsTo
|
|
169
169
|
*/
|
|
170
170
|
static associationMetadataByType = (0, shared_js_1.blankAssociationsFactory)(this, {
|
|
171
171
|
freeze: true,
|
|
@@ -1135,7 +1135,7 @@ class Dream {
|
|
|
1135
1135
|
*
|
|
1136
1136
|
* ```ts
|
|
1137
1137
|
* class Post extends ApplicationModel {
|
|
1138
|
-
* @
|
|
1138
|
+
* @deco.Sortable({ scope: ['user']})
|
|
1139
1139
|
* public position: DreamColumn<User, 'position'>
|
|
1140
1140
|
* }
|
|
1141
1141
|
*
|
|
@@ -1165,7 +1165,7 @@ class Dream {
|
|
|
1165
1165
|
*
|
|
1166
1166
|
* ```ts
|
|
1167
1167
|
* class User extends ApplicationModel {
|
|
1168
|
-
* @
|
|
1168
|
+
* @deco.Scope()
|
|
1169
1169
|
* public visible(query: Query<User>) {
|
|
1170
1170
|
* return query.where({ hidden: false })
|
|
1171
1171
|
* }
|
|
@@ -1290,10 +1290,10 @@ class Dream {
|
|
|
1290
1290
|
*
|
|
1291
1291
|
* ```ts
|
|
1292
1292
|
* class Post {
|
|
1293
|
-
* @
|
|
1293
|
+
* @deco.HasMany('LocalizedText')
|
|
1294
1294
|
* public localizedTexts: LocalizedText[]
|
|
1295
1295
|
*
|
|
1296
|
-
* @
|
|
1296
|
+
* @deco.HasOne('LocalizedText', {
|
|
1297
1297
|
* where: { locale: DreamConst.passthrough },
|
|
1298
1298
|
* })
|
|
1299
1299
|
* public currentLocalizedText: LocalizedText
|
|
@@ -1633,7 +1633,7 @@ class Dream {
|
|
|
1633
1633
|
*
|
|
1634
1634
|
* ```ts
|
|
1635
1635
|
* class User extends ApplicationModel {
|
|
1636
|
-
* @
|
|
1636
|
+
* @deco.Validates('presence')
|
|
1637
1637
|
* public email: DreamColumn<User, 'email'>
|
|
1638
1638
|
* }
|
|
1639
1639
|
* const user = User.new()
|
|
@@ -1679,7 +1679,7 @@ class Dream {
|
|
|
1679
1679
|
*
|
|
1680
1680
|
* ```ts
|
|
1681
1681
|
* class User extends ApplicationModel {
|
|
1682
|
-
* @
|
|
1682
|
+
* @deco.Validates('presence')
|
|
1683
1683
|
* public email: DreamColumn<User, 'email'>
|
|
1684
1684
|
* }
|
|
1685
1685
|
*
|
|
@@ -2070,7 +2070,7 @@ class Dream {
|
|
|
2070
2070
|
* ```ts
|
|
2071
2071
|
* class User extends ApplicationModel {
|
|
2072
2072
|
* ...
|
|
2073
|
-
* @
|
|
2073
|
+
* @deco.Validate()
|
|
2074
2074
|
* public async validateName() {
|
|
2075
2075
|
* if (typeof this.name === 'number')
|
|
2076
2076
|
* this.addError('name', 'name cannot be a number')
|
|
@@ -2698,10 +2698,10 @@ class Dream {
|
|
|
2698
2698
|
*
|
|
2699
2699
|
* ```ts
|
|
2700
2700
|
* class Post {
|
|
2701
|
-
* @
|
|
2701
|
+
* @deco.HasMany('LocalizedText')
|
|
2702
2702
|
* public localizedTexts: LocalizedText[]
|
|
2703
2703
|
*
|
|
2704
|
-
* @
|
|
2704
|
+
* @deco.HasOne('LocalizedText', {
|
|
2705
2705
|
* where: { locale: DreamConst.passthrough },
|
|
2706
2706
|
* })
|
|
2707
2707
|
* public currentLocalizedText: LocalizedText
|
|
@@ -2998,7 +2998,7 @@ class Dream {
|
|
|
2998
2998
|
*
|
|
2999
2999
|
* ```ts
|
|
3000
3000
|
* class User extends ApplicationModel {
|
|
3001
|
-
* @
|
|
3001
|
+
* @deco.BeforeDestroy()
|
|
3002
3002
|
* public softDelete() {
|
|
3003
3003
|
* await this.update({ deletedAt: DateTime.now() })
|
|
3004
3004
|
* this.preventDeletion()
|
|
@@ -3019,13 +3019,13 @@ class Dream {
|
|
|
3019
3019
|
*
|
|
3020
3020
|
* ```ts
|
|
3021
3021
|
* class User extends ApplicationModel {
|
|
3022
|
-
* @
|
|
3022
|
+
* @deco.BeforeDestroy()
|
|
3023
3023
|
* public async softDelete() {
|
|
3024
3024
|
* await this.update({ deletedAt: DateTime.now() })
|
|
3025
3025
|
* this.preventDeletion()
|
|
3026
3026
|
* }
|
|
3027
3027
|
*
|
|
3028
|
-
* @
|
|
3028
|
+
* @deco.BeforeDestroy()
|
|
3029
3029
|
* public async undoSoftDelete() {
|
|
3030
3030
|
* await this.update({ deletedAt: null })
|
|
3031
3031
|
* this.unpreventDeletion()
|
|
@@ -12,18 +12,25 @@ const EnvInternal_js_1 = require("../../helpers/EnvInternal.js");
|
|
|
12
12
|
const dreamPath_js_1 = require("../../helpers/path/dreamPath.js");
|
|
13
13
|
const snakeify_js_1 = require("../../helpers/snakeify.js");
|
|
14
14
|
const sspawn_js_1 = require("../../helpers/sspawn.js");
|
|
15
|
+
const index_js_2 = require("../../cli/index.js");
|
|
16
|
+
const colorize_js_1 = require("../../cli/logger/loggable/colorize.js");
|
|
15
17
|
async function writeSyncFile() {
|
|
16
18
|
const dbConf = new ConnectionConfRetriever_js_1.default().getConnectionConf('primary');
|
|
17
19
|
const dreamApp = index_js_1.default.getOrFail();
|
|
18
20
|
const dbSyncFilePath = path.join((0, dreamPath_js_1.default)('types'), 'db.ts');
|
|
19
21
|
const absoluteDbSyncPath = path.join(dreamApp.projectRoot, dbSyncFilePath);
|
|
20
|
-
await (0, sspawn_js_1.default)(`kysely-codegen --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}
|
|
22
|
+
await (0, sspawn_js_1.default)(`kysely-codegen --dialect=postgres --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}`, {
|
|
23
|
+
onStdout: message => {
|
|
24
|
+
index_js_2.default.logger.logContinueProgress((0, colorize_js_1.default)(`[db]`, { color: 'cyan' }) + ' ' + message, {
|
|
25
|
+
logPrefixColor: 'cyan',
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
});
|
|
21
29
|
// intentionally bypassing helpers here, since they often end up referencing
|
|
22
30
|
// from the dist folder, whereas dirname here is pointing to true src folder.
|
|
23
31
|
const file = (await fs.readFile(absoluteDbSyncPath)).toString();
|
|
24
32
|
const enhancedSchema = enhanceSchema(file);
|
|
25
33
|
await fs.writeFile(absoluteDbSyncPath, enhancedSchema);
|
|
26
|
-
index_js_1.default.log('done writing dream sync file!');
|
|
27
34
|
}
|
|
28
35
|
// begin: schema helpers
|
|
29
36
|
function enhanceSchema(file) {
|
|
@@ -15,20 +15,25 @@ const sspawn_js_1 = require("../helpers/sspawn.js");
|
|
|
15
15
|
const sync_js_1 = require("./helpers/sync.js");
|
|
16
16
|
class DreamBin {
|
|
17
17
|
static async sync(onSync) {
|
|
18
|
+
index_js_1.default.logger.logStartProgress('writing db schema...');
|
|
18
19
|
await (0, sync_js_1.default)();
|
|
20
|
+
index_js_1.default.logger.logEndProgress();
|
|
21
|
+
index_js_1.default.logger.logStartProgress('building dream schema...');
|
|
19
22
|
await this.buildDreamSchema();
|
|
23
|
+
index_js_1.default.logger.logEndProgress();
|
|
24
|
+
index_js_1.default.logger.logStartProgress('running sync hooks...');
|
|
20
25
|
await onSync();
|
|
26
|
+
index_js_1.default.logger.logEndProgress();
|
|
21
27
|
}
|
|
22
28
|
static async buildDreamSchema() {
|
|
23
|
-
const spinner = index_js_1.default.logger.log('writing dream schema...', { spinner: true });
|
|
24
29
|
await new SchemaBuilder_js_1.default().build();
|
|
25
|
-
spinner.stop();
|
|
26
30
|
}
|
|
27
31
|
static async dbCreate() {
|
|
28
32
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
29
33
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
30
|
-
|
|
34
|
+
index_js_1.default.logger.logStartProgress(`creating ${primaryDbConf.name}...`);
|
|
31
35
|
await (0, createDb_js_1.default)('primary');
|
|
36
|
+
index_js_1.default.logger.logEndProgress();
|
|
32
37
|
// TODO: add support for creating replicas. Began doing it below, but it is very tricky,
|
|
33
38
|
// and we don't need it at the moment, so kicking off for future development when we have more time
|
|
34
39
|
// to flesh this out.
|
|
@@ -37,13 +42,13 @@ class DreamBin {
|
|
|
37
42
|
// console.log(`creating ${process.env[replicaDbConf.name]}`)
|
|
38
43
|
// await createDb('replica')
|
|
39
44
|
// }
|
|
40
|
-
spinner.stop();
|
|
41
45
|
}
|
|
42
46
|
static async dbDrop() {
|
|
43
47
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
44
48
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
45
|
-
|
|
49
|
+
index_js_1.default.logger.logStartProgress(`dropping ${primaryDbConf.name}...`);
|
|
46
50
|
await (0, dropDb_js_1.default)('primary');
|
|
51
|
+
index_js_1.default.logger.logEndProgress();
|
|
47
52
|
// TODO: add support for dropping replicas. Began doing it below, but it is very tricky,
|
|
48
53
|
// and we don't need it at the moment, so kicking off for future development when we have more time
|
|
49
54
|
// to flesh this out.
|
|
@@ -52,27 +57,26 @@ class DreamBin {
|
|
|
52
57
|
// console.log(`dropping ${process.env[replicaDbConf.name]}`)
|
|
53
58
|
// await _dropDb('replica')
|
|
54
59
|
// }
|
|
55
|
-
spinner.stop();
|
|
56
60
|
}
|
|
57
61
|
static async dbMigrate() {
|
|
58
62
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
59
63
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
60
|
-
|
|
64
|
+
index_js_1.default.logger.logStartProgress(`migrating ${primaryDbConf.name}...`);
|
|
61
65
|
await (0, runMigration_js_1.default)({ mode: 'migrate' });
|
|
62
66
|
await this.duplicateDatabase();
|
|
63
|
-
|
|
67
|
+
index_js_1.default.logger.logEndProgress();
|
|
64
68
|
}
|
|
65
69
|
static async dbRollback(opts) {
|
|
66
70
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
67
71
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
68
|
-
|
|
72
|
+
index_js_1.default.logger.logStartProgress(`rolling back ${primaryDbConf.name}...`);
|
|
69
73
|
let step = opts.steps;
|
|
70
74
|
while (step > 0) {
|
|
71
75
|
await (0, runMigration_js_1.default)({ mode: 'rollback' });
|
|
72
76
|
step -= 1;
|
|
73
77
|
}
|
|
74
78
|
await this.duplicateDatabase();
|
|
75
|
-
|
|
79
|
+
index_js_1.default.logger.logEndProgress();
|
|
76
80
|
}
|
|
77
81
|
static async generateDream(fullyQualifiedModelName, columnsWithTypes, options) {
|
|
78
82
|
await (0, generateDream_js_1.default)({ fullyQualifiedModelName, columnsWithTypes, options });
|
|
@@ -87,8 +91,9 @@ class DreamBin {
|
|
|
87
91
|
// It is only made private so that people don't mistakenly try
|
|
88
92
|
// to use it to generate docs for their apps.
|
|
89
93
|
static async buildDocs() {
|
|
90
|
-
index_js_1.default.logger.
|
|
94
|
+
index_js_1.default.logger.logStartProgress('generating docs...');
|
|
91
95
|
await (0, sspawn_js_1.default)('yarn typedoc src/index.ts --tsconfig ./tsconfig.esm.build.json --out docs');
|
|
96
|
+
index_js_1.default.logger.logEndProgress();
|
|
92
97
|
}
|
|
93
98
|
static async duplicateDatabase() {
|
|
94
99
|
const parallelTests = index_js_2.default.getOrFail().parallelTests;
|
|
@@ -99,22 +104,16 @@ class DreamBin {
|
|
|
99
104
|
const client = await (0, loadPgClient_js_1.default)({ useSystemDb: true });
|
|
100
105
|
if (process.env.DREAM_CORE_DEVELOPMENT === '1') {
|
|
101
106
|
const replicaTestWorkerDatabaseName = `replica_test_${dbConf.name}`;
|
|
102
|
-
|
|
103
|
-
spinner: true,
|
|
104
|
-
});
|
|
107
|
+
index_js_1.default.logger.logContinueProgress(`creating fake replica test database ${replicaTestWorkerDatabaseName}...`);
|
|
105
108
|
await client.query(`DROP DATABASE IF EXISTS ${replicaTestWorkerDatabaseName};`);
|
|
106
109
|
await client.query(`CREATE DATABASE ${replicaTestWorkerDatabaseName} TEMPLATE ${dbConf.name};`);
|
|
107
|
-
spinner.stop();
|
|
108
110
|
}
|
|
109
111
|
for (let i = 2; i <= parallelTests; i++) {
|
|
110
112
|
const workerDatabaseName = `${dbConf.name}_${i}`;
|
|
111
113
|
console.log(`creating duplicate test database ${workerDatabaseName} for concurrent tests`);
|
|
112
|
-
|
|
113
|
-
spinner: true,
|
|
114
|
-
});
|
|
114
|
+
index_js_1.default.logger.logContinueProgress(`creating duplicate test database ${workerDatabaseName} for concurrent tests...`);
|
|
115
115
|
await client.query(`DROP DATABASE IF EXISTS ${workerDatabaseName};`);
|
|
116
116
|
await client.query(`CREATE DATABASE ${workerDatabaseName} TEMPLATE ${dbConf.name};`);
|
|
117
|
-
spinner.stop();
|
|
118
117
|
}
|
|
119
118
|
await client.end();
|
|
120
119
|
}
|
|
@@ -1,57 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const DreamCliLoggableSpinner_js_1 = require("./loggable/DreamCliLoggableSpinner.js");
|
|
4
3
|
const DreamCliLoggableText_js_1 = require("./loggable/DreamCliLoggableText.js");
|
|
5
4
|
class DreamCliLogger {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
permanent: false,
|
|
12
|
-
spinner: 'noise',
|
|
13
|
-
color: spinnerPrefixColor,
|
|
14
|
-
bgColor: spinnerPrefixBgColor,
|
|
15
|
-
})
|
|
16
|
-
: new DreamCliLoggableText_js_1.default(text, {
|
|
17
|
-
permanent,
|
|
18
|
-
logPrefix,
|
|
19
|
-
logPrefixColor: logPrefixColor || (permanent ? 'green' : 'yellow'),
|
|
20
|
-
logPrefixBgColor,
|
|
21
|
-
});
|
|
22
|
-
this.logs.push(loggable);
|
|
23
|
-
// re-render everything
|
|
24
|
-
this.render();
|
|
25
|
-
return loggable;
|
|
26
|
-
}
|
|
27
|
-
render() {
|
|
28
|
-
this.clear();
|
|
29
|
-
let skipNext = false;
|
|
30
|
-
this.logs.forEach(loggable => {
|
|
31
|
-
if (skipNext) {
|
|
32
|
-
skipNext = false;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
loggable.render();
|
|
5
|
+
log(text, { logPrefix, logPrefixColor, logPrefixBgColor } = {}) {
|
|
6
|
+
const loggable = new DreamCliLoggableText_js_1.default(text, {
|
|
7
|
+
logPrefix,
|
|
8
|
+
logPrefixColor: logPrefixColor || 'green',
|
|
9
|
+
logPrefixBgColor,
|
|
36
10
|
});
|
|
11
|
+
loggable.render();
|
|
37
12
|
}
|
|
38
|
-
|
|
39
|
-
|
|
13
|
+
logStartProgress(text, { logPrefix = '✺ ┌', logPrefixColor, logPrefixBgColor } = {}) {
|
|
14
|
+
this.log(text, { logPrefix, logPrefixColor, logPrefixBgColor });
|
|
40
15
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* then clear STDOUT and re-render with only
|
|
44
|
-
* the permanent logs remaining.
|
|
45
|
-
*/
|
|
46
|
-
purge() {
|
|
47
|
-
this.logs = this.logs.filter(log => log.permanent);
|
|
48
|
-
this.render();
|
|
16
|
+
logContinueProgress(text, { logPrefix = '✺ ├', logPrefixColor, logPrefixBgColor } = {}) {
|
|
17
|
+
this.log(text, { logPrefix, logPrefixColor, logPrefixBgColor });
|
|
49
18
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// @ts-expect-error this works fine with no args provided
|
|
53
|
-
process.stdout.clearLine?.();
|
|
54
|
-
process.stdout.cursorTo?.(0);
|
|
19
|
+
logEndProgress(text = 'complete', { logPrefix = '✺ └', logPrefixColor, logPrefixBgColor } = {}) {
|
|
20
|
+
this.log(text, { logPrefix, logPrefixColor, logPrefixBgColor });
|
|
55
21
|
}
|
|
56
22
|
}
|
|
57
23
|
exports.default = DreamCliLogger;
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const colorize_js_1 = require("./colorize.js");
|
|
4
4
|
class DreamCliLoggable {
|
|
5
|
-
permanent;
|
|
6
5
|
logPrefix;
|
|
7
6
|
logPrefixColor;
|
|
8
7
|
logPrefixBgColor;
|
|
9
|
-
constructor({
|
|
10
|
-
this.permanent = permanent;
|
|
8
|
+
constructor({ logPrefix = '✺', logPrefixColor, logPrefixBgColor, }) {
|
|
11
9
|
this.logPrefix = logPrefix;
|
|
12
10
|
this.logPrefixColor = logPrefixColor;
|
|
13
11
|
this.logPrefixBgColor = logPrefixBgColor;
|
|
@@ -6,8 +6,8 @@ class DreamCliLoggableText extends DreamCliLoggable_js_1.default {
|
|
|
6
6
|
text;
|
|
7
7
|
color;
|
|
8
8
|
bgColor;
|
|
9
|
-
constructor(text, {
|
|
10
|
-
super({
|
|
9
|
+
constructor(text, { logPrefix, color, bgColor, logPrefixColor, logPrefixBgColor, }) {
|
|
10
|
+
super({ logPrefix });
|
|
11
11
|
this.text = text;
|
|
12
12
|
this.color = color;
|
|
13
13
|
this.bgColor = bgColor;
|