@shushed/helpers 0.0.198-v2-20251121121601 → 0.0.198-v2-20251125103858
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.
- package/dist/cjs/dist-dereferenced/messages/price-change.js +1 -1
- package/dist/cjs/dist-dereferenced/price.js +1 -1
- package/dist/cjs/src-public/airtable.js +11 -8
- package/dist/cjs/src-public/utils.js +116 -0
- package/dist/types/dist-dereferenced/messages/price-change.d.ts +29 -20
- package/dist/types/dist-dereferenced/price.d.ts +29 -20
- package/dist/types/dist-types/messages/price-change.d.ts +6 -5
- package/dist/types/dist-types/price.d.ts +6 -5
- package/dist/types/src-public/utils.d.ts +34 -0
- package/package.json +1 -1
|
@@ -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": "PriceChange", "additionalProperties": false, "allOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Price", "type": "object", "additionalProperties": false, "properties": { "style_id": { "type": ["string", "null"] }, "colour_id": { "type": ["string", "null"] }, "pricelist_code": { "type": "string" }, "
|
|
3
|
+
const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "PriceChange", "additionalProperties": false, "allOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Price", "type": "object", "additionalProperties": false, "properties": { "style_id": { "type": ["string", "null"] }, "colour_id": { "type": ["string", "null"] }, "pricelist_code": { "type": "string" }, "price_changes": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "price": { "type": "integer", "minimum": 0 }, "price_type": { "type": "string", "enum": ["rrp", "perm", "pos"] }, "effective_from": { "type": "string", "format": "date-time" }, "effective_until": { "type": "string", "format": "date-time" } }, "includes_vat": { "type": "boolean" }, "required": ["price", "includes_vat", "price_type", "effective_from", "effective_until"] } }, "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"] }, "channel": { "type": "string" } }, "required": ["style_id", "colour_id", "pricelist_code", "markdown", "currency", "channel"] }, { "type": "object", "additionalProperties": false, "required": ["style_id", "colour_id", "full_price", "markdown", "pos", "currency", "effective_from", "channel"] }], "$id": "https://shushed.example.com/messages/price-change.schema.json" };
|
|
4
4
|
exports.default = schema;
|
|
@@ -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": "Price", "type": "object", "additionalProperties": false, "properties": { "style_id": { "type": ["string", "null"] }, "colour_id": { "type": ["string", "null"] }, "pricelist_code": { "type": "string" }, "
|
|
3
|
+
const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Price", "type": "object", "additionalProperties": false, "properties": { "style_id": { "type": ["string", "null"] }, "colour_id": { "type": ["string", "null"] }, "pricelist_code": { "type": "string" }, "price_changes": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "price": { "type": "integer", "minimum": 0 }, "price_type": { "type": "string", "enum": ["rrp", "perm", "pos"] }, "effective_from": { "type": "string", "format": "date-time" }, "effective_until": { "type": "string", "format": "date-time" } }, "includes_vat": { "type": "boolean" }, "required": ["price", "includes_vat", "price_type", "effective_from", "effective_until"] } }, "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"] }, "channel": { "type": "string" } }, "required": ["style_id", "colour_id", "pricelist_code", "markdown", "currency", "channel"], "$id": "https://shushed.example.com/price.schema.json" };
|
|
4
4
|
exports.default = schema;
|
|
@@ -212,19 +212,22 @@ class AirtableHelper extends runtime_1.default {
|
|
|
212
212
|
async getExistingRecords(formula = '') {
|
|
213
213
|
const allRecords = [];
|
|
214
214
|
let offset = undefined;
|
|
215
|
-
const tableUrl = `https://api.airtable.com/v0/${this.baseId}/${this.tableId}`;
|
|
215
|
+
const tableUrl = `https://api.airtable.com/v0/${this.baseId}/${this.tableId}/listRecords`;
|
|
216
216
|
do {
|
|
217
217
|
let responseRecords = null;
|
|
218
|
+
const params = {
|
|
219
|
+
filterByFormula: formula,
|
|
220
|
+
pageSize: 100,
|
|
221
|
+
returnFieldsByFieldId: true,
|
|
222
|
+
fields: Object.values(this.dictionary).filter((x, idx, arr) => arr.indexOf(x) === idx),
|
|
223
|
+
};
|
|
224
|
+
if (offset) {
|
|
225
|
+
params.offset = `${offset}`;
|
|
226
|
+
}
|
|
218
227
|
try {
|
|
219
228
|
responseRecords = await fetch(tableUrl, {
|
|
220
229
|
method: 'POST',
|
|
221
|
-
body: JSON.stringify(
|
|
222
|
-
filterByFormula: formula,
|
|
223
|
-
offset: offset,
|
|
224
|
-
pageSize: 100,
|
|
225
|
-
returnFieldsByFieldId: true,
|
|
226
|
-
fields: Object.values(this.dictionary),
|
|
227
|
-
}),
|
|
230
|
+
body: JSON.stringify(params),
|
|
228
231
|
headers: {
|
|
229
232
|
Authorization: `Bearer ${this.apiKey}`,
|
|
230
233
|
"Content-Type": "application/json",
|
|
@@ -16,6 +16,7 @@ exports.setRetryAfterVariable = setRetryAfterVariable;
|
|
|
16
16
|
exports.createFunction = createFunction;
|
|
17
17
|
exports.createOnResponse = createOnResponse;
|
|
18
18
|
exports.onResponse = onResponse;
|
|
19
|
+
exports.parsePrices = parsePrices;
|
|
19
20
|
const crypto_1 = __importDefault(require("crypto"));
|
|
20
21
|
const firestore_1 = require("@google-cloud/firestore");
|
|
21
22
|
const jwks_1 = __importDefault(require("./jwks"));
|
|
@@ -334,3 +335,118 @@ function onResponse(config, options, requiredFlag) {
|
|
|
334
335
|
cacheMaxAge: 0,
|
|
335
336
|
};
|
|
336
337
|
}
|
|
338
|
+
function parsePrices(priceData, timeZone = 'UTC') {
|
|
339
|
+
const result = [];
|
|
340
|
+
const defaultStartDate = convertDateToDatetimeTZ(new Date(0).toISOString(), timeZone);
|
|
341
|
+
const defaultEndDate = convertDateToDatetimeTZ(new Date('2099-01-01T00:00:00Z').toISOString(), timeZone);
|
|
342
|
+
for (let i = 0; i < priceData.length; i += 1) {
|
|
343
|
+
const priceChanges = (priceData[i].price_changes || []).map(x => ({
|
|
344
|
+
effective_from: x.effective_from ? (!isNaN(new Date(x.effective_from).getTime()) ? convertDateToDatetimeTZ(x.effective_from, timeZone) : null) : defaultStartDate,
|
|
345
|
+
effective_until: x.effective_until ? (!isNaN(new Date(x.effective_until).getTime()) ? convertDateToDatetimeTZ(x.effective_until, timeZone) : null) : defaultEndDate,
|
|
346
|
+
price: x.price * 100,
|
|
347
|
+
price_type: x.price_type,
|
|
348
|
+
}));
|
|
349
|
+
const rrpPriceTypes = parsePriceType(priceChanges.filter((x) => x.price_type === 'rrp'));
|
|
350
|
+
const permPriceTypes = parsePriceType(priceChanges.filter((x) => x.price_type === 'perm'));
|
|
351
|
+
const posPriceTypes = parsePriceType(priceChanges.filter((x) => x.price_type === 'pos'));
|
|
352
|
+
let currentPrice;
|
|
353
|
+
let currentPriceType;
|
|
354
|
+
if (rrpPriceTypes.current) {
|
|
355
|
+
currentPrice = rrpPriceTypes.current;
|
|
356
|
+
currentPriceType = 'rrp';
|
|
357
|
+
}
|
|
358
|
+
if (permPriceTypes.current) {
|
|
359
|
+
currentPrice = permPriceTypes.current;
|
|
360
|
+
currentPriceType = 'perm';
|
|
361
|
+
}
|
|
362
|
+
if (posPriceTypes.current) {
|
|
363
|
+
currentPrice = posPriceTypes.current;
|
|
364
|
+
currentPriceType = 'pos';
|
|
365
|
+
}
|
|
366
|
+
result.push({
|
|
367
|
+
...priceData[i],
|
|
368
|
+
current_price: currentPrice,
|
|
369
|
+
current_price_type: currentPriceType,
|
|
370
|
+
rrp: rrpPriceTypes,
|
|
371
|
+
perm: permPriceTypes,
|
|
372
|
+
pos: posPriceTypes
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return result;
|
|
376
|
+
}
|
|
377
|
+
function parsePriceType(priceTypeData, now = new Date()) {
|
|
378
|
+
if (!priceTypeData) {
|
|
379
|
+
return {
|
|
380
|
+
current: undefined,
|
|
381
|
+
historical: [],
|
|
382
|
+
future: []
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
const historicalEntries = [];
|
|
386
|
+
const futureEntries = [];
|
|
387
|
+
const currentEntries = [];
|
|
388
|
+
for (let i = 0; i < priceTypeData.length; i += 1) {
|
|
389
|
+
const price = priceTypeData[i];
|
|
390
|
+
if (price.effective_from !== null && price.effective_until !== null) {
|
|
391
|
+
const priceWithoutNulls = price;
|
|
392
|
+
if (priceWithoutNulls.effective_from.getTime() > priceWithoutNulls.effective_until.getTime()) {
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
else if (priceWithoutNulls.effective_from.getTime() > now.getTime()) {
|
|
396
|
+
futureEntries.push(priceWithoutNulls);
|
|
397
|
+
}
|
|
398
|
+
else if (priceWithoutNulls.effective_until.getTime() < now.getTime()) {
|
|
399
|
+
historicalEntries.push(priceWithoutNulls);
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
currentEntries.push(priceWithoutNulls);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const [currentEntry, ...otherFutureEntries] = currentEntries.sort(createSortPriceTypes(false));
|
|
407
|
+
const sortedHistoricalEntries = historicalEntries.concat(otherFutureEntries).sort(createSortPriceTypes(true));
|
|
408
|
+
const sortedFutureEntries = futureEntries.sort(createSortPriceTypes(true));
|
|
409
|
+
return {
|
|
410
|
+
current: currentEntry,
|
|
411
|
+
historical: sortedHistoricalEntries,
|
|
412
|
+
future: sortedFutureEntries
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function createSortPriceTypes(descending) {
|
|
416
|
+
return function (a, b) {
|
|
417
|
+
let effectiveFromSort;
|
|
418
|
+
if (descending) {
|
|
419
|
+
effectiveFromSort = b.effective_from.getTime() - a.effective_from.getTime();
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
effectiveFromSort = a.effective_from.getTime() - b.effective_from.getTime();
|
|
423
|
+
}
|
|
424
|
+
if (effectiveFromSort === 0) {
|
|
425
|
+
if (!descending) {
|
|
426
|
+
return b.effective_until.getTime() - a.effective_until.getTime();
|
|
427
|
+
}
|
|
428
|
+
return a.effective_until.getTime() - b.effective_until.getTime();
|
|
429
|
+
}
|
|
430
|
+
return effectiveFromSort;
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function convertDateToDatetimeTZ(dateString, timeZone) {
|
|
434
|
+
let normDateString = '';
|
|
435
|
+
if (dateString.includes('T')) {
|
|
436
|
+
normDateString = dateString.slice(0, 19);
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
normDateString = dateString + 'T00:00:00';
|
|
440
|
+
}
|
|
441
|
+
return new Date(normDateString + getOffsetString(timeZone));
|
|
442
|
+
}
|
|
443
|
+
function getOffsetString(timeZone, date = new Date()) {
|
|
444
|
+
const locale = date.toLocaleString("en-US", { timeZone });
|
|
445
|
+
const tzDate = new Date(locale);
|
|
446
|
+
const offsetMinutes = (tzDate.getTime() - date.getTime()) / 60000;
|
|
447
|
+
const sign = offsetMinutes >= 0 ? "+" : "-";
|
|
448
|
+
const abs = Math.abs(offsetMinutes);
|
|
449
|
+
const hours = String(Math.floor(abs / 60)).padStart(2, "0");
|
|
450
|
+
const minutes = String(abs % 60).padStart(2, "0");
|
|
451
|
+
return `${sign}${hours}:${minutes}`;
|
|
452
|
+
}
|
|
@@ -17,17 +17,34 @@ declare const schema: {
|
|
|
17
17
|
readonly pricelist_code: {
|
|
18
18
|
readonly type: "string";
|
|
19
19
|
};
|
|
20
|
-
readonly
|
|
21
|
-
readonly type: "
|
|
22
|
-
readonly
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
readonly price_changes: {
|
|
21
|
+
readonly type: "array";
|
|
22
|
+
readonly items: {
|
|
23
|
+
readonly type: "object";
|
|
24
|
+
readonly additionalProperties: false;
|
|
25
|
+
readonly properties: {
|
|
26
|
+
readonly price: {
|
|
27
|
+
readonly type: "integer";
|
|
28
|
+
readonly minimum: 0;
|
|
29
|
+
};
|
|
30
|
+
readonly price_type: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly enum: readonly ["rrp", "perm", "pos"];
|
|
33
|
+
};
|
|
34
|
+
readonly effective_from: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly format: "date-time";
|
|
37
|
+
};
|
|
38
|
+
readonly effective_until: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
readonly format: "date-time";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
readonly includes_vat: {
|
|
44
|
+
readonly type: "boolean";
|
|
45
|
+
};
|
|
46
|
+
readonly required: readonly ["price", "includes_vat", "price_type", "effective_from", "effective_until"];
|
|
47
|
+
};
|
|
31
48
|
};
|
|
32
49
|
readonly currency: {
|
|
33
50
|
readonly title: "Currency";
|
|
@@ -35,19 +52,11 @@ declare const schema: {
|
|
|
35
52
|
readonly type: "string";
|
|
36
53
|
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"];
|
|
37
54
|
};
|
|
38
|
-
readonly effective_from: {
|
|
39
|
-
readonly type: "string";
|
|
40
|
-
readonly format: "date-time";
|
|
41
|
-
};
|
|
42
|
-
readonly effective_until: {
|
|
43
|
-
readonly type: "string";
|
|
44
|
-
readonly format: "date-time";
|
|
45
|
-
};
|
|
46
55
|
readonly channel: {
|
|
47
56
|
readonly type: "string";
|
|
48
57
|
};
|
|
49
58
|
};
|
|
50
|
-
readonly required: readonly ["style_id", "colour_id", "pricelist_code", "
|
|
59
|
+
readonly required: readonly ["style_id", "colour_id", "pricelist_code", "markdown", "currency", "channel"];
|
|
51
60
|
}, {
|
|
52
61
|
readonly type: "object";
|
|
53
62
|
readonly additionalProperties: false;
|
|
@@ -13,17 +13,34 @@ declare const schema: {
|
|
|
13
13
|
readonly pricelist_code: {
|
|
14
14
|
readonly type: "string";
|
|
15
15
|
};
|
|
16
|
-
readonly
|
|
17
|
-
readonly type: "
|
|
18
|
-
readonly
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
readonly price_changes: {
|
|
17
|
+
readonly type: "array";
|
|
18
|
+
readonly items: {
|
|
19
|
+
readonly type: "object";
|
|
20
|
+
readonly additionalProperties: false;
|
|
21
|
+
readonly properties: {
|
|
22
|
+
readonly price: {
|
|
23
|
+
readonly type: "integer";
|
|
24
|
+
readonly minimum: 0;
|
|
25
|
+
};
|
|
26
|
+
readonly price_type: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly enum: readonly ["rrp", "perm", "pos"];
|
|
29
|
+
};
|
|
30
|
+
readonly effective_from: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly format: "date-time";
|
|
33
|
+
};
|
|
34
|
+
readonly effective_until: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly format: "date-time";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
readonly includes_vat: {
|
|
40
|
+
readonly type: "boolean";
|
|
41
|
+
};
|
|
42
|
+
readonly required: readonly ["price", "includes_vat", "price_type", "effective_from", "effective_until"];
|
|
43
|
+
};
|
|
27
44
|
};
|
|
28
45
|
readonly currency: {
|
|
29
46
|
readonly title: "Currency";
|
|
@@ -31,19 +48,11 @@ declare const schema: {
|
|
|
31
48
|
readonly type: "string";
|
|
32
49
|
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"];
|
|
33
50
|
};
|
|
34
|
-
readonly effective_from: {
|
|
35
|
-
readonly type: "string";
|
|
36
|
-
readonly format: "date-time";
|
|
37
|
-
};
|
|
38
|
-
readonly effective_until: {
|
|
39
|
-
readonly type: "string";
|
|
40
|
-
readonly format: "date-time";
|
|
41
|
-
};
|
|
42
51
|
readonly channel: {
|
|
43
52
|
readonly type: "string";
|
|
44
53
|
};
|
|
45
54
|
};
|
|
46
|
-
readonly required: readonly ["style_id", "colour_id", "pricelist_code", "
|
|
55
|
+
readonly required: readonly ["style_id", "colour_id", "pricelist_code", "markdown", "currency", "channel"];
|
|
47
56
|
readonly $id: "https://shushed.example.com/price.schema.json";
|
|
48
57
|
};
|
|
49
58
|
export default schema;
|
|
@@ -4,12 +4,13 @@ export interface Price {
|
|
|
4
4
|
style_id: (string | null);
|
|
5
5
|
colour_id: (string | null);
|
|
6
6
|
pricelist_code: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
price_changes?: {
|
|
8
|
+
price: number;
|
|
9
|
+
price_type: ("rrp" | "perm" | "pos");
|
|
10
|
+
effective_from: string;
|
|
11
|
+
effective_until: string;
|
|
12
|
+
}[];
|
|
10
13
|
currency: Currency;
|
|
11
|
-
effective_from: string;
|
|
12
|
-
effective_until?: string;
|
|
13
14
|
channel: string;
|
|
14
15
|
}
|
|
15
16
|
export default __MainSchema;
|
|
@@ -3,12 +3,13 @@ export interface __MainSchema {
|
|
|
3
3
|
style_id: (string | null);
|
|
4
4
|
colour_id: (string | null);
|
|
5
5
|
pricelist_code: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
price_changes?: {
|
|
7
|
+
price: number;
|
|
8
|
+
price_type: ("rrp" | "perm" | "pos");
|
|
9
|
+
effective_from: string;
|
|
10
|
+
effective_until: string;
|
|
11
|
+
}[];
|
|
9
12
|
currency: Currency;
|
|
10
|
-
effective_from: string;
|
|
11
|
-
effective_until?: string;
|
|
12
13
|
channel: string;
|
|
13
14
|
}
|
|
14
15
|
export default __MainSchema;
|
|
@@ -65,3 +65,37 @@ export declare function onResponse(config: any & {
|
|
|
65
65
|
value: any;
|
|
66
66
|
cacheMaxAge: number;
|
|
67
67
|
} | undefined;
|
|
68
|
+
interface Price {
|
|
69
|
+
price_changes: undefined | Array<{
|
|
70
|
+
price: number;
|
|
71
|
+
effective_from?: string;
|
|
72
|
+
effective_until?: string;
|
|
73
|
+
price_type: string;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
type NormPrice = {
|
|
77
|
+
effective_from: Date | null;
|
|
78
|
+
effective_until: Date | null;
|
|
79
|
+
price: number;
|
|
80
|
+
price_type: 'rrp' | 'perm' | 'pos';
|
|
81
|
+
};
|
|
82
|
+
export declare function parsePrices<T extends Price>(priceData: T[], timeZone?: string): (T & {
|
|
83
|
+
rrp: {
|
|
84
|
+
current: NormPrice | undefined;
|
|
85
|
+
future: NormPrice[];
|
|
86
|
+
historical: NormPrice[];
|
|
87
|
+
};
|
|
88
|
+
perm: {
|
|
89
|
+
current: NormPrice | undefined;
|
|
90
|
+
future: NormPrice[];
|
|
91
|
+
historical: NormPrice[];
|
|
92
|
+
};
|
|
93
|
+
pos: {
|
|
94
|
+
current: NormPrice | undefined;
|
|
95
|
+
future: NormPrice[];
|
|
96
|
+
historical: NormPrice[];
|
|
97
|
+
};
|
|
98
|
+
current_price: NormPrice | undefined;
|
|
99
|
+
current_price_type: "rrp" | "perm" | "pos" | undefined;
|
|
100
|
+
})[];
|
|
101
|
+
export {};
|