@api-components/api-type-document 4.2.15 → 4.2.16

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/README.md CHANGED
@@ -1,10 +1,8 @@
1
- [![Published on NPM](https://img.shields.io/npm/v/@api-components/api-type-document.svg)](https://www.npmjs.com/package/@api-components/api-type-document)
1
+ # DEPRECATED
2
2
 
3
- [![Build Status](https://travis-ci.com/advanced-rest-client/api-type-document.svg)](https://travis-ci.com/advanced-rest-client/api-type-document)
3
+ This component is being deprecated. The code base has been moved to [api-documentation](https://github.com/advanced-rest-client/api-documentation) module. This module will be archived when [PR 37](https://github.com/advanced-rest-client/api-documentation/pull/37) is merged.
4
4
 
5
- [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/advanced-rest-client/api-type-document)
6
-
7
- ## <api-type-document>
5
+ -----
8
6
 
9
7
  A documentation table for RAML type / OAS schema properties. Works with AMF data model.
10
8
 
@@ -19,7 +17,7 @@ For compatibility with previous model version use `3.x.x` version of the compone
19
17
 
20
18
  Custom property | Description | Default
21
19
  ----------------|-------------|----------
22
- `--api-type-document` | Mixin applied to this elment | `{}`
20
+ `--api-type-document` | Mixin applied to this element | `{}`
23
21
  `--api-type-document-union-button-background-color` | Background color of union selector button | `#fff`
24
22
  `--api-type-document-union-button-color` | Color of union selector button | `#000`
25
23
  `--api-type-document-union-button-active-background-color` | Background color of active union selector button | `#CDDC39`
@@ -29,7 +27,7 @@ From `property-shape-document`
29
27
 
30
28
  Custom property | Description | Default
31
29
  ----------------|-------------|----------
32
- `--property-shape-document` | Mixin applied each proeprty element | `{}`
30
+ `--property-shape-document` | Mixin applied each property element | `{}`
33
31
  `--property-shape-document-array-color` | Property border color when type is an array | `#8BC34A`
34
32
  `--property-shape-document-object-color` | Property border color when type is an object | `#FF9800`
35
33
  `--property-shape-document-union-color` | Property border color when type is an union | `#FFEB3B`
@@ -41,17 +39,17 @@ Custom property | Description | Default
41
39
  `--api-type-document-type-color` | Color of the "type" trait | `white`
42
40
  `--api-type-document-type-background-color` | Background color of the "type" trait | `#2196F3`
43
41
  `--api-type-document-trait-background-color` | Background color to main range trait (type, required, enum) | `#EEEEEE`,
44
- `--api-type-document-trait-border-radius` | Border radious of a main property traits like type, required, enum | `3px`
42
+ `--api-type-document-trait-border-radius` | Border radius of a main property traits like type, required, enum | `3px`
45
43
 
46
44
  From `property-range-document`
47
45
 
48
46
  Custom property | Description | Default
49
47
  ----------------|-------------|----------
50
- `--property-range-document` | Mixin applied to this elment | `{}`
48
+ `--property-range-document` | Mixin applied to this element | `{}`
51
49
  `--api-type-document-type-attribute-color` | Color of each attribute that describes a property | `#616161`
52
50
  `--api-type-document-examples-title-color` | Color of examples section title | ``
53
51
  `--api-type-document-examples-border-color` | Example section border color | `transparent`
54
- `--code-background-color` | Background color of the examples section | ``
52
+ `--code-background-color` | Background color of the examples section |``
55
53
  `--arc-font-body1` | Mixin applied to an example name label | `{}`
56
54
  `--arc-font-body2` | Mixin applied to the examples section title | `{}`
57
55
 
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.15",
4
+ "version": "4.2.16",
5
5
  "license": "Apache-2.0",
6
6
  "main": "index.js",
7
7
  "module": "index.js",
@@ -27,31 +27,31 @@
27
27
  "dependencies": {
28
28
  "@advanced-rest-client/arc-marked": "^1.1.0",
29
29
  "@advanced-rest-client/markdown-styles": "^3.1.4",
30
- "@anypoint-web-components/anypoint-button": "^1.2.0",
31
- "@api-components/amf-helper-mixin": "^4.4.0",
30
+ "@anypoint-web-components/anypoint-button": "^1.2.3",
31
+ "@api-components/amf-helper-mixin": "^4.5.6",
32
32
  "@api-components/api-annotation-document": "^4.1.0",
33
- "@api-components/api-resource-example-document": "^4.1.2",
33
+ "@api-components/api-resource-example-document": "^4.3.3",
34
34
  "@open-wc/dedupe-mixin": "^1.3.0",
35
35
  "lit-element": "^2.4.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@advanced-rest-client/arc-demo-helper": "^2.2.6",
39
- "@anypoint-web-components/anypoint-checkbox": "^1.1.4",
40
- "@anypoint-web-components/anypoint-styles": "^1.0.1",
41
- "@api-components/api-model-generator": "^0.2.13",
42
- "@commitlint/cli": "^12.0.1",
43
- "@commitlint/config-conventional": "^12.0.1",
38
+ "@advanced-rest-client/arc-demo-helper": "^3.0.3",
39
+ "@anypoint-web-components/anypoint-checkbox": "^1.2.2",
40
+ "@anypoint-web-components/anypoint-styles": "^1.0.2",
41
+ "@api-components/api-model-generator": "^0.2.14",
42
+ "@commitlint/cli": "^13.2.0",
43
+ "@commitlint/config-conventional": "^13.2.0",
44
44
  "@open-wc/eslint-config": "^4.2.0",
45
45
  "@open-wc/testing": "^2.5.15",
46
- "@web/dev-server": "^0.1.18",
47
- "@web/test-runner": "^0.12.16",
48
- "@web/test-runner-playwright": "^0.8.6",
49
- "eslint": "^7.30.0",
46
+ "@web/dev-server": "^0.1.24",
47
+ "@web/test-runner": "^0.13.18",
48
+ "@web/test-runner-playwright": "^0.8.8",
49
+ "eslint": "^7.32.0",
50
50
  "eslint-config-prettier": "^8.1.0",
51
- "husky": "^4.3.8",
52
- "lint-staged": "^10.5.4",
53
- "sinon": "^9.2.4",
54
- "typescript": "^4.3.5",
51
+ "husky": "^7.0.2",
52
+ "lint-staged": "^11.1.2",
53
+ "sinon": "^11.1.2",
54
+ "typescript": "^4.4.3",
55
55
  "typescript-lit-html-plugin": "^0.9.0"
56
56
  },
57
57
  "scripts": {
@@ -655,57 +655,48 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
655
655
  /**
656
656
  * @return {TemplateResult} Templates for object properties
657
657
  */
658
- _arrayTemplate() {
658
+ _arrayTemplate() {
659
659
  const items = this._computeArrayProperties(this._resolvedType) || [];
660
- return html`
661
- ${this.hasParentType
662
- ? html`<property-shape-document
663
- class="array-document"
664
- .amf="${this.amf}"
665
- .shape="${this._resolvedType}"
666
- .parentTypeName="${this.parentTypeName}"
667
- ?narrow="${this.narrow}"
668
- ?noExamplesActions="${this.noExamplesActions}"
669
- ?compatibility="${this.compatibility}"
670
- .mediaType="${this.mediaType}"
671
- ?graph="${this.graph}"
672
- ></property-shape-document>`
673
- : html`<span>Array of:</span>`}
674
-
675
- <div class="array-children">
676
- ${items.map(
677
- (item) => html`
678
- ${item.isShape
679
- ? html`<property-shape-document
680
- class="array-document"
681
- .amf="${this.amf}"
682
- .shape="${item}"
683
- parentTypeName="${this._computeArrayParentName(this.parentTypeName)}"
684
- ?narrow="${this.narrow}"
685
- ?noExamplesActions="${this.noExamplesActions}"
686
- ?compatibility="${this.compatibility}"
687
- .mediaType="${this.mediaType}"
688
- ?graph="${this.graph}"
689
- ></property-shape-document>`
690
- : ''}
691
- ${item.isType
692
- ? html`<api-type-document
693
- class="union-document"
694
- .amf="${this.amf}"
695
- .parentTypeName="${this.parentTypeName}"
696
- .type="${item}"
697
- ?narrow="${this.narrow}"
698
- ?noExamplesActions="${this.noExamplesActions}"
699
- ?noMainExample="${this._renderMainExample}"
700
- ?compatibility="${this.compatibility}"
701
- .mediaType="${this.mediaType}"
702
- ?graph="${this.graph}"
703
- ></api-type-document>`
704
- : ''}
705
- `
706
- )}
707
- </div>
708
- `;
660
+ const documents = items.map(
661
+ (item) => html`
662
+ ${item.isShape
663
+ ? html`<property-shape-document
664
+ class="array-document"
665
+ .amf="${this.amf}"
666
+ .shape="${item}"
667
+ parentTypeName="${this._computeArrayParentName(this.parentTypeName)}"
668
+ ?narrow="${this.narrow}"
669
+ ?noExamplesActions="${this.noExamplesActions}"
670
+ ?compatibility="${this.compatibility}"
671
+ .mediaType="${this.mediaType}"
672
+ ?graph="${this.graph}"
673
+ ></property-shape-document>`
674
+ : ''}
675
+ ${item.isType
676
+ ? html`<api-type-document
677
+ class="union-document"
678
+ .amf="${this.amf}"
679
+ .parentTypeName="${this.parentTypeName}"
680
+ .type="${item}"
681
+ ?narrow="${this.narrow}"
682
+ ?noExamplesActions="${this.noExamplesActions}"
683
+ ?noMainExample="${this._renderMainExample}"
684
+ ?compatibility="${this.compatibility}"
685
+ .mediaType="${this.mediaType}"
686
+ ?graph="${this.graph}"
687
+ ></api-type-document>`
688
+ : ''}
689
+ `
690
+ );
691
+ if (!this.hasParentType) {
692
+ return html`
693
+ <span>Array of:</span>
694
+ <div class="array-children">
695
+ ${documents}
696
+ </div>
697
+ `;
698
+ }
699
+ return html`${documents}`;
709
700
  }
710
701
 
711
702
  /**
@@ -115,6 +115,17 @@ interface PropertyDocumentMixin extends AmfHelperMixin {
115
115
  */
116
116
  _computeIsAnyOf(range: Object): boolean
117
117
 
118
+
119
+ /**
120
+ * Computes value for `isAllOf` property.
121
+ * AllOf type is identified as `http://www.w3.org/ns/shacl#and`
122
+ * Returns true if `and` property is present in shape. Otherwise returns false.
123
+ *
124
+ * @param {Object} range Range object of current shape.
125
+ * @returns {boolean}
126
+ */
127
+ _computeIsAllOf(range: Object): boolean
128
+
118
129
  /**
119
130
  * Computes list of type labels to render.
120
131
  *
@@ -345,6 +345,18 @@ const mxFunction = (base) => {
345
345
  return this._hasProperty(range, this.ns.w3.shacl.or);
346
346
  }
347
347
 
348
+
349
+ /**
350
+ * Computes value for `isAllOf` property.
351
+ * Returns true if `and` property is present in shape. Otherwise returns false.
352
+ *
353
+ * @param {Object} range Range object of current shape.
354
+ * @returns {boolean}
355
+ */
356
+ _computeIsAllOf(range) {
357
+ return this._hasProperty(range, this.ns.w3.shacl.and);
358
+ }
359
+
348
360
  /**
349
361
  * Computes list of type labels to render.
350
362
  *
@@ -272,12 +272,14 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
272
272
  this.isReadOnly = this._isReadOnly(range);
273
273
  this.isAnyOf = this._computeIsAnyOf(range);
274
274
  this.isOneOf = this._computeIsOneOf(range);
275
+ this.isAllOf = this._computeIsAllOf(range);
275
276
  this.isComplex = this._computeIsComplex(
276
277
  this.isUnion,
277
278
  this.isObject,
278
279
  this.isArray,
279
280
  this.isAnyOf,
280
- this.isOneOf
281
+ this.isOneOf,
282
+ this.isAllOf
281
283
  );
282
284
  this.isScalarArray = this.isArray
283
285
  ? this._computeIsScalarArray(range)
@@ -465,10 +467,13 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
465
467
  * @param {boolean} isUnion
466
468
  * @param {boolean} isObject
467
469
  * @param {boolean} isArray
470
+ * @param {boolean} isAnyOf
471
+ * @param {boolean} isOneOf
472
+ * @param {boolean} isAllOf
468
473
  * @return {boolean}
469
474
  */
470
- _computeIsComplex(isUnion, isObject, isArray, isAnyOf, isOneOf) {
471
- return isUnion || isObject || isArray || isAnyOf || isOneOf;
475
+ _computeIsComplex(isUnion, isObject, isArray, isAnyOf, isOneOf, isAllOf) {
476
+ return isUnion || isObject || isArray || isAnyOf || isOneOf || isAllOf;
472
477
  }
473
478
 
474
479
  _evaluateGraph() {