@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,236 @@
1
+ import ts from 'typescript';
2
+ import { is_string, } from './StringStartsWith';
3
+ import { non_empty_map, } from './ArrayUtilities';
4
+ export function adjust_class_name(class_name) {
5
+ if ('boolean' === class_name) {
6
+ return 'Docs_boolean';
7
+ }
8
+ if ('class' === class_name) {
9
+ return 'Docs_class';
10
+ }
11
+ return class_name.replace(/[^A-Za-z_\d]/g, '_');
12
+ }
13
+ export const modifier_map = {
14
+ abstract: () => {
15
+ return ts.factory.createModifier(ts.SyntaxKind.AbstractKeyword);
16
+ },
17
+ public: () => {
18
+ return ts.factory.createModifier(ts.SyntaxKind.PublicKeyword);
19
+ },
20
+ export: () => {
21
+ return ts.factory.createModifier(ts.SyntaxKind.ExportKeyword);
22
+ },
23
+ protected: () => {
24
+ return ts.factory.createModifier(ts.SyntaxKind.ProtectedKeyword);
25
+ },
26
+ const: () => {
27
+ return ts.factory.createModifier(ts.SyntaxKind.ConstKeyword);
28
+ },
29
+ readonly: () => {
30
+ return ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword);
31
+ },
32
+ static: () => {
33
+ return ts.factory.createModifier(ts.SyntaxKind.StaticKeyword);
34
+ },
35
+ declare: () => {
36
+ return ts.factory.createModifier(ts.SyntaxKind.DeclareKeyword);
37
+ },
38
+ };
39
+ export function create_modifiers(first, ...rest) {
40
+ const modifiers = rest.reduce((was, is) => {
41
+ if (!was.includes(is)) {
42
+ was.push(is);
43
+ }
44
+ return was;
45
+ }, [first]);
46
+ return non_empty_map(modifiers, e => modifier_map[e]());
47
+ }
48
+ export function type_reference_node(name, ...type_arguments) {
49
+ return ts.factory.createTypeReferenceNode(name, type_arguments);
50
+ }
51
+ export function createClass(name, members, options = {}, type_parameters = undefined) {
52
+ let resolved_modifiers = undefined;
53
+ const resolved_heritage = [];
54
+ const { modifiers, extends: class_extends } = options;
55
+ if (modifiers && modifiers.length) {
56
+ resolved_modifiers = modifiers
57
+ .reduce((was, is) => {
58
+ if (!was.includes(is)) {
59
+ was.push(is);
60
+ }
61
+ return was;
62
+ }, [])
63
+ .map((modifier) => {
64
+ if ('export' === modifier) {
65
+ return ts.factory.createModifier(ts.SyntaxKind.ExportKeyword);
66
+ }
67
+ return ts.factory.createModifier(ts.SyntaxKind.AbstractKeyword);
68
+ });
69
+ }
70
+ if (class_extends) {
71
+ resolved_heritage.push(ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [
72
+ ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(adjust_class_name(class_extends)), undefined),
73
+ ]));
74
+ }
75
+ return ts.factory.createClassDeclaration(resolved_modifiers, ts.factory.createIdentifier(adjust_class_name(name)), type_parameters, resolved_heritage, members);
76
+ }
77
+ export function createParameter(name, type, initializer = undefined) {
78
+ return ts.factory.createParameterDeclaration(undefined, undefined, name, undefined, 'object' === typeof type
79
+ ? type
80
+ : ts.factory.createKeywordTypeNode(type), initializer);
81
+ }
82
+ function create_method(name, type_parameters, parameters, modifiers, body, return_type = undefined) {
83
+ return ts.factory.createMethodDeclaration(create_modifiers(...modifiers), undefined, name, undefined, type_parameters.length ? type_parameters : undefined, parameters.map((entry) => {
84
+ if (!(entry instanceof Array)) {
85
+ return entry;
86
+ }
87
+ const [name, type] = entry;
88
+ return createParameter(name, type);
89
+ }), return_type, ts.factory.createBlock(body));
90
+ }
91
+ export function create_method_with_type_parameters(name, type_parameters, parameters, body, modifiers, return_type = undefined) {
92
+ return create_method(name, type_parameters, parameters, modifiers, body, return_type);
93
+ }
94
+ export function create_method_without_type_parameters(name, modifiers, parameters, body, return_type = undefined) {
95
+ return create_method(name, [], parameters, modifiers, body, return_type);
96
+ }
97
+ export function create_throw(throw_this, throw_arguments, type_parameters = undefined) {
98
+ return ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier(throw_this), type_parameters, throw_arguments));
99
+ }
100
+ export function create_throw_if(throw_this, throw_if, throw_arguments, type_parameters = undefined) {
101
+ return ts.factory.createIfStatement(throw_if, create_throw(throw_this, throw_arguments, type_parameters));
102
+ }
103
+ export function template_expression_from_string(template) {
104
+ const ast = ts.createSourceFile('create_span_from_template.ts', template, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);
105
+ if (1 !== ast.statements.length) {
106
+ throw new Error('Input must have only one statement!');
107
+ }
108
+ else if (!ts.isExpressionStatement(ast.statements[0])) {
109
+ throw new Error('Input must be an expression statement!');
110
+ }
111
+ else if (!ts.isTemplateExpression(ast.statements[0].expression)) {
112
+ throw new Error('Input must be a template literal expression!');
113
+ }
114
+ return ast.statements[0].expression;
115
+ }
116
+ export function parenthesize(expression) {
117
+ return ts.factory.createParenthesizedExpression(expression);
118
+ }
119
+ export function create_property_access(on, property) {
120
+ return ts.factory.createPropertyAccessExpression(ts.isNewExpression(on) ? parenthesize(on) : on, property);
121
+ }
122
+ const type_map = {
123
+ boolean: ts.SyntaxKind.BooleanKeyword,
124
+ number: ts.SyntaxKind.NumberKeyword,
125
+ object: ts.SyntaxKind.ObjectKeyword,
126
+ string: ts.SyntaxKind.StringKeyword,
127
+ undefined: ts.SyntaxKind.UndefinedKeyword,
128
+ never: ts.SyntaxKind.NeverKeyword,
129
+ unknown: ts.SyntaxKind.UnknownKeyword,
130
+ };
131
+ export function create_type(type) {
132
+ return ts.factory.createKeywordTypeNode(type_map[type]);
133
+ }
134
+ export function create_object_type_from_entries(entries, required) {
135
+ return ts.factory.createTypeLiteralNode(entries.map((entry) => {
136
+ const [property, type] = entry;
137
+ return createPropertySignature(property, type, required ? required.includes(property) : true);
138
+ }));
139
+ }
140
+ export function createPropertySignature(property, type, required = true) {
141
+ return ts.factory.createPropertySignature(undefined, property_name_or_computed(property), required
142
+ ? undefined
143
+ : ts.factory.createToken(ts.SyntaxKind.QuestionToken), type);
144
+ }
145
+ export function needs_element_access(property) {
146
+ return /[?[\]]/.test(property);
147
+ }
148
+ export function computed_property_name_or_undefined(property) {
149
+ return needs_element_access(property)
150
+ ? ts.factory.createComputedPropertyName(ts.factory.createStringLiteral(property))
151
+ : undefined;
152
+ }
153
+ export function property_name_or_computed(property) {
154
+ return computed_property_name_or_undefined(property) || property;
155
+ }
156
+ export function minimum_size_array_of_single_type(repeat, generate, max = undefined) {
157
+ if (repeat < 0) {
158
+ throw new Error(`repeat must be greater than or equal to 0, ${repeat} given.`);
159
+ }
160
+ else if (repeat !== (repeat | 0)) {
161
+ throw new Error(`repeat must be an integer, ${repeat} given.`);
162
+ }
163
+ const types = [];
164
+ for (let iteration = 0; iteration < repeat; ++iteration) {
165
+ types.push(generate());
166
+ }
167
+ if (repeat === max) {
168
+ return ts.factory.createTupleTypeNode(types);
169
+ }
170
+ return ts.factory.createTupleTypeNode([
171
+ ...types,
172
+ ts.factory.createRestTypeNode(ts.factory.createArrayTypeNode(generate())),
173
+ ]);
174
+ }
175
+ export function create_this_assignment(property, identifier) {
176
+ return ts.factory.createExpressionStatement(ts.factory.createAssignment(needs_element_access(property)
177
+ ? ts.factory.createElementAccessExpression(ts.factory.createThis(), ts.factory.createStringLiteral(property))
178
+ : create_property_access(ts.factory.createThis(), property), is_string(identifier)
179
+ ? ts.factory.createIdentifier(identifier)
180
+ : identifier));
181
+ }
182
+ export function create_index_access(identifier, index) {
183
+ return ts.factory.createElementAccessExpression(ts.factory.createIdentifier(identifier), index);
184
+ }
185
+ export function create_literal(value) {
186
+ if (value instanceof RegExp) {
187
+ return ts.factory.createRegularExpressionLiteral(value.toString());
188
+ }
189
+ return ts.factory.createLiteralTypeNode(null === value
190
+ ? ts.factory.createNull()
191
+ : ts.factory.createStringLiteral(value));
192
+ }
193
+ export function create_union(a, b, ...rest) {
194
+ return ts.factory.createUnionTypeNode([a, b, ...rest]);
195
+ }
196
+ function map_lazy_union_item_to_type(item) {
197
+ if ('object' === typeof item) {
198
+ if ('$ref' in item) {
199
+ return type_reference_node(adjust_class_name(item.$ref.substring(8)));
200
+ }
201
+ if ('const' in item) {
202
+ return create_literal(item.const);
203
+ }
204
+ return type_reference_node('StringPassedRegExp', create_literal(item.pattern));
205
+ }
206
+ return create_literal(item);
207
+ }
208
+ export function create_lazy_union(a, b, ...rest) {
209
+ return create_union(map_lazy_union_item_to_type(a), map_lazy_union_item_to_type(b), ...rest.map(map_lazy_union_item_to_type));
210
+ }
211
+ export function possibly_create_lazy_union(items) {
212
+ if (items.length < 1) {
213
+ throw new Error('Cannot create lazy unions from empty arrays!');
214
+ }
215
+ else if (1 === items.length) {
216
+ return map_lazy_union_item_to_type(items[0]);
217
+ }
218
+ const [a, b, ...rest] = items;
219
+ return create_lazy_union(a, b, ...rest);
220
+ }
221
+ export function create_typed_union(items) {
222
+ return ts.factory.createUnionTypeNode(items.map(create_literal));
223
+ }
224
+ export function create_const_declaration_list(first, ...rest) {
225
+ return ts.factory.createVariableDeclarationList([first, ...rest], ts.NodeFlags.Const);
226
+ }
227
+ export function create_const_statement(first, ...rest) {
228
+ return ts.factory.createVariableStatement(undefined, create_const_declaration_list(first, ...rest));
229
+ }
230
+ export function variable(name, value, type = undefined) {
231
+ return ts.factory.createVariableDeclaration(name, undefined, type, value);
232
+ }
233
+ export function not(expression) {
234
+ return ts.factory.createLogicalNot(expression);
235
+ }
236
+ //# sourceMappingURL=TsFactoryWrapper.js.map
@@ -0,0 +1,13 @@
1
+ import { Generator } from '../Generator';
2
+ import { UnrealEngineString_parent_type, UnrealEngineString_type } from '../../CustomParsingTypes/UnrealEngineString';
3
+ import { TypeReferenceNode } from 'typescript';
4
+ import Ajv from 'ajv/dist/2020';
5
+ export type UnrealEngineString_left_right<left extends string = string, right extends string = string> = (Exclude<UnrealEngineString_type, true> & {
6
+ left: left;
7
+ right: right;
8
+ });
9
+ export declare class UnrealEngineString extends Generator<UnrealEngineString_parent_type, TypeReferenceNode> {
10
+ constructor(ajv: Ajv);
11
+ generate(): (raw_data: UnrealEngineString_parent_type) => TypeReferenceNode;
12
+ static fromString<left extends string = string, right extends string = string>(value: string): UnrealEngineString_left_right<left, right>;
13
+ }
@@ -0,0 +1,26 @@
1
+ import { Generator, } from '../Generator';
2
+ import { UnrealEngineString_parent_schema, UnrealEngineString_reference_type, UnrealEngineString_regex, UnrealEngineString_schema_definitions, } from '../../CustomParsingTypes/UnrealEngineString';
3
+ export class UnrealEngineString extends Generator {
4
+ constructor(ajv) {
5
+ super(ajv, {
6
+ $defs: UnrealEngineString_schema_definitions,
7
+ ...UnrealEngineString_parent_schema,
8
+ });
9
+ }
10
+ generate() {
11
+ return (raw_data) => {
12
+ return UnrealEngineString_reference_type(raw_data.UnrealEngineString);
13
+ };
14
+ }
15
+ static fromString(value) {
16
+ const result = UnrealEngineString_regex.exec(value);
17
+ if (!result) {
18
+ throw new Error(`Not an UnrealEngineString (${value})`);
19
+ }
20
+ return {
21
+ left: result[1],
22
+ right: (result[2] || result[3]),
23
+ };
24
+ }
25
+ }
26
+ //# sourceMappingURL=UnrealEngineString.js.map
@@ -0,0 +1,25 @@
1
+ import { Generator } from '../Generator';
2
+ import { TypeReferenceNode } from 'typescript';
3
+ import Ajv from 'ajv/dist/2020';
4
+ export type RawData = {
5
+ type: 'string';
6
+ string_starts_with: string;
7
+ };
8
+ export declare const schema: {
9
+ type: string;
10
+ required: string[];
11
+ additionalProperties: boolean;
12
+ properties: {
13
+ type: {
14
+ type: string;
15
+ const: string;
16
+ };
17
+ string_starts_with: {
18
+ type: string;
19
+ };
20
+ };
21
+ };
22
+ export declare class string_starts_with extends Generator<RawData, TypeReferenceNode> {
23
+ constructor(ajv: Ajv);
24
+ generate(): (raw_data: RawData) => TypeReferenceNode;
25
+ }
@@ -0,0 +1,20 @@
1
+ import { Generator, } from '../Generator';
2
+ import { create_literal, type_reference_node, } from '../../TsFactoryWrapper';
3
+ export const schema = {
4
+ type: 'object',
5
+ required: ['type', 'string_starts_with'],
6
+ additionalProperties: false,
7
+ properties: {
8
+ type: { type: 'string', const: 'string' },
9
+ string_starts_with: { type: 'string' },
10
+ },
11
+ };
12
+ export class string_starts_with extends Generator {
13
+ constructor(ajv) {
14
+ super(ajv, schema);
15
+ }
16
+ generate() {
17
+ return (raw_data) => type_reference_node('StringStartsWith', create_literal(raw_data.string_starts_with));
18
+ }
19
+ }
20
+ //# sourceMappingURL=string_starts_with.js.map
@@ -0,0 +1,14 @@
1
+ import { TupleTypeNode, TypeLiteralNode, UnionTypeNode } from 'typescript';
2
+ import { TypeDefinitionDiscovery } from '../../TypeDefinitionDiscovery';
3
+ import { GeneratorDoesDiscovery } from '../GeneratorDoesDiscovery';
4
+ import { typed_string_inner_array_prefixItems_type, typed_string_inner_array_type, typed_string_inner_object_pattern_type, typed_string_inner_object_type, typed_string_parent_type } from '../../CustomParsingTypes/TypedString';
5
+ import { local_ref } from '../../StringStartsWith';
6
+ export declare class typed_string extends GeneratorDoesDiscovery<typed_string_parent_type, TypeLiteralNode | TupleTypeNode | UnionTypeNode> {
7
+ private readonly known_types;
8
+ constructor(supported_refs: local_ref<string>[], discovery: TypeDefinitionDiscovery);
9
+ generate(): (raw_data: typed_string_parent_type) => TypeLiteralNode | TupleTypeNode | UnionTypeNode;
10
+ static is_array_type(maybe: typed_string_inner_object_type | typed_string_inner_object_pattern_type | typed_string_inner_array_type | typed_string_inner_array_prefixItems_type): maybe is typed_string_inner_array_type;
11
+ static is_object_pattern_type(maybe: typed_string_inner_object_type | typed_string_inner_object_pattern_type | typed_string_inner_array_type | typed_string_inner_array_prefixItems_type): maybe is typed_string_inner_object_pattern_type;
12
+ static is_object_type(maybe: typed_string_inner_object_type | typed_string_inner_object_pattern_type | typed_string_inner_array_type | typed_string_inner_array_prefixItems_type): maybe is typed_string_inner_object_type;
13
+ static is_prefixItems_type(maybe: typed_string_inner_object_type | typed_string_inner_object_pattern_type | typed_string_inner_array_type | typed_string_inner_array_prefixItems_type): maybe is typed_string_inner_array_prefixItems_type;
14
+ }
@@ -0,0 +1,96 @@
1
+ import ts from 'typescript';
2
+ import { create_object_type_from_entries, createPropertySignature, minimum_size_array_of_single_type, } from '../../TsFactoryWrapper';
3
+ import { GeneratorDoesDiscovery, } from '../GeneratorDoesDiscovery';
4
+ import { UnrealEngineString, } from './UnrealEngineString';
5
+ import { generate_object_parent_schema, generate_typed_string_$defs, } from '../../CustomParsingTypes/TypedString';
6
+ import { object_has_property, } from '../../CustomParsingTypes/CustomPairingTypes';
7
+ function create_combinations(values) {
8
+ const as_array = [...values.values()];
9
+ const entered = [JSON.stringify(as_array)];
10
+ const result = [as_array];
11
+ const filter_these_out = [];
12
+ for (const item of as_array) {
13
+ const filtered = as_array.filter((maybe) => {
14
+ return (maybe !== item
15
+ && !filter_these_out.includes(maybe));
16
+ });
17
+ if (filtered.length) {
18
+ for (const entry of create_combinations(new Set(filtered))) {
19
+ const json_string = JSON.stringify(entry);
20
+ if (!entered.includes(json_string)) {
21
+ entered.push(json_string);
22
+ result.push(entry);
23
+ }
24
+ }
25
+ }
26
+ }
27
+ return [...(new Set(result)).values()];
28
+ }
29
+ export class typed_string extends GeneratorDoesDiscovery {
30
+ known_types;
31
+ constructor(supported_refs, discovery) {
32
+ super({
33
+ ...generate_object_parent_schema(),
34
+ $defs: {
35
+ ...generate_typed_string_$defs(supported_refs),
36
+ },
37
+ }, discovery);
38
+ this.known_types = [
39
+ new UnrealEngineString(discovery.docs.ajv),
40
+ ];
41
+ }
42
+ generate() {
43
+ return (raw_data) => {
44
+ const { typed_string: typed_string_value } = raw_data;
45
+ if (typed_string.is_array_type(typed_string_value)) {
46
+ for (const known_type of this.known_types) {
47
+ if (known_type.check(typed_string_value.items)) {
48
+ return minimum_size_array_of_single_type(typed_string_value.minItems, () => known_type.generate()(typed_string_value.items), typed_string_value.maxItems);
49
+ }
50
+ }
51
+ return minimum_size_array_of_single_type(typed_string_value.minItems, () => this.discovery.find(typed_string_value.items), typed_string_value.maxItems);
52
+ }
53
+ else if (typed_string.is_prefixItems_type(typed_string_value)) {
54
+ return minimum_size_array_of_single_type(typed_string_value.minItems, () => ts.factory.createTupleTypeNode(typed_string_value.prefixItems.map(e => this.discovery.find(e))), typed_string_value.maxItems);
55
+ }
56
+ else if (typed_string.is_object_pattern_type(typed_string_value)) {
57
+ const [property_regex, value,] = Object.entries(typed_string_value.patternProperties)[0];
58
+ const properties = property_regex.substring(2, property_regex.length - 2).split('|');
59
+ const combinations = create_combinations(new Set(properties));
60
+ const value_generator = () => this.discovery.find(value);
61
+ const result = combinations.map((required) => {
62
+ return ts.factory.createTypeLiteralNode(required.map(property => createPropertySignature(property, value_generator())));
63
+ });
64
+ return ts.factory.createUnionTypeNode(result);
65
+ }
66
+ return create_object_type_from_entries(Object.entries(typed_string_value.properties).map((entry) => {
67
+ for (const known_type of this.known_types) {
68
+ if (known_type.check(entry[1])) {
69
+ return [
70
+ entry[0],
71
+ known_type.generate()(entry[1]),
72
+ ];
73
+ }
74
+ }
75
+ return [
76
+ entry[0],
77
+ this.discovery.find(entry[1]),
78
+ ];
79
+ }), typed_string_value.required);
80
+ };
81
+ }
82
+ static is_array_type(maybe) {
83
+ return (object_has_property(maybe, 'items')
84
+ && !object_has_property(maybe, 'prefixItems'));
85
+ }
86
+ static is_object_pattern_type(maybe) {
87
+ return object_has_property(maybe, 'minProperties');
88
+ }
89
+ static is_object_type(maybe) {
90
+ return object_has_property(maybe, 'properties');
91
+ }
92
+ static is_prefixItems_type(maybe) {
93
+ return object_has_property(maybe, 'prefixItems');
94
+ }
95
+ }
96
+ //# sourceMappingURL=typed_string.js.map
@@ -0,0 +1,8 @@
1
+ import Ajv, { SchemaObject, ValidateFunction } from 'ajv/dist/2020';
2
+ import { TypeNode } from 'typescript';
3
+ export type AnyGenerator = Generator<any>;
4
+ export declare abstract class Generator<RawData, Type extends TypeNode = TypeNode> {
5
+ readonly check: ValidateFunction<RawData>;
6
+ protected constructor(ajv: Ajv, schema: SchemaObject);
7
+ abstract generate(): (raw_data: RawData) => Type;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { compile, } from '../AjvUtilities';
2
+ export class Generator {
3
+ check;
4
+ constructor(ajv, schema) {
5
+ this.check = compile(ajv, schema);
6
+ }
7
+ }
8
+ //# sourceMappingURL=Generator.js.map
@@ -0,0 +1,8 @@
1
+ import { TypeNode } from 'typescript';
2
+ import { Generator } from './Generator';
3
+ import { TypeDefinitionDiscovery } from '../TypeDefinitionDiscovery';
4
+ import { SchemaObject } from 'ajv/dist/2020';
5
+ export declare abstract class GeneratorDoesDiscovery<RawData, Type extends TypeNode = TypeNode> extends Generator<RawData, Type> {
6
+ protected readonly discovery: TypeDefinitionDiscovery;
7
+ protected constructor(schema: SchemaObject, discovery: TypeDefinitionDiscovery);
8
+ }
@@ -0,0 +1,9 @@
1
+ import { Generator, } from './Generator';
2
+ export class GeneratorDoesDiscovery extends Generator {
3
+ discovery;
4
+ constructor(schema, discovery) {
5
+ super(discovery.docs.ajv, schema);
6
+ this.discovery = discovery;
7
+ }
8
+ }
9
+ //# sourceMappingURL=GeneratorDoesDiscovery.js.map
@@ -0,0 +1,19 @@
1
+ import { GeneratorDoesDiscovery } from '../GeneratorDoesDiscovery';
2
+ import ts, { ArrayTypeNode, TupleTypeNode } from 'typescript';
3
+ import { TypeDefinitionDiscovery } from '../../TypeDefinitionDiscovery';
4
+ type RawData = {
5
+ type: 'array';
6
+ minItems?: 1;
7
+ maxItems?: 1;
8
+ items: {
9
+ [key: string]: unknown;
10
+ } | false;
11
+ prefixItems?: {
12
+ $ref: string;
13
+ }[];
14
+ };
15
+ export declare class ArrayType extends GeneratorDoesDiscovery<RawData, TupleTypeNode | ArrayTypeNode> {
16
+ constructor(supported_refs: string[], discovery: TypeDefinitionDiscovery);
17
+ generate(): (raw_data: RawData) => ts.ArrayTypeNode | ts.TupleTypeNode;
18
+ }
19
+ export {};
@@ -0,0 +1,61 @@
1
+ import { GeneratorDoesDiscovery, } from '../GeneratorDoesDiscovery';
2
+ import ts from 'typescript';
3
+ import { object_has_non_empty_array_property, object_has_property, } from '../../CustomParsingTypes/CustomPairingTypes';
4
+ import { minimum_size_array_of_single_type, } from '../../TsFactoryWrapper';
5
+ import { NoMatchError, } from '../../Exceptions';
6
+ export class ArrayType extends GeneratorDoesDiscovery {
7
+ constructor(supported_refs, discovery) {
8
+ super({
9
+ type: 'object',
10
+ required: ['type', 'items'],
11
+ additionalProperties: false,
12
+ properties: {
13
+ type: { type: 'string', const: 'array' },
14
+ minItems: { type: 'number', minimum: 0 },
15
+ maxItems: { type: 'number', minimum: 1 },
16
+ items: {
17
+ oneOf: [
18
+ { type: 'object' },
19
+ { type: 'boolean', const: false },
20
+ ],
21
+ },
22
+ uniqueItems: { type: 'boolean', const: true },
23
+ prefixItems: {
24
+ type: 'array',
25
+ minItems: 1,
26
+ items: {
27
+ type: 'object',
28
+ required: ['$ref'],
29
+ additionalProperties: false,
30
+ properties: {
31
+ type: { type: 'string', const: 'object' },
32
+ $ref: {
33
+ type: 'string',
34
+ enum: supported_refs,
35
+ },
36
+ unevaluatedProperties: {
37
+ type: 'boolean',
38
+ const: false,
39
+ },
40
+ },
41
+ },
42
+ },
43
+ },
44
+ }, discovery);
45
+ }
46
+ generate() {
47
+ return (raw_data) => {
48
+ if (false === raw_data.items) {
49
+ if (!object_has_non_empty_array_property(raw_data, 'prefixItems')) {
50
+ throw new NoMatchError(raw_data, 'Must specify prefixItems when items is false!');
51
+ }
52
+ return ts.factory.createTupleTypeNode(raw_data.prefixItems.map(e => this.discovery.find(e)));
53
+ }
54
+ if (object_has_property(raw_data, 'minItems')) {
55
+ return minimum_size_array_of_single_type(raw_data.minItems, () => this.discovery.find(raw_data.items), raw_data.maxItems);
56
+ }
57
+ return ts.factory.createArrayTypeNode(this.discovery.find(raw_data.items));
58
+ };
59
+ }
60
+ }
61
+ //# sourceMappingURL=ArrayType.js.map
@@ -0,0 +1,23 @@
1
+ import { IntersectionTypeNode, LiteralTypeNode, TypeReferenceNode } from 'typescript';
2
+ import { RawData as ObjectTypeRawData } from '../ObjectType';
3
+ import { TypeDefinitionDiscovery } from '../../../TypeDefinitionDiscovery';
4
+ import { GeneratorDoesDiscovery } from '../../GeneratorDoesDiscovery';
5
+ import { local_ref } from '../../../StringStartsWith';
6
+ type RawData = ObjectTypeRawData & {
7
+ properties: {
8
+ [key: string]: unknown;
9
+ };
10
+ $ref: local_ref<string>;
11
+ };
12
+ type Type = TypeReferenceNode | (IntersectionTypeNode & {
13
+ types: [
14
+ TypeReferenceNode,
15
+ LiteralTypeNode
16
+ ];
17
+ });
18
+ export declare class ExtendsObject extends GeneratorDoesDiscovery<RawData, Type> {
19
+ constructor(supported_refs: string[], discovery: TypeDefinitionDiscovery);
20
+ generate(): (raw_data: RawData) => Type;
21
+ protected create_reference_type($ref: local_ref<string>): TypeReferenceNode;
22
+ }
23
+ export {};
@@ -0,0 +1,40 @@
1
+ import ts from 'typescript';
2
+ import { schema as ObjectTypeSchema, } from '../ObjectType';
3
+ import { adjust_class_name, } from '../../../TsFactoryWrapper';
4
+ import { GeneratorDoesDiscovery, } from '../../GeneratorDoesDiscovery';
5
+ export class ExtendsObject extends GeneratorDoesDiscovery {
6
+ constructor(supported_refs, discovery) {
7
+ const { type, additionalProperties, properties, ...rest } = ObjectTypeSchema;
8
+ super({
9
+ ...rest,
10
+ type,
11
+ additionalProperties,
12
+ required: ['$ref'],
13
+ properties: {
14
+ ...properties,
15
+ $ref: { type: 'string', enum: supported_refs },
16
+ unevaluatedProperties: { type: 'boolean', const: false },
17
+ },
18
+ }, discovery);
19
+ }
20
+ generate() {
21
+ return (raw_data) => {
22
+ const { $ref, properties, ...rest } = raw_data;
23
+ const reference_type = this.create_reference_type($ref);
24
+ if (undefined === properties) {
25
+ return reference_type;
26
+ }
27
+ return ts.factory.createIntersectionTypeNode([
28
+ reference_type,
29
+ this.discovery.find({
30
+ ...rest,
31
+ properties,
32
+ }),
33
+ ]);
34
+ };
35
+ }
36
+ create_reference_type($ref) {
37
+ return ts.factory.createTypeReferenceNode(adjust_class_name(`${$ref.substring(8)}__type`));
38
+ }
39
+ }
40
+ //# sourceMappingURL=ExtendsObject.js.map