@rvoh/dream 0.29.3 → 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 +58 -1
- 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/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/esm/src/Dream.js +58 -1
- 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/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/types/src/Dream.d.ts +49 -0
- 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 +14 -14
- package/docs/classes/Dream.html +146 -122
- 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/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/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
|
*
|
|
@@ -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
|
}
|
|
@@ -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,
|
|
@@ -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
|
}
|
|
@@ -12,7 +12,7 @@ class CannotPassUndefinedAsAValueToAWhereClause extends Error {
|
|
|
12
12
|
return `
|
|
13
13
|
Cannot pass undefined as a value to a where clause.
|
|
14
14
|
|
|
15
|
-
dream class: ${this.dreamClass.
|
|
15
|
+
dream class: ${this.dreamClass.sanitizedName}
|
|
16
16
|
key receiving an undefined value: ${this.key}
|
|
17
17
|
`;
|
|
18
18
|
}
|
|
@@ -8,7 +8,7 @@ class CreateOrFindByFailedToCreateAndFind extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
get message() {
|
|
10
10
|
return `
|
|
11
|
-
Failed to create instance of ${this.dreamClass.
|
|
11
|
+
Failed to create instance of ${this.dreamClass.sanitizedName} and no matching model exists.
|
|
12
12
|
|
|
13
13
|
The likely cause is that one of the \`createWith\` fields violates
|
|
14
14
|
a uniqueness constraint.
|
|
@@ -15,7 +15,7 @@ class DoNotSetEncryptedFieldsDirectly extends Error {
|
|
|
15
15
|
Do not set @Encrypted columns directly. Instead, set their accessors, so that
|
|
16
16
|
those fields can be encrypted by Dream internally.
|
|
17
17
|
|
|
18
|
-
Dream class: ${this.dreamClass.
|
|
18
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
19
19
|
Problematic setter: ${this.encryptedColumnName}
|
|
20
20
|
Setter to be used instead: ${this.encryptedProperty}`;
|
|
21
21
|
}
|
|
@@ -14,7 +14,7 @@ Whenever the using SoftDelete decorator, you must have either a deletedAt column
|
|
|
14
14
|
or else another column defined, along with an ovrriding getter on your model, like so:
|
|
15
15
|
|
|
16
16
|
@SoftDelete()
|
|
17
|
-
class ${this.dreamClass.
|
|
17
|
+
class ${this.dreamClass.sanitizedName} extends ApplicationModel {
|
|
18
18
|
public get deletedAtField() {
|
|
19
19
|
return 'customDeletedAtField' as const
|
|
20
20
|
}
|
|
@@ -9,14 +9,14 @@ class MissingSerializersDefinition extends Error {
|
|
|
9
9
|
get message() {
|
|
10
10
|
return `
|
|
11
11
|
Missing serializers definition on the following class
|
|
12
|
-
Dream class: ${this.dreamClass.
|
|
12
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
13
13
|
|
|
14
|
-
Try something like this in your ${this.dreamClass.
|
|
14
|
+
Try something like this in your ${this.dreamClass.sanitizedName}'s serializer getter:
|
|
15
15
|
|
|
16
|
-
class ${this.dreamClass.
|
|
17
|
-
public get serializers(): DreamSerializers<${this.dreamClass.
|
|
16
|
+
class ${this.dreamClass.sanitizedName} {
|
|
17
|
+
public get serializers(): DreamSerializers<${this.dreamClass.sanitizedName}> {
|
|
18
18
|
return {
|
|
19
|
-
default: '${this.dreamClass.
|
|
19
|
+
default: '${this.dreamClass.sanitizedName}Serializer'
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
...
|
|
@@ -11,14 +11,14 @@ class MissingTable extends Error {
|
|
|
11
11
|
get message() {
|
|
12
12
|
return `
|
|
13
13
|
Missing table definition on the following dream class:
|
|
14
|
-
Dream class: ${this.dreamClass.
|
|
14
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
15
15
|
|
|
16
|
-
Try something like this in your ${this.dreamClass.
|
|
16
|
+
Try something like this in your ${this.dreamClass.sanitizedName}'s table getter:
|
|
17
17
|
|
|
18
|
-
class ${this.dreamClass.
|
|
18
|
+
class ${this.dreamClass.sanitizedName} {
|
|
19
19
|
...
|
|
20
20
|
public get table() {
|
|
21
|
-
return '${(0, pluralize_esm_1.default)((0, snakeify_js_1.default)(this.dreamClass.
|
|
21
|
+
return '${(0, pluralize_esm_1.default)((0, snakeify_js_1.default)(this.dreamClass.sanitizedName))}'
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
@@ -12,10 +12,10 @@ class NonBelongsToAssociationProvidedAsSortableDecoratorScope extends Error {
|
|
|
12
12
|
return `
|
|
13
13
|
Only BelongsTo associations are supported as scopes for the @Sortable decorator.
|
|
14
14
|
received:
|
|
15
|
-
dream model class: ${this.dreamClass.
|
|
15
|
+
dream model class: ${this.dreamClass.sanitizedName}
|
|
16
16
|
scope: ${this.scope}
|
|
17
17
|
|
|
18
|
-
BelongsTo scopes on ${this.dreamClass.
|
|
18
|
+
BelongsTo scopes on ${this.dreamClass.sanitizedName} are:
|
|
19
19
|
${this.dreamClass['associationMetadataByType'].belongsTo.map(assoc => assoc.as).join('\n ')}
|
|
20
20
|
`;
|
|
21
21
|
}
|
|
@@ -12,10 +12,10 @@ class NonExistentScopeProvidedToResort extends Error {
|
|
|
12
12
|
return `
|
|
13
13
|
Only BelongsTo scopes are supported by the #resort method
|
|
14
14
|
received:
|
|
15
|
-
dream model class: ${this.dreamClass.
|
|
15
|
+
dream model class: ${this.dreamClass.sanitizedName}
|
|
16
16
|
scope: ${this.scopes.join(', ')}
|
|
17
17
|
|
|
18
|
-
BelongsTo scopes on ${this.dreamClass.
|
|
18
|
+
BelongsTo scopes on ${this.dreamClass.sanitizedName} are:
|
|
19
19
|
${this.dreamClass['sortableFields'].map(conf => conf.positionField).join('\n ')}
|
|
20
20
|
`;
|
|
21
21
|
}
|
|
@@ -12,13 +12,13 @@ class SortableDecoratorRequiresColumnOrBelongsToAssociation extends Error {
|
|
|
12
12
|
return `
|
|
13
13
|
Only Column or BelongsTo scopes are supported by the @Sortable decorator.
|
|
14
14
|
received:
|
|
15
|
-
dream model class: ${this.dreamClass.
|
|
15
|
+
dream model class: ${this.dreamClass.sanitizedName}
|
|
16
16
|
scope: ${this.attributeOrScope}
|
|
17
17
|
|
|
18
|
-
Columns on ${this.dreamClass.
|
|
18
|
+
Columns on ${this.dreamClass.sanitizedName} are:
|
|
19
19
|
${[...this.dreamClass.columns()].join('\n ')}
|
|
20
20
|
|
|
21
|
-
BelongsTo scopes on ${this.dreamClass.
|
|
21
|
+
BelongsTo scopes on ${this.dreamClass.sanitizedName} are:
|
|
22
22
|
${this.dreamClass['associationMetadataByType'].belongsTo.map(assoc => assoc.as).join('\n ')}
|
|
23
23
|
`;
|
|
24
24
|
}
|
|
@@ -11,7 +11,7 @@ class CanOnlyPassBelongsToModelParam extends Error {
|
|
|
11
11
|
get message() {
|
|
12
12
|
return `
|
|
13
13
|
Can only pass BelongsTo associated models as params
|
|
14
|
-
Dream class: ${this.dreamClass.
|
|
14
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
15
15
|
Association: ${this.association.as}
|
|
16
16
|
Association type: ${this.association.type}
|
|
17
17
|
`;
|
|
@@ -11,7 +11,7 @@ class CannotAssociateThroughPolymorphic extends Error {
|
|
|
11
11
|
get message() {
|
|
12
12
|
return `
|
|
13
13
|
Cannot join through a polymorphic association
|
|
14
|
-
Dream class: ${this.dreamClass.
|
|
14
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
15
15
|
Association: ${this.association.as}
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
@@ -11,7 +11,7 @@ class CannotCreateAssociationWithThroughContext extends Error {
|
|
|
11
11
|
get message() {
|
|
12
12
|
return `
|
|
13
13
|
'createAssociation' is not supported for through associations.
|
|
14
|
-
Dream class: ${this.dreamClass.
|
|
14
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
15
15
|
Association: ${this.association.as}
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
@@ -15,7 +15,7 @@ class CannotJoinPolymorphicBelongsToError extends Error {
|
|
|
15
15
|
get message() {
|
|
16
16
|
return `
|
|
17
17
|
Cannot join on a polymorphic BelongsTo
|
|
18
|
-
Dream class: ${this.dreamClass.
|
|
18
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
19
19
|
Association: ${this.association.as}
|
|
20
20
|
Inner Join statements:
|
|
21
21
|
${JSON.stringify(this.innerJoinStatements, null, 2)}
|
|
@@ -11,7 +11,7 @@ class CannotPassNullOrUndefinedToRequiredBelongsTo extends Error {
|
|
|
11
11
|
get message() {
|
|
12
12
|
return `
|
|
13
13
|
Cannot pass null or undefined as a value to a required association.
|
|
14
|
-
Dream class: ${this.dreamClass.
|
|
14
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
15
15
|
Association: ${this.association.as}
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
@@ -18,7 +18,7 @@ class InvalidComputedForeignKey extends Error {
|
|
|
18
18
|
get message() {
|
|
19
19
|
return `
|
|
20
20
|
Add an explicit foreignKey declaration to this association declaration:
|
|
21
|
-
Dream class: ${this.dreamClass.
|
|
21
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
22
22
|
Association: ${this.partialAssociation.as}
|
|
23
23
|
Dream tried ${this.computedForeignKey} automatically, but it isn't a column in table ${this.table}.
|
|
24
24
|
`;
|
|
@@ -41,7 +41,7 @@ class ExplicitForeignKeyRequired extends Error {
|
|
|
41
41
|
return `
|
|
42
42
|
${this.explicitForeignKey} is not a valid column on table ${this.table}.
|
|
43
43
|
Fix the foreignKey declaration on:
|
|
44
|
-
Dream class: ${this.dreamClass.
|
|
44
|
+
Dream class: ${this.dreamClass.sanitizedName}
|
|
45
45
|
Association: ${this.partialAssociation.as}
|
|
46
46
|
`;
|
|
47
47
|
}
|
|
@@ -10,15 +10,15 @@ class JoinAttemptedOnMissingAssociation extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
get message() {
|
|
12
12
|
return `
|
|
13
|
-
A joins call has been attempted on \`${this.dreamClass.
|
|
14
|
-
but \`${this.dreamClass.
|
|
13
|
+
A joins call has been attempted on \`${this.dreamClass.sanitizedName}\` association \`${this.associationName}\`,
|
|
14
|
+
but \`${this.dreamClass.sanitizedName}\` does not define association \`${this.associationName}\`.
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
Either \`${this.associationName}\` is a typo in the joins statement, or association \`${this.associationName}\` needs to be defined on \`${this.dreamClass.name}\`, for example:
|
|
18
18
|
|
|
19
|
-
class ${this.dreamClass.
|
|
19
|
+
class ${this.dreamClass.sanitizedName} {
|
|
20
20
|
...
|
|
21
|
-
@${this.dreamClass.
|
|
21
|
+
@${this.dreamClass.sanitizedName}.HasMany('SomeModelClass')
|
|
22
22
|
public ${this.associationName}: SomeModelClass[]
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
@@ -10,15 +10,15 @@ class MissingThroughAssociation extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
get message() {
|
|
12
12
|
return `
|
|
13
|
-
\`${this.dreamClass.
|
|
13
|
+
\`${this.dreamClass.sanitizedName}\` defines through association \`${this.association.through}\`, but \`${this.dreamClass.name}\` does not define association \`${this.association.through}\`.
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
To fix, define association \`${this.association.through}\` on \`${this.dreamClass.
|
|
16
|
+
To fix, define association \`${this.association.through}\` on \`${this.dreamClass.sanitizedName}\`.
|
|
17
17
|
For example:
|
|
18
18
|
|
|
19
|
-
class ${this.dreamClass.
|
|
19
|
+
class ${this.dreamClass.sanitizedName} {
|
|
20
20
|
...
|
|
21
|
-
@${this.dreamClass.
|
|
21
|
+
@${this.dreamClass.sanitizedName}.HasMany('TheJoinModelClass')
|
|
22
22
|
public ${this.association.through}: TheJoinModelClass[]
|
|
23
23
|
}
|
|
24
24
|
`;
|