• 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/PrefixedString.ts
1
import type {
×
2
        TemplateLiteralTypeNode,
×
3
} from 'typescript';
×
4

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

×
14
import type {
×
15
        TemplatedStringParts,
×
16
} from '@signpostmarv/json-schema-typescript-codegen/ajv';
×
17
import {
×
18
        KeywordType,
×
19
        RegexpFailureError,
×
20
        TemplatedString,
×
21
} from '@signpostmarv/json-schema-typescript-codegen/ajv';
×
22

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

×
28
import type {
×
29
} from 'regexp.escape/auto';
×
30

×
31
export type mode = (
×
32
        | 'quoted'
×
33
        | 'non_quoted'
×
34
        | 'single_quoted'
×
35
        | 'version_specific_default'
×
36
);
×
37

×
38
export type PrefixedString_base_type<
×
39
        Mode extends string = string,
×
40
> = {
×
41
        type: 'string',
×
42
        DocsDotJson_PrefixedString: {
×
43
                prefix: string,
×
44
                mode: Mode,
×
45
                value: string|null,
×
46
        },
×
47
};
×
48

×
49
export type PrefixedString_type<
×
50
        Mode extends mode = mode,
×
51
> = PrefixedString_base_type<Mode>;
×
52

×
53
export type PrefixedString_base_schema<
×
54
        Mode extends string,
×
55
> = SchemaDefinitionDefinition<
×
56
        ['type', 'DocsDotJson_PrefixedString'],
×
57
        {
×
58
                $defs: (typeof $defs_schema)['properties']['$defs'],
×
59
                type: {
×
60
                        type: 'string',
×
61
                        const: 'string',
×
62
                },
×
63
                DocsDotJson_PrefixedString: {
×
64
                        type: 'object',
×
65
                        additionalProperties: false,
×
66
                        required: ['prefix', 'mode', 'value'],
×
67
                        properties: {
×
68
                                prefix: {
×
69
                                        type: 'string',
×
70
                                        minLength: 1,
×
71
                                },
×
72
                                mode: {
×
73
                                        type: 'string',
×
74
                                        const: Mode,
×
75
                                },
×
76
                                value: {
×
77
                                        oneOf: [
×
78
                                                {
×
79
                                                        type: 'string',
×
80
                                                        minLength: 1,
×
81
                                                },
×
82
                                                {
×
83
                                                        type: 'null',
×
84
                                                },
×
85
                                        ],
×
86
                                },
×
87
                        },
×
88
                },
×
89
        }
×
90
>;
×
91

×
92
type PrefixedString_schema<
×
93
        Mode extends mode,
×
94
> = PrefixedString_base_schema<Mode>;
×
95

×
96
export abstract class PrefixedString_base<
×
97
        Mode extends string,
×
98
        T_by_mode extends {[key in Mode]: string},
×
99
        SpecificOptions extends {mode: Mode},
×
100
        Type extends PrefixedString_base_type<Mode>,
×
101
        Schema extends PrefixedString_base_schema<Mode>,
×
102
        VersionSpecificDefaultMode extends Exclude<
×
103
                string,
×
104
                'version_specific_default'
×
105
        >,
×
106
> extends KeywordType<
×
107
                T_by_mode[Mode],
×
108
                Type,
×
109
                SpecificOptions,
×
110
                Schema,
×
111
                SpecificOptions
×
112
        > {
×
113
        #regex_from_instance: (
×
114
                instance: Type['DocsDotJson_PrefixedString'],
×
115
        ) => RegExp;
×
116

×
117
        protected version_specific_default: VersionSpecificDefaultMode;
×
118

×
119
        constructor(
×
120
                options: SchemalessTypeOptions,
×
121
                specific_options: SpecificOptions,
×
122
                version_specific_default: VersionSpecificDefaultMode,
×
123
                regex_from_instance: (
×
124
                        instance: Type['DocsDotJson_PrefixedString'],
×
125
                ) => RegExp,
×
126
        ) {
×
127
                super(
×
128
                        {
×
129
                                ...options,
×
130
                                ajv_keyword: {
×
131
                                        keyword: 'DocsDotJson_PrefixedString',
×
132
                                        type: 'string',
×
133
                                        macro: (
×
134
                                                instance: Type['DocsDotJson_PrefixedString'],
×
135
                                        ) => {
×
136
                                                let pattern = regex_from_instance(instance).toString();
×
137

×
138
                                                if (pattern.startsWith('/') && pattern.endsWith('/')) {
×
139
                                                        pattern = pattern.substring(1, pattern.length - 1);
×
140
                                                }
×
141

×
142
                                                return {
×
143
                                                        pattern,
×
144
                                                };
×
145
                                        },
×
146
                                },
×
147
                                type_definition: specific_options,
×
148
                                schema_definition: specific_options,
×
149
                                add_to_$defs_excluded: true,
×
150
                        },
×
151
                );
×
152

×
153
                this.#regex_from_instance = regex_from_instance;
×
154
                this.version_specific_default = version_specific_default;
×
155
        }
×
156

×
157
        generate_typescript_data(
×
158
                data: T_by_mode[Mode],
×
159
                schema_parser: SchemaParser,
×
160
                instance: Type,
×
161
        ): StringLiteral {
×
162
                const regex = this.#regex_from_instance(
×
163
                        instance.DocsDotJson_PrefixedString,
×
164
                );
×
165

×
166
                if (!regex.test(data)) {
×
167
                        throw new RegexpFailureError(
×
168
                                'Value does not match expected regex!',
×
169
                                regex,
×
170
                                data,
×
171
                        );
×
172
                }
×
173

×
174
                return factory.createStringLiteral(data);
×
175
        }
×
176

×
177
        generate_typescript_type({
×
178
                schema,
×
179
        }: {
×
180
                schema: Type,
×
181
        }): Promise<TemplateLiteralTypeNode> {
×
182
                return Promise.resolve(
×
183
                        TemplatedString.generate_typescript_type_from_parts(
×
184
                                this.TemplatedStringParts_by_value(
×
185
                                        schema.DocsDotJson_PrefixedString,
×
186
                                ),
×
187
                        ),
×
188
                );
×
189
        }
×
190

×
191
        protected abstract TemplatedStringParts_by_value(
×
192
                value: Type['DocsDotJson_PrefixedString'],
×
193
        ): TemplatedStringParts;
×
194
}
×
195

×
196
export type PrefixedString_value_type<
×
197
        Prefix extends Exclude<string, ''>,
×
198
> = {
×
199
        quoted: `${Prefix}'"/Game/FactoryGame/${
×
200
                string
×
201
        }"'`,
×
202
        single_quoted: `${Prefix}'/Game/FactoryGame/${
×
203
                string
×
204
        }'`,
×
205
        non_quoted: `${Prefix} /Game/FactoryGame/${
×
206
                string
×
207
        }`,
×
208
};
×
209

×
210
export class PrefixedString<
×
211
        Mode extends mode,
×
212
        Prefix extends Exclude<string, ''>,
×
213
        VersionSpecificDefaultMode extends Exclude<
×
214
                mode,
×
215
                'version_specific_default'
×
216
        >,
×
217
> extends PrefixedString_base<
×
218
                Mode,
×
219
                (
×
220
                        & PrefixedString_value_type<Prefix>
×
221
                        & {
×
222
                                version_specific_default: PrefixedString_value_type<
×
223
                                        Prefix
×
224
                                >[VersionSpecificDefaultMode],
×
225
                        }
×
226
                ),
×
227
                {mode: Mode},
×
228
                PrefixedString_type<Mode>,
×
229
                PrefixedString_schema<Mode>,
×
230
                VersionSpecificDefaultMode
×
231
        > {
×
232
        constructor(
×
233
                options: SchemalessTypeOptions,
×
234
                mode: Mode,
×
235
                version_specific_default: VersionSpecificDefaultMode,
×
236
        ) {
×
237
                super(
×
238
                        options,
×
239
                        {mode},
×
240
                        version_specific_default,
×
241
                        ({
×
242
                                prefix,
×
243
                                value,
×
244
                                mode,
×
245
                        }) => PrefixedString.#regex_from_prefix_value_and_mode(
×
246
                                prefix,
×
247
                                value,
×
248
                                mode,
×
249
                                version_specific_default,
×
250
                        ),
×
251
                );
×
252

×
253
                this.version_specific_default = version_specific_default;
×
254
        }
×
255

×
256
        protected TemplatedStringParts_by_value({
×
257
                prefix,
×
258
                mode,
×
259
                value,
×
260
        }: PrefixedString_type<
×
261
                Mode
×
262
        >['DocsDotJson_PrefixedString']): TemplatedStringParts {
×
263
                const head = {
×
264
                        non_quoted: `${prefix} /Game/FactoryGame/`,
×
265
                        quoted: `${prefix}'"/Game/FactoryGame/`,
×
266
                        single_quoted: `${prefix}'/Game/FactoryGame/`,
×
267
                        version_specific_default: '',
×
268
                };
×
269

×
270
                const tail = {
×
271
                        non_quoted: '',
×
272
                        quoted: `"'`,
×
273
                        single_quoted: `'`,
×
274
                        version_specific_default: '',
×
275
                };
×
276

×
277
                head[
×
278
                        'version_specific_default'
×
279
                ] = head[
×
280
                        this.version_specific_default
×
281
                ];
×
282
                tail[
×
283
                        'version_specific_default'
×
284
                ] = tail[
×
285
                        this.version_specific_default
×
286
                ];
×
287

×
288
                return [
×
289
                        head[mode],
×
290
                        null === value ? {type: 'string', minLength: 1} : value,
×
291
                        tail[mode],
×
292
                ];
×
293
        }
×
294

×
295
        static generate_schema_definition<
×
296
                Mode extends mode,
×
297
        >({
×
298
                mode,
×
299
        }: {
×
300
                mode: Mode,
×
301
        }): Readonly<PrefixedString_schema<Mode>> {
×
302
                const result: PrefixedString_schema<Mode> = {
×
303
                        type: 'object',
×
304
                        additionalProperties: false,
×
305
                        required: [
×
306
                                'type',
×
307
                                'DocsDotJson_PrefixedString',
×
308
                        ],
×
309
                        properties: {
×
310
                                $defs: $defs_schema.properties.$defs,
×
311
                                type: {
×
312
                                        type: 'string',
×
313
                                        const: 'string',
×
314
                                },
×
315
                                DocsDotJson_PrefixedString: {
×
316
                                        type: 'object',
×
317
                                        additionalProperties: false,
×
318
                                        required: ['prefix', 'mode', 'value'],
×
319
                                        properties: {
×
320
                                                prefix: {
×
321
                                                        type: 'string',
×
322
                                                        minLength: 1,
×
323
                                                },
×
324
                                                mode: {
×
325
                                                        type: 'string',
×
326
                                                        const: mode,
×
327
                                                },
×
328
                                                value: {
×
329
                                                        oneOf: [
×
330
                                                                {
×
331
                                                                        type: 'string',
×
332
                                                                        minLength: 1,
×
333
                                                                },
×
334
                                                                {
×
335
                                                                        type: 'null',
×
336
                                                                },
×
337
                                                        ],
×
338
                                                },
×
339
                                        },
×
340
                                },
×
341
                        },
×
342
                };
×
343

×
344
                return Object.freeze(result);
×
345
        }
×
346

×
347
        static generate_type_definition<
×
348
                Mode extends mode,
×
349
        >({
×
350
                prefix,
×
351
                mode,
×
352
        }: {
×
353
                prefix: Exclude<string, ''>,
×
354
                mode: Mode,
×
355
        }): Readonly<PrefixedString_type> {
×
356
                const result: PrefixedString_type<Mode> = {
×
357
                        type: 'string',
×
358
                        DocsDotJson_PrefixedString: {
×
359
                                prefix,
×
360
                                mode,
×
361
                                value: null,
×
362
                        },
×
363
                };
×
364

×
365
                return Object.freeze(result);
×
366
        }
×
367

×
368
        static regex_from_prefix_value_and_mode(
×
369
                prefix_string: Exclude<string, ''>|undefined,
×
370
                value: Exclude<string, ''>|null,
×
371
                mode: mode,
×
372
                version_specific_default: Exclude<mode, 'version_specific_default'>,
×
373
        ): string {
×
374
                let start: string;
×
375

×
376
                if (prefix_string) {
×
377
                        start = RegExp.escape({
×
378
                                quoted: `${prefix_string}'"`,
×
379
                                single_quoted: `${prefix_string}'`,
×
380
                                non_quoted: `${prefix_string} `,
×
381
                        }[
×
382
                                mode === 'version_specific_default'
×
383
                                        ? version_specific_default
×
384
                                        : mode
×
385
                        ]);
×
386
                } else {
×
387
                        start = {
×
388
                                quoted: `[^'"]+'"`,
×
389
                                single_quoted: `[^']+'`,
×
390
                                non_quoted: '[^ ]+ ',
×
391
                        }[
×
UNCOV
392
                                mode === 'version_specific_default'
×
UNCOV
393
                                        ? version_specific_default
×
UNCOV
394
                                        : mode
×
UNCOV
395
                        ];
×
UNCOV
396
                }
×
UNCOV
397

×
UNCOV
398

×
UNCOV
399
                if (null !== value) {
×
UNCOV
400
                        const escaped = RegExp.escape(value);
×
UNCOV
401
                        if ('quoted' === mode) {
×
UNCOV
402
                                return `${start}${escaped}"'`;
×
UNCOV
403
                        }
×
UNCOV
404

×
UNCOV
405
                        return `${start}${escaped}`;
×
UNCOV
406
                }
×
UNCOV
407

×
UNCOV
408
                const prefix = RegExp.escape('/Game/FactoryGame/');
×
UNCOV
409
                const suffix = RegExp.escape({
×
UNCOV
410
                        quoted: `"'`,
×
UNCOV
411
                        single_quoted: `'`,
×
UNCOV
412
                        non_quoted: '',
×
UNCOV
413
                }[
×
UNCOV
414
                        mode === 'version_specific_default'
×
UNCOV
415
                                ? version_specific_default
×
UNCOV
416
                                : mode
×
UNCOV
417
                ]);
×
UNCOV
418

×
UNCOV
419
                if ('quoted' === mode) {
×
UNCOV
420
                        return `${start}${prefix}(?:[^\\/_]+\\/)*[^."]+\\.[^."]+${suffix}`;
×
UNCOV
421
                }
×
UNCOV
422

×
UNCOV
423
                return `${start}${prefix}(?:[^\\/_]+\\/)*[^.]+\\.[^.]+${suffix}`;
×
UNCOV
424
        }
×
UNCOV
425

×
UNCOV
426
        static TemplatedStringParts_by_value(
×
UNCOV
427
                prefix: Exclude<string, ''>,
×
UNCOV
428
                mode: mode,
×
UNCOV
429
                version_specific_default: Exclude<mode, 'version_specific_default'>,
×
UNCOV
430
                value: Exclude<string, ''>|null,
×
UNCOV
431
        ): TemplatedStringParts {
×
UNCOV
432
                return [
×
UNCOV
433
                        {
×
UNCOV
434
                                non_quoted: `${prefix} /Game/FactoryGame/`,
×
UNCOV
435
                                quoted: `${prefix}'"/Game/FactoryGame/`,
×
UNCOV
436
                                single_quoted: `${prefix}'/Game/FactoryGame/`,
×
UNCOV
437
                        }[
×
UNCOV
438
                                mode === 'version_specific_default'
×
UNCOV
439
                                        ? version_specific_default
×
UNCOV
440
                                        : mode
×
UNCOV
441
                        ],
×
UNCOV
442
                        null === value ? {type: 'string'} : value,
×
UNCOV
443
                        {
×
UNCOV
444
                                non_quoted: '',
×
UNCOV
445
                                quoted: `"'`,
×
UNCOV
446
                                single_quoted: `'`,
×
UNCOV
447
                        }[
×
UNCOV
448
                                mode === 'version_specific_default'
×
UNCOV
449
                                        ? version_specific_default
×
UNCOV
450
                                        : mode
×
UNCOV
451
                        ],
×
UNCOV
452
                ];
×
UNCOV
453
        }
×
UNCOV
454

×
UNCOV
455
        static #regex_from_prefix_value_and_mode(
×
UNCOV
456
                prefix: Exclude<string, ''>,
×
UNCOV
457
                value: Exclude<string, ''>|null,
×
UNCOV
458
                mode: mode,
×
UNCOV
459
                version_specific_default: Exclude<mode, 'version_specific_default'>,
×
UNCOV
460
        ): RegExp {
×
UNCOV
461
                return new RegExp(`^${
×
UNCOV
462
                        this.regex_from_prefix_value_and_mode(
×
UNCOV
463
                                prefix,
×
UNCOV
464
                                value,
×
UNCOV
465
                                mode,
×
UNCOV
466
                                version_specific_default,
×
UNCOV
467
                        )
×
UNCOV
468
                }$`);
×
UNCOV
469
        }
×
UNCOV
470
}
×
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

© 2025 Coveralls, Inc