@shushed/helpers 0.0.159 → 0.0.160

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.
Files changed (2) hide show
  1. package/dist/index.js +0 -56
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -107196,7 +107196,6 @@ var PubSubHelper = class extends Runtime {
107196
107196
  return `${infraPrefix}-${shortHash(this.triggerId)}`;
107197
107197
  }
107198
107198
  async createOrUpdate(opts) {
107199
- this.logging.log("createOrUpdate called with", opts);
107200
107199
  const [topics] = await this.pubSub.getTopics();
107201
107200
  const infraPrefix = opts.topicName.indexOf("---") !== -1 ? opts.topicName : `${this.envName}---${opts.topicName}`;
107202
107201
  const mainDlqTopicName = `${infraPrefix}-${shortHash(this.triggerId)}-dlq`;
@@ -107229,7 +107228,6 @@ var PubSubHelper = class extends Runtime {
107229
107228
  mainTopic = await this.ensureTopicExists(opts.topicName);
107230
107229
  }
107231
107230
  if (!opts.table) {
107232
- this.logging.log("createOrUpdate deleting table subscriptions");
107233
107231
  if (tableSubscription) {
107234
107232
  await tableSubscription.delete();
107235
107233
  tableSubscription = null;
@@ -107239,9 +107237,7 @@ var PubSubHelper = class extends Runtime {
107239
107237
  tableDlqSubscription = null;
107240
107238
  }
107241
107239
  } else {
107242
- this.logging.log("createOrUpdate creating table subscription");
107243
107240
  if (opts.createDeadLetterQueues) {
107244
- this.logging.log("createOrUpdate ensuring dlqs exist for table subscription");
107245
107241
  tableDlqTopic = await this.ensureTopicExists(tableDlqTopicName);
107246
107242
  tableDlqSubscription = await this.ensureSubscribtionExists(tableDlqSubscriptionName, {
107247
107243
  topic: tableDlqTopic,
@@ -107249,7 +107245,6 @@ var PubSubHelper = class extends Runtime {
107249
107245
  dlqTopic: null
107250
107246
  });
107251
107247
  }
107252
- this.logging.log("createOrUpdate ensuring the table subscription exists");
107253
107248
  tableSubscription = await this.ensureSubscribtionExists(tableSubscriptionName, {
107254
107249
  topic,
107255
107250
  tableId: opts.table.tableId,
@@ -107262,7 +107257,6 @@ var PubSubHelper = class extends Runtime {
107262
107257
  }
107263
107258
  const pullPushSubscription = opts.pull || opts.push;
107264
107259
  if (!pullPushSubscription) {
107265
- this.logging.log("createOrUpdate deleting main subscriptions");
107266
107260
  if (mainSubscription) {
107267
107261
  await mainSubscription.delete();
107268
107262
  mainSubscription = null;
@@ -107273,7 +107267,6 @@ var PubSubHelper = class extends Runtime {
107273
107267
  }
107274
107268
  } else {
107275
107269
  if (opts.createDeadLetterQueues) {
107276
- this.logging.log("createOrUpdate creating dlqs for main subscription");
107277
107270
  mainDlqTopic = await this.ensureTopicExists(mainDlqTopicName);
107278
107271
  mainDlqSubscription = await this.ensureSubscribtionExists(mainDlqSubscriptionName, {
107279
107272
  topic: mainDlqTopic,
@@ -107292,7 +107285,6 @@ var PubSubHelper = class extends Runtime {
107292
107285
  });
107293
107286
  }
107294
107287
  if (!opts.createDeadLetterQueues) {
107295
- this.logging.log("createOrUpdate deleting all dlqs");
107296
107288
  if (mainDlqSubscription) {
107297
107289
  await mainDlqSubscription.delete();
107298
107290
  mainDlqSubscription = null;
@@ -107322,16 +107314,13 @@ var PubSubHelper = class extends Runtime {
107322
107314
  return topics.find((topic) => this.getNameFromFullyQualifiedName(topic.name) === topicName);
107323
107315
  }
107324
107316
  async ensureTopicExists(topicName) {
107325
- this.logging.log("ensureTopicExists called with", topicName);
107326
107317
  let topic = await this.findTopic(topicName);
107327
- this.logging.log(`ensureTopicExists topic ${!topic ? "does not " : ""}exists`);
107328
107318
  let topicMetadata;
107329
107319
  try {
107330
107320
  [topicMetadata] = await topic?.getMetadata() || [null];
107331
107321
  } catch (err) {
107332
107322
  throw new Error("Invariant: While getting topic metadata - " + err.message);
107333
107323
  }
107334
- this.logging.log(`ensureTopicExists retrieved topic metadata`);
107335
107324
  const metadata = {
107336
107325
  labels: {
107337
107326
  "created-at": (/* @__PURE__ */ new Date()).getTime().toString(),
@@ -107347,7 +107336,6 @@ var PubSubHelper = class extends Runtime {
107347
107336
  const simMetadata = Object.assign({}, topicMetadata?.labels || {}, metadata.labels);
107348
107337
  if (!(0, import_lodash.default)(topicMetadata?.labels, simMetadata)) {
107349
107338
  simMetadata["last-modified-at"] = (/* @__PURE__ */ new Date()).getTime().toString();
107350
- this.logging.log(`ensureTopicExists topic metadata has changed updating with`, simMetadata);
107351
107339
  try {
107352
107340
  await topic.setMetadata({
107353
107341
  labels: simMetadata
@@ -107358,10 +107346,6 @@ var PubSubHelper = class extends Runtime {
107358
107346
  }
107359
107347
  }
107360
107348
  } else {
107361
- this.logging.log(`ensureTopicExists creating new topic`, {
107362
- name: topicName,
107363
- labels: metadata.labels
107364
- });
107365
107349
  await this.pubSub.createTopic({
107366
107350
  name: topicName,
107367
107351
  labels: metadata.labels
@@ -107384,27 +107368,11 @@ var PubSubHelper = class extends Runtime {
107384
107368
  retryMaxDelay: 360,
107385
107369
  ackDeadline: 90
107386
107370
  };
107387
- this.logging.log("updateSubscription called with", subscriptionName, !!subscription, subscriptionMetaData, Object.assign({}, inputOpts, {
107388
- topic: inputOpts.topic.name,
107389
- dlqTopic: inputOpts.dlqTopic?.name
107390
- }));
107391
107371
  const opts = Object.assign({}, defaultOptions, inputOpts);
107392
- this.logging.log("updateSubscription final opts", Object.assign({}, opts, {
107393
- topic: opts.topic.name,
107394
- dlqTopic: opts.dlqTopic?.name
107395
- }));
107396
107372
  let nextMetadata = null;
107397
107373
  if (isSubscriptionOptionsPush(opts)) {
107398
- this.logging.log("updateSubscription, subscription is push");
107399
107374
  if (opts.endpointUrl !== subscriptionMetaData?.pushConfig?.pushEndpoint || this.serviceAccountEmail !== subscriptionMetaData?.pushConfig.oidcToken?.serviceAccountEmail || process.env.GCLOUD_PROJECT + "/" + this.triggerId !== subscriptionMetaData.pushConfig.oidcToken.audience) {
107400
107375
  if (subscriptionMetaData?.pushConfig?.pushEndpoint && subscription) {
107401
- this.logging.log("updateSubscription pushConfig changed, push configuration already exists, modifying", {
107402
- pushEndpoint: opts.endpointUrl,
107403
- oidcToken: {
107404
- serviceAccountEmail: this.serviceAccountEmail,
107405
- audience: process.env.GCLOUD_PROJECT + "/" + this.triggerId
107406
- }
107407
- });
107408
107376
  try {
107409
107377
  await subscription.modifyPushConfig({
107410
107378
  pushEndpoint: opts.endpointUrl,
@@ -107496,7 +107464,6 @@ var PubSubHelper = class extends Runtime {
107496
107464
  nextMetadata.bigqueryConfig = null;
107497
107465
  }
107498
107466
  if (subscription && nextMetadata) {
107499
- this.logging.log("updateSubscription updating subscription", nextMetadata);
107500
107467
  try {
107501
107468
  await subscription.setMetadata(nextMetadata);
107502
107469
  } catch (err) {
@@ -107509,20 +107476,14 @@ var PubSubHelper = class extends Runtime {
107509
107476
  async ensureSubscribtionExists(subscriptionName, opts) {
107510
107477
  let [subscriptions] = await opts.topic.getSubscriptions();
107511
107478
  let subscription = subscriptions.find((subscription2) => this.getNameFromFullyQualifiedName(subscription2.name) === subscriptionName) || null;
107512
- this.logging.log("ensureSubscribtionExists called with", subscriptionName, Object.assign({}, opts, {
107513
- topic: opts.topic.name,
107514
- dlqTopic: opts.dlqTopic?.name
107515
- }));
107516
107479
  let subscriptionMetaData;
107517
107480
  try {
107518
107481
  [subscriptionMetaData] = await subscription?.getMetadata() || [null];
107519
107482
  } catch (err) {
107520
107483
  throw new Error("Invariant: While getting subscription metadata - " + err.message);
107521
107484
  }
107522
- this.logging.log("ensureSubscribtionExists retrieved subscriptionMetaData", subscriptionMetaData);
107523
107485
  const createPayload = await this.updateSubscription(subscriptionName, subscription, subscriptionMetaData, opts);
107524
107486
  if (createPayload && !subscription) {
107525
- this.logging.log(`ensureSubscribtionExists creating subscription: ${subscriptionName} on topic: ${opts.topic.name} with`, createPayload);
107526
107487
  await opts.topic.createSubscription(subscriptionName, createPayload);
107527
107488
  [subscriptions] = await opts.topic.getSubscriptions();
107528
107489
  subscription = subscriptions.find((subscription2) => this.getNameFromFullyQualifiedName(subscription2.name) === subscriptionName) || null;
@@ -107533,7 +107494,6 @@ var PubSubHelper = class extends Runtime {
107533
107494
  return subscription;
107534
107495
  }
107535
107496
  async deleteSubscriptions(topicName) {
107536
- this.logging.log("deleteSubscriptions called with", topicName);
107537
107497
  return this.createOrUpdate({
107538
107498
  topicName,
107539
107499
  createDeadLetterQueues: false,
@@ -107543,7 +107503,6 @@ var PubSubHelper = class extends Runtime {
107543
107503
  });
107544
107504
  }
107545
107505
  async getStatus(topicName) {
107546
- this.logging.log("getStatus called with", topicName);
107547
107506
  const [topics] = await this.pubSub.getTopics();
107548
107507
  const infraPrefix = topicName.indexOf("---") !== -1 ? topicName : `${this.envName}---${topicName}`;
107549
107508
  const mainDlqTopicName = `${infraPrefix}-${shortHash(this.triggerId)}-dlq`;
@@ -107611,16 +107570,13 @@ var PubSubHelper = class extends Runtime {
107611
107570
  async pause(topicName) {
107612
107571
  const [topics] = await this.pubSub.getTopics();
107613
107572
  const mainTopic = topics.find((x) => this.getNameFromFullyQualifiedName(x.name) === topicName);
107614
- this.logging.log("paused called with", topicName);
107615
107573
  const infraPrefix = topicName.indexOf("---") !== -1 ? topicName : `${this.envName}---${topicName}`;
107616
107574
  let mainTopicSubscriptions = null;
107617
107575
  if (mainTopic) {
107618
107576
  [mainTopicSubscriptions] = await mainTopic.getSubscriptions();
107619
107577
  }
107620
107578
  const mainSubscriptionName = `${infraPrefix}-${shortHash(this.triggerId)}`;
107621
- this.logging.log("isRunning checking the", mainSubscriptionName);
107622
107579
  const mainSubscription = mainTopicSubscriptions?.find((x) => this.getNameFromFullyQualifiedName(x.name) === mainSubscriptionName) || null;
107623
- this.logging.log("pause found the", mainSubscription?.name);
107624
107580
  if (mainSubscription) {
107625
107581
  try {
107626
107582
  await mainSubscription.setMetadata({
@@ -107641,27 +107597,15 @@ var PubSubHelper = class extends Runtime {
107641
107597
  async resume(topicName) {
107642
107598
  const [topics] = await this.pubSub.getTopics();
107643
107599
  const mainTopic = topics.find((x) => this.getNameFromFullyQualifiedName(x.name) === topicName);
107644
- this.logging.log("resume called with", topicName);
107645
107600
  const infraPrefix = topicName.indexOf("---") !== -1 ? topicName : `${this.envName}---${topicName}`;
107646
107601
  let mainTopicSubscriptions = null;
107647
107602
  if (mainTopic) {
107648
107603
  [mainTopicSubscriptions] = await mainTopic.getSubscriptions();
107649
107604
  }
107650
107605
  const mainSubscriptionName = `${infraPrefix}-${shortHash(this.triggerId)}`;
107651
- this.logging.log("resume checking the", mainSubscriptionName);
107652
107606
  const mainSubscription = mainTopicSubscriptions?.find((x) => this.getNameFromFullyQualifiedName(x.name) === mainSubscriptionName) || null;
107653
- this.logging.log("resume found the", mainSubscription?.name);
107654
107607
  if (mainSubscription) {
107655
107608
  try {
107656
- this.logging.log("resume setting metadata", {
107657
- pushConfig: {
107658
- pushEndpoint: this.runtimeUrl + "/executeWorkflow/" + this.workflowId + "/" + this.triggerId + `?topic_name=${topicName}`,
107659
- oidcToken: {
107660
- serviceAccountEmail: this.serviceAccountEmail,
107661
- audience: process.env.GCLOUD_PROJECT + "/" + this.triggerId
107662
- }
107663
- }
107664
- });
107665
107609
  await mainSubscription.setMetadata({
107666
107610
  pushConfig: {
107667
107611
  pushEndpoint: this.runtimeUrl + "/executeWorkflow/" + this.workflowId + "/" + this.triggerId + `?topic_name=${topicName}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.159",
3
+ "version": "0.0.160",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",