@causa/workspace-google 0.17.0 → 0.18.0-beta.2

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 (147) hide show
  1. package/dist/configurations/schemas/google.yaml +37 -70
  2. package/dist/configurations/schemas/infrastructure.yaml +3 -5
  3. package/dist/configurations/schemas/service-container.yaml +7 -17
  4. package/dist/functions/emulator/start-firebase-storage.d.ts +1 -4
  5. package/dist/functions/emulator/start-firebase-storage.js +8 -11
  6. package/dist/functions/emulator/start-firestore.d.ts +1 -3
  7. package/dist/functions/emulator/start-firestore.js +8 -10
  8. package/dist/functions/emulator/start-identity-platform.d.ts +1 -4
  9. package/dist/functions/emulator/start-identity-platform.js +7 -10
  10. package/dist/functions/emulator/start-pubsub.call.d.ts +1 -2
  11. package/dist/functions/emulator/start-pubsub.call.js +2 -2
  12. package/dist/functions/emulator/start-pubsub.d.ts +1 -2
  13. package/dist/functions/emulator/start-pubsub.js +3 -3
  14. package/dist/functions/emulator/start-spanner.call.d.ts +1 -2
  15. package/dist/functions/emulator/start-spanner.call.js +2 -2
  16. package/dist/functions/emulator/start-spanner.d.ts +1 -2
  17. package/dist/functions/emulator/start-spanner.js +3 -3
  18. package/dist/functions/emulator/stop-firebase-storage.d.ts +1 -2
  19. package/dist/functions/emulator/stop-firebase-storage.js +5 -6
  20. package/dist/functions/emulator/stop-firestore.d.ts +1 -2
  21. package/dist/functions/emulator/stop-firestore.js +5 -6
  22. package/dist/functions/emulator/stop-identity-platform.d.ts +1 -2
  23. package/dist/functions/emulator/stop-identity-platform.js +5 -6
  24. package/dist/functions/emulator/stop-pubsub.d.ts +1 -2
  25. package/dist/functions/emulator/stop-pubsub.js +5 -6
  26. package/dist/functions/emulator/stop-spanner.d.ts +1 -2
  27. package/dist/functions/emulator/stop-spanner.js +5 -6
  28. package/dist/functions/event-topic/broker-create-topic-pubsub.call.d.ts +1 -2
  29. package/dist/functions/event-topic/broker-create-topic-pubsub.call.js +4 -4
  30. package/dist/functions/event-topic/broker-create-topic-pubsub.d.ts +2 -3
  31. package/dist/functions/event-topic/broker-create-topic-pubsub.js +7 -6
  32. package/dist/functions/event-topic/broker-create-trigger-cloud-run.call.d.ts +1 -2
  33. package/dist/functions/event-topic/broker-create-trigger-cloud-run.call.js +4 -4
  34. package/dist/functions/event-topic/broker-create-trigger-cloud-run.d.ts +2 -3
  35. package/dist/functions/event-topic/broker-create-trigger-cloud-run.js +8 -7
  36. package/dist/functions/event-topic/broker-delete-topic-pubsub.call.d.ts +1 -2
  37. package/dist/functions/event-topic/broker-delete-topic-pubsub.call.js +4 -4
  38. package/dist/functions/event-topic/broker-delete-topic-pubsub.d.ts +2 -3
  39. package/dist/functions/event-topic/broker-delete-topic-pubsub.js +7 -6
  40. package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.call.d.ts +1 -2
  41. package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.call.js +3 -3
  42. package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.d.ts +2 -3
  43. package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.js +7 -6
  44. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.call.d.ts +1 -2
  45. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.call.js +7 -4
  46. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.d.ts +2 -3
  47. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.js +7 -6
  48. package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.call.d.ts +1 -2
  49. package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.call.js +4 -4
  50. package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.d.ts +2 -3
  51. package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.js +7 -6
  52. package/dist/functions/event-topic/broker-get-topic-id-pubsub.d.ts +2 -3
  53. package/dist/functions/event-topic/broker-get-topic-id-pubsub.js +6 -6
  54. package/dist/functions/event-topic/broker-publish-events-google.call.d.ts +1 -2
  55. package/dist/functions/event-topic/broker-publish-events-google.call.js +6 -7
  56. package/dist/functions/event-topic/broker-publish-events-google.d.ts +2 -3
  57. package/dist/functions/event-topic/broker-publish-events-google.js +7 -6
  58. package/dist/functions/event-topic/create-backfill-source-bigquery.call.d.ts +1 -2
  59. package/dist/functions/event-topic/create-backfill-source-bigquery.call.js +4 -4
  60. package/dist/functions/event-topic/create-backfill-source-bigquery.d.ts +2 -3
  61. package/dist/functions/event-topic/create-backfill-source-bigquery.js +5 -5
  62. package/dist/functions/event-topic/query-events-bigquery.call.d.ts +1 -2
  63. package/dist/functions/event-topic/query-events-bigquery.call.js +4 -4
  64. package/dist/functions/event-topic/query-events-bigquery.d.ts +2 -3
  65. package/dist/functions/event-topic/query-events-bigquery.js +5 -5
  66. package/dist/functions/google-app-check/generate-token.call.d.ts +1 -2
  67. package/dist/functions/google-app-check/generate-token.call.js +3 -3
  68. package/dist/functions/google-app-check/generate-token.d.ts +2 -2
  69. package/dist/functions/google-app-check/generate-token.js +3 -3
  70. package/dist/functions/google-firebase-storage/merge-rules.d.ts +2 -2
  71. package/dist/functions/google-firebase-storage/merge-rules.js +4 -4
  72. package/dist/functions/google-firestore/extract-database.d.ts +11 -0
  73. package/dist/functions/google-firestore/extract-database.js +44 -0
  74. package/dist/functions/google-firestore/generate-typescript-decorators.d.ts +13 -0
  75. package/dist/functions/google-firestore/generate-typescript-decorators.js +78 -0
  76. package/dist/functions/google-firestore/index.d.ts +2 -0
  77. package/dist/functions/google-firestore/index.js +2 -0
  78. package/dist/functions/google-firestore/merge-rules.d.ts +2 -2
  79. package/dist/functions/google-firestore/merge-rules.js +4 -4
  80. package/dist/functions/google-firestore/query-records.call.d.ts +1 -2
  81. package/dist/functions/google-firestore/query-records.call.js +3 -3
  82. package/dist/functions/google-firestore/query-records.d.ts +1 -2
  83. package/dist/functions/google-firestore/query-records.js +3 -3
  84. package/dist/functions/google-identity-platform/generate-custom-token.call.d.ts +1 -2
  85. package/dist/functions/google-identity-platform/generate-custom-token.call.js +2 -2
  86. package/dist/functions/google-identity-platform/generate-custom-token.d.ts +2 -2
  87. package/dist/functions/google-identity-platform/generate-custom-token.js +3 -3
  88. package/dist/functions/google-identity-platform/generate-token.call.d.ts +1 -2
  89. package/dist/functions/google-identity-platform/generate-token.call.js +4 -4
  90. package/dist/functions/google-identity-platform/generate-token.d.ts +2 -2
  91. package/dist/functions/google-identity-platform/generate-token.js +3 -3
  92. package/dist/functions/google-pubsub/write-topics.d.ts +2 -3
  93. package/dist/functions/google-pubsub/write-topics.js +11 -12
  94. package/dist/functions/google-services/enable.call.d.ts +1 -2
  95. package/dist/functions/google-services/enable.call.js +3 -3
  96. package/dist/functions/google-services/enable.d.ts +2 -2
  97. package/dist/functions/google-services/enable.js +3 -3
  98. package/dist/functions/google-spanner/extract-database.d.ts +11 -0
  99. package/dist/functions/google-spanner/extract-database.js +25 -0
  100. package/dist/functions/google-spanner/generate-typescript-decorators.d.ts +14 -0
  101. package/dist/functions/google-spanner/generate-typescript-decorators.js +120 -0
  102. package/dist/functions/google-spanner/index.d.ts +2 -0
  103. package/dist/functions/google-spanner/index.js +2 -0
  104. package/dist/functions/google-spanner/list-databases.d.ts +2 -2
  105. package/dist/functions/google-spanner/list-databases.js +7 -7
  106. package/dist/functions/google-spanner/query-records.call.d.ts +1 -2
  107. package/dist/functions/google-spanner/query-records.call.js +4 -4
  108. package/dist/functions/google-spanner/query-records.d.ts +1 -2
  109. package/dist/functions/google-spanner/query-records.js +3 -3
  110. package/dist/functions/google-spanner/write-databases.d.ts +2 -3
  111. package/dist/functions/google-spanner/write-databases.js +11 -12
  112. package/dist/functions/index.js +3 -4
  113. package/dist/functions/project/get-artefact-destination-cloud-functions.d.ts +2 -3
  114. package/dist/functions/project/get-artefact-destination-cloud-functions.js +5 -6
  115. package/dist/functions/project/get-artefact-destination-cloud-run.d.ts +2 -3
  116. package/dist/functions/project/get-artefact-destination-cloud-run.js +5 -6
  117. package/dist/functions/project/push-artefact-cloud-functions.call.d.ts +1 -2
  118. package/dist/functions/project/push-artefact-cloud-functions.call.js +5 -5
  119. package/dist/functions/project/push-artefact-cloud-functions.d.ts +2 -3
  120. package/dist/functions/project/push-artefact-cloud-functions.js +5 -5
  121. package/dist/functions/secret/fetch-access-token.call.d.ts +1 -2
  122. package/dist/functions/secret/fetch-access-token.call.js +4 -2
  123. package/dist/functions/secret/fetch-access-token.d.ts +2 -2
  124. package/dist/functions/secret/fetch-access-token.js +3 -3
  125. package/dist/functions/secret/fetch-secret-manager.call.d.ts +1 -2
  126. package/dist/functions/secret/fetch-secret-manager.call.js +3 -3
  127. package/dist/functions/secret/fetch-secret-manager.d.ts +2 -2
  128. package/dist/functions/secret/fetch-secret-manager.js +3 -3
  129. package/dist/functions/service-container/query-logs-cloud-run.call.d.ts +1 -2
  130. package/dist/functions/service-container/query-logs-cloud-run.call.js +3 -3
  131. package/dist/functions/service-container/query-logs-cloud-run.d.ts +2 -3
  132. package/dist/functions/service-container/query-logs-cloud-run.js +5 -5
  133. package/package.json +16 -16
  134. package/dist/code-generation/google-firestore-renderer.d.ts +0 -12
  135. package/dist/code-generation/google-firestore-renderer.js +0 -89
  136. package/dist/code-generation/google-spanner-renderer.d.ts +0 -11
  137. package/dist/code-generation/google-spanner-renderer.js +0 -100
  138. package/dist/code-generation/index.d.ts +0 -2
  139. package/dist/code-generation/index.js +0 -2
  140. package/dist/code-generation/utils.d.ts +0 -12
  141. package/dist/code-generation/utils.js +0 -21
  142. package/dist/functions/typescript/get-decorator-renderer-google-firestore.d.ts +0 -9
  143. package/dist/functions/typescript/get-decorator-renderer-google-firestore.js +0 -15
  144. package/dist/functions/typescript/get-decorator-renderer-google-spanner.d.ts +0 -9
  145. package/dist/functions/typescript/get-decorator-renderer-google-spanner.js +0 -15
  146. package/dist/functions/typescript/index.d.ts +0 -2
  147. package/dist/functions/typescript/index.js +0 -2
@@ -1,4 +1,3 @@
1
- import { WorkspaceContext } from '@causa/workspace';
2
1
  import { ProjectGetArtefactDestination } from '@causa/workspace-core';
3
2
  /**
4
3
  * Implements the {@link ProjectGetArtefactDestination} function for Cloud Functions projects.
@@ -6,6 +5,6 @@ import { ProjectGetArtefactDestination } from '@causa/workspace-core';
6
5
  * defined in the `google.cloudFunctions.artefactStorage` configuration.
7
6
  */
8
7
  export declare class ProjectGetArtefactDestinationForCloudFunctions extends ProjectGetArtefactDestination {
9
- _call(context: WorkspaceContext): Promise<string>;
10
- _supports(context: WorkspaceContext): boolean;
8
+ _call(): Promise<string>;
9
+ _supports(): boolean;
11
10
  }
@@ -1,4 +1,3 @@
1
- import { WorkspaceContext } from '@causa/workspace';
2
1
  import { ProjectGetArtefactDestination, } from '@causa/workspace-core';
3
2
  /**
4
3
  * Implements the {@link ProjectGetArtefactDestination} function for Cloud Functions projects.
@@ -6,9 +5,9 @@ import { ProjectGetArtefactDestination, } from '@causa/workspace-core';
6
5
  * defined in the `google.cloudFunctions.artefactStorage` configuration.
7
6
  */
8
7
  export class ProjectGetArtefactDestinationForCloudFunctions extends ProjectGetArtefactDestination {
9
- async _call(context) {
10
- const projectName = context.getOrThrow('project.name');
11
- const googleConf = context.asConfiguration();
8
+ async _call() {
9
+ const projectName = this._context.getOrThrow('project.name');
10
+ const googleConf = this._context.asConfiguration();
12
11
  let bucketAndPrefix = googleConf.getOrThrow('google.cloudFunctions.artefactStorage.bucket');
13
12
  const archivesStoragePrefix = googleConf.get('google.cloudFunctions.artefactStorage.prefix');
14
13
  if (archivesStoragePrefix) {
@@ -16,8 +15,8 @@ export class ProjectGetArtefactDestinationForCloudFunctions extends ProjectGetAr
16
15
  }
17
16
  return `gs://${bucketAndPrefix}/${projectName}/${this.tag}.zip`;
18
17
  }
19
- _supports(context) {
20
- const conf = context.asConfiguration();
18
+ _supports() {
19
+ const conf = this._context.asConfiguration();
21
20
  return (conf.get('project.type') === 'serverlessFunctions' &&
22
21
  conf.get('serverlessFunctions.platform') === 'google.cloudFunctions');
23
22
  }
@@ -1,10 +1,9 @@
1
- import { WorkspaceContext } from '@causa/workspace';
2
1
  import { ProjectGetArtefactDestination } from '@causa/workspace-core';
3
2
  /**
4
3
  * Implements the {@link ProjectGetArtefactDestination} function for Cloud Run services.
5
4
  * The destination Docker repository is expected to be defined in `google.cloudRun.dockerRepository`.
6
5
  */
7
6
  export declare class ProjectGetArtefactDestinationForCloudRun extends ProjectGetArtefactDestination {
8
- _call(context: WorkspaceContext): Promise<string>;
9
- _supports(context: WorkspaceContext): boolean;
7
+ _call(): Promise<string>;
8
+ _supports(): boolean;
10
9
  }
@@ -1,19 +1,18 @@
1
- import { WorkspaceContext } from '@causa/workspace';
2
1
  import { ProjectGetArtefactDestination, } from '@causa/workspace-core';
3
2
  /**
4
3
  * Implements the {@link ProjectGetArtefactDestination} function for Cloud Run services.
5
4
  * The destination Docker repository is expected to be defined in `google.cloudRun.dockerRepository`.
6
5
  */
7
6
  export class ProjectGetArtefactDestinationForCloudRun extends ProjectGetArtefactDestination {
8
- async _call(context) {
9
- const projectName = context.getOrThrow('project.name');
10
- const dockerRepository = context
7
+ async _call() {
8
+ const projectName = this._context.getOrThrow('project.name');
9
+ const dockerRepository = this._context
11
10
  .asConfiguration()
12
11
  .getOrThrow('google.cloudRun.dockerRepository');
13
12
  return `${dockerRepository}/${projectName}:${this.tag}`;
14
13
  }
15
- _supports(context) {
16
- const conf = context.asConfiguration();
14
+ _supports() {
15
+ const conf = this._context.asConfiguration();
17
16
  return (conf.get('project.type') === 'serviceContainer' &&
18
17
  conf.get('serviceContainer.platform') === 'google.cloudRun');
19
18
  }
@@ -1,3 +1,2 @@
1
- import type { WorkspaceContext } from '@causa/workspace';
2
1
  import type { ProjectPushArtefactForCloudFunctions } from './push-artefact-cloud-functions.js';
3
- export default function call(this: ProjectPushArtefactForCloudFunctions, context: WorkspaceContext): Promise<string>;
2
+ export default function call(this: ProjectPushArtefactForCloudFunctions): Promise<string>;
@@ -1,9 +1,9 @@
1
1
  import { ArtefactAlreadyExistsError } from '@causa/workspace-core';
2
2
  import { rm } from 'fs/promises';
3
3
  import { CloudStorageService } from '../../services/storage.js';
4
- export default async function call(context) {
5
- context.logger.info(`🚚 Pushing Cloud Functions archive to Cloud Storage.`);
6
- const storageService = context.service(CloudStorageService);
4
+ export default async function call() {
5
+ this._context.logger.info(`🚚 Pushing Cloud Functions archive to Cloud Storage.`);
6
+ const storageService = this._context.service(CloudStorageService);
7
7
  const destination = storageService.getFileFromGsUri(this.destination);
8
8
  if (!this.overwrite) {
9
9
  const [exists] = await destination.exists();
@@ -12,8 +12,8 @@ export default async function call(context) {
12
12
  }
13
13
  }
14
14
  await destination.bucket.upload(this.artefact, { destination });
15
- context.logger.info(`🚚 Successfully pushed archive to '${this.destination}'.`);
16
- context.logger.debug(`🔥 Removing local artefact '${this.artefact}'.`);
15
+ this._context.logger.info(`🚚 Successfully pushed archive to '${this.destination}'.`);
16
+ this._context.logger.debug(`🔥 Removing local artefact '${this.artefact}'.`);
17
17
  await rm(this.artefact);
18
18
  return this.destination;
19
19
  }
@@ -1,4 +1,3 @@
1
- import { WorkspaceContext } from '@causa/workspace';
2
1
  import { ProjectPushArtefact } from '@causa/workspace-core';
3
2
  /**
4
3
  * Implements the {@link ProjectPushArtefact} function for Cloud Functions projects.
@@ -6,6 +5,6 @@ import { ProjectPushArtefact } from '@causa/workspace-core';
6
5
  * {@link ProjectPushArtefact.destination}.
7
6
  */
8
7
  export declare class ProjectPushArtefactForCloudFunctions extends ProjectPushArtefact {
9
- _call(context: WorkspaceContext): Promise<string>;
10
- _supports(context: WorkspaceContext): boolean;
8
+ _call(): Promise<string>;
9
+ _supports(): boolean;
11
10
  }
@@ -1,4 +1,4 @@
1
- import { callDeferred, WorkspaceContext } from '@causa/workspace';
1
+ import { callDeferred } from '@causa/workspace';
2
2
  import { ProjectPushArtefact, } from '@causa/workspace-core';
3
3
  /**
4
4
  * Implements the {@link ProjectPushArtefact} function for Cloud Functions projects.
@@ -6,11 +6,11 @@ import { ProjectPushArtefact, } from '@causa/workspace-core';
6
6
  * {@link ProjectPushArtefact.destination}.
7
7
  */
8
8
  export class ProjectPushArtefactForCloudFunctions extends ProjectPushArtefact {
9
- async _call(context) {
10
- return await callDeferred(this, context, import.meta.url);
9
+ async _call() {
10
+ return await callDeferred(this, import.meta.url);
11
11
  }
12
- _supports(context) {
13
- const conf = context.asConfiguration();
12
+ _supports() {
13
+ const conf = this._context.asConfiguration();
14
14
  return (conf.get('project.type') === 'serverlessFunctions' &&
15
15
  conf.get('serverlessFunctions.platform') === 'google.cloudFunctions');
16
16
  }
@@ -1,3 +1,2 @@
1
- import type { WorkspaceContext } from '@causa/workspace';
2
1
  import { type SecretFetchForGoogleAccessToken } from './fetch-access-token.js';
3
- export default function call(this: SecretFetchForGoogleAccessToken, context: WorkspaceContext): Promise<string>;
2
+ export default function call(this: SecretFetchForGoogleAccessToken): Promise<string>;
@@ -1,7 +1,9 @@
1
1
  import { GoogleApisService } from '../../services/google-apis.js';
2
2
  import { AuthClientResponseError, } from './fetch-access-token.js';
3
- export default async function call(context) {
4
- const authClient = await context.service(GoogleApisService).getAuthClient();
3
+ export default async function call() {
4
+ const authClient = await this._context
5
+ .service(GoogleApisService)
6
+ .getAuthClient();
5
7
  const { token } = await authClient.getAccessToken();
6
8
  if (!token) {
7
9
  throw new AuthClientResponseError();
@@ -1,4 +1,4 @@
1
- import { SecretFetch, WorkspaceContext } from '@causa/workspace';
1
+ import { SecretFetch } from '@causa/workspace';
2
2
  /**
3
3
  * An error thrown when the auth client does not return a token.
4
4
  */
@@ -13,6 +13,6 @@ export declare class AuthClientResponseError extends Error {
13
13
  * The backend ID is `google.accessToken`.
14
14
  */
15
15
  export declare class SecretFetchForGoogleAccessToken extends SecretFetch {
16
- _call(context: WorkspaceContext): Promise<string>;
16
+ _call(): Promise<string>;
17
17
  _supports(): boolean;
18
18
  }
@@ -1,4 +1,4 @@
1
- import { callDeferred, SecretFetch, WorkspaceContext } from '@causa/workspace';
1
+ import { callDeferred, SecretFetch } from '@causa/workspace';
2
2
  /**
3
3
  * An error thrown when the auth client does not return a token.
4
4
  */
@@ -15,8 +15,8 @@ export class AuthClientResponseError extends Error {
15
15
  * The backend ID is `google.accessToken`.
16
16
  */
17
17
  export class SecretFetchForGoogleAccessToken extends SecretFetch {
18
- async _call(context) {
19
- return await callDeferred(this, context, import.meta.url);
18
+ async _call() {
19
+ return await callDeferred(this, import.meta.url);
20
20
  }
21
21
  _supports() {
22
22
  return this.backend === 'google.accessToken';
@@ -1,3 +1,2 @@
1
- import { type WorkspaceContext } from '@causa/workspace';
2
1
  import { type SecretFetchForGoogleSecretManager } from './fetch-secret-manager.js';
3
- export default function call(this: SecretFetchForGoogleSecretManager, context: WorkspaceContext): Promise<string>;
2
+ export default function call(this: SecretFetchForGoogleSecretManager): Promise<string>;
@@ -1,4 +1,4 @@
1
- import { InvalidSecretDefinitionError, } from '@causa/workspace';
1
+ import { InvalidSecretDefinitionError } from '@causa/workspace';
2
2
  import { GoogleSecretManagerService } from '../../services/secret-manager.js';
3
3
  import { UndefinedDefaultGcpProjectError, UnexpectedSecretValueError, } from './fetch-secret-manager.js';
4
4
  /**
@@ -6,7 +6,7 @@ import { UndefinedDefaultGcpProjectError, UnexpectedSecretValueError, } from './
6
6
  * [projects/<projectId>/secrets]<secretName>[/versions/<version>]
7
7
  */
8
8
  const SECRET_ID_REGEX = /^(?:projects\/(?<projectId>[\w-]+)\/secrets\/)?(?<secretName>[\w-]+)(?:\/versions\/(?<version>(\d+|latest)))?$/;
9
- export default async function call(context) {
9
+ export default async function call() {
10
10
  const id = this.configuration.id;
11
11
  if (!id) {
12
12
  throw new InvalidSecretDefinitionError(`Missing 'id' field that should reference the secret.`);
@@ -16,7 +16,7 @@ export default async function call(context) {
16
16
  if (!secretName) {
17
17
  throw new InvalidSecretDefinitionError(`Failed to parse secret reference '${id}'.`);
18
18
  }
19
- const { client, defaultProject } = context.service(GoogleSecretManagerService);
19
+ const { client, defaultProject } = this._context.service(GoogleSecretManagerService);
20
20
  const project = match?.groups?.projectId ?? defaultProject;
21
21
  const version = match?.groups?.version ?? 'latest';
22
22
  if (!project) {
@@ -1,4 +1,4 @@
1
- import { SecretFetch, WorkspaceContext } from '@causa/workspace';
1
+ import { SecretFetch } from '@causa/workspace';
2
2
  /**
3
3
  * An error thrown when the default GCP project is needed to look up a secret but it has not been defined.
4
4
  */
@@ -28,6 +28,6 @@ export declare class UnexpectedSecretValueError extends Error {
28
28
  * `google.project`.
29
29
  */
30
30
  export declare class SecretFetchForGoogleSecretManager extends SecretFetch {
31
- _call(context: WorkspaceContext): Promise<string>;
31
+ _call(): Promise<string>;
32
32
  _supports(): boolean;
33
33
  }
@@ -1,4 +1,4 @@
1
- import { callDeferred, SecretFetch, WorkspaceContext } from '@causa/workspace';
1
+ import { callDeferred, SecretFetch } from '@causa/workspace';
2
2
  /**
3
3
  * An error thrown when the default GCP project is needed to look up a secret but it has not been defined.
4
4
  */
@@ -32,8 +32,8 @@ export class UnexpectedSecretValueError extends Error {
32
32
  * `google.project`.
33
33
  */
34
34
  export class SecretFetchForGoogleSecretManager extends SecretFetch {
35
- async _call(context) {
36
- return await callDeferred(this, context, import.meta.url);
35
+ async _call() {
36
+ return await callDeferred(this, import.meta.url);
37
37
  }
38
38
  _supports() {
39
39
  return this.backend === 'google.secretManager';
@@ -1,4 +1,3 @@
1
- import type { WorkspaceContext } from '@causa/workspace';
2
1
  import type { QueriedLogEntry } from '@causa/workspace-core';
3
2
  import type { ServiceContainerQueryLogsForCloudRun } from './query-logs-cloud-run.js';
4
- export default function call(this: ServiceContainerQueryLogsForCloudRun, context: WorkspaceContext): Promise<QueriedLogEntry[]>;
3
+ export default function call(this: ServiceContainerQueryLogsForCloudRun): Promise<QueriedLogEntry[]>;
@@ -7,7 +7,7 @@ const DEFAULT_FROM_OFFSET = 60 * 60 * 1000;
7
7
  * The default value for `limit` when it is not set.
8
8
  */
9
9
  const DEFAULT_LIMIT = 1000;
10
- export default async function call(context) {
10
+ export default async function call() {
11
11
  const from = this.from ?? new Date(Date.now() - DEFAULT_FROM_OFFSET);
12
12
  const limit = this.limit ?? DEFAULT_LIMIT;
13
13
  const filterParts = [
@@ -22,8 +22,8 @@ export default async function call(context) {
22
22
  filterParts.push(this.filter);
23
23
  }
24
24
  const filter = filterParts.join('\n');
25
- const loggingService = context.service(LoggingService);
26
- context.logger.debug(`Querying Cloud Logging for service '${this.service}' in project '${loggingService.projectId}' with filter:\n${filter}`);
25
+ const loggingService = this._context.service(LoggingService);
26
+ this._context.logger.debug(`Querying Cloud Logging for service '${this.service}' in project '${loggingService.projectId}' with filter:\n${filter}`);
27
27
  const [pageEntries] = await loggingService.logging.getEntries({
28
28
  filter,
29
29
  orderBy: 'timestamp asc',
@@ -1,4 +1,3 @@
1
- import { WorkspaceContext } from '@causa/workspace';
2
1
  import { type QueriedLogEntry, ServiceContainerQueryLogs } from '@causa/workspace-core';
3
2
  /**
4
3
  * Implements {@link ServiceContainerQueryLogs} for services deployed on Cloud Run.
@@ -7,6 +6,6 @@ import { type QueriedLogEntry, ServiceContainerQueryLogs } from '@causa/workspac
7
6
  * matches the input `service`. The optional `from` / `to` time range, `filter`, and `limit` are forwarded to the API.
8
7
  */
9
8
  export declare class ServiceContainerQueryLogsForCloudRun extends ServiceContainerQueryLogs {
10
- _call(context: WorkspaceContext): Promise<QueriedLogEntry[]>;
11
- _supports(context: WorkspaceContext): boolean;
9
+ _call(): Promise<QueriedLogEntry[]>;
10
+ _supports(): boolean;
12
11
  }
@@ -1,4 +1,4 @@
1
- import { callDeferred, WorkspaceContext } from '@causa/workspace';
1
+ import { callDeferred } from '@causa/workspace';
2
2
  import { ServiceContainerQueryLogs, } from '@causa/workspace-core';
3
3
  /**
4
4
  * Implements {@link ServiceContainerQueryLogs} for services deployed on Cloud Run.
@@ -7,11 +7,11 @@ import { ServiceContainerQueryLogs, } from '@causa/workspace-core';
7
7
  * matches the input `service`. The optional `from` / `to` time range, `filter`, and `limit` are forwarded to the API.
8
8
  */
9
9
  export class ServiceContainerQueryLogsForCloudRun extends ServiceContainerQueryLogs {
10
- async _call(context) {
11
- return await callDeferred(this, context, import.meta.url);
10
+ async _call() {
11
+ return await callDeferred(this, import.meta.url);
12
12
  }
13
- _supports(context) {
14
- return (context
13
+ _supports() {
14
+ return (this._context
15
15
  .asConfiguration()
16
16
  .get('serviceContainer.platform') === 'google.cloudRun');
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causa/workspace-google",
3
- "version": "0.17.0",
3
+ "version": "0.18.0-beta.2",
4
4
  "description": "The Causa workspace module providing many functionalities related to GCP and its services.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,12 +35,12 @@
35
35
  "generateConfigurationSchemas": "cs model genCode && perl -pi -e 's|\\@causa/runtime|\\@causa/workspace/validation|g' src/configurations/generated.ts"
36
36
  },
37
37
  "dependencies": {
38
- "@causa/cli": ">= 0.7.0 < 1.0.0",
39
- "@causa/workspace": ">= 0.24.1 < 1.0.0",
40
- "@causa/workspace-core": ">= 0.34.0 < 1.0.0",
41
- "@causa/workspace-typescript": ">= 0.22.0 < 1.0.0",
38
+ "@causa/cli": ">= 0.8.0-beta.1 < 1.0.0",
39
+ "@causa/workspace": ">= 0.25.0-beta.3 < 1.0.0",
40
+ "@causa/workspace-core": ">= 0.35.0-beta.2 < 1.0.0",
41
+ "@causa/workspace-typescript": ">= 0.23.0-beta.2 < 1.0.0",
42
42
  "@google-cloud/apikeys": "^2.2.2",
43
- "@google-cloud/bigquery": "^8.3.0",
43
+ "@google-cloud/bigquery": "^8.3.1",
44
44
  "@google-cloud/iam-credentials": "^4.2.2",
45
45
  "@google-cloud/logging": "^11.2.1",
46
46
  "@google-cloud/pubsub": "^5.3.0",
@@ -48,18 +48,17 @@
48
48
  "@google-cloud/run": "^3.2.1",
49
49
  "@google-cloud/secret-manager": "^6.1.2",
50
50
  "@google-cloud/service-usage": "^4.2.2",
51
- "@google-cloud/spanner": "^8.7.0",
51
+ "@google-cloud/spanner": "^8.7.1",
52
52
  "@google-cloud/storage": "^7.19.0",
53
53
  "class-validator": "^0.15.1",
54
- "firebase": "^12.12.1",
55
- "firebase-admin": "^13.8.0",
54
+ "firebase": "^12.13.0",
55
+ "firebase-admin": "^13.10.0",
56
56
  "globby": "^16.2.0",
57
57
  "google-auth-library": "^10.6.2",
58
58
  "google-gax": "5.0.6",
59
- "googleapis": "^171.4.0",
59
+ "googleapis": "^172.0.0",
60
60
  "micromatch": "^4.0.8",
61
- "pino": "^10.3.1",
62
- "quicktype-core": "^23.2.6"
61
+ "pino": "^10.3.1"
63
62
  },
64
63
  "devDependencies": {
65
64
  "@swc/core": "^1.15.33",
@@ -67,15 +66,16 @@
67
66
  "@tsconfig/node22": "^22.0.5",
68
67
  "@types/jest": "^30.0.0",
69
68
  "@types/micromatch": "^4.0.10",
70
- "@types/node": "^20.19.39",
69
+ "@types/node": "^20.19.41",
71
70
  "copyfiles": "^2.4.1",
72
- "eslint": "^10.3.0",
71
+ "eslint": "^10.4.0",
73
72
  "eslint-config-prettier": "^10.1.8",
74
73
  "eslint-plugin-prettier": "^5.5.5",
75
- "jest": "^30.3.0",
74
+ "jest": "^30.4.2",
76
75
  "jest-extended": "^7.0.0",
77
76
  "rimraf": "^6.1.3",
78
77
  "typescript": "^6.0.3",
79
- "typescript-eslint": "^8.59.1"
78
+ "typescript-eslint": "^8.59.4",
79
+ "yaml": "^2.9.0"
80
80
  }
81
81
  }
@@ -1,12 +0,0 @@
1
- import { type ClassContext, type TypeScriptDecorator, TypeScriptWithDecoratorsRenderer } from '@causa/workspace-typescript/code-generation';
2
- /**
3
- * A {@link TypeScriptDecoratorsRenderer} that adds Google Firestore decorators from the Causa Google runtime.
4
- *
5
- * If an object schema is marked with the `googleFirestoreCollection` attribute, the `@FirestoreCollection` decorator
6
- * is added to the class. If the `hasSoftDelete` property is `true`, the `@SoftDeletedFirestoreCollection` decorator
7
- * is also added.
8
- */
9
- export declare class GoogleFirestoreRenderer extends TypeScriptWithDecoratorsRenderer {
10
- decoratorsForClass(context: ClassContext): TypeScriptDecorator[];
11
- decoratorsForProperty(): TypeScriptDecorator[];
12
- }
@@ -1,89 +0,0 @@
1
- import { TypeScriptWithDecoratorsRenderer, } from '@causa/workspace-typescript/code-generation';
2
- import { schemaMatchesGlobPatterns } from './utils.js';
3
- /**
4
- * The name of the Causa attribute that should be present for a class to be decorated with Google Firestore decorators.
5
- */
6
- const GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE = 'googleFirestoreCollection';
7
- /**
8
- * The name of the Causa module for the TypeScript Google runtime.
9
- */
10
- const CAUSA_GOOGLE_MODULE = '@causa/runtime-google';
11
- /**
12
- * A {@link TypeScriptDecoratorsRenderer} that adds Google Firestore decorators from the Causa Google runtime.
13
- *
14
- * If an object schema is marked with the `googleFirestoreCollection` attribute, the `@FirestoreCollection` decorator
15
- * is added to the class. If the `hasSoftDelete` property is `true`, the `@SoftDeletedFirestoreCollection` decorator
16
- * is also added.
17
- */
18
- export class GoogleFirestoreRenderer extends TypeScriptWithDecoratorsRenderer {
19
- decoratorsForClass(context) {
20
- const collectionAttribute = context.objectAttributes[GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE];
21
- const globs = this.targetLanguage.options.generatorOptions?.google?.firestore?.globs;
22
- if (!collectionAttribute ||
23
- !schemaMatchesGlobPatterns(this, context, globs)) {
24
- return [];
25
- }
26
- const debugName = context.classType.getCombinedName();
27
- if (typeof collectionAttribute !== 'object') {
28
- throw new Error(`Invalid '${GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE}' attribute on '${debugName}'. Expected an object.`);
29
- }
30
- const { name, path, hasSoftDelete } = collectionAttribute;
31
- if (typeof name !== 'string') {
32
- throw new Error(`Invalid '${GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE}' attribute on '${debugName}'. Expected an object with a 'name' string property.`);
33
- }
34
- if (!Array.isArray(path)) {
35
- throw new Error(`Invalid '${GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE}' attribute on '${debugName}'. Expected an object with a 'path' array property.`);
36
- }
37
- const requiredProperties = path.flatMap((e) => typeof e === 'object' &&
38
- e !== null &&
39
- 'property' in e &&
40
- typeof e.property === 'string'
41
- ? [e.property]
42
- : []);
43
- const propertyReferences = new Map();
44
- this.forEachClassProperty(context.classType, 'none', (name, jsonName) => {
45
- if (requiredProperties.includes(jsonName)) {
46
- propertyReferences.set(jsonName, name);
47
- }
48
- });
49
- for (const propertyName of requiredProperties) {
50
- if (!propertyReferences.has(propertyName)) {
51
- throw new Error(`Property '${propertyName}' referenced in 'path' not found in '${debugName}'.`);
52
- }
53
- }
54
- const elements = path.map((element) => {
55
- if (typeof element === 'string') {
56
- return JSON.stringify(element);
57
- }
58
- if (typeof element === 'object' &&
59
- element !== null &&
60
- 'property' in element) {
61
- const propertyName = element.property;
62
- const generatedName = propertyReferences.get(propertyName);
63
- if (!generatedName) {
64
- throw new Error(`Property '${propertyName}' not found in property references.`);
65
- }
66
- return ['doc.', generatedName];
67
- }
68
- throw new Error(`Invalid path element in '${GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE}' attribute on '${debugName}'.`);
69
- });
70
- const pathExpression = path.length === 1
71
- ? elements
72
- : ['[', ...elements.flatMap((e) => [e, ', ']), "].join('/')"];
73
- const decorators = [];
74
- this.addDecoratorToList(decorators, context, 'FirestoreCollection', CAUSA_GOOGLE_MODULE, [
75
- '@FirestoreCollection({ name: ',
76
- JSON.stringify(name),
77
- ', path: (doc) => ',
78
- ...pathExpression,
79
- '})',
80
- ]);
81
- if (hasSoftDelete === true) {
82
- this.addDecoratorToList(decorators, context, 'SoftDeletedFirestoreCollection', CAUSA_GOOGLE_MODULE, ['@SoftDeletedFirestoreCollection()']);
83
- }
84
- return decorators;
85
- }
86
- decoratorsForProperty() {
87
- return [];
88
- }
89
- }
@@ -1,11 +0,0 @@
1
- import { type ClassContext, type ClassPropertyContext, type TypeScriptDecorator, TypeScriptWithDecoratorsRenderer } from '@causa/workspace-typescript/code-generation';
2
- /**
3
- * A {@link TypeScriptDecoratorsRenderer} that adds Google Spanner decorators from the Causa Google runtime.
4
- *
5
- * If an object schema is marked with the `googleSpannerTable` attribute, the `@SpannerTable` decorator is added to the
6
- * class, and `@SpannerColumn` decorators are added to all its properties.
7
- */
8
- export declare class GoogleSpannerRenderer extends TypeScriptWithDecoratorsRenderer {
9
- decoratorsForClass(context: ClassContext): TypeScriptDecorator[];
10
- decoratorsForProperty(context: ClassPropertyContext): TypeScriptDecorator[];
11
- }
@@ -1,100 +0,0 @@
1
- import { TypeScriptWithDecoratorsRenderer, getSingleType, typeScriptSourceForObject, } from '@causa/workspace-typescript/code-generation';
2
- import { schemaMatchesGlobPatterns } from './utils.js';
3
- /**
4
- * The name of the Causa attribute that should be present for a class to be decorated with Google Spanner decorators.
5
- */
6
- const GOOGLE_SPANNER_TABLE_ATTRIBUTE = 'googleSpannerTable';
7
- /**
8
- * The name of the optional Causa attribute that can be present on an object property schema to specify options for the
9
- * `@SpannerColumn` decorator.
10
- */
11
- const GOOGLE_SPANNER_COLUMN_ATTRIBUTE = 'googleSpannerColumn';
12
- /**
13
- * The name of the Causa module for the TypeScript Google runtime.
14
- */
15
- const CAUSA_GOOGLE_MODULE = '@causa/runtime-google';
16
- /**
17
- * The list of options that can be passed to the `@SpannerColumn` decorator and that indicates that the JSONSchema
18
- * specifies the type of the column. In this case, the renderer should not infer any type information.
19
- */
20
- const TYPE_INFO_COLUMN_ATTRIBUTE_NAMES = [
21
- 'isBigInt',
22
- 'isInt',
23
- 'isPreciseDate',
24
- 'isJson',
25
- ];
26
- /**
27
- * A {@link TypeScriptDecoratorsRenderer} that adds Google Spanner decorators from the Causa Google runtime.
28
- *
29
- * If an object schema is marked with the `googleSpannerTable` attribute, the `@SpannerTable` decorator is added to the
30
- * class, and `@SpannerColumn` decorators are added to all its properties.
31
- */
32
- export class GoogleSpannerRenderer extends TypeScriptWithDecoratorsRenderer {
33
- decoratorsForClass(context) {
34
- const tableAttribute = context.objectAttributes[GOOGLE_SPANNER_TABLE_ATTRIBUTE];
35
- const globs = this.targetLanguage.options.generatorOptions?.google?.spanner?.globs;
36
- if (!tableAttribute || !schemaMatchesGlobPatterns(this, context, globs)) {
37
- return [];
38
- }
39
- if (typeof tableAttribute !== 'object' ||
40
- !('primaryKey' in tableAttribute) ||
41
- !Array.isArray(tableAttribute.primaryKey) ||
42
- tableAttribute.primaryKey.length === 0 ||
43
- tableAttribute.primaryKey.some((k) => typeof k !== 'string')) {
44
- throw new Error(`Invalid '${GOOGLE_SPANNER_TABLE_ATTRIBUTE}' attribute on '${context.classType.getCombinedName()}'. Expected an object with a 'primaryKey' array.`);
45
- }
46
- if ('name' in tableAttribute && typeof tableAttribute.name !== 'string') {
47
- throw new Error(`Invalid 'name' in '${GOOGLE_SPANNER_TABLE_ATTRIBUTE}' attribute on '${context.classType.getCombinedName()}'. Expected a string.`);
48
- }
49
- const optionsSource = typeScriptSourceForObject({
50
- primaryKey: tableAttribute.primaryKey,
51
- name: tableAttribute.name,
52
- });
53
- const decorators = [];
54
- this.addDecoratorToList(decorators, context, 'SpannerTable', CAUSA_GOOGLE_MODULE, ['@SpannerTable(', optionsSource, ')']);
55
- return decorators;
56
- }
57
- decoratorsForProperty(context) {
58
- const globs = this.targetLanguage.options.generatorOptions?.google?.spanner?.globs;
59
- if (!context.objectAttributes[GOOGLE_SPANNER_TABLE_ATTRIBUTE] ||
60
- !schemaMatchesGlobPatterns(this, context, globs)) {
61
- return [];
62
- }
63
- const attributes = context.propertyAttributes[GOOGLE_SPANNER_COLUMN_ATTRIBUTE] ?? {};
64
- const { generatorOptions } = this.targetLanguage.options;
65
- const softDeletionColumn = generatorOptions?.google?.spanner?.softDeletionColumn;
66
- const { name: overriddenName, tsOptions } = attributes;
67
- if (tsOptions && typeof tsOptions !== 'object') {
68
- throw new Error(`Invalid 'tsOptions' in '${GOOGLE_SPANNER_COLUMN_ATTRIBUTE}' attribute. Expected an object.`);
69
- }
70
- const columnAttributes = tsOptions ?? {};
71
- if (overriddenName) {
72
- if (typeof overriddenName !== 'string') {
73
- throw new Error(`Invalid 'name' in '${GOOGLE_SPANNER_COLUMN_ATTRIBUTE}' attribute. Expected a string.`);
74
- }
75
- columnAttributes.name = overriddenName;
76
- }
77
- const columnName = overriddenName ?? this.names.get(context.name);
78
- if (columnName === softDeletionColumn) {
79
- columnAttributes.softDelete = true;
80
- }
81
- const singleTypeInfo = getSingleType(context.property.type);
82
- const schemaOverridesTypeInfo = TYPE_INFO_COLUMN_ATTRIBUTE_NAMES.some((name) => name in columnAttributes);
83
- if (!schemaOverridesTypeInfo && singleTypeInfo) {
84
- switch (singleTypeInfo.type?.kind) {
85
- case 'class':
86
- case 'object':
87
- case 'map':
88
- columnAttributes.isJson = true;
89
- break;
90
- case 'integer':
91
- columnAttributes.isInt = true;
92
- break;
93
- }
94
- }
95
- const optionsSource = typeScriptSourceForObject(columnAttributes);
96
- const decorators = [];
97
- this.addDecoratorToList(decorators, context, 'SpannerColumn', CAUSA_GOOGLE_MODULE, ['@SpannerColumn(', optionsSource, ')']);
98
- return decorators;
99
- }
100
- }
@@ -1,2 +0,0 @@
1
- export { GoogleFirestoreRenderer } from './google-firestore-renderer.js';
2
- export { GoogleSpannerRenderer } from './google-spanner-renderer.js';
@@ -1,2 +0,0 @@
1
- export { GoogleFirestoreRenderer } from './google-firestore-renderer.js';
2
- export { GoogleSpannerRenderer } from './google-spanner-renderer.js';