Added tags-delete(many) schema
ADD
src/assets/server/rest/v1/schemas/tag/tags-delete.json
+{
+ "title": "Delete several Tags",
+ "description": "",
+ "type": "object",
+ "properties": {
+ "tagIDs": {
+ "type": "array",
+ "items": {
+ "$ref": "tag.json#/definitions/id"
+ }
+ }
+ },
+ "required": [
+ "tagIDs"
+ ]
+}

MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -63,7 +63,7 @@ export default class TagService {
public static async handleDeleteTags(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const tagsIDs = TagSecurity.filterTagRequestByIDs(req.body);
+ const tagsIDs = TagValidator.getInstance().validateTagsDeleteMany(req.body).tagIDs;
// Delete
const result = await TagService.deleteTags(req.tenant, action, req.user, tagsIDs);
// Return
@@ -757,7 +757,7 @@ export default class TagService {
{
limit: filteredRequest.Limit,
skip: filteredRequest.Skip,
- sort: filteredRequest.SortFields,
+ sort: UtilsService.httpSortFieldsToMongoDB(filteredRequest.SortFields),
onlyRecordCount: filteredRequest.OnlyRecordCount
},
authorizationTagsFilters.projectFields,

MODIFY
src/server/rest/v1/validator/TagValidator.ts
src/server/rest/v1/validator/TagValidator.ts
@@ -12,6 +12,7 @@ export default class TagValidator extends SchemaValidator {
private tagCreate: Schema;
private tagUpdate: Schema;
private tagsGet: Schema;
+ private tagsDeleteMany: Schema;
private constructor() {
super('TagValidator');
@@ -19,6 +20,7 @@ export default class TagValidator extends SchemaValidator {
this.tagCreate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tag-create.json`, 'utf8'));
this.tagUpdate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tag-update.json`, 'utf8'));
this.tagsGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tags-get.json`, 'utf8'));
+ this.tagsDeleteMany = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tags-delete.json`, 'utf8'));
}
public static getInstance(): TagValidator {
@@ -46,4 +48,9 @@ export default class TagValidator extends SchemaValidator {
this.validate(this.tagsGet, data);
return data;
}
+
+ validateTagsDeleteMany(data: { tagIDs: string[] }): { tagIDs: string[] } {
+ this.validate(this.tagsDeleteMany, data);
+ return data;
+ }
}

Added tags-delete(many) schema