@causa/workspace-google 1.1.0 → 1.2.0
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/functions/index.js +2 -1
- package/dist/functions/typescript/generate-typescript-trigger-decorators.d.ts +12 -0
- package/dist/functions/typescript/generate-typescript-trigger-decorators.js +71 -0
- package/dist/functions/typescript/index.d.ts +1 -0
- package/dist/functions/typescript/index.js +1 -0
- package/package.json +4 -4
package/dist/functions/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { DatabaseQueryRecordsForSpanner, GoogleSpannerListDatabases, GoogleSpann
|
|
|
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
|
+
import { ModelGenerateTypeScriptTriggerDecoratorsForGoogle } from './typescript/index.js';
|
|
14
15
|
export function registerFunctions(context) {
|
|
15
|
-
context.registerFunctionImplementations(CausaListConfigurationSchemasForGoogle, DatabaseQueryRecordsForFirestore, DatabaseQueryRecordsForSpanner, EmulatorStartForFirebaseStorage, EmulatorStartForFirestore, EmulatorStartForIdentityPlatform, EmulatorStartForPubSub, EmulatorStartForSpanner, EmulatorStopForFirebaseStorage, EmulatorStopForFirestore, EmulatorStopForIdentityPlatform, EmulatorStopForPubSub, EmulatorStopForSpanner, EventTopicBrokerCreateTopicForPubSub, EventTopicBrokerCreateTriggerForCloudRun, EventTopicBrokerDeleteTopicForPubSub, EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole, EventTopicBrokerDeleteTriggerResourceForCloudRunService, EventTopicBrokerDeleteTriggerResourceForPubSubSubscription, EventTopicBrokerDeleteTriggerResourceForServiceAccount, EventTopicBrokerGetTopicIdForPubSub, EventTopicBrokerPublishEventsForGoogle, EventTopicBrokerWaitForProcessingForPubSub, EventTopicCreateBackfillSourceForBigQuery, EventTopicQueryEventsForBigQuery, GoogleAppCheckGenerateToken, GoogleFirebaseStorageMergeRules, GoogleFirestoreMergeRules, GoogleIdentityPlatformGenerateCustomToken, GoogleIdentityPlatformGenerateToken, GooglePubSubWriteTopics, GoogleServicesEnable, GoogleSpannerListDatabases, GoogleSpannerWriteDatabases, ModelGenerateTypeScriptDecoratorsForGoogleFirestore, ModelGenerateTypeScriptDecoratorsForGoogleSpanner, ModelSchemaExtractDatabaseForGoogleFirestore, ModelSchemaExtractDatabaseForGoogleSpanner, ProjectGetArtefactDestinationForCloudFunctions, ProjectGetArtefactDestinationForCloudRun, ProjectPushArtefactForCloudFunctions, SecretFetchForGoogleAccessToken, SecretFetchForGoogleSecretManager, ServiceContainerQueryLogsForCloudRun);
|
|
16
|
+
context.registerFunctionImplementations(CausaListConfigurationSchemasForGoogle, DatabaseQueryRecordsForFirestore, DatabaseQueryRecordsForSpanner, EmulatorStartForFirebaseStorage, EmulatorStartForFirestore, EmulatorStartForIdentityPlatform, EmulatorStartForPubSub, EmulatorStartForSpanner, EmulatorStopForFirebaseStorage, EmulatorStopForFirestore, EmulatorStopForIdentityPlatform, EmulatorStopForPubSub, EmulatorStopForSpanner, EventTopicBrokerCreateTopicForPubSub, EventTopicBrokerCreateTriggerForCloudRun, EventTopicBrokerDeleteTopicForPubSub, EventTopicBrokerDeleteTriggerResourceForCloudRunInvokerRole, EventTopicBrokerDeleteTriggerResourceForCloudRunService, EventTopicBrokerDeleteTriggerResourceForPubSubSubscription, EventTopicBrokerDeleteTriggerResourceForServiceAccount, EventTopicBrokerGetTopicIdForPubSub, EventTopicBrokerPublishEventsForGoogle, EventTopicBrokerWaitForProcessingForPubSub, EventTopicCreateBackfillSourceForBigQuery, EventTopicQueryEventsForBigQuery, GoogleAppCheckGenerateToken, GoogleFirebaseStorageMergeRules, GoogleFirestoreMergeRules, GoogleIdentityPlatformGenerateCustomToken, GoogleIdentityPlatformGenerateToken, GooglePubSubWriteTopics, GoogleServicesEnable, GoogleSpannerListDatabases, GoogleSpannerWriteDatabases, ModelGenerateTypeScriptDecoratorsForGoogleFirestore, ModelGenerateTypeScriptDecoratorsForGoogleSpanner, ModelGenerateTypeScriptTriggerDecoratorsForGoogle, ModelSchemaExtractDatabaseForGoogleFirestore, ModelSchemaExtractDatabaseForGoogleSpanner, ProjectGetArtefactDestinationForCloudFunctions, ProjectGetArtefactDestinationForCloudRun, ProjectPushArtefactForCloudFunctions, SecretFetchForGoogleAccessToken, SecretFetchForGoogleSecretManager, ServiceContainerQueryLogsForCloudRun);
|
|
16
17
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModelGenerateTypeScriptTriggerDecorators } from '@causa/workspace-typescript';
|
|
2
|
+
import { type TypeScriptDecorator } from '@causa/workspace-typescript/code-generation';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link ModelGenerateTypeScriptTriggerDecorators} for services running on the Google platform.
|
|
5
|
+
*
|
|
6
|
+
* Each supported trigger type is mapped to a `@UseEventHandler(...)` decorator with the handler ID of the Google
|
|
7
|
+
* service backing the trigger (Pub/Sub, Cloud Tasks, Cloud Scheduler, or Eventarc).
|
|
8
|
+
*/
|
|
9
|
+
export declare class ModelGenerateTypeScriptTriggerDecoratorsForGoogle extends ModelGenerateTypeScriptTriggerDecorators {
|
|
10
|
+
_call(): TypeScriptDecorator[];
|
|
11
|
+
_supports(): boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ModelGenerateTypeScriptTriggerDecorators } from '@causa/workspace-typescript';
|
|
2
|
+
import { externalImportSpec, externalSymbolAlias, } from '@causa/workspace-typescript/code-generation';
|
|
3
|
+
/**
|
|
4
|
+
* The name of the Causa module for the TypeScript runtime, from which `UseEventHandler` is imported.
|
|
5
|
+
*/
|
|
6
|
+
const CAUSA_RUNTIME_NESTJS_MODULE = '@causa/runtime/nestjs';
|
|
7
|
+
/**
|
|
8
|
+
* The name of the Causa module for the TypeScript Google runtime.
|
|
9
|
+
*/
|
|
10
|
+
const CAUSA_GOOGLE_MODULE = '@causa/runtime-google';
|
|
11
|
+
/**
|
|
12
|
+
* The handler ID symbol to pass to `UseEventHandler` for each supported trigger type, along with the module from
|
|
13
|
+
* which it should be imported.
|
|
14
|
+
*/
|
|
15
|
+
const HANDLER_IDS_FOR_TRIGGER_TYPES = {
|
|
16
|
+
event: { module: CAUSA_GOOGLE_MODULE, symbol: 'PUBSUB_EVENT_HANDLER_ID' },
|
|
17
|
+
'google.pubSub': {
|
|
18
|
+
module: CAUSA_GOOGLE_MODULE,
|
|
19
|
+
symbol: 'PUBSUB_EVENT_HANDLER_ID',
|
|
20
|
+
},
|
|
21
|
+
task: {
|
|
22
|
+
module: CAUSA_GOOGLE_MODULE,
|
|
23
|
+
symbol: 'CLOUD_TASKS_EVENT_HANDLER_ID',
|
|
24
|
+
},
|
|
25
|
+
'google.tasks': {
|
|
26
|
+
module: CAUSA_GOOGLE_MODULE,
|
|
27
|
+
symbol: 'CLOUD_TASKS_EVENT_HANDLER_ID',
|
|
28
|
+
},
|
|
29
|
+
cron: {
|
|
30
|
+
module: CAUSA_GOOGLE_MODULE,
|
|
31
|
+
symbol: 'CLOUD_SCHEDULER_EVENT_HANDLER_ID',
|
|
32
|
+
},
|
|
33
|
+
'google.scheduler': {
|
|
34
|
+
module: CAUSA_GOOGLE_MODULE,
|
|
35
|
+
symbol: 'CLOUD_SCHEDULER_EVENT_HANDLER_ID',
|
|
36
|
+
},
|
|
37
|
+
'google.eventarc': {
|
|
38
|
+
module: CAUSA_RUNTIME_NESTJS_MODULE,
|
|
39
|
+
symbol: 'CLOUDEVENTS_EVENT_HANDLER_ID',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Implements {@link ModelGenerateTypeScriptTriggerDecorators} for services running on the Google platform.
|
|
44
|
+
*
|
|
45
|
+
* Each supported trigger type is mapped to a `@UseEventHandler(...)` decorator with the handler ID of the Google
|
|
46
|
+
* service backing the trigger (Pub/Sub, Cloud Tasks, Cloud Scheduler, or Eventarc).
|
|
47
|
+
*/
|
|
48
|
+
export class ModelGenerateTypeScriptTriggerDecoratorsForGoogle extends ModelGenerateTypeScriptTriggerDecorators {
|
|
49
|
+
_call() {
|
|
50
|
+
const handlerId = HANDLER_IDS_FOR_TRIGGER_TYPES[this.trigger.type];
|
|
51
|
+
if (!handlerId) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const useEventHandlerAlias = externalSymbolAlias(CAUSA_RUNTIME_NESTJS_MODULE, 'UseEventHandler');
|
|
55
|
+
const handlerIdAlias = externalSymbolAlias(handlerId.module, handlerId.symbol);
|
|
56
|
+
const imports = {
|
|
57
|
+
[CAUSA_RUNTIME_NESTJS_MODULE]: [
|
|
58
|
+
externalImportSpec(CAUSA_RUNTIME_NESTJS_MODULE, 'UseEventHandler'),
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
(imports[handlerId.module] ??= []).push(externalImportSpec(handlerId.module, handlerId.symbol));
|
|
62
|
+
return [{ source: `@${useEventHandlerAlias}(${handlerIdAlias})`, imports }];
|
|
63
|
+
}
|
|
64
|
+
_supports() {
|
|
65
|
+
return (this.generator === 'typescriptNestjsController' &&
|
|
66
|
+
this._context.get('project.language') === 'typescript' &&
|
|
67
|
+
this._context
|
|
68
|
+
.asConfiguration()
|
|
69
|
+
.get('serviceContainer.platform') === 'google.cloudRun');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ModelGenerateTypeScriptTriggerDecoratorsForGoogle } from './generate-typescript-trigger-decorators.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ModelGenerateTypeScriptTriggerDecoratorsForGoogle } from './generate-typescript-trigger-decorators.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@causa/workspace-google",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "The Causa workspace module providing many functionalities related to GCP and its services.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@causa/cli": "^1.0.0",
|
|
39
39
|
"@causa/workspace": "^1.0.1",
|
|
40
|
-
"@causa/workspace-core": "^1.0
|
|
41
|
-
"@causa/workspace-typescript": "^1.0
|
|
40
|
+
"@causa/workspace-core": "^1.1.0",
|
|
41
|
+
"@causa/workspace-typescript": "^1.1.0",
|
|
42
42
|
"@google-cloud/apikeys": "^2.2.2",
|
|
43
43
|
"@google-cloud/bigquery": "^8.3.1",
|
|
44
44
|
"@google-cloud/iam-credentials": "^4.2.2",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@tsconfig/node22": "^22.0.5",
|
|
67
67
|
"@types/jest": "^30.0.0",
|
|
68
68
|
"@types/micromatch": "^4.0.10",
|
|
69
|
-
"@types/node": "^20.19.
|
|
69
|
+
"@types/node": "^20.19.43",
|
|
70
70
|
"copyfiles": "^2.4.1",
|
|
71
71
|
"eslint": "^10.4.1",
|
|
72
72
|
"eslint-config-prettier": "^10.1.8",
|