@shushed/helpers 0.0.227 → 0.0.229
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.
|
@@ -83,35 +83,36 @@ class PubSubHelper extends runtime_1.default {
|
|
|
83
83
|
const messageIds = [];
|
|
84
84
|
for (let i = 0; i < batches.length; i++) {
|
|
85
85
|
const batch = batches[i];
|
|
86
|
-
const results = await Promise.allSettled(batch.map((x) => {
|
|
86
|
+
const results = await Promise.allSettled(batch.map((x, index) => {
|
|
87
87
|
if (options.attributesGenerator) {
|
|
88
|
-
nextAttributes = Object.fromEntries(Object.entries(options.attributesGenerator(x)).filter(([_, v]) => v !== undefined && v !== null).map(([k, v]) => [k, typeof v === 'boolean' ? (v ? 'yes' : 'no') : `${v}`]));
|
|
88
|
+
nextAttributes = Object.fromEntries(Object.entries(options.attributesGenerator(x, index)).filter(([_, v]) => v !== undefined && v !== null).map(([k, v]) => [k, typeof v === 'boolean' ? (v ? 'yes' : 'no') : `${v}`]));
|
|
89
89
|
}
|
|
90
90
|
if (typeof options.extraAttributes === 'function') {
|
|
91
|
-
nextAttributes = Object.fromEntries(Object.entries(options.extraAttributes ? Object.assign({}, nextAttributes, options.extraAttributes(x)) : nextAttributes).filter(([_, v]) => v !== undefined && v !== null).map(([k, v]) => [k, typeof v === 'boolean' ? (v ? 'yes' : 'no') : `${v}`]));
|
|
91
|
+
nextAttributes = Object.fromEntries(Object.entries(options.extraAttributes ? Object.assign({}, nextAttributes, options.extraAttributes(x, index)) : nextAttributes).filter(([_, v]) => v !== undefined && v !== null).map(([k, v]) => [k, typeof v === 'boolean' ? (v ? 'yes' : 'no') : `${v}`]));
|
|
92
92
|
}
|
|
93
93
|
else if (typeof options.extraAttributes === 'object') {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
nextAttributes = Object.assign({}, nextAttributes, options.extraAttributes);
|
|
95
|
+
}
|
|
96
|
+
for (const key in nextAttributes) {
|
|
97
|
+
let resultForKey;
|
|
98
|
+
if (typeof nextAttributes[key] === 'function') {
|
|
99
|
+
resultForKey = nextAttributes[key](x, index);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
resultForKey = nextAttributes[key];
|
|
103
|
+
}
|
|
104
|
+
if (typeof resultForKey === 'boolean') {
|
|
105
|
+
nextAttributes[key] = resultForKey ? 'yes' : 'no';
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
nextAttributes[key] = `${resultForKey}`;
|
|
108
109
|
}
|
|
109
|
-
nextAttributes = Object.assign(nextAttributes, {
|
|
110
|
-
source_system: options.sourceSystem,
|
|
111
|
-
target_system: options.targetSystem,
|
|
112
|
-
buildship_id: this.systemEnvName + '-' + this.workflowId + '-' + this.triggerId,
|
|
113
|
-
});
|
|
114
110
|
}
|
|
111
|
+
nextAttributes = Object.assign(nextAttributes, {
|
|
112
|
+
source_system: options.sourceSystem,
|
|
113
|
+
target_system: options.targetSystem,
|
|
114
|
+
buildship_id: this.systemEnvName + '-' + this.workflowId + '-' + this.triggerId,
|
|
115
|
+
});
|
|
115
116
|
return topic.publishMessage({
|
|
116
117
|
data: Buffer.from(JSON.stringify(x)),
|
|
117
118
|
attributes: nextAttributes
|
|
@@ -97,7 +97,7 @@ class Runtime {
|
|
|
97
97
|
this.workflowId = opts.workflowId || opts.workflow?.id || '';
|
|
98
98
|
if (opts.trigger?.label) {
|
|
99
99
|
this.triggerId = opts.trigger.id || '00000000-0000-0000-0000-000000000000';
|
|
100
|
-
this.triggerName = opts.trigger
|
|
100
|
+
this.triggerName = opts.trigger?.label?.split(/\sv\d/)[0]?.trim() || this.workflowId;
|
|
101
101
|
this.triggerVersion = buildSemver((opts.trigger.label.split(/\sv\d/)[1]?.trim() || 'v0').replace(/^v/, ''));
|
|
102
102
|
this.triggerDataProperties = opts.trigger.data?.properties;
|
|
103
103
|
this.triggerConfigProperties = opts.trigger.config?.properties;
|
|
@@ -5,7 +5,7 @@ declare global {
|
|
|
5
5
|
var HUSH_PUBSUB_PUBLISH_TOPICS: Record<string, Topic>;
|
|
6
6
|
}
|
|
7
7
|
export declare function isSubscriptionBigQuery(opts: SubscriptionOptionsBigQuery | SubscriptionOptionsPull): opts is SubscriptionOptionsBigQuery;
|
|
8
|
-
type PublishAttributesGenerator<T> = (payload: any) => T;
|
|
8
|
+
type PublishAttributesGenerator<T> = (payload: any, index: number) => T;
|
|
9
9
|
type PublishAttributes = PublishAttributesGenerator<Record<string, string>> | Record<string, string> | Record<string, PublishAttributesGenerator<string | boolean | number> | boolean | number>;
|
|
10
10
|
export type Message = {
|
|
11
11
|
buildshipId: string;
|