@causa/workspace-google 0.4.0 → 0.5.0
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/README.md +6 -0
- package/dist/backfilling/bigquery.d.ts +53 -0
- package/dist/backfilling/bigquery.js +99 -0
- package/dist/backfilling/index.d.ts +2 -0
- package/dist/backfilling/index.js +2 -0
- package/dist/backfilling/pubsub.d.ts +34 -0
- package/dist/backfilling/pubsub.js +63 -0
- package/dist/configurations/google.d.ts +9 -0
- package/dist/functions/emulator/index.d.ts +10 -0
- package/dist/functions/emulator/index.js +10 -0
- package/dist/functions/{emulator-start-firebase-storage.js → emulator/start-firebase-storage.js} +4 -4
- package/dist/functions/{emulator-start-firestore.js → emulator/start-firestore.js} +3 -3
- package/dist/functions/{emulator-start-identity-platform.js → emulator/start-identity-platform.js} +3 -3
- package/dist/functions/{emulator-start-pubsub.js → emulator/start-pubsub.js} +3 -3
- package/dist/functions/{emulator-start-spanner.js → emulator/start-spanner.js} +3 -3
- package/dist/functions/{emulator-stop-firebase-storage.js → emulator/stop-firebase-storage.js} +1 -1
- package/dist/functions/{emulator-stop-firestore.js → emulator/stop-firestore.js} +1 -1
- package/dist/functions/{emulator-stop-identity-platform.js → emulator/stop-identity-platform.js} +1 -1
- package/dist/functions/{emulator-stop-pubsub.js → emulator/stop-pubsub.js} +1 -1
- package/dist/functions/{emulator-stop-spanner.js → emulator/stop-spanner.js} +1 -1
- package/dist/functions/event-topic/broker-create-topic-pubsub.d.ts +11 -0
- package/dist/functions/event-topic/broker-create-topic-pubsub.js +27 -0
- package/dist/functions/event-topic/broker-create-trigger-cloud-run.d.ts +11 -0
- package/dist/functions/event-topic/broker-create-trigger-cloud-run.js +38 -0
- package/dist/functions/event-topic/broker-delete-topic-pubsub.d.ts +10 -0
- package/dist/functions/event-topic/broker-delete-topic-pubsub.js +26 -0
- package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.d.ts +11 -0
- package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.js +29 -0
- package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.d.ts +10 -0
- package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.js +31 -0
- package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.d.ts +11 -0
- package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.js +28 -0
- package/dist/functions/event-topic/broker-get-topic-id-pubsub.d.ts +10 -0
- package/dist/functions/event-topic/broker-get-topic-id-pubsub.js +16 -0
- package/dist/functions/event-topic/broker-publish-events-google.d.ts +17 -0
- package/dist/functions/event-topic/broker-publish-events-google.js +45 -0
- package/dist/functions/event-topic/index.d.ts +8 -0
- package/dist/functions/event-topic/index.js +8 -0
- package/dist/functions/{google-app-check-generate-token.js → google-app-check/generate-token.js} +2 -2
- package/dist/functions/google-app-check/index.d.ts +1 -0
- package/dist/functions/google-app-check/index.js +1 -0
- package/dist/functions/google-firebase-storage/index.d.ts +1 -0
- package/dist/functions/google-firebase-storage/index.js +1 -0
- package/dist/functions/{google-firebase-storage-merge-rules.d.ts → google-firebase-storage/merge-rules.d.ts} +1 -1
- package/dist/functions/{google-firebase-storage-merge-rules.js → google-firebase-storage/merge-rules.js} +2 -2
- package/dist/functions/google-firestore/index.d.ts +1 -0
- package/dist/functions/google-firestore/index.js +1 -0
- package/dist/functions/{google-firestore-merge-rules.d.ts → google-firestore/merge-rules.d.ts} +1 -1
- package/dist/functions/{google-firestore-merge-rules.js → google-firestore/merge-rules.js} +2 -2
- package/dist/functions/{google-identity-platform-generate-custom-token.js → google-identity-platform/generate-custom-token.js} +1 -1
- package/dist/functions/{google-identity-platform-generate-token.js → google-identity-platform/generate-token.js} +3 -3
- package/dist/functions/google-identity-platform/index.d.ts +2 -0
- package/dist/functions/google-identity-platform/index.js +2 -0
- package/dist/functions/google-pubsub/index.d.ts +1 -0
- package/dist/functions/google-pubsub/index.js +1 -0
- package/dist/functions/{google-services-enable.d.ts → google-services/enable.d.ts} +1 -1
- package/dist/functions/{google-services-enable.js → google-services/enable.js} +1 -1
- package/dist/functions/google-services/index.d.ts +1 -0
- package/dist/functions/google-services/index.js +1 -0
- package/dist/functions/google-spanner/index.d.ts +2 -0
- package/dist/functions/google-spanner/index.js +2 -0
- package/dist/functions/{google-spanner-write-databases.js → google-spanner/write-databases.js} +1 -1
- package/dist/functions/index.js +12 -24
- package/dist/functions/project/index.d.ts +3 -0
- package/dist/functions/project/index.js +3 -0
- package/dist/functions/{project-push-artefact-cloud-functions.js → project/push-artefact-cloud-functions.js} +1 -1
- package/dist/functions/{secret-fetch-secret-manager.js → secret/fetch-secret-manager.js} +1 -1
- package/dist/functions/secret/index.d.ts +1 -0
- package/dist/functions/secret/index.js +1 -0
- package/dist/services/bigquery.d.ts +16 -0
- package/dist/services/bigquery.js +19 -0
- package/dist/services/cloud-run-pubsub-trigger.d.ts +101 -0
- package/dist/services/cloud-run-pubsub-trigger.js +177 -0
- package/dist/services/cloud-run.d.ts +35 -0
- package/dist/services/cloud-run.js +72 -0
- package/dist/services/iam.d.ts +43 -0
- package/dist/services/iam.js +65 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.js +6 -0
- package/dist/services/pubsub.d.ts +41 -0
- package/dist/services/pubsub.js +62 -0
- package/dist/services/resource-manager.d.ts +18 -0
- package/dist/services/resource-manager.js +35 -0
- package/package.json +16 -12
- /package/dist/functions/{emulator-start-firebase-storage.d.ts → emulator/start-firebase-storage.d.ts} +0 -0
- /package/dist/functions/{emulator-start-firestore.d.ts → emulator/start-firestore.d.ts} +0 -0
- /package/dist/functions/{emulator-start-identity-platform.d.ts → emulator/start-identity-platform.d.ts} +0 -0
- /package/dist/functions/{emulator-start-pubsub.d.ts → emulator/start-pubsub.d.ts} +0 -0
- /package/dist/functions/{emulator-start-spanner.d.ts → emulator/start-spanner.d.ts} +0 -0
- /package/dist/functions/{emulator-stop-firebase-storage.d.ts → emulator/stop-firebase-storage.d.ts} +0 -0
- /package/dist/functions/{emulator-stop-firestore.d.ts → emulator/stop-firestore.d.ts} +0 -0
- /package/dist/functions/{emulator-stop-identity-platform.d.ts → emulator/stop-identity-platform.d.ts} +0 -0
- /package/dist/functions/{emulator-stop-pubsub.d.ts → emulator/stop-pubsub.d.ts} +0 -0
- /package/dist/functions/{emulator-stop-spanner.d.ts → emulator/stop-spanner.d.ts} +0 -0
- /package/dist/functions/{google-app-check-generate-token.d.ts → google-app-check/generate-token.d.ts} +0 -0
- /package/dist/functions/{google-identity-platform-generate-custom-token.d.ts → google-identity-platform/generate-custom-token.d.ts} +0 -0
- /package/dist/functions/{google-identity-platform-generate-token.d.ts → google-identity-platform/generate-token.d.ts} +0 -0
- /package/dist/functions/{google-pubsub-write-topics.d.ts → google-pubsub/write-topics.d.ts} +0 -0
- /package/dist/functions/{google-pubsub-write-topics.js → google-pubsub/write-topics.js} +0 -0
- /package/dist/functions/{google-spanner-list-databases.d.ts → google-spanner/list-databases.d.ts} +0 -0
- /package/dist/functions/{google-spanner-list-databases.js → google-spanner/list-databases.js} +0 -0
- /package/dist/functions/{google-spanner-write-databases.d.ts → google-spanner/write-databases.d.ts} +0 -0
- /package/dist/functions/{project-get-artefact-destination-cloud-functions.d.ts → project/get-artefact-destination-cloud-functions.d.ts} +0 -0
- /package/dist/functions/{project-get-artefact-destination-cloud-functions.js → project/get-artefact-destination-cloud-functions.js} +0 -0
- /package/dist/functions/{project-get-artefact-destination-cloud-run.d.ts → project/get-artefact-destination-cloud-run.d.ts} +0 -0
- /package/dist/functions/{project-get-artefact-destination-cloud-run.js → project/get-artefact-destination-cloud-run.js} +0 -0
- /package/dist/functions/{project-push-artefact-cloud-functions.d.ts → project/push-artefact-cloud-functions.d.ts} +0 -0
- /package/dist/functions/{secret-fetch-secret-manager.d.ts → secret/fetch-secret-manager.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -35,6 +35,12 @@ The following emulators are implemented:
|
|
|
35
35
|
- `google.pubSub`: The Pub/Sub emulator from the `gcloud` tools. It automatically creates the topics for all event topics found in the Causa workspace. `events.broker` must be set to `google.pubSub` for this.
|
|
36
36
|
- `google.spanner`: The Spanner emulator. It automatically creates all the Spanner databases defined in the Causa workspace, and sets up their DDLs. See the `google.spanner` [configuration](./src/configurations/google.ts) for more details.
|
|
37
37
|
|
|
38
|
+
### Backfilling
|
|
39
|
+
|
|
40
|
+
Backfilling is supported when `google.pubSub` is set as the `events.broker`. Temporary triggers can be created for Cloud Run services, by referencing them using the format `[[projects/<projectId>/]locations/<location>/]services/<name>/path-to-trigger`.
|
|
41
|
+
|
|
42
|
+
When no source is specified, the default is to fetch events to backfill from the BigQuery dataset configured in `google.pubSub.bigQueryStorage`. A custom BigQuery table can also be set as source using the `bq://<projectId>.<datasetId>.<tableId>` format. It should have the `data` and `attributes` columns.
|
|
43
|
+
|
|
38
44
|
### Secrets backend
|
|
39
45
|
|
|
40
46
|
This module implements the `google.secretManager` secret backend, allowing fetching secrets from the Google Secret Manager service. Here are some example of how secrets with the `google.secretManager` backend should be defined:
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { BackfillEvent, BackfillEventsSource } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* An events source that reads events from a BigQuery table.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BigQueryEventsSource implements BackfillEventsSource {
|
|
7
|
+
readonly tableId: string;
|
|
8
|
+
readonly filter?: string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* The BigQuery client.
|
|
11
|
+
*/
|
|
12
|
+
private readonly bigQuery;
|
|
13
|
+
/**
|
|
14
|
+
* The job from which the events are read.
|
|
15
|
+
*/
|
|
16
|
+
private job;
|
|
17
|
+
/**
|
|
18
|
+
* The request for the next page of results.
|
|
19
|
+
* If this is `null` after initializing the job, there are no more results.
|
|
20
|
+
*/
|
|
21
|
+
private nextPageRequest;
|
|
22
|
+
/**
|
|
23
|
+
* The logger.
|
|
24
|
+
*/
|
|
25
|
+
private readonly logger;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new events source that reads events from a BigQuery table.
|
|
28
|
+
*
|
|
29
|
+
* @param context The {@link WorkspaceContext}.
|
|
30
|
+
* @param tableId The ID of the BigQuery table from which the events should be read.
|
|
31
|
+
* @param filter A SQL boolean expression that filters the events from the table.
|
|
32
|
+
*/
|
|
33
|
+
constructor(context: WorkspaceContext, tableId: string, filter?: string | undefined);
|
|
34
|
+
/**
|
|
35
|
+
* Creates a BigQuery job that reads the events from the table.
|
|
36
|
+
* The `data` and `attributes` columns are read to get the corresponding event properties.
|
|
37
|
+
* If a filter was specified, it is applied to the query as a where clause.
|
|
38
|
+
*
|
|
39
|
+
* @returns The BigQuery job that reads the events from the table.
|
|
40
|
+
*/
|
|
41
|
+
private createJob;
|
|
42
|
+
getBatch(): Promise<BackfillEvent[] | null>;
|
|
43
|
+
dispose(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Tries to create a new {@link BigQueryEventsSource} from the given source string.
|
|
46
|
+
*
|
|
47
|
+
* @param context The {@link WorkspaceContext}.
|
|
48
|
+
* @param source The string representing the source, in the format `bq://<projectId>.<datasetId>.<tableId>`.
|
|
49
|
+
* @param filter A SQL boolean expression that filters the events from the table.
|
|
50
|
+
* @returns A new {@link BigQueryEventsSource} if the source string is valid, otherwise `null`.
|
|
51
|
+
*/
|
|
52
|
+
static fromSourceAndFilter(context: WorkspaceContext, source: string, filter?: string): Promise<BigQueryEventsSource | null>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { BigQueryService } from '../services/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The number of rows (events) in a single batch.
|
|
4
|
+
*/
|
|
5
|
+
const BIGQUERY_MAX_RESULTS = 10000;
|
|
6
|
+
/**
|
|
7
|
+
* An events source that reads events from a BigQuery table.
|
|
8
|
+
*/
|
|
9
|
+
export class BigQueryEventsSource {
|
|
10
|
+
tableId;
|
|
11
|
+
filter;
|
|
12
|
+
/**
|
|
13
|
+
* The BigQuery client.
|
|
14
|
+
*/
|
|
15
|
+
bigQuery;
|
|
16
|
+
/**
|
|
17
|
+
* The job from which the events are read.
|
|
18
|
+
*/
|
|
19
|
+
job = null;
|
|
20
|
+
/**
|
|
21
|
+
* The request for the next page of results.
|
|
22
|
+
* If this is `null` after initializing the job, there are no more results.
|
|
23
|
+
*/
|
|
24
|
+
nextPageRequest = null;
|
|
25
|
+
/**
|
|
26
|
+
* The logger.
|
|
27
|
+
*/
|
|
28
|
+
logger;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new events source that reads events from a BigQuery table.
|
|
31
|
+
*
|
|
32
|
+
* @param context The {@link WorkspaceContext}.
|
|
33
|
+
* @param tableId The ID of the BigQuery table from which the events should be read.
|
|
34
|
+
* @param filter A SQL boolean expression that filters the events from the table.
|
|
35
|
+
*/
|
|
36
|
+
constructor(context, tableId, filter) {
|
|
37
|
+
this.tableId = tableId;
|
|
38
|
+
this.filter = filter;
|
|
39
|
+
this.bigQuery = context.service(BigQueryService).bigQuery;
|
|
40
|
+
this.logger = context.logger;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a BigQuery job that reads the events from the table.
|
|
44
|
+
* The `data` and `attributes` columns are read to get the corresponding event properties.
|
|
45
|
+
* If a filter was specified, it is applied to the query as a where clause.
|
|
46
|
+
*
|
|
47
|
+
* @returns The BigQuery job that reads the events from the table.
|
|
48
|
+
*/
|
|
49
|
+
async createJob() {
|
|
50
|
+
let query = `
|
|
51
|
+
SELECT
|
|
52
|
+
data,
|
|
53
|
+
attributes,
|
|
54
|
+
FROM
|
|
55
|
+
\`${this.tableId}\``;
|
|
56
|
+
if (this.filter) {
|
|
57
|
+
query += `
|
|
58
|
+
WHERE
|
|
59
|
+
(${this.filter})`;
|
|
60
|
+
}
|
|
61
|
+
this.logger.debug(`Creating BigQuery job from query '${query}'.`);
|
|
62
|
+
const [job] = await this.bigQuery.createQueryJob(query);
|
|
63
|
+
return job;
|
|
64
|
+
}
|
|
65
|
+
async getBatch() {
|
|
66
|
+
if (!this.job) {
|
|
67
|
+
this.job = await this.createJob();
|
|
68
|
+
}
|
|
69
|
+
else if (!this.nextPageRequest) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const [rows, nextPageRequest] = await this.job.getQueryResults(this.nextPageRequest ?? {
|
|
73
|
+
autoPaginate: false,
|
|
74
|
+
maxResults: BIGQUERY_MAX_RESULTS,
|
|
75
|
+
});
|
|
76
|
+
this.nextPageRequest = nextPageRequest ?? null;
|
|
77
|
+
return rows.map((row) => ({
|
|
78
|
+
data: Buffer.from(row.data),
|
|
79
|
+
attributes: JSON.parse(row.attributes),
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
async dispose() { }
|
|
83
|
+
/**
|
|
84
|
+
* Tries to create a new {@link BigQueryEventsSource} from the given source string.
|
|
85
|
+
*
|
|
86
|
+
* @param context The {@link WorkspaceContext}.
|
|
87
|
+
* @param source The string representing the source, in the format `bq://<projectId>.<datasetId>.<tableId>`.
|
|
88
|
+
* @param filter A SQL boolean expression that filters the events from the table.
|
|
89
|
+
* @returns A new {@link BigQueryEventsSource} if the source string is valid, otherwise `null`.
|
|
90
|
+
*/
|
|
91
|
+
static async fromSourceAndFilter(context, source, filter) {
|
|
92
|
+
const match = source.match(/^bq:\/\/(?<tableId>.+)$/);
|
|
93
|
+
if (!match?.groups?.tableId) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
const tableId = match.groups.tableId;
|
|
97
|
+
return new BigQueryEventsSource(context, tableId, filter);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { BackfillEvent, BackfillEventPublisher } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* A publisher that publishes events to backfill to a Pub/Sub topic.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PubSubBackfillEventPublisher extends BackfillEventPublisher {
|
|
7
|
+
readonly topicId: string;
|
|
8
|
+
/**
|
|
9
|
+
* The actual publisher, which handles batching and flow control.
|
|
10
|
+
*/
|
|
11
|
+
private readonly publisher;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new {@link PubSubBackfillEventPublisher}.
|
|
14
|
+
*
|
|
15
|
+
* @param context The {@link WorkspaceContext}.
|
|
16
|
+
* @param topicId The ID of the Pub/Sub topic to publish to.
|
|
17
|
+
* This should be a full Pub/Sub topic ID, e.g. `projects/<projectId>/topics/<topicId>`.
|
|
18
|
+
*/
|
|
19
|
+
constructor(context: WorkspaceContext, topicId: string);
|
|
20
|
+
/**
|
|
21
|
+
* Publishes an event to the Pub/Sub topic.
|
|
22
|
+
* Publishing actually occurs asynchronously. {@link PubSubBackfillEventPublisher.flush} must be called to wait for
|
|
23
|
+
* all events to be published.
|
|
24
|
+
*
|
|
25
|
+
* @param event The event to publish.
|
|
26
|
+
* @returns A promise that resolves when the publisher has caught up with publishing, or `null` if other events can be
|
|
27
|
+
* published immediately.
|
|
28
|
+
*/
|
|
29
|
+
protected publishEvent(event: BackfillEvent): Promise<void> | null;
|
|
30
|
+
/**
|
|
31
|
+
* Waits for all events to be published.
|
|
32
|
+
*/
|
|
33
|
+
protected flush(): Promise<void>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BackfillEventPublisher } from '@causa/workspace-core';
|
|
2
|
+
import { PubSubService } from '../services/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options when publishing events in batches to Pub/Sub.
|
|
5
|
+
*/
|
|
6
|
+
const PUBLISH_OPTIONS = {
|
|
7
|
+
flowControlOptions: {
|
|
8
|
+
maxOutstandingBytes: 512 * 1024 * 1024,
|
|
9
|
+
maxOutstandingMessages: 100000,
|
|
10
|
+
},
|
|
11
|
+
batching: {
|
|
12
|
+
maxBytes: 10 * 1024 * 1024,
|
|
13
|
+
maxMessages: 1000,
|
|
14
|
+
maxMilliseconds: 1000,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A publisher that publishes events to backfill to a Pub/Sub topic.
|
|
19
|
+
*/
|
|
20
|
+
export class PubSubBackfillEventPublisher extends BackfillEventPublisher {
|
|
21
|
+
topicId;
|
|
22
|
+
/**
|
|
23
|
+
* The actual publisher, which handles batching and flow control.
|
|
24
|
+
*/
|
|
25
|
+
publisher;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new {@link PubSubBackfillEventPublisher}.
|
|
28
|
+
*
|
|
29
|
+
* @param context The {@link WorkspaceContext}.
|
|
30
|
+
* @param topicId The ID of the Pub/Sub topic to publish to.
|
|
31
|
+
* This should be a full Pub/Sub topic ID, e.g. `projects/<projectId>/topics/<topicId>`.
|
|
32
|
+
*/
|
|
33
|
+
constructor(context, topicId) {
|
|
34
|
+
super(context);
|
|
35
|
+
this.topicId = topicId;
|
|
36
|
+
this.publisher = context
|
|
37
|
+
.service(PubSubService)
|
|
38
|
+
.pubSub.topic(topicId, PUBLISH_OPTIONS)
|
|
39
|
+
.flowControlled();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Publishes an event to the Pub/Sub topic.
|
|
43
|
+
* Publishing actually occurs asynchronously. {@link PubSubBackfillEventPublisher.flush} must be called to wait for
|
|
44
|
+
* all events to be published.
|
|
45
|
+
*
|
|
46
|
+
* @param event The event to publish.
|
|
47
|
+
* @returns A promise that resolves when the publisher has caught up with publishing, or `null` if other events can be
|
|
48
|
+
* published immediately.
|
|
49
|
+
*/
|
|
50
|
+
publishEvent(event) {
|
|
51
|
+
return this.publisher.publish({
|
|
52
|
+
data: event.data,
|
|
53
|
+
attributes: event.attributes,
|
|
54
|
+
orderingKey: event.key,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Waits for all events to be published.
|
|
59
|
+
*/
|
|
60
|
+
async flush() {
|
|
61
|
+
await this.publisher.all();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -10,6 +10,10 @@ export type GoogleConfiguration = {
|
|
|
10
10
|
* The ID of the default GCP project used when performing operations.
|
|
11
11
|
*/
|
|
12
12
|
readonly project?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The GCP region in which resource should be created and managed.
|
|
15
|
+
*/
|
|
16
|
+
readonly region?: string;
|
|
13
17
|
/**
|
|
14
18
|
* The ID of a local GCP project (which does not exist on GCP).
|
|
15
19
|
* This is for example used by emulators. It should usually start with `demo-` to be compatible with some emulators.
|
|
@@ -165,6 +169,11 @@ export type GoogleConfiguration = {
|
|
|
165
169
|
* The ID of the BigQuery dataset where raw Pub/Sub events should be stored.
|
|
166
170
|
*/
|
|
167
171
|
readonly rawEventsDatasetId?: string;
|
|
172
|
+
/**
|
|
173
|
+
* The BigQuery location for the datasets.
|
|
174
|
+
* See https://cloud.google.com/bigquery/docs/locations for more details.
|
|
175
|
+
*/
|
|
176
|
+
readonly location?: string;
|
|
168
177
|
};
|
|
169
178
|
};
|
|
170
179
|
/**
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { EmulatorStartForFirebaseStorage } from './start-firebase-storage.js';
|
|
2
|
+
export { EmulatorStartForFirestore } from './start-firestore.js';
|
|
3
|
+
export { EmulatorStartForIdentityPlatform } from './start-identity-platform.js';
|
|
4
|
+
export { EmulatorStartForPubSub } from './start-pubsub.js';
|
|
5
|
+
export { EmulatorStartForSpanner } from './start-spanner.js';
|
|
6
|
+
export { EmulatorStopForFirebaseStorage } from './stop-firebase-storage.js';
|
|
7
|
+
export { EmulatorStopForFirestore } from './stop-firestore.js';
|
|
8
|
+
export { EmulatorStopForIdentityPlatform } from './stop-identity-platform.js';
|
|
9
|
+
export { EmulatorStopForPubSub } from './stop-pubsub.js';
|
|
10
|
+
export { EmulatorStopForSpanner } from './stop-spanner.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { EmulatorStartForFirebaseStorage } from './start-firebase-storage.js';
|
|
2
|
+
export { EmulatorStartForFirestore } from './start-firestore.js';
|
|
3
|
+
export { EmulatorStartForIdentityPlatform } from './start-identity-platform.js';
|
|
4
|
+
export { EmulatorStartForPubSub } from './start-pubsub.js';
|
|
5
|
+
export { EmulatorStartForSpanner } from './start-spanner.js';
|
|
6
|
+
export { EmulatorStopForFirebaseStorage } from './stop-firebase-storage.js';
|
|
7
|
+
export { EmulatorStopForFirestore } from './stop-firestore.js';
|
|
8
|
+
export { EmulatorStopForIdentityPlatform } from './stop-identity-platform.js';
|
|
9
|
+
export { EmulatorStopForPubSub } from './stop-pubsub.js';
|
|
10
|
+
export { EmulatorStopForSpanner } from './stop-spanner.js';
|
package/dist/functions/{emulator-start-firebase-storage.js → emulator/start-firebase-storage.js}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EmulatorStart } from '@causa/workspace-core';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
|
-
import { FIREBASE_CONTAINER_STORAGE_RULES_FILE, FIREBASE_STORAGE_EMULATOR_NAME, FIREBASE_STORAGE_PORT, getFirebaseStorageContainerName, } from '
|
|
4
|
-
import { FirebaseEmulatorService } from '
|
|
5
|
-
import { GoogleFirebaseStorageMergeRules } from '
|
|
3
|
+
import { FIREBASE_CONTAINER_STORAGE_RULES_FILE, FIREBASE_STORAGE_EMULATOR_NAME, FIREBASE_STORAGE_PORT, getFirebaseStorageContainerName, } from '../../emulators/index.js';
|
|
4
|
+
import { FirebaseEmulatorService } from '../../services/index.js';
|
|
5
|
+
import { GoogleFirebaseStorageMergeRules } from '../google-firebase-storage/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* The Firebase configuration file enabling only the Storage emulator.
|
|
8
8
|
*/
|
|
9
|
-
const FIREBASE_CONF_FILE = fileURLToPath(new URL('
|
|
9
|
+
const FIREBASE_CONF_FILE = fileURLToPath(new URL('../../assets/firebase-storage.json', import.meta.url));
|
|
10
10
|
/**
|
|
11
11
|
* Implements {@link EmulatorStart} for the Firebase Storage container.
|
|
12
12
|
* This first merges the Firebase Storage security rules into a single file, and uses this file to configure the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EmulatorStart } from '@causa/workspace-core';
|
|
2
|
-
import { FIRESTORE_CONTAINER_RULES_FILE, FIRESTORE_EMULATOR_NAME, FIRESTORE_PORT, getFirestoreContainerName, } from '
|
|
3
|
-
import { GcloudEmulatorService } from '
|
|
4
|
-
import { GoogleFirestoreMergeRules } from '
|
|
2
|
+
import { FIRESTORE_CONTAINER_RULES_FILE, FIRESTORE_EMULATOR_NAME, FIRESTORE_PORT, getFirestoreContainerName, } from '../../emulators/index.js';
|
|
3
|
+
import { GcloudEmulatorService } from '../../services/index.js';
|
|
4
|
+
import { GoogleFirestoreMergeRules } from '../google-firestore/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Implements {@link EmulatorStart} for the Firestore emulator.
|
|
7
7
|
* This first merges the Firestore security rules into a single file, and uses this file to configure the emulator.
|
package/dist/functions/{emulator-start-identity-platform.js → emulator/start-identity-platform.js}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EmulatorStart } from '@causa/workspace-core';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
|
-
import { FIREBASE_AUTH_PORT, IDENTITY_PLATFORM_EMULATOR_NAME, getIdentityPlatformContainerName, } from '
|
|
4
|
-
import { FirebaseEmulatorService } from '
|
|
3
|
+
import { FIREBASE_AUTH_PORT, IDENTITY_PLATFORM_EMULATOR_NAME, getIdentityPlatformContainerName, } from '../../emulators/index.js';
|
|
4
|
+
import { FirebaseEmulatorService } from '../../services/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* The Firebase configuration file enabling only the Auth emulator.
|
|
7
7
|
*/
|
|
8
|
-
const FIREBASE_CONF_FILE = fileURLToPath(new URL('
|
|
8
|
+
const FIREBASE_CONF_FILE = fileURLToPath(new URL('../../assets/firebase-auth.json', import.meta.url));
|
|
9
9
|
/**
|
|
10
10
|
* Implements {@link EmulatorStart} for the Identity Platform emulator.
|
|
11
11
|
* This actually runs the "legacy" Firebase Auth emulator, which is the same service before it was re-branded.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EmulatorStart, EventTopicList, } from '@causa/workspace-core';
|
|
2
2
|
import { PubSub } from '@google-cloud/pubsub';
|
|
3
|
-
import { getLocalGcpProject } from '
|
|
4
|
-
import { PUBSUB_EMULATOR_NAME, PUBSUB_PORT, formatPubSubTopicAsEnvironmentVariable, getPubSubContainerName, } from '
|
|
5
|
-
import { GcloudEmulatorService } from '
|
|
3
|
+
import { getLocalGcpProject } from '../../configurations/utils.js';
|
|
4
|
+
import { PUBSUB_EMULATOR_NAME, PUBSUB_PORT, formatPubSubTopicAsEnvironmentVariable, getPubSubContainerName, } from '../../emulators/index.js';
|
|
5
|
+
import { GcloudEmulatorService } from '../../services/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Implements {@link EmulatorStart} for the Pub/Sub emulator.
|
|
8
8
|
* This first starts the Pub/Sub emulator, and then creates the topics defined in the workspace (if the workspace is
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DockerEmulatorService, EmulatorStart, } from '@causa/workspace-core';
|
|
2
2
|
import { Spanner } from '@google-cloud/spanner';
|
|
3
3
|
import { credentials } from '@grpc/grpc-js';
|
|
4
|
-
import { getLocalGcpProject, } from '
|
|
5
|
-
import { SPANNER_EMULATOR_NAME, SPANNER_GRPC_PORT, SPANNER_HTTP_PORT, SPANNER_IMAGE, getSpannerContainerName, } from '
|
|
6
|
-
import { GoogleSpannerListDatabases } from '
|
|
4
|
+
import { getLocalGcpProject, } from '../../configurations/index.js';
|
|
5
|
+
import { SPANNER_EMULATOR_NAME, SPANNER_GRPC_PORT, SPANNER_HTTP_PORT, SPANNER_IMAGE, getSpannerContainerName, } from '../../emulators/index.js';
|
|
6
|
+
import { GoogleSpannerListDatabases } from '../google-spanner/index.js';
|
|
7
7
|
/**
|
|
8
8
|
* Implements {@link EmulatorStart} for the Spanner emulator.
|
|
9
9
|
* This starts the emulator, creates a local instance, and creates the databases using the DDLs found in the workspace.
|
package/dist/functions/{emulator-stop-firebase-storage.js → emulator/stop-firebase-storage.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DockerEmulatorService, EmulatorStop } from '@causa/workspace-core';
|
|
2
|
-
import { FIREBASE_STORAGE_EMULATOR_NAME, getFirebaseStorageContainerName, } from '
|
|
2
|
+
import { FIREBASE_STORAGE_EMULATOR_NAME, getFirebaseStorageContainerName, } from '../../emulators/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Implements {@link EmulatorStop} for the Firebase Storage emulator.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DockerEmulatorService, EmulatorStop } from '@causa/workspace-core';
|
|
2
|
-
import { FIRESTORE_EMULATOR_NAME, getFirestoreContainerName, } from '
|
|
2
|
+
import { FIRESTORE_EMULATOR_NAME, getFirestoreContainerName, } from '../../emulators/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Implements {@link EmulatorStop} for the Firestore emulator.
|
|
5
5
|
*/
|
package/dist/functions/{emulator-stop-identity-platform.js → emulator/stop-identity-platform.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DockerEmulatorService, EmulatorStop } from '@causa/workspace-core';
|
|
2
|
-
import { IDENTITY_PLATFORM_EMULATOR_NAME, getIdentityPlatformContainerName, } from '
|
|
2
|
+
import { IDENTITY_PLATFORM_EMULATOR_NAME, getIdentityPlatformContainerName, } from '../../emulators/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Implements {@link EmulatorStop} for the Identity Platform emulator.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DockerEmulatorService, EmulatorStop } from '@causa/workspace-core';
|
|
2
|
-
import { PUBSUB_EMULATOR_NAME, getPubSubContainerName, } from '
|
|
2
|
+
import { PUBSUB_EMULATOR_NAME, getPubSubContainerName, } from '../../emulators/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Implements {@link EmulatorStop} for the Pub/Sub emulator.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DockerEmulatorService, EmulatorStop } from '@causa/workspace-core';
|
|
2
|
-
import { SPANNER_EMULATOR_NAME, getSpannerContainerName, } from '
|
|
2
|
+
import { SPANNER_EMULATOR_NAME, getSpannerContainerName, } from '../../emulators/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Implements {@link EmulatorStop} for the Spanner emulator.
|
|
5
5
|
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { EventTopicBrokerCreateTopic } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link EventTopicBrokerCreateTopic} for Pub/Sub.
|
|
5
|
+
* Topics are created in the GCP project set in the `google.project` configuration.
|
|
6
|
+
* If a `google.region` configuration is set, the message storage policy for the topic is set accordingly.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EventTopicBrokerCreateTopicForPubSub extends EventTopicBrokerCreateTopic {
|
|
9
|
+
_call(context: WorkspaceContext): Promise<string>;
|
|
10
|
+
_supports(context: WorkspaceContext): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EventTopicBrokerCreateTopic, } from '@causa/workspace-core';
|
|
2
|
+
import { PubSubService } from '../../services/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link EventTopicBrokerCreateTopic} for Pub/Sub.
|
|
5
|
+
* Topics are created in the GCP project set in the `google.project` configuration.
|
|
6
|
+
* If a `google.region` configuration is set, the message storage policy for the topic is set accordingly.
|
|
7
|
+
*/
|
|
8
|
+
export class EventTopicBrokerCreateTopicForPubSub extends EventTopicBrokerCreateTopic {
|
|
9
|
+
async _call(context) {
|
|
10
|
+
const googleConf = context.asConfiguration();
|
|
11
|
+
const projectId = googleConf.getOrThrow('google.project');
|
|
12
|
+
const region = googleConf.get('google.region');
|
|
13
|
+
const topicId = `projects/${projectId}/topics/${this.name}`;
|
|
14
|
+
context.logger.info(`📫 Creating Pub/Sub topic '${topicId}'.`);
|
|
15
|
+
await context.service(PubSubService).pubSub.createTopic({
|
|
16
|
+
name: topicId,
|
|
17
|
+
...(region
|
|
18
|
+
? { messageStoragePolicy: { allowedPersistenceRegions: [region] } }
|
|
19
|
+
: {}),
|
|
20
|
+
});
|
|
21
|
+
return topicId;
|
|
22
|
+
}
|
|
23
|
+
_supports(context) {
|
|
24
|
+
return (context.asConfiguration().get('events.broker') ===
|
|
25
|
+
'google.pubSub');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { EventTopicBrokerCreateTrigger } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link EventTopicBrokerCreateTrigger} for Cloud Run endpoints being triggered by Pub/Sub messages.
|
|
5
|
+
* The `id` argument should be a Cloud Run service ID, followed by the path to the trigger, e.g.
|
|
6
|
+
* `[[projects/<projectId>/]locations/<location>/]services/<name>/path-to-trigger`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EventTopicBrokerCreateTriggerForCloudRun extends EventTopicBrokerCreateTrigger {
|
|
9
|
+
_call(context: WorkspaceContext): Promise<string[]>;
|
|
10
|
+
_supports(context: WorkspaceContext): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { EventTopicBrokerCreateTrigger, } from '@causa/workspace-core';
|
|
2
|
+
import { CloudRunPubSubTriggerService } from '../../services/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The regular expression used to match Cloud Run trigger IDs, consisting of the service ID and the path to the trigger.
|
|
5
|
+
* [[projects/<projectId>/]locations/<location>/]services/<name>/path-to-trigger
|
|
6
|
+
*/
|
|
7
|
+
const CLOUD_RUN_TRIGGER_ID_REGEX = /^(?:(?:projects\/(?<projectId>[\w-]+)\/)?locations\/(?<location>[\w-]+)\/)?services\/(?<name>[\w-]+)(?<path>\/.*)$/;
|
|
8
|
+
/**
|
|
9
|
+
* Implements {@link EventTopicBrokerCreateTrigger} for Cloud Run endpoints being triggered by Pub/Sub messages.
|
|
10
|
+
* The `id` argument should be a Cloud Run service ID, followed by the path to the trigger, e.g.
|
|
11
|
+
* `[[projects/<projectId>/]locations/<location>/]services/<name>/path-to-trigger`.
|
|
12
|
+
*/
|
|
13
|
+
export class EventTopicBrokerCreateTriggerForCloudRun extends EventTopicBrokerCreateTrigger {
|
|
14
|
+
async _call(context) {
|
|
15
|
+
const match = this.trigger.match(CLOUD_RUN_TRIGGER_ID_REGEX);
|
|
16
|
+
if (!match?.groups) {
|
|
17
|
+
throw new Error('Oops.');
|
|
18
|
+
}
|
|
19
|
+
const googleConf = context.asConfiguration();
|
|
20
|
+
const projectId = match.groups.projectId ?? googleConf.getOrThrow('google.project');
|
|
21
|
+
const location = match.groups.location ??
|
|
22
|
+
googleConf.getOrThrow('google.cloudRun.location');
|
|
23
|
+
const name = match.groups.name;
|
|
24
|
+
const path = match.groups.path;
|
|
25
|
+
if (!name || !path) {
|
|
26
|
+
throw new Error('Oops.');
|
|
27
|
+
}
|
|
28
|
+
const serviceId = `projects/${projectId}/locations/${location}/services/${name}`;
|
|
29
|
+
return await context
|
|
30
|
+
.service(CloudRunPubSubTriggerService)
|
|
31
|
+
.create(this.backfillId, this.topicId, serviceId, path);
|
|
32
|
+
}
|
|
33
|
+
_supports(context) {
|
|
34
|
+
return (this.trigger.match(CLOUD_RUN_TRIGGER_ID_REGEX) != null &&
|
|
35
|
+
context.asConfiguration().get('events.broker') ===
|
|
36
|
+
'google.pubSub');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { EventTopicBrokerDeleteTopic } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link EventTopicBrokerDeleteTopic} for Pub/Sub.
|
|
5
|
+
* The `id` argument should be a full Pub/Sub topic ID, e.g. `projects/<projectId>/topics/<topicId>`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class EventTopicBrokerDeleteTopicForPubSub extends EventTopicBrokerDeleteTopic {
|
|
8
|
+
_call(context: WorkspaceContext): Promise<void>;
|
|
9
|
+
_supports(context: WorkspaceContext): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EventTopicBrokerDeleteTopic, } from '@causa/workspace-core';
|
|
2
|
+
import { status } from '@grpc/grpc-js';
|
|
3
|
+
import { PubSubService } from '../../services/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Implements {@link EventTopicBrokerDeleteTopic} for Pub/Sub.
|
|
6
|
+
* The `id` argument should be a full Pub/Sub topic ID, e.g. `projects/<projectId>/topics/<topicId>`.
|
|
7
|
+
*/
|
|
8
|
+
export class EventTopicBrokerDeleteTopicForPubSub extends EventTopicBrokerDeleteTopic {
|
|
9
|
+
async _call(context) {
|
|
10
|
+
context.logger.info(`📫 Deleting Pub/Sub topic '${this.id}'.`);
|
|
11
|
+
try {
|
|
12
|
+
await context.service(PubSubService).pubSub.topic(this.id).delete();
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error.code === status.NOT_FOUND) {
|
|
16
|
+
context.logger.warn(`⚠️ Pub/Sub topic to delete '${this.id}' does not exist. It might have already been deleted.`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
_supports(context) {
|
|
23
|
+
return (context.asConfiguration().get('events.broker') ===
|
|
24
|
+
'google.pubSub');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { EventTopicBrokerDeleteTriggerResource } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link EventTopicBrokerDeleteTriggerResource} for Cloud Run invoker roles.
|
|
5
|
+
* When setting up a Pub/Sub trigger for a Cloud Run service, a new binding is added to the Cloud Run service, allowing
|
|
6
|
+
* a dedicated service account to invoke the service. This function removes that binding.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole extends EventTopicBrokerDeleteTriggerResource {
|
|
9
|
+
_call(context: WorkspaceContext): Promise<void>;
|
|
10
|
+
_supports(context: WorkspaceContext): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EventTopicBrokerDeleteTriggerResource, } from '@causa/workspace-core';
|
|
2
|
+
import { CloudRunService } from '../../services/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The regular expression that matches a resource ID representing a Cloud Run invoker role for a given service account.
|
|
5
|
+
*/
|
|
6
|
+
const CLOUD_RUN_INVOKER_ID_REGEX = /^(?<serviceId>projects\/[\w-]+\/locations\/[\w-]+\/services\/[\w-]+)\/invokerBindings\/(?<pubSubServiceAccount>.+)$/;
|
|
7
|
+
/**
|
|
8
|
+
* Implements {@link EventTopicBrokerDeleteTriggerResource} for Cloud Run invoker roles.
|
|
9
|
+
* When setting up a Pub/Sub trigger for a Cloud Run service, a new binding is added to the Cloud Run service, allowing
|
|
10
|
+
* a dedicated service account to invoke the service. This function removes that binding.
|
|
11
|
+
*/
|
|
12
|
+
export class EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole extends EventTopicBrokerDeleteTriggerResource {
|
|
13
|
+
async _call(context) {
|
|
14
|
+
const match = this.id.match(CLOUD_RUN_INVOKER_ID_REGEX);
|
|
15
|
+
if (!match?.groups) {
|
|
16
|
+
throw new Error('Invalid Cloud Run invoker binding resource ID.');
|
|
17
|
+
}
|
|
18
|
+
const { serviceId, pubSubServiceAccount } = match.groups;
|
|
19
|
+
context.logger.info(`🛂 Removing invoker role on Cloud Run service '${serviceId}' for Pub/Sub service account '${pubSubServiceAccount}'.`);
|
|
20
|
+
await context
|
|
21
|
+
.service(CloudRunService)
|
|
22
|
+
.removeInvokerBinding(serviceId, pubSubServiceAccount);
|
|
23
|
+
}
|
|
24
|
+
_supports(context) {
|
|
25
|
+
return (this.id.match(CLOUD_RUN_INVOKER_ID_REGEX) != null &&
|
|
26
|
+
context.asConfiguration().get('events.broker') ===
|
|
27
|
+
'google.pubSub');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { EventTopicBrokerDeleteTriggerResource } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link EventTopicBrokerDeleteTriggerResource} for Pub/Sub subscriptions.
|
|
5
|
+
* Pub/Sub subscriptions are for example used when creating Cloud Run triggers.
|
|
6
|
+
*/
|
|
7
|
+
export declare class EventTopicBrokerDeleteTriggerResourceForPubSubSubscription extends EventTopicBrokerDeleteTriggerResource {
|
|
8
|
+
_call(context: WorkspaceContext): Promise<void>;
|
|
9
|
+
_supports(context: WorkspaceContext): boolean;
|
|
10
|
+
}
|