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

satisfactory-dev / Docs.json.ts / 20035721888

08 Dec 2025 04:46PM UTC coverage: 0.0%. Remained the same
20035721888

push

github

SignpostMarv
adjusting indentation

0 of 53 branches covered (0.0%)

Branch coverage included in aggregate %.

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

530 existing lines in 11 files now uncovered.

0 of 10264 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
export type Object_type = object_type_base<
×
30
        'properties',
×
31
        SchemaObject,
×
32
        [string, ...string[]],
×
33
        ObjectOfSchemas,
×
34
        ObjectOfSchemas
×
35
>;
×
36

×
37
export type Object_properties = object_schema<'properties'>;
×
38

×
39
export type Object_DataTo = ObjectLiteralExpression;
×
40

×
41
export type Object_SchemaTo = object_TypeLiteralNode_possibly_extended<
×
42
        'properties'
×
43
>;
×
44

×
45
export type Object_TypeGenerator = (
×
46
        schema: object_type_base<
×
47
                'properties',
×
48
                SchemaObject,
×
49
                [string, ...string[]],
×
50
                ObjectOfSchemas,
×
51
                ObjectOfSchemas
×
52
        >,
×
53
        schema_parser: SchemaParser,
×
54
) => Promise<object_TypeLiteralNode_possibly_extended<'properties'>>;
×
55

×
56
export const Object_type_schema = Object.freeze({
×
57
        type: 'object',
×
58
        required: ['type'],
×
59
        properties: {
×
60
                type: {
×
61
                        type: 'string',
×
62
                        const: 'object',
×
63
                },
×
64
        },
×
65
});
×
66

×
67
export function Object_compile_validator(
×
68
        ajv: Ajv,
×
69
): ValidateFunction<Object_type> {
×
70
        return ajv.compile<
×
71
                Object_type
×
72
        >(
×
73
                Object_type_schema,
×
74
        );
×
75
}
×
76

×
77
export function computedProperty_or_string(
×
78
        property: string,
×
79
): ComputedPropertyName|string {
×
80
        return /[?[\] ]/.test(property)
×
81
                ? factory.createComputedPropertyName(
×
82
                        factory.createStringLiteral(property),
×
83
                )
×
84
                : property;
×
85
}
×
86

×
87
export function Object_generate_typescript_data(
×
88
        data: string,
×
89
        schema_parser: SchemaParser,
×
90
        coerced_schema: Object_type,
×
91
        schema: SchemaObject,
×
92
): Object_DataTo {
×
93
        const properties = Object.keys(
×
94
                coerced_schema.properties,
×
95
        );
×
96

×
97
        const regex = new RegExp(`^\\((?:,?${properties.map(
×
98
                (property): [
×
99
                        string,
×
100
                        string,
×
101
                ] => [
×
102
                        property,
×
103
                        `(${RegExp.escape(property)})=([^=]+|\\(.+\\)(?=[,\\)]))`,
×
104
                ],
×
105
        ).map(([
×
106
                property,
×
107
                regex,
×
108
        ], i) => (
×
109
                (
×
110
                        coerced_schema.required || ([] as string[])
×
111
                ).includes(property)
×
112
                        ? `${i > 0 ? ',' : ''}${regex}`
×
113
                        : `(?:${i > 0 ? ',' : ''}${regex})?`
×
114
        )).join('')})*\\)$`);
×
115

×
116
        const match = regex.exec(data);
×
117

×
118
        if (null === match) {
×
119
                throw new TypeError('Data does not match expected regex!');
×
120
        }
×
121

×
122
        const [, ...matches] = match;
×
123

×
124
        const property_assignments: PropertyAssignment[] = [];
×
125

×
126
        for (let i = 0; i < matches.length; i += 2) {
×
127
                const property_name = matches[i];
×
128
                const property_value = matches[i + 1];
×
129

×
130
                if (
×
131
                        undefined === property_name
×
132
                        && undefined === property_value
×
133
                ) {
×
134
                        continue;
×
135
                }
×
136

×
137
                const property_schema = Type.maybe_add_$defs(
×
138
                        schema,
×
139
                        coerced_schema.properties[
×
140
                                property_name
×
141
                        ],
×
142
                );
×
143

×
144
                const type_for_property = schema_parser.parse(
×
145
                        property_schema,
×
146
                );
×
147

×
148
                const value = type_for_property
×
149
                        .generate_typescript_data(
×
150
                                property_value,
×
151
                                schema_parser,
×
152
                                property_schema,
×
153
                        );
×
154

×
155
                const property_assignment = factory
×
156
                        .createPropertyAssignment(
×
157
                                computedProperty_or_string(property_name),
×
158
                                value,
×
159
                        );
×
160

×
161
                property_assignments.push(property_assignment);
×
162
        }
×
163

×
164
        const sanity_check: Object_DataTo = factory
×
165
                .createObjectLiteralExpression(
×
166
                        property_assignments,
×
167
                        true,
×
168
                );
×
169

×
170
        return sanity_check;
×
171
}
×
172

×
173
export function Object_generate_typescript_type(
×
174
        schema: Object_type,
×
175
        schema_parser: SchemaParser,
×
176
): Promise<Object_SchemaTo> {
×
177
        const instance = schema_parser.types
×
178
                .find((maybe): maybe is ObjectUnspecified<
×
179
                        {[key: string]: unknown},
×
180
                        'properties'
×
181
                > => (
×
182
                        maybe instanceof ObjectUnspecified
×
183
                        && 'properties' === maybe.properties_mode
×
184
                ));
×
185

×
186
        if (undefined === instance) {
×
187
                throw new TypeError(`schema_parser not loaded with ${
×
188
                        ObjectUnspecified.constructor.name
×
189
                }<{[key: string]: unknown}, 'properties'>`);
×
190
        }
×
191

×
192
        return instance.generate_typescript_type({
×
193
                schema,
×
194
                schema_parser,
×
195
        });
×
196
}
×
197

×
198
export class PropertySchemaToRegex<
×
199
        T,
×
200
> {
×
201
        #matcher: ValidateFunction<T>;
×
202

×
203
        #value_to_regex: (value: T) => string;
×
204

×
205
        constructor(
×
206
                matcher: ValidateFunction<T>,
×
207
                value_to_regex: (value: T) => string,
×
208
        ) {
×
209
                this.#matcher = matcher;
×
210
                this.#value_to_regex = value_to_regex;
×
211
        }
×
212

×
213
        matches(value: unknown): value is T {
×
214
                return this.#matcher(value);
×
215
        }
×
216

×
217
        to_regex(value: T): string {
×
218
                return this.#value_to_regex(value);
×
219
        }
×
220
}
×
221

×
222
export function Object_type_to_regex(
×
223
        schema: Object_type,
×
224
        property_schema_to_regex: PropertySchemaToRegex<unknown>[],
×
225
) {
×
226
        const regex = `${
×
227
                Object.keys(schema.properties)
×
228
                        .map((property) => {
×
229
                                let value_regex = `(?:[^=]+)`;
×
230

×
231
                                const converter = property_schema_to_regex.find((maybe) => {
×
232
                                        return maybe.matches(schema.properties[property]);
×
233
                                });
×
234

×
235
                                if (converter) {
×
236
                                        value_regex = `${
×
237
                                                converter.to_regex(schema.properties[property])
×
238
                                        }`;
×
239
                                }
×
240

×
241
                                return `(?:,?${
×
242
                                        RegExp.escape(property)
×
243
                                }=${
×
244
                                        value_regex
×
UNCOV
245
                                })${
×
NEW
246
                                        (
×
NEW
247
                                                (schema.required || ([] as string[]))
×
NEW
248
                                                        .includes(property)
×
NEW
249
                                        )
×
NEW
250
                                                ? ''
×
NEW
251
                                                : '?'
×
UNCOV
252
                                }`;
×
UNCOV
253
                        })
×
UNCOV
254
                        .join('')
×
UNCOV
255
        }`;
×
UNCOV
256

×
UNCOV
257
        return `\\(${regex}\\)`;
×
UNCOV
258
}
×
UNCOV
259

×
UNCOV
260
export function Object_ajv_macro(
×
UNCOV
261
        schema: Object_type,
×
UNCOV
262
        property_schema_to_regex: PropertySchemaToRegex<unknown>[],
×
UNCOV
263
) {
×
UNCOV
264
        return Object.freeze({
×
UNCOV
265
                pattern: `^${
×
UNCOV
266
                        Object_type_to_regex(schema, property_schema_to_regex)
×
UNCOV
267
                }$`,
×
UNCOV
268
        });
×
UNCOV
269
}
×
UNCOV
270

×
UNCOV
271
export function Object_generate_schema_definition(
×
UNCOV
272
): Readonly<Object_properties> {
×
UNCOV
273
        return ObjectUnspecified
×
UNCOV
274
                .generate_schema_definition({
×
UNCOV
275
                        properties_mode: 'properties',
×
UNCOV
276
                });
×
UNCOV
277
}
×
UNCOV
278

×
UNCOV
279
export function Object_generate_type_definition(
×
UNCOV
280
): Readonly<Object_type> {
×
UNCOV
281
        return ObjectUnspecified
×
UNCOV
282
                .generate_type_definition({
×
UNCOV
283
                        properties_mode: 'properties',
×
UNCOV
284
                        properties: {},
×
UNCOV
285
                });
×
UNCOV
286
}
×
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