@travetto/model-firestore 3.0.0-rc.1 → 3.0.0-rc.10

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  <!-- This file was generated by @travetto/doc and should not be modified directly -->
2
- <!-- Please modify https://github.com/travetto/travetto/tree/main/module/model-firestore/doc.ts and execute "npx trv doc" to rebuild -->
2
+ <!-- Please modify https://github.com/travetto/travetto/tree/main/module/model-firestore/DOC.ts and execute "npx trv doc" to rebuild -->
3
3
  # Firestore Model Support
4
4
  ## Firestore backing for the travetto model module.
5
5
 
@@ -39,7 +39,7 @@ export class Init {
39
39
 
40
40
  **Code: Structure of FirestoreModelConfig**
41
41
  ```typescript
42
- import { ResourceManager } from '@travetto/base';
42
+ import { CommonFileResourceProvider } from '@travetto/base';
43
43
  import { Config } from '@travetto/config';
44
44
 
45
45
  @Config('model.firestore')
@@ -62,11 +62,12 @@ export class FirestoreModelConfig {
62
62
  process.env.FIRESTORE_EMULATOR_HOST = this.emulator;
63
63
  }
64
64
  if (this.credentialsFile && !this.credentials) {
65
- this.credentials = JSON.parse(await ResourceManager.read(this.credentialsFile, 'utf8'));
65
+ const resources = new CommonFileResourceProvider();
66
+ this.credentials = JSON.parse(await resources.read(this.credentialsFile));
66
67
  }
67
68
  }
68
69
  }
69
70
  ```
70
71
 
71
- Additionally, you can see that the class is registered with the [@Config](https://github.com/travetto/travetto/tree/main/module/config/src/decorator.ts#L9) annotation, and so these values can be overridden using the
72
- standard [Configuration](https://github.com/travetto/travetto/tree/main/module/config#readme "Environment-aware config management using yaml files")resolution paths.
72
+ Additionally, you can see that the class is registered with the [@Config](https://github.com/travetto/travetto/tree/main/module/config/src/decorator.ts#L13) annotation, and so these values can be overridden using the
73
+ standard [Configuration](https://github.com/travetto/travetto/tree/main/module/config#readme "Configuration support")resolution paths.
File without changes
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-firestore",
3
- "displayName": "Firestore Model Support",
4
- "version": "3.0.0-rc.1",
3
+ "version": "3.0.0-rc.10",
5
4
  "description": "Firestore backing for the travetto model module.",
6
5
  "keywords": [
7
6
  "typescript",
@@ -16,19 +15,31 @@
16
15
  "name": "Travetto Framework"
17
16
  },
18
17
  "files": [
19
- "index.ts",
18
+ "__index__.ts",
20
19
  "src",
21
20
  "support"
22
21
  ],
23
- "main": "index.ts",
22
+ "main": "__index__.ts",
24
23
  "repository": {
25
24
  "url": "https://github.com/travetto/travetto.git",
26
25
  "directory": "module/model-firestore"
27
26
  },
28
27
  "dependencies": {
29
- "@travetto/config": "^3.0.0-rc.1",
30
- "@travetto/model": "^3.0.0-rc.1",
31
- "@google-cloud/firestore": "^5.0.2"
28
+ "@google-cloud/firestore": "^5.0.2",
29
+ "@travetto/base": "^3.0.0-rc.7",
30
+ "@travetto/config": "^3.0.0-rc.10",
31
+ "@travetto/model": "^3.0.0-rc.10"
32
+ },
33
+ "peerDependencies": {
34
+ "@travetto/command": "^3.0.0-rc.7"
35
+ },
36
+ "peerDependenciesMeta": {
37
+ "@travetto/command": {
38
+ "optional": true
39
+ }
40
+ },
41
+ "travetto": {
42
+ "displayName": "Firestore Model Support"
32
43
  },
33
44
  "private": false,
34
45
  "publishConfig": {
package/src/config.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ResourceManager } from '@travetto/base';
1
+ import { FileResourceProvider } from '@travetto/base';
2
2
  import { Config } from '@travetto/config';
3
3
 
4
4
  @Config('model.firestore')
@@ -21,7 +21,8 @@ export class FirestoreModelConfig {
21
21
  process.env.FIRESTORE_EMULATOR_HOST = this.emulator;
22
22
  }
23
23
  if (this.credentialsFile && !this.credentials) {
24
- this.credentials = JSON.parse(await ResourceManager.read(this.credentialsFile, 'utf8'));
24
+ const resources = new FileResourceProvider({ includeCommon: true });
25
+ this.credentials = JSON.parse(await resources.read(this.credentialsFile));
25
26
  }
26
27
  }
27
28
  }
package/src/service.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DocumentData, FieldValue, Firestore, PartialWithFieldValue, Query, UpdateData } from '@google-cloud/firestore';
2
2
 
3
- import { ShutdownManager, Util, Class } from '@travetto/base';
3
+ import { ShutdownManager, type Class } from '@travetto/base';
4
4
  import { DeepPartial } from '@travetto/schema';
5
5
  import { Injectable } from '@travetto/di';
6
6
  import {
@@ -10,10 +10,11 @@ import {
10
10
 
11
11
  import { ModelCrudUtil } from '@travetto/model/src/internal/service/crud';
12
12
  import { ModelIndexedUtil } from '@travetto/model/src/internal/service/indexed';
13
+ import { ModelUtil } from '@travetto/model/src/internal/util';
13
14
 
14
15
  import { FirestoreModelConfig } from './config';
15
16
 
16
- const clone = <T>(inp: T): T => JSON.parse(JSON.stringify(inp));
17
+ const clone = structuredClone;
17
18
 
18
19
  const toSimpleObj = <T>(inp: T, missingValue: unknown = null): PartialWithFieldValue<DocumentData> =>
19
20
  JSON.parse(JSON.stringify(inp, (_, v) => v ?? null), (_, v) => v ?? missingValue);
@@ -42,7 +43,7 @@ export class FirestoreModelService implements ModelCrudSupport, ModelStorageSupp
42
43
 
43
44
  async postConstruct(): Promise<void> {
44
45
  this.client = new Firestore(this.config);
45
- ShutdownManager.onShutdown(this.constructor.ᚕid, () => this.client.terminate());
46
+ ShutdownManager.onShutdown(this, () => this.client.terminate());
46
47
  }
47
48
 
48
49
  // Storage
@@ -57,7 +58,7 @@ export class FirestoreModelService implements ModelCrudSupport, ModelStorageSupp
57
58
 
58
59
  // Crud
59
60
  uuid(): string {
60
- return Util.uuid();
61
+ return ModelUtil.uuid();
61
62
  }
62
63
 
63
64
  async get<T extends ModelType>(cls: Class<T>, id: string): Promise<T> {
@@ -1,7 +1,7 @@
1
- import { EnvUtil } from '@travetto/boot';
2
- import type { Service } from '@travetto/command/bin/lib/service';
1
+ import { Env } from '@travetto/base';
2
+ import type { Service } from '@travetto/command/support/bin/service';
3
3
 
4
- const version = EnvUtil.get('TRV_SERVICE_FIRESTORE', 'latest');
4
+ const version = Env.get('FIRESTORE_VERSION', 'latest');
5
5
 
6
6
  export const service: Service = {
7
7
  name: 'firestore',