• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

satisfactory-dev / Docs.json.ts / 20185801370

13 Dec 2025 02:48AM UTC coverage: 0.0%. Remained the same
20185801370

push

github

SignpostMarv
satisfying eslint

0 of 45 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 6 new or added lines in 2 files covered. (0.0%)

177 existing lines in 5 files now uncovered.

0 of 7338 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/version-specific/0.3.7.7/TypedString/Object.ts
1
import type {
×
2
        Ajv2020 as Ajv,
×
3
        ValidateFunction,
×
4
} from 'ajv/dist/2020.js';
×
5

×
6
import type {
×
7
        ComputedPropertyName,
×
8
        PropertyAssignment,
×
9
} from 'typescript';
×
10

×
11
import type {
×
12
        object_schema,
×
13
        object_type_base,
×
14
        object_TypeLiteralNode_possibly_extended,
×
15
        ObjectOfSchemas,
×
16
        SchemaObject,
×
17
        SchemaParser,
×
18
} from '@signpostmarv/json-schema-typescript-codegen';
×
19
import {
×
20
        ObjectUnspecified,
×
21
        Type,
×
22
} from '@signpostmarv/json-schema-typescript-codegen';
×
23

×
24
import {
×
25
        factory,
×
26
        type ObjectLiteralExpression,
×
27
} from '@signpostmarv/json-schema-typescript-codegen/typescript-overrides';
×
28

×
29
import {
×
30
        object_has_property,
×
31
        object_has_property_that_equals,
×
32
} from '@satisfactory-dev/predicates.ts';
×
33

×
34
import {
×
35
        FlexibleArray_regex__items__inner,
×
36
} from './FlexibleArray.ts';
×
37

×
38
export type Object_type = object_type_base<
×
39
        'properties',
×
40
        SchemaObject,
×
41
        [string, ...string[]],
×
42
        ObjectOfSchemas,
×
43
        ObjectOfSchemas
×
44
>;
×
45

×
46
export type Object_properties = object_schema<'properties'>;
×
47

×
48
export type Object_DataTo = ObjectLiteralExpression;
×
49

×
50
export type Object_SchemaTo = object_TypeLiteralNode_possibly_extended<
×
51
        'properties'
×
52
>;
×
53

×
54
export type Object_TypeGenerator = (
×
55
        schema: object_type_base<
×
56
                'properties',
×
57
                SchemaObject,
×
58
                [string, ...string[]],
×
59
                ObjectOfSchemas,
×
60
                ObjectOfSchemas
×
61
        >,
×
62
        schema_parser: SchemaParser,
×
63
) => Promise<object_TypeLiteralNode_possibly_extended<'properties'>>;
×
64

×
65
export const Object_type_schema = Object.freeze({
×
66
        type: 'object',
×
67
        required: ['type'],
×
68
        properties: {
×
69
                type: {
×
70
                        type: 'string',
×
71
                        const: 'object',
×
72
                },
×
73
        },
×
74
});
×
75

×
76
export function Object_compile_validator(
×
77
        ajv: Ajv,
×
78
): ValidateFunction<Object_type> {
×
79
        return ajv.compile<
×
80
                Object_type
×
81
        >(
×
82
                Object_type_schema,
×
83
        );
×
84
}
×
85

×
86
export function computedProperty_or_string(
×
87
        property: string,
×
88
): ComputedPropertyName|string {
×
89
        return /[?[\] ]/.test(property)
×
90
                ? factory.createComputedPropertyName(
×
91
                        factory.createStringLiteral(property),
×
92
                )
×
93
                : property;
×
94
}
×
95

×
96
export function Object_generate_typescript_data(
×
97
        data: string,
×
98
        schema_parser: SchemaParser,
×
99
        coerced_schema: Object_type,
×
100
        schema: SchemaObject,
×
101
        property_schema_to_regex: PropertySchemaToRegex<unknown>[],
×
102
): Object_DataTo {
×
103
        const properties = Object.keys(
×
104
                coerced_schema.properties,
×
105
        );
×
106

×
107
        const regex = new RegExp(`^\\((?:,?${properties.map(
×
108
                (property): [
×
109
                        string,
×
110
                        string,
×
111
                ] => {
×
112
                        const regex = FlexibleArray_regex__items__inner(
×
113
                                Type.maybe_add_$defs(
×
114
                                        coerced_schema,
×
115
                                        coerced_schema.properties[property],
×
116
                                ),
×
117
                                property_schema_to_regex,
×
118
                                true,
×
119
                        );
×
120

×
121
                        return [
×
122
                                property,
×
123
                                `(${RegExp.escape(property)})=${regex}`,
×
124
                        ];
×
125
                },
×
126
        ).map(([
×
127
                property,
×
128
                regex,
×
129
        ], i) => {
×
130
                const previous_optional = (
×
131
                        i > 0
×
132
                        && !(
×
133
                                coerced_schema.required || ([] as string[])
×
134
                        ).includes(properties[i - 1])
×
135
                );
×
136

×
137
                const current_required = (
×
138
                        coerced_schema.required || ([] as string[])
×
139
                ).includes(property);
×
140

×
141
                return (
×
142
                        current_required
×
143
                                ? `${
×
144
                                        i > 0
×
145
                                                ? (
×
146
                                                        previous_optional
×
147
                                                                ? ',?'
×
148
                                                                : ','
×
149
                                                )
×
150
                                                : ''
×
151
                                }${regex}`
×
152
                                : `(?:${i > 0 ? ',' : ''}${regex})?`
×
153
                );
×
154
        }).join('')})*\\)$`);
×
155

×
156
        const match = regex.exec(data);
×
157

×
158
        if (null === match) {
×
159
                throw new TypeError('Data does not match expected regex!');
×
160
        }
×
161

×
162
        const [, ...matches] = match;
×
163

×
164
        const property_assignments: PropertyAssignment[] = [];
×
165

×
166
        for (let i = 0; i < matches.length; i += 2) {
×
167
                const property_name = matches[i];
×
168
                let property_value = matches[i + 1];
×
169

×
170
                if (
×
171
                        undefined === property_name
×
172
                        && undefined === property_value
×
173
                ) {
×
174
                        continue;
×
175
                }
×
176

×
177
                let property_schema = coerced_schema.properties[
×
178
                        property_name
×
179
                ];
×
180

×
181
                if (!object_has_property_that_equals(
×
182
                        property_schema,
×
183
                        'type',
×
184
                        'string',
×
185
                )) {
×
186
                        property_schema = Type.maybe_add_$defs(
×
NEW
187
                                schema,
×
188
                                property_schema,
×
NEW
189
                        );
×
190
                }
×
191

×
192
                const type_for_property = schema_parser.parse(
×
193
                        property_schema,
×
194
                );
×
195

×
196
                if (
×
197
                        object_has_property(property_schema, 'type')
×
198
                        && 'string' === property_schema.type
×
199
                        && 'string' === typeof property_value
×
200
                        && property_value.startsWith('"')
×
201
                        && property_value.endsWith('"')
×
202
                ) {
×
203
                        property_value = property_value.substring(
×
204
                                1,
×
205
                                property_value.length - 1,
×
206
                        );
×
207
                }
×
208

×
209
                const value = type_for_property
×
210
                        .generate_typescript_data(
×
211
                                property_value,
×
212
                                schema_parser,
×
213
                                property_schema,
×
214
                        );
×
215

×
216
                const property_assignment = factory
×
217
                        .createPropertyAssignment(
×
218
                                computedProperty_or_string(property_name),
×
219
                                value,
×
220
                        );
×
221

×
222
                property_assignments.push(property_assignment);
×
223
        }
×
224

×
225
        const sanity_check: Object_DataTo = factory
×
226
                .createObjectLiteralExpression(
×
227
                        property_assignments,
×
228
                        true,
×
229
                );
×
230

×
231
        return sanity_check;
×
232
}
×
233

×
234
export function Object_generate_typescript_type(
×
235
        schema: Object_type,
×
236
        schema_parser: SchemaParser,
×
237
): Promise<Object_SchemaTo> {
×
238
        const instance = schema_parser.types
×
239
                .find((maybe): maybe is ObjectUnspecified<
×
240
                        {[key: string]: unknown},
×
241
                        'properties'
×
242
                > => (
×
243
                        maybe instanceof ObjectUnspecified
×
244
                        && 'properties' === maybe.properties_mode
×
245
                ));
×
246

×
247
        if (undefined === instance) {
×
248
                throw new TypeError(`schema_parser not loaded with ${
×
249
                        ObjectUnspecified.constructor.name
×
250
                }<{[key: string]: unknown}, 'properties'>`);
×
251
        }
×
252

×
253
        return instance.generate_typescript_type({
×
254
                schema,
×
255
                schema_parser,
×
256
        });
×
257
}
×
258

×
259
export class PropertySchemaToRegex<
×
260
        T,
×
261
> {
×
262
        #matcher: ValidateFunction<T>;
×
263

×
264
        #value_to_regex: (value: T) => string;
×
265

×
266
        constructor(
×
267
                matcher: ValidateFunction<T>,
×
268
                value_to_regex: (value: T) => string,
×
269
        ) {
×
270
                this.#matcher = matcher;
×
271
                this.#value_to_regex = value_to_regex;
×
272
        }
×
273

×
274
        matches(value: unknown): value is T {
×
275
                return this.#matcher(value);
×
276
        }
×
277

×
278
        to_regex(value: T): string {
×
279
                return this.#value_to_regex(value);
×
280
        }
×
281
}
×
282

×
283
export function Object_type_to_regex(
×
284
        schema: Object_type,
×
285
        property_schema_to_regex: PropertySchemaToRegex<unknown>[],
×
286
) {
×
UNCOV
287
        const regex = `${
×
UNCOV
288
                Object.keys(schema.properties)
×
UNCOV
289
                        .map((property) => {
×
UNCOV
290
                                let value_regex = `(?:[^=)]+)`;
×
UNCOV
291

×
UNCOV
292
                                let resolved = Type.maybe_add_$defs(
×
UNCOV
293
                                        schema,
×
UNCOV
294
                                        schema.properties[property],
×
UNCOV
295
                                );
×
UNCOV
296

×
UNCOV
297
                                let converter = property_schema_to_regex.find((maybe) => {
×
UNCOV
298
                                        return maybe.matches(resolved);
×
UNCOV
299
                                });
×
UNCOV
300

×
UNCOV
301
                                if (!converter && 'typed_string' in resolved) {
×
UNCOV
302
                                        resolved = Type.maybe_add_$defs(
×
UNCOV
303
                                                resolved,
×
UNCOV
304
                                                resolved.typed_string as SchemaObject,
×
UNCOV
305
                                        );
×
UNCOV
306

×
UNCOV
307
                                        converter = property_schema_to_regex.find((maybe) => {
×
UNCOV
308
                                                return maybe.matches(resolved);
×
UNCOV
309
                                        });
×
UNCOV
310
                                }
×
UNCOV
311

×
UNCOV
312
                                if (converter) {
×
UNCOV
313
                                        value_regex = `${
×
UNCOV
314
                                                converter.to_regex(resolved)
×
UNCOV
315
                                        }`;
×
UNCOV
316
                                }
×
UNCOV
317

×
UNCOV
318
                                return `(?:,?${
×
UNCOV
319
                                        RegExp.escape(property)
×
UNCOV
320
                                }=(?:${
×
UNCOV
321
                                        value_regex
×
UNCOV
322
                                }))${
×
UNCOV
323
                                        (
×
UNCOV
324
                                                (schema.required || ([] as string[]))
×
UNCOV
325
                                                        .includes(property)
×
UNCOV
326
                                        )
×
UNCOV
327
                                                ? ''
×
UNCOV
328
                                                : '?'
×
UNCOV
329
                                }`;
×
UNCOV
330
                        })
×
UNCOV
331
                        .join('')
×
UNCOV
332
        }`;
×
UNCOV
333

×
UNCOV
334
        return `\\(${regex}\\)`;
×
UNCOV
335
}
×
UNCOV
336

×
UNCOV
337
export function Object_ajv_macro(
×
UNCOV
338
        schema: Object_type,
×
UNCOV
339
        property_schema_to_regex: PropertySchemaToRegex<unknown>[],
×
UNCOV
340
) {
×
UNCOV
341
        return Object.freeze({
×
UNCOV
342
                pattern: `^${
×
UNCOV
343
                        Object_type_to_regex(schema, property_schema_to_regex)
×
UNCOV
344
                }$`,
×
UNCOV
345
        });
×
UNCOV
346
}
×
UNCOV
347

×
UNCOV
348
export function Object_generate_schema_definition(
×
UNCOV
349
): Readonly<Object_properties> {
×
UNCOV
350
        return ObjectUnspecified
×
UNCOV
351
                .generate_schema_definition({
×
UNCOV
352
                        properties_mode: 'properties',
×
UNCOV
353
                });
×
UNCOV
354
}
×
UNCOV
355

×
UNCOV
356
export function Object_generate_type_definition(
×
UNCOV
357
): Readonly<Object_type> {
×
UNCOV
358
        return ObjectUnspecified
×
UNCOV
359
                .generate_type_definition({
×
UNCOV
360
                        properties_mode: 'properties',
×
UNCOV
361
                        properties: {},
×
UNCOV
362
                });
×
UNCOV
363
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc