@causa/workspace-google 0.3.1 → 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.
Files changed (108) hide show
  1. package/README.md +14 -0
  2. package/dist/backfilling/bigquery.d.ts +53 -0
  3. package/dist/backfilling/bigquery.js +99 -0
  4. package/dist/backfilling/index.d.ts +2 -0
  5. package/dist/backfilling/index.js +2 -0
  6. package/dist/backfilling/pubsub.d.ts +34 -0
  7. package/dist/backfilling/pubsub.js +63 -0
  8. package/dist/configurations/google.d.ts +81 -0
  9. package/dist/functions/emulator/index.d.ts +10 -0
  10. package/dist/functions/emulator/index.js +10 -0
  11. package/dist/functions/{emulator-start-firebase-storage.js → emulator/start-firebase-storage.js} +4 -4
  12. package/dist/functions/{emulator-start-firestore.js → emulator/start-firestore.js} +3 -3
  13. package/dist/functions/{emulator-start-identity-platform.js → emulator/start-identity-platform.js} +3 -3
  14. package/dist/functions/{emulator-start-pubsub.js → emulator/start-pubsub.js} +3 -3
  15. package/dist/functions/{emulator-start-spanner.js → emulator/start-spanner.js} +5 -5
  16. package/dist/functions/{emulator-stop-firebase-storage.js → emulator/stop-firebase-storage.js} +1 -1
  17. package/dist/functions/{emulator-stop-firestore.js → emulator/stop-firestore.js} +1 -1
  18. package/dist/functions/{emulator-stop-identity-platform.js → emulator/stop-identity-platform.js} +1 -1
  19. package/dist/functions/{emulator-stop-pubsub.js → emulator/stop-pubsub.js} +1 -1
  20. package/dist/functions/{emulator-stop-spanner.js → emulator/stop-spanner.js} +1 -1
  21. package/dist/functions/event-topic/broker-create-topic-pubsub.d.ts +11 -0
  22. package/dist/functions/event-topic/broker-create-topic-pubsub.js +27 -0
  23. package/dist/functions/event-topic/broker-create-trigger-cloud-run.d.ts +11 -0
  24. package/dist/functions/event-topic/broker-create-trigger-cloud-run.js +38 -0
  25. package/dist/functions/event-topic/broker-delete-topic-pubsub.d.ts +10 -0
  26. package/dist/functions/event-topic/broker-delete-topic-pubsub.js +26 -0
  27. package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.d.ts +11 -0
  28. package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.js +29 -0
  29. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.d.ts +10 -0
  30. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.js +31 -0
  31. package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.d.ts +11 -0
  32. package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.js +28 -0
  33. package/dist/functions/event-topic/broker-get-topic-id-pubsub.d.ts +10 -0
  34. package/dist/functions/event-topic/broker-get-topic-id-pubsub.js +16 -0
  35. package/dist/functions/event-topic/broker-publish-events-google.d.ts +17 -0
  36. package/dist/functions/event-topic/broker-publish-events-google.js +45 -0
  37. package/dist/functions/event-topic/index.d.ts +8 -0
  38. package/dist/functions/event-topic/index.js +8 -0
  39. package/dist/functions/{google-app-check-generate-token.js → google-app-check/generate-token.js} +2 -2
  40. package/dist/functions/google-app-check/index.d.ts +1 -0
  41. package/dist/functions/google-app-check/index.js +1 -0
  42. package/dist/functions/google-firebase-storage/index.d.ts +1 -0
  43. package/dist/functions/google-firebase-storage/index.js +1 -0
  44. package/dist/functions/{google-firebase-storage-merge-rules.d.ts → google-firebase-storage/merge-rules.d.ts} +1 -1
  45. package/dist/functions/{google-firebase-storage-merge-rules.js → google-firebase-storage/merge-rules.js} +2 -2
  46. package/dist/functions/google-firestore/index.d.ts +1 -0
  47. package/dist/functions/google-firestore/index.js +1 -0
  48. package/dist/functions/{google-firestore-merge-rules.d.ts → google-firestore/merge-rules.d.ts} +1 -1
  49. package/dist/functions/{google-firestore-merge-rules.js → google-firestore/merge-rules.js} +2 -2
  50. package/dist/functions/{google-identity-platform-generate-custom-token.js → google-identity-platform/generate-custom-token.js} +1 -1
  51. package/dist/functions/{google-identity-platform-generate-token.js → google-identity-platform/generate-token.js} +3 -3
  52. package/dist/functions/google-identity-platform/index.d.ts +2 -0
  53. package/dist/functions/google-identity-platform/index.js +2 -0
  54. package/dist/functions/google-pubsub/index.d.ts +1 -0
  55. package/dist/functions/google-pubsub/index.js +1 -0
  56. package/dist/functions/google-pubsub/write-topics.d.ts +22 -0
  57. package/dist/functions/google-pubsub/write-topics.js +80 -0
  58. package/dist/functions/{google-services-enable.d.ts → google-services/enable.d.ts} +1 -1
  59. package/dist/functions/{google-services-enable.js → google-services/enable.js} +1 -1
  60. package/dist/functions/google-services/index.d.ts +1 -0
  61. package/dist/functions/google-services/index.js +1 -0
  62. package/dist/functions/google-spanner/index.d.ts +2 -0
  63. package/dist/functions/google-spanner/index.js +2 -0
  64. package/dist/functions/google-spanner/write-databases.d.ts +22 -0
  65. package/dist/functions/google-spanner/write-databases.js +73 -0
  66. package/dist/functions/index.js +12 -22
  67. package/dist/functions/project/index.d.ts +3 -0
  68. package/dist/functions/project/index.js +3 -0
  69. package/dist/functions/{project-push-artefact-cloud-functions.js → project/push-artefact-cloud-functions.js} +1 -1
  70. package/dist/functions/{secret-fetch-secret-manager.js → secret/fetch-secret-manager.js} +1 -1
  71. package/dist/functions/secret/index.d.ts +1 -0
  72. package/dist/functions/secret/index.js +1 -0
  73. package/dist/services/bigquery.d.ts +16 -0
  74. package/dist/services/bigquery.js +19 -0
  75. package/dist/services/cloud-run-pubsub-trigger.d.ts +101 -0
  76. package/dist/services/cloud-run-pubsub-trigger.js +177 -0
  77. package/dist/services/cloud-run.d.ts +35 -0
  78. package/dist/services/cloud-run.js +72 -0
  79. package/dist/services/iam.d.ts +43 -0
  80. package/dist/services/iam.js +65 -0
  81. package/dist/services/index.d.ts +6 -0
  82. package/dist/services/index.js +6 -0
  83. package/dist/services/pubsub.d.ts +41 -0
  84. package/dist/services/pubsub.js +62 -0
  85. package/dist/services/resource-manager.d.ts +18 -0
  86. package/dist/services/resource-manager.js +35 -0
  87. package/package.json +26 -22
  88. /package/dist/functions/{emulator-start-firebase-storage.d.ts → emulator/start-firebase-storage.d.ts} +0 -0
  89. /package/dist/functions/{emulator-start-firestore.d.ts → emulator/start-firestore.d.ts} +0 -0
  90. /package/dist/functions/{emulator-start-identity-platform.d.ts → emulator/start-identity-platform.d.ts} +0 -0
  91. /package/dist/functions/{emulator-start-pubsub.d.ts → emulator/start-pubsub.d.ts} +0 -0
  92. /package/dist/functions/{emulator-start-spanner.d.ts → emulator/start-spanner.d.ts} +0 -0
  93. /package/dist/functions/{emulator-stop-firebase-storage.d.ts → emulator/stop-firebase-storage.d.ts} +0 -0
  94. /package/dist/functions/{emulator-stop-firestore.d.ts → emulator/stop-firestore.d.ts} +0 -0
  95. /package/dist/functions/{emulator-stop-identity-platform.d.ts → emulator/stop-identity-platform.d.ts} +0 -0
  96. /package/dist/functions/{emulator-stop-pubsub.d.ts → emulator/stop-pubsub.d.ts} +0 -0
  97. /package/dist/functions/{emulator-stop-spanner.d.ts → emulator/stop-spanner.d.ts} +0 -0
  98. /package/dist/functions/{google-app-check-generate-token.d.ts → google-app-check/generate-token.d.ts} +0 -0
  99. /package/dist/functions/{google-identity-platform-generate-custom-token.d.ts → google-identity-platform/generate-custom-token.d.ts} +0 -0
  100. /package/dist/functions/{google-identity-platform-generate-token.d.ts → google-identity-platform/generate-token.d.ts} +0 -0
  101. /package/dist/functions/{google-spanner-list-databases.d.ts → google-spanner/list-databases.d.ts} +0 -0
  102. /package/dist/functions/{google-spanner-list-databases.js → google-spanner/list-databases.js} +0 -0
  103. /package/dist/functions/{project-get-artefact-destination-cloud-functions.d.ts → project/get-artefact-destination-cloud-functions.d.ts} +0 -0
  104. /package/dist/functions/{project-get-artefact-destination-cloud-functions.js → project/get-artefact-destination-cloud-functions.js} +0 -0
  105. /package/dist/functions/{project-get-artefact-destination-cloud-run.d.ts → project/get-artefact-destination-cloud-run.d.ts} +0 -0
  106. /package/dist/functions/{project-get-artefact-destination-cloud-run.js → project/get-artefact-destination-cloud-run.js} +0 -0
  107. /package/dist/functions/{project-push-artefact-cloud-functions.d.ts → project/push-artefact-cloud-functions.d.ts} +0 -0
  108. /package/dist/functions/{secret-fetch-secret-manager.d.ts → secret/fetch-secret-manager.d.ts} +0 -0
@@ -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
+ }
@@ -0,0 +1,31 @@
1
+ import { EventTopicBrokerDeleteTriggerResource, } from '@causa/workspace-core';
2
+ import { status } from '@grpc/grpc-js';
3
+ import { PubSubService } from '../../services/index.js';
4
+ /**
5
+ * Implements {@link EventTopicBrokerDeleteTriggerResource} for Pub/Sub subscriptions.
6
+ * Pub/Sub subscriptions are for example used when creating Cloud Run triggers.
7
+ */
8
+ export class EventTopicBrokerDeleteTriggerResourceForPubSubSubscription extends EventTopicBrokerDeleteTriggerResource {
9
+ async _call(context) {
10
+ context.logger.info(`📫 Deleting Pub/Sub subscription '${this.id}'.`);
11
+ try {
12
+ await context
13
+ .service(PubSubService)
14
+ .pubSub.subscription(this.id)
15
+ .delete();
16
+ }
17
+ catch (error) {
18
+ if (error.code === status.NOT_FOUND) {
19
+ context.logger.warn(`⚠️ Pub/Sub subscription '${this.id}' does not exist. It might have already been deleted.`);
20
+ }
21
+ else {
22
+ throw error;
23
+ }
24
+ }
25
+ }
26
+ _supports(context) {
27
+ return (this.id.match(/^projects\/[\w-]+\/subscriptions\/[\w-]+$/) != null &&
28
+ context.asConfiguration().get('events.broker') ===
29
+ 'google.pubSub');
30
+ }
31
+ }
@@ -0,0 +1,11 @@
1
+ import { WorkspaceContext } from '@causa/workspace';
2
+ import { EventTopicBrokerDeleteTriggerResource } from '@causa/workspace-core';
3
+ /**
4
+ * Implements {@link EventTopicBrokerDeleteTriggerResource} for GCP service accounts.
5
+ * Service accounts are used by Pub/Sub push subscriptions to authenticate requests when pushing messages (e.g. to Cloud
6
+ * Run services).
7
+ */
8
+ export declare class EventTopicBrokerDeleteTriggerResourceForServiceAccount extends EventTopicBrokerDeleteTriggerResource {
9
+ _call(context: WorkspaceContext): Promise<void>;
10
+ _supports(context: WorkspaceContext): boolean;
11
+ }
@@ -0,0 +1,28 @@
1
+ import { EventTopicBrokerDeleteTriggerResource, } from '@causa/workspace-core';
2
+ import { IamService } from '../../services/index.js';
3
+ /**
4
+ * Implements {@link EventTopicBrokerDeleteTriggerResource} for GCP service accounts.
5
+ * Service accounts are used by Pub/Sub push subscriptions to authenticate requests when pushing messages (e.g. to Cloud
6
+ * Run services).
7
+ */
8
+ export class EventTopicBrokerDeleteTriggerResourceForServiceAccount extends EventTopicBrokerDeleteTriggerResource {
9
+ async _call(context) {
10
+ context.logger.info(`🛂 Deleting Pub/Sub backfilling service account '${this.id}'.`);
11
+ try {
12
+ await context.service(IamService).deleteServiceAccount(this.id);
13
+ }
14
+ catch (error) {
15
+ if (error.code === 404) {
16
+ context.logger.warn(`⚠️ Pub/Sub backfilling service account '${this.id}' does not exist. It might have already been deleted.`);
17
+ }
18
+ else {
19
+ throw error;
20
+ }
21
+ }
22
+ }
23
+ _supports(context) {
24
+ return (this.id.match(/^projects\/[\w-]+\/serviceAccounts\/[^/]+$/) != null &&
25
+ context.asConfiguration().get('events.broker') ===
26
+ 'google.pubSub');
27
+ }
28
+ }
@@ -0,0 +1,10 @@
1
+ import { WorkspaceContext } from '@causa/workspace';
2
+ import { EventTopicBrokerGetTopicId } from '@causa/workspace-core';
3
+ /**
4
+ * Implements {@link EventTopicBrokerGetTopicId} for Pub/Sub.
5
+ * The returned topic ID is a full Pub/Sub topic ID, e.g. `projects/<projectId>/topics/<topicId>`.
6
+ */
7
+ export declare class EventTopicBrokerGetTopicIdForPubSub extends EventTopicBrokerGetTopicId {
8
+ _call(context: WorkspaceContext): Promise<string>;
9
+ _supports(context: WorkspaceContext): boolean;
10
+ }
@@ -0,0 +1,16 @@
1
+ import { EventTopicBrokerGetTopicId, } from '@causa/workspace-core';
2
+ /**
3
+ * Implements {@link EventTopicBrokerGetTopicId} for Pub/Sub.
4
+ * The returned topic ID is a full Pub/Sub topic ID, e.g. `projects/<projectId>/topics/<topicId>`.
5
+ */
6
+ export class EventTopicBrokerGetTopicIdForPubSub extends EventTopicBrokerGetTopicId {
7
+ async _call(context) {
8
+ const googleConf = context.asConfiguration();
9
+ const projectId = googleConf.getOrThrow('google.project');
10
+ return `projects/${projectId}/topics/${this.eventTopic}`;
11
+ }
12
+ _supports(context) {
13
+ return (context.asConfiguration().get('events.broker') ===
14
+ 'google.pubSub');
15
+ }
16
+ }
@@ -0,0 +1,17 @@
1
+ import { WorkspaceContext } from '@causa/workspace';
2
+ import { EventTopicBrokerPublishEvents } from '@causa/workspace-core';
3
+ /**
4
+ * Implements {@link EventTopicBrokerPublishEvents} for a Google / GCP stack.
5
+ * The supported message broker is Pub/Sub.
6
+ */
7
+ export declare class EventTopicBrokerPublishEventsForGoogle extends EventTopicBrokerPublishEvents {
8
+ /**
9
+ * Tries to create a {@link BackfillEventsSource} from the provided `source` and `filter`.
10
+ *
11
+ * @param context The {@link WorkspaceContext}.
12
+ * @returns The {@link BackfillEventsSource} to use for backfilling.
13
+ */
14
+ private createSource;
15
+ _call(context: WorkspaceContext): Promise<void>;
16
+ _supports(context: WorkspaceContext): boolean;
17
+ }
@@ -0,0 +1,45 @@
1
+ import { EventTopicBrokerPublishEvents, JsonFilesEventSource, } from '@causa/workspace-core';
2
+ import { BigQueryEventsSource, PubSubBackfillEventPublisher, } from '../../backfilling/index.js';
3
+ /**
4
+ * Implements {@link EventTopicBrokerPublishEvents} for a Google / GCP stack.
5
+ * The supported message broker is Pub/Sub.
6
+ */
7
+ export class EventTopicBrokerPublishEventsForGoogle extends EventTopicBrokerPublishEvents {
8
+ /**
9
+ * Tries to create a {@link BackfillEventsSource} from the provided `source` and `filter`.
10
+ *
11
+ * @param context The {@link WorkspaceContext}.
12
+ * @returns The {@link BackfillEventsSource} to use for backfilling.
13
+ */
14
+ async createSource(context) {
15
+ if (!this.source) {
16
+ const googleConf = context.asConfiguration();
17
+ const projectId = googleConf.getOrThrow('google.project');
18
+ const rawEventsDatasetId = googleConf.get('google.pubSub.bigQueryStorage.rawEventsDatasetId');
19
+ if (!rawEventsDatasetId) {
20
+ throw new Error('Cannot use the default event source because BigQuery storage is not configured.');
21
+ }
22
+ const tableName = this.eventTopic.replace(/[-\.]/g, '_');
23
+ const tableId = `${projectId}.${rawEventsDatasetId}.${tableName}`;
24
+ return new BigQueryEventsSource(context, tableId);
25
+ }
26
+ const bqSource = await BigQueryEventsSource.fromSourceAndFilter(context, this.source, this.filter);
27
+ if (bqSource) {
28
+ return bqSource;
29
+ }
30
+ const jsonFilesSource = await JsonFilesEventSource.fromSourceAndFilter(context, this.source, this.filter);
31
+ if (jsonFilesSource) {
32
+ return jsonFilesSource;
33
+ }
34
+ throw new Error(`The event source '${this.source}' is not supported.`);
35
+ }
36
+ async _call(context) {
37
+ const source = await this.createSource(context);
38
+ const publisher = new PubSubBackfillEventPublisher(context, this.topicId);
39
+ await publisher.publishFromSource(source);
40
+ }
41
+ _supports(context) {
42
+ return (context.asConfiguration().get('events.broker') ===
43
+ 'google.pubSub');
44
+ }
45
+ }
@@ -0,0 +1,8 @@
1
+ export { EventTopicBrokerCreateTopicForPubSub } from './broker-create-topic-pubsub.js';
2
+ export { EventTopicBrokerCreateTriggerForCloudRun } from './broker-create-trigger-cloud-run.js';
3
+ export { EventTopicBrokerDeleteTopicForPubSub } from './broker-delete-topic-pubsub.js';
4
+ export { EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole } from './broker-delete-trigger-resource-cloud-run-invoker-role.js';
5
+ export { EventTopicBrokerDeleteTriggerResourceForPubSubSubscription } from './broker-delete-trigger-resource-pubsub-subscription.js';
6
+ export { EventTopicBrokerDeleteTriggerResourceForServiceAccount } from './broker-delete-trigger-resource-service-account.js';
7
+ export { EventTopicBrokerGetTopicIdForPubSub } from './broker-get-topic-id-pubsub.js';
8
+ export { EventTopicBrokerPublishEventsForGoogle } from './broker-publish-events-google.js';
@@ -0,0 +1,8 @@
1
+ export { EventTopicBrokerCreateTopicForPubSub } from './broker-create-topic-pubsub.js';
2
+ export { EventTopicBrokerCreateTriggerForCloudRun } from './broker-create-trigger-cloud-run.js';
3
+ export { EventTopicBrokerDeleteTopicForPubSub } from './broker-delete-topic-pubsub.js';
4
+ export { EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole } from './broker-delete-trigger-resource-cloud-run-invoker-role.js';
5
+ export { EventTopicBrokerDeleteTriggerResourceForPubSubSubscription } from './broker-delete-trigger-resource-pubsub-subscription.js';
6
+ export { EventTopicBrokerDeleteTriggerResourceForServiceAccount } from './broker-delete-trigger-resource-service-account.js';
7
+ export { EventTopicBrokerGetTopicIdForPubSub } from './broker-get-topic-id-pubsub.js';
8
+ export { EventTopicBrokerPublishEventsForGoogle } from './broker-publish-events-google.js';
@@ -12,8 +12,8 @@ import { WorkspaceFunction } from '@causa/workspace';
12
12
  import { AllowMissing } from '@causa/workspace/validation';
13
13
  import { IsString } from 'class-validator';
14
14
  import { getAppCheck } from 'firebase-admin/app-check';
15
- import { appCheckCommandDefinition } from '../cli/index.js';
16
- import { FirebaseAppService } from '../services/index.js';
15
+ import { appCheckCommandDefinition } from '../../cli/index.js';
16
+ import { FirebaseAppService } from '../../services/index.js';
17
17
  /**
18
18
  * The time to live of generated tokens, in seconds.
19
19
  */
@@ -0,0 +1 @@
1
+ export { GoogleAppCheckGenerateToken } from './generate-token.js';
@@ -0,0 +1 @@
1
+ export { GoogleAppCheckGenerateToken } from './generate-token.js';
@@ -0,0 +1 @@
1
+ export { GoogleFirebaseStorageMergeRules } from './merge-rules.js';
@@ -0,0 +1 @@
1
+ export { GoogleFirebaseStorageMergeRules } from './merge-rules.js';
@@ -1,6 +1,6 @@
1
1
  import { WorkspaceContext, WorkspaceFunction } from '@causa/workspace';
2
2
  import { InfrastructureProcessor } from '@causa/workspace-core';
3
- import { GoogleConfiguration } from '../configurations/index.js';
3
+ import { GoogleConfiguration } from '../../configurations/index.js';
4
4
  /**
5
5
  * The return value of {@link GoogleFirebaseStorageMergeRules}.
6
6
  */
@@ -11,8 +11,8 @@ import { CliCommand } from '@causa/cli';
11
11
  import { WorkspaceFunction } from '@causa/workspace';
12
12
  import { AllowMissing } from '@causa/workspace/validation';
13
13
  import { IsBoolean } from 'class-validator';
14
- import { firebaseStorageCommandDefinition } from '../cli/index.js';
15
- import { mergeFirebaseRulesFiles } from '../firebase/index.js';
14
+ import { firebaseStorageCommandDefinition } from '../../cli/index.js';
15
+ import { mergeFirebaseRulesFiles } from '../../firebase/index.js';
16
16
  /**
17
17
  * The default location where the security rules file for Firebase Storage will be written.
18
18
  */
@@ -0,0 +1 @@
1
+ export { GoogleFirestoreMergeRules } from './merge-rules.js';
@@ -0,0 +1 @@
1
+ export { GoogleFirestoreMergeRules } from './merge-rules.js';
@@ -1,6 +1,6 @@
1
1
  import { WorkspaceContext, WorkspaceFunction } from '@causa/workspace';
2
2
  import { InfrastructureProcessor } from '@causa/workspace-core';
3
- import { GoogleConfiguration } from '../configurations/index.js';
3
+ import { GoogleConfiguration } from '../../configurations/index.js';
4
4
  /**
5
5
  * The return value of {@link GoogleFirestoreMergeRules}.
6
6
  */
@@ -11,8 +11,8 @@ import { CliCommand } from '@causa/cli';
11
11
  import { WorkspaceFunction } from '@causa/workspace';
12
12
  import { AllowMissing } from '@causa/workspace/validation';
13
13
  import { IsBoolean } from 'class-validator';
14
- import { firestoreCommandDefinition } from '../cli/index.js';
15
- import { mergeFirebaseRulesFiles } from '../firebase/index.js';
14
+ import { firestoreCommandDefinition } from '../../cli/index.js';
15
+ import { mergeFirebaseRulesFiles } from '../../firebase/index.js';
16
16
  /**
17
17
  * The default location where the security rules file for Firestore will be written.
18
18
  */
@@ -11,7 +11,7 @@ import { WorkspaceFunction } from '@causa/workspace';
11
11
  import { AllowMissing } from '@causa/workspace/validation';
12
12
  import { IsObject, IsString } from 'class-validator';
13
13
  import { getAuth } from 'firebase-admin/auth';
14
- import { FirebaseAppService } from '../index.js';
14
+ import { FirebaseAppService } from '../../services/index.js';
15
15
  /**
16
16
  * Generates a custom token that can be used to sign in to Identity Platform as a given user.
17
17
  * Optionally, custom claims can be set in the token.
@@ -13,9 +13,9 @@ import { AllowMissing } from '@causa/workspace/validation';
13
13
  import { Transform } from 'class-transformer';
14
14
  import { IsObject, IsString } from 'class-validator';
15
15
  import { getAuth, signInWithCustomToken } from 'firebase/auth';
16
- import { identityPlatformCommandDefinition } from '../cli/index.js';
17
- import { FirebaseAppService } from '../services/index.js';
18
- import { GoogleIdentityPlatformGenerateCustomToken } from './google-identity-platform-generate-custom-token.js';
16
+ import { identityPlatformCommandDefinition } from '../../cli/index.js';
17
+ import { FirebaseAppService } from '../../services/index.js';
18
+ import { GoogleIdentityPlatformGenerateCustomToken } from './generate-custom-token.js';
19
19
  /**
20
20
  * Generates an ID token for an Identity Platform end user.
21
21
  * For this function to succeed, the `google.project` should be set, which usually means setting the environment in the
@@ -0,0 +1,2 @@
1
+ export { GoogleIdentityPlatformGenerateCustomToken } from './generate-custom-token.js';
2
+ export { GoogleIdentityPlatformGenerateToken } from './generate-token.js';
@@ -0,0 +1,2 @@
1
+ export { GoogleIdentityPlatformGenerateCustomToken } from './generate-custom-token.js';
2
+ export { GoogleIdentityPlatformGenerateToken } from './generate-token.js';
@@ -0,0 +1 @@
1
+ export { GooglePubSubWriteTopics } from './write-topics.js';
@@ -0,0 +1 @@
1
+ export { GooglePubSubWriteTopics } from './write-topics.js';
@@ -0,0 +1,22 @@
1
+ import { ProcessorResult, WorkspaceContext, WorkspaceFunction } from '@causa/workspace';
2
+ import { InfrastructureProcessor } from '@causa/workspace-core';
3
+ /**
4
+ * A function that uses {@link EventTopicList} to find all the topics in the workspace, and writes their configurations
5
+ * to a directory.
6
+ * The `google.pubSub.topicConfigurationsDirectory` configuration can be used to specify the output location of the
7
+ * topic configurations.
8
+ * This function returns a partial configuration, such that it can be used as a processor.
9
+ */
10
+ export declare class GooglePubSubWriteTopics extends WorkspaceFunction<Promise<ProcessorResult>> implements InfrastructureProcessor {
11
+ readonly tearDown?: boolean;
12
+ /**
13
+ * Returns the path to the directory where Pub/Sub topic configurations should be written.
14
+ * It is either fetched from the workspace configuration, or the default value is used.
15
+ *
16
+ * @param context The {@link WorkspaceContext}.
17
+ * @returns The path to the directory where topic configurations should be written.
18
+ */
19
+ private getConfigurationsDirectory;
20
+ _call(context: WorkspaceContext): Promise<ProcessorResult>;
21
+ _supports(): boolean;
22
+ }
@@ -0,0 +1,80 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { WorkspaceFunction, } from '@causa/workspace';
11
+ import { EventTopicList, } from '@causa/workspace-core';
12
+ import { CAUSA_FOLDER } from '@causa/workspace/initialization';
13
+ import { AllowMissing } from '@causa/workspace/validation';
14
+ import { IsBoolean } from 'class-validator';
15
+ import { mkdir, rm, writeFile } from 'fs/promises';
16
+ import { join } from 'path';
17
+ /**
18
+ * The default directory where Pub/Sub topic configurations are written, relative to the workspace root.
19
+ */
20
+ const DEFAULT_TOPIC_CONFIGURATIONS_DIRECTORY = join(CAUSA_FOLDER, 'pubsub-topics');
21
+ /**
22
+ * A function that uses {@link EventTopicList} to find all the topics in the workspace, and writes their configurations
23
+ * to a directory.
24
+ * The `google.pubSub.topicConfigurationsDirectory` configuration can be used to specify the output location of the
25
+ * topic configurations.
26
+ * This function returns a partial configuration, such that it can be used as a processor.
27
+ */
28
+ export class GooglePubSubWriteTopics extends WorkspaceFunction {
29
+ tearDown;
30
+ /**
31
+ * Returns the path to the directory where Pub/Sub topic configurations should be written.
32
+ * It is either fetched from the workspace configuration, or the default value is used.
33
+ *
34
+ * @param context The {@link WorkspaceContext}.
35
+ * @returns The path to the directory where topic configurations should be written.
36
+ */
37
+ getConfigurationsDirectory(context) {
38
+ return (context
39
+ .asConfiguration()
40
+ .get('google.pubSub.topicConfigurationsDirectory') ??
41
+ DEFAULT_TOPIC_CONFIGURATIONS_DIRECTORY);
42
+ }
43
+ async _call(context) {
44
+ const topicConfigurationsDirectory = this.getConfigurationsDirectory(context);
45
+ const absoluteDir = join(context.rootPath, topicConfigurationsDirectory);
46
+ await rm(absoluteDir, { recursive: true, force: true });
47
+ if (this.tearDown) {
48
+ context.logger.debug(`📫 Tore down Pub/Sub topic configurations directory '${absoluteDir}'.`);
49
+ return { configuration: {} };
50
+ }
51
+ context.logger.info('️📫 Listing and writing Pub/Sub topic configurations.');
52
+ const topics = await context.call(EventTopicList, {});
53
+ context.logger.debug(`📫 Writing configurations for Pub/Sub topics: ${topics
54
+ .map((d) => `'${d.id}'`)
55
+ .join(', ')}.`);
56
+ await mkdir(absoluteDir, { recursive: true });
57
+ await Promise.all(topics.map(async (topic) => {
58
+ const topicConfiguration = {
59
+ ...topic,
60
+ bigQueryTableName: topic.id.replace(/[-\.]/g, '_'),
61
+ };
62
+ const topicFile = join(absoluteDir, `${topic.id}.json`);
63
+ await writeFile(topicFile, JSON.stringify(topicConfiguration));
64
+ }));
65
+ context.logger.debug(`️📫 Wrote Pub/Sub topic configurations in '${absoluteDir}'.`);
66
+ return {
67
+ configuration: {
68
+ google: { pubSub: { topicConfigurationsDirectory } },
69
+ },
70
+ };
71
+ }
72
+ _supports() {
73
+ return true;
74
+ }
75
+ }
76
+ __decorate([
77
+ IsBoolean(),
78
+ AllowMissing(),
79
+ __metadata("design:type", Boolean)
80
+ ], GooglePubSubWriteTopics.prototype, "tearDown", void 0);
@@ -1,6 +1,6 @@
1
1
  import { WorkspaceContext, WorkspaceFunction } from '@causa/workspace';
2
2
  import { InfrastructureProcessor } from '@causa/workspace-core';
3
- import { GoogleConfiguration } from '../configurations/index.js';
3
+ import { GoogleConfiguration } from '../../configurations/index.js';
4
4
  /**
5
5
  * The return value of {@link GoogleServicesEnable}.
6
6
  */
@@ -12,7 +12,7 @@ import { WorkspaceFunction } from '@causa/workspace';
12
12
  import { AllowMissing } from '@causa/workspace/validation';
13
13
  import { ServiceUsageClient } from '@google-cloud/service-usage';
14
14
  import { IsBoolean } from 'class-validator';
15
- import { googleCommandDefinition } from '../cli/index.js';
15
+ import { googleCommandDefinition } from '../../cli/index.js';
16
16
  /**
17
17
  * The maximum number of GCP services that can be enabled at the same time.
18
18
  */
@@ -0,0 +1 @@
1
+ export { GoogleServicesEnable } from './enable.js';
@@ -0,0 +1 @@
1
+ export { GoogleServicesEnable } from './enable.js';
@@ -0,0 +1,2 @@
1
+ export { GoogleSpannerListDatabases } from './list-databases.js';
2
+ export { GoogleSpannerWriteDatabases } from './write-databases.js';
@@ -0,0 +1,2 @@
1
+ export { GoogleSpannerListDatabases } from './list-databases.js';
2
+ export { GoogleSpannerWriteDatabases } from './write-databases.js';
@@ -0,0 +1,22 @@
1
+ import { ProcessorResult, WorkspaceContext, WorkspaceFunction } from '@causa/workspace';
2
+ import { InfrastructureProcessor } from '@causa/workspace-core';
3
+ /**
4
+ * A function that uses {@link GoogleSpannerListDatabases} to find all the Spanner databases in the workspace, and
5
+ * writes their configurations to a directory.
6
+ * The `google.spanner.databaseConfigurationsDirectory` configuration can be used to specify the output location of the
7
+ * database configurations.
8
+ * This function returns a partial configuration, such that it can be used as a processor.
9
+ */
10
+ export declare class GoogleSpannerWriteDatabases extends WorkspaceFunction<Promise<ProcessorResult>> implements InfrastructureProcessor {
11
+ readonly tearDown?: boolean;
12
+ /**
13
+ * Returns the path to the directory where Spanner databases configurations should be written.
14
+ * It is either fetched from the workspace configuration, or the default value is used.
15
+ *
16
+ * @param context The {@link WorkspaceContext}.
17
+ * @returns The path to the directory where database configurations should be written.
18
+ */
19
+ private getConfigurationsDirectory;
20
+ _call(context: WorkspaceContext): Promise<ProcessorResult>;
21
+ _supports(): boolean;
22
+ }