@cloudoperators/juno-k8s-client 1.0.2 → 1.0.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/build/apiErrorHandler.d.ts +10 -2
- package/build/apiErrorHandler.d.ts.map +1 -1
- package/build/client.d.ts +9 -8
- package/build/client.d.ts.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +190 -189
- package/build/logger.d.ts.map +1 -1
- package/build/request.d.ts +3 -2
- package/build/request.d.ts.map +1 -1
- package/build/urlHelpers.d.ts.map +1 -1
- package/build/utils.d.ts.map +1 -1
- package/build/watch.d.ts +15 -15
- package/build/watch.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface K8sApiError extends Error {
|
|
2
|
+
apiVersion?: string;
|
|
3
|
+
kind?: string;
|
|
4
|
+
message: string;
|
|
5
|
+
metadata?: Record<string, any>;
|
|
6
|
+
reason?: string;
|
|
7
|
+
status?: string;
|
|
8
|
+
code?: number;
|
|
2
9
|
response?: {
|
|
3
10
|
data?: {
|
|
4
11
|
message?: string;
|
|
5
12
|
};
|
|
13
|
+
status?: number;
|
|
6
14
|
};
|
|
7
15
|
}
|
|
8
|
-
declare const apiErrorHandler: (apiError:
|
|
16
|
+
declare const apiErrorHandler: (apiError: K8sApiError) => Promise<K8sApiError>;
|
|
9
17
|
export default apiErrorHandler;
|
|
10
18
|
//# sourceMappingURL=apiErrorHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiErrorHandler.d.ts","sourceRoot":"","sources":["../src/apiErrorHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apiErrorHandler.d.ts","sourceRoot":"","sources":["../src/apiErrorHandler.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF;AAED,QAAA,MAAM,eAAe,aAAoB,WAAW,KAAG,OAAO,CAAC,WAAW,CAIzE,CAAA;AAED,eAAe,eAAe,CAAA"}
|
package/build/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Watch } from './watch';
|
|
2
|
+
import { K8sApiError } from './apiErrorHandler';
|
|
2
3
|
interface ClientOptions {
|
|
3
4
|
apiEndpoint: string;
|
|
4
5
|
token: string;
|
|
@@ -7,7 +8,7 @@ interface ClientOptions {
|
|
|
7
8
|
interface RequestOptions {
|
|
8
9
|
params?: Record<string, any>;
|
|
9
10
|
headers?: Record<string, string>;
|
|
10
|
-
body?:
|
|
11
|
+
body?: Object | null;
|
|
11
12
|
signal?: AbortSignal;
|
|
12
13
|
mode?: RequestMode;
|
|
13
14
|
cache?: RequestCache;
|
|
@@ -18,15 +19,15 @@ declare function createClient(options: ClientOptions): {
|
|
|
18
19
|
WATCH_ADDED: string;
|
|
19
20
|
WATCH_DELETED: string;
|
|
20
21
|
WATCH_MODIFIED: string;
|
|
21
|
-
head: (path: string, options?: RequestOptions) => Promise<Response>;
|
|
22
|
-
get: (path: string, options?: RequestOptions) => Promise<
|
|
23
|
-
post: (path: string, data: {}, options?: RequestOptions) => Promise<
|
|
24
|
-
put: (path: string, data: {}, options?: RequestOptions) => Promise<
|
|
25
|
-
patch: (path: string, data: {}, options?: RequestOptions) => Promise<
|
|
26
|
-
delete: (path: string, data?: {} | null, options?: RequestOptions) => Promise<
|
|
22
|
+
head: (path: string, options?: RequestOptions) => Promise<Response | K8sApiError>;
|
|
23
|
+
get: (path: string, options?: RequestOptions) => Promise<unknown>;
|
|
24
|
+
post: (path: string, data: {}, options?: RequestOptions) => Promise<unknown>;
|
|
25
|
+
put: (path: string, data: {}, options?: RequestOptions) => Promise<unknown>;
|
|
26
|
+
patch: (path: string, data: {}, options?: RequestOptions) => Promise<unknown>;
|
|
27
|
+
delete: (path: string, data?: {} | null, options?: RequestOptions) => Promise<unknown>;
|
|
27
28
|
watch: (path: string, options?: RequestOptions) => Watch;
|
|
28
29
|
refreshToken: (newToken: string) => void;
|
|
29
30
|
currentToken: () => string;
|
|
30
31
|
};
|
|
31
|
-
export { createClient };
|
|
32
|
+
export { createClient, type RequestOptions };
|
|
32
33
|
//# sourceMappingURL=client.d.ts.map
|
package/build/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAmC,MAAM,SAAS,CAAA;AAChE,OAAuB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/D,UAAU,aAAa;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,WAAW,CAAC,EAAE,kBAAkB,CAAA;CACjC;AAED,iBAAS,YAAY,CAAC,OAAO,EAAE,aAAa;;;;;iBA2BtB,MAAM,YAAW,cAAc,KAAQ,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC;gBAIvE,MAAM,YAAW,cAAc,KAAQ,OAAO,CAAC,OAAO,CAAC;iBAMtD,MAAM,QAAQ,EAAE,YAAW,cAAc,KAAQ,OAAO,CAAC,OAAO,CAAC;gBAOlE,MAAM,QAAQ,EAAE,YAAW,cAAc,KAAQ,OAAO,CAAC,OAAO,CAAC;kBAM/D,MAAM,QAAQ,EAAE,YAAW,cAAc,KAAQ,OAAO,CAAC,OAAO,CAAC;mBAanE,MAAM,SAAS,EAAE,GAAG,IAAI,YAAW,cAAc,KAAQ,OAAO,CAAC,OAAO,CAAC;kBAMvE,MAAM,YAAW,cAAc,KAAQ,KAAK;6BAIjC,MAAM,KAAG,IAAI;wBAIpB,MAAM;EAmBhC;AAED,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,CAAA"}
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -1,238 +1,239 @@
|
|
|
1
|
-
function
|
|
2
|
-
return typeof
|
|
1
|
+
function j(t) {
|
|
2
|
+
return typeof t == "string" || t instanceof String;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return typeof
|
|
4
|
+
function F(t) {
|
|
5
|
+
return typeof t == "number" && t.constructor === Number;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function V(t) {
|
|
8
|
+
return t !== null && typeof t == "object" && t.constructor === Object;
|
|
9
9
|
}
|
|
10
|
-
const B = (
|
|
11
|
-
if (!
|
|
12
|
-
const
|
|
13
|
-
for (const
|
|
14
|
-
if (Object.
|
|
15
|
-
const
|
|
16
|
-
|
|
10
|
+
const B = (t) => {
|
|
11
|
+
if (!t) return;
|
|
12
|
+
const s = [];
|
|
13
|
+
for (const r in t)
|
|
14
|
+
if (Object.keys(t).includes(r)) {
|
|
15
|
+
const d = t[r];
|
|
16
|
+
s.push(encodeURIComponent(r) + "=" + encodeURIComponent(d));
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return s.join("&");
|
|
19
19
|
};
|
|
20
|
-
function
|
|
21
|
-
if (
|
|
20
|
+
function E(...t) {
|
|
21
|
+
if (t.length < 2)
|
|
22
22
|
throw new Error("Bad parameters: buildUrl needs at least two non-empty parameters.");
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
if (!
|
|
23
|
+
const s = V(t[t.length - 1]) ? t.pop() : null;
|
|
24
|
+
t.forEach((e) => {
|
|
25
|
+
if (!e || !(j(e) || F(e)))
|
|
26
26
|
throw new Error(
|
|
27
27
|
"Bad parameters: buildUrl accepts only strings and numbers, with a hash map as the last parameter"
|
|
28
28
|
);
|
|
29
|
-
if (
|
|
29
|
+
if (j(e) && e.indexOf("?") >= 0)
|
|
30
30
|
throw new Error(
|
|
31
31
|
'Bad parameters: buildUrl does not accept strings with "?" character. Please use a hashmap as the last parameter instead!'
|
|
32
32
|
);
|
|
33
33
|
});
|
|
34
|
-
let
|
|
35
|
-
const [
|
|
36
|
-
if (!
|
|
37
|
-
throw new Error(`Bad URL: ${
|
|
38
|
-
return
|
|
34
|
+
let r = t.join("/");
|
|
35
|
+
const [d, i] = r.split("://");
|
|
36
|
+
if (!d || !i)
|
|
37
|
+
throw new Error(`Bad URL: ${r}`);
|
|
38
|
+
return r = `${d}://${i.replace(/\/\/+/g, "/")}`, s && (r += `?${B(s)}`), r;
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const I = "k8sClient:", P = (t) => function(...s) {
|
|
41
41
|
try {
|
|
42
|
-
const
|
|
43
|
-
console[
|
|
44
|
-
} catch (
|
|
45
|
-
console.error(
|
|
42
|
+
const r = [`${I}`, ...s];
|
|
43
|
+
console[t](...r);
|
|
44
|
+
} catch (r) {
|
|
45
|
+
console.error(I, "Logging error:", r);
|
|
46
46
|
}
|
|
47
|
-
},
|
|
48
|
-
if (
|
|
49
|
-
return
|
|
47
|
+
}, k = P("error"), f = P("debug"), L = (t) => {
|
|
48
|
+
if (t.status >= 200 && t.status < 300)
|
|
49
|
+
return t;
|
|
50
50
|
{
|
|
51
|
-
const
|
|
52
|
-
throw
|
|
51
|
+
const s = new Error(t.statusText || `${t.status}`);
|
|
52
|
+
throw s.response = t, s;
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
(
|
|
59
|
-
{ credentials: "same-origin", method:
|
|
55
|
+
function m(t, s, r = {}) {
|
|
56
|
+
r.params && (s = E(s, r.params));
|
|
57
|
+
const i = ["signal", "headers", "body", "mode", "cache", "credentials"].reduce(
|
|
58
|
+
(e, n) => r[n] ? { ...e, [n]: r[n] } : e,
|
|
59
|
+
{ credentials: "same-origin", method: t }
|
|
60
60
|
);
|
|
61
|
-
return
|
|
61
|
+
return i.body && typeof i.body != "string" && (i.body = JSON.stringify(i.body)), f("fetch >", s, i), fetch(s, i).then(L);
|
|
62
62
|
}
|
|
63
|
-
const
|
|
63
|
+
const D = "ADDED", A = "MODIFIED", O = "DELETED", R = "ERROR", X = "BOOKMARK";
|
|
64
64
|
class $ {
|
|
65
|
-
constructor(
|
|
65
|
+
constructor(s, r = {}, d) {
|
|
66
|
+
var i;
|
|
66
67
|
this.listeners = {
|
|
67
|
-
[
|
|
68
|
-
[
|
|
69
|
-
[
|
|
70
|
-
[
|
|
71
|
-
}, this.controller = new AbortController(), this.signal = this.controller.signal, this.resourceVersion = null, this.PREFIX = "watch >", this.decoder = new TextDecoder(), this.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
68
|
+
[D]: [],
|
|
69
|
+
[A]: [],
|
|
70
|
+
[O]: [],
|
|
71
|
+
[R]: []
|
|
72
|
+
}, this.controller = new AbortController(), this.signal = this.controller.signal, this.resourceVersion = null, this.PREFIX = "watch >", this.decoder = new TextDecoder(), this.refreshToken = (e) => {
|
|
73
|
+
this.options.headers && (this.options.headers.Authorization = `Bearer ${e}`);
|
|
74
|
+
}, this.checkType = (e) => {
|
|
75
|
+
if (![D, A, O, R].includes(e))
|
|
76
|
+
throw new Error(`Bad type: ${e}`);
|
|
77
|
+
}, this.addListener = (e, n) => {
|
|
78
|
+
this.checkType(e), this.listeners[e].push(n);
|
|
79
|
+
}, this.informListeners = (e, n) => {
|
|
80
|
+
const a = this.listeners[e];
|
|
81
|
+
a && a.forEach((c) => {
|
|
82
|
+
try {
|
|
83
|
+
c(n);
|
|
84
|
+
} catch (l) {
|
|
85
|
+
k(l);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}, this.handleEvents = (e) => {
|
|
89
|
+
Array.isArray(e) || (e = [e]);
|
|
90
|
+
const n = this;
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
const a = {};
|
|
93
|
+
e.forEach((c) => {
|
|
94
|
+
var l, y;
|
|
95
|
+
c.type === X ? n.resourceVersion = ((y = (l = c == null ? void 0 : c.object) == null ? void 0 : l.metadata) == null ? void 0 : y.resourceVersion) ?? null : (a[c.type] || (a[c.type] = []), a[c.type].push(c.object));
|
|
96
|
+
}), Object.keys(a).forEach((c) => n.informListeners(c, a[c]));
|
|
97
|
+
});
|
|
98
|
+
}, this.getResourceVersion = async () => {
|
|
99
|
+
if (this.resourceVersion) return this.resourceVersion;
|
|
100
|
+
f(this.PREFIX, "get resource version from API");
|
|
101
|
+
const { metadata: e, items: n } = await m("GET", this.url, this.options).then(
|
|
102
|
+
(a) => (
|
|
103
|
+
// 'Body.json()' type definition expects 'any' as a return value
|
|
104
|
+
a.json()
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
return this.resourceVersion = e.resourceVersion, n && this.informListeners(D, n), this.resourceVersion;
|
|
108
|
+
}, this.start = () => {
|
|
109
|
+
const e = this;
|
|
110
|
+
return e.getCurrentToken && e.refreshToken(e.getCurrentToken()), e.getResourceVersion().then((n) => (f(e.PREFIX, "current resource version", n), m("GET", e.url, {
|
|
111
|
+
...e.options,
|
|
112
|
+
params: {
|
|
113
|
+
...e.options.params,
|
|
114
|
+
watch: 1,
|
|
115
|
+
allowWatchBookmarks: !0,
|
|
116
|
+
resourceVersion: n
|
|
117
|
+
},
|
|
118
|
+
signal: e.signal
|
|
119
|
+
}))).then(async (n) => {
|
|
120
|
+
var y;
|
|
121
|
+
const a = (y = n.body) == null ? void 0 : y.getReader();
|
|
122
|
+
let c = !1, l = "";
|
|
123
|
+
for (; !c; ) {
|
|
124
|
+
f(e.PREFIX, "read stream chunk");
|
|
125
|
+
const p = await (a == null ? void 0 : a.read());
|
|
126
|
+
c = (p == null ? void 0 : p.done) ?? !0, l += e.decoder.decode((p == null ? void 0 : p.value) || new Uint8Array());
|
|
127
|
+
const w = l.split(/\n|\r|\r\n/);
|
|
128
|
+
l = w.pop() ?? "";
|
|
129
|
+
const g = [];
|
|
130
|
+
w.forEach((h) => {
|
|
131
|
+
var u;
|
|
132
|
+
const o = JSON.parse(h);
|
|
133
|
+
if (o.type === R && ((u = o == null ? void 0 : o.object) == null ? void 0 : u.code) === 410) {
|
|
134
|
+
e.cancel(), setTimeout(() => {
|
|
135
|
+
f(e.PREFIX, "resource is gone 410", "recreate watch request!"), e.start();
|
|
136
|
+
});
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
g.push(o);
|
|
140
|
+
}), f(e.PREFIX, "inform listeners", w), e.handleEvents(g);
|
|
141
|
+
}
|
|
142
|
+
}).catch((n) => {
|
|
143
|
+
var c;
|
|
144
|
+
if (n.name === "AbortError") return;
|
|
145
|
+
const a = n.code ?? ((c = n == null ? void 0 : n.response) == null ? void 0 : c.status);
|
|
146
|
+
if (a === 410) {
|
|
147
|
+
f(e.PREFIX, "resource is gone 410"), e.resourceVersion = null, setTimeout(() => e.start(), 0);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (a === 404) {
|
|
151
|
+
e.handleEvents({ type: R, object: n }), e.cancel();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
k("WATCH ERROR", n, n.code, a, n.response), console.dir(n), setTimeout(() => {
|
|
155
|
+
f(e.PREFIX, "recover connection", "restart!"), e.start();
|
|
156
|
+
}, 3e4);
|
|
157
|
+
}), e.cancel;
|
|
158
|
+
}, this.on = (e, n) => (this.addListener(e, n), this), this.cancel = () => {
|
|
159
|
+
f(this.PREFIX, "cancel connection"), this.controller.abort();
|
|
160
|
+
}, this.url = s, this.options = r, this.getCurrentToken = d, (i = r == null ? void 0 : r.params) != null && i.resourceVersion && (this.resourceVersion = r.params.resourceVersion, delete r.params.resourceVersion);
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
|
-
const
|
|
163
|
-
var
|
|
164
|
-
const
|
|
165
|
-
return Promise.reject(
|
|
163
|
+
const b = async (t) => {
|
|
164
|
+
var r;
|
|
165
|
+
const s = (r = t.response) != null && r.data ? new Error(t.response.data.message ?? t.message) : t;
|
|
166
|
+
return Promise.reject(s);
|
|
166
167
|
};
|
|
167
|
-
function H(
|
|
168
|
-
const { apiEndpoint:
|
|
169
|
-
let
|
|
170
|
-
if (!
|
|
171
|
-
throw new Error(`Bad options: ${JSON.stringify(
|
|
172
|
-
const
|
|
173
|
-
Authorization: `Bearer ${
|
|
168
|
+
function H(t) {
|
|
169
|
+
const { apiEndpoint: s } = t;
|
|
170
|
+
let r = t.token;
|
|
171
|
+
if (!s || !r)
|
|
172
|
+
throw new Error(`Bad options: ${JSON.stringify(t, null, 4)}. Please provide apiEndpoint and token`);
|
|
173
|
+
const d = () => ({
|
|
174
|
+
Authorization: `Bearer ${r}`,
|
|
174
175
|
"Content-Type": "application/json"
|
|
175
176
|
});
|
|
176
|
-
function
|
|
177
|
-
const
|
|
178
|
-
...
|
|
179
|
-
...
|
|
180
|
-
...
|
|
177
|
+
function i(h, o = {}) {
|
|
178
|
+
const u = {
|
|
179
|
+
...d(),
|
|
180
|
+
...o.headers,
|
|
181
|
+
...h.headers
|
|
181
182
|
};
|
|
182
183
|
return {
|
|
183
|
-
...c,
|
|
184
184
|
...o,
|
|
185
|
-
|
|
185
|
+
...h,
|
|
186
|
+
headers: u
|
|
186
187
|
};
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
-
return
|
|
189
|
+
function e(h, o = {}) {
|
|
190
|
+
return m("HEAD", E(s, h), i(o)).catch(b);
|
|
190
191
|
}
|
|
191
|
-
function
|
|
192
|
-
return
|
|
192
|
+
function n(h, o = {}) {
|
|
193
|
+
return m("GET", E(s, h), i(o)).then((u) => u.json()).catch(b);
|
|
193
194
|
}
|
|
194
|
-
function
|
|
195
|
-
return
|
|
195
|
+
function a(h, o, u = {}) {
|
|
196
|
+
return m("POST", E(s, h), i(u, { body: o })).then((C) => C.json()).catch(b);
|
|
196
197
|
}
|
|
197
|
-
function
|
|
198
|
-
return
|
|
198
|
+
function c(h, o, u = {}) {
|
|
199
|
+
return m("PUT", E(s, h), i(u, { body: o })).then((T) => T.json()).catch(b);
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
-
return
|
|
201
|
+
function l(h, o, u = {}) {
|
|
202
|
+
return m(
|
|
202
203
|
"PATCH",
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
E(s, h),
|
|
205
|
+
i(u, {
|
|
205
206
|
headers: { "Content-Type": "application/merge-patch+json" },
|
|
206
|
-
body:
|
|
207
|
+
body: o
|
|
207
208
|
})
|
|
208
|
-
).then((
|
|
209
|
+
).then((T) => T.json()).catch(b);
|
|
209
210
|
}
|
|
210
|
-
function
|
|
211
|
-
return
|
|
211
|
+
function y(h, o, u = {}) {
|
|
212
|
+
return m("DELETE", E(s, h), i(u, { body: o })).then((T) => T.json()).catch(b);
|
|
212
213
|
}
|
|
213
|
-
function
|
|
214
|
-
return new $(
|
|
214
|
+
function p(h, o = {}) {
|
|
215
|
+
return new $(E(s, h), i(o), () => r);
|
|
215
216
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
217
|
+
function w(h) {
|
|
218
|
+
r = h;
|
|
218
219
|
}
|
|
219
|
-
function
|
|
220
|
-
return
|
|
220
|
+
function g() {
|
|
221
|
+
return r;
|
|
221
222
|
}
|
|
222
223
|
return {
|
|
223
|
-
WATCH_ERROR:
|
|
224
|
-
WATCH_ADDED:
|
|
225
|
-
WATCH_DELETED:
|
|
226
|
-
WATCH_MODIFIED:
|
|
227
|
-
head:
|
|
228
|
-
get:
|
|
229
|
-
post:
|
|
230
|
-
put:
|
|
231
|
-
patch:
|
|
232
|
-
delete:
|
|
233
|
-
watch:
|
|
234
|
-
refreshToken:
|
|
235
|
-
currentToken:
|
|
224
|
+
WATCH_ERROR: R,
|
|
225
|
+
WATCH_ADDED: D,
|
|
226
|
+
WATCH_DELETED: O,
|
|
227
|
+
WATCH_MODIFIED: A,
|
|
228
|
+
head: e,
|
|
229
|
+
get: n,
|
|
230
|
+
post: a,
|
|
231
|
+
put: c,
|
|
232
|
+
patch: l,
|
|
233
|
+
delete: y,
|
|
234
|
+
watch: p,
|
|
235
|
+
refreshToken: w,
|
|
236
|
+
currentToken: g
|
|
236
237
|
};
|
|
237
238
|
}
|
|
238
239
|
export {
|
package/build/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,GAAG,YAVY,OAAO,EAAE,SAUA,CAAA;AACrC,eAAO,MAAM,KAAK,YAXU,OAAO,EAAE,SAWI,CAAA;AACzC,eAAO,MAAM,KAAK,YAZU,OAAO,EAAE,SAYI,CAAA;AACzC,eAAO,MAAM,IAAI,YAbW,OAAO,EAAE,SAaE,CAAA"}
|
package/build/request.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
interface RequestOptions {
|
|
2
2
|
params?: Record<string, any>;
|
|
3
3
|
signal?: AbortSignal;
|
|
4
|
-
headers?: HeadersInit;
|
|
5
|
-
body?:
|
|
4
|
+
headers?: HeadersInit | null;
|
|
5
|
+
body?: Object | null;
|
|
6
6
|
mode?: RequestMode;
|
|
7
7
|
cache?: RequestCache;
|
|
8
8
|
credentials?: RequestCredentials;
|
|
9
|
+
[key: string]: any;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Creates a request.
|
package/build/request.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAUA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAaD;;;;;;;GAOG;AACH,iBAAS,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA2B7F;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlHelpers.d.ts","sourceRoot":"","sources":["../src/urlHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"urlHelpers.d.ts","sourceRoot":"","sources":["../src/urlHelpers.ts"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH,iBAAS,QAAQ,CAAC,GAAG,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,MAAM,CAmC5E;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
package/build/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,iBAAS,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAE7C;AAED;;;;GAIG;AACH,iBAAS,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAE7C;AAED;;;;GAIG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAEtC;AAED;;;;GAIG;AACH,iBAAS,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,GAAG,EAAE,CAE3C;AAED;;;;GAIG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAEjD;AAED;;;;GAIG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,IAAI,CAEzC;AAED;;;;GAIG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS,CAEnD;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,CAAA"}
|
package/build/watch.d.ts
CHANGED
|
@@ -2,36 +2,36 @@ declare const ADDED = "ADDED";
|
|
|
2
2
|
declare const MODIFIED = "MODIFIED";
|
|
3
3
|
declare const DELETED = "DELETED";
|
|
4
4
|
declare const ERROR = "ERROR";
|
|
5
|
-
type Listener = (_items:
|
|
5
|
+
type Listener = (_items: unknown) => void;
|
|
6
6
|
interface WatchOptions {
|
|
7
|
-
params?: Record<string,
|
|
7
|
+
params?: Record<string, string>;
|
|
8
8
|
headers?: Record<string, string>;
|
|
9
9
|
signal?: AbortSignal;
|
|
10
|
-
body?:
|
|
10
|
+
body?: Object | null;
|
|
11
11
|
mode?: RequestMode;
|
|
12
12
|
cache?: RequestCache;
|
|
13
13
|
credentials?: RequestCredentials;
|
|
14
14
|
}
|
|
15
15
|
declare class Watch {
|
|
16
|
-
private listeners;
|
|
17
|
-
private controller;
|
|
18
|
-
private signal;
|
|
16
|
+
private readonly listeners;
|
|
17
|
+
private readonly controller;
|
|
18
|
+
private readonly signal;
|
|
19
19
|
private resourceVersion;
|
|
20
|
-
private PREFIX;
|
|
21
|
-
private decoder;
|
|
22
|
-
private url;
|
|
23
|
-
private options;
|
|
24
|
-
private getCurrentToken?;
|
|
20
|
+
private readonly PREFIX;
|
|
21
|
+
private readonly decoder;
|
|
22
|
+
private readonly url;
|
|
23
|
+
private readonly options;
|
|
24
|
+
private readonly getCurrentToken?;
|
|
25
25
|
constructor(url: string, options?: WatchOptions, getCurrentToken?: () => string);
|
|
26
|
-
refreshToken(newToken: string)
|
|
26
|
+
refreshToken: (newToken: string) => void;
|
|
27
27
|
private checkType;
|
|
28
28
|
private addListener;
|
|
29
29
|
private informListeners;
|
|
30
30
|
private handleEvents;
|
|
31
31
|
private getResourceVersion;
|
|
32
|
-
start()
|
|
33
|
-
on(type: string, listener: Listener)
|
|
34
|
-
cancel()
|
|
32
|
+
start: () => () => void;
|
|
33
|
+
on: (type: string, listener: Listener) => this;
|
|
34
|
+
cancel: () => void;
|
|
35
35
|
}
|
|
36
36
|
export { ADDED, MODIFIED, DELETED, ERROR, Watch };
|
|
37
37
|
//# sourceMappingURL=watch.d.ts.map
|
package/build/watch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":"AASA,QAAA,MAAM,KAAK,UAAU,CAAA;AACrB,QAAA,MAAM,QAAQ,aAAa,CAAA;AAC3B,QAAA,MAAM,OAAO,YAAY,CAAA;AACzB,QAAA,MAAM,KAAK,UAAU,CAAA;AAGrB,KAAK,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;AAmBzC,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,WAAW,CAAC,EAAE,kBAAkB,CAAA;CACjC;AAED,cAAM,KAAK;IACT,OAAO,CAAC,QAAQ,CAAC,SAAS,CAKzB;IACD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyC;IACpE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;IAC7D,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAc;gBAEnC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,EAAE,eAAe,CAAC,EAAE,MAAM,MAAM;IAYnF,YAAY,aAAc,MAAM,UAI/B;IAED,OAAO,CAAC,SAAS,CAIhB;IAED,OAAO,CAAC,WAAW,CAGlB;IAED,OAAO,CAAC,eAAe,CAYtB;IAED,OAAO,CAAC,YAAY,CAsBnB;IAED,OAAO,CAAC,kBAAkB,CAazB;IAED,KAAK,mBAmFJ;IAED,EAAE,SAAU,MAAM,YAAY,QAAQ,UAGrC;IAED,MAAM,aAGL;CACF;AAED,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudoperators/juno-k8s-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"author": "UI-Team",
|
|
5
5
|
"description": "JavaScript client for Kubernetes API",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@cloudoperators/juno-config": "*",
|
|
32
|
-
"vite": "^
|
|
32
|
+
"vite": "^6.0.0",
|
|
33
33
|
"vite-plugin-dts": "^4.0.3"
|
|
34
34
|
}
|
|
35
35
|
}
|