@causa/workspace-google 0.16.0 → 0.18.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/configurations/schemas/google.yaml +37 -70
- package/dist/configurations/schemas/infrastructure.yaml +3 -5
- package/dist/configurations/schemas/service-container.yaml +7 -17
- package/dist/functions/emulator/start-firebase-storage.d.ts +1 -4
- package/dist/functions/emulator/start-firebase-storage.js +8 -11
- package/dist/functions/emulator/start-firestore.d.ts +1 -3
- package/dist/functions/emulator/start-firestore.js +8 -10
- package/dist/functions/emulator/start-identity-platform.d.ts +1 -4
- package/dist/functions/emulator/start-identity-platform.js +7 -10
- package/dist/functions/emulator/start-pubsub.call.d.ts +1 -2
- package/dist/functions/emulator/start-pubsub.call.js +2 -2
- package/dist/functions/emulator/start-pubsub.d.ts +1 -2
- package/dist/functions/emulator/start-pubsub.js +3 -3
- package/dist/functions/emulator/start-spanner.call.d.ts +1 -2
- package/dist/functions/emulator/start-spanner.call.js +2 -2
- package/dist/functions/emulator/start-spanner.d.ts +1 -2
- package/dist/functions/emulator/start-spanner.js +3 -3
- package/dist/functions/emulator/stop-firebase-storage.d.ts +1 -2
- package/dist/functions/emulator/stop-firebase-storage.js +5 -6
- package/dist/functions/emulator/stop-firestore.d.ts +1 -2
- package/dist/functions/emulator/stop-firestore.js +5 -6
- package/dist/functions/emulator/stop-identity-platform.d.ts +1 -2
- package/dist/functions/emulator/stop-identity-platform.js +5 -6
- package/dist/functions/emulator/stop-pubsub.d.ts +1 -2
- package/dist/functions/emulator/stop-pubsub.js +5 -6
- package/dist/functions/emulator/stop-spanner.d.ts +1 -2
- package/dist/functions/emulator/stop-spanner.js +5 -6
- package/dist/functions/event-topic/broker-create-topic-pubsub.call.d.ts +1 -2
- package/dist/functions/event-topic/broker-create-topic-pubsub.call.js +4 -4
- package/dist/functions/event-topic/broker-create-topic-pubsub.d.ts +2 -3
- package/dist/functions/event-topic/broker-create-topic-pubsub.js +7 -6
- package/dist/functions/event-topic/broker-create-trigger-cloud-run.call.d.ts +1 -2
- package/dist/functions/event-topic/broker-create-trigger-cloud-run.call.js +4 -4
- package/dist/functions/event-topic/broker-create-trigger-cloud-run.d.ts +2 -3
- package/dist/functions/event-topic/broker-create-trigger-cloud-run.js +8 -7
- package/dist/functions/event-topic/broker-delete-topic-pubsub.call.d.ts +1 -2
- package/dist/functions/event-topic/broker-delete-topic-pubsub.call.js +4 -4
- package/dist/functions/event-topic/broker-delete-topic-pubsub.d.ts +2 -3
- package/dist/functions/event-topic/broker-delete-topic-pubsub.js +7 -6
- package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.call.d.ts +1 -2
- package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.call.js +3 -3
- package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.d.ts +2 -3
- package/dist/functions/event-topic/broker-delete-trigger-resource-cloud-run-invoker-role.js +7 -6
- package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.call.d.ts +1 -2
- package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.call.js +7 -4
- package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.d.ts +2 -3
- package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.js +7 -6
- package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.call.d.ts +1 -2
- package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.call.js +4 -4
- package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.d.ts +2 -3
- package/dist/functions/event-topic/broker-delete-trigger-resource-service-account.js +7 -6
- package/dist/functions/event-topic/broker-get-topic-id-pubsub.d.ts +2 -3
- package/dist/functions/event-topic/broker-get-topic-id-pubsub.js +6 -6
- package/dist/functions/event-topic/broker-publish-events-google.call.d.ts +1 -2
- package/dist/functions/event-topic/broker-publish-events-google.call.js +6 -7
- package/dist/functions/event-topic/broker-publish-events-google.d.ts +2 -3
- package/dist/functions/event-topic/broker-publish-events-google.js +7 -6
- package/dist/functions/event-topic/create-backfill-source-bigquery.call.d.ts +1 -2
- package/dist/functions/event-topic/create-backfill-source-bigquery.call.js +4 -4
- package/dist/functions/event-topic/create-backfill-source-bigquery.d.ts +2 -3
- package/dist/functions/event-topic/create-backfill-source-bigquery.js +5 -5
- package/dist/functions/event-topic/index.d.ts +1 -0
- package/dist/functions/event-topic/index.js +1 -0
- package/dist/functions/event-topic/query-events-bigquery.call.d.ts +3 -0
- package/dist/functions/event-topic/query-events-bigquery.call.js +41 -0
- package/dist/functions/event-topic/query-events-bigquery.d.ts +9 -0
- package/dist/functions/event-topic/query-events-bigquery.js +17 -0
- package/dist/functions/google-app-check/generate-token.call.d.ts +1 -2
- package/dist/functions/google-app-check/generate-token.call.js +3 -3
- package/dist/functions/google-app-check/generate-token.d.ts +2 -2
- package/dist/functions/google-app-check/generate-token.js +3 -3
- package/dist/functions/google-firebase-storage/merge-rules.d.ts +2 -2
- package/dist/functions/google-firebase-storage/merge-rules.js +4 -4
- package/dist/functions/google-firestore/extract-database.d.ts +11 -0
- package/dist/functions/google-firestore/extract-database.js +44 -0
- package/dist/functions/google-firestore/index.d.ts +2 -0
- package/dist/functions/google-firestore/index.js +2 -0
- package/dist/functions/google-firestore/merge-rules.d.ts +2 -2
- package/dist/functions/google-firestore/merge-rules.js +4 -4
- package/dist/functions/google-firestore/query-records.call.d.ts +2 -0
- package/dist/functions/google-firestore/query-records.call.js +50 -0
- package/dist/functions/google-firestore/query-records.d.ts +17 -0
- package/dist/functions/google-firestore/query-records.js +22 -0
- package/dist/functions/google-identity-platform/generate-custom-token.call.d.ts +1 -2
- package/dist/functions/google-identity-platform/generate-custom-token.call.js +2 -2
- package/dist/functions/google-identity-platform/generate-custom-token.d.ts +2 -2
- package/dist/functions/google-identity-platform/generate-custom-token.js +3 -3
- package/dist/functions/google-identity-platform/generate-token.call.d.ts +1 -2
- package/dist/functions/google-identity-platform/generate-token.call.js +4 -4
- package/dist/functions/google-identity-platform/generate-token.d.ts +2 -2
- package/dist/functions/google-identity-platform/generate-token.js +3 -3
- package/dist/functions/google-pubsub/write-topics.d.ts +2 -3
- package/dist/functions/google-pubsub/write-topics.js +11 -12
- package/dist/functions/google-services/enable.call.d.ts +1 -2
- package/dist/functions/google-services/enable.call.js +3 -3
- package/dist/functions/google-services/enable.d.ts +2 -2
- package/dist/functions/google-services/enable.js +3 -3
- package/dist/functions/google-spanner/extract-database.d.ts +11 -0
- package/dist/functions/google-spanner/extract-database.js +25 -0
- package/dist/functions/google-spanner/index.d.ts +2 -0
- package/dist/functions/google-spanner/index.js +2 -0
- package/dist/functions/google-spanner/list-databases.d.ts +2 -2
- package/dist/functions/google-spanner/list-databases.js +7 -7
- package/dist/functions/google-spanner/query-records.call.d.ts +2 -0
- package/dist/functions/google-spanner/query-records.call.js +66 -0
- package/dist/functions/google-spanner/query-records.d.ts +22 -0
- package/dist/functions/google-spanner/query-records.js +27 -0
- package/dist/functions/google-spanner/write-databases.d.ts +2 -3
- package/dist/functions/google-spanner/write-databases.js +11 -12
- package/dist/functions/index.js +5 -4
- package/dist/functions/project/get-artefact-destination-cloud-functions.d.ts +2 -3
- package/dist/functions/project/get-artefact-destination-cloud-functions.js +5 -6
- package/dist/functions/project/get-artefact-destination-cloud-run.d.ts +2 -3
- package/dist/functions/project/get-artefact-destination-cloud-run.js +5 -6
- package/dist/functions/project/push-artefact-cloud-functions.call.d.ts +1 -2
- package/dist/functions/project/push-artefact-cloud-functions.call.js +5 -5
- package/dist/functions/project/push-artefact-cloud-functions.d.ts +2 -3
- package/dist/functions/project/push-artefact-cloud-functions.js +5 -5
- package/dist/functions/secret/fetch-access-token.call.d.ts +1 -2
- package/dist/functions/secret/fetch-access-token.call.js +4 -2
- package/dist/functions/secret/fetch-access-token.d.ts +2 -2
- package/dist/functions/secret/fetch-access-token.js +3 -3
- package/dist/functions/secret/fetch-secret-manager.call.d.ts +1 -2
- package/dist/functions/secret/fetch-secret-manager.call.js +3 -3
- package/dist/functions/secret/fetch-secret-manager.d.ts +2 -2
- package/dist/functions/secret/fetch-secret-manager.js +3 -3
- package/dist/functions/service-container/index.d.ts +1 -0
- package/dist/functions/service-container/index.js +1 -0
- package/dist/functions/service-container/query-logs-cloud-run.call.d.ts +3 -0
- package/dist/functions/service-container/query-logs-cloud-run.call.js +36 -0
- package/dist/functions/service-container/query-logs-cloud-run.d.ts +11 -0
- package/dist/functions/service-container/query-logs-cloud-run.js +18 -0
- package/dist/functions/typescript/get-decorator-renderer-google-firestore.d.ts +1 -2
- package/dist/functions/typescript/get-decorator-renderer-google-firestore.js +2 -3
- package/dist/functions/typescript/get-decorator-renderer-google-spanner.d.ts +1 -2
- package/dist/functions/typescript/get-decorator-renderer-google-spanner.js +2 -3
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/logging.d.ts +16 -0
- package/dist/services/logging.js +20 -0
- package/package.json +22 -20
|
@@ -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(
|
|
9
|
-
const projectName =
|
|
10
|
-
const dockerRepository =
|
|
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(
|
|
16
|
-
const conf =
|
|
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
|
|
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(
|
|
5
|
-
|
|
6
|
-
const storageService =
|
|
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
|
-
|
|
16
|
-
|
|
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(
|
|
10
|
-
_supports(
|
|
8
|
+
_call(): Promise<string>;
|
|
9
|
+
_supports(): boolean;
|
|
11
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callDeferred
|
|
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(
|
|
10
|
-
return await callDeferred(this,
|
|
9
|
+
async _call() {
|
|
10
|
+
return await callDeferred(this, import.meta.url);
|
|
11
11
|
}
|
|
12
|
-
_supports(
|
|
13
|
-
const conf =
|
|
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
|
|
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(
|
|
4
|
-
const authClient = await
|
|
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
|
|
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(
|
|
16
|
+
_call(): Promise<string>;
|
|
17
17
|
_supports(): boolean;
|
|
18
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callDeferred, SecretFetch
|
|
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(
|
|
19
|
-
return await callDeferred(this,
|
|
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
|
|
2
|
+
export default function call(this: SecretFetchForGoogleSecretManager): Promise<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidSecretDefinitionError
|
|
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(
|
|
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 } =
|
|
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
|
|
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(
|
|
31
|
+
_call(): Promise<string>;
|
|
32
32
|
_supports(): boolean;
|
|
33
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callDeferred, SecretFetch
|
|
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(
|
|
36
|
-
return await callDeferred(this,
|
|
35
|
+
async _call() {
|
|
36
|
+
return await callDeferred(this, import.meta.url);
|
|
37
37
|
}
|
|
38
38
|
_supports() {
|
|
39
39
|
return this.backend === 'google.secretManager';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ServiceContainerQueryLogsForCloudRun } from './query-logs-cloud-run.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ServiceContainerQueryLogsForCloudRun } from './query-logs-cloud-run.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LoggingService } from '../../services/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The default duration applied to `from` when it is not set, in milliseconds.
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_FROM_OFFSET = 60 * 60 * 1000;
|
|
6
|
+
/**
|
|
7
|
+
* The default value for `limit` when it is not set.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_LIMIT = 1000;
|
|
10
|
+
export default async function call() {
|
|
11
|
+
const from = this.from ?? new Date(Date.now() - DEFAULT_FROM_OFFSET);
|
|
12
|
+
const limit = this.limit ?? DEFAULT_LIMIT;
|
|
13
|
+
const filterParts = [
|
|
14
|
+
`resource.type="cloud_run_revision"`,
|
|
15
|
+
`resource.labels.service_name=~"${this.service}"`,
|
|
16
|
+
`timestamp>="${from.toISOString()}"`,
|
|
17
|
+
];
|
|
18
|
+
if (this.to) {
|
|
19
|
+
filterParts.push(`timestamp<"${this.to.toISOString()}"`);
|
|
20
|
+
}
|
|
21
|
+
if (this.filter) {
|
|
22
|
+
filterParts.push(this.filter);
|
|
23
|
+
}
|
|
24
|
+
const filter = filterParts.join('\n');
|
|
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
|
+
const [pageEntries] = await loggingService.logging.getEntries({
|
|
28
|
+
filter,
|
|
29
|
+
orderBy: 'timestamp asc',
|
|
30
|
+
maxResults: limit,
|
|
31
|
+
});
|
|
32
|
+
return pageEntries.map((entry) => ({
|
|
33
|
+
timestamp: entry.metadata.timestamp,
|
|
34
|
+
message: entry.toStructuredJSON(),
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type QueriedLogEntry, ServiceContainerQueryLogs } from '@causa/workspace-core';
|
|
2
|
+
/**
|
|
3
|
+
* Implements {@link ServiceContainerQueryLogs} for services deployed on Cloud Run.
|
|
4
|
+
*
|
|
5
|
+
* Queries the Cloud Logging API for entries emitted by `cloud_run_revision` resources whose `service_name` label
|
|
6
|
+
* matches the input `service`. The optional `from` / `to` time range, `filter`, and `limit` are forwarded to the API.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ServiceContainerQueryLogsForCloudRun extends ServiceContainerQueryLogs {
|
|
9
|
+
_call(): Promise<QueriedLogEntry[]>;
|
|
10
|
+
_supports(): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { callDeferred } from '@causa/workspace';
|
|
2
|
+
import { ServiceContainerQueryLogs, } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link ServiceContainerQueryLogs} for services deployed on Cloud Run.
|
|
5
|
+
*
|
|
6
|
+
* Queries the Cloud Logging API for entries emitted by `cloud_run_revision` resources whose `service_name` label
|
|
7
|
+
* matches the input `service`. The optional `from` / `to` time range, `filter`, and `limit` are forwarded to the API.
|
|
8
|
+
*/
|
|
9
|
+
export class ServiceContainerQueryLogsForCloudRun extends ServiceContainerQueryLogs {
|
|
10
|
+
async _call() {
|
|
11
|
+
return await callDeferred(this, import.meta.url);
|
|
12
|
+
}
|
|
13
|
+
_supports() {
|
|
14
|
+
return (this._context
|
|
15
|
+
.asConfiguration()
|
|
16
|
+
.get('serviceContainer.platform') === 'google.cloudRun');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import { TypeScriptGetDecoratorRenderer, type TypeScriptWithDecoratorsRendererType } from '@causa/workspace-typescript';
|
|
3
2
|
/**
|
|
4
3
|
* Implements {@link TypeScriptGetDecoratorRenderer} for the `GoogleFirestoreRenderer`.
|
|
5
4
|
*/
|
|
6
5
|
export declare class TypeScriptGetDecoratorRendererForGoogleFirestore extends TypeScriptGetDecoratorRenderer {
|
|
7
6
|
_call(): Promise<TypeScriptWithDecoratorsRendererType>;
|
|
8
|
-
_supports(
|
|
7
|
+
_supports(): boolean;
|
|
9
8
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import { TypeScriptGetDecoratorRenderer, } from '@causa/workspace-typescript';
|
|
3
2
|
/**
|
|
4
3
|
* Implements {@link TypeScriptGetDecoratorRenderer} for the `GoogleFirestoreRenderer`.
|
|
@@ -8,8 +7,8 @@ export class TypeScriptGetDecoratorRendererForGoogleFirestore extends TypeScript
|
|
|
8
7
|
const { GoogleFirestoreRenderer } = await import('../../code-generation/index.js');
|
|
9
8
|
return GoogleFirestoreRenderer;
|
|
10
9
|
}
|
|
11
|
-
_supports(
|
|
12
|
-
return (
|
|
10
|
+
_supports() {
|
|
11
|
+
return (this._context.get('project.language') === 'typescript' &&
|
|
13
12
|
this.generator === 'typescriptModelClass');
|
|
14
13
|
}
|
|
15
14
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import { TypeScriptGetDecoratorRenderer, type TypeScriptWithDecoratorsRendererType } from '@causa/workspace-typescript';
|
|
3
2
|
/**
|
|
4
3
|
* Implements {@link TypeScriptGetDecoratorRenderer} for the `GoogleSpannerRenderer`.
|
|
5
4
|
*/
|
|
6
5
|
export declare class TypeScriptGetDecoratorRendererForGoogleSpanner extends TypeScriptGetDecoratorRenderer {
|
|
7
6
|
_call(): Promise<TypeScriptWithDecoratorsRendererType>;
|
|
8
|
-
_supports(
|
|
7
|
+
_supports(): boolean;
|
|
9
8
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import { TypeScriptGetDecoratorRenderer, } from '@causa/workspace-typescript';
|
|
3
2
|
/**
|
|
4
3
|
* Implements {@link TypeScriptGetDecoratorRenderer} for the `GoogleSpannerRenderer`.
|
|
@@ -8,8 +7,8 @@ export class TypeScriptGetDecoratorRendererForGoogleSpanner extends TypeScriptGe
|
|
|
8
7
|
const { GoogleSpannerRenderer } = await import('../../code-generation/index.js');
|
|
9
8
|
return GoogleSpannerRenderer;
|
|
10
9
|
}
|
|
11
|
-
_supports(
|
|
12
|
-
return (
|
|
10
|
+
_supports() {
|
|
11
|
+
return (this._context.get('project.language') === 'typescript' &&
|
|
13
12
|
this.generator === 'typescriptModelClass');
|
|
14
13
|
}
|
|
15
14
|
}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { FirebaseEmulatorService } from './firebase-emulator.js';
|
|
|
8
8
|
export { GcloudEmulatorService } from './gcloud-emulator.js';
|
|
9
9
|
export { GoogleApisService } from './google-apis.js';
|
|
10
10
|
export { IamService } from './iam.js';
|
|
11
|
+
export { LoggingService } from './logging.js';
|
|
11
12
|
export { PubSubService } from './pubsub.js';
|
|
12
13
|
export { ResourceManagerService } from './resource-manager.js';
|
|
13
14
|
export { GoogleSecretManagerService } from './secret-manager.js';
|
package/dist/services/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { FirebaseEmulatorService } from './firebase-emulator.js';
|
|
|
7
7
|
export { GcloudEmulatorService } from './gcloud-emulator.js';
|
|
8
8
|
export { GoogleApisService } from './google-apis.js';
|
|
9
9
|
export { IamService } from './iam.js';
|
|
10
|
+
export { LoggingService } from './logging.js';
|
|
10
11
|
export { PubSubService } from './pubsub.js';
|
|
11
12
|
export { ResourceManagerService } from './resource-manager.js';
|
|
12
13
|
export { GoogleSecretManagerService } from './secret-manager.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { Logging } from '@google-cloud/logging';
|
|
3
|
+
/**
|
|
4
|
+
* A service that provides access to Cloud Logging.
|
|
5
|
+
*/
|
|
6
|
+
export declare class LoggingService {
|
|
7
|
+
/**
|
|
8
|
+
* The Cloud Logging client configured with the GCP project ID.
|
|
9
|
+
*/
|
|
10
|
+
readonly logging: Logging;
|
|
11
|
+
/**
|
|
12
|
+
* The GCP project ID.
|
|
13
|
+
*/
|
|
14
|
+
readonly projectId: string;
|
|
15
|
+
constructor(context: WorkspaceContext);
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { Logging } from '@google-cloud/logging';
|
|
3
|
+
/**
|
|
4
|
+
* A service that provides access to Cloud Logging.
|
|
5
|
+
*/
|
|
6
|
+
export class LoggingService {
|
|
7
|
+
/**
|
|
8
|
+
* The Cloud Logging client configured with the GCP project ID.
|
|
9
|
+
*/
|
|
10
|
+
logging;
|
|
11
|
+
/**
|
|
12
|
+
* The GCP project ID.
|
|
13
|
+
*/
|
|
14
|
+
projectId;
|
|
15
|
+
constructor(context) {
|
|
16
|
+
const googleConf = context.asConfiguration();
|
|
17
|
+
this.projectId = googleConf.getOrThrow('google.project');
|
|
18
|
+
this.logging = new Logging({ projectId: this.projectId });
|
|
19
|
+
}
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@causa/workspace-google",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0-beta.1",
|
|
4
4
|
"description": "The Causa workspace module providing many functionalities related to GCP and its services.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,23 +35,24 @@
|
|
|
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.
|
|
39
|
-
"@causa/workspace": ">= 0.
|
|
40
|
-
"@causa/workspace-core": ">= 0.
|
|
41
|
-
"@causa/workspace-typescript": ">= 0.
|
|
42
|
-
"@google-cloud/apikeys": "^2.2.
|
|
43
|
-
"@google-cloud/bigquery": "^8.
|
|
44
|
-
"@google-cloud/iam-credentials": "^4.2.
|
|
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.1 < 1.0.0",
|
|
41
|
+
"@causa/workspace-typescript": ">= 0.23.0-beta.1 < 1.0.0",
|
|
42
|
+
"@google-cloud/apikeys": "^2.2.2",
|
|
43
|
+
"@google-cloud/bigquery": "^8.3.1",
|
|
44
|
+
"@google-cloud/iam-credentials": "^4.2.2",
|
|
45
|
+
"@google-cloud/logging": "^11.2.1",
|
|
45
46
|
"@google-cloud/pubsub": "^5.3.0",
|
|
46
|
-
"@google-cloud/resource-manager": "^6.2.
|
|
47
|
-
"@google-cloud/run": "^3.2.
|
|
48
|
-
"@google-cloud/secret-manager": "^6.1.
|
|
49
|
-
"@google-cloud/service-usage": "^4.2.
|
|
50
|
-
"@google-cloud/spanner": "^8.
|
|
47
|
+
"@google-cloud/resource-manager": "^6.2.2",
|
|
48
|
+
"@google-cloud/run": "^3.2.1",
|
|
49
|
+
"@google-cloud/secret-manager": "^6.1.2",
|
|
50
|
+
"@google-cloud/service-usage": "^4.2.2",
|
|
51
|
+
"@google-cloud/spanner": "^8.7.1",
|
|
51
52
|
"@google-cloud/storage": "^7.19.0",
|
|
52
53
|
"class-validator": "^0.15.1",
|
|
53
|
-
"firebase": "^12.
|
|
54
|
-
"firebase-admin": "^13.
|
|
54
|
+
"firebase": "^12.13.0",
|
|
55
|
+
"firebase-admin": "^13.10.0",
|
|
55
56
|
"globby": "^16.2.0",
|
|
56
57
|
"google-auth-library": "^10.6.2",
|
|
57
58
|
"google-gax": "5.0.6",
|
|
@@ -61,20 +62,21 @@
|
|
|
61
62
|
"quicktype-core": "^23.2.6"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
|
-
"@swc/core": "^1.15.
|
|
65
|
+
"@swc/core": "^1.15.33",
|
|
65
66
|
"@swc/jest": "^0.2.39",
|
|
66
67
|
"@tsconfig/node22": "^22.0.5",
|
|
67
68
|
"@types/jest": "^30.0.0",
|
|
68
69
|
"@types/micromatch": "^4.0.10",
|
|
69
|
-
"@types/node": "^20.19.
|
|
70
|
+
"@types/node": "^20.19.41",
|
|
70
71
|
"copyfiles": "^2.4.1",
|
|
71
|
-
"eslint": "^10.
|
|
72
|
+
"eslint": "^10.4.0",
|
|
72
73
|
"eslint-config-prettier": "^10.1.8",
|
|
73
74
|
"eslint-plugin-prettier": "^5.5.5",
|
|
74
|
-
"jest": "^30.
|
|
75
|
+
"jest": "^30.4.2",
|
|
75
76
|
"jest-extended": "^7.0.0",
|
|
76
77
|
"rimraf": "^6.1.3",
|
|
77
78
|
"typescript": "^6.0.3",
|
|
78
|
-
"typescript-eslint": "^8.59.
|
|
79
|
+
"typescript-eslint": "^8.59.3",
|
|
80
|
+
"yaml": "^2.9.0"
|
|
79
81
|
}
|
|
80
82
|
}
|