@travetto/model 3.0.0-rc.23 → 3.0.0-rc.25

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 (2) hide show
  1. package/README.md +29 -24
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -6,6 +6,10 @@
6
6
  **Install: @travetto/model**
7
7
  ```bash
8
8
  npm install @travetto/model
9
+
10
+ # or
11
+
12
+ yarn add @travetto/model
9
13
  ```
10
14
 
11
15
  This module provides a set of contracts/interfaces to data model persistence, modification and retrieval. This module builds heavily upon the [Schema](https://github.com/travetto/travetto/tree/main/module/schema#readme "Data type registry for runtime validation, reflection and binding."), which is used for data model validation.
@@ -49,7 +53,7 @@ export interface ModelBasicSupport<C = unknown> {
49
53
  ```
50
54
 
51
55
  ### [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/service/crud.ts#L11)
52
- The crud contract, builds upon the basic contract, and is built around the idea of simple data retrieval and storage, to create a foundation for other services that need only basic support. The model extension in [Authentication](https://github.com/travetto/travetto/tree/main/module/auth#readme "Authentication scaffolding for the travetto framework"), is an example of a module that only needs create, read and delete, and so any implementation of [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.") that honors this contract, can be used with the [Authentication](https://github.com/travetto/travetto/tree/main/module/auth#readme "Authentication scaffolding for the travetto framework") model extension.
56
+ The crud contract, builds upon the basic contract, and is built around the idea of simple data retrieval and storage, to create a foundation for other services that need only basic support. The model extension in [Authentication](https://github.com/travetto/travetto/tree/main/module/auth#readme "Authentication scaffolding for the Travetto framework"), is an example of a module that only needs create, read and delete, and so any implementation of [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.") that honors this contract, can be used with the [Authentication](https://github.com/travetto/travetto/tree/main/module/auth#readme "Authentication scaffolding for the Travetto framework") model extension.
53
57
 
54
58
  **Code: Crud Contract**
55
59
  ```typescript
@@ -293,34 +297,35 @@ export class MemoryModelService implements ModelCrudSupport, ModelStreamSupport,
293
297
  sorted: new Map<string, Map<string, Map<string, number>>>(),
294
298
  unsorted: new Map<string, Map<string, Set<string>>>()
295
299
  };
296
- get client(): Map<string, StoreType> { return this.#store; }
297
- async postConstruct(): Promise<void> ;
300
+ get client(): Map<string, StoreType>;
301
+ constructor(public readonly config: MemoryModelConfig) { }
302
+ async postConstruct(): Promise<void>;
298
303
  // CRUD Support
299
- uuid(): string ;
300
- async get<T extends ModelType>(cls: Class<T>, id: string): Promise<T> ;
301
- async create<T extends ModelType>(cls: Class<T>, item: OptionalId<T>): Promise<T> ;
302
- async update<T extends ModelType>(cls: Class<T>, item: T): Promise<T> ;
303
- async upsert<T extends ModelType>(cls: Class<T>, item: OptionalId<T>): Promise<T> ;
304
- async updatePartial<T extends ModelType>(cls: Class<T>, item: Partial<T> & { id: string }, view?: string): Promise<T> ;
305
- async delete<T extends ModelType>(cls: Class<T>, id: string): Promise<void> ;
306
- async * list<T extends ModelType>(cls: Class<T>): AsyncIterable<T> ;
304
+ uuid(): string;
305
+ async get<T extends ModelType>(cls: Class<T>, id: string): Promise<T>;
306
+ async create<T extends ModelType>(cls: Class<T>, item: OptionalId<T>): Promise<T>;
307
+ async update<T extends ModelType>(cls: Class<T>, item: T): Promise<T>;
308
+ async upsert<T extends ModelType>(cls: Class<T>, item: OptionalId<T>): Promise<T>;
309
+ async updatePartial<T extends ModelType>(cls: Class<T>, item: Partial<T> & { id: string }, view?: string): Promise<T>;
310
+ async delete<T extends ModelType>(cls: Class<T>, id: string): Promise<void>;
311
+ async * list<T extends ModelType>(cls: Class<T>): AsyncIterable<T>;
307
312
  // Stream Support
308
- async upsertStream(location: string, input: Readable, meta: StreamMeta): Promise<void> ;
309
- async getStream(location: string): Promise<Readable> ;
310
- async describeStream(location: string): Promise<StreamMeta> ;
311
- async deleteStream(location: string): Promise<void> ;
313
+ async upsertStream(location: string, input: Readable, meta: StreamMeta): Promise<void>;
314
+ async getStream(location: string): Promise<Readable>;
315
+ async describeStream(location: string): Promise<StreamMeta>;
316
+ async deleteStream(location: string): Promise<void>;
312
317
  // Expiry Support
313
- async deleteExpired<T extends ModelType>(cls: Class<T>): Promise<number> ;
318
+ async deleteExpired<T extends ModelType>(cls: Class<T>): Promise<number>;
314
319
  // Storage Support
315
- async createStorage(): Promise<void> ;
316
- async deleteStorage(): Promise<void> ;
317
- async createModel<T extends ModelType>(cls: Class<T>): Promise<void> ;
318
- async truncateModel<T extends ModelType>(cls: Class<T>): Promise<void> ;
320
+ async createStorage(): Promise<void>;
321
+ async deleteStorage(): Promise<void>;
322
+ async createModel<T extends ModelType>(cls: Class<T>): Promise<void>;
323
+ async truncateModel<T extends ModelType>(cls: Class<T>): Promise<void>;
319
324
  // Indexed
320
- async getByIndex<T extends ModelType>(cls: Class<T>, idx: string, body: DeepPartial<T>): Promise<T> ;
321
- async deleteByIndex<T extends ModelType>(cls: Class<T>, idx: string, body: DeepPartial<T>): Promise<void> ;
322
- upsertByIndex<T extends ModelType>(cls: Class<T>, idx: string, body: OptionalId<T>): Promise<T> ;
323
- async * listByIndex<T extends ModelType>(cls: Class<T>, idx: string, body?: DeepPartial<T>): AsyncIterable<T> ;
325
+ async getByIndex<T extends ModelType>(cls: Class<T>, idx: string, body: DeepPartial<T>): Promise<T>;
326
+ async deleteByIndex<T extends ModelType>(cls: Class<T>, idx: string, body: DeepPartial<T>): Promise<void>;
327
+ upsertByIndex<T extends ModelType>(cls: Class<T>, idx: string, body: OptionalId<T>): Promise<T>;
328
+ async * listByIndex<T extends ModelType>(cls: Class<T>, idx: string, body?: DeepPartial<T>): AsyncIterable<T>;
324
329
  }
325
330
  ```
326
331
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model",
3
- "version": "3.0.0-rc.23",
3
+ "version": "3.0.0-rc.25",
4
4
  "description": "Datastore abstraction for core operations.",
5
5
  "keywords": [
6
6
  "datastore",
@@ -26,14 +26,14 @@
26
26
  "directory": "module/model"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/config": "^3.0.0-rc.23",
30
- "@travetto/di": "^3.0.0-rc.22",
31
- "@travetto/registry": "^3.0.0-rc.22",
32
- "@travetto/schema": "^3.0.0-rc.23"
29
+ "@travetto/config": "^3.0.0-rc.25",
30
+ "@travetto/di": "^3.0.0-rc.24",
31
+ "@travetto/registry": "^3.0.0-rc.24",
32
+ "@travetto/schema": "^3.0.0-rc.25"
33
33
  },
34
34
  "peerDependencies": {
35
- "@travetto/cli": "^3.0.0-rc.22",
36
- "@travetto/test": "^3.0.0-rc.25"
35
+ "@travetto/cli": "^3.0.0-rc.24",
36
+ "@travetto/test": "^3.0.0-rc.27"
37
37
  },
38
38
  "peerDependenciesMeta": {
39
39
  "@travetto/cli": {