@satisfactory-dev/docs.json.ts 0.6.1
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/LICENSE.md +190 -0
- package/README.md +81 -0
- package/assert/CustomAssert.d.ts +2 -0
- package/assert/CustomAssert.js +5 -0
- package/lib/AjvUtilities.d.ts +7 -0
- package/lib/AjvUtilities.js +59 -0
- package/lib/ArrayUtilities.d.ts +24 -0
- package/lib/ArrayUtilities.js +21 -0
- package/lib/CustomParsingTypes/CustomPairingTypes.d.ts +37 -0
- package/lib/CustomParsingTypes/CustomPairingTypes.js +42 -0
- package/lib/CustomParsingTypes/TypedString.d.ts +411 -0
- package/lib/CustomParsingTypes/TypedString.js +204 -0
- package/lib/CustomParsingTypes/TypedStringConst.d.ts +28 -0
- package/lib/CustomParsingTypes/TypedStringConst.js +35 -0
- package/lib/CustomParsingTypes/TypedStringEnum.d.ts +30 -0
- package/lib/CustomParsingTypes/TypedStringEnum.js +36 -0
- package/lib/CustomParsingTypes/TypedStringPattern.d.ts +64 -0
- package/lib/CustomParsingTypes/TypedStringPattern.js +82 -0
- package/lib/CustomParsingTypes/UnrealEngineString.d.ts +215 -0
- package/lib/CustomParsingTypes/UnrealEngineString.js +308 -0
- package/lib/CustomParsingTypes/ValueToRegexFormatter.d.ts +29 -0
- package/lib/CustomParsingTypes/ValueToRegexFormatter.js +205 -0
- package/lib/DataDiscovery/CustomTypes/BooleanOrBooleanExtended.d.ts +12 -0
- package/lib/DataDiscovery/CustomTypes/BooleanOrBooleanExtended.js +32 -0
- package/lib/DataDiscovery/CustomTypes/StringStartsWith.d.ts +9 -0
- package/lib/DataDiscovery/CustomTypes/StringStartsWith.js +19 -0
- package/lib/DataDiscovery/CustomTypes/TypedString.d.ts +23 -0
- package/lib/DataDiscovery/CustomTypes/TypedString.js +251 -0
- package/lib/DataDiscovery/CustomTypes/UnrealEngineString.d.ts +9 -0
- package/lib/DataDiscovery/CustomTypes/UnrealEngineString.js +45 -0
- package/lib/DataDiscovery/Generator.d.ts +19 -0
- package/lib/DataDiscovery/Generator.js +41 -0
- package/lib/DataDiscovery/JsonSchema/Array.d.ts +17 -0
- package/lib/DataDiscovery/JsonSchema/Array.js +41 -0
- package/lib/DataDiscovery/JsonSchema/Object.d.ts +61 -0
- package/lib/DataDiscovery/JsonSchema/Object.js +184 -0
- package/lib/DataDiscovery/JsonSchema/OneOf.d.ts +13 -0
- package/lib/DataDiscovery/JsonSchema/OneOf.js +47 -0
- package/lib/DataDiscovery/JsonSchema/Ref.d.ts +17 -0
- package/lib/DataDiscovery/JsonSchema/Ref.js +66 -0
- package/lib/DataDiscovery/JsonSchema/StringType.d.ts +39 -0
- package/lib/DataDiscovery/JsonSchema/StringType.js +121 -0
- package/lib/DataDiscovery/Literal.d.ts +8 -0
- package/lib/DataDiscovery/Literal.js +69 -0
- package/lib/DataDiscovery.d.ts +28 -0
- package/lib/DataDiscovery.js +116 -0
- package/lib/DocsToAutoImport/ArrayTypeNodes.d.ts +5 -0
- package/lib/DocsToAutoImport/ArrayTypeNodes.js +7 -0
- package/lib/DocsToAutoImport/ClassDeclarations.d.ts +5 -0
- package/lib/DocsToAutoImport/ClassDeclarations.js +14 -0
- package/lib/DocsToAutoImport/FunctionDeclaration.d.ts +5 -0
- package/lib/DocsToAutoImport/FunctionDeclaration.js +16 -0
- package/lib/DocsToAutoImport/LiteralTypeNodes.d.ts +5 -0
- package/lib/DocsToAutoImport/LiteralTypeNodes.js +23 -0
- package/lib/DocsToAutoImport/MethodDeclarations.d.ts +5 -0
- package/lib/DocsToAutoImport/MethodDeclarations.js +15 -0
- package/lib/DocsToAutoImport/NodeExtraction.d.ts +6 -0
- package/lib/DocsToAutoImport/NodeExtraction.js +21 -0
- package/lib/DocsToAutoImport/PropertyDeclarations.d.ts +5 -0
- package/lib/DocsToAutoImport/PropertyDeclarations.js +10 -0
- package/lib/DocsToAutoImport/TupleTypeNodes.d.ts +5 -0
- package/lib/DocsToAutoImport/TupleTypeNodes.js +7 -0
- package/lib/DocsToAutoImport/TypeLiteralNodes.d.ts +5 -0
- package/lib/DocsToAutoImport/TypeLiteralNodes.js +33 -0
- package/lib/DocsToAutoImport/TypeReferenceNodes.d.ts +5 -0
- package/lib/DocsToAutoImport/TypeReferenceNodes.js +7 -0
- package/lib/DocsToAutoImport/from_Node_array.d.ts +3 -0
- package/lib/DocsToAutoImport/from_Node_array.js +245 -0
- package/lib/DocsTsAutoImports.d.ts +21 -0
- package/lib/DocsTsAutoImports.js +110 -0
- package/lib/DocsTsGenerator/FilesGenerator.d.ts +25 -0
- package/lib/DocsTsGenerator/FilesGenerator.js +52 -0
- package/lib/DocsTsGenerator.d.ts +47 -0
- package/lib/DocsTsGenerator.js +188 -0
- package/lib/DocsValidation.d.ts +7 -0
- package/lib/DocsValidation.js +179 -0
- package/lib/Exceptions.d.ts +7 -0
- package/lib/Exceptions.js +13 -0
- package/lib/FilesGenerator.d.ts +19 -0
- package/lib/FilesGenerator.js +38 -0
- package/lib/MarkdownUtilities.d.ts +16 -0
- package/lib/MarkdownUtilities.js +68 -0
- package/lib/StringStartsWith.d.ts +10 -0
- package/lib/StringStartsWith.js +20 -0
- package/lib/TsFactoryWrapper.d.ts +80 -0
- package/lib/TsFactoryWrapper.js +236 -0
- package/lib/TypeDefinitionDiscovery/CustomParsingTypes/UnrealEngineString.d.ts +13 -0
- package/lib/TypeDefinitionDiscovery/CustomParsingTypes/UnrealEngineString.js +26 -0
- package/lib/TypeDefinitionDiscovery/CustomParsingTypes/string_starts_with.d.ts +25 -0
- package/lib/TypeDefinitionDiscovery/CustomParsingTypes/string_starts_with.js +20 -0
- package/lib/TypeDefinitionDiscovery/CustomParsingTypes/typed_string.d.ts +14 -0
- package/lib/TypeDefinitionDiscovery/CustomParsingTypes/typed_string.js +96 -0
- package/lib/TypeDefinitionDiscovery/Generator.d.ts +8 -0
- package/lib/TypeDefinitionDiscovery/Generator.js +8 -0
- package/lib/TypeDefinitionDiscovery/GeneratorDoesDiscovery.d.ts +8 -0
- package/lib/TypeDefinitionDiscovery/GeneratorDoesDiscovery.js +9 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/ArrayType.d.ts +19 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/ArrayType.js +61 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/Object/ExtendsObject.d.ts +23 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/Object/ExtendsObject.js +40 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/ObjectType.d.ts +91 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/ObjectType.js +76 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String/Const.d.ts +29 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String/Const.js +20 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String/Enum/BooleanEnum.d.ts +16 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String/Enum/BooleanEnum.js +47 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String/Enum.d.ts +40 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String/Enum.js +22 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String/Pattern.d.ts +13 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String/Pattern.js +21 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String.d.ts +52 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/String.js +72 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/oneOf_or_anyOf.d.ts +63 -0
- package/lib/TypeDefinitionDiscovery/JsonSchema/oneOf_or_anyOf.js +47 -0
- package/lib/TypeDefinitionDiscovery.d.ts +49 -0
- package/lib/TypeDefinitionDiscovery.js +376 -0
- package/lib/TypeDefinitionWriter.d.ts +22 -0
- package/lib/TypeDefinitionWriter.js +233 -0
- package/lib/TypesDiscovery/CandidatesDiscovery.d.ts +10 -0
- package/lib/TypesDiscovery/CandidatesDiscovery.js +14 -0
- package/lib/TypesDiscovery/CustomParsingTypes/UnrealEngineString.d.ts +5 -0
- package/lib/TypesDiscovery/CustomParsingTypes/UnrealEngineString.js +18 -0
- package/lib/TypesDiscovery/CustomParsingTypes/typed_string.d.ts +6 -0
- package/lib/TypesDiscovery/CustomParsingTypes/typed_string.js +34 -0
- package/lib/TypesDiscovery/JsonSchema/$ref.d.ts +7 -0
- package/lib/TypesDiscovery/JsonSchema/$ref.js +33 -0
- package/lib/TypesDiscovery/JsonSchema/const.d.ts +6 -0
- package/lib/TypesDiscovery/JsonSchema/const.js +22 -0
- package/lib/TypesDiscovery/JsonSchema/enum.d.ts +6 -0
- package/lib/TypesDiscovery/JsonSchema/enum.js +22 -0
- package/lib/TypesDiscovery/JsonSchema/properties.d.ts +4 -0
- package/lib/TypesDiscovery/JsonSchema/properties.js +14 -0
- package/lib/TypesDiscovery/non_array_object_property.d.ts +4 -0
- package/lib/TypesDiscovery/non_array_object_property.js +11 -0
- package/lib/TypesDiscovery/non_empty_array_property.d.ts +4 -0
- package/lib/TypesDiscovery/non_empty_array_property.js +11 -0
- package/lib/TypesDiscovery.d.ts +24 -0
- package/lib/TypesDiscovery.js +77 -0
- package/lib/TypesGeneration/validators.d.ts +9 -0
- package/lib/TypesGeneration/validators.js +26 -0
- package/lib/TypesGeneration.d.ts +17 -0
- package/lib/TypesGeneration.js +53 -0
- package/lib/__dirname.d.ts +1 -0
- package/lib/__dirname.js +6 -0
- package/lib/helpers.d.ts +5 -0
- package/lib/helpers.js +29 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +9 -0
- package/package.json +39 -0
- package/schema/update8.schema.json +8848 -0
- package/setup_PerformanceObserver.d.ts +3 -0
- package/setup_PerformanceObserver.js +55 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { IntersectionTypeNode, TypeLiteralNode, TypeReferenceNode } from 'typescript';
|
|
2
|
+
import { TypeDefinitionDiscovery } from '../../TypeDefinitionDiscovery';
|
|
3
|
+
import { GeneratorDoesDiscovery } from '../GeneratorDoesDiscovery';
|
|
4
|
+
export type RawData = {
|
|
5
|
+
type: 'object';
|
|
6
|
+
required?: [string, ...string[]];
|
|
7
|
+
additionalProperties: false;
|
|
8
|
+
properties: {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
not?: {
|
|
12
|
+
anyOf: {
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}[];
|
|
15
|
+
} | {
|
|
16
|
+
oneOf: {
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const schema: {
|
|
22
|
+
type: string;
|
|
23
|
+
required: string[];
|
|
24
|
+
additionalProperties: boolean;
|
|
25
|
+
properties: {
|
|
26
|
+
$ref: {
|
|
27
|
+
type: string;
|
|
28
|
+
pattern: string;
|
|
29
|
+
};
|
|
30
|
+
type: {
|
|
31
|
+
type: string;
|
|
32
|
+
const: string;
|
|
33
|
+
};
|
|
34
|
+
additionalProperties: {
|
|
35
|
+
type: string;
|
|
36
|
+
const: boolean;
|
|
37
|
+
};
|
|
38
|
+
unevaluatedProperties: {
|
|
39
|
+
type: string;
|
|
40
|
+
const: boolean;
|
|
41
|
+
};
|
|
42
|
+
required: {
|
|
43
|
+
type: string;
|
|
44
|
+
minItems: number;
|
|
45
|
+
items: {
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
properties: {
|
|
50
|
+
type: string;
|
|
51
|
+
minProperties: number;
|
|
52
|
+
};
|
|
53
|
+
not: {
|
|
54
|
+
oneOf: ({
|
|
55
|
+
type: string;
|
|
56
|
+
required: string[];
|
|
57
|
+
additionalProperties: boolean;
|
|
58
|
+
properties: {
|
|
59
|
+
oneOf: {
|
|
60
|
+
type: string;
|
|
61
|
+
minItems: number;
|
|
62
|
+
items: {
|
|
63
|
+
type: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
anyOf?: undefined;
|
|
67
|
+
};
|
|
68
|
+
} | {
|
|
69
|
+
type: string;
|
|
70
|
+
required: string[];
|
|
71
|
+
additionalProperties: boolean;
|
|
72
|
+
properties: {
|
|
73
|
+
anyOf: {
|
|
74
|
+
type: string;
|
|
75
|
+
minItems: number;
|
|
76
|
+
items: {
|
|
77
|
+
type: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
oneOf?: undefined;
|
|
81
|
+
};
|
|
82
|
+
})[];
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type possible = TypeLiteralNode | TypeReferenceNode | IntersectionTypeNode;
|
|
87
|
+
export declare class ObjectType extends GeneratorDoesDiscovery<RawData, possible> {
|
|
88
|
+
constructor(discovery: TypeDefinitionDiscovery);
|
|
89
|
+
generate(): (raw_data: RawData) => possible;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { adjust_class_name, create_object_type_from_entries, type_reference_node, } from '../../TsFactoryWrapper';
|
|
3
|
+
import { GeneratorDoesDiscovery, } from '../GeneratorDoesDiscovery';
|
|
4
|
+
import { is_string, } from '../../StringStartsWith';
|
|
5
|
+
export const schema = {
|
|
6
|
+
type: 'object',
|
|
7
|
+
required: ['type', 'properties'],
|
|
8
|
+
additionalProperties: false,
|
|
9
|
+
properties: {
|
|
10
|
+
$ref: { type: 'string', pattern: '^#/\\$defs/' },
|
|
11
|
+
type: { type: 'string', const: 'object' },
|
|
12
|
+
additionalProperties: { type: 'boolean', const: false },
|
|
13
|
+
unevaluatedProperties: { type: 'boolean', const: false },
|
|
14
|
+
required: {
|
|
15
|
+
type: 'array',
|
|
16
|
+
minItems: 1,
|
|
17
|
+
items: { type: 'string' },
|
|
18
|
+
},
|
|
19
|
+
properties: { type: 'object', minProperties: 1 },
|
|
20
|
+
not: {
|
|
21
|
+
oneOf: [
|
|
22
|
+
{
|
|
23
|
+
type: 'object',
|
|
24
|
+
required: ['oneOf'],
|
|
25
|
+
additionalProperties: false,
|
|
26
|
+
properties: {
|
|
27
|
+
oneOf: {
|
|
28
|
+
type: 'array',
|
|
29
|
+
minItems: 1,
|
|
30
|
+
items: { type: 'object' },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'object',
|
|
36
|
+
required: ['anyOf'],
|
|
37
|
+
additionalProperties: false,
|
|
38
|
+
properties: {
|
|
39
|
+
anyOf: {
|
|
40
|
+
type: 'array',
|
|
41
|
+
minItems: 1,
|
|
42
|
+
items: { type: 'object' },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export class ObjectType extends GeneratorDoesDiscovery {
|
|
51
|
+
constructor(discovery) {
|
|
52
|
+
super(schema, discovery);
|
|
53
|
+
}
|
|
54
|
+
generate() {
|
|
55
|
+
return (raw_data) => {
|
|
56
|
+
let type = create_object_type_from_entries(Object.entries(raw_data.properties).map((entry) => {
|
|
57
|
+
return [
|
|
58
|
+
entry[0],
|
|
59
|
+
this.discovery.find(entry[1]),
|
|
60
|
+
];
|
|
61
|
+
}), raw_data.required);
|
|
62
|
+
if ('not' in raw_data) {
|
|
63
|
+
const exclude = this.discovery.find(raw_data.not);
|
|
64
|
+
type = type_reference_node('Exclude', type, exclude);
|
|
65
|
+
}
|
|
66
|
+
else if ('$ref' in raw_data && is_string(raw_data.$ref)) {
|
|
67
|
+
type = ts.factory.createIntersectionTypeNode([
|
|
68
|
+
type_reference_node(adjust_class_name(`${raw_data.$ref.substring(8)}__type`)),
|
|
69
|
+
type,
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
return type;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=ObjectType.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Ajv from 'ajv/dist/2020';
|
|
2
|
+
import { LiteralTypeNode, StringLiteral } from 'typescript';
|
|
3
|
+
import { Generator } from '../../Generator';
|
|
4
|
+
type RawData = {
|
|
5
|
+
type: 'string';
|
|
6
|
+
const: string;
|
|
7
|
+
};
|
|
8
|
+
type Type = (LiteralTypeNode & {
|
|
9
|
+
literal: StringLiteral;
|
|
10
|
+
});
|
|
11
|
+
export declare const schema: {
|
|
12
|
+
type: string;
|
|
13
|
+
required: string[];
|
|
14
|
+
additionalProperties: boolean;
|
|
15
|
+
properties: {
|
|
16
|
+
type: {
|
|
17
|
+
type: string;
|
|
18
|
+
const: string;
|
|
19
|
+
};
|
|
20
|
+
const: {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare class Const extends Generator<RawData, Type> {
|
|
26
|
+
constructor(ajv: Ajv);
|
|
27
|
+
generate(): (raw_data: RawData) => Type;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { create_literal, } from '../../../TsFactoryWrapper';
|
|
2
|
+
import { Generator, } from '../../Generator';
|
|
3
|
+
export const schema = {
|
|
4
|
+
type: 'object',
|
|
5
|
+
required: ['type', 'const'],
|
|
6
|
+
additionalProperties: false,
|
|
7
|
+
properties: {
|
|
8
|
+
type: { type: 'string', const: 'string' },
|
|
9
|
+
const: { type: 'string' },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
export class Const extends Generator {
|
|
13
|
+
constructor(ajv) {
|
|
14
|
+
super(ajv, schema);
|
|
15
|
+
}
|
|
16
|
+
generate() {
|
|
17
|
+
return (raw_data) => create_literal(raw_data.const);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Const.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Generator } from '../../../Generator';
|
|
2
|
+
import ts, { KeywordTypeNode, UnionTypeNode } from 'typescript';
|
|
3
|
+
import Ajv from 'ajv/dist/2020';
|
|
4
|
+
export type boolean_or_null_type = {
|
|
5
|
+
type: 'string';
|
|
6
|
+
enum: ['True', 'False'];
|
|
7
|
+
} | {
|
|
8
|
+
type: 'string';
|
|
9
|
+
enum: ['True', 'False', ''];
|
|
10
|
+
};
|
|
11
|
+
type boolean_or_null_return = KeywordTypeNode<ts.SyntaxKind.BooleanKeyword> | UnionTypeNode;
|
|
12
|
+
export declare class BooleanEnum extends Generator<boolean_or_null_type, KeywordTypeNode<ts.SyntaxKind.BooleanKeyword> | UnionTypeNode> {
|
|
13
|
+
constructor(ajv: Ajv);
|
|
14
|
+
generate(): (raw_data: boolean_or_null_type) => boolean_or_null_return;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Generator, } from '../../../Generator';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
import { create_literal, create_union, } from '../../../../TsFactoryWrapper';
|
|
4
|
+
export class BooleanEnum extends Generator {
|
|
5
|
+
constructor(ajv) {
|
|
6
|
+
super(ajv, {
|
|
7
|
+
type: 'object',
|
|
8
|
+
required: ['type', 'enum'],
|
|
9
|
+
additionalProperties: false,
|
|
10
|
+
properties: {
|
|
11
|
+
type: { type: 'string', const: 'string' },
|
|
12
|
+
enum: {
|
|
13
|
+
oneOf: [
|
|
14
|
+
{
|
|
15
|
+
type: 'array',
|
|
16
|
+
minItems: 2,
|
|
17
|
+
maxItems: 2,
|
|
18
|
+
prefixItems: [
|
|
19
|
+
{ type: 'string', const: 'True' },
|
|
20
|
+
{ type: 'string', const: 'False' },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'array',
|
|
25
|
+
minItems: 3,
|
|
26
|
+
maxItems: 3,
|
|
27
|
+
prefixItems: [
|
|
28
|
+
{ type: 'string', const: 'True' },
|
|
29
|
+
{ type: 'string', const: 'False' },
|
|
30
|
+
{ type: 'string', const: '' },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
generate() {
|
|
39
|
+
return (raw_data) => {
|
|
40
|
+
const boolean = ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword);
|
|
41
|
+
return 2 === raw_data.enum.length
|
|
42
|
+
? boolean
|
|
43
|
+
: create_union(boolean, create_literal(null));
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=BooleanEnum.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Generator } from '../../Generator';
|
|
2
|
+
import Ajv from 'ajv/dist/2020';
|
|
3
|
+
import { LiteralTypeNode, StringLiteral, UnionTypeNode } from 'typescript';
|
|
4
|
+
type RawData = {
|
|
5
|
+
type: 'string';
|
|
6
|
+
enum: [string, ...string[]];
|
|
7
|
+
};
|
|
8
|
+
type Type = UnionTypeNode & {
|
|
9
|
+
types: [
|
|
10
|
+
(LiteralTypeNode & {
|
|
11
|
+
literal: StringLiteral;
|
|
12
|
+
}),
|
|
13
|
+
...(LiteralTypeNode & {
|
|
14
|
+
literal: StringLiteral;
|
|
15
|
+
})[]
|
|
16
|
+
];
|
|
17
|
+
};
|
|
18
|
+
export declare const schema: {
|
|
19
|
+
type: string;
|
|
20
|
+
required: string[];
|
|
21
|
+
additionalProperties: boolean;
|
|
22
|
+
properties: {
|
|
23
|
+
type: {
|
|
24
|
+
type: string;
|
|
25
|
+
const: string;
|
|
26
|
+
};
|
|
27
|
+
enum: {
|
|
28
|
+
type: string;
|
|
29
|
+
minItems: number;
|
|
30
|
+
items: {
|
|
31
|
+
type: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare class Enum extends Generator<RawData, Type> {
|
|
37
|
+
constructor(ajv: Ajv);
|
|
38
|
+
generate(): (raw_data: RawData) => Type;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Generator, } from '../../Generator';
|
|
2
|
+
import { create_typed_union, } from '../../../TsFactoryWrapper';
|
|
3
|
+
export const schema = {
|
|
4
|
+
type: 'object',
|
|
5
|
+
required: ['type', 'enum'],
|
|
6
|
+
additionalProperties: false,
|
|
7
|
+
properties: {
|
|
8
|
+
type: { type: 'string', const: 'string' },
|
|
9
|
+
enum: { type: 'array', minItems: 1, items: { type: 'string' } },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
export class Enum extends Generator {
|
|
13
|
+
constructor(ajv) {
|
|
14
|
+
super(ajv, schema);
|
|
15
|
+
}
|
|
16
|
+
generate() {
|
|
17
|
+
return (raw_data) => {
|
|
18
|
+
return create_typed_union(raw_data.enum);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=Enum.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Ajv from 'ajv/dist/2020';
|
|
2
|
+
import { TypeReferenceNode } from 'typescript';
|
|
3
|
+
import { Generator } from '../../Generator';
|
|
4
|
+
export declare class Pattern extends Generator<{
|
|
5
|
+
type: 'string';
|
|
6
|
+
pattern: string;
|
|
7
|
+
}, TypeReferenceNode> {
|
|
8
|
+
constructor(ajv: Ajv);
|
|
9
|
+
generate(): (raw_data: {
|
|
10
|
+
type: 'string';
|
|
11
|
+
pattern: string;
|
|
12
|
+
}) => TypeReferenceNode;
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { create_literal, type_reference_node, } from '../../../TsFactoryWrapper';
|
|
2
|
+
import { Generator, } from '../../Generator';
|
|
3
|
+
export class Pattern extends Generator {
|
|
4
|
+
constructor(ajv) {
|
|
5
|
+
super(ajv, {
|
|
6
|
+
type: 'object',
|
|
7
|
+
required: ['type', 'pattern'],
|
|
8
|
+
additionalProperties: false,
|
|
9
|
+
properties: {
|
|
10
|
+
type: { type: 'string', const: 'string' },
|
|
11
|
+
pattern: { type: 'string' },
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
generate() {
|
|
16
|
+
return (raw_data) => {
|
|
17
|
+
return type_reference_node('StringPassedRegExp', create_literal(raw_data.pattern));
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=Pattern.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Generator } from '../Generator';
|
|
2
|
+
import { KeywordTypeNode, TypeReferenceNode } from 'typescript';
|
|
3
|
+
import Ajv from 'ajv/dist/2020';
|
|
4
|
+
export declare class StringType extends Generator<{
|
|
5
|
+
type: 'string';
|
|
6
|
+
}, KeywordTypeNode> {
|
|
7
|
+
constructor(ajv: Ajv);
|
|
8
|
+
generate(): (raw_data: {
|
|
9
|
+
type: 'string';
|
|
10
|
+
}) => KeywordTypeNode;
|
|
11
|
+
}
|
|
12
|
+
export declare class NonEmptyString extends Generator<{
|
|
13
|
+
type: 'string';
|
|
14
|
+
minLength: 1;
|
|
15
|
+
}, TypeReferenceNode> {
|
|
16
|
+
constructor(ajv: Ajv);
|
|
17
|
+
generate(): () => TypeReferenceNode;
|
|
18
|
+
}
|
|
19
|
+
export type not_matching_string_type = {
|
|
20
|
+
type: 'string';
|
|
21
|
+
enum: [string, ...string[]];
|
|
22
|
+
};
|
|
23
|
+
type RawDataNonEmptyWithExclusions = {
|
|
24
|
+
type: 'string';
|
|
25
|
+
minLength: 1;
|
|
26
|
+
not: not_matching_string_type;
|
|
27
|
+
};
|
|
28
|
+
export declare const not_matching_string_schema: {
|
|
29
|
+
type: string;
|
|
30
|
+
required: string[];
|
|
31
|
+
additionalProperties: boolean;
|
|
32
|
+
properties: {
|
|
33
|
+
type: {
|
|
34
|
+
type: string;
|
|
35
|
+
const: string;
|
|
36
|
+
};
|
|
37
|
+
enum: {
|
|
38
|
+
type: string;
|
|
39
|
+
minItems: number;
|
|
40
|
+
uniqueItems: boolean;
|
|
41
|
+
items: {
|
|
42
|
+
type: string;
|
|
43
|
+
minLength: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export declare class NonEmptyStringWithExclusions extends Generator<RawDataNonEmptyWithExclusions, TypeReferenceNode> {
|
|
49
|
+
constructor(ajv: Ajv);
|
|
50
|
+
generate(): (raw_data: RawDataNonEmptyWithExclusions) => TypeReferenceNode;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Generator, } from '../Generator';
|
|
2
|
+
import { create_literal, create_type, possibly_create_lazy_union, type_reference_node, } from '../../TsFactoryWrapper';
|
|
3
|
+
export class StringType extends Generator {
|
|
4
|
+
constructor(ajv) {
|
|
5
|
+
super(ajv, {
|
|
6
|
+
type: 'object',
|
|
7
|
+
required: ['type'],
|
|
8
|
+
additionalProperties: false,
|
|
9
|
+
properties: {
|
|
10
|
+
type: { type: 'string', const: 'string' },
|
|
11
|
+
minLength: { type: 'number', minimum: 0, not: { const: 1 } },
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
generate() {
|
|
16
|
+
return () => create_type('string');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class NonEmptyString extends Generator {
|
|
20
|
+
constructor(ajv) {
|
|
21
|
+
super(ajv, {
|
|
22
|
+
type: 'object',
|
|
23
|
+
required: ['type', 'minLength'],
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
properties: {
|
|
26
|
+
type: { type: 'string', const: 'string' },
|
|
27
|
+
minLength: { type: 'number', const: 1 },
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
generate() {
|
|
32
|
+
return () => type_reference_node('Exclude', create_type('string'), create_literal(''));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const not_matching_string_schema = {
|
|
36
|
+
type: 'object',
|
|
37
|
+
required: ['type', 'enum'],
|
|
38
|
+
additionalProperties: false,
|
|
39
|
+
properties: {
|
|
40
|
+
type: { type: 'string', const: 'string' },
|
|
41
|
+
enum: {
|
|
42
|
+
type: 'array',
|
|
43
|
+
minItems: 1,
|
|
44
|
+
uniqueItems: true,
|
|
45
|
+
items: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
minLength: 1,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export class NonEmptyStringWithExclusions extends Generator {
|
|
53
|
+
constructor(ajv) {
|
|
54
|
+
super(ajv, {
|
|
55
|
+
type: 'object',
|
|
56
|
+
required: ['type', 'minLength'],
|
|
57
|
+
additionalProperties: false,
|
|
58
|
+
properties: {
|
|
59
|
+
type: { type: 'string', const: 'string' },
|
|
60
|
+
minLength: { type: 'number', const: 1 },
|
|
61
|
+
not: not_matching_string_schema,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
generate() {
|
|
66
|
+
return (raw_data) => type_reference_node('Exclude', create_type('string'), possibly_create_lazy_union([
|
|
67
|
+
'',
|
|
68
|
+
...raw_data.not.enum,
|
|
69
|
+
]));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=String.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { UnionTypeNode } from 'typescript';
|
|
2
|
+
import { GeneratorDoesDiscovery } from '../GeneratorDoesDiscovery';
|
|
3
|
+
import { TypeDefinitionDiscovery } from '../../TypeDefinitionDiscovery';
|
|
4
|
+
type RawData = {
|
|
5
|
+
oneOf: [
|
|
6
|
+
{
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
},
|
|
9
|
+
...{
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}[]
|
|
12
|
+
];
|
|
13
|
+
} | {
|
|
14
|
+
anyOf: [
|
|
15
|
+
{
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
},
|
|
18
|
+
...{
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}[]
|
|
21
|
+
];
|
|
22
|
+
};
|
|
23
|
+
export declare const schema: {
|
|
24
|
+
oneOf: ({
|
|
25
|
+
type: string;
|
|
26
|
+
required: string[];
|
|
27
|
+
additionalProperties: boolean;
|
|
28
|
+
properties: {
|
|
29
|
+
type: {
|
|
30
|
+
type: string;
|
|
31
|
+
const: string;
|
|
32
|
+
};
|
|
33
|
+
oneOf: {
|
|
34
|
+
type: string;
|
|
35
|
+
minItems: number;
|
|
36
|
+
items: {
|
|
37
|
+
type: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
anyOf?: undefined;
|
|
41
|
+
};
|
|
42
|
+
} | {
|
|
43
|
+
type: string;
|
|
44
|
+
required: string[];
|
|
45
|
+
additionalProperties: boolean;
|
|
46
|
+
properties: {
|
|
47
|
+
anyOf: {
|
|
48
|
+
type: string;
|
|
49
|
+
minItems: number;
|
|
50
|
+
items: {
|
|
51
|
+
type: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
type?: undefined;
|
|
55
|
+
oneOf?: undefined;
|
|
56
|
+
};
|
|
57
|
+
})[];
|
|
58
|
+
};
|
|
59
|
+
export declare class oneOf_or_anyOf extends GeneratorDoesDiscovery<RawData, UnionTypeNode> {
|
|
60
|
+
constructor(discovery: TypeDefinitionDiscovery);
|
|
61
|
+
generate(): (raw_data: RawData) => UnionTypeNode;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { GeneratorDoesDiscovery, } from '../GeneratorDoesDiscovery';
|
|
3
|
+
export const schema = {
|
|
4
|
+
oneOf: [
|
|
5
|
+
{
|
|
6
|
+
type: 'object',
|
|
7
|
+
required: ['oneOf'],
|
|
8
|
+
additionalProperties: false,
|
|
9
|
+
properties: {
|
|
10
|
+
type: { type: 'string', const: 'string' },
|
|
11
|
+
oneOf: {
|
|
12
|
+
type: 'array',
|
|
13
|
+
minItems: 1,
|
|
14
|
+
items: { type: 'object' },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'object',
|
|
20
|
+
required: ['anyOf'],
|
|
21
|
+
additionalProperties: false,
|
|
22
|
+
properties: {
|
|
23
|
+
anyOf: {
|
|
24
|
+
type: 'array',
|
|
25
|
+
minItems: 1,
|
|
26
|
+
items: { type: 'object' },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
export class oneOf_or_anyOf extends GeneratorDoesDiscovery {
|
|
33
|
+
constructor(discovery) {
|
|
34
|
+
super(schema, discovery);
|
|
35
|
+
}
|
|
36
|
+
generate() {
|
|
37
|
+
return (raw_data) => {
|
|
38
|
+
const source = 'oneOf' in raw_data
|
|
39
|
+
? raw_data.oneOf
|
|
40
|
+
: raw_data.anyOf;
|
|
41
|
+
return ts.factory.createUnionTypeNode(source.map((e) => {
|
|
42
|
+
return this.discovery.find(e);
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=oneOf_or_anyOf.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Ajv from 'ajv/dist/2020';
|
|
2
|
+
import { TypesDiscovery } from './TypesDiscovery';
|
|
3
|
+
import { CandidatesDiscovery } from './TypesDiscovery/CandidatesDiscovery';
|
|
4
|
+
import ts, { TypeNode } from 'typescript';
|
|
5
|
+
import { AnyGenerator } from './TypeDefinitionDiscovery/Generator';
|
|
6
|
+
import { FilesGenerator } from './FilesGenerator';
|
|
7
|
+
import { DocsTsGenerator } from './DocsTsGenerator';
|
|
8
|
+
import { GeneratesMarkdown } from './MarkdownUtilities';
|
|
9
|
+
export type ref_discovery_type = {
|
|
10
|
+
found_types: {
|
|
11
|
+
[key: string]: (raw_data: unknown) => TypeNode;
|
|
12
|
+
};
|
|
13
|
+
missing_types: string[];
|
|
14
|
+
found_classes: {
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}[];
|
|
17
|
+
missing_classes: {
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
export declare class TypeDefinitionDiscovery extends FilesGenerator implements GeneratesMarkdown {
|
|
22
|
+
private $ref_discovery;
|
|
23
|
+
private readonly candidates;
|
|
24
|
+
readonly docs: DocsTsGenerator;
|
|
25
|
+
readonly types_discovery: TypesDiscovery;
|
|
26
|
+
constructor(types_discovery: [
|
|
27
|
+
CandidatesDiscovery,
|
|
28
|
+
...CandidatesDiscovery[]
|
|
29
|
+
], type_definition_discover: [
|
|
30
|
+
AnyGenerator,
|
|
31
|
+
...AnyGenerator[]
|
|
32
|
+
], docs: DocsTsGenerator);
|
|
33
|
+
add_candidates(...candidates: AnyGenerator[]): void;
|
|
34
|
+
discover_type_$defs(): Promise<ref_discovery_type>;
|
|
35
|
+
find(maybe: unknown): TypeNode;
|
|
36
|
+
generate_files(): AsyncGenerator<{
|
|
37
|
+
file: string;
|
|
38
|
+
node: ts.TypeAliasDeclaration;
|
|
39
|
+
}, void, unknown>;
|
|
40
|
+
generate_markdown(): Promise<string>;
|
|
41
|
+
private discover_type_definitions_from;
|
|
42
|
+
/**
|
|
43
|
+
* @todo move to DocsTsGenerator
|
|
44
|
+
*/
|
|
45
|
+
private schema_from_json;
|
|
46
|
+
private search;
|
|
47
|
+
static custom_parsing_discovery(ajv: Ajv): [AnyGenerator, ...AnyGenerator[]];
|
|
48
|
+
static standard_jsonschema_discovery(ajv: Ajv): [AnyGenerator, ...AnyGenerator[]];
|
|
49
|
+
}
|