@api-client/core 0.19.5 → 0.19.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.
@@ -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.19.5",
4
+ "version": "0.19.7",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -542,6 +542,17 @@ export class DomainProperty extends DomainElement {
542
542
  return object.schema as PropertyWebBindings
543
543
  }
544
544
 
545
+ /**
546
+ * Reads the web binding definition, if any.
547
+ * Useful for reading binding data without mutating the model when the binding
548
+ * is missing (unlike `getWebBinding()` which creates the binding when missing).
549
+ * @returns The web binding definition, if any
550
+ */
551
+ readWebBinding(): PropertyWebBindings | undefined {
552
+ const object = this.bindings.find((i) => i.type === 'web') as PropertyBinding | undefined
553
+ return object?.schema as PropertyWebBindings | undefined
554
+ }
555
+
545
556
  /**
546
557
  * Returns the schema value of the binding, if any was created.
547
558
  * @param type The type of the binding to read.
@@ -9,6 +9,18 @@ const SemanticSchema = {
9
9
  required: ['id'],
10
10
  }
11
11
 
12
+ const AssociationTarget = {
13
+ type: Type.OBJECT,
14
+ properties: {
15
+ key: { type: Type.STRING, description: 'The key of the target entity.' },
16
+ domain: {
17
+ type: Type.STRING,
18
+ description: 'The key of the target data domain. Only set when the target is in a different data domain.',
19
+ },
20
+ },
21
+ required: ['key'],
22
+ }
23
+
12
24
  const SchemaDefaultValue = {
13
25
  type: Type.OBJECT,
14
26
  properties: {
@@ -27,28 +39,28 @@ const SchemaDefaultValue = {
27
39
  const PropertySchemaShape = {
28
40
  type: Type.OBJECT,
29
41
  properties: {
30
- minimum: { type: Type.NUMBER },
31
- maximum: { type: Type.NUMBER },
32
- exclusiveMinimum: { type: Type.BOOLEAN },
33
- exclusiveMaximum: { type: Type.BOOLEAN },
34
- multipleOf: { type: Type.NUMBER },
35
- enum: { type: Type.ARRAY, items: { type: Type.STRING } },
36
- examples: { type: Type.ARRAY, items: { type: Type.STRING } },
37
- defaultValue: SchemaDefaultValue,
38
- pattern: { type: Type.STRING },
42
+ minimum: { type: Type.NUMBER, nullable: true },
43
+ maximum: { type: Type.NUMBER, nullable: true },
44
+ exclusiveMinimum: { type: Type.BOOLEAN, nullable: true },
45
+ exclusiveMaximum: { type: Type.BOOLEAN, nullable: true },
46
+ multipleOf: { type: Type.NUMBER, nullable: true },
47
+ enum: { type: Type.ARRAY, items: { type: Type.STRING }, nullable: true },
48
+ examples: { type: Type.ARRAY, items: { type: Type.STRING }, nullable: true },
49
+ defaultValue: { ...SchemaDefaultValue, nullable: true },
50
+ pattern: { type: Type.STRING, nullable: true },
39
51
  },
40
52
  }
41
53
 
42
54
  const PropertyConstraintsSchema = {
43
55
  type: Type.OBJECT,
44
56
  properties: {
45
- required: { type: Type.BOOLEAN },
46
- unique: { type: Type.BOOLEAN },
47
- index: { type: Type.BOOLEAN },
48
- primary: { type: Type.BOOLEAN },
49
- multiple: { type: Type.BOOLEAN },
50
- readOnly: { type: Type.BOOLEAN },
51
- writeOnly: { type: Type.BOOLEAN },
57
+ required: { type: Type.BOOLEAN, nullable: true },
58
+ unique: { type: Type.BOOLEAN, nullable: true },
59
+ index: { type: Type.BOOLEAN, nullable: true },
60
+ primary: { type: Type.BOOLEAN, nullable: true },
61
+ multiple: { type: Type.BOOLEAN, nullable: true },
62
+ readOnly: { type: Type.BOOLEAN, nullable: true },
63
+ writeOnly: { type: Type.BOOLEAN, nullable: true },
52
64
  },
53
65
  }
54
66
 
@@ -74,7 +86,7 @@ const PropertySchema = {
74
86
  items: SemanticSchema,
75
87
  description: "List of semantics applied to this property. Note: ONLY use semantics with scope='property'.",
76
88
  },
77
- tags: { type: Type.ARRAY, items: { type: Type.STRING } },
89
+ tags: { type: Type.ARRAY, items: { type: Type.STRING }, nullable: true },
78
90
  },
79
91
  required: ['key', 'name', 'type', 'displayName', 'description'],
80
92
  }
@@ -97,7 +109,7 @@ const AssociationSchema = {
97
109
  name: { type: Type.STRING },
98
110
  displayName: { type: Type.STRING },
99
111
  description: { type: Type.STRING },
100
- targets: { type: Type.ARRAY, items: { type: Type.STRING }, description: 'List of target entity keys' },
112
+ targets: { type: Type.ARRAY, items: AssociationTarget },
101
113
  required: { type: Type.BOOLEAN },
102
114
  multiple: {
103
115
  type: Type.BOOLEAN,
@@ -150,6 +162,9 @@ const EntitySchema = {
150
162
  required: ['key', 'name', 'modelKey', 'displayName', 'description'],
151
163
  }
152
164
 
165
+ /**
166
+ * Allows modifying a property (not adding)
167
+ */
153
168
  const PropertyDeltaSchema = {
154
169
  type: Type.OBJECT,
155
170
  properties: {
@@ -161,9 +176,9 @@ const PropertyDeltaSchema = {
161
176
  type: Type.STRING,
162
177
  description: 'Enum: string, number, boolean, date, datetime, time, binary',
163
178
  },
164
- constraints: PropertyConstraintsSchema,
165
- deprecated: { type: Type.BOOLEAN },
166
- schema: PropertySchemaShape,
179
+ constraints: { ...PropertyConstraintsSchema, nullable: true },
180
+ deprecated: { type: Type.BOOLEAN, nullable: true },
181
+ schema: { ...PropertySchemaShape, nullable: true },
167
182
  addedSemantics: {
168
183
  type: Type.ARRAY,
169
184
  items: SemanticSchema,
@@ -182,13 +197,14 @@ const AssociationDeltaSchema = {
182
197
  name: { type: Type.STRING },
183
198
  displayName: { type: Type.STRING },
184
199
  description: { type: Type.STRING },
185
- targets: { type: Type.ARRAY, items: { type: Type.STRING } },
186
- required: { type: Type.BOOLEAN },
200
+ targets: { type: Type.ARRAY, items: AssociationTarget },
201
+ required: { type: Type.BOOLEAN, nullable: true },
187
202
  multiple: {
188
203
  type: Type.BOOLEAN,
204
+ nullable: true,
189
205
  description: 'Whether the association can have multiple targets (like User has multiple addresses)',
190
206
  },
191
- onDelete: { type: Type.STRING, description: 'Enum: restrict, cascade, setNull, doNothing' },
207
+ onDelete: { type: Type.STRING, nullable: true, description: 'Enum: restrict, cascade, setNull, doNothing' },
192
208
  addedSemantics: {
193
209
  type: Type.ARRAY,
194
210
  items: SemanticSchema,
@@ -256,7 +272,7 @@ export const DOMAIN_SCHEMA = {
256
272
  name: { type: Type.STRING },
257
273
  displayName: { type: Type.STRING },
258
274
  description: { type: Type.STRING },
259
- tags: { type: Type.ARRAY, items: { type: Type.STRING } },
275
+ tags: { type: Type.ARRAY, items: { type: Type.STRING }, nullable: true },
260
276
  addedSemantics: {
261
277
  type: Type.ARRAY,
262
278
  items: SemanticSchema,
@@ -19,13 +19,12 @@ The \`reasoning\` string in your JSON output is the presentation layer. It will
19
19
  - **Keep it Conversational:** Use simple markdown (like bullet points) to provide a friendly, easily scannable summary of what you built for them.
20
20
  - **Proactive Next Steps:** Always conclude your summary with a single, highly relevant question asking the user what they want to do next. Base this on what you just built or what might be missing.
21
21
 
22
- # REFERENTIAL INTEGRITY (NO PHANTOM KEYS)
23
- You must absolutely guarantee that every key listed in an association's \`targets\` array actually exists.
24
- - **The Target Rule:** A target key is ONLY valid if it meets one of two conditions:
25
- 1. It is the exact \`key\` of an entity you are actively creating in the \`addedEntities\` array in this exact response.
26
- 2. It is the exact \`key\` of an entity explicitly provided to you in the Current Domain context.
27
- - **ANTI-PATTERN:** Inventing a logical target key (e.g., \`resource_entity\`, \`user_id\`) that does not exist in the context or your current payload.
28
- - **Missing Targets:** If the user asks you to link to an entity that does not exist, you MUST create that missing entity in \`addedEntities\` first so you have a valid key to target.
22
+ # REFERENTIAL INTEGRITY (STRICT KEYS ONLY)
23
+ You must absolutely guarantee that you never hallucinate or invent a \`key\` for an existing object.
24
+ - **Modifications & Deletions:** When adding objects to \`modifiedModels\`, \`modifiedEntities\`, \`deletedModelKeys\`, or \`deletedEntityKeys\`, the \`key\` you use MUST be an exact match to an existing \`nanoid\` key provided to you in the Current Domain Context.
25
+ - **Association Targets:** A target key in an association is ONLY valid if it exists in the Current Domain Context, or if you are actively creating it in \`addedEntities\`.
26
+ - **ANTI-PATTERN:** Inventing a placeholder key to modify an object that you don't know the exact nanoid for.
27
+ - **Handling Missing Objects:** If the user asks you to modify an entity but it does not exist in the provided context, you MUST assume it is a brand new entity. Define its complete schema inside \`addedEntities\` instead of trying to modify a phantom key.
29
28
 
30
29
  # CREATION & DEPENDENCY LOGIC (THE TWO-PASS RULE)
31
30
  When creating multiple new entities that relate to one another, you must respect referential integrity. You cannot reference an entity in an association before it exists.
@@ -771,6 +771,44 @@ test.group('DomainProperty.readBinding()', () => {
771
771
  })
772
772
  })
773
773
 
774
+ test.group('DomainProperty.readWebBinding()', () => {
775
+ test('returns undefined if no web binding exists', ({ assert }) => {
776
+ const dataDomain = new DataDomain()
777
+ const property = new DomainProperty(dataDomain, 'test-parent')
778
+ const binding = property.readWebBinding()
779
+ assert.isUndefined(binding)
780
+ })
781
+
782
+ test('returns the web binding schema if it exists', ({ assert }) => {
783
+ const dataDomain = new DataDomain()
784
+ const property = new DomainProperty(dataDomain, 'test-parent', {
785
+ bindings: [{ type: 'web', schema: { format: 'float' } }],
786
+ })
787
+ const webBindings = property.readWebBinding()
788
+ assert.deepEqual(webBindings, { format: 'float' })
789
+ })
790
+
791
+ test('returns undefined if the web binding exists but has no schema', ({ assert }) => {
792
+ const dataDomain = new DataDomain()
793
+ const property = new DomainProperty(dataDomain, 'test-parent', {
794
+ // @ts-expect-error Testing undefined value
795
+ bindings: [{ type: 'web', schema: undefined }],
796
+ })
797
+ const webBindings = property.readWebBinding()
798
+ assert.isUndefined(webBindings)
799
+ })
800
+
801
+ test('returns undefined if the web binding exists but the schema is null', ({ assert }) => {
802
+ const dataDomain = new DataDomain()
803
+ const property = new DomainProperty(dataDomain, 'test-parent', {
804
+ // @ts-expect-error Testing null value
805
+ bindings: [{ type: 'web', schema: null }],
806
+ })
807
+ const webBindings = property.readWebBinding()
808
+ assert.isNull(webBindings)
809
+ })
810
+ })
811
+
774
812
  test.group('DomainProperty.toApiShape()', () => {
775
813
  test('returns an object', ({ assert }) => {
776
814
  const dataDomain = new DataDomain()