@causa/workspace-google 0.17.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/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/query-events-bigquery.call.d.ts +1 -2
- package/dist/functions/event-topic/query-events-bigquery.call.js +4 -4
- package/dist/functions/event-topic/query-events-bigquery.d.ts +2 -3
- package/dist/functions/event-topic/query-events-bigquery.js +5 -5
- 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 +1 -0
- package/dist/functions/google-firestore/index.js +1 -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 +1 -2
- package/dist/functions/google-firestore/query-records.call.js +3 -3
- package/dist/functions/google-firestore/query-records.d.ts +1 -2
- package/dist/functions/google-firestore/query-records.js +3 -3
- 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 +1 -0
- package/dist/functions/google-spanner/index.js +1 -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 +1 -2
- package/dist/functions/google-spanner/query-records.call.js +4 -4
- package/dist/functions/google-spanner/query-records.d.ts +1 -2
- package/dist/functions/google-spanner/query-records.js +3 -3
- 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 +3 -3
- 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/query-logs-cloud-run.call.d.ts +1 -2
- package/dist/functions/service-container/query-logs-cloud-run.call.js +3 -3
- package/dist/functions/service-container/query-logs-cloud-run.d.ts +2 -3
- package/dist/functions/service-container/query-logs-cloud-run.js +5 -5
- 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/package.json +14 -13
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
export { ModelSchemaExtractDatabaseForGoogleSpanner } from './extract-database.js';
|
|
1
2
|
export { GoogleSpannerListDatabases } from './list-databases.js';
|
|
2
3
|
export { DatabaseQueryRecordsForSpanner } from './query-records.js';
|
|
3
4
|
export { GoogleSpannerWriteDatabases } from './write-databases.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { ModelSchemaExtractDatabaseForGoogleSpanner } from './extract-database.js';
|
|
1
2
|
export { GoogleSpannerListDatabases } from './list-databases.js';
|
|
2
3
|
export { DatabaseQueryRecordsForSpanner } from './query-records.js';
|
|
3
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
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import { type DatabaseQueryRecordsForSpanner } from './query-records.js';
|
|
3
|
-
export default function call(this: DatabaseQueryRecordsForSpanner
|
|
2
|
+
export default function call(this: DatabaseQueryRecordsForSpanner): Promise<any[]>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Numeric, PGNumeric, Spanner, SpannerDate, } from '@google-cloud/spanner';
|
|
2
2
|
import { SPANNER_QUERY_RECORDS_LIMIT, } from './query-records.js';
|
|
3
|
-
export default async function call(
|
|
3
|
+
export default async function call() {
|
|
4
4
|
if (!this.database) {
|
|
5
5
|
throw new Error(`The 'database' input is required for the 'google.spanner' engine.`);
|
|
6
6
|
}
|
|
7
7
|
if (!this.query) {
|
|
8
8
|
throw new Error(`The 'query' input is required for the 'google.spanner' engine.`);
|
|
9
9
|
}
|
|
10
|
-
const googleConf =
|
|
10
|
+
const googleConf = this._context.asConfiguration();
|
|
11
11
|
const projectId = googleConf.getOrThrow('google.project');
|
|
12
12
|
const instanceName = googleConf.getOrThrow('google.spanner.instance.name');
|
|
13
|
-
|
|
13
|
+
this._context.logger.debug(`🗃️ Querying Spanner database '${this.database}' in instance '${instanceName}' (project '${projectId}').`);
|
|
14
14
|
const spanner = new Spanner({ projectId });
|
|
15
15
|
let database;
|
|
16
16
|
try {
|
|
@@ -23,7 +23,7 @@ export default async function call(context) {
|
|
|
23
23
|
});
|
|
24
24
|
for await (const row of stream) {
|
|
25
25
|
if (rows.length >= SPANNER_QUERY_RECORDS_LIMIT) {
|
|
26
|
-
|
|
26
|
+
this._context.logger.warn(`⚠️ Spanner query exceeded the hard limit of ${SPANNER_QUERY_RECORDS_LIMIT} rows. Results were truncated.`);
|
|
27
27
|
break;
|
|
28
28
|
}
|
|
29
29
|
rows.push(toJson(row));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import { DatabaseQueryRecords } from '@causa/workspace-core';
|
|
3
2
|
/**
|
|
4
3
|
* The engine identifier handled by this implementation.
|
|
@@ -18,6 +17,6 @@ export declare const SPANNER_QUERY_RECORDS_LIMIT = 100000;
|
|
|
18
17
|
* Results are streamed and capped to {@link SPANNER_QUERY_RECORDS_LIMIT} rows.
|
|
19
18
|
*/
|
|
20
19
|
export declare class DatabaseQueryRecordsForSpanner extends DatabaseQueryRecords {
|
|
21
|
-
_call(
|
|
20
|
+
_call(): Promise<any[]>;
|
|
22
21
|
_supports(): boolean;
|
|
23
22
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callDeferred
|
|
1
|
+
import { callDeferred } from '@causa/workspace';
|
|
2
2
|
import { DatabaseQueryRecords } from '@causa/workspace-core';
|
|
3
3
|
/**
|
|
4
4
|
* The engine identifier handled by this implementation.
|
|
@@ -18,8 +18,8 @@ export const SPANNER_QUERY_RECORDS_LIMIT = 100_000;
|
|
|
18
18
|
* Results are streamed and capped to {@link SPANNER_QUERY_RECORDS_LIMIT} rows.
|
|
19
19
|
*/
|
|
20
20
|
export class DatabaseQueryRecordsForSpanner extends DatabaseQueryRecords {
|
|
21
|
-
async _call(
|
|
22
|
-
return await callDeferred(this,
|
|
21
|
+
async _call() {
|
|
22
|
+
return await callDeferred(this, import.meta.url);
|
|
23
23
|
}
|
|
24
24
|
_supports() {
|
|
25
25
|
return this.engine === SPANNER_ENGINE;
|
|
@@ -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
|
@@ -3,15 +3,15 @@ import { EmulatorStartForFirebaseStorage, EmulatorStartForFirestore, EmulatorSta
|
|
|
3
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 { DatabaseQueryRecordsForFirestore, 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 { DatabaseQueryRecordsForSpanner, 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
13
|
import { ServiceContainerQueryLogsForCloudRun } from './service-container/index.js';
|
|
14
14
|
import { TypeScriptGetDecoratorRendererForGoogleFirestore, TypeScriptGetDecoratorRendererForGoogleSpanner, } from './typescript/index.js';
|
|
15
15
|
export function registerFunctions(context) {
|
|
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, ProjectGetArtefactDestinationForCloudFunctions, ProjectGetArtefactDestinationForCloudRun, ProjectPushArtefactForCloudFunctions, SecretFetchForGoogleAccessToken, SecretFetchForGoogleSecretManager, ServiceContainerQueryLogsForCloudRun, 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);
|
|
17
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
|
}
|
|
@@ -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>;
|