rerobe-js-orm 4.8.7 → 4.8.8

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.
@@ -75,6 +75,41 @@ export namespace UNIT_SYSTEM_TYPES {
75
75
  let metric: string;
76
76
  let imperial: string;
77
77
  }
78
+ export namespace LABEL_PRINTER_BARCODE_SYMBOLOGIES {
79
+ let code128: string;
80
+ let ean13: string;
81
+ }
82
+ export namespace LABEL_PRINTER_PROTOCOLS {
83
+ let zebraZpl: string;
84
+ }
85
+ export namespace DEFAULT_LABEL_LAYOUT {
86
+ let topElements: {
87
+ source: string;
88
+ visible: boolean;
89
+ fontSize: number;
90
+ paddingTop: number;
91
+ transform: string;
92
+ }[];
93
+ namespace barcode {
94
+ let visible: boolean;
95
+ let heightDots: number;
96
+ let moduleWidth: number;
97
+ let paddingBottom: number;
98
+ }
99
+ namespace sku {
100
+ let visible_1: boolean;
101
+ export { visible_1 as visible };
102
+ export let fontSize: number;
103
+ }
104
+ }
105
+ export namespace LABEL_PRINTER_CONFIG_DEFAULTS {
106
+ export let protocol: string;
107
+ export let widthMm: number;
108
+ export let heightMm: number;
109
+ export let dpi: number;
110
+ export let symbology: string;
111
+ export { DEFAULT_LABEL_LAYOUT as layout };
112
+ }
78
113
  export namespace METRIC_WEIGHT_TYPES {
79
114
  let kilogram: string;
80
115
  let gram: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AUTOMATED_PAYOUT_MONTH_DAYS = exports.AUTOMATED_PAYOUT_BUSINESS_DAYS = exports.AUTOMATED_PAYOUT_SCHEDULE = exports.SUBSCRIPTION_STATUSES = exports.RIBBN_WEBHOOK_EVENT_DICT = exports.IMPERIAL_WEIGHT_TYPES = exports.METRIC_WEIGHT_TYPES = exports.UNIT_SYSTEM_TYPES = exports.INDUSTRY_TYPE_OPTIONS = exports.INDUSTRY_TYPES = exports.PAYMENT_TIERS = exports.DEFAULT_MARKETPLACE_SELLER_CAPABILITIES = exports.MARKETPLACE_SELLER_CAPABILITIES = exports.MERCHANT_RELATIONSHIP_TYPES = exports.MERCHANT_ACCOUNT_CLASSES = exports.MERCHANT_ACCOUNT_MODES = exports.MERCHANT_TYPES = void 0;
3
+ exports.AUTOMATED_PAYOUT_MONTH_DAYS = exports.AUTOMATED_PAYOUT_BUSINESS_DAYS = exports.AUTOMATED_PAYOUT_SCHEDULE = exports.SUBSCRIPTION_STATUSES = exports.RIBBN_WEBHOOK_EVENT_DICT = exports.IMPERIAL_WEIGHT_TYPES = exports.METRIC_WEIGHT_TYPES = exports.LABEL_PRINTER_CONFIG_DEFAULTS = exports.DEFAULT_LABEL_LAYOUT = exports.LABEL_PRINTER_PROTOCOLS = exports.LABEL_PRINTER_BARCODE_SYMBOLOGIES = exports.UNIT_SYSTEM_TYPES = exports.INDUSTRY_TYPE_OPTIONS = exports.INDUSTRY_TYPES = exports.PAYMENT_TIERS = exports.DEFAULT_MARKETPLACE_SELLER_CAPABILITIES = exports.MARKETPLACE_SELLER_CAPABILITIES = exports.MERCHANT_RELATIONSHIP_TYPES = exports.MERCHANT_ACCOUNT_CLASSES = exports.MERCHANT_ACCOUNT_MODES = exports.MERCHANT_TYPES = void 0;
4
4
  exports.MERCHANT_TYPES = {
5
5
  individual: 'INDIVIDUAL',
6
6
  business: 'BUSINESS',
@@ -83,6 +83,40 @@ exports.UNIT_SYSTEM_TYPES = {
83
83
  metric: 'METRIC',
84
84
  imperial: 'IMPERIAL',
85
85
  };
86
+ // Label printer config controls how price-tag labels are rendered for both
87
+ // the marketplace merchant (channel partner) and any merchants they manage.
88
+ // Source of truth lives on the parent merchant doc; managed merchants read
89
+ // it via the `getMarketplaceParentLabelConfig` API. Connection to the
90
+ // physical printer is per-browser/per-device (WebUSB), not stored here.
91
+ exports.LABEL_PRINTER_BARCODE_SYMBOLOGIES = {
92
+ code128: 'CODE128',
93
+ ean13: 'EAN13',
94
+ };
95
+ exports.LABEL_PRINTER_PROTOCOLS = {
96
+ // ZPL is what the Zebra ZD421 family speaks. Future-proofed for additional
97
+ // protocols (e.g. Epson ePOS-Print) via the same setting shape.
98
+ zebraZpl: 'ZEBRA_ZPL',
99
+ };
100
+ // Sensible defaults sized for a standard 50x30 mm clothing price tag on a
101
+ // 203 dpi Zebra ZD421. Stored as plain numbers/strings so they survive
102
+ // Firestore round-trips without conversion.
103
+ exports.DEFAULT_LABEL_LAYOUT = {
104
+ topElements: [
105
+ { source: 'merchantName', visible: true, fontSize: 20, paddingTop: 0, transform: 'uppercase' },
106
+ { source: 'title', visible: true, fontSize: 18, paddingTop: 4, transform: 'none' },
107
+ { source: 'price', visible: true, fontSize: 30, paddingTop: 8, transform: 'none' },
108
+ ],
109
+ barcode: { visible: true, heightDots: 32, moduleWidth: 1, paddingBottom: 8 },
110
+ sku: { visible: true, fontSize: 14 },
111
+ };
112
+ exports.LABEL_PRINTER_CONFIG_DEFAULTS = {
113
+ protocol: 'ZEBRA_ZPL',
114
+ widthMm: 30,
115
+ heightMm: 20,
116
+ dpi: 203,
117
+ symbology: 'CODE128',
118
+ layout: exports.DEFAULT_LABEL_LAYOUT,
119
+ };
86
120
  exports.METRIC_WEIGHT_TYPES = {
87
121
  kilogram: 'KILOGRAM',
88
122
  gram: 'GRAM',
@@ -1,4 +1,35 @@
1
1
  import Base from '../Base';
2
+ export type LabelTextSource = 'merchantName' | 'title' | 'price';
3
+ export type LabelTextElement = {
4
+ source: LabelTextSource | string;
5
+ visible: boolean;
6
+ fontSize: number;
7
+ paddingTop: number;
8
+ transform: 'uppercase' | 'none' | string;
9
+ };
10
+ export type LabelBarcodeConfig = {
11
+ visible: boolean;
12
+ heightDots: number;
13
+ moduleWidth: 1 | 2;
14
+ paddingBottom: number;
15
+ };
16
+ export type LabelSkuConfig = {
17
+ visible: boolean;
18
+ fontSize: number;
19
+ };
20
+ export type LabelLayout = {
21
+ topElements: LabelTextElement[];
22
+ barcode: LabelBarcodeConfig;
23
+ sku: LabelSkuConfig;
24
+ };
25
+ export type LabelPrinterConfig = {
26
+ protocol: string;
27
+ widthMm: number;
28
+ heightMm: number;
29
+ dpi: number;
30
+ symbology: string;
31
+ layout: LabelLayout;
32
+ };
2
33
  export default class Merchant extends Base {
3
34
  static MERCHANT_TYPES: {
4
35
  individual: string;
@@ -46,6 +77,58 @@ export default class Merchant extends Base {
46
77
  upgradeToStandalone: string;
47
78
  };
48
79
  static DEFAULT_MARKETPLACE_SELLER_CAPABILITIES: string[];
80
+ static LABEL_PRINTER_BARCODE_SYMBOLOGIES: {
81
+ code128: string;
82
+ ean13: string;
83
+ };
84
+ static LABEL_PRINTER_PROTOCOLS: {
85
+ zebraZpl: string;
86
+ };
87
+ static LABEL_PRINTER_CONFIG_DEFAULTS: {
88
+ protocol: string;
89
+ widthMm: number;
90
+ heightMm: number;
91
+ dpi: number;
92
+ symbology: string;
93
+ layout: {
94
+ topElements: {
95
+ source: string;
96
+ visible: boolean;
97
+ fontSize: number;
98
+ paddingTop: number;
99
+ transform: string;
100
+ }[];
101
+ barcode: {
102
+ visible: boolean;
103
+ heightDots: number;
104
+ moduleWidth: number;
105
+ paddingBottom: number;
106
+ };
107
+ sku: {
108
+ visible: boolean;
109
+ fontSize: number;
110
+ };
111
+ };
112
+ };
113
+ static DEFAULT_LABEL_LAYOUT: {
114
+ topElements: {
115
+ source: string;
116
+ visible: boolean;
117
+ fontSize: number;
118
+ paddingTop: number;
119
+ transform: string;
120
+ }[];
121
+ barcode: {
122
+ visible: boolean;
123
+ heightDots: number;
124
+ moduleWidth: number;
125
+ paddingBottom: number;
126
+ };
127
+ sku: {
128
+ visible: boolean;
129
+ fontSize: number;
130
+ };
131
+ };
49
132
  static INDUSTRY_TYPES: {
50
133
  beauty: string;
51
134
  clothing: string;
@@ -112,6 +195,8 @@ export default class Merchant extends Base {
112
195
  hasAutomatedPayouts?: boolean;
113
196
  hasAIQuickList?: boolean;
114
197
  hasReceiptPrinter?: boolean;
198
+ hasLabelPrinter?: boolean;
199
+ labelPrinterConfig?: LabelPrinterConfig;
115
200
  hasActiveWebshop?: boolean;
116
201
  stripeSubscription?: StripeSubscription;
117
202
  subscriptionStatus?: string;
@@ -124,6 +209,7 @@ export default class Merchant extends Base {
124
209
  featureAccess?: MerchantFeatureAccess | null;
125
210
  isMarketplaceSeller?: boolean;
126
211
  constructor(props?: any);
212
+ static normalizeLabelPrinterConfig(input?: Partial<LabelPrinterConfig> | Record<string, any> | null): LabelPrinterConfig;
127
213
  toObj(): MerchantObj;
128
214
  toMerchantMutableData(): MerchantMutableData;
129
215
  isManagedMarketplaceMerchant(): boolean;
@@ -90,6 +90,82 @@ class Merchant extends Base_1.default {
90
90
  if (props === null || props === void 0 ? void 0 : props.hasReceiptPrinter) {
91
91
  this.hasReceiptPrinter = props.hasReceiptPrinter;
92
92
  }
93
+ if (props === null || props === void 0 ? void 0 : props.hasLabelPrinter) {
94
+ this.hasLabelPrinter = props.hasLabelPrinter;
95
+ }
96
+ if ((props === null || props === void 0 ? void 0 : props.labelPrinterConfig) && typeof props.labelPrinterConfig === 'object') {
97
+ this.labelPrinterConfig = Merchant.normalizeLabelPrinterConfig(props.labelPrinterConfig);
98
+ }
99
+ }
100
+ // Coerce arbitrary input into a fully-populated, type-safe LabelPrinterConfig
101
+ // by layering it over the defaults. Migrates legacy `showFields` shapes
102
+ // into the new `layout` schema so older stored configs keep working.
103
+ static normalizeLabelPrinterConfig(input) {
104
+ const defaults = Merchant.LABEL_PRINTER_CONFIG_DEFAULTS;
105
+ const raw = (input || {});
106
+ const protocol = typeof raw.protocol === 'string' && raw.protocol ? raw.protocol : defaults.protocol;
107
+ const symbology = typeof raw.symbology === 'string' && raw.symbology ? raw.symbology : defaults.symbology;
108
+ const layout = (() => {
109
+ const fallback = defaults.layout;
110
+ const rawLayout = raw.layout && typeof raw.layout === 'object' ? raw.layout : null;
111
+ const legacyShowFields = raw.showFields && typeof raw.showFields === 'object' ? raw.showFields : null;
112
+ if (!rawLayout && legacyShowFields) {
113
+ return {
114
+ topElements: fallback.topElements.map((el) => (Object.assign(Object.assign({}, el), { visible: legacyShowFields[el.source] !== false }))),
115
+ barcode: Object.assign({}, fallback.barcode),
116
+ sku: Object.assign(Object.assign({}, fallback.sku), { visible: legacyShowFields.sku !== false }),
117
+ };
118
+ }
119
+ if (!rawLayout) {
120
+ return {
121
+ topElements: fallback.topElements.map((el) => (Object.assign({}, el))),
122
+ barcode: Object.assign({}, fallback.barcode),
123
+ sku: Object.assign({}, fallback.sku),
124
+ };
125
+ }
126
+ const rawTop = Array.isArray(rawLayout.topElements) ? rawLayout.topElements : [];
127
+ const topElements = rawTop
128
+ .map((entry, index) => {
129
+ if (!entry || typeof entry !== 'object')
130
+ return null;
131
+ const fb = fallback.topElements.find((e) => e.source === entry.source) ||
132
+ fallback.topElements[index] ||
133
+ fallback.topElements[0];
134
+ return {
135
+ source: typeof entry.source === 'string' ? entry.source : fb.source,
136
+ visible: typeof entry.visible === 'boolean' ? entry.visible : fb.visible,
137
+ fontSize: Number(entry.fontSize) > 0 ? Number(entry.fontSize) : fb.fontSize,
138
+ paddingTop: Number(entry.paddingTop) >= 0 ? Number(entry.paddingTop) : fb.paddingTop,
139
+ transform: entry.transform === 'uppercase' || entry.transform === 'none' ? entry.transform : fb.transform,
140
+ };
141
+ })
142
+ .filter(Boolean);
143
+ const rawBarcode = (rawLayout.barcode || {});
144
+ const barcode = {
145
+ visible: typeof rawBarcode.visible === 'boolean' ? rawBarcode.visible : fallback.barcode.visible,
146
+ heightDots: Number(rawBarcode.heightDots) > 0 ? Number(rawBarcode.heightDots) : fallback.barcode.heightDots,
147
+ moduleWidth: rawBarcode.moduleWidth === 2 ? 2 : 1,
148
+ paddingBottom: Number(rawBarcode.paddingBottom) >= 0 ? Number(rawBarcode.paddingBottom) : fallback.barcode.paddingBottom,
149
+ };
150
+ const rawSku = (rawLayout.sku || {});
151
+ const sku = {
152
+ visible: typeof rawSku.visible === 'boolean' ? rawSku.visible : fallback.sku.visible,
153
+ fontSize: Number(rawSku.fontSize) > 0 ? Number(rawSku.fontSize) : fallback.sku.fontSize,
154
+ };
155
+ return {
156
+ topElements: topElements.length > 0 ? topElements : fallback.topElements.map((el) => (Object.assign({}, el))),
157
+ barcode,
158
+ sku,
159
+ };
160
+ })();
161
+ return {
162
+ protocol,
163
+ widthMm: Number(raw.widthMm) > 0 ? Number(raw.widthMm) : defaults.widthMm,
164
+ heightMm: Number(raw.heightMm) > 0 ? Number(raw.heightMm) : defaults.heightMm,
165
+ dpi: Number(raw.dpi) > 0 ? Number(raw.dpi) : defaults.dpi,
166
+ symbology,
167
+ layout,
168
+ };
93
169
  }
94
170
  toObj() {
95
171
  const mObj = {
@@ -166,6 +242,12 @@ class Merchant extends Base_1.default {
166
242
  if (this.hasReceiptPrinter) {
167
243
  mObj.hasReceiptPrinter = this.hasReceiptPrinter;
168
244
  }
245
+ if (this.hasLabelPrinter) {
246
+ mObj.hasLabelPrinter = this.hasLabelPrinter;
247
+ }
248
+ if (this.labelPrinterConfig) {
249
+ mObj.labelPrinterConfig = this.labelPrinterConfig;
250
+ }
169
251
  if (this.organizationNumbers && Object.keys(this.organizationNumbers).length > 0) {
170
252
  mObj.organizationNumbers = this.organizationNumbers;
171
253
  }
@@ -222,6 +304,10 @@ Merchant.MERCHANT_ACCOUNT_CLASSES = merchant_constants_1.MERCHANT_ACCOUNT_CLASSE
222
304
  Merchant.MERCHANT_RELATIONSHIP_TYPES = merchant_constants_1.MERCHANT_RELATIONSHIP_TYPES;
223
305
  Merchant.MARKETPLACE_SELLER_CAPABILITIES = merchant_constants_1.MARKETPLACE_SELLER_CAPABILITIES;
224
306
  Merchant.DEFAULT_MARKETPLACE_SELLER_CAPABILITIES = merchant_constants_1.DEFAULT_MARKETPLACE_SELLER_CAPABILITIES;
307
+ Merchant.LABEL_PRINTER_BARCODE_SYMBOLOGIES = merchant_constants_1.LABEL_PRINTER_BARCODE_SYMBOLOGIES;
308
+ Merchant.LABEL_PRINTER_PROTOCOLS = merchant_constants_1.LABEL_PRINTER_PROTOCOLS;
309
+ Merchant.LABEL_PRINTER_CONFIG_DEFAULTS = merchant_constants_1.LABEL_PRINTER_CONFIG_DEFAULTS;
310
+ Merchant.DEFAULT_LABEL_LAYOUT = merchant_constants_1.DEFAULT_LABEL_LAYOUT;
225
311
  Merchant.INDUSTRY_TYPES = merchant_constants_1.INDUSTRY_TYPES;
226
312
  Merchant.UNIT_SYSTEM_TYPES = merchant_constants_1.UNIT_SYSTEM_TYPES;
227
313
  Merchant.METRIC_WEIGHT_TYPES = merchant_constants_1.METRIC_WEIGHT_TYPES;
@@ -1072,6 +1072,17 @@ class Product extends Base_1.default {
1072
1072
  name: 'sku',
1073
1073
  type: 'string',
1074
1074
  },
1075
+ {
1076
+ // Flat array of every non-empty `variantInventory[].sku` so a
1077
+ // scanner / search bar can resolve a variant-level barcode to
1078
+ // the parent product. Maintained by the onWriteProduct trigger
1079
+ // (projection of variantInventory.sku → variantSkus). Empty
1080
+ // array for single-SKU products.
1081
+ facet: true,
1082
+ optional: true,
1083
+ name: 'variantSkus',
1084
+ type: 'string[]',
1085
+ },
1075
1086
  {
1076
1087
  facet: true,
1077
1088
  optional: true,
@@ -52,11 +52,39 @@ type MerchantSystemOnlyMutableData = {
52
52
  hasAutomatedPayouts?: boolean;
53
53
  hasAIQuickList?: boolean;
54
54
  hasReceiptPrinter?: boolean;
55
+ hasLabelPrinter?: boolean;
56
+ labelPrinterConfig?: LabelPrinterConfigData;
55
57
  hasActiveWebshop?: boolean;
56
58
  subscriptionStatus?: string;
57
59
  channelPartners?: string[];
58
60
  isMarketplaceSeller?: boolean;
59
61
  };
62
+ type LabelPrinterConfigData = {
63
+ protocol: string;
64
+ widthMm: number;
65
+ heightMm: number;
66
+ dpi: number;
67
+ symbology: string;
68
+ layout: {
69
+ topElements: {
70
+ source: string;
71
+ visible: boolean;
72
+ fontSize: number;
73
+ paddingTop: number;
74
+ transform: string;
75
+ }[];
76
+ barcode: {
77
+ visible: boolean;
78
+ heightDots: number;
79
+ moduleWidth: 1 | 2;
80
+ paddingBottom: number;
81
+ };
82
+ sku: {
83
+ visible: boolean;
84
+ fontSize: number;
85
+ };
86
+ };
87
+ };
60
88
  type MerchantObj = MerchantMutableData & MerchantSystemOnlyMutableData;
61
89
  type MerchantTypes = 'INDIVIDUAL' | 'BUSINESS';
62
90
  type MerchantAccountMode = 'STANDALONE' | 'MANAGED';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.8.7",
3
+ "version": "4.8.8",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",