@managesome/eposmatic-toolkit 0.2.359 → 0.2.361

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.
@@ -48,6 +48,8 @@ function getReceiptTypes(value) {
48
48
  const validReceiptTypes = new Set(constants_1.ALL_RECEIPT_TYPES);
49
49
  if (!Array.isArray(value))
50
50
  return [...constants_1.ALL_RECEIPT_TYPES];
51
+ if (value.length === 0)
52
+ return [];
51
53
  const receiptTypes = Array.from(new Set(value.filter((receiptType) => typeof receiptType === 'string' && validReceiptTypes.has(receiptType))));
52
54
  return receiptTypes.length > 0 ? receiptTypes : [...constants_1.ALL_RECEIPT_TYPES];
53
55
  }
@@ -58,6 +60,15 @@ function getInterfaceType(value) {
58
60
  }
59
61
  return constants_1.PRINTER_INTERFACE_ENUM.LAN;
60
62
  }
63
+ function getBrandType(value) {
64
+ if (value === null)
65
+ return null;
66
+ const validBrandTypes = new Set(constants_1.ALL_PRINTER_BRAND_TYPES);
67
+ if (typeof value === 'string' && validBrandTypes.has(value)) {
68
+ return value;
69
+ }
70
+ return null;
71
+ }
61
72
  function getPrintingPreference(value) {
62
73
  const validPreferences = new Set(constants_1.ALL_PRINTING_PREFERENCES);
63
74
  if (typeof value === 'string' && validPreferences.has(value)) {
@@ -84,6 +95,8 @@ function getSelectedPlatforms(value) {
84
95
  const validPlatforms = new Set(constants_1.ALL_PLATFORMS);
85
96
  if (!Array.isArray(value))
86
97
  return [...constants_1.ALL_PLATFORMS];
98
+ if (value.length === 0)
99
+ return [];
87
100
  const selectedPlatforms = Array.from(new Set(value.filter((platform) => typeof platform === 'string' && validPlatforms.has(platform))));
88
101
  return selectedPlatforms.length > 0 ? selectedPlatforms : [...constants_1.ALL_PLATFORMS];
89
102
  }
@@ -215,6 +228,7 @@ function syncPrinterSettingsFields(printerSettings) {
215
228
  tenant_id: getStringValue(settings.tenant_id, ''),
216
229
  target: getStringValue(settings.target, ''),
217
230
  mac_address: getNullableStringValue(settings.mac_address, null),
231
+ brand_type: getBrandType(settings.brand_type),
218
232
  interface_type: getInterfaceType(settings.interface_type),
219
233
  name: getStringValue(settings.name, ''),
220
234
  staff_id: getStringValue(settings.staff_id, ''),
@@ -65,6 +65,7 @@ export declare const PrinterSettingsSchema: Schema<any, import("mongoose").Model
65
65
  } | null | undefined;
66
66
  } | null | undefined;
67
67
  mac_address?: string | null | undefined;
68
+ brand_type?: import("../../constants").PRINTER_BRAND_TYPE_ENUM | null | undefined;
68
69
  backup_printer_target?: string | null | undefined;
69
70
  boolSettings?: {
70
71
  isActive: boolean;
@@ -134,6 +135,7 @@ export declare const PrinterSettingsSchema: Schema<any, import("mongoose").Model
134
135
  } | null | undefined;
135
136
  } | null | undefined;
136
137
  mac_address?: string | null | undefined;
138
+ brand_type?: import("../../constants").PRINTER_BRAND_TYPE_ENUM | null | undefined;
137
139
  backup_printer_target?: string | null | undefined;
138
140
  boolSettings?: {
139
141
  isActive: boolean;
@@ -203,6 +205,7 @@ export declare const PrinterSettingsSchema: Schema<any, import("mongoose").Model
203
205
  } | null | undefined;
204
206
  } | null | undefined;
205
207
  mac_address?: string | null | undefined;
208
+ brand_type?: import("../../constants").PRINTER_BRAND_TYPE_ENUM | null | undefined;
206
209
  backup_printer_target?: string | null | undefined;
207
210
  boolSettings?: {
208
211
  isActive: boolean;
@@ -23,6 +23,11 @@ exports.PrinterSettingsSchema = new mongoose_1.Schema({
23
23
  type: String,
24
24
  required: false,
25
25
  },
26
+ brand_type: {
27
+ type: String,
28
+ enum: [...constants_1.ALL_PRINTER_BRAND_TYPES, null],
29
+ required: false,
30
+ },
26
31
  interface_type: {
27
32
  type: String,
28
33
  enum: constants_1.ALL_PRINTER_INTERFACES,
@@ -1,4 +1,4 @@
1
- import { KITCHEN_DOCKET_FONT_TYPE_ENUM, ORDER_TYPE_ENUM, PLATFORMS_ENUM, PRINTER_INTERFACE_ENUM, PRINTING_PREFERENCE_ENUM, RECEIPT_TYPE_ENUM } from '../../constants';
1
+ import { KITCHEN_DOCKET_FONT_TYPE_ENUM, ORDER_TYPE_ENUM, PLATFORMS_ENUM, PRINTER_BRAND_TYPE_ENUM, PRINTER_INTERFACE_ENUM, PRINTING_PREFERENCE_ENUM, RECEIPT_TYPE_ENUM } from '../../constants';
2
2
  export interface IIncludedItemsMap {
3
3
  [key: string]: {
4
4
  sortId: number;
@@ -53,6 +53,7 @@ export interface IPrinterSettings {
53
53
  tenant_id: string;
54
54
  target: string;
55
55
  mac_address?: string | null;
56
+ brand_type?: PRINTER_BRAND_TYPE_ENUM | null;
56
57
  interface_type: PRINTER_INTERFACE_ENUM;
57
58
  name: string;
58
59
  staff_id: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../constants");
4
+ const printer_helpers_1 = require("../helpers/utils/printer-helpers");
5
+ describe('syncPrinterSettingsFields receiptTypes', () => {
6
+ it('preserves explicit empty receiptTypes arrays', () => {
7
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
8
+ receiptTypes: [],
9
+ });
10
+ expect(result.receiptTypes).toEqual([]);
11
+ });
12
+ it('falls back to all receiptTypes when input is not an array', () => {
13
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
14
+ receiptTypes: 'invalid',
15
+ });
16
+ expect(result.receiptTypes).toEqual(constants_1.ALL_RECEIPT_TYPES);
17
+ });
18
+ it('falls back to all receiptTypes when array has only invalid values', () => {
19
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
20
+ receiptTypes: ['invalid'],
21
+ });
22
+ expect(result.receiptTypes).toEqual(constants_1.ALL_RECEIPT_TYPES);
23
+ });
24
+ it('keeps only valid deduplicated receiptTypes', () => {
25
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
26
+ receiptTypes: [constants_1.RECEIPT_TYPE_ENUM.CUSTOMER, 'invalid', constants_1.RECEIPT_TYPE_ENUM.CUSTOMER],
27
+ });
28
+ expect(result.receiptTypes).toEqual([constants_1.RECEIPT_TYPE_ENUM.CUSTOMER]);
29
+ });
30
+ });
31
+ describe('syncPrinterSettingsFields selectedPlatforms', () => {
32
+ it('preserves explicit empty selectedPlatforms arrays', () => {
33
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
34
+ [constants_1.RECEIPT_TYPE_ENUM.KITCHEN]: {
35
+ selectedPlatforms: [],
36
+ },
37
+ [constants_1.RECEIPT_TYPE_ENUM.CUSTOMER]: {
38
+ selectedPlatforms: [],
39
+ },
40
+ });
41
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.KITCHEN].selectedPlatforms).toEqual([]);
42
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.CUSTOMER].selectedPlatforms).toEqual([]);
43
+ });
44
+ it('falls back to all selectedPlatforms when array has only invalid values', () => {
45
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
46
+ [constants_1.RECEIPT_TYPE_ENUM.KITCHEN]: {
47
+ selectedPlatforms: ['invalid'],
48
+ },
49
+ [constants_1.RECEIPT_TYPE_ENUM.CUSTOMER]: {
50
+ selectedPlatforms: ['invalid'],
51
+ },
52
+ });
53
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.KITCHEN].selectedPlatforms).toEqual(constants_1.ALL_PLATFORMS);
54
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.CUSTOMER].selectedPlatforms).toEqual(constants_1.ALL_PLATFORMS);
55
+ });
56
+ it('keeps only valid deduplicated selectedPlatforms', () => {
57
+ const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
58
+ [constants_1.RECEIPT_TYPE_ENUM.KITCHEN]: {
59
+ selectedPlatforms: [constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY, 'invalid', constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY],
60
+ },
61
+ });
62
+ expect(result[constants_1.RECEIPT_TYPE_ENUM.KITCHEN].selectedPlatforms).toEqual([constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY]);
63
+ });
64
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.359",
3
+ "version": "0.2.361",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",