@api-client/core 0.16.1 → 0.17.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.
Files changed (29) hide show
  1. package/bin/test.ts +0 -4
  2. package/build/src/index.d.ts +72 -72
  3. package/build/src/index.d.ts.map +1 -1
  4. package/build/src/index.js +3 -3
  5. package/build/src/index.js.map +1 -1
  6. package/build/src/modeling/GraphUtils.d.ts.map +1 -1
  7. package/build/src/modeling/GraphUtils.js +16 -4
  8. package/build/src/modeling/GraphUtils.js.map +1 -1
  9. package/build/src/modeling/Semantics.d.ts +52 -0
  10. package/build/src/modeling/Semantics.d.ts.map +1 -1
  11. package/build/src/modeling/Semantics.js +206 -97
  12. package/build/src/modeling/Semantics.js.map +1 -1
  13. package/build/tsconfig.tsbuildinfo +1 -1
  14. package/data/models/example-generator-api.json +12 -12
  15. package/package.json +1 -1
  16. package/src/modeling/GraphUtils.ts +15 -4
  17. package/src/modeling/Semantics.ts +226 -101
  18. package/tests/unit/modeling/api_model.spec.ts +25 -6
  19. package/tests/unit/modeling/data_domain.spec.ts +47 -47
  20. package/tests/unit/modeling/data_domain_associations.spec.ts +41 -30
  21. package/tests/unit/modeling/data_domain_change_observers.spec.ts +30 -6
  22. package/tests/unit/modeling/data_domain_entities.spec.ts +62 -62
  23. package/tests/unit/modeling/data_domain_foreign.spec.ts +59 -59
  24. package/tests/unit/modeling/data_domain_models.spec.ts +80 -82
  25. package/tests/unit/modeling/data_domain_namespaces.spec.ts +76 -76
  26. package/tests/unit/modeling/data_domain_property.spec.ts +29 -29
  27. package/tests/unit/modeling/data_domain_serialization.spec.ts +9 -9
  28. package/tests/unit/modeling/domain_asociation_targets.spec.ts +26 -26
  29. package/tests/unit/modeling/semantics.spec.ts +73 -1
@@ -2,10 +2,13 @@ import { test } from '@japa/runner'
2
2
  import {
3
3
  SemanticType,
4
4
  SemanticScope,
5
+ SemanticCategory,
5
6
  isEntitySemantic,
6
7
  isPropertySemantic,
7
8
  isAssociationSemantic,
8
9
  DataSemantics,
10
+ getSemanticsByCategory,
11
+ getSemanticsByCategoryType,
9
12
  type EntitySemantic,
10
13
  type PropertySemantic,
11
14
  type AssociationSemantic,
@@ -45,18 +48,21 @@ test.group('Semantics', () => {
45
48
  displayName: 'User Entity',
46
49
  description: 'Test',
47
50
  scope: SemanticScope.Entity,
51
+ category: SemanticCategory.Identity,
48
52
  }
49
53
  const propertySemantic: PropertySemantic = {
50
54
  id: SemanticType.CreatedTimestamp,
51
55
  displayName: 'Creation Timestamp',
52
56
  description: 'Test',
53
57
  scope: SemanticScope.Property,
58
+ category: SemanticCategory.Lifecycle,
54
59
  }
55
60
  const associationSemantic: AssociationSemantic = {
56
61
  id: SemanticType.ResourceOwnerIdentifier,
57
62
  displayName: 'Resource Owner Identifier',
58
63
  description: 'Test',
59
64
  scope: SemanticScope.Association,
65
+ category: SemanticCategory.Identity,
60
66
  }
61
67
 
62
68
  assert.isTrue(isEntitySemantic(entitySemantic))
@@ -70,18 +76,21 @@ test.group('Semantics', () => {
70
76
  displayName: 'User Entity',
71
77
  description: 'Test',
72
78
  scope: SemanticScope.Entity,
79
+ category: SemanticCategory.Identity,
73
80
  }
74
81
  const propertySemantic: PropertySemantic = {
75
82
  id: SemanticType.CreatedTimestamp,
76
83
  displayName: 'Creation Timestamp',
77
84
  description: 'Test',
78
85
  scope: SemanticScope.Property,
86
+ category: SemanticCategory.Lifecycle,
79
87
  }
80
88
  const associationSemantic: AssociationSemantic = {
81
89
  id: SemanticType.ResourceOwnerIdentifier,
82
90
  displayName: 'Resource Owner Identifier',
83
91
  description: 'Test',
84
92
  scope: SemanticScope.Association,
93
+ category: SemanticCategory.Identity,
85
94
  }
86
95
 
87
96
  assert.isFalse(isPropertySemantic(entitySemantic))
@@ -95,18 +104,21 @@ test.group('Semantics', () => {
95
104
  displayName: 'User Entity',
96
105
  description: 'Test',
97
106
  scope: SemanticScope.Entity,
107
+ category: SemanticCategory.Identity,
98
108
  }
99
109
  const propertySemantic: PropertySemantic = {
100
110
  id: SemanticType.CreatedTimestamp,
101
111
  displayName: 'Creation Timestamp',
102
112
  description: 'Test',
103
113
  scope: SemanticScope.Property,
114
+ category: SemanticCategory.Lifecycle,
104
115
  }
105
116
  const associationSemantic: AssociationSemantic = {
106
117
  id: SemanticType.ResourceOwnerIdentifier,
107
118
  displayName: 'Resource Owner Identifier',
108
119
  description: 'Test',
109
120
  scope: SemanticScope.Association,
121
+ category: SemanticCategory.Identity,
110
122
  }
111
123
 
112
124
  assert.isFalse(isAssociationSemantic(entitySemantic))
@@ -128,6 +140,11 @@ test.group('Semantics', () => {
128
140
  assert.isNotEmpty(semantic.description, `description for ${type} should not be empty`)
129
141
 
130
142
  assert.oneOf(semantic.scope, Object.values(SemanticScope), `scope for ${type} should be a valid SemanticScope`)
143
+ assert.oneOf(
144
+ semantic.category,
145
+ Object.values(SemanticCategory),
146
+ `category for ${type} should be a valid SemanticCategory`
147
+ )
131
148
 
132
149
  if (isPropertySemantic(semantic)) {
133
150
  if (semantic.applicableDataTypes) {
@@ -142,15 +159,18 @@ test.group('Semantics', () => {
142
159
  // Specific checks for some semantics
143
160
  const userSemantic = DataSemantics[SemanticType.User]
144
161
  assert.equal(userSemantic.scope, SemanticScope.Entity)
162
+ assert.equal(userSemantic.category, SemanticCategory.Identity)
145
163
 
146
164
  const createdTimestampSemantic = DataSemantics[SemanticType.CreatedTimestamp]
147
165
  assert.equal(createdTimestampSemantic.scope, SemanticScope.Property)
166
+ assert.equal(createdTimestampSemantic.category, SemanticCategory.Lifecycle)
148
167
  if (isPropertySemantic(createdTimestampSemantic)) {
149
168
  assert.deepEqual(createdTimestampSemantic.applicableDataTypes, ['datetime'])
150
169
  }
151
170
 
152
171
  const resourceOwnerSemantic = DataSemantics[SemanticType.ResourceOwnerIdentifier]
153
172
  assert.equal(resourceOwnerSemantic.scope, SemanticScope.Association)
173
+ assert.equal(resourceOwnerSemantic.category, SemanticCategory.Identity)
154
174
  })
155
175
 
156
176
  test('GeospatialCoordinates semantic should have correct definition', ({ assert }) => {
@@ -193,6 +213,58 @@ test.group('Semantics', () => {
193
213
  const description = geospatialSemantic.description
194
214
 
195
215
  // Check that the description mentions key features
196
- assert.equal(description, 'Annotates a field that holds geospatial coordinate data (latitude/longitude).')
216
+ assert.equal(description, 'Location coordinates')
217
+ })
218
+
219
+ test('getSemanticsByCategory should group semantics correctly', ({ assert }) => {
220
+ const semanticsByCategory = getSemanticsByCategory()
221
+
222
+ // Check that all categories are present
223
+ const expectedCategories = Object.values(SemanticCategory)
224
+ expectedCategories.forEach((category) => {
225
+ assert.isDefined(semanticsByCategory[category], `Category ${category} should be present`)
226
+ assert.isArray(semanticsByCategory[category], `Category ${category} should be an array`)
227
+ })
228
+
229
+ // Check that User semantic is in Identity category
230
+ const identitySemantics = semanticsByCategory[SemanticCategory.Identity]
231
+ const userSemantic = identitySemantics.find((s) => s.id === SemanticType.User)
232
+ assert.isDefined(userSemantic, 'User semantic should be in Identity category')
233
+
234
+ // Check that CreatedTimestamp is in Lifecycle category
235
+ const lifecycleSemantics = semanticsByCategory[SemanticCategory.Lifecycle]
236
+ const createdTimestampSemantic = lifecycleSemantics.find((s) => s.id === SemanticType.CreatedTimestamp)
237
+ assert.isDefined(createdTimestampSemantic, 'CreatedTimestamp semantic should be in Lifecycle category')
238
+
239
+ // Check that Title is in Content category
240
+ const contentSemantics = semanticsByCategory[SemanticCategory.Content]
241
+ const titleSemantic = contentSemantics.find((s) => s.id === SemanticType.Title)
242
+ assert.isDefined(titleSemantic, 'Title semantic should be in Content category')
243
+
244
+ // Verify all semantics are categorized (total count should match)
245
+ const totalSemantics = Object.values(semanticsByCategory).flat().length
246
+ const allSemantics = Object.values(DataSemantics).length
247
+ assert.equal(totalSemantics, allSemantics, 'All semantics should be categorized')
248
+ })
249
+
250
+ test('getSemanticsByCategoryType should filter semantics by category', ({ assert }) => {
251
+ const identitySemantics = getSemanticsByCategoryType(SemanticCategory.Identity)
252
+
253
+ // All returned semantics should be in Identity category
254
+ identitySemantics.forEach((semantic) => {
255
+ assert.equal(semantic.category, SemanticCategory.Identity, 'All semantics should be in Identity category')
256
+ })
257
+
258
+ // Should include User semantic
259
+ const userSemantic = identitySemantics.find((s) => s.id === SemanticType.User)
260
+ assert.isDefined(userSemantic, 'Should include User semantic')
261
+
262
+ // Should include Password semantic
263
+ const passwordSemantic = identitySemantics.find((s) => s.id === SemanticType.Password)
264
+ assert.isDefined(passwordSemantic, 'Should include Password semantic')
265
+
266
+ // Test empty result for a category with no semantics (if any)
267
+ const locationSemantics = getSemanticsByCategoryType(SemanticCategory.Location)
268
+ assert.isArray(locationSemantics, 'Should return an array even if empty')
197
269
  })
198
270
  })