@shushed/helpers 0.0.218 → 0.0.220

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.
@@ -39,96 +39,81 @@
39
39
  "sitoo"
40
40
  ]
41
41
  },
42
- "history": {
43
- "type": "array",
44
- "items": {
45
- "type": "object",
46
- "properties": {
47
- "quantity": {
48
- "type": "integer",
49
- "minimum": 0,
50
- "description": "Quantity of stock available on hand"
51
- },
52
- "description": {
53
- "type": "string"
54
- },
55
- "entry_no": {
56
- "type": "string",
57
- "description": "BC Entry no. Should be empty for other systems"
58
- },
59
- "external_entry_no": {
60
- "type": "string",
61
- "description": "External Entry no. Might be empty for other systems"
62
- },
63
- "document_no": {
64
- "type": "string",
65
- "description": "BC Document no. Should be empty for other systems"
66
- },
67
- "external_document_no": {
68
- "type": "string",
69
- "description": "Original document i.e. Sitoo ID that caused the change"
70
- },
71
- "type": {
72
- "type": "string",
73
- "enum": [
74
- "transfer",
75
- "negative adjustment",
76
- "positive adjustment",
77
- "purchase",
78
- "sale"
79
- ]
80
- },
81
- "unit_cost": {
82
- "oneOf": [
83
- {
84
- "$ref": "https://shushed.example.com/money.schema.json"
85
- },
86
- {
87
- "type": "null"
88
- }
89
- ],
90
- "description": "Cost per unit, can be null"
91
- },
92
- "document_date": {
93
- "type": "string",
94
- "format": "date",
95
- "description": "Date of the creation of the document. Preferably creation time of the item ledger entry",
96
- "faker": {
97
- "date.between": [
98
- "2024-01-01",
99
- "2025-04-30"
100
- ]
101
- }
102
- },
103
- "posting_date": {
104
- "type": "string",
105
- "format": "date",
106
- "description": "Date of posting the record in BC. This should be empty for non-BC systems. Preferably creation time of the item ledger entry",
107
- "faker": {
108
- "date.between": [
109
- "2024-01-01",
110
- "2025-04-30"
111
- ]
112
- }
113
- },
114
- "created_at": {
115
- "type": "string",
116
- "format": "date-time",
117
- "description": "Date time of the creation of the record. Preferably creation time of the item ledger entry",
118
- "faker": {
119
- "date.between": [
120
- "2024-01-01T00:00:00.000Z",
121
- "2025-04-30T00:00:00.000Z"
122
- ]
123
- }
124
- }
42
+ "quantity": {
43
+ "type": "integer",
44
+ "minimum": 0,
45
+ "description": "Quantity of stock available on hand"
46
+ },
47
+ "description": {
48
+ "type": "string"
49
+ },
50
+ "entry_no": {
51
+ "type": "string",
52
+ "description": "BC Entry no. Should be empty for other systems"
53
+ },
54
+ "external_entry_no": {
55
+ "type": "string",
56
+ "description": "External Entry no. Might be empty for other systems"
57
+ },
58
+ "document_no": {
59
+ "type": "string",
60
+ "description": "BC Document no. Should be empty for other systems"
61
+ },
62
+ "external_document_no": {
63
+ "type": "string",
64
+ "description": "Original document i.e. Sitoo ID that caused the change"
65
+ },
66
+ "type": {
67
+ "type": "string",
68
+ "enum": [
69
+ "transfer",
70
+ "negative adjustment",
71
+ "positive adjustment",
72
+ "purchase",
73
+ "sale"
74
+ ]
75
+ },
76
+ "unit_cost": {
77
+ "oneOf": [
78
+ {
79
+ "$ref": "https://shushed.example.com/money.schema.json"
125
80
  },
126
- "required": [
127
- "quantity",
128
- "created_at",
129
- "entry_no",
130
- "document_date",
131
- "type"
81
+ {
82
+ "type": "null"
83
+ }
84
+ ],
85
+ "description": "Cost per unit, can be null"
86
+ },
87
+ "document_date": {
88
+ "type": "string",
89
+ "format": "date",
90
+ "description": "Date of the creation of the document. Preferably creation time of the item ledger entry",
91
+ "faker": {
92
+ "date.between": [
93
+ "2024-01-01",
94
+ "2025-04-30"
95
+ ]
96
+ }
97
+ },
98
+ "posting_date": {
99
+ "type": "string",
100
+ "format": "date",
101
+ "description": "Date of posting the record in BC. This should be empty for non-BC systems. Preferably creation time of the item ledger entry",
102
+ "faker": {
103
+ "date.between": [
104
+ "2024-01-01",
105
+ "2025-04-30"
106
+ ]
107
+ }
108
+ },
109
+ "created_at": {
110
+ "type": "string",
111
+ "format": "date-time",
112
+ "description": "Date time of the creation of the record. Preferably creation time of the item ledger entry",
113
+ "faker": {
114
+ "date.between": [
115
+ "2024-01-01T00:00:00.000Z",
116
+ "2025-04-30T00:00:00.000Z"
132
117
  ]
133
118
  }
134
119
  },
@@ -150,8 +135,10 @@
150
135
  "location_code",
151
136
  "colour_id",
152
137
  "size_code",
153
- "history",
154
- "entry_no",
155
- "last_modified_at"
138
+ "last_modified_at",
139
+ "quantity",
140
+ "created_at",
141
+ "document_date",
142
+ "type"
156
143
  ]
157
144
  }
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Stock Movement Schema", "type": "object", "additionalProperties": false, "properties": { "style_id": { "type": "string", "minLength": 1 }, "colour_id": { "type": "string", "minLength": 1 }, "size_code": { "type": "string", "minLength": 1 }, "location_code": { "type": "string", "pattern": "^\\d{3}-[A-Z]+$|^[A-Z]{2,}-?[A-Z]*$|^[A-Z]{2,}\\d{3}$" }, "source_system": { "type": "string", "enum": ["bc", "centra", "sitoo"] }, "history": { "type": "array", "items": { "type": "object", "properties": { "quantity": { "type": "integer", "minimum": 0 }, "entry_no": { "type": "string" }, "external_entry_no": { "type": "string" }, "document_no": { "type": "string" }, "external_document_no": { "type": "string" }, "type": { "type": "string", "enum": ["transfer", "negative adjustment", "positive adjustment", "purchase", "sale"] }, "unit_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "type": "object", "additionalProperties": false, "properties": { "value": { "type": "integer", "minimum": 0 }, "decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 }, "currency": { "title": "Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_value": { "type": "integer", "minimum": 0 }, "lcy_currency": { "title": "LCY Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 } }, "required": ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"] }, { "type": "null" }] }, "document_date": { "type": "string", "format": "date" }, "posting_date": { "type": "string", "format": "date" }, "created_at": { "type": "string", "format": "date-time" } }, "required": ["quantity", "created_at", "entry_no", "document_date", "type"] } }, "last_modified_at": { "type": "string", "format": "date-time" } }, "required": ["style_id", "source_system", "location_code", "colour_id", "size_code", "history", "entry_no", "last_modified_at"], "$id": "https://shushed.example.com/stock-move.schema.json" };
3
+ const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Stock Movement Schema", "type": "object", "additionalProperties": false, "properties": { "style_id": { "type": "string", "minLength": 1 }, "colour_id": { "type": "string", "minLength": 1 }, "size_code": { "type": "string", "minLength": 1 }, "location_code": { "type": "string", "pattern": "^\\d{3}-[A-Z]+$|^[A-Z]{2,}-?[A-Z]*$|^[A-Z]{2,}\\d{3}$" }, "source_system": { "type": "string", "enum": ["bc", "centra", "sitoo"] }, "quantity": { "type": "integer", "minimum": 0 }, "entry_no": { "type": "string" }, "external_entry_no": { "type": "string" }, "document_no": { "type": "string" }, "external_document_no": { "type": "string" }, "type": { "type": "string", "enum": ["transfer", "negative adjustment", "positive adjustment", "purchase", "sale"] }, "unit_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "type": "object", "additionalProperties": false, "properties": { "value": { "type": "integer", "minimum": 0 }, "decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 }, "currency": { "title": "Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_value": { "type": "integer", "minimum": 0 }, "lcy_currency": { "title": "LCY Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 } }, "required": ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"] }, { "type": "null" }] }, "document_date": { "type": "string", "format": "date" }, "posting_date": { "type": "string", "format": "date" }, "created_at": { "type": "string", "format": "date-time" }, "last_modified_at": { "type": "string", "format": "date-time" } }, "required": ["style_id", "source_system", "location_code", "colour_id", "size_code", "last_modified_at", "quantity", "created_at", "document_date", "type"], "$id": "https://shushed.example.com/stock-move.schema.json" };
4
4
  exports.default = schema;
@@ -99,6 +99,12 @@ class CentraHelper extends env_1.default {
99
99
  getCacheKeyForMarket(marketExternalId) {
100
100
  return `${this.getCacheKeyForMarkets()}_${marketExternalId}`;
101
101
  }
102
+ getCacheKeyForCampaigns() {
103
+ return `centra_${this.shaToken}_campaign_name`;
104
+ }
105
+ getCacheKeyForCampaign(campaignName) {
106
+ return `${this.getCacheKeyForCampaigns()}_${campaignName}`;
107
+ }
102
108
  getCacheKeyForSizeCharts() {
103
109
  return `centra_${this.shaToken}_size_chart_external_id`;
104
110
  }
@@ -218,7 +224,7 @@ class CentraHelper extends env_1.default {
218
224
  return result;
219
225
  }
220
226
  async fetchCentraCampaigns(names) {
221
- const limit = (names?.length || 0) > 200 ? 200 : (names?.length || 0);
227
+ const limit = names ? (names.length > 200 ? 200 : names.length) : 200;
222
228
  let nextCursor = null;
223
229
  const result = {};
224
230
  do {
@@ -799,6 +805,49 @@ class CentraHelper extends env_1.default {
799
805
  }
800
806
  return Object.assign({}, pricelistInCache, pricelistToSet);
801
807
  }
808
+ async getCentraCampaigns(alwaysFetch = false) {
809
+ let campaignInCache = {};
810
+ let dedupedCampaignNamesInCache = [];
811
+ let campaignsToFetch = null;
812
+ if (!alwaysFetch) {
813
+ const campaignNamesInCache = await (this.get(this.getCacheKeyForCampaigns(), 'env', {
814
+ isEphemeral: true,
815
+ encrypted: false,
816
+ }).then(x => x ? JSON.parse(x) : null));
817
+ if (campaignNamesInCache) {
818
+ dedupedCampaignNamesInCache = campaignNamesInCache.filter((x, index, self) => self.indexOf(x) === index);
819
+ campaignInCache = Object.fromEntries(Object.entries(await this.get(dedupedCampaignNamesInCache.map((x) => this.getCacheKeyForCampaign(x)), 'env', {
820
+ isEphemeral: true,
821
+ encrypted: false,
822
+ })).map(([key, value]) => [key, value ? JSON.parse(value || 'null') : undefined]).filter(([_, value]) => value));
823
+ campaignsToFetch = dedupedCampaignNamesInCache.filter(x => !campaignInCache[x]);
824
+ }
825
+ }
826
+ const campaignToSet = {};
827
+ if (!campaignsToFetch || campaignsToFetch.length) {
828
+ const campaigns = await this.fetchCentraCampaigns();
829
+ if (CentraHelper.isCentraErrors(campaigns)) {
830
+ return new Error(`Failed to fetch campaigns: ${campaigns.errors.map((x) => x.message).join(', ')}`);
831
+ }
832
+ else {
833
+ for (const campaign of Object.values(campaigns)) {
834
+ campaignToSet[campaign.name] = campaign;
835
+ }
836
+ await this.set(Object.entries(campaignToSet).filter(([_, value]) => !(value instanceof Error)).map(([key, value]) => ({ name: this.getCacheKeyForCampaign(key), value: JSON.stringify(value) })), 'env', {
837
+ ephemeralMs: CACHE_EXPIRATION_MS,
838
+ encrypted: false,
839
+ });
840
+ await this.set([{
841
+ name: this.getCacheKeyForCampaigns(),
842
+ value: JSON.stringify(Object.keys(campaignToSet)),
843
+ }], 'env', {
844
+ ephemeralMs: CACHE_EXPIRATION_MS,
845
+ encrypted: false,
846
+ });
847
+ }
848
+ }
849
+ return Object.assign({}, campaignInCache, campaignToSet);
850
+ }
802
851
  async getCentraMarkets(alwaysFetch = false) {
803
852
  let marketInCache = {};
804
853
  let dedupedMarketNamesInCache = [];
@@ -24,96 +24,87 @@ declare const schema: {
24
24
  readonly type: "string";
25
25
  readonly enum: readonly ["bc", "centra", "sitoo"];
26
26
  };
27
- readonly history: {
28
- readonly type: "array";
29
- readonly items: {
27
+ readonly quantity: {
28
+ readonly type: "integer";
29
+ readonly minimum: 0;
30
+ };
31
+ readonly entry_no: {
32
+ readonly type: "string";
33
+ };
34
+ readonly external_entry_no: {
35
+ readonly type: "string";
36
+ };
37
+ readonly document_no: {
38
+ readonly type: "string";
39
+ };
40
+ readonly external_document_no: {
41
+ readonly type: "string";
42
+ };
43
+ readonly type: {
44
+ readonly type: "string";
45
+ readonly enum: readonly ["transfer", "negative adjustment", "positive adjustment", "purchase", "sale"];
46
+ };
47
+ readonly unit_cost: {
48
+ readonly oneOf: readonly [{
49
+ readonly $schema: "http://json-schema.org/draft-07/schema#";
50
+ readonly title: "Money";
30
51
  readonly type: "object";
52
+ readonly additionalProperties: false;
31
53
  readonly properties: {
32
- readonly quantity: {
54
+ readonly value: {
33
55
  readonly type: "integer";
34
56
  readonly minimum: 0;
35
57
  };
36
- readonly entry_no: {
37
- readonly type: "string";
38
- };
39
- readonly external_entry_no: {
40
- readonly type: "string";
41
- };
42
- readonly document_no: {
43
- readonly type: "string";
44
- };
45
- readonly external_document_no: {
46
- readonly type: "string";
58
+ readonly decimal_places: {
59
+ readonly type: "integer";
60
+ readonly minimum: 0;
61
+ readonly maximum: 4;
47
62
  };
48
- readonly type: {
63
+ readonly currency: {
64
+ readonly title: "Currency";
65
+ readonly $schema: "http://json-schema.org/draft-07/schema#";
49
66
  readonly type: "string";
50
- readonly enum: readonly ["transfer", "negative adjustment", "positive adjustment", "purchase", "sale"];
67
+ readonly enum: readonly ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"];
51
68
  };
52
- readonly unit_cost: {
53
- readonly oneOf: readonly [{
54
- readonly $schema: "http://json-schema.org/draft-07/schema#";
55
- readonly title: "Money";
56
- readonly type: "object";
57
- readonly additionalProperties: false;
58
- readonly properties: {
59
- readonly value: {
60
- readonly type: "integer";
61
- readonly minimum: 0;
62
- };
63
- readonly decimal_places: {
64
- readonly type: "integer";
65
- readonly minimum: 0;
66
- readonly maximum: 4;
67
- };
68
- readonly currency: {
69
- readonly title: "Currency";
70
- readonly $schema: "http://json-schema.org/draft-07/schema#";
71
- readonly type: "string";
72
- readonly enum: readonly ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"];
73
- };
74
- readonly lcy_value: {
75
- readonly type: "integer";
76
- readonly minimum: 0;
77
- };
78
- readonly lcy_currency: {
79
- readonly title: "LCY Currency";
80
- readonly $schema: "http://json-schema.org/draft-07/schema#";
81
- readonly type: "string";
82
- readonly enum: readonly ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"];
83
- };
84
- readonly lcy_decimal_places: {
85
- readonly type: "integer";
86
- readonly minimum: 0;
87
- readonly maximum: 4;
88
- };
89
- };
90
- readonly required: readonly ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"];
91
- }, {
92
- readonly type: "null";
93
- }];
94
- };
95
- readonly document_date: {
96
- readonly type: "string";
97
- readonly format: "date";
69
+ readonly lcy_value: {
70
+ readonly type: "integer";
71
+ readonly minimum: 0;
98
72
  };
99
- readonly posting_date: {
73
+ readonly lcy_currency: {
74
+ readonly title: "LCY Currency";
75
+ readonly $schema: "http://json-schema.org/draft-07/schema#";
100
76
  readonly type: "string";
101
- readonly format: "date";
77
+ readonly enum: readonly ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"];
102
78
  };
103
- readonly created_at: {
104
- readonly type: "string";
105
- readonly format: "date-time";
79
+ readonly lcy_decimal_places: {
80
+ readonly type: "integer";
81
+ readonly minimum: 0;
82
+ readonly maximum: 4;
106
83
  };
107
84
  };
108
- readonly required: readonly ["quantity", "created_at", "entry_no", "document_date", "type"];
109
- };
85
+ readonly required: readonly ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"];
86
+ }, {
87
+ readonly type: "null";
88
+ }];
89
+ };
90
+ readonly document_date: {
91
+ readonly type: "string";
92
+ readonly format: "date";
93
+ };
94
+ readonly posting_date: {
95
+ readonly type: "string";
96
+ readonly format: "date";
97
+ };
98
+ readonly created_at: {
99
+ readonly type: "string";
100
+ readonly format: "date-time";
110
101
  };
111
102
  readonly last_modified_at: {
112
103
  readonly type: "string";
113
104
  readonly format: "date-time";
114
105
  };
115
106
  };
116
- readonly required: readonly ["style_id", "source_system", "location_code", "colour_id", "size_code", "history", "entry_no", "last_modified_at"];
107
+ readonly required: readonly ["style_id", "source_system", "location_code", "colour_id", "size_code", "last_modified_at", "quantity", "created_at", "document_date", "type"];
117
108
  readonly $id: "https://shushed.example.com/stock-move.schema.json";
118
109
  };
119
110
  export default schema;
@@ -6,20 +6,17 @@ export interface __MainSchema {
6
6
  size_code: string;
7
7
  location_code: string;
8
8
  source_system: ("bc" | "centra" | "sitoo");
9
- history: {
10
- quantity: number;
11
- description?: string;
12
- entry_no: string;
13
- external_entry_no?: string;
14
- document_no?: string;
15
- external_document_no?: string;
16
- type: ("transfer" | "negative adjustment" | "positive adjustment" | "purchase" | "sale");
17
- unit_cost?: (Money | null);
18
- document_date: string;
19
- posting_date?: string;
20
- created_at: string;
21
- [k: string]: unknown;
22
- }[];
9
+ quantity: number;
10
+ description?: string;
11
+ entry_no?: string;
12
+ external_entry_no?: string;
13
+ document_no?: string;
14
+ external_document_no?: string;
15
+ type: ("transfer" | "negative adjustment" | "positive adjustment" | "purchase" | "sale");
16
+ unit_cost?: (Money | null);
17
+ document_date: string;
18
+ posting_date?: string;
19
+ created_at: string;
23
20
  last_modified_at: string;
24
21
  }
25
22
  export interface Money {
@@ -140,6 +140,8 @@ export default class CentraHelper extends EnvEngine {
140
140
  getCacheKeyForCountryCode(countryCode: string): string;
141
141
  getCacheKeyForMarkets(): string;
142
142
  getCacheKeyForMarket(marketExternalId: string): string;
143
+ getCacheKeyForCampaigns(): string;
144
+ getCacheKeyForCampaign(campaignName: string): string;
143
145
  getCacheKeyForSizeCharts(): string;
144
146
  getCacheKeyForCountries(): string;
145
147
  getCacheKeyForCountry(countryIso2Code: string): string;
@@ -163,6 +165,7 @@ export default class CentraHelper extends EnvEngine {
163
165
  private fetchCentraVariants;
164
166
  getCentraWarehouses(externalIds?: string[] | null | undefined, alwaysFetch?: boolean): Promise<Error | Record<string, Error | BasicCentraWarehouse>>;
165
167
  getCentraPricelists(names?: string[] | null | undefined, alwaysFetch?: boolean): Promise<Error | Record<string, Error | BasicPricelist>>;
168
+ getCentraCampaigns(alwaysFetch?: boolean): Promise<Error | Record<string, Error | BasicCentraMarket>>;
166
169
  getCentraMarkets(alwaysFetch?: boolean): Promise<Error | Record<string, Error | BasicCentraMarket>>;
167
170
  getCentraCountries(iso2Codes?: string[] | null | undefined, alwaysFetch?: boolean): Promise<Error | Record<string, Error | BasicCentraCountry>>;
168
171
  getCentraSizeCharts(externalIds?: string[] | null | undefined, alwaysFetch?: boolean): Promise<Error | Record<string, Error | BasicCentraSizeChart>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.218",
3
+ "version": "0.0.220",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",