@causa/workspace-google 0.9.3 → 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:
|
|
11
|
-
maxOutstandingMessages:
|
|
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';
|
|
@@ -109,7 +110,6 @@ export class CloudRunPubSubTriggerService {
|
|
|
109
110
|
}
|
|
110
111
|
this.invokerBindingIds.add(invokerBindingId);
|
|
111
112
|
this.logger.info(`🛂 Granting invoker IAM role to backfilling service account '${pubSubServiceAccount}' for Cloud Run service '${serviceId}'.`);
|
|
112
|
-
// This may fail due to eventual consistency during service account creation.
|
|
113
113
|
await this.cloudRunService.addInvokerBinding(serviceId, pubSubServiceAccount);
|
|
114
114
|
return invokerBindingId;
|
|
115
115
|
}
|
|
@@ -138,6 +138,8 @@ export class CloudRunPubSubTriggerService {
|
|
|
138
138
|
minimumBackoff: { seconds: 1, nanos: 0 },
|
|
139
139
|
maximumBackoff: { seconds: 60, nanos: 0 },
|
|
140
140
|
},
|
|
141
|
+
// This can occur due to eventual consistency when the service account is created.
|
|
142
|
+
gaxOpts: { retry: { retryCodes: [grpc.status.INVALID_ARGUMENT] } },
|
|
141
143
|
});
|
|
142
144
|
return subscriptionId;
|
|
143
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,11 +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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
policy,
|
|
46
|
-
});
|
|
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] } });
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
48
|
* Removes a service account from the list of allowed invokers of a Cloud Run service.
|
|
@@ -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
|
-
|
|
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.
|
|
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",
|
|
@@ -34,42 +34,42 @@
|
|
|
34
34
|
"@causa/workspace-core": ">= 0.22.3 < 1.0.0",
|
|
35
35
|
"@causa/workspace-typescript": ">= 0.10.2 < 1.0.0",
|
|
36
36
|
"@google-cloud/apikeys": "^2.1.0",
|
|
37
|
-
"@google-cloud/bigquery": "^8.
|
|
38
|
-
"@google-cloud/iam-credentials": "^4.0
|
|
39
|
-
"@google-cloud/pubsub": "^5.
|
|
40
|
-
"@google-cloud/resource-manager": "^6.0
|
|
41
|
-
"@google-cloud/run": "^2.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
42
|
"@google-cloud/secret-manager": "^6.0.1",
|
|
43
43
|
"@google-cloud/service-usage": "^4.1.0",
|
|
44
|
-
"@google-cloud/spanner": "
|
|
44
|
+
"@google-cloud/spanner": "8.0.0",
|
|
45
45
|
"@google-cloud/storage": "^7.16.0",
|
|
46
46
|
"class-validator": "^0.14.2",
|
|
47
|
-
"firebase": "^11.
|
|
48
|
-
"firebase-admin": "^13.
|
|
47
|
+
"firebase": "^11.9.1",
|
|
48
|
+
"firebase-admin": "^13.4.0",
|
|
49
49
|
"globby": "^14.1.0",
|
|
50
|
-
"google-auth-library": "^
|
|
51
|
-
"google-gax": "
|
|
52
|
-
"googleapis": "^
|
|
53
|
-
"pino": "^9.
|
|
54
|
-
"quicktype-core": "^23.
|
|
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.
|
|
58
|
+
"@swc/core": "^1.12.1",
|
|
59
59
|
"@swc/jest": "^0.2.38",
|
|
60
|
-
"@tsconfig/node20": "^20.1.
|
|
61
|
-
"@types/jest": "^
|
|
62
|
-
"@types/node": "^18.19.
|
|
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.
|
|
65
|
+
"eslint": "^9.29.0",
|
|
66
66
|
"eslint-config-prettier": "^10.1.5",
|
|
67
|
-
"eslint-plugin-prettier": "^5.
|
|
68
|
-
"jest": "^
|
|
69
|
-
"jest-extended": "^
|
|
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
72
|
"typescript": "^5.8.3",
|
|
73
|
-
"typescript-eslint": "^8.
|
|
73
|
+
"typescript-eslint": "^8.34.1"
|
|
74
74
|
}
|
|
75
75
|
}
|