@floristcloud/api-lib 1.2.79 → 1.2.81

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.
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetDailyOrdersSummaryContractQuery = void 0;
4
+ const zod_1 = require("zod");
5
+ const date_helper_1 = require("../../helpers/date.helper");
6
+ const GetDailyOrdersSummaryRequestSchema = zod_1.z
7
+ .object({
8
+ startDate: zod_1.z.coerce.date(),
9
+ endDate: zod_1.z.coerce.date(),
10
+ })
11
+ .refine(value => (0, date_helper_1.dateRangeCheck)(value.startDate, value.endDate), {
12
+ message: 'End date must be greater than start date',
13
+ path: ['endDate', 'startDate'],
14
+ })
15
+ .refine(value => (0, date_helper_1.isStatementPeriodWithinLimit)(value.startDate, value.endDate), {
16
+ message: 'Report period must not exceed 1 year',
17
+ path: ['endDate', 'startDate'],
18
+ });
19
+ const UnitsByMeasureSchema = zod_1.z.object({
20
+ PIECE: zod_1.z.number(),
21
+ PACK: zod_1.z.number(),
22
+ BOX: zod_1.z.number(),
23
+ });
24
+ const metricsShape = {
25
+ ordersCreated: zod_1.z.number(),
26
+ ordersCompleted: zod_1.z.number(),
27
+ totalSum: zod_1.z.number(),
28
+ unitsByMeasure: UnitsByMeasureSchema,
29
+ };
30
+ const DailyOrdersSummaryTotalsSchema = zod_1.z.object(Object.assign({}, metricsShape));
31
+ const DailyOrdersSummaryByDayItemSchema = zod_1.z.object(Object.assign({ date: zod_1.z.string() }, metricsShape));
32
+ const DailyOrdersSummaryByResponsibleItemSchema = zod_1.z.object(Object.assign({ responsibleUserUUID: zod_1.z.string().nullable(), responsibleUserName: zod_1.z.string().nullable() }, metricsShape));
33
+ const GetDailyOrdersSummaryResponseSchema = zod_1.z.object({
34
+ data: zod_1.z.object({
35
+ totals: DailyOrdersSummaryTotalsSchema,
36
+ byDay: zod_1.z.array(DailyOrdersSummaryByDayItemSchema),
37
+ byResponsible: zod_1.z.array(DailyOrdersSummaryByResponsibleItemSchema),
38
+ }),
39
+ });
40
+ var GetDailyOrdersSummaryContractQuery;
41
+ (function (GetDailyOrdersSummaryContractQuery) {
42
+ GetDailyOrdersSummaryContractQuery.RequestSchema = GetDailyOrdersSummaryRequestSchema;
43
+ GetDailyOrdersSummaryContractQuery.ResponseSchema = GetDailyOrdersSummaryResponseSchema;
44
+ })(GetDailyOrdersSummaryContractQuery || (exports.GetDailyOrdersSummaryContractQuery = GetDailyOrdersSummaryContractQuery = {}));
@@ -26,3 +26,4 @@ __exportStar(require("./export-inventory-movement.query"), exports);
26
26
  __exportStar(require("./export-inventory-turnover.query"), exports);
27
27
  __exportStar(require("./export-client-statement.query"), exports);
28
28
  __exportStar(require("./get-report-by-client-weeks.query"), exports);
29
+ __exportStar(require("./get-daily-orders-summary.query"), exports);
@@ -18,4 +18,7 @@ var ActionLogTypeEnum;
18
18
  ActionLogTypeEnum["DELETE_PREORDER"] = "DELETE_PREORDER";
19
19
  ActionLogTypeEnum["DELETE_PREORDER_ITEM"] = "DELETE_PREORDER_ITEM";
20
20
  ActionLogTypeEnum["UPDATE_PREORDER_ITEM"] = "UPDATE_PREORDER_ITEM";
21
+ ActionLogTypeEnum["UPDATE_CONSIGNMENT_ITEM"] = "UPDATE_CONSIGNMENT_ITEM";
22
+ ActionLogTypeEnum["CREATE_CONSIGNMENT_ITEMS"] = "CREATE_CONSIGNMENT_ITEMS";
23
+ ActionLogTypeEnum["DELETE_CONSIGNMENT_ITEMS"] = "DELETE_CONSIGNMENT_ITEMS";
21
24
  })(ActionLogTypeEnum || (exports.ActionLogTypeEnum = ActionLogTypeEnum = {}));
@@ -15,6 +15,9 @@ const pre_order_create_action_log_schema_1 = require("./pre-order-create-action-
15
15
  const pre_order_delete_action_log_schema_1 = require("./pre-order-delete-action-log.schema");
16
16
  const pre_order_product_update_action_log_schema_1 = require("./pre-order-product-update-action-log.schema");
17
17
  const pre_order_product_delete_action_log_schema_1 = require("./pre-order-product-delete-action-log.schema");
18
+ const consignment_product_update_action_log_schema_1 = require("./consignment-product-update-action-log.schema");
19
+ const consignment_items_create_action_log_schema_1 = require("./consignment-items-create-action-log.schema");
20
+ const consignment_items_delete_action_log_schema_1 = require("./consignment-items-delete-action-log.schema");
18
21
  exports.ActionLogPayloadSchema = zod_1.z.union([
19
22
  order_delete_action_log_payload_schema_1.OrderDeleteActionLogPayloadSchema,
20
23
  order_merge_action_log_schema_1.OrderMergeActionLogSchema,
@@ -29,5 +32,8 @@ exports.ActionLogPayloadSchema = zod_1.z.union([
29
32
  pre_order_delete_action_log_schema_1.PreOrderDeleteActionLogSchema,
30
33
  pre_order_product_update_action_log_schema_1.PreOrderProductUpdateActionLogSchema,
31
34
  pre_order_product_delete_action_log_schema_1.PreOrderProductDeleteActionLogSchema,
35
+ consignment_product_update_action_log_schema_1.ConsignmentProductUpdateActionLogSchema,
36
+ consignment_items_create_action_log_schema_1.ConsignmentItemsCreateActionLogSchema,
37
+ consignment_items_delete_action_log_schema_1.ConsignmentItemsDeleteActionLogSchema,
32
38
  zod_1.z.null(),
33
39
  ]);
@@ -17,6 +17,9 @@ const pre_order_create_action_log_schema_1 = require("./pre-order-create-action-
17
17
  const pre_order_delete_action_log_schema_1 = require("./pre-order-delete-action-log.schema");
18
18
  const pre_order_product_update_action_log_schema_1 = require("./pre-order-product-update-action-log.schema");
19
19
  const pre_order_product_delete_action_log_schema_1 = require("./pre-order-product-delete-action-log.schema");
20
+ const consignment_product_update_action_log_schema_1 = require("./consignment-product-update-action-log.schema");
21
+ const consignment_items_create_action_log_schema_1 = require("./consignment-items-create-action-log.schema");
22
+ const consignment_items_delete_action_log_schema_1 = require("./consignment-items-delete-action-log.schema");
20
23
  const BaseActionFields = zod_1.z.object({
21
24
  uuid: zod_1.z.string(),
22
25
  companyUUID: zod_1.z.string(),
@@ -115,6 +118,24 @@ exports.ActionLogSchema = zod_1.z.discriminatedUnion('actionType', [
115
118
  payload: zod_1.z.null(),
116
119
  })
117
120
  .merge(BaseActionFields),
121
+ zod_1.z
122
+ .object({
123
+ actionType: zod_1.z.literal(enum_1.ActionLogTypeEnum.UPDATE_CONSIGNMENT_ITEM),
124
+ payload: consignment_product_update_action_log_schema_1.ConsignmentProductUpdateActionLogSchema,
125
+ })
126
+ .merge(BaseActionFields),
127
+ zod_1.z
128
+ .object({
129
+ actionType: zod_1.z.literal(enum_1.ActionLogTypeEnum.CREATE_CONSIGNMENT_ITEMS),
130
+ payload: consignment_items_create_action_log_schema_1.ConsignmentItemsCreateActionLogSchema,
131
+ })
132
+ .merge(BaseActionFields),
133
+ zod_1.z
134
+ .object({
135
+ actionType: zod_1.z.literal(enum_1.ActionLogTypeEnum.DELETE_CONSIGNMENT_ITEMS),
136
+ payload: consignment_items_delete_action_log_schema_1.ConsignmentItemsDeleteActionLogSchema,
137
+ })
138
+ .merge(BaseActionFields),
118
139
  ]);
119
140
  exports.CreateActionLogSchema = zod_1.z.object({
120
141
  actionType: zod_1.z.nativeEnum(enum_1.ActionLogTypeEnum),
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsignmentItemsCreateActionLogSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ConsignmentItemBriefSchema = zod_1.z.object({
6
+ productUUID: zod_1.z.string(),
7
+ productName: zod_1.z.string(),
8
+ });
9
+ exports.ConsignmentItemsCreateActionLogSchema = zod_1.z.object({
10
+ consignmentUUID: zod_1.z.string(),
11
+ count: zod_1.z.coerce.number(),
12
+ products: zod_1.z.array(ConsignmentItemBriefSchema),
13
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsignmentItemsDeleteActionLogSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ConsignmentItemsDeleteActionLogSchema = zod_1.z.object({
6
+ consignmentUUID: zod_1.z.string(),
7
+ count: zod_1.z.coerce.number(),
8
+ });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsignmentProductInfoSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ConsignmentProductInfoSchema = zod_1.z.object({
6
+ consignmentUUID: zod_1.z.string(),
7
+ productUUID: zod_1.z.string(),
8
+ productName: zod_1.z.string(),
9
+ categoryName: zod_1.z.string().nullable(),
10
+ article: zod_1.z.string().nullable(),
11
+ });
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsignmentProductUpdateActionLogSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const consignment_product_info_schema_1 = require("./consignment-product-info.schema");
6
+ const ConsignmentProductChangeSchema = zod_1.z.object({
7
+ field: zod_1.z.string(),
8
+ oldValue: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.null()]),
9
+ newValue: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.null()]),
10
+ });
11
+ exports.ConsignmentProductUpdateActionLogSchema = zod_1.z.object({
12
+ product: consignment_product_info_schema_1.ConsignmentProductInfoSchema,
13
+ changes: zod_1.z.array(ConsignmentProductChangeSchema),
14
+ });
@@ -31,3 +31,7 @@ __exportStar(require("./pre-order-product-update-action-log.schema"), exports);
31
31
  __exportStar(require("./pre-order-product-delete-action-log.schema"), exports);
32
32
  __exportStar(require("./transaction-add-action-log.schema"), exports);
33
33
  __exportStar(require("./transaction-delete-action-log.schema"), exports);
34
+ __exportStar(require("./consignment-product-info.schema"), exports);
35
+ __exportStar(require("./consignment-product-update-action-log.schema"), exports);
36
+ __exportStar(require("./consignment-items-create-action-log.schema"), exports);
37
+ __exportStar(require("./consignment-items-delete-action-log.schema"), exports);
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ import { dateRangeCheck, isStatementPeriodWithinLimit } from '../../helpers/date.helper';
3
+
4
+ const GetDailyOrdersSummaryRequestSchema = z
5
+ .object({
6
+ startDate: z.coerce.date(),
7
+ endDate: z.coerce.date(),
8
+ })
9
+ .refine(value => dateRangeCheck(value.startDate, value.endDate), {
10
+ message: 'End date must be greater than start date',
11
+ path: ['endDate', 'startDate'],
12
+ })
13
+ .refine(value => isStatementPeriodWithinLimit(value.startDate, value.endDate), {
14
+ message: 'Report period must not exceed 1 year',
15
+ path: ['endDate', 'startDate'],
16
+ });
17
+
18
+ const UnitsByMeasureSchema = z.object({
19
+ PIECE: z.number(),
20
+ PACK: z.number(),
21
+ BOX: z.number(),
22
+ });
23
+
24
+ const metricsShape = {
25
+ ordersCreated: z.number(),
26
+ ordersCompleted: z.number(),
27
+ totalSum: z.number(),
28
+ unitsByMeasure: UnitsByMeasureSchema,
29
+ };
30
+
31
+ const DailyOrdersSummaryTotalsSchema = z.object({ ...metricsShape });
32
+
33
+ const DailyOrdersSummaryByDayItemSchema = z.object({
34
+ date: z.string(),
35
+ ...metricsShape,
36
+ });
37
+
38
+ const DailyOrdersSummaryByResponsibleItemSchema = z.object({
39
+ responsibleUserUUID: z.string().nullable(),
40
+ responsibleUserName: z.string().nullable(),
41
+ ...metricsShape,
42
+ });
43
+
44
+ const GetDailyOrdersSummaryResponseSchema = z.object({
45
+ data: z.object({
46
+ totals: DailyOrdersSummaryTotalsSchema,
47
+ byDay: z.array(DailyOrdersSummaryByDayItemSchema),
48
+ byResponsible: z.array(DailyOrdersSummaryByResponsibleItemSchema),
49
+ }),
50
+ });
51
+
52
+ export namespace GetDailyOrdersSummaryContractQuery {
53
+ export const RequestSchema = GetDailyOrdersSummaryRequestSchema;
54
+ export type Request = z.infer<typeof RequestSchema>;
55
+
56
+ export const ResponseSchema = GetDailyOrdersSummaryResponseSchema;
57
+ export type Response = z.infer<typeof ResponseSchema>;
58
+ }
@@ -10,3 +10,4 @@ export * from './export-inventory-movement.query';
10
10
  export * from './export-inventory-turnover.query';
11
11
  export * from './export-client-statement.query';
12
12
  export * from './get-report-by-client-weeks.query';
13
+ export * from './get-daily-orders-summary.query';
@@ -14,4 +14,7 @@ export enum ActionLogTypeEnum {
14
14
  DELETE_PREORDER = 'DELETE_PREORDER',
15
15
  DELETE_PREORDER_ITEM = 'DELETE_PREORDER_ITEM',
16
16
  UPDATE_PREORDER_ITEM = 'UPDATE_PREORDER_ITEM',
17
+ UPDATE_CONSIGNMENT_ITEM = 'UPDATE_CONSIGNMENT_ITEM',
18
+ CREATE_CONSIGNMENT_ITEMS = 'CREATE_CONSIGNMENT_ITEMS',
19
+ DELETE_CONSIGNMENT_ITEMS = 'DELETE_CONSIGNMENT_ITEMS',
17
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floristcloud/api-lib",
3
- "version": "1.2.79",
3
+ "version": "1.2.81",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -12,6 +12,9 @@ import { PreOrderCreateActionLogSchema } from './pre-order-create-action-log.sch
12
12
  import { PreOrderDeleteActionLogSchema } from './pre-order-delete-action-log.schema';
13
13
  import { PreOrderProductUpdateActionLogSchema } from './pre-order-product-update-action-log.schema';
14
14
  import { PreOrderProductDeleteActionLogSchema } from './pre-order-product-delete-action-log.schema';
15
+ import { ConsignmentProductUpdateActionLogSchema } from './consignment-product-update-action-log.schema';
16
+ import { ConsignmentItemsCreateActionLogSchema } from './consignment-items-create-action-log.schema';
17
+ import { ConsignmentItemsDeleteActionLogSchema } from './consignment-items-delete-action-log.schema';
15
18
 
16
19
  export const ActionLogPayloadSchema = z.union([
17
20
  OrderDeleteActionLogPayloadSchema,
@@ -27,5 +30,8 @@ export const ActionLogPayloadSchema = z.union([
27
30
  PreOrderDeleteActionLogSchema,
28
31
  PreOrderProductUpdateActionLogSchema,
29
32
  PreOrderProductDeleteActionLogSchema,
33
+ ConsignmentProductUpdateActionLogSchema,
34
+ ConsignmentItemsCreateActionLogSchema,
35
+ ConsignmentItemsDeleteActionLogSchema,
30
36
  z.null(),
31
37
  ]);
@@ -14,6 +14,9 @@ import { PreOrderCreateActionLogSchema } from './pre-order-create-action-log.sch
14
14
  import { PreOrderDeleteActionLogSchema } from './pre-order-delete-action-log.schema';
15
15
  import { PreOrderProductUpdateActionLogSchema } from './pre-order-product-update-action-log.schema';
16
16
  import { PreOrderProductDeleteActionLogSchema } from './pre-order-product-delete-action-log.schema';
17
+ import { ConsignmentProductUpdateActionLogSchema } from './consignment-product-update-action-log.schema';
18
+ import { ConsignmentItemsCreateActionLogSchema } from './consignment-items-create-action-log.schema';
19
+ import { ConsignmentItemsDeleteActionLogSchema } from './consignment-items-delete-action-log.schema';
17
20
 
18
21
  const BaseActionFields = z.object({
19
22
  uuid: z.string(),
@@ -114,6 +117,24 @@ export const ActionLogSchema = z.discriminatedUnion('actionType', [
114
117
  payload: z.null(),
115
118
  })
116
119
  .merge(BaseActionFields),
120
+ z
121
+ .object({
122
+ actionType: z.literal(ActionLogTypeEnum.UPDATE_CONSIGNMENT_ITEM),
123
+ payload: ConsignmentProductUpdateActionLogSchema,
124
+ })
125
+ .merge(BaseActionFields),
126
+ z
127
+ .object({
128
+ actionType: z.literal(ActionLogTypeEnum.CREATE_CONSIGNMENT_ITEMS),
129
+ payload: ConsignmentItemsCreateActionLogSchema,
130
+ })
131
+ .merge(BaseActionFields),
132
+ z
133
+ .object({
134
+ actionType: z.literal(ActionLogTypeEnum.DELETE_CONSIGNMENT_ITEMS),
135
+ payload: ConsignmentItemsDeleteActionLogSchema,
136
+ })
137
+ .merge(BaseActionFields),
117
138
  ]);
118
139
 
119
140
  export const CreateActionLogSchema = z.object({
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+
3
+ const ConsignmentItemBriefSchema = z.object({
4
+ productUUID: z.string(),
5
+ productName: z.string(),
6
+ });
7
+
8
+ export const ConsignmentItemsCreateActionLogSchema = z.object({
9
+ consignmentUUID: z.string(),
10
+ count: z.coerce.number(),
11
+ products: z.array(ConsignmentItemBriefSchema),
12
+ });
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+
3
+ export const ConsignmentItemsDeleteActionLogSchema = z.object({
4
+ consignmentUUID: z.string(),
5
+ count: z.coerce.number(),
6
+ });
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+
3
+ export const ConsignmentProductInfoSchema = z.object({
4
+ consignmentUUID: z.string(),
5
+ productUUID: z.string(),
6
+ productName: z.string(),
7
+ categoryName: z.string().nullable(),
8
+ article: z.string().nullable(),
9
+ });
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ import { ConsignmentProductInfoSchema } from './consignment-product-info.schema';
3
+
4
+ const ConsignmentProductChangeSchema = z.object({
5
+ field: z.string(),
6
+ oldValue: z.union([z.string(), z.number(), z.null()]),
7
+ newValue: z.union([z.string(), z.number(), z.null()]),
8
+ });
9
+
10
+ export const ConsignmentProductUpdateActionLogSchema = z.object({
11
+ product: ConsignmentProductInfoSchema,
12
+ changes: z.array(ConsignmentProductChangeSchema),
13
+ });
@@ -15,3 +15,7 @@ export * from './pre-order-product-update-action-log.schema';
15
15
  export * from './pre-order-product-delete-action-log.schema';
16
16
  export * from './transaction-add-action-log.schema';
17
17
  export * from './transaction-delete-action-log.schema';
18
+ export * from './consignment-product-info.schema';
19
+ export * from './consignment-product-update-action-log.schema';
20
+ export * from './consignment-items-create-action-log.schema';
21
+ export * from './consignment-items-delete-action-log.schema';