@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
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { callDeferred,
|
|
10
|
+
import { callDeferred, WorkspaceFunction } from '@causa/workspace';
|
|
11
11
|
import { AllowMissing } from '@causa/workspace/validation';
|
|
12
12
|
import { IsObject, IsString } from 'class-validator';
|
|
13
13
|
/**
|
|
@@ -26,8 +26,8 @@ export class GoogleIdentityPlatformGenerateCustomToken extends WorkspaceFunction
|
|
|
26
26
|
* A dictionary of custom claims to add to the token.
|
|
27
27
|
*/
|
|
28
28
|
claims;
|
|
29
|
-
async _call(
|
|
30
|
-
return await callDeferred(this,
|
|
29
|
+
async _call() {
|
|
30
|
+
return await callDeferred(this, import.meta.url);
|
|
31
31
|
}
|
|
32
32
|
_supports() {
|
|
33
33
|
return true;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import type { GoogleIdentityPlatformGenerateToken } from './generate-token.js';
|
|
3
|
-
export default function call(this: GoogleIdentityPlatformGenerateToken
|
|
2
|
+
export default function call(this: GoogleIdentityPlatformGenerateToken): Promise<string>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getAuth, signInWithCustomToken } from 'firebase/auth';
|
|
2
2
|
import { FirebaseAppService } from '../../services/firebase-app.js';
|
|
3
3
|
import { GoogleIdentityPlatformGenerateCustomToken } from './generate-custom-token.js';
|
|
4
|
-
export default async function call(
|
|
5
|
-
|
|
6
|
-
const customToken = await
|
|
7
|
-
const app = await
|
|
4
|
+
export default async function call() {
|
|
5
|
+
this._context.logger.info(`🛂 Signing in user '${this.user}' with a custom token.`);
|
|
6
|
+
const customToken = await this._context.call(GoogleIdentityPlatformGenerateCustomToken, { user: this.user, claims: this.claims });
|
|
7
|
+
const app = await this._context.service(FirebaseAppService).getApp();
|
|
8
8
|
const auth = getAuth(app);
|
|
9
9
|
const credentials = await signInWithCustomToken(auth, customToken);
|
|
10
10
|
return this.refreshToken
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkspaceFunction } from '@causa/workspace';
|
|
2
2
|
/**
|
|
3
3
|
* Generates an ID token for an Identity Platform end user.
|
|
4
4
|
* For this function to succeed, the `google.project` should be set, which usually means setting the environment in the
|
|
@@ -17,6 +17,6 @@ export declare class GoogleIdentityPlatformGenerateToken extends WorkspaceFuncti
|
|
|
17
17
|
* Whether to return the refresh token instead of the ID token.
|
|
18
18
|
*/
|
|
19
19
|
readonly refreshToken?: boolean;
|
|
20
|
-
_call(
|
|
20
|
+
_call(): Promise<string>;
|
|
21
21
|
_supports(): boolean;
|
|
22
22
|
}
|
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { CliArgument, CliCommand, CliOption } from '@causa/cli';
|
|
11
|
-
import { callDeferred,
|
|
11
|
+
import { callDeferred, WorkspaceFunction } from '@causa/workspace';
|
|
12
12
|
import { AllowMissing } from '@causa/workspace/validation';
|
|
13
13
|
import { Transform } from 'class-transformer';
|
|
14
14
|
import { IsBoolean, IsObject, IsString } from 'class-validator';
|
|
@@ -31,8 +31,8 @@ let GoogleIdentityPlatformGenerateToken = class GoogleIdentityPlatformGenerateTo
|
|
|
31
31
|
* Whether to return the refresh token instead of the ID token.
|
|
32
32
|
*/
|
|
33
33
|
refreshToken;
|
|
34
|
-
async _call(
|
|
35
|
-
return await callDeferred(this,
|
|
34
|
+
async _call() {
|
|
35
|
+
return await callDeferred(this, import.meta.url);
|
|
36
36
|
}
|
|
37
37
|
_supports() {
|
|
38
38
|
return true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ProcessorResult,
|
|
1
|
+
import { type ProcessorResult, WorkspaceFunction } from '@causa/workspace';
|
|
2
2
|
import { type InfrastructureProcessor } from '@causa/workspace-core';
|
|
3
3
|
/**
|
|
4
4
|
* A function that uses {@link EventTopicList} to find all the topics in the workspace, and writes their configurations
|
|
@@ -13,10 +13,9 @@ export declare class GooglePubSubWriteTopics extends WorkspaceFunction<Promise<P
|
|
|
13
13
|
* Returns the path to the directory where Pub/Sub topic configurations should be written.
|
|
14
14
|
* It is either fetched from the workspace configuration, or the default value is used.
|
|
15
15
|
*
|
|
16
|
-
* @param context The {@link WorkspaceContext}.
|
|
17
16
|
* @returns The path to the directory where topic configurations should be written.
|
|
18
17
|
*/
|
|
19
18
|
private getConfigurationsDirectory;
|
|
20
|
-
_call(
|
|
19
|
+
_call(): Promise<ProcessorResult>;
|
|
21
20
|
_supports(): boolean;
|
|
22
21
|
}
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { WorkspaceFunction } from '@causa/workspace';
|
|
11
11
|
import { EventTopicList, } from '@causa/workspace-core';
|
|
12
12
|
import { CAUSA_FOLDER } from '@causa/workspace/initialization';
|
|
13
13
|
import { AllowMissing } from '@causa/workspace/validation';
|
|
@@ -31,26 +31,25 @@ export class GooglePubSubWriteTopics extends WorkspaceFunction {
|
|
|
31
31
|
* Returns the path to the directory where Pub/Sub topic configurations should be written.
|
|
32
32
|
* It is either fetched from the workspace configuration, or the default value is used.
|
|
33
33
|
*
|
|
34
|
-
* @param context The {@link WorkspaceContext}.
|
|
35
34
|
* @returns The path to the directory where topic configurations should be written.
|
|
36
35
|
*/
|
|
37
|
-
getConfigurationsDirectory(
|
|
38
|
-
return (
|
|
36
|
+
getConfigurationsDirectory() {
|
|
37
|
+
return (this._context
|
|
39
38
|
.asConfiguration()
|
|
40
39
|
.get('google.pubSub.topicConfigurationsDirectory') ??
|
|
41
40
|
DEFAULT_TOPIC_CONFIGURATIONS_DIRECTORY);
|
|
42
41
|
}
|
|
43
|
-
async _call(
|
|
44
|
-
const topicConfigurationsDirectory = this.getConfigurationsDirectory(
|
|
45
|
-
const absoluteDir = join(
|
|
42
|
+
async _call() {
|
|
43
|
+
const topicConfigurationsDirectory = this.getConfigurationsDirectory();
|
|
44
|
+
const absoluteDir = join(this._context.rootPath, topicConfigurationsDirectory);
|
|
46
45
|
await rm(absoluteDir, { recursive: true, force: true });
|
|
47
46
|
if (this.tearDown) {
|
|
48
|
-
|
|
47
|
+
this._context.logger.debug(`📫 Tore down Pub/Sub topic configurations directory '${absoluteDir}'.`);
|
|
49
48
|
return { configuration: {} };
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
const topics = await
|
|
53
|
-
|
|
50
|
+
this._context.logger.info('️📫 Listing and writing Pub/Sub topic configurations.');
|
|
51
|
+
const topics = await this._context.call(EventTopicList, {});
|
|
52
|
+
this._context.logger.debug(`📫 Writing configurations for Pub/Sub topics: ${topics
|
|
54
53
|
.map((d) => `'${d.id}'`)
|
|
55
54
|
.join(', ')}.`);
|
|
56
55
|
await mkdir(absoluteDir, { recursive: true });
|
|
@@ -62,7 +61,7 @@ export class GooglePubSubWriteTopics extends WorkspaceFunction {
|
|
|
62
61
|
const topicFile = join(absoluteDir, `${topic.id}.json`);
|
|
63
62
|
await writeFile(topicFile, JSON.stringify(topicConfiguration));
|
|
64
63
|
}));
|
|
65
|
-
|
|
64
|
+
this._context.logger.debug(`️📫 Wrote Pub/Sub topic configurations in '${absoluteDir}'.`);
|
|
66
65
|
return {
|
|
67
66
|
configuration: {
|
|
68
67
|
google: { pubSub: { topicConfigurationsDirectory } },
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import type { GoogleConfiguration } from '../../configurations/index.js';
|
|
3
2
|
import type { GoogleServicesEnable } from './enable.js';
|
|
4
|
-
export default function call(this: GoogleServicesEnable
|
|
3
|
+
export default function call(this: GoogleServicesEnable): Promise<{
|
|
5
4
|
configuration: GoogleConfiguration;
|
|
6
5
|
services: string[];
|
|
7
6
|
}>;
|
|
@@ -3,11 +3,11 @@ import { ServiceUsageClient } from '@google-cloud/service-usage';
|
|
|
3
3
|
* The maximum number of GCP services that can be enabled at the same time.
|
|
4
4
|
*/
|
|
5
5
|
const MAX_SERVICE_BATCH = 20;
|
|
6
|
-
export default async function call(
|
|
6
|
+
export default async function call() {
|
|
7
7
|
if (this.tearDown) {
|
|
8
8
|
return { configuration: {}, services: [] };
|
|
9
9
|
}
|
|
10
|
-
const googleConf =
|
|
10
|
+
const googleConf = this._context.asConfiguration();
|
|
11
11
|
const gcpProject = googleConf.getOrThrow('google.project');
|
|
12
12
|
const services = googleConf.get('google.services');
|
|
13
13
|
if (!services) {
|
|
@@ -20,7 +20,7 @@ export default async function call(context) {
|
|
|
20
20
|
const parent = `projects/${gcpProject}`;
|
|
21
21
|
while (servicesToEnable.length > 0) {
|
|
22
22
|
const serviceIds = servicesToEnable.splice(0, MAX_SERVICE_BATCH);
|
|
23
|
-
|
|
23
|
+
this._context.logger.info(`➕ Enabling GCP service(s) ${serviceIds
|
|
24
24
|
.map((s) => `'${s}'`)
|
|
25
25
|
.join(', ')} in project '${gcpProject}'.`);
|
|
26
26
|
const [operation] = await serviceUsageClient.batchEnableServices({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkspaceFunction } from '@causa/workspace';
|
|
2
2
|
import type { InfrastructureProcessor } from '@causa/workspace-core';
|
|
3
3
|
import type { GoogleConfiguration } from '../../configurations/index.js';
|
|
4
4
|
/**
|
|
@@ -22,7 +22,7 @@ type GoogleServicesEnableResult = {
|
|
|
22
22
|
*/
|
|
23
23
|
export declare class GoogleServicesEnable extends WorkspaceFunction<Promise<GoogleServicesEnableResult>> implements InfrastructureProcessor {
|
|
24
24
|
readonly tearDown?: boolean;
|
|
25
|
-
_call(
|
|
25
|
+
_call(): Promise<GoogleServicesEnableResult>;
|
|
26
26
|
_supports(): boolean;
|
|
27
27
|
}
|
|
28
28
|
export {};
|
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { CliCommand } from '@causa/cli';
|
|
11
|
-
import { callDeferred,
|
|
11
|
+
import { callDeferred, WorkspaceFunction } from '@causa/workspace';
|
|
12
12
|
import { AllowMissing } from '@causa/workspace/validation';
|
|
13
13
|
import { IsBoolean } from 'class-validator';
|
|
14
14
|
import { googleCommandDefinition } from '../../cli/index.js';
|
|
@@ -17,8 +17,8 @@ import { googleCommandDefinition } from '../../cli/index.js';
|
|
|
17
17
|
*/
|
|
18
18
|
let GoogleServicesEnable = class GoogleServicesEnable extends WorkspaceFunction {
|
|
19
19
|
tearDown;
|
|
20
|
-
async _call(
|
|
21
|
-
return await callDeferred(this,
|
|
20
|
+
async _call() {
|
|
21
|
+
return await callDeferred(this, import.meta.url);
|
|
22
22
|
}
|
|
23
23
|
_supports() {
|
|
24
24
|
return true;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModelSchemaExtractDatabase, type SchemaDatabase } from '@causa/workspace-core';
|
|
2
|
+
/**
|
|
3
|
+
* Implements {@link ModelSchemaExtractDatabase} for Google Spanner.
|
|
4
|
+
* The schema is selected when it carries a `googleSpannerTable` Causa extension with a `primaryKey` array. The table
|
|
5
|
+
* name defaults to the schema's name when not explicitly set, and the primary keys are read from the extension's
|
|
6
|
+
* `primaryKey` array.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ModelSchemaExtractDatabaseForGoogleSpanner extends ModelSchemaExtractDatabase {
|
|
9
|
+
_call(): SchemaDatabase;
|
|
10
|
+
_supports(): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ModelSchemaExtractDatabase, } from '@causa/workspace-core';
|
|
2
|
+
/**
|
|
3
|
+
* The name of the Causa extension marking an object schema as a Google Spanner table.
|
|
4
|
+
*/
|
|
5
|
+
const GOOGLE_SPANNER_TABLE_EXTENSION = 'googleSpannerTable';
|
|
6
|
+
/**
|
|
7
|
+
* Implements {@link ModelSchemaExtractDatabase} for Google Spanner.
|
|
8
|
+
* The schema is selected when it carries a `googleSpannerTable` Causa extension with a `primaryKey` array. The table
|
|
9
|
+
* name defaults to the schema's name when not explicitly set, and the primary keys are read from the extension's
|
|
10
|
+
* `primaryKey` array.
|
|
11
|
+
*/
|
|
12
|
+
export class ModelSchemaExtractDatabaseForGoogleSpanner extends ModelSchemaExtractDatabase {
|
|
13
|
+
_call() {
|
|
14
|
+
const extension = this.schema.extensions[GOOGLE_SPANNER_TABLE_EXTENSION];
|
|
15
|
+
const primaryKeys = extension.primaryKey.filter((k) => typeof k === 'string');
|
|
16
|
+
const table = typeof extension.name === 'string' ? extension.name : this.schema.name;
|
|
17
|
+
return { engine: 'google.spanner', table, primaryKeys };
|
|
18
|
+
}
|
|
19
|
+
_supports() {
|
|
20
|
+
const extension = this.schema.extensions[GOOGLE_SPANNER_TABLE_EXTENSION];
|
|
21
|
+
return (typeof extension === 'object' &&
|
|
22
|
+
extension !== null &&
|
|
23
|
+
Array.isArray(extension.primaryKey));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { ModelSchemaExtractDatabaseForGoogleSpanner } from './extract-database.js';
|
|
1
2
|
export { GoogleSpannerListDatabases } from './list-databases.js';
|
|
3
|
+
export { DatabaseQueryRecordsForSpanner } from './query-records.js';
|
|
2
4
|
export { GoogleSpannerWriteDatabases } from './write-databases.js';
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { ModelSchemaExtractDatabaseForGoogleSpanner } from './extract-database.js';
|
|
1
2
|
export { GoogleSpannerListDatabases } from './list-databases.js';
|
|
3
|
+
export { DatabaseQueryRecordsForSpanner } from './query-records.js';
|
|
2
4
|
export { GoogleSpannerWriteDatabases } from './write-databases.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkspaceFunction } from '@causa/workspace';
|
|
2
2
|
/**
|
|
3
3
|
* The definition of a Spanner database with its DDL statements.
|
|
4
4
|
*/
|
|
@@ -20,7 +20,7 @@ export type SpannerDatabase = {
|
|
|
20
20
|
* A function that lists Spanner databases defined in the workspace, and returns their corresponding DDLs.
|
|
21
21
|
*/
|
|
22
22
|
export declare class GoogleSpannerListDatabases extends WorkspaceFunction<Promise<SpannerDatabase[]>> {
|
|
23
|
-
_call(
|
|
23
|
+
_call(): Promise<SpannerDatabase[]>;
|
|
24
24
|
/**
|
|
25
25
|
* Parses a SQL file containing Spanner DDL statements.
|
|
26
26
|
* End-of-the-line comments are removed, and statements are split using semicolons.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkspaceFunction, listFilesAndFormat } from '@causa/workspace';
|
|
2
2
|
import { readFile } from 'fs/promises';
|
|
3
3
|
/**
|
|
4
4
|
* The default format used to infer the ID / name of the database from the format parts.
|
|
@@ -16,16 +16,16 @@ const DEFAULT_DDL_REGULAR_EXPRESSION = 'domains/(?<database>[\\w-]+)\\/spanner\\
|
|
|
16
16
|
* A function that lists Spanner databases defined in the workspace, and returns their corresponding DDLs.
|
|
17
17
|
*/
|
|
18
18
|
export class GoogleSpannerListDatabases extends WorkspaceFunction {
|
|
19
|
-
async _call(
|
|
20
|
-
const googleConf =
|
|
19
|
+
async _call() {
|
|
20
|
+
const googleConf = this._context.asConfiguration();
|
|
21
21
|
const format = googleConf.get('google.spanner.ddls.format') ??
|
|
22
22
|
DEFAULT_DDL_DATABASE_ID_FORMAT;
|
|
23
23
|
const globs = googleConf.get('google.spanner.ddls.globs') ?? DEFAULT_DDL_GLOBS;
|
|
24
24
|
const regExp = googleConf.get('google.spanner.ddls.regularExpression') ??
|
|
25
25
|
DEFAULT_DDL_REGULAR_EXPRESSION;
|
|
26
|
-
|
|
27
|
-
const filesAndFormats = await listFilesAndFormat(globs, regExp, format,
|
|
28
|
-
nonMatchingPathHandler: (path) =>
|
|
26
|
+
this._context.logger.debug('🗃️ Listing Spanner databases and DDL files.');
|
|
27
|
+
const filesAndFormats = await listFilesAndFormat(globs, regExp, format, this._context.rootPath, {
|
|
28
|
+
nonMatchingPathHandler: (path) => this._context.logger.warn(`📂 Path '${path}' matches the Spanner DDL globs but did not match the regular expression. It will be ignored.`),
|
|
29
29
|
});
|
|
30
30
|
const databaseDdlFiles = filesAndFormats.reduce((files, { rendered, filePath }) => {
|
|
31
31
|
(files[rendered] ?? (files[rendered] = [])).push(filePath);
|
|
@@ -35,7 +35,7 @@ export class GoogleSpannerListDatabases extends WorkspaceFunction {
|
|
|
35
35
|
ddlFiles.sort();
|
|
36
36
|
const ddlsInFiles = await Promise.all(ddlFiles.map((ddlFile) => this.parseDdlFile(ddlFile)));
|
|
37
37
|
const ddls = ddlsInFiles.flatMap((ddls) => ddls);
|
|
38
|
-
|
|
38
|
+
this._context.logger.debug(`🗃️ Found Spanner database '${id}' with ${ddlFiles.length} DDL file(s) and ${ddls.length} statement(s).`);
|
|
39
39
|
return { id, ddlFiles, ddls };
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Numeric, PGNumeric, Spanner, SpannerDate, } from '@google-cloud/spanner';
|
|
2
|
+
import { SPANNER_QUERY_RECORDS_LIMIT, } from './query-records.js';
|
|
3
|
+
export default async function call() {
|
|
4
|
+
if (!this.database) {
|
|
5
|
+
throw new Error(`The 'database' input is required for the 'google.spanner' engine.`);
|
|
6
|
+
}
|
|
7
|
+
if (!this.query) {
|
|
8
|
+
throw new Error(`The 'query' input is required for the 'google.spanner' engine.`);
|
|
9
|
+
}
|
|
10
|
+
const googleConf = this._context.asConfiguration();
|
|
11
|
+
const projectId = googleConf.getOrThrow('google.project');
|
|
12
|
+
const instanceName = googleConf.getOrThrow('google.spanner.instance.name');
|
|
13
|
+
this._context.logger.debug(`🗃️ Querying Spanner database '${this.database}' in instance '${instanceName}' (project '${projectId}').`);
|
|
14
|
+
const spanner = new Spanner({ projectId });
|
|
15
|
+
let database;
|
|
16
|
+
try {
|
|
17
|
+
database = spanner.instance(instanceName).database(this.database);
|
|
18
|
+
const rows = [];
|
|
19
|
+
const stream = database.runStream({
|
|
20
|
+
sql: this.query,
|
|
21
|
+
json: true,
|
|
22
|
+
jsonOptions: { wrapNumbers: false, wrapStructs: false },
|
|
23
|
+
});
|
|
24
|
+
for await (const row of stream) {
|
|
25
|
+
if (rows.length >= SPANNER_QUERY_RECORDS_LIMIT) {
|
|
26
|
+
this._context.logger.warn(`⚠️ Spanner query exceeded the hard limit of ${SPANNER_QUERY_RECORDS_LIMIT} rows. Results were truncated.`);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
rows.push(toJson(row));
|
|
30
|
+
}
|
|
31
|
+
return rows;
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
await database?.close();
|
|
35
|
+
spanner.close();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Recursively converts Spanner-specific types in a row to JSON-friendly equivalents:
|
|
40
|
+
* - {@link Numeric} / {@link PGNumeric} (NUMERIC / PG_NUMERIC) → their string value.
|
|
41
|
+
* - {@link SpannerDate} (DATE) → `YYYY-MM-DD` string.
|
|
42
|
+
* - Other `Date` subclasses such as `PreciseDate` (TIMESTAMP) → plain {@link Date} instances.
|
|
43
|
+
*
|
|
44
|
+
* `Buffer` values are returned as-is.
|
|
45
|
+
*/
|
|
46
|
+
function toJson(value) {
|
|
47
|
+
if (value === null || typeof value !== 'object') {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
if (value instanceof Numeric || value instanceof PGNumeric) {
|
|
51
|
+
return value.value;
|
|
52
|
+
}
|
|
53
|
+
if (value instanceof SpannerDate) {
|
|
54
|
+
return value.toJSON();
|
|
55
|
+
}
|
|
56
|
+
if (value instanceof Date) {
|
|
57
|
+
return new Date(value.getTime());
|
|
58
|
+
}
|
|
59
|
+
if (Buffer.isBuffer(value)) {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
return value.map(toJson);
|
|
64
|
+
}
|
|
65
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toJson(v)]));
|
|
66
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DatabaseQueryRecords } from '@causa/workspace-core';
|
|
2
|
+
/**
|
|
3
|
+
* The engine identifier handled by this implementation.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SPANNER_ENGINE = "google.spanner";
|
|
6
|
+
/**
|
|
7
|
+
* The maximum number of rows that will be returned by a single query.
|
|
8
|
+
* Acts as a safety mechanism to avoid loading huge result sets in memory.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SPANNER_QUERY_RECORDS_LIMIT = 100000;
|
|
11
|
+
/**
|
|
12
|
+
* Implements {@link DatabaseQueryRecords} for Spanner databases.
|
|
13
|
+
*
|
|
14
|
+
* The Spanner instance and GCP project are read from the workspace configuration. The `database` input is the name of
|
|
15
|
+
* the database within the instance, and `query` is a regular SQL statement.
|
|
16
|
+
*
|
|
17
|
+
* Results are streamed and capped to {@link SPANNER_QUERY_RECORDS_LIMIT} rows.
|
|
18
|
+
*/
|
|
19
|
+
export declare class DatabaseQueryRecordsForSpanner extends DatabaseQueryRecords {
|
|
20
|
+
_call(): Promise<any[]>;
|
|
21
|
+
_supports(): boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { callDeferred } from '@causa/workspace';
|
|
2
|
+
import { DatabaseQueryRecords } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* The engine identifier handled by this implementation.
|
|
5
|
+
*/
|
|
6
|
+
export const SPANNER_ENGINE = 'google.spanner';
|
|
7
|
+
/**
|
|
8
|
+
* The maximum number of rows that will be returned by a single query.
|
|
9
|
+
* Acts as a safety mechanism to avoid loading huge result sets in memory.
|
|
10
|
+
*/
|
|
11
|
+
export const SPANNER_QUERY_RECORDS_LIMIT = 100_000;
|
|
12
|
+
/**
|
|
13
|
+
* Implements {@link DatabaseQueryRecords} for Spanner databases.
|
|
14
|
+
*
|
|
15
|
+
* The Spanner instance and GCP project are read from the workspace configuration. The `database` input is the name of
|
|
16
|
+
* the database within the instance, and `query` is a regular SQL statement.
|
|
17
|
+
*
|
|
18
|
+
* Results are streamed and capped to {@link SPANNER_QUERY_RECORDS_LIMIT} rows.
|
|
19
|
+
*/
|
|
20
|
+
export class DatabaseQueryRecordsForSpanner extends DatabaseQueryRecords {
|
|
21
|
+
async _call() {
|
|
22
|
+
return await callDeferred(this, import.meta.url);
|
|
23
|
+
}
|
|
24
|
+
_supports() {
|
|
25
|
+
return this.engine === SPANNER_ENGINE;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ProcessorResult,
|
|
1
|
+
import { type ProcessorResult, WorkspaceFunction } from '@causa/workspace';
|
|
2
2
|
import type { InfrastructureProcessor } from '@causa/workspace-core';
|
|
3
3
|
/**
|
|
4
4
|
* A function that uses {@link GoogleSpannerListDatabases} to find all the Spanner databases in the workspace, and
|
|
@@ -13,10 +13,9 @@ export declare class GoogleSpannerWriteDatabases extends WorkspaceFunction<Promi
|
|
|
13
13
|
* Returns the path to the directory where Spanner databases configurations should be written.
|
|
14
14
|
* It is either fetched from the workspace configuration, or the default value is used.
|
|
15
15
|
*
|
|
16
|
-
* @param context The {@link WorkspaceContext}.
|
|
17
16
|
* @returns The path to the directory where database configurations should be written.
|
|
18
17
|
*/
|
|
19
18
|
private getConfigurationsDirectory;
|
|
20
|
-
_call(
|
|
19
|
+
_call(): Promise<ProcessorResult>;
|
|
21
20
|
_supports(): boolean;
|
|
22
21
|
}
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { WorkspaceFunction } from '@causa/workspace';
|
|
11
11
|
import { CAUSA_FOLDER } from '@causa/workspace/initialization';
|
|
12
12
|
import { AllowMissing } from '@causa/workspace/validation';
|
|
13
13
|
import { IsBoolean } from 'class-validator';
|
|
@@ -31,31 +31,30 @@ export class GoogleSpannerWriteDatabases extends WorkspaceFunction {
|
|
|
31
31
|
* Returns the path to the directory where Spanner databases configurations should be written.
|
|
32
32
|
* It is either fetched from the workspace configuration, or the default value is used.
|
|
33
33
|
*
|
|
34
|
-
* @param context The {@link WorkspaceContext}.
|
|
35
34
|
* @returns The path to the directory where database configurations should be written.
|
|
36
35
|
*/
|
|
37
|
-
getConfigurationsDirectory(
|
|
38
|
-
return (
|
|
36
|
+
getConfigurationsDirectory() {
|
|
37
|
+
return (this._context
|
|
39
38
|
.asConfiguration()
|
|
40
39
|
.get('google.spanner.databaseConfigurationsDirectory') ??
|
|
41
40
|
DEFAULT_DATABASE_CONFIGURATIONS_DIRECTORY);
|
|
42
41
|
}
|
|
43
|
-
async _call(
|
|
44
|
-
const databaseConfigurationsDirectory = this.getConfigurationsDirectory(
|
|
45
|
-
const absoluteDir = join(
|
|
42
|
+
async _call() {
|
|
43
|
+
const databaseConfigurationsDirectory = this.getConfigurationsDirectory();
|
|
44
|
+
const absoluteDir = join(this._context.rootPath, databaseConfigurationsDirectory);
|
|
46
45
|
await rm(absoluteDir, { recursive: true, force: true });
|
|
47
46
|
if (this.tearDown) {
|
|
48
|
-
|
|
47
|
+
this._context.logger.debug(`️🗃️ Tore down Spanner database configurations directory '${absoluteDir}'.`);
|
|
49
48
|
return { configuration: {} };
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
const databases = await
|
|
50
|
+
this._context.logger.info('🗃️ Listing and writing Spanner database configurations.');
|
|
51
|
+
const databases = await this._context.call(GoogleSpannerListDatabases, {});
|
|
53
52
|
await mkdir(absoluteDir, { recursive: true });
|
|
54
|
-
|
|
53
|
+
this._context.logger.debug(`🗃️ Writing configurations for Spanner databases: ${databases
|
|
55
54
|
.map((d) => `'${d.id}'`)
|
|
56
55
|
.join(', ')}.`);
|
|
57
56
|
await Promise.all(databases.map((database) => writeFile(join(absoluteDir, `${database.id}.json`), JSON.stringify(database))));
|
|
58
|
-
|
|
57
|
+
this._context.logger.debug(`🗃️ Wrote Spanner database configurations in '${absoluteDir}'.`);
|
|
59
58
|
return {
|
|
60
59
|
configuration: {
|
|
61
60
|
google: { spanner: { databaseConfigurationsDirectory } },
|
package/dist/functions/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { CausaListConfigurationSchemasForGoogle } from './causa/index.js';
|
|
2
2
|
import { EmulatorStartForFirebaseStorage, EmulatorStartForFirestore, EmulatorStartForIdentityPlatform, EmulatorStartForPubSub, EmulatorStartForSpanner, EmulatorStopForFirebaseStorage, EmulatorStopForFirestore, EmulatorStopForIdentityPlatform, EmulatorStopForPubSub, EmulatorStopForSpanner, } from './emulator/index.js';
|
|
3
|
-
import { EventTopicBrokerCreateTopicForPubSub, EventTopicBrokerCreateTriggerForCloudRun, EventTopicBrokerDeleteTopicForPubSub, EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole, EventTopicBrokerDeleteTriggerResourceForPubSubSubscription, EventTopicBrokerDeleteTriggerResourceForServiceAccount, EventTopicBrokerGetTopicIdForPubSub, EventTopicBrokerPublishEventsForGoogle, EventTopicCreateBackfillSourceForBigQuery, } from './event-topic/index.js';
|
|
3
|
+
import { EventTopicBrokerCreateTopicForPubSub, EventTopicBrokerCreateTriggerForCloudRun, EventTopicBrokerDeleteTopicForPubSub, EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole, EventTopicBrokerDeleteTriggerResourceForPubSubSubscription, EventTopicBrokerDeleteTriggerResourceForServiceAccount, EventTopicBrokerGetTopicIdForPubSub, EventTopicBrokerPublishEventsForGoogle, EventTopicCreateBackfillSourceForBigQuery, EventTopicQueryEventsForBigQuery, } from './event-topic/index.js';
|
|
4
4
|
import { GoogleAppCheckGenerateToken } from './google-app-check/index.js';
|
|
5
5
|
import { GoogleFirebaseStorageMergeRules } from './google-firebase-storage/index.js';
|
|
6
|
-
import { GoogleFirestoreMergeRules } from './google-firestore/index.js';
|
|
6
|
+
import { DatabaseQueryRecordsForFirestore, GoogleFirestoreMergeRules, ModelSchemaExtractDatabaseForGoogleFirestore, } from './google-firestore/index.js';
|
|
7
7
|
import { GoogleIdentityPlatformGenerateCustomToken, GoogleIdentityPlatformGenerateToken, } from './google-identity-platform/index.js';
|
|
8
8
|
import { GooglePubSubWriteTopics } from './google-pubsub/index.js';
|
|
9
9
|
import { GoogleServicesEnable } from './google-services/index.js';
|
|
10
|
-
import { GoogleSpannerListDatabases, GoogleSpannerWriteDatabases, } from './google-spanner/index.js';
|
|
10
|
+
import { DatabaseQueryRecordsForSpanner, GoogleSpannerListDatabases, GoogleSpannerWriteDatabases, ModelSchemaExtractDatabaseForGoogleSpanner, } from './google-spanner/index.js';
|
|
11
11
|
import { ProjectGetArtefactDestinationForCloudFunctions, ProjectGetArtefactDestinationForCloudRun, ProjectPushArtefactForCloudFunctions, } from './project/index.js';
|
|
12
12
|
import { SecretFetchForGoogleAccessToken, SecretFetchForGoogleSecretManager, } from './secret/index.js';
|
|
13
|
+
import { ServiceContainerQueryLogsForCloudRun } from './service-container/index.js';
|
|
13
14
|
import { TypeScriptGetDecoratorRendererForGoogleFirestore, TypeScriptGetDecoratorRendererForGoogleSpanner, } from './typescript/index.js';
|
|
14
15
|
export function registerFunctions(context) {
|
|
15
|
-
context.registerFunctionImplementations(CausaListConfigurationSchemasForGoogle, EmulatorStartForFirebaseStorage, EmulatorStartForFirestore, EmulatorStartForIdentityPlatform, EmulatorStartForPubSub, EmulatorStartForSpanner, EmulatorStopForFirebaseStorage, EmulatorStopForFirestore, EmulatorStopForIdentityPlatform, EmulatorStopForPubSub, EmulatorStopForSpanner, EventTopicBrokerCreateTopicForPubSub, EventTopicBrokerCreateTriggerForCloudRun, EventTopicBrokerDeleteTopicForPubSub, EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole, EventTopicBrokerDeleteTriggerResourceForPubSubSubscription, EventTopicBrokerDeleteTriggerResourceForServiceAccount, EventTopicBrokerGetTopicIdForPubSub, EventTopicBrokerPublishEventsForGoogle, EventTopicCreateBackfillSourceForBigQuery, GoogleAppCheckGenerateToken, GoogleFirebaseStorageMergeRules, GoogleFirestoreMergeRules, GoogleIdentityPlatformGenerateCustomToken, GoogleIdentityPlatformGenerateToken, GooglePubSubWriteTopics, GoogleServicesEnable, GoogleSpannerListDatabases, GoogleSpannerWriteDatabases, ProjectGetArtefactDestinationForCloudFunctions, ProjectGetArtefactDestinationForCloudRun, ProjectPushArtefactForCloudFunctions, SecretFetchForGoogleAccessToken, SecretFetchForGoogleSecretManager, TypeScriptGetDecoratorRendererForGoogleFirestore, TypeScriptGetDecoratorRendererForGoogleSpanner);
|
|
16
|
+
context.registerFunctionImplementations(CausaListConfigurationSchemasForGoogle, DatabaseQueryRecordsForFirestore, DatabaseQueryRecordsForSpanner, EmulatorStartForFirebaseStorage, EmulatorStartForFirestore, EmulatorStartForIdentityPlatform, EmulatorStartForPubSub, EmulatorStartForSpanner, EmulatorStopForFirebaseStorage, EmulatorStopForFirestore, EmulatorStopForIdentityPlatform, EmulatorStopForPubSub, EmulatorStopForSpanner, EventTopicBrokerCreateTopicForPubSub, EventTopicBrokerCreateTriggerForCloudRun, EventTopicBrokerDeleteTopicForPubSub, EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole, EventTopicBrokerDeleteTriggerResourceForPubSubSubscription, EventTopicBrokerDeleteTriggerResourceForServiceAccount, EventTopicBrokerGetTopicIdForPubSub, EventTopicBrokerPublishEventsForGoogle, EventTopicCreateBackfillSourceForBigQuery, EventTopicQueryEventsForBigQuery, GoogleAppCheckGenerateToken, GoogleFirebaseStorageMergeRules, GoogleFirestoreMergeRules, GoogleIdentityPlatformGenerateCustomToken, GoogleIdentityPlatformGenerateToken, GooglePubSubWriteTopics, GoogleServicesEnable, GoogleSpannerListDatabases, GoogleSpannerWriteDatabases, ModelSchemaExtractDatabaseForGoogleFirestore, ModelSchemaExtractDatabaseForGoogleSpanner, ProjectGetArtefactDestinationForCloudFunctions, ProjectGetArtefactDestinationForCloudRun, ProjectPushArtefactForCloudFunctions, SecretFetchForGoogleAccessToken, SecretFetchForGoogleSecretManager, ServiceContainerQueryLogsForCloudRun, TypeScriptGetDecoratorRendererForGoogleFirestore, TypeScriptGetDecoratorRendererForGoogleSpanner);
|
|
16
17
|
}
|
|
@@ -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(
|
|
10
|
-
_supports(
|
|
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(
|
|
10
|
-
const projectName =
|
|
11
|
-
const googleConf =
|
|
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(
|
|
20
|
-
const conf =
|
|
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(
|
|
9
|
-
_supports(
|
|
7
|
+
_call(): Promise<string>;
|
|
8
|
+
_supports(): boolean;
|
|
10
9
|
}
|