@floristcloud/api-lib 1.2.211 → 1.2.213
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/build/constant/error.js +2 -0
- package/build/constant/validation-i18n-key.js +1 -0
- package/build/constant/validation-i18n-message.js +1 -0
- package/build/schemas/client/client-user-attached-error-data.schema.js +9 -0
- package/build/schemas/client/index.js +1 -0
- package/build/schemas/user/create-user-by-client-id-data.schema.js +5 -2
- package/build/schemas/user/create-user-by-client-id-response.schema.js +2 -0
- package/build/schemas/user/index.js +3 -0
- package/build/schemas/user/user-duplicate-candidate.schema.js +18 -0
- package/build/schemas/user/user-duplicate-error-data.schema.js +9 -0
- package/build/schemas/user/user-linked-client.schema.js +9 -0
- package/build/types/client-user-attached-error-data.type.js +2 -0
- package/build/types/index.js +3 -0
- package/build/types/user-duplicate-candidate.type.js +2 -0
- package/build/types/user-duplicate-error-data.type.js +2 -0
- package/constant/error.ts +2 -0
- package/constant/validation-i18n-key.ts +1 -0
- package/constant/validation-i18n-message.ts +1 -0
- package/package.json +1 -1
- package/schemas/client/client-user-attached-error-data.schema.ts +7 -0
- package/schemas/client/index.ts +1 -0
- package/schemas/user/create-user-by-client-id-data.schema.ts +5 -2
- package/schemas/user/create-user-by-client-id-response.schema.ts +2 -0
- package/schemas/user/index.ts +3 -0
- package/schemas/user/user-duplicate-candidate.schema.ts +16 -0
- package/schemas/user/user-duplicate-error-data.schema.ts +7 -0
- package/schemas/user/user-linked-client.schema.ts +7 -0
- package/types/client-user-attached-error-data.type.ts +4 -0
- package/types/index.ts +6 -0
- package/types/user-duplicate-candidate.type.ts +4 -0
- package/types/user-duplicate-error-data.type.ts +4 -0
package/build/constant/error.js
CHANGED
|
@@ -272,6 +272,8 @@ exports.ERRORS = {
|
|
|
272
272
|
message: 'Client must keep a default legal profile: assign another one instead',
|
|
273
273
|
httpCode: 409,
|
|
274
274
|
},
|
|
275
|
+
// Client.userUUID уникален: у пользователя может быть только один клиент. errorData — ClientUserAttachedErrorData.
|
|
276
|
+
CLIENT_USER_ATTACHED_TO_OTHER_CLIENT: { code: 'CL050', message: 'The user is already attached to another client', httpCode: 409 },
|
|
275
277
|
CLIENT_CALCULATE_FAILED: { code: 'CL023', message: 'Failed calculate by client', httpCode: 500 },
|
|
276
278
|
//BRANCH
|
|
277
279
|
BRANCH_NOT_CREATED: { code: 'B001', message: 'Failed to create branch', httpCode: 500 },
|
|
@@ -15,6 +15,7 @@ exports.ValidationI18nKey = {
|
|
|
15
15
|
dateRange: 'validation.dateRange',
|
|
16
16
|
reportPeriodMax: 'validation.reportPeriodMax',
|
|
17
17
|
emailOrPhoneRequired: 'validation.emailOrPhoneRequired',
|
|
18
|
+
passwordOrEmailRequired: 'validation.passwordOrEmailRequired',
|
|
18
19
|
allowedRoles: 'validation.allowedRoles',
|
|
19
20
|
statusNotAllowedWebshop: 'validation.statusNotAllowedWebshop',
|
|
20
21
|
targetOrderInList: 'validation.targetOrderInList',
|
|
@@ -18,6 +18,7 @@ exports.VALIDATION_I18N_MESSAGE = {
|
|
|
18
18
|
[validation_i18n_key_1.ValidationI18nKey.dateRange]: 'Start date must be before or equal to end date',
|
|
19
19
|
[validation_i18n_key_1.ValidationI18nKey.reportPeriodMax]: 'The selected period exceeds the maximum allowed range',
|
|
20
20
|
[validation_i18n_key_1.ValidationI18nKey.emailOrPhoneRequired]: 'Either email or phone is required',
|
|
21
|
+
[validation_i18n_key_1.ValidationI18nKey.passwordOrEmailRequired]: 'Password is required when the user has no email',
|
|
21
22
|
[validation_i18n_key_1.ValidationI18nKey.allowedRoles]: 'The specified role is not allowed',
|
|
22
23
|
[validation_i18n_key_1.ValidationI18nKey.statusNotAllowedWebshop]: 'This status is not allowed in the webshop',
|
|
23
24
|
[validation_i18n_key_1.ValidationI18nKey.targetOrderInList]: 'The target order must not be included in the source order list',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientUserAttachedErrorDataSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const user_linked_client_schema_1 = require("../user/user-linked-client.schema");
|
|
6
|
+
// errorData ответа CL050 (CLIENT_USER_ATTACHED_TO_OTHER_CLIENT): клиент, к которому пользователь уже привязан
|
|
7
|
+
exports.ClientUserAttachedErrorDataSchema = zod_1.z.object({
|
|
8
|
+
client: user_linked_client_schema_1.UserLinkedClientSchema,
|
|
9
|
+
});
|
|
@@ -49,3 +49,4 @@ __exportStar(require("./legal-identifier-value.schema"), exports);
|
|
|
49
49
|
__exportStar(require("./client-filters-values.schema"), exports);
|
|
50
50
|
__exportStar(require("./get-client-filters-values-request.schema"), exports);
|
|
51
51
|
__exportStar(require("./get-client-filters-values-response.schema"), exports);
|
|
52
|
+
__exportStar(require("./client-user-attached-error-data.schema"), exports);
|
|
@@ -4,12 +4,15 @@ exports.CreateUserByClientIdDataSchema = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const password_schema_1 = require("../auth/password.schema");
|
|
6
6
|
const userRole_enum_1 = require("../../enum/userRole.enum");
|
|
7
|
+
const validation_i18n_key_1 = require("../../constant/validation-i18n-key");
|
|
7
8
|
exports.CreateUserByClientIdDataSchema = zod_1.z
|
|
8
9
|
.object({
|
|
9
|
-
|
|
10
|
+
// Без пароля сервер генерирует его сам и отправляет на email (FC-621)
|
|
11
|
+
password: password_schema_1.PasswordSchema.optional(),
|
|
10
12
|
name: zod_1.z.string(),
|
|
11
13
|
email: zod_1.z.email().toLowerCase().nullable().optional(),
|
|
12
14
|
phone: zod_1.z.string().nullable().optional(),
|
|
13
15
|
roles: zod_1.z.array(zod_1.z.nativeEnum(userRole_enum_1.UserRoleEnum)).optional().default([userRole_enum_1.UserRoleEnum.BUYER]),
|
|
14
16
|
})
|
|
15
|
-
.refine(data => data.email || data.phone, { message:
|
|
17
|
+
.refine(data => data.email || data.phone, { message: validation_i18n_key_1.ValidationI18nKey.emailOrPhoneRequired })
|
|
18
|
+
.refine(data => data.password || data.email, { message: validation_i18n_key_1.ValidationI18nKey.passwordOrEmailRequired, path: ['password'] });
|
|
@@ -8,4 +8,6 @@ exports.CreateUserByClientIdResponseSchema = zod_1.z.object({
|
|
|
8
8
|
code: zod_1.z.string().optional(),
|
|
9
9
|
i18nKey: zod_1.z.string().optional(),
|
|
10
10
|
data: user_schema_1.UserSchema,
|
|
11
|
+
// Письмо с данными для входа принято почтовым сервисом; false — email нет или отправка не удалась
|
|
12
|
+
isCredentialsEmailSent: zod_1.z.boolean(),
|
|
11
13
|
});
|
|
@@ -32,3 +32,6 @@ __exportStar(require("./get-me-data.schema"), exports);
|
|
|
32
32
|
__exportStar(require("./get-me-response.schema"), exports);
|
|
33
33
|
__exportStar(require("./get-user-data.schema"), exports);
|
|
34
34
|
__exportStar(require("./get-user-response.schema"), exports);
|
|
35
|
+
__exportStar(require("./user-linked-client.schema"), exports);
|
|
36
|
+
__exportStar(require("./user-duplicate-candidate.schema"), exports);
|
|
37
|
+
__exportStar(require("./user-duplicate-error-data.schema"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserDuplicateCandidateSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const userRole_enum_1 = require("../../enum/userRole.enum");
|
|
6
|
+
const userStatus_enum_1 = require("../../enum/userStatus.enum");
|
|
7
|
+
const user_linked_client_schema_1 = require("./user-linked-client.schema");
|
|
8
|
+
// Существующий пользователь компании с тем же email или телефоном. Отдаётся только тем, кто может
|
|
9
|
+
// привязывать пользователей к клиентам (ADMIN, global): остальным детали чужих учёток не видны.
|
|
10
|
+
exports.UserDuplicateCandidateSchema = zod_1.z.object({
|
|
11
|
+
uuid: zod_1.z.uuid(),
|
|
12
|
+
name: zod_1.z.string(),
|
|
13
|
+
email: zod_1.z.string().nullable(),
|
|
14
|
+
phone: zod_1.z.string().nullable(),
|
|
15
|
+
roles: zod_1.z.array(zod_1.z.nativeEnum(userRole_enum_1.UserRoleEnum)),
|
|
16
|
+
status: zod_1.z.nativeEnum(userStatus_enum_1.UserStatusEnum),
|
|
17
|
+
client: user_linked_client_schema_1.UserLinkedClientSchema.nullable(),
|
|
18
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserDuplicateErrorDataSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const user_duplicate_candidate_schema_1 = require("./user-duplicate-candidate.schema");
|
|
6
|
+
// errorData ответа U006 (USER_ALREADY_EXISTS) при создании пользователя для клиента
|
|
7
|
+
exports.UserDuplicateErrorDataSchema = zod_1.z.object({
|
|
8
|
+
users: zod_1.z.array(user_duplicate_candidate_schema_1.UserDuplicateCandidateSchema),
|
|
9
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserLinkedClientSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
// Клиент, к которому привязан пользователь (Client.userUUID)
|
|
6
|
+
exports.UserLinkedClientSchema = zod_1.z.object({
|
|
7
|
+
uuid: zod_1.z.uuid(),
|
|
8
|
+
name: zod_1.z.string(),
|
|
9
|
+
});
|
package/build/types/index.js
CHANGED
|
@@ -16,3 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./client-import-data.type"), exports);
|
|
18
18
|
__exportStar(require("./order-vat-source-confirmation.type"), exports);
|
|
19
|
+
__exportStar(require("./user-duplicate-candidate.type"), exports);
|
|
20
|
+
__exportStar(require("./user-duplicate-error-data.type"), exports);
|
|
21
|
+
__exportStar(require("./client-user-attached-error-data.type"), exports);
|
package/constant/error.ts
CHANGED
|
@@ -282,6 +282,8 @@ export const ERRORS = {
|
|
|
282
282
|
message: 'Client must keep a default legal profile: assign another one instead',
|
|
283
283
|
httpCode: 409,
|
|
284
284
|
},
|
|
285
|
+
// Client.userUUID уникален: у пользователя может быть только один клиент. errorData — ClientUserAttachedErrorData.
|
|
286
|
+
CLIENT_USER_ATTACHED_TO_OTHER_CLIENT: { code: 'CL050', message: 'The user is already attached to another client', httpCode: 409 },
|
|
285
287
|
CLIENT_CALCULATE_FAILED: { code: 'CL023', message: 'Failed calculate by client', httpCode: 500 },
|
|
286
288
|
//BRANCH
|
|
287
289
|
BRANCH_NOT_CREATED: { code: 'B001', message: 'Failed to create branch', httpCode: 500 },
|
|
@@ -12,6 +12,7 @@ export const ValidationI18nKey = {
|
|
|
12
12
|
dateRange: 'validation.dateRange',
|
|
13
13
|
reportPeriodMax: 'validation.reportPeriodMax',
|
|
14
14
|
emailOrPhoneRequired: 'validation.emailOrPhoneRequired',
|
|
15
|
+
passwordOrEmailRequired: 'validation.passwordOrEmailRequired',
|
|
15
16
|
allowedRoles: 'validation.allowedRoles',
|
|
16
17
|
statusNotAllowedWebshop: 'validation.statusNotAllowedWebshop',
|
|
17
18
|
targetOrderInList: 'validation.targetOrderInList',
|
|
@@ -16,6 +16,7 @@ export const VALIDATION_I18N_MESSAGE: Record<ValidationI18nKeyType, string> = {
|
|
|
16
16
|
[ValidationI18nKey.dateRange]: 'Start date must be before or equal to end date',
|
|
17
17
|
[ValidationI18nKey.reportPeriodMax]: 'The selected period exceeds the maximum allowed range',
|
|
18
18
|
[ValidationI18nKey.emailOrPhoneRequired]: 'Either email or phone is required',
|
|
19
|
+
[ValidationI18nKey.passwordOrEmailRequired]: 'Password is required when the user has no email',
|
|
19
20
|
[ValidationI18nKey.allowedRoles]: 'The specified role is not allowed',
|
|
20
21
|
[ValidationI18nKey.statusNotAllowedWebshop]: 'This status is not allowed in the webshop',
|
|
21
22
|
[ValidationI18nKey.targetOrderInList]: 'The target order must not be included in the source order list',
|
package/package.json
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { UserLinkedClientSchema } from '../user/user-linked-client.schema';
|
|
3
|
+
|
|
4
|
+
// errorData ответа CL050 (CLIENT_USER_ATTACHED_TO_OTHER_CLIENT): клиент, к которому пользователь уже привязан
|
|
5
|
+
export const ClientUserAttachedErrorDataSchema = z.object({
|
|
6
|
+
client: UserLinkedClientSchema,
|
|
7
|
+
});
|
package/schemas/client/index.ts
CHANGED
|
@@ -33,3 +33,4 @@ export * from './legal-identifier-value.schema';
|
|
|
33
33
|
export * from './client-filters-values.schema';
|
|
34
34
|
export * from './get-client-filters-values-request.schema';
|
|
35
35
|
export * from './get-client-filters-values-response.schema';
|
|
36
|
+
export * from './client-user-attached-error-data.schema';
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { PasswordSchema } from '../auth/password.schema';
|
|
3
3
|
import { UserRoleEnum } from '../../enum/userRole.enum';
|
|
4
|
+
import { ValidationI18nKey } from '../../constant/validation-i18n-key';
|
|
4
5
|
|
|
5
6
|
export const CreateUserByClientIdDataSchema = z
|
|
6
7
|
.object({
|
|
7
|
-
|
|
8
|
+
// Без пароля сервер генерирует его сам и отправляет на email (FC-621)
|
|
9
|
+
password: PasswordSchema.optional(),
|
|
8
10
|
name: z.string(),
|
|
9
11
|
email: z.email().toLowerCase().nullable().optional(),
|
|
10
12
|
phone: z.string().nullable().optional(),
|
|
11
13
|
roles: z.array(z.nativeEnum(UserRoleEnum)).optional().default([UserRoleEnum.BUYER]),
|
|
12
14
|
})
|
|
13
|
-
.refine(data => data.email || data.phone, { message:
|
|
15
|
+
.refine(data => data.email || data.phone, { message: ValidationI18nKey.emailOrPhoneRequired })
|
|
16
|
+
.refine(data => data.password || data.email, { message: ValidationI18nKey.passwordOrEmailRequired, path: ['password'] });
|
|
@@ -6,4 +6,6 @@ export const CreateUserByClientIdResponseSchema = z.object({
|
|
|
6
6
|
code: z.string().optional(),
|
|
7
7
|
i18nKey: z.string().optional(),
|
|
8
8
|
data: UserSchema,
|
|
9
|
+
// Письмо с данными для входа принято почтовым сервисом; false — email нет или отправка не удалась
|
|
10
|
+
isCredentialsEmailSent: z.boolean(),
|
|
9
11
|
});
|
package/schemas/user/index.ts
CHANGED
|
@@ -16,3 +16,6 @@ export * from './get-me-data.schema';
|
|
|
16
16
|
export * from './get-me-response.schema';
|
|
17
17
|
export * from './get-user-data.schema';
|
|
18
18
|
export * from './get-user-response.schema';
|
|
19
|
+
export * from './user-linked-client.schema';
|
|
20
|
+
export * from './user-duplicate-candidate.schema';
|
|
21
|
+
export * from './user-duplicate-error-data.schema';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { UserRoleEnum } from '../../enum/userRole.enum';
|
|
3
|
+
import { UserStatusEnum } from '../../enum/userStatus.enum';
|
|
4
|
+
import { UserLinkedClientSchema } from './user-linked-client.schema';
|
|
5
|
+
|
|
6
|
+
// Существующий пользователь компании с тем же email или телефоном. Отдаётся только тем, кто может
|
|
7
|
+
// привязывать пользователей к клиентам (ADMIN, global): остальным детали чужих учёток не видны.
|
|
8
|
+
export const UserDuplicateCandidateSchema = z.object({
|
|
9
|
+
uuid: z.uuid(),
|
|
10
|
+
name: z.string(),
|
|
11
|
+
email: z.string().nullable(),
|
|
12
|
+
phone: z.string().nullable(),
|
|
13
|
+
roles: z.array(z.nativeEnum(UserRoleEnum)),
|
|
14
|
+
status: z.nativeEnum(UserStatusEnum),
|
|
15
|
+
client: UserLinkedClientSchema.nullable(),
|
|
16
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { UserDuplicateCandidateSchema } from './user-duplicate-candidate.schema';
|
|
3
|
+
|
|
4
|
+
// errorData ответа U006 (USER_ALREADY_EXISTS) при создании пользователя для клиента
|
|
5
|
+
export const UserDuplicateErrorDataSchema = z.object({
|
|
6
|
+
users: z.array(UserDuplicateCandidateSchema),
|
|
7
|
+
});
|
package/types/index.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export * from './client-import-data.type';
|
|
2
2
|
|
|
3
3
|
export * from './order-vat-source-confirmation.type';
|
|
4
|
+
|
|
5
|
+
export * from './user-duplicate-candidate.type';
|
|
6
|
+
|
|
7
|
+
export * from './user-duplicate-error-data.type';
|
|
8
|
+
|
|
9
|
+
export * from './client-user-attached-error-data.type';
|