@api-client/core 0.11.1 → 0.11.3
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/modeling/DataAssociation.d.ts +10 -9
- package/build/src/modeling/DataAssociation.d.ts.map +1 -1
- package/build/src/modeling/DataAssociation.js +14 -0
- package/build/src/modeling/DataAssociation.js.map +1 -1
- package/build/src/modeling/DataEntity.d.ts +64 -9
- package/build/src/modeling/DataEntity.d.ts.map +1 -1
- package/build/src/modeling/DataEntity.js +128 -16
- package/build/src/modeling/DataEntity.js.map +1 -1
- package/build/src/modeling/DataFormat.d.ts +8 -0
- package/build/src/modeling/DataFormat.d.ts.map +1 -1
- package/build/src/modeling/DataFormat.js +1 -0
- package/build/src/modeling/DataFormat.js.map +1 -1
- package/build/src/modeling/DataNamespace.d.ts +23 -1
- package/build/src/modeling/DataNamespace.d.ts.map +1 -1
- package/build/src/modeling/DataNamespace.js +39 -0
- package/build/src/modeling/DataNamespace.js.map +1 -1
- package/data/models/example-generator-api.json +8 -8
- package/package.json +1 -1
- package/src/modeling/DataAssociation.ts +15 -15
- package/src/modeling/DataEntity.ts +152 -16
- package/src/modeling/DataFormat.ts +10 -0
- package/src/modeling/DataNamespace.ts +45 -1
- package/src/modeling/readme.md +134 -0
- package/tests/unit/modeling/data_entity.spec.ts +481 -0
- package/tests/unit/modeling/data_namespace.spec.ts +245 -0
|
@@ -821,3 +821,248 @@ test.group('computeForeignNamespaceKeys()', () => {
|
|
|
821
821
|
assert.deepEqual(result, [n2.key])
|
|
822
822
|
})
|
|
823
823
|
})
|
|
824
|
+
|
|
825
|
+
test.group('findAssociatedEntity()', (group) => {
|
|
826
|
+
let root: DataNamespace
|
|
827
|
+
let foreign: DataNamespace
|
|
828
|
+
let e1: DataEntity
|
|
829
|
+
let e2: DataEntity
|
|
830
|
+
|
|
831
|
+
group.each.setup(() => {
|
|
832
|
+
root = new DataNamespace()
|
|
833
|
+
foreign = new DataNamespace()
|
|
834
|
+
root.addForeign(foreign)
|
|
835
|
+
const model1 = root.addDataModel('m1')
|
|
836
|
+
const model2 = foreign.addDataModel('m2')
|
|
837
|
+
e1 = model1.addEntity('e1')
|
|
838
|
+
e2 = model2.addEntity('e2')
|
|
839
|
+
})
|
|
840
|
+
|
|
841
|
+
test('finds an entity in the current namespace', ({ assert }) => {
|
|
842
|
+
const result = root.findAssociatedEntity(e1.key)
|
|
843
|
+
assert.deepEqual(result, e1)
|
|
844
|
+
})
|
|
845
|
+
|
|
846
|
+
test('finds an entity in a foreign namespace', ({ assert }) => {
|
|
847
|
+
const result = root.findAssociatedEntity(e2.key, foreign.key)
|
|
848
|
+
assert.deepEqual(result, e2)
|
|
849
|
+
})
|
|
850
|
+
|
|
851
|
+
test('returns undefined when the entity is not found in the current namespace', ({ assert }) => {
|
|
852
|
+
const result = root.findAssociatedEntity('non-existent-key')
|
|
853
|
+
assert.isUndefined(result)
|
|
854
|
+
})
|
|
855
|
+
|
|
856
|
+
test('returns undefined when the entity is not found in a foreign namespace', ({ assert }) => {
|
|
857
|
+
const result = root.findAssociatedEntity('non-existent-key', foreign.key)
|
|
858
|
+
assert.isUndefined(result)
|
|
859
|
+
})
|
|
860
|
+
|
|
861
|
+
test('returns undefined when the foreign namespace does not exist', ({ assert }) => {
|
|
862
|
+
const result = root.findAssociatedEntity(e2.key, 'non-existent-namespace')
|
|
863
|
+
assert.isUndefined(result)
|
|
864
|
+
})
|
|
865
|
+
|
|
866
|
+
test('returns undefined when no namespace is provided and the entity is in a foreign namespace', ({ assert }) => {
|
|
867
|
+
const result = root.findAssociatedEntity(e2.key)
|
|
868
|
+
assert.isUndefined(result)
|
|
869
|
+
})
|
|
870
|
+
})
|
|
871
|
+
|
|
872
|
+
test.group('addForeign()', (group) => {
|
|
873
|
+
let root: DataNamespace
|
|
874
|
+
let foreign: DataNamespace
|
|
875
|
+
|
|
876
|
+
group.each.setup(() => {
|
|
877
|
+
root = new DataNamespace()
|
|
878
|
+
foreign = new DataNamespace()
|
|
879
|
+
})
|
|
880
|
+
|
|
881
|
+
test('adds a foreign namespace', ({ assert }) => {
|
|
882
|
+
root.addForeign(foreign)
|
|
883
|
+
assert.deepEqual(root.foreign, [foreign])
|
|
884
|
+
})
|
|
885
|
+
|
|
886
|
+
test('does not add the same foreign namespace twice', ({ assert }) => {
|
|
887
|
+
root.addForeign(foreign)
|
|
888
|
+
root.addForeign(foreign)
|
|
889
|
+
assert.deepEqual(root.foreign, [foreign])
|
|
890
|
+
})
|
|
891
|
+
})
|
|
892
|
+
|
|
893
|
+
test.group('removeForeign()', (group) => {
|
|
894
|
+
let root: DataNamespace
|
|
895
|
+
let foreign: DataNamespace
|
|
896
|
+
let foreign2: DataNamespace
|
|
897
|
+
|
|
898
|
+
group.each.setup(() => {
|
|
899
|
+
root = new DataNamespace()
|
|
900
|
+
foreign = new DataNamespace()
|
|
901
|
+
foreign2 = new DataNamespace()
|
|
902
|
+
root.addForeign(foreign)
|
|
903
|
+
root.addForeign(foreign2)
|
|
904
|
+
})
|
|
905
|
+
|
|
906
|
+
test('removes a foreign namespace', ({ assert }) => {
|
|
907
|
+
root.removeForeign(foreign)
|
|
908
|
+
assert.deepEqual(root.foreign, [foreign2])
|
|
909
|
+
})
|
|
910
|
+
|
|
911
|
+
test('does nothing when the foreign namespace does not exist', ({ assert }) => {
|
|
912
|
+
const other = new DataNamespace()
|
|
913
|
+
root.removeForeign(other)
|
|
914
|
+
assert.deepEqual(root.foreign, [foreign, foreign2])
|
|
915
|
+
})
|
|
916
|
+
})
|
|
917
|
+
|
|
918
|
+
test.group('hasForeignNamespace()', (group) => {
|
|
919
|
+
let root: DataNamespace
|
|
920
|
+
let foreign: DataNamespace
|
|
921
|
+
|
|
922
|
+
group.each.setup(() => {
|
|
923
|
+
root = new DataNamespace()
|
|
924
|
+
foreign = new DataNamespace()
|
|
925
|
+
root.addForeign(foreign)
|
|
926
|
+
})
|
|
927
|
+
|
|
928
|
+
test('returns true when the foreign namespace exists', ({ assert }) => {
|
|
929
|
+
const result = root.hasForeignNamespace(foreign.key)
|
|
930
|
+
assert.isTrue(result)
|
|
931
|
+
})
|
|
932
|
+
|
|
933
|
+
test('returns false when the foreign namespace does not exist', ({ assert }) => {
|
|
934
|
+
const result = root.hasForeignNamespace('non-existent-key')
|
|
935
|
+
assert.isFalse(result)
|
|
936
|
+
})
|
|
937
|
+
})
|
|
938
|
+
|
|
939
|
+
test.group('listNamespaces()', (group) => {
|
|
940
|
+
let root: DataNamespace
|
|
941
|
+
let n1: DataNamespace
|
|
942
|
+
let n2: DataNamespace
|
|
943
|
+
let m1: DataModel
|
|
944
|
+
|
|
945
|
+
group.each.setup(() => {
|
|
946
|
+
root = new DataNamespace()
|
|
947
|
+
n1 = root.addNamespace('n1')
|
|
948
|
+
n2 = root.addNamespace('n2')
|
|
949
|
+
m1 = root.addDataModel('m1')
|
|
950
|
+
})
|
|
951
|
+
|
|
952
|
+
test('lists all namespaces', ({ assert }) => {
|
|
953
|
+
const result = root.listNamespaces()
|
|
954
|
+
assert.deepEqual(result, [n1, n2])
|
|
955
|
+
})
|
|
956
|
+
|
|
957
|
+
test('lists namespaces in a sub-namespace', ({ assert }) => {
|
|
958
|
+
const n3 = n1.addNamespace('n3')
|
|
959
|
+
const result = n1.listNamespaces()
|
|
960
|
+
assert.deepEqual(result, [n3])
|
|
961
|
+
})
|
|
962
|
+
|
|
963
|
+
test('does not list data models', ({ assert }) => {
|
|
964
|
+
const result = root.listNamespaces()
|
|
965
|
+
assert.notDeepInclude(result, m1)
|
|
966
|
+
})
|
|
967
|
+
})
|
|
968
|
+
|
|
969
|
+
test.group('listDataModels()', (group) => {
|
|
970
|
+
let root: DataNamespace
|
|
971
|
+
let n1: DataNamespace
|
|
972
|
+
let m1: DataModel
|
|
973
|
+
let m2: DataModel
|
|
974
|
+
let e1: DataEntity
|
|
975
|
+
|
|
976
|
+
group.each.setup(() => {
|
|
977
|
+
root = new DataNamespace()
|
|
978
|
+
n1 = root.addNamespace('n1')
|
|
979
|
+
m1 = root.addDataModel('m1')
|
|
980
|
+
m2 = n1.addDataModel('m2')
|
|
981
|
+
e1 = m2.addEntity('e1')
|
|
982
|
+
})
|
|
983
|
+
|
|
984
|
+
test('lists all data models', ({ assert }) => {
|
|
985
|
+
const result = root.listDataModels()
|
|
986
|
+
assert.deepEqual(result, [m1])
|
|
987
|
+
})
|
|
988
|
+
|
|
989
|
+
test('lists data models in a sub-namespace', ({ assert }) => {
|
|
990
|
+
const m3 = n1.addDataModel('m3')
|
|
991
|
+
const result = n1.listDataModels()
|
|
992
|
+
assert.deepEqual(result, [m2, m3])
|
|
993
|
+
})
|
|
994
|
+
|
|
995
|
+
test('does not list entities', ({ assert }) => {
|
|
996
|
+
const result = root.listDataModels()
|
|
997
|
+
assert.notDeepInclude(result, e1)
|
|
998
|
+
})
|
|
999
|
+
})
|
|
1000
|
+
|
|
1001
|
+
test.group('getRoot()', (group) => {
|
|
1002
|
+
let root: DataNamespace
|
|
1003
|
+
let n1: DataNamespace
|
|
1004
|
+
let n2: DataNamespace
|
|
1005
|
+
|
|
1006
|
+
group.each.setup(() => {
|
|
1007
|
+
root = new DataNamespace()
|
|
1008
|
+
n1 = root.addNamespace('n1')
|
|
1009
|
+
n2 = n1.addNamespace('n2')
|
|
1010
|
+
})
|
|
1011
|
+
|
|
1012
|
+
test('returns self when called on the root namespace', ({ assert }) => {
|
|
1013
|
+
const result = root.getRoot()
|
|
1014
|
+
assert.deepEqual(result, root)
|
|
1015
|
+
})
|
|
1016
|
+
|
|
1017
|
+
test('returns the root namespace when called on a sub-namespace', ({ assert }) => {
|
|
1018
|
+
const result = n1.getRoot()
|
|
1019
|
+
assert.deepEqual(result, root)
|
|
1020
|
+
})
|
|
1021
|
+
|
|
1022
|
+
test('returns the root namespace when called on a sub-sub-namespace', ({ assert }) => {
|
|
1023
|
+
const result = n2.getRoot()
|
|
1024
|
+
assert.deepEqual(result, root)
|
|
1025
|
+
})
|
|
1026
|
+
})
|
|
1027
|
+
|
|
1028
|
+
test.group('getParent()', (group) => {
|
|
1029
|
+
let root: DataNamespace
|
|
1030
|
+
let n1: DataNamespace
|
|
1031
|
+
let n2: DataNamespace
|
|
1032
|
+
|
|
1033
|
+
group.each.setup(() => {
|
|
1034
|
+
root = new DataNamespace()
|
|
1035
|
+
n1 = root.addNamespace('n1')
|
|
1036
|
+
n2 = n1.addNamespace('n2')
|
|
1037
|
+
})
|
|
1038
|
+
|
|
1039
|
+
test('returns undefined when called on the root namespace', ({ assert }) => {
|
|
1040
|
+
const result = root.getParent()
|
|
1041
|
+
assert.isUndefined(result)
|
|
1042
|
+
})
|
|
1043
|
+
|
|
1044
|
+
test('returns the parent namespace when called on a sub-namespace', ({ assert }) => {
|
|
1045
|
+
const result = n2.getParent()
|
|
1046
|
+
assert.deepEqual(result, n1)
|
|
1047
|
+
})
|
|
1048
|
+
})
|
|
1049
|
+
|
|
1050
|
+
test.group('isRoot()', (group) => {
|
|
1051
|
+
let root: DataNamespace
|
|
1052
|
+
let n1: DataNamespace
|
|
1053
|
+
|
|
1054
|
+
group.each.setup(() => {
|
|
1055
|
+
root = new DataNamespace()
|
|
1056
|
+
n1 = root.addNamespace('n1')
|
|
1057
|
+
})
|
|
1058
|
+
|
|
1059
|
+
test('returns true when called on the root namespace', ({ assert }) => {
|
|
1060
|
+
const result = root.isRoot()
|
|
1061
|
+
assert.isTrue(result)
|
|
1062
|
+
})
|
|
1063
|
+
|
|
1064
|
+
test('returns false when called on a sub-namespace', ({ assert }) => {
|
|
1065
|
+
const result = n1.isRoot()
|
|
1066
|
+
assert.isFalse(result)
|
|
1067
|
+
})
|
|
1068
|
+
})
|