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

satisfactory-dev / Docs.json.ts / 20385899622

20 Dec 2025 12:10AM UTC coverage: 0.0%. Remained the same
20385899622

push

github

SignpostMarv
adjusting indentation

0 of 53 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 11 new or added lines in 1 file covered. (0.0%)

230 existing lines in 15 files now uncovered.

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

×
6
import type {
×
7
        $ref,
×
8
        SchemaDefinitionDefinition,
×
9
        SchemalessTypeOptions,
×
10
        SchemaObject,
×
11
        SchemaParser,
×
12
        TypeDefinitionSchema,
×
13
} from '@signpostmarv/json-schema-typescript-codegen';
×
14
import {
×
15
        Type,
×
16
} from '@signpostmarv/json-schema-typescript-codegen';
×
17

×
18
// required for type hinting on github actions checks
×
19
import type {
×
20
} from '@signpostmarv/json-schema-typescript-codegen/javascript-overrides';
×
21

×
22
import {
×
23
        KeywordType,
×
24
} from '@signpostmarv/json-schema-typescript-codegen/ajv';
×
25

×
26
import {
×
27
        object_has_property,
×
28
} from '@satisfactory-dev/predicates.ts';
×
29

×
30
import type {
×
31
        Empty_DataTo,
×
32
        Empty_properties,
×
33
        Empty_SchemaTo,
×
34
        Empty_type,
×
35
        Empty_TypeGenerator,
×
36
} from './TypedString/Empty.ts';
×
37
import {
×
38
        Empty_ajv_macro,
×
39
        Empty_compile_vaildator,
×
40
        Empty_generate_schema_definition,
×
41
        Empty_generate_type_definition,
×
42
        Empty_generate_typescript_data,
×
43
        Empty_generate_typescript_type,
×
44
} from './TypedString/Empty.ts';
×
45

×
46
import type {
×
47
        Object_DataTo,
×
48
        Object_properties,
×
49
        Object_SchemaTo,
×
50
        Object_type,
×
51
        Object_TypeGenerator,
×
52
        PropertySchemaToRegex,
×
53
} from './TypedString/Object.ts';
×
54
import {
×
55
        Object_ajv_macro,
×
56
        Object_compile_validator,
×
57
        Object_generate_schema_definition,
×
58
        Object_generate_type_definition,
×
59
        Object_generate_typescript_data,
×
60
        Object_generate_typescript_type,
×
61
} from './TypedString/Object.ts';
×
62

×
63
import type {
×
64
        FlexibleArray_DataTo,
×
65
        FlexibleArray_schema_properties,
×
66
        FlexibleArray_SchemaTo,
×
67
        FlexibleArray_type,
×
68
} from './TypedString/FlexibleArray.ts';
×
69
import {
×
70
        FlexibleArray_ajv_macro__items,
×
71
        FlexibleArray_ajv_macro__prefixItems,
×
72
        FlexibleArray_compile_validator,
×
73
        FlexibleArray_generate_data,
×
74
        FlexibleArray_generate_schema_definition__items,
×
75
        FlexibleArray_generate_schema_definition__prefixItems,
×
76
        FlexibleArray_generate_type,
×
77
        FlexibleArray_generate_type_definition__items,
×
78
        FlexibleArray_generate_type_definition__prefixItems,
×
79
} from './TypedString/FlexibleArray.ts';
×
80

×
81
import {
×
82
        ConstString,
×
83
} from './TypedString/PropertySchemaToRegex/ConstString.ts';
×
84

×
85
import {
×
86
        PrefixedString as PrefixedStringMatcher,
×
87
} from './TypedString/PropertySchemaToRegex/PrefixedString.ts';
×
88

×
89
import {
×
90
        NamedListMatcher,
×
91
} from './TypedString/PropertySchemaToRegex/NamedListMatcher.ts';
×
92

×
93
import {
×
94
        TemplatedStringMatcher,
×
95
} from './TypedString/PropertySchemaToRegex/TemplatedStringMatcher.ts';
×
96

×
97
import {
×
98
        FlexibleArrayMatcher__items,
×
99
        FlexibleArrayMatcher__prefixItems,
×
100
} from './TypedString/PropertySchemaToRegex/FlexibleArrayMatcher.ts';
×
101

×
102
import {
×
103
        EnumString,
×
104
} from './TypedString/PropertySchemaToRegex/EnumString.ts';
×
105

×
106
import {
×
107
        PatternString,
×
108
} from './TypedString/PropertySchemaToRegex/PatternString.ts';
×
109

×
110
import {
×
111
        RefResolver,
×
112
} from './TypedString/PropertySchemaToRegex/RefResolver.ts';
×
113

×
114
export type TypedString_mode = (
×
115
        | 'Empty'
×
116
        | 'Object'
×
117
        | 'FlexibleArray__items'
×
118
        | 'FlexibleArray__prefixItems'
×
119
);
×
120

×
121
export type TypedString_type__by_mode = {
×
122
        Empty: Empty_type,
×
123
        Object: Object_type,
×
124
        FlexibleArray__items: FlexibleArray_type<'items'>,
×
125
        FlexibleArray__prefixItems: FlexibleArray_type<'prefixItems'>,
×
126
};
×
127

×
128
export type TypedString_type<
×
129
        Mode extends TypedString_mode,
×
130
> = {
×
131
        type: 'string',
×
132
        typed_string: TypedString_type__by_mode[Mode],
×
133
};
×
134

×
135
export type TypedString_matcher<
×
136
        Mode extends TypedString_mode,
×
137
> = [
×
138
        Mode,
×
139
        ValidateFunction<TypedString_type<Mode>['typed_string']>,
×
140
];
×
141

×
142
export type TypedString_type_OneOf = {
×
143
        oneOf: [
×
144
                TypedString_type<'Empty'>,
×
145
                TypedString_type<'Object'>,
×
146
                TypedString_type<'FlexibleArray__items'>,
×
147
                TypedString_type<'FlexibleArray__prefixItems'>,
×
148
        ],
×
149
};
×
150

×
151
export type TypedString_schema_properties = {
×
152
        Empty: Empty_properties,
×
153
        Object: Object_properties,
×
154
        FlexibleArray__items: FlexibleArray_schema_properties<'items'>,
×
155
        FlexibleArray__prefixItems: FlexibleArray_schema_properties<'prefixItems'>,
×
156
};
×
157

×
158
type TypedString_schema_properties_typed_string<
×
159
        Mode extends TypedString_mode,
×
160
> = TypedString_schema_properties[Mode];
×
161

×
162
type TypedString_schema<
×
163
        Mode extends TypedString_mode,
×
164
> = SchemaDefinitionDefinition<
×
165
        ['type', 'typed_string'],
×
166
        {
×
167
                $defs: {
×
168
                        type: 'object',
×
169
                        additionalProperties: {
×
170
                                type: 'object',
×
171
                        },
×
172
                },
×
173
                type: {
×
174
                        type: 'string',
×
175
                        const: 'string',
×
176
                },
×
177
                typed_string: TypedString_schema_properties_typed_string<Mode>,
×
178
        }
×
179
>;
×
180

×
181
export type TypedString_schema_OneOf = TypeDefinitionSchema & {
×
182
        oneOf: [
×
183
                TypedString_schema<'Empty'>,
×
184
                TypedString_schema<'Object'>,
×
185
                TypedString_schema<'FlexibleArray__items'>,
×
186
                TypedString_schema<'FlexibleArray__prefixItems'>,
×
187
        ],
×
188
};
×
189

×
190
export type TypedString_SchemaTo__by_mode = {
×
191
        Empty: Empty_SchemaTo,
×
192
        Object: Object_SchemaTo,
×
193
        FlexibleArray__items: FlexibleArray_SchemaTo<'items'>,
×
194
        FlexibleArray__prefixItems: FlexibleArray_SchemaTo<'prefixItems'>,
×
195
};
×
196

×
197
type TypedString_SchemaTo<
×
198
        Mode extends TypedString_mode,
×
199
> = TypedString_SchemaTo__by_mode[Mode];
×
200

×
201
export type TypedString_DataTo__by_mode = {
×
202
        Empty: Empty_DataTo,
×
203
        Object: Object_DataTo,
×
204
        FlexibleArray__items: FlexibleArray_DataTo,
×
205
        FlexibleArray__prefixItems: FlexibleArray_DataTo,
×
206
};
×
207

×
208
type TypedString_DataTo<
×
209
        Mode extends TypedString_mode,
×
210
> = TypedString_DataTo__by_mode[Mode];
×
211

×
212
export type Type_Generator__by_mode = {
×
213
        Empty: Empty_TypeGenerator,
×
214
        Object: Object_TypeGenerator,
×
215
};
×
216

×
217
export function compile_validators(ajv: Ajv): {
×
218
        [key in TypedString_mode]: ValidateFunction<
×
219
                TypedString_type<key>['typed_string']
×
220
        >
×
221
} {
×
222
        return {
×
223
                Empty: Empty_compile_vaildator(ajv),
×
224
                Object: Object_compile_validator(ajv),
×
225
                FlexibleArray__items: FlexibleArray_compile_validator(ajv, 'items'),
×
226
                FlexibleArray__prefixItems: FlexibleArray_compile_validator(
×
227
                        ajv,
×
228
                        'prefixItems',
×
229
                ),
×
230
        };
×
231
}
×
232

×
233
export type PropertySchemaToRegex__matchers_object = {
×
234
        [key: string]: (
×
235
                options: {
×
236
                        ajv: Ajv,
×
237
                        existing: PropertySchemaToRegex<unknown>[],
×
238
                        Object_matcher_instance: PropertySchemaToRegex<{
×
239
                                type: 'string',
×
240
                                typed_string: Object_type,
×
241
                        }>,
×
242
                        $ref_instance: $ref,
×
243
                },
×
244
        ) => PropertySchemaToRegex<unknown>[],
×
245
};
×
246

×
247
export function PropertySchemaToRegex__matchers_as_object(
×
248
): PropertySchemaToRegex__matchers_object {
×
249
        return {
×
250
                ConstString: ({ajv}) => [ConstString(ajv)],
×
251
                EnumString: ({ajv}) => [EnumString(ajv)],
×
252
                PatternString: ({ajv}) => [PatternString(ajv)],
×
253
                PrefixedStringMatcher: ({ajv}) => [
×
254
                        PrefixedStringMatcher(ajv, 'quoted', 'quoted'),
×
255
                        PrefixedStringMatcher(ajv, 'single_quoted', 'quoted'),
×
256
                        PrefixedStringMatcher(ajv, 'non_quoted', 'quoted'),
×
257
                        PrefixedStringMatcher(ajv, 'version_specific_default', 'quoted'),
×
258
                ],
×
259
                NamedListMatcher: ({ajv}) => [NamedListMatcher(ajv)],
×
260
                TemplatedStringMatcher: ({ajv}) => [TemplatedStringMatcher(ajv)],
×
261
                FlexibleArrayMatcher: ({ajv, existing}) => [
×
262
                        FlexibleArrayMatcher__items(
×
263
                                ajv,
×
264
                                existing,
×
265
                        ),
×
266
                        FlexibleArrayMatcher__prefixItems(
×
267
                                ajv,
×
268
                                existing,
×
269
                        ),
×
270
                ],
×
271
                $ref: ({ajv, existing, $ref_instance}) => [RefResolver(
×
272
                        ajv,
×
273
                        existing,
×
274
                        $ref_instance,
×
275
                )],
×
276
        } as PropertySchemaToRegex__matchers_object;
×
277
}
×
278

×
279
export function PropertySchemaToRegex__matchers(
×
280
        ajv: Ajv,
×
281
        existing: PropertySchemaToRegex<unknown>[],
×
282
        Object_matcher_instance: PropertySchemaToRegex<{
×
283
                type: 'string',
×
284
                typed_string: Object_type,
×
285
        }>,
×
286
        $ref_instance: $ref,
×
287
) {
×
288
        return Object.values(
×
289
                PropertySchemaToRegex__matchers_as_object(),
×
290
        ).flatMap((cb) => cb({
×
291
                ajv,
×
292
                existing,
×
293
                Object_matcher_instance,
×
294
                $ref_instance,
×
295
        }));
×
296
}
×
297

×
298
export function generate_typescript_data__by_mode<
×
299
        Mode extends TypedString_mode,
×
300
>(
×
301
        data: string,
×
302
        schema_parser: SchemaParser,
×
303
        schema: TypedString_type<Mode>,
×
304
        mode: TypedString_mode,
×
305
        property_schema_to_regex: PropertySchemaToRegex<unknown>[],
×
306
): TypedString_DataTo<Mode>|undefined {
×
307
        let result: TypedString_DataTo<Mode>;
×
308

×
309
        if ('Empty' === mode) {
×
310
                result = Empty_generate_typescript_data() as typeof result;
×
311
        } else if ('Object' === mode) {
×
312
                let coerced_schema = schema.typed_string as TypedString_type<
×
313
                        'Object'
×
314
                >['typed_string'];
×
315

×
316
                coerced_schema = Type.maybe_add_$defs(schema, coerced_schema);
×
317

×
318
                result = Object_generate_typescript_data(
×
319
                        data,
×
320
                        schema_parser,
×
321
                        coerced_schema,
×
322
                        schema,
×
323
                        property_schema_to_regex,
×
324
                ) as typeof result;
×
325
        } else if (
×
326
                'FlexibleArray__items' === mode
×
327
        ) {
×
328
                let coerced = (
×
329
                        schema as TypedString_type<'FlexibleArray__items'>
×
330
                ).typed_string;
×
331

×
332
                if ('$defs' in schema && !('$defs' in coerced)) {
×
333
                        coerced = {
×
334
                                $defs: schema.$defs,
×
335
                                ...coerced,
×
336
                        } as TypedString_type<'FlexibleArray__items'>['typed_string'];
×
337
                }
×
338

×
339
                return FlexibleArray_generate_data<'items'>(
×
340
                        'items',
×
341
                        data,
×
342
                        coerced,
×
343
                        schema_parser,
×
344
                        property_schema_to_regex,
×
345
                ) as TypedString_DataTo<Mode>;
×
346
        } else if (
×
347
                'FlexibleArray__prefixItems' === mode
×
348
        ) {
×
349
                const coerced = (
×
350
                        schema as TypedString_type<'FlexibleArray__prefixItems'>
×
351
                ).typed_string;
×
352

×
353
                return FlexibleArray_generate_data<'prefixItems'>(
×
354
                        'prefixItems',
×
355
                        data,
×
356
                        coerced,
×
357
                        schema_parser,
×
358
                        property_schema_to_regex,
×
359
                ) as TypedString_DataTo<Mode>;
×
360
        } else {
×
361
                return undefined;
×
362
        }
×
363

×
364
        return result;
×
365
}
×
366

×
367
function generate_typescript_data<
×
368
        Mode extends TypedString_mode,
×
369
>(
×
370
        data: string,
×
371
        schema_parser: SchemaParser,
×
372
        schema: TypedString_type<Mode>,
×
373
        mode_by_validator: TypedString_matcher<TypedString_mode>[],
×
374
        property_schema_to_regex: PropertySchemaToRegex<unknown>[],
×
375
): TypedString_DataTo<Mode>|undefined {
×
376
        const mode = TypedString.mode_from_schema(
×
377
                schema.typed_string,
×
378
                mode_by_validator,
×
379
        );
×
380

×
381
        return generate_typescript_data__by_mode(
×
382
                data,
×
383
                schema_parser,
×
384
                schema,
×
385
                mode,
×
386
                property_schema_to_regex,
×
387
        );
×
388
}
×
389

×
390
export function generate_typescript_type__by_mode<
×
391
        Mode extends TypedString_mode,
×
392
>(
×
393
        data: unknown,
×
394
        schema: TypedString_type<Mode>,
×
395
        schema_parser: SchemaParser,
×
396
        mode: Mode,
×
397
): Promise<
×
398
        TypedString_SchemaTo<Mode>
×
399
>|undefined {
×
400
        let result: Promise<
×
401
                TypedString_SchemaTo<Mode>
×
402
        >;
×
403

×
404
        if ('Empty' === mode) {
×
405
                result = Promise.resolve(
×
406
                        Empty_generate_typescript_type(),
×
407
                ) as typeof result;
×
408
        } else if ('Object' === mode) {
×
409
                const coerced_schema: (
×
410
                        Object_type
×
411
                ) = schema.typed_string as Object_type;
×
412

×
413
                result = Object_generate_typescript_type(
×
414
                        coerced_schema,
×
415
                        schema_parser,
×
416
                ) as typeof result;
×
417
        } else if (
×
418
                'FlexibleArray__items' === mode
×
419
        ) {
×
420
                const coerced = (
×
421
                        schema as TypedString_type<'FlexibleArray__items'>
×
422
                ).typed_string;
×
423

×
424
                return FlexibleArray_generate_type(
×
425
                        'items',
×
426
                        data,
×
427
                        coerced,
×
428
                        schema_parser,
×
429
                ) as Promise<TypedString_SchemaTo<Mode>>;
×
430
        } else if (
×
431
                'FlexibleArray__prefixItems' === mode
×
432
        ) {
×
433
                const coerced = (
×
434
                        schema as TypedString_type<'FlexibleArray__prefixItems'>
×
435
                ).typed_string;
×
436

×
437
                return FlexibleArray_generate_type(
×
438
                        'prefixItems',
×
439
                        data,
×
440
                        coerced,
×
441
                        schema_parser,
×
442
                ) as Promise<TypedString_SchemaTo<Mode>>;
×
443
        } else {
×
444
                return undefined;
×
445
        }
×
446

×
447
        return result;
×
448
}
×
449

×
450
function generate_typescript_type<
×
451
        Mode extends TypedString_mode,
×
452
>(
×
453
        data: unknown,
×
454
        schema: TypedString_type<Mode>,
×
455
        schema_parser: SchemaParser,
×
456
        mode_by_validator: TypedString_matcher<TypedString_mode>[],
×
457
): Promise<
×
458
        TypedString_SchemaTo<Mode>
×
459
>|undefined {
×
460
        const mode = TypedString.mode_from_schema(
×
461
                schema.typed_string,
×
462
                mode_by_validator,
×
463
        );
×
464

×
465
        return generate_typescript_type__by_mode(
×
466
                data,
×
467
                schema,
×
468
                schema_parser,
×
469
                mode,
×
470
        );
×
471
}
×
472

×
473
export class TypedString<
×
474
        Mode extends TypedString_mode,
×
475
> extends
×
476
        KeywordType<
×
477
                Exclude<string, ''>,
×
478
                TypedString_type_OneOf,
×
479
                Record<string, never>,
×
480
                TypedString_schema_OneOf,
×
481
                Record<string, never>,
×
482
                TypedString_SchemaTo<Mode>,
×
483
                TypedString_DataTo<Mode>,
×
484
                TypedString_type<Mode>
×
485
        > {
×
486
        #mode_by_validator: TypedString_matcher<TypedString_mode>[];
×
487

×
488
        #property_schema_to_regex: PropertySchemaToRegex<unknown>[];
×
489

×
490
        constructor(
×
491
                options: SchemalessTypeOptions,
×
492
                {
×
493
                        $ref_instance,
×
494
                        Object: Object_options,
×
495
                }: {
×
496
                        $ref_instance: $ref,
×
497
                        Object?: {
×
498
                                matchers: PropertySchemaToRegex<unknown>[],
×
499
                        },
×
500
                },
×
501
        ) {
×
502
                const mode_from_schema = compile_validators(options.ajv);
×
503

×
504
                const entries = Object.entries(mode_from_schema);
×
505

×
506
                super({
×
507
                        ...options,
×
508
                        ajv_keyword: {
×
509
                                keyword: 'typed_string',
×
510
                                type: 'string',
×
511
                                macro: (
×
512
                                        schema: TypedString_type<Mode>['typed_string'],
×
513
                                        parent_schema,
×
514
                                        it,
×
515
                                ) => {
×
516
                                        const mode = TypedString.mode_from_schema(
×
517
                                                schema,
×
518
                                                entries,
×
519
                                        );
×
520

×
521
                                        let root_schema: SchemaObject = {$defs: {}};
×
522

×
523
                                        if (
×
524
                                                object_has_property(it.self.schemas, it.baseId)
×
525
                                                && object_has_property(
×
526
                                                        it.self.schemas[it.baseId],
×
527
                                                        'schema',
×
528
                                                )
×
529
                                                && object_has_property(
×
530
                                                        it.self.schemas[it.baseId]?.schema,
×
531
                                                        '$defs',
×
532
                                                )
×
533
                                        ) {
×
534
                                                root_schema = it.self.schemas[
×
535
                                                        it.baseId
×
536
                                                ]?.schema as SchemaObject;
×
537
                                        } else if (
×
538
                                                '#' === it.baseId
×
539
                                                && object_has_property(
×
540
                                                        it.schemaEnv.root.schema,
×
541
                                                        '$defs',
×
542
                                                )
×
543
                                        ) {
×
544
                                                root_schema = (
×
545
                                                        it.schemaEnv.root.schema as SchemaObject
×
546
                                                );
×
547
                                        }
×
548

×
549
                                        if (Object.keys(root_schema.$defs || {}).length > 0) {
×
550
                                                schema = Type.maybe_add_$defs(
×
551
                                                        root_schema,
×
552
                                                        schema,
×
553
                                                );
×
554
                                        }
×
555

×
556
                                        return TypedString.ajv_macro(mode, schema, {
×
557
                                                $ref_instance,
×
558
                                                Object: Object_options || {
×
559
                                                        matchers: [],
×
560
                                                },
×
561
                                        });
×
562
                                },
×
563
                        },
×
564
                        type_definition: {},
×
565
                        schema_definition: {},
×
566
                });
×
567

×
568
                this.#mode_by_validator = entries;
×
569
                this.#property_schema_to_regex = Object_options?.matchers || [];
×
570
        }
×
571

×
572
        generate_typescript_data(
×
573
                data: string,
×
574
                schema_parser: SchemaParser,
×
575
                schema: TypedString_type<Mode>,
×
576
        ): TypedString_DataTo<Mode> {
×
577
                const result = generate_typescript_data(
×
578
                        data,
×
579
                        schema_parser,
×
580
                        schema,
×
581
                        this.#mode_by_validator,
×
582
                        this.#property_schema_to_regex,
×
583
                );
×
584

×
585
                if (!result) {
×
586
                        throw new TypeError('Not implemented!');
×
587
                }
×
588

×
589
                return result;
×
590
        }
×
591

×
592
        generate_typescript_type({
×
593
                data,
×
594
                schema,
×
595
                schema_parser,
×
596
        }: {
×
597
                data: unknown,
×
598
                schema: TypedString_type<Mode>,
×
599
                schema_parser: SchemaParser,
×
600
        }): Promise<TypedString_SchemaTo<Mode>> {
×
601
                const result = generate_typescript_type(
×
602
                        data,
×
603
                        schema,
×
604
                        schema_parser,
×
605
                        this.#mode_by_validator,
×
606
                );
×
607

×
608
                if (undefined === result) {
×
609
                        throw new TypeError('not implemented!');
×
610
                }
×
611

×
612
                return result;
×
613
        }
×
614

×
615
        static ajv_macro<
×
616
                Mode extends TypedString_mode,
×
617
        >(
×
618
                mode: Mode,
×
619
                schema: TypedString_type<Mode>['typed_string'],
×
620
                {
×
621
                        Object,
×
622
                }: {
×
623
                        $ref_instance: $ref,
×
624
                        Object: {
×
625
                                matchers: PropertySchemaToRegex<unknown>[],
×
626
                        },
×
627
                },
×
628
        ) {
×
629
                if ('Empty' === mode) {
×
630
                        return Empty_ajv_macro();
×
631
                } else if ('Object' === mode) {
×
632
                        const coerced = schema as TypedString_type<
×
633
                                'Object'
×
634
                        >['typed_string'];
×
635

×
636
                        return Object_ajv_macro(
×
637
                                coerced,
×
638
                                Object.matchers,
×
639
                        );
×
640
                } else if (
×
641
                        'FlexibleArray__items' === mode
×
642
                ) {
×
643
                        const coerced = (
×
644
                                schema as TypedString_type<
×
645
                                        'FlexibleArray__items'
×
646
                                >['typed_string']
×
647
                        );
×
648

×
649
                        return FlexibleArray_ajv_macro__items(
×
650
                                coerced,
×
651
                                Object.matchers,
×
652
                        );
×
653
                } else if (
×
654
                        'FlexibleArray__prefixItems' === mode
×
655
                ) {
×
656
                        const coerced = (
×
657
                                schema as TypedString_type<
×
658
                                        'FlexibleArray__prefixItems'
×
659
                                >['typed_string']
×
660
                        );
×
661

×
662
                        return FlexibleArray_ajv_macro__prefixItems(
×
663
                                coerced,
×
664
                                Object.matchers,
×
665
                        );
×
666
                } else {
×
667
                        throw new TypeError('Mode not implemented!');
×
668
                }
×
669
        }
×
670

×
671
        static generate_schema_definition(): Readonly<TypedString_schema_OneOf> {
×
672
                return Object.freeze({
×
673
                        oneOf: [
×
674
                                this.#generate_schema_definition('Empty'),
×
675
                                this.#generate_schema_definition('Object'),
×
676
                                this.#generate_schema_definition('FlexibleArray__items'),
×
677
                                this.#generate_schema_definition('FlexibleArray__prefixItems'),
×
678
                        ],
×
679
                });
×
680
        }
×
681

×
682
        static #generate_schema_definition<
×
683
                Mode extends TypedString_mode,
×
684
        >(
×
685
                mode: Mode,
×
686
        ): Readonly<TypedString_schema<Mode>> {
×
687
                let typed_string: TypedString_schema_properties_typed_string<
×
688
                        Mode
×
689
                >;
×
690

×
691
                if ('Empty' === mode) {
×
692
                        typed_string = Empty_generate_schema_definition(
×
693
                        ) as typeof typed_string;
×
694
                } else if ('Object' === mode) {
×
695
                        typed_string = Object_generate_schema_definition(
×
696
                        ) as typeof typed_string;
×
697
                } else if ('FlexibleArray__items' === mode) {
×
698
                        typed_string = FlexibleArray_generate_schema_definition__items(
×
699
                        ) as typeof typed_string;
×
700
                } else if ('FlexibleArray__prefixItems' === mode) {
×
701
                        // eslint-disable-next-line @stylistic/max-len
×
702
                        typed_string = FlexibleArray_generate_schema_definition__prefixItems(
×
703
                        ) as typeof typed_string;
×
704
                } else {
×
705
                        throw new TypeError('not implemented!');
×
706
                }
×
707

×
708
                const properties: TypedString_schema<Mode>['properties'] = {
×
709
                        $defs: {
×
710
                                type: 'object',
×
711
                                additionalProperties: {
×
712
                                        type: 'object',
×
713
                                },
×
714
                        },
×
715
                        type: {
×
716
                                type: 'string',
×
717
                                const: 'string',
×
718
                        },
×
719
                        typed_string,
×
720
                };
×
721

×
722
                return Object.freeze({
×
723
                        type: 'object',
×
724
                        additionalProperties: false,
×
725
                        required: ['type', 'typed_string'],
×
726
                        properties,
×
727
                });
×
728
        }
×
729

×
730
        static generate_type_definition(): Readonly<TypedString_type_OneOf> {
×
731
                return Object.freeze({
×
732
                        oneOf: [
×
733
                                this.#generate_type_definition('Empty'),
×
734
                                this.#generate_type_definition('Object'),
×
735
                                this.#generate_type_definition('FlexibleArray__items'),
×
736
                                this.#generate_type_definition('FlexibleArray__prefixItems'),
×
737
                        ],
×
738
                });
×
739
        }
×
740

×
741
        static #generate_type_definition<
×
742
                Mode extends TypedString_mode,
×
743
        >(
×
744
                mode: Mode,
×
745
        ): Readonly<TypedString_type<Mode>> {
×
746
                let typed_string: TypedString_type<Mode>['typed_string'];
×
747

×
748
                if ('Empty' === mode) {
×
749
                        typed_string = Empty_generate_type_definition(
×
750
                        ) as typeof typed_string;
×
751
                } else if ('Object' === mode) {
×
752
                        typed_string = Object_generate_type_definition(
×
753
                        ) as typeof typed_string;
×
754
                } else if ('FlexibleArray__items' === mode) {
×
755
                        typed_string = FlexibleArray_generate_type_definition__items(
×
756
                        ) as typeof typed_string;
×
757
                } else if ('FlexibleArray__prefixItems' === mode) {
×
758
                        typed_string = FlexibleArray_generate_type_definition__prefixItems(
×
759
                        ) as typeof typed_string;
×
760
                } else {
×
761
                        throw new TypeError('Not Implemented!');
×
762
                }
×
763

×
764
                return Object.freeze({
×
765
                        type: 'string',
×
766
                        typed_string,
×
767
                });
×
768
        }
×
769

×
770
        static mode_from_schema<
×
771
                Mode extends TypedString_mode,
×
772
        >(
×
773
                schema: TypedString_type<Mode>['typed_string'],
×
774
                matchers: TypedString_matcher<TypedString_mode>[],
×
775
        ): Mode;
×
776
        static mode_from_schema(
×
777
                schema: unknown,
×
778
                matchers: TypedString_matcher<TypedString_mode>[],
×
779
        ): TypedString_mode {
×
780
                let match = matchers.find(([, maybe]) => maybe(schema));
×
781

×
782
                if (undefined === match) {
×
783
                        if (
×
784
                                object_has_property(schema, 'uniqueItems')
×
785
                                && false === schema.uniqueItems
×
786
                        ) {
×
787
                                match = matchers.find(([, maybe]) => maybe({
×
788
                                        ...schema,
×
789
                                        uniqueItems: true,
×
790
                                }));
×
791
                        }
×
792
                }
×
793

×
794
                if (undefined === match) {
×
795
                        console.error(schema);
×
796

×
797
                        throw new TypeError('No mode determined for schema!');
×
798
                }
×
799

×
800
                return match[0];
×
801
        }
×
UNCOV
802
}
×
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