kubernetes-fluent-client 3.6.2 → 3.6.3
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.
- package/dist/generate.d.ts +5 -3
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +4 -4
- package/package.json +5 -3
- package/src/generate.ts +9 -7
package/dist/generate.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { InputData, TargetLanguage } from "quicktype-core";
|
|
1
|
+
import { InputData, TargetLanguage, quicktype } from "quicktype-core";
|
|
2
2
|
import { CustomResourceDefinition } from "./upstream.js";
|
|
3
3
|
import { LogFn } from "./types.js";
|
|
4
|
+
export type QuicktypeLang = Parameters<typeof quicktype>[0]["lang"];
|
|
4
5
|
export interface GenerateOptions {
|
|
5
6
|
source: string;
|
|
6
7
|
directory?: string;
|
|
7
8
|
plain?: boolean;
|
|
8
|
-
language
|
|
9
|
+
language: QuicktypeLang;
|
|
9
10
|
npmPackage?: string;
|
|
10
11
|
logFn: LogFn;
|
|
11
12
|
noPost?: boolean;
|
|
@@ -35,9 +36,10 @@ export declare function prepareInputData(name: string, schema: string): Promise<
|
|
|
35
36
|
* Generates TypeScript types using quicktype.
|
|
36
37
|
*
|
|
37
38
|
* @param inputData - The input data for quicktype.
|
|
39
|
+
* @param opts - The options for generating the TypeScript types.
|
|
38
40
|
* @returns A promise that resolves to an array of generated TypeScript type lines.
|
|
39
41
|
*/
|
|
40
|
-
export declare function generateTypes(inputData: InputData): Promise<string[]>;
|
|
42
|
+
export declare function generateTypes(inputData: InputData, opts: GenerateOptions): Promise<string[]>;
|
|
41
43
|
/**
|
|
42
44
|
* Writes the processed lines to the output file.
|
|
43
45
|
*
|
package/dist/generate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,SAAS,EAET,cAAc,
|
|
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M,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
|
@@ -32,7 +32,7 @@ export async function convertCRDtoTS(crd, opts) {
|
|
|
32
32
|
const schema = JSON.stringify(match.schema.openAPIV3Schema);
|
|
33
33
|
opts.logFn(`- Generating ${crd.spec.group}/${match.name} types for ${name}`);
|
|
34
34
|
const inputData = await prepareInputData(name, schema);
|
|
35
|
-
const generatedTypes = await generateTypes(inputData);
|
|
35
|
+
const generatedTypes = await generateTypes(inputData, opts);
|
|
36
36
|
const fileName = `${name.toLowerCase()}-${match.name.toLowerCase()}`;
|
|
37
37
|
writeGeneratedFile(fileName, opts.directory || "", generatedTypes, opts.language || "ts");
|
|
38
38
|
results[fileName] = generatedTypes;
|
|
@@ -61,14 +61,14 @@ export async function prepareInputData(name, schema) {
|
|
|
61
61
|
* Generates TypeScript types using quicktype.
|
|
62
62
|
*
|
|
63
63
|
* @param inputData - The input data for quicktype.
|
|
64
|
+
* @param opts - The options for generating the TypeScript types.
|
|
64
65
|
* @returns A promise that resolves to an array of generated TypeScript type lines.
|
|
65
66
|
*/
|
|
66
|
-
export async function generateTypes(inputData) {
|
|
67
|
-
// If the language is not specified, default to TypeScript
|
|
67
|
+
export async function generateTypes(inputData, opts) {
|
|
68
68
|
// Generate the types
|
|
69
69
|
const out = await quicktype({
|
|
70
70
|
inputData,
|
|
71
|
-
lang:
|
|
71
|
+
lang: opts.language,
|
|
72
72
|
rendererOptions: { "just-types": "true" },
|
|
73
73
|
});
|
|
74
74
|
return out.lines;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kubernetes-fluent-client",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.3",
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"semantic-release": "semantic-release",
|
|
41
41
|
"test": "vitest src run --coverage",
|
|
42
42
|
"test:e2e": "vitest run e2e/",
|
|
43
|
-
"test:e2e:prep-crds": "kubectl apply -f test/ && npx tsx src/cli.ts crd ./test/datastore.crd.yaml e2e && npx tsx src/cli.ts crd https://raw.githubusercontent.com/defenseunicorns/kubernetes-fluent-client/refs/heads/main/test/webapp.crd.yaml e2e",
|
|
43
|
+
"test:e2e:prep-crds": "kubectl apply -f test/ && npx tsx src/cli.ts crd ./test/datastore.crd.yaml e2e && npx tsx src/cli.ts crd https://raw.githubusercontent.com/defenseunicorns/kubernetes-fluent-client/refs/heads/main/test/webapp.crd.yaml e2e && npx tsx src/cli.ts crd https://raw.githubusercontent.com/defenseunicorns/kubernetes-fluent-client/refs/heads/main/test/webapp.crd.yaml -l json-schema e2e/schemas/webapp",
|
|
44
44
|
"test:e2e:prep-cluster": "k3d cluster create kfc-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system",
|
|
45
45
|
"test:e2e:prep-image": "npm run build && npm pack && npm i kubernetes-fluent-client-0.0.0-development.tgz --no-save",
|
|
46
46
|
"test:e2e:run": "npm run test:e2e:prep-cluster && npm run test:e2e:prep-crds && npm run test:e2e:prep-image && npm run test:e2e && npm run test:e2e:cleanup",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"fast-json-patch": "3.1.1",
|
|
55
55
|
"http-status-codes": "2.3.0",
|
|
56
56
|
"node-fetch": "2.7.0",
|
|
57
|
-
"quicktype-core": "23.2.
|
|
57
|
+
"quicktype-core": "23.2.6",
|
|
58
58
|
"type-fest": "^4.39.1",
|
|
59
59
|
"undici": "^7.7.0",
|
|
60
60
|
"yargs": "18.0.0"
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@eslint/eslintrc": "^3.1.0",
|
|
66
66
|
"@eslint/js": "^9.14.0",
|
|
67
67
|
"@types/byline": "4.2.36",
|
|
68
|
+
"@types/command-line-args": "^5.2.3",
|
|
68
69
|
"@types/readable-stream": "4.0.21",
|
|
69
70
|
"@types/urijs": "^1.19.25",
|
|
70
71
|
"@types/ws": "^8.18.1",
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
"@typescript-eslint/eslint-plugin": "8.33.1",
|
|
73
74
|
"@typescript-eslint/parser": "8.33.1",
|
|
74
75
|
"@vitest/coverage-v8": "^3.2.1",
|
|
76
|
+
"command-line-args": "^6.0.1",
|
|
75
77
|
"eslint-plugin-jsdoc": "50.7.1",
|
|
76
78
|
"globals": "^16.0.0",
|
|
77
79
|
"husky": "^9.1.6",
|
package/src/generate.ts
CHANGED
|
@@ -16,12 +16,12 @@ 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
|
-
|
|
19
|
+
export type QuicktypeLang = Parameters<typeof quicktype>[0]["lang"];
|
|
20
20
|
export interface GenerateOptions {
|
|
21
21
|
source: string; // URL, file path, or K8s CRD name
|
|
22
22
|
directory?: string; // Output directory path
|
|
23
23
|
plain?: boolean; // Disable fluent client wrapping
|
|
24
|
-
language
|
|
24
|
+
language: QuicktypeLang; // Language for type generation (default: "ts")
|
|
25
25
|
npmPackage?: string; // Override NPM package
|
|
26
26
|
logFn: LogFn; // Log function callback
|
|
27
27
|
noPost?: boolean; // Enable/disable post-processing
|
|
@@ -73,7 +73,7 @@ export async function convertCRDtoTS(
|
|
|
73
73
|
opts.logFn(`- Generating ${crd.spec.group}/${match.name} types for ${name}`);
|
|
74
74
|
|
|
75
75
|
const inputData = await prepareInputData(name, schema);
|
|
76
|
-
const generatedTypes = await generateTypes(inputData);
|
|
76
|
+
const generatedTypes = await generateTypes(inputData, opts);
|
|
77
77
|
|
|
78
78
|
const fileName = `${name.toLowerCase()}-${match.name.toLowerCase()}`;
|
|
79
79
|
writeGeneratedFile(fileName, opts.directory || "", generatedTypes, opts.language || "ts");
|
|
@@ -110,15 +110,17 @@ export async function prepareInputData(name: string, schema: string): Promise<In
|
|
|
110
110
|
* Generates TypeScript types using quicktype.
|
|
111
111
|
*
|
|
112
112
|
* @param inputData - The input data for quicktype.
|
|
113
|
+
* @param opts - The options for generating the TypeScript types.
|
|
113
114
|
* @returns A promise that resolves to an array of generated TypeScript type lines.
|
|
114
115
|
*/
|
|
115
|
-
export async function generateTypes(
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
export async function generateTypes(
|
|
117
|
+
inputData: InputData,
|
|
118
|
+
opts: GenerateOptions,
|
|
119
|
+
): Promise<string[]> {
|
|
118
120
|
// Generate the types
|
|
119
121
|
const out = await quicktype({
|
|
120
122
|
inputData,
|
|
121
|
-
lang:
|
|
123
|
+
lang: opts.language,
|
|
122
124
|
rendererOptions: { "just-types": "true" },
|
|
123
125
|
});
|
|
124
126
|
|