@api-client/core 0.20.6 → 0.20.7

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/build/src/modeling/ExposedEntity.d.ts.map +1 -1
  2. package/build/src/modeling/ExposedEntity.js +55 -4
  3. package/build/src/modeling/ExposedEntity.js.map +1 -1
  4. package/build/src/modeling/RuntimeApiModel.d.ts.map +1 -1
  5. package/build/src/modeling/RuntimeApiModel.js +6 -2
  6. package/build/src/modeling/RuntimeApiModel.js.map +1 -1
  7. package/build/src/modeling/generators/RuntimeModelGenerator.d.ts +15 -0
  8. package/build/src/modeling/generators/RuntimeModelGenerator.d.ts.map +1 -0
  9. package/build/src/modeling/generators/RuntimeModelGenerator.js +78 -0
  10. package/build/src/modeling/generators/RuntimeModelGenerator.js.map +1 -0
  11. package/build/src/modeling/helpers/endpointHelpers.d.ts +6 -1
  12. package/build/src/modeling/helpers/endpointHelpers.d.ts.map +1 -1
  13. package/build/src/modeling/helpers/endpointHelpers.js +43 -4
  14. package/build/src/modeling/helpers/endpointHelpers.js.map +1 -1
  15. package/build/src/modeling/validation/api_model_rules.d.ts.map +1 -1
  16. package/build/src/modeling/validation/api_model_rules.js +17 -0
  17. package/build/src/modeling/validation/api_model_rules.js.map +1 -1
  18. package/build/tsconfig.tsbuildinfo +1 -1
  19. package/package.json +3 -3
  20. package/src/modeling/ExposedEntity.ts +62 -4
  21. package/src/modeling/RuntimeApiModel.ts +7 -2
  22. package/src/modeling/generators/RuntimeModelGenerator.ts +79 -0
  23. package/src/modeling/helpers/endpointHelpers.ts +51 -4
  24. package/src/modeling/validation/api_model_rules.ts +19 -0
  25. package/tests/unit/modeling/RuntimeApiModel.spec.ts +17 -3
  26. package/tests/unit/modeling/exposed_entity.spec.ts +95 -0
  27. package/tests/unit/modeling/generators/RuntimeModelGenerator.spec.ts +192 -0
  28. package/tests/unit/modeling/helpers/endpointHelpers.spec.ts +10 -3
  29. package/tests/unit/modeling/validation/api_model_rules.spec.ts +35 -0
@@ -249,6 +249,41 @@ test.group('ApiModel Validation', () => {
249
249
  assert.isTrue(issues.some((i) => i.code === 'EXPOSURE_INVALID_RESOURCE_PATH_FORMAT'))
250
250
  })
251
251
 
252
+ test('validateExposedEntity - catches duplicate path parameters in branch', ({ assert }) => {
253
+ const domain = new DataDomain({ info: { version: '1.0.0' } })
254
+ const model = new ApiModel({}, domain)
255
+
256
+ // Parent exposure with parameter {id}
257
+ const parentExposure = new ExposedEntity(model, {
258
+ key: 'parent',
259
+ entity: { key: 'fakeParent' },
260
+ hasCollection: true,
261
+ collectionPath: '/parents',
262
+ resourcePath: '/parents/{id}',
263
+ isRoot: true,
264
+ actions: [],
265
+ })
266
+
267
+ // Child exposure with the same parameter {id}
268
+ const childExposure = new ExposedEntity(model, {
269
+ key: 'child',
270
+ entity: { key: 'fakeChild' },
271
+ hasCollection: true,
272
+ collectionPath: '/children',
273
+ resourcePath: '/children/{id}',
274
+ parent: { key: 'parent', association: { key: 'toChildren' } },
275
+ actions: [],
276
+ })
277
+
278
+ model.exposes = new Map([
279
+ [parentExposure.key, parentExposure],
280
+ [childExposure.key, childExposure],
281
+ ])
282
+
283
+ const issues = validateExposedEntity(childExposure, model)
284
+ assert.isTrue(issues.some((i) => i.code === 'EXPOSURE_DUPLICATE_PATH_PARAMETER'))
285
+ })
286
+
252
287
  test('validateExposedEntity - List needs pagination contract', ({ assert }) => {
253
288
  const domain = new DataDomain({ info: { version: '1.0.0' } })
254
289
  const model = new ApiModel({}, domain)