@api-client/core 0.14.1 → 0.14.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.
Files changed (96) hide show
  1. package/build/src/browser.d.ts +1 -1
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js.map +1 -1
  4. package/build/src/index.d.ts +2 -1
  5. package/build/src/index.d.ts.map +1 -1
  6. package/build/src/index.js +1 -0
  7. package/build/src/index.js.map +1 -1
  8. package/build/src/modeling/ApiFile.d.ts +23 -0
  9. package/build/src/modeling/ApiFile.d.ts.map +1 -0
  10. package/build/src/modeling/ApiFile.js +44 -0
  11. package/build/src/modeling/ApiFile.js.map +1 -0
  12. package/build/src/modeling/ApiModel.d.ts +159 -0
  13. package/build/src/modeling/ApiModel.d.ts.map +1 -0
  14. package/build/src/modeling/ApiModel.js +237 -0
  15. package/build/src/modeling/ApiModel.js.map +1 -0
  16. package/build/src/modeling/DataDomain.d.ts +1 -1
  17. package/build/src/modeling/DataDomain.d.ts.map +1 -1
  18. package/build/src/modeling/DataDomain.js +1 -3
  19. package/build/src/modeling/DataDomain.js.map +1 -1
  20. package/build/src/modeling/DomainAssociation.d.ts +35 -0
  21. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  22. package/build/src/modeling/DomainAssociation.js +42 -5
  23. package/build/src/modeling/DomainAssociation.js.map +1 -1
  24. package/build/src/modeling/DomainEntity.js +1 -1
  25. package/build/src/modeling/DomainEntity.js.map +1 -1
  26. package/build/src/modeling/DomainFile.d.ts +1 -2
  27. package/build/src/modeling/DomainFile.d.ts.map +1 -1
  28. package/build/src/modeling/DomainFile.js +3 -41
  29. package/build/src/modeling/DomainFile.js.map +1 -1
  30. package/build/src/modeling/Semantics.d.ts +62 -7
  31. package/build/src/modeling/Semantics.d.ts.map +1 -1
  32. package/build/src/modeling/Semantics.js +76 -7
  33. package/build/src/modeling/Semantics.js.map +1 -1
  34. package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -1
  35. package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
  36. package/build/src/modeling/types.d.ts +491 -0
  37. package/build/src/modeling/types.d.ts.map +1 -1
  38. package/build/src/modeling/types.js.map +1 -1
  39. package/build/src/models/kinds.d.ts +2 -0
  40. package/build/src/models/kinds.d.ts.map +1 -1
  41. package/build/src/models/kinds.js +2 -0
  42. package/build/src/models/kinds.js.map +1 -1
  43. package/build/src/models/store/File.d.ts +19 -2
  44. package/build/src/models/store/File.d.ts.map +1 -1
  45. package/build/src/models/store/File.js +100 -13
  46. package/build/src/models/store/File.js.map +1 -1
  47. package/build/tsconfig.tsbuildinfo +1 -1
  48. package/data/models/APIC-187.json +3 -3
  49. package/data/models/APIC-188.json +3 -3
  50. package/data/models/APIC-233.json +1 -1
  51. package/data/models/APIC-391.json +2 -2
  52. package/data/models/APIC-483.json +1 -1
  53. package/data/models/APIC-487.json +1 -1
  54. package/data/models/APIC-655.json +1 -1
  55. package/data/models/APIC-689.json +1 -1
  56. package/data/models/APIC-690.json +5 -5
  57. package/data/models/SE-10469.json +1 -1
  58. package/data/models/SE-13092.json +5 -5
  59. package/data/models/SE-22063.json +12 -2
  60. package/data/models/amf-helper-api.json +154 -14
  61. package/data/models/arc-demo-api.json +95 -15
  62. package/data/models/async-api.json +1 -1
  63. package/data/models/example-generator-api.json +361 -21
  64. package/data/models/expanded-api.json +1 -1
  65. package/data/models/flattened-api.json +1 -1
  66. package/data/models/multiple-servers.json +1 -1
  67. package/data/models/oas-3-api.json +1 -1
  68. package/data/models/oas-date.json +1 -1
  69. package/data/models/oas-types.json +1 -1
  70. package/data/models/oas-unions.json +1 -1
  71. package/data/models/petstore.json +1 -1
  72. package/data/models/raml-date.json +1 -1
  73. package/data/models/recursive.json +1 -1
  74. package/data/models/schema-api.json +62 -2
  75. package/data/models/secured-api.json +16 -16
  76. package/data/models/tracked-to-linked.json +4 -4
  77. package/package.json +3 -4
  78. package/src/modeling/ApiFile.ts +53 -0
  79. package/src/modeling/ApiModel.ts +327 -0
  80. package/src/modeling/DataDomain.ts +1 -1
  81. package/src/modeling/DomainAssociation.ts +56 -0
  82. package/src/modeling/DomainEntity.ts +1 -1
  83. package/src/modeling/DomainFile.ts +3 -40
  84. package/src/modeling/Semantics.ts +79 -7
  85. package/src/modeling/amf/ShapeGenerator.ts +1 -1
  86. package/src/modeling/types.ts +545 -0
  87. package/src/models/kinds.ts +2 -0
  88. package/src/models/store/File.ts +100 -13
  89. package/tests/unit/modeling/api_model.spec.ts +291 -0
  90. package/tests/unit/modeling/domain_asociation.spec.ts +92 -2
  91. package/tests/unit/modeling/domain_entity.spec.ts +15 -15
  92. package/tests/unit/modeling/domain_file.spec.ts +1 -11
  93. package/tests/unit/modeling/domain_model_entities.spec.ts +2 -2
  94. package/tests/unit/modeling/semantics.spec.ts +146 -0
  95. package/tests/unit/models/File/constructor.spec.ts +3 -2
  96. package/tests/unit/models/File/shortcutTo.spec.ts +1 -1
@@ -0,0 +1,146 @@
1
+ import { test } from '@japa/runner'
2
+ import {
3
+ SemanticType,
4
+ SemanticScope,
5
+ isEntitySemantic,
6
+ isPropertySemantic,
7
+ isAssociationSemantic,
8
+ DataSemantics,
9
+ type EntitySemantic,
10
+ type PropertySemantic,
11
+ type AssociationSemantic,
12
+ type DataSemantic,
13
+ } from '../../../src/modeling/Semantics.js'
14
+
15
+ test.group('Semantics', () => {
16
+ test('SemanticType enum should have correct values', ({ assert }) => {
17
+ assert.equal(SemanticType.User, 'Semantic#User')
18
+ assert.equal(SemanticType.CreatedTimestamp, 'Semantic#CreatedTimestamp')
19
+ assert.equal(SemanticType.UpdatedTimestamp, 'Semantic#UpdatedTimestamp')
20
+ assert.equal(SemanticType.DeletedTimestamp, 'Semantic#DeletedTimestamp')
21
+ assert.equal(SemanticType.DeletedFlag, 'Semantic#DeletedFlag')
22
+ assert.equal(SemanticType.PublicUniqueName, 'Semantic#PublicUniqueName')
23
+ assert.equal(SemanticType.UserRole, 'Semantic#UserRole')
24
+ assert.equal(SemanticType.ResourceOwnerIdentifier, 'Semantic#ResourceOwnerIdentifier')
25
+ })
26
+
27
+ test('SemanticScope enum should have correct values', ({ assert }) => {
28
+ assert.equal(SemanticScope.Entity, 'Entity')
29
+ assert.equal(SemanticScope.Property, 'Property')
30
+ assert.equal(SemanticScope.Association, 'Association')
31
+ })
32
+
33
+ test('isEntitySemantic type guard', ({ assert }) => {
34
+ const entitySemantic: EntitySemantic = {
35
+ id: SemanticType.User,
36
+ displayName: 'User Entity',
37
+ description: 'Test',
38
+ scope: SemanticScope.Entity,
39
+ }
40
+ const propertySemantic: PropertySemantic = {
41
+ id: SemanticType.CreatedTimestamp,
42
+ displayName: 'Creation Timestamp',
43
+ description: 'Test',
44
+ scope: SemanticScope.Property,
45
+ }
46
+ const associationSemantic: AssociationSemantic = {
47
+ id: SemanticType.ResourceOwnerIdentifier,
48
+ displayName: 'Resource Owner Identifier',
49
+ description: 'Test',
50
+ scope: SemanticScope.Association,
51
+ }
52
+
53
+ assert.isTrue(isEntitySemantic(entitySemantic))
54
+ assert.isFalse(isEntitySemantic(propertySemantic))
55
+ assert.isFalse(isEntitySemantic(associationSemantic))
56
+ })
57
+
58
+ test('isPropertySemantic type guard', ({ assert }) => {
59
+ const entitySemantic: EntitySemantic = {
60
+ id: SemanticType.User,
61
+ displayName: 'User Entity',
62
+ description: 'Test',
63
+ scope: SemanticScope.Entity,
64
+ }
65
+ const propertySemantic: PropertySemantic = {
66
+ id: SemanticType.CreatedTimestamp,
67
+ displayName: 'Creation Timestamp',
68
+ description: 'Test',
69
+ scope: SemanticScope.Property,
70
+ }
71
+ const associationSemantic: AssociationSemantic = {
72
+ id: SemanticType.ResourceOwnerIdentifier,
73
+ displayName: 'Resource Owner Identifier',
74
+ description: 'Test',
75
+ scope: SemanticScope.Association,
76
+ }
77
+
78
+ assert.isFalse(isPropertySemantic(entitySemantic))
79
+ assert.isTrue(isPropertySemantic(propertySemantic))
80
+ assert.isFalse(isPropertySemantic(associationSemantic))
81
+ })
82
+
83
+ test('isAssociationSemantic type guard', ({ assert }) => {
84
+ const entitySemantic: EntitySemantic = {
85
+ id: SemanticType.User,
86
+ displayName: 'User Entity',
87
+ description: 'Test',
88
+ scope: SemanticScope.Entity,
89
+ }
90
+ const propertySemantic: PropertySemantic = {
91
+ id: SemanticType.CreatedTimestamp,
92
+ displayName: 'Creation Timestamp',
93
+ description: 'Test',
94
+ scope: SemanticScope.Property,
95
+ }
96
+ const associationSemantic: AssociationSemantic = {
97
+ id: SemanticType.ResourceOwnerIdentifier,
98
+ displayName: 'Resource Owner Identifier',
99
+ description: 'Test',
100
+ scope: SemanticScope.Association,
101
+ }
102
+
103
+ assert.isFalse(isAssociationSemantic(entitySemantic))
104
+ assert.isFalse(isAssociationSemantic(propertySemantic))
105
+ assert.isTrue(isAssociationSemantic(associationSemantic))
106
+ })
107
+
108
+ test('DataSemantics should contain correct definitions', ({ assert }) => {
109
+ const semanticTypes = Object.values(SemanticType)
110
+ semanticTypes.forEach((type) => {
111
+ const semantic: DataSemantic | undefined = DataSemantics[type]
112
+ assert.isDefined(semantic, `Semantic definition for ${type} should exist`)
113
+ if (!semantic) return
114
+
115
+ assert.equal(semantic.id, type, `ID for ${type} should match`)
116
+ assert.isString(semantic.displayName, `displayName for ${type} should be a string`)
117
+ assert.isNotEmpty(semantic.displayName, `displayName for ${type} should not be empty`)
118
+ assert.isString(semantic.description, `description for ${type} should be a string`)
119
+ assert.isNotEmpty(semantic.description, `description for ${type} should not be empty`)
120
+
121
+ assert.oneOf(semantic.scope, Object.values(SemanticScope), `scope for ${type} should be a valid SemanticScope`)
122
+
123
+ if (isPropertySemantic(semantic)) {
124
+ if (semantic.applicableDataTypes) {
125
+ assert.isArray(semantic.applicableDataTypes, `applicableDataTypes for ${type} should be an array if present`)
126
+ semantic.applicableDataTypes.forEach((dt) => {
127
+ assert.isString(dt, `Each applicableDataType for ${type} should be a string`)
128
+ })
129
+ }
130
+ }
131
+ })
132
+
133
+ // Specific checks for some semantics
134
+ const userSemantic = DataSemantics[SemanticType.User]
135
+ assert.equal(userSemantic.scope, SemanticScope.Entity)
136
+
137
+ const createdTimestampSemantic = DataSemantics[SemanticType.CreatedTimestamp]
138
+ assert.equal(createdTimestampSemantic.scope, SemanticScope.Property)
139
+ if (isPropertySemantic(createdTimestampSemantic)) {
140
+ assert.deepEqual(createdTimestampSemantic.applicableDataTypes, ['datetime'])
141
+ }
142
+
143
+ const resourceOwnerSemantic = DataSemantics[SemanticType.ResourceOwnerIdentifier]
144
+ assert.equal(resourceOwnerSemantic.scope, SemanticScope.Association)
145
+ })
146
+ })
@@ -5,8 +5,9 @@ test.group('File.constructor()', () => {
5
5
  test('creates a default File', ({ assert }) => {
6
6
  const result = new File()
7
7
  assert.equal(result.kind, '')
8
- assert.equal(result.key, '')
9
- assert.deepEqual(result.info.toJSON(), { kind: ThingKind, name: '' })
8
+ assert.isString(result.key, 'has the key')
9
+ assert.isNotEmpty(result.key, 'key is not empty')
10
+ assert.deepEqual(result.info.toJSON(), { kind: ThingKind, name: 'Unnamed file' })
10
11
  assert.deepEqual(result.parents, [])
11
12
  assert.deepEqual(result.permissionIds, [])
12
13
  assert.isFalse(result.deleted, 'deleted')
@@ -46,7 +46,7 @@ test.group('File.shortcutTo()', () => {
46
46
  })
47
47
 
48
48
  test('creates a shortcut from a name with fromName()', ({ assert }) => {
49
- const file = File.fromName('test-file')
49
+ const file = File.fromName('test-file', 'shortcut')
50
50
  const targetId = 'target-file-id'
51
51
  file.shortcutTo(targetId)
52
52
  assert.equal(file.shortcutTarget, targetId)