@causa/workspace-google 1.1.0 → 1.3.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.
@@ -25,7 +25,7 @@ export default async function call() {
25
25
  conditions.push(`(${this.filter})`);
26
26
  }
27
27
  const query = `
28
- SELECT publish_time, data, attributes
28
+ SELECT message_id, publish_time, data, attributes
29
29
  FROM \`${tableId}\`
30
30
  WHERE ${conditions.join(' AND ')}
31
31
  ORDER BY publish_time ASC
@@ -34,6 +34,7 @@ export default async function call() {
34
34
  const bigQuery = this._context.service(BigQueryService).bigQuery;
35
35
  const [rows] = await bigQuery.query({ query, params });
36
36
  return rows.map((row) => ({
37
+ id: row.message_id,
37
38
  timestamp: new Date(row.publish_time.value),
38
39
  attributes: row.attributes ? JSON.parse(row.attributes) : {},
39
40
  data: JSON.parse(row.data.toString('utf8')),
@@ -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
  }
@@ -30,6 +30,7 @@ export default async function call() {
30
30
  maxResults: limit,
31
31
  });
32
32
  return pageEntries.map((entry) => ({
33
+ id: entry.metadata.insertId ?? undefined,
33
34
  timestamp: entry.metadata.timestamp,
34
35
  message: entry.toStructuredJSON(),
35
36
  }));
@@ -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.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "The Causa workspace module providing many functionalities related to GCP and its services.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,46 +36,47 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@causa/cli": "^1.0.0",
39
- "@causa/workspace": "^1.0.1",
40
- "@causa/workspace-core": "^1.0.1",
41
- "@causa/workspace-typescript": "^1.0.1",
39
+ "@causa/workspace": "^1.0.2",
40
+ "@causa/workspace-core": "^1.3.0",
41
+ "@causa/workspace-typescript": "^1.3.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",
45
- "@google-cloud/logging": "^11.2.2",
46
- "@google-cloud/monitoring": "^5.3.3",
45
+ "@google-cloud/logging": "^11.3.0",
46
+ "@google-cloud/monitoring": "^5.4.0",
47
47
  "@google-cloud/pubsub": "^5.3.1",
48
- "@google-cloud/resource-manager": "^6.2.2",
49
- "@google-cloud/run": "^3.2.1",
50
- "@google-cloud/secret-manager": "^6.1.3",
48
+ "@google-cloud/resource-manager": "^6.3.0",
49
+ "@google-cloud/run": "^3.3.0",
50
+ "@google-cloud/secret-manager": "^6.2.0",
51
51
  "@google-cloud/service-usage": "^4.2.2",
52
- "@google-cloud/spanner": "^8.7.1",
52
+ "@google-cloud/spanner": "^8.9.0",
53
53
  "@google-cloud/storage": "^7.21.0",
54
+ "class-transformer": "^0.5.1",
54
55
  "class-validator": "^0.15.1",
55
- "firebase": "^12.14.0",
56
- "firebase-admin": "^14.0.0",
57
- "globby": "^16.2.0",
56
+ "firebase": "^12.16.0",
57
+ "firebase-admin": "^14.2.0",
58
+ "globby": "^16.2.2",
58
59
  "google-gax": "5.0.6",
59
60
  "googleapis": "^173.0.0",
60
61
  "micromatch": "^4.0.8",
61
62
  "pino": "^10.3.1"
62
63
  },
63
64
  "devDependencies": {
64
- "@swc/core": "^1.15.41",
65
+ "@swc/core": "^1.15.46",
65
66
  "@swc/jest": "^0.2.39",
66
67
  "@tsconfig/node22": "^22.0.5",
67
68
  "@types/jest": "^30.0.0",
68
69
  "@types/micromatch": "^4.0.10",
69
- "@types/node": "^20.19.42",
70
+ "@types/node": "^22.20.1",
70
71
  "copyfiles": "^2.4.1",
71
- "eslint": "^10.4.1",
72
+ "eslint": "^10.7.0",
72
73
  "eslint-config-prettier": "^10.1.8",
73
74
  "eslint-plugin-prettier": "^5.5.6",
74
75
  "jest": "^30.4.2",
75
76
  "jest-extended": "^7.0.0",
76
77
  "rimraf": "^6.1.3",
77
78
  "typescript": "^6.0.3",
78
- "typescript-eslint": "^8.61.0",
79
+ "typescript-eslint": "^8.65.0",
79
80
  "yaml": "^2.9.0"
80
81
  }
81
82
  }