@cuboapp/api-backend 1.0.3 → 1.0.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/package.json +1 -1
- package/src/helpers/query.ts +3 -0
- package/src/helpers/withes.ts +9 -3
- package/src/index.ts +1 -1
- package/src/types/db.ts +10 -1
package/package.json
CHANGED
package/src/helpers/query.ts
CHANGED
package/src/helpers/withes.ts
CHANGED
|
@@ -76,12 +76,18 @@ export class ApiHelpersWithes<T extends CuboApiEntitiesMap<T>> {
|
|
|
76
76
|
throw new Error('relation for key not found: "' + partKey + '"')
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
let relationEntity: CuboEntity | undefined
|
|
80
|
+
|
|
79
81
|
if (relation_entity_id) {
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
82
|
+
relationEntity = await this.helpers.entities.getById(relation_entity_id)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!relationEntity && relation_entity_alias) {
|
|
86
|
+
relationEntity = await this.helpers.entities.getByAlias(relation_entity_alias)
|
|
83
87
|
}
|
|
84
88
|
|
|
89
|
+
lastEntity = relationEntity
|
|
90
|
+
|
|
85
91
|
if (!lastEntity) {
|
|
86
92
|
throw new Error('entity for relation key not found: "' + partKey + '"')
|
|
87
93
|
}
|
package/src/index.ts
CHANGED
|
@@ -273,7 +273,7 @@ export class CuboBackendApi<T extends CuboApiEntitiesMap<T>> {
|
|
|
273
273
|
const entity = await this.helpers.entities.getByAlias(entityAlias)
|
|
274
274
|
const augmentation = this.augmentations?.[entityAlias]
|
|
275
275
|
|
|
276
|
-
if (augmentation?.beforeUpdate) {
|
|
276
|
+
if (augmentation?.beforeUpdate && !opts?.excludeHooks?.includes('beforeUpdate')) {
|
|
277
277
|
opts.queryOptions = await augmentation.beforeUpdate(req, opts)
|
|
278
278
|
}
|
|
279
279
|
|
package/src/types/db.ts
CHANGED
|
@@ -18,7 +18,16 @@ export type CuboCrudMethodOptions<E extends object = {}> = {
|
|
|
18
18
|
transaction?: Transaction
|
|
19
19
|
performer_id?: number
|
|
20
20
|
extra?: any
|
|
21
|
-
excludeHooks?: (
|
|
21
|
+
excludeHooks?: (
|
|
22
|
+
| 'beforeGetMany'
|
|
23
|
+
| 'beforeGetOne'
|
|
24
|
+
| 'afterCreate'
|
|
25
|
+
| 'afterUpdate'
|
|
26
|
+
| 'afterDelete'
|
|
27
|
+
| 'afterGetMany'
|
|
28
|
+
| 'afterGetOne'
|
|
29
|
+
| 'beforeUpdate'
|
|
30
|
+
)[]
|
|
22
31
|
|
|
23
32
|
log?: boolean
|
|
24
33
|
|