@api-client/core 0.18.62 → 0.18.64

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 (80) hide show
  1. package/API_MODELING_EXPLAINER.md +57 -0
  2. package/DATA_MODELING_EXPLAINER.md +74 -0
  3. package/build/src/modeling/DataDomain.d.ts +6 -5
  4. package/build/src/modeling/DataDomain.d.ts.map +1 -1
  5. package/build/src/modeling/DataDomain.js +5 -4
  6. package/build/src/modeling/DataDomain.js.map +1 -1
  7. package/build/src/modeling/DomainAssociation.js +1 -1
  8. package/build/src/modeling/DomainAssociation.js.map +1 -1
  9. package/build/src/modeling/DomainEntity.d.ts +9 -6
  10. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  11. package/build/src/modeling/DomainEntity.js +34 -18
  12. package/build/src/modeling/DomainEntity.js.map +1 -1
  13. package/build/src/modeling/ai/Semantics.d.ts +7 -0
  14. package/build/src/modeling/ai/Semantics.d.ts.map +1 -0
  15. package/build/src/modeling/ai/Semantics.js +552 -0
  16. package/build/src/modeling/ai/Semantics.js.map +1 -0
  17. package/build/src/modeling/definitions/Calculated.d.ts +1 -1
  18. package/build/src/modeling/definitions/Calculated.js.map +1 -1
  19. package/build/src/modeling/definitions/Country.d.ts +1 -1
  20. package/build/src/modeling/definitions/Country.js.map +1 -1
  21. package/build/src/modeling/definitions/Derived.d.ts +1 -1
  22. package/build/src/modeling/definitions/Derived.js.map +1 -1
  23. package/build/src/modeling/definitions/Description.d.ts +0 -1
  24. package/build/src/modeling/definitions/Description.d.ts.map +1 -1
  25. package/build/src/modeling/definitions/Description.js.map +1 -1
  26. package/build/src/modeling/definitions/Email.d.ts +5 -1
  27. package/build/src/modeling/definitions/Email.d.ts.map +1 -1
  28. package/build/src/modeling/definitions/Email.js.map +1 -1
  29. package/build/src/modeling/definitions/HTML.d.ts +0 -22
  30. package/build/src/modeling/definitions/HTML.d.ts.map +1 -1
  31. package/build/src/modeling/definitions/HTML.js +0 -1
  32. package/build/src/modeling/definitions/HTML.js.map +1 -1
  33. package/build/src/modeling/definitions/Markdown.d.ts +0 -16
  34. package/build/src/modeling/definitions/Markdown.d.ts.map +1 -1
  35. package/build/src/modeling/definitions/Markdown.js +0 -1
  36. package/build/src/modeling/definitions/Markdown.js.map +1 -1
  37. package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
  38. package/build/src/modeling/helpers/Intelisense.js +2 -2
  39. package/build/src/modeling/helpers/Intelisense.js.map +1 -1
  40. package/build/src/modeling/importers/JsonSchemaImporter.js +1 -1
  41. package/build/src/modeling/importers/JsonSchemaImporter.js.map +1 -1
  42. package/build/src/modeling/types.d.ts +0 -14
  43. package/build/src/modeling/types.d.ts.map +1 -1
  44. package/build/src/modeling/types.js.map +1 -1
  45. package/build/tsconfig.tsbuildinfo +1 -1
  46. package/data/models/example-generator-api.json +15 -15
  47. package/package.json +4 -4
  48. package/src/modeling/DataDomain.ts +6 -6
  49. package/src/modeling/DomainAssociation.ts +1 -1
  50. package/src/modeling/DomainEntity.ts +36 -18
  51. package/src/modeling/ai/Semantics.ts +597 -0
  52. package/src/modeling/ai/readme.md +7 -0
  53. package/src/modeling/definitions/Calculated.ts +1 -1
  54. package/src/modeling/definitions/Country.ts +1 -1
  55. package/src/modeling/definitions/Derived.ts +1 -1
  56. package/src/modeling/definitions/Description.ts +0 -1
  57. package/src/modeling/definitions/Email.ts +5 -1
  58. package/src/modeling/definitions/HTML.ts +0 -23
  59. package/src/modeling/definitions/Markdown.ts +0 -17
  60. package/src/modeling/helpers/Intelisense.ts +8 -14
  61. package/src/modeling/importers/JsonSchemaImporter.ts +1 -1
  62. package/src/modeling/types.ts +0 -15
  63. package/tests/unit/modeling/amf/shape_generator.spec.ts +4 -4
  64. package/tests/unit/modeling/api_model_expose_entity.spec.ts +11 -11
  65. package/tests/unit/modeling/api_model_remove_entity.spec.ts +1 -1
  66. package/tests/unit/modeling/data_domain_associations.spec.ts +6 -6
  67. package/tests/unit/modeling/data_domain_foreign.spec.ts +2 -2
  68. package/tests/unit/modeling/data_domain_namespaces.spec.ts +1 -1
  69. package/tests/unit/modeling/data_domain_serialization.spec.ts +15 -15
  70. package/tests/unit/modeling/domain_asociation.spec.ts +15 -15
  71. package/tests/unit/modeling/domain_entity.spec.ts +3 -3
  72. package/tests/unit/modeling/domain_entity_associations.spec.ts +4 -4
  73. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +16 -16
  74. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +14 -14
  75. package/tests/unit/modeling/domain_property.spec.ts +1 -1
  76. package/tests/unit/modeling/domain_validation.spec.ts +3 -3
  77. package/tests/unit/modeling/domain_versioning.spec.ts +5 -5
  78. package/tests/unit/modeling/exposed_entity_setter_validation.spec.ts +1 -1
  79. package/tests/unit/modeling/validation/association_validation.spec.ts +40 -56
  80. package/tests/unit/modeling/validation/entity_validation.spec.ts +2 -2
@@ -42062,9 +42062,6 @@
42062
42062
  "@id": "#209"
42063
42063
  },
42064
42064
  {
42065
- "@id": "#206"
42066
- },
42067
- {
42068
42065
  "@id": "#191"
42069
42066
  },
42070
42067
  {
@@ -42080,6 +42077,9 @@
42080
42077
  "@id": "#203"
42081
42078
  },
42082
42079
  {
42080
+ "@id": "#206"
42081
+ },
42082
+ {
42083
42083
  "@id": "#209"
42084
42084
  }
42085
42085
  ],
@@ -43436,7 +43436,7 @@
43436
43436
  "doc:ExternalDomainElement",
43437
43437
  "doc:DomainElement"
43438
43438
  ],
43439
- "doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
43439
+ "doc:raw": "countryCode: \"BE\"\ngraydonEnterpriseId: 1057155523\nregistrationId: \"0422319093\"\nvatNumber: \"BE0422319093\"\ngraydonCompanyId: \"0422319093\"\nisBranchOffice: false\n",
43440
43440
  "core:mediaType": "application/yaml",
43441
43441
  "sourcemaps:sources": [
43442
43442
  {
@@ -43457,7 +43457,7 @@
43457
43457
  "doc:ExternalDomainElement",
43458
43458
  "doc:DomainElement"
43459
43459
  ],
43460
- "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43460
+ "doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
43461
43461
  "core:mediaType": "application/yaml",
43462
43462
  "sourcemaps:sources": [
43463
43463
  {
@@ -43478,7 +43478,7 @@
43478
43478
  "doc:ExternalDomainElement",
43479
43479
  "doc:DomainElement"
43480
43480
  ],
43481
- "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43481
+ "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43482
43482
  "core:mediaType": "application/yaml",
43483
43483
  "sourcemaps:sources": [
43484
43484
  {
@@ -43499,7 +43499,7 @@
43499
43499
  "doc:ExternalDomainElement",
43500
43500
  "doc:DomainElement"
43501
43501
  ],
43502
- "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43502
+ "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43503
43503
  "core:mediaType": "application/yaml",
43504
43504
  "sourcemaps:sources": [
43505
43505
  {
@@ -43520,7 +43520,7 @@
43520
43520
  "doc:ExternalDomainElement",
43521
43521
  "doc:DomainElement"
43522
43522
  ],
43523
- "doc:raw": "code: '7487'\ndescription: 'Financial and insurance activities'\ntype: \"PRIMARY\"\nclassificationCode: 'BE_NACEBEL2008'\nactivityGroupCode: 'ABCDE'\n",
43523
+ "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43524
43524
  "core:mediaType": "application/yaml",
43525
43525
  "sourcemaps:sources": [
43526
43526
  {
@@ -43541,7 +43541,7 @@
43541
43541
  "doc:ExternalDomainElement",
43542
43542
  "doc:DomainElement"
43543
43543
  ],
43544
- "doc:raw": "countryCode: \"BE\"\ngraydonEnterpriseId: 1057155523\nregistrationId: \"0422319093\"\nvatNumber: \"BE0422319093\"\ngraydonCompanyId: \"0422319093\"\nisBranchOffice: false\n",
43544
+ "doc:raw": "code: '7487'\ndescription: 'Financial and insurance activities'\ntype: \"PRIMARY\"\nclassificationCode: 'BE_NACEBEL2008'\nactivityGroupCode: 'ABCDE'\n",
43545
43545
  "core:mediaType": "application/yaml",
43546
43546
  "sourcemaps:sources": [
43547
43547
  {
@@ -44756,32 +44756,32 @@
44756
44756
  {
44757
44757
  "@id": "#193/source-map/lexical/element_0",
44758
44758
  "sourcemaps:element": "amf://id#193",
44759
- "sourcemaps:value": "[(1,0)-(10,0)]"
44759
+ "sourcemaps:value": "[(1,0)-(7,0)]"
44760
44760
  },
44761
44761
  {
44762
44762
  "@id": "#196/source-map/lexical/element_0",
44763
44763
  "sourcemaps:element": "amf://id#196",
44764
- "sourcemaps:value": "[(1,0)-(3,0)]"
44764
+ "sourcemaps:value": "[(1,0)-(10,0)]"
44765
44765
  },
44766
44766
  {
44767
44767
  "@id": "#199/source-map/lexical/element_0",
44768
44768
  "sourcemaps:element": "amf://id#199",
44769
- "sourcemaps:value": "[(1,0)-(5,0)]"
44769
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44770
44770
  },
44771
44771
  {
44772
44772
  "@id": "#202/source-map/lexical/element_0",
44773
44773
  "sourcemaps:element": "amf://id#202",
44774
- "sourcemaps:value": "[(1,0)-(3,0)]"
44774
+ "sourcemaps:value": "[(1,0)-(5,0)]"
44775
44775
  },
44776
44776
  {
44777
44777
  "@id": "#205/source-map/lexical/element_0",
44778
44778
  "sourcemaps:element": "amf://id#205",
44779
- "sourcemaps:value": "[(1,0)-(6,0)]"
44779
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44780
44780
  },
44781
44781
  {
44782
44782
  "@id": "#208/source-map/lexical/element_0",
44783
44783
  "sourcemaps:element": "amf://id#208",
44784
- "sourcemaps:value": "[(1,0)-(7,0)]"
44784
+ "sourcemaps:value": "[(1,0)-(6,0)]"
44785
44785
  },
44786
44786
  {
44787
44787
  "@id": "#223/source-map/lexical/element_0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.18.62",
4
+ "version": "0.18.64",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -108,7 +108,7 @@
108
108
  "devDependencies": {
109
109
  "@commitlint/cli": "^20.1.0",
110
110
  "@commitlint/config-conventional": "^20.0.0",
111
- "@eslint/js": "^9.20.0",
111
+ "@eslint/js": "^10.0.1",
112
112
  "@japa/api-client": "^3.0.3",
113
113
  "@japa/assert": "^4.0.1",
114
114
  "@japa/browser-client": "^2.1.1",
@@ -128,13 +128,13 @@
128
128
  "@web/dev-server-rollup": "^0.6.4",
129
129
  "@web/test-runner": "^0.20.0",
130
130
  "@web/test-runner-playwright": "^0.11.0",
131
- "amf-client-js": "^5.9.1-3",
131
+ "amf-client-js": "^5.10.0-0",
132
132
  "c8": "^10.1.3",
133
133
  "chai-as-promised": "^8.0.2",
134
134
  "conventional-changelog": "^7.1.0",
135
135
  "conventional-changelog-conventionalcommits": "^9.1.0",
136
136
  "cors": "^2.8.5",
137
- "eslint": "^9.20.1",
137
+ "eslint": "^10.0.1",
138
138
  "eslint-config-prettier": "^10.0.1",
139
139
  "eslint-plugin-no-only-tests": "^3.3.0",
140
140
  "eslint-plugin-prettier": "^5.2.3",
@@ -9,7 +9,6 @@ import {
9
9
  DomainPropertyKind,
10
10
  } from '../models/kinds.js'
11
11
  import type {
12
- AssociationAddOptions,
13
12
  DeserializationIssue,
14
13
  DeserializationMode,
15
14
  DomainGraphEdge,
@@ -22,7 +21,7 @@ import type {
22
21
  import { type DomainNamespaceSchema, DomainNamespace, type NamespaceOrderedItem } from './DomainNamespace.js'
23
22
  import { type DomainModelSchema, DomainModel } from './DomainModel.js'
24
23
  import { type DomainEntitySchema, DomainEntity } from './DomainEntity.js'
25
- import { DomainAssociation } from './DomainAssociation.js'
24
+ import { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'
26
25
  import { DomainProperty, DomainPropertySchema } from './DomainProperty.js'
27
26
  import { type IThing, Thing } from '../models/Thing.js'
28
27
  import { removeGraphNode } from './GraphUtils.js'
@@ -57,6 +56,7 @@ export interface DataDomainSchema extends DependentModelSchema {
57
56
  * - **Root Container:** Holds all data elements within a domain.
58
57
  * - **Graph-Based Structure:** Uses a graph to represent relationships between data elements.
59
58
  * - **Namespace Management:** Supports creating and managing namespaces to organize data models.
59
+ * Namespaces are optional.
60
60
  * - **Data Model Management:** Supports creating and managing data models to group entities.
61
61
  * - **Entity Management:** Supports creating and managing entities, which define the structure of data.
62
62
  * - **Property Management:** Supports creating and managing properties, which define the data elements
@@ -1084,17 +1084,17 @@ export class DataDomain extends DependentModel {
1084
1084
  * calls the `addAssociation` method on it.
1085
1085
  *
1086
1086
  * @param source The key of the source entity.
1087
- * @param init The association options.
1087
+ * @param input The partial association schema.
1088
1088
  * @returns The created association.
1089
1089
  * @throws Error When the source entity does not exist.
1090
1090
  * @example
1091
1091
  * ```typescript
1092
1092
  * const addressAssociation = dataDomain.addAssociation(
1093
- * 'user', { key: 'address' }
1093
+ * 'user-key', { targets: [{ key: 'address-key' }] }
1094
1094
  * );
1095
1095
  * ```
1096
1096
  */
1097
- addAssociation(source: string, init?: AssociationAddOptions): DomainAssociation {
1097
+ addAssociation(source: string, input?: Partial<DomainAssociationSchema>): DomainAssociation {
1098
1098
  if (!this.graph.hasNode(source)) {
1099
1099
  throw new Error(`Source entity ${source} not found`)
1100
1100
  }
@@ -1105,7 +1105,7 @@ export class DataDomain extends DependentModel {
1105
1105
  if (entity.domain.key !== this.key) {
1106
1106
  throw new Error(`Cannot add an association to a foreign domain`)
1107
1107
  }
1108
- return entity.addAssociation(init)
1108
+ return entity.addAssociation(input)
1109
1109
  }
1110
1110
 
1111
1111
  /**
@@ -625,7 +625,7 @@ export class DomainAssociation extends DomainElement {
625
625
  copy.info = { name: newName }
626
626
  }
627
627
 
628
- const result = parent.addAssociation({}, copy)
628
+ const result = parent.addAssociation(copy)
629
629
 
630
630
  // Copy the target entities
631
631
  for (const target of this.targets) {
@@ -8,7 +8,6 @@ import type { IShapeUnion } from '../amf/definitions/Shapes.js'
8
8
  import { DomainProperty, type DomainPropertySchema } from './DomainProperty.js'
9
9
  import { RemovePropertyException } from '../exceptions/remove_property_exception.js'
10
10
  import { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'
11
- import type { AssociationAddOptions } from './types.js'
12
11
  import type { FileBreadcrumb } from '../models/store/File.js'
13
12
  import type { DomainModel } from './DomainModel.js'
14
13
  import type { DomainNamespace } from './DomainNamespace.js'
@@ -628,35 +627,54 @@ export class DomainEntity extends DomainElement {
628
627
  /**
629
628
  * Adds an association to this entity.
630
629
  *
631
- * @param init The association options.
630
+ * Add rules:
631
+ * - If the target is specified, it has to exist in the graph.
632
+ * - The association targets can be local or foreign.
633
+ *
634
+ * Please note that you can't just add targets to the association schema.
635
+ * This function manipulates the graph to insert the required metadata.
636
+ *
632
637
  * @param input The partial association schema.
633
638
  * @returns The created `DomainAssociation` instance.
634
639
  * @throws Error When the target entity does not exist.
635
640
  * @example
636
641
  * ```typescript
637
- * const association = entity.addAssociation({
638
- * key: 'address',
639
- * });
642
+ * const association = entity.addAssociation({ info: { name: 'Address' }, targets: [{ key: 'address' }] });
640
643
  * ```
641
644
  */
642
- addAssociation(init: AssociationAddOptions = {}, input?: Partial<DomainAssociationSchema>): DomainAssociation {
645
+ addAssociation(input: Partial<DomainAssociationSchema> = {}): DomainAssociation {
643
646
  const { graph } = this.root
644
- if (init.domain && init.key) {
645
- // target is foreign
646
- const foreignKey = `${init.domain}:${init.key}`
647
- if (!graph.hasNode(foreignKey)) {
648
- throw new Error(`Foreign entity ${foreignKey} not found`)
649
- }
650
- } else if (init.key) {
651
- if (!graph.hasNode(init.key)) {
652
- throw new Error(`Target entity ${init.key} not found`)
647
+
648
+ // clean up any target information from the input
649
+ // so we won't break the graph and the app.
650
+ const inputCopy = { ...input }
651
+ const targets = inputCopy.targets
652
+ delete inputCopy.targets
653
+
654
+ const hasTargets = Array.isArray(targets) && targets.length
655
+ if (hasTargets) {
656
+ for (const target of targets) {
657
+ if (target.domain && target.key) {
658
+ // target is foreign
659
+ const foreignKey = `${target.domain}:${target.key}`
660
+ if (!graph.hasNode(foreignKey)) {
661
+ throw new Error(`Foreign entity ${foreignKey} not found`)
662
+ }
663
+ } else if (target.key) {
664
+ if (!graph.hasNode(target.key)) {
665
+ throw new Error(`Target entity ${target.key} not found`)
666
+ }
667
+ }
653
668
  }
654
669
  }
655
- const item = new DomainAssociation(this.root, this.key, input)
670
+
671
+ const item = new DomainAssociation(this.root, this.key, inputCopy)
656
672
  graph.setNode(item.key, item)
657
673
  graph.setEdge(this.key, item.key, { type: 'association' })
658
- if (init.key) {
659
- item.addTarget(init.key, init.domain)
674
+ if (hasTargets) {
675
+ for (const target of targets) {
676
+ item.addTarget(target.key, target.domain)
677
+ }
660
678
  }
661
679
  this.fields.push({ type: 'association', key: item.key })
662
680
  this.root.notifyChange()