@floristcloud/api-lib 1.2.25 → 1.2.27

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.
@@ -16,6 +16,14 @@ const GetMoyskladStatusResponseSchema = zod_1.z.object({
16
16
  nameProcessingConvention: zod_1.z.nativeEnum(consignment_import_name_convention_enum_1.ConsignmentImportNameConventionEnum).nullable(),
17
17
  isRemoveSizeFromName: zod_1.z.boolean(),
18
18
  isCutCategoryFromName: zod_1.z.boolean(),
19
+ lastStockSyncedAt: zod_1.z.string().datetime().nullable(),
20
+ stockSyncStatus: zod_1.z.enum(['PENDING', 'RUNNING', 'DEAD', 'IDLE']),
21
+ stockSyncDeadInfo: zod_1.z
22
+ .object({
23
+ errorCode: zod_1.z.string(),
24
+ errorMessage: zod_1.z.string(),
25
+ })
26
+ .nullable(),
19
27
  }),
20
28
  });
21
29
  var GetMoyskladStatusContractQuery;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetOrderSyncStatusContractQuery = void 0;
4
+ const zod_1 = require("zod");
5
+ const outbound_sync_intent_enum_1 = require("../../../enum/outbound-sync-intent.enum");
6
+ const PendingJobSchema = zod_1.z.object({
7
+ intent: zod_1.z.nativeEnum(outbound_sync_intent_enum_1.OutboundSyncIntentEnum),
8
+ attempts: zod_1.z.number().int().nonnegative(),
9
+ errorCode: zod_1.z.string().nullable(),
10
+ errorMessage: zod_1.z.string().nullable(),
11
+ nextAttemptAt: zod_1.z.string().datetime(),
12
+ });
13
+ const DeadJobSchema = zod_1.z.object({
14
+ intent: zod_1.z.nativeEnum(outbound_sync_intent_enum_1.OutboundSyncIntentEnum),
15
+ errorCode: zod_1.z.string(),
16
+ errorMessage: zod_1.z.string(),
17
+ });
18
+ const OrderSyncStatusSchema = zod_1.z.object({
19
+ orderUUID: zod_1.z.string().uuid(),
20
+ isLinked: zod_1.z.boolean(),
21
+ externalHref: zod_1.z.string().nullable(),
22
+ isClientLinked: zod_1.z.boolean(),
23
+ hasUnlinkedProducts: zod_1.z.boolean(),
24
+ missingProductUUIDs: zod_1.z.array(zod_1.z.string().uuid()),
25
+ lastSyncedAt: zod_1.z.string().datetime().nullable(),
26
+ pendingJob: PendingJobSchema.nullable(),
27
+ isDead: zod_1.z.boolean(),
28
+ deadJob: DeadJobSchema.nullable(),
29
+ });
30
+ const GetOrderSyncStatusResponseSchema = zod_1.z.object({
31
+ message: zod_1.z.string().optional(),
32
+ data: OrderSyncStatusSchema,
33
+ });
34
+ var GetOrderSyncStatusContractQuery;
35
+ (function (GetOrderSyncStatusContractQuery) {
36
+ GetOrderSyncStatusContractQuery.ResponseSchema = GetOrderSyncStatusResponseSchema;
37
+ GetOrderSyncStatusContractQuery.StatusSchema = OrderSyncStatusSchema;
38
+ })(GetOrderSyncStatusContractQuery || (exports.GetOrderSyncStatusContractQuery = GetOrderSyncStatusContractQuery = {}));
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetOrdersBatchSyncStatusContractQuery = void 0;
4
+ const zod_1 = require("zod");
5
+ const GetOrdersBatchSyncStatusRequestSchema = zod_1.z.object({
6
+ orderUUIDs: zod_1.z.array(zod_1.z.string().uuid()).min(1).max(200),
7
+ });
8
+ const OrderSyncStatusSlimSchema = zod_1.z.object({
9
+ orderUUID: zod_1.z.string().uuid(),
10
+ isLinked: zod_1.z.boolean(),
11
+ hasIssues: zod_1.z.boolean(),
12
+ });
13
+ const GetOrdersBatchSyncStatusResponseSchema = zod_1.z.object({
14
+ message: zod_1.z.string().optional(),
15
+ data: zod_1.z.object({
16
+ statuses: zod_1.z.array(OrderSyncStatusSlimSchema),
17
+ }),
18
+ });
19
+ var GetOrdersBatchSyncStatusContractQuery;
20
+ (function (GetOrdersBatchSyncStatusContractQuery) {
21
+ GetOrdersBatchSyncStatusContractQuery.RequestSchema = GetOrdersBatchSyncStatusRequestSchema;
22
+ GetOrdersBatchSyncStatusContractQuery.ResponseSchema = GetOrdersBatchSyncStatusResponseSchema;
23
+ GetOrdersBatchSyncStatusContractQuery.SlimStatusSchema = OrderSyncStatusSlimSchema;
24
+ })(GetOrdersBatchSyncStatusContractQuery || (exports.GetOrdersBatchSyncStatusContractQuery = GetOrdersBatchSyncStatusContractQuery = {}));
@@ -24,3 +24,6 @@ __exportStar(require("./scan-moysklad-import.query"), exports);
24
24
  __exportStar(require("./execute-moysklad-import.command"), exports);
25
25
  __exportStar(require("./scan-moysklad-clients-import.query"), exports);
26
26
  __exportStar(require("./execute-moysklad-clients-import.command"), exports);
27
+ __exportStar(require("./get-order-sync-status.query"), exports);
28
+ __exportStar(require("./get-orders-batch-sync-status.query"), exports);
29
+ __exportStar(require("./sync-moysklad-stock.command"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SyncMoyskladStockContractCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const SyncMoyskladStockResponseSchema = zod_1.z.object({
6
+ message: zod_1.z.string().optional(),
7
+ data: zod_1.z.object({
8
+ jobUUID: zod_1.z.string().uuid(),
9
+ status: zod_1.z.enum(['PENDING', 'RUNNING']),
10
+ wasAlreadyQueued: zod_1.z.boolean(),
11
+ }),
12
+ });
13
+ var SyncMoyskladStockContractCommand;
14
+ (function (SyncMoyskladStockContractCommand) {
15
+ SyncMoyskladStockContractCommand.ResponseSchema = SyncMoyskladStockResponseSchema;
16
+ })(SyncMoyskladStockContractCommand || (exports.SyncMoyskladStockContractCommand = SyncMoyskladStockContractCommand = {}));
@@ -986,7 +986,11 @@ exports.ERRORS = {
986
986
  MOYSKLAD_NOT_CONNECTED: { code: 'MS003', message: 'MoySklad integration is not connected for this company', httpCode: 404 },
987
987
  MOYSKLAD_API_ERROR: { code: 'MS004', message: 'MoySklad API request failed', httpCode: 502 },
988
988
  MOYSKLAD_DISCONNECT_FAILED: { code: 'MS005', message: 'Failed to disconnect MoySklad integration', httpCode: 500 },
989
- MOYSKLAD_SETTINGS_INVALID: { code: 'MS006', message: 'Provided organization or store does not belong to the connected MoySklad account', httpCode: 400 },
989
+ MOYSKLAD_SETTINGS_INVALID: {
990
+ code: 'MS006',
991
+ message: 'Provided organization or store does not belong to the connected MoySklad account',
992
+ httpCode: 400,
993
+ },
990
994
  INTEGRATION_ENC_KEY_NOT_SET: { code: 'MS007', message: 'Integration encryption key is not configured on the server', httpCode: 500 },
991
995
  MOYSKLAD_IMPORT_IN_PROGRESS: { code: 'MS008', message: 'MoySklad import is already in progress for this company', httpCode: 409 },
992
996
  MOYSKLAD_CLIENTS_IMPORT_IN_PROGRESS: {
@@ -1004,11 +1008,6 @@ exports.ERRORS = {
1004
1008
  message: 'Order client has no MoySklad link; import clients first',
1005
1009
  httpCode: 400,
1006
1010
  },
1007
- MOYSKLAD_ORDER_PRODUCT_NOT_LINKED: {
1008
- code: 'MS012',
1009
- message: 'One or more order products have no MoySklad link',
1010
- httpCode: 400,
1011
- },
1012
1011
  MOYSKLAD_INTEGRATION_INCOMPLETE: {
1013
1012
  code: 'MS013',
1014
1013
  message: 'MoySklad integration is missing default organization or store',
@@ -1034,4 +1033,19 @@ exports.ERRORS = {
1034
1033
  message: 'Outbound sync entity type is not supported by this provider',
1035
1034
  httpCode: 400,
1036
1035
  },
1036
+ MOYSKLAD_STOCK_SYNC_CAP_EXCEEDED: {
1037
+ code: 'MS015',
1038
+ message: 'MoySklad stock-sync concurrency cap exceeded; will retry shortly',
1039
+ httpCode: 429,
1040
+ },
1041
+ MOYSKLAD_STOCK_SYNC_LOCK_BUSY: {
1042
+ code: 'MS016',
1043
+ message: 'MoySklad sync lock is held by another job for this company; will retry shortly',
1044
+ httpCode: 409,
1045
+ },
1046
+ MOYSKLAD_INTEGRATION_DISABLED: {
1047
+ code: 'MS017',
1048
+ message: 'MoySklad integration is disabled for this company',
1049
+ httpCode: 409,
1050
+ },
1037
1051
  };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isColorCode = exports.COLOR_CODE_LIST = exports.ColorCodeEnum = void 0;
4
+ var ColorCodeEnum;
5
+ (function (ColorCodeEnum) {
6
+ ColorCodeEnum["RED"] = "red";
7
+ ColorCodeEnum["PINK"] = "pink";
8
+ ColorCodeEnum["WHITE"] = "white";
9
+ ColorCodeEnum["YELLOW"] = "yellow";
10
+ ColorCodeEnum["ORANGE"] = "orange";
11
+ ColorCodeEnum["PURPLE"] = "purple";
12
+ ColorCodeEnum["BLUE"] = "blue";
13
+ ColorCodeEnum["LIGHT_BLUE"] = "light-blue";
14
+ ColorCodeEnum["GREEN"] = "green";
15
+ ColorCodeEnum["MINT"] = "mint";
16
+ ColorCodeEnum["CREAM"] = "cream";
17
+ ColorCodeEnum["PEACH"] = "peach";
18
+ ColorCodeEnum["BURGUNDY"] = "burgundy";
19
+ ColorCodeEnum["LAVENDER"] = "lavender";
20
+ ColorCodeEnum["CORAL"] = "coral";
21
+ ColorCodeEnum["BLACK"] = "black";
22
+ ColorCodeEnum["BROWN"] = "brown";
23
+ ColorCodeEnum["GOLD"] = "gold";
24
+ ColorCodeEnum["SILVER"] = "silver";
25
+ ColorCodeEnum["BEIGE"] = "beige";
26
+ ColorCodeEnum["MIX"] = "mix";
27
+ })(ColorCodeEnum || (exports.ColorCodeEnum = ColorCodeEnum = {}));
28
+ const COLOR_CODE_KEYS = Object.keys(ColorCodeEnum);
29
+ exports.COLOR_CODE_LIST = COLOR_CODE_KEYS.map(k => ColorCodeEnum[k]);
30
+ const isColorCode = (value) => {
31
+ if (typeof value !== 'string')
32
+ return false;
33
+ const list = exports.COLOR_CODE_LIST;
34
+ return list.indexOf(value) !== -1;
35
+ };
36
+ exports.isColorCode = isColorCode;
@@ -80,6 +80,7 @@ __exportStar(require("./order-delivery-status.enum"), exports);
80
80
  __exportStar(require("./consignment-write-off-archives-status.enum"), exports);
81
81
  __exportStar(require("./context-message-context-type.enum"), exports);
82
82
  __exportStar(require("./country-code.enum"), exports);
83
+ __exportStar(require("./color-code.enum"), exports);
83
84
  __exportStar(require("./pre-order-aggregation-mode.enum"), exports);
84
85
  __exportStar(require("./order-webshop-available-status-list"), exports);
85
86
  __exportStar(require("./transaction-type-groups"), exports);
@@ -14,6 +14,14 @@ const GetMoyskladStatusResponseSchema = z.object({
14
14
  nameProcessingConvention: z.nativeEnum(ConsignmentImportNameConventionEnum).nullable(),
15
15
  isRemoveSizeFromName: z.boolean(),
16
16
  isCutCategoryFromName: z.boolean(),
17
+ lastStockSyncedAt: z.string().datetime().nullable(),
18
+ stockSyncStatus: z.enum(['PENDING', 'RUNNING', 'DEAD', 'IDLE']),
19
+ stockSyncDeadInfo: z
20
+ .object({
21
+ errorCode: z.string(),
22
+ errorMessage: z.string(),
23
+ })
24
+ .nullable(),
17
25
  }),
18
26
  });
19
27
 
@@ -0,0 +1,41 @@
1
+ import { z } from 'zod';
2
+ import { OutboundSyncIntentEnum } from '../../../enum/outbound-sync-intent.enum';
3
+
4
+ const PendingJobSchema = z.object({
5
+ intent: z.nativeEnum(OutboundSyncIntentEnum),
6
+ attempts: z.number().int().nonnegative(),
7
+ errorCode: z.string().nullable(),
8
+ errorMessage: z.string().nullable(),
9
+ nextAttemptAt: z.string().datetime(),
10
+ });
11
+
12
+ const DeadJobSchema = z.object({
13
+ intent: z.nativeEnum(OutboundSyncIntentEnum),
14
+ errorCode: z.string(),
15
+ errorMessage: z.string(),
16
+ });
17
+
18
+ const OrderSyncStatusSchema = z.object({
19
+ orderUUID: z.string().uuid(),
20
+ isLinked: z.boolean(),
21
+ externalHref: z.string().nullable(),
22
+ isClientLinked: z.boolean(),
23
+ hasUnlinkedProducts: z.boolean(),
24
+ missingProductUUIDs: z.array(z.string().uuid()),
25
+ lastSyncedAt: z.string().datetime().nullable(),
26
+ pendingJob: PendingJobSchema.nullable(),
27
+ isDead: z.boolean(),
28
+ deadJob: DeadJobSchema.nullable(),
29
+ });
30
+
31
+ const GetOrderSyncStatusResponseSchema = z.object({
32
+ message: z.string().optional(),
33
+ data: OrderSyncStatusSchema,
34
+ });
35
+
36
+ export namespace GetOrderSyncStatusContractQuery {
37
+ export const ResponseSchema = GetOrderSyncStatusResponseSchema;
38
+ export type Response = z.infer<typeof ResponseSchema>;
39
+ export const StatusSchema = OrderSyncStatusSchema;
40
+ export type Status = z.infer<typeof OrderSyncStatusSchema>;
41
+ }
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+
3
+ const GetOrdersBatchSyncStatusRequestSchema = z.object({
4
+ orderUUIDs: z.array(z.string().uuid()).min(1).max(200),
5
+ });
6
+
7
+ const OrderSyncStatusSlimSchema = z.object({
8
+ orderUUID: z.string().uuid(),
9
+ isLinked: z.boolean(),
10
+ hasIssues: z.boolean(),
11
+ });
12
+
13
+ const GetOrdersBatchSyncStatusResponseSchema = z.object({
14
+ message: z.string().optional(),
15
+ data: z.object({
16
+ statuses: z.array(OrderSyncStatusSlimSchema),
17
+ }),
18
+ });
19
+
20
+ export namespace GetOrdersBatchSyncStatusContractQuery {
21
+ export const RequestSchema = GetOrdersBatchSyncStatusRequestSchema;
22
+ export type Request = z.infer<typeof RequestSchema>;
23
+ export const ResponseSchema = GetOrdersBatchSyncStatusResponseSchema;
24
+ export type Response = z.infer<typeof ResponseSchema>;
25
+ export const SlimStatusSchema = OrderSyncStatusSlimSchema;
26
+ export type SlimStatus = z.infer<typeof OrderSyncStatusSlimSchema>;
27
+ }
@@ -8,3 +8,6 @@ export * from './scan-moysklad-import.query';
8
8
  export * from './execute-moysklad-import.command';
9
9
  export * from './scan-moysklad-clients-import.query';
10
10
  export * from './execute-moysklad-clients-import.command';
11
+ export * from './get-order-sync-status.query';
12
+ export * from './get-orders-batch-sync-status.query';
13
+ export * from './sync-moysklad-stock.command';
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+
3
+ const SyncMoyskladStockResponseSchema = z.object({
4
+ message: z.string().optional(),
5
+ data: z.object({
6
+ jobUUID: z.string().uuid(),
7
+ status: z.enum(['PENDING', 'RUNNING']),
8
+ wasAlreadyQueued: z.boolean(),
9
+ }),
10
+ });
11
+
12
+ export namespace SyncMoyskladStockContractCommand {
13
+ export const ResponseSchema = SyncMoyskladStockResponseSchema;
14
+ export type Response = z.infer<typeof ResponseSchema>;
15
+ }
package/constant/error.ts CHANGED
@@ -1046,7 +1046,11 @@ export const ERRORS = {
1046
1046
  MOYSKLAD_NOT_CONNECTED: { code: 'MS003', message: 'MoySklad integration is not connected for this company', httpCode: 404 },
1047
1047
  MOYSKLAD_API_ERROR: { code: 'MS004', message: 'MoySklad API request failed', httpCode: 502 },
1048
1048
  MOYSKLAD_DISCONNECT_FAILED: { code: 'MS005', message: 'Failed to disconnect MoySklad integration', httpCode: 500 },
1049
- MOYSKLAD_SETTINGS_INVALID: { code: 'MS006', message: 'Provided organization or store does not belong to the connected MoySklad account', httpCode: 400 },
1049
+ MOYSKLAD_SETTINGS_INVALID: {
1050
+ code: 'MS006',
1051
+ message: 'Provided organization or store does not belong to the connected MoySklad account',
1052
+ httpCode: 400,
1053
+ },
1050
1054
  INTEGRATION_ENC_KEY_NOT_SET: { code: 'MS007', message: 'Integration encryption key is not configured on the server', httpCode: 500 },
1051
1055
  MOYSKLAD_IMPORT_IN_PROGRESS: { code: 'MS008', message: 'MoySklad import is already in progress for this company', httpCode: 409 },
1052
1056
  MOYSKLAD_CLIENTS_IMPORT_IN_PROGRESS: {
@@ -1064,11 +1068,6 @@ export const ERRORS = {
1064
1068
  message: 'Order client has no MoySklad link; import clients first',
1065
1069
  httpCode: 400,
1066
1070
  },
1067
- MOYSKLAD_ORDER_PRODUCT_NOT_LINKED: {
1068
- code: 'MS012',
1069
- message: 'One or more order products have no MoySklad link',
1070
- httpCode: 400,
1071
- },
1072
1071
  MOYSKLAD_INTEGRATION_INCOMPLETE: {
1073
1072
  code: 'MS013',
1074
1073
  message: 'MoySklad integration is missing default organization or store',
@@ -1094,4 +1093,19 @@ export const ERRORS = {
1094
1093
  message: 'Outbound sync entity type is not supported by this provider',
1095
1094
  httpCode: 400,
1096
1095
  },
1096
+ MOYSKLAD_STOCK_SYNC_CAP_EXCEEDED: {
1097
+ code: 'MS015',
1098
+ message: 'MoySklad stock-sync concurrency cap exceeded; will retry shortly',
1099
+ httpCode: 429,
1100
+ },
1101
+ MOYSKLAD_STOCK_SYNC_LOCK_BUSY: {
1102
+ code: 'MS016',
1103
+ message: 'MoySklad sync lock is held by another job for this company; will retry shortly',
1104
+ httpCode: 409,
1105
+ },
1106
+ MOYSKLAD_INTEGRATION_DISABLED: {
1107
+ code: 'MS017',
1108
+ message: 'MoySklad integration is disabled for this company',
1109
+ httpCode: 409,
1110
+ },
1097
1111
  } as const;
@@ -0,0 +1,32 @@
1
+ export enum ColorCodeEnum {
2
+ RED = 'red',
3
+ PINK = 'pink',
4
+ WHITE = 'white',
5
+ YELLOW = 'yellow',
6
+ ORANGE = 'orange',
7
+ PURPLE = 'purple',
8
+ BLUE = 'blue',
9
+ LIGHT_BLUE = 'light-blue',
10
+ GREEN = 'green',
11
+ MINT = 'mint',
12
+ CREAM = 'cream',
13
+ PEACH = 'peach',
14
+ BURGUNDY = 'burgundy',
15
+ LAVENDER = 'lavender',
16
+ CORAL = 'coral',
17
+ BLACK = 'black',
18
+ BROWN = 'brown',
19
+ GOLD = 'gold',
20
+ SILVER = 'silver',
21
+ BEIGE = 'beige',
22
+ MIX = 'mix',
23
+ }
24
+
25
+ const COLOR_CODE_KEYS = Object.keys(ColorCodeEnum) as Array<keyof typeof ColorCodeEnum>;
26
+ export const COLOR_CODE_LIST: readonly ColorCodeEnum[] = COLOR_CODE_KEYS.map(k => ColorCodeEnum[k]) as readonly ColorCodeEnum[];
27
+
28
+ export const isColorCode = (value: unknown): value is ColorCodeEnum => {
29
+ if (typeof value !== 'string') return false;
30
+ const list = COLOR_CODE_LIST as readonly string[];
31
+ return list.indexOf(value) !== -1;
32
+ };
package/enum/index.ts CHANGED
@@ -64,6 +64,7 @@ export * from './order-delivery-status.enum';
64
64
  export * from './consignment-write-off-archives-status.enum';
65
65
  export * from './context-message-context-type.enum';
66
66
  export * from './country-code.enum';
67
+ export * from './color-code.enum';
67
68
  export * from './pre-order-aggregation-mode.enum';
68
69
  export * from './order-webshop-available-status-list';
69
70
  export * from './transaction-type-groups';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floristcloud/api-lib",
3
- "version": "1.2.25",
3
+ "version": "1.2.27",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {