@rvoh/dream 0.29.2 → 0.29.4
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/dist/cjs/src/Dream.js +59 -2
- package/dist/cjs/src/decorators/Decorators.js +34 -26
- package/dist/cjs/src/decorators/STI.js +1 -1
- package/dist/cjs/src/decorators/associations/shared.js +3 -3
- package/dist/cjs/src/decorators/hooks/AfterCreate.js +1 -1
- package/dist/cjs/src/decorators/hooks/AfterCreateCommit.js +1 -1
- package/dist/cjs/src/decorators/hooks/AfterDestroy.js +1 -1
- package/dist/cjs/src/decorators/hooks/AfterDestroyCommit.js +1 -1
- package/dist/cjs/src/decorators/hooks/AfterSave.js +1 -1
- package/dist/cjs/src/decorators/hooks/AfterSaveCommit.js +1 -1
- package/dist/cjs/src/decorators/hooks/AfterUpdate.js +1 -1
- package/dist/cjs/src/decorators/hooks/AfterUpdateCommit.js +1 -1
- package/dist/cjs/src/decorators/hooks/BeforeCreate.js +1 -1
- package/dist/cjs/src/decorators/hooks/BeforeDestroy.js +1 -1
- package/dist/cjs/src/decorators/hooks/BeforeSave.js +1 -1
- package/dist/cjs/src/decorators/hooks/BeforeUpdate.js +1 -1
- package/dist/cjs/src/decorators/sortable/Sortable.js +8 -19
- package/dist/cjs/src/dream/Query.js +8 -8
- package/dist/cjs/src/dream/internal/associations/createAssociation.js +1 -1
- package/dist/cjs/src/dream/internal/runHooksFor.js +1 -1
- package/dist/cjs/src/dream/internal/saveDream.js +1 -1
- package/dist/cjs/src/dream/internal/sqlResultToDreamInstance.js +1 -1
- package/dist/cjs/src/errors/CannotCallUndestroyOnANonSoftDeleteModel.js +1 -1
- package/dist/cjs/src/errors/CannotDefineAssociationWithBothDependentAndPassthrough.js +1 -1
- package/dist/cjs/src/errors/CannotDefineAssociationWithBothDependentAndRequiredOnClause.js +1 -1
- package/dist/cjs/src/errors/CannotPassUndefinedAsAValueToAWhereClause.js +1 -1
- package/dist/cjs/src/errors/CannotReloadUnsavedDream.js +1 -1
- package/dist/cjs/src/errors/CreateOrFindByFailedToCreateAndFind.js +1 -1
- package/dist/cjs/src/errors/DoNotSetEncryptedFieldsDirectly.js +1 -1
- package/dist/cjs/src/errors/MissingDeletedAtFieldForSoftDelete.js +1 -1
- package/dist/cjs/src/errors/MissingSerializersDefinition.js +5 -5
- package/dist/cjs/src/errors/MissingTable.js +4 -4
- package/dist/cjs/src/errors/NonBelongsToAssociationProvidedAsSortableDecoratorScope.js +2 -2
- package/dist/cjs/src/errors/NonExistentScopeProvidedToResort.js +2 -2
- package/dist/cjs/src/errors/SortableDecoratorRequiresColumnOrBelongsToAssociation.js +3 -3
- package/dist/cjs/src/errors/associations/CanOnlyPassBelongsToModelParam.js +1 -1
- package/dist/cjs/src/errors/associations/CannotAssociateThroughPolymorphic.js +1 -1
- package/dist/cjs/src/errors/associations/CannotCreateAssociationWithThroughContext.js +1 -1
- package/dist/cjs/src/errors/associations/CannotJoinPolymorphicBelongsToError.js +1 -1
- package/dist/cjs/src/errors/associations/CannotPassNullOrUndefinedToRequiredBelongsTo.js +1 -1
- package/dist/cjs/src/errors/associations/InvalidComputedForeignKey.js +2 -2
- package/dist/cjs/src/errors/associations/JoinAttemptedOnMissingAssociation.js +4 -4
- package/dist/cjs/src/errors/associations/MissingThroughAssociation.js +4 -4
- package/dist/cjs/src/errors/associations/MissingThroughAssociationSource.js +10 -10
- package/dist/cjs/src/errors/associations/NonLoadedAssociation.js +1 -1
- package/dist/cjs/src/errors/ops/AnyRequiresArrayColumn.js +1 -1
- package/dist/cjs/src/errors/schema-builder/FailedToIdentifyAssociation.js +4 -4
- package/dist/cjs/src/errors/sti/STIChildMissing.js +1 -1
- package/dist/cjs/src/errors/sti/StiChildIncompatibleWithSoftDeleteDecorator.js +1 -1
- package/dist/cjs/src/index.js +2 -28
- package/dist/esm/src/Dream.js +59 -2
- package/dist/esm/src/decorators/Decorators.js +34 -26
- package/dist/esm/src/decorators/STI.js +1 -1
- package/dist/esm/src/decorators/associations/shared.js +3 -3
- package/dist/esm/src/decorators/hooks/AfterCreate.js +1 -1
- package/dist/esm/src/decorators/hooks/AfterCreateCommit.js +1 -1
- package/dist/esm/src/decorators/hooks/AfterDestroy.js +1 -1
- package/dist/esm/src/decorators/hooks/AfterDestroyCommit.js +1 -1
- package/dist/esm/src/decorators/hooks/AfterSave.js +1 -1
- package/dist/esm/src/decorators/hooks/AfterSaveCommit.js +1 -1
- package/dist/esm/src/decorators/hooks/AfterUpdate.js +1 -1
- package/dist/esm/src/decorators/hooks/AfterUpdateCommit.js +1 -1
- package/dist/esm/src/decorators/hooks/BeforeCreate.js +1 -1
- package/dist/esm/src/decorators/hooks/BeforeDestroy.js +1 -1
- package/dist/esm/src/decorators/hooks/BeforeSave.js +1 -1
- package/dist/esm/src/decorators/hooks/BeforeUpdate.js +1 -1
- package/dist/esm/src/decorators/sortable/Sortable.js +8 -19
- package/dist/esm/src/dream/Query.js +8 -8
- package/dist/esm/src/dream/internal/associations/createAssociation.js +1 -1
- package/dist/esm/src/dream/internal/runHooksFor.js +1 -1
- package/dist/esm/src/dream/internal/saveDream.js +1 -1
- package/dist/esm/src/dream/internal/sqlResultToDreamInstance.js +1 -1
- package/dist/esm/src/errors/CannotCallUndestroyOnANonSoftDeleteModel.js +1 -1
- package/dist/esm/src/errors/CannotDefineAssociationWithBothDependentAndPassthrough.js +1 -1
- package/dist/esm/src/errors/CannotDefineAssociationWithBothDependentAndRequiredOnClause.js +1 -1
- package/dist/esm/src/errors/CannotPassUndefinedAsAValueToAWhereClause.js +1 -1
- package/dist/esm/src/errors/CannotReloadUnsavedDream.js +1 -1
- package/dist/esm/src/errors/CreateOrFindByFailedToCreateAndFind.js +1 -1
- package/dist/esm/src/errors/DoNotSetEncryptedFieldsDirectly.js +1 -1
- package/dist/esm/src/errors/MissingDeletedAtFieldForSoftDelete.js +1 -1
- package/dist/esm/src/errors/MissingSerializersDefinition.js +5 -5
- package/dist/esm/src/errors/MissingTable.js +4 -4
- package/dist/esm/src/errors/NonBelongsToAssociationProvidedAsSortableDecoratorScope.js +2 -2
- package/dist/esm/src/errors/NonExistentScopeProvidedToResort.js +2 -2
- package/dist/esm/src/errors/SortableDecoratorRequiresColumnOrBelongsToAssociation.js +3 -3
- package/dist/esm/src/errors/associations/CanOnlyPassBelongsToModelParam.js +1 -1
- package/dist/esm/src/errors/associations/CannotAssociateThroughPolymorphic.js +1 -1
- package/dist/esm/src/errors/associations/CannotCreateAssociationWithThroughContext.js +1 -1
- package/dist/esm/src/errors/associations/CannotJoinPolymorphicBelongsToError.js +1 -1
- package/dist/esm/src/errors/associations/CannotPassNullOrUndefinedToRequiredBelongsTo.js +1 -1
- package/dist/esm/src/errors/associations/InvalidComputedForeignKey.js +2 -2
- package/dist/esm/src/errors/associations/JoinAttemptedOnMissingAssociation.js +4 -4
- package/dist/esm/src/errors/associations/MissingThroughAssociation.js +4 -4
- package/dist/esm/src/errors/associations/MissingThroughAssociationSource.js +10 -10
- package/dist/esm/src/errors/associations/NonLoadedAssociation.js +1 -1
- package/dist/esm/src/errors/ops/AnyRequiresArrayColumn.js +1 -1
- package/dist/esm/src/errors/schema-builder/FailedToIdentifyAssociation.js +4 -4
- package/dist/esm/src/errors/sti/STIChildMissing.js +1 -1
- package/dist/esm/src/errors/sti/StiChildIncompatibleWithSoftDeleteDecorator.js +1 -1
- package/dist/esm/src/index.js +0 -13
- package/dist/types/src/Dream.d.ts +50 -1
- package/dist/types/src/decorators/Decorators.d.ts +34 -26
- package/dist/types/src/index.d.ts +0 -13
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- 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 +31 -28
- package/docs/classes/Dream.html +147 -123
- package/docs/classes/DreamApplication.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +3 -3
- 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 +50 -50
- 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 +1 -1
- package/docs/functions/RendersOne.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/Scope.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/Validate.html +1 -1
- package/docs/functions/Validates.html +1 -1
- package/docs/functions/Virtual.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/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/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/modules.html +1 -14
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.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/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 -1
- package/dist/cjs/src/errors/sortable/CannotCallSortableOnSTIChild.js +0 -18
- package/dist/esm/src/errors/sortable/CannotCallSortableOnSTIChild.js +0 -15
- package/dist/types/src/errors/sortable/CannotCallSortableOnSTIChild.d.ts +0 -6
- package/docs/functions/AfterCreate.html +0 -1
- package/docs/functions/AfterCreateCommit.html +0 -13
- package/docs/functions/AfterDestroy.html +0 -1
- package/docs/functions/AfterDestroyCommit.html +0 -13
- package/docs/functions/AfterSave.html +0 -1
- package/docs/functions/AfterSaveCommit.html +0 -13
- package/docs/functions/AfterUpdate.html +0 -1
- package/docs/functions/AfterUpdateCommit.html +0 -13
- package/docs/functions/BeforeCreate.html +0 -1
- package/docs/functions/BeforeDestroy.html +0 -1
- package/docs/functions/BeforeSave.html +0 -1
- package/docs/functions/BeforeUpdate.html +0 -1
- package/docs/functions/Sortable.html +0 -1
|
@@ -97,8 +97,16 @@ export default class Decorators {
|
|
|
97
97
|
// end: HasOne
|
|
98
98
|
//////////////
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
100
|
+
* Sortable decorator.
|
|
101
|
+
*
|
|
102
|
+
* NOTE: the Sortable decorator may not be used in STI child models (it may be used in the STI base class)
|
|
103
|
+
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* class Balloon {
|
|
106
|
+
* @Deco.Sortable()
|
|
107
|
+
* public position: DreamColumn<Balloon, 'position'>
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
102
110
|
*
|
|
103
111
|
* @param scope - The column, association, or combination there-of which you would like to restrict the incrementing logic to
|
|
104
112
|
* @returns A Sortable decorator
|
|
@@ -107,11 +115,11 @@ export default class Decorators {
|
|
|
107
115
|
return Sortable(opts);
|
|
108
116
|
}
|
|
109
117
|
/**
|
|
110
|
-
*
|
|
118
|
+
* BeforeCreate decorator
|
|
111
119
|
*
|
|
112
120
|
* ```ts
|
|
113
121
|
* class User {
|
|
114
|
-
*
|
|
122
|
+
* @Deco.BeforeCreate()
|
|
115
123
|
* public doSomething() {
|
|
116
124
|
* console.log('hi!')
|
|
117
125
|
* }
|
|
@@ -125,11 +133,11 @@ export default class Decorators {
|
|
|
125
133
|
return BeforeCreate(opts);
|
|
126
134
|
}
|
|
127
135
|
/**
|
|
128
|
-
*
|
|
136
|
+
* BeforeSave decorator
|
|
129
137
|
*
|
|
130
138
|
* ```ts
|
|
131
139
|
* class User {
|
|
132
|
-
*
|
|
140
|
+
* @Deco.BeforeSave()
|
|
133
141
|
* public doSomething() {
|
|
134
142
|
* console.log('hi!')
|
|
135
143
|
* }
|
|
@@ -143,11 +151,11 @@ export default class Decorators {
|
|
|
143
151
|
return BeforeSave(opts);
|
|
144
152
|
}
|
|
145
153
|
/**
|
|
146
|
-
*
|
|
154
|
+
* BeforeUpdate decorator
|
|
147
155
|
*
|
|
148
156
|
* ```ts
|
|
149
157
|
* class User {
|
|
150
|
-
*
|
|
158
|
+
* @Deco.BeforeUpdate()
|
|
151
159
|
* public doSomething() {
|
|
152
160
|
* console.log('hi!')
|
|
153
161
|
* }
|
|
@@ -161,11 +169,11 @@ export default class Decorators {
|
|
|
161
169
|
return BeforeUpdate(opts);
|
|
162
170
|
}
|
|
163
171
|
/**
|
|
164
|
-
*
|
|
172
|
+
* BeforeDestroy decorator
|
|
165
173
|
*
|
|
166
174
|
* ```ts
|
|
167
175
|
* class User {
|
|
168
|
-
*
|
|
176
|
+
* @Deco.BeforeDestroy()
|
|
169
177
|
* public doSomething() {
|
|
170
178
|
* console.log('hi!')
|
|
171
179
|
* }
|
|
@@ -178,11 +186,11 @@ export default class Decorators {
|
|
|
178
186
|
return BeforeDestroy();
|
|
179
187
|
}
|
|
180
188
|
/**
|
|
181
|
-
*
|
|
189
|
+
* AfterCreate decorator
|
|
182
190
|
*
|
|
183
191
|
* ```ts
|
|
184
192
|
* class User {
|
|
185
|
-
*
|
|
193
|
+
* @Deco.AfterCreate()
|
|
186
194
|
* public doSomething() {
|
|
187
195
|
* console.log('hi!')
|
|
188
196
|
* }
|
|
@@ -196,11 +204,11 @@ export default class Decorators {
|
|
|
196
204
|
return AfterCreate(opts);
|
|
197
205
|
}
|
|
198
206
|
/**
|
|
199
|
-
*
|
|
207
|
+
* AfterCreateCommit decorator
|
|
200
208
|
*
|
|
201
209
|
* ```ts
|
|
202
210
|
* class User {
|
|
203
|
-
*
|
|
211
|
+
* @Deco.AfterCreateCommit()
|
|
204
212
|
* public doSomething() {
|
|
205
213
|
* console.log('hi!')
|
|
206
214
|
* }
|
|
@@ -213,11 +221,11 @@ export default class Decorators {
|
|
|
213
221
|
return AfterCreateCommit(opts);
|
|
214
222
|
}
|
|
215
223
|
/**
|
|
216
|
-
*
|
|
224
|
+
* AfterSave decorator
|
|
217
225
|
*
|
|
218
226
|
* ```ts
|
|
219
227
|
* class User {
|
|
220
|
-
*
|
|
228
|
+
* @Deco.AfterSave()
|
|
221
229
|
* public doSomething() {
|
|
222
230
|
* console.log('hi!')
|
|
223
231
|
* }
|
|
@@ -231,11 +239,11 @@ export default class Decorators {
|
|
|
231
239
|
return AfterSave(opts);
|
|
232
240
|
}
|
|
233
241
|
/**
|
|
234
|
-
*
|
|
242
|
+
* AfterSaveCommit decorator
|
|
235
243
|
*
|
|
236
244
|
* ```ts
|
|
237
245
|
* class User {
|
|
238
|
-
*
|
|
246
|
+
* @Deco.AfterSaveCommit()
|
|
239
247
|
* public doSomething() {
|
|
240
248
|
* console.log('hi!')
|
|
241
249
|
* }
|
|
@@ -249,11 +257,11 @@ export default class Decorators {
|
|
|
249
257
|
return AfterSaveCommit(opts);
|
|
250
258
|
}
|
|
251
259
|
/**
|
|
252
|
-
*
|
|
260
|
+
* AfterUpdate decorator
|
|
253
261
|
*
|
|
254
262
|
* ```ts
|
|
255
263
|
* class User {
|
|
256
|
-
*
|
|
264
|
+
* @Deco.AfterUpdate()
|
|
257
265
|
* public doSomething() {
|
|
258
266
|
* console.log('hi!')
|
|
259
267
|
* }
|
|
@@ -267,11 +275,11 @@ export default class Decorators {
|
|
|
267
275
|
return AfterUpdate(opts);
|
|
268
276
|
}
|
|
269
277
|
/**
|
|
270
|
-
*
|
|
278
|
+
* AfterUpdateCommit decorator
|
|
271
279
|
*
|
|
272
280
|
* ```ts
|
|
273
281
|
* class User {
|
|
274
|
-
*
|
|
282
|
+
* @Deco.AfterUpdateCommit()
|
|
275
283
|
* public doSomething() {
|
|
276
284
|
* console.log('hi!')
|
|
277
285
|
* }
|
|
@@ -285,11 +293,11 @@ export default class Decorators {
|
|
|
285
293
|
return AfterUpdateCommit(opts);
|
|
286
294
|
}
|
|
287
295
|
/**
|
|
288
|
-
*
|
|
296
|
+
* AfterDestroy decorator
|
|
289
297
|
*
|
|
290
298
|
* ```ts
|
|
291
299
|
* class User {
|
|
292
|
-
*
|
|
300
|
+
* @Deco.AfterDestroy()
|
|
293
301
|
* public doSomething() {
|
|
294
302
|
* console.log('hi!')
|
|
295
303
|
* }
|
|
@@ -303,11 +311,11 @@ export default class Decorators {
|
|
|
303
311
|
return AfterDestroy();
|
|
304
312
|
}
|
|
305
313
|
/**
|
|
306
|
-
*
|
|
314
|
+
* AfterDestroyCommit decorator
|
|
307
315
|
*
|
|
308
316
|
* ```ts
|
|
309
317
|
* class User {
|
|
310
|
-
*
|
|
318
|
+
* @Deco.AfterDestroyCommit()
|
|
311
319
|
* public doSomething() {
|
|
312
320
|
* console.log('hi!')
|
|
313
321
|
* }
|
|
@@ -21,7 +21,7 @@ export default function STI(dreamClass, { value } = {}) {
|
|
|
21
21
|
stiChildClass['sti'] = {
|
|
22
22
|
active: true,
|
|
23
23
|
baseClass,
|
|
24
|
-
value: value || stiChildClass.
|
|
24
|
+
value: value || stiChildClass.sanitizedName,
|
|
25
25
|
};
|
|
26
26
|
stiChildClass[STI_SCOPE_NAME] = function (query) {
|
|
27
27
|
return query.where({ type: stiChildClass['sti'].value });
|
|
@@ -38,7 +38,7 @@ export function foreignKeyTypeField(foreignKey, dream, partialAssociation) {
|
|
|
38
38
|
}
|
|
39
39
|
export function modelCBtoSingleDreamClass(dreamClass, partialAssociation) {
|
|
40
40
|
if (Array.isArray(partialAssociation.modelCB()))
|
|
41
|
-
throw new Error(`Polymorphic association ${partialAssociation.as} on model ${dreamClass.
|
|
41
|
+
throw new Error(`Polymorphic association ${partialAssociation.as} on model ${dreamClass.sanitizedName} requires an explicit foreignKey`);
|
|
42
42
|
return partialAssociation.modelCB();
|
|
43
43
|
}
|
|
44
44
|
export function applyGetterAndSetter(target, partialAssociation, { foreignKeyBase, isBelongsTo, } = {}) {
|
|
@@ -76,7 +76,7 @@ export function applyGetterAndSetter(target, partialAssociation, { foreignKeyBas
|
|
|
76
76
|
partialAssociation.primaryKeyValue(associatedModel);
|
|
77
77
|
if (partialAssociation.polymorphic)
|
|
78
78
|
this[foreignKeyTypeField(foreignKeyBase, dreamClass, partialAssociation)] =
|
|
79
|
-
associatedModel?.
|
|
79
|
+
associatedModel?.['sanitizedConstructorName'];
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
});
|
|
@@ -93,7 +93,7 @@ export function associationPrimaryKeyAccessors(partialAssociation, dreamClass) {
|
|
|
93
93
|
if (Array.isArray(associationClass)) {
|
|
94
94
|
throw new Error(`
|
|
95
95
|
Cannot lookup primaryKey on polymorphic association:
|
|
96
|
-
dream class: ${dreamClass.
|
|
96
|
+
dream class: ${dreamClass.sanitizedName}
|
|
97
97
|
association: ${this.as}
|
|
98
98
|
`);
|
|
99
99
|
}
|
|
@@ -13,7 +13,7 @@ export function afterCreateImplementation(target, key, opts = {}) {
|
|
|
13
13
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
14
14
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
15
15
|
const hookStatement = {
|
|
16
|
-
className: dreamClass.
|
|
16
|
+
className: dreamClass.sanitizedName,
|
|
17
17
|
method: key,
|
|
18
18
|
type: 'afterCreate',
|
|
19
19
|
ifChanged: opts.ifChanged,
|
|
@@ -30,7 +30,7 @@ export function afterCreateCommitImplementation(target, key, opts = {}) {
|
|
|
30
30
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
31
31
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
32
32
|
const hookStatement = {
|
|
33
|
-
className: dreamClass.
|
|
33
|
+
className: dreamClass.sanitizedName,
|
|
34
34
|
method: key,
|
|
35
35
|
type: 'afterCreateCommit',
|
|
36
36
|
ifChanged: opts.ifChanged,
|
|
@@ -13,7 +13,7 @@ export function afterDestroyImplementation(target, key) {
|
|
|
13
13
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
14
14
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
15
15
|
const hookStatement = {
|
|
16
|
-
className: dreamClass.
|
|
16
|
+
className: dreamClass.sanitizedName,
|
|
17
17
|
method: key,
|
|
18
18
|
type: 'afterDestroy',
|
|
19
19
|
};
|
|
@@ -28,7 +28,7 @@ export function afterDestroyCommitImplementation(target, key) {
|
|
|
28
28
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
29
29
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
30
30
|
const hookStatement = {
|
|
31
|
-
className: dreamClass.
|
|
31
|
+
className: dreamClass.sanitizedName,
|
|
32
32
|
method: key,
|
|
33
33
|
type: 'afterDestroyCommit',
|
|
34
34
|
};
|
|
@@ -13,7 +13,7 @@ export function afterSaveImplementation(target, key, opts = {}) {
|
|
|
13
13
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
14
14
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
15
15
|
const hookStatement = {
|
|
16
|
-
className: dreamClass.
|
|
16
|
+
className: dreamClass.sanitizedName,
|
|
17
17
|
method: key,
|
|
18
18
|
type: 'afterSave',
|
|
19
19
|
ifChanged: opts.ifChanged,
|
|
@@ -30,7 +30,7 @@ export function afterSaveCommitImplementation(target, key, opts = {}) {
|
|
|
30
30
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
31
31
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
32
32
|
const hookStatement = {
|
|
33
|
-
className: dreamClass.
|
|
33
|
+
className: dreamClass.sanitizedName,
|
|
34
34
|
method: key,
|
|
35
35
|
type: 'afterSaveCommit',
|
|
36
36
|
ifChanged: opts.ifChanged,
|
|
@@ -13,7 +13,7 @@ export function afterUpdateImplementation(target, key, opts = {}) {
|
|
|
13
13
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
14
14
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
15
15
|
const hookStatement = {
|
|
16
|
-
className: dreamClass.
|
|
16
|
+
className: dreamClass.sanitizedName,
|
|
17
17
|
method: key,
|
|
18
18
|
type: 'afterUpdate',
|
|
19
19
|
ifChanged: opts.ifChanged,
|
|
@@ -30,7 +30,7 @@ export function afterUpdateCommitImplementation(target, key, opts = {}) {
|
|
|
30
30
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
31
31
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
32
32
|
const hookStatement = {
|
|
33
|
-
className: dreamClass.
|
|
33
|
+
className: dreamClass.sanitizedName,
|
|
34
34
|
method: key,
|
|
35
35
|
type: 'afterUpdateCommit',
|
|
36
36
|
ifChanged: opts.ifChanged,
|
|
@@ -13,7 +13,7 @@ export function beforeCreateImplementation(target, key, opts = {}) {
|
|
|
13
13
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
14
14
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
15
15
|
const hookStatement = {
|
|
16
|
-
className: dreamClass.
|
|
16
|
+
className: dreamClass.sanitizedName,
|
|
17
17
|
method: key,
|
|
18
18
|
type: 'beforeCreate',
|
|
19
19
|
ifChanging: opts.ifChanging,
|
|
@@ -13,7 +13,7 @@ export function beforeDestroyImplementation(target, key) {
|
|
|
13
13
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
14
14
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
15
15
|
const hookStatement = {
|
|
16
|
-
className: dreamClass.
|
|
16
|
+
className: dreamClass.sanitizedName,
|
|
17
17
|
method: key,
|
|
18
18
|
type: 'beforeDestroy',
|
|
19
19
|
};
|
|
@@ -13,7 +13,7 @@ export function beforeSaveImplementation(target, key, opts = {}) {
|
|
|
13
13
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
14
14
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
15
15
|
const hookStatement = {
|
|
16
|
-
className: dreamClass.
|
|
16
|
+
className: dreamClass.sanitizedName,
|
|
17
17
|
method: key,
|
|
18
18
|
type: 'beforeSave',
|
|
19
19
|
ifChanging: opts.ifChanging,
|
|
@@ -13,7 +13,7 @@ export function beforeUpdateImplementation(target, key, opts = {}) {
|
|
|
13
13
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
14
14
|
dreamClass['hooks'] = blankHooksFactory(dreamClass);
|
|
15
15
|
const hookStatement = {
|
|
16
|
-
className: dreamClass.
|
|
16
|
+
className: dreamClass.sanitizedName,
|
|
17
17
|
method: key,
|
|
18
18
|
type: 'beforeUpdate',
|
|
19
19
|
ifChanging: opts.ifChanging,
|
|
@@ -6,6 +6,7 @@ import { afterDestroyCommitImplementation } from '../hooks/AfterDestroyCommit.js
|
|
|
6
6
|
import { afterUpdateImplementation } from '../hooks/AfterUpdate.js';
|
|
7
7
|
import { afterUpdateCommitImplementation } from '../hooks/AfterUpdateCommit.js';
|
|
8
8
|
import { beforeSaveImplementation } from '../hooks/BeforeSave.js';
|
|
9
|
+
import { STI_SCOPE_NAME } from '../STI.js';
|
|
9
10
|
import scopeArray from './helpers/scopeArray.js';
|
|
10
11
|
import afterSortableCreate from './hooks/afterSortableCreate.js';
|
|
11
12
|
import afterSortableDestroy from './hooks/afterSortableDestroy.js';
|
|
@@ -19,18 +20,6 @@ export default function Sortable(opts = {}) {
|
|
|
19
20
|
const dreamClass = dream.constructor;
|
|
20
21
|
if (!dreamClass['globallyInitializingDecorators'])
|
|
21
22
|
return;
|
|
22
|
-
if (dreamClass['sti']['active']) {
|
|
23
|
-
if (!(dreamClass instanceof dreamClass['stiBaseClassOrOwnClass'])) {
|
|
24
|
-
// what we should really be doing is throwing CannotCallSortableOnSTIChild,
|
|
25
|
-
// but we cannot, since there is no way to know during this initializer if
|
|
26
|
-
// the Sortable decorator was applied to the STI child, or the STI parent.
|
|
27
|
-
//
|
|
28
|
-
// because of this bizarre issue, we are forced to early return when
|
|
29
|
-
// we are processing Sortable on an STI child.
|
|
30
|
-
// throw new CannotCallSortableOnSTIChild(dreamClass)
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
23
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'sortableFields')) {
|
|
35
24
|
// This pattern allows `sortableFields` on a base STI class and on
|
|
36
25
|
// child STI classes. The new `sortableFields` property will be created
|
|
@@ -55,7 +44,7 @@ export default function Sortable(opts = {}) {
|
|
|
55
44
|
// before saving, we remember the new value for position, but clear it from our
|
|
56
45
|
// supervised attributes to prevent position from saving
|
|
57
46
|
dreamPrototype[beforeSaveMethodName] = async function (txn) {
|
|
58
|
-
let query = dreamClass.query();
|
|
47
|
+
let query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME);
|
|
59
48
|
if (txn)
|
|
60
49
|
query = query.txn(txn);
|
|
61
50
|
await beforeSortableSave({
|
|
@@ -70,7 +59,7 @@ export default function Sortable(opts = {}) {
|
|
|
70
59
|
// if no transaction is provided, leverage update commit hook instead
|
|
71
60
|
if (!txn)
|
|
72
61
|
return;
|
|
73
|
-
const query = dreamClass.query().txn(txn);
|
|
62
|
+
const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME).txn(txn);
|
|
74
63
|
await afterUpdateSortable({
|
|
75
64
|
dream: this,
|
|
76
65
|
positionField,
|
|
@@ -83,7 +72,7 @@ export default function Sortable(opts = {}) {
|
|
|
83
72
|
// if transaction is provided, leverage update hook instead
|
|
84
73
|
if (txn)
|
|
85
74
|
return;
|
|
86
|
-
const query = dreamClass.query();
|
|
75
|
+
const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME);
|
|
87
76
|
await afterUpdateSortable({
|
|
88
77
|
dream: this,
|
|
89
78
|
positionField,
|
|
@@ -98,7 +87,7 @@ export default function Sortable(opts = {}) {
|
|
|
98
87
|
// if no transaction is provided, leverage create commit hook instead
|
|
99
88
|
if (!txn)
|
|
100
89
|
return;
|
|
101
|
-
const query = dreamClass.query().txn(txn);
|
|
90
|
+
const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME).txn(txn);
|
|
102
91
|
await afterSortableCreate({
|
|
103
92
|
dream: this,
|
|
104
93
|
positionField,
|
|
@@ -111,7 +100,7 @@ export default function Sortable(opts = {}) {
|
|
|
111
100
|
// if transaction is provided, leverage create hook instead
|
|
112
101
|
if (txn)
|
|
113
102
|
return;
|
|
114
|
-
const query = dreamClass.query();
|
|
103
|
+
const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME);
|
|
115
104
|
await afterSortableCreate({
|
|
116
105
|
dream: this,
|
|
117
106
|
positionField,
|
|
@@ -125,7 +114,7 @@ export default function Sortable(opts = {}) {
|
|
|
125
114
|
// if no transaction is provided, leverage destroy commit hook instead
|
|
126
115
|
if (!txn)
|
|
127
116
|
return;
|
|
128
|
-
const query = dreamClass.query().txn(txn);
|
|
117
|
+
const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME).txn(txn);
|
|
129
118
|
await afterSortableDestroy({
|
|
130
119
|
dream: this,
|
|
131
120
|
positionField,
|
|
@@ -137,7 +126,7 @@ export default function Sortable(opts = {}) {
|
|
|
137
126
|
// if transaction is provided, leverage destroy hook instead
|
|
138
127
|
if (txn)
|
|
139
128
|
return;
|
|
140
|
-
const query = dreamClass.query();
|
|
129
|
+
const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME);
|
|
141
130
|
await afterSortableDestroy({
|
|
142
131
|
dream: this,
|
|
143
132
|
positionField,
|
|
@@ -365,7 +365,7 @@ export default class Query extends ConnectedToDB {
|
|
|
365
365
|
async findOrFail(primaryKey) {
|
|
366
366
|
const record = await this.find(primaryKey);
|
|
367
367
|
if (!record)
|
|
368
|
-
throw new RecordNotFound(this.dreamInstance
|
|
368
|
+
throw new RecordNotFound(this.dreamInstance['sanitizedConstructorName']);
|
|
369
369
|
return record;
|
|
370
370
|
}
|
|
371
371
|
/**
|
|
@@ -400,7 +400,7 @@ export default class Query extends ConnectedToDB {
|
|
|
400
400
|
async findOrFailBy(whereStatement) {
|
|
401
401
|
const record = await this.findBy(whereStatement);
|
|
402
402
|
if (!record)
|
|
403
|
-
throw new RecordNotFound(this.dreamInstance
|
|
403
|
+
throw new RecordNotFound(this.dreamInstance['sanitizedConstructorName']);
|
|
404
404
|
return record;
|
|
405
405
|
}
|
|
406
406
|
/**
|
|
@@ -1420,7 +1420,7 @@ export default class Query extends ConnectedToDB {
|
|
|
1420
1420
|
async firstOrFail() {
|
|
1421
1421
|
const record = await this.first();
|
|
1422
1422
|
if (!record)
|
|
1423
|
-
throw new RecordNotFound(this.dreamInstance
|
|
1423
|
+
throw new RecordNotFound(this.dreamInstance['sanitizedConstructorName']);
|
|
1424
1424
|
return record;
|
|
1425
1425
|
}
|
|
1426
1426
|
/**
|
|
@@ -1459,7 +1459,7 @@ export default class Query extends ConnectedToDB {
|
|
|
1459
1459
|
async lastOrFail() {
|
|
1460
1460
|
const record = await this.last();
|
|
1461
1461
|
if (!record)
|
|
1462
|
-
throw new RecordNotFound(this.dreamInstance
|
|
1462
|
+
throw new RecordNotFound(this.dreamInstance['sanitizedConstructorName']);
|
|
1463
1463
|
return record;
|
|
1464
1464
|
}
|
|
1465
1465
|
/**
|
|
@@ -1754,7 +1754,7 @@ export default class Query extends ConnectedToDB {
|
|
|
1754
1754
|
}
|
|
1755
1755
|
async preloadPolymorphicAssociationModel(dreams, association, associatedDreamClass, associatedDreams) {
|
|
1756
1756
|
const relevantAssociatedModels = dreams.filter((dream) => {
|
|
1757
|
-
return dream[association.foreignKeyTypeField()] === associatedDreamClass['
|
|
1757
|
+
return dream[association.foreignKeyTypeField()] === associatedDreamClass['stiBaseClassOrOwnClassName'];
|
|
1758
1758
|
});
|
|
1759
1759
|
if (relevantAssociatedModels.length) {
|
|
1760
1760
|
dreams.forEach((dream) => {
|
|
@@ -1777,7 +1777,7 @@ export default class Query extends ConnectedToDB {
|
|
|
1777
1777
|
for (const loadedAssociation of loadedAssociations) {
|
|
1778
1778
|
dreams
|
|
1779
1779
|
.filter((dream) => {
|
|
1780
|
-
return (dream[association.foreignKeyTypeField()] === loadedAssociation['
|
|
1780
|
+
return (dream[association.foreignKeyTypeField()] === loadedAssociation['stiBaseClassOrOwnClassName'] &&
|
|
1781
1781
|
dream[association.foreignKey()] === association.primaryKeyValue(loadedAssociation));
|
|
1782
1782
|
})
|
|
1783
1783
|
.forEach((dream) => {
|
|
@@ -2070,8 +2070,8 @@ export default class Query extends ConnectedToDB {
|
|
|
2070
2070
|
if (association.polymorphic) {
|
|
2071
2071
|
join = join.on((eb) => this.whereStatementToExpressionWrapper(eb, this.aliasWhereStatement({
|
|
2072
2072
|
[association.foreignKeyTypeField()]: throughClass
|
|
2073
|
-
? throughClass['
|
|
2074
|
-
: dreamClass['
|
|
2073
|
+
? throughClass['stiBaseClassOrOwnClassName']
|
|
2074
|
+
: dreamClass['stiBaseClassOrOwnClassName'],
|
|
2075
2075
|
}, currentAssociationTableOrAlias)));
|
|
2076
2076
|
}
|
|
2077
2077
|
if (timeToApplyThroughAssociations) {
|
|
@@ -25,7 +25,7 @@ export default async function createAssociation(dream, txn = null, associationNa
|
|
|
25
25
|
...opts,
|
|
26
26
|
};
|
|
27
27
|
if (hasAssociation.polymorphic) {
|
|
28
|
-
modifiedOpts[hasAssociation.foreignKeyTypeField()] = dream['
|
|
28
|
+
modifiedOpts[hasAssociation.foreignKeyTypeField()] = dream['stiBaseClassOrOwnClassName'];
|
|
29
29
|
}
|
|
30
30
|
if (txn) {
|
|
31
31
|
hasresult = await associationClass.txn(txn).create(modifiedOpts);
|
|
@@ -51,7 +51,7 @@ export async function runHook(statement, dream, txn) {
|
|
|
51
51
|
Attempting to run ${statement.method} as part of the ${statement.type}
|
|
52
52
|
Dream model hook sequence, but we encountered a method that does not exist.
|
|
53
53
|
|
|
54
|
-
Please make sure "${statement.method}" is defined on ${dream
|
|
54
|
+
Please make sure "${statement.method}" is defined on ${dream['sanitizedConstructorName']}
|
|
55
55
|
`);
|
|
56
56
|
}
|
|
57
57
|
await dream[statement.method](txn);
|
|
@@ -20,7 +20,7 @@ export default async function saveDream(dream, txn = null, { skipHooks = false }
|
|
|
20
20
|
// need to check validations after running before hooks, or else
|
|
21
21
|
// model hooks that might make a model valid cannot run
|
|
22
22
|
if (dream.isInvalid)
|
|
23
|
-
throw new ValidationError(dream
|
|
23
|
+
throw new ValidationError(dream['sanitizedConstructorName'], dream.errors);
|
|
24
24
|
if (alreadyPersisted && !dream.isDirty)
|
|
25
25
|
return dream;
|
|
26
26
|
let query;
|
|
@@ -25,7 +25,7 @@ export default function sqlResultToDreamInstance(dreamClass, sqlResult) {
|
|
|
25
25
|
export function findExtendingDreamClass(dreamClass, type) {
|
|
26
26
|
if (!dreamClass['extendedBy'])
|
|
27
27
|
return undefined;
|
|
28
|
-
const extendingDreamClass = dreamClass['extendedBy'].find(extendingDreamClass => extendingDreamClass.
|
|
28
|
+
const extendingDreamClass = dreamClass['extendedBy'].find(extendingDreamClass => extendingDreamClass.sanitizedName === type);
|
|
29
29
|
if (extendingDreamClass)
|
|
30
30
|
return extendingDreamClass;
|
|
31
31
|
return dreamClass['extendedBy']
|
|
@@ -10,7 +10,7 @@ Cannot call "undestroy" on a non-SoftDelete model. Ensure that your
|
|
|
10
10
|
model has @SoftDelete applied before calling "undestroy":
|
|
11
11
|
|
|
12
12
|
@SoftDelete()
|
|
13
|
-
class ${this.dreamClass.
|
|
13
|
+
class ${this.dreamClass.sanitizedName} extends ApplicationModel {
|
|
14
14
|
...
|
|
15
15
|
}
|
|
16
16
|
`;
|
|
@@ -10,7 +10,7 @@ export default class CannotDefineAssociationWithBothDependentAndPassthrough exte
|
|
|
10
10
|
return `
|
|
11
11
|
Cannot define association with both "dependent" and "DreamConst.passthrough".
|
|
12
12
|
Error found when trying to parse "${this.associationName}" on the
|
|
13
|
-
${this.dreamClass.
|
|
13
|
+
${this.dreamClass.sanitizedName} dream class.
|
|
14
14
|
`;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -10,7 +10,7 @@ export default class CannotDefineAssociationWithBothDependentAndRequiredOnClause
|
|
|
10
10
|
return `
|
|
11
11
|
Cannot define association with both "dependent" and "DreamConst.required".
|
|
12
12
|
Error found when trying to parse "${this.associationName}" on the
|
|
13
|
-
${this.dreamClass.
|
|
13
|
+
${this.dreamClass.sanitizedName} dream class.
|
|
14
14
|
`;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -10,7 +10,7 @@ export default class CannotPassUndefinedAsAValueToAWhereClause extends Error {
|
|
|
10
10
|
return `
|
|
11
11
|
Cannot pass undefined as a value to a where clause.
|
|
12
12
|
|
|
13
|
-
dream class: ${this.dreamClass.
|
|
13
|
+
dream class: ${this.dreamClass.sanitizedName}
|
|
14
14
|
key receiving an undefined value: ${this.key}
|
|
15
15
|
`;
|
|
16
16
|
}
|
|
@@ -6,7 +6,7 @@ export default class CreateOrFindByFailedToCreateAndFind extends Error {
|
|
|
6
6
|
}
|
|
7
7
|
get message() {
|
|
8
8
|
return `
|
|
9
|
-
Failed to create instance of ${this.dreamClass.
|
|
9
|
+
Failed to create instance of ${this.dreamClass.sanitizedName} and no matching model exists.
|
|
10
10
|
|
|
11
11
|
The likely cause is that one of the \`createWith\` fields violates
|
|
12
12
|
a uniqueness constraint.
|
|
@@ -13,7 +13,7 @@ export default class DoNotSetEncryptedFieldsDirectly extends Error {
|
|
|
13
13
|
Do not set @Encrypted columns directly. Instead, set their accessors, so that
|
|
14
14
|
those fields can be encrypted by Dream internally.
|
|
15
15
|
|
|
16
|
-
Dream class: ${this.dreamClass.
|
|
16
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
17
17
|
Problematic setter: ${this.encryptedColumnName}
|
|
18
18
|
Setter to be used instead: ${this.encryptedProperty}`;
|
|
19
19
|
}
|
|
@@ -12,7 +12,7 @@ Whenever the using SoftDelete decorator, you must have either a deletedAt column
|
|
|
12
12
|
or else another column defined, along with an ovrriding getter on your model, like so:
|
|
13
13
|
|
|
14
14
|
@SoftDelete()
|
|
15
|
-
class ${this.dreamClass.
|
|
15
|
+
class ${this.dreamClass.sanitizedName} extends ApplicationModel {
|
|
16
16
|
public get deletedAtField() {
|
|
17
17
|
return 'customDeletedAtField' as const
|
|
18
18
|
}
|
|
@@ -7,14 +7,14 @@ export default class MissingSerializersDefinition extends Error {
|
|
|
7
7
|
get message() {
|
|
8
8
|
return `
|
|
9
9
|
Missing serializers definition on the following class
|
|
10
|
-
Dream class: ${this.dreamClass.
|
|
10
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
11
11
|
|
|
12
|
-
Try something like this in your ${this.dreamClass.
|
|
12
|
+
Try something like this in your ${this.dreamClass.sanitizedName}'s serializer getter:
|
|
13
13
|
|
|
14
|
-
class ${this.dreamClass.
|
|
15
|
-
public get serializers(): DreamSerializers<${this.dreamClass.
|
|
14
|
+
class ${this.dreamClass.sanitizedName} {
|
|
15
|
+
public get serializers(): DreamSerializers<${this.dreamClass.sanitizedName}> {
|
|
16
16
|
return {
|
|
17
|
-
default: '${this.dreamClass.
|
|
17
|
+
default: '${this.dreamClass.sanitizedName}Serializer'
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
...
|