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

satisfactory-dev / Docs.json.ts / 19870519821

02 Dec 2025 07:12PM UTC coverage: 0.0%. Remained the same
19870519821

push

github

SignpostMarv
consistent order

0 of 38 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 8672 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.5.2.1/TypedString.ts
1
import type {
×
2
        Ajv2020 as Ajv,
×
3
        ValidateFunction,
×
4
} from 'ajv/dist/2020.js';
×
5

×
6
import type {
×
7
        SchemaDefinitionDefinition,
×
8
        SchemalessTypeOptions,
×
9
        SchemaParser,
×
10
        TypeDefinitionSchema,
×
11
} from '@signpostmarv/json-schema-typescript-codegen';
×
12

×
13
import {
×
14
        KeywordType,
×
15
} from '@signpostmarv/json-schema-typescript-codegen/ajv';
×
16

×
17
import type {
×
18
} from '@signpostmarv/json-schema-typescript-codegen/javascript-overrides';
×
19

×
20
import type {
×
21
        Thingish_list_DataTo,
×
22
        Thingish_list_schema_properties,
×
23
        Thingish_list_SchemaTo,
×
24
        Thingish_list_type,
×
25
} from './TypedString/Thingish_list.ts';
×
26
import {
×
27
        Thingish_list_compile_validator,
×
28
        Thingish_list_generate_schema_definition,
×
29
        Thingish_list_generate_type_definition_prefixItems,
×
30
        Thingish_list_generate_typescript_data,
×
31
        Thingish_list_generate_typescript_type,
×
32
        Thingish_list_schema_ajv_macro,
×
33
} from './TypedString/Thingish_list.ts';
×
34

×
35
import type {
×
36
        TypedString_DataTo__by_mode as TypedString_DataTo__by_mode__update4,
×
37
        TypedString_mode as TypedString_mode__update4,
×
38
        TypedString_schema_OneOf as TypedString_schema_OneOf__update4,
×
39
        TypedString_schema_properties as TypedString_schema_properties__update4,
×
40
        TypedString_SchemaTo__by_mode as TypedString_SchemaTo__by_mode__update4,
×
41
        TypedString_type__by_mode as TypedString_type__by_mode__update4,
×
42
        TypedString_type_OneOf as TypedString_type_OneOf__update4,
×
43
} from '../0.4.2.11/TypedString.ts';
×
44
import {
×
45
        compile_validators as compile_validators__update4,
×
46
        // eslint-disable-next-line @stylistic/max-len
×
47
        generate_typescript_data__by_mode as generate_typescript_data__by_mode__update4,
×
48
        // eslint-disable-next-line @stylistic/max-len
×
49
        generate_typescript_type__by_mode as generate_typescript_type__by_mode__update4,
×
50
        TypedString as TypedString__update4,
×
51
} from '../0.4.2.11/TypedString.ts';
×
52

×
53
import type {
×
54
        Thing_list_DataTo,
×
55
        Thing_list_schema_properties,
×
56
        Thing_list_SchemaTo,
×
57
        Thing_list_type,
×
58
} from './TypedString/Thing_list.ts';
×
59
import {
×
60
        Thing_list_ajv_macro,
×
61
        Thing_list_compile_validator,
×
62
        Thing_list_generate_schema_definition,
×
63
        Thing_list_generate_type_definition,
×
64
        Thing_list_generate_typescript_data,
×
65
        Thing_list_generate_typescript_type,
×
66
} from './TypedString/Thing_list.ts';
×
67

×
68
export type TypedString_mode = (
×
69
        | TypedString_mode__update4
×
70
        | 'Thing_list'
×
71
        | 'Thingish_list'
×
72
);
×
73

×
74
export type TypedString_type__by_mode = (
×
75
        & TypedString_type__by_mode__update4
×
76
        & {
×
77
                Thing_list: Thing_list_type,
×
78
                Thingish_list: Thingish_list_type<
×
79
                        TypedString_type<'Thingish_list'>
×
80
                >,
×
81
        }
×
82
);
×
83

×
84
type TypedString_type<
×
85
        Mode extends TypedString_mode,
×
86
> = {
×
87
        type: 'string',
×
88
        typed_string: TypedString_type__by_mode[Mode],
×
89
};
×
90

×
91
type TypedString_matcher<
×
92
        Mode extends TypedString_mode,
×
93
> = [
×
94
        Mode,
×
95
        ValidateFunction<TypedString_type<Mode>['typed_string']>,
×
96
];
×
97

×
98
export type TypedString_type_OneOf = {
×
99
        oneOf: [
×
100
                ...TypedString_type_OneOf__update4['oneOf'],
×
101
                TypedString_type<'Thing_list'>,
×
102
                TypedString_type<'Thingish_list'>,
×
103
        ],
×
104
};
×
105

×
106
export type TypedString_schema_properties = (
×
107
        & TypedString_schema_properties__update4
×
108
        & {
×
109
                Thing_list: Thing_list_schema_properties,
×
110
                Thingish_list: Thingish_list_schema_properties,
×
111
        }
×
112
);
×
113

×
114
type TypedString_schema_properties_typed_string<
×
115
        Mode extends TypedString_mode,
×
116
> = TypedString_schema_properties[Mode];
×
117

×
118
type TypedString_schema<
×
119
        Mode extends TypedString_mode,
×
120
> = SchemaDefinitionDefinition<
×
121
        ['type', 'typed_string'],
×
122
        {
×
123
                $defs: {
×
124
                        type: 'object',
×
125
                        additionalProperties: {
×
126
                                type: 'object',
×
127
                        },
×
128
                },
×
129
                type: {
×
130
                        type: 'string',
×
131
                        const: 'string',
×
132
                },
×
133
                typed_string: TypedString_schema_properties_typed_string<Mode>,
×
134
        }
×
135
>;
×
136

×
137
export type TypedString_schema_OneOf = TypeDefinitionSchema & {
×
138
        oneOf: [
×
139
                ...TypedString_schema_OneOf__update4['oneOf'],
×
140
                TypedString_schema<'Thing_list'>,
×
141
                TypedString_schema<'Thingish_list'>,
×
142
        ],
×
143
};
×
144

×
145
export type TypedString_SchemaTo__by_mode = (
×
146
        & TypedString_SchemaTo__by_mode__update4
×
147
        & {
×
148
                Thing_list: Thing_list_SchemaTo,
×
149
                Thingish_list: Thingish_list_SchemaTo,
×
150
        }
×
151
);
×
152

×
153
type TypedString_SchemaTo<
×
154
        Mode extends TypedString_mode,
×
155
> = TypedString_SchemaTo__by_mode[Mode];
×
156

×
157
export type TypedString_DataTo__by_mode = (
×
158
        & TypedString_DataTo__by_mode__update4
×
159
        & {
×
160
                Thing_list: Thing_list_DataTo,
×
161
                Thingish_list: Thingish_list_DataTo,
×
162
        }
×
163
);
×
164

×
165
type TypedString_DataTo<
×
166
        Mode extends TypedString_mode,
×
167
> = TypedString_DataTo__by_mode[Mode];
×
168

×
169
export function compile_validators(ajv: Ajv): {
×
170
        [key in TypedString_mode]: ValidateFunction<
×
171
                TypedString_type<key>['typed_string']
×
172
        >
×
173
} {
×
174
        return {
×
175
                ...compile_validators__update4(ajv),
×
176
                Thing_list: Thing_list_compile_validator(ajv),
×
177
                Thingish_list: Thingish_list_compile_validator(ajv),
×
178
        };
×
179
}
×
180

×
181
export function generate_typescript_data<
×
182
        Mode extends TypedString_mode,
×
183
>(
×
184
        data: string,
×
185
        schema_parser: SchemaParser,
×
186
        schema: TypedString_type<Mode>,
×
187
        mode_by_validator: TypedString_matcher<TypedString_mode>[],
×
188
): TypedString_DataTo<Mode>|undefined {
×
189
        const mode = TypedString.mode_from_schema(
×
190
                schema.typed_string,
×
191
                mode_by_validator,
×
192
        );
×
193

×
194
        return generate_typescript_data__by_mode(
×
195
                data,
×
196
                schema_parser,
×
197
                schema,
×
198
                mode,
×
199
        );
×
200
}
×
201

×
202
export function generate_typescript_data__by_mode<
×
203
        Mode extends TypedString_mode,
×
204
>(
×
205
        data: string,
×
206
        schema_parser: SchemaParser,
×
207
        schema: TypedString_type<Mode>,
×
208
        mode: Mode,
×
209
) {
×
210
        if ('Thing_list' === mode) {
×
211
                const coerced = (
×
212
                        schema as TypedString_type<
×
213
                                'Thing_list'
×
214
                        >
×
215
                ).typed_string;
×
216

×
217
                return Thing_list_generate_typescript_data(
×
218
                        data,
×
219
                        schema_parser,
×
220
                        coerced,
×
221
                ) as TypedString_DataTo<Mode>;
×
222
        } else if ('Thingish_list' === mode) {
×
223
                const coerced = (
×
224
                        schema as TypedString_type<
×
225
                                'Thingish_list'
×
226
                        >
×
227
                ).typed_string;
×
228

×
229
                return Thingish_list_generate_typescript_data(
×
230
                        data,
×
231
                        schema_parser,
×
232
                        coerced,
×
233
                ) as TypedString_DataTo<Mode>;
×
234
        }
×
235

×
236
        const coerced = schema as TypedString_type<
×
237
                Exclude<Mode, (
×
238
                        | 'Thing_list'
×
239
                        | 'Thingish_list'
×
240
                )>
×
241
        >;
×
242

×
243
        return generate_typescript_data__by_mode__update4(
×
244
                data,
×
245
                schema_parser,
×
246
                coerced,
×
247
                mode,
×
248
        ) as TypedString_DataTo<Mode>|undefined;
×
249
}
×
250

×
251
function generate_typescript_type<
×
252
        Mode extends TypedString_mode,
×
253
>(
×
254
        schema: TypedString_type<Mode>,
×
255
        schema_parser: SchemaParser,
×
256
        mode_by_validator: TypedString_matcher<TypedString_mode>[],
×
257
): Promise<
×
258
        TypedString_SchemaTo<Mode>
×
259
>|undefined {
×
260
        const mode = TypedString.mode_from_schema(
×
261
                schema.typed_string,
×
262
                mode_by_validator,
×
263
        );
×
264

×
265
        return generate_typescript_type__by_mode(
×
266
                schema,
×
267
                schema_parser,
×
268
                mode,
×
269
        );
×
270
}
×
271

×
272
export function generate_typescript_type__by_mode<
×
273
        Mode extends TypedString_mode,
×
274
>(
×
275
        schema: TypedString_type<Mode>,
×
276
        schema_parser: SchemaParser,
×
277
        mode: Mode,
×
278
): Promise<
×
279
        TypedString_SchemaTo<Mode>
×
280
>|undefined {
×
281
        if ('Thing_list' === mode) {
×
282
                const coerced = (
×
283
                        schema as TypedString_type<
×
284
                                'Thing_list'
×
285
                        >
×
286
                ).typed_string;
×
287

×
288
                return Thing_list_generate_typescript_type(
×
289
                        coerced,
×
290
                        schema_parser,
×
291
                ) as Promise<TypedString_SchemaTo<Mode>>;
×
292
        } else if ('Thingish_list' === mode) {
×
293
                const coerced = (
×
294
                        schema as TypedString_type<
×
295
                                'Thingish_list'
×
296
                        >
×
297
                ).typed_string;
×
298

×
299
                return Thingish_list_generate_typescript_type(
×
300
                        coerced,
×
301
                        schema_parser,
×
302
                ) as Promise<TypedString_SchemaTo<Mode>>;
×
303
        }
×
304

×
305
        const coerced = schema as TypedString_type<
×
306
                Exclude<Mode, (
×
307
                        | 'Thing_list'
×
308
                        | 'Thingish_list'
×
309
                )>
×
310
        >;
×
311

×
312
        return generate_typescript_type__by_mode__update4(
×
313
                coerced,
×
314
                schema_parser,
×
315
                mode,
×
316
        ) as Promise<TypedString_SchemaTo<Mode>>|undefined;
×
317
}
×
318

×
319

×
320
export class TypedString<
×
321
        Mode extends TypedString_mode,
×
322
> extends
×
323
        KeywordType<
×
324
                Exclude<string, ''>,
×
325
                TypedString_type_OneOf,
×
326
                Record<string, never>,
×
327
                TypedString_schema_OneOf,
×
328
                Record<string, never>,
×
329
                TypedString_SchemaTo<Mode>,
×
330
                TypedString_DataTo<Mode>,
×
331
                TypedString_type<Mode>
×
332
        > {
×
333
        #mode_by_validator: TypedString_matcher<TypedString_mode>[];
×
334

×
335
        constructor(
×
336
                options: SchemalessTypeOptions,
×
337
                {
×
338
                        String_enum_list,
×
339
                }: {
×
340
                        String_enum_list?: {
×
341
                                quoted: boolean,
×
342
                        },
×
343
                } = {},
×
344
        ) {
×
345
                const mode_from_schema = compile_validators(options.ajv);
×
346

×
347
                const entries = Object.entries(mode_from_schema);
×
348

×
349
                super({
×
350
                        ...options,
×
351
                        ajv_keyword: {
×
352
                                keyword: 'typed_string',
×
353
                                type: 'string',
×
354
                                macro: (
×
355
                                        schema: TypedString_type<Mode>['typed_string'],
×
356
                                ) => {
×
357
                                        const mode = TypedString.mode_from_schema(
×
358
                                                schema,
×
359
                                                entries,
×
360
                                        );
×
361

×
362
                                        return TypedString.ajv_macro(mode, schema, {
×
363
                                                String_enum_list: String_enum_list || {
×
364
                                                        quoted: false,
×
365
                                                },
×
366
                                        });
×
367
                                },
×
368
                        },
×
369
                        type_definition: {},
×
370
                        schema_definition: {},
×
371
                });
×
372

×
373
                this.#mode_by_validator = entries;
×
374
        }
×
375

×
376
        generate_typescript_data(
×
377
                data: string,
×
378
                schema_parser: SchemaParser,
×
379
                schema: TypedString_type<Mode>,
×
380
        ): TypedString_DataTo<Mode> {
×
381
                const result = generate_typescript_data(
×
382
                        data,
×
383
                        schema_parser,
×
384
                        schema,
×
385
                        this.#mode_by_validator,
×
386
                );
×
387

×
388
                if (!result) {
×
389
                        throw new TypeError('Not implemented!');
×
390
                }
×
391

×
392
                return result;
×
393
        }
×
394

×
395
        async generate_typescript_type({
×
396
                schema,
×
397
                schema_parser,
×
398
        }: {
×
399
                schema: TypedString_type<Mode>,
×
400
                schema_parser: SchemaParser,
×
401
        }): Promise<TypedString_SchemaTo<Mode>> {
×
402
                const result = generate_typescript_type(
×
403
                        schema,
×
404
                        schema_parser,
×
405
                        this.#mode_by_validator,
×
406
                );
×
407

×
408
                if (undefined === result) {
×
409
                        throw new TypeError('not implemented!');
×
410
                }
×
411

×
412
                return result;
×
413
        }
×
414

×
415
        static ajv_macro<
×
416
                Mode extends TypedString_mode,
×
417
        >(
×
418
                mode: Mode,
×
419
                schema: TypedString_type<Mode>['typed_string'],
×
420
                options: {
×
421
                        String_enum_list: {
×
422
                                quoted: boolean,
×
423
                        },
×
424
                },
×
425
        ) {
×
426
                if ('Thing_list' === mode) {
×
427
                        const coerced_schema = schema as TypedString_type<
×
428
                                'Thing_list'
×
429
                        >[
×
430
                                'typed_string'
×
431
                        ];
×
432

×
433
                        return Thing_list_ajv_macro(coerced_schema);
×
434
                } else if ('Thingish_list' === mode) {
×
435
                        const coerced_schema = schema as TypedString_type<
×
436
                                'Thingish_list'
×
437
                        >[
×
438
                                'typed_string'
×
439
                        ];
×
440

×
441
                        return Thingish_list_schema_ajv_macro(coerced_schema);
×
442
                }
×
443

×
444
                const coerced = schema as TypedString_type<
×
445
                        Exclude<Mode, (
×
446
                                | 'Thing_list'
×
447
                                | 'Thingish_list'
×
448
                        )>
×
449
                >['typed_string'];
×
450

×
451
                return TypedString__update4.ajv_macro(
×
452
                        mode,
×
453
                        coerced,
×
454
                        options,
×
455
                );
×
456
        }
×
457

×
458
        static generate_schema_definition(): Readonly<TypedString_schema_OneOf> {
×
459
                return Object.freeze({
×
460
                        oneOf: [
×
461
                                ...TypedString__update4.generate_schema_definition().oneOf,
×
462
                                this.#generate_schema_definition(
×
463
                                        'Thing_list',
×
464
                                ),
×
465
                                this.#generate_schema_definition(
×
466
                                        'Thingish_list',
×
467
                                ),
×
468
                        ],
×
469
                });
×
470
        }
×
471

×
472
        static #generate_schema_definition<
×
473
                Mode extends (
×
474
                        | 'Thing_list'
×
475
                        | 'Thingish_list'
×
476
                ),
×
477
        >(
×
478
                mode: Mode,
×
479
        ): Readonly<TypedString_schema<Mode>> {
×
480
                let typed_string: TypedString_schema_properties_typed_string<
×
481
                        Mode
×
482
                >;
×
483

×
484
                if ('Thing_list' === mode) {
×
485
                        typed_string = Thing_list_generate_schema_definition(
×
486
                        ) as typeof typed_string;
×
487
                } else if ('Thingish_list' === mode) {
×
488
                        typed_string = Thingish_list_generate_schema_definition(
×
489
                        ) as typeof typed_string;
×
490
                } else {
×
491
                        throw new TypeError('Not implemented');
×
492
                }
×
493

×
494
                const properties: TypedString_schema<Mode>['properties'] = {
×
495
                        $defs: {
×
496
                                type: 'object',
×
497
                                additionalProperties: {
×
498
                                        type: 'object',
×
499
                                },
×
500
                        },
×
501
                        type: {
×
502
                                type: 'string',
×
503
                                const: 'string',
×
504
                        },
×
505
                        typed_string,
×
506
                };
×
507

×
508
                return Object.freeze({
×
509
                        type: 'object',
×
510
                        additionalProperties: false,
×
511
                        required: ['type', 'typed_string'],
×
512
                        properties,
×
513
                });
×
514
        }
×
515

×
516
        static generate_type_definition(): Readonly<TypedString_type_OneOf> {
×
517
                return Object.freeze({
×
518
                        oneOf: [
×
519
                                ...TypedString__update4.generate_type_definition().oneOf,
×
520
                                this.#generate_type_definition('Thing_list'),
×
521
                                this.#generate_type_definition('Thingish_list'),
×
522
                        ],
×
523
                });
×
524
        }
×
525

×
526
        static #generate_type_definition<
×
527
                Mode extends (
×
528
                        | 'Thing_list'
×
529
                        | 'Thingish_list'
×
530
                ),
×
531
        >(
×
532
                mode: Mode,
×
533
        ): Readonly<TypedString_type<Mode>> {
×
534
                let typed_string: TypedString_type<Mode>['typed_string'];
×
535

×
536
                if ('Thing_list' === mode) {
×
537
                        typed_string = Thing_list_generate_type_definition(
×
538
                        ) as typeof typed_string;
×
539
                } else if ('Thingish_list' === mode) {
×
540
                        typed_string = Thingish_list_generate_type_definition_prefixItems(
×
541
                        ) as unknown as typeof typed_string;
×
542
                } else {
×
543
                        throw new TypeError('Not implemented!');
×
544
                }
×
545

×
546
                return Object.freeze({
×
547
                        type: 'string',
×
548
                        typed_string,
×
549
                });
×
550
        }
×
551

×
552
        static mode_from_schema<
×
553
                Mode extends TypedString_mode,
×
554
        >(
×
555
                schema: TypedString_type<Mode>['typed_string'],
×
556
                matchers: TypedString_matcher<TypedString_mode>[],
×
557
        ): Mode;
×
558
        static mode_from_schema(
×
559
                schema: unknown,
×
560
                matchers: TypedString_matcher<TypedString_mode>[],
×
561
        ): TypedString_mode {
×
562
                const match = matchers.find(([, maybe]) => maybe(schema));
×
563

×
564
                if (undefined === match) {
×
565
                        throw new TypeError('No mode determined for schema!');
×
566
                }
×
567

×
568
                return match[0];
×
569
        }
×
570
}
×
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