@causa/workspace-google 0.9.2 → 0.9.4

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.
@@ -7,8 +7,8 @@ import { PubSubService } from '../services/index.js';
7
7
  */
8
8
  const PUBLISH_OPTIONS = {
9
9
  flowControlOptions: {
10
- maxOutstandingBytes: 512 * 1024 * 1024,
11
- maxOutstandingMessages: 100000,
10
+ maxOutstandingBytes: 10 * 1024 * 1024,
11
+ maxOutstandingMessages: 1000,
12
12
  },
13
13
  batching: {
14
14
  maxBytes: 10 * 1024 * 1024,
@@ -2,6 +2,7 @@ import { WorkspaceContext } from '@causa/workspace';
2
2
  import { EventTopicTriggerCreationError } from '@causa/workspace-core';
3
3
  import { Subscription } from '@google-cloud/pubsub';
4
4
  import { randomBytes } from 'crypto';
5
+ import { grpc } from 'google-gax';
5
6
  import { CloudRunService } from './cloud-run.js';
6
7
  import { IamService } from './iam.js';
7
8
  import { PubSubService } from './pubsub.js';
@@ -137,6 +138,8 @@ export class CloudRunPubSubTriggerService {
137
138
  minimumBackoff: { seconds: 1, nanos: 0 },
138
139
  maximumBackoff: { seconds: 60, nanos: 0 },
139
140
  },
141
+ // This can occur due to eventual consistency when the service account is created.
142
+ gaxOpts: { retry: { retryCodes: [grpc.status.INVALID_ARGUMENT] } },
140
143
  });
141
144
  return subscriptionId;
142
145
  }
@@ -1,4 +1,5 @@
1
1
  import { ServicesClient } from '@google-cloud/run';
2
+ import { grpc } from 'google-gax';
2
3
  /**
3
4
  * The role used to allow a service account to call a Cloud Run service.
4
5
  */
@@ -39,10 +40,9 @@ export class CloudRunService {
39
40
  const members = [`serviceAccount:${serviceAccountEmail}`];
40
41
  const binding = { role: INVOKER_ROLE, members };
41
42
  policy.bindings = [...(policy.bindings ?? []), binding];
42
- await this.servicesClient.setIamPolicy({
43
- resource: serviceId,
44
- policy,
45
- });
43
+ await this.servicesClient.setIamPolicy({ resource: serviceId, policy },
44
+ // This can occur due to eventual consistency when the service account is created.
45
+ { retry: { retryCodes: [grpc.status.INVALID_ARGUMENT] } });
46
46
  }
47
47
  /**
48
48
  * Removes a service account from the list of allowed invokers of a Cloud Run service.
@@ -19,11 +19,11 @@ export class PubSubService {
19
19
  */
20
20
  projectId;
21
21
  constructor(context) {
22
- this.pubSub = new PubSub();
23
22
  this.resourceManagerService = context.service(ResourceManagerService);
24
23
  this.projectId = context
25
24
  .asConfiguration()
26
25
  .getOrThrow('google.project');
26
+ this.pubSub = new PubSub({ projectId: this.projectId });
27
27
  }
28
28
  /**
29
29
  * The cached promise that resolves to the GCP service account used by Pub/Sub.
@@ -17,16 +17,12 @@ export class ResourceManagerService {
17
17
  * @returns The number of the GCP project.
18
18
  */
19
19
  async getProjectNumber(projectId) {
20
- const [projects] = await this.projectsClient.searchProjects({
21
- query: `projectId:${projectId}`,
22
- pageSize: 1,
23
- });
20
+ const [projects] = await this.projectsClient.searchProjects({ query: `projectId:${projectId}`, pageSize: 1 }, { autoPaginate: false });
24
21
  if (projects.length < 1) {
25
22
  throw new Error(`Could not find GCP project '${projectId}'.`);
26
23
  }
27
24
  const [project] = projects;
28
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
- const [projectsConst, projectNumber] = project.name?.split('/') ?? [];
25
+ const projectNumber = project.name?.split('/').at(1);
30
26
  if (!projectNumber) {
31
27
  throw new Error(`Failed to parse invalid project name '${project.name}'.`);
32
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causa/workspace-google",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "description": "The Causa workspace module providing many functionalities related to GCP and its services.",
5
5
  "repository": "github:causa-io/workspace-module-google",
6
6
  "license": "ISC",
@@ -31,45 +31,45 @@
31
31
  "dependencies": {
32
32
  "@causa/cli": ">= 0.6.1 < 1.0.0",
33
33
  "@causa/workspace": ">= 0.16.1 < 1.0.0",
34
- "@causa/workspace-core": ">= 0.22.2 < 1.0.0",
35
- "@causa/workspace-typescript": ">= 0.10.1 < 1.0.0",
36
- "@google-cloud/apikeys": "^1.3.1",
37
- "@google-cloud/bigquery": "^7.9.2",
38
- "@google-cloud/iam-credentials": "^3.3.0",
39
- "@google-cloud/pubsub": "^4.10.0",
40
- "@google-cloud/resource-manager": "^5.3.1",
41
- "@google-cloud/run": "^1.5.1",
42
- "@google-cloud/secret-manager": "^5.6.0",
43
- "@google-cloud/service-usage": "^3.4.1",
44
- "@google-cloud/spanner": "7.19.1",
45
- "@google-cloud/storage": "^7.15.2",
46
- "class-validator": "^0.14.1",
47
- "firebase": "^11.4.0",
48
- "firebase-admin": "^13.2.0",
34
+ "@causa/workspace-core": ">= 0.22.3 < 1.0.0",
35
+ "@causa/workspace-typescript": ">= 0.10.2 < 1.0.0",
36
+ "@google-cloud/apikeys": "^2.1.0",
37
+ "@google-cloud/bigquery": "^8.1.0",
38
+ "@google-cloud/iam-credentials": "^4.1.0",
39
+ "@google-cloud/pubsub": "^5.1.0",
40
+ "@google-cloud/resource-manager": "^6.1.0",
41
+ "@google-cloud/run": "^2.1.0",
42
+ "@google-cloud/secret-manager": "^6.0.1",
43
+ "@google-cloud/service-usage": "^4.1.0",
44
+ "@google-cloud/spanner": "8.0.0",
45
+ "@google-cloud/storage": "^7.16.0",
46
+ "class-validator": "^0.14.2",
47
+ "firebase": "^11.9.1",
48
+ "firebase-admin": "^13.4.0",
49
49
  "globby": "^14.1.0",
50
- "google-auth-library": "^9.15.1",
51
- "google-gax": "4.4.1",
52
- "googleapis": "^146.0.0",
53
- "pino": "^9.6.0",
54
- "quicktype-core": "^23.0.171",
50
+ "google-auth-library": "^10.1.0",
51
+ "google-gax": "5.0.1-rc.1",
52
+ "googleapis": "^150.0.1",
53
+ "pino": "^9.7.0",
54
+ "quicktype-core": "^23.2.6",
55
55
  "uuid": "^11.1.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@swc/core": "^1.11.10",
59
- "@swc/jest": "^0.2.37",
60
- "@tsconfig/node20": "^20.1.4",
61
- "@types/jest": "^29.5.14",
62
- "@types/node": "^18.19.80",
58
+ "@swc/core": "^1.12.1",
59
+ "@swc/jest": "^0.2.38",
60
+ "@tsconfig/node20": "^20.1.6",
61
+ "@types/jest": "^30.0.0",
62
+ "@types/node": "^18.19.112",
63
63
  "@types/uuid": "^10.0.0",
64
64
  "copyfiles": "^2.4.1",
65
- "eslint": "^9.22.0",
66
- "eslint-config-prettier": "^10.1.1",
67
- "eslint-plugin-prettier": "^5.2.3",
68
- "jest": "^29.7.0",
69
- "jest-extended": "^4.0.2",
65
+ "eslint": "^9.29.0",
66
+ "eslint-config-prettier": "^10.1.5",
67
+ "eslint-plugin-prettier": "^5.5.0",
68
+ "jest": "^30.0.0",
69
+ "jest-extended": "^6.0.0",
70
70
  "rimraf": "^6.0.1",
71
71
  "ts-node": "^10.9.2",
72
- "typescript": "^5.8.2",
73
- "typescript-eslint": "^8.26.1"
72
+ "typescript": "^5.8.3",
73
+ "typescript-eslint": "^8.34.1"
74
74
  }
75
75
  }