@causa/workspace-google 0.4.0 → 0.6.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 (112) 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 +9 -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.d.ts → emulator/start-spanner.d.ts} +8 -0
  16. package/dist/functions/{emulator-start-spanner.js → emulator/start-spanner.js} +29 -14
  17. package/dist/functions/{emulator-stop-firebase-storage.js → emulator/stop-firebase-storage.js} +1 -1
  18. package/dist/functions/{emulator-stop-firestore.js → emulator/stop-firestore.js} +1 -1
  19. package/dist/functions/{emulator-stop-identity-platform.js → emulator/stop-identity-platform.js} +1 -1
  20. package/dist/functions/{emulator-stop-pubsub.js → emulator/stop-pubsub.js} +1 -1
  21. package/dist/functions/{emulator-stop-spanner.js → emulator/stop-spanner.js} +1 -1
  22. package/dist/functions/event-topic/broker-create-topic-pubsub.d.ts +11 -0
  23. package/dist/functions/event-topic/broker-create-topic-pubsub.js +27 -0
  24. package/dist/functions/event-topic/broker-create-trigger-cloud-run.d.ts +11 -0
  25. package/dist/functions/event-topic/broker-create-trigger-cloud-run.js +38 -0
  26. package/dist/functions/event-topic/broker-delete-topic-pubsub.d.ts +10 -0
  27. package/dist/functions/event-topic/broker-delete-topic-pubsub.js +26 -0
  28. package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.d.ts +11 -0
  29. package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.js +29 -0
  30. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.d.ts +10 -0
  31. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.js +31 -0
  32. package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.d.ts +11 -0
  33. package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.js +28 -0
  34. package/dist/functions/event-topic/broker-get-topic-id-pubsub.d.ts +10 -0
  35. package/dist/functions/event-topic/broker-get-topic-id-pubsub.js +16 -0
  36. package/dist/functions/event-topic/broker-publish-events-google.d.ts +17 -0
  37. package/dist/functions/event-topic/broker-publish-events-google.js +45 -0
  38. package/dist/functions/event-topic/index.d.ts +8 -0
  39. package/dist/functions/event-topic/index.js +8 -0
  40. package/dist/functions/{google-app-check-generate-token.js → google-app-check/generate-token.js} +4 -3
  41. package/dist/functions/google-app-check/index.d.ts +1 -0
  42. package/dist/functions/google-app-check/index.js +1 -0
  43. package/dist/functions/google-firebase-storage/index.d.ts +1 -0
  44. package/dist/functions/google-firebase-storage/index.js +1 -0
  45. package/dist/functions/{google-firebase-storage-merge-rules.d.ts → google-firebase-storage/merge-rules.d.ts} +1 -1
  46. package/dist/functions/{google-firebase-storage-merge-rules.js → google-firebase-storage/merge-rules.js} +4 -3
  47. package/dist/functions/google-firestore/index.d.ts +1 -0
  48. package/dist/functions/google-firestore/index.js +1 -0
  49. package/dist/functions/{google-firestore-merge-rules.d.ts → google-firestore/merge-rules.d.ts} +1 -1
  50. package/dist/functions/{google-firestore-merge-rules.js → google-firestore/merge-rules.js} +4 -3
  51. package/dist/functions/{google-identity-platform-generate-custom-token.js → google-identity-platform/generate-custom-token.js} +1 -1
  52. package/dist/functions/{google-identity-platform-generate-token.js → google-identity-platform/generate-token.js} +5 -4
  53. package/dist/functions/google-identity-platform/index.d.ts +2 -0
  54. package/dist/functions/google-identity-platform/index.js +2 -0
  55. package/dist/functions/google-pubsub/index.d.ts +1 -0
  56. package/dist/functions/google-pubsub/index.js +1 -0
  57. package/dist/functions/{google-services-enable.d.ts → google-services/enable.d.ts} +1 -1
  58. package/dist/functions/{google-services-enable.js → google-services/enable.js} +3 -2
  59. package/dist/functions/google-services/index.d.ts +1 -0
  60. package/dist/functions/google-services/index.js +1 -0
  61. package/dist/functions/google-spanner/index.d.ts +2 -0
  62. package/dist/functions/google-spanner/index.js +2 -0
  63. package/dist/functions/{google-spanner-write-databases.js → google-spanner/write-databases.js} +1 -1
  64. package/dist/functions/index.js +12 -24
  65. package/dist/functions/project/index.d.ts +3 -0
  66. package/dist/functions/project/index.js +3 -0
  67. package/dist/functions/{project-push-artefact-cloud-functions.js → project/push-artefact-cloud-functions.js} +1 -1
  68. package/dist/functions/secret/fetch-access-token.d.ts +18 -0
  69. package/dist/functions/secret/fetch-access-token.js +30 -0
  70. package/dist/functions/{secret-fetch-secret-manager.js → secret/fetch-secret-manager.js} +1 -1
  71. package/dist/functions/secret/index.d.ts +2 -0
  72. package/dist/functions/secret/index.js +2 -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/google-apis.d.ts +3 -2
  80. package/dist/services/google-apis.js +3 -2
  81. package/dist/services/iam.d.ts +43 -0
  82. package/dist/services/iam.js +65 -0
  83. package/dist/services/index.d.ts +6 -0
  84. package/dist/services/index.js +6 -0
  85. package/dist/services/pubsub.d.ts +41 -0
  86. package/dist/services/pubsub.js +62 -0
  87. package/dist/services/resource-manager.d.ts +18 -0
  88. package/dist/services/resource-manager.js +35 -0
  89. package/package.json +30 -25
  90. /package/dist/functions/{emulator-start-firebase-storage.d.ts → emulator/start-firebase-storage.d.ts} +0 -0
  91. /package/dist/functions/{emulator-start-firestore.d.ts → emulator/start-firestore.d.ts} +0 -0
  92. /package/dist/functions/{emulator-start-identity-platform.d.ts → emulator/start-identity-platform.d.ts} +0 -0
  93. /package/dist/functions/{emulator-start-pubsub.d.ts → emulator/start-pubsub.d.ts} +0 -0
  94. /package/dist/functions/{emulator-stop-firebase-storage.d.ts → emulator/stop-firebase-storage.d.ts} +0 -0
  95. /package/dist/functions/{emulator-stop-firestore.d.ts → emulator/stop-firestore.d.ts} +0 -0
  96. /package/dist/functions/{emulator-stop-identity-platform.d.ts → emulator/stop-identity-platform.d.ts} +0 -0
  97. /package/dist/functions/{emulator-stop-pubsub.d.ts → emulator/stop-pubsub.d.ts} +0 -0
  98. /package/dist/functions/{emulator-stop-spanner.d.ts → emulator/stop-spanner.d.ts} +0 -0
  99. /package/dist/functions/{google-app-check-generate-token.d.ts → google-app-check/generate-token.d.ts} +0 -0
  100. /package/dist/functions/{google-identity-platform-generate-custom-token.d.ts → google-identity-platform/generate-custom-token.d.ts} +0 -0
  101. /package/dist/functions/{google-identity-platform-generate-token.d.ts → google-identity-platform/generate-token.d.ts} +0 -0
  102. /package/dist/functions/{google-pubsub-write-topics.d.ts → google-pubsub/write-topics.d.ts} +0 -0
  103. /package/dist/functions/{google-pubsub-write-topics.js → google-pubsub/write-topics.js} +0 -0
  104. /package/dist/functions/{google-spanner-list-databases.d.ts → google-spanner/list-databases.d.ts} +0 -0
  105. /package/dist/functions/{google-spanner-list-databases.js → google-spanner/list-databases.js} +0 -0
  106. /package/dist/functions/{google-spanner-write-databases.d.ts → google-spanner/write-databases.d.ts} +0 -0
  107. /package/dist/functions/{project-get-artefact-destination-cloud-functions.d.ts → project/get-artefact-destination-cloud-functions.d.ts} +0 -0
  108. /package/dist/functions/{project-get-artefact-destination-cloud-functions.js → project/get-artefact-destination-cloud-functions.js} +0 -0
  109. /package/dist/functions/{project-get-artefact-destination-cloud-run.d.ts → project/get-artefact-destination-cloud-run.d.ts} +0 -0
  110. /package/dist/functions/{project-get-artefact-destination-cloud-run.js → project/get-artefact-destination-cloud-run.js} +0 -0
  111. /package/dist/functions/{project-push-artefact-cloud-functions.d.ts → project/push-artefact-cloud-functions.d.ts} +0 -0
  112. /package/dist/functions/{secret-fetch-secret-manager.d.ts → secret/fetch-secret-manager.d.ts} +0 -0
@@ -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
  */
@@ -21,7 +21,7 @@ const TOKEN_TTL = 3600;
21
21
  /**
22
22
  * Generates a new AppCheck token.
23
23
  */
24
- export let GoogleAppCheckGenerateToken = class GoogleAppCheckGenerateToken extends WorkspaceFunction {
24
+ let GoogleAppCheckGenerateToken = class GoogleAppCheckGenerateToken extends WorkspaceFunction {
25
25
  /**
26
26
  * The ID of the Firebase app for which the token will be generated.
27
27
  * If `undefined`, a Firebase app ID will be found in the configuration or using the API.
@@ -64,3 +64,4 @@ If the Firebase app ID is not specified, it will:
64
64
  outputFn: (token) => console.log(token),
65
65
  })
66
66
  ], GoogleAppCheckGenerateToken);
67
+ export { GoogleAppCheckGenerateToken };
@@ -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
  */
@@ -27,7 +27,7 @@ const DEFAULT_FIREBASE_STORAGE_SECURITY_RULE_FILE = 'storage.rules';
27
27
  * Returns a configuration with `google.firebaseStorage.securityRuleFile` set, such that the function can be used as a
28
28
  * processor.
29
29
  */
30
- export let GoogleFirebaseStorageMergeRules = class GoogleFirebaseStorageMergeRules extends WorkspaceFunction {
30
+ let GoogleFirebaseStorageMergeRules = class GoogleFirebaseStorageMergeRules extends WorkspaceFunction {
31
31
  tearDown;
32
32
  async _call(context) {
33
33
  if (this.tearDown) {
@@ -69,3 +69,4 @@ Input files are looked for in the workspace using the globs defined in google.fi
69
69
  outputFn: ({ securityRuleFile }) => console.log(securityRuleFile),
70
70
  })
71
71
  ], GoogleFirebaseStorageMergeRules);
72
+ export { GoogleFirebaseStorageMergeRules };
@@ -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
  */
@@ -27,7 +27,7 @@ const DEFAULT_FIRESTORE_SECURITY_RULE_FILE = 'firestore.rules';
27
27
  * Returns a configuration with `google.firestore.securityRuleFile` set, such that the function can be used as a
28
28
  * processor.
29
29
  */
30
- export let GoogleFirestoreMergeRules = class GoogleFirestoreMergeRules extends WorkspaceFunction {
30
+ let GoogleFirestoreMergeRules = class GoogleFirestoreMergeRules extends WorkspaceFunction {
31
31
  tearDown;
32
32
  async _call(context) {
33
33
  if (this.tearDown) {
@@ -69,3 +69,4 @@ Input files are looked for in the workspace using the globs defined in google.fi
69
69
  outputFn: ({ securityRuleFile }) => console.log(securityRuleFile),
70
70
  })
71
71
  ], GoogleFirestoreMergeRules);
72
+ export { GoogleFirestoreMergeRules };
@@ -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,15 +13,15 @@ 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
22
22
  * context. Also `google.firebase` children can be used to configure (and speed up) how tokens are generated.
23
23
  */
24
- export let GoogleIdentityPlatformGenerateToken = class GoogleIdentityPlatformGenerateToken extends WorkspaceFunction {
24
+ let GoogleIdentityPlatformGenerateToken = class GoogleIdentityPlatformGenerateToken extends WorkspaceFunction {
25
25
  /**
26
26
  * The ID of the user for which the token will be generated.
27
27
  */
@@ -71,3 +71,4 @@ Optional custom claims can be included in the signed token.`,
71
71
  outputFn: (token) => console.log(token),
72
72
  })
73
73
  ], GoogleIdentityPlatformGenerateToken);
74
+ export { GoogleIdentityPlatformGenerateToken };
@@ -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';
@@ -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
  */
@@ -20,7 +20,7 @@ const MAX_SERVICE_BATCH = 20;
20
20
  /**
21
21
  * Enables GCP services defined in `google.services` for the GCP project defined in `google.project`.
22
22
  */
23
- export let GoogleServicesEnable = class GoogleServicesEnable extends WorkspaceFunction {
23
+ let GoogleServicesEnable = class GoogleServicesEnable extends WorkspaceFunction {
24
24
  tearDown;
25
25
  async _call(context) {
26
26
  if (this.tearDown) {
@@ -72,3 +72,4 @@ They will be enabled in the 'google.project' GCP project.`,
72
72
  outputFn: ({ services }) => console.log(services.join('\n')),
73
73
  })
74
74
  ], GoogleServicesEnable);
75
+ export { GoogleServicesEnable };
@@ -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';
@@ -13,7 +13,7 @@ import { AllowMissing } from '@causa/workspace/validation';
13
13
  import { IsBoolean } from 'class-validator';
14
14
  import { mkdir, rm, writeFile } from 'fs/promises';
15
15
  import { join } from 'path';
16
- import { GoogleSpannerListDatabases } from './google-spanner-list-databases.js';
16
+ import { GoogleSpannerListDatabases } from './list-databases.js';
17
17
  /**
18
18
  * The default directory where Spanner database configurations are written, relative to the workspace root.
19
19
  */
@@ -1,26 +1,14 @@
1
- import { EmulatorStartForFirebaseStorage } from './emulator-start-firebase-storage.js';
2
- import { EmulatorStartForFirestore } from './emulator-start-firestore.js';
3
- import { EmulatorStartForIdentityPlatform } from './emulator-start-identity-platform.js';
4
- import { EmulatorStartForPubSub } from './emulator-start-pubsub.js';
5
- import { EmulatorStartForSpanner } from './emulator-start-spanner.js';
6
- import { EmulatorStopForFirebaseStorage } from './emulator-stop-firebase-storage.js';
7
- import { EmulatorStopForFirestore } from './emulator-stop-firestore.js';
8
- import { EmulatorStopForIdentityPlatform } from './emulator-stop-identity-platform.js';
9
- import { EmulatorStopForPubSub } from './emulator-stop-pubsub.js';
10
- import { EmulatorStopForSpanner } from './emulator-stop-spanner.js';
11
- import { GoogleAppCheckGenerateToken } from './google-app-check-generate-token.js';
12
- import { GoogleFirebaseStorageMergeRules } from './google-firebase-storage-merge-rules.js';
13
- import { GoogleFirestoreMergeRules } from './google-firestore-merge-rules.js';
14
- import { GoogleIdentityPlatformGenerateCustomToken } from './google-identity-platform-generate-custom-token.js';
15
- import { GoogleIdentityPlatformGenerateToken } from './google-identity-platform-generate-token.js';
16
- import { GooglePubSubWriteTopics } from './google-pubsub-write-topics.js';
17
- import { GoogleServicesEnable } from './google-services-enable.js';
18
- import { GoogleSpannerListDatabases } from './google-spanner-list-databases.js';
19
- import { GoogleSpannerWriteDatabases } from './google-spanner-write-databases.js';
20
- import { ProjectGetArtefactDestinationForCloudFunctions } from './project-get-artefact-destination-cloud-functions.js';
21
- import { ProjectGetArtefactDestinationForCloudRun } from './project-get-artefact-destination-cloud-run.js';
22
- import { ProjectPushArtefactForCloudFunctions } from './project-push-artefact-cloud-functions.js';
23
- import { SecretFetchForGoogleSecretManager } from './secret-fetch-secret-manager.js';
1
+ import { EmulatorStartForFirebaseStorage, EmulatorStartForFirestore, EmulatorStartForIdentityPlatform, EmulatorStartForPubSub, EmulatorStartForSpanner, EmulatorStopForFirebaseStorage, EmulatorStopForFirestore, EmulatorStopForIdentityPlatform, EmulatorStopForPubSub, EmulatorStopForSpanner, } from './emulator/index.js';
2
+ import { EventTopicBrokerCreateTopicForPubSub, EventTopicBrokerCreateTriggerForCloudRun, EventTopicBrokerDeleteTopicForPubSub, EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole, EventTopicBrokerDeleteTriggerResourceForPubSubSubscription, EventTopicBrokerDeleteTriggerResourceForServiceAccount, EventTopicBrokerGetTopicIdForPubSub, EventTopicBrokerPublishEventsForGoogle, } from './event-topic/index.js';
3
+ import { GoogleAppCheckGenerateToken } from './google-app-check/index.js';
4
+ import { GoogleFirebaseStorageMergeRules } from './google-firebase-storage/index.js';
5
+ import { GoogleFirestoreMergeRules } from './google-firestore/index.js';
6
+ import { GoogleIdentityPlatformGenerateCustomToken, GoogleIdentityPlatformGenerateToken, } from './google-identity-platform/index.js';
7
+ import { GooglePubSubWriteTopics } from './google-pubsub/index.js';
8
+ import { GoogleServicesEnable } from './google-services/index.js';
9
+ import { GoogleSpannerListDatabases, GoogleSpannerWriteDatabases, } from './google-spanner/index.js';
10
+ import { ProjectGetArtefactDestinationForCloudFunctions, ProjectGetArtefactDestinationForCloudRun, ProjectPushArtefactForCloudFunctions, } from './project/index.js';
11
+ import { SecretFetchForGoogleAccessToken, SecretFetchForGoogleSecretManager, } from './secret/index.js';
24
12
  export function registerFunctions(context) {
25
- context.registerFunctionImplementations(EmulatorStartForFirebaseStorage, EmulatorStartForFirestore, EmulatorStartForIdentityPlatform, EmulatorStartForPubSub, EmulatorStartForSpanner, EmulatorStopForFirebaseStorage, EmulatorStopForFirestore, EmulatorStopForIdentityPlatform, EmulatorStopForPubSub, EmulatorStopForSpanner, GoogleAppCheckGenerateToken, GoogleFirebaseStorageMergeRules, GoogleFirestoreMergeRules, GoogleIdentityPlatformGenerateCustomToken, GoogleIdentityPlatformGenerateToken, GooglePubSubWriteTopics, GoogleServicesEnable, GoogleSpannerListDatabases, GoogleSpannerWriteDatabases, ProjectGetArtefactDestinationForCloudFunctions, ProjectGetArtefactDestinationForCloudRun, ProjectPushArtefactForCloudFunctions, SecretFetchForGoogleSecretManager);
13
+ context.registerFunctionImplementations(EmulatorStartForFirebaseStorage, EmulatorStartForFirestore, EmulatorStartForIdentityPlatform, EmulatorStartForPubSub, EmulatorStartForSpanner, EmulatorStopForFirebaseStorage, EmulatorStopForFirestore, EmulatorStopForIdentityPlatform, EmulatorStopForPubSub, EmulatorStopForSpanner, EventTopicBrokerCreateTopicForPubSub, EventTopicBrokerCreateTriggerForCloudRun, EventTopicBrokerDeleteTopicForPubSub, EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole, EventTopicBrokerDeleteTriggerResourceForPubSubSubscription, EventTopicBrokerDeleteTriggerResourceForServiceAccount, EventTopicBrokerGetTopicIdForPubSub, EventTopicBrokerPublishEventsForGoogle, GoogleAppCheckGenerateToken, GoogleFirebaseStorageMergeRules, GoogleFirestoreMergeRules, GoogleIdentityPlatformGenerateCustomToken, GoogleIdentityPlatformGenerateToken, GooglePubSubWriteTopics, GoogleServicesEnable, GoogleSpannerListDatabases, GoogleSpannerWriteDatabases, ProjectGetArtefactDestinationForCloudFunctions, ProjectGetArtefactDestinationForCloudRun, ProjectPushArtefactForCloudFunctions, SecretFetchForGoogleAccessToken, SecretFetchForGoogleSecretManager);
26
14
  }
@@ -0,0 +1,3 @@
1
+ export { ProjectGetArtefactDestinationForCloudFunctions } from './get-artefact-destination-cloud-functions.js';
2
+ export { ProjectGetArtefactDestinationForCloudRun } from './get-artefact-destination-cloud-run.js';
3
+ export { ProjectPushArtefactForCloudFunctions } from './push-artefact-cloud-functions.js';
@@ -0,0 +1,3 @@
1
+ export { ProjectGetArtefactDestinationForCloudFunctions } from './get-artefact-destination-cloud-functions.js';
2
+ export { ProjectGetArtefactDestinationForCloudRun } from './get-artefact-destination-cloud-run.js';
3
+ export { ProjectPushArtefactForCloudFunctions } from './push-artefact-cloud-functions.js';
@@ -1,6 +1,6 @@
1
1
  import { ArtefactAlreadyExistsError, ProjectPushArtefact, } from '@causa/workspace-core';
2
2
  import { rm } from 'fs/promises';
3
- import { CloudStorageService } from '../services/index.js';
3
+ import { CloudStorageService } from '../../services/index.js';
4
4
  /**
5
5
  * Implements the {@link ProjectPushArtefact} function for Cloud Functions projects.
6
6
  * This copies the local archive of the Cloud Functions project to the Google Cloud Storage URI set in
@@ -0,0 +1,18 @@
1
+ import { SecretFetch, WorkspaceContext } from '@causa/workspace';
2
+ /**
3
+ * An error thrown when the auth client does not return a token.
4
+ */
5
+ export declare class AuthClientResponseError extends Error {
6
+ constructor();
7
+ }
8
+ /**
9
+ * Implements {@link SecretFetch} to retrieve a Google access token.
10
+ * This backend does not require any configuration, as it does not fetch a specific secret and can only return a single
11
+ * value. A Google access token can be used to authenticate with other Google services. The returned token is configured
12
+ * with the current user (or service account)'s credentials, and for the configured GCP project (if any).
13
+ * The backend ID is `google.accessToken`.
14
+ */
15
+ export declare class SecretFetchForGoogleAccessToken extends SecretFetch {
16
+ _call(context: WorkspaceContext): Promise<string>;
17
+ _supports(): boolean;
18
+ }
@@ -0,0 +1,30 @@
1
+ import { SecretFetch } from '@causa/workspace';
2
+ import { GoogleApisService } from '../../services/index.js';
3
+ /**
4
+ * An error thrown when the auth client does not return a token.
5
+ */
6
+ export class AuthClientResponseError extends Error {
7
+ constructor() {
8
+ super('Failed to retrieve the Google access token from the auth client response.');
9
+ }
10
+ }
11
+ /**
12
+ * Implements {@link SecretFetch} to retrieve a Google access token.
13
+ * This backend does not require any configuration, as it does not fetch a specific secret and can only return a single
14
+ * value. A Google access token can be used to authenticate with other Google services. The returned token is configured
15
+ * with the current user (or service account)'s credentials, and for the configured GCP project (if any).
16
+ * The backend ID is `google.accessToken`.
17
+ */
18
+ export class SecretFetchForGoogleAccessToken extends SecretFetch {
19
+ async _call(context) {
20
+ const authClient = await context.service(GoogleApisService).getAuthClient();
21
+ const { token } = await authClient.getAccessToken();
22
+ if (!token) {
23
+ throw new AuthClientResponseError();
24
+ }
25
+ return token;
26
+ }
27
+ _supports() {
28
+ return this.backend === 'google.accessToken';
29
+ }
30
+ }
@@ -1,5 +1,5 @@
1
1
  import { InvalidSecretDefinitionError, SecretFetch, } from '@causa/workspace';
2
- import { GoogleSecretManagerService } from '../services/index.js';
2
+ import { GoogleSecretManagerService } from '../../services/index.js';
3
3
  /**
4
4
  * The regular expression used to match the (Secret Manager) secret ID/name, and possibly its version and project.
5
5
  * [projects/<projectId>/secrets]<secretName>[/versions/<version>]