@floristcloud/api-lib 1.2.152 → 1.2.154
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/commands/index.js +1 -0
- package/build/commands/order-attachment/create-order-attachment.command.js +9 -0
- package/build/commands/order-attachment/delete-order-attachment.command.js +8 -0
- package/build/commands/order-attachment/get-order-attachment-list-for-client.query.js +8 -0
- package/build/commands/order-attachment/get-order-attachment-list.query.js +8 -0
- package/build/commands/order-attachment/index.js +21 -0
- package/build/commands/order-attachment/update-order-attachment.command.js +9 -0
- package/build/constant/error.js +5 -0
- package/build/enum/action-log-type.enum.js +3 -0
- package/build/enum/index.js +2 -0
- package/build/enum/order-attachment-type.enum.js +9 -0
- package/build/enum/order-attachment-updated-field.enum.js +9 -0
- package/build/schemas/action-log/action-log-payload.schema.js +6 -0
- package/build/schemas/action-log/action-log.schema.js +21 -0
- package/build/schemas/action-log/index.js +4 -0
- package/build/schemas/action-log/order-attachment-create-action-log.schema.js +9 -0
- package/build/schemas/action-log/order-attachment-delete-action-log.schema.js +9 -0
- package/build/schemas/action-log/order-attachment-info.schema.js +14 -0
- package/build/schemas/action-log/order-attachment-update-action-log.schema.js +20 -0
- package/build/schemas/index.js +2 -0
- package/build/schemas/order-attachment/order-attachment-for-client.schema.js +19 -0
- package/build/schemas/order-attachment/order-attachment.schema.js +57 -0
- package/commands/index.ts +1 -0
- package/commands/order-attachment/create-order-attachment.command.ts +13 -0
- package/commands/order-attachment/delete-order-attachment.command.ts +7 -0
- package/commands/order-attachment/get-order-attachment-list-for-client.query.ts +7 -0
- package/commands/order-attachment/get-order-attachment-list.query.ts +7 -0
- package/commands/order-attachment/index.ts +5 -0
- package/commands/order-attachment/update-order-attachment.command.ts +13 -0
- package/constant/error.ts +5 -0
- package/enum/action-log-type.enum.ts +3 -0
- package/enum/index.ts +2 -0
- package/enum/order-attachment-type.enum.ts +5 -0
- package/enum/order-attachment-updated-field.enum.ts +5 -0
- package/package.json +1 -1
- package/schemas/action-log/action-log-payload.schema.ts +6 -0
- package/schemas/action-log/action-log.schema.ts +21 -0
- package/schemas/action-log/index.ts +4 -0
- package/schemas/action-log/order-attachment-create-action-log.schema.ts +7 -0
- package/schemas/action-log/order-attachment-delete-action-log.schema.ts +7 -0
- package/schemas/action-log/order-attachment-info.schema.ts +12 -0
- package/schemas/action-log/order-attachment-update-action-log.schema.ts +20 -0
- package/schemas/index.ts +2 -0
- package/schemas/order-attachment/order-attachment-for-client.schema.ts +18 -0
- package/schemas/order-attachment/order-attachment.schema.ts +63 -0
package/build/commands/index.js
CHANGED
|
@@ -69,6 +69,7 @@ __exportStar(require("./integration"), exports);
|
|
|
69
69
|
__exportStar(require("./account-deletion-request"), exports);
|
|
70
70
|
__exportStar(require("./service"), exports);
|
|
71
71
|
__exportStar(require("./order-service-line"), exports);
|
|
72
|
+
__exportStar(require("./order-attachment"), exports);
|
|
72
73
|
// Session contracts exported individually to avoid webpack TDZ issues with Next.js SSG
|
|
73
74
|
var session_logout_command_1 = require("./session/session-logout.command");
|
|
74
75
|
Object.defineProperty(exports, "SessionLogoutContractCommand", { enumerable: true, get: function () { return session_logout_command_1.SessionLogoutContractCommand; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateOrderAttachmentContractCommand = void 0;
|
|
4
|
+
const order_attachment_schema_1 = require("../../schemas/order-attachment/order-attachment.schema");
|
|
5
|
+
var CreateOrderAttachmentContractCommand;
|
|
6
|
+
(function (CreateOrderAttachmentContractCommand) {
|
|
7
|
+
CreateOrderAttachmentContractCommand.RequestSchema = order_attachment_schema_1.CreateOrderAttachmentRequestSchema;
|
|
8
|
+
CreateOrderAttachmentContractCommand.ResponseSchema = order_attachment_schema_1.CreateOrderAttachmentResponseSchema;
|
|
9
|
+
})(CreateOrderAttachmentContractCommand || (exports.CreateOrderAttachmentContractCommand = CreateOrderAttachmentContractCommand = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteOrderAttachmentContractCommand = void 0;
|
|
4
|
+
const order_attachment_schema_1 = require("../../schemas/order-attachment/order-attachment.schema");
|
|
5
|
+
var DeleteOrderAttachmentContractCommand;
|
|
6
|
+
(function (DeleteOrderAttachmentContractCommand) {
|
|
7
|
+
DeleteOrderAttachmentContractCommand.ResponseSchema = order_attachment_schema_1.DeleteOrderAttachmentResponseSchema;
|
|
8
|
+
})(DeleteOrderAttachmentContractCommand || (exports.DeleteOrderAttachmentContractCommand = DeleteOrderAttachmentContractCommand = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetOrderAttachmentListForClientContractQuery = void 0;
|
|
4
|
+
const order_attachment_for_client_schema_1 = require("../../schemas/order-attachment/order-attachment-for-client.schema");
|
|
5
|
+
var GetOrderAttachmentListForClientContractQuery;
|
|
6
|
+
(function (GetOrderAttachmentListForClientContractQuery) {
|
|
7
|
+
GetOrderAttachmentListForClientContractQuery.ResponseSchema = order_attachment_for_client_schema_1.GetOrderAttachmentListForClientResponseSchema;
|
|
8
|
+
})(GetOrderAttachmentListForClientContractQuery || (exports.GetOrderAttachmentListForClientContractQuery = GetOrderAttachmentListForClientContractQuery = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetOrderAttachmentListContractQuery = void 0;
|
|
4
|
+
const order_attachment_schema_1 = require("../../schemas/order-attachment/order-attachment.schema");
|
|
5
|
+
var GetOrderAttachmentListContractQuery;
|
|
6
|
+
(function (GetOrderAttachmentListContractQuery) {
|
|
7
|
+
GetOrderAttachmentListContractQuery.ResponseSchema = order_attachment_schema_1.GetOrderAttachmentListResponseSchema;
|
|
8
|
+
})(GetOrderAttachmentListContractQuery || (exports.GetOrderAttachmentListContractQuery = GetOrderAttachmentListContractQuery = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./create-order-attachment.command"), exports);
|
|
18
|
+
__exportStar(require("./update-order-attachment.command"), exports);
|
|
19
|
+
__exportStar(require("./delete-order-attachment.command"), exports);
|
|
20
|
+
__exportStar(require("./get-order-attachment-list.query"), exports);
|
|
21
|
+
__exportStar(require("./get-order-attachment-list-for-client.query"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateOrderAttachmentContractCommand = void 0;
|
|
4
|
+
const order_attachment_schema_1 = require("../../schemas/order-attachment/order-attachment.schema");
|
|
5
|
+
var UpdateOrderAttachmentContractCommand;
|
|
6
|
+
(function (UpdateOrderAttachmentContractCommand) {
|
|
7
|
+
UpdateOrderAttachmentContractCommand.RequestSchema = order_attachment_schema_1.UpdateOrderAttachmentRequestSchema;
|
|
8
|
+
UpdateOrderAttachmentContractCommand.ResponseSchema = order_attachment_schema_1.UpdateOrderAttachmentResponseSchema;
|
|
9
|
+
})(UpdateOrderAttachmentContractCommand || (exports.UpdateOrderAttachmentContractCommand = UpdateOrderAttachmentContractCommand = {}));
|
package/build/constant/error.js
CHANGED
|
@@ -460,6 +460,11 @@ exports.ERRORS = {
|
|
|
460
460
|
ORDER_SERVICE_LINE_NOT_DELETED: { code: 'OSL004', message: 'Service in order not deleted', httpCode: 500 },
|
|
461
461
|
ORDER_SERVICE_LINE_NOT_UPDATED: { code: 'OSL005', message: 'Service in order not updated', httpCode: 500 },
|
|
462
462
|
ORDER_SERVICE_LINE_MODIFY_NOT_ALLOWED: { code: 'OSL006', message: 'Modifying order services is not allowed', httpCode: 409 },
|
|
463
|
+
ORDER_ATTACHMENT_NOT_CREATED: { code: 'OAT001', message: 'Failed to attach file to order', httpCode: 500 },
|
|
464
|
+
ORDER_ATTACHMENT_FETCH_FAILED: { code: 'OAT002', message: 'Error when retrieving order attachments', httpCode: 500 },
|
|
465
|
+
ORDER_ATTACHMENT_NOT_FOUND: { code: 'OAT003', message: 'Order attachment not found', httpCode: 404 },
|
|
466
|
+
ORDER_ATTACHMENT_NOT_DELETED: { code: 'OAT004', message: 'Order attachment not deleted', httpCode: 500 },
|
|
467
|
+
ORDER_ATTACHMENT_NOT_UPDATED: { code: 'OAT005', message: 'Order attachment not updated', httpCode: 500 },
|
|
463
468
|
//ORDER DELIVERY
|
|
464
469
|
ORDER_DELIVERY_ALREADY_EXIST: { code: 'OD006', message: 'Delivery for the order already exists', httpCode: 409 },
|
|
465
470
|
ORDER_DELIVERY_NOT_CREATED: { code: 'OD007', message: 'Failed to create order delivery', httpCode: 500 },
|
|
@@ -76,6 +76,9 @@ var ActionLogTypeEnum;
|
|
|
76
76
|
ActionLogTypeEnum["DELETE_COLLECTION_ITEMS"] = "DELETE_COLLECTION_ITEMS";
|
|
77
77
|
ActionLogTypeEnum["MOVE_COLLECTION_ITEMS"] = "MOVE_COLLECTION_ITEMS";
|
|
78
78
|
ActionLogTypeEnum["UPDATE_COLLECTION_ITEM_MULTIPLICITY_OPTIONS"] = "UPDATE_COLLECTION_ITEM_MULTIPLICITY_OPTIONS";
|
|
79
|
+
ActionLogTypeEnum["CREATE_ORDER_ATTACHMENT"] = "CREATE_ORDER_ATTACHMENT";
|
|
80
|
+
ActionLogTypeEnum["UPDATE_ORDER_ATTACHMENT"] = "UPDATE_ORDER_ATTACHMENT";
|
|
81
|
+
ActionLogTypeEnum["DELETE_ORDER_ATTACHMENT"] = "DELETE_ORDER_ATTACHMENT";
|
|
79
82
|
ActionLogTypeEnum["UPDATE_CLIENT_MARKING"] = "UPDATE_CLIENT_MARKING";
|
|
80
83
|
ActionLogTypeEnum["UPDATE_CLIENT_PROFILE"] = "UPDATE_CLIENT_PROFILE";
|
|
81
84
|
ActionLogTypeEnum["COPY_PREORDER_COLLECTION"] = "COPY_PREORDER_COLLECTION";
|
package/build/enum/index.js
CHANGED
|
@@ -21,6 +21,8 @@ __exportStar(require("./outbound-sync-intent.enum"), exports);
|
|
|
21
21
|
__exportStar(require("./outbound-sync-status.enum"), exports);
|
|
22
22
|
__exportStar(require("./order-type.enum"), exports);
|
|
23
23
|
__exportStar(require("./order-status.enum"), exports);
|
|
24
|
+
__exportStar(require("./order-attachment-type.enum"), exports);
|
|
25
|
+
__exportStar(require("./order-attachment-updated-field.enum"), exports);
|
|
24
26
|
__exportStar(require("./order-product-verify-source.enum"), exports);
|
|
25
27
|
__exportStar(require("./order-restricted-status-list"), exports);
|
|
26
28
|
__exportStar(require("./order-balance-status-list"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrderAttachmentTypeEnum = void 0;
|
|
4
|
+
/** Что прикрепили к заказу: загруженный файл или внешняя ссылка. */
|
|
5
|
+
var OrderAttachmentTypeEnum;
|
|
6
|
+
(function (OrderAttachmentTypeEnum) {
|
|
7
|
+
OrderAttachmentTypeEnum["FILE"] = "FILE";
|
|
8
|
+
OrderAttachmentTypeEnum["LINK"] = "LINK";
|
|
9
|
+
})(OrderAttachmentTypeEnum || (exports.OrderAttachmentTypeEnum = OrderAttachmentTypeEnum = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrderAttachmentUpdatedFieldEnum = void 0;
|
|
4
|
+
/** Поля вложения заказа, изменение которых попадает в журнал. Ссылку и тип не правят: их меняют пересозданием. */
|
|
5
|
+
var OrderAttachmentUpdatedFieldEnum;
|
|
6
|
+
(function (OrderAttachmentUpdatedFieldEnum) {
|
|
7
|
+
OrderAttachmentUpdatedFieldEnum["NAME"] = "NAME";
|
|
8
|
+
OrderAttachmentUpdatedFieldEnum["IS_VISIBLE_TO_CLIENT"] = "IS_VISIBLE_TO_CLIENT";
|
|
9
|
+
})(OrderAttachmentUpdatedFieldEnum || (exports.OrderAttachmentUpdatedFieldEnum = OrderAttachmentUpdatedFieldEnum = {}));
|
|
@@ -78,6 +78,9 @@ const collection_items_move_action_log_schema_1 = require("./collection-items-mo
|
|
|
78
78
|
const collection_item_multiplicity_options_action_log_schema_1 = require("./collection-item-multiplicity-options-action-log.schema");
|
|
79
79
|
const client_marking_action_log_schema_1 = require("./client-marking-action-log.schema");
|
|
80
80
|
const client_profile_action_log_schema_1 = require("./client-profile-action-log.schema");
|
|
81
|
+
const order_attachment_create_action_log_schema_1 = require("./order-attachment-create-action-log.schema");
|
|
82
|
+
const order_attachment_update_action_log_schema_1 = require("./order-attachment-update-action-log.schema");
|
|
83
|
+
const order_attachment_delete_action_log_schema_1 = require("./order-attachment-delete-action-log.schema");
|
|
81
84
|
exports.ActionLogPayloadSchema = zod_1.z.union([
|
|
82
85
|
order_delete_action_log_payload_schema_1.OrderDeleteActionLogPayloadSchema,
|
|
83
86
|
order_merge_action_log_schema_1.OrderMergeActionLogSchema,
|
|
@@ -152,5 +155,8 @@ exports.ActionLogPayloadSchema = zod_1.z.union([
|
|
|
152
155
|
collection_item_multiplicity_options_action_log_schema_1.CollectionItemMultiplicityOptionsActionLogSchema,
|
|
153
156
|
client_marking_action_log_schema_1.ClientMarkingActionLogSchema,
|
|
154
157
|
client_profile_action_log_schema_1.ClientProfileActionLogSchema,
|
|
158
|
+
order_attachment_create_action_log_schema_1.OrderAttachmentCreateActionLogSchema,
|
|
159
|
+
order_attachment_update_action_log_schema_1.OrderAttachmentUpdateActionLogSchema,
|
|
160
|
+
order_attachment_delete_action_log_schema_1.OrderAttachmentDeleteActionLogSchema,
|
|
155
161
|
zod_1.z.null(),
|
|
156
162
|
]);
|
|
@@ -74,6 +74,9 @@ const collection_items_delete_action_log_schema_1 = require("./collection-items-
|
|
|
74
74
|
const pre_order_collection_copy_action_log_schema_1 = require("./pre-order-collection-copy-action-log.schema");
|
|
75
75
|
const collection_items_move_action_log_schema_1 = require("./collection-items-move-action-log.schema");
|
|
76
76
|
const collection_item_multiplicity_options_action_log_schema_1 = require("./collection-item-multiplicity-options-action-log.schema");
|
|
77
|
+
const order_attachment_create_action_log_schema_1 = require("./order-attachment-create-action-log.schema");
|
|
78
|
+
const order_attachment_update_action_log_schema_1 = require("./order-attachment-update-action-log.schema");
|
|
79
|
+
const order_attachment_delete_action_log_schema_1 = require("./order-attachment-delete-action-log.schema");
|
|
77
80
|
const client_marking_action_log_schema_1 = require("./client-marking-action-log.schema");
|
|
78
81
|
const client_profile_action_log_schema_1 = require("./client-profile-action-log.schema");
|
|
79
82
|
const BaseActionFields = zod_1.z.object({
|
|
@@ -456,6 +459,24 @@ exports.ActionLogSchema = zod_1.z.discriminatedUnion('actionType', [
|
|
|
456
459
|
payload: collection_item_multiplicity_options_action_log_schema_1.CollectionItemMultiplicityOptionsActionLogSchema,
|
|
457
460
|
})
|
|
458
461
|
.merge(BaseActionFields),
|
|
462
|
+
zod_1.z
|
|
463
|
+
.object({
|
|
464
|
+
actionType: zod_1.z.literal(enum_1.ActionLogTypeEnum.CREATE_ORDER_ATTACHMENT),
|
|
465
|
+
payload: order_attachment_create_action_log_schema_1.OrderAttachmentCreateActionLogSchema,
|
|
466
|
+
})
|
|
467
|
+
.merge(BaseActionFields),
|
|
468
|
+
zod_1.z
|
|
469
|
+
.object({
|
|
470
|
+
actionType: zod_1.z.literal(enum_1.ActionLogTypeEnum.UPDATE_ORDER_ATTACHMENT),
|
|
471
|
+
payload: order_attachment_update_action_log_schema_1.OrderAttachmentUpdateActionLogSchema,
|
|
472
|
+
})
|
|
473
|
+
.merge(BaseActionFields),
|
|
474
|
+
zod_1.z
|
|
475
|
+
.object({
|
|
476
|
+
actionType: zod_1.z.literal(enum_1.ActionLogTypeEnum.DELETE_ORDER_ATTACHMENT),
|
|
477
|
+
payload: order_attachment_delete_action_log_schema_1.OrderAttachmentDeleteActionLogSchema,
|
|
478
|
+
})
|
|
479
|
+
.merge(BaseActionFields),
|
|
459
480
|
zod_1.z
|
|
460
481
|
.object({
|
|
461
482
|
actionType: zod_1.z.literal(enum_1.ActionLogTypeEnum.UPDATE_CLIENT_MARKING),
|
|
@@ -97,3 +97,7 @@ __exportStar(require("./collection-item-multiplicity-options-action-log.schema")
|
|
|
97
97
|
__exportStar(require("./client-marking-action-log.schema"), exports);
|
|
98
98
|
__exportStar(require("./client-profile-action-log.schema"), exports);
|
|
99
99
|
__exportStar(require("./pre-order-collection-copy-action-log.schema"), exports);
|
|
100
|
+
__exportStar(require("./order-attachment-info.schema"), exports);
|
|
101
|
+
__exportStar(require("./order-attachment-create-action-log.schema"), exports);
|
|
102
|
+
__exportStar(require("./order-attachment-update-action-log.schema"), exports);
|
|
103
|
+
__exportStar(require("./order-attachment-delete-action-log.schema"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrderAttachmentCreateActionLogSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const order_attachment_info_schema_1 = require("./order-attachment-info.schema");
|
|
6
|
+
/** К заказу прикрепили файл или ссылку. */
|
|
7
|
+
exports.OrderAttachmentCreateActionLogSchema = zod_1.z.object({
|
|
8
|
+
attachment: order_attachment_info_schema_1.OrderAttachmentInfoSchema,
|
|
9
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrderAttachmentDeleteActionLogSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const order_attachment_info_schema_1 = require("./order-attachment-info.schema");
|
|
6
|
+
/** Вложение сняли с заказа. Снимок берётся до удаления: записи в базе после него уже нет. */
|
|
7
|
+
exports.OrderAttachmentDeleteActionLogSchema = zod_1.z.object({
|
|
8
|
+
attachment: order_attachment_info_schema_1.OrderAttachmentInfoSchema,
|
|
9
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrderAttachmentInfoSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const order_attachment_type_enum_1 = require("../../enum/order-attachment-type.enum");
|
|
6
|
+
/** Снимок вложения заказа на момент события: чем прикрепили, как подписано и видит ли клиент. */
|
|
7
|
+
exports.OrderAttachmentInfoSchema = zod_1.z.object({
|
|
8
|
+
orderUUID: zod_1.z.string(),
|
|
9
|
+
attachmentUUID: zod_1.z.string(),
|
|
10
|
+
type: zod_1.z.nativeEnum(order_attachment_type_enum_1.OrderAttachmentTypeEnum),
|
|
11
|
+
name: zod_1.z.string(),
|
|
12
|
+
url: zod_1.z.string(),
|
|
13
|
+
isVisibleToClient: zod_1.z.boolean(),
|
|
14
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrderAttachmentUpdateActionLogSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const order_attachment_updated_field_enum_1 = require("../../enum/order-attachment-updated-field.enum");
|
|
6
|
+
const order_attachment_info_schema_1 = require("./order-attachment-info.schema");
|
|
7
|
+
/**
|
|
8
|
+
* Правка вложения: снимок до правки и изменённые поля. Переключатель видимости меняет то, что
|
|
9
|
+
* контрагент видит в своём заказе, поэтому смена этого поля должна быть видна в истории.
|
|
10
|
+
*/
|
|
11
|
+
exports.OrderAttachmentUpdateActionLogSchema = zod_1.z.object({
|
|
12
|
+
attachment: order_attachment_info_schema_1.OrderAttachmentInfoSchema,
|
|
13
|
+
changes: zod_1.z
|
|
14
|
+
.array(zod_1.z.object({
|
|
15
|
+
field: zod_1.z.nativeEnum(order_attachment_updated_field_enum_1.OrderAttachmentUpdatedFieldEnum),
|
|
16
|
+
oldValue: zod_1.z.string().nullable(),
|
|
17
|
+
newValue: zod_1.z.string().nullable(),
|
|
18
|
+
}))
|
|
19
|
+
.min(1),
|
|
20
|
+
});
|
package/build/schemas/index.js
CHANGED
|
@@ -74,6 +74,8 @@ __exportStar(require("./discount-rules/discount-rules.schema"), exports);
|
|
|
74
74
|
__exportStar(require("./package/validate-package.schema"), exports);
|
|
75
75
|
__exportStar(require("./service/service.schema"), exports);
|
|
76
76
|
__exportStar(require("./order-service-line/order-service-line.schema"), exports);
|
|
77
|
+
__exportStar(require("./order-attachment/order-attachment.schema"), exports);
|
|
78
|
+
__exportStar(require("./order-attachment/order-attachment-for-client.schema"), exports);
|
|
77
79
|
__exportStar(require("./distribution/validate-distribution-by-product.schema"), exports);
|
|
78
80
|
__exportStar(require("./consignment/consignment-distribution-validation.schema"), exports);
|
|
79
81
|
__exportStar(require("./product-image-template/product-image-template.schema"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetOrderAttachmentListForClientResponseSchema = exports.OrderAttachmentForClientSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const order_attachment_schema_1 = require("./order-attachment.schema");
|
|
6
|
+
/** Вложение глазами клиента: без автора-сотрудника и без флага видимости, который для него всегда включён. */
|
|
7
|
+
exports.OrderAttachmentForClientSchema = order_attachment_schema_1.OrderAttachmentSchema.pick({
|
|
8
|
+
uuid: true,
|
|
9
|
+
orderUUID: true,
|
|
10
|
+
type: true,
|
|
11
|
+
name: true,
|
|
12
|
+
url: true,
|
|
13
|
+
createdAt: true,
|
|
14
|
+
});
|
|
15
|
+
exports.GetOrderAttachmentListForClientResponseSchema = zod_1.z.object({
|
|
16
|
+
data: zod_1.z.object({
|
|
17
|
+
attachmentList: zod_1.z.array(exports.OrderAttachmentForClientSchema),
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteOrderAttachmentResponseSchema = exports.GetOrderAttachmentListResponseSchema = exports.UpdateOrderAttachmentResponseSchema = exports.UpdateOrderAttachmentRequestSchema = exports.CreateOrderAttachmentResponseSchema = exports.CreateOrderAttachmentRequestSchema = exports.OrderAttachmentSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const order_attachment_type_enum_1 = require("../../enum/order-attachment-type.enum");
|
|
6
|
+
/**
|
|
7
|
+
* Ссылка на файл в бакете (для FILE её отдаёт `PUT /files/upload-file`) или внешний адрес (для LINK).
|
|
8
|
+
* Схему не сужаем до домена CDN: в LINK кладут ссылки на сторонние сервисы доставки.
|
|
9
|
+
*
|
|
10
|
+
* Протокол только http/https: `z.url()` сам по себе принимает и `javascript:`, и `data:text/html`,
|
|
11
|
+
* а вложение с включённой видимостью витрина отдаёт клиенту и рисует ссылкой — то есть сотрудник
|
|
12
|
+
* мог бы подложить контрагенту исполняемый адрес.
|
|
13
|
+
*/
|
|
14
|
+
const OrderAttachmentUrlSchema = zod_1.z.url({ protocol: /^https?$/ }).max(2048);
|
|
15
|
+
const OrderAttachmentNameSchema = zod_1.z.string().trim().min(1).max(255);
|
|
16
|
+
exports.OrderAttachmentSchema = zod_1.z.object({
|
|
17
|
+
uuid: zod_1.z.uuid(),
|
|
18
|
+
orderUUID: zod_1.z.uuid(),
|
|
19
|
+
type: zod_1.z.nativeEnum(order_attachment_type_enum_1.OrderAttachmentTypeEnum),
|
|
20
|
+
name: OrderAttachmentNameSchema,
|
|
21
|
+
url: OrderAttachmentUrlSchema,
|
|
22
|
+
isVisibleToClient: zod_1.z.boolean(),
|
|
23
|
+
createdByUserUUID: zod_1.z.uuid(),
|
|
24
|
+
createdAt: zod_1.z.date(),
|
|
25
|
+
updatedAt: zod_1.z.date(),
|
|
26
|
+
});
|
|
27
|
+
exports.CreateOrderAttachmentRequestSchema = zod_1.z.object({
|
|
28
|
+
type: zod_1.z.nativeEnum(order_attachment_type_enum_1.OrderAttachmentTypeEnum),
|
|
29
|
+
name: OrderAttachmentNameSchema,
|
|
30
|
+
url: OrderAttachmentUrlSchema,
|
|
31
|
+
// По умолчанию вложение внутреннее: клиент увидит его, только когда это включат явно.
|
|
32
|
+
isVisibleToClient: zod_1.z.boolean().optional().default(false),
|
|
33
|
+
});
|
|
34
|
+
exports.CreateOrderAttachmentResponseSchema = zod_1.z.object({
|
|
35
|
+
data: exports.OrderAttachmentSchema,
|
|
36
|
+
});
|
|
37
|
+
exports.UpdateOrderAttachmentRequestSchema = zod_1.z
|
|
38
|
+
.object({
|
|
39
|
+
name: OrderAttachmentNameSchema.optional(),
|
|
40
|
+
isVisibleToClient: zod_1.z.boolean().optional(),
|
|
41
|
+
})
|
|
42
|
+
.refine(data => data.name !== undefined || data.isVisibleToClient !== undefined, {
|
|
43
|
+
message: 'validation.emptyUpdate',
|
|
44
|
+
});
|
|
45
|
+
exports.UpdateOrderAttachmentResponseSchema = zod_1.z.object({
|
|
46
|
+
data: exports.OrderAttachmentSchema,
|
|
47
|
+
});
|
|
48
|
+
exports.GetOrderAttachmentListResponseSchema = zod_1.z.object({
|
|
49
|
+
data: zod_1.z.object({
|
|
50
|
+
attachmentList: zod_1.z.array(exports.OrderAttachmentSchema),
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
exports.DeleteOrderAttachmentResponseSchema = zod_1.z.object({
|
|
54
|
+
data: zod_1.z.object({
|
|
55
|
+
success: zod_1.z.boolean(),
|
|
56
|
+
}),
|
|
57
|
+
});
|
package/commands/index.ts
CHANGED
|
@@ -52,6 +52,7 @@ export * from './integration';
|
|
|
52
52
|
export * from './account-deletion-request';
|
|
53
53
|
export * from './service';
|
|
54
54
|
export * from './order-service-line';
|
|
55
|
+
export * from './order-attachment';
|
|
55
56
|
// Session contracts exported individually to avoid webpack TDZ issues with Next.js SSG
|
|
56
57
|
export { SessionLogoutContractCommand } from './session/session-logout.command';
|
|
57
58
|
export { SessionRevokeAllContractCommand } from './session/session-revoke-all.command';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
CreateOrderAttachmentRequestSchema,
|
|
4
|
+
CreateOrderAttachmentResponseSchema,
|
|
5
|
+
} from '../../schemas/order-attachment/order-attachment.schema';
|
|
6
|
+
|
|
7
|
+
export namespace CreateOrderAttachmentContractCommand {
|
|
8
|
+
export const RequestSchema = CreateOrderAttachmentRequestSchema;
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = CreateOrderAttachmentResponseSchema;
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DeleteOrderAttachmentResponseSchema } from '../../schemas/order-attachment/order-attachment.schema';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteOrderAttachmentContractCommand {
|
|
5
|
+
export const ResponseSchema = DeleteOrderAttachmentResponseSchema;
|
|
6
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GetOrderAttachmentListForClientResponseSchema } from '../../schemas/order-attachment/order-attachment-for-client.schema';
|
|
3
|
+
|
|
4
|
+
export namespace GetOrderAttachmentListForClientContractQuery {
|
|
5
|
+
export const ResponseSchema = GetOrderAttachmentListForClientResponseSchema;
|
|
6
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GetOrderAttachmentListResponseSchema } from '../../schemas/order-attachment/order-attachment.schema';
|
|
3
|
+
|
|
4
|
+
export namespace GetOrderAttachmentListContractQuery {
|
|
5
|
+
export const ResponseSchema = GetOrderAttachmentListResponseSchema;
|
|
6
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './create-order-attachment.command';
|
|
2
|
+
export * from './update-order-attachment.command';
|
|
3
|
+
export * from './delete-order-attachment.command';
|
|
4
|
+
export * from './get-order-attachment-list.query';
|
|
5
|
+
export * from './get-order-attachment-list-for-client.query';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
UpdateOrderAttachmentRequestSchema,
|
|
4
|
+
UpdateOrderAttachmentResponseSchema,
|
|
5
|
+
} from '../../schemas/order-attachment/order-attachment.schema';
|
|
6
|
+
|
|
7
|
+
export namespace UpdateOrderAttachmentContractCommand {
|
|
8
|
+
export const RequestSchema = UpdateOrderAttachmentRequestSchema;
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = UpdateOrderAttachmentResponseSchema;
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
package/constant/error.ts
CHANGED
|
@@ -476,6 +476,11 @@ export const ERRORS = {
|
|
|
476
476
|
ORDER_SERVICE_LINE_NOT_DELETED: { code: 'OSL004', message: 'Service in order not deleted', httpCode: 500 },
|
|
477
477
|
ORDER_SERVICE_LINE_NOT_UPDATED: { code: 'OSL005', message: 'Service in order not updated', httpCode: 500 },
|
|
478
478
|
ORDER_SERVICE_LINE_MODIFY_NOT_ALLOWED: { code: 'OSL006', message: 'Modifying order services is not allowed', httpCode: 409 },
|
|
479
|
+
ORDER_ATTACHMENT_NOT_CREATED: { code: 'OAT001', message: 'Failed to attach file to order', httpCode: 500 },
|
|
480
|
+
ORDER_ATTACHMENT_FETCH_FAILED: { code: 'OAT002', message: 'Error when retrieving order attachments', httpCode: 500 },
|
|
481
|
+
ORDER_ATTACHMENT_NOT_FOUND: { code: 'OAT003', message: 'Order attachment not found', httpCode: 404 },
|
|
482
|
+
ORDER_ATTACHMENT_NOT_DELETED: { code: 'OAT004', message: 'Order attachment not deleted', httpCode: 500 },
|
|
483
|
+
ORDER_ATTACHMENT_NOT_UPDATED: { code: 'OAT005', message: 'Order attachment not updated', httpCode: 500 },
|
|
479
484
|
|
|
480
485
|
//ORDER DELIVERY
|
|
481
486
|
ORDER_DELIVERY_ALREADY_EXIST: { code: 'OD006', message: 'Delivery for the order already exists', httpCode: 409 },
|
|
@@ -72,6 +72,9 @@ export enum ActionLogTypeEnum {
|
|
|
72
72
|
DELETE_COLLECTION_ITEMS = 'DELETE_COLLECTION_ITEMS',
|
|
73
73
|
MOVE_COLLECTION_ITEMS = 'MOVE_COLLECTION_ITEMS',
|
|
74
74
|
UPDATE_COLLECTION_ITEM_MULTIPLICITY_OPTIONS = 'UPDATE_COLLECTION_ITEM_MULTIPLICITY_OPTIONS',
|
|
75
|
+
CREATE_ORDER_ATTACHMENT = 'CREATE_ORDER_ATTACHMENT',
|
|
76
|
+
UPDATE_ORDER_ATTACHMENT = 'UPDATE_ORDER_ATTACHMENT',
|
|
77
|
+
DELETE_ORDER_ATTACHMENT = 'DELETE_ORDER_ATTACHMENT',
|
|
75
78
|
UPDATE_CLIENT_MARKING = 'UPDATE_CLIENT_MARKING',
|
|
76
79
|
UPDATE_CLIENT_PROFILE = 'UPDATE_CLIENT_PROFILE',
|
|
77
80
|
COPY_PREORDER_COLLECTION = 'COPY_PREORDER_COLLECTION',
|
package/enum/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from './outbound-sync-intent.enum';
|
|
|
5
5
|
export * from './outbound-sync-status.enum';
|
|
6
6
|
export * from './order-type.enum';
|
|
7
7
|
export * from './order-status.enum';
|
|
8
|
+
export * from './order-attachment-type.enum';
|
|
9
|
+
export * from './order-attachment-updated-field.enum';
|
|
8
10
|
export * from './order-product-verify-source.enum';
|
|
9
11
|
export * from './order-restricted-status-list';
|
|
10
12
|
export * from './order-balance-status-list';
|
package/package.json
CHANGED
|
@@ -78,6 +78,9 @@ import { CollectionItemsMoveActionLogSchema } from './collection-items-move-acti
|
|
|
78
78
|
import { CollectionItemMultiplicityOptionsActionLogSchema } from './collection-item-multiplicity-options-action-log.schema';
|
|
79
79
|
import { ClientMarkingActionLogSchema } from './client-marking-action-log.schema';
|
|
80
80
|
import { ClientProfileActionLogSchema } from './client-profile-action-log.schema';
|
|
81
|
+
import { OrderAttachmentCreateActionLogSchema } from './order-attachment-create-action-log.schema';
|
|
82
|
+
import { OrderAttachmentUpdateActionLogSchema } from './order-attachment-update-action-log.schema';
|
|
83
|
+
import { OrderAttachmentDeleteActionLogSchema } from './order-attachment-delete-action-log.schema';
|
|
81
84
|
|
|
82
85
|
export const ActionLogPayloadSchema = z.union([
|
|
83
86
|
OrderDeleteActionLogPayloadSchema,
|
|
@@ -153,5 +156,8 @@ export const ActionLogPayloadSchema = z.union([
|
|
|
153
156
|
CollectionItemMultiplicityOptionsActionLogSchema,
|
|
154
157
|
ClientMarkingActionLogSchema,
|
|
155
158
|
ClientProfileActionLogSchema,
|
|
159
|
+
OrderAttachmentCreateActionLogSchema,
|
|
160
|
+
OrderAttachmentUpdateActionLogSchema,
|
|
161
|
+
OrderAttachmentDeleteActionLogSchema,
|
|
156
162
|
z.null(),
|
|
157
163
|
]);
|
|
@@ -79,6 +79,9 @@ import { PreOrderCollectionCopyActionLogSchema } from './pre-order-collection-co
|
|
|
79
79
|
|
|
80
80
|
import { CollectionItemsMoveActionLogSchema } from './collection-items-move-action-log.schema';
|
|
81
81
|
import { CollectionItemMultiplicityOptionsActionLogSchema } from './collection-item-multiplicity-options-action-log.schema';
|
|
82
|
+
import { OrderAttachmentCreateActionLogSchema } from './order-attachment-create-action-log.schema';
|
|
83
|
+
import { OrderAttachmentUpdateActionLogSchema } from './order-attachment-update-action-log.schema';
|
|
84
|
+
import { OrderAttachmentDeleteActionLogSchema } from './order-attachment-delete-action-log.schema';
|
|
82
85
|
import { ClientMarkingActionLogSchema } from './client-marking-action-log.schema';
|
|
83
86
|
import { ClientProfileActionLogSchema } from './client-profile-action-log.schema';
|
|
84
87
|
|
|
@@ -463,6 +466,24 @@ export const ActionLogSchema = z.discriminatedUnion('actionType', [
|
|
|
463
466
|
payload: CollectionItemMultiplicityOptionsActionLogSchema,
|
|
464
467
|
})
|
|
465
468
|
.merge(BaseActionFields),
|
|
469
|
+
z
|
|
470
|
+
.object({
|
|
471
|
+
actionType: z.literal(ActionLogTypeEnum.CREATE_ORDER_ATTACHMENT),
|
|
472
|
+
payload: OrderAttachmentCreateActionLogSchema,
|
|
473
|
+
})
|
|
474
|
+
.merge(BaseActionFields),
|
|
475
|
+
z
|
|
476
|
+
.object({
|
|
477
|
+
actionType: z.literal(ActionLogTypeEnum.UPDATE_ORDER_ATTACHMENT),
|
|
478
|
+
payload: OrderAttachmentUpdateActionLogSchema,
|
|
479
|
+
})
|
|
480
|
+
.merge(BaseActionFields),
|
|
481
|
+
z
|
|
482
|
+
.object({
|
|
483
|
+
actionType: z.literal(ActionLogTypeEnum.DELETE_ORDER_ATTACHMENT),
|
|
484
|
+
payload: OrderAttachmentDeleteActionLogSchema,
|
|
485
|
+
})
|
|
486
|
+
.merge(BaseActionFields),
|
|
466
487
|
z
|
|
467
488
|
.object({
|
|
468
489
|
actionType: z.literal(ActionLogTypeEnum.UPDATE_CLIENT_MARKING),
|
|
@@ -81,3 +81,7 @@ export * from './collection-item-multiplicity-options-action-log.schema';
|
|
|
81
81
|
export * from './client-marking-action-log.schema';
|
|
82
82
|
export * from './client-profile-action-log.schema';
|
|
83
83
|
export * from './pre-order-collection-copy-action-log.schema';
|
|
84
|
+
export * from './order-attachment-info.schema';
|
|
85
|
+
export * from './order-attachment-create-action-log.schema';
|
|
86
|
+
export * from './order-attachment-update-action-log.schema';
|
|
87
|
+
export * from './order-attachment-delete-action-log.schema';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OrderAttachmentInfoSchema } from './order-attachment-info.schema';
|
|
3
|
+
|
|
4
|
+
/** Вложение сняли с заказа. Снимок берётся до удаления: записи в базе после него уже нет. */
|
|
5
|
+
export const OrderAttachmentDeleteActionLogSchema = z.object({
|
|
6
|
+
attachment: OrderAttachmentInfoSchema,
|
|
7
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OrderAttachmentTypeEnum } from '../../enum/order-attachment-type.enum';
|
|
3
|
+
|
|
4
|
+
/** Снимок вложения заказа на момент события: чем прикрепили, как подписано и видит ли клиент. */
|
|
5
|
+
export const OrderAttachmentInfoSchema = z.object({
|
|
6
|
+
orderUUID: z.string(),
|
|
7
|
+
attachmentUUID: z.string(),
|
|
8
|
+
type: z.nativeEnum(OrderAttachmentTypeEnum),
|
|
9
|
+
name: z.string(),
|
|
10
|
+
url: z.string(),
|
|
11
|
+
isVisibleToClient: z.boolean(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OrderAttachmentUpdatedFieldEnum } from '../../enum/order-attachment-updated-field.enum';
|
|
3
|
+
import { OrderAttachmentInfoSchema } from './order-attachment-info.schema';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Правка вложения: снимок до правки и изменённые поля. Переключатель видимости меняет то, что
|
|
7
|
+
* контрагент видит в своём заказе, поэтому смена этого поля должна быть видна в истории.
|
|
8
|
+
*/
|
|
9
|
+
export const OrderAttachmentUpdateActionLogSchema = z.object({
|
|
10
|
+
attachment: OrderAttachmentInfoSchema,
|
|
11
|
+
changes: z
|
|
12
|
+
.array(
|
|
13
|
+
z.object({
|
|
14
|
+
field: z.nativeEnum(OrderAttachmentUpdatedFieldEnum),
|
|
15
|
+
oldValue: z.string().nullable(),
|
|
16
|
+
newValue: z.string().nullable(),
|
|
17
|
+
}),
|
|
18
|
+
)
|
|
19
|
+
.min(1),
|
|
20
|
+
});
|
package/schemas/index.ts
CHANGED
|
@@ -58,6 +58,8 @@ export * from './discount-rules/discount-rules.schema';
|
|
|
58
58
|
export * from './package/validate-package.schema';
|
|
59
59
|
export * from './service/service.schema';
|
|
60
60
|
export * from './order-service-line/order-service-line.schema';
|
|
61
|
+
export * from './order-attachment/order-attachment.schema';
|
|
62
|
+
export * from './order-attachment/order-attachment-for-client.schema';
|
|
61
63
|
export * from './distribution/validate-distribution-by-product.schema';
|
|
62
64
|
export * from './consignment/consignment-distribution-validation.schema';
|
|
63
65
|
export * from './product-image-template/product-image-template.schema';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OrderAttachmentSchema } from './order-attachment.schema';
|
|
3
|
+
|
|
4
|
+
/** Вложение глазами клиента: без автора-сотрудника и без флага видимости, который для него всегда включён. */
|
|
5
|
+
export const OrderAttachmentForClientSchema = OrderAttachmentSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
orderUUID: true,
|
|
8
|
+
type: true,
|
|
9
|
+
name: true,
|
|
10
|
+
url: true,
|
|
11
|
+
createdAt: true,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const GetOrderAttachmentListForClientResponseSchema = z.object({
|
|
15
|
+
data: z.object({
|
|
16
|
+
attachmentList: z.array(OrderAttachmentForClientSchema),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OrderAttachmentTypeEnum } from '../../enum/order-attachment-type.enum';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Ссылка на файл в бакете (для FILE её отдаёт `PUT /files/upload-file`) или внешний адрес (для LINK).
|
|
6
|
+
* Схему не сужаем до домена CDN: в LINK кладут ссылки на сторонние сервисы доставки.
|
|
7
|
+
*
|
|
8
|
+
* Протокол только http/https: `z.url()` сам по себе принимает и `javascript:`, и `data:text/html`,
|
|
9
|
+
* а вложение с включённой видимостью витрина отдаёт клиенту и рисует ссылкой — то есть сотрудник
|
|
10
|
+
* мог бы подложить контрагенту исполняемый адрес.
|
|
11
|
+
*/
|
|
12
|
+
const OrderAttachmentUrlSchema = z.url({ protocol: /^https?$/ }).max(2048);
|
|
13
|
+
|
|
14
|
+
const OrderAttachmentNameSchema = z.string().trim().min(1).max(255);
|
|
15
|
+
|
|
16
|
+
export const OrderAttachmentSchema = z.object({
|
|
17
|
+
uuid: z.uuid(),
|
|
18
|
+
orderUUID: z.uuid(),
|
|
19
|
+
type: z.nativeEnum(OrderAttachmentTypeEnum),
|
|
20
|
+
name: OrderAttachmentNameSchema,
|
|
21
|
+
url: OrderAttachmentUrlSchema,
|
|
22
|
+
isVisibleToClient: z.boolean(),
|
|
23
|
+
createdByUserUUID: z.uuid(),
|
|
24
|
+
createdAt: z.date(),
|
|
25
|
+
updatedAt: z.date(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const CreateOrderAttachmentRequestSchema = z.object({
|
|
29
|
+
type: z.nativeEnum(OrderAttachmentTypeEnum),
|
|
30
|
+
name: OrderAttachmentNameSchema,
|
|
31
|
+
url: OrderAttachmentUrlSchema,
|
|
32
|
+
// По умолчанию вложение внутреннее: клиент увидит его, только когда это включат явно.
|
|
33
|
+
isVisibleToClient: z.boolean().optional().default(false),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const CreateOrderAttachmentResponseSchema = z.object({
|
|
37
|
+
data: OrderAttachmentSchema,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const UpdateOrderAttachmentRequestSchema = z
|
|
41
|
+
.object({
|
|
42
|
+
name: OrderAttachmentNameSchema.optional(),
|
|
43
|
+
isVisibleToClient: z.boolean().optional(),
|
|
44
|
+
})
|
|
45
|
+
.refine(data => data.name !== undefined || data.isVisibleToClient !== undefined, {
|
|
46
|
+
message: 'validation.emptyUpdate',
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const UpdateOrderAttachmentResponseSchema = z.object({
|
|
50
|
+
data: OrderAttachmentSchema,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const GetOrderAttachmentListResponseSchema = z.object({
|
|
54
|
+
data: z.object({
|
|
55
|
+
attachmentList: z.array(OrderAttachmentSchema),
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const DeleteOrderAttachmentResponseSchema = z.object({
|
|
60
|
+
data: z.object({
|
|
61
|
+
success: z.boolean(),
|
|
62
|
+
}),
|
|
63
|
+
});
|