@rvoh/dream 0.33.0 → 0.35.0
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 +14 -0
- package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +14 -0
- package/dist/cjs/src/dream/internal/destroyDream.js +1 -2
- package/dist/cjs/src/dream/internal/runHooksFor.js +66 -28
- package/dist/cjs/src/dream/internal/saveDream.js +2 -4
- package/dist/cjs/src/dream/internal/undestroyDream.js +1 -2
- package/dist/cjs/src/errors/associations/CannotAssociationQueryOnUnpersistedDream.js +18 -0
- package/dist/cjs/src/errors/associations/CannotCreateAssociationOnUnpersistedDream.js +18 -0
- package/dist/cjs/src/errors/associations/CannotDestroyAssociationOnUnpersistedDream.js +18 -0
- package/dist/cjs/src/errors/associations/CannotUpdateAssociationOnUnpersistedDream.js +18 -0
- package/dist/cjs/src/helpers/DreamLogos/DreamLogos.js +12 -0
- package/dist/cjs/src/helpers/{DreamGlam/howyadoins/whaaaaaaaaaaok.js → DreamLogos/logos.js} +2 -2
- package/dist/cjs/src/helpers/cli/autoGeneratedFileDisclaimer.js +2 -2
- package/dist/cjs/src/helpers/cli/generateDreamContent.js +2 -2
- package/dist/cjs/src/helpers/cli/generateSerializerContent.js +14 -6
- package/dist/cjs/src/index.js +5 -6
- package/dist/esm/src/Dream.js +14 -0
- package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +14 -0
- package/dist/esm/src/dream/internal/destroyDream.js +1 -2
- package/dist/esm/src/dream/internal/runHooksFor.js +66 -28
- package/dist/esm/src/dream/internal/saveDream.js +2 -4
- package/dist/esm/src/dream/internal/undestroyDream.js +1 -2
- package/dist/esm/src/errors/associations/CannotAssociationQueryOnUnpersistedDream.js +15 -0
- package/dist/esm/src/errors/associations/CannotCreateAssociationOnUnpersistedDream.js +15 -0
- package/dist/esm/src/errors/associations/CannotDestroyAssociationOnUnpersistedDream.js +15 -0
- package/dist/esm/src/errors/associations/CannotUpdateAssociationOnUnpersistedDream.js +15 -0
- package/dist/esm/src/helpers/DreamLogos/DreamLogos.js +9 -0
- package/dist/esm/src/helpers/{DreamGlam/howyadoins/whaaaaaaaaaaok.js → DreamLogos/logos.js} +1 -1
- package/dist/esm/src/helpers/cli/autoGeneratedFileDisclaimer.js +2 -2
- package/dist/esm/src/helpers/cli/generateDreamContent.js +2 -2
- package/dist/esm/src/helpers/cli/generateSerializerContent.js +14 -6
- package/dist/esm/src/index.js +3 -3
- package/dist/types/src/decorators/Decorators.d.ts +27 -27
- package/dist/types/src/errors/associations/CannotAssociationQueryOnUnpersistedDream.d.ts +7 -0
- package/dist/types/src/errors/associations/CannotCreateAssociationOnUnpersistedDream.d.ts +7 -0
- package/dist/types/src/errors/associations/CannotDestroyAssociationOnUnpersistedDream.d.ts +7 -0
- package/dist/types/src/errors/associations/CannotUpdateAssociationOnUnpersistedDream.d.ts +7 -0
- package/dist/types/src/helpers/DreamLogos/DreamLogos.d.ts +4 -0
- package/dist/types/src/helpers/DreamLogos/logos.d.ts +2 -0
- package/dist/types/src/index.d.ts +4 -3
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +66 -21
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +6 -5
- package/docs/classes/Decorators.html +38 -38
- package/docs/classes/Dream.html +131 -131
- package/docs/classes/DreamApplication.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamLogos.html +4 -0
- 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 +6 -5
- package/docs/classes/NonLoadedAssociation.html +6 -5
- package/docs/classes/Query.html +51 -51
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +6 -5
- package/docs/classes/ValidationError.html +6 -5
- 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/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/debug.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sort.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/untypedDb.html +1 -0
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/index.html +7 -7
- 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 +11 -11
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DbConnectionType.html +1 -0
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
- package/docs/types/SerializableDreamOrViewModel.html +1 -1
- package/docs/types/SerializableTypes.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModelSerializerKey.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +5 -5
- package/dist/cjs/src/dream/internal/safelyRunCommitHooks.js +0 -15
- package/dist/cjs/src/helpers/DreamGlam/DreamGlam.js +0 -16
- package/dist/cjs/src/helpers/DreamGlam/howyadoins/fluffstopherwalkin.js +0 -42
- package/dist/esm/src/dream/internal/safelyRunCommitHooks.js +0 -12
- package/dist/esm/src/helpers/DreamGlam/DreamGlam.js +0 -13
- package/dist/esm/src/helpers/DreamGlam/howyadoins/fluffstopherwalkin.js +0 -39
- package/dist/types/src/dream/internal/safelyRunCommitHooks.d.ts +0 -7
- package/dist/types/src/helpers/DreamGlam/DreamGlam.d.ts +0 -5
- package/dist/types/src/helpers/DreamGlam/howyadoins/fluffstopherwalkin.d.ts +0 -1
- package/dist/types/src/helpers/DreamGlam/howyadoins/whaaaaaaaaaaok.d.ts +0 -2
- package/docs/classes/DreamDbConnection.html +0 -4
- package/docs/classes/DreamGlam.html +0 -5
- package/docs/functions/db.html +0 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import CannotAssociationQueryOnUnpersistedDream from '../errors/associations/CannotAssociationQueryOnUnpersistedDream.js';
|
|
2
|
+
import CannotCreateAssociationOnUnpersistedDream from '../errors/associations/CannotCreateAssociationOnUnpersistedDream.js';
|
|
3
|
+
import CannotDestroyAssociationOnUnpersistedDream from '../errors/associations/CannotDestroyAssociationOnUnpersistedDream.js';
|
|
4
|
+
import CannotUpdateAssociationOnUnpersistedDream from '../errors/associations/CannotUpdateAssociationOnUnpersistedDream.js';
|
|
1
5
|
import associationQuery from './internal/associations/associationQuery.js';
|
|
2
6
|
import associationUpdateQuery from './internal/associations/associationUpdateQuery.js';
|
|
3
7
|
import createAssociation from './internal/associations/createAssociation.js';
|
|
@@ -308,6 +312,8 @@ export default class DreamInstanceTransactionBuilder {
|
|
|
308
312
|
* @returns A Query scoped to the specified association on the current instance
|
|
309
313
|
*/
|
|
310
314
|
associationQuery(associationName, joinOnStatements) {
|
|
315
|
+
if (this.dreamInstance.isNewRecord)
|
|
316
|
+
throw new CannotAssociationQueryOnUnpersistedDream(this.dreamInstance, associationName);
|
|
311
317
|
return associationQuery(this.dreamInstance, this.dreamTransaction, associationName, {
|
|
312
318
|
joinOnStatements: joinOnStatements,
|
|
313
319
|
bypassAllDefaultScopes: DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
|
|
@@ -339,6 +345,8 @@ export default class DreamInstanceTransactionBuilder {
|
|
|
339
345
|
* @returns The number of updated records
|
|
340
346
|
*/
|
|
341
347
|
async updateAssociation(associationName, attributes, updateAssociationOptions) {
|
|
348
|
+
if (this.dreamInstance.isNewRecord)
|
|
349
|
+
throw new CannotUpdateAssociationOnUnpersistedDream(this.dreamInstance, associationName);
|
|
342
350
|
return await associationUpdateQuery(this.dreamInstance, this.dreamTransaction, associationName, {
|
|
343
351
|
joinOnStatements: {
|
|
344
352
|
on: updateAssociationOptions?.on,
|
|
@@ -365,6 +373,8 @@ export default class DreamInstanceTransactionBuilder {
|
|
|
365
373
|
* @returns The created association
|
|
366
374
|
*/
|
|
367
375
|
async createAssociation(associationName, opts = {}) {
|
|
376
|
+
if (this.dreamInstance.isNewRecord)
|
|
377
|
+
throw new CannotCreateAssociationOnUnpersistedDream(this.dreamInstance, associationName);
|
|
368
378
|
return await createAssociation(this.dreamInstance, this.dreamTransaction, associationName, opts);
|
|
369
379
|
}
|
|
370
380
|
/**
|
|
@@ -387,6 +397,8 @@ export default class DreamInstanceTransactionBuilder {
|
|
|
387
397
|
* @returns The number of records deleted
|
|
388
398
|
*/
|
|
389
399
|
async destroyAssociation(associationName, options) {
|
|
400
|
+
if (this.dreamInstance.isNewRecord)
|
|
401
|
+
throw new CannotDestroyAssociationOnUnpersistedDream(this.dreamInstance, associationName);
|
|
390
402
|
return await destroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
|
|
391
403
|
...destroyOptions(options),
|
|
392
404
|
joinOnStatements: {
|
|
@@ -421,6 +433,8 @@ export default class DreamInstanceTransactionBuilder {
|
|
|
421
433
|
* @returns The number of records deleted
|
|
422
434
|
*/
|
|
423
435
|
async reallyDestroyAssociation(associationName, options) {
|
|
436
|
+
if (this.dreamInstance.isNewRecord)
|
|
437
|
+
throw new CannotDestroyAssociationOnUnpersistedDream(this.dreamInstance, associationName);
|
|
424
438
|
return await destroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
|
|
425
439
|
...reallyDestroyOptions(options),
|
|
426
440
|
joinOnStatements: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import destroyAssociatedRecords from './destroyAssociatedRecords.js';
|
|
2
2
|
import runHooksFor from './runHooksFor.js';
|
|
3
|
-
import safelyRunCommitHooks from './safelyRunCommitHooks.js';
|
|
4
3
|
import softDeleteDream from './softDeleteDream.js';
|
|
5
4
|
/**
|
|
6
5
|
* @internal
|
|
@@ -39,7 +38,7 @@ async function destroyDreamWithTransaction(dream, txn, options) {
|
|
|
39
38
|
await maybeDestroyDream(dream, txn, reallyDestroy);
|
|
40
39
|
if (!skipHooks) {
|
|
41
40
|
await runHooksFor('afterDestroy', dream, true, null, txn || undefined);
|
|
42
|
-
await
|
|
41
|
+
await runHooksFor('afterDestroyCommit', dream, true, null, txn);
|
|
43
42
|
}
|
|
44
43
|
if (shouldSoftDelete(dream, reallyDestroy)) {
|
|
45
44
|
await dream.txn(txn).reload();
|
|
@@ -1,47 +1,89 @@
|
|
|
1
1
|
export default async function runHooksFor(key, dream, alreadyPersisted, beforeSaveChanges, txn) {
|
|
2
2
|
const Base = dream.constructor;
|
|
3
|
-
for (const
|
|
4
|
-
if (
|
|
3
|
+
for (const hook of Base['hooks'][key]) {
|
|
4
|
+
if (hook.ifChanging?.length) {
|
|
5
5
|
switch (key) {
|
|
6
6
|
case 'beforeCreate':
|
|
7
|
-
|
|
7
|
+
if (shouldRunBeforeCreateHook(dream, hook)) {
|
|
8
|
+
await runHook(hook, dream, txn);
|
|
9
|
+
}
|
|
8
10
|
break;
|
|
9
11
|
case 'beforeSave':
|
|
10
|
-
if (alreadyPersisted)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if ((alreadyPersisted && shouldRunBeforeUpdateHook(dream, hook)) ||
|
|
13
|
+
(!alreadyPersisted && shouldRunBeforeCreateHook(dream, hook))) {
|
|
14
|
+
await runHook(hook, dream, txn);
|
|
15
|
+
}
|
|
14
16
|
break;
|
|
15
17
|
case 'beforeUpdate':
|
|
16
|
-
|
|
18
|
+
if (shouldRunBeforeUpdateHook(dream, hook)) {
|
|
19
|
+
await runHook(hook, dream, txn);
|
|
20
|
+
}
|
|
17
21
|
break;
|
|
18
22
|
default:
|
|
19
23
|
throw new Error(`Unexpected statement key detected with ifChanging clause: ${key}`);
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
|
-
else if (
|
|
26
|
+
else if (hook.ifChanged?.length) {
|
|
23
27
|
switch (key) {
|
|
24
28
|
case 'afterCreate':
|
|
29
|
+
if (shouldRunAfterCreateHook(dream, hook, beforeSaveChanges)) {
|
|
30
|
+
await runHook(hook, dream, txn);
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
25
33
|
case 'afterCreateCommit':
|
|
26
|
-
|
|
34
|
+
if (shouldRunAfterCreateHook(dream, hook, beforeSaveChanges)) {
|
|
35
|
+
if (txn)
|
|
36
|
+
txn.addCommitHook(hook, dream);
|
|
37
|
+
else
|
|
38
|
+
await runHook(hook, dream);
|
|
39
|
+
}
|
|
27
40
|
break;
|
|
28
41
|
case 'afterSave':
|
|
42
|
+
if ((alreadyPersisted && shouldRunAfterUpdateHook(dream, hook)) ||
|
|
43
|
+
(!alreadyPersisted && shouldRunAfterCreateHook(dream, hook, beforeSaveChanges))) {
|
|
44
|
+
await runHook(hook, dream, txn);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
29
47
|
case 'afterSaveCommit':
|
|
30
|
-
if (alreadyPersisted)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
if ((alreadyPersisted && shouldRunAfterUpdateHook(dream, hook)) ||
|
|
49
|
+
(!alreadyPersisted && shouldRunAfterCreateHook(dream, hook, beforeSaveChanges))) {
|
|
50
|
+
if (txn)
|
|
51
|
+
txn.addCommitHook(hook, dream);
|
|
52
|
+
else
|
|
53
|
+
await runHook(hook, dream);
|
|
54
|
+
}
|
|
34
55
|
break;
|
|
35
56
|
case 'afterUpdate':
|
|
57
|
+
if (shouldRunAfterUpdateHook(dream, hook)) {
|
|
58
|
+
await runHook(hook, dream, txn);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
36
61
|
case 'afterUpdateCommit':
|
|
37
|
-
|
|
62
|
+
if (shouldRunAfterUpdateHook(dream, hook)) {
|
|
63
|
+
if (txn)
|
|
64
|
+
txn.addCommitHook(hook, dream);
|
|
65
|
+
else
|
|
66
|
+
await runHook(hook, dream);
|
|
67
|
+
}
|
|
38
68
|
break;
|
|
39
69
|
default:
|
|
40
70
|
throw new Error(`Unexpected statement key detected with ifChanged clause: ${key}`);
|
|
41
71
|
}
|
|
42
72
|
}
|
|
43
73
|
else {
|
|
44
|
-
|
|
74
|
+
switch (key) {
|
|
75
|
+
case 'afterCreateCommit':
|
|
76
|
+
case 'afterSaveCommit':
|
|
77
|
+
case 'afterUpdateCommit':
|
|
78
|
+
case 'afterDestroyCommit':
|
|
79
|
+
if (txn)
|
|
80
|
+
txn.addCommitHook(hook, dream);
|
|
81
|
+
else
|
|
82
|
+
await runHook(hook, dream);
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
await runHook(hook, dream, txn);
|
|
86
|
+
}
|
|
45
87
|
}
|
|
46
88
|
}
|
|
47
89
|
}
|
|
@@ -56,40 +98,36 @@ Please make sure "${statement.method}" is defined on ${dream['sanitizedConstruct
|
|
|
56
98
|
}
|
|
57
99
|
await dream[statement.method](txn);
|
|
58
100
|
}
|
|
59
|
-
|
|
101
|
+
function shouldRunBeforeCreateHook(dream, statement) {
|
|
60
102
|
let shouldRun = false;
|
|
61
103
|
for (const attribute of statement.ifChanging) {
|
|
62
104
|
if (dream[attribute] !== undefined)
|
|
63
105
|
shouldRun = true;
|
|
64
106
|
}
|
|
65
|
-
|
|
66
|
-
await runHook(statement, dream, txn);
|
|
107
|
+
return shouldRun;
|
|
67
108
|
}
|
|
68
|
-
|
|
109
|
+
function shouldRunAfterCreateHook(dream, statement, beforeSaveChanges) {
|
|
69
110
|
let shouldRun = false;
|
|
70
111
|
for (const attribute of statement.ifChanged) {
|
|
71
112
|
if (beforeSaveChanges?.[attribute] &&
|
|
72
113
|
beforeSaveChanges[attribute].was !== beforeSaveChanges[attribute].now)
|
|
73
114
|
shouldRun = true;
|
|
74
115
|
}
|
|
75
|
-
|
|
76
|
-
await runHook(statement, dream, txn);
|
|
116
|
+
return shouldRun;
|
|
77
117
|
}
|
|
78
|
-
|
|
118
|
+
function shouldRunBeforeUpdateHook(dream, statement) {
|
|
79
119
|
let shouldRun = false;
|
|
80
120
|
for (const attribute of statement.ifChanging) {
|
|
81
121
|
if (dream.willSaveChangeToAttribute(attribute))
|
|
82
122
|
shouldRun = true;
|
|
83
123
|
}
|
|
84
|
-
|
|
85
|
-
await runHook(statement, dream, txn);
|
|
124
|
+
return shouldRun;
|
|
86
125
|
}
|
|
87
|
-
|
|
126
|
+
function shouldRunAfterUpdateHook(dream, statement) {
|
|
88
127
|
let shouldRun = false;
|
|
89
128
|
for (const attribute of statement.ifChanged) {
|
|
90
129
|
if (dream.savedChangeToAttribute(attribute))
|
|
91
130
|
shouldRun = true;
|
|
92
131
|
}
|
|
93
|
-
|
|
94
|
-
await runHook(statement, dream, txn);
|
|
132
|
+
return shouldRun;
|
|
95
133
|
}
|
|
@@ -5,7 +5,6 @@ import namespaceColumn from '../../helpers/namespaceColumn.js';
|
|
|
5
5
|
import sqlAttributes from '../../helpers/sqlAttributes.js';
|
|
6
6
|
import executeDatabaseQuery from './executeDatabaseQuery.js';
|
|
7
7
|
import runHooksFor from './runHooksFor.js';
|
|
8
|
-
import safelyRunCommitHooks from './safelyRunCommitHooks.js';
|
|
9
8
|
export default async function saveDream(dream, txn = null, { skipHooks = false } = {}) {
|
|
10
9
|
const db = txn?.kyselyTransaction || _db('primary');
|
|
11
10
|
const alreadyPersisted = dream.isPersisted;
|
|
@@ -56,9 +55,8 @@ export default async function saveDream(dream, txn = null, { skipHooks = false }
|
|
|
56
55
|
await runHooksFor('afterUpdate', dream, alreadyPersisted, beforeSaveChanges, txn);
|
|
57
56
|
else
|
|
58
57
|
await runHooksFor('afterCreate', dream, alreadyPersisted, beforeSaveChanges, txn);
|
|
59
|
-
|
|
60
|
-
await
|
|
61
|
-
await safelyRunCommitHooks(dream, 'afterSaveCommit', alreadyPersisted, beforeSaveChanges, txn);
|
|
58
|
+
await runHooksFor(alreadyPersisted ? 'afterUpdateCommit' : 'afterCreateCommit', dream, alreadyPersisted, beforeSaveChanges, txn);
|
|
59
|
+
await runHooksFor('afterSaveCommit', dream, alreadyPersisted, beforeSaveChanges, txn);
|
|
62
60
|
}
|
|
63
61
|
return dream;
|
|
64
62
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { applySortableScopesToQuery } from '../../decorators/field/sortable/helpers/setPosition.js';
|
|
2
2
|
import runHooksFor from './runHooksFor.js';
|
|
3
|
-
import safelyRunCommitHooks from './safelyRunCommitHooks.js';
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*
|
|
@@ -38,7 +37,7 @@ async function undestroyDreamWithTransaction(dream, txn, options) {
|
|
|
38
37
|
}
|
|
39
38
|
if (!skipHooks) {
|
|
40
39
|
await runHooksFor('afterUpdate', dream, true, null, txn);
|
|
41
|
-
await
|
|
40
|
+
await runHooksFor('afterUpdateCommit', dream, true, null, txn);
|
|
42
41
|
}
|
|
43
42
|
await dream.txn(txn).reload();
|
|
44
43
|
return dream;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default class CannotAssociationQueryOnUnpersistedDream extends Error {
|
|
2
|
+
dream;
|
|
3
|
+
associationName;
|
|
4
|
+
constructor(dream, associationName) {
|
|
5
|
+
super();
|
|
6
|
+
this.dream = dream;
|
|
7
|
+
this.associationName = associationName;
|
|
8
|
+
}
|
|
9
|
+
get message() {
|
|
10
|
+
return `Cannot perform associationQuery on an unpersisted Dream.
|
|
11
|
+
Dream class: ${this.dream.sanitizedConstructorName}
|
|
12
|
+
Association: ${this.associationName.toString()}
|
|
13
|
+
`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default class CannotCreateAssociationOnUnpersistedDream extends Error {
|
|
2
|
+
dream;
|
|
3
|
+
associationName;
|
|
4
|
+
constructor(dream, associationName) {
|
|
5
|
+
super();
|
|
6
|
+
this.dream = dream;
|
|
7
|
+
this.associationName = associationName;
|
|
8
|
+
}
|
|
9
|
+
get message() {
|
|
10
|
+
return `Cannot perform createAssociation on an unpersisted Dream.
|
|
11
|
+
Dream class: ${this.dream.sanitizedConstructorName}
|
|
12
|
+
Association: ${this.associationName.toString()}
|
|
13
|
+
`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default class CannotDestroyAssociationOnUnpersistedDream extends Error {
|
|
2
|
+
dream;
|
|
3
|
+
associationName;
|
|
4
|
+
constructor(dream, associationName) {
|
|
5
|
+
super();
|
|
6
|
+
this.dream = dream;
|
|
7
|
+
this.associationName = associationName;
|
|
8
|
+
}
|
|
9
|
+
get message() {
|
|
10
|
+
return `Cannot perform destroyAssociation on an unpersisted Dream.
|
|
11
|
+
Dream class: ${this.dream.sanitizedConstructorName}
|
|
12
|
+
Association: ${this.associationName.toString()}
|
|
13
|
+
`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default class CannotUpdateAssociationOnUnpersistedDream extends Error {
|
|
2
|
+
dream;
|
|
3
|
+
associationName;
|
|
4
|
+
constructor(dream, associationName) {
|
|
5
|
+
super();
|
|
6
|
+
this.dream = dream;
|
|
7
|
+
this.associationName = associationName;
|
|
8
|
+
}
|
|
9
|
+
get message() {
|
|
10
|
+
return `Cannot perform updateAssociation on an unpersisted Dream.
|
|
11
|
+
Dream class: ${this.dream.sanitizedConstructorName}
|
|
12
|
+
Association: ${this.associationName.toString()}
|
|
13
|
+
`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DreamLogos from '../DreamLogos/DreamLogos.js';
|
|
2
2
|
export default function autogeneratedFileDisclaimer(startComment = '\n/*', endComment = '\n*/') {
|
|
3
3
|
return `\
|
|
4
4
|
${startComment}
|
|
5
|
-
${
|
|
5
|
+
${DreamLogos.monochrome()}
|
|
6
6
|
|
|
7
7
|
This file was automatically generated by my cat, Aster.
|
|
8
8
|
He does not want you mucking about with his files,
|
|
@@ -75,7 +75,7 @@ public ${camelize(attributeName)}: ${getAttributeType(attribute, modelClassName)
|
|
|
75
75
|
return `\
|
|
76
76
|
import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'${uniq(modelImportStatements).join('')}
|
|
77
77
|
|
|
78
|
-
const deco = new Decorators<
|
|
78
|
+
const deco = new Decorators<typeof ${modelClassName}>()
|
|
79
79
|
|
|
80
80
|
${isSTI ? `\n@STI(${parentModelClassName})` : ''}
|
|
81
81
|
export default class ${modelClassName} extends ${isSTI ? parentModelClassName : 'ApplicationModel'} {
|
|
@@ -86,7 +86,7 @@ ${isSTI
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
`}${serializer
|
|
89
|
-
? ` public get serializers(): DreamSerializers<${modelClassName}> {
|
|
89
|
+
? ` public ${isSTI ? 'override ' : ''}get serializers(): DreamSerializers<${modelClassName}> {
|
|
90
90
|
return {
|
|
91
91
|
default: '${serializerNameFromFullyQualifiedModelName(fullyQualifiedModelName)}',
|
|
92
92
|
summary: '${serializerNameFromFullyQualifiedModelName(fullyQualifiedModelName, 'summary')}',
|
|
@@ -29,13 +29,13 @@ export default function generateSerializerContent({ fullyQualifiedModelName, col
|
|
|
29
29
|
Passthrough extends object,
|
|
30
30
|
>`;
|
|
31
31
|
dreamSerializerTypeArgs = `<DataType, Passthrough>`;
|
|
32
|
-
const defaultSerialzerClassName =
|
|
33
|
-
const summarySerialzerClassName =
|
|
32
|
+
const defaultSerialzerClassName = serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName));
|
|
33
|
+
const summarySerialzerClassName = serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName), 'summary');
|
|
34
34
|
const defaultSerialzerExtends = isSTI
|
|
35
|
-
?
|
|
35
|
+
? serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedParentName))
|
|
36
36
|
: summarySerialzerClassName;
|
|
37
37
|
const summarySerialzerExtends = isSTI
|
|
38
|
-
?
|
|
38
|
+
? serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedParentName), 'summary')
|
|
39
39
|
: 'DreamSerializer';
|
|
40
40
|
const additionalModelImports = [];
|
|
41
41
|
columnsWithTypes.forEach(attr => {
|
|
@@ -98,8 +98,16 @@ function attributeOptionsSpecifier(type, attr) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
function importStatementForSerializer(originModelName, destinationModelName) {
|
|
101
|
-
|
|
101
|
+
const defaultSerializer = globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(destinationModelName)));
|
|
102
|
+
const summarySerializer = globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(destinationModelName), 'summary'));
|
|
103
|
+
const importFrom = relativeDreamPath('serializers', 'serializers', originModelName, destinationModelName);
|
|
104
|
+
return `\nimport ${defaultSerializer}, { ${summarySerializer} } from '${importFrom}'`;
|
|
102
105
|
}
|
|
103
106
|
function importStatementForModel(originModelName, destinationModelName = originModelName) {
|
|
104
|
-
|
|
107
|
+
const modelName = globalClassNameFromFullyQualifiedModelName(destinationModelName);
|
|
108
|
+
const importFrom = relativeDreamPath('serializers', 'models', originModelName, destinationModelName);
|
|
109
|
+
return `\nimport ${modelName} from '${importFrom}'`;
|
|
110
|
+
}
|
|
111
|
+
function fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName) {
|
|
112
|
+
return fullyQualifiedModelName.split('/').pop() ?? '';
|
|
105
113
|
}
|
package/dist/esm/src/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { default as DreamBin } from './bin/index.js';
|
|
2
2
|
export { default as DreamCLI } from './cli/index.js';
|
|
3
|
-
export { closeAllDbConnections,
|
|
3
|
+
export { closeAllDbConnections, dreamDbConnections } from './db/DreamDbConnection.js';
|
|
4
4
|
export { pgErrorType } from './db/errors.js';
|
|
5
|
-
export { default as
|
|
5
|
+
export { default as untypedDb } from './db/index.js';
|
|
6
6
|
export { default as DreamMigrationHelpers } from './db/migration-helpers/DreamMigrationHelpers.js';
|
|
7
7
|
export { default as validateColumn } from './db/validators/validateColumn.js';
|
|
8
8
|
export { default as validateTable } from './db/validators/validateTable.js';
|
|
@@ -31,7 +31,7 @@ export { default as generateDream } from './helpers/cli/generateDream.js';
|
|
|
31
31
|
export { default as compact } from './helpers/compact.js';
|
|
32
32
|
export { DateTime } from './helpers/DateTime.js';
|
|
33
33
|
export { default as debug } from './helpers/debug.js';
|
|
34
|
-
export { default as
|
|
34
|
+
export { default as DreamLogos } from './helpers/DreamLogos/DreamLogos.js';
|
|
35
35
|
export { default as Env } from './helpers/Env.js';
|
|
36
36
|
export { default as globalClassNameFromFullyQualifiedModelName } from './helpers/globalClassNameFromFullyQualifiedModelName.js';
|
|
37
37
|
export { default as hyphenize } from './helpers/hyphenize.js';
|
|
@@ -6,15 +6,15 @@ import { HasOneOptions, HasOneThroughOptions, PolymorphicHasOneOptions } from '.
|
|
|
6
6
|
import { DreamColumnNames, GlobalModelNameTableMap, SortableOptions } from '../types/dream.js';
|
|
7
7
|
import { AfterHookOpts, BeforeHookOpts } from '../types/lifecycle.js';
|
|
8
8
|
import { ValidationType } from '../types/validation.js';
|
|
9
|
-
export default class Decorators<T extends Dream
|
|
10
|
-
BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<
|
|
11
|
-
BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<
|
|
12
|
-
HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<
|
|
13
|
-
HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<
|
|
14
|
-
HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<
|
|
15
|
-
HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<
|
|
16
|
-
HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<
|
|
17
|
-
HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<
|
|
9
|
+
export default class Decorators<TD extends typeof Dream, T extends Dream = InstanceType<TD>> {
|
|
10
|
+
BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalNameOrNames, options?: NonPolymorphicBelongsToOptions<T, AssociationGlobalNameOrNames>): any;
|
|
11
|
+
BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalNameOrNames, options?: PolymorphicBelongsToOptions<T, AssociationGlobalNameOrNames>): any;
|
|
12
|
+
HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasManyOptions<T, AssociationGlobalName>): any;
|
|
13
|
+
HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasManyThroughOptions<T, AssociationGlobalName>): any;
|
|
14
|
+
HasMany<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: PolymorphicHasManyOptions<T, AssociationGlobalName>): any;
|
|
15
|
+
HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasOneOptions<T, AssociationGlobalName>): any;
|
|
16
|
+
HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: HasOneThroughOptions<T, AssociationGlobalName>): any;
|
|
17
|
+
HasOne<const AssociationGlobalName extends keyof GlobalModelNameTableMap<T>>(this: Decorators<TD>, globalAssociationNameOrNames: AssociationGlobalName, options?: PolymorphicHasOneOptions<T, AssociationGlobalName>): any;
|
|
18
18
|
/**
|
|
19
19
|
* The Encrypted decorator automatically encrypts (upon setting)
|
|
20
20
|
* and decrypts (upon getting) so that the encrypted value is
|
|
@@ -37,7 +37,7 @@ export default class Decorators<T extends Dream> {
|
|
|
37
37
|
* @param column — if omitted, then 'encrypted' is prepended to the Pascal cased version of the decorated field
|
|
38
38
|
* @returns An Encrypted decorator
|
|
39
39
|
*/
|
|
40
|
-
Encrypted(this: Decorators<
|
|
40
|
+
Encrypted(this: Decorators<TD>, column?: DreamColumnNames<T>): any;
|
|
41
41
|
/**
|
|
42
42
|
* The Scope decorator decorates a static method that accepts
|
|
43
43
|
* and returns a Dream Query.
|
|
@@ -55,7 +55,7 @@ export default class Decorators<T extends Dream> {
|
|
|
55
55
|
* @param opts.default - boolean: if true, then this scope will be applied to all queries involving this model
|
|
56
56
|
* @returns A Scope decorator
|
|
57
57
|
*/
|
|
58
|
-
Scope(this: Decorators<
|
|
58
|
+
Scope(this: Decorators<TD>, opts?: {
|
|
59
59
|
default?: boolean;
|
|
60
60
|
}): any;
|
|
61
61
|
/**
|
|
@@ -74,7 +74,7 @@ export default class Decorators<T extends Dream> {
|
|
|
74
74
|
* @param scope - The column, association, or combination there-of which you would like to restrict the incrementing logic to
|
|
75
75
|
* @returns A Sortable decorator
|
|
76
76
|
*/
|
|
77
|
-
Sortable(this: Decorators<
|
|
77
|
+
Sortable(this: Decorators<TD>, opts?: SortableOptions<T>): any;
|
|
78
78
|
/**
|
|
79
79
|
* The Validate decorator decorates a method to run
|
|
80
80
|
* before saving a model to the database.
|
|
@@ -97,7 +97,7 @@ export default class Decorators<T extends Dream> {
|
|
|
97
97
|
*
|
|
98
98
|
* @returns A Validate decorator
|
|
99
99
|
*/
|
|
100
|
-
Validate(this: Decorators<
|
|
100
|
+
Validate(this: Decorators<TD>): any;
|
|
101
101
|
/**
|
|
102
102
|
* The Validates decorator decorates a field to validate
|
|
103
103
|
* according to the specified validator and options.
|
|
@@ -120,7 +120,7 @@ export default class Decorators<T extends Dream> {
|
|
|
120
120
|
} : VT extends 'length' ? {
|
|
121
121
|
min: number;
|
|
122
122
|
max?: number;
|
|
123
|
-
} : VT extends 'contains' ? string | RegExp : never>(this: Decorators<
|
|
123
|
+
} : VT extends 'contains' ? string | RegExp : never>(this: Decorators<TD>, type: VT, args?: VTArgs): any;
|
|
124
124
|
/**
|
|
125
125
|
* The Virtual decorator enables setting of fields as if they
|
|
126
126
|
* corresponded to columns in the model's table so they can
|
|
@@ -182,7 +182,7 @@ export default class Decorators<T extends Dream> {
|
|
|
182
182
|
*
|
|
183
183
|
* @returns An Virtual decorator
|
|
184
184
|
*/
|
|
185
|
-
Virtual(this: Decorators<
|
|
185
|
+
Virtual(this: Decorators<TD>, type?: SerializableTypes): any;
|
|
186
186
|
/**
|
|
187
187
|
* BeforeCreate decorator
|
|
188
188
|
*
|
|
@@ -198,7 +198,7 @@ export default class Decorators<T extends Dream> {
|
|
|
198
198
|
* @returns The BeforeCreate decorator
|
|
199
199
|
*
|
|
200
200
|
*/
|
|
201
|
-
BeforeCreate(this: Decorators<
|
|
201
|
+
BeforeCreate(this: Decorators<TD>, opts?: BeforeHookOpts<T>): any;
|
|
202
202
|
/**
|
|
203
203
|
* BeforeSave decorator
|
|
204
204
|
*
|
|
@@ -214,7 +214,7 @@ export default class Decorators<T extends Dream> {
|
|
|
214
214
|
* @returns The BeforeSave decorator
|
|
215
215
|
*
|
|
216
216
|
*/
|
|
217
|
-
BeforeSave(this: Decorators<
|
|
217
|
+
BeforeSave(this: Decorators<TD>, opts?: BeforeHookOpts<T>): any;
|
|
218
218
|
/**
|
|
219
219
|
* BeforeUpdate decorator
|
|
220
220
|
*
|
|
@@ -230,7 +230,7 @@ export default class Decorators<T extends Dream> {
|
|
|
230
230
|
* @returns The BeforeUpdate decorator
|
|
231
231
|
*
|
|
232
232
|
*/
|
|
233
|
-
BeforeUpdate(this: Decorators<
|
|
233
|
+
BeforeUpdate(this: Decorators<TD>, opts?: BeforeHookOpts<T>): any;
|
|
234
234
|
/**
|
|
235
235
|
* BeforeDestroy decorator
|
|
236
236
|
*
|
|
@@ -245,7 +245,7 @@ export default class Decorators<T extends Dream> {
|
|
|
245
245
|
*
|
|
246
246
|
* @returns The BeforeDestroy decorator
|
|
247
247
|
*/
|
|
248
|
-
BeforeDestroy(this: Decorators<
|
|
248
|
+
BeforeDestroy(this: Decorators<TD>): any;
|
|
249
249
|
/**
|
|
250
250
|
* AfterCreate decorator
|
|
251
251
|
*
|
|
@@ -261,7 +261,7 @@ export default class Decorators<T extends Dream> {
|
|
|
261
261
|
* @returns The AfterCreate decorator
|
|
262
262
|
*
|
|
263
263
|
*/
|
|
264
|
-
AfterCreate(this: Decorators<
|
|
264
|
+
AfterCreate(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
|
|
265
265
|
/**
|
|
266
266
|
* AfterCreateCommit decorator
|
|
267
267
|
*
|
|
@@ -276,7 +276,7 @@ export default class Decorators<T extends Dream> {
|
|
|
276
276
|
*
|
|
277
277
|
* @returns The AfterCreateCommit decorator
|
|
278
278
|
*/
|
|
279
|
-
AfterCreateCommit(this: Decorators<
|
|
279
|
+
AfterCreateCommit(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
|
|
280
280
|
/**
|
|
281
281
|
* AfterSave decorator
|
|
282
282
|
*
|
|
@@ -292,7 +292,7 @@ export default class Decorators<T extends Dream> {
|
|
|
292
292
|
* @returns The AfterSave decorator
|
|
293
293
|
*
|
|
294
294
|
*/
|
|
295
|
-
AfterSave(this: Decorators<
|
|
295
|
+
AfterSave(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
|
|
296
296
|
/**
|
|
297
297
|
* AfterSaveCommit decorator
|
|
298
298
|
*
|
|
@@ -308,7 +308,7 @@ export default class Decorators<T extends Dream> {
|
|
|
308
308
|
* @returns The AfterSaveCommit decorator
|
|
309
309
|
*
|
|
310
310
|
*/
|
|
311
|
-
AfterSaveCommit(this: Decorators<
|
|
311
|
+
AfterSaveCommit(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
|
|
312
312
|
/**
|
|
313
313
|
* AfterUpdate decorator
|
|
314
314
|
*
|
|
@@ -324,7 +324,7 @@ export default class Decorators<T extends Dream> {
|
|
|
324
324
|
* @returns The AfterUpdate decorator
|
|
325
325
|
*
|
|
326
326
|
*/
|
|
327
|
-
AfterUpdate(this: Decorators<
|
|
327
|
+
AfterUpdate(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
|
|
328
328
|
/**
|
|
329
329
|
* AfterUpdateCommit decorator
|
|
330
330
|
*
|
|
@@ -340,7 +340,7 @@ export default class Decorators<T extends Dream> {
|
|
|
340
340
|
* @returns The AfterUpdateCommit decorator
|
|
341
341
|
*
|
|
342
342
|
*/
|
|
343
|
-
AfterUpdateCommit(this: Decorators<
|
|
343
|
+
AfterUpdateCommit(this: Decorators<TD>, opts?: AfterHookOpts<T>): any;
|
|
344
344
|
/**
|
|
345
345
|
* AfterDestroy decorator
|
|
346
346
|
*
|
|
@@ -356,7 +356,7 @@ export default class Decorators<T extends Dream> {
|
|
|
356
356
|
* @returns The AfterDestroy decorator
|
|
357
357
|
*
|
|
358
358
|
*/
|
|
359
|
-
AfterDestroy(this: Decorators<
|
|
359
|
+
AfterDestroy(this: Decorators<TD>): any;
|
|
360
360
|
/**
|
|
361
361
|
* AfterDestroyCommit decorator
|
|
362
362
|
*
|
|
@@ -372,5 +372,5 @@ export default class Decorators<T extends Dream> {
|
|
|
372
372
|
* @returns The AfterDestroyCommit decorator
|
|
373
373
|
*
|
|
374
374
|
*/
|
|
375
|
-
AfterDestroyCommit(this: Decorators<
|
|
375
|
+
AfterDestroyCommit(this: Decorators<TD>): any;
|
|
376
376
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Dream from '../../Dream.js';
|
|
2
|
+
export default class CannotAssociationQueryOnUnpersistedDream extends Error {
|
|
3
|
+
dream: Dream;
|
|
4
|
+
associationName: string | number | symbol;
|
|
5
|
+
constructor(dream: Dream, associationName: string | number | symbol);
|
|
6
|
+
get message(): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Dream from '../../Dream.js';
|
|
2
|
+
export default class CannotCreateAssociationOnUnpersistedDream extends Error {
|
|
3
|
+
dream: Dream;
|
|
4
|
+
associationName: string | number | symbol;
|
|
5
|
+
constructor(dream: Dream, associationName: string | number | symbol);
|
|
6
|
+
get message(): string;
|
|
7
|
+
}
|