fix import typo / fix merge regression / check tags required import properties
MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -3,7 +3,7 @@ import { ActionsResponse, ImportStatus } from '../../../../types/GlobalType';
import { HTTPAuthError, HTTPError } from '../../../../types/HTTPError';
import { NextFunction, Request, Response } from 'express';
import { OCPITokenType, OCPITokenWhitelist } from '../../../../types/ocpi/OCPIToken';
-import Tag, { ImportedTag } from '../../../../types/Tag';
+import Tag, { ImportedTag, TagRequiredImportProperties } from '../../../../types/Tag';
import AppAuthError from '../../../../exception/AppAuthError';
import AppError from '../../../../exception/AppError';
@@ -490,6 +490,20 @@ export default class TagService {
quote: 'off'
});
void converter.subscribe(async (tag: ImportedTag) => {
+ // Check the format of the first entry
+ if (!result.inSuccess && !result.inError) {
+ if (!TagRequiredImportProperties.every((property) => Object.keys(tag).includes(property))) {
+ void Logging.logError({
+ tenantID: req.user.tenantID,
+ module: MODULE_NAME, method: 'handleImportTags',
+ action: action,
+ user: req.user.id,
+ message: `Invalid Csv file '${filename}', all properties: '${TagRequiredImportProperties.join(', ')}' are required`,
+ });
+ res.writeHead(HTTPError.INVALID_FILE_FORMAT);
+ res.end();
+ }
+ }
// Set default value
tag.importedBy = importedBy;
tag.importedOn = importedOn;

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -1013,7 +1013,8 @@ export default class TransactionService {
return result;
}
- private static async getTransactions(req: Request, action: ServerAction, params: { withTag?: boolean } = {}, projectFields): Promise<DataResult<Transaction>> {
+ private static async getTransactions(req: Request, action: ServerAction,
+ params: { completedTransactions?: boolean, withTag?: boolean } = {}, projectFields): Promise<DataResult<Transaction>> {
// Check Transactions
if (!Authorizations.canListTransactions(req.user)) {
throw new AppAuthError({

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -20,7 +20,7 @@ import Cypher from '../../../../utils/Cypher';
import { DataResult } from '../../../../types/DataResult';
import EmspOCPIClient from '../../../../client/ocpi/EmspOCPIClient';
import I18nManager from '../../../../utils/I18nManager';
-import JSONStream from 'jsonstream';
+import JSONStream from 'JSONStream';
import Logging from '../../../../utils/Logging';
import NotificationHandler from '../../../../notification/NotificationHandler';
import OCPIClientFactory from '../../../../client/ocpi/OCPIClientFactory';
@@ -888,6 +888,7 @@ export default class UserService {
quote: 'off'
});
void converter.subscribe(async (user: ImportedUser) => {
+ // Check the format of the first entry
if (!result.inSuccess && !result.inError) {
if (!UserRequiredImportProperties.every((property) => Object.keys(user).includes(property))) {
void Logging.logError({

fix import typo / fix merge regression / check tags required import properties