@causa/runtime-google 0.31.0 → 0.32.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.
@@ -0,0 +1,6 @@
1
+ import { v1 } from 'firebase-admin/firestore';
2
+ /**
3
+ * The low-level client to access administrative Firestore operations.
4
+ */
5
+ export declare const FirestoreAdminClient: typeof import("@google-cloud/firestore/types/v1/firestore_admin_client.js").FirestoreAdminClient;
6
+ export type FirestoreAdminClient = InstanceType<typeof v1.FirestoreAdminClient>;
@@ -0,0 +1,5 @@
1
+ import { v1 } from 'firebase-admin/firestore';
2
+ /**
3
+ * The low-level client to access administrative Firestore operations.
4
+ */
5
+ export const FirestoreAdminClient = v1.FirestoreAdminClient;
@@ -1,3 +1,4 @@
1
1
  export { getDefaultFirebaseApp } from './app.js';
2
+ export { FirestoreAdminClient } from './firestore-admin-client.type.js';
2
3
  export { FIREBASE_APP_TOKEN, InjectFirebaseApp, } from './inject-firebase-app.decorator.js';
3
4
  export { FirebaseModule } from './module.js';
@@ -1,3 +1,4 @@
1
1
  export { getDefaultFirebaseApp } from './app.js';
2
+ export { FirestoreAdminClient } from './firestore-admin-client.type.js';
2
3
  export { FIREBASE_APP_TOKEN, InjectFirebaseApp, } from './inject-firebase-app.decorator.js';
3
4
  export { FirebaseModule } from './module.js';
@@ -1,6 +1,7 @@
1
1
  import { OnApplicationShutdown } from '@nestjs/common';
2
2
  import { App } from 'firebase-admin/app';
3
3
  import { Firestore } from 'firebase-admin/firestore';
4
+ import { FirestoreAdminClient } from './firestore-admin-client.type.js';
4
5
  /**
5
6
  * A private service that handles the graceful shutdown of the Firebase App.
6
7
  * Should be imported in the `FirebaseModule`.
@@ -8,6 +9,7 @@ import { Firestore } from 'firebase-admin/firestore';
8
9
  export declare class FirebaseLifecycleService implements OnApplicationShutdown {
9
10
  private readonly app;
10
11
  private readonly firestore;
11
- constructor(app: App, firestore: Firestore);
12
+ private readonly firestoreAdmin;
13
+ constructor(app: App, firestore: Firestore, firestoreAdmin: FirestoreAdminClient);
12
14
  onApplicationShutdown(): Promise<void>;
13
15
  }
@@ -13,6 +13,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  import { Injectable } from '@nestjs/common';
14
14
  import { deleteApp } from 'firebase-admin/app';
15
15
  import { Firestore } from 'firebase-admin/firestore';
16
+ import { FirestoreAdminClient } from './firestore-admin-client.type.js';
16
17
  import { InjectFirebaseApp } from './inject-firebase-app.decorator.js';
17
18
  /**
18
19
  * A private service that handles the graceful shutdown of the Firebase App.
@@ -21,11 +22,14 @@ import { InjectFirebaseApp } from './inject-firebase-app.decorator.js';
21
22
  let FirebaseLifecycleService = class FirebaseLifecycleService {
22
23
  app;
23
24
  firestore;
24
- constructor(app, firestore) {
25
+ firestoreAdmin;
26
+ constructor(app, firestore, firestoreAdmin) {
25
27
  this.app = app;
26
28
  this.firestore = firestore;
29
+ this.firestoreAdmin = firestoreAdmin;
27
30
  }
28
31
  async onApplicationShutdown() {
32
+ await this.firestoreAdmin.close();
29
33
  await this.firestore.terminate();
30
34
  await deleteApp(this.app);
31
35
  }
@@ -33,6 +37,7 @@ let FirebaseLifecycleService = class FirebaseLifecycleService {
33
37
  FirebaseLifecycleService = __decorate([
34
38
  Injectable(),
35
39
  __param(0, InjectFirebaseApp()),
36
- __metadata("design:paramtypes", [Object, Firestore])
40
+ __metadata("design:paramtypes", [Object, Firestore,
41
+ FirestoreAdminClient])
37
42
  ], FirebaseLifecycleService);
38
43
  export { FirebaseLifecycleService };
@@ -12,6 +12,7 @@ import { Auth, getAuth } from 'firebase-admin/auth';
12
12
  import { Firestore, getFirestore } from 'firebase-admin/firestore';
13
13
  import { Messaging, getMessaging } from 'firebase-admin/messaging';
14
14
  import { getDefaultFirebaseApp } from './app.js';
15
+ import { FirestoreAdminClient } from './firestore-admin-client.type.js';
15
16
  import { FIREBASE_APP_TOKEN } from './inject-firebase-app.decorator.js';
16
17
  import { FirebaseLifecycleService } from './lifecycle.service.js';
17
18
  /**
@@ -31,6 +32,10 @@ const childProviders = [
31
32
  useFactory: getMessaging,
32
33
  inject: [FIREBASE_APP_TOKEN],
33
34
  },
35
+ {
36
+ provide: FirestoreAdminClient,
37
+ useFactory: () => new FirestoreAdminClient(),
38
+ },
34
39
  ];
35
40
  /**
36
41
  * Creates the module metadata for the {@link FirebaseModule}.
@@ -1,11 +1,16 @@
1
1
  import { BaseHealthIndicatorService } from '@causa/runtime/nestjs';
2
2
  import { HealthIndicatorResult } from '@nestjs/terminus';
3
3
  import { Firestore } from 'firebase-admin/firestore';
4
+ import { FirestoreAdminClient } from '../firebase/index.js';
4
5
  /**
5
6
  * A service testing the availability of the Firestore service.
6
7
  */
7
8
  export declare class FirestoreHealthIndicator extends BaseHealthIndicatorService {
8
- private readonly firestore;
9
- constructor(firestore: Firestore);
9
+ private readonly admin;
10
+ /**
11
+ * The ID of the database used by Firestore.
12
+ */
13
+ private readonly databaseId;
14
+ constructor(admin: FirestoreAdminClient, firestore: Firestore);
10
15
  check(): Promise<HealthIndicatorResult>;
11
16
  }
@@ -11,6 +11,7 @@ import { BaseHealthIndicatorService } from '@causa/runtime/nestjs';
11
11
  import { Injectable } from '@nestjs/common';
12
12
  import { HealthCheckError } from '@nestjs/terminus';
13
13
  import { Firestore } from 'firebase-admin/firestore';
14
+ import { FirestoreAdminClient } from '../firebase/index.js';
14
15
  /**
15
16
  * The key used to identify the Firestore health indicator.
16
17
  */
@@ -19,18 +20,25 @@ const FIRESTORE_HEALTH_KEY = 'google.firestore';
19
20
  * A service testing the availability of the Firestore service.
20
21
  */
21
22
  let FirestoreHealthIndicator = class FirestoreHealthIndicator extends BaseHealthIndicatorService {
22
- firestore;
23
- constructor(firestore) {
23
+ admin;
24
+ /**
25
+ * The ID of the database used by Firestore.
26
+ */
27
+ databaseId;
28
+ constructor(admin, firestore) {
24
29
  super();
25
- this.firestore = firestore;
30
+ this.admin = admin;
31
+ this.databaseId = firestore.databaseId;
26
32
  }
27
33
  async check() {
28
34
  try {
29
- await this.firestore.listCollections();
35
+ const projectId = await this.admin.getProjectId();
36
+ const name = this.admin.databasePath(projectId, this.databaseId);
37
+ await this.admin.getDatabase({ name });
30
38
  return this.getStatus(FIRESTORE_HEALTH_KEY, true);
31
39
  }
32
40
  catch (error) {
33
- throw new HealthCheckError('Failed to check health by listing Firestore collections.', this.getStatus(FIRESTORE_HEALTH_KEY, false, {
41
+ throw new HealthCheckError('Failed to check health by getting Firestore database.', this.getStatus(FIRESTORE_HEALTH_KEY, false, {
34
42
  error: error.message,
35
43
  }));
36
44
  }
@@ -38,6 +46,7 @@ let FirestoreHealthIndicator = class FirestoreHealthIndicator extends BaseHealth
38
46
  };
39
47
  FirestoreHealthIndicator = __decorate([
40
48
  Injectable(),
41
- __metadata("design:paramtypes", [Firestore])
49
+ __metadata("design:paramtypes", [FirestoreAdminClient,
50
+ Firestore])
42
51
  ], FirestoreHealthIndicator);
43
52
  export { FirestoreHealthIndicator };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causa/runtime-google",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "An extension to the Causa runtime SDK (`@causa/runtime`), providing Google-specific features.",
5
5
  "repository": "github:causa-io/runtime-typescript-google",
6
6
  "license": "ISC",
@@ -31,15 +31,15 @@
31
31
  "dependencies": {
32
32
  "@causa/runtime": ">= 0.22.0 < 1.0.0",
33
33
  "@google-cloud/precise-date": "^4.0.0",
34
- "@google-cloud/pubsub": "^4.7.1",
34
+ "@google-cloud/pubsub": "^4.7.2",
35
35
  "@google-cloud/spanner": "^7.14.0",
36
36
  "@google-cloud/tasks": "^5.5.0",
37
- "@grpc/grpc-js": "^1.11.2",
38
- "@nestjs/common": "^10.4.1",
37
+ "@grpc/grpc-js": "^1.11.3",
38
+ "@nestjs/common": "^10.4.3",
39
39
  "@nestjs/config": "^3.2.3",
40
- "@nestjs/core": "^10.4.1",
40
+ "@nestjs/core": "^10.4.3",
41
41
  "@nestjs/passport": "^10.0.3",
42
- "@nestjs/swagger": "^7.4.0",
42
+ "@nestjs/swagger": "^7.4.2",
43
43
  "@nestjs/terminus": "^10.2.3",
44
44
  "class-transformer": "^0.5.1",
45
45
  "class-validator": "^0.14.1",
@@ -52,10 +52,10 @@
52
52
  "reflect-metadata": "^0.2.2"
53
53
  },
54
54
  "devDependencies": {
55
- "@nestjs/testing": "^10.4.1",
55
+ "@nestjs/testing": "^10.4.3",
56
56
  "@tsconfig/node18": "^18.2.4",
57
57
  "@types/jest": "^29.5.13",
58
- "@types/jsonwebtoken": "^9.0.6",
58
+ "@types/jsonwebtoken": "^9.0.7",
59
59
  "@types/node": "^18.19.50",
60
60
  "@types/passport-http-bearer": "^1.0.41",
61
61
  "@types/supertest": "^6.0.2",
@@ -71,7 +71,7 @@
71
71
  "ts-jest": "^29.2.5",
72
72
  "ts-node": "^10.9.2",
73
73
  "typescript": "^5.5.4",
74
- "typescript-eslint": "^8.5.0",
74
+ "typescript-eslint": "^8.6.0",
75
75
  "uuid": "^10.0.0"
76
76
  }
77
77
  }