@floristcloud/api-lib 1.2.19 → 1.2.20
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/integration/index.js +1 -0
- package/build/commands/integration/moysklad/connect-moysklad.command.js +19 -0
- package/build/commands/integration/moysklad/disconnect-moysklad.command.js +14 -0
- package/build/commands/integration/moysklad/enable-moysklad.command.js +19 -0
- package/build/commands/integration/moysklad/execute-moysklad-clients-import.command.js +36 -0
- package/build/commands/integration/moysklad/execute-moysklad-import.command.js +44 -0
- package/build/commands/integration/moysklad/get-moysklad-status.query.js +20 -0
- package/build/commands/integration/moysklad/index.js +26 -0
- package/build/commands/integration/moysklad/list-moysklad-catalogs.query.js +19 -0
- package/build/commands/integration/moysklad/preview-moysklad-products.query.js +42 -0
- package/build/commands/integration/moysklad/scan-moysklad-clients-import.query.js +61 -0
- package/build/commands/integration/moysklad/scan-moysklad-import.query.js +60 -0
- package/build/constant/error.js +14 -0
- package/build/enum/external-entity-type.enum.js +10 -0
- package/build/enum/index.js +2 -0
- package/build/enum/integration-provider.enum.js +7 -0
- package/commands/integration/index.ts +1 -0
- package/commands/integration/moysklad/connect-moysklad.command.ts +20 -0
- package/commands/integration/moysklad/disconnect-moysklad.command.ts +13 -0
- package/commands/integration/moysklad/enable-moysklad.command.ts +20 -0
- package/commands/integration/moysklad/execute-moysklad-clients-import.command.ts +41 -0
- package/commands/integration/moysklad/execute-moysklad-import.command.ts +46 -0
- package/commands/integration/moysklad/get-moysklad-status.query.ts +19 -0
- package/commands/integration/moysklad/index.ts +10 -0
- package/commands/integration/moysklad/list-moysklad-catalogs.query.ts +19 -0
- package/commands/integration/moysklad/preview-moysklad-products.query.ts +44 -0
- package/commands/integration/moysklad/scan-moysklad-clients-import.query.ts +68 -0
- package/commands/integration/moysklad/scan-moysklad-import.query.ts +61 -0
- package/constant/error.ts +15 -0
- package/enum/external-entity-type.enum.ts +6 -0
- package/enum/index.ts +2 -0
- package/enum/integration-provider.enum.ts +3 -0
- package/package.json +1 -1
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./telegram"), exports);
|
|
18
18
|
__exportStar(require("./telegram-staff"), exports);
|
|
19
|
+
__exportStar(require("./moysklad"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectMoyskladContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const ConnectMoyskladRequestSchema = zod_1.z.object({
|
|
6
|
+
token: zod_1.z.string().min(20).max(200),
|
|
7
|
+
});
|
|
8
|
+
const ConnectMoyskladResponseSchema = zod_1.z.object({
|
|
9
|
+
message: zod_1.z.string().optional(),
|
|
10
|
+
data: zod_1.z.object({
|
|
11
|
+
tokenLastFour: zod_1.z.string().length(4),
|
|
12
|
+
accountId: zod_1.z.string().nullable(),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
var ConnectMoyskladContractCommand;
|
|
16
|
+
(function (ConnectMoyskladContractCommand) {
|
|
17
|
+
ConnectMoyskladContractCommand.RequestSchema = ConnectMoyskladRequestSchema;
|
|
18
|
+
ConnectMoyskladContractCommand.ResponseSchema = ConnectMoyskladResponseSchema;
|
|
19
|
+
})(ConnectMoyskladContractCommand || (exports.ConnectMoyskladContractCommand = ConnectMoyskladContractCommand = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DisconnectMoyskladContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const DisconnectMoyskladResponseSchema = zod_1.z.object({
|
|
6
|
+
message: zod_1.z.string().optional(),
|
|
7
|
+
data: zod_1.z.object({
|
|
8
|
+
success: zod_1.z.literal(true),
|
|
9
|
+
}),
|
|
10
|
+
});
|
|
11
|
+
var DisconnectMoyskladContractCommand;
|
|
12
|
+
(function (DisconnectMoyskladContractCommand) {
|
|
13
|
+
DisconnectMoyskladContractCommand.ResponseSchema = DisconnectMoyskladResponseSchema;
|
|
14
|
+
})(DisconnectMoyskladContractCommand || (exports.DisconnectMoyskladContractCommand = DisconnectMoyskladContractCommand = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnableMoyskladContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const EnableMoyskladRequestSchema = zod_1.z.object({
|
|
6
|
+
defaultOrgId: zod_1.z.string().min(1),
|
|
7
|
+
defaultStoreId: zod_1.z.string().min(1),
|
|
8
|
+
});
|
|
9
|
+
const EnableMoyskladResponseSchema = zod_1.z.object({
|
|
10
|
+
message: zod_1.z.string().optional(),
|
|
11
|
+
data: zod_1.z.object({
|
|
12
|
+
isEnabled: zod_1.z.literal(true),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
var EnableMoyskladContractCommand;
|
|
16
|
+
(function (EnableMoyskladContractCommand) {
|
|
17
|
+
EnableMoyskladContractCommand.RequestSchema = EnableMoyskladRequestSchema;
|
|
18
|
+
EnableMoyskladContractCommand.ResponseSchema = EnableMoyskladResponseSchema;
|
|
19
|
+
})(EnableMoyskladContractCommand || (exports.EnableMoyskladContractCommand = EnableMoyskladContractCommand = {}));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecuteMoyskladClientsImportContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const error_message_schema_1 = require("../../../schemas/error-message.schema");
|
|
6
|
+
const scan_moysklad_clients_import_query_1 = require("./scan-moysklad-clients-import.query");
|
|
7
|
+
const ExecutableClientItemSchema = scan_moysklad_clients_import_query_1.ScanMoyskladClientsImportContractQuery.ItemSchema.extend({
|
|
8
|
+
bindToExistingClientUUID: zod_1.z.string().nullable().default(null),
|
|
9
|
+
});
|
|
10
|
+
const ExecuteMoyskladClientsImportRequestSchema = zod_1.z.object({
|
|
11
|
+
items: zod_1.z.array(ExecutableClientItemSchema),
|
|
12
|
+
missingExternalIds: zod_1.z.array(zod_1.z.string()).default([]),
|
|
13
|
+
orphanedExternalIds: zod_1.z.array(zod_1.z.string()).default([]),
|
|
14
|
+
});
|
|
15
|
+
const ImportWarningSchema = zod_1.z.object({
|
|
16
|
+
externalSourceId: zod_1.z.string(),
|
|
17
|
+
warning: error_message_schema_1.ErrorMessageSchema,
|
|
18
|
+
});
|
|
19
|
+
const ExecuteMoyskladClientsImportResponseSchema = zod_1.z.object({
|
|
20
|
+
message: zod_1.z.string().optional(),
|
|
21
|
+
data: zod_1.z.object({
|
|
22
|
+
created: zod_1.z.number(),
|
|
23
|
+
updated: zod_1.z.number(),
|
|
24
|
+
bound: zod_1.z.number(),
|
|
25
|
+
archived: zod_1.z.number(),
|
|
26
|
+
orphansCleaned: zod_1.z.number(),
|
|
27
|
+
warnings: zod_1.z.array(ImportWarningSchema).default([]),
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
var ExecuteMoyskladClientsImportContractCommand;
|
|
31
|
+
(function (ExecuteMoyskladClientsImportContractCommand) {
|
|
32
|
+
ExecuteMoyskladClientsImportContractCommand.ItemSchema = ExecutableClientItemSchema;
|
|
33
|
+
ExecuteMoyskladClientsImportContractCommand.RequestSchema = ExecuteMoyskladClientsImportRequestSchema;
|
|
34
|
+
ExecuteMoyskladClientsImportContractCommand.ResponseSchema = ExecuteMoyskladClientsImportResponseSchema;
|
|
35
|
+
ExecuteMoyskladClientsImportContractCommand.WarningSchema = ImportWarningSchema;
|
|
36
|
+
})(ExecuteMoyskladClientsImportContractCommand || (exports.ExecuteMoyskladClientsImportContractCommand = ExecuteMoyskladClientsImportContractCommand = {}));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecuteMoyskladImportContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enum_1 = require("../../../enum");
|
|
6
|
+
const ExecutableItemSchema = zod_1.z.object({
|
|
7
|
+
externalSourceId: zod_1.z.string(),
|
|
8
|
+
externalHref: zod_1.z.string(),
|
|
9
|
+
name: zod_1.z.string(),
|
|
10
|
+
article: zod_1.z.string().nullable(),
|
|
11
|
+
barcode: zod_1.z.string().nullable(),
|
|
12
|
+
size: zod_1.z.string().nullable(),
|
|
13
|
+
color: zod_1.z.string().nullable(),
|
|
14
|
+
country: zod_1.z.string().nullable(),
|
|
15
|
+
grower: zod_1.z.string().nullable(),
|
|
16
|
+
price: zod_1.z.number(),
|
|
17
|
+
costPrice: zod_1.z.number(),
|
|
18
|
+
balance: zod_1.z.number(),
|
|
19
|
+
vat: zod_1.z.number().nullable(),
|
|
20
|
+
salesUnit: zod_1.z.nativeEnum(enum_1.SalesUnitEnum),
|
|
21
|
+
status: zod_1.z.enum(['new', 'known']),
|
|
22
|
+
internalUUID: zod_1.z.string().nullable(),
|
|
23
|
+
resolvedCategoryUUID: zod_1.z.string().nullable(),
|
|
24
|
+
});
|
|
25
|
+
const ExecuteMoyskladImportRequestSchema = zod_1.z.object({
|
|
26
|
+
items: zod_1.z.array(ExecutableItemSchema),
|
|
27
|
+
missingExternalIds: zod_1.z.array(zod_1.z.string()).default([]),
|
|
28
|
+
orphanedExternalIds: zod_1.z.array(zod_1.z.string()).default([]),
|
|
29
|
+
});
|
|
30
|
+
const ExecuteMoyskladImportResponseSchema = zod_1.z.object({
|
|
31
|
+
message: zod_1.z.string().optional(),
|
|
32
|
+
data: zod_1.z.object({
|
|
33
|
+
created: zod_1.z.number(),
|
|
34
|
+
updated: zod_1.z.number(),
|
|
35
|
+
archived: zod_1.z.number(),
|
|
36
|
+
orphansCleaned: zod_1.z.number(),
|
|
37
|
+
consignmentUUID: zod_1.z.string(),
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
var ExecuteMoyskladImportContractCommand;
|
|
41
|
+
(function (ExecuteMoyskladImportContractCommand) {
|
|
42
|
+
ExecuteMoyskladImportContractCommand.RequestSchema = ExecuteMoyskladImportRequestSchema;
|
|
43
|
+
ExecuteMoyskladImportContractCommand.ResponseSchema = ExecuteMoyskladImportResponseSchema;
|
|
44
|
+
})(ExecuteMoyskladImportContractCommand || (exports.ExecuteMoyskladImportContractCommand = ExecuteMoyskladImportContractCommand = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetMoyskladStatusContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const GetMoyskladStatusResponseSchema = zod_1.z.object({
|
|
6
|
+
message: zod_1.z.string().optional(),
|
|
7
|
+
data: zod_1.z.object({
|
|
8
|
+
isConnected: zod_1.z.boolean(),
|
|
9
|
+
isEnabled: zod_1.z.boolean(),
|
|
10
|
+
tokenLastFour: zod_1.z.string().length(4).nullable(),
|
|
11
|
+
accountId: zod_1.z.string().nullable(),
|
|
12
|
+
defaultOrgId: zod_1.z.string().nullable(),
|
|
13
|
+
defaultStoreId: zod_1.z.string().nullable(),
|
|
14
|
+
lastSyncAt: zod_1.z.string().datetime().nullable(),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
var GetMoyskladStatusContractQuery;
|
|
18
|
+
(function (GetMoyskladStatusContractQuery) {
|
|
19
|
+
GetMoyskladStatusContractQuery.ResponseSchema = GetMoyskladStatusResponseSchema;
|
|
20
|
+
})(GetMoyskladStatusContractQuery || (exports.GetMoyskladStatusContractQuery = GetMoyskladStatusContractQuery = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
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("./connect-moysklad.command"), exports);
|
|
18
|
+
__exportStar(require("./enable-moysklad.command"), exports);
|
|
19
|
+
__exportStar(require("./disconnect-moysklad.command"), exports);
|
|
20
|
+
__exportStar(require("./get-moysklad-status.query"), exports);
|
|
21
|
+
__exportStar(require("./list-moysklad-catalogs.query"), exports);
|
|
22
|
+
__exportStar(require("./preview-moysklad-products.query"), exports);
|
|
23
|
+
__exportStar(require("./scan-moysklad-import.query"), exports);
|
|
24
|
+
__exportStar(require("./execute-moysklad-import.command"), exports);
|
|
25
|
+
__exportStar(require("./scan-moysklad-clients-import.query"), exports);
|
|
26
|
+
__exportStar(require("./execute-moysklad-clients-import.command"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListMoyskladCatalogsContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const MoyskladCatalogItemSchema = zod_1.z.object({
|
|
6
|
+
id: zod_1.z.string().min(1),
|
|
7
|
+
name: zod_1.z.string(),
|
|
8
|
+
});
|
|
9
|
+
const ListMoyskladCatalogsResponseSchema = zod_1.z.object({
|
|
10
|
+
message: zod_1.z.string().optional(),
|
|
11
|
+
data: zod_1.z.object({
|
|
12
|
+
organizations: zod_1.z.array(MoyskladCatalogItemSchema),
|
|
13
|
+
stores: zod_1.z.array(MoyskladCatalogItemSchema),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
var ListMoyskladCatalogsContractQuery;
|
|
17
|
+
(function (ListMoyskladCatalogsContractQuery) {
|
|
18
|
+
ListMoyskladCatalogsContractQuery.ResponseSchema = ListMoyskladCatalogsResponseSchema;
|
|
19
|
+
})(ListMoyskladCatalogsContractQuery || (exports.ListMoyskladCatalogsContractQuery = ListMoyskladCatalogsContractQuery = {}));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreviewMoyskladProductsContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const PreviewMoyskladProductsRequestSchema = zod_1.z.object({
|
|
6
|
+
limit: zod_1.z.coerce.number().int().min(1).max(100).default(20),
|
|
7
|
+
});
|
|
8
|
+
const MappedProductPreviewSchema = zod_1.z.object({
|
|
9
|
+
externalSourceId: zod_1.z.string(),
|
|
10
|
+
externalHref: zod_1.z.string(),
|
|
11
|
+
name: zod_1.z.string(),
|
|
12
|
+
article: zod_1.z.string().nullable(),
|
|
13
|
+
size: zod_1.z.string().nullable(),
|
|
14
|
+
color: zod_1.z.string().nullable(),
|
|
15
|
+
country: zod_1.z.string().nullable(),
|
|
16
|
+
grower: zod_1.z.string().nullable(),
|
|
17
|
+
price: zod_1.z.number(),
|
|
18
|
+
costPrice: zod_1.z.number(),
|
|
19
|
+
balance: zod_1.z.number(),
|
|
20
|
+
categoryName: zod_1.z.string().nullable(),
|
|
21
|
+
});
|
|
22
|
+
const PreviewMoyskladProductsResponseSchema = zod_1.z.object({
|
|
23
|
+
message: zod_1.z.string().optional(),
|
|
24
|
+
data: zod_1.z.object({
|
|
25
|
+
rawProductCount: zod_1.z.number(),
|
|
26
|
+
expandedItemCount: zod_1.z.number(),
|
|
27
|
+
summary: zod_1.z.object({
|
|
28
|
+
withCategory: zod_1.z.number(),
|
|
29
|
+
withoutCategory: zod_1.z.number(),
|
|
30
|
+
withColor: zod_1.z.number(),
|
|
31
|
+
withCountry: zod_1.z.number(),
|
|
32
|
+
withGrower: zod_1.z.number(),
|
|
33
|
+
withSize: zod_1.z.number(),
|
|
34
|
+
}),
|
|
35
|
+
items: zod_1.z.array(MappedProductPreviewSchema),
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
var PreviewMoyskladProductsContractQuery;
|
|
39
|
+
(function (PreviewMoyskladProductsContractQuery) {
|
|
40
|
+
PreviewMoyskladProductsContractQuery.RequestSchema = PreviewMoyskladProductsRequestSchema;
|
|
41
|
+
PreviewMoyskladProductsContractQuery.ResponseSchema = PreviewMoyskladProductsResponseSchema;
|
|
42
|
+
})(PreviewMoyskladProductsContractQuery || (exports.PreviewMoyskladProductsContractQuery = PreviewMoyskladProductsContractQuery = {}));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScanMoyskladClientsImportContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const client_legal_type_enum_1 = require("../../../enum/client-legal-type.enum");
|
|
6
|
+
const client_type_enum_1 = require("../../../enum/client-type.enum");
|
|
7
|
+
const ScannedClientItemSchema = zod_1.z.object({
|
|
8
|
+
externalSourceId: zod_1.z.string(),
|
|
9
|
+
externalHref: zod_1.z.string(),
|
|
10
|
+
name: zod_1.z.string(),
|
|
11
|
+
contactName: zod_1.z.string().nullable(),
|
|
12
|
+
phone: zod_1.z.string().nullable(),
|
|
13
|
+
rawPhone: zod_1.z.string().nullable(),
|
|
14
|
+
email: zod_1.z.string().nullable(),
|
|
15
|
+
address: zod_1.z.string().nullable(),
|
|
16
|
+
code: zod_1.z.string().nullable(),
|
|
17
|
+
comment: zod_1.z.string().nullable(),
|
|
18
|
+
clientType: zod_1.z.nativeEnum(client_type_enum_1.ClientTypeEnum),
|
|
19
|
+
legalType: zod_1.z.nativeEnum(client_legal_type_enum_1.ClientLegalTypeEnum).nullable(),
|
|
20
|
+
archived: zod_1.z.boolean(),
|
|
21
|
+
firstName: zod_1.z.string().nullable(),
|
|
22
|
+
lastName: zod_1.z.string().nullable(),
|
|
23
|
+
middleName: zod_1.z.string().nullable(),
|
|
24
|
+
legalTitle: zod_1.z.string().nullable(),
|
|
25
|
+
inn: zod_1.z.string().nullable(),
|
|
26
|
+
kpp: zod_1.z.string().nullable(),
|
|
27
|
+
ogrn: zod_1.z.string().nullable(),
|
|
28
|
+
ogrnip: zod_1.z.string().nullable(),
|
|
29
|
+
legalAddress: zod_1.z.string().nullable(),
|
|
30
|
+
bankName: zod_1.z.string().nullable(),
|
|
31
|
+
bankAccountNumber: zod_1.z.string().nullable(),
|
|
32
|
+
bankBic: zod_1.z.string().nullable(),
|
|
33
|
+
isPhoneNormalized: zod_1.z.boolean(),
|
|
34
|
+
status: zod_1.z.enum(['new', 'known']),
|
|
35
|
+
internalUUID: zod_1.z.string().nullable(),
|
|
36
|
+
suggestedMatch: zod_1.z
|
|
37
|
+
.object({
|
|
38
|
+
clientUUID: zod_1.z.string(),
|
|
39
|
+
clientDisplayName: zod_1.z.string(),
|
|
40
|
+
matchedBy: zod_1.z.enum(['INN', 'PHONE']),
|
|
41
|
+
})
|
|
42
|
+
.nullable(),
|
|
43
|
+
});
|
|
44
|
+
const ScanMoyskladClientsImportResponseSchema = zod_1.z.object({
|
|
45
|
+
message: zod_1.z.string().optional(),
|
|
46
|
+
data: zod_1.z.object({
|
|
47
|
+
rawCount: zod_1.z.number(),
|
|
48
|
+
knownCount: zod_1.z.number(),
|
|
49
|
+
newCount: zod_1.z.number(),
|
|
50
|
+
matchedCount: zod_1.z.number(),
|
|
51
|
+
archivedInMSCount: zod_1.z.number(),
|
|
52
|
+
missingExternalIds: zod_1.z.array(zod_1.z.string()),
|
|
53
|
+
orphanedExternalIds: zod_1.z.array(zod_1.z.string()),
|
|
54
|
+
items: zod_1.z.array(ScannedClientItemSchema),
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
var ScanMoyskladClientsImportContractQuery;
|
|
58
|
+
(function (ScanMoyskladClientsImportContractQuery) {
|
|
59
|
+
ScanMoyskladClientsImportContractQuery.ItemSchema = ScannedClientItemSchema;
|
|
60
|
+
ScanMoyskladClientsImportContractQuery.ResponseSchema = ScanMoyskladClientsImportResponseSchema;
|
|
61
|
+
})(ScanMoyskladClientsImportContractQuery || (exports.ScanMoyskladClientsImportContractQuery = ScanMoyskladClientsImportContractQuery = {}));
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScanMoyskladImportContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enum_1 = require("../../../enum");
|
|
6
|
+
const ScannedItemSchema = zod_1.z.object({
|
|
7
|
+
externalSourceId: zod_1.z.string(),
|
|
8
|
+
externalHref: zod_1.z.string(),
|
|
9
|
+
name: zod_1.z.string(),
|
|
10
|
+
article: zod_1.z.string().nullable(),
|
|
11
|
+
barcode: zod_1.z.string().nullable(),
|
|
12
|
+
size: zod_1.z.string().nullable(),
|
|
13
|
+
color: zod_1.z.string().nullable(),
|
|
14
|
+
country: zod_1.z.string().nullable(),
|
|
15
|
+
grower: zod_1.z.string().nullable(),
|
|
16
|
+
price: zod_1.z.number(),
|
|
17
|
+
costPrice: zod_1.z.number(),
|
|
18
|
+
balance: zod_1.z.number(),
|
|
19
|
+
categoryName: zod_1.z.string().nullable(),
|
|
20
|
+
vat: zod_1.z.number().nullable(),
|
|
21
|
+
salesUnit: zod_1.z.nativeEnum(enum_1.SalesUnitEnum),
|
|
22
|
+
status: zod_1.z.enum(['new', 'known']),
|
|
23
|
+
internalUUID: zod_1.z.string().nullable(),
|
|
24
|
+
resolvedCategoryUUID: zod_1.z.string().nullable(),
|
|
25
|
+
resolvedCategoryName: zod_1.z.string().nullable(),
|
|
26
|
+
});
|
|
27
|
+
const CategoryMatchSchema = zod_1.z.object({
|
|
28
|
+
fcCategoryUUID: zod_1.z.string(),
|
|
29
|
+
fcCategoryName: zod_1.z.string(),
|
|
30
|
+
itemsCount: zod_1.z.number(),
|
|
31
|
+
});
|
|
32
|
+
const ScanMoyskladImportResponseSchema = zod_1.z.object({
|
|
33
|
+
message: zod_1.z.string().optional(),
|
|
34
|
+
data: zod_1.z.object({
|
|
35
|
+
rawProductCount: zod_1.z.number(),
|
|
36
|
+
expandedItemCount: zod_1.z.number(),
|
|
37
|
+
knownItems: zod_1.z.number(),
|
|
38
|
+
newItems: zod_1.z.number(),
|
|
39
|
+
missingItemsCount: zod_1.z.number(),
|
|
40
|
+
missingExternalIds: zod_1.z.array(zod_1.z.string()),
|
|
41
|
+
orphanedItemsCount: zod_1.z.number(),
|
|
42
|
+
orphanedExternalIds: zod_1.z.array(zod_1.z.string()),
|
|
43
|
+
categories: zod_1.z.object({
|
|
44
|
+
matched: zod_1.z.array(CategoryMatchSchema),
|
|
45
|
+
}),
|
|
46
|
+
summary: zod_1.z.object({
|
|
47
|
+
withCategory: zod_1.z.number(),
|
|
48
|
+
withoutCategory: zod_1.z.number(),
|
|
49
|
+
withColor: zod_1.z.number(),
|
|
50
|
+
withCountry: zod_1.z.number(),
|
|
51
|
+
withGrower: zod_1.z.number(),
|
|
52
|
+
withSize: zod_1.z.number(),
|
|
53
|
+
}),
|
|
54
|
+
items: zod_1.z.array(ScannedItemSchema),
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
var ScanMoyskladImportContractQuery;
|
|
58
|
+
(function (ScanMoyskladImportContractQuery) {
|
|
59
|
+
ScanMoyskladImportContractQuery.ResponseSchema = ScanMoyskladImportResponseSchema;
|
|
60
|
+
})(ScanMoyskladImportContractQuery || (exports.ScanMoyskladImportContractQuery = ScanMoyskladImportContractQuery = {}));
|
package/build/constant/error.js
CHANGED
|
@@ -978,4 +978,18 @@ exports.ERRORS = {
|
|
|
978
978
|
PUBLIC_ACCOUNT_DELETION_INVALID_CODE: { code: 'ADR009', message: 'Invalid or expired verification code', httpCode: 400 },
|
|
979
979
|
PUBLIC_ACCOUNT_DELETION_INVALID_TOKEN: { code: 'ADR010', message: 'Invalid or expired verification token', httpCode: 400 },
|
|
980
980
|
PUBLIC_ACCOUNT_DELETION_NO_TENANTS_SELECTED: { code: 'ADR011', message: 'No valid tenants selected for deletion', httpCode: 400 },
|
|
981
|
+
// MOYSKLAD INTEGRATION
|
|
982
|
+
MOYSKLAD_INVALID_TOKEN: { code: 'MS001', message: 'MoySklad token is invalid or has insufficient permissions', httpCode: 400 },
|
|
983
|
+
MOYSKLAD_CONNECT_FAILED: { code: 'MS002', message: 'Failed to connect MoySklad integration', httpCode: 500 },
|
|
984
|
+
MOYSKLAD_NOT_CONNECTED: { code: 'MS003', message: 'MoySklad integration is not connected for this company', httpCode: 404 },
|
|
985
|
+
MOYSKLAD_API_ERROR: { code: 'MS004', message: 'MoySklad API request failed', httpCode: 502 },
|
|
986
|
+
MOYSKLAD_DISCONNECT_FAILED: { code: 'MS005', message: 'Failed to disconnect MoySklad integration', httpCode: 500 },
|
|
987
|
+
MOYSKLAD_SETTINGS_INVALID: { code: 'MS006', message: 'Provided organization or store does not belong to the connected MoySklad account', httpCode: 400 },
|
|
988
|
+
INTEGRATION_ENC_KEY_NOT_SET: { code: 'MS007', message: 'Integration encryption key is not configured on the server', httpCode: 500 },
|
|
989
|
+
MOYSKLAD_IMPORT_IN_PROGRESS: { code: 'MS008', message: 'MoySklad import is already in progress for this company', httpCode: 409 },
|
|
990
|
+
MOYSKLAD_CLIENTS_IMPORT_IN_PROGRESS: {
|
|
991
|
+
code: 'MS009',
|
|
992
|
+
message: 'MoySklad clients import is already in progress for this company',
|
|
993
|
+
httpCode: 409,
|
|
994
|
+
},
|
|
981
995
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExternalEntityTypeEnum = void 0;
|
|
4
|
+
var ExternalEntityTypeEnum;
|
|
5
|
+
(function (ExternalEntityTypeEnum) {
|
|
6
|
+
ExternalEntityTypeEnum["PRODUCT"] = "PRODUCT";
|
|
7
|
+
ExternalEntityTypeEnum["CATEGORY"] = "CATEGORY";
|
|
8
|
+
ExternalEntityTypeEnum["CLIENT"] = "CLIENT";
|
|
9
|
+
ExternalEntityTypeEnum["ORDER"] = "ORDER";
|
|
10
|
+
})(ExternalEntityTypeEnum || (exports.ExternalEntityTypeEnum = ExternalEntityTypeEnum = {}));
|
package/build/enum/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./consignment-status.enum"), exports);
|
|
18
|
+
__exportStar(require("./integration-provider.enum"), exports);
|
|
19
|
+
__exportStar(require("./external-entity-type.enum"), exports);
|
|
18
20
|
__exportStar(require("./order-type.enum"), exports);
|
|
19
21
|
__exportStar(require("./order-status.enum"), exports);
|
|
20
22
|
__exportStar(require("./order-restricted-status-list"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntegrationProviderEnum = void 0;
|
|
4
|
+
var IntegrationProviderEnum;
|
|
5
|
+
(function (IntegrationProviderEnum) {
|
|
6
|
+
IntegrationProviderEnum["MOYSKLAD"] = "MOYSKLAD";
|
|
7
|
+
})(IntegrationProviderEnum || (exports.IntegrationProviderEnum = IntegrationProviderEnum = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const ConnectMoyskladRequestSchema = z.object({
|
|
4
|
+
token: z.string().min(20).max(200),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const ConnectMoyskladResponseSchema = z.object({
|
|
8
|
+
message: z.string().optional(),
|
|
9
|
+
data: z.object({
|
|
10
|
+
tokenLastFour: z.string().length(4),
|
|
11
|
+
accountId: z.string().nullable(),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export namespace ConnectMoyskladContractCommand {
|
|
16
|
+
export const RequestSchema = ConnectMoyskladRequestSchema;
|
|
17
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
18
|
+
export const ResponseSchema = ConnectMoyskladResponseSchema;
|
|
19
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const DisconnectMoyskladResponseSchema = z.object({
|
|
4
|
+
message: z.string().optional(),
|
|
5
|
+
data: z.object({
|
|
6
|
+
success: z.literal(true),
|
|
7
|
+
}),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export namespace DisconnectMoyskladContractCommand {
|
|
11
|
+
export const ResponseSchema = DisconnectMoyskladResponseSchema;
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const EnableMoyskladRequestSchema = z.object({
|
|
4
|
+
defaultOrgId: z.string().min(1),
|
|
5
|
+
defaultStoreId: z.string().min(1),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const EnableMoyskladResponseSchema = z.object({
|
|
9
|
+
message: z.string().optional(),
|
|
10
|
+
data: z.object({
|
|
11
|
+
isEnabled: z.literal(true),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export namespace EnableMoyskladContractCommand {
|
|
16
|
+
export const RequestSchema = EnableMoyskladRequestSchema;
|
|
17
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
18
|
+
export const ResponseSchema = EnableMoyskladResponseSchema;
|
|
19
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ErrorMessageSchema } from '../../../schemas/error-message.schema';
|
|
3
|
+
import { ScanMoyskladClientsImportContractQuery } from './scan-moysklad-clients-import.query';
|
|
4
|
+
|
|
5
|
+
const ExecutableClientItemSchema = ScanMoyskladClientsImportContractQuery.ItemSchema.extend({
|
|
6
|
+
bindToExistingClientUUID: z.string().nullable().default(null),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const ExecuteMoyskladClientsImportRequestSchema = z.object({
|
|
10
|
+
items: z.array(ExecutableClientItemSchema),
|
|
11
|
+
missingExternalIds: z.array(z.string()).default([]),
|
|
12
|
+
orphanedExternalIds: z.array(z.string()).default([]),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const ImportWarningSchema = z.object({
|
|
16
|
+
externalSourceId: z.string(),
|
|
17
|
+
warning: ErrorMessageSchema,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const ExecuteMoyskladClientsImportResponseSchema = z.object({
|
|
21
|
+
message: z.string().optional(),
|
|
22
|
+
data: z.object({
|
|
23
|
+
created: z.number(),
|
|
24
|
+
updated: z.number(),
|
|
25
|
+
bound: z.number(),
|
|
26
|
+
archived: z.number(),
|
|
27
|
+
orphansCleaned: z.number(),
|
|
28
|
+
warnings: z.array(ImportWarningSchema).default([]),
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export namespace ExecuteMoyskladClientsImportContractCommand {
|
|
33
|
+
export const ItemSchema = ExecutableClientItemSchema;
|
|
34
|
+
export type Item = z.infer<typeof ExecutableClientItemSchema>;
|
|
35
|
+
export const RequestSchema = ExecuteMoyskladClientsImportRequestSchema;
|
|
36
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
37
|
+
export const ResponseSchema = ExecuteMoyskladClientsImportResponseSchema;
|
|
38
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
39
|
+
export const WarningSchema = ImportWarningSchema;
|
|
40
|
+
export type Warning = z.infer<typeof WarningSchema>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SalesUnitEnum } from '../../../enum';
|
|
3
|
+
|
|
4
|
+
const ExecutableItemSchema = z.object({
|
|
5
|
+
externalSourceId: z.string(),
|
|
6
|
+
externalHref: z.string(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
article: z.string().nullable(),
|
|
9
|
+
barcode: z.string().nullable(),
|
|
10
|
+
size: z.string().nullable(),
|
|
11
|
+
color: z.string().nullable(),
|
|
12
|
+
country: z.string().nullable(),
|
|
13
|
+
grower: z.string().nullable(),
|
|
14
|
+
price: z.number(),
|
|
15
|
+
costPrice: z.number(),
|
|
16
|
+
balance: z.number(),
|
|
17
|
+
vat: z.number().nullable(),
|
|
18
|
+
salesUnit: z.nativeEnum(SalesUnitEnum),
|
|
19
|
+
status: z.enum(['new', 'known']),
|
|
20
|
+
internalUUID: z.string().nullable(),
|
|
21
|
+
resolvedCategoryUUID: z.string().nullable(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const ExecuteMoyskladImportRequestSchema = z.object({
|
|
25
|
+
items: z.array(ExecutableItemSchema),
|
|
26
|
+
missingExternalIds: z.array(z.string()).default([]),
|
|
27
|
+
orphanedExternalIds: z.array(z.string()).default([]),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const ExecuteMoyskladImportResponseSchema = z.object({
|
|
31
|
+
message: z.string().optional(),
|
|
32
|
+
data: z.object({
|
|
33
|
+
created: z.number(),
|
|
34
|
+
updated: z.number(),
|
|
35
|
+
archived: z.number(),
|
|
36
|
+
orphansCleaned: z.number(),
|
|
37
|
+
consignmentUUID: z.string(),
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export namespace ExecuteMoyskladImportContractCommand {
|
|
42
|
+
export const RequestSchema = ExecuteMoyskladImportRequestSchema;
|
|
43
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
44
|
+
export const ResponseSchema = ExecuteMoyskladImportResponseSchema;
|
|
45
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const GetMoyskladStatusResponseSchema = z.object({
|
|
4
|
+
message: z.string().optional(),
|
|
5
|
+
data: z.object({
|
|
6
|
+
isConnected: z.boolean(),
|
|
7
|
+
isEnabled: z.boolean(),
|
|
8
|
+
tokenLastFour: z.string().length(4).nullable(),
|
|
9
|
+
accountId: z.string().nullable(),
|
|
10
|
+
defaultOrgId: z.string().nullable(),
|
|
11
|
+
defaultStoreId: z.string().nullable(),
|
|
12
|
+
lastSyncAt: z.string().datetime().nullable(),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export namespace GetMoyskladStatusContractQuery {
|
|
17
|
+
export const ResponseSchema = GetMoyskladStatusResponseSchema;
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './connect-moysklad.command';
|
|
2
|
+
export * from './enable-moysklad.command';
|
|
3
|
+
export * from './disconnect-moysklad.command';
|
|
4
|
+
export * from './get-moysklad-status.query';
|
|
5
|
+
export * from './list-moysklad-catalogs.query';
|
|
6
|
+
export * from './preview-moysklad-products.query';
|
|
7
|
+
export * from './scan-moysklad-import.query';
|
|
8
|
+
export * from './execute-moysklad-import.command';
|
|
9
|
+
export * from './scan-moysklad-clients-import.query';
|
|
10
|
+
export * from './execute-moysklad-clients-import.command';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const MoyskladCatalogItemSchema = z.object({
|
|
4
|
+
id: z.string().min(1),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const ListMoyskladCatalogsResponseSchema = z.object({
|
|
9
|
+
message: z.string().optional(),
|
|
10
|
+
data: z.object({
|
|
11
|
+
organizations: z.array(MoyskladCatalogItemSchema),
|
|
12
|
+
stores: z.array(MoyskladCatalogItemSchema),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export namespace ListMoyskladCatalogsContractQuery {
|
|
17
|
+
export const ResponseSchema = ListMoyskladCatalogsResponseSchema;
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const PreviewMoyskladProductsRequestSchema = z.object({
|
|
4
|
+
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const MappedProductPreviewSchema = z.object({
|
|
8
|
+
externalSourceId: z.string(),
|
|
9
|
+
externalHref: z.string(),
|
|
10
|
+
name: z.string(),
|
|
11
|
+
article: z.string().nullable(),
|
|
12
|
+
size: z.string().nullable(),
|
|
13
|
+
color: z.string().nullable(),
|
|
14
|
+
country: z.string().nullable(),
|
|
15
|
+
grower: z.string().nullable(),
|
|
16
|
+
price: z.number(),
|
|
17
|
+
costPrice: z.number(),
|
|
18
|
+
balance: z.number(),
|
|
19
|
+
categoryName: z.string().nullable(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const PreviewMoyskladProductsResponseSchema = z.object({
|
|
23
|
+
message: z.string().optional(),
|
|
24
|
+
data: z.object({
|
|
25
|
+
rawProductCount: z.number(),
|
|
26
|
+
expandedItemCount: z.number(),
|
|
27
|
+
summary: z.object({
|
|
28
|
+
withCategory: z.number(),
|
|
29
|
+
withoutCategory: z.number(),
|
|
30
|
+
withColor: z.number(),
|
|
31
|
+
withCountry: z.number(),
|
|
32
|
+
withGrower: z.number(),
|
|
33
|
+
withSize: z.number(),
|
|
34
|
+
}),
|
|
35
|
+
items: z.array(MappedProductPreviewSchema),
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export namespace PreviewMoyskladProductsContractQuery {
|
|
40
|
+
export const RequestSchema = PreviewMoyskladProductsRequestSchema;
|
|
41
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
42
|
+
export const ResponseSchema = PreviewMoyskladProductsResponseSchema;
|
|
43
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ClientLegalTypeEnum } from '../../../enum/client-legal-type.enum';
|
|
3
|
+
import { ClientTypeEnum } from '../../../enum/client-type.enum';
|
|
4
|
+
|
|
5
|
+
const ScannedClientItemSchema = z.object({
|
|
6
|
+
externalSourceId: z.string(),
|
|
7
|
+
externalHref: z.string(),
|
|
8
|
+
|
|
9
|
+
name: z.string(),
|
|
10
|
+
contactName: z.string().nullable(),
|
|
11
|
+
phone: z.string().nullable(),
|
|
12
|
+
rawPhone: z.string().nullable(),
|
|
13
|
+
email: z.string().nullable(),
|
|
14
|
+
address: z.string().nullable(),
|
|
15
|
+
code: z.string().nullable(),
|
|
16
|
+
comment: z.string().nullable(),
|
|
17
|
+
clientType: z.nativeEnum(ClientTypeEnum),
|
|
18
|
+
legalType: z.nativeEnum(ClientLegalTypeEnum).nullable(),
|
|
19
|
+
archived: z.boolean(),
|
|
20
|
+
|
|
21
|
+
firstName: z.string().nullable(),
|
|
22
|
+
lastName: z.string().nullable(),
|
|
23
|
+
middleName: z.string().nullable(),
|
|
24
|
+
|
|
25
|
+
legalTitle: z.string().nullable(),
|
|
26
|
+
inn: z.string().nullable(),
|
|
27
|
+
kpp: z.string().nullable(),
|
|
28
|
+
ogrn: z.string().nullable(),
|
|
29
|
+
ogrnip: z.string().nullable(),
|
|
30
|
+
legalAddress: z.string().nullable(),
|
|
31
|
+
|
|
32
|
+
bankName: z.string().nullable(),
|
|
33
|
+
bankAccountNumber: z.string().nullable(),
|
|
34
|
+
bankBic: z.string().nullable(),
|
|
35
|
+
|
|
36
|
+
isPhoneNormalized: z.boolean(),
|
|
37
|
+
|
|
38
|
+
status: z.enum(['new', 'known']),
|
|
39
|
+
internalUUID: z.string().nullable(),
|
|
40
|
+
suggestedMatch: z
|
|
41
|
+
.object({
|
|
42
|
+
clientUUID: z.string(),
|
|
43
|
+
clientDisplayName: z.string(),
|
|
44
|
+
matchedBy: z.enum(['INN', 'PHONE']),
|
|
45
|
+
})
|
|
46
|
+
.nullable(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const ScanMoyskladClientsImportResponseSchema = z.object({
|
|
50
|
+
message: z.string().optional(),
|
|
51
|
+
data: z.object({
|
|
52
|
+
rawCount: z.number(),
|
|
53
|
+
knownCount: z.number(),
|
|
54
|
+
newCount: z.number(),
|
|
55
|
+
matchedCount: z.number(),
|
|
56
|
+
archivedInMSCount: z.number(),
|
|
57
|
+
missingExternalIds: z.array(z.string()),
|
|
58
|
+
orphanedExternalIds: z.array(z.string()),
|
|
59
|
+
items: z.array(ScannedClientItemSchema),
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export namespace ScanMoyskladClientsImportContractQuery {
|
|
64
|
+
export const ItemSchema = ScannedClientItemSchema;
|
|
65
|
+
export type Item = z.infer<typeof ScannedClientItemSchema>;
|
|
66
|
+
export const ResponseSchema = ScanMoyskladClientsImportResponseSchema;
|
|
67
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SalesUnitEnum } from '../../../enum';
|
|
3
|
+
|
|
4
|
+
const ScannedItemSchema = z.object({
|
|
5
|
+
externalSourceId: z.string(),
|
|
6
|
+
externalHref: z.string(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
article: z.string().nullable(),
|
|
9
|
+
barcode: z.string().nullable(),
|
|
10
|
+
size: z.string().nullable(),
|
|
11
|
+
color: z.string().nullable(),
|
|
12
|
+
country: z.string().nullable(),
|
|
13
|
+
grower: z.string().nullable(),
|
|
14
|
+
price: z.number(),
|
|
15
|
+
costPrice: z.number(),
|
|
16
|
+
balance: z.number(),
|
|
17
|
+
categoryName: z.string().nullable(),
|
|
18
|
+
vat: z.number().nullable(),
|
|
19
|
+
salesUnit: z.nativeEnum(SalesUnitEnum),
|
|
20
|
+
status: z.enum(['new', 'known']),
|
|
21
|
+
internalUUID: z.string().nullable(),
|
|
22
|
+
resolvedCategoryUUID: z.string().nullable(),
|
|
23
|
+
resolvedCategoryName: z.string().nullable(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const CategoryMatchSchema = z.object({
|
|
27
|
+
fcCategoryUUID: z.string(),
|
|
28
|
+
fcCategoryName: z.string(),
|
|
29
|
+
itemsCount: z.number(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const ScanMoyskladImportResponseSchema = z.object({
|
|
33
|
+
message: z.string().optional(),
|
|
34
|
+
data: z.object({
|
|
35
|
+
rawProductCount: z.number(),
|
|
36
|
+
expandedItemCount: z.number(),
|
|
37
|
+
knownItems: z.number(),
|
|
38
|
+
newItems: z.number(),
|
|
39
|
+
missingItemsCount: z.number(),
|
|
40
|
+
missingExternalIds: z.array(z.string()),
|
|
41
|
+
orphanedItemsCount: z.number(),
|
|
42
|
+
orphanedExternalIds: z.array(z.string()),
|
|
43
|
+
categories: z.object({
|
|
44
|
+
matched: z.array(CategoryMatchSchema),
|
|
45
|
+
}),
|
|
46
|
+
summary: z.object({
|
|
47
|
+
withCategory: z.number(),
|
|
48
|
+
withoutCategory: z.number(),
|
|
49
|
+
withColor: z.number(),
|
|
50
|
+
withCountry: z.number(),
|
|
51
|
+
withGrower: z.number(),
|
|
52
|
+
withSize: z.number(),
|
|
53
|
+
}),
|
|
54
|
+
items: z.array(ScannedItemSchema),
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export namespace ScanMoyskladImportContractQuery {
|
|
59
|
+
export const ResponseSchema = ScanMoyskladImportResponseSchema;
|
|
60
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
61
|
+
}
|
package/constant/error.ts
CHANGED
|
@@ -1037,4 +1037,19 @@ export const ERRORS = {
|
|
|
1037
1037
|
PUBLIC_ACCOUNT_DELETION_INVALID_CODE: { code: 'ADR009', message: 'Invalid or expired verification code', httpCode: 400 },
|
|
1038
1038
|
PUBLIC_ACCOUNT_DELETION_INVALID_TOKEN: { code: 'ADR010', message: 'Invalid or expired verification token', httpCode: 400 },
|
|
1039
1039
|
PUBLIC_ACCOUNT_DELETION_NO_TENANTS_SELECTED: { code: 'ADR011', message: 'No valid tenants selected for deletion', httpCode: 400 },
|
|
1040
|
+
|
|
1041
|
+
// MOYSKLAD INTEGRATION
|
|
1042
|
+
MOYSKLAD_INVALID_TOKEN: { code: 'MS001', message: 'MoySklad token is invalid or has insufficient permissions', httpCode: 400 },
|
|
1043
|
+
MOYSKLAD_CONNECT_FAILED: { code: 'MS002', message: 'Failed to connect MoySklad integration', httpCode: 500 },
|
|
1044
|
+
MOYSKLAD_NOT_CONNECTED: { code: 'MS003', message: 'MoySklad integration is not connected for this company', httpCode: 404 },
|
|
1045
|
+
MOYSKLAD_API_ERROR: { code: 'MS004', message: 'MoySklad API request failed', httpCode: 502 },
|
|
1046
|
+
MOYSKLAD_DISCONNECT_FAILED: { code: 'MS005', message: 'Failed to disconnect MoySklad integration', httpCode: 500 },
|
|
1047
|
+
MOYSKLAD_SETTINGS_INVALID: { code: 'MS006', message: 'Provided organization or store does not belong to the connected MoySklad account', httpCode: 400 },
|
|
1048
|
+
INTEGRATION_ENC_KEY_NOT_SET: { code: 'MS007', message: 'Integration encryption key is not configured on the server', httpCode: 500 },
|
|
1049
|
+
MOYSKLAD_IMPORT_IN_PROGRESS: { code: 'MS008', message: 'MoySklad import is already in progress for this company', httpCode: 409 },
|
|
1050
|
+
MOYSKLAD_CLIENTS_IMPORT_IN_PROGRESS: {
|
|
1051
|
+
code: 'MS009',
|
|
1052
|
+
message: 'MoySklad clients import is already in progress for this company',
|
|
1053
|
+
httpCode: 409,
|
|
1054
|
+
},
|
|
1040
1055
|
} as const;
|
package/enum/index.ts
CHANGED