@twin.org/tools-core 0.0.3-next.15 → 0.0.3-next.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.
Files changed (132) hide show
  1. package/dist/es/index.js +20 -11
  2. package/dist/es/index.js.map +1 -1
  3. package/dist/es/models/ITypeScriptToSchemaContext.js +2 -0
  4. package/dist/es/models/ITypeScriptToSchemaContext.js.map +1 -0
  5. package/dist/es/models/ITypeScriptToSchemaDiagnostics.js +4 -0
  6. package/dist/es/models/ITypeScriptToSchemaDiagnostics.js.map +1 -0
  7. package/dist/es/models/ITypeScriptToSchemaOptions.js +4 -0
  8. package/dist/es/models/ITypeScriptToSchemaOptions.js.map +1 -0
  9. package/dist/es/utils/constants.js +43 -0
  10. package/dist/es/utils/constants.js.map +1 -0
  11. package/dist/es/utils/diagnosticReporter.js +32 -0
  12. package/dist/es/utils/diagnosticReporter.js.map +1 -0
  13. package/dist/es/utils/disallowedTypeGuard.js +151 -0
  14. package/dist/es/utils/disallowedTypeGuard.js.map +1 -0
  15. package/dist/es/utils/enum.js +152 -0
  16. package/dist/es/utils/enum.js.map +1 -0
  17. package/dist/es/utils/fileUtils.js +130 -0
  18. package/dist/es/utils/fileUtils.js.map +1 -0
  19. package/dist/es/utils/importTypeQuerySchemaResolver.js +328 -0
  20. package/dist/es/utils/importTypeQuerySchemaResolver.js.map +1 -0
  21. package/dist/es/utils/indexSignaturePatternResolver.js +94 -0
  22. package/dist/es/utils/indexSignaturePatternResolver.js.map +1 -0
  23. package/dist/es/utils/intersectionSchemaMerger.js +85 -0
  24. package/dist/es/utils/intersectionSchemaMerger.js.map +1 -0
  25. package/dist/es/utils/jsonSchemaBuilder.js +3189 -0
  26. package/dist/es/utils/jsonSchemaBuilder.js.map +1 -0
  27. package/dist/es/utils/mappedTypeSchemaResolver.js +231 -0
  28. package/dist/es/utils/mappedTypeSchemaResolver.js.map +1 -0
  29. package/dist/es/utils/objectTransformer.js +162 -0
  30. package/dist/es/utils/objectTransformer.js.map +1 -0
  31. package/dist/es/utils/regEx.js +128 -0
  32. package/dist/es/utils/regEx.js.map +1 -0
  33. package/dist/es/utils/resolver.js +164 -0
  34. package/dist/es/utils/resolver.js.map +1 -0
  35. package/dist/es/utils/templateLiteralPatternBuilder.js +94 -0
  36. package/dist/es/utils/templateLiteralPatternBuilder.js.map +1 -0
  37. package/dist/es/utils/typeScriptToSchema.js +102 -0
  38. package/dist/es/utils/typeScriptToSchema.js.map +1 -0
  39. package/dist/es/utils/utility.js +134 -0
  40. package/dist/es/utils/utility.js.map +1 -0
  41. package/dist/es/utils/utilityTypeSchemaMapper.js +412 -0
  42. package/dist/es/utils/utilityTypeSchemaMapper.js.map +1 -0
  43. package/dist/types/index.d.ts +20 -11
  44. package/dist/types/models/ITypeScriptToSchemaContext.d.ts +64 -0
  45. package/dist/types/models/ITypeScriptToSchemaDiagnostics.d.ts +31 -0
  46. package/dist/types/models/ITypeScriptToSchemaOptions.d.ts +22 -0
  47. package/dist/types/utils/constants.d.ts +13 -0
  48. package/dist/types/utils/diagnosticReporter.d.ts +17 -0
  49. package/dist/types/utils/disallowedTypeGuard.d.ts +16 -0
  50. package/dist/types/utils/enum.d.ts +42 -0
  51. package/dist/types/utils/fileUtils.d.ts +66 -0
  52. package/dist/types/utils/importTypeQuerySchemaResolver.d.ts +52 -0
  53. package/dist/types/utils/indexSignaturePatternResolver.d.ts +21 -0
  54. package/dist/types/utils/intersectionSchemaMerger.d.ts +16 -0
  55. package/dist/types/utils/jsonSchemaBuilder.d.ts +721 -0
  56. package/dist/types/utils/mappedTypeSchemaResolver.d.ts +46 -0
  57. package/dist/types/utils/objectTransformer.d.ts +33 -0
  58. package/dist/types/utils/regEx.d.ts +24 -0
  59. package/dist/types/utils/resolver.d.ts +16 -0
  60. package/dist/types/utils/templateLiteralPatternBuilder.d.ts +12 -0
  61. package/dist/types/utils/typeScriptToSchema.d.ts +31 -0
  62. package/dist/types/utils/utility.d.ts +58 -0
  63. package/dist/types/utils/utilityTypeSchemaMapper.d.ts +92 -0
  64. package/docs/changelog.md +15 -1
  65. package/docs/examples.md +55 -148
  66. package/docs/reference/classes/Constants.md +29 -0
  67. package/docs/reference/classes/DiagnosticReporter.md +49 -0
  68. package/docs/reference/classes/DisallowedTypeGuard.md +35 -0
  69. package/docs/reference/classes/Enum.md +93 -0
  70. package/docs/reference/classes/FileUtils.md +237 -0
  71. package/docs/reference/classes/ImportTypeQuerySchemaResolver.md +87 -0
  72. package/docs/reference/classes/IndexSignaturePatternResolver.md +69 -0
  73. package/docs/reference/classes/IntersectionSchemaMerger.md +48 -0
  74. package/docs/reference/classes/JsonSchemaBuilder.md +2772 -0
  75. package/docs/reference/classes/MappedTypeSchemaResolver.md +211 -0
  76. package/docs/reference/classes/ObjectTransformer.md +119 -0
  77. package/docs/reference/classes/RegEx.md +99 -0
  78. package/docs/reference/classes/Resolver.md +41 -0
  79. package/docs/reference/classes/TemplateLiteralPatternBuilder.md +35 -0
  80. package/docs/reference/classes/TypeScriptToSchema.md +91 -0
  81. package/docs/reference/classes/Utility.md +164 -0
  82. package/docs/reference/classes/UtilityTypeSchemaMapper.md +341 -0
  83. package/docs/reference/index.md +20 -14
  84. package/docs/reference/interfaces/ITypeScriptToSchemaContext.md +113 -0
  85. package/docs/reference/interfaces/ITypeScriptToSchemaDiagnostics.md +55 -0
  86. package/docs/reference/interfaces/ITypeScriptToSchemaOptions.md +44 -0
  87. package/locales/en.json +30 -1
  88. package/package.json +3 -2
  89. package/dist/es/models/IJsonSchema.js +0 -2
  90. package/dist/es/models/IJsonSchema.js.map +0 -1
  91. package/dist/es/models/IOpenApi.js +0 -2
  92. package/dist/es/models/IOpenApi.js.map +0 -1
  93. package/dist/es/models/IOpenApiExample.js +0 -4
  94. package/dist/es/models/IOpenApiExample.js.map +0 -1
  95. package/dist/es/models/IOpenApiHeader.js +0 -4
  96. package/dist/es/models/IOpenApiHeader.js.map +0 -1
  97. package/dist/es/models/IOpenApiPathMethod.js +0 -2
  98. package/dist/es/models/IOpenApiPathMethod.js.map +0 -1
  99. package/dist/es/models/IOpenApiResponse.js +0 -2
  100. package/dist/es/models/IOpenApiResponse.js.map +0 -1
  101. package/dist/es/models/IOpenApiSecurityScheme.js +0 -4
  102. package/dist/es/models/IOpenApiSecurityScheme.js.map +0 -1
  103. package/dist/es/models/IPackageJson.js +0 -4
  104. package/dist/es/models/IPackageJson.js.map +0 -1
  105. package/dist/es/models/jsonTypeName.js +0 -2
  106. package/dist/es/models/jsonTypeName.js.map +0 -1
  107. package/dist/es/utils/jsonSchemaHelper.js +0 -282
  108. package/dist/es/utils/jsonSchemaHelper.js.map +0 -1
  109. package/dist/es/utils/openApiHelper.js +0 -12
  110. package/dist/es/utils/openApiHelper.js.map +0 -1
  111. package/dist/types/models/IJsonSchema.d.ts +0 -5
  112. package/dist/types/models/IOpenApi.d.ts +0 -54
  113. package/dist/types/models/IOpenApiExample.d.ts +0 -13
  114. package/dist/types/models/IOpenApiHeader.d.ts +0 -19
  115. package/dist/types/models/IOpenApiPathMethod.d.ts +0 -65
  116. package/dist/types/models/IOpenApiResponse.d.ts +0 -32
  117. package/dist/types/models/IOpenApiSecurityScheme.d.ts +0 -25
  118. package/dist/types/models/IPackageJson.d.ts +0 -15
  119. package/dist/types/models/jsonTypeName.d.ts +0 -5
  120. package/dist/types/utils/jsonSchemaHelper.d.ts +0 -78
  121. package/dist/types/utils/openApiHelper.d.ts +0 -9
  122. package/docs/reference/classes/JsonSchemaHelper.md +0 -233
  123. package/docs/reference/classes/OpenApiHelper.md +0 -21
  124. package/docs/reference/interfaces/IOpenApi.md +0 -103
  125. package/docs/reference/interfaces/IOpenApiExample.md +0 -19
  126. package/docs/reference/interfaces/IOpenApiHeader.md +0 -31
  127. package/docs/reference/interfaces/IOpenApiPathMethod.md +0 -119
  128. package/docs/reference/interfaces/IOpenApiResponse.md +0 -35
  129. package/docs/reference/interfaces/IOpenApiSecurityScheme.md +0 -43
  130. package/docs/reference/interfaces/IPackageJson.md +0 -23
  131. package/docs/reference/type-aliases/IJsonSchema.md +0 -5
  132. package/docs/reference/type-aliases/JsonTypeName.md +0 -5
@@ -0,0 +1,44 @@
1
+ # Interface: ITypeScriptToSchemaOptions
2
+
3
+ Options for TypeScript to JSON schema generation.
4
+
5
+ ## Properties
6
+
7
+ ### externalReferences? {#externalreferences}
8
+
9
+ > `optional` **externalReferences?**: `object`
10
+
11
+ Mapping of package ids, type ids, wildcard patterns, or regex patterns to schema id prefixes
12
+ or replacement templates for referenced schemas.
13
+
14
+ #### Index Signature
15
+
16
+ \[`id`: `string`\]: `string`
17
+
18
+ ***
19
+
20
+ ### onDiagnostic? {#ondiagnostic}
21
+
22
+ > `optional` **onDiagnostic?**: (`diagnostic`) => `void`
23
+
24
+ Optional diagnostic callback for non-fatal generation issues.
25
+
26
+ #### Parameters
27
+
28
+ ##### diagnostic
29
+
30
+ [`ITypeScriptToSchemaDiagnostics`](ITypeScriptToSchemaDiagnostics.md)
31
+
32
+ The diagnostic details for the generation issue.
33
+
34
+ #### Returns
35
+
36
+ `void`
37
+
38
+ ***
39
+
40
+ ### suppressPackageWarnings? {#suppresspackagewarnings}
41
+
42
+ > `optional` **suppressPackageWarnings?**: `string`[]
43
+
44
+ Package names where diagnostics should be suppressed, e.g. jose.
package/locales/en.json CHANGED
@@ -1,3 +1,32 @@
1
1
  {
2
- "error": {}
2
+ "error": {
3
+ "jsonSchemaBuilder": {
4
+ "invalidJsonSchemaTagKey": "Ignoring invalid @json-schema tag key \"{rawKey}\". Mapped key \"{schemaKey}\" is not supported by JSON Schema.",
5
+ "missingTypeReferenceSchema": "Unable to resolve type \"{typeName}\"{importSource} required as base type for utility type. Ensure the type is in the configured packages list or its external package exports TypeScript source files that can be parsed via the AST."
6
+ }
7
+ },
8
+ "jsonSchemaBuilder": {
9
+ "diagnostic": {
10
+ "symbolValuedProperty": "Skipping symbol-typed property \"{propertyName}\".",
11
+ "symbolKeyedMember": "Skipping symbol-keyed member \"{memberName}\".",
12
+ "unsupportedComputedPropertyName": "Skipping unsupported computed property name \"{propertyName}\".",
13
+ "functionTypedProperty": "Skipping function-typed property \"{propertyName}\".",
14
+ "unsupportedIndexSignature": "Skipping index signature with unsupported key type \"{keyType}\".",
15
+ "unresolvedKeyofOperand": "Could not resolve keyof operand \"{operand}\".",
16
+ "unmappedTypeNode": "Unsupported TypeScript type node kind \"{kind}\"; the type will be omitted.",
17
+ "unresolvedMappedTypeRemap": "Could not resolve mapped type key remap for \"{typeName}\"; falling back to additionalProperties.",
18
+ "unsupportedImportTypeForm": "Skipping unsupported import type form \"{argument}\".",
19
+ "unresolvedImportTypeQualifier": "Could not resolve import type qualifier for \"{argument}\".",
20
+ "unresolvedTypeQueryTarget": "Could not resolve type query target \"{target}\".",
21
+ "unsupportedInferredExpressionKind": "Skipping unsupported inferred expression kind \"{kind}\".",
22
+ "unsupportedInferredObjectComputedKey": "Skipping inferred object property with unsupported computed key \"{propertyName}\".",
23
+ "unsupportedInferredObjectSpread": "Skipping inferred object spread expression \"{expression}\".",
24
+ "unsupportedInferredObjectMemberKind": "Skipping inferred object member kind \"{kind}\".",
25
+ "unsupportedInferredTupleElement": "Skipping unsupported inferred tuple element kind \"{kind}\".",
26
+ "unsupportedTemplateLiteralSpan": "Could not derive a regex pattern for template literal type \"{type}\"; falling back to string.",
27
+ "unsupportedTypeElementMember": "Skipping unsupported type member kind \"{kind}\".",
28
+ "unsupportedUtilityType": "Skipping unsupported utility type \"{utilityType}\".",
29
+ "excludedEnclosingObjectDisallowedType": "Excluding enclosing object \"{enclosingObjectName}\" because property \"{propertyName}\" uses disallowed type \"{disallowedTypeName}\"."
30
+ }
31
+ }
3
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/tools-core",
3
- "version": "0.0.3-next.15",
3
+ "version": "0.0.3-next.16",
4
4
  "description": "Shared utilities and models for tooling packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,7 +16,8 @@
16
16
  "dependencies": {
17
17
  "@twin.org/core": "next",
18
18
  "@twin.org/nameof": "next",
19
- "ajv": "8.18.0"
19
+ "@twin.org/tools-models": "0.0.3-next.16",
20
+ "glob": "13.0.6"
20
21
  },
21
22
  "main": "./dist/es/index.js",
22
23
  "types": "./dist/types/index.d.ts",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IJsonSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IJsonSchema.js","sourceRoot":"","sources":["../../../src/models/IJsonSchema.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { AnySchemaObject } from \"ajv/dist/2020.js\";\n\n/**\n * Default schema type.\n */\nexport type IJsonSchema = AnySchemaObject;\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IOpenApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IOpenApi.js","sourceRoot":"","sources":["../../../src/models/IOpenApi.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonSchema } from \"./IJsonSchema.js\";\nimport type { IOpenApiPathMethod } from \"./IOpenApiPathMethod.js\";\nimport type { IOpenApiSecurityScheme } from \"./IOpenApiSecurityScheme.js\";\n\n/**\n * The Open API config definition.\n */\nexport interface IOpenApi {\n\t/**\n\t * The open api version.\n\t */\n\topenapi: string;\n\n\t/**\n\t * Info.\n\t */\n\tinfo: {\n\t\ttitle: string;\n\t\tversion: string;\n\t\tdescription: string;\n\t\tlicense?: {\n\t\t\tname: string;\n\t\t\turl: string;\n\t\t};\n\t};\n\n\t/**\n\t * The servers for the endpoints.\n\t */\n\tservers?: {\n\t\turl: string;\n\t}[];\n\n\t/**\n\t * Tags for the endpoints.\n\t */\n\ttags?: {\n\t\tname: string;\n\t\tdescription: string;\n\t}[];\n\n\t/**\n\t * The paths.\n\t */\n\tpaths: {\n\t\t[path: string]: {\n\t\t\t[method: string]: IOpenApiPathMethod;\n\t\t};\n\t};\n\n\t/**\n\t * The components.\n\t */\n\tcomponents?: {\n\t\tschemas?: IJsonSchema;\n\t\tsecuritySchemes?: {\n\t\t\t[name: string]: IOpenApiSecurityScheme;\n\t\t};\n\t};\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- export {};
4
- //# sourceMappingURL=IOpenApiExample.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IOpenApiExample.js","sourceRoot":"","sources":["../../../src/models/IOpenApiExample.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The Open API config definition.\n */\nexport interface IOpenApiExample {\n\t/**\n\t * The summary of the example.\n\t */\n\tsummary?: string;\n\n\t/**\n\t * The value of the example.\n\t */\n\tvalue: unknown;\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- export {};
4
- //# sourceMappingURL=IOpenApiHeader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IOpenApiHeader.js","sourceRoot":"","sources":["../../../src/models/IOpenApiHeader.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The Open API config definition.\n */\nexport interface IOpenApiHeader {\n\t/**\n\t * The schema of the header.\n\t */\n\tschema?: {\n\t\ttype: string;\n\t};\n\n\t/**\n\t * The description of the header.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * The format of the header.\n\t */\n\tformat?: string;\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IOpenApiPathMethod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IOpenApiPathMethod.js","sourceRoot":"","sources":["../../../src/models/IOpenApiPathMethod.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonSchema } from \"./IJsonSchema.js\";\nimport type { IOpenApiExample } from \"./IOpenApiExample.js\";\nimport type { IOpenApiResponse } from \"./IOpenApiResponse.js\";\nimport type { JsonTypeName } from \"./jsonTypeName.js\";\n\n/**\n * The Open API config definition.\n */\nexport interface IOpenApiPathMethod {\n\t/**\n\t * The operation id.\n\t */\n\toperationId: string;\n\n\t/**\n\t * Summary.\n\t */\n\tsummary: string;\n\n\t/**\n\t * Tags.\n\t */\n\ttags?: string[];\n\n\t/**\n\t * Parameters.\n\t */\n\tparameters?: {\n\t\tname: string;\n\t\tin: string;\n\t\tdescription?: string;\n\t\trequired: boolean;\n\t\tschema: {\n\t\t\ttype?: JsonTypeName | JsonTypeName[];\n\t\t\tenum?: IJsonSchema[];\n\t\t\t$ref?: string;\n\t\t};\n\t\tstyle?: string;\n\t}[];\n\n\t/**\n\t * Request body.\n\t */\n\trequestBody?: {\n\t\trequired: boolean;\n\t\tdescription?: string;\n\t\tcontent?: {\n\t\t\t[contentType: string]: {\n\t\t\t\tschema: {\n\t\t\t\t\t$ref: string;\n\t\t\t\t};\n\t\t\t\texamples?: {\n\t\t\t\t\t[id: string]: IOpenApiExample;\n\t\t\t\t};\n\t\t\t};\n\t\t};\n\t};\n\n\t/**\n\t * Response body.\n\t */\n\tresponses?: {\n\t\t[code: string]: IOpenApiResponse;\n\t};\n\n\t/**\n\t * Security model for the API.\n\t */\n\tsecurity?: {\n\t\t[name: string]: string[];\n\t}[];\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IOpenApiResponse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IOpenApiResponse.js","sourceRoot":"","sources":["../../../src/models/IOpenApiResponse.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IOpenApiExample } from \"./IOpenApiExample.js\";\nimport type { IOpenApiHeader } from \"./IOpenApiHeader.js\";\n\n/**\n * The Open API config definition.\n */\nexport interface IOpenApiResponse {\n\t/**\n\t * Descriptions for the response.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Content for the response.\n\t */\n\tcontent?: {\n\t\t[contentType: string]: {\n\t\t\tschema: {\n\t\t\t\ttype?: string;\n\t\t\t\tformat?: string;\n\t\t\t\t$ref?: string;\n\t\t\t};\n\t\t\texamples?: {\n\t\t\t\t[id: string]: IOpenApiExample;\n\t\t\t};\n\t\t};\n\t};\n\n\t/**\n\t * The headers for the response.\n\t */\n\theaders?: {\n\t\t[id: string]: IOpenApiHeader;\n\t};\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- export {};
4
- //# sourceMappingURL=IOpenApiSecurityScheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IOpenApiSecurityScheme.js","sourceRoot":"","sources":["../../../src/models/IOpenApiSecurityScheme.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The Open API config definition for security scheme.\n */\nexport interface IOpenApiSecurityScheme {\n\t/**\n\t * The type of the security schema.\n\t */\n\ttype?: string;\n\n\t/**\n\t * The scheme method.\n\t */\n\tscheme?: string;\n\n\t/**\n\t * The bearer format.\n\t */\n\tbearerFormat?: string;\n\n\t/**\n\t * Where is the token located.\n\t */\n\tin?: string;\n\n\t/**\n\t * What is the name of the token.\n\t */\n\tname?: string;\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- export {};
4
- //# sourceMappingURL=IPackageJson.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IPackageJson.js","sourceRoot":"","sources":["../../../src/models/IPackageJson.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for each individual package.\n */\nexport interface IPackageJson {\n\t/**\n\t * The name of the package.\n\t */\n\tname: string;\n\n\t/**\n\t * The dependencies for the package.\n\t */\n\tdependencies?: { [id: string]: string };\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=jsonTypeName.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonTypeName.js","sourceRoot":"","sources":["../../../src/models/jsonTypeName.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JSONType } from \"ajv/dist/2020.js\";\n\n/**\n * Default schema type.\n */\nexport type JsonTypeName = JSONType;\n"]}
@@ -1,282 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- import { Is } from "@twin.org/core";
4
- /**
5
- * Helper class for JSON Schema processing.
6
- */
7
- export class JsonSchemaHelper {
8
- /**
9
- * The JSON Schema version used.
10
- */
11
- static SCHEMA_VERSION = "https://json-schema.org/draft/2020-12/schema";
12
- /**
13
- * Process arrays in the schema object.
14
- * @param schemaObject The schema object to process.
15
- */
16
- static processArrays(schemaObject) {
17
- if (Is.object(schemaObject)) {
18
- // new json schema version has prefixItems instead of items for arrays with fixed ordering
19
- // so convert any old style schemas that use items as an array
20
- // prefixItems validates fixed positions and is an array
21
- // items validates the rest and is an object
22
- // additionalItems no longer exists
23
- // https://www.learnjsonschema.com/2020-12/applicator/items/
24
- // https://www.learnjsonschema.com/2020-12/applicator/prefixitems/
25
- if (Is.array(schemaObject.items)) {
26
- if (Is.object(schemaObject.additionalItems)) {
27
- // If the items are an array then this is fixed ordering
28
- // so move to prefixItems and then do the same for additionalItems
29
- schemaObject.prefixItems = schemaObject.items;
30
- delete schemaObject.items;
31
- schemaObject.items = schemaObject.additionalItems;
32
- }
33
- else if (Is.integer(schemaObject.minItems) &&
34
- Is.integer(schemaObject.maxItems) &&
35
- schemaObject.minItems === schemaObject.maxItems &&
36
- schemaObject.maxItems === schemaObject.items.length) {
37
- // There is a fixed number of items which matches the items array length
38
- // so move construct an allOf to enforce the fixed length
39
- schemaObject.items = { allOf: schemaObject.items };
40
- delete schemaObject.minItems;
41
- delete schemaObject.maxItems;
42
- }
43
- else {
44
- // no additional items so wrap in an anyOf
45
- schemaObject.items = { anyOf: schemaObject.items };
46
- }
47
- }
48
- // We can't use additionalItems in the new schema version
49
- // so just remove it after processing
50
- delete schemaObject.additionalItems;
51
- // Since we are generating JSON-LD schemas we need to support
52
- // additional properties to allow for object expansion
53
- // but don't change anything that has specific additional properties defined
54
- if (schemaObject.additionalProperties === false) {
55
- delete schemaObject.additionalProperties;
56
- }
57
- JsonSchemaHelper.processSchemaDictionary(schemaObject.properties);
58
- JsonSchemaHelper.processArrays(schemaObject.additionalProperties);
59
- JsonSchemaHelper.processSchemaArray(schemaObject.allOf);
60
- JsonSchemaHelper.processSchemaArray(schemaObject.anyOf);
61
- JsonSchemaHelper.processSchemaArray(schemaObject.oneOf);
62
- if (Is.stringValue(schemaObject.$ref)) {
63
- schemaObject.$ref = JsonSchemaHelper.normaliseTypeName(schemaObject.$ref);
64
- }
65
- }
66
- }
67
- /**
68
- * Process arrays in the schema object.
69
- * @param schemaDictionary The schema object to process.
70
- */
71
- static processSchemaDictionary(schemaDictionary) {
72
- if (Is.object(schemaDictionary)) {
73
- for (const item of Object.values(schemaDictionary)) {
74
- if (Is.object(item)) {
75
- JsonSchemaHelper.processArrays(item);
76
- }
77
- }
78
- }
79
- }
80
- /**
81
- * Process arrays in the schema object.
82
- * @param schemaArray The schema object to process.
83
- */
84
- static processSchemaArray(schemaArray) {
85
- if (Is.arrayValue(schemaArray)) {
86
- const seenSignatures = new Set();
87
- for (const item of schemaArray) {
88
- if (Is.object(item)) {
89
- const signature = JSON.stringify(item);
90
- // There is a bug in JSON schema generator where spread tuple produce the same output
91
- // e.g. [typeA, ...typeB] and [...typeA, typeB] can produce the same items schema
92
- // in the legacy shape { items: { typeA }, additionalItems: [typeB] }.
93
- // For duplicate signatures we normalize one entry to the alternate approximation
94
- // so we don't emit identical duplicated anyOf/oneOf branches.
95
- if (seenSignatures.has(signature) &&
96
- Is.array(item.items) &&
97
- Is.object(item.additionalItems)) {
98
- const originalItems = item.items;
99
- item.items = [item.additionalItems];
100
- item.additionalItems = originalItems[0];
101
- }
102
- seenSignatures.add(signature);
103
- JsonSchemaHelper.processArrays(item);
104
- }
105
- }
106
- }
107
- }
108
- /**
109
- * Cleanup TypeScript markers from the type name.
110
- * @param typeName The definition string to clean up.
111
- * @returns The cleaned up definition string.
112
- */
113
- static normaliseTypeName(typeName) {
114
- // Remove the partial markers
115
- let sTypeName = typeName.replace(/^Partial<I(.*?)>/g, "$1");
116
- sTypeName = sTypeName.replace(/Partial%3CI(.*?)%3E/g, "$1");
117
- // Remove the omit markers
118
- sTypeName = sTypeName.replace(/^Omit<I(.*?),.*>/g, "$1");
119
- sTypeName = sTypeName.replace(/Omit%3CI(.*?)%2C.*%3E/g, "$1");
120
- // Remove the pick markers
121
- sTypeName = sTypeName.replace(/^Pick<I(.*?),.*>/g, "$1");
122
- sTypeName = sTypeName.replace(/Pick%3CI(.*?)%2C.*%3E/g, "$1");
123
- // Cleanup the generic markers
124
- sTypeName = sTypeName.replace(/^(.*?)<I(.*?)>/g, "$1<$2>");
125
- sTypeName = sTypeName.replace(/(.*?)%3CI(.*?)%3E/g, "$1<$2>");
126
- // Cleanup the unknown markers
127
- sTypeName = sTypeName.replace(/<unknown>/g, "");
128
- sTypeName = sTypeName.replace(/%3Cunknown%3E/g, "");
129
- // Replace the other url markers
130
- sTypeName = sTypeName.replace(/%7C/g, "|").replace(/%3C/g, "<").replace(/%3E/g, ">");
131
- return sTypeName;
132
- }
133
- /**
134
- * Extract type from properties definition.
135
- * @param allTypes All the known types.
136
- * @param schema The schema to extract from.
137
- * @param output The output types.
138
- */
139
- static extractTypesFromSchema(allTypes, schema, output) {
140
- const additionalTypes = [];
141
- if (Is.stringValue(schema.$ref)) {
142
- additionalTypes.push(JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", "")));
143
- }
144
- else if (Is.object(schema.items)) {
145
- if (Is.arrayValue(schema.items)) {
146
- for (const itemSchema of schema.items) {
147
- JsonSchemaHelper.extractTypesFromSchema(allTypes, itemSchema, output);
148
- }
149
- }
150
- else {
151
- JsonSchemaHelper.extractTypesFromSchema(allTypes, schema.items, output);
152
- }
153
- }
154
- else if (Is.object(schema.properties) || Is.object(schema.additionalProperties)) {
155
- if (Is.object(schema.properties)) {
156
- for (const prop in schema.properties) {
157
- const p = schema.properties[prop];
158
- if (Is.object(p)) {
159
- JsonSchemaHelper.extractTypesFromSchema(allTypes, p, output);
160
- }
161
- }
162
- }
163
- if (Is.object(schema.additionalProperties)) {
164
- JsonSchemaHelper.extractTypesFromSchema(allTypes, schema.additionalProperties, output);
165
- }
166
- }
167
- else if (Is.arrayValue(schema.anyOf)) {
168
- for (const prop of schema.anyOf) {
169
- if (Is.object(prop)) {
170
- JsonSchemaHelper.extractTypesFromSchema(allTypes, prop, output);
171
- }
172
- }
173
- }
174
- else if (Is.arrayValue(schema.oneOf)) {
175
- for (const prop of schema.oneOf) {
176
- if (Is.object(prop)) {
177
- JsonSchemaHelper.extractTypesFromSchema(allTypes, prop, output);
178
- }
179
- }
180
- }
181
- if (additionalTypes.length > 0) {
182
- JsonSchemaHelper.extractTypes(allTypes, additionalTypes, output);
183
- }
184
- }
185
- /**
186
- * Extract the required types from all the known schemas.
187
- * @param allSchemas All the known schemas.
188
- * @param requiredTypes The required types.
189
- * @param referencedSchemas The references schemas.
190
- */
191
- static extractTypes(allSchemas, requiredTypes, referencedSchemas) {
192
- for (const typeKey of Object.keys(allSchemas)) {
193
- if (!referencedSchemas[typeKey]) {
194
- for (const requiredType of requiredTypes) {
195
- const regex = JsonSchemaHelper.stringToRegEx(requiredType);
196
- if (regex.test(typeKey)) {
197
- referencedSchemas[typeKey] = allSchemas[typeKey];
198
- JsonSchemaHelper.extractTypesFromSchema(allSchemas, allSchemas[typeKey], referencedSchemas);
199
- }
200
- }
201
- }
202
- }
203
- }
204
- /**
205
- * Expand the types inline.
206
- * @param schemas The schemas to include the expanded types.
207
- * @param expandedTypes The types to expand.
208
- */
209
- static expandTypes(schemas, expandedTypes) {
210
- for (const typeKey of Object.keys(schemas)) {
211
- const schema = schemas[typeKey];
212
- JsonSchemaHelper.expandSchemaTypes(schemas, schema, expandedTypes);
213
- }
214
- }
215
- /**
216
- * Expand the types inline.
217
- * @param allSchemas All the known schemas.
218
- * @param schema The schemas to include the expanded types.
219
- * @param expandedTypes The types to expand.
220
- */
221
- static expandSchemaTypes(allSchemas, schema, expandedTypes) {
222
- if (Is.stringValue(schema.$ref)) {
223
- for (const expandedType of expandedTypes) {
224
- const typeName = JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", ""));
225
- const regex = JsonSchemaHelper.stringToRegEx(expandedType);
226
- if (regex.test(typeName) && allSchemas[typeName]) {
227
- delete schema.$ref;
228
- Object.assign(schema, allSchemas[typeName]);
229
- break;
230
- }
231
- }
232
- }
233
- else if (Is.object(schema.items)) {
234
- if (Is.arrayValue(schema.items)) {
235
- for (const itemSchema of schema.items) {
236
- JsonSchemaHelper.expandSchemaTypes(allSchemas, itemSchema, expandedTypes);
237
- }
238
- }
239
- else {
240
- JsonSchemaHelper.expandSchemaTypes(allSchemas, schema.items, expandedTypes);
241
- }
242
- }
243
- else if (Is.object(schema.properties) || Is.object(schema.additionalProperties)) {
244
- if (Is.object(schema.properties)) {
245
- for (const prop in schema.properties) {
246
- const p = schema.properties[prop];
247
- if (Is.object(p)) {
248
- JsonSchemaHelper.expandSchemaTypes(allSchemas, p, expandedTypes);
249
- }
250
- }
251
- }
252
- if (Is.object(schema.additionalProperties)) {
253
- JsonSchemaHelper.expandSchemaTypes(allSchemas, schema.additionalProperties, expandedTypes);
254
- }
255
- }
256
- else if (Is.arrayValue(schema.anyOf)) {
257
- for (const prop of schema.anyOf) {
258
- if (Is.object(prop)) {
259
- JsonSchemaHelper.expandSchemaTypes(allSchemas, prop, expandedTypes);
260
- }
261
- }
262
- }
263
- else if (Is.arrayValue(schema.oneOf)) {
264
- for (const prop of schema.oneOf) {
265
- if (Is.object(prop)) {
266
- JsonSchemaHelper.expandSchemaTypes(allSchemas, prop, expandedTypes);
267
- }
268
- }
269
- }
270
- }
271
- /**
272
- * Convert a string pattern to a regular expression.
273
- * @param matchPattern The pattern to convert.
274
- * @returns The regular expression.
275
- */
276
- static stringToRegEx(matchPattern) {
277
- return matchPattern.startsWith("/") && matchPattern.endsWith("/")
278
- ? new RegExp(matchPattern.slice(1, -1))
279
- : new RegExp(`^${matchPattern}$`);
280
- }
281
- }
282
- //# sourceMappingURL=jsonSchemaHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonSchemaHelper.js","sourceRoot":"","sources":["../../../src/utils/jsonSchemaHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC5B;;OAEG;IACI,MAAM,CAAU,cAAc,GAAG,8CAA8C,CAAC;IAEvF;;;OAGG;IACI,MAAM,CAAC,aAAa,CAAC,YAAyB;QACpD,IAAI,EAAE,CAAC,MAAM,CAAc,YAAY,CAAC,EAAE,CAAC;YAC1C,0FAA0F;YAC1F,8DAA8D;YAC9D,wDAAwD;YACxD,4CAA4C;YAC5C,mCAAmC;YACnC,4DAA4D;YAC5D,kEAAkE;YAClE,IAAI,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC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AM,CAAC,IAAI,YAAY,GAAG,CAAC,CAAC;IACpC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Is } from \"@twin.org/core\";\nimport type { IJsonSchema } from \"../models/IJsonSchema.js\";\n\n/**\n * Helper class for JSON Schema processing.\n */\nexport class JsonSchemaHelper {\n\t/**\n\t * The JSON Schema version used.\n\t */\n\tpublic static readonly SCHEMA_VERSION = \"https://json-schema.org/draft/2020-12/schema\";\n\n\t/**\n\t * Process arrays in the schema object.\n\t * @param schemaObject The schema object to process.\n\t */\n\tpublic static processArrays(schemaObject: IJsonSchema): void {\n\t\tif (Is.object<IJsonSchema>(schemaObject)) {\n\t\t\t// new json schema version has prefixItems instead of items for arrays with fixed ordering\n\t\t\t// so convert any old style schemas that use items as an array\n\t\t\t// prefixItems validates fixed positions and is an array\n\t\t\t// items validates the rest and is an object\n\t\t\t// additionalItems no longer exists\n\t\t\t// https://www.learnjsonschema.com/2020-12/applicator/items/\n\t\t\t// https://www.learnjsonschema.com/2020-12/applicator/prefixitems/\n\t\t\tif (Is.array(schemaObject.items)) {\n\t\t\t\tif (Is.object(schemaObject.additionalItems)) {\n\t\t\t\t\t// If the items are an array then this is fixed ordering\n\t\t\t\t\t// so move to prefixItems and then do the same for additionalItems\n\t\t\t\t\tschemaObject.prefixItems = schemaObject.items;\n\t\t\t\t\tdelete schemaObject.items;\n\t\t\t\t\tschemaObject.items = schemaObject.additionalItems;\n\t\t\t\t} else if (\n\t\t\t\t\tIs.integer(schemaObject.minItems) &&\n\t\t\t\t\tIs.integer(schemaObject.maxItems) &&\n\t\t\t\t\tschemaObject.minItems === schemaObject.maxItems &&\n\t\t\t\t\tschemaObject.maxItems === schemaObject.items.length\n\t\t\t\t) {\n\t\t\t\t\t// There is a fixed number of items which matches the items array length\n\t\t\t\t\t// so move construct an allOf to enforce the fixed length\n\t\t\t\t\tschemaObject.items = { allOf: schemaObject.items };\n\t\t\t\t\tdelete schemaObject.minItems;\n\t\t\t\t\tdelete schemaObject.maxItems;\n\t\t\t\t} else {\n\t\t\t\t\t// no additional items so wrap in an anyOf\n\t\t\t\t\tschemaObject.items = { anyOf: schemaObject.items };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// We can't use additionalItems in the new schema version\n\t\t\t// so just remove it after processing\n\t\t\tdelete schemaObject.additionalItems;\n\n\t\t\t// Since we are generating JSON-LD schemas we need to support\n\t\t\t// additional properties to allow for object expansion\n\t\t\t// but don't change anything that has specific additional properties defined\n\t\t\tif (schemaObject.additionalProperties === false) {\n\t\t\t\tdelete schemaObject.additionalProperties;\n\t\t\t}\n\n\t\t\tJsonSchemaHelper.processSchemaDictionary(schemaObject.properties);\n\t\t\tJsonSchemaHelper.processArrays(schemaObject.additionalProperties);\n\t\t\tJsonSchemaHelper.processSchemaArray(schemaObject.allOf);\n\t\t\tJsonSchemaHelper.processSchemaArray(schemaObject.anyOf);\n\t\t\tJsonSchemaHelper.processSchemaArray(schemaObject.oneOf);\n\n\t\t\tif (Is.stringValue(schemaObject.$ref)) {\n\t\t\t\tschemaObject.$ref = JsonSchemaHelper.normaliseTypeName(schemaObject.$ref);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Process arrays in the schema object.\n\t * @param schemaDictionary The schema object to process.\n\t */\n\tpublic static processSchemaDictionary(schemaDictionary?: { [key: string]: IJsonSchema }): void {\n\t\tif (Is.object(schemaDictionary)) {\n\t\t\tfor (const item of Object.values(schemaDictionary)) {\n\t\t\t\tif (Is.object<IJsonSchema>(item)) {\n\t\t\t\t\tJsonSchemaHelper.processArrays(item);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Process arrays in the schema object.\n\t * @param schemaArray The schema object to process.\n\t */\n\tpublic static processSchemaArray(schemaArray?: IJsonSchema[]): void {\n\t\tif (Is.arrayValue(schemaArray)) {\n\t\t\tconst seenSignatures = new Set<string>();\n\t\t\tfor (const item of schemaArray) {\n\t\t\t\tif (Is.object<IJsonSchema>(item)) {\n\t\t\t\t\tconst signature = JSON.stringify(item);\n\t\t\t\t\t// There is a bug in JSON schema generator where spread tuple produce the same output\n\t\t\t\t\t// e.g. [typeA, ...typeB] and [...typeA, typeB] can produce the same items schema\n\t\t\t\t\t// in the legacy shape { items: { typeA }, additionalItems: [typeB] }.\n\t\t\t\t\t// For duplicate signatures we normalize one entry to the alternate approximation\n\t\t\t\t\t// so we don't emit identical duplicated anyOf/oneOf branches.\n\t\t\t\t\tif (\n\t\t\t\t\t\tseenSignatures.has(signature) &&\n\t\t\t\t\t\tIs.array(item.items) &&\n\t\t\t\t\t\tIs.object(item.additionalItems)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst originalItems = item.items;\n\t\t\t\t\t\titem.items = [item.additionalItems];\n\t\t\t\t\t\titem.additionalItems = originalItems[0];\n\t\t\t\t\t}\n\t\t\t\t\tseenSignatures.add(signature);\n\t\t\t\t\tJsonSchemaHelper.processArrays(item);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Cleanup TypeScript markers from the type name.\n\t * @param typeName The definition string to clean up.\n\t * @returns The cleaned up definition string.\n\t */\n\tpublic static normaliseTypeName(typeName: string): string {\n\t\t// Remove the partial markers\n\t\tlet sTypeName = typeName.replace(/^Partial<I(.*?)>/g, \"$1\");\n\t\tsTypeName = sTypeName.replace(/Partial%3CI(.*?)%3E/g, \"$1\");\n\n\t\t// Remove the omit markers\n\t\tsTypeName = sTypeName.replace(/^Omit<I(.*?),.*>/g, \"$1\");\n\t\tsTypeName = sTypeName.replace(/Omit%3CI(.*?)%2C.*%3E/g, \"$1\");\n\n\t\t// Remove the pick markers\n\t\tsTypeName = sTypeName.replace(/^Pick<I(.*?),.*>/g, \"$1\");\n\t\tsTypeName = sTypeName.replace(/Pick%3CI(.*?)%2C.*%3E/g, \"$1\");\n\n\t\t// Cleanup the generic markers\n\t\tsTypeName = sTypeName.replace(/^(.*?)<I(.*?)>/g, \"$1<$2>\");\n\t\tsTypeName = sTypeName.replace(/(.*?)%3CI(.*?)%3E/g, \"$1<$2>\");\n\n\t\t// Cleanup the unknown markers\n\t\tsTypeName = sTypeName.replace(/<unknown>/g, \"\");\n\t\tsTypeName = sTypeName.replace(/%3Cunknown%3E/g, \"\");\n\n\t\t// Replace the other url markers\n\t\tsTypeName = sTypeName.replace(/%7C/g, \"|\").replace(/%3C/g, \"<\").replace(/%3E/g, \">\");\n\n\t\treturn sTypeName;\n\t}\n\n\t/**\n\t * Extract type from properties definition.\n\t * @param allTypes All the known types.\n\t * @param schema The schema to extract from.\n\t * @param output The output types.\n\t */\n\tpublic static extractTypesFromSchema(\n\t\tallTypes: { [id: string]: IJsonSchema },\n\t\tschema: IJsonSchema,\n\t\toutput: { [id: string]: IJsonSchema }\n\t): void {\n\t\tconst additionalTypes = [];\n\n\t\tif (Is.stringValue(schema.$ref)) {\n\t\t\tadditionalTypes.push(\n\t\t\t\tJsonSchemaHelper.normaliseTypeName(schema.$ref.replace(\"#/definitions/\", \"\"))\n\t\t\t);\n\t\t} else if (Is.object<IJsonSchema>(schema.items)) {\n\t\t\tif (Is.arrayValue<IJsonSchema>(schema.items)) {\n\t\t\t\tfor (const itemSchema of schema.items) {\n\t\t\t\t\tJsonSchemaHelper.extractTypesFromSchema(allTypes, itemSchema, output);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tJsonSchemaHelper.extractTypesFromSchema(allTypes, schema.items, output);\n\t\t\t}\n\t\t} else if (Is.object(schema.properties) || Is.object(schema.additionalProperties)) {\n\t\t\tif (Is.object(schema.properties)) {\n\t\t\t\tfor (const prop in schema.properties) {\n\t\t\t\t\tconst p = schema.properties[prop];\n\t\t\t\t\tif (Is.object<IJsonSchema>(p)) {\n\t\t\t\t\t\tJsonSchemaHelper.extractTypesFromSchema(allTypes, p, output);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.object(schema.additionalProperties)) {\n\t\t\t\tJsonSchemaHelper.extractTypesFromSchema(allTypes, schema.additionalProperties, output);\n\t\t\t}\n\t\t} else if (Is.arrayValue(schema.anyOf)) {\n\t\t\tfor (const prop of schema.anyOf) {\n\t\t\t\tif (Is.object<IJsonSchema>(prop)) {\n\t\t\t\t\tJsonSchemaHelper.extractTypesFromSchema(allTypes, prop, output);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.arrayValue(schema.oneOf)) {\n\t\t\tfor (const prop of schema.oneOf) {\n\t\t\t\tif (Is.object<IJsonSchema>(prop)) {\n\t\t\t\t\tJsonSchemaHelper.extractTypesFromSchema(allTypes, prop, output);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (additionalTypes.length > 0) {\n\t\t\tJsonSchemaHelper.extractTypes(allTypes, additionalTypes, output);\n\t\t}\n\t}\n\n\t/**\n\t * Extract the required types from all the known schemas.\n\t * @param allSchemas All the known schemas.\n\t * @param requiredTypes The required types.\n\t * @param referencedSchemas The references schemas.\n\t */\n\tpublic static extractTypes(\n\t\tallSchemas: { [id: string]: IJsonSchema },\n\t\trequiredTypes: string[],\n\t\treferencedSchemas: { [id: string]: IJsonSchema }\n\t): void {\n\t\tfor (const typeKey of Object.keys(allSchemas)) {\n\t\t\tif (!referencedSchemas[typeKey]) {\n\t\t\t\tfor (const requiredType of requiredTypes) {\n\t\t\t\t\tconst regex = JsonSchemaHelper.stringToRegEx(requiredType);\n\n\t\t\t\t\tif (regex.test(typeKey)) {\n\t\t\t\t\t\treferencedSchemas[typeKey] = allSchemas[typeKey];\n\t\t\t\t\t\tJsonSchemaHelper.extractTypesFromSchema(\n\t\t\t\t\t\t\tallSchemas,\n\t\t\t\t\t\t\tallSchemas[typeKey],\n\t\t\t\t\t\t\treferencedSchemas\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Expand the types inline.\n\t * @param schemas The schemas to include the expanded types.\n\t * @param expandedTypes The types to expand.\n\t */\n\tpublic static expandTypes(schemas: { [id: string]: IJsonSchema }, expandedTypes: string[]): void {\n\t\tfor (const typeKey of Object.keys(schemas)) {\n\t\t\tconst schema = schemas[typeKey];\n\n\t\t\tJsonSchemaHelper.expandSchemaTypes(schemas, schema, expandedTypes);\n\t\t}\n\t}\n\n\t/**\n\t * Expand the types inline.\n\t * @param allSchemas All the known schemas.\n\t * @param schema The schemas to include the expanded types.\n\t * @param expandedTypes The types to expand.\n\t */\n\tpublic static expandSchemaTypes(\n\t\tallSchemas: { [id: string]: IJsonSchema },\n\t\tschema: IJsonSchema,\n\t\texpandedTypes: string[]\n\t): void {\n\t\tif (Is.stringValue(schema.$ref)) {\n\t\t\tfor (const expandedType of expandedTypes) {\n\t\t\t\tconst typeName = JsonSchemaHelper.normaliseTypeName(\n\t\t\t\t\tschema.$ref.replace(\"#/definitions/\", \"\")\n\t\t\t\t);\n\t\t\t\tconst regex = JsonSchemaHelper.stringToRegEx(expandedType);\n\t\t\t\tif (regex.test(typeName) && allSchemas[typeName]) {\n\t\t\t\t\tdelete schema.$ref;\n\t\t\t\t\tObject.assign(schema, allSchemas[typeName]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.object<IJsonSchema>(schema.items)) {\n\t\t\tif (Is.arrayValue<IJsonSchema>(schema.items)) {\n\t\t\t\tfor (const itemSchema of schema.items) {\n\t\t\t\t\tJsonSchemaHelper.expandSchemaTypes(allSchemas, itemSchema, expandedTypes);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tJsonSchemaHelper.expandSchemaTypes(allSchemas, schema.items, expandedTypes);\n\t\t\t}\n\t\t} else if (Is.object(schema.properties) || Is.object(schema.additionalProperties)) {\n\t\t\tif (Is.object(schema.properties)) {\n\t\t\t\tfor (const prop in schema.properties) {\n\t\t\t\t\tconst p = schema.properties[prop];\n\t\t\t\t\tif (Is.object<IJsonSchema>(p)) {\n\t\t\t\t\t\tJsonSchemaHelper.expandSchemaTypes(allSchemas, p, expandedTypes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.object(schema.additionalProperties)) {\n\t\t\t\tJsonSchemaHelper.expandSchemaTypes(allSchemas, schema.additionalProperties, expandedTypes);\n\t\t\t}\n\t\t} else if (Is.arrayValue(schema.anyOf)) {\n\t\t\tfor (const prop of schema.anyOf) {\n\t\t\t\tif (Is.object<IJsonSchema>(prop)) {\n\t\t\t\t\tJsonSchemaHelper.expandSchemaTypes(allSchemas, prop, expandedTypes);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.arrayValue(schema.oneOf)) {\n\t\t\tfor (const prop of schema.oneOf) {\n\t\t\t\tif (Is.object<IJsonSchema>(prop)) {\n\t\t\t\t\tJsonSchemaHelper.expandSchemaTypes(allSchemas, prop, expandedTypes);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Convert a string pattern to a regular expression.\n\t * @param matchPattern The pattern to convert.\n\t * @returns The regular expression.\n\t */\n\tpublic static stringToRegEx(matchPattern: string): RegExp {\n\t\treturn matchPattern.startsWith(\"/\") && matchPattern.endsWith(\"/\")\n\t\t\t? new RegExp(matchPattern.slice(1, -1))\n\t\t\t: new RegExp(`^${matchPattern}$`);\n\t}\n}\n"]}
@@ -1,12 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- /**
4
- * Helper class for OpenAPI processing.
5
- */
6
- export class OpenApiHelper {
7
- /**
8
- * The OpenAPI version used.
9
- */
10
- static API_VERSION = "3.1.1";
11
- }
12
- //# sourceMappingURL=openApiHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openApiHelper.js","sourceRoot":"","sources":["../../../src/utils/openApiHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,MAAM,OAAO,aAAa;IACzB;;OAEG;IACI,MAAM,CAAU,WAAW,GAAG,OAAO,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Helper class for OpenAPI processing.\n */\nexport class OpenApiHelper {\n\t/**\n\t * The OpenAPI version used.\n\t */\n\tpublic static readonly API_VERSION = \"3.1.1\";\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { AnySchemaObject } from "ajv/dist/2020.js";
2
- /**
3
- * Default schema type.
4
- */
5
- export type IJsonSchema = AnySchemaObject;
@@ -1,54 +0,0 @@
1
- import type { IJsonSchema } from "./IJsonSchema.js";
2
- import type { IOpenApiPathMethod } from "./IOpenApiPathMethod.js";
3
- import type { IOpenApiSecurityScheme } from "./IOpenApiSecurityScheme.js";
4
- /**
5
- * The Open API config definition.
6
- */
7
- export interface IOpenApi {
8
- /**
9
- * The open api version.
10
- */
11
- openapi: string;
12
- /**
13
- * Info.
14
- */
15
- info: {
16
- title: string;
17
- version: string;
18
- description: string;
19
- license?: {
20
- name: string;
21
- url: string;
22
- };
23
- };
24
- /**
25
- * The servers for the endpoints.
26
- */
27
- servers?: {
28
- url: string;
29
- }[];
30
- /**
31
- * Tags for the endpoints.
32
- */
33
- tags?: {
34
- name: string;
35
- description: string;
36
- }[];
37
- /**
38
- * The paths.
39
- */
40
- paths: {
41
- [path: string]: {
42
- [method: string]: IOpenApiPathMethod;
43
- };
44
- };
45
- /**
46
- * The components.
47
- */
48
- components?: {
49
- schemas?: IJsonSchema;
50
- securitySchemes?: {
51
- [name: string]: IOpenApiSecurityScheme;
52
- };
53
- };
54
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * The Open API config definition.
3
- */
4
- export interface IOpenApiExample {
5
- /**
6
- * The summary of the example.
7
- */
8
- summary?: string;
9
- /**
10
- * The value of the example.
11
- */
12
- value: unknown;
13
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * The Open API config definition.
3
- */
4
- export interface IOpenApiHeader {
5
- /**
6
- * The schema of the header.
7
- */
8
- schema?: {
9
- type: string;
10
- };
11
- /**
12
- * The description of the header.
13
- */
14
- description?: string;
15
- /**
16
- * The format of the header.
17
- */
18
- format?: string;
19
- }