@travetto/model 3.1.8 → 3.1.9
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 -3
- package/package.json +4 -4
- package/src/registry/decorator.ts +2 -0
- package/src/registry/model.ts +2 -2
package/README.md
CHANGED
|
@@ -205,7 +205,7 @@ export interface ModelBulkSupport extends ModelCrudSupport {
|
|
|
205
205
|
```
|
|
206
206
|
|
|
207
207
|
## Declaration
|
|
208
|
-
Models are declared via the [@Model](https://github.com/travetto/travetto/tree/main/module/model/src/registry/decorator.ts#
|
|
208
|
+
Models are declared via the [@Model](https://github.com/travetto/travetto/tree/main/module/model/src/registry/decorator.ts#L13) decorator, which allows the system to know that this is a class that is compatible with the module. The only requirement for a model is the [ModelType](https://github.com/travetto/travetto/tree/main/module/model/src/types/model.ts#L9)
|
|
209
209
|
|
|
210
210
|
**Code: ModelType**
|
|
211
211
|
```typescript
|
|
@@ -384,7 +384,7 @@ export class MemoryPolymorphicSuite extends ModelPolymorphismSuite {
|
|
|
384
384
|
```
|
|
385
385
|
|
|
386
386
|
## CLI - model:export
|
|
387
|
-
The module provides the ability to generate an export of the model structure from all the various [@Model](https://github.com/travetto/travetto/tree/main/module/model/src/registry/decorator.ts#
|
|
387
|
+
The module provides the ability to generate an export of the model structure from all the various [@Model](https://github.com/travetto/travetto/tree/main/module/model/src/registry/decorator.ts#L13)s within the application. This is useful for being able to generate the appropriate files to manually create the data schemas in production.
|
|
388
388
|
|
|
389
389
|
**Terminal: Running model export**
|
|
390
390
|
```bash
|
|
@@ -407,7 +407,7 @@ Models
|
|
|
407
407
|
```
|
|
408
408
|
|
|
409
409
|
## CLI - model:install
|
|
410
|
-
The module provides the ability to install all the various [@Model](https://github.com/travetto/travetto/tree/main/module/model/src/registry/decorator.ts#
|
|
410
|
+
The module provides the ability to install all the various [@Model](https://github.com/travetto/travetto/tree/main/module/model/src/registry/decorator.ts#L13)s within the application given the current configuration being targeted. This is useful for being able to prepare the datastore manually.
|
|
411
411
|
|
|
412
412
|
**Terminal: Running model install**
|
|
413
413
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.9",
|
|
4
4
|
"description": "Datastore abstraction for core operations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datastore",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"directory": "module/model"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^3.1.
|
|
29
|
+
"@travetto/config": "^3.1.3",
|
|
30
30
|
"@travetto/di": "^3.1.1",
|
|
31
31
|
"@travetto/registry": "^3.1.1",
|
|
32
|
-
"@travetto/schema": "^3.1.
|
|
32
|
+
"@travetto/schema": "^3.1.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@travetto/cli": "^3.1.
|
|
35
|
+
"@travetto/cli": "^3.1.3",
|
|
36
36
|
"@travetto/test": "^3.1.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Class } from '@travetto/base';
|
|
2
|
+
import { SchemaRegistry } from '@travetto/schema';
|
|
2
3
|
|
|
3
4
|
import { ModelType } from '../types/model';
|
|
4
5
|
import { ModelRegistry } from './model';
|
|
@@ -15,6 +16,7 @@ export function Model(conf: Partial<ModelOptions<ModelType>> | string = {}) {
|
|
|
15
16
|
conf = { store: conf };
|
|
16
17
|
}
|
|
17
18
|
ModelRegistry.register(target, conf);
|
|
19
|
+
SchemaRegistry.register(target, { baseType: conf.baseType });
|
|
18
20
|
return target;
|
|
19
21
|
};
|
|
20
22
|
}
|
package/src/registry/model.ts
CHANGED
|
@@ -64,8 +64,8 @@ class $ModelRegistry extends MetadataRegistry<ModelOptions<ModelType>> {
|
|
|
64
64
|
delete view.id.required; // Allow ids to be optional
|
|
65
65
|
|
|
66
66
|
if ('type' in view && this.getBaseModel(cls) !== cls) {
|
|
67
|
-
config.subType = schema.
|
|
68
|
-
delete view.
|
|
67
|
+
config.subType = !!schema.subTypeName; // Copy from schema
|
|
68
|
+
delete view[schema.subTypeField].required; // Allow type to be optional
|
|
69
69
|
}
|
|
70
70
|
return config;
|
|
71
71
|
}
|