@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.
Files changed (152) hide show
  1. package/LICENSE.md +190 -0
  2. package/README.md +81 -0
  3. package/assert/CustomAssert.d.ts +2 -0
  4. package/assert/CustomAssert.js +5 -0
  5. package/lib/AjvUtilities.d.ts +7 -0
  6. package/lib/AjvUtilities.js +59 -0
  7. package/lib/ArrayUtilities.d.ts +24 -0
  8. package/lib/ArrayUtilities.js +21 -0
  9. package/lib/CustomParsingTypes/CustomPairingTypes.d.ts +37 -0
  10. package/lib/CustomParsingTypes/CustomPairingTypes.js +42 -0
  11. package/lib/CustomParsingTypes/TypedString.d.ts +411 -0
  12. package/lib/CustomParsingTypes/TypedString.js +204 -0
  13. package/lib/CustomParsingTypes/TypedStringConst.d.ts +28 -0
  14. package/lib/CustomParsingTypes/TypedStringConst.js +35 -0
  15. package/lib/CustomParsingTypes/TypedStringEnum.d.ts +30 -0
  16. package/lib/CustomParsingTypes/TypedStringEnum.js +36 -0
  17. package/lib/CustomParsingTypes/TypedStringPattern.d.ts +64 -0
  18. package/lib/CustomParsingTypes/TypedStringPattern.js +82 -0
  19. package/lib/CustomParsingTypes/UnrealEngineString.d.ts +215 -0
  20. package/lib/CustomParsingTypes/UnrealEngineString.js +308 -0
  21. package/lib/CustomParsingTypes/ValueToRegexFormatter.d.ts +29 -0
  22. package/lib/CustomParsingTypes/ValueToRegexFormatter.js +205 -0
  23. package/lib/DataDiscovery/CustomTypes/BooleanOrBooleanExtended.d.ts +12 -0
  24. package/lib/DataDiscovery/CustomTypes/BooleanOrBooleanExtended.js +32 -0
  25. package/lib/DataDiscovery/CustomTypes/StringStartsWith.d.ts +9 -0
  26. package/lib/DataDiscovery/CustomTypes/StringStartsWith.js +19 -0
  27. package/lib/DataDiscovery/CustomTypes/TypedString.d.ts +23 -0
  28. package/lib/DataDiscovery/CustomTypes/TypedString.js +251 -0
  29. package/lib/DataDiscovery/CustomTypes/UnrealEngineString.d.ts +9 -0
  30. package/lib/DataDiscovery/CustomTypes/UnrealEngineString.js +45 -0
  31. package/lib/DataDiscovery/Generator.d.ts +19 -0
  32. package/lib/DataDiscovery/Generator.js +41 -0
  33. package/lib/DataDiscovery/JsonSchema/Array.d.ts +17 -0
  34. package/lib/DataDiscovery/JsonSchema/Array.js +41 -0
  35. package/lib/DataDiscovery/JsonSchema/Object.d.ts +61 -0
  36. package/lib/DataDiscovery/JsonSchema/Object.js +184 -0
  37. package/lib/DataDiscovery/JsonSchema/OneOf.d.ts +13 -0
  38. package/lib/DataDiscovery/JsonSchema/OneOf.js +47 -0
  39. package/lib/DataDiscovery/JsonSchema/Ref.d.ts +17 -0
  40. package/lib/DataDiscovery/JsonSchema/Ref.js +66 -0
  41. package/lib/DataDiscovery/JsonSchema/StringType.d.ts +39 -0
  42. package/lib/DataDiscovery/JsonSchema/StringType.js +121 -0
  43. package/lib/DataDiscovery/Literal.d.ts +8 -0
  44. package/lib/DataDiscovery/Literal.js +69 -0
  45. package/lib/DataDiscovery.d.ts +28 -0
  46. package/lib/DataDiscovery.js +116 -0
  47. package/lib/DocsToAutoImport/ArrayTypeNodes.d.ts +5 -0
  48. package/lib/DocsToAutoImport/ArrayTypeNodes.js +7 -0
  49. package/lib/DocsToAutoImport/ClassDeclarations.d.ts +5 -0
  50. package/lib/DocsToAutoImport/ClassDeclarations.js +14 -0
  51. package/lib/DocsToAutoImport/FunctionDeclaration.d.ts +5 -0
  52. package/lib/DocsToAutoImport/FunctionDeclaration.js +16 -0
  53. package/lib/DocsToAutoImport/LiteralTypeNodes.d.ts +5 -0
  54. package/lib/DocsToAutoImport/LiteralTypeNodes.js +23 -0
  55. package/lib/DocsToAutoImport/MethodDeclarations.d.ts +5 -0
  56. package/lib/DocsToAutoImport/MethodDeclarations.js +15 -0
  57. package/lib/DocsToAutoImport/NodeExtraction.d.ts +6 -0
  58. package/lib/DocsToAutoImport/NodeExtraction.js +21 -0
  59. package/lib/DocsToAutoImport/PropertyDeclarations.d.ts +5 -0
  60. package/lib/DocsToAutoImport/PropertyDeclarations.js +10 -0
  61. package/lib/DocsToAutoImport/TupleTypeNodes.d.ts +5 -0
  62. package/lib/DocsToAutoImport/TupleTypeNodes.js +7 -0
  63. package/lib/DocsToAutoImport/TypeLiteralNodes.d.ts +5 -0
  64. package/lib/DocsToAutoImport/TypeLiteralNodes.js +33 -0
  65. package/lib/DocsToAutoImport/TypeReferenceNodes.d.ts +5 -0
  66. package/lib/DocsToAutoImport/TypeReferenceNodes.js +7 -0
  67. package/lib/DocsToAutoImport/from_Node_array.d.ts +3 -0
  68. package/lib/DocsToAutoImport/from_Node_array.js +245 -0
  69. package/lib/DocsTsAutoImports.d.ts +21 -0
  70. package/lib/DocsTsAutoImports.js +110 -0
  71. package/lib/DocsTsGenerator/FilesGenerator.d.ts +25 -0
  72. package/lib/DocsTsGenerator/FilesGenerator.js +52 -0
  73. package/lib/DocsTsGenerator.d.ts +47 -0
  74. package/lib/DocsTsGenerator.js +188 -0
  75. package/lib/DocsValidation.d.ts +7 -0
  76. package/lib/DocsValidation.js +179 -0
  77. package/lib/Exceptions.d.ts +7 -0
  78. package/lib/Exceptions.js +13 -0
  79. package/lib/FilesGenerator.d.ts +19 -0
  80. package/lib/FilesGenerator.js +38 -0
  81. package/lib/MarkdownUtilities.d.ts +16 -0
  82. package/lib/MarkdownUtilities.js +68 -0
  83. package/lib/StringStartsWith.d.ts +10 -0
  84. package/lib/StringStartsWith.js +20 -0
  85. package/lib/TsFactoryWrapper.d.ts +80 -0
  86. package/lib/TsFactoryWrapper.js +236 -0
  87. package/lib/TypeDefinitionDiscovery/CustomParsingTypes/UnrealEngineString.d.ts +13 -0
  88. package/lib/TypeDefinitionDiscovery/CustomParsingTypes/UnrealEngineString.js +26 -0
  89. package/lib/TypeDefinitionDiscovery/CustomParsingTypes/string_starts_with.d.ts +25 -0
  90. package/lib/TypeDefinitionDiscovery/CustomParsingTypes/string_starts_with.js +20 -0
  91. package/lib/TypeDefinitionDiscovery/CustomParsingTypes/typed_string.d.ts +14 -0
  92. package/lib/TypeDefinitionDiscovery/CustomParsingTypes/typed_string.js +96 -0
  93. package/lib/TypeDefinitionDiscovery/Generator.d.ts +8 -0
  94. package/lib/TypeDefinitionDiscovery/Generator.js +8 -0
  95. package/lib/TypeDefinitionDiscovery/GeneratorDoesDiscovery.d.ts +8 -0
  96. package/lib/TypeDefinitionDiscovery/GeneratorDoesDiscovery.js +9 -0
  97. package/lib/TypeDefinitionDiscovery/JsonSchema/ArrayType.d.ts +19 -0
  98. package/lib/TypeDefinitionDiscovery/JsonSchema/ArrayType.js +61 -0
  99. package/lib/TypeDefinitionDiscovery/JsonSchema/Object/ExtendsObject.d.ts +23 -0
  100. package/lib/TypeDefinitionDiscovery/JsonSchema/Object/ExtendsObject.js +40 -0
  101. package/lib/TypeDefinitionDiscovery/JsonSchema/ObjectType.d.ts +91 -0
  102. package/lib/TypeDefinitionDiscovery/JsonSchema/ObjectType.js +76 -0
  103. package/lib/TypeDefinitionDiscovery/JsonSchema/String/Const.d.ts +29 -0
  104. package/lib/TypeDefinitionDiscovery/JsonSchema/String/Const.js +20 -0
  105. package/lib/TypeDefinitionDiscovery/JsonSchema/String/Enum/BooleanEnum.d.ts +16 -0
  106. package/lib/TypeDefinitionDiscovery/JsonSchema/String/Enum/BooleanEnum.js +47 -0
  107. package/lib/TypeDefinitionDiscovery/JsonSchema/String/Enum.d.ts +40 -0
  108. package/lib/TypeDefinitionDiscovery/JsonSchema/String/Enum.js +22 -0
  109. package/lib/TypeDefinitionDiscovery/JsonSchema/String/Pattern.d.ts +13 -0
  110. package/lib/TypeDefinitionDiscovery/JsonSchema/String/Pattern.js +21 -0
  111. package/lib/TypeDefinitionDiscovery/JsonSchema/String.d.ts +52 -0
  112. package/lib/TypeDefinitionDiscovery/JsonSchema/String.js +72 -0
  113. package/lib/TypeDefinitionDiscovery/JsonSchema/oneOf_or_anyOf.d.ts +63 -0
  114. package/lib/TypeDefinitionDiscovery/JsonSchema/oneOf_or_anyOf.js +47 -0
  115. package/lib/TypeDefinitionDiscovery.d.ts +49 -0
  116. package/lib/TypeDefinitionDiscovery.js +376 -0
  117. package/lib/TypeDefinitionWriter.d.ts +22 -0
  118. package/lib/TypeDefinitionWriter.js +233 -0
  119. package/lib/TypesDiscovery/CandidatesDiscovery.d.ts +10 -0
  120. package/lib/TypesDiscovery/CandidatesDiscovery.js +14 -0
  121. package/lib/TypesDiscovery/CustomParsingTypes/UnrealEngineString.d.ts +5 -0
  122. package/lib/TypesDiscovery/CustomParsingTypes/UnrealEngineString.js +18 -0
  123. package/lib/TypesDiscovery/CustomParsingTypes/typed_string.d.ts +6 -0
  124. package/lib/TypesDiscovery/CustomParsingTypes/typed_string.js +34 -0
  125. package/lib/TypesDiscovery/JsonSchema/$ref.d.ts +7 -0
  126. package/lib/TypesDiscovery/JsonSchema/$ref.js +33 -0
  127. package/lib/TypesDiscovery/JsonSchema/const.d.ts +6 -0
  128. package/lib/TypesDiscovery/JsonSchema/const.js +22 -0
  129. package/lib/TypesDiscovery/JsonSchema/enum.d.ts +6 -0
  130. package/lib/TypesDiscovery/JsonSchema/enum.js +22 -0
  131. package/lib/TypesDiscovery/JsonSchema/properties.d.ts +4 -0
  132. package/lib/TypesDiscovery/JsonSchema/properties.js +14 -0
  133. package/lib/TypesDiscovery/non_array_object_property.d.ts +4 -0
  134. package/lib/TypesDiscovery/non_array_object_property.js +11 -0
  135. package/lib/TypesDiscovery/non_empty_array_property.d.ts +4 -0
  136. package/lib/TypesDiscovery/non_empty_array_property.js +11 -0
  137. package/lib/TypesDiscovery.d.ts +24 -0
  138. package/lib/TypesDiscovery.js +77 -0
  139. package/lib/TypesGeneration/validators.d.ts +9 -0
  140. package/lib/TypesGeneration/validators.js +26 -0
  141. package/lib/TypesGeneration.d.ts +17 -0
  142. package/lib/TypesGeneration.js +53 -0
  143. package/lib/__dirname.d.ts +1 -0
  144. package/lib/__dirname.js +6 -0
  145. package/lib/helpers.d.ts +5 -0
  146. package/lib/helpers.js +29 -0
  147. package/lib/index.d.ts +8 -0
  148. package/lib/index.js +9 -0
  149. package/package.json +39 -0
  150. package/schema/update8.schema.json +8848 -0
  151. package/setup_PerformanceObserver.d.ts +3 -0
  152. package/setup_PerformanceObserver.js +55 -0
@@ -0,0 +1,13 @@
1
+ import { ConverterMatchesSchema, ExpressionResult } from '../Generator';
2
+ import { DataDiscovery } from '../../DataDiscovery';
3
+ import { SchemaObject } from 'ajv/dist/2020';
4
+ type oneOf = {
5
+ oneOf: [SchemaObject, ...SchemaObject[]];
6
+ };
7
+ export declare class OneOfConverter extends ConverterMatchesSchema<oneOf> {
8
+ private readonly discovery;
9
+ constructor(discovery: DataDiscovery);
10
+ can_convert_schema_and_raw_data(schema: SchemaObject, raw_data: unknown): Promise<boolean>;
11
+ convert(schema: oneOf, raw_data: unknown): Promise<ExpressionResult>;
12
+ }
13
+ export {};
@@ -0,0 +1,47 @@
1
+ import { Converter, ConverterMatchesSchema, } from '../Generator';
2
+ import { NoMatchError, } from '../../Exceptions';
3
+ const schema = {
4
+ type: 'object',
5
+ required: ['oneOf'],
6
+ additionalProperties: false,
7
+ properties: {
8
+ oneOf: {
9
+ type: 'array',
10
+ minItems: 1,
11
+ items: { type: 'object', minProperties: 1 },
12
+ },
13
+ },
14
+ };
15
+ export class OneOfConverter extends ConverterMatchesSchema {
16
+ discovery;
17
+ constructor(discovery) {
18
+ super(discovery.docs.ajv, schema);
19
+ this.discovery = discovery;
20
+ }
21
+ async can_convert_schema_and_raw_data(schema, raw_data) {
22
+ if (this.can_convert_schema(schema)) {
23
+ for (const entry of schema.oneOf) {
24
+ if (await Converter.has_matching_schema_and_raw_data(await this.discovery.candidates, entry, raw_data)) {
25
+ return true;
26
+ }
27
+ }
28
+ }
29
+ return false;
30
+ }
31
+ async convert(schema, raw_data) {
32
+ const candidates = await this.discovery.candidates;
33
+ for (const entry of schema.oneOf) {
34
+ const converter = await Converter.has_matching_schema_and_raw_data(candidates, entry, raw_data);
35
+ if (converter
36
+ && await converter.can_convert_schema_and_raw_data(entry, raw_data)) {
37
+ return await converter.convert(entry, raw_data);
38
+ }
39
+ }
40
+ throw new NoMatchError({
41
+ schema,
42
+ raw_data,
43
+ oneOf: await Promise.all(schema.oneOf.map((e) => Converter.has_matching_schema_and_raw_data(candidates, e, raw_data))),
44
+ }, 'Unable to convert data!');
45
+ }
46
+ }
47
+ //# sourceMappingURL=OneOf.js.map
@@ -0,0 +1,17 @@
1
+ import { Converter, ConverterMatchesSchema, ExpressionResult } from '../Generator';
2
+ import { local_ref } from '../../StringStartsWith';
3
+ import { DataDiscovery } from '../../DataDiscovery';
4
+ import { SchemaObject } from 'ajv/dist/2020';
5
+ type schema_type = {
6
+ $ref: local_ref<string>;
7
+ };
8
+ type final_resolve_result = [SchemaObject, Converter<SchemaObject>];
9
+ export declare class Ref extends ConverterMatchesSchema<schema_type> {
10
+ private readonly cache;
11
+ private readonly discovery;
12
+ constructor(discovery: DataDiscovery);
13
+ can_convert_schema_and_raw_data(schema: SchemaObject, raw_data: unknown): Promise<boolean>;
14
+ convert(schema: schema_type, raw_data: schema_type): Promise<ExpressionResult>;
15
+ resolve_to_final_converter_schema_only(schema: schema_type): Promise<final_resolve_result>;
16
+ }
17
+ export {};
@@ -0,0 +1,66 @@
1
+ import { Converter, ConverterMatchesSchema, } from '../Generator';
2
+ import { NoMatchError, } from '../../Exceptions';
3
+ export class Ref extends ConverterMatchesSchema {
4
+ cache = {};
5
+ discovery;
6
+ constructor(discovery) {
7
+ super(discovery.docs.ajv, {
8
+ type: 'object',
9
+ required: ['$ref'],
10
+ additionalProperties: false,
11
+ properties: {
12
+ $ref: { type: 'string', pattern: '^#/\\$defs/' },
13
+ },
14
+ });
15
+ this.discovery = discovery;
16
+ }
17
+ async can_convert_schema_and_raw_data(schema, raw_data) {
18
+ performance.mark(`${this.constructor.name}.can_convert_schema_and_raw_data() start`);
19
+ if (!this.can_convert_schema(schema)) {
20
+ performance.measure(`${this.constructor.name}.can_convert_schema_and_raw_data() early exit`, `${this.constructor.name}.can_convert_schema_and_raw_data() start`);
21
+ return false;
22
+ }
23
+ const maybe = await this.resolve_to_final_converter_schema_only(schema);
24
+ const [definition, converter] = maybe;
25
+ const result = await converter.can_convert_schema_and_raw_data(definition, raw_data);
26
+ performance.measure(`${this.constructor.name}.can_convert_schema_and_raw_data() resolved`, `${this.constructor.name}.can_convert_schema_and_raw_data() start`);
27
+ return result;
28
+ }
29
+ async convert(schema, raw_data) {
30
+ performance.mark(`${this.constructor.name}.convert() start`);
31
+ const maybe = await this.resolve_to_final_converter_schema_only(schema);
32
+ if (undefined === maybe) {
33
+ throw new NoMatchError({
34
+ schema,
35
+ raw_data,
36
+ }, 'No final converter found!');
37
+ }
38
+ const [definition, converter,] = maybe;
39
+ const result = await converter.convert(definition, raw_data);
40
+ performance.measure(`${this.constructor.name}.convert()`, `${this.constructor.name}.convert() start`);
41
+ return result;
42
+ }
43
+ async resolve_to_final_converter_schema_only(schema) {
44
+ let checking = schema;
45
+ performance.mark(`${this.constructor.name}.resolve_to_final_converter_schema_only() start`);
46
+ if (!(schema.$ref in this.cache)) {
47
+ while (this.can_convert_schema(checking)) {
48
+ checking = await this.discovery.docs.definition(checking.$ref.substring(8));
49
+ }
50
+ if (this.can_convert_schema(checking)) {
51
+ throw new NoMatchError({
52
+ schema,
53
+ checking,
54
+ }, 'Did not resolve past $ref type');
55
+ }
56
+ const converter = await Converter.find_matching_schema(await this.discovery.candidates, checking);
57
+ performance.measure(`${this.constructor.name}.resolve_to_final_converter_schema_only()`, `${this.constructor.name}.resolve_to_final_converter_schema_only() start`);
58
+ this.cache[schema.$ref] = [checking, converter];
59
+ }
60
+ else {
61
+ performance.measure(`${this.constructor.name}.resolve_to_final_converter_schema_only() cached`, `${this.constructor.name}.resolve_to_final_converter_schema_only() start`);
62
+ }
63
+ return this.cache[schema.$ref];
64
+ }
65
+ }
66
+ //# sourceMappingURL=Ref.js.map
@@ -0,0 +1,39 @@
1
+ import { ConverterMatchesSchema, ExpressionResult } from '../Generator';
2
+ import Ajv, { SchemaObject } from 'ajv/dist/2020';
3
+ import { enum_schema_type } from '../../CustomParsingTypes/TypedStringEnum';
4
+ import { const_schema_type } from '../../CustomParsingTypes/TypedStringConst';
5
+ import { AsExpression, StringLiteral } from 'typescript';
6
+ export type string_schema = {
7
+ type: 'string';
8
+ minLength?: number;
9
+ };
10
+ export type pattern_schema = {
11
+ type: 'string';
12
+ pattern: string;
13
+ };
14
+ declare abstract class StringConverter<Schema extends SchemaObject> extends ConverterMatchesSchema<Schema, string, StringLiteral> {
15
+ private readonly maybe_not;
16
+ protected constructor(ajv: Ajv, schema: SchemaObject);
17
+ can_convert_schema_and_raw_data(schema: SchemaObject, raw_data: unknown): Promise<boolean>;
18
+ }
19
+ export declare class BasicStringConverter extends StringConverter<string_schema> {
20
+ constructor(ajv: Ajv);
21
+ convert(_: string_schema, raw_data: string): Promise<ExpressionResult<StringLiteral>>;
22
+ }
23
+ declare abstract class StringConvertHasConstraints<Schema extends SchemaObject> extends StringConverter<Schema> {
24
+ convert(schema: Schema, raw_data: string): Promise<ExpressionResult<StringLiteral>>;
25
+ }
26
+ export declare class ConstStringConverter extends StringConvertHasConstraints<const_schema_type> {
27
+ constructor(ajv: Ajv);
28
+ can_convert_schema_and_raw_data(schema: SchemaObject, raw_data: unknown): Promise<boolean>;
29
+ }
30
+ export declare class EnumStringConverter extends StringConvertHasConstraints<enum_schema_type> {
31
+ constructor(ajv: Ajv);
32
+ can_convert_schema_and_raw_data(schema: SchemaObject, raw_data: unknown): Promise<boolean>;
33
+ }
34
+ export declare class PatternConverter extends ConverterMatchesSchema<pattern_schema, string, AsExpression> {
35
+ constructor(ajv: Ajv);
36
+ can_convert_schema_and_raw_data(schema: SchemaObject, raw_data: unknown): Promise<boolean>;
37
+ convert(schema: pattern_schema, raw_data: string): Promise<ExpressionResult<AsExpression>>;
38
+ }
39
+ export {};
@@ -0,0 +1,121 @@
1
+ import { ConverterMatchesSchema, ExpressionResult, } from '../Generator';
2
+ import { NoMatchError, } from '../../Exceptions';
3
+ import { is_string, } from '../../StringStartsWith';
4
+ import ts from 'typescript';
5
+ import { create_literal, type_reference_node, } from '../../TsFactoryWrapper';
6
+ import { object_has_property, value_is_non_array_object, } from '../../CustomParsingTypes/CustomPairingTypes';
7
+ import { not_matching_string_schema, } from '../../TypeDefinitionDiscovery/JsonSchema/String';
8
+ import { compile, } from '../../AjvUtilities';
9
+ class StringConverter extends ConverterMatchesSchema {
10
+ maybe_not;
11
+ constructor(ajv, schema) {
12
+ super(ajv, schema);
13
+ this.maybe_not = compile(ajv, not_matching_string_schema);
14
+ }
15
+ can_convert_schema_and_raw_data(schema, raw_data) {
16
+ if (!is_string(raw_data)
17
+ || (object_has_property(schema, 'not', value_is_non_array_object)
18
+ && (!this.maybe_not(schema.not)
19
+ || schema.not.enum.includes(raw_data)))) {
20
+ return Promise.resolve(false);
21
+ }
22
+ return Promise.resolve(this.can_convert_schema(schema));
23
+ }
24
+ }
25
+ export class BasicStringConverter extends StringConverter {
26
+ constructor(ajv) {
27
+ super(ajv, {
28
+ type: 'object',
29
+ required: ['type'],
30
+ additionalProperties: false,
31
+ properties: {
32
+ type: { type: 'string', const: 'string' },
33
+ minLength: { type: 'number', minimum: 0 },
34
+ not: not_matching_string_schema,
35
+ },
36
+ });
37
+ }
38
+ convert(_, raw_data) {
39
+ return Promise.resolve(new ExpressionResult(ts.factory.createStringLiteral(raw_data)));
40
+ }
41
+ }
42
+ class StringConvertHasConstraints extends StringConverter {
43
+ async convert(schema, raw_data) {
44
+ if (!await this.can_convert_schema_and_raw_data(schema, raw_data)) {
45
+ throw new NoMatchError({
46
+ schema,
47
+ raw_data,
48
+ }, 'Raw data probably did not pass check!');
49
+ }
50
+ return Promise.resolve(new ExpressionResult(ts.factory.createStringLiteral(raw_data)));
51
+ }
52
+ }
53
+ export class ConstStringConverter extends StringConvertHasConstraints {
54
+ constructor(ajv) {
55
+ super(ajv, {
56
+ type: 'object',
57
+ required: ['type', 'const'],
58
+ additionalProperties: false,
59
+ properties: {
60
+ type: { type: 'string', const: 'string' },
61
+ const: { type: 'string' },
62
+ },
63
+ });
64
+ }
65
+ can_convert_schema_and_raw_data(schema, raw_data) {
66
+ return Promise.resolve(this.can_convert_schema(schema)
67
+ && is_string(raw_data)
68
+ && schema.const === raw_data);
69
+ }
70
+ }
71
+ export class EnumStringConverter extends StringConvertHasConstraints {
72
+ constructor(ajv) {
73
+ super(ajv, {
74
+ type: 'object',
75
+ required: ['type', 'enum'],
76
+ additionalProperties: false,
77
+ properties: {
78
+ type: { type: 'string', const: 'string' },
79
+ enum: {
80
+ type: 'array',
81
+ minItems: 1,
82
+ items: { type: 'string' },
83
+ },
84
+ },
85
+ });
86
+ }
87
+ can_convert_schema_and_raw_data(schema, raw_data) {
88
+ return Promise.resolve(this.can_convert_schema(schema)
89
+ && is_string(raw_data)
90
+ && schema.enum.includes(raw_data));
91
+ }
92
+ }
93
+ export class PatternConverter extends ConverterMatchesSchema {
94
+ constructor(ajv) {
95
+ super(ajv, {
96
+ type: 'object',
97
+ required: ['type', 'pattern'],
98
+ additionalProperties: false,
99
+ properties: {
100
+ type: { type: 'string', const: 'string' },
101
+ pattern: { type: 'string', minLength: 2 },
102
+ },
103
+ });
104
+ }
105
+ can_convert_schema_and_raw_data(schema, raw_data) {
106
+ return Promise.resolve(this.can_convert_schema(schema)
107
+ && is_string(raw_data)
108
+ && (new RegExp(schema.pattern)).test(raw_data));
109
+ }
110
+ async convert(schema, raw_data) {
111
+ if (!this.can_convert_schema(schema)
112
+ || !await this.can_convert_schema_and_raw_data(schema, raw_data)) {
113
+ throw new NoMatchError({
114
+ schema,
115
+ raw_data,
116
+ }, 'Cannot convert schema!');
117
+ }
118
+ return Promise.resolve(new ExpressionResult(ts.factory.createAsExpression(ts.factory.createStringLiteral(raw_data), type_reference_node('StringPassedRegExp', create_literal(schema.pattern)))));
119
+ }
120
+ }
121
+ //# sourceMappingURL=StringType.js.map
@@ -0,0 +1,8 @@
1
+ import { ArrayLiteralExpression, Expression, FalseLiteral, Identifier, ObjectLiteralExpression, StringLiteral, TrueLiteral } from 'typescript';
2
+ export declare class Literal {
3
+ array_literal(from: unknown[]): Promise<ArrayLiteralExpression>;
4
+ object_literal(from: {
5
+ [key: string]: unknown;
6
+ }): Promise<ObjectLiteralExpression>;
7
+ value_literal(from: unknown): Promise<StringLiteral | TrueLiteral | FalseLiteral | Identifier | ArrayLiteralExpression | Expression | ObjectLiteralExpression>;
8
+ }
@@ -0,0 +1,69 @@
1
+ import { property_name_or_computed, } from '../TsFactoryWrapper';
2
+ import { NoMatchError, } from '../Exceptions';
3
+ import { ExpressionResult, } from './Generator';
4
+ import { is_string, } from '../StringStartsWith';
5
+ import { value_is_non_array_object, } from '../CustomParsingTypes/CustomPairingTypes';
6
+ import ts from 'typescript';
7
+ export class Literal {
8
+ async array_literal(from) {
9
+ const items = [];
10
+ for (const e of from) {
11
+ items.push(await this.value_literal(e));
12
+ }
13
+ return ts.factory.createArrayLiteralExpression(items);
14
+ }
15
+ async object_literal(from) {
16
+ const properties = [];
17
+ for (const entry of Object.entries(from)) {
18
+ try {
19
+ const value = this.value_literal(entry[1]);
20
+ properties.push(ts.factory.createPropertyAssignment(property_name_or_computed(entry[0]), await value));
21
+ }
22
+ catch (error) {
23
+ throw new NoMatchError({
24
+ property: entry[0],
25
+ original_value: entry[1],
26
+ error,
27
+ }, 'Failed to convert property value!');
28
+ }
29
+ }
30
+ return ts.factory.createObjectLiteralExpression(properties);
31
+ }
32
+ async value_literal(from) {
33
+ performance.mark(`${this.constructor.name}.value_literal() start`);
34
+ if (is_string(from)) {
35
+ const result = ts.factory.createStringLiteral(from);
36
+ performance.measure(`${this.constructor.name}.value_literal() createStringLiteral`, `${this.constructor.name}.value_literal() start`);
37
+ return result;
38
+ }
39
+ else if (from instanceof ExpressionResult) {
40
+ const result = from.expression;
41
+ performance.measure(`${this.constructor.name}.value_literal() ExpressionResult`, `${this.constructor.name}.value_literal() start`);
42
+ return result;
43
+ }
44
+ if (value_is_non_array_object(from)) {
45
+ const result = await this.object_literal(from);
46
+ performance.measure(`${this.constructor.name}.value_literal() object_literal`, `${this.constructor.name}.value_literal() start`);
47
+ return result;
48
+ }
49
+ else if ('boolean' === typeof from) {
50
+ const result = from
51
+ ? ts.factory.createTrue()
52
+ : ts.factory.createFalse();
53
+ performance.measure(`${this.constructor.name}.value_literal() boolean`, `${this.constructor.name}.value_literal() start`);
54
+ return result;
55
+ }
56
+ else if (undefined === from) {
57
+ const result = ts.factory.createIdentifier('undefined');
58
+ performance.measure(`${this.constructor.name}.value_literal() undefined`, `${this.constructor.name}.value_literal() start`);
59
+ return result;
60
+ }
61
+ else if (!(from instanceof Array)) {
62
+ throw new NoMatchError(from, 'not an array!');
63
+ }
64
+ const result = await this.array_literal(from);
65
+ performance.measure(`${this.constructor.name}.value_literal() array`, `${this.constructor.name}.value_literal() start`);
66
+ return result;
67
+ }
68
+ }
69
+ //# sourceMappingURL=Literal.js.map
@@ -0,0 +1,28 @@
1
+ import { DocsDataItem, DocsTsGenerator } from './DocsTsGenerator';
2
+ import { GeneratesMarkdown } from './MarkdownUtilities';
3
+ import { Converter } from './DataDiscovery/Generator';
4
+ import { FilesGenerator } from './FilesGenerator';
5
+ import ts from 'typescript';
6
+ import { Literal } from './DataDiscovery/Literal';
7
+ import { SchemaObject } from 'ajv/dist/2020';
8
+ type progress = {
9
+ [p: string]: string[];
10
+ };
11
+ export declare class DataDiscovery extends FilesGenerator implements GeneratesMarkdown {
12
+ private readonly progress;
13
+ readonly candidates: Promise<[
14
+ Converter<SchemaObject>,
15
+ ...Converter<SchemaObject>[]
16
+ ]>;
17
+ readonly docs: DocsTsGenerator;
18
+ readonly literal: Literal;
19
+ constructor(docs: DocsTsGenerator, literal?: Literal);
20
+ expecting(): Promise<progress>;
21
+ generate(): Promise<[ts.Expression, DocsDataItem][]>;
22
+ generate_files(): AsyncGenerator<{
23
+ file: string;
24
+ node: ts.VariableStatement;
25
+ }, void, unknown>;
26
+ generate_markdown(): Promise<string>;
27
+ }
28
+ export {};
@@ -0,0 +1,116 @@
1
+ import { reduce, remove_indentation, } from './MarkdownUtilities';
2
+ import { Converter, } from './DataDiscovery/Generator';
3
+ import { FilesGenerator, } from './FilesGenerator';
4
+ import { adjust_unrealengine_value, } from './CustomParsingTypes/UnrealEngineString';
5
+ import { adjust_class_name, create_const_statement, create_modifiers, type_reference_node, variable, } from './TsFactoryWrapper';
6
+ import ts from 'typescript';
7
+ import { UnrealEngineString, } from './TypeDefinitionDiscovery/CustomParsingTypes/UnrealEngineString';
8
+ import { ObjectConverter, PatternedObjectConverter, } from './DataDiscovery/JsonSchema/Object';
9
+ import { ArrayConverter, } from './DataDiscovery/JsonSchema/Array';
10
+ import { BooleanConverter, } from './DataDiscovery/CustomTypes/BooleanOrBooleanExtended';
11
+ import { Literal, } from './DataDiscovery/Literal';
12
+ import { TypedStringConverter, } from './DataDiscovery/CustomTypes/TypedString';
13
+ import { BasicStringConverter, ConstStringConverter, EnumStringConverter, PatternConverter, } from './DataDiscovery/JsonSchema/StringType';
14
+ import { OneOfConverter, } from './DataDiscovery/JsonSchema/OneOf';
15
+ import { StringStartsWithConverter, } from './DataDiscovery/CustomTypes/StringStartsWith';
16
+ import { UnrealEngineStringConverter, } from './DataDiscovery/CustomTypes/UnrealEngineString';
17
+ import { Ref, } from './DataDiscovery/JsonSchema/Ref';
18
+ export class DataDiscovery extends FilesGenerator {
19
+ progress = {};
20
+ candidates;
21
+ docs;
22
+ literal;
23
+ constructor(docs, literal) {
24
+ super();
25
+ this.docs = docs;
26
+ this.literal = literal || new Literal();
27
+ this.candidates = docs.schema().then(({ $defs }) => {
28
+ return [
29
+ new BooleanConverter(docs.ajv),
30
+ new ArrayConverter(this),
31
+ new BasicStringConverter(docs.ajv),
32
+ new ConstStringConverter(docs.ajv),
33
+ new EnumStringConverter(docs.ajv),
34
+ new PatternConverter(docs.ajv),
35
+ new StringStartsWithConverter(docs.ajv),
36
+ new UnrealEngineStringConverter(),
37
+ new ObjectConverter(this),
38
+ new PatternedObjectConverter(this),
39
+ new TypedStringConverter(this, $defs),
40
+ new OneOfConverter(this),
41
+ new Ref(this),
42
+ ];
43
+ });
44
+ }
45
+ async expecting() {
46
+ const json = await this.docs.get();
47
+ return Object.fromEntries(json.map(e => [e.NativeClass, e.Classes.map(e => e.ClassName)]));
48
+ }
49
+ async generate() {
50
+ const result = [];
51
+ const [schema, docs,] = await Promise.all([
52
+ this.docs.schema(),
53
+ this.docs.get(),
54
+ ]);
55
+ let index = 0;
56
+ for (const e of docs) {
57
+ performance.mark(`${this.constructor.name}.generate() start`);
58
+ const converter = await Converter.find_matching_schema(await this.candidates, schema.prefixItems[index]);
59
+ const maybe_result = await this.literal.value_literal(await converter.convert(schema.prefixItems[index], e));
60
+ performance.measure(`${this.constructor.name}.generate() on item`, `${this.constructor.name}.generate() start`);
61
+ result.push([maybe_result, e]);
62
+ ++index;
63
+ }
64
+ return result;
65
+ }
66
+ async *generate_files() {
67
+ for (const result of await this.generate()) {
68
+ const NativeClass_raw = result[1].NativeClass;
69
+ this.progress[NativeClass_raw] = [];
70
+ const entry_class_name = adjust_unrealengine_value(UnrealEngineString.fromString(NativeClass_raw).right);
71
+ const file = `data/CoreUObject/${entry_class_name}.ts`;
72
+ for (const item of result[1].Classes) {
73
+ this.progress[NativeClass_raw].push(item.ClassName);
74
+ }
75
+ performance.mark(`${this.constructor.name}.generate_files() const generation start`);
76
+ const result_statement = create_const_statement(variable(adjust_class_name(entry_class_name), result[0], type_reference_node(adjust_class_name(`${entry_class_name}__NativeClass`))));
77
+ performance.measure(`${this.constructor.name}.generate_files() const generation`, `${this.constructor.name}.generate_files() const generation start`);
78
+ yield {
79
+ file,
80
+ node: ts.factory.updateVariableStatement(result_statement, create_modifiers('export'), result_statement.declarationList),
81
+ };
82
+ }
83
+ }
84
+ async generate_markdown() {
85
+ let expected_count = 0;
86
+ const grouped_progress = {
87
+ members: [],
88
+ subgroups: Object.entries(await this.expecting()).reduce((was, is) => {
89
+ const [NativeClass, Classes] = is;
90
+ expected_count += 1 + Classes.length;
91
+ was[NativeClass] = { members: Classes, subgroups: {} };
92
+ return was;
93
+ }, {}),
94
+ };
95
+ let actual_count = 0;
96
+ for (const Classes of Object.values(this.progress)) {
97
+ actual_count += 1 + Classes.length;
98
+ }
99
+ return remove_indentation(`
100
+ # Data Progress
101
+
102
+ ${((actual_count / expected_count) * 100).toFixed(2)}% Complete (${actual_count} of ${expected_count})
103
+
104
+ ${reduce(grouped_progress).map((group) => {
105
+ return remove_indentation(`${'#'.repeat(group.depth)} ${group.title}
106
+
107
+ ${group.members.map((key) => {
108
+ const done = (group.title in this.progress
109
+ && this.progress[group.title].includes(key));
110
+ return `- [${done ? 'x' : ' '}] ${key.replace(/__/g, '\\_\\_')}`;
111
+ }).join('\n')}`);
112
+ }).join('\n\n')}
113
+ `);
114
+ }
115
+ }
116
+ //# sourceMappingURL=DataDiscovery.js.map
@@ -0,0 +1,5 @@
1
+ import { NodeExtraction } from './NodeExtraction';
2
+ import { ArrayTypeNode, Node } from 'typescript';
3
+ export declare class ArrayTypeNodes extends NodeExtraction<ArrayTypeNode> {
4
+ protected extract(nodes: ArrayTypeNode[]): Node[];
5
+ }
@@ -0,0 +1,7 @@
1
+ import { NodeExtraction, } from './NodeExtraction';
2
+ export class ArrayTypeNodes extends NodeExtraction {
3
+ extract(nodes) {
4
+ return nodes.map((e) => e.elementType);
5
+ }
6
+ }
7
+ //# sourceMappingURL=ArrayTypeNodes.js.map
@@ -0,0 +1,5 @@
1
+ import { NodeExtraction } from './NodeExtraction';
2
+ import { ClassDeclaration, Node } from 'typescript';
3
+ export declare class ClassDeclarations extends NodeExtraction<ClassDeclaration> {
4
+ protected extract(nodes: ClassDeclaration[]): Node[];
5
+ }
@@ -0,0 +1,14 @@
1
+ import { NodeExtraction, } from './NodeExtraction';
2
+ export class ClassDeclarations extends NodeExtraction {
3
+ extract(nodes) {
4
+ return nodes
5
+ .map((e) => [
6
+ e.members,
7
+ e.heritageClauses || [],
8
+ e.typeParameters || [],
9
+ e.name ? [e.name] : [],
10
+ ])
11
+ .flat(2);
12
+ }
13
+ }
14
+ //# sourceMappingURL=ClassDeclarations.js.map
@@ -0,0 +1,5 @@
1
+ import { NodeExtraction } from './NodeExtraction';
2
+ import { FunctionDeclaration, Node } from 'typescript';
3
+ export declare class FunctionDeclarations extends NodeExtraction<FunctionDeclaration> {
4
+ extract(nodes: FunctionDeclaration[]): Node[];
5
+ }
@@ -0,0 +1,16 @@
1
+ import { NodeExtraction, } from './NodeExtraction';
2
+ export class FunctionDeclarations extends NodeExtraction {
3
+ extract(nodes) {
4
+ return nodes
5
+ .map((e) => [
6
+ e.name,
7
+ ...e.parameters,
8
+ e.type,
9
+ ...(e.typeParameters || []),
10
+ ...(e.body?.statements || []),
11
+ ])
12
+ .flat()
13
+ .filter((maybe) => !!maybe);
14
+ }
15
+ }
16
+ //# sourceMappingURL=FunctionDeclaration.js.map
@@ -0,0 +1,5 @@
1
+ import { NodeExtraction } from './NodeExtraction';
2
+ import { EntityName, LiteralTypeNode } from 'typescript';
3
+ export declare class LiteralTypeNodes extends NodeExtraction<LiteralTypeNode> {
4
+ protected extract(nodes: LiteralTypeNode[]): EntityName[];
5
+ }
@@ -0,0 +1,23 @@
1
+ import { NodeExtraction, } from './NodeExtraction';
2
+ import ts from 'typescript';
3
+ import { NoMatchError, } from '../Exceptions';
4
+ export class LiteralTypeNodes extends NodeExtraction {
5
+ extract(nodes) {
6
+ if (nodes.length < 1) {
7
+ return [];
8
+ }
9
+ const types = nodes.map((e) => e.literal);
10
+ const others = [];
11
+ for (const type of types) {
12
+ if (type.kind !== ts.SyntaxKind.NullKeyword
13
+ && type.kind !== ts.SyntaxKind.StringLiteral) {
14
+ others.push(type);
15
+ }
16
+ }
17
+ if (others.length > 0) {
18
+ throw new NoMatchError(others, 'Unsupported types found!');
19
+ }
20
+ return [];
21
+ }
22
+ }
23
+ //# sourceMappingURL=LiteralTypeNodes.js.map
@@ -0,0 +1,5 @@
1
+ import { NodeExtraction } from './NodeExtraction';
2
+ import { MethodDeclaration, Node } from 'typescript';
3
+ export declare class MethodDeclarations extends NodeExtraction<MethodDeclaration> {
4
+ extract(nodes: MethodDeclaration[]): Node[];
5
+ }
@@ -0,0 +1,15 @@
1
+ import { NodeExtraction, } from './NodeExtraction';
2
+ export class MethodDeclarations extends NodeExtraction {
3
+ extract(nodes) {
4
+ return nodes
5
+ .map((e) => [
6
+ ...e.parameters,
7
+ e.type,
8
+ ...(e.typeParameters || []),
9
+ ...(e.body?.statements || []),
10
+ ])
11
+ .flat()
12
+ .filter((maybe) => !!maybe);
13
+ }
14
+ }
15
+ //# sourceMappingURL=MethodDeclarations.js.map
@@ -0,0 +1,6 @@
1
+ import { EntityName, Node } from 'typescript';
2
+ export declare abstract class NodeExtraction<T extends Node> {
3
+ readonly results: EntityName[];
4
+ constructor(nodes: T[]);
5
+ protected abstract extract(nodes: T[]): Node[];
6
+ }