@carlonicora/nestjs-neo4jsonapi 1.40.0 → 1.42.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/common/decorators/audit.decorator.d.ts +9 -0
- package/dist/common/decorators/audit.decorator.d.ts.map +1 -0
- package/dist/common/decorators/audit.decorator.js +28 -0
- package/dist/common/decorators/audit.decorator.js.map +1 -0
- package/dist/common/decorators/cache-invalidate.decorator.d.ts +11 -0
- package/dist/common/decorators/cache-invalidate.decorator.d.ts.map +1 -0
- package/dist/common/decorators/cache-invalidate.decorator.js +36 -0
- package/dist/common/decorators/cache-invalidate.decorator.js.map +1 -0
- package/dist/common/decorators/index.d.ts +3 -0
- package/dist/common/decorators/index.d.ts.map +1 -1
- package/dist/common/decorators/index.js +3 -0
- package/dist/common/decorators/index.js.map +1 -1
- package/dist/common/decorators/validate-id.decorator.d.ts +19 -0
- package/dist/common/decorators/validate-id.decorator.d.ts.map +1 -0
- package/dist/common/decorators/validate-id.decorator.js +42 -0
- package/dist/common/decorators/validate-id.decorator.js.map +1 -0
- package/dist/common/handlers/crud.handlers.d.ts +74 -0
- package/dist/common/handlers/crud.handlers.d.ts.map +1 -0
- package/dist/common/handlers/crud.handlers.js +91 -0
- package/dist/common/handlers/crud.handlers.js.map +1 -0
- package/dist/common/handlers/index.d.ts +9 -0
- package/dist/common/handlers/index.d.ts.map +1 -0
- package/dist/common/handlers/index.js +14 -0
- package/dist/common/handlers/index.js.map +1 -0
- package/dist/common/handlers/relationship.handlers.d.ts +61 -0
- package/dist/common/handlers/relationship.handlers.d.ts.map +1 -0
- package/dist/common/handlers/relationship.handlers.js +77 -0
- package/dist/common/handlers/relationship.handlers.js.map +1 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +2 -0
- package/dist/common/index.js.map +1 -1
- package/dist/foundations/audit/index.d.ts +1 -1
- package/dist/foundations/audit/index.d.ts.map +1 -1
- package/dist/foundations/audit/services/audit.service.d.ts.map +1 -1
- package/dist/foundations/audit/services/audit.service.js +1 -0
- package/dist/foundations/audit/services/audit.service.js.map +1 -1
- package/dist/foundations/company/controllers/company.controller.d.ts.map +1 -1
- package/dist/foundations/company/controllers/company.controller.js +6 -5
- package/dist/foundations/company/controllers/company.controller.js.map +1 -1
- package/dist/foundations/notification/controllers/notification.controller.d.ts +3 -1
- package/dist/foundations/notification/controllers/notification.controller.d.ts.map +1 -1
- package/dist/foundations/notification/controllers/notification.controller.js +8 -2
- package/dist/foundations/notification/controllers/notification.controller.js.map +1 -1
- package/dist/foundations/role/controllers/role.controller.d.ts +5 -1
- package/dist/foundations/role/controllers/role.controller.d.ts.map +1 -1
- package/dist/foundations/role/controllers/role.controller.js +13 -2
- package/dist/foundations/role/controllers/role.controller.js.map +1 -1
- package/dist/foundations/role/role.module.d.ts.map +1 -1
- package/dist/foundations/role/role.module.js +2 -1
- package/dist/foundations/role/role.module.js.map +1 -1
- package/dist/foundations/two-factor/controllers/passkey.controller.d.ts +3 -1
- package/dist/foundations/two-factor/controllers/passkey.controller.d.ts.map +1 -1
- package/dist/foundations/two-factor/controllers/passkey.controller.js +9 -2
- package/dist/foundations/two-factor/controllers/passkey.controller.js.map +1 -1
- package/dist/foundations/two-factor/controllers/totp.controller.d.ts +3 -1
- package/dist/foundations/two-factor/controllers/totp.controller.d.ts.map +1 -1
- package/dist/foundations/two-factor/controllers/totp.controller.js +8 -2
- package/dist/foundations/two-factor/controllers/totp.controller.js.map +1 -1
- package/dist/foundations/user/controllers/user.controller.d.ts +1 -1
- package/dist/foundations/user/controllers/user.controller.d.ts.map +1 -1
- package/dist/foundations/user/controllers/user.controller.js +11 -9
- package/dist/foundations/user/controllers/user.controller.js.map +1 -1
- package/dist/scripts/generate-module/templates/controller.template.d.ts +1 -0
- package/dist/scripts/generate-module/templates/controller.template.d.ts.map +1 -1
- package/dist/scripts/generate-module/templates/controller.template.js +37 -75
- package/dist/scripts/generate-module/templates/controller.template.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataMeta } from "../interfaces/datamodel.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that automatically logs an audit entry after the method executes.
|
|
4
|
+
*
|
|
5
|
+
* @param meta - The entity metadata (provides labelName for audit)
|
|
6
|
+
* @param id - The route param name to extract the entity ID (e.g., "cullId", "rollId")
|
|
7
|
+
*/
|
|
8
|
+
export declare function Audit(meta: DataMeta, id: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
9
|
+
//# sourceMappingURL=audit.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.decorator.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/audit.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,IAC7B,QAAQ,GAAG,EAAE,aAAa,MAAM,EAAE,YAAY,kBAAkB,wBAmBlF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Audit = Audit;
|
|
4
|
+
/**
|
|
5
|
+
* Decorator that automatically logs an audit entry after the method executes.
|
|
6
|
+
*
|
|
7
|
+
* @param meta - The entity metadata (provides labelName for audit)
|
|
8
|
+
* @param id - The route param name to extract the entity ID (e.g., "cullId", "rollId")
|
|
9
|
+
*/
|
|
10
|
+
function Audit(meta, id) {
|
|
11
|
+
return function (target, propertyKey, descriptor) {
|
|
12
|
+
const originalMethod = descriptor.value;
|
|
13
|
+
descriptor.value = async function (...args) {
|
|
14
|
+
const result = await originalMethod.apply(this, args);
|
|
15
|
+
const req = args.find((arg) => arg?.params);
|
|
16
|
+
const paramId = req?.params?.[id];
|
|
17
|
+
if (paramId && this.auditService) {
|
|
18
|
+
this.auditService.createAuditEntry({
|
|
19
|
+
entityType: meta.labelName,
|
|
20
|
+
entityId: paramId,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
return descriptor;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=audit.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/audit.decorator.ts"],"names":[],"mappings":";;AAQA,sBAoBC;AA1BD;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,IAAc,EAAE,EAAU;IAC9C,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QACxC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAG,IAAW;YAC/C,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEtD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC5C,MAAM,OAAO,GAAG,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;YAElC,IAAI,OAAO,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACjC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC;oBACjC,UAAU,EAAE,IAAI,CAAC,SAAS;oBAC1B,QAAQ,EAAE,OAAiB;iBAC5B,CAAC,CAAC;YACL,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataMeta } from "../interfaces/datamodel.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that invalidates cache after the method executes.
|
|
4
|
+
*
|
|
5
|
+
* @param meta - The entity metadata (provides endpoint for cache key)
|
|
6
|
+
* @param id - Optional: The route param name to extract the entity ID.
|
|
7
|
+
* If omitted, invalidates all entries for this type.
|
|
8
|
+
* If provided, invalidates the specific element using req.params[id].
|
|
9
|
+
*/
|
|
10
|
+
export declare function CacheInvalidate(meta: DataMeta, id?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
11
|
+
//# sourceMappingURL=cache-invalidate.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-invalidate.decorator.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/cache-invalidate.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,MAAM,IACxC,QAAQ,GAAG,EAAE,aAAa,MAAM,EAAE,YAAY,kBAAkB,wBAwBlF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CacheInvalidate = CacheInvalidate;
|
|
4
|
+
/**
|
|
5
|
+
* Decorator that invalidates cache after the method executes.
|
|
6
|
+
*
|
|
7
|
+
* @param meta - The entity metadata (provides endpoint for cache key)
|
|
8
|
+
* @param id - Optional: The route param name to extract the entity ID.
|
|
9
|
+
* If omitted, invalidates all entries for this type.
|
|
10
|
+
* If provided, invalidates the specific element using req.params[id].
|
|
11
|
+
*/
|
|
12
|
+
function CacheInvalidate(meta, id) {
|
|
13
|
+
return function (target, propertyKey, descriptor) {
|
|
14
|
+
const originalMethod = descriptor.value;
|
|
15
|
+
descriptor.value = async function (...args) {
|
|
16
|
+
const result = await originalMethod.apply(this, args);
|
|
17
|
+
if (this.cacheService) {
|
|
18
|
+
if (!id) {
|
|
19
|
+
// No id param → invalidate by type
|
|
20
|
+
await this.cacheService.invalidateByType(meta.endpoint);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// id param provided → invalidate specific element
|
|
24
|
+
const req = args.find((arg) => arg?.params);
|
|
25
|
+
const paramId = req?.params?.[id];
|
|
26
|
+
if (paramId) {
|
|
27
|
+
await this.cacheService.invalidateByElement(meta.endpoint, paramId);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
return descriptor;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=cache-invalidate.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-invalidate.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/cache-invalidate.decorator.ts"],"names":[],"mappings":";;AAUA,0CAyBC;AAjCD;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,IAAc,EAAE,EAAW;IACzD,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QACxC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAG,IAAW;YAC/C,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEtD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,IAAI,CAAC,EAAE,EAAE,CAAC;oBACR,mCAAmC;oBACnC,MAAM,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC1D,CAAC;qBAAM,CAAC;oBACN,kDAAkD;oBAClD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;oBAC5C,MAAM,OAAO,GAAG,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;oBAElC,IAAI,OAAO,EAAE,CAAC;wBACZ,MAAM,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAiB,CAAC,CAAC;oBAChF,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
export * from "./audit.decorator";
|
|
2
|
+
export * from "./cache-invalidate.decorator";
|
|
1
3
|
export * from "./conditional-service.decorator";
|
|
2
4
|
export * from "./module.decorator";
|
|
3
5
|
export * from "./oauth.scopes.decorator";
|
|
4
6
|
export * from "./rate-limit.decorator";
|
|
5
7
|
export * from "./roles.decorator";
|
|
6
8
|
export * from "./tool.decorator";
|
|
9
|
+
export * from "./validate-id.decorator";
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
|
|
@@ -14,10 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./audit.decorator"), exports);
|
|
18
|
+
__exportStar(require("./cache-invalidate.decorator"), exports);
|
|
17
19
|
__exportStar(require("./conditional-service.decorator"), exports);
|
|
18
20
|
__exportStar(require("./module.decorator"), exports);
|
|
19
21
|
__exportStar(require("./oauth.scopes.decorator"), exports);
|
|
20
22
|
__exportStar(require("./rate-limit.decorator"), exports);
|
|
21
23
|
__exportStar(require("./roles.decorator"), exports);
|
|
22
24
|
__exportStar(require("./tool.decorator"), exports);
|
|
25
|
+
__exportStar(require("./validate-id.decorator"), exports);
|
|
23
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD;AAChD,qDAAmC;AACnC,2DAAyC;AACzC,yDAAuC;AACvC,oDAAkC;AAClC,mDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,+DAA6C;AAC7C,kEAAgD;AAChD,qDAAmC;AACnC,2DAAyC;AACzC,yDAAuC;AACvC,oDAAkC;AAClC,mDAAiC;AACjC,0DAAwC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates that the URL param ID matches the body ID.
|
|
3
|
+
* Eliminates the repeated `if (id !== body.data.id)` check found in 28 places.
|
|
4
|
+
*
|
|
5
|
+
* @param paramName - The route param name (e.g., "rollId", "cullId")
|
|
6
|
+
* @param bodyPath - Optional path to ID in body (default: "data.id")
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* @Put(`${endpoint}/:cullId`)
|
|
11
|
+
* @ValidateId("cullId")
|
|
12
|
+
* @CacheInvalidate(cullMeta, "cullId")
|
|
13
|
+
* async update(@Res() reply, @Body() body: CullPutDTO) {
|
|
14
|
+
* return this.crud.update(reply, body);
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function ValidateId(paramName: string, bodyPath?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
19
|
+
//# sourceMappingURL=validate-id.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-id.decorator.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/validate-id.decorator.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,SAAY,IAC/C,QAAQ,GAAG,EAAE,aAAa,MAAM,EAAE,YAAY,kBAAkB,wBAsBlF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidateId = ValidateId;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
/**
|
|
6
|
+
* Validates that the URL param ID matches the body ID.
|
|
7
|
+
* Eliminates the repeated `if (id !== body.data.id)` check found in 28 places.
|
|
8
|
+
*
|
|
9
|
+
* @param paramName - The route param name (e.g., "rollId", "cullId")
|
|
10
|
+
* @param bodyPath - Optional path to ID in body (default: "data.id")
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* @Put(`${endpoint}/:cullId`)
|
|
15
|
+
* @ValidateId("cullId")
|
|
16
|
+
* @CacheInvalidate(cullMeta, "cullId")
|
|
17
|
+
* async update(@Res() reply, @Body() body: CullPutDTO) {
|
|
18
|
+
* return this.crud.update(reply, body);
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
function ValidateId(paramName, bodyPath = "data.id") {
|
|
23
|
+
return function (target, propertyKey, descriptor) {
|
|
24
|
+
const originalMethod = descriptor.value;
|
|
25
|
+
descriptor.value = async function (...args) {
|
|
26
|
+
// Find the request object (has params property)
|
|
27
|
+
const req = args.find((arg) => arg?.params);
|
|
28
|
+
const paramId = req?.params?.[paramName];
|
|
29
|
+
// Find the body object (has data property for JSON:API format)
|
|
30
|
+
const body = args.find((arg) => arg?.data !== undefined);
|
|
31
|
+
// Navigate to the body ID using the bodyPath
|
|
32
|
+
const bodyId = bodyPath.split(".").reduce((obj, key) => obj?.[key], body);
|
|
33
|
+
// Only validate if both IDs are present and they don't match
|
|
34
|
+
if (paramId && bodyId && paramId !== bodyId) {
|
|
35
|
+
throw new common_1.PreconditionFailedException("ID in URL does not match ID in body");
|
|
36
|
+
}
|
|
37
|
+
return originalMethod.apply(this, args);
|
|
38
|
+
};
|
|
39
|
+
return descriptor;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=validate-id.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-id.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/validate-id.decorator.ts"],"names":[],"mappings":";;AAmBA,gCAuBC;AA1CD,2CAA6D;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,UAAU,CAAC,SAAiB,EAAE,QAAQ,GAAG,SAAS;IAChE,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QACxC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAG,IAAW;YAC/C,gDAAgD;YAChD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC5C,MAAM,OAAO,GAAG,GAAG,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;YAEzC,+DAA+D;YAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC;YAEzD,6CAA6C;YAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;YAE1E,6DAA6D;YAC7D,IAAI,OAAO,IAAI,MAAM,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;gBAC5C,MAAM,IAAI,oCAA2B,CAAC,qCAAqC,CAAC,CAAC;YAC/E,CAAC;YAED,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC1C,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { FastifyReply } from "fastify";
|
|
2
|
+
import { AbstractService } from "../../core/neo4j/abstracts/abstract.service";
|
|
3
|
+
/**
|
|
4
|
+
* Standard query parameters for list operations
|
|
5
|
+
*/
|
|
6
|
+
export interface ListQueryParams {
|
|
7
|
+
query: any;
|
|
8
|
+
search?: string;
|
|
9
|
+
fetchAll?: boolean;
|
|
10
|
+
orderBy?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates handler functions for standard CRUD operations.
|
|
14
|
+
* Controllers call these from their decorated methods, delegating
|
|
15
|
+
* the actual logic while retaining their route and cross-cutting decorators.
|
|
16
|
+
*
|
|
17
|
+
* @param getService - Lambda returning the service instance (for DI compatibility)
|
|
18
|
+
* @returns Object with findAll, findById, create, update, patch, delete handlers
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* @Controller()
|
|
23
|
+
* export class CullController {
|
|
24
|
+
* private readonly crud = createCrudHandlers(() => this.cullService);
|
|
25
|
+
*
|
|
26
|
+
* constructor(private readonly cullService: CullService) {}
|
|
27
|
+
*
|
|
28
|
+
* @Get(endpoint)
|
|
29
|
+
* async findAll(@Res() reply, @Query() query, @Query("search") search?, ...) {
|
|
30
|
+
* return this.crud.findAll(reply, { query, search, fetchAll, orderBy });
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* @Put(`${endpoint}/:id`)
|
|
34
|
+
* @ValidateId("id")
|
|
35
|
+
* @CacheInvalidate(meta, "id")
|
|
36
|
+
* async update(@Res() reply, @Body() body: PutDTO) {
|
|
37
|
+
* return this.crud.update(reply, body);
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function createCrudHandlers<TService extends AbstractService<any, any>>(getService: () => TService): {
|
|
43
|
+
/**
|
|
44
|
+
* Handle findAll requests with standard pagination/search
|
|
45
|
+
*/
|
|
46
|
+
findAll(reply: FastifyReply, params: ListQueryParams): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Handle findById requests
|
|
49
|
+
*/
|
|
50
|
+
findById(reply: FastifyReply, id: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Handle create requests from JSON:API DTO
|
|
53
|
+
*/
|
|
54
|
+
create(reply: FastifyReply, body: {
|
|
55
|
+
data: any;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Handle update (PUT) requests from JSON:API DTO
|
|
59
|
+
*/
|
|
60
|
+
update(reply: FastifyReply, body: {
|
|
61
|
+
data: any;
|
|
62
|
+
}): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Handle partial update (PATCH) requests from JSON:API DTO
|
|
65
|
+
*/
|
|
66
|
+
patch(reply: FastifyReply, body: {
|
|
67
|
+
data: any;
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Handle delete requests
|
|
71
|
+
*/
|
|
72
|
+
delete(reply: FastifyReply, id: string): Promise<void>;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=crud.handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.handlers.d.ts","sourceRoot":"","sources":["../../../src/common/handlers/crud.handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAkB,MAAM,6CAA6C,CAAC;AAE9F;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,MAAM,QAAQ;IAErG;;OAEG;mBACkB,YAAY,UAAU,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1E;;OAEG;oBACmB,YAAY,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9D;;OAEG;kBACiB,YAAY,QAAQ;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrE;;OAEG;kBACiB,YAAY,QAAQ;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrE;;OAEG;iBACgB,YAAY,QAAQ;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpE;;OAEG;kBACiB,YAAY,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;EAK/D"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCrudHandlers = createCrudHandlers;
|
|
4
|
+
/**
|
|
5
|
+
* Creates handler functions for standard CRUD operations.
|
|
6
|
+
* Controllers call these from their decorated methods, delegating
|
|
7
|
+
* the actual logic while retaining their route and cross-cutting decorators.
|
|
8
|
+
*
|
|
9
|
+
* @param getService - Lambda returning the service instance (for DI compatibility)
|
|
10
|
+
* @returns Object with findAll, findById, create, update, patch, delete handlers
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* @Controller()
|
|
15
|
+
* export class CullController {
|
|
16
|
+
* private readonly crud = createCrudHandlers(() => this.cullService);
|
|
17
|
+
*
|
|
18
|
+
* constructor(private readonly cullService: CullService) {}
|
|
19
|
+
*
|
|
20
|
+
* @Get(endpoint)
|
|
21
|
+
* async findAll(@Res() reply, @Query() query, @Query("search") search?, ...) {
|
|
22
|
+
* return this.crud.findAll(reply, { query, search, fetchAll, orderBy });
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @Put(`${endpoint}/:id`)
|
|
26
|
+
* @ValidateId("id")
|
|
27
|
+
* @CacheInvalidate(meta, "id")
|
|
28
|
+
* async update(@Res() reply, @Body() body: PutDTO) {
|
|
29
|
+
* return this.crud.update(reply, body);
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
function createCrudHandlers(getService) {
|
|
35
|
+
return {
|
|
36
|
+
/**
|
|
37
|
+
* Handle findAll requests with standard pagination/search
|
|
38
|
+
*/
|
|
39
|
+
async findAll(reply, params) {
|
|
40
|
+
const response = await getService().find({
|
|
41
|
+
term: params.search,
|
|
42
|
+
query: params.query,
|
|
43
|
+
fetchAll: params.fetchAll,
|
|
44
|
+
orderBy: params.orderBy,
|
|
45
|
+
});
|
|
46
|
+
reply.send(response);
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Handle findById requests
|
|
50
|
+
*/
|
|
51
|
+
async findById(reply, id) {
|
|
52
|
+
const response = await getService().findById({ id });
|
|
53
|
+
reply.send(response);
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Handle create requests from JSON:API DTO
|
|
57
|
+
*/
|
|
58
|
+
async create(reply, body) {
|
|
59
|
+
const response = await getService().createFromDTO({
|
|
60
|
+
data: body.data,
|
|
61
|
+
});
|
|
62
|
+
reply.send(response);
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Handle update (PUT) requests from JSON:API DTO
|
|
66
|
+
*/
|
|
67
|
+
async update(reply, body) {
|
|
68
|
+
const response = await getService().putFromDTO({
|
|
69
|
+
data: body.data,
|
|
70
|
+
});
|
|
71
|
+
reply.send(response);
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* Handle partial update (PATCH) requests from JSON:API DTO
|
|
75
|
+
*/
|
|
76
|
+
async patch(reply, body) {
|
|
77
|
+
const response = await getService().patchFromDTO({
|
|
78
|
+
data: body.data,
|
|
79
|
+
});
|
|
80
|
+
reply.send(response);
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Handle delete requests
|
|
84
|
+
*/
|
|
85
|
+
async delete(reply, id) {
|
|
86
|
+
await getService().delete({ id });
|
|
87
|
+
reply.send();
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=crud.handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.handlers.js","sourceRoot":"","sources":["../../../src/common/handlers/crud.handlers.ts"],"names":[],"mappings":";;AA2CA,gDA6DC;AA3FD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,kBAAkB,CAA6C,UAA0B;IACvG,OAAO;QACL;;WAEG;QACH,KAAK,CAAC,OAAO,CAAC,KAAmB,EAAE,MAAuB;YACxD,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,CAAC,IAAI,CAAC;gBACvC,IAAI,EAAE,MAAM,CAAC,MAAM;gBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,QAAQ,CAAC,KAAmB,EAAE,EAAU;YAC5C,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACrD,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,MAAM,CAAC,KAAmB,EAAE,IAAmB;YACnD,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,CAAC,aAAa,CAAC;gBAChD,IAAI,EAAE,IAAI,CAAC,IAAiC;aAC7C,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,MAAM,CAAC,KAAmB,EAAE,IAAmB;YACnD,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,CAAC,UAAU,CAAC;gBAC7C,IAAI,EAAE,IAAI,CAAC,IAAiC;aAC7C,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,KAAK,CAAC,KAAmB,EAAE,IAAmB;YAClD,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,CAAC,YAAY,CAAC;gBAC/C,IAAI,EAAE,IAAI,CAAC,IAAiC;aAC7C,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,MAAM,CAAC,KAAmB,EAAE,EAAU;YAC1C,MAAM,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAClC,KAAK,CAAC,IAAI,EAAE,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler factories for reducing controller boilerplate
|
|
3
|
+
*
|
|
4
|
+
* These factories create reusable handler functions that controllers
|
|
5
|
+
* can delegate to from their decorated methods.
|
|
6
|
+
*/
|
|
7
|
+
export { createCrudHandlers, ListQueryParams } from "./crud.handlers";
|
|
8
|
+
export { createRelationshipHandlers, RelatedQueryParams } from "./relationship.handlers";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Handler factories for reducing controller boilerplate
|
|
4
|
+
*
|
|
5
|
+
* These factories create reusable handler functions that controllers
|
|
6
|
+
* can delegate to from their decorated methods.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createRelationshipHandlers = exports.createCrudHandlers = void 0;
|
|
10
|
+
var crud_handlers_1 = require("./crud.handlers");
|
|
11
|
+
Object.defineProperty(exports, "createCrudHandlers", { enumerable: true, get: function () { return crud_handlers_1.createCrudHandlers; } });
|
|
12
|
+
var relationship_handlers_1 = require("./relationship.handlers");
|
|
13
|
+
Object.defineProperty(exports, "createRelationshipHandlers", { enumerable: true, get: function () { return relationship_handlers_1.createRelationshipHandlers; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/handlers/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,iDAAsE;AAA7D,mHAAA,kBAAkB,OAAA;AAC3B,iEAAyF;AAAhF,mIAAA,0BAA0B,OAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { FastifyReply } from "fastify";
|
|
2
|
+
import { AbstractService } from "../../core/neo4j/abstracts/abstract.service";
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for findByRelated queries
|
|
5
|
+
*/
|
|
6
|
+
export interface RelatedQueryParams {
|
|
7
|
+
relationship: string;
|
|
8
|
+
id: string | string[];
|
|
9
|
+
query: any;
|
|
10
|
+
search?: string;
|
|
11
|
+
fetchAll?: boolean;
|
|
12
|
+
orderBy?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates handlers for relationship-based queries and operations.
|
|
16
|
+
* Used for controllers that need to query entities by related entity ID
|
|
17
|
+
* or manage to-many relationships.
|
|
18
|
+
*
|
|
19
|
+
* @param getService - Lambda returning the service instance
|
|
20
|
+
* @returns Object with findByRelated, addToRelationship, removeFromRelationship handlers
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* @Controller()
|
|
25
|
+
* export class GalleryController {
|
|
26
|
+
* private readonly relationships = createRelationshipHandlers(() => this.galleryService);
|
|
27
|
+
*
|
|
28
|
+
* constructor(private readonly galleryService: GalleryService) {}
|
|
29
|
+
*
|
|
30
|
+
* @Get(`${ownerMeta.endpoint}/:userId/${GalleryDescriptor.model.endpoint}`)
|
|
31
|
+
* async findByOwner(@Res() reply, @Param("userId") userId, @Query() query, ...) {
|
|
32
|
+
* return this.relationships.findByRelated(reply, {
|
|
33
|
+
* relationship: GalleryDescriptor.relationshipKeys.owner,
|
|
34
|
+
* id: userId, query, search, fetchAll, orderBy,
|
|
35
|
+
* });
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* @Post(`${galleryMeta.endpoint}/:galleryId/${photographMeta.endpoint}`)
|
|
39
|
+
* async addPhotographs(@Res() reply, @Param("galleryId") galleryId, @Body() body) {
|
|
40
|
+
* return this.relationships.addToRelationship(
|
|
41
|
+
* reply, galleryId, GalleryDescriptor.relationshipKeys.photograph, body.data
|
|
42
|
+
* );
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function createRelationshipHandlers<TService extends AbstractService<any, any>>(getService: () => TService): {
|
|
48
|
+
/**
|
|
49
|
+
* Find entities by a related entity ID
|
|
50
|
+
*/
|
|
51
|
+
findByRelated(reply: FastifyReply, params: RelatedQueryParams): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Add items to a to-many relationship
|
|
54
|
+
*/
|
|
55
|
+
addToRelationship(reply: FastifyReply, entityId: string, relationship: string, data: any): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Remove items from a to-many relationship
|
|
58
|
+
*/
|
|
59
|
+
removeFromRelationship(reply: FastifyReply, entityId: string, relationship: string, data: any[]): Promise<void>;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=relationship.handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationship.handlers.d.ts","sourceRoot":"","sources":["../../../src/common/handlers/relationship.handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,MAAM,QAAQ;IAE7G;;OAEG;yBACwB,YAAY,UAAU,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnF;;OAEG;6BAC4B,YAAY,YAAY,MAAM,gBAAgB,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAS9G;;OAEG;kCAEM,YAAY,YACT,MAAM,gBACF,MAAM,QACd,GAAG,EAAE,GACV,OAAO,CAAC,IAAI,CAAC;EASnB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRelationshipHandlers = createRelationshipHandlers;
|
|
4
|
+
/**
|
|
5
|
+
* Creates handlers for relationship-based queries and operations.
|
|
6
|
+
* Used for controllers that need to query entities by related entity ID
|
|
7
|
+
* or manage to-many relationships.
|
|
8
|
+
*
|
|
9
|
+
* @param getService - Lambda returning the service instance
|
|
10
|
+
* @returns Object with findByRelated, addToRelationship, removeFromRelationship handlers
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* @Controller()
|
|
15
|
+
* export class GalleryController {
|
|
16
|
+
* private readonly relationships = createRelationshipHandlers(() => this.galleryService);
|
|
17
|
+
*
|
|
18
|
+
* constructor(private readonly galleryService: GalleryService) {}
|
|
19
|
+
*
|
|
20
|
+
* @Get(`${ownerMeta.endpoint}/:userId/${GalleryDescriptor.model.endpoint}`)
|
|
21
|
+
* async findByOwner(@Res() reply, @Param("userId") userId, @Query() query, ...) {
|
|
22
|
+
* return this.relationships.findByRelated(reply, {
|
|
23
|
+
* relationship: GalleryDescriptor.relationshipKeys.owner,
|
|
24
|
+
* id: userId, query, search, fetchAll, orderBy,
|
|
25
|
+
* });
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* @Post(`${galleryMeta.endpoint}/:galleryId/${photographMeta.endpoint}`)
|
|
29
|
+
* async addPhotographs(@Res() reply, @Param("galleryId") galleryId, @Body() body) {
|
|
30
|
+
* return this.relationships.addToRelationship(
|
|
31
|
+
* reply, galleryId, GalleryDescriptor.relationshipKeys.photograph, body.data
|
|
32
|
+
* );
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function createRelationshipHandlers(getService) {
|
|
38
|
+
return {
|
|
39
|
+
/**
|
|
40
|
+
* Find entities by a related entity ID
|
|
41
|
+
*/
|
|
42
|
+
async findByRelated(reply, params) {
|
|
43
|
+
const response = await getService().findByRelated({
|
|
44
|
+
relationship: params.relationship,
|
|
45
|
+
id: params.id,
|
|
46
|
+
term: params.search,
|
|
47
|
+
query: params.query,
|
|
48
|
+
fetchAll: params.fetchAll,
|
|
49
|
+
orderBy: params.orderBy,
|
|
50
|
+
});
|
|
51
|
+
reply.send(response);
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Add items to a to-many relationship
|
|
55
|
+
*/
|
|
56
|
+
async addToRelationship(reply, entityId, relationship, data) {
|
|
57
|
+
const response = await getService().addToRelationshipFromDTO({
|
|
58
|
+
id: entityId,
|
|
59
|
+
relationship: relationship,
|
|
60
|
+
data,
|
|
61
|
+
});
|
|
62
|
+
reply.send(response);
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Remove items from a to-many relationship
|
|
66
|
+
*/
|
|
67
|
+
async removeFromRelationship(reply, entityId, relationship, data) {
|
|
68
|
+
const response = await getService().removeFromRelationshipFromDTO({
|
|
69
|
+
id: entityId,
|
|
70
|
+
relationship: relationship,
|
|
71
|
+
data,
|
|
72
|
+
});
|
|
73
|
+
reply.send(response);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=relationship.handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationship.handlers.js","sourceRoot":"","sources":["../../../src/common/handlers/relationship.handlers.ts"],"names":[],"mappings":";;AAgDA,gEA8CC;AA/ED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,0BAA0B,CAA6C,UAA0B;IAC/G,OAAO;QACL;;WAEG;QACH,KAAK,CAAC,aAAa,CAAC,KAAmB,EAAE,MAA0B;YACjE,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,CAAC,aAAa,CAAC;gBAChD,YAAY,EAAE,MAAM,CAAC,YAAmB;gBACxC,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,IAAI,EAAE,MAAM,CAAC,MAAM;gBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,iBAAiB,CAAC,KAAmB,EAAE,QAAgB,EAAE,YAAoB,EAAE,IAAS;YAC5F,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,CAAC,wBAAwB,CAAC;gBAC3D,EAAE,EAAE,QAAQ;gBACZ,YAAY,EAAE,YAAmB;gBACjC,IAAI;aACL,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAED;;WAEG;QACH,KAAK,CAAC,sBAAsB,CAC1B,KAAmB,EACnB,QAAgB,EAChB,YAAoB,EACpB,IAAW;YAEX,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,CAAC,6BAA6B,CAAC;gBAChE,EAAE,EAAE,QAAQ;gBACZ,YAAY,EAAE,YAAmB;gBACjC,IAAI;aACL,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/common/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./registries";
|
|
|
16
16
|
export * from "./repositories";
|
|
17
17
|
export * from "./strategies";
|
|
18
18
|
export * from "./types";
|
|
19
|
+
export * from "./handlers";
|
|
19
20
|
export * from "./tokens";
|
|
20
21
|
export * from "./constants/system.roles";
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,cAAc,WAAW,CAAC;AAG1B,cAAc,UAAU,CAAC;AAGzB,cAAc,WAAW,CAAC;AAG1B,cAAc,cAAc,CAAC;AAG7B,cAAc,cAAc,CAAC;AAG7B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,cAAc,WAAW,CAAC;AAG1B,cAAc,UAAU,CAAC;AAGzB,cAAc,WAAW,CAAC;AAG1B,cAAc,cAAc,CAAC;AAG7B,cAAc,cAAc,CAAC;AAG7B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,cAAc,YAAY,CAAC;AAG3B,cAAc,UAAU,CAAC;AAGzB,cAAc,0BAA0B,CAAC"}
|
package/dist/common/index.js
CHANGED
|
@@ -44,6 +44,8 @@ __exportStar(require("./repositories"), exports);
|
|
|
44
44
|
__exportStar(require("./strategies"), exports);
|
|
45
45
|
// Types
|
|
46
46
|
__exportStar(require("./types"), exports);
|
|
47
|
+
// Handlers
|
|
48
|
+
__exportStar(require("./handlers"), exports);
|
|
47
49
|
// Tokens and interfaces for dependency injection
|
|
48
50
|
__exportStar(require("./tokens"), exports);
|
|
49
51
|
// Constants
|
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,YAAY;AACZ,8CAA4B;AAE5B,WAAW;AACX,6CAA2B;AAE3B,aAAa;AACb,+CAA6B;AAE7B,QAAQ;AACR,0CAAwB;AAExB,UAAU;AACV,4CAA0B;AAE1B,SAAS;AACT,2CAAyB;AAEzB,UAAU;AACV,4CAA0B;AAE1B,aAAa;AACb,+CAA6B;AAE7B,aAAa;AACb,+CAA6B;AAE7B,eAAe;AACf,iDAA+B;AAE/B,aAAa;AACb,+CAA6B;AAE7B,QAAQ;AACR,0CAAwB;AAExB,iDAAiD;AACjD,2CAAyB;AAEzB,YAAY;AACZ,2DAAyC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,YAAY;AACZ,8CAA4B;AAE5B,WAAW;AACX,6CAA2B;AAE3B,aAAa;AACb,+CAA6B;AAE7B,QAAQ;AACR,0CAAwB;AAExB,UAAU;AACV,4CAA0B;AAE1B,SAAS;AACT,2CAAyB;AAEzB,UAAU;AACV,4CAA0B;AAE1B,aAAa;AACb,+CAA6B;AAE7B,aAAa;AACb,+CAA6B;AAE7B,eAAe;AACf,iDAA+B;AAE/B,aAAa;AACb,+CAA6B;AAE7B,QAAQ;AACR,0CAAwB;AAExB,WAAW;AACX,6CAA2B;AAE3B,iDAAiD;AACjD,2CAAyB;AAEzB,YAAY;AACZ,2DAAyC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AuditModule } from "./audit.module";
|
|
2
|
-
export { Audit } from "./entities/audit.entity";
|
|
2
|
+
export type { Audit as AuditEntity } from "./entities/audit.entity";
|
|
3
3
|
export { auditMeta } from "./entities/audit.meta";
|
|
4
4
|
export { auditModel } from "./entities/audit.model";
|
|
5
5
|
export { AuditRepository } from "./repositories/audit.repository";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/foundations/audit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/foundations/audit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/audit/services/audit.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAE5E,qBACa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAFV,OAAO,EAAE,cAAc,EACvB,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,UAAU;IAGnC,gBAAgB,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"audit.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/audit/services/audit.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAE5E,qBACa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAFV,OAAO,EAAE,cAAc,EACvB,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,UAAU;IAGnC,gBAAgB,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAajF,UAAU,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAcxE"}
|
|
@@ -23,6 +23,7 @@ let AuditService = class AuditService {
|
|
|
23
23
|
this.clsService = clsService;
|
|
24
24
|
}
|
|
25
25
|
async createAuditEntry(params) {
|
|
26
|
+
console.log("Creating audit entry for", params.entityType, "ID:", params.entityId);
|
|
26
27
|
const userId = this.clsService.get("userId");
|
|
27
28
|
if (!userId)
|
|
28
29
|
return;
|