@shushed/helpers 0.0.233 → 0.0.235
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/bigquery.js +0 -1
- package/dist/cjs/src-public/env.js +0 -3
- package/dist/cjs/src-public/pubsub.js +19 -9
- package/dist/cjs/src-public/runtime.js +2 -2
- package/dist/types/dist-dereferenced/messages/price-change.d.ts +7 -1
- package/dist/types/dist-dereferenced/price.d.ts +7 -1
- package/dist/types/dist-types/messages/price-change.d.ts +1 -0
- package/dist/types/dist-types/price.d.ts +1 -0
- package/dist/types/src-public/pubsub.d.ts +1 -1
- 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" }, "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" };
|
|
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" }, "sizes": { "type": "array", "items": { "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": ["sizes", "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" }, "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" };
|
|
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" }, "sizes": { "type": "array", "items": { "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": ["sizes", "style_id", "colour_id", "pricelist_code", "markdown", "currency", "channel"], "$id": "https://shushed.example.com/price.schema.json" };
|
|
4
4
|
exports.default = schema;
|
|
@@ -777,9 +777,6 @@ class EnvEngine extends runtime_1.default {
|
|
|
777
777
|
projectId: pubSubProjectId
|
|
778
778
|
});
|
|
779
779
|
global.HUSH_PUBSUB_INSTANCE = pubSub;
|
|
780
|
-
this.logging.log('getPubSubHelper', {
|
|
781
|
-
serviceAccountEmail: serviceAccount,
|
|
782
|
-
});
|
|
783
780
|
return new pubsub_1.default(this, {
|
|
784
781
|
serviceAccountEmail: serviceAccount
|
|
785
782
|
}, pubSub);
|
|
@@ -64,15 +64,6 @@ class PubSubHelper extends runtime_1.default {
|
|
|
64
64
|
return message;
|
|
65
65
|
}
|
|
66
66
|
async publish(options, payloads) {
|
|
67
|
-
if (!pubSubPublishTopics[options.topicName]) {
|
|
68
|
-
pubSubPublishTopics[options.topicName] = this.pubSub.topic(options.topicName, {
|
|
69
|
-
batching: {
|
|
70
|
-
maxMessages: 10,
|
|
71
|
-
maxMilliseconds: 15
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const topic = pubSubPublishTopics[options.topicName];
|
|
76
67
|
const batches = payloads.length > 5 ? (0, lodash_chunk_1.default)(payloads, 10) : [payloads];
|
|
77
68
|
let nextAttributes = {};
|
|
78
69
|
const messageIds = [];
|
|
@@ -112,6 +103,25 @@ class PubSubHelper extends runtime_1.default {
|
|
|
112
103
|
};
|
|
113
104
|
let messageId = null;
|
|
114
105
|
if (!options.dryRun) {
|
|
106
|
+
let topicName = '';
|
|
107
|
+
if (typeof options.topicName === 'function') {
|
|
108
|
+
options.topicName = options.topicName(message.data);
|
|
109
|
+
}
|
|
110
|
+
else if (typeof options.topicName === 'string') {
|
|
111
|
+
topicName = options.topicName;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
throw new Error('topicName must be a string or a function');
|
|
115
|
+
}
|
|
116
|
+
if (!pubSubPublishTopics[topicName]) {
|
|
117
|
+
pubSubPublishTopics[topicName] = this.pubSub.topic(topicName, {
|
|
118
|
+
batching: {
|
|
119
|
+
maxMessages: 10,
|
|
120
|
+
maxMilliseconds: 15
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const topic = pubSubPublishTopics[topicName];
|
|
115
125
|
messageId = await topic.publishMessage({
|
|
116
126
|
data: Buffer.from(JSON.stringify(message.data)),
|
|
117
127
|
attributes: message.attributes,
|
|
@@ -98,7 +98,7 @@ class Runtime {
|
|
|
98
98
|
if (opts.trigger?.label) {
|
|
99
99
|
this.triggerId = opts.trigger.id || '00000000-0000-0000-0000-000000000000';
|
|
100
100
|
this.triggerName = opts.trigger?.label?.split(/\sv\d/)[0]?.trim() || this.workflowId;
|
|
101
|
-
this.triggerVersion = buildSemver((opts.trigger
|
|
101
|
+
this.triggerVersion = buildSemver((opts.trigger?.label?.split(/\sv/)?.find(x => /^\d/.test(x))?.trim() || '0'));
|
|
102
102
|
this.triggerDataProperties = opts.trigger.data?.properties;
|
|
103
103
|
this.triggerConfigProperties = opts.trigger.config?.properties;
|
|
104
104
|
}
|
|
@@ -182,7 +182,7 @@ class Runtime {
|
|
|
182
182
|
exports.default = Runtime;
|
|
183
183
|
;
|
|
184
184
|
function buildSemver(version) {
|
|
185
|
-
const parts = version.split(
|
|
185
|
+
const parts = version.split('.').map(x => parseInt(x, 10)).filter(x => !isNaN(x));
|
|
186
186
|
for (let i = parts.length; i < 3; i++) {
|
|
187
187
|
parts.push(0);
|
|
188
188
|
}
|
|
@@ -17,6 +17,12 @@ declare const schema: {
|
|
|
17
17
|
readonly pricelist_code: {
|
|
18
18
|
readonly type: "string";
|
|
19
19
|
};
|
|
20
|
+
readonly sizes: {
|
|
21
|
+
readonly type: "array";
|
|
22
|
+
readonly items: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
20
26
|
readonly price_changes: {
|
|
21
27
|
readonly type: "array";
|
|
22
28
|
readonly items: {
|
|
@@ -56,7 +62,7 @@ declare const schema: {
|
|
|
56
62
|
readonly type: "string";
|
|
57
63
|
};
|
|
58
64
|
};
|
|
59
|
-
readonly required: readonly ["style_id", "colour_id", "pricelist_code", "markdown", "currency", "channel"];
|
|
65
|
+
readonly required: readonly ["sizes", "style_id", "colour_id", "pricelist_code", "markdown", "currency", "channel"];
|
|
60
66
|
}, {
|
|
61
67
|
readonly type: "object";
|
|
62
68
|
readonly additionalProperties: false;
|
|
@@ -13,6 +13,12 @@ declare const schema: {
|
|
|
13
13
|
readonly pricelist_code: {
|
|
14
14
|
readonly type: "string";
|
|
15
15
|
};
|
|
16
|
+
readonly sizes: {
|
|
17
|
+
readonly type: "array";
|
|
18
|
+
readonly items: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
16
22
|
readonly price_changes: {
|
|
17
23
|
readonly type: "array";
|
|
18
24
|
readonly items: {
|
|
@@ -52,7 +58,7 @@ declare const schema: {
|
|
|
52
58
|
readonly type: "string";
|
|
53
59
|
};
|
|
54
60
|
};
|
|
55
|
-
readonly required: readonly ["style_id", "colour_id", "pricelist_code", "markdown", "currency", "channel"];
|
|
61
|
+
readonly required: readonly ["sizes", "style_id", "colour_id", "pricelist_code", "markdown", "currency", "channel"];
|
|
56
62
|
readonly $id: "https://shushed.example.com/price.schema.json";
|
|
57
63
|
};
|
|
58
64
|
export default schema;
|
|
@@ -52,7 +52,7 @@ declare class PubSubHelper extends Runtime {
|
|
|
52
52
|
static decodeMessageFromRequest(req: PubSubMessage): Promise<ReceivedMessage>;
|
|
53
53
|
static decodeMessageFromRequest(req: Context): Promise<ReceivedMessage>;
|
|
54
54
|
publish(options: Partial<Message> & {
|
|
55
|
-
topicName: string;
|
|
55
|
+
topicName: string | ((payload: any) => string);
|
|
56
56
|
extraAttributes?: PublishAttributes;
|
|
57
57
|
attributesGenerator?: PublishAttributesGenerator<Record<string, string>>;
|
|
58
58
|
dryRun?: boolean;
|