@api-components/api-type-document 4.2.29 → 4.2.31
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/package.json +2 -2
- package/src/ApiTypeDocument.js +14 -6
- package/src/PropertyDocumentMixin.d.ts +10 -8
- package/src/PropertyDocumentMixin.js +65 -0
- package/src/PropertyShapeDocument.js +264 -7
- package/src/ShapeStyles.js +20 -39
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-components/api-type-document",
|
|
3
3
|
"description": "A documentation table for type (resource) properties. Works with AMF data model",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.31",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "index.js",
|
|
@@ -99,4 +99,4 @@
|
|
|
99
99
|
"eslint --fix"
|
|
100
100
|
]
|
|
101
101
|
}
|
|
102
|
-
}
|
|
102
|
+
}
|
package/src/ApiTypeDocument.js
CHANGED
|
@@ -560,9 +560,9 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
560
560
|
if (Array.isArray(item)) {
|
|
561
561
|
return item;
|
|
562
562
|
}
|
|
563
|
-
|
|
563
|
+
|
|
564
564
|
const propertyKey = this._getAmfKey(this.ns.w3.shacl.property);
|
|
565
|
-
const itemProperties = this._ensureArray(item[propertyKey])
|
|
565
|
+
const itemProperties = this._ensureArray(item[propertyKey]||[])
|
|
566
566
|
const additionalPropertiesKey = this._getAmfKey(this.ns.w3.shacl.additionalPropertiesSchema);
|
|
567
567
|
|
|
568
568
|
// If the item doesn't have additional properties, filter the read-only properties and return
|
|
@@ -571,9 +571,9 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
const additionalPropertiesSchema = this._ensureArray(item[additionalPropertiesKey])
|
|
574
|
-
|
|
574
|
+
|
|
575
575
|
// If the item does have additional properties, ensure they are in an array
|
|
576
|
-
const additionalProperties = this._ensureArray(additionalPropertiesSchema[0][propertyKey])
|
|
576
|
+
const additionalProperties = this._ensureArray(additionalPropertiesSchema[0][propertyKey] || additionalPropertiesSchema[0])
|
|
577
577
|
|
|
578
578
|
// Combine the item's properties and additional properties
|
|
579
579
|
const combinedProperties = [...itemProperties, ...additionalProperties]
|
|
@@ -819,6 +819,14 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
819
819
|
return this._multiTypeTemplate({ label, items, typeName, selected, selectTypeCallback, type });
|
|
820
820
|
}
|
|
821
821
|
|
|
822
|
+
_getItemLabel(item){
|
|
823
|
+
if(item.label==='Unknown type' && item.avroValue){
|
|
824
|
+
return item.avroValue
|
|
825
|
+
}
|
|
826
|
+
return item.label
|
|
827
|
+
|
|
828
|
+
}
|
|
829
|
+
|
|
822
830
|
/**
|
|
823
831
|
*
|
|
824
832
|
* @param {Object} args
|
|
@@ -843,8 +851,8 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
843
851
|
aria-pressed="${selected === index ? 'true' : 'false'}"
|
|
844
852
|
@click="${selectTypeCallback}"
|
|
845
853
|
?compatibility="${this.compatibility}"
|
|
846
|
-
title="Select ${item
|
|
847
|
-
>${item
|
|
854
|
+
title="Select ${this._getItemLabel(item)} type"
|
|
855
|
+
>${this._getItemLabel(item)}</anypoint-button
|
|
848
856
|
>`
|
|
849
857
|
)}
|
|
850
858
|
</div>
|
|
@@ -25,7 +25,7 @@ interface PropertyDocumentMixin extends AmfHelperMixin {
|
|
|
25
25
|
* This is used to select/generate examples according to current body
|
|
26
26
|
* media type. When not set it only renders examples that were defined
|
|
27
27
|
* in API spec file in a form as they were written.
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
29
|
* @attribute
|
|
30
30
|
*/
|
|
31
31
|
mediaType: string;
|
|
@@ -55,7 +55,7 @@ interface PropertyDocumentMixin extends AmfHelperMixin {
|
|
|
55
55
|
* @param range AMF property range object
|
|
56
56
|
* @returns Data type of the property.
|
|
57
57
|
*/
|
|
58
|
-
_computeRangeDataType(range: Object): String|undefined;
|
|
58
|
+
_computeRangeDataType(range: Object): String | undefined;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Computes type from a scalar shape.
|
|
@@ -78,7 +78,7 @@ interface PropertyDocumentMixin extends AmfHelperMixin {
|
|
|
78
78
|
* @param range Range object of current shape.
|
|
79
79
|
* @returns List of Array items.
|
|
80
80
|
*/
|
|
81
|
-
_computeArrayProperties(range: Object): ArrayPropertyItem[]|undefined;
|
|
81
|
+
_computeArrayProperties(range: Object): ArrayPropertyItem[] | undefined;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Computes value for `isUnion` property.
|
|
@@ -110,7 +110,7 @@ interface PropertyDocumentMixin extends AmfHelperMixin {
|
|
|
110
110
|
/**
|
|
111
111
|
* Computes value for `isAnyOf` property.
|
|
112
112
|
* AnyOf type is identified as a `http://www.w3.org/ns/shacl#or`
|
|
113
|
-
*
|
|
113
|
+
*
|
|
114
114
|
* @param range Range object of current shape.
|
|
115
115
|
*/
|
|
116
116
|
_computeIsAnyOf(range: Object): boolean
|
|
@@ -141,7 +141,7 @@ interface PropertyDocumentMixin extends AmfHelperMixin {
|
|
|
141
141
|
* @param items Array's items property or a single property
|
|
142
142
|
* @returns Label for the union type.
|
|
143
143
|
*/
|
|
144
|
-
_computeArrayUnionLabel(items: object|object[]): string|undefined;
|
|
144
|
+
_computeArrayUnionLabel(items: object | object[]): string | undefined;
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
147
|
* Computes name label for the shape.
|
|
@@ -150,7 +150,9 @@ interface PropertyDocumentMixin extends AmfHelperMixin {
|
|
|
150
150
|
* @param shape The shape of the property.
|
|
151
151
|
* @returns Display name of the property
|
|
152
152
|
*/
|
|
153
|
-
_computeDisplayName(range: Object, shape: Object): string|undefined;
|
|
153
|
+
_computeDisplayName(range: Object, shape: Object): string | undefined;
|
|
154
|
+
|
|
155
|
+
_computeParentName(range: Object, shape: Object): string | undefined;
|
|
154
156
|
|
|
155
157
|
_computeHasMediaType(mediaType: string): boolean;
|
|
156
158
|
|
|
@@ -159,5 +161,5 @@ interface PropertyDocumentMixin extends AmfHelperMixin {
|
|
|
159
161
|
_isPropertyReadOnly(property: any): boolean;
|
|
160
162
|
_isReadOnly(property: any): boolean;
|
|
161
163
|
}
|
|
162
|
-
export {PropertyDocumentMixinConstructor};
|
|
163
|
-
export {PropertyDocumentMixin};
|
|
164
|
+
export { PropertyDocumentMixinConstructor };
|
|
165
|
+
export { PropertyDocumentMixin };
|
|
@@ -172,6 +172,7 @@ const mxFunction = (base) => {
|
|
|
172
172
|
return 'String';
|
|
173
173
|
case this._getAmfKey(sc.integer):
|
|
174
174
|
case sc.integer:
|
|
175
|
+
case sc.int:
|
|
175
176
|
return 'Integer';
|
|
176
177
|
case this._getAmfKey(sc.long):
|
|
177
178
|
case sc.long:
|
|
@@ -205,6 +206,10 @@ const mxFunction = (base) => {
|
|
|
205
206
|
case this._getAmfKey(rs.password):
|
|
206
207
|
case rs.password:
|
|
207
208
|
return 'Password';
|
|
209
|
+
case sc.bytes:
|
|
210
|
+
return 'Bytes'
|
|
211
|
+
case sc.fixed:
|
|
212
|
+
return 'Fixed'
|
|
208
213
|
default:
|
|
209
214
|
return 'Unknown type';
|
|
210
215
|
}
|
|
@@ -356,6 +361,37 @@ const mxFunction = (base) => {
|
|
|
356
361
|
return this._hasProperty(range, this.ns.w3.shacl.and);
|
|
357
362
|
}
|
|
358
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Computes source values of the property. Only for async / avro
|
|
366
|
+
*
|
|
367
|
+
* @param {Object} data Range object of current shape.
|
|
368
|
+
*/
|
|
369
|
+
_computeAvroSourceMap(data) {
|
|
370
|
+
try{
|
|
371
|
+
const sourcesKey = this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.sources)
|
|
372
|
+
const avroSchemaKey = this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.avroSchema)
|
|
373
|
+
const valueKey = this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.value)
|
|
374
|
+
if(data[sourcesKey] && data[sourcesKey][0][avroSchemaKey]){
|
|
375
|
+
const avroValues = this._ensureArray(data[sourcesKey][0][avroSchemaKey])
|
|
376
|
+
return avroValues[0][valueKey][0]['@value']
|
|
377
|
+
}
|
|
378
|
+
return undefined
|
|
379
|
+
}catch(_){
|
|
380
|
+
return undefined
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Computes source values of the property. Only for async / avro
|
|
387
|
+
*
|
|
388
|
+
* @param {Object} data Range object of current shape.
|
|
389
|
+
* @return {Object} Size of the property
|
|
390
|
+
*/
|
|
391
|
+
_computeAvroShapeRangeSourceMap(data) {
|
|
392
|
+
return this._computeAvroSourceMap(data)
|
|
393
|
+
}
|
|
394
|
+
|
|
359
395
|
/**
|
|
360
396
|
* Computes list of type labels to render.
|
|
361
397
|
*
|
|
@@ -369,6 +405,7 @@ const mxFunction = (base) => {
|
|
|
369
405
|
return undefined;
|
|
370
406
|
}
|
|
371
407
|
return list.map((obj) => {
|
|
408
|
+
const avroValue = this._computeAvroShapeRangeSourceMap(obj) || null
|
|
372
409
|
let item = obj;
|
|
373
410
|
if (Array.isArray(item)) {
|
|
374
411
|
[item] = item;
|
|
@@ -419,6 +456,7 @@ const mxFunction = (base) => {
|
|
|
419
456
|
isArray,
|
|
420
457
|
isType,
|
|
421
458
|
label,
|
|
459
|
+
avroValue
|
|
422
460
|
};
|
|
423
461
|
});
|
|
424
462
|
}
|
|
@@ -455,6 +493,33 @@ const mxFunction = (base) => {
|
|
|
455
493
|
if (!shape || !range) {
|
|
456
494
|
return undefined;
|
|
457
495
|
}
|
|
496
|
+
|
|
497
|
+
const coreName = this.ns.aml.vocabularies.core.name;
|
|
498
|
+
const shaclName = this.ns.w3.shacl.name;
|
|
499
|
+
const parameterType = this.ns.aml.vocabularies.apiContract.Parameter;
|
|
500
|
+
const nodeShapeType = this.ns.w3.shacl.NodeShape;
|
|
501
|
+
|
|
502
|
+
// Check if the shape is of type Parameter
|
|
503
|
+
if (this._hasType(shape, parameterType)) {
|
|
504
|
+
return /** @type string */ (this._getValue(range, coreName));
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// Check if the range is of type NodeShape
|
|
508
|
+
if (this._hasType(range, nodeShapeType)) {
|
|
509
|
+
return (
|
|
510
|
+
/** @type string */ (this._getValue(range, coreName)) ||
|
|
511
|
+
/** @type string */ (this._getValue(shape, shaclName))
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// Default case: return the core name from the range
|
|
516
|
+
return /** @type string */ (this._getValue(range, coreName));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
_computeParentName(range, shape) {
|
|
520
|
+
if (!shape || !range) {
|
|
521
|
+
return undefined;
|
|
522
|
+
}
|
|
458
523
|
// let name;
|
|
459
524
|
if (
|
|
460
525
|
this._hasType(shape, this.ns.aml.vocabularies.apiContract.Parameter)
|
|
@@ -34,6 +34,31 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
34
34
|
* `displayName` was specified in the API spec for this property.
|
|
35
35
|
*/
|
|
36
36
|
propertyName: { type: String },
|
|
37
|
+
/**
|
|
38
|
+
* A type size.
|
|
39
|
+
* Is only used for async / avro api
|
|
40
|
+
*/
|
|
41
|
+
size: { type: String },
|
|
42
|
+
/**
|
|
43
|
+
* A type defaultValue.
|
|
44
|
+
* Is only used for async / avro api
|
|
45
|
+
*/
|
|
46
|
+
defaultValue: { type: String },
|
|
47
|
+
/**
|
|
48
|
+
* A type namespace.
|
|
49
|
+
* Is only used for async / avro api
|
|
50
|
+
*/
|
|
51
|
+
namespace: { type: String },
|
|
52
|
+
/**
|
|
53
|
+
* A type aliases.
|
|
54
|
+
* Is only used for async / avro api
|
|
55
|
+
*/
|
|
56
|
+
aliases: { type: Array },
|
|
57
|
+
/**
|
|
58
|
+
* Avro original value type.
|
|
59
|
+
* Is only used for async / avro api
|
|
60
|
+
*/
|
|
61
|
+
avroValue: { type: String },
|
|
37
62
|
/**
|
|
38
63
|
* Computed value, true if `displayName` has been defined for this
|
|
39
64
|
* property.
|
|
@@ -98,7 +123,7 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
98
123
|
/**
|
|
99
124
|
* A description of the shape to render.
|
|
100
125
|
*/
|
|
101
|
-
shapeDescription: { type: String },
|
|
126
|
+
shapeDescription: { type: String },
|
|
102
127
|
/**
|
|
103
128
|
* Computed value, true if description is set.
|
|
104
129
|
*/
|
|
@@ -211,6 +236,11 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
211
236
|
|
|
212
237
|
constructor() {
|
|
213
238
|
super();
|
|
239
|
+
this.avroValue = undefined
|
|
240
|
+
this.defaultValue = undefined
|
|
241
|
+
this.size = undefined
|
|
242
|
+
this.namespace = undefined
|
|
243
|
+
this.aliases = undefined
|
|
214
244
|
this.hasDisplayName = false;
|
|
215
245
|
this.hasParentTypeName = false;
|
|
216
246
|
this.hasPropertyDescription = false;
|
|
@@ -289,7 +319,15 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
289
319
|
|
|
290
320
|
_shapeRangeChanged(shape, range) {
|
|
291
321
|
this.displayName = this._computeDisplayName(range, shape);
|
|
322
|
+
this.parentName = this.isObject ? this._computeParentName(range, shape) : undefined;
|
|
292
323
|
this.propertyName = this._computePropertyName(range, shape);
|
|
324
|
+
this.avroValue = this._computeAvroShapeRangeSourceMap(range, shape)
|
|
325
|
+
const {size,namespace,aliases, defaultValue} = this._computeAvroProperties(range, shape)
|
|
326
|
+
this.size = size
|
|
327
|
+
this.namespace = namespace
|
|
328
|
+
this.aliases = aliases
|
|
329
|
+
this.defaultValue = defaultValue
|
|
330
|
+
|
|
293
331
|
this.hasDisplayName = this._computeHasDisplayName(
|
|
294
332
|
this.displayName,
|
|
295
333
|
this.propertyName
|
|
@@ -369,6 +407,118 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
369
407
|
return undefined;
|
|
370
408
|
}
|
|
371
409
|
|
|
410
|
+
/**
|
|
411
|
+
* Computes avro property. Only for async / avro
|
|
412
|
+
*
|
|
413
|
+
* @param {Object} range Range object of current shape.
|
|
414
|
+
* @param {Object} shape The shape object
|
|
415
|
+
* @return {String|undefined} Size of the property
|
|
416
|
+
*/
|
|
417
|
+
_computeAvroProperty(range, shape, prop) {
|
|
418
|
+
if (!shape && !range) {
|
|
419
|
+
return undefined;
|
|
420
|
+
}
|
|
421
|
+
let result
|
|
422
|
+
if (shape) {
|
|
423
|
+
shape = this._resolve(shape);
|
|
424
|
+
result = /** @type string */ (this._getValue(
|
|
425
|
+
shape,
|
|
426
|
+
this.ns.aml.vocabularies.shapes[prop]
|
|
427
|
+
));
|
|
428
|
+
|
|
429
|
+
}
|
|
430
|
+
if (range && !result) {
|
|
431
|
+
range = this._resolve(range);
|
|
432
|
+
result = this._getValue(range, this.ns.aml.vocabularies.shapes[prop]);
|
|
433
|
+
}
|
|
434
|
+
return result ? String(result): undefined;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Computes avro defaultValue. Only for async / avro
|
|
439
|
+
*
|
|
440
|
+
* @param {Object} range Range object of current shape.
|
|
441
|
+
* @param {Object} shape The shape object
|
|
442
|
+
* @return {String|undefined} Size of the property
|
|
443
|
+
*/
|
|
444
|
+
_computeAvroDefaultValue(range, shape) {
|
|
445
|
+
if (!shape && !range) {
|
|
446
|
+
return undefined;
|
|
447
|
+
}
|
|
448
|
+
const defaultValueKey = this.ns.w3.shacl.defaultValue
|
|
449
|
+
let result
|
|
450
|
+
if (shape) {
|
|
451
|
+
shape = this._resolve(shape);
|
|
452
|
+
if(shape[defaultValueKey]){
|
|
453
|
+
result = this._getValue(shape[defaultValueKey][0], this.ns.aml.vocabularies.data.value)
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (range && !result) {
|
|
457
|
+
range = this._resolve(range);
|
|
458
|
+
if(range[defaultValueKey]){
|
|
459
|
+
result = this._getValue(range[defaultValueKey], this.ns.aml.vocabularies.data.value)
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return result ? String(result): undefined;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Computes size of the property. Only for async / avro
|
|
467
|
+
*
|
|
468
|
+
* @param {Object} range Range object of current shape.
|
|
469
|
+
* @param {Object} shape The shape object
|
|
470
|
+
* @return {Object|undefined} Size,namespace,aliases,defaultValue of the property (only when has avroValues)
|
|
471
|
+
*/
|
|
472
|
+
_computeAvroProperties(range, shape) {
|
|
473
|
+
if(!this.avroValue){
|
|
474
|
+
return {size:undefined, namespace:undefined, aliases:undefined, defaultValue:undefined}
|
|
475
|
+
}
|
|
476
|
+
const size = this._computeAvroProperty(range,shape,"size")
|
|
477
|
+
const namespace = this._computeAvroProperty(range,shape,"namespace")
|
|
478
|
+
const aliases = this._computeAvroProperty(range,shape,"aliases")
|
|
479
|
+
const defaultValue = this._computeAvroDefaultValue(range,shape)
|
|
480
|
+
return {size, namespace, aliases, defaultValue}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Computes source values of the property. Only for async / avro
|
|
485
|
+
*
|
|
486
|
+
* @param {Object} data Range object of current shape.
|
|
487
|
+
*/
|
|
488
|
+
_computeAvroSourceMap(data) {
|
|
489
|
+
try{
|
|
490
|
+
const sourcesKey = this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.sources)
|
|
491
|
+
const avroSchemaKey = this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.avroSchema)
|
|
492
|
+
const valueKey = this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.value)
|
|
493
|
+
if(data[sourcesKey] && data[sourcesKey][0][avroSchemaKey]){
|
|
494
|
+
const avroValues = this._ensureArray(data[sourcesKey][0][avroSchemaKey])
|
|
495
|
+
return avroValues[0][valueKey][0]['@value']
|
|
496
|
+
}
|
|
497
|
+
return undefined
|
|
498
|
+
}catch(_){
|
|
499
|
+
return undefined
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Computes source values of the property. Only for async / avro
|
|
506
|
+
*
|
|
507
|
+
* @param {Object} range Range object of current shape.
|
|
508
|
+
* @param {Object} shape The shape object
|
|
509
|
+
* @return {Object} Size of the property
|
|
510
|
+
*/
|
|
511
|
+
_computeAvroShapeRangeSourceMap(range,shape) {
|
|
512
|
+
const shapeValue = this._computeAvroSourceMap(shape)
|
|
513
|
+
if(shapeValue){
|
|
514
|
+
return shapeValue
|
|
515
|
+
}
|
|
516
|
+
return this._computeAvroSourceMap(range)
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
372
522
|
/**
|
|
373
523
|
* Computes value for `hasDisplayName` property.
|
|
374
524
|
* Indicates that `displayName` has been defined in the API specification.
|
|
@@ -563,6 +713,16 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
563
713
|
return this._hasType(item, this.ns.aml.vocabularies.shapes.ScalarShape);
|
|
564
714
|
}
|
|
565
715
|
|
|
716
|
+
_getParentTypeName() {
|
|
717
|
+
if (this.isArray) {
|
|
718
|
+
return 'item'
|
|
719
|
+
}
|
|
720
|
+
if(this.isObject){
|
|
721
|
+
return this.parentName
|
|
722
|
+
}
|
|
723
|
+
return this.displayName
|
|
724
|
+
}
|
|
725
|
+
|
|
566
726
|
/**
|
|
567
727
|
* @return {TemplateResult|string} Template for a complex shape (object/array/union)
|
|
568
728
|
*/
|
|
@@ -571,7 +731,7 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
571
731
|
return '';
|
|
572
732
|
}
|
|
573
733
|
const range = this._resolve(this.range);
|
|
574
|
-
const parentTypeName = this.
|
|
734
|
+
const parentTypeName = this._getParentTypeName();
|
|
575
735
|
return html`<api-type-document
|
|
576
736
|
class="children complex"
|
|
577
737
|
.amf="${this.amf}"
|
|
@@ -588,13 +748,24 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
588
748
|
></api-type-document>`;
|
|
589
749
|
}
|
|
590
750
|
|
|
751
|
+
_getTypeLabelData(){
|
|
752
|
+
const { propertyDataType, avroValue } = this;
|
|
753
|
+
if(avroValue==='map'){
|
|
754
|
+
return {dataType:'Map',customValue:false}
|
|
755
|
+
}
|
|
756
|
+
if(propertyDataType==='Unknown type' && avroValue){
|
|
757
|
+
return {dataType:avroValue,customValue:true}
|
|
758
|
+
}
|
|
759
|
+
return {dataType:propertyDataType,customValue:false}
|
|
760
|
+
}
|
|
761
|
+
|
|
591
762
|
/**
|
|
592
763
|
* @return {TemplateResult} Template for a type name label
|
|
593
764
|
*/
|
|
594
765
|
_getTypeNameTemplate() {
|
|
595
|
-
let dataType = this.propertyDataType;
|
|
596
|
-
const id = this._targetTypeId;
|
|
597
766
|
const { isScalarArray } = this;
|
|
767
|
+
let {dataType} = this._getTypeLabelData();
|
|
768
|
+
const id = this._targetTypeId;
|
|
598
769
|
if (id) {
|
|
599
770
|
const label = this._targetTypeName;
|
|
600
771
|
return html`
|
|
@@ -613,9 +784,75 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
613
784
|
const itemType = this.arrayScalarTypeName;
|
|
614
785
|
dataType = `${dataType} of ${itemType}`;
|
|
615
786
|
}
|
|
616
|
-
return html
|
|
787
|
+
return html`
|
|
788
|
+
<span class="data-type">${dataType}</span>`;
|
|
789
|
+
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* @return {TemplateResult | String} Template size value (only for async / avro)
|
|
794
|
+
*/
|
|
795
|
+
_getFixedTypeSizeAvroTemplate() {
|
|
796
|
+
const { size } = this;
|
|
797
|
+
if(!size){
|
|
798
|
+
return ''
|
|
799
|
+
}
|
|
800
|
+
return html`
|
|
801
|
+
<div class="fixed-type-size"><span>Size: ${size}</span></div>`;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* @return {TemplateResult | String} Template size value (only for async / avro)
|
|
806
|
+
*/
|
|
807
|
+
_getCustomAvroValueTemplate() {
|
|
808
|
+
const {customValue} = this._getTypeLabelData()
|
|
809
|
+
if(!customValue){
|
|
810
|
+
return ''
|
|
811
|
+
}
|
|
812
|
+
return html`
|
|
813
|
+
<div class="fixed-type-size"><span>This is a custom Avro type. You can read the definitions for this value in the specification.</span></div>`;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* @return {TemplateResult | String} Template size value (only for async / avro)
|
|
818
|
+
*/
|
|
819
|
+
_getDefaultValueAvroTemplate() {
|
|
820
|
+
const { defaultValue } = this;
|
|
821
|
+
if(!defaultValue){
|
|
822
|
+
return ''
|
|
823
|
+
}
|
|
824
|
+
return html`
|
|
825
|
+
<div class="fixed-type-size"><span>Default Value: ${defaultValue}</span></div>`;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* @return {TemplateResult | String} Template namespace value (only for async / avro)
|
|
830
|
+
*/
|
|
831
|
+
_getTypeNamespaceAvroTemplate() {
|
|
832
|
+
const { namespace } = this;
|
|
833
|
+
if(!namespace){
|
|
834
|
+
return ''
|
|
835
|
+
}
|
|
836
|
+
return html`
|
|
837
|
+
<div class="fixed-type-size"><span>Namespace: ${namespace}</span></div>`;
|
|
617
838
|
}
|
|
618
839
|
|
|
840
|
+
/**
|
|
841
|
+
* @return {TemplateResult | String} Template namespace value (only for async / avro)
|
|
842
|
+
*/
|
|
843
|
+
_getTypeAliasesAvroTemplate() {
|
|
844
|
+
const { aliases } = this;
|
|
845
|
+
if (!aliases) {
|
|
846
|
+
return '';
|
|
847
|
+
}
|
|
848
|
+
return html`
|
|
849
|
+
<div class="fixed-type-size">
|
|
850
|
+
Aliases: ${aliases.map(alias => html`<span>${alias}</span>`)}
|
|
851
|
+
</div>
|
|
852
|
+
`;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
|
|
619
856
|
/**
|
|
620
857
|
* @return {TemplateResult|string} Template for the description
|
|
621
858
|
*/
|
|
@@ -662,8 +899,9 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
662
899
|
displayName,
|
|
663
900
|
propertyName,
|
|
664
901
|
parentTypeName,
|
|
665
|
-
hasParentTypeName
|
|
902
|
+
hasParentTypeName
|
|
666
903
|
} = this;
|
|
904
|
+
|
|
667
905
|
return html` ${hasDisplayName
|
|
668
906
|
? html`<div class="property-display-name">${displayName}</div>`
|
|
669
907
|
: ''}
|
|
@@ -684,6 +922,20 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
684
922
|
return html`<div class="deprecated-warning">Warning: Deprecated</div>`
|
|
685
923
|
}
|
|
686
924
|
|
|
925
|
+
_noNameAvroClass() {
|
|
926
|
+
const {
|
|
927
|
+
hasDisplayName,
|
|
928
|
+
propertyName,
|
|
929
|
+
isComplex,
|
|
930
|
+
avroValue,
|
|
931
|
+
_renderToggleButton
|
|
932
|
+
} = this;
|
|
933
|
+
if(!hasDisplayName && !propertyName && isComplex && avroValue && _renderToggleButton){
|
|
934
|
+
return ' no-name'
|
|
935
|
+
}
|
|
936
|
+
return ''
|
|
937
|
+
}
|
|
938
|
+
|
|
687
939
|
/**
|
|
688
940
|
* @return {TemplateResult} Main render function.
|
|
689
941
|
*/
|
|
@@ -692,7 +944,7 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
692
944
|
${this.styles}
|
|
693
945
|
</style>
|
|
694
946
|
${this._headerTemplate()}
|
|
695
|
-
<div class="property-traits">
|
|
947
|
+
<div class="property-traits${this._noNameAvroClass()}">
|
|
696
948
|
${this._getTypeNameTemplate()}
|
|
697
949
|
${this.isRequired
|
|
698
950
|
? html`<span
|
|
@@ -716,6 +968,11 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
716
968
|
>`
|
|
717
969
|
: ''}
|
|
718
970
|
</div>
|
|
971
|
+
${this._getCustomAvroValueTemplate()}
|
|
972
|
+
${this._getDefaultValueAvroTemplate()}
|
|
973
|
+
${this._getFixedTypeSizeAvroTemplate()}
|
|
974
|
+
${this._getTypeNamespaceAvroTemplate()}
|
|
975
|
+
${this._getTypeAliasesAvroTemplate()}
|
|
719
976
|
${this._deprecatedWarningTemplate()}
|
|
720
977
|
${this._descriptionTemplate()}
|
|
721
978
|
<property-range-document
|
package/src/ShapeStyles.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import { css } from
|
|
1
|
+
import { css } from "lit-element";
|
|
2
2
|
|
|
3
3
|
export default css`
|
|
4
4
|
:host {
|
|
5
5
|
display: block;
|
|
6
6
|
border-bottom-width: 1px;
|
|
7
|
-
border-bottom-color: var(
|
|
8
|
-
|
|
9
|
-
#cfd8dc
|
|
10
|
-
);
|
|
11
|
-
border-bottom-style: var(
|
|
12
|
-
--property-shape-document-border-bottom-style,
|
|
13
|
-
dashed
|
|
14
|
-
);
|
|
7
|
+
border-bottom-color: var(--property-shape-document-border-bottom-color, #cfd8dc);
|
|
8
|
+
border-bottom-style: var(--property-shape-document-border-bottom-style, dashed);
|
|
15
9
|
padding: var(--property-shape-document-padding);
|
|
16
10
|
}
|
|
17
11
|
|
|
@@ -24,27 +18,12 @@ export default css`
|
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
.property-title {
|
|
27
|
-
font-family: var(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var(--arc-font-subhead-font-size, 1rem)
|
|
34
|
-
);
|
|
35
|
-
font-weight: var(
|
|
36
|
-
--property-shape-document-title-font-weight,
|
|
37
|
-
var(--arc-font-subhead-font-weight)
|
|
38
|
-
);
|
|
39
|
-
line-height: var(
|
|
40
|
-
--property-shape-document-title-line-height,
|
|
41
|
-
var(--arc-font-subhead-line-height)
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
margin: var(
|
|
45
|
-
--property-shape-document-title-margin,
|
|
46
|
-
4px 0 4px 0
|
|
47
|
-
);
|
|
21
|
+
font-family: var(--property-shape-document-title-font-family, var(--arc-font-subhead-font-family));
|
|
22
|
+
font-size: var(--property-shape-document-title-font-size, var(--arc-font-subhead-font-size, 1rem));
|
|
23
|
+
font-weight: var(--property-shape-document-title-font-weight, var(--arc-font-subhead-font-weight));
|
|
24
|
+
line-height: var(--property-shape-document-title-line-height, var(--arc-font-subhead-line-height));
|
|
25
|
+
|
|
26
|
+
margin: var(--property-shape-document-title-margin, 4px 0 4px 0);
|
|
48
27
|
font-size: 1rem;
|
|
49
28
|
font-weight: var(--api-type-document-property-title-font-weight, 500);
|
|
50
29
|
word-break: break-word;
|
|
@@ -52,10 +31,7 @@ export default css`
|
|
|
52
31
|
}
|
|
53
32
|
|
|
54
33
|
.property-title[secondary] {
|
|
55
|
-
font-weight: var(
|
|
56
|
-
--api-type-document-property-title-secondary-font-weight,
|
|
57
|
-
400
|
|
58
|
-
);
|
|
34
|
+
font-weight: var(--api-type-document-property-title-secondary-font-weight, 400);
|
|
59
35
|
color: var(--api-type-document-property-title-secondary-color, #616161);
|
|
60
36
|
}
|
|
61
37
|
|
|
@@ -65,10 +41,7 @@ export default css`
|
|
|
65
41
|
|
|
66
42
|
.property-display-name {
|
|
67
43
|
font-weight: var(--api-type-document-property-name-font-weight, 500);
|
|
68
|
-
color: var(
|
|
69
|
-
--api-type-document-property-name-color,
|
|
70
|
-
var(--api-type-document-property-color, #212121)
|
|
71
|
-
);
|
|
44
|
+
color: var(--api-type-document-property-name-color, var(--api-type-document-property-color, #212121));
|
|
72
45
|
margin: 4px 0 4px 0;
|
|
73
46
|
font-size: var(--api-type-document-property-name-font-size, 16px);
|
|
74
47
|
}
|
|
@@ -117,6 +90,10 @@ export default css`
|
|
|
117
90
|
margin-bottom: 8px;
|
|
118
91
|
}
|
|
119
92
|
|
|
93
|
+
.property-traits.no-name {
|
|
94
|
+
margin-top: -33px;
|
|
95
|
+
}
|
|
96
|
+
|
|
120
97
|
.property-traits > span {
|
|
121
98
|
display: inline-block;
|
|
122
99
|
margin-right: 8px;
|
|
@@ -134,6 +111,10 @@ export default css`
|
|
|
134
111
|
font-weight: var(--api-type-document-trait-data-type-font-weight, normal);
|
|
135
112
|
}
|
|
136
113
|
|
|
114
|
+
.property-traits > span.fixed-type-size {
|
|
115
|
+
padding: var(--api-type-document-trait-fixed-type-size-padding, 2px 1px);
|
|
116
|
+
}
|
|
117
|
+
|
|
137
118
|
arc-marked {
|
|
138
119
|
background-color: transparent;
|
|
139
120
|
padding: 0;
|
|
@@ -159,7 +140,7 @@ export default css`
|
|
|
159
140
|
-ms-flex: 1;
|
|
160
141
|
flex: 1;
|
|
161
142
|
}
|
|
162
|
-
|
|
143
|
+
|
|
163
144
|
.property-traits > span.readonly-type {
|
|
164
145
|
background-color: var(--api-type-readonly-property-background-color, #ff9292);
|
|
165
146
|
color: var(--api-type-readonly-property-color, black);
|