@causa/workspace-google 0.18.0-beta.1 → 0.18.0-beta.3

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.
Files changed (57) hide show
  1. package/dist/configurations/generated.d.ts +30 -0
  2. package/dist/configurations/generated.js +60 -0
  3. package/dist/configurations/schemas/google.yaml +43 -0
  4. package/dist/emulators/firebase-storage.d.ts +9 -1
  5. package/dist/emulators/firebase-storage.js +13 -1
  6. package/dist/emulators/firestore.d.ts +9 -1
  7. package/dist/emulators/firestore.js +13 -1
  8. package/dist/emulators/identity-platform.d.ts +9 -1
  9. package/dist/emulators/identity-platform.js +13 -1
  10. package/dist/emulators/pubsub.d.ts +9 -1
  11. package/dist/emulators/pubsub.js +13 -1
  12. package/dist/emulators/spanner.d.ts +18 -2
  13. package/dist/emulators/spanner.js +26 -2
  14. package/dist/functions/emulator/start-firebase-storage.js +4 -3
  15. package/dist/functions/emulator/start-firestore.js +5 -10
  16. package/dist/functions/emulator/start-identity-platform.js +4 -7
  17. package/dist/functions/emulator/start-pubsub.call.js +10 -9
  18. package/dist/functions/emulator/start-spanner.call.js +14 -13
  19. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.js +2 -1
  20. package/dist/functions/event-topic/broker-wait-for-processing-pubsub.call.d.ts +2 -0
  21. package/dist/functions/event-topic/broker-wait-for-processing-pubsub.call.js +119 -0
  22. package/dist/functions/event-topic/broker-wait-for-processing-pubsub.d.ts +16 -0
  23. package/dist/functions/event-topic/broker-wait-for-processing-pubsub.js +23 -0
  24. package/dist/functions/event-topic/index.d.ts +1 -0
  25. package/dist/functions/event-topic/index.js +1 -0
  26. package/dist/functions/google-firestore/generate-typescript-decorators.d.ts +13 -0
  27. package/dist/functions/google-firestore/generate-typescript-decorators.js +78 -0
  28. package/dist/functions/google-firestore/index.d.ts +1 -0
  29. package/dist/functions/google-firestore/index.js +1 -0
  30. package/dist/functions/google-spanner/generate-typescript-decorators.d.ts +14 -0
  31. package/dist/functions/google-spanner/generate-typescript-decorators.js +120 -0
  32. package/dist/functions/google-spanner/index.d.ts +1 -0
  33. package/dist/functions/google-spanner/index.js +1 -0
  34. package/dist/functions/index.js +4 -5
  35. package/dist/services/cloud-monitoring.d.ts +44 -0
  36. package/dist/services/cloud-monitoring.js +61 -0
  37. package/dist/services/index.d.ts +2 -1
  38. package/dist/services/index.js +2 -1
  39. package/dist/services/pubsub.d.ts +1 -0
  40. package/dist/services/pubsub.js +1 -0
  41. package/dist/services/pubsub.utils.d.ts +9 -0
  42. package/dist/services/pubsub.utils.js +11 -0
  43. package/package.json +8 -8
  44. package/dist/code-generation/google-firestore-renderer.d.ts +0 -12
  45. package/dist/code-generation/google-firestore-renderer.js +0 -89
  46. package/dist/code-generation/google-spanner-renderer.d.ts +0 -11
  47. package/dist/code-generation/google-spanner-renderer.js +0 -100
  48. package/dist/code-generation/index.d.ts +0 -2
  49. package/dist/code-generation/index.js +0 -2
  50. package/dist/code-generation/utils.d.ts +0 -12
  51. package/dist/code-generation/utils.js +0 -21
  52. package/dist/functions/typescript/get-decorator-renderer-google-firestore.d.ts +0 -8
  53. package/dist/functions/typescript/get-decorator-renderer-google-firestore.js +0 -14
  54. package/dist/functions/typescript/get-decorator-renderer-google-spanner.d.ts +0 -8
  55. package/dist/functions/typescript/get-decorator-renderer-google-spanner.js +0 -14
  56. package/dist/functions/typescript/index.d.ts +0 -2
  57. package/dist/functions/typescript/index.js +0 -2
@@ -0,0 +1,61 @@
1
+ import { WorkspaceContext } from '@causa/workspace';
2
+ import { MetricServiceClient } from '@google-cloud/monitoring';
3
+ /**
4
+ * A service exposing a thin wrapper around the Cloud Monitoring API.
5
+ */
6
+ export class CloudMonitoringService {
7
+ /**
8
+ * The underlying Cloud Monitoring client.
9
+ */
10
+ client;
11
+ /**
12
+ * The ID of the GCP project from which metrics are read.
13
+ */
14
+ projectId;
15
+ constructor(context) {
16
+ this.projectId = context
17
+ .asConfiguration()
18
+ .getOrThrow('google.project');
19
+ this.client = new MetricServiceClient();
20
+ }
21
+ /**
22
+ * Fetches the data points for a single time series over the given time interval.
23
+ * Returns the points sorted in ascending timestamp order. Each point's timestamp is the end of the corresponding
24
+ * interval, in milliseconds since epoch. An empty array is returned when no series matches the filter.
25
+ *
26
+ * @param filter The Cloud Monitoring metric filter expression (e.g. `metric.type = "..."`).
27
+ * @param start The inclusive lower bound of the interval to fetch.
28
+ * @param end The exclusive upper bound of the interval to fetch.
29
+ * @param options Optional aggregation options.
30
+ * @returns The list of points, ordered by ascending timestamp.
31
+ */
32
+ async listPoints(filter, start, end, options = {}) {
33
+ const aggregation = options.aligner && options.alignmentPeriod
34
+ ? {
35
+ alignmentPeriod: { seconds: options.alignmentPeriod },
36
+ perSeriesAligner: options.aligner,
37
+ }
38
+ : undefined;
39
+ const [series] = await this.client.listTimeSeries({
40
+ name: `projects/${this.projectId}`,
41
+ filter,
42
+ interval: {
43
+ startTime: { seconds: Math.floor(start.getTime() / 1000) },
44
+ endTime: { seconds: Math.floor(end.getTime() / 1000) },
45
+ },
46
+ aggregation,
47
+ });
48
+ return (series.at(0)?.points ?? [])
49
+ .map(({ interval, value: rawValue }) => {
50
+ const endSeconds = Number(interval?.endTime?.seconds ?? 0);
51
+ const endNanos = interval?.endTime?.nanos ?? 0;
52
+ const timestamp = endSeconds * 1000 + Math.floor(endNanos / 1e6);
53
+ const value = Number(rawValue?.int64Value ??
54
+ rawValue?.doubleValue ??
55
+ rawValue?.distributionValue?.count ??
56
+ 0);
57
+ return { timestamp, value };
58
+ })
59
+ .sort((a, b) => a.timestamp - b.timestamp);
60
+ }
61
+ }
@@ -1,4 +1,5 @@
1
1
  export { BigQueryService } from './bigquery.js';
2
+ export { CloudMonitoringService, type MetricPoint, } from './cloud-monitoring.js';
2
3
  export { CloudRunPubSubTriggerService } from './cloud-run-pubsub-trigger.js';
3
4
  export { CloudRunService } from './cloud-run.js';
4
5
  export * from './firebase-app.errors.js';
@@ -9,7 +10,7 @@ export { GcloudEmulatorService } from './gcloud-emulator.js';
9
10
  export { GoogleApisService } from './google-apis.js';
10
11
  export { IamService } from './iam.js';
11
12
  export { LoggingService } from './logging.js';
12
- export { PubSubService } from './pubsub.js';
13
+ export { PUBSUB_SUBSCRIPTION_ID_REGEX, PubSubService, shortSubscriptionId, } from './pubsub.js';
13
14
  export { ResourceManagerService } from './resource-manager.js';
14
15
  export { GoogleSecretManagerService } from './secret-manager.js';
15
16
  export * from './storage.errors.js';
@@ -1,4 +1,5 @@
1
1
  export { BigQueryService } from './bigquery.js';
2
+ export { CloudMonitoringService, } from './cloud-monitoring.js';
2
3
  export { CloudRunPubSubTriggerService } from './cloud-run-pubsub-trigger.js';
3
4
  export { CloudRunService } from './cloud-run.js';
4
5
  export * from './firebase-app.errors.js';
@@ -8,7 +9,7 @@ export { GcloudEmulatorService } from './gcloud-emulator.js';
8
9
  export { GoogleApisService } from './google-apis.js';
9
10
  export { IamService } from './iam.js';
10
11
  export { LoggingService } from './logging.js';
11
- export { PubSubService } from './pubsub.js';
12
+ export { PUBSUB_SUBSCRIPTION_ID_REGEX, PubSubService, shortSubscriptionId, } from './pubsub.js';
12
13
  export { ResourceManagerService } from './resource-manager.js';
13
14
  export { GoogleSecretManagerService } from './secret-manager.js';
14
15
  export * from './storage.errors.js';
@@ -1,6 +1,7 @@
1
1
  import { WorkspaceContext } from '@causa/workspace';
2
2
  import { PubSub } from '@google-cloud/pubsub';
3
3
  import { iam_v1 } from 'googleapis';
4
+ export { PUBSUB_SUBSCRIPTION_ID_REGEX, shortSubscriptionId, } from './pubsub.utils.js';
4
5
  /**
5
6
  * A service for managing Pub/Sub resources
6
7
  */
@@ -2,6 +2,7 @@ import { WorkspaceContext } from '@causa/workspace';
2
2
  import { PubSub } from '@google-cloud/pubsub';
3
3
  import { iam_v1 } from 'googleapis';
4
4
  import { ResourceManagerService } from './resource-manager.js';
5
+ export { PUBSUB_SUBSCRIPTION_ID_REGEX, shortSubscriptionId, } from './pubsub.utils.js';
5
6
  /**
6
7
  * A service for managing Pub/Sub resources
7
8
  */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The regular expression matching a Pub/Sub subscription resource ID
3
+ * (e.g. `projects/<projectId>/subscriptions/<name>`).
4
+ */
5
+ export declare const PUBSUB_SUBSCRIPTION_ID_REGEX: RegExp;
6
+ /**
7
+ * Returns the short subscription ID (the last path segment) for a full subscription resource name.
8
+ */
9
+ export declare function shortSubscriptionId(id: string): string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The regular expression matching a Pub/Sub subscription resource ID
3
+ * (e.g. `projects/<projectId>/subscriptions/<name>`).
4
+ */
5
+ export const PUBSUB_SUBSCRIPTION_ID_REGEX = /^projects\/[\w-]+\/subscriptions\/[\w-]+$/;
6
+ /**
7
+ * Returns the short subscription ID (the last path segment) for a full subscription resource name.
8
+ */
9
+ export function shortSubscriptionId(id) {
10
+ return id.split('/').at(-1) ?? id;
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causa/workspace-google",
3
- "version": "0.18.0-beta.1",
3
+ "version": "0.18.0-beta.3",
4
4
  "description": "The Causa workspace module providing many functionalities related to GCP and its services.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,12 +37,13 @@
37
37
  "dependencies": {
38
38
  "@causa/cli": ">= 0.8.0-beta.1 < 1.0.0",
39
39
  "@causa/workspace": ">= 0.25.0-beta.3 < 1.0.0",
40
- "@causa/workspace-core": ">= 0.35.0-beta.1 < 1.0.0",
41
- "@causa/workspace-typescript": ">= 0.23.0-beta.1 < 1.0.0",
40
+ "@causa/workspace-core": ">= 0.35.0-beta.6 < 1.0.0",
41
+ "@causa/workspace-typescript": ">= 0.23.0-beta.4 < 1.0.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
45
  "@google-cloud/logging": "^11.2.1",
46
+ "@google-cloud/monitoring": "^5.3.2",
46
47
  "@google-cloud/pubsub": "^5.3.0",
47
48
  "@google-cloud/resource-manager": "^6.2.2",
48
49
  "@google-cloud/run": "^3.2.1",
@@ -56,13 +57,12 @@
56
57
  "globby": "^16.2.0",
57
58
  "google-auth-library": "^10.6.2",
58
59
  "google-gax": "5.0.6",
59
- "googleapis": "^171.4.0",
60
+ "googleapis": "^172.0.0",
60
61
  "micromatch": "^4.0.8",
61
- "pino": "^10.3.1",
62
- "quicktype-core": "^23.2.6"
62
+ "pino": "^10.3.1"
63
63
  },
64
64
  "devDependencies": {
65
- "@swc/core": "^1.15.33",
65
+ "@swc/core": "^1.15.40",
66
66
  "@swc/jest": "^0.2.39",
67
67
  "@tsconfig/node22": "^22.0.5",
68
68
  "@types/jest": "^30.0.0",
@@ -76,7 +76,7 @@
76
76
  "jest-extended": "^7.0.0",
77
77
  "rimraf": "^6.1.3",
78
78
  "typescript": "^6.0.3",
79
- "typescript-eslint": "^8.59.3",
79
+ "typescript-eslint": "^8.60.0",
80
80
  "yaml": "^2.9.0"
81
81
  }
82
82
  }
@@ -1,12 +0,0 @@
1
- import { type ClassContext, type TypeScriptDecorator, TypeScriptWithDecoratorsRenderer } from '@causa/workspace-typescript/code-generation';
2
- /**
3
- * A {@link TypeScriptDecoratorsRenderer} that adds Google Firestore decorators from the Causa Google runtime.
4
- *
5
- * If an object schema is marked with the `googleFirestoreCollection` attribute, the `@FirestoreCollection` decorator
6
- * is added to the class. If the `hasSoftDelete` property is `true`, the `@SoftDeletedFirestoreCollection` decorator
7
- * is also added.
8
- */
9
- export declare class GoogleFirestoreRenderer extends TypeScriptWithDecoratorsRenderer {
10
- decoratorsForClass(context: ClassContext): TypeScriptDecorator[];
11
- decoratorsForProperty(): TypeScriptDecorator[];
12
- }
@@ -1,89 +0,0 @@
1
- import { TypeScriptWithDecoratorsRenderer, } from '@causa/workspace-typescript/code-generation';
2
- import { schemaMatchesGlobPatterns } from './utils.js';
3
- /**
4
- * The name of the Causa attribute that should be present for a class to be decorated with Google Firestore decorators.
5
- */
6
- const GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE = 'googleFirestoreCollection';
7
- /**
8
- * The name of the Causa module for the TypeScript Google runtime.
9
- */
10
- const CAUSA_GOOGLE_MODULE = '@causa/runtime-google';
11
- /**
12
- * A {@link TypeScriptDecoratorsRenderer} that adds Google Firestore decorators from the Causa Google runtime.
13
- *
14
- * If an object schema is marked with the `googleFirestoreCollection` attribute, the `@FirestoreCollection` decorator
15
- * is added to the class. If the `hasSoftDelete` property is `true`, the `@SoftDeletedFirestoreCollection` decorator
16
- * is also added.
17
- */
18
- export class GoogleFirestoreRenderer extends TypeScriptWithDecoratorsRenderer {
19
- decoratorsForClass(context) {
20
- const collectionAttribute = context.objectAttributes[GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE];
21
- const globs = this.targetLanguage.options.generatorOptions?.google?.firestore?.globs;
22
- if (!collectionAttribute ||
23
- !schemaMatchesGlobPatterns(this, context, globs)) {
24
- return [];
25
- }
26
- const debugName = context.classType.getCombinedName();
27
- if (typeof collectionAttribute !== 'object') {
28
- throw new Error(`Invalid '${GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE}' attribute on '${debugName}'. Expected an object.`);
29
- }
30
- const { name, path, hasSoftDelete } = collectionAttribute;
31
- if (typeof name !== 'string') {
32
- throw new Error(`Invalid '${GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE}' attribute on '${debugName}'. Expected an object with a 'name' string property.`);
33
- }
34
- if (!Array.isArray(path)) {
35
- throw new Error(`Invalid '${GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE}' attribute on '${debugName}'. Expected an object with a 'path' array property.`);
36
- }
37
- const requiredProperties = path.flatMap((e) => typeof e === 'object' &&
38
- e !== null &&
39
- 'property' in e &&
40
- typeof e.property === 'string'
41
- ? [e.property]
42
- : []);
43
- const propertyReferences = new Map();
44
- this.forEachClassProperty(context.classType, 'none', (name, jsonName) => {
45
- if (requiredProperties.includes(jsonName)) {
46
- propertyReferences.set(jsonName, name);
47
- }
48
- });
49
- for (const propertyName of requiredProperties) {
50
- if (!propertyReferences.has(propertyName)) {
51
- throw new Error(`Property '${propertyName}' referenced in 'path' not found in '${debugName}'.`);
52
- }
53
- }
54
- const elements = path.map((element) => {
55
- if (typeof element === 'string') {
56
- return JSON.stringify(element);
57
- }
58
- if (typeof element === 'object' &&
59
- element !== null &&
60
- 'property' in element) {
61
- const propertyName = element.property;
62
- const generatedName = propertyReferences.get(propertyName);
63
- if (!generatedName) {
64
- throw new Error(`Property '${propertyName}' not found in property references.`);
65
- }
66
- return ['doc.', generatedName];
67
- }
68
- throw new Error(`Invalid path element in '${GOOGLE_FIRESTORE_COLLECTION_ATTRIBUTE}' attribute on '${debugName}'.`);
69
- });
70
- const pathExpression = path.length === 1
71
- ? elements
72
- : ['[', ...elements.flatMap((e) => [e, ', ']), "].join('/')"];
73
- const decorators = [];
74
- this.addDecoratorToList(decorators, context, 'FirestoreCollection', CAUSA_GOOGLE_MODULE, [
75
- '@FirestoreCollection({ name: ',
76
- JSON.stringify(name),
77
- ', path: (doc) => ',
78
- ...pathExpression,
79
- '})',
80
- ]);
81
- if (hasSoftDelete === true) {
82
- this.addDecoratorToList(decorators, context, 'SoftDeletedFirestoreCollection', CAUSA_GOOGLE_MODULE, ['@SoftDeletedFirestoreCollection()']);
83
- }
84
- return decorators;
85
- }
86
- decoratorsForProperty() {
87
- return [];
88
- }
89
- }
@@ -1,11 +0,0 @@
1
- import { type ClassContext, type ClassPropertyContext, type TypeScriptDecorator, TypeScriptWithDecoratorsRenderer } from '@causa/workspace-typescript/code-generation';
2
- /**
3
- * A {@link TypeScriptDecoratorsRenderer} that adds Google Spanner decorators from the Causa Google runtime.
4
- *
5
- * If an object schema is marked with the `googleSpannerTable` attribute, the `@SpannerTable` decorator is added to the
6
- * class, and `@SpannerColumn` decorators are added to all its properties.
7
- */
8
- export declare class GoogleSpannerRenderer extends TypeScriptWithDecoratorsRenderer {
9
- decoratorsForClass(context: ClassContext): TypeScriptDecorator[];
10
- decoratorsForProperty(context: ClassPropertyContext): TypeScriptDecorator[];
11
- }
@@ -1,100 +0,0 @@
1
- import { TypeScriptWithDecoratorsRenderer, getSingleType, typeScriptSourceForObject, } from '@causa/workspace-typescript/code-generation';
2
- import { schemaMatchesGlobPatterns } from './utils.js';
3
- /**
4
- * The name of the Causa attribute that should be present for a class to be decorated with Google Spanner decorators.
5
- */
6
- const GOOGLE_SPANNER_TABLE_ATTRIBUTE = 'googleSpannerTable';
7
- /**
8
- * The name of the optional Causa attribute that can be present on an object property schema to specify options for the
9
- * `@SpannerColumn` decorator.
10
- */
11
- const GOOGLE_SPANNER_COLUMN_ATTRIBUTE = 'googleSpannerColumn';
12
- /**
13
- * The name of the Causa module for the TypeScript Google runtime.
14
- */
15
- const CAUSA_GOOGLE_MODULE = '@causa/runtime-google';
16
- /**
17
- * The list of options that can be passed to the `@SpannerColumn` decorator and that indicates that the JSONSchema
18
- * specifies the type of the column. In this case, the renderer should not infer any type information.
19
- */
20
- const TYPE_INFO_COLUMN_ATTRIBUTE_NAMES = [
21
- 'isBigInt',
22
- 'isInt',
23
- 'isPreciseDate',
24
- 'isJson',
25
- ];
26
- /**
27
- * A {@link TypeScriptDecoratorsRenderer} that adds Google Spanner decorators from the Causa Google runtime.
28
- *
29
- * If an object schema is marked with the `googleSpannerTable` attribute, the `@SpannerTable` decorator is added to the
30
- * class, and `@SpannerColumn` decorators are added to all its properties.
31
- */
32
- export class GoogleSpannerRenderer extends TypeScriptWithDecoratorsRenderer {
33
- decoratorsForClass(context) {
34
- const tableAttribute = context.objectAttributes[GOOGLE_SPANNER_TABLE_ATTRIBUTE];
35
- const globs = this.targetLanguage.options.generatorOptions?.google?.spanner?.globs;
36
- if (!tableAttribute || !schemaMatchesGlobPatterns(this, context, globs)) {
37
- return [];
38
- }
39
- if (typeof tableAttribute !== 'object' ||
40
- !('primaryKey' in tableAttribute) ||
41
- !Array.isArray(tableAttribute.primaryKey) ||
42
- tableAttribute.primaryKey.length === 0 ||
43
- tableAttribute.primaryKey.some((k) => typeof k !== 'string')) {
44
- throw new Error(`Invalid '${GOOGLE_SPANNER_TABLE_ATTRIBUTE}' attribute on '${context.classType.getCombinedName()}'. Expected an object with a 'primaryKey' array.`);
45
- }
46
- if ('name' in tableAttribute && typeof tableAttribute.name !== 'string') {
47
- throw new Error(`Invalid 'name' in '${GOOGLE_SPANNER_TABLE_ATTRIBUTE}' attribute on '${context.classType.getCombinedName()}'. Expected a string.`);
48
- }
49
- const optionsSource = typeScriptSourceForObject({
50
- primaryKey: tableAttribute.primaryKey,
51
- name: tableAttribute.name,
52
- });
53
- const decorators = [];
54
- this.addDecoratorToList(decorators, context, 'SpannerTable', CAUSA_GOOGLE_MODULE, ['@SpannerTable(', optionsSource, ')']);
55
- return decorators;
56
- }
57
- decoratorsForProperty(context) {
58
- const globs = this.targetLanguage.options.generatorOptions?.google?.spanner?.globs;
59
- if (!context.objectAttributes[GOOGLE_SPANNER_TABLE_ATTRIBUTE] ||
60
- !schemaMatchesGlobPatterns(this, context, globs)) {
61
- return [];
62
- }
63
- const attributes = context.propertyAttributes[GOOGLE_SPANNER_COLUMN_ATTRIBUTE] ?? {};
64
- const { generatorOptions } = this.targetLanguage.options;
65
- const softDeletionColumn = generatorOptions?.google?.spanner?.softDeletionColumn;
66
- const { name: overriddenName, tsOptions } = attributes;
67
- if (tsOptions && typeof tsOptions !== 'object') {
68
- throw new Error(`Invalid 'tsOptions' in '${GOOGLE_SPANNER_COLUMN_ATTRIBUTE}' attribute. Expected an object.`);
69
- }
70
- const columnAttributes = tsOptions ?? {};
71
- if (overriddenName) {
72
- if (typeof overriddenName !== 'string') {
73
- throw new Error(`Invalid 'name' in '${GOOGLE_SPANNER_COLUMN_ATTRIBUTE}' attribute. Expected a string.`);
74
- }
75
- columnAttributes.name = overriddenName;
76
- }
77
- const columnName = overriddenName ?? this.names.get(context.name);
78
- if (columnName === softDeletionColumn) {
79
- columnAttributes.softDelete = true;
80
- }
81
- const singleTypeInfo = getSingleType(context.property.type);
82
- const schemaOverridesTypeInfo = TYPE_INFO_COLUMN_ATTRIBUTE_NAMES.some((name) => name in columnAttributes);
83
- if (!schemaOverridesTypeInfo && singleTypeInfo) {
84
- switch (singleTypeInfo.type?.kind) {
85
- case 'class':
86
- case 'object':
87
- case 'map':
88
- columnAttributes.isJson = true;
89
- break;
90
- case 'integer':
91
- columnAttributes.isInt = true;
92
- break;
93
- }
94
- }
95
- const optionsSource = typeScriptSourceForObject(columnAttributes);
96
- const decorators = [];
97
- this.addDecoratorToList(decorators, context, 'SpannerColumn', CAUSA_GOOGLE_MODULE, ['@SpannerColumn(', optionsSource, ')']);
98
- return decorators;
99
- }
100
- }
@@ -1,2 +0,0 @@
1
- export { GoogleFirestoreRenderer } from './google-firestore-renderer.js';
2
- export { GoogleSpannerRenderer } from './google-spanner-renderer.js';
@@ -1,2 +0,0 @@
1
- export { GoogleFirestoreRenderer } from './google-firestore-renderer.js';
2
- export { GoogleSpannerRenderer } from './google-spanner-renderer.js';
@@ -1,12 +0,0 @@
1
- import type { ClassContext } from '@causa/workspace-typescript/code-generation';
2
- import { TypeScriptWithDecoratorsRenderer } from '@causa/workspace-typescript/code-generation';
3
- /**
4
- * Checks whether the schema matches the glob patterns specified in the renderer's options.
5
- * If this returns `false`, the decorators should not be generated for the schema.
6
- *
7
- * @param renderer The renderer instance.
8
- * @param context The {@link ClassContext} of the schema to check.
9
- * @param globs The glob patterns to match against, or undefined/null if not configured.
10
- * @returns `true` if the decorators should be generated for the schema.
11
- */
12
- export declare function schemaMatchesGlobPatterns(renderer: TypeScriptWithDecoratorsRenderer, context: ClassContext, globs: unknown): boolean;
@@ -1,21 +0,0 @@
1
- import { TypeScriptWithDecoratorsRenderer } from '@causa/workspace-typescript/code-generation';
2
- import micromatch from 'micromatch';
3
- import { join } from 'path';
4
- /**
5
- * Checks whether the schema matches the glob patterns specified in the renderer's options.
6
- * If this returns `false`, the decorators should not be generated for the schema.
7
- *
8
- * @param renderer The renderer instance.
9
- * @param context The {@link ClassContext} of the schema to check.
10
- * @param globs The glob patterns to match against, or undefined/null if not configured.
11
- * @returns `true` if the decorators should be generated for the schema.
12
- */
13
- export function schemaMatchesGlobPatterns(renderer, context, globs) {
14
- const { uri } = context;
15
- if (!uri || !globs || !Array.isArray(globs)) {
16
- return true;
17
- }
18
- const projectPath = renderer.targetLanguage.workspaceContext.getProjectPathOrThrow();
19
- const absoluteGlobs = globs.map((g) => join(projectPath, g));
20
- return micromatch.isMatch(uri, absoluteGlobs);
21
- }
@@ -1,8 +0,0 @@
1
- import { TypeScriptGetDecoratorRenderer, type TypeScriptWithDecoratorsRendererType } from '@causa/workspace-typescript';
2
- /**
3
- * Implements {@link TypeScriptGetDecoratorRenderer} for the `GoogleFirestoreRenderer`.
4
- */
5
- export declare class TypeScriptGetDecoratorRendererForGoogleFirestore extends TypeScriptGetDecoratorRenderer {
6
- _call(): Promise<TypeScriptWithDecoratorsRendererType>;
7
- _supports(): boolean;
8
- }
@@ -1,14 +0,0 @@
1
- import { TypeScriptGetDecoratorRenderer, } from '@causa/workspace-typescript';
2
- /**
3
- * Implements {@link TypeScriptGetDecoratorRenderer} for the `GoogleFirestoreRenderer`.
4
- */
5
- export class TypeScriptGetDecoratorRendererForGoogleFirestore extends TypeScriptGetDecoratorRenderer {
6
- async _call() {
7
- const { GoogleFirestoreRenderer } = await import('../../code-generation/index.js');
8
- return GoogleFirestoreRenderer;
9
- }
10
- _supports() {
11
- return (this._context.get('project.language') === 'typescript' &&
12
- this.generator === 'typescriptModelClass');
13
- }
14
- }
@@ -1,8 +0,0 @@
1
- import { TypeScriptGetDecoratorRenderer, type TypeScriptWithDecoratorsRendererType } from '@causa/workspace-typescript';
2
- /**
3
- * Implements {@link TypeScriptGetDecoratorRenderer} for the `GoogleSpannerRenderer`.
4
- */
5
- export declare class TypeScriptGetDecoratorRendererForGoogleSpanner extends TypeScriptGetDecoratorRenderer {
6
- _call(): Promise<TypeScriptWithDecoratorsRendererType>;
7
- _supports(): boolean;
8
- }
@@ -1,14 +0,0 @@
1
- import { TypeScriptGetDecoratorRenderer, } from '@causa/workspace-typescript';
2
- /**
3
- * Implements {@link TypeScriptGetDecoratorRenderer} for the `GoogleSpannerRenderer`.
4
- */
5
- export class TypeScriptGetDecoratorRendererForGoogleSpanner extends TypeScriptGetDecoratorRenderer {
6
- async _call() {
7
- const { GoogleSpannerRenderer } = await import('../../code-generation/index.js');
8
- return GoogleSpannerRenderer;
9
- }
10
- _supports() {
11
- return (this._context.get('project.language') === 'typescript' &&
12
- this.generator === 'typescriptModelClass');
13
- }
14
- }
@@ -1,2 +0,0 @@
1
- export { TypeScriptGetDecoratorRendererForGoogleFirestore } from './get-decorator-renderer-google-firestore.js';
2
- export { TypeScriptGetDecoratorRendererForGoogleSpanner } from './get-decorator-renderer-google-spanner.js';
@@ -1,2 +0,0 @@
1
- export { TypeScriptGetDecoratorRendererForGoogleFirestore } from './get-decorator-renderer-google-firestore.js';
2
- export { TypeScriptGetDecoratorRendererForGoogleSpanner } from './get-decorator-renderer-google-spanner.js';