@travetto/model-firestore 8.0.0-alpha.0 → 8.0.0-alpha.1
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/README.md +3 -2
- package/package.json +5 -5
- package/src/config.ts +3 -1
- package/src/service.ts +3 -2
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ export class Init {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
where the [FirestoreModelConfig](https://github.com/travetto/travetto/tree/main/module/model-firestore/src/config.ts#
|
|
39
|
+
where the [FirestoreModelConfig](https://github.com/travetto/travetto/tree/main/module/model-firestore/src/config.ts#L7) is defined by:
|
|
40
40
|
|
|
41
41
|
**Code: Structure of FirestoreModelConfig**
|
|
42
42
|
```typescript
|
|
@@ -50,7 +50,8 @@ export class FirestoreModelConfig {
|
|
|
50
50
|
modifyStorage?: boolean;
|
|
51
51
|
credentials?: FirestoreModelConfigCredentials;
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
@PostConstruct()
|
|
54
|
+
async finalizeConfig(): Promise<void> {
|
|
54
55
|
if (!this.databaseURL && !Runtime.production) {
|
|
55
56
|
this.projectId ??= 'trv-local-dev';
|
|
56
57
|
this.emulator ??= 'localhost:7000'; // From docker
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-firestore",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.1",
|
|
4
4
|
"description": "Firestore backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@google-cloud/firestore": "^8.3.0",
|
|
29
|
-
"@travetto/config": "^8.0.0-alpha.
|
|
30
|
-
"@travetto/model": "^8.0.0-alpha.
|
|
31
|
-
"@travetto/runtime": "^8.0.0-alpha.
|
|
29
|
+
"@travetto/config": "^8.0.0-alpha.1",
|
|
30
|
+
"@travetto/model": "^8.0.0-alpha.1",
|
|
31
|
+
"@travetto/runtime": "^8.0.0-alpha.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@travetto/cli": "^8.0.0-alpha.
|
|
34
|
+
"@travetto/cli": "^8.0.0-alpha.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependenciesMeta": {
|
|
37
37
|
"@travetto/cli": {
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JSONUtil, Runtime, RuntimeResources } from '@travetto/runtime';
|
|
2
2
|
import { Config } from '@travetto/config';
|
|
3
3
|
import { Schema, SchemaValidator } from '@travetto/schema';
|
|
4
|
+
import { PostConstruct } from '@travetto/di';
|
|
4
5
|
|
|
5
6
|
@Schema()
|
|
6
7
|
class FirestoreModelConfigCredentials {
|
|
@@ -19,7 +20,8 @@ export class FirestoreModelConfig {
|
|
|
19
20
|
modifyStorage?: boolean;
|
|
20
21
|
credentials?: FirestoreModelConfigCredentials;
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
@PostConstruct()
|
|
24
|
+
async finalizeConfig(): Promise<void> {
|
|
23
25
|
if (!this.databaseURL && !Runtime.production) {
|
|
24
26
|
this.projectId ??= 'trv-local-dev';
|
|
25
27
|
this.emulator ??= 'localhost:7000'; // From docker
|
package/src/service.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DocumentData, FieldValue, Firestore, type Query } from '@google-cloud/firestore';
|
|
2
2
|
|
|
3
3
|
import { JSONUtil, ShutdownManager, type Class, type DeepPartial } from '@travetto/runtime';
|
|
4
|
-
import { Injectable } from '@travetto/di';
|
|
4
|
+
import { Injectable, PostConstruct } from '@travetto/di';
|
|
5
5
|
import {
|
|
6
6
|
type ModelCrudSupport, ModelRegistryIndex, type ModelStorageSupport,
|
|
7
7
|
type ModelIndexedSupport, type ModelType, NotFoundError, type OptionalId,
|
|
@@ -38,7 +38,8 @@ export class FirestoreModelService implements ModelCrudSupport, ModelStorageSupp
|
|
|
38
38
|
return this.client.collection(this.#resolveTable(cls));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
@PostConstruct()
|
|
42
|
+
async initializeClient(): Promise<void> {
|
|
42
43
|
this.client = new Firestore({ ...this.config, useBigInt: true });
|
|
43
44
|
ShutdownManager.signal.addEventListener('abort', () => this.client.terminate());
|
|
44
45
|
}
|