@api-client/core 0.13.6 → 0.14.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/build/src/amf/AmfTypes.d.ts +1 -1
- package/build/src/amf/AmfTypes.js +1 -1
- package/build/src/amf/AmfTypes.js.map +1 -1
- package/build/src/amf/Utils.d.ts +0 -6
- package/build/src/amf/Utils.d.ts.map +1 -1
- package/build/src/amf/Utils.js +0 -14
- package/build/src/amf/Utils.js.map +1 -1
- package/build/src/browser.d.ts +1 -0
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +1 -0
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +1 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/legacy.d.ts +0 -8
- package/build/src/legacy.d.ts.map +1 -1
- package/build/src/legacy.js +0 -9
- package/build/src/legacy.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DataDomain.js +2 -2
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DataFormat.d.ts +0 -40
- package/build/src/modeling/DataFormat.d.ts.map +1 -1
- package/build/src/modeling/DataFormat.js +0 -27
- package/build/src/modeling/DataFormat.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +28 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js +73 -4
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +25 -9
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +65 -21
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.d.ts +3 -4
- package/build/src/modeling/DomainFile.d.ts.map +1 -1
- package/build/src/modeling/DomainFile.js +5 -9
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +3 -3
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +2 -2
- package/build/src/modeling/DomainModel.js +2 -2
- package/build/src/modeling/DomainModel.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +28 -12
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js +61 -26
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/Semantics.d.ts +109 -0
- package/build/src/modeling/Semantics.d.ts.map +1 -0
- package/build/src/modeling/Semantics.js +97 -0
- package/build/src/modeling/Semantics.js.map +1 -0
- package/build/src/models/CertificateFile.d.ts +2 -3
- package/build/src/models/CertificateFile.d.ts.map +1 -1
- package/build/src/models/CertificateFile.js +4 -8
- package/build/src/models/CertificateFile.js.map +1 -1
- package/build/src/models/Folder.d.ts +1 -2
- package/build/src/models/Folder.d.ts.map +1 -1
- package/build/src/models/Folder.js +2 -4
- package/build/src/models/Folder.js.map +1 -1
- package/build/src/models/Project.d.ts +2 -3
- package/build/src/models/Project.d.ts.map +1 -1
- package/build/src/models/Project.js +4 -8
- package/build/src/models/Project.js.map +1 -1
- package/build/src/models/kinds.d.ts +0 -24
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +0 -24
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/File.d.ts +1 -21
- package/build/src/models/store/File.d.ts.map +1 -1
- package/build/src/models/store/File.js +3 -23
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/data_catalog.d.ts +1 -1
- package/build/src/models/store/data_catalog.js.map +1 -1
- package/build/src/sdk/FilesSdk.js +1 -1
- package/build/src/sdk/FilesSdk.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +22 -22
- package/eslint.config.js +1 -0
- package/package.json +5 -5
- package/src/amf/AmfTypes.ts +1 -1
- package/src/amf/Utils.ts +0 -15
- package/src/modeling/Bindings.ts +1 -1
- package/src/modeling/DataDomain.ts +2 -2
- package/src/modeling/DataFormat.ts +0 -48
- package/src/modeling/DomainAssociation.ts +66 -3
- package/src/modeling/DomainEntity.ts +56 -17
- package/src/modeling/DomainFile.ts +5 -9
- package/src/modeling/DomainImpactAnalysis.ts +3 -3
- package/src/modeling/DomainModel.ts +2 -2
- package/src/modeling/DomainProperty.ts +60 -21
- package/src/modeling/Semantics.ts +178 -0
- package/src/modeling/graph.md +14 -14
- package/src/modeling/readme.md +29 -29
- package/src/models/CertificateFile.ts +4 -12
- package/src/models/Folder.ts +2 -4
- package/src/models/Project.ts +4 -8
- package/src/models/kinds.ts +0 -25
- package/src/models/store/File.ts +4 -35
- package/src/models/store/data_catalog.ts +1 -1
- package/src/sdk/FilesSdk.ts +1 -1
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
- package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
- package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
- package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
- package/tests/unit/modeling/domain_entity.spec.ts +27 -26
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
- package/tests/unit/modeling/domain_file.spec.ts +4 -27
- package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
- package/tests/unit/models/Certificate/from_name.spec.ts +3 -15
- package/tests/unit/models/File/constructor.spec.ts +0 -1
- package/tests/unit/models/File/new.spec.ts +0 -13
- package/tests/unit/models/File/shortcutTo.spec.ts +1 -2
- package/tests/unit/models/File/toJSON.spec.ts +0 -13
- package/tests/unit/models/File/updateByMeMeta.spec.ts +4 -6
- package/tests/unit/models/Folder/create.spec.ts +2 -23
- package/tests/unit/models/Project/create.spec.ts +6 -32
- package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
- package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
- package/build/src/amf/AmfShapeGenerator.js +0 -416
- package/build/src/amf/AmfShapeGenerator.js.map +0 -1
- package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
- package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataAssociation.js +0 -443
- package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
- package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
- package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataEntity.js +0 -855
- package/build/src/modeling/legacy/DataEntity.js.map +0 -1
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
- package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
- package/build/src/modeling/legacy/DataModel.d.ts +0 -99
- package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataModel.js +0 -237
- package/build/src/modeling/legacy/DataModel.js.map +0 -1
- package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
- package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataNamespace.js +0 -784
- package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
- package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
- package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataProperty.js +0 -415
- package/build/src/modeling/legacy/DataProperty.js.map +0 -1
- package/build/src/models/store/DataFile.d.ts +0 -31
- package/build/src/models/store/DataFile.d.ts.map +0 -1
- package/build/src/models/store/DataFile.js +0 -92
- package/build/src/models/store/DataFile.js.map +0 -1
- package/src/amf/AmfShapeGenerator.ts +0 -477
- package/src/modeling/legacy/DataAssociation.ts +0 -554
- package/src/modeling/legacy/DataEntity.ts +0 -1019
- package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
- package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
- package/src/modeling/legacy/DataModel.ts +0 -276
- package/src/modeling/legacy/DataNamespace.ts +0 -929
- package/src/modeling/legacy/DataProperty.ts +0 -630
- package/src/models/store/DataFile.ts +0 -100
- package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
- package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
- package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
- package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
- package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
- package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
- package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
- package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
- package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
|
@@ -1,68 +1,50 @@
|
|
|
1
1
|
import { test } from '@japa/runner'
|
|
2
2
|
import { HttpProject, IProject, Project, ProjectKind, ThingKind } from '../../../../src/index.js'
|
|
3
3
|
|
|
4
|
-
const organization = 'test-organization'
|
|
5
|
-
|
|
6
4
|
test.group('Project.fromProject()', () => {
|
|
7
5
|
test('sets the kind', ({ assert }) => {
|
|
8
6
|
const p1 = HttpProject.fromName('p1')
|
|
9
|
-
const result = Project.fromProject(p1
|
|
7
|
+
const result = Project.fromProject(p1)
|
|
10
8
|
assert.equal(result.kind, ProjectKind)
|
|
11
9
|
})
|
|
12
10
|
|
|
13
|
-
test('sets the organization', ({ assert }) => {
|
|
14
|
-
const p1 = HttpProject.fromName('p1')
|
|
15
|
-
const result = Project.fromProject(p1, organization)
|
|
16
|
-
assert.equal(result.organization, organization)
|
|
17
|
-
})
|
|
18
|
-
|
|
19
11
|
test('sets the name', ({ assert }) => {
|
|
20
12
|
const p1 = HttpProject.fromName('p1')
|
|
21
|
-
const result = Project.fromProject(p1
|
|
13
|
+
const result = Project.fromProject(p1)
|
|
22
14
|
assert.equal(result.info.name, 'p1')
|
|
23
15
|
})
|
|
24
16
|
|
|
25
17
|
test('sets the key', ({ assert }) => {
|
|
26
18
|
const p1 = HttpProject.fromName('p1')
|
|
27
|
-
const result = Project.fromProject(p1
|
|
19
|
+
const result = Project.fromProject(p1)
|
|
28
20
|
assert.equal(result.key, p1.key)
|
|
29
21
|
})
|
|
30
22
|
|
|
31
23
|
test('respects schema instead of instance', ({ assert }) => {
|
|
32
24
|
const p1 = HttpProject.fromName('p1')
|
|
33
|
-
const result = Project.fromProject(p1.toJSON()
|
|
25
|
+
const result = Project.fromProject(p1.toJSON())
|
|
34
26
|
assert.equal(result.info.name, 'p1')
|
|
35
27
|
})
|
|
36
28
|
})
|
|
37
29
|
|
|
38
30
|
test.group('Project.fromName()', () => {
|
|
39
31
|
test('creates project from a name', ({ assert }) => {
|
|
40
|
-
const project = Project.fromName('test'
|
|
32
|
+
const project = Project.fromName('test')
|
|
41
33
|
assert.equal(project.info.name, 'test')
|
|
42
34
|
assert.equal(project.kind, ProjectKind)
|
|
43
|
-
assert.isUndefined(project.owner)
|
|
44
|
-
assert.equal(project.organization, 'org-id')
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test('sets the owner', ({ assert }) => {
|
|
48
|
-
const project = Project.fromName('test', 'org-id', 'owner-test')
|
|
49
|
-
assert.equal(project.owner, 'owner-test')
|
|
50
35
|
})
|
|
51
36
|
})
|
|
52
37
|
|
|
53
38
|
test.group('Project.constructor()', () => {
|
|
54
39
|
test('creates project from a name', ({ assert }) => {
|
|
55
|
-
const project = Project.fromName('test'
|
|
40
|
+
const project = Project.fromName('test')
|
|
56
41
|
assert.equal(project.info.name, 'test')
|
|
57
42
|
assert.equal(project.kind, ProjectKind)
|
|
58
|
-
assert.isUndefined(project.owner)
|
|
59
|
-
assert.equal(project.organization, 'org-id')
|
|
60
43
|
})
|
|
61
44
|
|
|
62
45
|
test('creates a default project', ({ assert }) => {
|
|
63
46
|
const result = new Project()
|
|
64
47
|
assert.equal(result.kind, ProjectKind)
|
|
65
|
-
assert.isUndefined(result.owner)
|
|
66
48
|
assert.typeOf(result.key, 'string')
|
|
67
49
|
assert.typeOf(result.lastModified, 'object')
|
|
68
50
|
})
|
|
@@ -70,13 +52,11 @@ test.group('Project.constructor()', () => {
|
|
|
70
52
|
test('creates a project from the schema values', ({ assert }) => {
|
|
71
53
|
const schema: IProject = {
|
|
72
54
|
kind: ProjectKind,
|
|
73
|
-
organization,
|
|
74
55
|
info: {
|
|
75
56
|
kind: ThingKind,
|
|
76
57
|
name: 'hello',
|
|
77
58
|
description: 'a desc',
|
|
78
59
|
},
|
|
79
|
-
owner: 'me',
|
|
80
60
|
key: '123',
|
|
81
61
|
parents: ['p1'],
|
|
82
62
|
permissionIds: ['pr1'],
|
|
@@ -98,9 +78,7 @@ test.group('Project.constructor()', () => {
|
|
|
98
78
|
}
|
|
99
79
|
const result = new Project(schema)
|
|
100
80
|
assert.equal(result.kind, ProjectKind)
|
|
101
|
-
assert.equal(result.organization, organization)
|
|
102
81
|
assert.equal(result.info.name, 'hello')
|
|
103
|
-
assert.equal(result.owner, 'me')
|
|
104
82
|
assert.equal(result.key, '123')
|
|
105
83
|
assert.deepEqual(result.parents, ['p1'])
|
|
106
84
|
assert.deepEqual(result.permissionIds, ['pr1'])
|
|
@@ -112,13 +90,11 @@ test.group('Project.constructor()', () => {
|
|
|
112
90
|
test('creates a project from the JSON schema string', ({ assert }) => {
|
|
113
91
|
const schema: IProject = {
|
|
114
92
|
kind: ProjectKind,
|
|
115
|
-
organization,
|
|
116
93
|
info: {
|
|
117
94
|
kind: ThingKind,
|
|
118
95
|
name: 'hello',
|
|
119
96
|
description: 'a desc',
|
|
120
97
|
},
|
|
121
|
-
owner: 'me',
|
|
122
98
|
key: '123',
|
|
123
99
|
parents: ['p1'],
|
|
124
100
|
permissionIds: ['pr1'],
|
|
@@ -139,9 +115,7 @@ test.group('Project.constructor()', () => {
|
|
|
139
115
|
}
|
|
140
116
|
const result = new Project(JSON.stringify(schema))
|
|
141
117
|
assert.equal(result.kind, ProjectKind)
|
|
142
|
-
assert.equal(result.organization, organization)
|
|
143
118
|
assert.equal(result.info.name, 'hello')
|
|
144
|
-
assert.equal(result.owner, 'me')
|
|
145
119
|
assert.equal(result.key, '123')
|
|
146
120
|
assert.deepEqual(result.lastModified, schema.lastModified)
|
|
147
121
|
})
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { type PropertyWebBindings } from '../modeling/Bindings.js';
|
|
2
|
-
import { DataAssociation } from '../modeling/legacy/DataAssociation.js';
|
|
3
|
-
import { DataEntity } from '../modeling/legacy/DataEntity.js';
|
|
4
|
-
import { DataProperty, type DataPropertySchema } from '../modeling/legacy/DataProperty.js';
|
|
5
|
-
import { IApiAnyShape, IApiArrayShape, IApiDataExample, IApiFileShape, IApiNodeShape, IApiPropertyShape, IApiRecursiveShape, IApiScalarShape, IApiShape, IShapeUnion } from './definitions/Shapes.js';
|
|
6
|
-
import { DataValueGenerator } from './DataValueGenerator.js';
|
|
7
|
-
/**
|
|
8
|
-
* Serializes Data shapes (DataEntity, DataProperty, DataAssociation) to AMF-related shapes.
|
|
9
|
-
*
|
|
10
|
-
* This is used when defining entities (according to the `DataEntity` schema)
|
|
11
|
-
* and then we want to translate this into AMF shapes.
|
|
12
|
-
*
|
|
13
|
-
* @deprecated This class refers to the deprecated old data domain model.
|
|
14
|
-
* Use the `ShapeGenerator` with the new domain model.
|
|
15
|
-
*/
|
|
16
|
-
export declare class AmfShapeGenerator {
|
|
17
|
-
#private;
|
|
18
|
-
/**
|
|
19
|
-
* Used with data domain value generation for entity properties.
|
|
20
|
-
* Lazily loaded class only when functions are used.
|
|
21
|
-
* This needs to be a class instances because some functions are incremental
|
|
22
|
-
*/
|
|
23
|
-
get valueGenerator(): DataValueGenerator;
|
|
24
|
-
/**
|
|
25
|
-
* Serializes the Entity to the AMF node shape.
|
|
26
|
-
*
|
|
27
|
-
* @param input The Property to serialize.
|
|
28
|
-
* @param generatedEntities The list keys of already generated entities. This prohibits recursive shape generation.
|
|
29
|
-
*/
|
|
30
|
-
entity(input: DataEntity, generatedEntities?: string[]): IApiNodeShape | IApiRecursiveShape;
|
|
31
|
-
/**
|
|
32
|
-
* Serializes an Entity Property to the AMF property shape.
|
|
33
|
-
*
|
|
34
|
-
* @param input The Property to serialize.
|
|
35
|
-
*/
|
|
36
|
-
property(input: DataProperty): IApiPropertyShape;
|
|
37
|
-
/**
|
|
38
|
-
* Serializes an Entity property to the AMF property shape with association
|
|
39
|
-
* targets as defined in the schema configuration.
|
|
40
|
-
*
|
|
41
|
-
* @param input The Property to serialize.
|
|
42
|
-
*/
|
|
43
|
-
associationProperty(input: DataAssociation, generatedEntities?: string[]): IApiPropertyShape;
|
|
44
|
-
/**
|
|
45
|
-
* Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.
|
|
46
|
-
*
|
|
47
|
-
* @param input The data association instance.
|
|
48
|
-
* @returns The range value for the PropertyShape.
|
|
49
|
-
*/
|
|
50
|
-
associationShape(input: DataAssociation, generatedEntities?: string[]): IShapeUnion | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.
|
|
53
|
-
*
|
|
54
|
-
* @param input The data association instance.
|
|
55
|
-
* @returns The range value for the PropertyShape.
|
|
56
|
-
*/
|
|
57
|
-
associationUnion(input: DataAssociation, generatedEntities?: string[]): IShapeUnion | IShapeUnion[] | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* The DataProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for
|
|
60
|
-
* default value, examples, and enum values. We also look for the `web`
|
|
61
|
-
* bindings for more detailed definition of a shape.
|
|
62
|
-
*
|
|
63
|
-
* @param input
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
protected _readPropertyRange(input: DataProperty): IApiArrayShape | IApiFileShape | IApiScalarShape;
|
|
67
|
-
protected _createAmfSchema(input: DataProperty, schema?: DataPropertySchema, bindings?: PropertyWebBindings): IApiArrayShape | IApiFileShape | IApiScalarShape;
|
|
68
|
-
/**
|
|
69
|
-
* Normally this would be part of generating a scalar schema but the the property is an array this
|
|
70
|
-
* is generated on the array and not on the range.
|
|
71
|
-
*
|
|
72
|
-
* @param result The scalar or array shape.
|
|
73
|
-
* @param schema The property schema
|
|
74
|
-
* @param type The data type of the parent property as set on the `range`
|
|
75
|
-
* @param isArray Whether the DataProperty is multiple
|
|
76
|
-
*/
|
|
77
|
-
protected _setShapeSchema(input: DataProperty, result: IApiAnyShape, schema: DataPropertySchema, type: string, isArray?: boolean): void;
|
|
78
|
-
protected _generateArrayShape(input: DataProperty, schema?: DataPropertySchema, bindings?: PropertyWebBindings): IApiArrayShape;
|
|
79
|
-
protected _generateScalarShape(input: DataProperty, schema?: DataPropertySchema, bindings?: PropertyWebBindings): IApiScalarShape;
|
|
80
|
-
protected _generateExamples(examples: string[], type: string): IApiDataExample[];
|
|
81
|
-
protected _generateArrayExamples(examples: string[], type: string): IApiDataExample[];
|
|
82
|
-
protected _generateFileShape(input: DataProperty, schema?: DataPropertySchema, bindings?: PropertyWebBindings): IApiFileShape;
|
|
83
|
-
protected _fillScalarShapeCommonProperties(result: IApiFileShape | IApiScalarShape, input: DataProperty, bindings?: PropertyWebBindings): void;
|
|
84
|
-
protected _updateBaseProperties(input: DataProperty | DataAssociation | DataEntity, target: IApiShape): void;
|
|
85
|
-
protected _recursiveShape(input: DataEntity): IApiRecursiveShape;
|
|
86
|
-
/**
|
|
87
|
-
* Translates generated schema from an array shape to the shape defined in the `items` of the array.
|
|
88
|
-
*
|
|
89
|
-
* @param array The source array.
|
|
90
|
-
* @returns The definition of the `items` of the array.
|
|
91
|
-
*/
|
|
92
|
-
refactorArrayToShape(array: IApiArrayShape): IShapeUnion;
|
|
93
|
-
/**
|
|
94
|
-
* Translates the shape to an array shape. This happens when data model property
|
|
95
|
-
* is changed from 'multiple' to not-multiple and back.
|
|
96
|
-
*
|
|
97
|
-
* @param id The key of the parameter or an association
|
|
98
|
-
* @param shape The shape to wrap as an array.
|
|
99
|
-
* @returns Array shape.
|
|
100
|
-
*/
|
|
101
|
-
refactorShapeToArray(id: string, shape: IShapeUnion): IApiArrayShape;
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=AmfShapeGenerator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AmfShapeGenerator.d.ts","sourceRoot":"","sources":["../../../src/amf/AmfShapeGenerator.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
import { IAmfExampleTypes, modelTypeToAmfDataType } from './AmfTypes.js';
|
|
2
|
-
import { AmfNamespace } from './definitions/Namespace.js';
|
|
3
|
-
import { anyShape, arrayShape, fileShape, nodeShape, propertyShape, recursiveShape, scalarShape, unionShape, } from './definitions/Shapes.js';
|
|
4
|
-
import { AmfDataNode } from './models/AmfDataNode.js';
|
|
5
|
-
import { nanoid } from '../nanoid.js';
|
|
6
|
-
import { DataEntityKind, DataPropertyKind } from '../models/kinds.js';
|
|
7
|
-
import { DataValueGenerator } from './DataValueGenerator.js';
|
|
8
|
-
/**
|
|
9
|
-
* Serializes Data shapes (DataEntity, DataProperty, DataAssociation) to AMF-related shapes.
|
|
10
|
-
*
|
|
11
|
-
* This is used when defining entities (according to the `DataEntity` schema)
|
|
12
|
-
* and then we want to translate this into AMF shapes.
|
|
13
|
-
*
|
|
14
|
-
* @deprecated This class refers to the deprecated old data domain model.
|
|
15
|
-
* Use the `ShapeGenerator` with the new domain model.
|
|
16
|
-
*/
|
|
17
|
-
export class AmfShapeGenerator {
|
|
18
|
-
#valueGenerator;
|
|
19
|
-
/**
|
|
20
|
-
* Used with data domain value generation for entity properties.
|
|
21
|
-
* Lazily loaded class only when functions are used.
|
|
22
|
-
* This needs to be a class instances because some functions are incremental
|
|
23
|
-
*/
|
|
24
|
-
get valueGenerator() {
|
|
25
|
-
if (!this.#valueGenerator) {
|
|
26
|
-
this.#valueGenerator = new DataValueGenerator();
|
|
27
|
-
}
|
|
28
|
-
return this.#valueGenerator;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Serializes the Entity to the AMF node shape.
|
|
32
|
-
*
|
|
33
|
-
* @param input The Property to serialize.
|
|
34
|
-
* @param generatedEntities The list keys of already generated entities. This prohibits recursive shape generation.
|
|
35
|
-
*/
|
|
36
|
-
entity(input, generatedEntities = []) {
|
|
37
|
-
if (generatedEntities.includes(input.key)) {
|
|
38
|
-
// create a recursive shape.
|
|
39
|
-
return this._recursiveShape(input);
|
|
40
|
-
}
|
|
41
|
-
generatedEntities.push(input.key);
|
|
42
|
-
const result = nodeShape(input.key);
|
|
43
|
-
result.id = input.key;
|
|
44
|
-
this._updateBaseProperties(input, result);
|
|
45
|
-
result.properties = [];
|
|
46
|
-
input.properties.forEach((item) => {
|
|
47
|
-
// we check whether the property is hidden.
|
|
48
|
-
// This is not happening when calling the `property()` because this method
|
|
49
|
-
// always returns the AMF shape.
|
|
50
|
-
const wb = item.readBinding('web');
|
|
51
|
-
if (wb && wb.hidden) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const shape = this.property(item);
|
|
55
|
-
result.properties.push(shape);
|
|
56
|
-
});
|
|
57
|
-
input.associations.forEach((assoc) => {
|
|
58
|
-
const prop = this.associationProperty(assoc, generatedEntities);
|
|
59
|
-
result.properties.push(prop);
|
|
60
|
-
});
|
|
61
|
-
input.getComputedParents().forEach((parent) => {
|
|
62
|
-
const shape = this.entity(parent, generatedEntities);
|
|
63
|
-
result.inherits.push(shape);
|
|
64
|
-
});
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Serializes an Entity Property to the AMF property shape.
|
|
69
|
-
*
|
|
70
|
-
* @param input The Property to serialize.
|
|
71
|
-
*/
|
|
72
|
-
property(input) {
|
|
73
|
-
const { required, key } = input;
|
|
74
|
-
const result = propertyShape(key);
|
|
75
|
-
result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`;
|
|
76
|
-
if (required) {
|
|
77
|
-
result.minCount = 1;
|
|
78
|
-
}
|
|
79
|
-
result.range = this._readPropertyRange(input);
|
|
80
|
-
// for example, Example generator needs to know the name of the property
|
|
81
|
-
// as it does not look into the "range" object.
|
|
82
|
-
this._updateBaseProperties(input, result);
|
|
83
|
-
// sync the name of the property shape with the range, in case it was changed by the bindings
|
|
84
|
-
if (result.range.name) {
|
|
85
|
-
result.name = result.range.name;
|
|
86
|
-
}
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Serializes an Entity property to the AMF property shape with association
|
|
91
|
-
* targets as defined in the schema configuration.
|
|
92
|
-
*
|
|
93
|
-
* @param input The Property to serialize.
|
|
94
|
-
*/
|
|
95
|
-
associationProperty(input, generatedEntities = []) {
|
|
96
|
-
const { required, key } = input;
|
|
97
|
-
const result = propertyShape(key);
|
|
98
|
-
result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`;
|
|
99
|
-
if (required) {
|
|
100
|
-
result.minCount = 1;
|
|
101
|
-
}
|
|
102
|
-
result.range = this.associationShape(input, generatedEntities);
|
|
103
|
-
this._updateBaseProperties(input, result);
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.
|
|
108
|
-
*
|
|
109
|
-
* @param input The data association instance.
|
|
110
|
-
* @returns The range value for the PropertyShape.
|
|
111
|
-
*/
|
|
112
|
-
associationShape(input, generatedEntities = []) {
|
|
113
|
-
const schema = input.schema;
|
|
114
|
-
if (schema && schema.linked) {
|
|
115
|
-
// This is a link to the schema. In an API that would be the id
|
|
116
|
-
// of a resource to request the data from.
|
|
117
|
-
const range = scalarShape(input.key);
|
|
118
|
-
range.id = `link-${input.key}`;
|
|
119
|
-
range.dataType = modelTypeToAmfDataType('string');
|
|
120
|
-
return range;
|
|
121
|
-
}
|
|
122
|
-
const items = this.associationUnion(input, generatedEntities);
|
|
123
|
-
if (!items) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const unionType = (schema && schema.unionType) || 'anyOf';
|
|
127
|
-
if (Array.isArray(items)) {
|
|
128
|
-
const range = unionShape(input.key);
|
|
129
|
-
this._updateBaseProperties(input, range);
|
|
130
|
-
range.anyOf = [];
|
|
131
|
-
if (unionType === 'anyOf') {
|
|
132
|
-
range.anyOf = items;
|
|
133
|
-
}
|
|
134
|
-
else if (unionType === 'allOf') {
|
|
135
|
-
range.and = items;
|
|
136
|
-
}
|
|
137
|
-
else if (unionType === 'oneOf') {
|
|
138
|
-
range.xone = items;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
// not.
|
|
142
|
-
range.not = items[0]; // ?
|
|
143
|
-
}
|
|
144
|
-
if (input.multiple) {
|
|
145
|
-
return this.refactorShapeToArray(input.key, range);
|
|
146
|
-
}
|
|
147
|
-
return range;
|
|
148
|
-
}
|
|
149
|
-
if (unionType === 'not') {
|
|
150
|
-
const wrapper = anyShape(input.key);
|
|
151
|
-
wrapper.id = `not-shape-${input.key}`;
|
|
152
|
-
wrapper.not = items;
|
|
153
|
-
return wrapper;
|
|
154
|
-
}
|
|
155
|
-
if (input.multiple) {
|
|
156
|
-
return this.refactorShapeToArray(input.key, items);
|
|
157
|
-
}
|
|
158
|
-
return items;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.
|
|
162
|
-
*
|
|
163
|
-
* @param input The data association instance.
|
|
164
|
-
* @returns The range value for the PropertyShape.
|
|
165
|
-
*/
|
|
166
|
-
associationUnion(input, generatedEntities = []) {
|
|
167
|
-
const targets = input.getTargets().map((i) => this.entity(i, generatedEntities));
|
|
168
|
-
if (!targets.length) {
|
|
169
|
-
return undefined;
|
|
170
|
-
}
|
|
171
|
-
if (targets.length > 1) {
|
|
172
|
-
return targets;
|
|
173
|
-
}
|
|
174
|
-
return targets[0];
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* The DataProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for
|
|
178
|
-
* default value, examples, and enum values. We also look for the `web`
|
|
179
|
-
* bindings for more detailed definition of a shape.
|
|
180
|
-
*
|
|
181
|
-
* @param input
|
|
182
|
-
* @returns
|
|
183
|
-
*/
|
|
184
|
-
_readPropertyRange(input) {
|
|
185
|
-
const bindings = input.readBinding('web');
|
|
186
|
-
let schema;
|
|
187
|
-
if (input.schema) {
|
|
188
|
-
schema = input.schema;
|
|
189
|
-
}
|
|
190
|
-
return this._createAmfSchema(input, schema, bindings);
|
|
191
|
-
}
|
|
192
|
-
_createAmfSchema(input, schema, bindings) {
|
|
193
|
-
const { multiple, type } = input;
|
|
194
|
-
if (multiple) {
|
|
195
|
-
return this._generateArrayShape(input, schema, bindings);
|
|
196
|
-
}
|
|
197
|
-
if (type === 'binary') {
|
|
198
|
-
return this._generateFileShape(input, schema, bindings);
|
|
199
|
-
}
|
|
200
|
-
return this._generateScalarShape(input, schema, bindings);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Normally this would be part of generating a scalar schema but the the property is an array this
|
|
204
|
-
* is generated on the array and not on the range.
|
|
205
|
-
*
|
|
206
|
-
* @param result The scalar or array shape.
|
|
207
|
-
* @param schema The property schema
|
|
208
|
-
* @param type The data type of the parent property as set on the `range`
|
|
209
|
-
* @param isArray Whether the DataProperty is multiple
|
|
210
|
-
*/
|
|
211
|
-
_setShapeSchema(input, result, schema, type, isArray) {
|
|
212
|
-
if (schema.defaultValue) {
|
|
213
|
-
const { type: dfFormat } = schema.defaultValue;
|
|
214
|
-
const { value } = schema.defaultValue;
|
|
215
|
-
if (dfFormat === 'function') {
|
|
216
|
-
const tmp = this.valueGenerator.generate(value, input.type);
|
|
217
|
-
if (tmp !== DataValueGenerator.noValue) {
|
|
218
|
-
const dt = AmfDataNode.scalar(tmp, dfFormat);
|
|
219
|
-
result.defaultValue = dt.toJSON();
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
const dt = AmfDataNode.scalar(value, type);
|
|
224
|
-
result.defaultValue = dt.toJSON();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (Array.isArray(schema.enum)) {
|
|
228
|
-
result.values = schema.enum.map((i) => AmfDataNode.scalar(i, type).toJSON());
|
|
229
|
-
}
|
|
230
|
-
if (Array.isArray(schema.examples)) {
|
|
231
|
-
if (isArray) {
|
|
232
|
-
result.examples = this._generateArrayExamples(schema.examples, type);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
result.examples = this._generateExamples(schema.examples, type);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
_generateArrayShape(input, schema, bindings) {
|
|
240
|
-
const result = arrayShape(input.key);
|
|
241
|
-
const { type } = input;
|
|
242
|
-
if (type === 'binary') {
|
|
243
|
-
// we do not pass schema to the range generator as we set schema's properties on the array shape.
|
|
244
|
-
result.items = this._generateFileShape(input, undefined, bindings);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
result.items = this._generateScalarShape(input, undefined, bindings);
|
|
248
|
-
}
|
|
249
|
-
if (schema) {
|
|
250
|
-
const type = result.items.dataType;
|
|
251
|
-
this._setShapeSchema(input, result, schema, type, input.multiple);
|
|
252
|
-
}
|
|
253
|
-
return result;
|
|
254
|
-
}
|
|
255
|
-
_generateScalarShape(input, schema, bindings) {
|
|
256
|
-
const result = scalarShape(input.key);
|
|
257
|
-
this._updateBaseProperties(input, result);
|
|
258
|
-
this._fillScalarShapeCommonProperties(result, input, bindings);
|
|
259
|
-
if (!result.dataType) {
|
|
260
|
-
result.dataType = modelTypeToAmfDataType(input.type, bindings);
|
|
261
|
-
}
|
|
262
|
-
if (schema) {
|
|
263
|
-
this._setShapeSchema(input, result, schema, result.dataType, input.multiple);
|
|
264
|
-
}
|
|
265
|
-
return result;
|
|
266
|
-
}
|
|
267
|
-
_generateExamples(examples, type) {
|
|
268
|
-
return examples.map((current) => {
|
|
269
|
-
const value = AmfDataNode.scalar(current, type).toJSON();
|
|
270
|
-
const item = {
|
|
271
|
-
id: nanoid(),
|
|
272
|
-
customDomainProperties: [],
|
|
273
|
-
strict: true,
|
|
274
|
-
types: IAmfExampleTypes,
|
|
275
|
-
structuredValue: value,
|
|
276
|
-
};
|
|
277
|
-
return item;
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
_generateArrayExamples(examples, type) {
|
|
281
|
-
const item = {
|
|
282
|
-
id: nanoid(),
|
|
283
|
-
customDomainProperties: [],
|
|
284
|
-
strict: true,
|
|
285
|
-
types: IAmfExampleTypes,
|
|
286
|
-
};
|
|
287
|
-
const value = new AmfDataNode('array');
|
|
288
|
-
examples.forEach((item) => {
|
|
289
|
-
const member = AmfDataNode.scalar(item, type);
|
|
290
|
-
value.addMember(member);
|
|
291
|
-
});
|
|
292
|
-
item.structuredValue = value.toJSON();
|
|
293
|
-
return [item];
|
|
294
|
-
}
|
|
295
|
-
_generateFileShape(input, schema, bindings) {
|
|
296
|
-
// if (bindings && bindings.format === 'base64') {
|
|
297
|
-
// // this is a binary format of a string shape
|
|
298
|
-
// }
|
|
299
|
-
const result = fileShape(input.key);
|
|
300
|
-
this._updateBaseProperties(input, result);
|
|
301
|
-
if (bindings) {
|
|
302
|
-
if (Array.isArray(bindings.fileTypes)) {
|
|
303
|
-
result.fileTypes = bindings.fileTypes;
|
|
304
|
-
}
|
|
305
|
-
this._fillScalarShapeCommonProperties(result, input, bindings);
|
|
306
|
-
if (bindings.format === 'base64') {
|
|
307
|
-
result.format = AmfNamespace.w3.xmlSchema.base64Binary;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return result;
|
|
311
|
-
}
|
|
312
|
-
_fillScalarShapeCommonProperties(result, input, bindings) {
|
|
313
|
-
if (bindings?.name) {
|
|
314
|
-
result.name = bindings.name;
|
|
315
|
-
}
|
|
316
|
-
if (bindings?.xml) {
|
|
317
|
-
result.xmlSerialization = bindings.xml;
|
|
318
|
-
}
|
|
319
|
-
if (bindings?.pattern) {
|
|
320
|
-
result.pattern = bindings.pattern;
|
|
321
|
-
}
|
|
322
|
-
const { schema, type } = input;
|
|
323
|
-
if (schema) {
|
|
324
|
-
if (typeof schema.multipleOf === 'number') {
|
|
325
|
-
result.multipleOf = schema.multipleOf;
|
|
326
|
-
}
|
|
327
|
-
if (typeof schema.minimum === 'number') {
|
|
328
|
-
if (type === 'string') {
|
|
329
|
-
result.minLength = schema.minimum;
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
result.minimum = schema.minimum;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
if (typeof schema.maximum === 'number') {
|
|
336
|
-
if (type === 'string') {
|
|
337
|
-
result.maxLength = schema.maximum;
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
result.maximum = schema.maximum;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if (typeof schema.exclusiveMinimum === 'boolean') {
|
|
344
|
-
result.exclusiveMinimum = schema.exclusiveMinimum;
|
|
345
|
-
}
|
|
346
|
-
if (typeof schema.exclusiveMaximum === 'boolean') {
|
|
347
|
-
result.exclusiveMaximum = schema.exclusiveMaximum;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
if (bindings?.format) {
|
|
351
|
-
switch (bindings.format) {
|
|
352
|
-
case 'base64':
|
|
353
|
-
result.format = AmfNamespace.w3.xmlSchema.base64Binary;
|
|
354
|
-
break;
|
|
355
|
-
case 'double':
|
|
356
|
-
result.format = AmfNamespace.w3.xmlSchema.double;
|
|
357
|
-
break;
|
|
358
|
-
case 'float':
|
|
359
|
-
result.format = AmfNamespace.w3.xmlSchema.float;
|
|
360
|
-
break;
|
|
361
|
-
case 'int32':
|
|
362
|
-
result.format = AmfNamespace.w3.xmlSchema.integer;
|
|
363
|
-
break;
|
|
364
|
-
case 'int64':
|
|
365
|
-
result.format = AmfNamespace.w3.xmlSchema.integer;
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
// result.format = bindings.format
|
|
369
|
-
}
|
|
370
|
-
if (typeof input.readOnly === 'boolean') {
|
|
371
|
-
result.readOnly = input.readOnly;
|
|
372
|
-
}
|
|
373
|
-
if (typeof input.writeOnly === 'boolean') {
|
|
374
|
-
result.writeOnly = input.writeOnly;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
_updateBaseProperties(input, target) {
|
|
378
|
-
// const bindings = input.readBinding('web') as PropertyWebBindings | undefined
|
|
379
|
-
target.name = input.info.name;
|
|
380
|
-
target.displayName = input.info.displayName;
|
|
381
|
-
target.description = input.info.description;
|
|
382
|
-
if (input.kind === DataPropertyKind) {
|
|
383
|
-
target.deprecated = input.deprecated;
|
|
384
|
-
}
|
|
385
|
-
else if (input.kind === DataEntityKind) {
|
|
386
|
-
target.deprecated = input.deprecated;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
_recursiveShape(input) {
|
|
390
|
-
return recursiveShape(input.key, input.key);
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Translates generated schema from an array shape to the shape defined in the `items` of the array.
|
|
394
|
-
*
|
|
395
|
-
* @param array The source array.
|
|
396
|
-
* @returns The definition of the `items` of the array.
|
|
397
|
-
*/
|
|
398
|
-
refactorArrayToShape(array) {
|
|
399
|
-
const { items } = array;
|
|
400
|
-
return items;
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Translates the shape to an array shape. This happens when data model property
|
|
404
|
-
* is changed from 'multiple' to not-multiple and back.
|
|
405
|
-
*
|
|
406
|
-
* @param id The key of the parameter or an association
|
|
407
|
-
* @param shape The shape to wrap as an array.
|
|
408
|
-
* @returns Array shape.
|
|
409
|
-
*/
|
|
410
|
-
refactorShapeToArray(id, shape) {
|
|
411
|
-
const result = arrayShape(id);
|
|
412
|
-
result.items = shape;
|
|
413
|
-
return result;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
//# sourceMappingURL=AmfShapeGenerator.js.map
|