kubernetes-fluent-client 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/cli.d.ts +3 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/dist/cli.js +68 -0
  4. package/dist/fetch.d.ts +22 -0
  5. package/dist/fetch.d.ts.map +1 -0
  6. package/dist/fetch.js +82 -0
  7. package/dist/fetch.test.d.ts +2 -0
  8. package/dist/fetch.test.d.ts.map +1 -0
  9. package/dist/fetch.test.js +97 -0
  10. package/dist/fileSystem.d.ts +11 -0
  11. package/dist/fileSystem.d.ts.map +1 -0
  12. package/dist/fileSystem.js +42 -0
  13. package/dist/fileSystem.test.d.ts +2 -0
  14. package/dist/fileSystem.test.d.ts.map +1 -0
  15. package/dist/fileSystem.test.js +75 -0
  16. package/dist/fluent/http2-watch.spec.d.ts +2 -0
  17. package/dist/fluent/http2-watch.spec.d.ts.map +1 -0
  18. package/dist/fluent/http2-watch.spec.js +284 -0
  19. package/dist/fluent/index.d.ts +12 -0
  20. package/dist/fluent/index.d.ts.map +1 -0
  21. package/dist/fluent/index.js +228 -0
  22. package/dist/fluent/index.test.d.ts +2 -0
  23. package/dist/fluent/index.test.d.ts.map +1 -0
  24. package/dist/fluent/index.test.js +193 -0
  25. package/dist/fluent/types.d.ts +187 -0
  26. package/dist/fluent/types.d.ts.map +1 -0
  27. package/dist/fluent/types.js +16 -0
  28. package/dist/fluent/utils.d.ts +41 -0
  29. package/dist/fluent/utils.d.ts.map +1 -0
  30. package/dist/fluent/utils.js +153 -0
  31. package/dist/fluent/utils.test.d.ts +2 -0
  32. package/dist/fluent/utils.test.d.ts.map +1 -0
  33. package/dist/fluent/utils.test.js +215 -0
  34. package/dist/fluent/watch.d.ts +88 -0
  35. package/dist/fluent/watch.d.ts.map +1 -0
  36. package/dist/fluent/watch.js +546 -0
  37. package/dist/fluent/watch.spec.d.ts +2 -0
  38. package/dist/fluent/watch.spec.d.ts.map +1 -0
  39. package/dist/fluent/watch.spec.js +261 -0
  40. package/dist/generate.d.ts +84 -0
  41. package/dist/generate.d.ts.map +1 -0
  42. package/dist/generate.js +208 -0
  43. package/dist/generate.test.d.ts +2 -0
  44. package/dist/generate.test.d.ts.map +1 -0
  45. package/dist/generate.test.js +320 -0
  46. package/dist/helpers.d.ts +33 -0
  47. package/dist/helpers.d.ts.map +1 -0
  48. package/dist/helpers.js +103 -0
  49. package/dist/helpers.test.d.ts +2 -0
  50. package/dist/helpers.test.d.ts.map +1 -0
  51. package/dist/helpers.test.js +37 -0
  52. package/dist/index.d.ts +14 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +60 -0
  55. package/dist/kinds.d.ts +16 -0
  56. package/dist/kinds.d.ts.map +1 -0
  57. package/dist/kinds.js +570 -0
  58. package/dist/kinds.test.d.ts +2 -0
  59. package/dist/kinds.test.d.ts.map +1 -0
  60. package/dist/kinds.test.js +155 -0
  61. package/dist/patch.d.ts +7 -0
  62. package/dist/patch.d.ts.map +1 -0
  63. package/dist/patch.js +2 -0
  64. package/dist/postProcessing.d.ts +246 -0
  65. package/dist/postProcessing.d.ts.map +1 -0
  66. package/dist/postProcessing.js +497 -0
  67. package/dist/postProcessing.test.d.ts +2 -0
  68. package/dist/postProcessing.test.d.ts.map +1 -0
  69. package/dist/postProcessing.test.js +550 -0
  70. package/dist/types.d.ts +32 -0
  71. package/dist/types.d.ts.map +1 -0
  72. package/dist/types.js +16 -0
  73. package/dist/upstream.d.ts +4 -0
  74. package/dist/upstream.d.ts.map +1 -0
  75. package/dist/upstream.js +56 -0
  76. package/package.json +1 -1
@@ -0,0 +1,497 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.postProcessing = postProcessing;
29
+ exports.mapFilesToCRD = mapFilesToCRD;
30
+ exports.processFiles = processFiles;
31
+ exports.processAndModifySingleFile = processAndModifySingleFile;
32
+ exports.applyCRDPostProcessing = applyCRDPostProcessing;
33
+ exports.readFile = readFile;
34
+ exports.writeFile = writeFile;
35
+ exports.getGenericKindProperties = getGenericKindProperties;
36
+ exports.collectInterfaceNames = collectInterfaceNames;
37
+ exports.isClassExtendingGenericKind = isClassExtendingGenericKind;
38
+ exports.updateBraceBalance = updateBraceBalance;
39
+ exports.getPropertyPattern = getPropertyPattern;
40
+ exports.modifyPropertiesAndAddEslintDirective = modifyPropertiesAndAddEslintDirective;
41
+ exports.addDeclareAndOptionalModifiersToProperties = addDeclareAndOptionalModifiersToProperties;
42
+ exports.addDeclareToGenericKindProperties = addDeclareToGenericKindProperties;
43
+ exports.makePropertiesOptional = makePropertiesOptional;
44
+ exports.processEslintDisable = processEslintDisable;
45
+ exports.wrapWithFluentClient = wrapWithFluentClient;
46
+ exports.normalizeIndentation = normalizeIndentation;
47
+ exports.normalizeLineIndentation = normalizeLineIndentation;
48
+ exports.normalizePropertySpacing = normalizePropertySpacing;
49
+ exports.removePropertyStringAny = removePropertyStringAny;
50
+ exports.shouldWrapWithFluentClient = shouldWrapWithFluentClient;
51
+ exports.processLines = processLines;
52
+ exports.processClassContext = processClassContext;
53
+ exports.modifyAndNormalizeClassProperties = modifyAndNormalizeClassProperties;
54
+ exports.normalizeIndentationAndSpacing = normalizeIndentationAndSpacing;
55
+ exports.logError = logError;
56
+ const fs = __importStar(require("fs"));
57
+ const path = __importStar(require("path"));
58
+ const types_1 = require("./types");
59
+ const fileSystem_1 = require("./fileSystem");
60
+ const genericKindProperties = getGenericKindProperties();
61
+ /**
62
+ * Performs post-processing on generated TypeScript files.
63
+ *
64
+ * @param allResults The array of CRD results.
65
+ * @param opts The options for post-processing.
66
+ * @param fileSystem The file system interface for reading and writing files.
67
+ */
68
+ async function postProcessing(allResults, opts, fileSystem = new fileSystem_1.NodeFileSystem()) {
69
+ if (!opts.directory) {
70
+ opts.logFn("⚠️ Error: Directory is not defined.");
71
+ return;
72
+ }
73
+ const files = fileSystem.readdirSync(opts.directory);
74
+ opts.logFn("\n🔧 Post-processing started...");
75
+ const fileResultMap = mapFilesToCRD(allResults);
76
+ await processFiles(files, fileResultMap, opts, fileSystem);
77
+ opts.logFn("🔧 Post-processing completed.\n");
78
+ }
79
+ /**
80
+ * Creates a map linking each file to its corresponding CRD result.
81
+ *
82
+ * @param allResults - The array of CRD results.
83
+ * @returns A map linking file names to their corresponding CRD results.
84
+ */
85
+ function mapFilesToCRD(allResults) {
86
+ const fileResultMap = {};
87
+ for (const { name, crd, version } of allResults) {
88
+ const expectedFileName = `${name.toLowerCase()}-${version.toLowerCase()}.ts`;
89
+ fileResultMap[expectedFileName] = { name, crd, version };
90
+ }
91
+ if (Object.keys(fileResultMap).length === 0) {
92
+ console.warn("⚠️ Warning: No CRD results were mapped to files.");
93
+ }
94
+ return fileResultMap;
95
+ }
96
+ /**
97
+ * Processes the list of files, applying CRD post-processing to each.
98
+ *
99
+ * @param files - The list of file names to process.
100
+ * @param fileResultMap - A map linking file names to their corresponding CRD results.
101
+ * @param opts - Options for the generation process.
102
+ * @param fileSystem - The file system interface for reading and writing files.
103
+ */
104
+ async function processFiles(files, fileResultMap, opts, fileSystem) {
105
+ for (const file of files) {
106
+ if (!opts.directory) {
107
+ throw new Error("Directory is not defined.");
108
+ }
109
+ const filePath = path.join(opts.directory, file);
110
+ const fileResult = fileResultMap[file];
111
+ if (!fileResult) {
112
+ opts.logFn(`⚠️ Warning: No matching CRD result found for file: ${filePath}`);
113
+ continue;
114
+ }
115
+ try {
116
+ processAndModifySingleFile(filePath, fileResult, opts, fileSystem);
117
+ }
118
+ catch (error) {
119
+ logError(error, filePath, opts.logFn);
120
+ }
121
+ }
122
+ }
123
+ /**
124
+ * Handles the processing of a single file: reading, modifying, and writing back to disk.
125
+ *
126
+ * @param filePath - The path to the file to be processed.
127
+ * @param fileResult - The associated CRD result for this file.
128
+ * @param fileResult.name - The name of the schema.
129
+ * @param fileResult.crd - The CustomResourceDefinition object.
130
+ * @param fileResult.version - The version of the CRD.
131
+ * @param opts - Options for the generation process.
132
+ * @param fileSystem - The file system interface for reading and writing files.
133
+ */
134
+ function processAndModifySingleFile(filePath, fileResult, opts, fileSystem) {
135
+ opts.logFn(`🔍 Processing file: ${filePath}`);
136
+ const { name, crd, version } = fileResult;
137
+ let fileContent;
138
+ try {
139
+ fileContent = fileSystem.readFile(filePath);
140
+ }
141
+ catch (error) {
142
+ logError(error, filePath, opts.logFn);
143
+ return;
144
+ }
145
+ let modifiedContent;
146
+ try {
147
+ modifiedContent = applyCRDPostProcessing(fileContent, name, crd, version, opts);
148
+ }
149
+ catch (error) {
150
+ logError(error, filePath, opts.logFn);
151
+ return;
152
+ }
153
+ try {
154
+ fileSystem.writeFile(filePath, modifiedContent);
155
+ opts.logFn(`✅ Successfully processed and wrote file: ${filePath}`);
156
+ }
157
+ catch (error) {
158
+ logError(error, filePath, opts.logFn);
159
+ }
160
+ }
161
+ /**
162
+ * Processes the TypeScript file content, applying wrapping and property modifications.
163
+ *
164
+ * @param content The content of the TypeScript file.
165
+ * @param name The name of the schema.
166
+ * @param crd The CustomResourceDefinition object.
167
+ * @param version The version of the CRD.
168
+ * @param opts The options for processing.
169
+ * @returns The processed TypeScript file content.
170
+ */
171
+ function applyCRDPostProcessing(content, name, crd, version, opts) {
172
+ try {
173
+ let lines = content.split("\n");
174
+ // Wraps with the fluent client if needed
175
+ if (shouldWrapWithFluentClient(opts)) {
176
+ lines = wrapWithFluentClient(lines, name, crd, version, opts.npmPackage);
177
+ }
178
+ const foundInterfaces = collectInterfaceNames(lines);
179
+ // Process the lines, focusing on classes extending `GenericKind`
180
+ const processedLines = processLines(lines, genericKindProperties, foundInterfaces);
181
+ // Normalize the final output
182
+ const normalizedLines = normalizeIndentationAndSpacing(processedLines, opts);
183
+ return normalizedLines.join("\n");
184
+ }
185
+ catch (error) {
186
+ throw new Error(`Error while applying post-processing for ${name}: ${error.message}`);
187
+ }
188
+ }
189
+ /**
190
+ * Reads the content of a file from disk.
191
+ *
192
+ * @param filePath The path to the file.
193
+ * @returns The file contents as a string.
194
+ */
195
+ function readFile(filePath) {
196
+ try {
197
+ return fs.readFileSync(filePath, "utf8");
198
+ }
199
+ catch (error) {
200
+ throw new Error(`Failed to read file at ${filePath}: ${error.message}`);
201
+ }
202
+ }
203
+ /**
204
+ * Writes the modified content back to the file.
205
+ *
206
+ * @param filePath The path to the file.
207
+ * @param content The modified content to write.
208
+ */
209
+ function writeFile(filePath, content) {
210
+ try {
211
+ fs.writeFileSync(filePath, content, "utf8");
212
+ }
213
+ catch (error) {
214
+ throw new Error(`Failed to write file at ${filePath}: ${error.message}`);
215
+ }
216
+ }
217
+ /**
218
+ * Retrieves the properties of the `GenericKind` class, excluding dynamic properties like `[key: string]: any`.
219
+ *
220
+ * @returns An array of property names that belong to `GenericKind`.
221
+ */
222
+ function getGenericKindProperties() {
223
+ const properties = Object.getOwnPropertyNames(new types_1.GenericKind());
224
+ return properties.filter(prop => prop !== "[key: string]");
225
+ }
226
+ /**
227
+ * Collects interface names from TypeScript file lines.
228
+ *
229
+ * @param lines The lines of the file content.
230
+ * @returns A set of found interface names.
231
+ */
232
+ function collectInterfaceNames(lines) {
233
+ // https://regex101.com/r/S6w8pW/1
234
+ const interfacePattern = /export interface (?<interfaceName>\w+)/;
235
+ const foundInterfaces = new Set();
236
+ for (const line of lines) {
237
+ const match = line.match(interfacePattern);
238
+ if (match?.groups?.interfaceName) {
239
+ foundInterfaces.add(match.groups.interfaceName);
240
+ }
241
+ }
242
+ return foundInterfaces;
243
+ }
244
+ /**
245
+ * Identifies whether a line declares a class that extends `GenericKind`.
246
+ *
247
+ * @param line The current line of code.
248
+ * @returns True if the line defines a class that extends `GenericKind`, false otherwise.
249
+ */
250
+ function isClassExtendingGenericKind(line) {
251
+ return line.includes("class") && line.includes("extends GenericKind");
252
+ }
253
+ /**
254
+ * Adjusts the brace balance to determine if the parser is within a class definition.
255
+ *
256
+ * @param line The current line of code.
257
+ * @param braceBalance The current balance of curly braces.
258
+ * @returns The updated brace balance.
259
+ */
260
+ function updateBraceBalance(line, braceBalance) {
261
+ return braceBalance + (line.includes("{") ? 1 : 0) - (line.includes("}") ? 1 : 0);
262
+ }
263
+ /**
264
+ * Generates a regular expression to match a property pattern in TypeScript.
265
+ *
266
+ * @param prop The property name to match.
267
+ * @returns A regular expression to match the property pattern.
268
+ */
269
+ function getPropertyPattern(prop) {
270
+ // For prop="kind", the pattern will match "kind ? :" or "kind :"
271
+ // https://regex101.com/r/mF8kXn/1
272
+ return new RegExp(`\\b${prop}\\b\\s*\\?\\s*:|\\b${prop}\\b\\s*:`);
273
+ }
274
+ /**
275
+ * Applies ESLint and property modifiers to a line of code.
276
+ *
277
+ * @param line - The current line of code.
278
+ * @param genericKindProperties - The list of properties from `GenericKind`.
279
+ * @param foundInterfaces - The set of found interfaces in the file.
280
+ * @returns The modified line.
281
+ */
282
+ function modifyPropertiesAndAddEslintDirective(line, genericKindProperties, foundInterfaces) {
283
+ line = addDeclareAndOptionalModifiersToProperties(line, genericKindProperties, foundInterfaces);
284
+ line = processEslintDisable(line, genericKindProperties);
285
+ return line;
286
+ }
287
+ /**
288
+ * Applies property modifiers to a line of code.
289
+ *
290
+ * @param line The current line of code.
291
+ * @param genericKindProperties The list of properties from `GenericKind`.
292
+ * @param foundInterfaces The set of found interfaces in the file.
293
+ * @returns The modified line.
294
+ */
295
+ function addDeclareAndOptionalModifiersToProperties(line, genericKindProperties, foundInterfaces) {
296
+ line = addDeclareToGenericKindProperties(line, genericKindProperties);
297
+ line = makePropertiesOptional(line, foundInterfaces);
298
+ line = normalizeLineIndentation(line);
299
+ return line;
300
+ }
301
+ /**
302
+ * Adds the `declare` keyword to `GenericKind` properties.
303
+ *
304
+ * @param line The current line of code.
305
+ * @param genericKindProperties The list of properties from `GenericKind`.
306
+ * @returns The modified line with the `declare` keyword, if applicable.
307
+ */
308
+ function addDeclareToGenericKindProperties(line, genericKindProperties) {
309
+ for (const prop of genericKindProperties) {
310
+ const propertyPattern = getPropertyPattern(prop);
311
+ if (propertyPattern.test(line)) {
312
+ return line.replace(prop, `declare ${prop}`);
313
+ }
314
+ }
315
+ return line;
316
+ }
317
+ /**
318
+ * Makes a property optional if its type matches one of the found interfaces and it is not already optional.
319
+ *
320
+ * @param line The current line of code.
321
+ * @param foundInterfaces The set of found interfaces in the file.
322
+ * @returns The modified line with the optional `?` symbol.
323
+ */
324
+ function makePropertiesOptional(line, foundInterfaces) {
325
+ // https://regex101.com/r/kX8TCj/1
326
+ const propertyTypePattern = /:\s*(?<propertyType>\w+)\s*;/;
327
+ const match = line.match(propertyTypePattern);
328
+ if (match?.groups?.propertyType) {
329
+ const { propertyType } = match.groups;
330
+ if (foundInterfaces.has(propertyType) && !line.includes("?")) {
331
+ return line.replace(":", "?:");
332
+ }
333
+ }
334
+ return line;
335
+ }
336
+ /**
337
+ * Adds an ESLint disable comment for `[key: string]: any` if it's not part of `GenericKind`.
338
+ *
339
+ * @param line The current line of code.
340
+ * @param genericKindProperties The list of properties from `GenericKind`.
341
+ * @returns The modified line with the ESLint disable comment.
342
+ */
343
+ function processEslintDisable(line, genericKindProperties) {
344
+ if (line.includes("[key: string]: any") && !genericKindProperties.includes("[key: string]")) {
345
+ return ` // eslint-disable-next-line @typescript-eslint/no-explicit-any\n${line}`;
346
+ }
347
+ return line;
348
+ }
349
+ /**
350
+ * Wraps the generated TypeScript file with fluent client elements (`GenericKind` and `RegisterKind`).
351
+ *
352
+ * @param lines The generated TypeScript lines.
353
+ * @param name The name of the schema.
354
+ * @param crd The CustomResourceDefinition object.
355
+ * @param version The version of the CRD.
356
+ * @param npmPackage The NPM package name for the fluent client.
357
+ * @returns The processed TypeScript lines.
358
+ */
359
+ function wrapWithFluentClient(lines, name, crd, version, npmPackage = "kubernetes-fluent-client") {
360
+ const autoGenNotice = `// This file is auto-generated by ${npmPackage}, do not edit manually`;
361
+ const imports = `import { GenericKind, RegisterKind } from "${npmPackage}";`;
362
+ const classIndex = lines.findIndex(line => line.includes(`export interface ${name} {`));
363
+ if (classIndex !== -1) {
364
+ lines[classIndex] = `export class ${name} extends GenericKind {`;
365
+ }
366
+ lines.unshift(autoGenNotice, imports);
367
+ lines.push(`RegisterKind(${name}, {`, ` group: "${crd.spec.group}",`, ` version: "${version}",`, ` kind: "${name}",`, ` plural: "${crd.spec.names.plural}",`, `});`);
368
+ return lines;
369
+ }
370
+ /**
371
+ * Normalizes indentation for TypeScript lines to a consistent format.
372
+ *
373
+ * @param lines The generated TypeScript lines.
374
+ * @returns The lines with normalized indentation.
375
+ */
376
+ function normalizeIndentation(lines) {
377
+ return lines.map(line => line.replace(/^ {4}/, " "));
378
+ }
379
+ /**
380
+ * Normalizes the indentation of a single line to use two spaces instead of four.
381
+ *
382
+ * @param line The line of code to normalize.
383
+ * @returns The line with normalized indentation.
384
+ */
385
+ function normalizeLineIndentation(line) {
386
+ return line.replace(/^ {4}/, " ");
387
+ }
388
+ /**
389
+ * Normalizes spacing between property names and types in TypeScript lines.
390
+ *
391
+ * @param lines The generated TypeScript lines.
392
+ * @returns The lines with normalized property spacing.
393
+ */
394
+ function normalizePropertySpacing(lines) {
395
+ // https://regex101.com/r/XEv3pL/1
396
+ return lines.map(line => line.replace(/\s*\?\s*:\s*/, "?: "));
397
+ }
398
+ /**
399
+ * Removes lines containing `[property: string]: any;` from TypeScript files.
400
+ *
401
+ * @param lines The generated TypeScript lines.
402
+ * @param opts The options for processing.
403
+ * @returns The lines with `[property: string]: any;` removed.
404
+ */
405
+ function removePropertyStringAny(lines, opts) {
406
+ if (opts.language === "ts" || opts.language === "typescript") {
407
+ return lines.filter(line => !line.includes("[property: string]: any;"));
408
+ }
409
+ return lines;
410
+ }
411
+ /**
412
+ * Determines if the content should be wrapped with the fluent client.
413
+ *
414
+ * @param opts The options for generating the content.
415
+ * @returns True if the content should be wrapped with the fluent client, false otherwise.
416
+ */
417
+ function shouldWrapWithFluentClient(opts) {
418
+ return opts.language === "ts" && !opts.plain;
419
+ }
420
+ /**
421
+ * Processes the lines of the TypeScript file, focusing on classes extending `GenericKind`.
422
+ *
423
+ * @param lines The lines of the file content.
424
+ * @param genericKindProperties The list of properties from `GenericKind`.
425
+ * @param foundInterfaces The set of found interfaces in the file.
426
+ * @returns The processed lines.
427
+ */
428
+ function processLines(lines, genericKindProperties, foundInterfaces) {
429
+ let insideClass = false;
430
+ let braceBalance = 0;
431
+ return lines.map(line => {
432
+ const result = processClassContext(line, insideClass, braceBalance, genericKindProperties, foundInterfaces);
433
+ insideClass = result.insideClass;
434
+ braceBalance = result.braceBalance;
435
+ return result.line;
436
+ });
437
+ }
438
+ /**
439
+ * Processes a single line inside a class extending `GenericKind`.
440
+ *
441
+ * @param line The current line of code.
442
+ * @param insideClass Whether we are inside a class context.
443
+ * @param braceBalance The current brace balance to detect when we exit the class.
444
+ * @param genericKindProperties The list of properties from `GenericKind`.
445
+ * @param foundInterfaces The set of found interfaces in the file.
446
+ * @returns An object containing the updated line, updated insideClass flag, and braceBalance.
447
+ */
448
+ function processClassContext(line, insideClass, braceBalance, genericKindProperties, foundInterfaces) {
449
+ if (isClassExtendingGenericKind(line)) {
450
+ insideClass = true;
451
+ braceBalance = 0;
452
+ }
453
+ if (!insideClass)
454
+ return { line, insideClass, braceBalance };
455
+ braceBalance = updateBraceBalance(line, braceBalance);
456
+ line = modifyAndNormalizeClassProperties(line, genericKindProperties, foundInterfaces);
457
+ if (braceBalance === 0) {
458
+ insideClass = false;
459
+ }
460
+ return { line, insideClass, braceBalance };
461
+ }
462
+ /**
463
+ * Processes a single line inside a class extending `GenericKind`.
464
+ *
465
+ * @param line The current line of code.
466
+ * @param genericKindProperties The list of properties from `GenericKind`.
467
+ * @param foundInterfaces The set of found interfaces in the file.
468
+ * @returns The modified line.
469
+ */
470
+ function modifyAndNormalizeClassProperties(line, genericKindProperties, foundInterfaces) {
471
+ line = modifyPropertiesAndAddEslintDirective(line, genericKindProperties, foundInterfaces);
472
+ line = normalizeLineIndentation(line);
473
+ return line;
474
+ }
475
+ /**
476
+ * Normalizes lines after processing, including indentation, spacing, and removing unnecessary lines.
477
+ *
478
+ * @param lines The lines of the file content.
479
+ * @param opts The options for processing.
480
+ * @returns The normalized lines.
481
+ */
482
+ function normalizeIndentationAndSpacing(lines, opts) {
483
+ let normalizedLines = normalizeIndentation(lines);
484
+ normalizedLines = normalizePropertySpacing(normalizedLines);
485
+ return removePropertyStringAny(normalizedLines, opts);
486
+ }
487
+ /**
488
+ * Handles logging for errors with stack trace.
489
+ *
490
+ * @param error The error object to log.
491
+ * @param filePath The path of the file being processed.
492
+ * @param logFn The logging function.
493
+ */
494
+ function logError(error, filePath, logFn) {
495
+ logFn(`❌ Error processing file: ${filePath} - ${error.message}`);
496
+ logFn(`Stack trace: ${error.stack}`);
497
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=postProcessing.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postProcessing.test.d.ts","sourceRoot":"","sources":["../src/postProcessing.test.ts"],"names":[],"mappings":""}