@shushed/helpers 0.0.74 → 0.0.75
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 +35 -3
- package/dist/index.js +56 -27
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -28910,9 +28910,41 @@ declare class PubSubHelper extends Runtime {
|
|
|
28910
28910
|
tableDlqSubscription: Subscription | null;
|
|
28911
28911
|
tableSubscription: Subscription | null;
|
|
28912
28912
|
}>;
|
|
28913
|
-
|
|
28914
|
-
|
|
28915
|
-
|
|
28913
|
+
getStatus(topicName: string): Promise<{
|
|
28914
|
+
subscriptions: {
|
|
28915
|
+
main: {
|
|
28916
|
+
name: string;
|
|
28917
|
+
shortName: string;
|
|
28918
|
+
isPush: boolean;
|
|
28919
|
+
} | null;
|
|
28920
|
+
table: {
|
|
28921
|
+
name: string;
|
|
28922
|
+
shortName: string;
|
|
28923
|
+
tableId: string | null | undefined;
|
|
28924
|
+
} | null;
|
|
28925
|
+
tableDlq: {
|
|
28926
|
+
name: string;
|
|
28927
|
+
shortName: string;
|
|
28928
|
+
} | null;
|
|
28929
|
+
mainDlq: {
|
|
28930
|
+
name: string;
|
|
28931
|
+
shortName: string;
|
|
28932
|
+
} | null;
|
|
28933
|
+
};
|
|
28934
|
+
topics: {
|
|
28935
|
+
main: {
|
|
28936
|
+
name: string;
|
|
28937
|
+
shortName: string;
|
|
28938
|
+
} | null;
|
|
28939
|
+
mainDlq: {
|
|
28940
|
+
name: string;
|
|
28941
|
+
shortName: string;
|
|
28942
|
+
} | null;
|
|
28943
|
+
tableDlq: {
|
|
28944
|
+
name: string;
|
|
28945
|
+
shortName: string;
|
|
28946
|
+
} | null;
|
|
28947
|
+
};
|
|
28916
28948
|
}>;
|
|
28917
28949
|
pause(topicName: string): Promise<{
|
|
28918
28950
|
subscriptionId: string;
|
package/dist/index.js
CHANGED
|
@@ -875,7 +875,6 @@ var PubSubHelper = class extends Runtime {
|
|
|
875
875
|
async createOrUpdate(opts) {
|
|
876
876
|
this.logging.log("createOrUpdate called with", opts);
|
|
877
877
|
const [topics] = await this.pubSub.getTopics();
|
|
878
|
-
this.logging.log("topics discovered", topics);
|
|
879
878
|
const infraPrefix = opts.topicName.indexOf("---") !== -1 ? opts.topicName : `${this.envName}---${opts.topicName}`;
|
|
880
879
|
const mainDlqTopicName = `${infraPrefix}-${shortHash(this.triggerId)}-dlq`;
|
|
881
880
|
const tableDlqTopicName = `${infraPrefix}-${shortHash(this.triggerId)}-bq-dlq`;
|
|
@@ -902,22 +901,6 @@ var PubSubHelper = class extends Runtime {
|
|
|
902
901
|
let mainDlqSubscription = mainDlqTopicSubscriptions?.find((x) => this.getNameFromFullyQualifiedName(x.name) === mainDlqSubscriptionName) || null;
|
|
903
902
|
let tableSubscription = mainTopicSubscriptions?.find((x) => this.getNameFromFullyQualifiedName(x.name) === tableSubscriptionName) || null;
|
|
904
903
|
let tableDlqSubscription = tableDlqTopicSubscriptions?.find((x) => this.getNameFromFullyQualifiedName(x.name) === tableDlqSubscriptionName) || null;
|
|
905
|
-
this.logging.log("environment discovery", {
|
|
906
|
-
mainTopicName: opts.topicName,
|
|
907
|
-
mainDlqTopicName,
|
|
908
|
-
tableDlqTopicName,
|
|
909
|
-
mainSubscriptionName,
|
|
910
|
-
mainDlqSubscriptionName,
|
|
911
|
-
tableSubscriptionName,
|
|
912
|
-
tableDlqSubscriptionName,
|
|
913
|
-
mainTopicExists: mainTopic,
|
|
914
|
-
mainDlqTopicExists: mainDlqTopic,
|
|
915
|
-
tableDlqTopicExists: tableDlqTopic,
|
|
916
|
-
mainSubscriptionExists: mainSubscription,
|
|
917
|
-
mainDlqSubscriptionExists: mainDlqSubscription,
|
|
918
|
-
tableSubscriptionExists: tableSubscription,
|
|
919
|
-
tableDlqSubscriptionExists: tableDlqSubscription
|
|
920
|
-
});
|
|
921
904
|
const topic = await this.ensureTopicExists(opts.topicName);
|
|
922
905
|
if (opts.table || opts.pull || opts.push) {
|
|
923
906
|
mainTopic = await this.ensureTopicExists(opts.topicName);
|
|
@@ -1236,24 +1219,70 @@ var PubSubHelper = class extends Runtime {
|
|
|
1236
1219
|
table: null
|
|
1237
1220
|
});
|
|
1238
1221
|
}
|
|
1239
|
-
async
|
|
1222
|
+
async getStatus(topicName) {
|
|
1223
|
+
this.logging.log("getStatus called with", topicName);
|
|
1240
1224
|
const [topics] = await this.pubSub.getTopics();
|
|
1241
|
-
const mainTopic = topics.find((x) => this.getNameFromFullyQualifiedName(x.name) === topicName);
|
|
1242
|
-
this.logging.log("isRunning called with", topicName);
|
|
1243
1225
|
const infraPrefix = topicName.indexOf("---") !== -1 ? topicName : `${this.envName}---${topicName}`;
|
|
1226
|
+
const mainDlqTopicName = `${infraPrefix}-${shortHash(this.triggerId)}-dlq`;
|
|
1227
|
+
const tableDlqTopicName = `${infraPrefix}-${shortHash(this.triggerId)}-bq-dlq`;
|
|
1228
|
+
const mainTopic = topics.find((x) => this.getNameFromFullyQualifiedName(x.name) === topicName);
|
|
1229
|
+
const mainDlqTopic = topics.find((x) => this.getNameFromFullyQualifiedName(x.name) === mainDlqTopicName);
|
|
1230
|
+
const tableDlqTopic = topics.find((x) => this.getNameFromFullyQualifiedName(x.name) === tableDlqTopicName);
|
|
1231
|
+
const mainSubscriptionName = `${infraPrefix}-${shortHash(this.triggerId)}`;
|
|
1232
|
+
const mainDlqSubscriptionName = `${infraPrefix}-${shortHash(this.triggerId)}-dlq`;
|
|
1233
|
+
const tableSubscriptionName = `${infraPrefix}-${shortHash(this.triggerId)}-bq`;
|
|
1234
|
+
const tableDlqSubscriptionName = `${infraPrefix}-${shortHash(this.triggerId)}-bq-dlq`;
|
|
1244
1235
|
let mainTopicSubscriptions = null;
|
|
1236
|
+
let mainDlqTopicSubscriptions = null;
|
|
1237
|
+
let tableDlqTopicSubscriptions = null;
|
|
1245
1238
|
if (mainTopic) {
|
|
1246
1239
|
[mainTopicSubscriptions] = await mainTopic.getSubscriptions();
|
|
1247
1240
|
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1241
|
+
if (mainDlqTopic) {
|
|
1242
|
+
[mainDlqTopicSubscriptions] = await mainDlqTopic.getSubscriptions();
|
|
1243
|
+
}
|
|
1244
|
+
if (tableDlqTopic) {
|
|
1245
|
+
[tableDlqTopicSubscriptions] = await tableDlqTopic.getSubscriptions();
|
|
1246
|
+
}
|
|
1250
1247
|
const mainSubscription = mainTopicSubscriptions?.find((x) => this.getNameFromFullyQualifiedName(x.name) === mainSubscriptionName) || null;
|
|
1251
|
-
this.
|
|
1252
|
-
const
|
|
1253
|
-
this.
|
|
1248
|
+
const mainDlqSubscription = mainDlqTopicSubscriptions?.find((x) => this.getNameFromFullyQualifiedName(x.name) === mainDlqSubscriptionName) || null;
|
|
1249
|
+
const tableSubscription = mainTopicSubscriptions?.find((x) => this.getNameFromFullyQualifiedName(x.name) === tableSubscriptionName) || null;
|
|
1250
|
+
const tableDlqSubscription = tableDlqTopicSubscriptions?.find((x) => this.getNameFromFullyQualifiedName(x.name) === tableDlqSubscriptionName) || null;
|
|
1254
1251
|
return {
|
|
1255
|
-
|
|
1256
|
-
|
|
1252
|
+
subscriptions: {
|
|
1253
|
+
main: mainSubscription ? {
|
|
1254
|
+
name: mainSubscription.name,
|
|
1255
|
+
shortName: this.getNameFromFullyQualifiedName(mainSubscription.name),
|
|
1256
|
+
isPush: (await mainSubscription.getMetadata())[0]?.pushConfig?.pushEndpoint ? true : false
|
|
1257
|
+
} : null,
|
|
1258
|
+
table: tableSubscription ? {
|
|
1259
|
+
name: tableSubscription.name,
|
|
1260
|
+
shortName: this.getNameFromFullyQualifiedName(tableSubscription.name),
|
|
1261
|
+
tableId: (await tableSubscription.getMetadata())[0]?.bigqueryConfig?.table
|
|
1262
|
+
} : null,
|
|
1263
|
+
tableDlq: tableDlqSubscription ? {
|
|
1264
|
+
name: tableDlqSubscription.name,
|
|
1265
|
+
shortName: this.getNameFromFullyQualifiedName(tableDlqSubscription.name)
|
|
1266
|
+
} : null,
|
|
1267
|
+
mainDlq: mainDlqSubscription ? {
|
|
1268
|
+
name: mainDlqSubscription.name,
|
|
1269
|
+
shortName: this.getNameFromFullyQualifiedName(mainDlqSubscription.name)
|
|
1270
|
+
} : null
|
|
1271
|
+
},
|
|
1272
|
+
topics: {
|
|
1273
|
+
main: mainTopic ? {
|
|
1274
|
+
name: mainTopic.name,
|
|
1275
|
+
shortName: this.getNameFromFullyQualifiedName(mainTopic.name)
|
|
1276
|
+
} : null,
|
|
1277
|
+
mainDlq: mainDlqTopic ? {
|
|
1278
|
+
name: mainDlqTopic.name,
|
|
1279
|
+
shortName: this.getNameFromFullyQualifiedName(mainDlqTopic.name)
|
|
1280
|
+
} : null,
|
|
1281
|
+
tableDlq: tableDlqTopic ? {
|
|
1282
|
+
name: tableDlqTopic.name,
|
|
1283
|
+
shortName: this.getNameFromFullyQualifiedName(tableDlqTopic.name)
|
|
1284
|
+
} : null
|
|
1285
|
+
}
|
|
1257
1286
|
};
|
|
1258
1287
|
}
|
|
1259
1288
|
async pause(topicName) {
|