@shushed/helpers 0.0.35 → 0.0.37
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/index.d.ts +2 -0
- package/dist/index.js +20 -11
- package/dist/package.json +2 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -28743,6 +28743,7 @@ declare class EnvEngine extends Runtime {
|
|
|
28743
28743
|
|
|
28744
28744
|
type Message = {
|
|
28745
28745
|
buildshipId: string;
|
|
28746
|
+
exportableToBigQuery: boolean;
|
|
28746
28747
|
body: any;
|
|
28747
28748
|
sourceSystem: string;
|
|
28748
28749
|
targetSystem: string;
|
|
@@ -28750,6 +28751,7 @@ type Message = {
|
|
|
28750
28751
|
recordModifiedAt: Date | null;
|
|
28751
28752
|
originalPublishTime: Date | null;
|
|
28752
28753
|
publishTime: Date | null;
|
|
28754
|
+
extraAttributes: Record<string, string>;
|
|
28753
28755
|
};
|
|
28754
28756
|
type LastModifiedKeys = 'last_modified_date_time' | 'last_modified_date' | 'last_modified_datetime' | 'record_modified_at' | 'lastModifiedDateTime' | 'lastModifiedAt' | 'last_modified_at' | 'SystemModifiedAt' | 'system_modified_at' | 'lastUpdatedAt' | 'modified_at' | 'last_updated_at' | 'modifiedAt';
|
|
28755
28757
|
type AtLeastOne<T, Keys extends keyof T = keyof T> = Partial<T> & {
|
package/dist/index.js
CHANGED
|
@@ -678,6 +678,7 @@ var env_default = EnvEngine;
|
|
|
678
678
|
|
|
679
679
|
// src-public/pubsub.ts
|
|
680
680
|
var import_co_body = __toESM(require("co-body"));
|
|
681
|
+
var import_lodash = __toESM(require("lodash.omit"));
|
|
681
682
|
function isSubscriptionOptionsPush(opts) {
|
|
682
683
|
return "endpointUrl" in opts;
|
|
683
684
|
}
|
|
@@ -705,7 +706,9 @@ var PubSubHelper = class extends Runtime {
|
|
|
705
706
|
originalPublishTime: parseDateOrDefault(rawMessage.attributes?.original_publish_time, parseDateOrDefault(rawMessage.publish_time)),
|
|
706
707
|
buildshipId: rawMessage.attributes?.buildship_id || "unknown",
|
|
707
708
|
publishTime: parseDateOrDefault(rawMessage.publish_time),
|
|
708
|
-
body: messageBody
|
|
709
|
+
body: messageBody,
|
|
710
|
+
exportableToBigQuery: !!rawMessage.attributes?.bigquery,
|
|
711
|
+
extraAttributes: (0, import_lodash.default)(rawMessage.attributes || {}, ["source_system", "target_system", "process_started_at", "record_modified_at", "original_publish_time", "buildship_id", "publish_time", "bigquery"])
|
|
709
712
|
};
|
|
710
713
|
return message;
|
|
711
714
|
}
|
|
@@ -726,16 +729,21 @@ var PubSubHelper = class extends Runtime {
|
|
|
726
729
|
for (let i = 0; i < normPayloads.length; i++) {
|
|
727
730
|
const normPayload = normPayloads[i];
|
|
728
731
|
promises.push((async () => {
|
|
732
|
+
const attributes = {
|
|
733
|
+
...(0, import_lodash.default)(options.extraAttributes || {}, ["source_system", "target_system", "process_started_at", "record_modified_at", "original_publish_time", "buildship_id", "publish_time", "bigquery"]),
|
|
734
|
+
source_system: options.sourceSystem,
|
|
735
|
+
target_system: options.targetSystem || orgMessage?.targetSystem || "*",
|
|
736
|
+
process_started_at: (options.processStartedAt || orgMessage?.processStartedAt || /* @__PURE__ */ new Date()).toISOString(),
|
|
737
|
+
record_modified_at: (getEventTime(normPayload, null) || /* @__PURE__ */ new Date()).toISOString(),
|
|
738
|
+
original_publish_time: (orgMessage?.originalPublishTime || orgMessage?.publishTime || /* @__PURE__ */ new Date())?.toDateString() || "",
|
|
739
|
+
buildship_id: this.systemEnvName + "-" + this.workflowId + "-" + this.triggerId
|
|
740
|
+
};
|
|
741
|
+
if (options.exportableToBigQuery) {
|
|
742
|
+
attributes.bigquery = "yes";
|
|
743
|
+
}
|
|
729
744
|
const result = await topic.publishMessage({
|
|
730
745
|
data: Buffer.from(JSON.stringify(normPayload)),
|
|
731
|
-
attributes
|
|
732
|
-
source_system: options.sourceSystem,
|
|
733
|
-
target_system: options.targetSystem || orgMessage?.targetSystem || "*",
|
|
734
|
-
process_started_at: (options.processStartedAt || orgMessage?.processStartedAt || /* @__PURE__ */ new Date()).toISOString(),
|
|
735
|
-
record_modified_at: (getEventTime(normPayload, null) || /* @__PURE__ */ new Date()).toISOString(),
|
|
736
|
-
original_publish_time: (orgMessage?.originalPublishTime || orgMessage?.publishTime || /* @__PURE__ */ new Date())?.toDateString() || "",
|
|
737
|
-
buildship_id: this.systemEnvName + "-" + this.workflowId + "-" + this.triggerId
|
|
738
|
-
}
|
|
746
|
+
attributes
|
|
739
747
|
});
|
|
740
748
|
return result;
|
|
741
749
|
})());
|
|
@@ -743,7 +751,7 @@ var PubSubHelper = class extends Runtime {
|
|
|
743
751
|
return Promise.all(promises);
|
|
744
752
|
}
|
|
745
753
|
async createOrUpdate(opts) {
|
|
746
|
-
const subscriptionName = `${this.envName
|
|
754
|
+
const subscriptionName = `${this.envName}---${this.triggerId}`;
|
|
747
755
|
const topic = await this.ensureTopicExists(opts.topicName);
|
|
748
756
|
let dlqTopic = null;
|
|
749
757
|
let dlqSubscription = null;
|
|
@@ -839,6 +847,7 @@ var PubSubHelper = class extends Runtime {
|
|
|
839
847
|
serviceAccountEmail: this.serviceAccountEmail,
|
|
840
848
|
useTableSchema: false
|
|
841
849
|
};
|
|
850
|
+
payload.filter = `attributes:bigquery`;
|
|
842
851
|
} else {
|
|
843
852
|
payload.ackDeadlineSeconds = opts.ackDeadline || 90;
|
|
844
853
|
payload.pushConfig = {
|
|
@@ -854,7 +863,7 @@ var PubSubHelper = class extends Runtime {
|
|
|
854
863
|
};
|
|
855
864
|
if (opts.dlqTopic) {
|
|
856
865
|
payload.deadLetterPolicy = {
|
|
857
|
-
deadLetterTopic:
|
|
866
|
+
deadLetterTopic: opts.dlqTopic.name,
|
|
858
867
|
maxDeliveryAttempts: opts.retryLimit
|
|
859
868
|
};
|
|
860
869
|
}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shushed/helpers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"author": "",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"description": "",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"ajv-formats": "^3.0.1",
|
|
11
11
|
"co-body": "^6.2.0",
|
|
12
12
|
"jose": "^6.0.11",
|
|
13
|
-
"lodash.clonedeep": "^4.5.0"
|
|
13
|
+
"lodash.clonedeep": "^4.5.0",
|
|
14
|
+
"lodash.omit": "^4.5.0"
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
16
17
|
"dist"
|