kubernetes-fluent-client 3.10.4 → 3.10.5

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.
@@ -1,6 +1,15 @@
1
1
  import { InputData, TargetLanguage, quicktype } from "quicktype-core";
2
2
  import { CustomResourceDefinition } from "./upstream.js";
3
3
  import { LogFn } from "./types.js";
4
+ /**
5
+ * Recursively fixes _enum properties to enum for quicktype compatibility.
6
+ * The Kubernetes client library converts 'enum' to '_enum' to avoid JS reserved keywords,
7
+ * but quicktype expects 'enum'.
8
+ *
9
+ * @param obj - The schema object to fix
10
+ * @returns The fixed schema object with enum properties restored
11
+ */
12
+ export declare function fixEnumProperties(obj: unknown): unknown;
4
13
  export type QuicktypeLang = Parameters<typeof quicktype>[0]["lang"];
5
14
  export interface GenerateOptions {
6
15
  source: string;
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,SAAS,EAET,cAAc,EACd,SAAS,EACV,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACpE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,GAAG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,CASnB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,EAAE,MAAM,GAAG,cAAc,GAChC,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,wBAAwB,EAAE,CAAC,CA0B/F;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAMtD;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAC5D;IACE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,wBAAwB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,EAAE,CACJ,CA8BA"}
package/dist/generate.js CHANGED
@@ -7,6 +7,34 @@ import { FetchingJSONSchemaStore, InputData, JSONSchemaInput, quicktype, } from
7
7
  import { fetch } from "./fetch.js";
8
8
  import { K8s } from "./fluent/index.js";
9
9
  import { CustomResourceDefinition } from "./upstream.js";
10
+ /**
11
+ * Recursively fixes _enum properties to enum for quicktype compatibility.
12
+ * The Kubernetes client library converts 'enum' to '_enum' to avoid JS reserved keywords,
13
+ * but quicktype expects 'enum'.
14
+ *
15
+ * @param obj - The schema object to fix
16
+ * @returns The fixed schema object with enum properties restored
17
+ */
18
+ export function fixEnumProperties(obj) {
19
+ if (!obj || typeof obj !== "object") {
20
+ return obj;
21
+ }
22
+ if (Array.isArray(obj)) {
23
+ return obj.map(fixEnumProperties);
24
+ }
25
+ const result = {};
26
+ for (const [key, value] of Object.entries(obj)) {
27
+ if (key === "_enum") {
28
+ // Convert _enum back to enum
29
+ result.enum = value;
30
+ }
31
+ else {
32
+ // Recursively fix nested objects
33
+ result[key] = fixEnumProperties(value);
34
+ }
35
+ }
36
+ return result;
37
+ }
10
38
  /**
11
39
  * Converts a CustomResourceDefinition to TypeScript types
12
40
  *
@@ -30,7 +58,9 @@ export async function convertCRDtoTS(crd, opts) {
30
58
  opts.logFn(`Skipping ${crd.metadata?.name ?? "unknown"}, it does not appear to have a valid schema`);
31
59
  continue;
32
60
  }
33
- const schema = JSON.stringify(match.schema.openAPIV3Schema);
61
+ // Fix _enum properties to enum for quicktype compatibility
62
+ const fixedSchema = fixEnumProperties(match.schema.openAPIV3Schema);
63
+ const schema = JSON.stringify(fixedSchema);
34
64
  opts.logFn(`- Generating ${crd.spec.group}/${match.name} types for ${name}`);
35
65
  const inputData = await prepareInputData(name, schema);
36
66
  const generatedTypes = await generateTypes(inputData, opts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubernetes-fluent-client",
3
- "version": "3.10.4",
3
+ "version": "3.10.5",
4
4
  "description": "A @kubernetes/client-node fluent API wrapper that leverages K8s Server Side Apply.",
5
5
  "bin": "./dist/cli.js",
6
6
  "main": "dist/index.js",
@@ -50,9 +50,10 @@
50
50
  "prepare": "if [ \"$NODE_ENV\" != 'production' ]; then husky; fi"
51
51
  },
52
52
  "dependencies": {
53
- "@kubernetes/client-node": "1.3.0",
53
+ "@kubernetes/client-node": "1.4.0",
54
54
  "fast-json-patch": "3.1.1",
55
55
  "http-status-codes": "2.3.0",
56
+ "js-yaml": "^4.1.0",
56
57
  "node-fetch": "2.7.0",
57
58
  "quicktype-core": "23.2.6",
58
59
  "type-fest": "^5.0.0",
@@ -60,8 +61,8 @@
60
61
  "yargs": "18.0.0"
61
62
  },
62
63
  "devDependencies": {
63
- "@commitlint/cli": "19.8.1",
64
- "@commitlint/config-conventional": "19.8.1",
64
+ "@commitlint/cli": "20.1.0",
65
+ "@commitlint/config-conventional": "20.0.0",
65
66
  "@eslint/eslintrc": "^3.1.0",
66
67
  "@eslint/js": "^9.14.0",
67
68
  "@types/byline": "4.2.36",
@@ -70,17 +71,17 @@
70
71
  "@types/urijs": "^1.19.25",
71
72
  "@types/ws": "^8.18.1",
72
73
  "@types/yargs": "17.0.33",
73
- "@typescript-eslint/eslint-plugin": "8.44.1",
74
- "@typescript-eslint/parser": "8.44.1",
74
+ "@typescript-eslint/eslint-plugin": "8.45.0",
75
+ "@typescript-eslint/parser": "8.45.0",
75
76
  "@vitest/coverage-v8": "^3.2.1",
76
77
  "command-line-args": "^6.0.1",
77
- "eslint-plugin-jsdoc": "60.2.0",
78
+ "eslint-plugin-jsdoc": "60.8.2",
78
79
  "globals": "^16.0.0",
79
80
  "husky": "^9.1.6",
80
81
  "lint-staged": "^16.0.0",
81
82
  "prettier": "3.6.2",
82
83
  "semantic-release": "24.2.9",
83
- "typescript": "5.9.2",
84
+ "typescript": "5.9.3",
84
85
  "vitest": "^3.2.1"
85
86
  },
86
87
  "overrides": {
package/src/generate.ts CHANGED
@@ -16,6 +16,37 @@ import { fetch } from "./fetch.js";
16
16
  import { K8s } from "./fluent/index.js";
17
17
  import { CustomResourceDefinition } from "./upstream.js";
18
18
  import { LogFn } from "./types.js";
19
+
20
+ /**
21
+ * Recursively fixes _enum properties to enum for quicktype compatibility.
22
+ * The Kubernetes client library converts 'enum' to '_enum' to avoid JS reserved keywords,
23
+ * but quicktype expects 'enum'.
24
+ *
25
+ * @param obj - The schema object to fix
26
+ * @returns The fixed schema object with enum properties restored
27
+ */
28
+ export function fixEnumProperties(obj: unknown): unknown {
29
+ if (!obj || typeof obj !== "object") {
30
+ return obj;
31
+ }
32
+
33
+ if (Array.isArray(obj)) {
34
+ return obj.map(fixEnumProperties);
35
+ }
36
+
37
+ const result: Record<string, unknown> = {};
38
+ for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
39
+ if (key === "_enum") {
40
+ // Convert _enum back to enum
41
+ result.enum = value;
42
+ } else {
43
+ // Recursively fix nested objects
44
+ result[key] = fixEnumProperties(value);
45
+ }
46
+ }
47
+
48
+ return result;
49
+ }
19
50
  export type QuicktypeLang = Parameters<typeof quicktype>[0]["lang"];
20
51
  export interface GenerateOptions {
21
52
  source: string; // URL, file path, or K8s CRD name
@@ -71,7 +102,9 @@ export async function convertCRDtoTS(
71
102
  continue;
72
103
  }
73
104
 
74
- const schema = JSON.stringify(match.schema.openAPIV3Schema);
105
+ // Fix _enum properties to enum for quicktype compatibility
106
+ const fixedSchema = fixEnumProperties(match.schema.openAPIV3Schema);
107
+ const schema = JSON.stringify(fixedSchema);
75
108
  opts.logFn(`- Generating ${crd.spec.group}/${match.name} types for ${name}`);
76
109
 
77
110
  const inputData = await prepareInputData(name, schema);