@api-client/core 0.7.12 → 0.8.0

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 (88) hide show
  1. package/SECURITY.md +14 -0
  2. package/build/browser.d.ts +6 -0
  3. package/build/browser.js +6 -0
  4. package/build/browser.js.map +1 -1
  5. package/build/index.d.ts +6 -0
  6. package/build/index.js +6 -0
  7. package/build/index.js.map +1 -1
  8. package/build/src/amf/AmfMixin.d.ts +55 -42
  9. package/build/src/amf/AmfMixin.js +9 -3
  10. package/build/src/amf/AmfMixin.js.map +1 -1
  11. package/build/src/amf/AmfSerializer.d.ts +72 -72
  12. package/build/src/amf/AmfSerializer.js +9 -4
  13. package/build/src/amf/AmfSerializer.js.map +1 -1
  14. package/build/src/amf/AmfShapeGenerator.d.ts +17 -17
  15. package/build/src/amf/AmfShapeGenerator.js +3 -3
  16. package/build/src/amf/AmfShapeGenerator.js.map +1 -1
  17. package/build/src/amf/AmfTypes.d.ts +16 -16
  18. package/build/src/amf/AmfTypes.js +16 -16
  19. package/build/src/amf/AmfTypes.js.map +1 -1
  20. package/build/src/amf/ApiExampleGenerator.d.ts +3 -3
  21. package/build/src/amf/ApiExampleGenerator.js.map +1 -1
  22. package/build/src/amf/ApiMonacoSchemaGenerator.d.ts +6 -6
  23. package/build/src/amf/ApiMonacoSchemaGenerator.js.map +1 -1
  24. package/build/src/amf/ApiSchemaGenerator.d.ts +2 -2
  25. package/build/src/amf/ApiSchemaGenerator.js.map +1 -1
  26. package/build/src/amf/ApiSchemaValues.d.ts +12 -12
  27. package/build/src/amf/ApiSchemaValues.js.map +1 -1
  28. package/build/src/amf/Parsing.d.ts +5 -5
  29. package/build/src/amf/Utils.d.ts +6 -6
  30. package/build/src/amf/Utils.js.map +1 -1
  31. package/build/src/amf/data-node/DataNodeBase.d.ts +5 -5
  32. package/build/src/amf/data-node/DataNodeBase.js.map +1 -1
  33. package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts +2 -2
  34. package/build/src/amf/data-node/JsonDataNodeGenerator.js.map +1 -1
  35. package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts +2 -2
  36. package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js.map +1 -1
  37. package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts +2 -2
  38. package/build/src/amf/data-node/XmlDataNodeGenerator.js.map +1 -1
  39. package/build/src/amf/definitions/Amf.d.ts +339 -339
  40. package/build/src/amf/definitions/Api.d.ts +158 -158
  41. package/build/src/amf/definitions/Base.d.ts +5 -5
  42. package/build/src/amf/definitions/Shapes.d.ts +46 -46
  43. package/build/src/amf/definitions/Shapes.js +11 -11
  44. package/build/src/amf/definitions/Shapes.js.map +1 -1
  45. package/build/src/amf/models/AmfDataNode.d.ts +5 -5
  46. package/build/src/amf/models/AmfDataNode.js +4 -4
  47. package/build/src/amf/models/AmfDataNode.js.map +1 -1
  48. package/build/src/amf/shape/ShapeBase.d.ts +13 -13
  49. package/build/src/amf/shape/ShapeBase.js.map +1 -1
  50. package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts +13 -13
  51. package/build/src/amf/shape/ShapeJsonSchemaGenerator.js.map +1 -1
  52. package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts +16 -16
  53. package/build/src/amf/shape/ShapeXmlSchemaGenerator.js.map +1 -1
  54. package/build/src/events/amf/AmfEvents.d.ts +4 -4
  55. package/build/src/events/amf/AmfEvents.js.map +1 -1
  56. package/build/src/models/data/Bindings.d.ts +2 -2
  57. package/build/src/models/data/DataAssociation.d.ts +4 -4
  58. package/build/src/models/data/DataAssociation.js.map +1 -1
  59. package/build/src/models/data/DataEntity.d.ts +2 -2
  60. package/build/src/models/data/DataProperty.d.ts +2 -2
  61. package/package.json +1 -1
  62. package/src/amf/AmfMixin.ts +124 -117
  63. package/src/amf/AmfSerializer.ts +245 -240
  64. package/src/amf/AmfShapeGenerator.ts +23 -23
  65. package/src/amf/AmfTypes.ts +16 -16
  66. package/src/amf/ApiExampleGenerator.ts +4 -4
  67. package/src/amf/ApiMonacoSchemaGenerator.ts +11 -11
  68. package/src/amf/ApiSchemaGenerator.ts +3 -3
  69. package/src/amf/ApiSchemaValues.ts +21 -21
  70. package/src/amf/Parsing.ts +5 -5
  71. package/src/amf/Utils.ts +15 -15
  72. package/src/amf/data-node/DataNodeBase.ts +8 -8
  73. package/src/amf/data-node/JsonDataNodeGenerator.ts +2 -2
  74. package/src/amf/data-node/UrlEncodedDataNodeGenerator.ts +2 -2
  75. package/src/amf/data-node/XmlDataNodeGenerator.ts +2 -2
  76. package/src/amf/definitions/Amf.ts +315 -314
  77. package/src/amf/definitions/Api.ts +158 -157
  78. package/src/amf/definitions/Base.ts +5 -5
  79. package/src/amf/definitions/Shapes.ts +60 -60
  80. package/src/amf/models/AmfDataNode.ts +17 -17
  81. package/src/amf/shape/ShapeBase.ts +16 -16
  82. package/src/amf/shape/ShapeJsonSchemaGenerator.ts +27 -27
  83. package/src/amf/shape/ShapeXmlSchemaGenerator.ts +42 -42
  84. package/src/events/amf/AmfEvents.ts +7 -7
  85. package/src/models/data/Bindings.ts +2 -2
  86. package/src/models/data/DataAssociation.ts +4 -4
  87. package/src/models/data/DataEntity.ts +2 -2
  88. package/src/models/data/DataProperty.ts +2 -2
package/src/amf/Utils.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { UrlEncoder } from "../lib/parsers/UrlEncoder.js";
2
2
  import { AmfNamespace } from "./definitions/Namespace.js";
3
- import { INodeShape, IPropertyShape, IShapeUnion, IUnionShape } from "./definitions/Shapes.js";
3
+ import { IApiNodeShape, IApiPropertyShape, IShapeUnion, IApiUnionShape } from "./definitions/Shapes.js";
4
4
 
5
5
  /**
6
6
  * @param indent The current indent
7
7
  */
8
- export function toXml(obj: any, indent=0): string {
8
+ export function toXml(obj: Record<string, unknown>, indent=0): string {
9
9
  if (typeof obj !== 'object') {
10
10
  return obj;
11
11
  }
@@ -14,7 +14,7 @@ export function toXml(obj: any, indent=0): string {
14
14
  Object.keys(obj).forEach((prop) => {
15
15
  xml += Array.isArray(obj[prop]) ? '' : `${tabs}<${prop}>`;
16
16
  if (Array.isArray(obj[prop])) {
17
- (obj[prop] as any[]).forEach((item) => {
17
+ (obj[prop] as Record<string, unknown>[]).forEach((item) => {
18
18
  xml += `<${prop}>\n`;
19
19
  xml += tabs;
20
20
  xml += toXml({ ...item }, indent + 1);
@@ -22,7 +22,7 @@ export function toXml(obj: any, indent=0): string {
22
22
  });
23
23
  } else if (typeof obj[prop] === "object") {
24
24
  xml += `\n`;
25
- xml += toXml({ ...obj[prop] }, indent + 1);
25
+ xml += toXml({ ...obj[prop] as Record<string, unknown> }, indent + 1);
26
26
  } else {
27
27
  xml += `${obj[prop]}`;
28
28
  }
@@ -60,7 +60,7 @@ export function wwwFormUrlEncode(str: string, replacePlus?: boolean): string {
60
60
  /**
61
61
  * Processes a value that should be a number.
62
62
  */
63
- export function parseNumberInput(value: any, defaultValue?: number): number | undefined {
63
+ export function parseNumberInput(value: unknown, defaultValue?: number): number | undefined {
64
64
  if (typeof value === 'number') {
65
65
  return value;
66
66
  }
@@ -74,13 +74,13 @@ export function parseNumberInput(value: any, defaultValue?: number): number | un
74
74
  /**
75
75
  * Processes a value that should be a number.
76
76
  */
77
- export function parseBooleanInput(value: any, defaultValue?: boolean): boolean | undefined {
77
+ export function parseBooleanInput(value: unknown, defaultValue?: boolean): boolean | undefined {
78
78
  const type = typeof value;
79
79
  if (type === 'boolean') {
80
- return value;
80
+ return value as boolean;
81
81
  }
82
82
  if (type === 'string') {
83
- const trimmed = value.trim();
83
+ const trimmed = (value as string).trim();
84
84
  if (trimmed === 'true') {
85
85
  return true;
86
86
  }
@@ -95,7 +95,7 @@ export function parseBooleanInput(value: any, defaultValue?: boolean): boolean |
95
95
  * Casts the `value` to the corresponding data type
96
96
  * @param type The w3 schema type
97
97
  */
98
- export function readTypedValue(value: any, type?: string): string | null | number | boolean | undefined {
98
+ export function readTypedValue(value: unknown, type?: string): string | null | number | boolean | undefined {
99
99
  if (value === undefined || value === null) {
100
100
  return value;
101
101
  }
@@ -116,7 +116,7 @@ export function readTypedValue(value: any, type?: string): string | null | numbe
116
116
  case AmfNamespace.w3.xmlSchema.nil:
117
117
  return null;
118
118
  default:
119
- return value;
119
+ return value as string | null | number | boolean | undefined;
120
120
  }
121
121
  }
122
122
 
@@ -141,8 +141,8 @@ export function getUnionMember(anyOf: IShapeUnion[], selectedUnions: string[] =
141
141
  * @param {string[]=} [selectedUnions=[]]
142
142
  * @returns {ApiPropertyShape[]}
143
143
  */
144
- export function collectNodeProperties(schema: INodeShape, selectedUnions?: string[]): IPropertyShape[] {
145
- let result: IPropertyShape[] = [];
144
+ export function collectNodeProperties(schema: IApiNodeShape, selectedUnions?: string[]): IApiPropertyShape[] {
145
+ let result: IApiPropertyShape[] = [];
146
146
  const { properties, inherits } = schema;
147
147
  if (properties.length) {
148
148
  result = [...properties];
@@ -151,14 +151,14 @@ export function collectNodeProperties(schema: INodeShape, selectedUnions?: strin
151
151
  inherits.forEach((s) => {
152
152
  let node = s;
153
153
  if (node.types.includes(AmfNamespace.aml.vocabularies.shapes.UnionShape)) {
154
- const union = node as IUnionShape;
154
+ const union = node as IApiUnionShape;
155
155
  const { anyOf=[] } = union;
156
156
  node = getUnionMember(anyOf, selectedUnions);
157
157
  }
158
158
  if (!node.types.includes(AmfNamespace.w3.shacl.NodeShape)) {
159
159
  return;
160
160
  }
161
- const typed = node as INodeShape;
161
+ const typed = node as IApiNodeShape;
162
162
  // const p = typed.properties;
163
163
  // if (Array.isArray(p) && p.length) {
164
164
  // result = result.concat(p);
@@ -169,7 +169,7 @@ export function collectNodeProperties(schema: INodeShape, selectedUnions?: strin
169
169
  }
170
170
  });
171
171
  }
172
- const merged: IPropertyShape[] = [];
172
+ const merged: IApiPropertyShape[] = [];
173
173
  result.forEach((item) => {
174
174
  const existing = merged.find(i => i.name === item.name);
175
175
  if (existing) {
@@ -1,5 +1,5 @@
1
1
  import { AmfNamespace as ns } from "../definitions/Namespace.js";
2
- import { IArrayNode, IDataNode, IObjectNode, IScalarNode } from "../definitions/Shapes.js";
2
+ import { IApiArrayNode, IApiDataNode, IApiObjectNode, IApiScalarNode } from "../definitions/Shapes.js";
3
3
  import { readTypedValue } from '../Utils.js';
4
4
 
5
5
  /**
@@ -10,16 +10,16 @@ export class DataNodeBase {
10
10
  * @param node The AMF data node to turn into a schema.
11
11
  * @returns Undefined when passed non-DataNode domain element.
12
12
  */
13
- processNode(node: IDataNode): any | undefined {
13
+ processNode(node: IApiDataNode): any | undefined {
14
14
  const { types } = node;
15
15
  if (types.includes(ns.aml.vocabularies.data.Scalar)) {
16
- return this.processScalarNode(node as IScalarNode);
16
+ return this.processScalarNode(node as IApiScalarNode);
17
17
  }
18
18
  if (types.includes(ns.aml.vocabularies.data.Array)) {
19
- return this.processArrayNode(node as IArrayNode);
19
+ return this.processArrayNode(node as IApiArrayNode);
20
20
  }
21
21
  if (types.includes(ns.aml.vocabularies.data.Object)) {
22
- return this.processObjectNode(node as IObjectNode);
22
+ return this.processObjectNode(node as IApiObjectNode);
23
23
  }
24
24
  return undefined;
25
25
  }
@@ -28,7 +28,7 @@ export class DataNodeBase {
28
28
  * @param scalar The scalar node to process.
29
29
  * @returns The scalar value.
30
30
  */
31
- processScalarNode(scalar: IScalarNode): any {
31
+ processScalarNode(scalar: IApiScalarNode): any {
32
32
  return readTypedValue(scalar.value, scalar.dataType);
33
33
  }
34
34
 
@@ -36,7 +36,7 @@ export class DataNodeBase {
36
36
  * @param array The array node to process.
37
37
  * @returns Array value.
38
38
  */
39
- processArrayNode(array: IArrayNode): any[] {
39
+ processArrayNode(array: IApiArrayNode): any[] {
40
40
  const container: any[] = [];
41
41
  array.members.forEach((member) => {
42
42
  const result = this.processNode(member);
@@ -51,7 +51,7 @@ export class DataNodeBase {
51
51
  * @param object The object node to process.
52
52
  * @returns Object value.
53
53
  */
54
- processObjectNode(object: IObjectNode): any {
54
+ processObjectNode(object: IApiObjectNode): any {
55
55
  const container: any = {};
56
56
  const { properties } = object;
57
57
  Object.keys(properties).forEach((key) => {
@@ -1,4 +1,4 @@
1
- import { IDataNode } from '../definitions/Shapes.js';
1
+ import { IApiDataNode } from '../definitions/Shapes.js';
2
2
  import { DataNodeBase } from './DataNodeBase.js';
3
3
 
4
4
  /** @typedef {import('../../helpers/api').ApiDataNode} ApiDataNode */
@@ -13,7 +13,7 @@ export class JsonDataNodeGenerator extends DataNodeBase {
13
13
  * @param node The AMF's data node to transform into a schema.
14
14
  * @returns Undefined when passed non-DataNode domain element.
15
15
  */
16
- generate(node: IDataNode): string | undefined {
16
+ generate(node: IApiDataNode): string | undefined {
17
17
  const result = this.processNode(node);
18
18
  if (!result) {
19
19
  return result;
@@ -1,5 +1,5 @@
1
1
  import { DataNodeBase } from './DataNodeBase.js';
2
- import { IDataNode } from '../definitions/Shapes.js';
2
+ import { IApiDataNode } from '../definitions/Shapes.js';
3
3
  import { UrlEncoder } from "../../lib/parsers/UrlEncoder.js";
4
4
 
5
5
  /** @typedef {import('../../helpers/api').ApiDataNode} ApiDataNode */
@@ -11,7 +11,7 @@ export class UrlEncodedDataNodeGenerator extends DataNodeBase {
11
11
  * @param shapeName When provided it wraps the returned value with the shape name.
12
12
  * @returns Undefined when passed non-DataNode domain element.
13
13
  */
14
- generate(node: IDataNode, shapeName?: string): string | undefined {
14
+ generate(node: IApiDataNode, shapeName?: string): string | undefined {
15
15
  const result = this.processNode(node);
16
16
  const isArray = Array.isArray(result);
17
17
  if (shapeName && (typeof result !== 'object' || isArray)) {
@@ -1,6 +1,6 @@
1
1
  import { DataNodeBase } from './DataNodeBase.js';
2
2
  import { toXml } from '../Utils.js';
3
- import { IDataNode } from '../definitions/Shapes.js';
3
+ import { IApiDataNode } from '../definitions/Shapes.js';
4
4
 
5
5
  export interface IDataGenerateOptions {
6
6
  /**
@@ -20,7 +20,7 @@ export class XmlDataNodeGenerator extends DataNodeBase {
20
20
  * @param shapeName When provided it wraps the returned value with the shape name.
21
21
  * @returns Undefined when passed non-DataNode domain element.
22
22
  */
23
- generate(node: IDataNode, shapeName?: string, opts: IDataGenerateOptions = {}): string | undefined {
23
+ generate(node: IApiDataNode, shapeName?: string, opts: IDataGenerateOptions = {}): string | undefined {
24
24
  const result = this.processNode(node);
25
25
  if (!result) {
26
26
  return result;