@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
|
@@ -18,28 +18,27 @@ const PUBLISH_OPTIONS = {
|
|
|
18
18
|
maxMilliseconds: 1000,
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
|
-
export default async function call(
|
|
22
|
-
const publisher =
|
|
21
|
+
export default async function call() {
|
|
22
|
+
const publisher = this._context
|
|
23
23
|
.service(PubSubService)
|
|
24
24
|
.pubSub.topic(this.topicId, PUBLISH_OPTIONS)
|
|
25
25
|
.flowControlled();
|
|
26
|
-
|
|
26
|
+
this._context.logger.info('📫 Publishing events.');
|
|
27
27
|
let numEvents = 0;
|
|
28
28
|
for await (const event of this.source()) {
|
|
29
29
|
numEvents += 1;
|
|
30
30
|
const wait = publisher.publish({
|
|
31
31
|
data: event.data,
|
|
32
32
|
attributes: event.attributes,
|
|
33
|
-
orderingKey: event.key,
|
|
34
33
|
});
|
|
35
34
|
if (wait) {
|
|
36
|
-
|
|
35
|
+
this._context.logger.debug('Waiting for the publisher to catch up before resuming publishing.');
|
|
37
36
|
await wait;
|
|
38
37
|
}
|
|
39
38
|
if (numEvents % PUBLISH_PROGRESS_LOG_INTERVAL === 0) {
|
|
40
|
-
|
|
39
|
+
this._context.logger.debug(`Published ${numEvents} events.`);
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
await publisher.all();
|
|
44
|
-
|
|
43
|
+
this._context.logger.info(`📫 Finished publishing ${numEvents} events.`);
|
|
45
44
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import { EventTopicBrokerPublishEvents } from '@causa/workspace-core';
|
|
3
2
|
/**
|
|
4
3
|
* Implements {@link EventTopicBrokerPublishEvents} for a Google / GCP stack.
|
|
5
4
|
* The supported message broker is Pub/Sub.
|
|
6
5
|
*/
|
|
7
6
|
export declare class EventTopicBrokerPublishEventsForGoogle extends EventTopicBrokerPublishEvents {
|
|
8
|
-
_call(
|
|
9
|
-
_supports(
|
|
7
|
+
_call(): Promise<void>;
|
|
8
|
+
_supports(): boolean;
|
|
10
9
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { callDeferred
|
|
1
|
+
import { callDeferred } from '@causa/workspace';
|
|
2
2
|
import { EventTopicBrokerPublishEvents, } from '@causa/workspace-core';
|
|
3
3
|
/**
|
|
4
4
|
* Implements {@link EventTopicBrokerPublishEvents} for a Google / GCP stack.
|
|
5
5
|
* The supported message broker is Pub/Sub.
|
|
6
6
|
*/
|
|
7
7
|
export class EventTopicBrokerPublishEventsForGoogle extends EventTopicBrokerPublishEvents {
|
|
8
|
-
async _call(
|
|
9
|
-
return await callDeferred(this,
|
|
8
|
+
async _call() {
|
|
9
|
+
return await callDeferred(this, import.meta.url);
|
|
10
10
|
}
|
|
11
|
-
_supports(
|
|
12
|
-
return (
|
|
13
|
-
|
|
11
|
+
_supports() {
|
|
12
|
+
return (this._context
|
|
13
|
+
.asConfiguration()
|
|
14
|
+
.get('events.broker') === 'google.pubSub');
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import type { BackfillEvent } from '@causa/workspace-core';
|
|
3
2
|
import { type EventTopicCreateBackfillSourceForBigQuery } from './create-backfill-source-bigquery.js';
|
|
4
|
-
export default function call(this: EventTopicCreateBackfillSourceForBigQuery
|
|
3
|
+
export default function call(this: EventTopicCreateBackfillSourceForBigQuery): Promise<AsyncIterable<BackfillEvent>>;
|
|
@@ -21,8 +21,8 @@ function resolveTableId(self, context) {
|
|
|
21
21
|
const tableName = self.eventTopic.replace(/[-\.]/g, '_');
|
|
22
22
|
return `${projectId}.${rawEventsDatasetId}.${tableName}`;
|
|
23
23
|
}
|
|
24
|
-
export default async function call(
|
|
25
|
-
const tableId = resolveTableId(this,
|
|
24
|
+
export default async function call() {
|
|
25
|
+
const tableId = resolveTableId(this, this._context);
|
|
26
26
|
let query = `
|
|
27
27
|
SELECT
|
|
28
28
|
data,
|
|
@@ -34,8 +34,8 @@ export default async function call(context) {
|
|
|
34
34
|
WHERE
|
|
35
35
|
(${this.filter})`;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
const bigQuery =
|
|
37
|
+
this._context.logger.debug(`Creating BigQuery job from query '${query}'.`);
|
|
38
|
+
const bigQuery = this._context.service(BigQueryService).bigQuery;
|
|
39
39
|
const [job] = await bigQuery.createQueryJob(query);
|
|
40
40
|
return (async function* () {
|
|
41
41
|
for await (const row of job.getQueryResultsStream()) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import { type BackfillEvent, EventTopicCreateBackfillSource } from '@causa/workspace-core';
|
|
3
2
|
/**
|
|
4
3
|
* The regular expression used to parse a `bq://<tableId>` source string.
|
|
@@ -15,6 +14,6 @@ export declare const BIGQUERY_SOURCE_REGEX: RegExp;
|
|
|
15
14
|
* The returned async iterable pages through the query results and yields each row as a {@link BackfillEvent}.
|
|
16
15
|
*/
|
|
17
16
|
export declare class EventTopicCreateBackfillSourceForBigQuery extends EventTopicCreateBackfillSource {
|
|
18
|
-
_call(
|
|
19
|
-
_supports(
|
|
17
|
+
_call(): Promise<AsyncIterable<BackfillEvent>>;
|
|
18
|
+
_supports(): boolean;
|
|
20
19
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callDeferred
|
|
1
|
+
import { callDeferred } from '@causa/workspace';
|
|
2
2
|
import { EventTopicCreateBackfillSource, } from '@causa/workspace-core';
|
|
3
3
|
/**
|
|
4
4
|
* The regular expression used to parse a `bq://<tableId>` source string.
|
|
@@ -15,17 +15,17 @@ export const BIGQUERY_SOURCE_REGEX = /^bq:\/\/(?<tableId>.+)$/;
|
|
|
15
15
|
* The returned async iterable pages through the query results and yields each row as a {@link BackfillEvent}.
|
|
16
16
|
*/
|
|
17
17
|
export class EventTopicCreateBackfillSourceForBigQuery extends EventTopicCreateBackfillSource {
|
|
18
|
-
async _call(
|
|
19
|
-
return await callDeferred(this,
|
|
18
|
+
async _call() {
|
|
19
|
+
return await callDeferred(this, import.meta.url);
|
|
20
20
|
}
|
|
21
|
-
_supports(
|
|
21
|
+
_supports() {
|
|
22
22
|
if (this.source?.match(BIGQUERY_SOURCE_REGEX)) {
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
if (this.source) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
|
-
const conf =
|
|
28
|
+
const conf = this._context.asConfiguration();
|
|
29
29
|
return (conf.get('events.broker') === 'google.pubSub' &&
|
|
30
30
|
!!conf.get('google.pubSub.bigQueryStorage.rawEventsDatasetId'));
|
|
31
31
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import type { QueriedEvent } from '@causa/workspace-core';
|
|
3
2
|
import type { EventTopicQueryEventsForBigQuery } from './query-events-bigquery.js';
|
|
4
|
-
export default function call(this: EventTopicQueryEventsForBigQuery
|
|
3
|
+
export default function call(this: EventTopicQueryEventsForBigQuery): Promise<QueriedEvent[]>;
|
|
@@ -7,10 +7,10 @@ const DEFAULT_FROM_OFFSET = 60 * 60 * 1000;
|
|
|
7
7
|
* The default value for `limit` when it is not set.
|
|
8
8
|
*/
|
|
9
9
|
const DEFAULT_LIMIT = 1000;
|
|
10
|
-
export default async function call(
|
|
10
|
+
export default async function call() {
|
|
11
11
|
const from = this.from ?? new Date(Date.now() - DEFAULT_FROM_OFFSET);
|
|
12
12
|
const limit = this.limit ?? DEFAULT_LIMIT;
|
|
13
|
-
const googleConf =
|
|
13
|
+
const googleConf = this._context.asConfiguration();
|
|
14
14
|
const projectId = googleConf.getOrThrow('google.project');
|
|
15
15
|
const rawEventsDatasetId = googleConf.getOrThrow('google.pubSub.bigQueryStorage.rawEventsDatasetId');
|
|
16
16
|
const tableName = this.topic.replace(/[-\.]/g, '_');
|
|
@@ -30,8 +30,8 @@ export default async function call(context) {
|
|
|
30
30
|
WHERE ${conditions.join(' AND ')}
|
|
31
31
|
ORDER BY publish_time ASC
|
|
32
32
|
LIMIT ${limit}`;
|
|
33
|
-
|
|
34
|
-
const bigQuery =
|
|
33
|
+
this._context.logger.debug(`Querying BigQuery for events:\n${query}`);
|
|
34
|
+
const bigQuery = this._context.service(BigQueryService).bigQuery;
|
|
35
35
|
const [rows] = await bigQuery.query({ query, params });
|
|
36
36
|
return rows.map((row) => ({
|
|
37
37
|
timestamp: new Date(row.publish_time.value),
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import { EventTopicQueryEvents, type QueriedEvent } from '@causa/workspace-core';
|
|
3
2
|
/**
|
|
4
3
|
* Implements {@link EventTopicQueryEvents} for Pub/Sub topics whose events are stored in BigQuery via a BigQuery
|
|
5
4
|
* subscription. The events are read from the dataset configured at `google.pubSub.bigQueryStorage.rawEventsDatasetId`.
|
|
6
5
|
*/
|
|
7
6
|
export declare class EventTopicQueryEventsForBigQuery extends EventTopicQueryEvents {
|
|
8
|
-
_call(
|
|
9
|
-
_supports(
|
|
7
|
+
_call(): Promise<QueriedEvent[]>;
|
|
8
|
+
_supports(): boolean;
|
|
10
9
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { callDeferred
|
|
1
|
+
import { callDeferred } from '@causa/workspace';
|
|
2
2
|
import { EventTopicQueryEvents, } from '@causa/workspace-core';
|
|
3
3
|
/**
|
|
4
4
|
* Implements {@link EventTopicQueryEvents} for Pub/Sub topics whose events are stored in BigQuery via a BigQuery
|
|
5
5
|
* subscription. The events are read from the dataset configured at `google.pubSub.bigQueryStorage.rawEventsDatasetId`.
|
|
6
6
|
*/
|
|
7
7
|
export class EventTopicQueryEventsForBigQuery extends EventTopicQueryEvents {
|
|
8
|
-
async _call(
|
|
9
|
-
return await callDeferred(this,
|
|
8
|
+
async _call() {
|
|
9
|
+
return await callDeferred(this, import.meta.url);
|
|
10
10
|
}
|
|
11
|
-
_supports(
|
|
12
|
-
const conf =
|
|
11
|
+
_supports() {
|
|
12
|
+
const conf = this._context.asConfiguration();
|
|
13
13
|
return (conf.get('events.broker') === 'google.pubSub' &&
|
|
14
14
|
conf.get('events.format') === 'json' &&
|
|
15
15
|
!!conf.get('google.pubSub.bigQueryStorage.rawEventsDatasetId'));
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import type { GoogleAppCheckGenerateToken } from './generate-token.js';
|
|
3
|
-
export default function call(this: GoogleAppCheckGenerateToken
|
|
2
|
+
export default function call(this: GoogleAppCheckGenerateToken): Promise<string>;
|
|
@@ -4,11 +4,11 @@ import { FirebaseAppService } from '../../services/firebase-app.js';
|
|
|
4
4
|
* The time to live of generated tokens, in seconds.
|
|
5
5
|
*/
|
|
6
6
|
const TOKEN_TTL = 3600;
|
|
7
|
-
export default async function call(
|
|
8
|
-
const firebaseAppService =
|
|
7
|
+
export default async function call() {
|
|
8
|
+
const firebaseAppService = this._context.service(FirebaseAppService);
|
|
9
9
|
const app = await firebaseAppService.getAdminAppForAdminServiceAccount();
|
|
10
10
|
const appId = this.app ?? (await firebaseAppService.getAppId());
|
|
11
|
-
|
|
11
|
+
this._context.logger.info(`🛂 Generating AppCheck token for Firebase application '${appId}'.`);
|
|
12
12
|
const appCheck = getAppCheck(app);
|
|
13
13
|
const { token } = await appCheck.createToken(appId, {
|
|
14
14
|
ttlMillis: TOKEN_TTL * 1000,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkspaceFunction } from '@causa/workspace';
|
|
2
2
|
/**
|
|
3
3
|
* Generates a new AppCheck token.
|
|
4
4
|
*/
|
|
@@ -8,6 +8,6 @@ export declare class GoogleAppCheckGenerateToken extends WorkspaceFunction<Promi
|
|
|
8
8
|
* If `undefined`, a Firebase app ID will be found in the configuration or using the API.
|
|
9
9
|
*/
|
|
10
10
|
readonly app?: string;
|
|
11
|
-
_call(
|
|
11
|
+
_call(): Promise<string>;
|
|
12
12
|
_supports(): boolean;
|
|
13
13
|
}
|
|
@@ -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, 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 { IsString } from 'class-validator';
|
|
14
14
|
import { appCheckCommandDefinition } from '../../cli/index.js';
|
|
@@ -21,8 +21,8 @@ let GoogleAppCheckGenerateToken = class GoogleAppCheckGenerateToken extends Work
|
|
|
21
21
|
* If `undefined`, a Firebase app ID will be found in the configuration or using the API.
|
|
22
22
|
*/
|
|
23
23
|
app;
|
|
24
|
-
async _call(
|
|
25
|
-
return await callDeferred(this,
|
|
24
|
+
async _call() {
|
|
25
|
+
return await callDeferred(this, import.meta.url);
|
|
26
26
|
}
|
|
27
27
|
_supports() {
|
|
28
28
|
return true;
|
|
@@ -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
|
/**
|
|
@@ -27,7 +27,7 @@ type GoogleFirebaseStorageMergeRulesResult = {
|
|
|
27
27
|
*/
|
|
28
28
|
export declare class GoogleFirebaseStorageMergeRules extends WorkspaceFunction<Promise<GoogleFirebaseStorageMergeRulesResult>> implements InfrastructureProcessor {
|
|
29
29
|
readonly tearDown?: boolean;
|
|
30
|
-
_call(
|
|
30
|
+
_call(): Promise<GoogleFirebaseStorageMergeRulesResult>;
|
|
31
31
|
_supports(): boolean;
|
|
32
32
|
}
|
|
33
33
|
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 {
|
|
11
|
+
import { WorkspaceFunction } from '@causa/workspace';
|
|
12
12
|
import { AllowMissing } from '@causa/workspace/validation';
|
|
13
13
|
import { IsBoolean } from 'class-validator';
|
|
14
14
|
import { firebaseStorageCommandDefinition } from '../../cli/index.js';
|
|
@@ -29,11 +29,11 @@ const DEFAULT_FIREBASE_STORAGE_SECURITY_RULE_FILE = 'storage.rules';
|
|
|
29
29
|
*/
|
|
30
30
|
let GoogleFirebaseStorageMergeRules = class GoogleFirebaseStorageMergeRules extends WorkspaceFunction {
|
|
31
31
|
tearDown;
|
|
32
|
-
async _call(
|
|
32
|
+
async _call() {
|
|
33
33
|
if (this.tearDown) {
|
|
34
34
|
return { configuration: {}, securityRuleFile: null };
|
|
35
35
|
}
|
|
36
|
-
const googleConf =
|
|
36
|
+
const googleConf = this._context.asConfiguration();
|
|
37
37
|
let securityRuleFile = googleConf.get('google.firebaseStorage.securityRuleFile') ??
|
|
38
38
|
DEFAULT_FIREBASE_STORAGE_SECURITY_RULE_FILE;
|
|
39
39
|
const globs = googleConf.get('google.firebaseStorage.securityRuleFiles') ?? [];
|
|
@@ -44,7 +44,7 @@ service firebase.storage {
|
|
|
44
44
|
${rules}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`, securityRuleFile,
|
|
47
|
+
`, securityRuleFile, this._context);
|
|
48
48
|
return {
|
|
49
49
|
configuration: { google: { firebaseStorage: { securityRuleFile } } },
|
|
50
50
|
securityRuleFile,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModelSchemaExtractDatabase, type SchemaDatabase } from '@causa/workspace-core';
|
|
2
|
+
/**
|
|
3
|
+
* Implements {@link ModelSchemaExtractDatabase} for Google Firestore.
|
|
4
|
+
* The schema is selected when it carries a `googleFirestoreCollection` Causa extension with a `path` array. The table
|
|
5
|
+
* label is the slash-joined formatted path (e.g. `users/{userId}/orders/{orderId}`), optionally prefixed by the
|
|
6
|
+
* extension's `name`. Property references in the path become the primary keys.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ModelSchemaExtractDatabaseForGoogleFirestore extends ModelSchemaExtractDatabase {
|
|
9
|
+
_call(): SchemaDatabase;
|
|
10
|
+
_supports(): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ModelSchemaExtractDatabase, } from '@causa/workspace-core';
|
|
2
|
+
/**
|
|
3
|
+
* The name of the Causa extension marking an object schema as a Google Firestore collection.
|
|
4
|
+
*/
|
|
5
|
+
const GOOGLE_FIRESTORE_COLLECTION_EXTENSION = 'googleFirestoreCollection';
|
|
6
|
+
/**
|
|
7
|
+
* Implements {@link ModelSchemaExtractDatabase} for Google Firestore.
|
|
8
|
+
* The schema is selected when it carries a `googleFirestoreCollection` Causa extension with a `path` array. The table
|
|
9
|
+
* label is the slash-joined formatted path (e.g. `users/{userId}/orders/{orderId}`), optionally prefixed by the
|
|
10
|
+
* extension's `name`. Property references in the path become the primary keys.
|
|
11
|
+
*/
|
|
12
|
+
export class ModelSchemaExtractDatabaseForGoogleFirestore extends ModelSchemaExtractDatabase {
|
|
13
|
+
_call() {
|
|
14
|
+
const extension = this.schema.extensions[GOOGLE_FIRESTORE_COLLECTION_EXTENSION];
|
|
15
|
+
const primaryKeys = [];
|
|
16
|
+
const segments = extension.path.map((element) => {
|
|
17
|
+
if (typeof element === 'string') {
|
|
18
|
+
return element;
|
|
19
|
+
}
|
|
20
|
+
if (typeof element === 'object' &&
|
|
21
|
+
element !== null &&
|
|
22
|
+
'property' in element &&
|
|
23
|
+
typeof element.property === 'string') {
|
|
24
|
+
primaryKeys.push(element.property);
|
|
25
|
+
return `{${element.property}}`;
|
|
26
|
+
}
|
|
27
|
+
return '?';
|
|
28
|
+
});
|
|
29
|
+
if (typeof extension.name === 'string') {
|
|
30
|
+
segments.unshift(extension.name);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
engine: 'google.firestore',
|
|
34
|
+
table: segments.join('/'),
|
|
35
|
+
primaryKeys,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
_supports() {
|
|
39
|
+
const extension = this.schema.extensions[GOOGLE_FIRESTORE_COLLECTION_EXTENSION];
|
|
40
|
+
return (typeof extension === 'object' &&
|
|
41
|
+
extension !== null &&
|
|
42
|
+
Array.isArray(extension.path));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -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
|
/**
|
|
@@ -27,7 +27,7 @@ type GoogleFirestoreMergeRulesResult = {
|
|
|
27
27
|
*/
|
|
28
28
|
export declare class GoogleFirestoreMergeRules extends WorkspaceFunction<Promise<GoogleFirestoreMergeRulesResult>> implements InfrastructureProcessor {
|
|
29
29
|
readonly tearDown?: boolean;
|
|
30
|
-
_call(
|
|
30
|
+
_call(): Promise<GoogleFirestoreMergeRulesResult>;
|
|
31
31
|
_supports(): boolean;
|
|
32
32
|
}
|
|
33
33
|
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 {
|
|
11
|
+
import { WorkspaceFunction } from '@causa/workspace';
|
|
12
12
|
import { AllowMissing } from '@causa/workspace/validation';
|
|
13
13
|
import { IsBoolean } from 'class-validator';
|
|
14
14
|
import { firestoreCommandDefinition } from '../../cli/index.js';
|
|
@@ -29,11 +29,11 @@ const DEFAULT_FIRESTORE_SECURITY_RULE_FILE = 'firestore.rules';
|
|
|
29
29
|
*/
|
|
30
30
|
let GoogleFirestoreMergeRules = class GoogleFirestoreMergeRules extends WorkspaceFunction {
|
|
31
31
|
tearDown;
|
|
32
|
-
async _call(
|
|
32
|
+
async _call() {
|
|
33
33
|
if (this.tearDown) {
|
|
34
34
|
return { configuration: {}, securityRuleFile: null };
|
|
35
35
|
}
|
|
36
|
-
const googleConf =
|
|
36
|
+
const googleConf = this._context.asConfiguration();
|
|
37
37
|
let securityRuleFile = googleConf.get('google.firestore.securityRuleFile') ??
|
|
38
38
|
DEFAULT_FIRESTORE_SECURITY_RULE_FILE;
|
|
39
39
|
const globs = googleConf.get('google.firestore.securityRuleFiles') ?? [];
|
|
@@ -44,7 +44,7 @@ service cloud.firestore {
|
|
|
44
44
|
${rules}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`, securityRuleFile,
|
|
47
|
+
`, securityRuleFile, this._context);
|
|
48
48
|
return {
|
|
49
49
|
configuration: { google: { firestore: { securityRuleFile } } },
|
|
50
50
|
securityRuleFile,
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import type { DatabaseQueryRecordsForFirestore } from './query-records.js';
|
|
3
|
-
export default function call(this: DatabaseQueryRecordsForFirestore
|
|
2
|
+
export default function call(this: DatabaseQueryRecordsForFirestore): Promise<any[]>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { deleteApp, initializeApp } from 'firebase-admin/app';
|
|
2
2
|
import { DocumentReference, GeoPoint, getFirestore, Timestamp, } from 'firebase-admin/firestore';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
export default async function call(
|
|
4
|
+
export default async function call() {
|
|
5
5
|
if (!this.query) {
|
|
6
6
|
throw new Error(`The 'query' input is required for the 'google.firestore' engine.`);
|
|
7
7
|
}
|
|
8
|
-
const googleConf =
|
|
8
|
+
const googleConf = this._context.asConfiguration();
|
|
9
9
|
const projectId = googleConf.getOrThrow('google.project');
|
|
10
10
|
const database = this.database ?? '(default)';
|
|
11
|
-
|
|
11
|
+
this._context.logger.debug(`🗃️ Fetching Firestore document '${this.query}' from database '${database}' in project '${projectId}'.`);
|
|
12
12
|
const app = initializeApp({ projectId }, randomUUID());
|
|
13
13
|
try {
|
|
14
14
|
const firestore = getFirestore(app, database);
|
|
@@ -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.
|
|
@@ -13,6 +12,6 @@ export declare const FIRESTORE_ENGINE = "google.firestore";
|
|
|
13
12
|
* Returns an array containing a single document's data, or an empty array if the document does not exist.
|
|
14
13
|
*/
|
|
15
14
|
export declare class DatabaseQueryRecordsForFirestore extends DatabaseQueryRecords {
|
|
16
|
-
_call(
|
|
15
|
+
_call(): Promise<any[]>;
|
|
17
16
|
_supports(): boolean;
|
|
18
17
|
}
|
|
@@ -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.
|
|
@@ -13,8 +13,8 @@ export const FIRESTORE_ENGINE = 'google.firestore';
|
|
|
13
13
|
* Returns an array containing a single document's data, or an empty array if the document does not exist.
|
|
14
14
|
*/
|
|
15
15
|
export class DatabaseQueryRecordsForFirestore extends DatabaseQueryRecords {
|
|
16
|
-
async _call(
|
|
17
|
-
return await callDeferred(this,
|
|
16
|
+
async _call() {
|
|
17
|
+
return await callDeferred(this, import.meta.url);
|
|
18
18
|
}
|
|
19
19
|
_supports() {
|
|
20
20
|
return this.engine === FIRESTORE_ENGINE;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { WorkspaceContext } from '@causa/workspace';
|
|
2
1
|
import type { GoogleIdentityPlatformGenerateCustomToken } from './generate-custom-token.js';
|
|
3
|
-
export default function call(this: GoogleIdentityPlatformGenerateCustomToken
|
|
2
|
+
export default function call(this: GoogleIdentityPlatformGenerateCustomToken): Promise<string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAuth } from 'firebase-admin/auth';
|
|
2
2
|
import { FirebaseAppService } from '../../services/firebase-app.js';
|
|
3
|
-
export default async function call(
|
|
4
|
-
const adminApp = await
|
|
3
|
+
export default async function call() {
|
|
4
|
+
const adminApp = await this._context
|
|
5
5
|
.service(FirebaseAppService)
|
|
6
6
|
.getAdminAppForAdminServiceAccount();
|
|
7
7
|
return await getAuth(adminApp).createCustomToken(this.user, this.claims);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkspaceFunction } from '@causa/workspace';
|
|
2
2
|
/**
|
|
3
3
|
* Generates a custom token that can be used to sign in to Identity Platform as a given user.
|
|
4
4
|
* Optionally, custom claims can be set in the token.
|
|
@@ -15,6 +15,6 @@ export declare class GoogleIdentityPlatformGenerateCustomToken extends Workspace
|
|
|
15
15
|
* A dictionary of custom claims to add to the token.
|
|
16
16
|
*/
|
|
17
17
|
readonly claims?: Record<string, any>;
|
|
18
|
-
_call(
|
|
18
|
+
_call(): Promise<string>;
|
|
19
19
|
_supports(): boolean;
|
|
20
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
|
}
|