@causa/workspace-google 1.4.0-beta.1 → 1.4.0-beta.2

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 (56) hide show
  1. package/README.md +14 -0
  2. package/dist/functions/google-app-check/generate-token.js +3 -1
  3. package/dist/functions/google-firebase-storage/merge-rules.js +3 -1
  4. package/dist/functions/google-firestore/merge-rules.js +3 -1
  5. package/dist/functions/google-identity-platform/generate-custom-token.js +7 -2
  6. package/dist/functions/google-pubsub/write-topics.js +7 -2
  7. package/dist/functions/google-services/enable.js +3 -1
  8. package/dist/functions/google-spanner/write-databases.js +7 -2
  9. package/dist/functions/graph/fetch-environment-metric-series.call.d.ts +3 -0
  10. package/dist/functions/graph/fetch-environment-metric-series.call.js +107 -0
  11. package/dist/functions/graph/fetch-environment-metric-series.d.ts +23 -0
  12. package/dist/functions/graph/fetch-environment-metric-series.js +40 -0
  13. package/dist/functions/graph/get-environment-provider.d.ts +11 -0
  14. package/dist/functions/graph/get-environment-provider.js +20 -0
  15. package/dist/functions/graph/index.d.ts +2 -0
  16. package/dist/functions/graph/index.js +2 -0
  17. package/dist/functions/index.js +2 -2
  18. package/dist/graph/cloud-run.d.ts +2 -2
  19. package/dist/graph/cloud-run.js +2 -2
  20. package/dist/graph/environment/fetchers/cloud-monitoring-alerts.d.ts +6 -0
  21. package/dist/graph/environment/fetchers/cloud-monitoring-alerts.js +106 -0
  22. package/dist/graph/environment/fetchers/cloud-monitoring.d.ts +5 -0
  23. package/dist/graph/environment/fetchers/cloud-monitoring.js +13 -0
  24. package/dist/graph/environment/fetchers/cloud-run.d.ts +5 -0
  25. package/dist/graph/environment/fetchers/cloud-run.js +88 -0
  26. package/dist/graph/environment/fetchers/cloud-scheduler.d.ts +5 -0
  27. package/dist/graph/environment/fetchers/cloud-scheduler.js +95 -0
  28. package/dist/graph/environment/fetchers/console-links.d.ts +14 -0
  29. package/dist/graph/environment/fetchers/console-links.js +132 -0
  30. package/dist/graph/environment/fetchers/error-reporting.d.ts +5 -0
  31. package/dist/graph/environment/fetchers/error-reporting.js +98 -0
  32. package/dist/graph/environment/fetchers/index.d.ts +5 -0
  33. package/dist/graph/environment/fetchers/index.js +17 -0
  34. package/dist/graph/environment/index.d.ts +9 -0
  35. package/dist/graph/environment/index.js +9 -0
  36. package/dist/graph/environment/load-balancer-backends.d.ts +82 -0
  37. package/dist/graph/environment/load-balancer-backends.js +126 -0
  38. package/dist/graph/environment/monitoring-alerts.d.ts +60 -0
  39. package/dist/graph/environment/monitoring-alerts.js +67 -0
  40. package/dist/graph/environment/monitoring-catalog.d.ts +95 -0
  41. package/dist/graph/environment/monitoring-catalog.js +356 -0
  42. package/dist/graph/environment/monitoring-mappings.d.ts +133 -0
  43. package/dist/graph/environment/monitoring-mappings.js +97 -0
  44. package/dist/graph/environment/monitoring-query.d.ts +116 -0
  45. package/dist/graph/environment/monitoring-query.js +314 -0
  46. package/dist/graph/environment/monitoring-values.d.ts +41 -0
  47. package/dist/graph/environment/monitoring-values.js +119 -0
  48. package/dist/graph/environment/resource-resolvers.d.ts +7 -0
  49. package/dist/graph/environment/resource-resolvers.js +57 -0
  50. package/dist/graph/environment/resources.d.ts +45 -0
  51. package/dist/graph/environment/resources.js +49 -0
  52. package/dist/graph/index.d.ts +1 -0
  53. package/dist/graph/index.js +1 -0
  54. package/dist/graph/spanner.d.ts +2 -2
  55. package/dist/graph/spanner.js +2 -2
  56. package/package.json +19 -19
@@ -0,0 +1,45 @@
1
+ import type { GraphEnvironmentContext, GraphNodeEntry } from '@causa/workspace-core/graph';
2
+ /**
3
+ * The segments of a Google Cloud resource name, keyed by collection.
4
+ * For example, `projects/my-project/locations/europe-west1/services/my-service` is
5
+ * `{ projects: 'my-project', locations: 'europe-west1', services: 'my-service' }`.
6
+ */
7
+ export type ResourceNameSegments = Record<string, string>;
8
+ /**
9
+ * Parses a Google Cloud resource name into its segments.
10
+ * The `global` segment, which is not followed by an ID (e.g. in `projects/my-project/global/urlMaps/api`), is skipped.
11
+ *
12
+ * @param name The resource name.
13
+ * @returns The segments, keyed by collection.
14
+ */
15
+ export declare function parseResourceName(name: string): ResourceNameSegments;
16
+ /**
17
+ * A node whose resource is a Google Cloud resource, along with its full name.
18
+ */
19
+ export type GoogleResource = {
20
+ /**
21
+ * The node.
22
+ */
23
+ readonly node: GraphNodeEntry;
24
+ /**
25
+ * The type of the resource, e.g. `run.googleapis.com/Service`.
26
+ */
27
+ readonly type: string;
28
+ /**
29
+ * The full resource name.
30
+ */
31
+ readonly name: string;
32
+ /**
33
+ * The segments of the resource name.
34
+ */
35
+ readonly segments: ResourceNameSegments;
36
+ };
37
+ /**
38
+ * Returns the Google Cloud resources of the graph, with the segments of their names.
39
+ *
40
+ * @param environment The context of the environment.
41
+ * @param resourceType The type of the resources. Defaults to all Google Cloud resource types.
42
+ * @param nodeType The type of the nodes. Defaults to all node types.
43
+ * @returns The resources, in the order of the graph.
44
+ */
45
+ export declare function googleResources(environment: GraphEnvironmentContext, resourceType?: string, nodeType?: string): GoogleResource[];
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Parses a Google Cloud resource name into its segments.
3
+ * The `global` segment, which is not followed by an ID (e.g. in `projects/my-project/global/urlMaps/api`), is skipped.
4
+ *
5
+ * @param name The resource name.
6
+ * @returns The segments, keyed by collection.
7
+ */
8
+ export function parseResourceName(name) {
9
+ const tokens = name.split('/');
10
+ const segments = {};
11
+ for (let index = 0; index < tokens.length;) {
12
+ const collection = tokens[index];
13
+ if (collection === 'global') {
14
+ index += 1;
15
+ continue;
16
+ }
17
+ segments[collection] = tokens[index + 1] ?? '';
18
+ index += 2;
19
+ }
20
+ return segments;
21
+ }
22
+ /**
23
+ * Returns whether a resource type is the type of a Google Cloud resource.
24
+ *
25
+ * @param type The type of the resource.
26
+ * @returns `true` for Google Cloud resource types, e.g. `run.googleapis.com/Service`.
27
+ */
28
+ function isGoogleResourceType(type) {
29
+ return type.includes('.googleapis.com/');
30
+ }
31
+ /**
32
+ * Returns the Google Cloud resources of the graph, with the segments of their names.
33
+ *
34
+ * @param environment The context of the environment.
35
+ * @param resourceType The type of the resources. Defaults to all Google Cloud resource types.
36
+ * @param nodeType The type of the nodes. Defaults to all node types.
37
+ * @returns The resources, in the order of the graph.
38
+ */
39
+ export function googleResources(environment, resourceType, nodeType) {
40
+ return environment
41
+ .resources(resourceType, nodeType)
42
+ .filter(({ resource }) => isGoogleResourceType(resource.type))
43
+ .map(({ node, resource: { type, id } }) => ({
44
+ node,
45
+ type,
46
+ name: id,
47
+ segments: parseResourceName(id),
48
+ }));
49
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './cloud-run.js';
2
+ export * from './environment/index.js';
2
3
  export * from './ids.js';
3
4
  export * from './rules/configuration/index.js';
4
5
  export * from './rules/terraform/index.js';
@@ -1,4 +1,5 @@
1
1
  export * from './cloud-run.js';
2
+ export * from './environment/index.js';
2
3
  export * from './ids.js';
3
4
  export * from './rules/configuration/index.js';
4
5
  export * from './rules/terraform/index.js';
@@ -1,5 +1,5 @@
1
1
  import type { GraphOriginSource } from '@causa/workspace-core';
2
- import { GraphFact, type EntityFacts, type GraphContext, type GraphFactOutput, type WorkspaceDomain } from '@causa/workspace-core/graph';
2
+ import { GraphExtractionFact, type EntityFacts, type GraphContext, type GraphFactOutput, type WorkspaceDomain } from '@causa/workspace-core/graph';
3
3
  /**
4
4
  * A table created by a `CREATE TABLE` statement in a Spanner DDL file.
5
5
  */
@@ -63,7 +63,7 @@ export type SpannerFacts = {
63
63
  * The Spanner databases of the workspace, as `GoogleSpannerListDatabases` lists them, and the tables their DDL files
64
64
  * create.
65
65
  */
66
- export declare class SpannerFact extends GraphFact<SpannerFacts> {
66
+ export declare class SpannerFact extends GraphExtractionFact<SpannerFacts> {
67
67
  compute(graph: GraphContext): Promise<GraphFactOutput<SpannerFacts>>;
68
68
  /**
69
69
  * Parses the tables created by the `CREATE TABLE` statements of DDL files.
@@ -1,4 +1,4 @@
1
- import { domainAt, domainOfFile, DomainsFact, GraphFact, } from '@causa/workspace-core/graph';
1
+ import { domainAt, domainOfFile, DomainsFact, GraphExtractionFact, } from '@causa/workspace-core/graph';
2
2
  import { readFile } from 'fs/promises';
3
3
  import { dirname, join, relative } from 'path';
4
4
  import { GoogleSpannerListDatabases } from '../functions/google-spanner/index.js';
@@ -7,7 +7,7 @@ import { SPANNER_ENGINE, spannerDatabaseLocator, spannerDatabaseName, } from './
7
7
  * The Spanner databases of the workspace, as `GoogleSpannerListDatabases` lists them, and the tables their DDL files
8
8
  * create.
9
9
  */
10
- export class SpannerFact extends GraphFact {
10
+ export class SpannerFact extends GraphExtractionFact {
11
11
  async compute(graph) {
12
12
  const { context } = graph;
13
13
  const instance = context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causa/workspace-google",
3
- "version": "1.4.0-beta.1",
3
+ "version": "1.4.0-beta.2",
4
4
  "description": "The Causa workspace module providing many functionalities related to GCP and its services.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,21 +35,21 @@
35
35
  "generateConfigurationSchemas": "cs model genCode && perl -pi -e 's|\\@causa/runtime|\\@causa/workspace/validation|g' src/configurations/generated.ts"
36
36
  },
37
37
  "dependencies": {
38
- "@causa/cli": "^1.0.0",
39
- "@causa/workspace": "^1.2.0",
40
- "@causa/workspace-core": "^1.5.0-beta.1",
41
- "@causa/workspace-terraform": "^1.1.0-beta.1",
42
- "@causa/workspace-typescript": "^1.3.0",
43
- "@google-cloud/apikeys": "^3.1.0",
38
+ "@causa/cli": "^1.0.1-beta.1",
39
+ "@causa/workspace": "^1.3.0-beta.1",
40
+ "@causa/workspace-core": "^1.5.0-beta.2",
41
+ "@causa/workspace-terraform": "^1.1.0-beta.2",
42
+ "@causa/workspace-typescript": "^1.4.0-beta.1",
43
+ "@google-cloud/apikeys": "^3.1.1",
44
44
  "@google-cloud/bigquery": "^9.1.0",
45
- "@google-cloud/iam-credentials": "^5.0.0",
45
+ "@google-cloud/iam-credentials": "^5.0.1",
46
46
  "@google-cloud/logging": "^12.1.0",
47
- "@google-cloud/monitoring": "^6.1.0",
47
+ "@google-cloud/monitoring": "^6.1.1",
48
48
  "@google-cloud/pubsub": "^6.1.0",
49
- "@google-cloud/resource-manager": "^7.1.0",
50
- "@google-cloud/run": "^4.1.0",
51
- "@google-cloud/secret-manager": "^7.1.0",
52
- "@google-cloud/service-usage": "^5.1.0",
49
+ "@google-cloud/resource-manager": "^7.1.1",
50
+ "@google-cloud/run": "^4.1.1",
51
+ "@google-cloud/secret-manager": "^7.1.1",
52
+ "@google-cloud/service-usage": "^5.1.1",
53
53
  "@google-cloud/spanner": "^9.0.0",
54
54
  "@google-cloud/storage": "^8.2.0",
55
55
  "class-transformer": "^0.5.1",
@@ -58,26 +58,26 @@
58
58
  "firebase-admin": "^14.5.0",
59
59
  "globby": "^16.2.4",
60
60
  "google-gax": "5.0.6",
61
- "googleapis": "^182.0.0",
61
+ "googleapis": "^183.0.0",
62
62
  "micromatch": "^4.0.8",
63
- "pino": "^10.3.1"
63
+ "pino": "^10.4.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@swc/core": "^1.16.2",
66
+ "@swc/core": "^1.16.13",
67
67
  "@swc/jest": "^0.2.39",
68
68
  "@tsconfig/node22": "^22.0.6",
69
69
  "@types/jest": "^30.0.0",
70
70
  "@types/micromatch": "^4.0.10",
71
- "@types/node": "^22.20.4",
71
+ "@types/node": "^22.20.5",
72
72
  "copyfiles": "^2.4.1",
73
- "eslint": "^10.11.0",
73
+ "eslint": "^10.12.0",
74
74
  "eslint-config-prettier": "^10.1.8",
75
75
  "eslint-plugin-prettier": "^5.5.6",
76
76
  "jest": "^30.5.2",
77
77
  "jest-extended": "^7.0.0",
78
78
  "rimraf": "^6.1.3",
79
79
  "typescript": "^6.0.3",
80
- "typescript-eslint": "^8.70.1",
80
+ "typescript-eslint": "^8.71.1",
81
81
  "yaml": "^2.9.1"
82
82
  }
83
83
  }