@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,308 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { adjust_class_name, create_const_statement, create_index_access, create_literal, create_method_with_type_parameters, create_method_without_type_parameters, create_modifiers, create_property_access, create_this_assignment, create_throw_if, create_type, createClass, createParameter, not, parenthesize, possibly_create_lazy_union, template_expression_from_string, type_reference_node, variable, } from '../TsFactoryWrapper';
|
|
3
|
+
import { object_has_property, value_is_non_array_object, } from './CustomPairingTypes';
|
|
4
|
+
import { is_string, local_ref, } from '../StringStartsWith';
|
|
5
|
+
export const UnrealEngineString_regex = /^([^']+)'(?:"([^"]+)"|([^"]+))'$/;
|
|
6
|
+
export const UnrealEngineString_general_regex = `/(?:[A-Z-][A-Za-z0-9_-]+/)+(?:[A-Z][A-Za-z_0-9-]+\\.[A-Z][A-Za-z_0-9-]+(?:_C)?(?::[A-Z][A-Za-z0-9_]+)?|[A-Z][A-Za-z_]+\\.[A-Z][A-Za-z_]+)`;
|
|
7
|
+
export function string_or_string_array_to_node(value) {
|
|
8
|
+
if (is_string(value)) {
|
|
9
|
+
return create_literal(value);
|
|
10
|
+
}
|
|
11
|
+
return ts.factory.createUnionTypeNode(value.map(e => create_literal(e)));
|
|
12
|
+
}
|
|
13
|
+
export function is_UnrealEngineString_parent(maybe) {
|
|
14
|
+
return (value_is_non_array_object(maybe)
|
|
15
|
+
&& 3 === Object.keys(maybe).length
|
|
16
|
+
&& object_has_property(maybe, 'type')
|
|
17
|
+
&& 'string' === maybe.type
|
|
18
|
+
&& object_has_property(maybe, 'minLength')
|
|
19
|
+
&& 1 === maybe.minLength
|
|
20
|
+
&& object_has_property(maybe, 'UnrealEngineString')
|
|
21
|
+
&& (true === maybe.UnrealEngineString
|
|
22
|
+
|| is_UnrealEngineString_object(maybe.UnrealEngineString)));
|
|
23
|
+
}
|
|
24
|
+
export const UnrealEngineString_schema_definitions = {
|
|
25
|
+
UnrealEngineString_left_string: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
pattern: `^(/Script/[A-Z][A-Za-z]+.[A-Z][A-Za-z]+(?:2D)?|${UnrealEngineString_general_regex})$`,
|
|
28
|
+
},
|
|
29
|
+
UnrealEngineString_right_string: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
pattern: `^${UnrealEngineString_general_regex}$`,
|
|
32
|
+
},
|
|
33
|
+
UnrealEngineString_left: {
|
|
34
|
+
oneOf: [
|
|
35
|
+
{
|
|
36
|
+
$ref: local_ref('UnrealEngineString_left_string'),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'array',
|
|
40
|
+
minItems: 1,
|
|
41
|
+
items: {
|
|
42
|
+
$ref: local_ref('UnrealEngineString_left_string'),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
UnrealEngineString_right_starts_with: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
pattern: `^/(?:[A-Z][A-Za-z_\\-.]+/)+(?:[A-Z][A-Za-z_\\-.]+/|[A-Z][A-Za-z_\\-.]+\\.[A-Z][A-Za-z_\\-]+)$`,
|
|
50
|
+
},
|
|
51
|
+
UnrealEngineString_right: { oneOf: [
|
|
52
|
+
{
|
|
53
|
+
$ref: local_ref('UnrealEngineString_right_string'),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'array',
|
|
57
|
+
minItems: 1,
|
|
58
|
+
items: {
|
|
59
|
+
$ref: local_ref('UnrealEngineString_right_string'),
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'object',
|
|
64
|
+
required: ['starts_with'],
|
|
65
|
+
additionalProperties: false,
|
|
66
|
+
properties: { starts_with: { oneOf: [
|
|
67
|
+
{
|
|
68
|
+
$ref: local_ref('UnrealEngineString_right_starts_with'),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'array',
|
|
72
|
+
minItems: 1,
|
|
73
|
+
items: {
|
|
74
|
+
$ref: local_ref('UnrealEngineString_right_starts_with'),
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
] } },
|
|
78
|
+
},
|
|
79
|
+
] },
|
|
80
|
+
};
|
|
81
|
+
export const UnrealEngineString_schema = {
|
|
82
|
+
oneOf: [
|
|
83
|
+
{
|
|
84
|
+
type: 'object',
|
|
85
|
+
required: ['left', 'right'],
|
|
86
|
+
additionalProperties: false,
|
|
87
|
+
properties: {
|
|
88
|
+
left: {
|
|
89
|
+
$ref: local_ref('UnrealEngineString_left'),
|
|
90
|
+
},
|
|
91
|
+
right: {
|
|
92
|
+
$ref: local_ref('UnrealEngineString_right'),
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: 'object',
|
|
98
|
+
required: ['left'],
|
|
99
|
+
additionalProperties: false,
|
|
100
|
+
properties: {
|
|
101
|
+
left: {
|
|
102
|
+
$ref: local_ref('UnrealEngineString_left'),
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'object',
|
|
108
|
+
required: ['right'],
|
|
109
|
+
additionalProperties: false,
|
|
110
|
+
properties: {
|
|
111
|
+
right: {
|
|
112
|
+
$ref: local_ref('UnrealEngineString_right'),
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: 'boolean',
|
|
118
|
+
const: true,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
export const UnrealEngineString_parent_schema = {
|
|
123
|
+
type: 'object',
|
|
124
|
+
required: ['type', 'minLength', 'UnrealEngineString'],
|
|
125
|
+
additionalProperties: false,
|
|
126
|
+
properties: {
|
|
127
|
+
type: { type: 'string', const: 'string' },
|
|
128
|
+
minLength: { type: 'number', const: 1 },
|
|
129
|
+
UnrealEngineString: UnrealEngineString_schema,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
export const UnrealEngineString_left_default = [
|
|
133
|
+
'/Script/Engine.BlueprintGeneratedClass',
|
|
134
|
+
];
|
|
135
|
+
const right_value_starts_with_suffix = '(?:[A-Z][A-Za-z0-9_.]+/)*[A-Z][A-Za-z_.0-9-]+(?::[A-Z][A-Za-z0-9]+)?';
|
|
136
|
+
export class UnrealEngineString {
|
|
137
|
+
static already_configured = new WeakSet();
|
|
138
|
+
static ajv_macro_generator(inner) {
|
|
139
|
+
return (data_from_schema) => {
|
|
140
|
+
const data = true === data_from_schema ? {} : data_from_schema;
|
|
141
|
+
const left_value = ('left' in data
|
|
142
|
+
? data.left instanceof Array
|
|
143
|
+
? data.left
|
|
144
|
+
: [data.left]
|
|
145
|
+
: UnrealEngineString_left_default).join('|');
|
|
146
|
+
const right_value = 'right' in data
|
|
147
|
+
? `(?:${(data.right instanceof Array
|
|
148
|
+
? data.right
|
|
149
|
+
: [
|
|
150
|
+
is_string(data.right)
|
|
151
|
+
? data.right
|
|
152
|
+
: `(?:${(data.right
|
|
153
|
+
.starts_with instanceof Array
|
|
154
|
+
? data.right.starts_with
|
|
155
|
+
: [data.right.starts_with])
|
|
156
|
+
.map((starts_with) => `${starts_with}${right_value_starts_with_suffix}`)
|
|
157
|
+
.join('|')})`,
|
|
158
|
+
]).join('|')})`
|
|
159
|
+
: UnrealEngineString_general_regex;
|
|
160
|
+
const regex = `(?:(?:${left_value})'(?:${right_value}|"${right_value}")')`;
|
|
161
|
+
return {
|
|
162
|
+
pattern: inner ? regex : `^${regex}$`,
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
static configure_ajv(ajv) {
|
|
167
|
+
if (this.already_configured.has(ajv)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
this.already_configured.add(ajv);
|
|
171
|
+
ajv.addKeyword({
|
|
172
|
+
keyword: 'UnrealEngineString',
|
|
173
|
+
type: 'string',
|
|
174
|
+
metaSchema: {
|
|
175
|
+
$defs: UnrealEngineString_schema_definitions,
|
|
176
|
+
...UnrealEngineString_schema,
|
|
177
|
+
},
|
|
178
|
+
macro: this.ajv_macro_generator(false),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
static CustomGenerators() {
|
|
182
|
+
const UnrealEngineString_class = createClass('UnrealEngineString', [
|
|
183
|
+
ts.factory.createPropertyDeclaration(create_modifiers('readonly'), 'left', undefined, ts.factory.createTypeReferenceNode('left'), undefined),
|
|
184
|
+
ts.factory.createPropertyDeclaration(create_modifiers('readonly'), 'right', undefined, ts.factory.createTypeReferenceNode('right'), undefined),
|
|
185
|
+
create_method_without_type_parameters('constructor', ['protected'], [
|
|
186
|
+
createParameter('left', ts.factory.createTypeReferenceNode('left')),
|
|
187
|
+
createParameter('right', ts.factory.createTypeReferenceNode('right')),
|
|
188
|
+
], [
|
|
189
|
+
create_this_assignment('left', 'left'),
|
|
190
|
+
create_this_assignment('right', 'right'),
|
|
191
|
+
]),
|
|
192
|
+
create_method_with_type_parameters('fromString', [
|
|
193
|
+
ts.factory.createTypeParameterDeclaration(undefined, 'left', create_type('string'), create_type('string')),
|
|
194
|
+
ts.factory.createTypeParameterDeclaration(undefined, 'right', create_type('string'), create_type('string')),
|
|
195
|
+
], [
|
|
196
|
+
createParameter('value', create_type('string')),
|
|
197
|
+
], [
|
|
198
|
+
create_const_statement(variable('result', ts.factory.createCallExpression(create_property_access(ts.factory.createRegularExpressionLiteral(UnrealEngineString_regex.toString()), 'exec'), undefined, [
|
|
199
|
+
ts.factory.createIdentifier('value'),
|
|
200
|
+
]))),
|
|
201
|
+
create_throw_if('Error', not(ts.factory.createIdentifier('result')), [
|
|
202
|
+
template_expression_from_string('`Not an UnrealEngineString (${value})`'),
|
|
203
|
+
]),
|
|
204
|
+
ts.factory.createReturnStatement(ts.factory.createNewExpression(ts.factory.createIdentifier('UnrealEngineString'), [
|
|
205
|
+
ts.factory.createTypeReferenceNode('left'),
|
|
206
|
+
ts.factory.createTypeReferenceNode('right'),
|
|
207
|
+
], [
|
|
208
|
+
ts.factory.createAsExpression(create_index_access('result', 1), ts.factory.createTypeReferenceNode('left')),
|
|
209
|
+
ts.factory.createAsExpression(parenthesize(ts.factory.createLogicalOr(create_index_access('result', 2), create_index_access('result', 3))), ts.factory.createTypeReferenceNode('right')),
|
|
210
|
+
])),
|
|
211
|
+
], ['static'], ts.factory.createTypeReferenceNode('UnrealEngineString', [
|
|
212
|
+
ts.factory.createTypeReferenceNode('left'),
|
|
213
|
+
ts.factory.createTypeReferenceNode('right'),
|
|
214
|
+
])),
|
|
215
|
+
], {
|
|
216
|
+
modifiers: ['export'],
|
|
217
|
+
}, [
|
|
218
|
+
ts.factory.createTypeParameterDeclaration(undefined, 'left', create_type('string'), create_type('string')),
|
|
219
|
+
ts.factory.createTypeParameterDeclaration(undefined, 'right', create_type('string'), create_type('string')),
|
|
220
|
+
]);
|
|
221
|
+
return [
|
|
222
|
+
{
|
|
223
|
+
file: 'utils/validators.ts',
|
|
224
|
+
node: UnrealEngineString_class,
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
export function adjust_unrealengine_value(value) {
|
|
230
|
+
return adjust_class_name(value.replace(/^\/Script\/FactoryGame\./, ''));
|
|
231
|
+
}
|
|
232
|
+
export function flexibly_create_UnrealEngineString_reference_type(type_arguments) {
|
|
233
|
+
return type_reference_node('UnrealEngineString', ...(type_arguments || []));
|
|
234
|
+
}
|
|
235
|
+
const empty_object = {};
|
|
236
|
+
export function UnrealEngineString_reference_type(data_from_schema) {
|
|
237
|
+
const data = true === data_from_schema ? {} : data_from_schema;
|
|
238
|
+
let left_value = create_literal(UnrealEngineString_left_default[0]);
|
|
239
|
+
let left_changed = false;
|
|
240
|
+
let right_value = create_type('string');
|
|
241
|
+
let right_changed = false;
|
|
242
|
+
if ('object' === typeof data && 'left' in data) {
|
|
243
|
+
const { left } = data;
|
|
244
|
+
const left_options = [
|
|
245
|
+
...new Set(left instanceof Array ? left : [left]).values(),
|
|
246
|
+
];
|
|
247
|
+
if (1 === left_options.length) {
|
|
248
|
+
left_value = create_literal(left_options[0]);
|
|
249
|
+
}
|
|
250
|
+
else if (left_options.length > 1) {
|
|
251
|
+
left_value = possibly_create_lazy_union(left_options);
|
|
252
|
+
}
|
|
253
|
+
left_changed = true;
|
|
254
|
+
}
|
|
255
|
+
if ('object' === typeof data && 'right' in data) {
|
|
256
|
+
const { right } = data;
|
|
257
|
+
if ('object' === typeof right && 'starts_with' in right) {
|
|
258
|
+
const { starts_with } = right;
|
|
259
|
+
const right_options = [
|
|
260
|
+
...new Set(starts_with instanceof Array ? starts_with : [starts_with]).values(),
|
|
261
|
+
];
|
|
262
|
+
if (right_options.length >= 1) {
|
|
263
|
+
right_value = type_reference_node('StringStartsWith', (1 === right_options.length
|
|
264
|
+
? create_literal(right_options[0])
|
|
265
|
+
: possibly_create_lazy_union(right_options)));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
const right_options = [
|
|
270
|
+
...new Set(right instanceof Array ? right : [right]).values(),
|
|
271
|
+
];
|
|
272
|
+
if (right_options.length >= 1) {
|
|
273
|
+
right_value =
|
|
274
|
+
1 === right_options.length
|
|
275
|
+
? create_literal(right_options[0])
|
|
276
|
+
: possibly_create_lazy_union(right_options);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
right_changed = true;
|
|
280
|
+
}
|
|
281
|
+
return flexibly_create_UnrealEngineString_reference_type(left_changed || right_changed
|
|
282
|
+
? right_changed
|
|
283
|
+
? [left_value, right_value]
|
|
284
|
+
: [left_value]
|
|
285
|
+
: undefined);
|
|
286
|
+
}
|
|
287
|
+
function is_string_or_string_array(maybe) {
|
|
288
|
+
return (is_string(maybe)
|
|
289
|
+
|| (maybe instanceof Array
|
|
290
|
+
&& maybe.length >= 1
|
|
291
|
+
&& maybe.every(is_string)));
|
|
292
|
+
}
|
|
293
|
+
function is_UnrealEngineString_object(maybe) {
|
|
294
|
+
if (!value_is_non_array_object(maybe)) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
const keys = Object.keys(maybe);
|
|
298
|
+
const has_left = 'left' in maybe && is_string_or_string_array(maybe.left);
|
|
299
|
+
const has_right = object_has_property(maybe, 'right')
|
|
300
|
+
&& (value_is_non_array_object(maybe.right)
|
|
301
|
+
? 'starts_with' in maybe.right
|
|
302
|
+
&& 1 === Object.keys(maybe.right).length
|
|
303
|
+
&& is_string_or_string_array(maybe.right.starts_with)
|
|
304
|
+
: is_string_or_string_array(maybe.right));
|
|
305
|
+
return ((2 === keys.length && has_left && has_right)
|
|
306
|
+
|| (1 === keys.length && (has_left || has_right)));
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=UnrealEngineString.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SchemaObject } from 'ajv/dist/2020';
|
|
2
|
+
export declare class ValueToRegexFormatter {
|
|
3
|
+
private typed_string_const;
|
|
4
|
+
private typed_string_enum;
|
|
5
|
+
private typed_string_pattern_general;
|
|
6
|
+
private UnrealEngineString;
|
|
7
|
+
private readonly $defs;
|
|
8
|
+
private readonly supported_$ref_object;
|
|
9
|
+
constructor($defs: {
|
|
10
|
+
[key: string]: SchemaObject;
|
|
11
|
+
});
|
|
12
|
+
pattern_from_value(value: unknown): {
|
|
13
|
+
pattern: string;
|
|
14
|
+
};
|
|
15
|
+
private is_supported_$ref_object;
|
|
16
|
+
private is_supported_definition;
|
|
17
|
+
private is_Texture2D_basic;
|
|
18
|
+
private prepare_$ref_regex;
|
|
19
|
+
private Texture2D_basic_regex;
|
|
20
|
+
private typed_string_array_inner_to_regex;
|
|
21
|
+
private typed_string_object_inner_to_regex;
|
|
22
|
+
private typed_string_object_pattern_inner_to_regex;
|
|
23
|
+
private value_to_regex;
|
|
24
|
+
private static is_typed_string_array_inner;
|
|
25
|
+
private static is_typed_string_array_prefixItems;
|
|
26
|
+
private static is_typed_string_object_inner;
|
|
27
|
+
private static is_typed_string_object_parent;
|
|
28
|
+
private static is_typed_string_object_pattern_inner;
|
|
29
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { annoyingly_have_to_escape_property, is_non_empty_array, object_has_non_empty_array_property, object_has_property, object_has_property_that_equals, object_only_has_that_property, value_is_non_array_object, } from './CustomPairingTypes';
|
|
2
|
+
import { is_string, local_ref, } from '../StringStartsWith';
|
|
3
|
+
import { NoMatchError, } from '../Exceptions';
|
|
4
|
+
import { is_UnrealEngineString_parent, UnrealEngineString, } from './UnrealEngineString';
|
|
5
|
+
import { typed_string_const, } from './TypedStringConst';
|
|
6
|
+
import { typed_string_enum, } from './TypedStringEnum';
|
|
7
|
+
import { typed_string_pattern_general, typed_string_pattern_is_supported_schema, typed_string_pattern_value_regex, } from './TypedStringPattern';
|
|
8
|
+
function is_number(maybe) {
|
|
9
|
+
return 'number' === typeof maybe;
|
|
10
|
+
}
|
|
11
|
+
export class ValueToRegexFormatter {
|
|
12
|
+
typed_string_const;
|
|
13
|
+
typed_string_enum;
|
|
14
|
+
typed_string_pattern_general;
|
|
15
|
+
UnrealEngineString;
|
|
16
|
+
$defs;
|
|
17
|
+
supported_$ref_object;
|
|
18
|
+
constructor($defs) {
|
|
19
|
+
this.$defs = $defs;
|
|
20
|
+
this.UnrealEngineString = UnrealEngineString.ajv_macro_generator(true);
|
|
21
|
+
this.typed_string_const = typed_string_const;
|
|
22
|
+
this.typed_string_enum = typed_string_enum;
|
|
23
|
+
this.typed_string_pattern_general = typed_string_pattern_general;
|
|
24
|
+
this.supported_$ref_object = this.prepare_$ref_regex($defs);
|
|
25
|
+
}
|
|
26
|
+
pattern_from_value(value) {
|
|
27
|
+
return {
|
|
28
|
+
pattern: `^${this.value_to_regex(value)}$`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
is_supported_$ref_object(maybe) {
|
|
32
|
+
return (object_only_has_that_property(maybe, '$ref', is_string)
|
|
33
|
+
&& object_has_property(this.supported_$ref_object, maybe.$ref));
|
|
34
|
+
}
|
|
35
|
+
is_supported_definition(maybe) {
|
|
36
|
+
return (this.typed_string_const.is_supported_schema(maybe)
|
|
37
|
+
|| this.typed_string_enum.is_supported_schema(maybe)
|
|
38
|
+
|| this.typed_string_pattern_general.is_supported_schema(maybe)
|
|
39
|
+
|| typed_string_pattern_is_supported_schema(maybe)
|
|
40
|
+
|| is_UnrealEngineString_parent(maybe)
|
|
41
|
+
|| ValueToRegexFormatter.is_typed_string_object_parent(maybe)
|
|
42
|
+
|| (object_only_has_that_property(maybe, 'oneOf')
|
|
43
|
+
&& is_non_empty_array(maybe.oneOf, value_is_non_array_object)
|
|
44
|
+
&& maybe.oneOf.every(e => this.is_supported_definition(e))));
|
|
45
|
+
}
|
|
46
|
+
is_Texture2D_basic(maybe) {
|
|
47
|
+
return (value_is_non_array_object(maybe)
|
|
48
|
+
&& 2 === Object.keys(maybe).length
|
|
49
|
+
&& object_has_property_that_equals(maybe, 'type', 'string')
|
|
50
|
+
&& object_has_property_that_equals(maybe, 'string_starts_with', 'Texture2D /Game/FactoryGame/'));
|
|
51
|
+
}
|
|
52
|
+
prepare_$ref_regex($defs) {
|
|
53
|
+
return Object.fromEntries(Object.entries($defs)
|
|
54
|
+
.filter(maybe => {
|
|
55
|
+
return this.is_supported_definition(maybe[1]);
|
|
56
|
+
}).map(entry => {
|
|
57
|
+
return [
|
|
58
|
+
local_ref(entry[0]),
|
|
59
|
+
this.value_to_regex(entry[1]),
|
|
60
|
+
];
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
Texture2D_basic_regex() {
|
|
64
|
+
return `(?:Texture2D \\/Game\\/FactoryGame\\/(?:[A-Z][A-Za-z0-9_.]+/)*[A-Z][A-Za-z_.0-9-]+(?::[A-Z][A-Za-z0-9]+)?)`;
|
|
65
|
+
}
|
|
66
|
+
typed_string_array_inner_to_regex(typed_string_array) {
|
|
67
|
+
const regex = this.value_to_regex(typed_string_array.items);
|
|
68
|
+
return `\\(${regex}${undefined === typed_string_array.minItems
|
|
69
|
+
? ''
|
|
70
|
+
: `(?:,${regex}){${typed_string_array.minItems - 1},}`}\\)`;
|
|
71
|
+
}
|
|
72
|
+
typed_string_object_inner_to_regex(typed_string_object) {
|
|
73
|
+
return `\\(${Object.entries(typed_string_object.properties).map((entry, index) => {
|
|
74
|
+
const [property, value] = entry;
|
|
75
|
+
return `(?:${index > 0
|
|
76
|
+
? ','
|
|
77
|
+
: ''}${annoyingly_have_to_escape_property(property)}=(?:${this.value_to_regex(value)}))${typed_string_object.required.includes(property)
|
|
78
|
+
? ''
|
|
79
|
+
: '?'}`;
|
|
80
|
+
}).join('')}\\)`;
|
|
81
|
+
}
|
|
82
|
+
typed_string_object_pattern_inner_to_regex(typed_string_object) {
|
|
83
|
+
const [property_regex, value] = Object.entries(typed_string_object.patternProperties)[0];
|
|
84
|
+
const regex = `(?:${annoyingly_have_to_escape_property(property_regex.substring(1, property_regex.length - 1))})=(?:${this.value_to_regex(value)})`;
|
|
85
|
+
return `\\(${regex}(,${regex}){${typed_string_object.minProperties - 1},}\\)`;
|
|
86
|
+
}
|
|
87
|
+
value_to_regex(value) {
|
|
88
|
+
if (ValueToRegexFormatter.is_typed_string_object_inner(value)) {
|
|
89
|
+
return this.typed_string_object_inner_to_regex(value);
|
|
90
|
+
}
|
|
91
|
+
else if (ValueToRegexFormatter.is_typed_string_object_pattern_inner(value)) {
|
|
92
|
+
return this.typed_string_object_pattern_inner_to_regex(value);
|
|
93
|
+
}
|
|
94
|
+
else if (ValueToRegexFormatter.is_typed_string_object_parent(value)) {
|
|
95
|
+
return this.value_to_regex(value.typed_string);
|
|
96
|
+
}
|
|
97
|
+
else if (ValueToRegexFormatter.is_typed_string_array_inner(value)) {
|
|
98
|
+
return this.typed_string_array_inner_to_regex(value);
|
|
99
|
+
}
|
|
100
|
+
else if (this.is_supported_$ref_object(value)) {
|
|
101
|
+
return this.supported_$ref_object[value.$ref];
|
|
102
|
+
}
|
|
103
|
+
else if (this.typed_string_const.is_supported_schema(value)) {
|
|
104
|
+
return this.typed_string_const.value_regex(value);
|
|
105
|
+
}
|
|
106
|
+
else if (this.typed_string_enum.is_supported_schema(value)) {
|
|
107
|
+
return this.typed_string_enum.value_regex(value);
|
|
108
|
+
}
|
|
109
|
+
else if (this.typed_string_pattern_general.is_supported_schema(value)) {
|
|
110
|
+
return this.typed_string_pattern_general.value_regex(value);
|
|
111
|
+
}
|
|
112
|
+
else if (typed_string_pattern_is_supported_schema(value)) {
|
|
113
|
+
return typed_string_pattern_value_regex(value);
|
|
114
|
+
}
|
|
115
|
+
else if (is_UnrealEngineString_parent(value)) {
|
|
116
|
+
return this.UnrealEngineString(value.UnrealEngineString).pattern;
|
|
117
|
+
}
|
|
118
|
+
else if (object_has_non_empty_array_property(value, 'oneOf')) {
|
|
119
|
+
return `(?:${value.oneOf.map(e => this.value_to_regex(e)).join('|')})`;
|
|
120
|
+
}
|
|
121
|
+
else if (object_only_has_that_property(value, '$ref', is_string)
|
|
122
|
+
&& value.$ref.startsWith('#/$defs/')
|
|
123
|
+
&& value.$ref.substring(8) in this.$defs
|
|
124
|
+
&& object_only_has_that_property(this.$defs[value.$ref.substring(8)], 'oneOf')
|
|
125
|
+
&& is_non_empty_array(this.$defs[value.$ref.substring(8)].oneOf, value_is_non_array_object)) {
|
|
126
|
+
const oneOf = this.$defs[value.$ref.substring(8)].oneOf;
|
|
127
|
+
return `(?:${oneOf
|
|
128
|
+
.map((e) => this.value_to_regex(e))
|
|
129
|
+
.join('|')})`;
|
|
130
|
+
}
|
|
131
|
+
else if (undefined === this.supported_$ref_object
|
|
132
|
+
&& object_only_has_that_property(value, '$ref', is_string)
|
|
133
|
+
&& value.$ref.startsWith('#/$defs/')
|
|
134
|
+
&& value.$ref.substring(8) in this.$defs
|
|
135
|
+
&& this.is_supported_definition(this.$defs[value.$ref.substring(8)])) {
|
|
136
|
+
return this.value_to_regex(this.$defs[value.$ref.substring(8)]);
|
|
137
|
+
}
|
|
138
|
+
else if (this.is_Texture2D_basic(value)) {
|
|
139
|
+
return this.Texture2D_basic_regex();
|
|
140
|
+
}
|
|
141
|
+
else if (ValueToRegexFormatter.is_typed_string_array_prefixItems(value)) {
|
|
142
|
+
const item_regex = `\\(${value.prefixItems.map(e => this.value_to_regex(e)).join(', ')}\\)`;
|
|
143
|
+
return `(?:\\(${item_regex}(?:,${item_regex}){${Math.max(0, value.minItems - 1)},${value.maxItems
|
|
144
|
+
? Math.max(1, value.maxItems - 1)
|
|
145
|
+
: ''}}\\))`;
|
|
146
|
+
}
|
|
147
|
+
throw new NoMatchError(value, `Unsupported value! ${JSON.stringify(value)}`);
|
|
148
|
+
}
|
|
149
|
+
static is_typed_string_array_inner(maybe) {
|
|
150
|
+
if (!value_is_non_array_object(maybe)) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
const total_keys = Object.keys(maybe).length;
|
|
154
|
+
let expected_keys = 3;
|
|
155
|
+
if (!object_has_property(maybe, 'minItems')) {
|
|
156
|
+
--expected_keys;
|
|
157
|
+
}
|
|
158
|
+
else if (!object_has_property(maybe, 'minItems', is_number)) {
|
|
159
|
+
throw new NoMatchError(maybe, 'Unsupported minItems value!');
|
|
160
|
+
}
|
|
161
|
+
if (!object_has_property(maybe, 'maxItems')) {
|
|
162
|
+
--expected_keys;
|
|
163
|
+
}
|
|
164
|
+
else if (!object_has_property(maybe, 'maxItems', is_number)) {
|
|
165
|
+
throw new NoMatchError(maybe, 'Unsupported maxItems value!');
|
|
166
|
+
}
|
|
167
|
+
return (object_has_property(maybe, 'items')
|
|
168
|
+
&& total_keys === expected_keys);
|
|
169
|
+
}
|
|
170
|
+
static is_typed_string_array_prefixItems(maybe) {
|
|
171
|
+
if (!value_is_non_array_object(maybe)) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
const total_keys = Object.keys(maybe).length;
|
|
175
|
+
let expected_keys = 4;
|
|
176
|
+
if (!object_has_property(maybe, 'maxItems')) {
|
|
177
|
+
--expected_keys;
|
|
178
|
+
}
|
|
179
|
+
else if (!object_has_property(maybe, 'maxItems', is_number)) {
|
|
180
|
+
throw new NoMatchError(maybe, 'Unsupported maxItems value!');
|
|
181
|
+
}
|
|
182
|
+
return (object_has_property_that_equals(maybe, 'items', false)
|
|
183
|
+
&& object_has_non_empty_array_property(maybe, 'prefixItems', value_is_non_array_object)
|
|
184
|
+
&& total_keys === expected_keys);
|
|
185
|
+
}
|
|
186
|
+
static is_typed_string_object_inner(maybe) {
|
|
187
|
+
return (object_has_non_empty_array_property(maybe, 'required', is_string)
|
|
188
|
+
&& object_has_property(maybe, 'properties', value_is_non_array_object)
|
|
189
|
+
&& 2 === Object.keys(maybe).length);
|
|
190
|
+
}
|
|
191
|
+
static is_typed_string_object_parent(maybe) {
|
|
192
|
+
return (object_has_property_that_equals(maybe, 'type', 'string')
|
|
193
|
+
&& object_has_property_that_equals(maybe, 'minLength', 1)
|
|
194
|
+
&& object_has_property(maybe, 'typed_string')
|
|
195
|
+
&& 3 === Object.keys(maybe).length
|
|
196
|
+
&& (this.is_typed_string_object_inner(maybe.typed_string)
|
|
197
|
+
|| this.is_typed_string_array_inner(maybe.typed_string)));
|
|
198
|
+
}
|
|
199
|
+
static is_typed_string_object_pattern_inner(maybe) {
|
|
200
|
+
return (object_has_property(maybe, 'minProperties', is_number)
|
|
201
|
+
&& object_has_property(maybe, 'patternProperties', value_is_non_array_object)
|
|
202
|
+
&& 2 === Object.keys(maybe).length);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=ValueToRegexFormatter.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Ajv, { SchemaObject } from 'ajv/dist/2020';
|
|
2
|
+
import { local_ref } from '../../StringStartsWith';
|
|
3
|
+
import { ConverterMatchesSchema, ExpressionResult } from '../Generator';
|
|
4
|
+
import { FalseLiteral, NullLiteral, TrueLiteral } from 'typescript';
|
|
5
|
+
export type schema_type = SchemaObject & {
|
|
6
|
+
$ref: local_ref<'boolean' | 'boolean-extended'>;
|
|
7
|
+
};
|
|
8
|
+
export declare class BooleanConverter extends ConverterMatchesSchema<schema_type, 'True' | 'False' | '', TrueLiteral | FalseLiteral | NullLiteral> {
|
|
9
|
+
constructor(ajv: Ajv);
|
|
10
|
+
can_convert_schema_and_raw_data(schema: SchemaObject, raw_data: unknown): Promise<boolean>;
|
|
11
|
+
convert(_: schema_type, raw_data: '' | 'True' | 'False'): Promise<ExpressionResult<NullLiteral | TrueLiteral | FalseLiteral>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { local_ref, } from '../../StringStartsWith';
|
|
2
|
+
import { ConverterMatchesSchema, ExpressionResult, } from '../Generator';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
const schema = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
required: ['$ref'],
|
|
7
|
+
additionalProperties: false,
|
|
8
|
+
properties: {
|
|
9
|
+
$ref: { type: 'string', enum: [
|
|
10
|
+
local_ref('boolean'),
|
|
11
|
+
local_ref('boolean-extended'),
|
|
12
|
+
] },
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export class BooleanConverter extends ConverterMatchesSchema {
|
|
16
|
+
constructor(ajv) {
|
|
17
|
+
super(ajv, schema);
|
|
18
|
+
}
|
|
19
|
+
can_convert_schema_and_raw_data(schema, raw_data) {
|
|
20
|
+
return Promise.resolve(this.can_convert_schema(schema) && ('True' === raw_data
|
|
21
|
+
|| 'False' === raw_data
|
|
22
|
+
|| '' === raw_data));
|
|
23
|
+
}
|
|
24
|
+
convert(_, raw_data) {
|
|
25
|
+
return Promise.resolve(new ExpressionResult('' === raw_data
|
|
26
|
+
? ts.factory.createNull()
|
|
27
|
+
: ('True' === raw_data
|
|
28
|
+
? ts.factory.createTrue()
|
|
29
|
+
: ts.factory.createFalse())));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=BooleanOrBooleanExtended.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConverterMatchesSchema, ExpressionResult } from '../Generator';
|
|
2
|
+
import Ajv, { SchemaObject } from 'ajv/dist/2020';
|
|
3
|
+
import { RawData } from '../../TypeDefinitionDiscovery/CustomParsingTypes/string_starts_with';
|
|
4
|
+
import ts, { AsExpression } from 'typescript';
|
|
5
|
+
export declare class StringStartsWithConverter extends ConverterMatchesSchema<RawData, string, AsExpression> {
|
|
6
|
+
constructor(ajv: Ajv);
|
|
7
|
+
can_convert_schema_and_raw_data(schema: SchemaObject, raw_data: unknown): Promise<boolean>;
|
|
8
|
+
convert(schema: RawData, raw_data: string): Promise<ExpressionResult<ts.AsExpression>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ConverterMatchesSchema, ExpressionResult, } from '../Generator';
|
|
2
|
+
import { schema, } from '../../TypeDefinitionDiscovery/CustomParsingTypes/string_starts_with';
|
|
3
|
+
import { is_string, } from '../../StringStartsWith';
|
|
4
|
+
import ts from 'typescript';
|
|
5
|
+
import { create_literal, type_reference_node, } from '../../TsFactoryWrapper';
|
|
6
|
+
export class StringStartsWithConverter extends ConverterMatchesSchema {
|
|
7
|
+
constructor(ajv) {
|
|
8
|
+
super(ajv, schema);
|
|
9
|
+
}
|
|
10
|
+
can_convert_schema_and_raw_data(schema, raw_data) {
|
|
11
|
+
return Promise.resolve(is_string(raw_data)
|
|
12
|
+
&& this.can_convert_schema(schema)
|
|
13
|
+
&& raw_data.startsWith(schema.string_starts_with));
|
|
14
|
+
}
|
|
15
|
+
convert(schema, raw_data) {
|
|
16
|
+
return Promise.resolve(new ExpressionResult(ts.factory.createAsExpression(ts.factory.createStringLiteral(raw_data), type_reference_node('StringStartsWith', create_literal(schema.string_starts_with)))));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=StringStartsWith.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ConverterMatchesSchema, ExpressionResult } from '../Generator';
|
|
2
|
+
import { typed_string_parent_type } from '../../CustomParsingTypes/TypedString';
|
|
3
|
+
import { SchemaObject } from 'ajv/dist/2020';
|
|
4
|
+
import { DataDiscovery } from '../../DataDiscovery';
|
|
5
|
+
import { ArrayLiteralExpression, ObjectLiteralExpression } from 'typescript';
|
|
6
|
+
export declare class TypedStringConverter extends ConverterMatchesSchema<typed_string_parent_type, string, ArrayLiteralExpression | ObjectLiteralExpression> {
|
|
7
|
+
private readonly $defs;
|
|
8
|
+
private readonly discovery;
|
|
9
|
+
private readonly regex_schema_cache;
|
|
10
|
+
constructor(discovery: DataDiscovery, $defs: {
|
|
11
|
+
[key: string]: SchemaObject;
|
|
12
|
+
});
|
|
13
|
+
can_convert_schema_and_raw_data(schema: SchemaObject, raw_data: unknown): Promise<boolean>;
|
|
14
|
+
convert(schema: typed_string_parent_type, raw_data: string): Promise<ExpressionResult<ArrayLiteralExpression | ObjectLiteralExpression>>;
|
|
15
|
+
private check_shallow_array_prefixItems_schema;
|
|
16
|
+
private check_shallow_array_schema;
|
|
17
|
+
private check_shallow_array_schema_assert;
|
|
18
|
+
private convert_array;
|
|
19
|
+
private convert_object;
|
|
20
|
+
private convert_object_check_shallow_parse;
|
|
21
|
+
private convert_object_property_schema;
|
|
22
|
+
private convert_prefixItems;
|
|
23
|
+
}
|