@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
package/dist/cjs/src/Dream.js
CHANGED
|
@@ -313,6 +313,43 @@ class Dream {
|
|
|
313
313
|
static get stiBaseClassOrOwnClass() {
|
|
314
314
|
return this.sti.baseClass || this;
|
|
315
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* @internal
|
|
318
|
+
*
|
|
319
|
+
* Returns either the base STI class name, or else this class name
|
|
320
|
+
*
|
|
321
|
+
* NOTE: This is necessary due to changes in esbuild strategy WRT esm,
|
|
322
|
+
* compiled class names can contain a prefixing underscore if they contain
|
|
323
|
+
* private fields.
|
|
324
|
+
*
|
|
325
|
+
* This can create confusion when the class name is used as an attribute,
|
|
326
|
+
* as is done in the case of polymorphic associations, which use the class
|
|
327
|
+
* name as the "type" value for the polymorphic association.
|
|
328
|
+
*
|
|
329
|
+
* As such, any time the class name is being used as a value, it should be
|
|
330
|
+
* done using this value, rather than going to the class name directly.
|
|
331
|
+
*
|
|
332
|
+
* see https://github.com/evanw/esbuild/issues/1260 for more information
|
|
333
|
+
*
|
|
334
|
+
* @returns string
|
|
335
|
+
*/
|
|
336
|
+
static get stiBaseClassOrOwnClassName() {
|
|
337
|
+
return this.stiBaseClassOrOwnClass.sanitizedName;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* @internal
|
|
341
|
+
*
|
|
342
|
+
* Returns the class name, replacing prefixed underscores, since esbuild
|
|
343
|
+
* will translate some class names to have underscore prefixes, which can
|
|
344
|
+
* cause unexpected behavior.
|
|
345
|
+
*
|
|
346
|
+
* see https://github.com/evanw/esbuild/issues/1260 for more information
|
|
347
|
+
*
|
|
348
|
+
* @returns string
|
|
349
|
+
*/
|
|
350
|
+
static get sanitizedName() {
|
|
351
|
+
return this.name.replace(/^_/, '');
|
|
352
|
+
}
|
|
316
353
|
/**
|
|
317
354
|
* @internal
|
|
318
355
|
*
|
|
@@ -323,6 +360,26 @@ class Dream {
|
|
|
323
360
|
get stiBaseClassOrOwnClass() {
|
|
324
361
|
return this.constructor.stiBaseClassOrOwnClass;
|
|
325
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* @internal
|
|
365
|
+
*
|
|
366
|
+
* Shadows .stiBaseClassOrOwnClassName. Returns a string
|
|
367
|
+
*
|
|
368
|
+
* @returns A string
|
|
369
|
+
*/
|
|
370
|
+
get stiBaseClassOrOwnClassName() {
|
|
371
|
+
return this.constructor.stiBaseClassOrOwnClassName;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* @internal
|
|
375
|
+
*
|
|
376
|
+
* Shadows .sanitizedName. Returns a string
|
|
377
|
+
*
|
|
378
|
+
* @returns A string
|
|
379
|
+
*/
|
|
380
|
+
get sanitizedConstructorName() {
|
|
381
|
+
return this.constructor.sanitizedName;
|
|
382
|
+
}
|
|
326
383
|
/**
|
|
327
384
|
* @internal
|
|
328
385
|
*
|
|
@@ -1075,7 +1132,7 @@ class Dream {
|
|
|
1075
1132
|
*
|
|
1076
1133
|
* ```ts
|
|
1077
1134
|
* class Post extends ApplicationModel {
|
|
1078
|
-
* @Sortable({ scope: ['user']})
|
|
1135
|
+
* @Deco.Sortable({ scope: ['user']})
|
|
1079
1136
|
* public position: DreamColumn<User, 'position'>
|
|
1080
1137
|
* }
|
|
1081
1138
|
*
|
|
@@ -1858,7 +1915,7 @@ class Dream {
|
|
|
1858
1915
|
}
|
|
1859
1916
|
if (belongsToAssociationMetaData.polymorphic) {
|
|
1860
1917
|
const foreignKeyTypeField = belongsToAssociationMetaData.foreignKeyTypeField();
|
|
1861
|
-
returnValues[foreignKeyTypeField] = associatedObject?.
|
|
1918
|
+
returnValues[foreignKeyTypeField] = associatedObject?.stiBaseClassOrOwnClassName;
|
|
1862
1919
|
setAttributeOnDreamInstance(foreignKeyTypeField, returnValues[foreignKeyTypeField]);
|
|
1863
1920
|
}
|
|
1864
1921
|
}
|
|
@@ -99,8 +99,16 @@ class Decorators {
|
|
|
99
99
|
// end: HasOne
|
|
100
100
|
//////////////
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
102
|
+
* Sortable decorator.
|
|
103
|
+
*
|
|
104
|
+
* NOTE: the Sortable decorator may not be used in STI child models (it may be used in the STI base class)
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* class Balloon {
|
|
108
|
+
* @Deco.Sortable()
|
|
109
|
+
* public position: DreamColumn<Balloon, 'position'>
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
104
112
|
*
|
|
105
113
|
* @param scope - The column, association, or combination there-of which you would like to restrict the incrementing logic to
|
|
106
114
|
* @returns A Sortable decorator
|
|
@@ -109,11 +117,11 @@ class Decorators {
|
|
|
109
117
|
return (0, Sortable_js_1.default)(opts);
|
|
110
118
|
}
|
|
111
119
|
/**
|
|
112
|
-
*
|
|
120
|
+
* BeforeCreate decorator
|
|
113
121
|
*
|
|
114
122
|
* ```ts
|
|
115
123
|
* class User {
|
|
116
|
-
*
|
|
124
|
+
* @Deco.BeforeCreate()
|
|
117
125
|
* public doSomething() {
|
|
118
126
|
* console.log('hi!')
|
|
119
127
|
* }
|
|
@@ -127,11 +135,11 @@ class Decorators {
|
|
|
127
135
|
return (0, BeforeCreate_js_1.default)(opts);
|
|
128
136
|
}
|
|
129
137
|
/**
|
|
130
|
-
*
|
|
138
|
+
* BeforeSave decorator
|
|
131
139
|
*
|
|
132
140
|
* ```ts
|
|
133
141
|
* class User {
|
|
134
|
-
*
|
|
142
|
+
* @Deco.BeforeSave()
|
|
135
143
|
* public doSomething() {
|
|
136
144
|
* console.log('hi!')
|
|
137
145
|
* }
|
|
@@ -145,11 +153,11 @@ class Decorators {
|
|
|
145
153
|
return (0, BeforeSave_js_1.default)(opts);
|
|
146
154
|
}
|
|
147
155
|
/**
|
|
148
|
-
*
|
|
156
|
+
* BeforeUpdate decorator
|
|
149
157
|
*
|
|
150
158
|
* ```ts
|
|
151
159
|
* class User {
|
|
152
|
-
*
|
|
160
|
+
* @Deco.BeforeUpdate()
|
|
153
161
|
* public doSomething() {
|
|
154
162
|
* console.log('hi!')
|
|
155
163
|
* }
|
|
@@ -163,11 +171,11 @@ class Decorators {
|
|
|
163
171
|
return (0, BeforeUpdate_js_1.default)(opts);
|
|
164
172
|
}
|
|
165
173
|
/**
|
|
166
|
-
*
|
|
174
|
+
* BeforeDestroy decorator
|
|
167
175
|
*
|
|
168
176
|
* ```ts
|
|
169
177
|
* class User {
|
|
170
|
-
*
|
|
178
|
+
* @Deco.BeforeDestroy()
|
|
171
179
|
* public doSomething() {
|
|
172
180
|
* console.log('hi!')
|
|
173
181
|
* }
|
|
@@ -180,11 +188,11 @@ class Decorators {
|
|
|
180
188
|
return (0, BeforeDestroy_js_1.default)();
|
|
181
189
|
}
|
|
182
190
|
/**
|
|
183
|
-
*
|
|
191
|
+
* AfterCreate decorator
|
|
184
192
|
*
|
|
185
193
|
* ```ts
|
|
186
194
|
* class User {
|
|
187
|
-
*
|
|
195
|
+
* @Deco.AfterCreate()
|
|
188
196
|
* public doSomething() {
|
|
189
197
|
* console.log('hi!')
|
|
190
198
|
* }
|
|
@@ -198,11 +206,11 @@ class Decorators {
|
|
|
198
206
|
return (0, AfterCreate_js_1.default)(opts);
|
|
199
207
|
}
|
|
200
208
|
/**
|
|
201
|
-
*
|
|
209
|
+
* AfterCreateCommit decorator
|
|
202
210
|
*
|
|
203
211
|
* ```ts
|
|
204
212
|
* class User {
|
|
205
|
-
*
|
|
213
|
+
* @Deco.AfterCreateCommit()
|
|
206
214
|
* public doSomething() {
|
|
207
215
|
* console.log('hi!')
|
|
208
216
|
* }
|
|
@@ -215,11 +223,11 @@ class Decorators {
|
|
|
215
223
|
return (0, AfterCreateCommit_js_1.default)(opts);
|
|
216
224
|
}
|
|
217
225
|
/**
|
|
218
|
-
*
|
|
226
|
+
* AfterSave decorator
|
|
219
227
|
*
|
|
220
228
|
* ```ts
|
|
221
229
|
* class User {
|
|
222
|
-
*
|
|
230
|
+
* @Deco.AfterSave()
|
|
223
231
|
* public doSomething() {
|
|
224
232
|
* console.log('hi!')
|
|
225
233
|
* }
|
|
@@ -233,11 +241,11 @@ class Decorators {
|
|
|
233
241
|
return (0, AfterSave_js_1.default)(opts);
|
|
234
242
|
}
|
|
235
243
|
/**
|
|
236
|
-
*
|
|
244
|
+
* AfterSaveCommit decorator
|
|
237
245
|
*
|
|
238
246
|
* ```ts
|
|
239
247
|
* class User {
|
|
240
|
-
*
|
|
248
|
+
* @Deco.AfterSaveCommit()
|
|
241
249
|
* public doSomething() {
|
|
242
250
|
* console.log('hi!')
|
|
243
251
|
* }
|
|
@@ -251,11 +259,11 @@ class Decorators {
|
|
|
251
259
|
return (0, AfterSaveCommit_js_1.default)(opts);
|
|
252
260
|
}
|
|
253
261
|
/**
|
|
254
|
-
*
|
|
262
|
+
* AfterUpdate decorator
|
|
255
263
|
*
|
|
256
264
|
* ```ts
|
|
257
265
|
* class User {
|
|
258
|
-
*
|
|
266
|
+
* @Deco.AfterUpdate()
|
|
259
267
|
* public doSomething() {
|
|
260
268
|
* console.log('hi!')
|
|
261
269
|
* }
|
|
@@ -269,11 +277,11 @@ class Decorators {
|
|
|
269
277
|
return (0, AfterUpdate_js_1.default)(opts);
|
|
270
278
|
}
|
|
271
279
|
/**
|
|
272
|
-
*
|
|
280
|
+
* AfterUpdateCommit decorator
|
|
273
281
|
*
|
|
274
282
|
* ```ts
|
|
275
283
|
* class User {
|
|
276
|
-
*
|
|
284
|
+
* @Deco.AfterUpdateCommit()
|
|
277
285
|
* public doSomething() {
|
|
278
286
|
* console.log('hi!')
|
|
279
287
|
* }
|
|
@@ -287,11 +295,11 @@ class Decorators {
|
|
|
287
295
|
return (0, AfterUpdateCommit_js_1.default)(opts);
|
|
288
296
|
}
|
|
289
297
|
/**
|
|
290
|
-
*
|
|
298
|
+
* AfterDestroy decorator
|
|
291
299
|
*
|
|
292
300
|
* ```ts
|
|
293
301
|
* class User {
|
|
294
|
-
*
|
|
302
|
+
* @Deco.AfterDestroy()
|
|
295
303
|
* public doSomething() {
|
|
296
304
|
* console.log('hi!')
|
|
297
305
|
* }
|
|
@@ -305,11 +313,11 @@ class Decorators {
|
|
|
305
313
|
return (0, AfterDestroy_js_1.default)();
|
|
306
314
|
}
|
|
307
315
|
/**
|
|
308
|
-
*
|
|
316
|
+
* AfterDestroyCommit decorator
|
|
309
317
|
*
|
|
310
318
|
* ```ts
|
|
311
319
|
* class User {
|
|
312
|
-
*
|
|
320
|
+
* @Deco.AfterDestroyCommit()
|
|
313
321
|
* public doSomething() {
|
|
314
322
|
* console.log('hi!')
|
|
315
323
|
* }
|
|
@@ -25,7 +25,7 @@ function STI(dreamClass, { value } = {}) {
|
|
|
25
25
|
stiChildClass['sti'] = {
|
|
26
26
|
active: true,
|
|
27
27
|
baseClass,
|
|
28
|
-
value: value || stiChildClass.
|
|
28
|
+
value: value || stiChildClass.sanitizedName,
|
|
29
29
|
};
|
|
30
30
|
stiChildClass[exports.STI_SCOPE_NAME] = function (query) {
|
|
31
31
|
return query.where({ type: stiChildClass['sti'].value });
|
|
@@ -47,7 +47,7 @@ function foreignKeyTypeField(foreignKey, dream, partialAssociation) {
|
|
|
47
47
|
}
|
|
48
48
|
function modelCBtoSingleDreamClass(dreamClass, partialAssociation) {
|
|
49
49
|
if (Array.isArray(partialAssociation.modelCB()))
|
|
50
|
-
throw new Error(`Polymorphic association ${partialAssociation.as} on model ${dreamClass.
|
|
50
|
+
throw new Error(`Polymorphic association ${partialAssociation.as} on model ${dreamClass.sanitizedName} requires an explicit foreignKey`);
|
|
51
51
|
return partialAssociation.modelCB();
|
|
52
52
|
}
|
|
53
53
|
function applyGetterAndSetter(target, partialAssociation, { foreignKeyBase, isBelongsTo, } = {}) {
|
|
@@ -85,7 +85,7 @@ function applyGetterAndSetter(target, partialAssociation, { foreignKeyBase, isBe
|
|
|
85
85
|
partialAssociation.primaryKeyValue(associatedModel);
|
|
86
86
|
if (partialAssociation.polymorphic)
|
|
87
87
|
this[foreignKeyTypeField(foreignKeyBase, dreamClass, partialAssociation)] =
|
|
88
|
-
associatedModel?.
|
|
88
|
+
associatedModel?.['sanitizedConstructorName'];
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
});
|
|
@@ -102,7 +102,7 @@ function associationPrimaryKeyAccessors(partialAssociation, dreamClass) {
|
|
|
102
102
|
if (Array.isArray(associationClass)) {
|
|
103
103
|
throw new Error(`
|
|
104
104
|
Cannot lookup primaryKey on polymorphic association:
|
|
105
|
-
dream class: ${dreamClass.
|
|
105
|
+
dream class: ${dreamClass.sanitizedName}
|
|
106
106
|
association: ${this.as}
|
|
107
107
|
`);
|
|
108
108
|
}
|
|
@@ -17,7 +17,7 @@ function afterCreateImplementation(target, key, opts = {}) {
|
|
|
17
17
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
18
18
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
19
19
|
const hookStatement = {
|
|
20
|
-
className: dreamClass.
|
|
20
|
+
className: dreamClass.sanitizedName,
|
|
21
21
|
method: key,
|
|
22
22
|
type: 'afterCreate',
|
|
23
23
|
ifChanged: opts.ifChanged,
|
|
@@ -34,7 +34,7 @@ function afterCreateCommitImplementation(target, key, opts = {}) {
|
|
|
34
34
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
35
35
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
36
36
|
const hookStatement = {
|
|
37
|
-
className: dreamClass.
|
|
37
|
+
className: dreamClass.sanitizedName,
|
|
38
38
|
method: key,
|
|
39
39
|
type: 'afterCreateCommit',
|
|
40
40
|
ifChanged: opts.ifChanged,
|
|
@@ -17,7 +17,7 @@ function afterDestroyImplementation(target, key) {
|
|
|
17
17
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
18
18
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
19
19
|
const hookStatement = {
|
|
20
|
-
className: dreamClass.
|
|
20
|
+
className: dreamClass.sanitizedName,
|
|
21
21
|
method: key,
|
|
22
22
|
type: 'afterDestroy',
|
|
23
23
|
};
|
|
@@ -32,7 +32,7 @@ function afterDestroyCommitImplementation(target, key) {
|
|
|
32
32
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
33
33
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
34
34
|
const hookStatement = {
|
|
35
|
-
className: dreamClass.
|
|
35
|
+
className: dreamClass.sanitizedName,
|
|
36
36
|
method: key,
|
|
37
37
|
type: 'afterDestroyCommit',
|
|
38
38
|
};
|
|
@@ -17,7 +17,7 @@ function afterSaveImplementation(target, key, opts = {}) {
|
|
|
17
17
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
18
18
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
19
19
|
const hookStatement = {
|
|
20
|
-
className: dreamClass.
|
|
20
|
+
className: dreamClass.sanitizedName,
|
|
21
21
|
method: key,
|
|
22
22
|
type: 'afterSave',
|
|
23
23
|
ifChanged: opts.ifChanged,
|
|
@@ -34,7 +34,7 @@ function afterSaveCommitImplementation(target, key, opts = {}) {
|
|
|
34
34
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
35
35
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
36
36
|
const hookStatement = {
|
|
37
|
-
className: dreamClass.
|
|
37
|
+
className: dreamClass.sanitizedName,
|
|
38
38
|
method: key,
|
|
39
39
|
type: 'afterSaveCommit',
|
|
40
40
|
ifChanged: opts.ifChanged,
|
|
@@ -17,7 +17,7 @@ function afterUpdateImplementation(target, key, opts = {}) {
|
|
|
17
17
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
18
18
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
19
19
|
const hookStatement = {
|
|
20
|
-
className: dreamClass.
|
|
20
|
+
className: dreamClass.sanitizedName,
|
|
21
21
|
method: key,
|
|
22
22
|
type: 'afterUpdate',
|
|
23
23
|
ifChanged: opts.ifChanged,
|
|
@@ -34,7 +34,7 @@ function afterUpdateCommitImplementation(target, key, opts = {}) {
|
|
|
34
34
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
35
35
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
36
36
|
const hookStatement = {
|
|
37
|
-
className: dreamClass.
|
|
37
|
+
className: dreamClass.sanitizedName,
|
|
38
38
|
method: key,
|
|
39
39
|
type: 'afterUpdateCommit',
|
|
40
40
|
ifChanged: opts.ifChanged,
|
|
@@ -17,7 +17,7 @@ function beforeCreateImplementation(target, key, opts = {}) {
|
|
|
17
17
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
18
18
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
19
19
|
const hookStatement = {
|
|
20
|
-
className: dreamClass.
|
|
20
|
+
className: dreamClass.sanitizedName,
|
|
21
21
|
method: key,
|
|
22
22
|
type: 'beforeCreate',
|
|
23
23
|
ifChanging: opts.ifChanging,
|
|
@@ -17,7 +17,7 @@ function beforeDestroyImplementation(target, key) {
|
|
|
17
17
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
18
18
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
19
19
|
const hookStatement = {
|
|
20
|
-
className: dreamClass.
|
|
20
|
+
className: dreamClass.sanitizedName,
|
|
21
21
|
method: key,
|
|
22
22
|
type: 'beforeDestroy',
|
|
23
23
|
};
|
|
@@ -17,7 +17,7 @@ function beforeSaveImplementation(target, key, opts = {}) {
|
|
|
17
17
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
18
18
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
19
19
|
const hookStatement = {
|
|
20
|
-
className: dreamClass.
|
|
20
|
+
className: dreamClass.sanitizedName,
|
|
21
21
|
method: key,
|
|
22
22
|
type: 'beforeSave',
|
|
23
23
|
ifChanging: opts.ifChanging,
|
|
@@ -17,7 +17,7 @@ function beforeUpdateImplementation(target, key, opts = {}) {
|
|
|
17
17
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'hooks'))
|
|
18
18
|
dreamClass['hooks'] = (0, shared_js_1.blankHooksFactory)(dreamClass);
|
|
19
19
|
const hookStatement = {
|
|
20
|
-
className: dreamClass.
|
|
20
|
+
className: dreamClass.sanitizedName,
|
|
21
21
|
method: key,
|
|
22
22
|
type: 'beforeUpdate',
|
|
23
23
|
ifChanging: opts.ifChanging,
|
|
@@ -9,6 +9,7 @@ const AfterDestroyCommit_js_1 = require("../hooks/AfterDestroyCommit.js");
|
|
|
9
9
|
const AfterUpdate_js_1 = require("../hooks/AfterUpdate.js");
|
|
10
10
|
const AfterUpdateCommit_js_1 = require("../hooks/AfterUpdateCommit.js");
|
|
11
11
|
const BeforeSave_js_1 = require("../hooks/BeforeSave.js");
|
|
12
|
+
const STI_js_1 = require("../STI.js");
|
|
12
13
|
const scopeArray_js_1 = require("./helpers/scopeArray.js");
|
|
13
14
|
const afterSortableCreate_js_1 = require("./hooks/afterSortableCreate.js");
|
|
14
15
|
const afterSortableDestroy_js_1 = require("./hooks/afterSortableDestroy.js");
|
|
@@ -22,18 +23,6 @@ function Sortable(opts = {}) {
|
|
|
22
23
|
const dreamClass = dream.constructor;
|
|
23
24
|
if (!dreamClass['globallyInitializingDecorators'])
|
|
24
25
|
return;
|
|
25
|
-
if (dreamClass['sti']['active']) {
|
|
26
|
-
if (!(dreamClass instanceof dreamClass['stiBaseClassOrOwnClass'])) {
|
|
27
|
-
// what we should really be doing is throwing CannotCallSortableOnSTIChild,
|
|
28
|
-
// but we cannot, since there is no way to know during this initializer if
|
|
29
|
-
// the Sortable decorator was applied to the STI child, or the STI parent.
|
|
30
|
-
//
|
|
31
|
-
// because of this bizarre issue, we are forced to early return when
|
|
32
|
-
// we are processing Sortable on an STI child.
|
|
33
|
-
// throw new CannotCallSortableOnSTIChild(dreamClass)
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
26
|
if (!Object.getOwnPropertyDescriptor(dreamClass, 'sortableFields')) {
|
|
38
27
|
// This pattern allows `sortableFields` on a base STI class and on
|
|
39
28
|
// child STI classes. The new `sortableFields` property will be created
|
|
@@ -58,7 +47,7 @@ function Sortable(opts = {}) {
|
|
|
58
47
|
// before saving, we remember the new value for position, but clear it from our
|
|
59
48
|
// supervised attributes to prevent position from saving
|
|
60
49
|
dreamPrototype[beforeSaveMethodName] = async function (txn) {
|
|
61
|
-
let query = dreamClass.query();
|
|
50
|
+
let query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME);
|
|
62
51
|
if (txn)
|
|
63
52
|
query = query.txn(txn);
|
|
64
53
|
await (0, beforeSortableSave_js_1.default)({
|
|
@@ -73,7 +62,7 @@ function Sortable(opts = {}) {
|
|
|
73
62
|
// if no transaction is provided, leverage update commit hook instead
|
|
74
63
|
if (!txn)
|
|
75
64
|
return;
|
|
76
|
-
const query = dreamClass.query().txn(txn);
|
|
65
|
+
const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME).txn(txn);
|
|
77
66
|
await (0, afterSortableUpdate_js_1.default)({
|
|
78
67
|
dream: this,
|
|
79
68
|
positionField,
|
|
@@ -86,7 +75,7 @@ function Sortable(opts = {}) {
|
|
|
86
75
|
// if transaction is provided, leverage update hook instead
|
|
87
76
|
if (txn)
|
|
88
77
|
return;
|
|
89
|
-
const query = dreamClass.query();
|
|
78
|
+
const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME);
|
|
90
79
|
await (0, afterSortableUpdate_js_1.default)({
|
|
91
80
|
dream: this,
|
|
92
81
|
positionField,
|
|
@@ -101,7 +90,7 @@ function Sortable(opts = {}) {
|
|
|
101
90
|
// if no transaction is provided, leverage create commit hook instead
|
|
102
91
|
if (!txn)
|
|
103
92
|
return;
|
|
104
|
-
const query = dreamClass.query().txn(txn);
|
|
93
|
+
const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME).txn(txn);
|
|
105
94
|
await (0, afterSortableCreate_js_1.default)({
|
|
106
95
|
dream: this,
|
|
107
96
|
positionField,
|
|
@@ -114,7 +103,7 @@ function Sortable(opts = {}) {
|
|
|
114
103
|
// if transaction is provided, leverage create hook instead
|
|
115
104
|
if (txn)
|
|
116
105
|
return;
|
|
117
|
-
const query = dreamClass.query();
|
|
106
|
+
const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME);
|
|
118
107
|
await (0, afterSortableCreate_js_1.default)({
|
|
119
108
|
dream: this,
|
|
120
109
|
positionField,
|
|
@@ -128,7 +117,7 @@ function Sortable(opts = {}) {
|
|
|
128
117
|
// if no transaction is provided, leverage destroy commit hook instead
|
|
129
118
|
if (!txn)
|
|
130
119
|
return;
|
|
131
|
-
const query = dreamClass.query().txn(txn);
|
|
120
|
+
const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME).txn(txn);
|
|
132
121
|
await (0, afterSortableDestroy_js_1.default)({
|
|
133
122
|
dream: this,
|
|
134
123
|
positionField,
|
|
@@ -140,7 +129,7 @@ function Sortable(opts = {}) {
|
|
|
140
129
|
// if transaction is provided, leverage destroy hook instead
|
|
141
130
|
if (txn)
|
|
142
131
|
return;
|
|
143
|
-
const query = dreamClass.query();
|
|
132
|
+
const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME);
|
|
144
133
|
await (0, afterSortableDestroy_js_1.default)({
|
|
145
134
|
dream: this,
|
|
146
135
|
positionField,
|
|
@@ -367,7 +367,7 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
367
367
|
async findOrFail(primaryKey) {
|
|
368
368
|
const record = await this.find(primaryKey);
|
|
369
369
|
if (!record)
|
|
370
|
-
throw new RecordNotFound_js_1.default(this.dreamInstance
|
|
370
|
+
throw new RecordNotFound_js_1.default(this.dreamInstance['sanitizedConstructorName']);
|
|
371
371
|
return record;
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
@@ -402,7 +402,7 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
402
402
|
async findOrFailBy(whereStatement) {
|
|
403
403
|
const record = await this.findBy(whereStatement);
|
|
404
404
|
if (!record)
|
|
405
|
-
throw new RecordNotFound_js_1.default(this.dreamInstance
|
|
405
|
+
throw new RecordNotFound_js_1.default(this.dreamInstance['sanitizedConstructorName']);
|
|
406
406
|
return record;
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
@@ -1422,7 +1422,7 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
1422
1422
|
async firstOrFail() {
|
|
1423
1423
|
const record = await this.first();
|
|
1424
1424
|
if (!record)
|
|
1425
|
-
throw new RecordNotFound_js_1.default(this.dreamInstance
|
|
1425
|
+
throw new RecordNotFound_js_1.default(this.dreamInstance['sanitizedConstructorName']);
|
|
1426
1426
|
return record;
|
|
1427
1427
|
}
|
|
1428
1428
|
/**
|
|
@@ -1461,7 +1461,7 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
1461
1461
|
async lastOrFail() {
|
|
1462
1462
|
const record = await this.last();
|
|
1463
1463
|
if (!record)
|
|
1464
|
-
throw new RecordNotFound_js_1.default(this.dreamInstance
|
|
1464
|
+
throw new RecordNotFound_js_1.default(this.dreamInstance['sanitizedConstructorName']);
|
|
1465
1465
|
return record;
|
|
1466
1466
|
}
|
|
1467
1467
|
/**
|
|
@@ -1756,7 +1756,7 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
1756
1756
|
}
|
|
1757
1757
|
async preloadPolymorphicAssociationModel(dreams, association, associatedDreamClass, associatedDreams) {
|
|
1758
1758
|
const relevantAssociatedModels = dreams.filter((dream) => {
|
|
1759
|
-
return dream[association.foreignKeyTypeField()] === associatedDreamClass['
|
|
1759
|
+
return dream[association.foreignKeyTypeField()] === associatedDreamClass['stiBaseClassOrOwnClassName'];
|
|
1760
1760
|
});
|
|
1761
1761
|
if (relevantAssociatedModels.length) {
|
|
1762
1762
|
dreams.forEach((dream) => {
|
|
@@ -1779,7 +1779,7 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
1779
1779
|
for (const loadedAssociation of loadedAssociations) {
|
|
1780
1780
|
dreams
|
|
1781
1781
|
.filter((dream) => {
|
|
1782
|
-
return (dream[association.foreignKeyTypeField()] === loadedAssociation['
|
|
1782
|
+
return (dream[association.foreignKeyTypeField()] === loadedAssociation['stiBaseClassOrOwnClassName'] &&
|
|
1783
1783
|
dream[association.foreignKey()] === association.primaryKeyValue(loadedAssociation));
|
|
1784
1784
|
})
|
|
1785
1785
|
.forEach((dream) => {
|
|
@@ -2072,8 +2072,8 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
2072
2072
|
if (association.polymorphic) {
|
|
2073
2073
|
join = join.on((eb) => this.whereStatementToExpressionWrapper(eb, this.aliasWhereStatement({
|
|
2074
2074
|
[association.foreignKeyTypeField()]: throughClass
|
|
2075
|
-
? throughClass['
|
|
2076
|
-
: dreamClass['
|
|
2075
|
+
? throughClass['stiBaseClassOrOwnClassName']
|
|
2076
|
+
: dreamClass['stiBaseClassOrOwnClassName'],
|
|
2077
2077
|
}, currentAssociationTableOrAlias)));
|
|
2078
2078
|
}
|
|
2079
2079
|
if (timeToApplyThroughAssociations) {
|
|
@@ -28,7 +28,7 @@ async function createAssociation(dream, txn = null, associationName, opts = {})
|
|
|
28
28
|
...opts,
|
|
29
29
|
};
|
|
30
30
|
if (hasAssociation.polymorphic) {
|
|
31
|
-
modifiedOpts[hasAssociation.foreignKeyTypeField()] = dream['
|
|
31
|
+
modifiedOpts[hasAssociation.foreignKeyTypeField()] = dream['stiBaseClassOrOwnClassName'];
|
|
32
32
|
}
|
|
33
33
|
if (txn) {
|
|
34
34
|
hasresult = await associationClass.txn(txn).create(modifiedOpts);
|
|
@@ -55,7 +55,7 @@ async function runHook(statement, dream, txn) {
|
|
|
55
55
|
Attempting to run ${statement.method} as part of the ${statement.type}
|
|
56
56
|
Dream model hook sequence, but we encountered a method that does not exist.
|
|
57
57
|
|
|
58
|
-
Please make sure "${statement.method}" is defined on ${dream
|
|
58
|
+
Please make sure "${statement.method}" is defined on ${dream['sanitizedConstructorName']}
|
|
59
59
|
`);
|
|
60
60
|
}
|
|
61
61
|
await dream[statement.method](txn);
|
|
@@ -23,7 +23,7 @@ async function saveDream(dream, txn = null, { skipHooks = false } = {}) {
|
|
|
23
23
|
// need to check validations after running before hooks, or else
|
|
24
24
|
// model hooks that might make a model valid cannot run
|
|
25
25
|
if (dream.isInvalid)
|
|
26
|
-
throw new ValidationError_js_1.default(dream
|
|
26
|
+
throw new ValidationError_js_1.default(dream['sanitizedConstructorName'], dream.errors);
|
|
27
27
|
if (alreadyPersisted && !dream.isDirty)
|
|
28
28
|
return dream;
|
|
29
29
|
let query;
|
|
@@ -29,7 +29,7 @@ function sqlResultToDreamInstance(dreamClass, sqlResult) {
|
|
|
29
29
|
function findExtendingDreamClass(dreamClass, type) {
|
|
30
30
|
if (!dreamClass['extendedBy'])
|
|
31
31
|
return undefined;
|
|
32
|
-
const extendingDreamClass = dreamClass['extendedBy'].find(extendingDreamClass => extendingDreamClass.
|
|
32
|
+
const extendingDreamClass = dreamClass['extendedBy'].find(extendingDreamClass => extendingDreamClass.sanitizedName === type);
|
|
33
33
|
if (extendingDreamClass)
|
|
34
34
|
return extendingDreamClass;
|
|
35
35
|
return dreamClass['extendedBy']
|
|
@@ -12,7 +12,7 @@ Cannot call "undestroy" on a non-SoftDelete model. Ensure that your
|
|
|
12
12
|
model has @SoftDelete applied before calling "undestroy":
|
|
13
13
|
|
|
14
14
|
@SoftDelete()
|
|
15
|
-
class ${this.dreamClass.
|
|
15
|
+
class ${this.dreamClass.sanitizedName} extends ApplicationModel {
|
|
16
16
|
...
|
|
17
17
|
}
|
|
18
18
|
`;
|
|
@@ -12,7 +12,7 @@ class CannotDefineAssociationWithBothDependentAndPassthrough extends Error {
|
|
|
12
12
|
return `
|
|
13
13
|
Cannot define association with both "dependent" and "DreamConst.passthrough".
|
|
14
14
|
Error found when trying to parse "${this.associationName}" on the
|
|
15
|
-
${this.dreamClass.
|
|
15
|
+
${this.dreamClass.sanitizedName} dream class.
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -12,7 +12,7 @@ class CannotDefineAssociationWithBothDependentAndRequiredOnClause extends Error
|
|
|
12
12
|
return `
|
|
13
13
|
Cannot define association with both "dependent" and "DreamConst.required".
|
|
14
14
|
Error found when trying to parse "${this.associationName}" on the
|
|
15
|
-
${this.dreamClass.
|
|
15
|
+
${this.dreamClass.sanitizedName} dream class.
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
18
18
|
}
|