@api-client/core 0.18.54 → 0.18.56
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.
- package/build/src/modeling/Semantics.d.ts +32 -5
- package/build/src/modeling/Semantics.d.ts.map +1 -1
- package/build/src/modeling/Semantics.js +129 -5
- package/build/src/modeling/Semantics.js.map +1 -1
- package/build/src/modeling/definitions/Country.d.ts +38 -0
- package/build/src/modeling/definitions/Country.d.ts.map +1 -0
- package/build/src/modeling/definitions/Country.js +22 -0
- package/build/src/modeling/definitions/Country.js.map +1 -0
- package/build/src/modeling/definitions/PostalCode.d.ts +48 -0
- package/build/src/modeling/definitions/PostalCode.d.ts.map +1 -0
- package/build/src/modeling/definitions/PostalCode.js +22 -0
- package/build/src/modeling/definitions/PostalCode.js.map +1 -0
- package/build/src/modeling/helpers/Intelisense.d.ts +5 -0
- package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
- package/build/src/modeling/helpers/Intelisense.js +90 -0
- package/build/src/modeling/helpers/Intelisense.js.map +1 -1
- package/build/src/modeling/templates/verticals/business-services/ecommerce-domain.d.ts.map +1 -1
- package/build/src/modeling/templates/verticals/business-services/ecommerce-domain.js +10 -0
- package/build/src/modeling/templates/verticals/business-services/ecommerce-domain.js.map +1 -1
- package/build/src/modeling/templates/verticals/business-services/financial-services-domain.d.ts.map +1 -1
- package/build/src/modeling/templates/verticals/business-services/financial-services-domain.js +14 -2
- package/build/src/modeling/templates/verticals/business-services/financial-services-domain.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +6 -6
- package/package.json +1 -1
- package/src/modeling/Semantics.ts +132 -5
- package/src/modeling/definitions/Country.ts +62 -0
- package/src/modeling/definitions/PostalCode.ts +70 -0
- package/src/modeling/helpers/Intelisense.ts +95 -0
- package/src/modeling/templates/verticals/business-services/ecommerce-domain.ts +10 -0
- package/src/modeling/templates/verticals/business-services/financial-services-domain.ts +15 -2
- package/tests/unit/modeling/helpers/intellisense.spec.ts +209 -0
|
@@ -34,8 +34,15 @@ import {
|
|
|
34
34
|
addRecommendedFields,
|
|
35
35
|
addDisplayNameField,
|
|
36
36
|
addRoleField,
|
|
37
|
+
addCountryField,
|
|
38
|
+
addPostalCodeField,
|
|
39
|
+
addStreetAddressField,
|
|
40
|
+
addCityField,
|
|
41
|
+
addRegionField,
|
|
37
42
|
} from '../../../../src/modeling/helpers/Intelisense.js'
|
|
38
43
|
import { SemanticType } from '../../../../src/modeling/Semantics.js'
|
|
44
|
+
import { createCountrySemantic } from '../../../../src/modeling/definitions/Country.js'
|
|
45
|
+
import { createPostalCodeSemantic } from '../../../../src/modeling/definitions/PostalCode.js'
|
|
39
46
|
|
|
40
47
|
function createTestEntity(): DomainEntity {
|
|
41
48
|
const domain = new DataDomain({ key: 'test-domain', info: { name: 'Test Domain' } })
|
|
@@ -261,6 +268,46 @@ test.group('addAutoField()', () => {
|
|
|
261
268
|
assert.equal(field.type, 'number')
|
|
262
269
|
assert.isTrue(field.required)
|
|
263
270
|
})
|
|
271
|
+
|
|
272
|
+
test('adds street address field when autoField is "street-address"', ({ assert }) => {
|
|
273
|
+
const entity = createTestEntity()
|
|
274
|
+
const field = addAutoField(entity, 'street-address') as DomainProperty
|
|
275
|
+
assert.instanceOf(field, DomainProperty)
|
|
276
|
+
assert.equal(field.info.name, 'street_address')
|
|
277
|
+
assert.isTrue(field.hasSemantic(SemanticType.StreetAddress))
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
test('adds city field when autoField is "city"', ({ assert }) => {
|
|
281
|
+
const entity = createTestEntity()
|
|
282
|
+
const field = addAutoField(entity, 'city') as DomainProperty
|
|
283
|
+
assert.instanceOf(field, DomainProperty)
|
|
284
|
+
assert.equal(field.info.name, 'city')
|
|
285
|
+
assert.isTrue(field.hasSemantic(SemanticType.City))
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
test('adds postal code field when autoField is "postal-code"', ({ assert }) => {
|
|
289
|
+
const entity = createTestEntity()
|
|
290
|
+
const field = addAutoField(entity, 'postal-code') as DomainProperty
|
|
291
|
+
assert.instanceOf(field, DomainProperty)
|
|
292
|
+
assert.equal(field.info.name, 'postal_code')
|
|
293
|
+
assert.isTrue(field.hasSemantic(SemanticType.PostalCode))
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
test('adds country field when autoField is "country"', ({ assert }) => {
|
|
297
|
+
const entity = createTestEntity()
|
|
298
|
+
const field = addAutoField(entity, 'country') as DomainProperty
|
|
299
|
+
assert.instanceOf(field, DomainProperty)
|
|
300
|
+
assert.equal(field.info.name, 'country')
|
|
301
|
+
assert.isTrue(field.hasSemantic(SemanticType.Country))
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
test('adds region field when autoField is "region"', ({ assert }) => {
|
|
305
|
+
const entity = createTestEntity()
|
|
306
|
+
const field = addAutoField(entity, 'region') as DomainProperty
|
|
307
|
+
assert.instanceOf(field, DomainProperty)
|
|
308
|
+
assert.equal(field.info.name, 'region')
|
|
309
|
+
assert.isTrue(field.hasSemantic(SemanticType.Region))
|
|
310
|
+
})
|
|
264
311
|
})
|
|
265
312
|
|
|
266
313
|
test.group('addIdField()', () => {
|
|
@@ -1028,3 +1075,165 @@ test.group('addRecommendedFields()', () => {
|
|
|
1028
1075
|
assert.isAtLeast([...entity.properties].length, initialFieldCount + 1)
|
|
1029
1076
|
})
|
|
1030
1077
|
})
|
|
1078
|
+
|
|
1079
|
+
test.group('addCountryField()', () => {
|
|
1080
|
+
test('creates new country field when none exists', ({ assert }) => {
|
|
1081
|
+
const entity = createTestEntity()
|
|
1082
|
+
const field = addCountryField(entity) as DomainProperty
|
|
1083
|
+
assert.instanceOf(field, DomainProperty)
|
|
1084
|
+
assert.equal(field.info.name, 'country')
|
|
1085
|
+
assert.equal(field.type, 'string')
|
|
1086
|
+
assert.isTrue(field.required)
|
|
1087
|
+
assert.isTrue(field.index)
|
|
1088
|
+
assert.isTrue(field.semantics.length > 0)
|
|
1089
|
+
})
|
|
1090
|
+
|
|
1091
|
+
test('returns existing country field when one exists', ({ assert }) => {
|
|
1092
|
+
const entity = createTestEntity()
|
|
1093
|
+
const existingField = entity.addProperty({
|
|
1094
|
+
info: { name: 'country', displayName: 'Country' },
|
|
1095
|
+
type: 'string',
|
|
1096
|
+
semantics: [createCountrySemantic()],
|
|
1097
|
+
})
|
|
1098
|
+
const field = addCountryField(entity)
|
|
1099
|
+
assert.equal(field, existingField)
|
|
1100
|
+
})
|
|
1101
|
+
|
|
1102
|
+
test('merges custom info with defaults', ({ assert }) => {
|
|
1103
|
+
const entity = createTestEntity()
|
|
1104
|
+
const field = addCountryField(entity, { description: 'Country code' }) as DomainProperty
|
|
1105
|
+
assert.equal(field.info.name, 'country')
|
|
1106
|
+
assert.equal(field.info.displayName, 'Country')
|
|
1107
|
+
assert.equal(field.info.description, 'Country code')
|
|
1108
|
+
})
|
|
1109
|
+
})
|
|
1110
|
+
|
|
1111
|
+
test.group('addPostalCodeField()', () => {
|
|
1112
|
+
test('creates new postal code field when none exists', ({ assert }) => {
|
|
1113
|
+
const entity = createTestEntity()
|
|
1114
|
+
const field = addPostalCodeField(entity) as DomainProperty
|
|
1115
|
+
assert.instanceOf(field, DomainProperty)
|
|
1116
|
+
assert.equal(field.info.name, 'postal_code')
|
|
1117
|
+
assert.equal(field.info.displayName, 'Postal Code')
|
|
1118
|
+
assert.equal(field.type, 'string')
|
|
1119
|
+
assert.isTrue(field.required)
|
|
1120
|
+
assert.isTrue(field.index)
|
|
1121
|
+
assert.isTrue(field.semantics.length > 0)
|
|
1122
|
+
})
|
|
1123
|
+
|
|
1124
|
+
test('returns existing postal code field when one exists', ({ assert }) => {
|
|
1125
|
+
const entity = createTestEntity()
|
|
1126
|
+
const existingField = entity.addProperty({
|
|
1127
|
+
info: { name: 'postal_code', displayName: 'Postal Code' },
|
|
1128
|
+
type: 'string',
|
|
1129
|
+
semantics: [createPostalCodeSemantic()],
|
|
1130
|
+
})
|
|
1131
|
+
const field = addPostalCodeField(entity)
|
|
1132
|
+
assert.equal(field, existingField)
|
|
1133
|
+
})
|
|
1134
|
+
|
|
1135
|
+
test('merges custom info with defaults', ({ assert }) => {
|
|
1136
|
+
const entity = createTestEntity()
|
|
1137
|
+
const field = addPostalCodeField(entity, { description: 'ZIP code' }) as DomainProperty
|
|
1138
|
+
assert.equal(field.info.name, 'postal_code')
|
|
1139
|
+
assert.equal(field.info.displayName, 'Postal Code')
|
|
1140
|
+
assert.equal(field.info.description, 'ZIP code')
|
|
1141
|
+
})
|
|
1142
|
+
})
|
|
1143
|
+
|
|
1144
|
+
test.group('addStreetAddressField()', () => {
|
|
1145
|
+
test('creates new street address field when none exists', ({ assert }) => {
|
|
1146
|
+
const entity = createTestEntity()
|
|
1147
|
+
const field = addStreetAddressField(entity) as DomainProperty
|
|
1148
|
+
assert.instanceOf(field, DomainProperty)
|
|
1149
|
+
assert.equal(field.info.name, 'street_address')
|
|
1150
|
+
assert.equal(field.info.displayName, 'Street Address')
|
|
1151
|
+
assert.equal(field.type, 'string')
|
|
1152
|
+
assert.isTrue(field.required)
|
|
1153
|
+
assert.isTrue(field.semantics.length > 0)
|
|
1154
|
+
})
|
|
1155
|
+
|
|
1156
|
+
test('returns existing street address field when one exists', ({ assert }) => {
|
|
1157
|
+
const entity = createTestEntity()
|
|
1158
|
+
const existingField = entity.addProperty({
|
|
1159
|
+
info: { name: 'street_address', displayName: 'Street Address' },
|
|
1160
|
+
type: 'string',
|
|
1161
|
+
semantics: [{ id: SemanticType.StreetAddress }],
|
|
1162
|
+
})
|
|
1163
|
+
const field = addStreetAddressField(entity)
|
|
1164
|
+
assert.equal(field, existingField)
|
|
1165
|
+
})
|
|
1166
|
+
|
|
1167
|
+
test('merges custom info with defaults', ({ assert }) => {
|
|
1168
|
+
const entity = createTestEntity()
|
|
1169
|
+
const field = addStreetAddressField(entity, { description: 'Street address XXX' }) as DomainProperty
|
|
1170
|
+
assert.equal(field.info.name, 'street_address')
|
|
1171
|
+
assert.equal(field.info.displayName, 'Street Address')
|
|
1172
|
+
assert.equal(field.info.description, 'Street address XXX')
|
|
1173
|
+
})
|
|
1174
|
+
})
|
|
1175
|
+
|
|
1176
|
+
test.group('addCityField()', () => {
|
|
1177
|
+
test('creates new city field when none exists', ({ assert }) => {
|
|
1178
|
+
const entity = createTestEntity()
|
|
1179
|
+
const field = addCityField(entity) as DomainProperty
|
|
1180
|
+
assert.instanceOf(field, DomainProperty)
|
|
1181
|
+
assert.equal(field.info.name, 'city')
|
|
1182
|
+
assert.equal(field.info.displayName, 'City')
|
|
1183
|
+
assert.equal(field.type, 'string')
|
|
1184
|
+
assert.isTrue(field.required)
|
|
1185
|
+
assert.isTrue(field.index)
|
|
1186
|
+
assert.isTrue(field.semantics.length > 0)
|
|
1187
|
+
})
|
|
1188
|
+
|
|
1189
|
+
test('returns existing city field when one exists', ({ assert }) => {
|
|
1190
|
+
const entity = createTestEntity()
|
|
1191
|
+
const existingField = entity.addProperty({
|
|
1192
|
+
info: { name: 'city', displayName: 'City' },
|
|
1193
|
+
type: 'string',
|
|
1194
|
+
semantics: [{ id: SemanticType.City }],
|
|
1195
|
+
})
|
|
1196
|
+
const field = addCityField(entity)
|
|
1197
|
+
assert.equal(field, existingField)
|
|
1198
|
+
})
|
|
1199
|
+
|
|
1200
|
+
test('merges custom info with defaults', ({ assert }) => {
|
|
1201
|
+
const entity = createTestEntity()
|
|
1202
|
+
const field = addCityField(entity, { description: 'City XXX' }) as DomainProperty
|
|
1203
|
+
assert.equal(field.info.name, 'city')
|
|
1204
|
+
assert.equal(field.info.displayName, 'City')
|
|
1205
|
+
assert.equal(field.info.description, 'City XXX')
|
|
1206
|
+
})
|
|
1207
|
+
})
|
|
1208
|
+
|
|
1209
|
+
test.group('addRegionField()', () => {
|
|
1210
|
+
test('creates new region field when none exists', ({ assert }) => {
|
|
1211
|
+
const entity = createTestEntity()
|
|
1212
|
+
const field = addRegionField(entity) as DomainProperty
|
|
1213
|
+
assert.instanceOf(field, DomainProperty)
|
|
1214
|
+
assert.equal(field.info.name, 'region')
|
|
1215
|
+
assert.equal(field.info.displayName, 'Region')
|
|
1216
|
+
assert.equal(field.type, 'string')
|
|
1217
|
+
assert.isTrue(field.index)
|
|
1218
|
+
assert.isTrue(field.semantics.length > 0)
|
|
1219
|
+
})
|
|
1220
|
+
|
|
1221
|
+
test('returns existing region field when one exists', ({ assert }) => {
|
|
1222
|
+
const entity = createTestEntity()
|
|
1223
|
+
const existingField = entity.addProperty({
|
|
1224
|
+
info: { name: 'region', displayName: 'Region' },
|
|
1225
|
+
type: 'string',
|
|
1226
|
+
semantics: [{ id: SemanticType.Region }],
|
|
1227
|
+
})
|
|
1228
|
+
const field = addRegionField(entity)
|
|
1229
|
+
assert.equal(field, existingField)
|
|
1230
|
+
})
|
|
1231
|
+
|
|
1232
|
+
test('merges custom info with defaults', ({ assert }) => {
|
|
1233
|
+
const entity = createTestEntity()
|
|
1234
|
+
const field = addRegionField(entity, { description: 'Region XXX' }) as DomainProperty
|
|
1235
|
+
assert.equal(field.info.name, 'region')
|
|
1236
|
+
assert.equal(field.info.displayName, 'Region')
|
|
1237
|
+
assert.equal(field.info.description, 'Region XXX')
|
|
1238
|
+
})
|
|
1239
|
+
})
|