@kwirthmagnify/kwirth-plugin-topology 0.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.
- package/back.js +1757 -0
- package/front.js +26630 -0
- package/package.json +8 -0
package/back.js
ADDED
|
@@ -0,0 +1,1757 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../common/dist/Channel.js
|
|
34
|
+
var require_Channel = __commonJS({
|
|
35
|
+
"../../common/dist/Channel.js"(exports2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
38
|
+
exports2.EClusterType = exports2.ClusterTypeEnum = void 0;
|
|
39
|
+
var ClusterTypeEnum;
|
|
40
|
+
(function(ClusterTypeEnum2) {
|
|
41
|
+
ClusterTypeEnum2["KUBERNETES"] = "kubernetes";
|
|
42
|
+
ClusterTypeEnum2["DOCKER"] = "docker";
|
|
43
|
+
})(ClusterTypeEnum || (exports2.ClusterTypeEnum = ClusterTypeEnum = {}));
|
|
44
|
+
var EClusterType2;
|
|
45
|
+
(function(EClusterType3) {
|
|
46
|
+
EClusterType3["KUBERNETES"] = "kubernetes";
|
|
47
|
+
EClusterType3["DOCKER"] = "docker";
|
|
48
|
+
})(EClusterType2 || (exports2.EClusterType = EClusterType2 = {}));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// ../../common/dist/InstanceMessage.js
|
|
53
|
+
var require_InstanceMessage = __commonJS({
|
|
54
|
+
"../../common/dist/InstanceMessage.js"(exports2) {
|
|
55
|
+
"use strict";
|
|
56
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
57
|
+
exports2.EInstanceMessageFlow = exports2.InstanceMessageFlowEnum = exports2.EInstanceMessageAction = exports2.InstanceMessageActionEnum = exports2.EInstanceMessageType = exports2.InstanceMessageTypeEnum = exports2.EInstanceMessageChannel = exports2.InstanceMessageChannelEnum = void 0;
|
|
58
|
+
var InstanceMessageChannelEnum;
|
|
59
|
+
(function(InstanceMessageChannelEnum2) {
|
|
60
|
+
InstanceMessageChannelEnum2["NONE"] = "none";
|
|
61
|
+
InstanceMessageChannelEnum2["LOG"] = "log";
|
|
62
|
+
InstanceMessageChannelEnum2["METRICS"] = "metrics";
|
|
63
|
+
InstanceMessageChannelEnum2["AUDIT"] = "audit";
|
|
64
|
+
InstanceMessageChannelEnum2["OPS"] = "ops";
|
|
65
|
+
InstanceMessageChannelEnum2["ALERT"] = "alert";
|
|
66
|
+
InstanceMessageChannelEnum2["TRIVY"] = "trivy";
|
|
67
|
+
})(InstanceMessageChannelEnum || (exports2.InstanceMessageChannelEnum = InstanceMessageChannelEnum = {}));
|
|
68
|
+
var EInstanceMessageChannel;
|
|
69
|
+
(function(EInstanceMessageChannel2) {
|
|
70
|
+
EInstanceMessageChannel2["NONE"] = "none";
|
|
71
|
+
EInstanceMessageChannel2["LOG"] = "log";
|
|
72
|
+
EInstanceMessageChannel2["METRICS"] = "metrics";
|
|
73
|
+
EInstanceMessageChannel2["AUDIT"] = "audit";
|
|
74
|
+
EInstanceMessageChannel2["OPS"] = "ops";
|
|
75
|
+
EInstanceMessageChannel2["ALERT"] = "alert";
|
|
76
|
+
EInstanceMessageChannel2["TRIVY"] = "trivy";
|
|
77
|
+
EInstanceMessageChannel2["MAGNIFY"] = "magnify";
|
|
78
|
+
})(EInstanceMessageChannel || (exports2.EInstanceMessageChannel = EInstanceMessageChannel = {}));
|
|
79
|
+
var InstanceMessageTypeEnum;
|
|
80
|
+
(function(InstanceMessageTypeEnum2) {
|
|
81
|
+
InstanceMessageTypeEnum2["DATA"] = "data";
|
|
82
|
+
InstanceMessageTypeEnum2["SIGNAL"] = "signal";
|
|
83
|
+
})(InstanceMessageTypeEnum || (exports2.InstanceMessageTypeEnum = InstanceMessageTypeEnum = {}));
|
|
84
|
+
var EInstanceMessageType2;
|
|
85
|
+
(function(EInstanceMessageType3) {
|
|
86
|
+
EInstanceMessageType3["DATA"] = "data";
|
|
87
|
+
EInstanceMessageType3["SIGNAL"] = "signal";
|
|
88
|
+
})(EInstanceMessageType2 || (exports2.EInstanceMessageType = EInstanceMessageType2 = {}));
|
|
89
|
+
var InstanceMessageActionEnum;
|
|
90
|
+
(function(InstanceMessageActionEnum2) {
|
|
91
|
+
InstanceMessageActionEnum2["NONE"] = "none";
|
|
92
|
+
InstanceMessageActionEnum2["ROUTE"] = "route";
|
|
93
|
+
InstanceMessageActionEnum2["START"] = "start";
|
|
94
|
+
InstanceMessageActionEnum2["STOP"] = "stop";
|
|
95
|
+
InstanceMessageActionEnum2["PAUSE"] = "pause";
|
|
96
|
+
InstanceMessageActionEnum2["CONTINUE"] = "continue";
|
|
97
|
+
InstanceMessageActionEnum2["MODIFY"] = "modify";
|
|
98
|
+
InstanceMessageActionEnum2["PING"] = "ping";
|
|
99
|
+
InstanceMessageActionEnum2["RECONNECT"] = "reconnect";
|
|
100
|
+
InstanceMessageActionEnum2["COMMAND"] = "command";
|
|
101
|
+
InstanceMessageActionEnum2["WEBSOCKET"] = "websocket";
|
|
102
|
+
})(InstanceMessageActionEnum || (exports2.InstanceMessageActionEnum = InstanceMessageActionEnum = {}));
|
|
103
|
+
var EInstanceMessageAction2;
|
|
104
|
+
(function(EInstanceMessageAction3) {
|
|
105
|
+
EInstanceMessageAction3["NONE"] = "none";
|
|
106
|
+
EInstanceMessageAction3["RI"] = "ri";
|
|
107
|
+
EInstanceMessageAction3["ROUTE"] = "route";
|
|
108
|
+
EInstanceMessageAction3["START"] = "start";
|
|
109
|
+
EInstanceMessageAction3["STOP"] = "stop";
|
|
110
|
+
EInstanceMessageAction3["PAUSE"] = "pause";
|
|
111
|
+
EInstanceMessageAction3["CONTINUE"] = "continue";
|
|
112
|
+
EInstanceMessageAction3["MODIFY"] = "modify";
|
|
113
|
+
EInstanceMessageAction3["PING"] = "ping";
|
|
114
|
+
EInstanceMessageAction3["RECONNECT"] = "reconnect";
|
|
115
|
+
EInstanceMessageAction3["COMMAND"] = "command";
|
|
116
|
+
EInstanceMessageAction3["WEBSOCKET"] = "websocket";
|
|
117
|
+
})(EInstanceMessageAction2 || (exports2.EInstanceMessageAction = EInstanceMessageAction2 = {}));
|
|
118
|
+
var InstanceMessageFlowEnum;
|
|
119
|
+
(function(InstanceMessageFlowEnum2) {
|
|
120
|
+
InstanceMessageFlowEnum2["IMMEDIATE"] = "immediate";
|
|
121
|
+
InstanceMessageFlowEnum2["REQUEST"] = "request";
|
|
122
|
+
InstanceMessageFlowEnum2["RESPONSE"] = "response";
|
|
123
|
+
InstanceMessageFlowEnum2["UNSOLICITED"] = "unsolicited";
|
|
124
|
+
})(InstanceMessageFlowEnum || (exports2.InstanceMessageFlowEnum = InstanceMessageFlowEnum = {}));
|
|
125
|
+
var EInstanceMessageFlow2;
|
|
126
|
+
(function(EInstanceMessageFlow3) {
|
|
127
|
+
EInstanceMessageFlow3["IMMEDIATE"] = "immediate";
|
|
128
|
+
EInstanceMessageFlow3["REQUEST"] = "request";
|
|
129
|
+
EInstanceMessageFlow3["RESPONSE"] = "response";
|
|
130
|
+
EInstanceMessageFlow3["UNSOLICITED"] = "unsolicited";
|
|
131
|
+
})(EInstanceMessageFlow2 || (exports2.EInstanceMessageFlow = EInstanceMessageFlow2 = {}));
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// ../../common/dist/InstanceConfig.js
|
|
136
|
+
var require_InstanceConfig = __commonJS({
|
|
137
|
+
"../../common/dist/InstanceConfig.js"(exports2) {
|
|
138
|
+
"use strict";
|
|
139
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
140
|
+
exports2.EInstanceConfigScope = exports2.EInstanceConfigView = exports2.EInstanceConfigObject = exports2.InstanceConfigScopeEnum = exports2.InstanceConfigViewEnum = exports2.InstanceConfigObjectEnum = void 0;
|
|
141
|
+
var InstanceConfigObjectEnum;
|
|
142
|
+
(function(InstanceConfigObjectEnum2) {
|
|
143
|
+
InstanceConfigObjectEnum2["PODS"] = "pods";
|
|
144
|
+
InstanceConfigObjectEnum2["EVENTS"] = "events";
|
|
145
|
+
})(InstanceConfigObjectEnum || (exports2.InstanceConfigObjectEnum = InstanceConfigObjectEnum = {}));
|
|
146
|
+
var InstanceConfigViewEnum;
|
|
147
|
+
(function(InstanceConfigViewEnum2) {
|
|
148
|
+
InstanceConfigViewEnum2["NONE"] = "none";
|
|
149
|
+
InstanceConfigViewEnum2["CLUSTER"] = "cluster";
|
|
150
|
+
InstanceConfigViewEnum2["NAMESPACE"] = "namespace";
|
|
151
|
+
InstanceConfigViewEnum2["GROUP"] = "group";
|
|
152
|
+
InstanceConfigViewEnum2["POD"] = "pod";
|
|
153
|
+
InstanceConfigViewEnum2["CONTAINER"] = "container";
|
|
154
|
+
})(InstanceConfigViewEnum || (exports2.InstanceConfigViewEnum = InstanceConfigViewEnum = {}));
|
|
155
|
+
var InstanceConfigScopeEnum;
|
|
156
|
+
(function(InstanceConfigScopeEnum2) {
|
|
157
|
+
InstanceConfigScopeEnum2["NONE"] = "none";
|
|
158
|
+
InstanceConfigScopeEnum2["API"] = "api";
|
|
159
|
+
InstanceConfigScopeEnum2["CLUSTER"] = "cluster";
|
|
160
|
+
InstanceConfigScopeEnum2["FILTER"] = "filter";
|
|
161
|
+
InstanceConfigScopeEnum2["VIEW"] = "view";
|
|
162
|
+
InstanceConfigScopeEnum2["SNAPSHOT"] = "snapshot";
|
|
163
|
+
InstanceConfigScopeEnum2["STREAM"] = "stream";
|
|
164
|
+
InstanceConfigScopeEnum2["CREATE"] = "create";
|
|
165
|
+
InstanceConfigScopeEnum2["SUBSCRIBE"] = "subscribe";
|
|
166
|
+
InstanceConfigScopeEnum2["GET"] = "get";
|
|
167
|
+
InstanceConfigScopeEnum2["EXECUTE"] = "execute";
|
|
168
|
+
InstanceConfigScopeEnum2["RESTART"] = "restart";
|
|
169
|
+
InstanceConfigScopeEnum2["WORKLOAD"] = "workload";
|
|
170
|
+
InstanceConfigScopeEnum2["KUBERNETES"] = "kubernetes";
|
|
171
|
+
})(InstanceConfigScopeEnum || (exports2.InstanceConfigScopeEnum = InstanceConfigScopeEnum = {}));
|
|
172
|
+
var EInstanceConfigObject;
|
|
173
|
+
(function(EInstanceConfigObject2) {
|
|
174
|
+
EInstanceConfigObject2["PODS"] = "pods";
|
|
175
|
+
EInstanceConfigObject2["EVENTS"] = "events";
|
|
176
|
+
})(EInstanceConfigObject || (exports2.EInstanceConfigObject = EInstanceConfigObject = {}));
|
|
177
|
+
var EInstanceConfigView;
|
|
178
|
+
(function(EInstanceConfigView2) {
|
|
179
|
+
EInstanceConfigView2["NONE"] = "none";
|
|
180
|
+
EInstanceConfigView2["CLUSTER"] = "cluster";
|
|
181
|
+
EInstanceConfigView2["NAMESPACE"] = "namespace";
|
|
182
|
+
EInstanceConfigView2["GROUP"] = "group";
|
|
183
|
+
EInstanceConfigView2["POD"] = "pod";
|
|
184
|
+
EInstanceConfigView2["CONTAINER"] = "container";
|
|
185
|
+
})(EInstanceConfigView || (exports2.EInstanceConfigView = EInstanceConfigView = {}));
|
|
186
|
+
var EInstanceConfigScope;
|
|
187
|
+
(function(EInstanceConfigScope2) {
|
|
188
|
+
EInstanceConfigScope2["NONE"] = "none";
|
|
189
|
+
EInstanceConfigScope2["API"] = "api";
|
|
190
|
+
EInstanceConfigScope2["CLUSTER"] = "cluster";
|
|
191
|
+
EInstanceConfigScope2["FILTER"] = "filter";
|
|
192
|
+
EInstanceConfigScope2["VIEW"] = "view";
|
|
193
|
+
EInstanceConfigScope2["SNAPSHOT"] = "snapshot";
|
|
194
|
+
EInstanceConfigScope2["STREAM"] = "stream";
|
|
195
|
+
EInstanceConfigScope2["CREATE"] = "create";
|
|
196
|
+
EInstanceConfigScope2["SUBSCRIBE"] = "subscribe";
|
|
197
|
+
EInstanceConfigScope2["GET"] = "get";
|
|
198
|
+
EInstanceConfigScope2["EXECUTE"] = "execute";
|
|
199
|
+
EInstanceConfigScope2["RESTART"] = "restart";
|
|
200
|
+
EInstanceConfigScope2["WORKLOAD"] = "workload";
|
|
201
|
+
EInstanceConfigScope2["KUBERNETES"] = "kubernetes";
|
|
202
|
+
})(EInstanceConfigScope || (exports2.EInstanceConfigScope = EInstanceConfigScope = {}));
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// ../../common/dist/RouteMessage.js
|
|
207
|
+
var require_RouteMessage = __commonJS({
|
|
208
|
+
"../../common/dist/RouteMessage.js"(exports2) {
|
|
209
|
+
"use strict";
|
|
210
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// ../../common/dist/SignalMessage.js
|
|
215
|
+
var require_SignalMessage = __commonJS({
|
|
216
|
+
"../../common/dist/SignalMessage.js"(exports2) {
|
|
217
|
+
"use strict";
|
|
218
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
219
|
+
exports2.ESignalMessageEvent = exports2.ESignalMessageLevel = exports2.SignalMessageEventEnum = exports2.SignalMessageLevelEnum = void 0;
|
|
220
|
+
var SignalMessageLevelEnum;
|
|
221
|
+
(function(SignalMessageLevelEnum2) {
|
|
222
|
+
SignalMessageLevelEnum2["INFO"] = "info";
|
|
223
|
+
SignalMessageLevelEnum2["WARNING"] = "warning";
|
|
224
|
+
SignalMessageLevelEnum2["ERROR"] = "error";
|
|
225
|
+
})(SignalMessageLevelEnum || (exports2.SignalMessageLevelEnum = SignalMessageLevelEnum = {}));
|
|
226
|
+
var SignalMessageEventEnum;
|
|
227
|
+
(function(SignalMessageEventEnum2) {
|
|
228
|
+
SignalMessageEventEnum2["ADD"] = "add";
|
|
229
|
+
SignalMessageEventEnum2["DELETE"] = "delete";
|
|
230
|
+
SignalMessageEventEnum2["OTHER"] = "other";
|
|
231
|
+
})(SignalMessageEventEnum || (exports2.SignalMessageEventEnum = SignalMessageEventEnum = {}));
|
|
232
|
+
var ESignalMessageLevel2;
|
|
233
|
+
(function(ESignalMessageLevel3) {
|
|
234
|
+
ESignalMessageLevel3["INFO"] = "info";
|
|
235
|
+
ESignalMessageLevel3["WARNING"] = "warning";
|
|
236
|
+
ESignalMessageLevel3["ERROR"] = "error";
|
|
237
|
+
})(ESignalMessageLevel2 || (exports2.ESignalMessageLevel = ESignalMessageLevel2 = {}));
|
|
238
|
+
var ESignalMessageEvent;
|
|
239
|
+
(function(ESignalMessageEvent2) {
|
|
240
|
+
ESignalMessageEvent2["ADD"] = "add";
|
|
241
|
+
ESignalMessageEvent2["DELETE"] = "delete";
|
|
242
|
+
ESignalMessageEvent2["OTHER"] = "other";
|
|
243
|
+
})(ESignalMessageEvent || (exports2.ESignalMessageEvent = ESignalMessageEvent = {}));
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// ../../common/dist/ApiKey.js
|
|
248
|
+
var require_ApiKey = __commonJS({
|
|
249
|
+
"../../common/dist/ApiKey.js"(exports2) {
|
|
250
|
+
"use strict";
|
|
251
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// ../../common/node_modules/uuid/dist/cjs/max.js
|
|
256
|
+
var require_max = __commonJS({
|
|
257
|
+
"../../common/node_modules/uuid/dist/cjs/max.js"(exports2) {
|
|
258
|
+
"use strict";
|
|
259
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
260
|
+
exports2.default = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// ../../common/node_modules/uuid/dist/cjs/nil.js
|
|
265
|
+
var require_nil = __commonJS({
|
|
266
|
+
"../../common/node_modules/uuid/dist/cjs/nil.js"(exports2) {
|
|
267
|
+
"use strict";
|
|
268
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
269
|
+
exports2.default = "00000000-0000-0000-0000-000000000000";
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// ../../common/node_modules/uuid/dist/cjs/regex.js
|
|
274
|
+
var require_regex = __commonJS({
|
|
275
|
+
"../../common/node_modules/uuid/dist/cjs/regex.js"(exports2) {
|
|
276
|
+
"use strict";
|
|
277
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
278
|
+
exports2.default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// ../../common/node_modules/uuid/dist/cjs/validate.js
|
|
283
|
+
var require_validate = __commonJS({
|
|
284
|
+
"../../common/node_modules/uuid/dist/cjs/validate.js"(exports2) {
|
|
285
|
+
"use strict";
|
|
286
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
287
|
+
var regex_js_1 = require_regex();
|
|
288
|
+
function validate(uuid) {
|
|
289
|
+
return typeof uuid === "string" && regex_js_1.default.test(uuid);
|
|
290
|
+
}
|
|
291
|
+
exports2.default = validate;
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// ../../common/node_modules/uuid/dist/cjs/parse.js
|
|
296
|
+
var require_parse = __commonJS({
|
|
297
|
+
"../../common/node_modules/uuid/dist/cjs/parse.js"(exports2) {
|
|
298
|
+
"use strict";
|
|
299
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
300
|
+
var validate_js_1 = require_validate();
|
|
301
|
+
function parse(uuid) {
|
|
302
|
+
if (!(0, validate_js_1.default)(uuid)) {
|
|
303
|
+
throw TypeError("Invalid UUID");
|
|
304
|
+
}
|
|
305
|
+
let v;
|
|
306
|
+
return Uint8Array.of((v = parseInt(uuid.slice(0, 8), 16)) >>> 24, v >>> 16 & 255, v >>> 8 & 255, v & 255, (v = parseInt(uuid.slice(9, 13), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(14, 18), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(19, 23), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255, v / 4294967296 & 255, v >>> 24 & 255, v >>> 16 & 255, v >>> 8 & 255, v & 255);
|
|
307
|
+
}
|
|
308
|
+
exports2.default = parse;
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// ../../common/node_modules/uuid/dist/cjs/stringify.js
|
|
313
|
+
var require_stringify = __commonJS({
|
|
314
|
+
"../../common/node_modules/uuid/dist/cjs/stringify.js"(exports2) {
|
|
315
|
+
"use strict";
|
|
316
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
317
|
+
exports2.unsafeStringify = void 0;
|
|
318
|
+
var validate_js_1 = require_validate();
|
|
319
|
+
var byteToHex = [];
|
|
320
|
+
for (let i = 0; i < 256; ++i) {
|
|
321
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
322
|
+
}
|
|
323
|
+
function unsafeStringify(arr, offset = 0) {
|
|
324
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
325
|
+
}
|
|
326
|
+
exports2.unsafeStringify = unsafeStringify;
|
|
327
|
+
function stringify(arr, offset = 0) {
|
|
328
|
+
const uuid = unsafeStringify(arr, offset);
|
|
329
|
+
if (!(0, validate_js_1.default)(uuid)) {
|
|
330
|
+
throw TypeError("Stringified UUID is invalid");
|
|
331
|
+
}
|
|
332
|
+
return uuid;
|
|
333
|
+
}
|
|
334
|
+
exports2.default = stringify;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// ../../common/node_modules/uuid/dist/cjs/rng.js
|
|
339
|
+
var require_rng = __commonJS({
|
|
340
|
+
"../../common/node_modules/uuid/dist/cjs/rng.js"(exports2) {
|
|
341
|
+
"use strict";
|
|
342
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
343
|
+
var crypto_1 = require("crypto");
|
|
344
|
+
var rnds8Pool = new Uint8Array(256);
|
|
345
|
+
var poolPtr = rnds8Pool.length;
|
|
346
|
+
function rng() {
|
|
347
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
|
348
|
+
(0, crypto_1.randomFillSync)(rnds8Pool);
|
|
349
|
+
poolPtr = 0;
|
|
350
|
+
}
|
|
351
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
352
|
+
}
|
|
353
|
+
exports2.default = rng;
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// ../../common/node_modules/uuid/dist/cjs/v1.js
|
|
358
|
+
var require_v1 = __commonJS({
|
|
359
|
+
"../../common/node_modules/uuid/dist/cjs/v1.js"(exports2) {
|
|
360
|
+
"use strict";
|
|
361
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
362
|
+
exports2.updateV1State = void 0;
|
|
363
|
+
var rng_js_1 = require_rng();
|
|
364
|
+
var stringify_js_1 = require_stringify();
|
|
365
|
+
var _state = {};
|
|
366
|
+
function v1(options, buf, offset) {
|
|
367
|
+
let bytes;
|
|
368
|
+
const isV6 = options?._v6 ?? false;
|
|
369
|
+
if (options) {
|
|
370
|
+
const optionsKeys = Object.keys(options);
|
|
371
|
+
if (optionsKeys.length === 1 && optionsKeys[0] === "_v6") {
|
|
372
|
+
options = void 0;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (options) {
|
|
376
|
+
bytes = v1Bytes(options.random ?? options.rng?.() ?? (0, rng_js_1.default)(), options.msecs, options.nsecs, options.clockseq, options.node, buf, offset);
|
|
377
|
+
} else {
|
|
378
|
+
const now = Date.now();
|
|
379
|
+
const rnds = (0, rng_js_1.default)();
|
|
380
|
+
updateV1State(_state, now, rnds);
|
|
381
|
+
bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? void 0 : _state.clockseq, isV6 ? void 0 : _state.node, buf, offset);
|
|
382
|
+
}
|
|
383
|
+
return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
|
|
384
|
+
}
|
|
385
|
+
function updateV1State(state, now, rnds) {
|
|
386
|
+
state.msecs ??= -Infinity;
|
|
387
|
+
state.nsecs ??= 0;
|
|
388
|
+
if (now === state.msecs) {
|
|
389
|
+
state.nsecs++;
|
|
390
|
+
if (state.nsecs >= 1e4) {
|
|
391
|
+
state.node = void 0;
|
|
392
|
+
state.nsecs = 0;
|
|
393
|
+
}
|
|
394
|
+
} else if (now > state.msecs) {
|
|
395
|
+
state.nsecs = 0;
|
|
396
|
+
} else if (now < state.msecs) {
|
|
397
|
+
state.node = void 0;
|
|
398
|
+
}
|
|
399
|
+
if (!state.node) {
|
|
400
|
+
state.node = rnds.slice(10, 16);
|
|
401
|
+
state.node[0] |= 1;
|
|
402
|
+
state.clockseq = (rnds[8] << 8 | rnds[9]) & 16383;
|
|
403
|
+
}
|
|
404
|
+
state.msecs = now;
|
|
405
|
+
return state;
|
|
406
|
+
}
|
|
407
|
+
exports2.updateV1State = updateV1State;
|
|
408
|
+
function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
|
|
409
|
+
if (rnds.length < 16) {
|
|
410
|
+
throw new Error("Random bytes length must be >= 16");
|
|
411
|
+
}
|
|
412
|
+
if (!buf) {
|
|
413
|
+
buf = new Uint8Array(16);
|
|
414
|
+
offset = 0;
|
|
415
|
+
} else {
|
|
416
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
417
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
msecs ??= Date.now();
|
|
421
|
+
nsecs ??= 0;
|
|
422
|
+
clockseq ??= (rnds[8] << 8 | rnds[9]) & 16383;
|
|
423
|
+
node ??= rnds.slice(10, 16);
|
|
424
|
+
msecs += 122192928e5;
|
|
425
|
+
const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
|
|
426
|
+
buf[offset++] = tl >>> 24 & 255;
|
|
427
|
+
buf[offset++] = tl >>> 16 & 255;
|
|
428
|
+
buf[offset++] = tl >>> 8 & 255;
|
|
429
|
+
buf[offset++] = tl & 255;
|
|
430
|
+
const tmh = msecs / 4294967296 * 1e4 & 268435455;
|
|
431
|
+
buf[offset++] = tmh >>> 8 & 255;
|
|
432
|
+
buf[offset++] = tmh & 255;
|
|
433
|
+
buf[offset++] = tmh >>> 24 & 15 | 16;
|
|
434
|
+
buf[offset++] = tmh >>> 16 & 255;
|
|
435
|
+
buf[offset++] = clockseq >>> 8 | 128;
|
|
436
|
+
buf[offset++] = clockseq & 255;
|
|
437
|
+
for (let n = 0; n < 6; ++n) {
|
|
438
|
+
buf[offset++] = node[n];
|
|
439
|
+
}
|
|
440
|
+
return buf;
|
|
441
|
+
}
|
|
442
|
+
exports2.default = v1;
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
// ../../common/node_modules/uuid/dist/cjs/v1ToV6.js
|
|
447
|
+
var require_v1ToV6 = __commonJS({
|
|
448
|
+
"../../common/node_modules/uuid/dist/cjs/v1ToV6.js"(exports2) {
|
|
449
|
+
"use strict";
|
|
450
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
451
|
+
var parse_js_1 = require_parse();
|
|
452
|
+
var stringify_js_1 = require_stringify();
|
|
453
|
+
function v1ToV6(uuid) {
|
|
454
|
+
const v1Bytes = typeof uuid === "string" ? (0, parse_js_1.default)(uuid) : uuid;
|
|
455
|
+
const v6Bytes = _v1ToV6(v1Bytes);
|
|
456
|
+
return typeof uuid === "string" ? (0, stringify_js_1.unsafeStringify)(v6Bytes) : v6Bytes;
|
|
457
|
+
}
|
|
458
|
+
exports2.default = v1ToV6;
|
|
459
|
+
function _v1ToV6(v1Bytes) {
|
|
460
|
+
return Uint8Array.of((v1Bytes[6] & 15) << 4 | v1Bytes[7] >> 4 & 15, (v1Bytes[7] & 15) << 4 | (v1Bytes[4] & 240) >> 4, (v1Bytes[4] & 15) << 4 | (v1Bytes[5] & 240) >> 4, (v1Bytes[5] & 15) << 4 | (v1Bytes[0] & 240) >> 4, (v1Bytes[0] & 15) << 4 | (v1Bytes[1] & 240) >> 4, (v1Bytes[1] & 15) << 4 | (v1Bytes[2] & 240) >> 4, 96 | v1Bytes[2] & 15, v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
// ../../common/node_modules/uuid/dist/cjs/md5.js
|
|
466
|
+
var require_md5 = __commonJS({
|
|
467
|
+
"../../common/node_modules/uuid/dist/cjs/md5.js"(exports2) {
|
|
468
|
+
"use strict";
|
|
469
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
470
|
+
var crypto_1 = require("crypto");
|
|
471
|
+
function md5(bytes) {
|
|
472
|
+
if (Array.isArray(bytes)) {
|
|
473
|
+
bytes = Buffer.from(bytes);
|
|
474
|
+
} else if (typeof bytes === "string") {
|
|
475
|
+
bytes = Buffer.from(bytes, "utf8");
|
|
476
|
+
}
|
|
477
|
+
return (0, crypto_1.createHash)("md5").update(bytes).digest();
|
|
478
|
+
}
|
|
479
|
+
exports2.default = md5;
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
// ../../common/node_modules/uuid/dist/cjs/v35.js
|
|
484
|
+
var require_v35 = __commonJS({
|
|
485
|
+
"../../common/node_modules/uuid/dist/cjs/v35.js"(exports2) {
|
|
486
|
+
"use strict";
|
|
487
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
488
|
+
exports2.URL = exports2.DNS = exports2.stringToBytes = void 0;
|
|
489
|
+
var parse_js_1 = require_parse();
|
|
490
|
+
var stringify_js_1 = require_stringify();
|
|
491
|
+
function stringToBytes(str) {
|
|
492
|
+
str = unescape(encodeURIComponent(str));
|
|
493
|
+
const bytes = new Uint8Array(str.length);
|
|
494
|
+
for (let i = 0; i < str.length; ++i) {
|
|
495
|
+
bytes[i] = str.charCodeAt(i);
|
|
496
|
+
}
|
|
497
|
+
return bytes;
|
|
498
|
+
}
|
|
499
|
+
exports2.stringToBytes = stringToBytes;
|
|
500
|
+
exports2.DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
501
|
+
exports2.URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
502
|
+
function v35(version, hash, value, namespace, buf, offset) {
|
|
503
|
+
const valueBytes = typeof value === "string" ? stringToBytes(value) : value;
|
|
504
|
+
const namespaceBytes = typeof namespace === "string" ? (0, parse_js_1.default)(namespace) : namespace;
|
|
505
|
+
if (typeof namespace === "string") {
|
|
506
|
+
namespace = (0, parse_js_1.default)(namespace);
|
|
507
|
+
}
|
|
508
|
+
if (namespace?.length !== 16) {
|
|
509
|
+
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
|
|
510
|
+
}
|
|
511
|
+
let bytes = new Uint8Array(16 + valueBytes.length);
|
|
512
|
+
bytes.set(namespaceBytes);
|
|
513
|
+
bytes.set(valueBytes, namespaceBytes.length);
|
|
514
|
+
bytes = hash(bytes);
|
|
515
|
+
bytes[6] = bytes[6] & 15 | version;
|
|
516
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
517
|
+
if (buf) {
|
|
518
|
+
offset = offset || 0;
|
|
519
|
+
for (let i = 0; i < 16; ++i) {
|
|
520
|
+
buf[offset + i] = bytes[i];
|
|
521
|
+
}
|
|
522
|
+
return buf;
|
|
523
|
+
}
|
|
524
|
+
return (0, stringify_js_1.unsafeStringify)(bytes);
|
|
525
|
+
}
|
|
526
|
+
exports2.default = v35;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
// ../../common/node_modules/uuid/dist/cjs/v3.js
|
|
531
|
+
var require_v3 = __commonJS({
|
|
532
|
+
"../../common/node_modules/uuid/dist/cjs/v3.js"(exports2) {
|
|
533
|
+
"use strict";
|
|
534
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
535
|
+
exports2.URL = exports2.DNS = void 0;
|
|
536
|
+
var md5_js_1 = require_md5();
|
|
537
|
+
var v35_js_1 = require_v35();
|
|
538
|
+
var v35_js_2 = require_v35();
|
|
539
|
+
Object.defineProperty(exports2, "DNS", { enumerable: true, get: function() {
|
|
540
|
+
return v35_js_2.DNS;
|
|
541
|
+
} });
|
|
542
|
+
Object.defineProperty(exports2, "URL", { enumerable: true, get: function() {
|
|
543
|
+
return v35_js_2.URL;
|
|
544
|
+
} });
|
|
545
|
+
function v3(value, namespace, buf, offset) {
|
|
546
|
+
return (0, v35_js_1.default)(48, md5_js_1.default, value, namespace, buf, offset);
|
|
547
|
+
}
|
|
548
|
+
v3.DNS = v35_js_1.DNS;
|
|
549
|
+
v3.URL = v35_js_1.URL;
|
|
550
|
+
exports2.default = v3;
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
// ../../common/node_modules/uuid/dist/cjs/native.js
|
|
555
|
+
var require_native = __commonJS({
|
|
556
|
+
"../../common/node_modules/uuid/dist/cjs/native.js"(exports2) {
|
|
557
|
+
"use strict";
|
|
558
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
559
|
+
var crypto_1 = require("crypto");
|
|
560
|
+
exports2.default = { randomUUID: crypto_1.randomUUID };
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
// ../../common/node_modules/uuid/dist/cjs/v4.js
|
|
565
|
+
var require_v4 = __commonJS({
|
|
566
|
+
"../../common/node_modules/uuid/dist/cjs/v4.js"(exports2) {
|
|
567
|
+
"use strict";
|
|
568
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
569
|
+
var native_js_1 = require_native();
|
|
570
|
+
var rng_js_1 = require_rng();
|
|
571
|
+
var stringify_js_1 = require_stringify();
|
|
572
|
+
function v4(options, buf, offset) {
|
|
573
|
+
if (native_js_1.default.randomUUID && !buf && !options) {
|
|
574
|
+
return native_js_1.default.randomUUID();
|
|
575
|
+
}
|
|
576
|
+
options = options || {};
|
|
577
|
+
const rnds = options.random ?? options.rng?.() ?? (0, rng_js_1.default)();
|
|
578
|
+
if (rnds.length < 16) {
|
|
579
|
+
throw new Error("Random bytes length must be >= 16");
|
|
580
|
+
}
|
|
581
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
582
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
583
|
+
if (buf) {
|
|
584
|
+
offset = offset || 0;
|
|
585
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
586
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
587
|
+
}
|
|
588
|
+
for (let i = 0; i < 16; ++i) {
|
|
589
|
+
buf[offset + i] = rnds[i];
|
|
590
|
+
}
|
|
591
|
+
return buf;
|
|
592
|
+
}
|
|
593
|
+
return (0, stringify_js_1.unsafeStringify)(rnds);
|
|
594
|
+
}
|
|
595
|
+
exports2.default = v4;
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
// ../../common/node_modules/uuid/dist/cjs/sha1.js
|
|
600
|
+
var require_sha1 = __commonJS({
|
|
601
|
+
"../../common/node_modules/uuid/dist/cjs/sha1.js"(exports2) {
|
|
602
|
+
"use strict";
|
|
603
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
604
|
+
var crypto_1 = require("crypto");
|
|
605
|
+
function sha1(bytes) {
|
|
606
|
+
if (Array.isArray(bytes)) {
|
|
607
|
+
bytes = Buffer.from(bytes);
|
|
608
|
+
} else if (typeof bytes === "string") {
|
|
609
|
+
bytes = Buffer.from(bytes, "utf8");
|
|
610
|
+
}
|
|
611
|
+
return (0, crypto_1.createHash)("sha1").update(bytes).digest();
|
|
612
|
+
}
|
|
613
|
+
exports2.default = sha1;
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
// ../../common/node_modules/uuid/dist/cjs/v5.js
|
|
618
|
+
var require_v5 = __commonJS({
|
|
619
|
+
"../../common/node_modules/uuid/dist/cjs/v5.js"(exports2) {
|
|
620
|
+
"use strict";
|
|
621
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
622
|
+
exports2.URL = exports2.DNS = void 0;
|
|
623
|
+
var sha1_js_1 = require_sha1();
|
|
624
|
+
var v35_js_1 = require_v35();
|
|
625
|
+
var v35_js_2 = require_v35();
|
|
626
|
+
Object.defineProperty(exports2, "DNS", { enumerable: true, get: function() {
|
|
627
|
+
return v35_js_2.DNS;
|
|
628
|
+
} });
|
|
629
|
+
Object.defineProperty(exports2, "URL", { enumerable: true, get: function() {
|
|
630
|
+
return v35_js_2.URL;
|
|
631
|
+
} });
|
|
632
|
+
function v5(value, namespace, buf, offset) {
|
|
633
|
+
return (0, v35_js_1.default)(80, sha1_js_1.default, value, namespace, buf, offset);
|
|
634
|
+
}
|
|
635
|
+
v5.DNS = v35_js_1.DNS;
|
|
636
|
+
v5.URL = v35_js_1.URL;
|
|
637
|
+
exports2.default = v5;
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
// ../../common/node_modules/uuid/dist/cjs/v6.js
|
|
642
|
+
var require_v6 = __commonJS({
|
|
643
|
+
"../../common/node_modules/uuid/dist/cjs/v6.js"(exports2) {
|
|
644
|
+
"use strict";
|
|
645
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
646
|
+
var stringify_js_1 = require_stringify();
|
|
647
|
+
var v1_js_1 = require_v1();
|
|
648
|
+
var v1ToV6_js_1 = require_v1ToV6();
|
|
649
|
+
function v6(options, buf, offset) {
|
|
650
|
+
options ??= {};
|
|
651
|
+
offset ??= 0;
|
|
652
|
+
let bytes = (0, v1_js_1.default)({ ...options, _v6: true }, new Uint8Array(16));
|
|
653
|
+
bytes = (0, v1ToV6_js_1.default)(bytes);
|
|
654
|
+
if (buf) {
|
|
655
|
+
for (let i = 0; i < 16; i++) {
|
|
656
|
+
buf[offset + i] = bytes[i];
|
|
657
|
+
}
|
|
658
|
+
return buf;
|
|
659
|
+
}
|
|
660
|
+
return (0, stringify_js_1.unsafeStringify)(bytes);
|
|
661
|
+
}
|
|
662
|
+
exports2.default = v6;
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
// ../../common/node_modules/uuid/dist/cjs/v6ToV1.js
|
|
667
|
+
var require_v6ToV1 = __commonJS({
|
|
668
|
+
"../../common/node_modules/uuid/dist/cjs/v6ToV1.js"(exports2) {
|
|
669
|
+
"use strict";
|
|
670
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
671
|
+
var parse_js_1 = require_parse();
|
|
672
|
+
var stringify_js_1 = require_stringify();
|
|
673
|
+
function v6ToV1(uuid) {
|
|
674
|
+
const v6Bytes = typeof uuid === "string" ? (0, parse_js_1.default)(uuid) : uuid;
|
|
675
|
+
const v1Bytes = _v6ToV1(v6Bytes);
|
|
676
|
+
return typeof uuid === "string" ? (0, stringify_js_1.unsafeStringify)(v1Bytes) : v1Bytes;
|
|
677
|
+
}
|
|
678
|
+
exports2.default = v6ToV1;
|
|
679
|
+
function _v6ToV1(v6Bytes) {
|
|
680
|
+
return Uint8Array.of((v6Bytes[3] & 15) << 4 | v6Bytes[4] >> 4 & 15, (v6Bytes[4] & 15) << 4 | (v6Bytes[5] & 240) >> 4, (v6Bytes[5] & 15) << 4 | v6Bytes[6] & 15, v6Bytes[7], (v6Bytes[1] & 15) << 4 | (v6Bytes[2] & 240) >> 4, (v6Bytes[2] & 15) << 4 | (v6Bytes[3] & 240) >> 4, 16 | (v6Bytes[0] & 240) >> 4, (v6Bytes[0] & 15) << 4 | (v6Bytes[1] & 240) >> 4, v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
// ../../common/node_modules/uuid/dist/cjs/v7.js
|
|
686
|
+
var require_v7 = __commonJS({
|
|
687
|
+
"../../common/node_modules/uuid/dist/cjs/v7.js"(exports2) {
|
|
688
|
+
"use strict";
|
|
689
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
690
|
+
exports2.updateV7State = void 0;
|
|
691
|
+
var rng_js_1 = require_rng();
|
|
692
|
+
var stringify_js_1 = require_stringify();
|
|
693
|
+
var _state = {};
|
|
694
|
+
function v7(options, buf, offset) {
|
|
695
|
+
let bytes;
|
|
696
|
+
if (options) {
|
|
697
|
+
bytes = v7Bytes(options.random ?? options.rng?.() ?? (0, rng_js_1.default)(), options.msecs, options.seq, buf, offset);
|
|
698
|
+
} else {
|
|
699
|
+
const now = Date.now();
|
|
700
|
+
const rnds = (0, rng_js_1.default)();
|
|
701
|
+
updateV7State(_state, now, rnds);
|
|
702
|
+
bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
|
|
703
|
+
}
|
|
704
|
+
return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
|
|
705
|
+
}
|
|
706
|
+
function updateV7State(state, now, rnds) {
|
|
707
|
+
state.msecs ??= -Infinity;
|
|
708
|
+
state.seq ??= 0;
|
|
709
|
+
if (now > state.msecs) {
|
|
710
|
+
state.seq = rnds[6] << 23 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
|
711
|
+
state.msecs = now;
|
|
712
|
+
} else {
|
|
713
|
+
state.seq = state.seq + 1 | 0;
|
|
714
|
+
if (state.seq === 0) {
|
|
715
|
+
state.msecs++;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return state;
|
|
719
|
+
}
|
|
720
|
+
exports2.updateV7State = updateV7State;
|
|
721
|
+
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
|
722
|
+
if (rnds.length < 16) {
|
|
723
|
+
throw new Error("Random bytes length must be >= 16");
|
|
724
|
+
}
|
|
725
|
+
if (!buf) {
|
|
726
|
+
buf = new Uint8Array(16);
|
|
727
|
+
offset = 0;
|
|
728
|
+
} else {
|
|
729
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
730
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
msecs ??= Date.now();
|
|
734
|
+
seq ??= rnds[6] * 127 << 24 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
|
735
|
+
buf[offset++] = msecs / 1099511627776 & 255;
|
|
736
|
+
buf[offset++] = msecs / 4294967296 & 255;
|
|
737
|
+
buf[offset++] = msecs / 16777216 & 255;
|
|
738
|
+
buf[offset++] = msecs / 65536 & 255;
|
|
739
|
+
buf[offset++] = msecs / 256 & 255;
|
|
740
|
+
buf[offset++] = msecs & 255;
|
|
741
|
+
buf[offset++] = 112 | seq >>> 28 & 15;
|
|
742
|
+
buf[offset++] = seq >>> 20 & 255;
|
|
743
|
+
buf[offset++] = 128 | seq >>> 14 & 63;
|
|
744
|
+
buf[offset++] = seq >>> 6 & 255;
|
|
745
|
+
buf[offset++] = seq << 2 & 255 | rnds[10] & 3;
|
|
746
|
+
buf[offset++] = rnds[11];
|
|
747
|
+
buf[offset++] = rnds[12];
|
|
748
|
+
buf[offset++] = rnds[13];
|
|
749
|
+
buf[offset++] = rnds[14];
|
|
750
|
+
buf[offset++] = rnds[15];
|
|
751
|
+
return buf;
|
|
752
|
+
}
|
|
753
|
+
exports2.default = v7;
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
// ../../common/node_modules/uuid/dist/cjs/version.js
|
|
758
|
+
var require_version = __commonJS({
|
|
759
|
+
"../../common/node_modules/uuid/dist/cjs/version.js"(exports2) {
|
|
760
|
+
"use strict";
|
|
761
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
762
|
+
var validate_js_1 = require_validate();
|
|
763
|
+
function version(uuid) {
|
|
764
|
+
if (!(0, validate_js_1.default)(uuid)) {
|
|
765
|
+
throw TypeError("Invalid UUID");
|
|
766
|
+
}
|
|
767
|
+
return parseInt(uuid.slice(14, 15), 16);
|
|
768
|
+
}
|
|
769
|
+
exports2.default = version;
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
// ../../common/node_modules/uuid/dist/cjs/index.js
|
|
774
|
+
var require_cjs = __commonJS({
|
|
775
|
+
"../../common/node_modules/uuid/dist/cjs/index.js"(exports2) {
|
|
776
|
+
"use strict";
|
|
777
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
778
|
+
exports2.version = exports2.validate = exports2.v7 = exports2.v6ToV1 = exports2.v6 = exports2.v5 = exports2.v4 = exports2.v3 = exports2.v1ToV6 = exports2.v1 = exports2.stringify = exports2.parse = exports2.NIL = exports2.MAX = void 0;
|
|
779
|
+
var max_js_1 = require_max();
|
|
780
|
+
Object.defineProperty(exports2, "MAX", { enumerable: true, get: function() {
|
|
781
|
+
return max_js_1.default;
|
|
782
|
+
} });
|
|
783
|
+
var nil_js_1 = require_nil();
|
|
784
|
+
Object.defineProperty(exports2, "NIL", { enumerable: true, get: function() {
|
|
785
|
+
return nil_js_1.default;
|
|
786
|
+
} });
|
|
787
|
+
var parse_js_1 = require_parse();
|
|
788
|
+
Object.defineProperty(exports2, "parse", { enumerable: true, get: function() {
|
|
789
|
+
return parse_js_1.default;
|
|
790
|
+
} });
|
|
791
|
+
var stringify_js_1 = require_stringify();
|
|
792
|
+
Object.defineProperty(exports2, "stringify", { enumerable: true, get: function() {
|
|
793
|
+
return stringify_js_1.default;
|
|
794
|
+
} });
|
|
795
|
+
var v1_js_1 = require_v1();
|
|
796
|
+
Object.defineProperty(exports2, "v1", { enumerable: true, get: function() {
|
|
797
|
+
return v1_js_1.default;
|
|
798
|
+
} });
|
|
799
|
+
var v1ToV6_js_1 = require_v1ToV6();
|
|
800
|
+
Object.defineProperty(exports2, "v1ToV6", { enumerable: true, get: function() {
|
|
801
|
+
return v1ToV6_js_1.default;
|
|
802
|
+
} });
|
|
803
|
+
var v3_js_1 = require_v3();
|
|
804
|
+
Object.defineProperty(exports2, "v3", { enumerable: true, get: function() {
|
|
805
|
+
return v3_js_1.default;
|
|
806
|
+
} });
|
|
807
|
+
var v4_js_1 = require_v4();
|
|
808
|
+
Object.defineProperty(exports2, "v4", { enumerable: true, get: function() {
|
|
809
|
+
return v4_js_1.default;
|
|
810
|
+
} });
|
|
811
|
+
var v5_js_1 = require_v5();
|
|
812
|
+
Object.defineProperty(exports2, "v5", { enumerable: true, get: function() {
|
|
813
|
+
return v5_js_1.default;
|
|
814
|
+
} });
|
|
815
|
+
var v6_js_1 = require_v6();
|
|
816
|
+
Object.defineProperty(exports2, "v6", { enumerable: true, get: function() {
|
|
817
|
+
return v6_js_1.default;
|
|
818
|
+
} });
|
|
819
|
+
var v6ToV1_js_1 = require_v6ToV1();
|
|
820
|
+
Object.defineProperty(exports2, "v6ToV1", { enumerable: true, get: function() {
|
|
821
|
+
return v6ToV1_js_1.default;
|
|
822
|
+
} });
|
|
823
|
+
var v7_js_1 = require_v7();
|
|
824
|
+
Object.defineProperty(exports2, "v7", { enumerable: true, get: function() {
|
|
825
|
+
return v7_js_1.default;
|
|
826
|
+
} });
|
|
827
|
+
var validate_js_1 = require_validate();
|
|
828
|
+
Object.defineProperty(exports2, "validate", { enumerable: true, get: function() {
|
|
829
|
+
return validate_js_1.default;
|
|
830
|
+
} });
|
|
831
|
+
var version_js_1 = require_version();
|
|
832
|
+
Object.defineProperty(exports2, "version", { enumerable: true, get: function() {
|
|
833
|
+
return version_js_1.default;
|
|
834
|
+
} });
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
// ../../common/dist/AccessKey.js
|
|
839
|
+
var require_AccessKey = __commonJS({
|
|
840
|
+
"../../common/dist/AccessKey.js"(exports2) {
|
|
841
|
+
"use strict";
|
|
842
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
843
|
+
exports2.AccessKey = void 0;
|
|
844
|
+
exports2.accessKeyBuild = accessKeyBuild;
|
|
845
|
+
exports2.accessKeyCreate = accessKeyCreate;
|
|
846
|
+
exports2.accessKeyDeserialize = accessKeyDeserialize;
|
|
847
|
+
exports2.accessKeySerialize = accessKeySerialize;
|
|
848
|
+
exports2.parseResource = parseResource;
|
|
849
|
+
exports2.parseResources = parseResources;
|
|
850
|
+
exports2.buildResource = buildResource;
|
|
851
|
+
var uuid_1 = require_cjs();
|
|
852
|
+
var AccessKey = class {
|
|
853
|
+
constructor() {
|
|
854
|
+
this.id = "";
|
|
855
|
+
this.type = "volatile";
|
|
856
|
+
this.resources = "";
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
exports2.AccessKey = AccessKey;
|
|
860
|
+
function accessKeyCreate(type, resources) {
|
|
861
|
+
let accessKey = new AccessKey();
|
|
862
|
+
accessKey.id = (0, uuid_1.v4)();
|
|
863
|
+
accessKey.type = type;
|
|
864
|
+
accessKey.resources = resources;
|
|
865
|
+
return accessKey;
|
|
866
|
+
}
|
|
867
|
+
function accessKeyBuild(id, type, resources) {
|
|
868
|
+
let accessKey = new AccessKey();
|
|
869
|
+
accessKey.id = id;
|
|
870
|
+
accessKey.type = type;
|
|
871
|
+
accessKey.resources = resources;
|
|
872
|
+
return accessKey;
|
|
873
|
+
}
|
|
874
|
+
function accessKeySerialize(accessKey) {
|
|
875
|
+
return `${accessKey.id}|${accessKey.type}|${accessKey.resources}`;
|
|
876
|
+
}
|
|
877
|
+
function accessKeyDeserialize(key) {
|
|
878
|
+
var parts = key.split("|");
|
|
879
|
+
return accessKeyBuild(parts[0], parts[1], parts[2]);
|
|
880
|
+
}
|
|
881
|
+
function parseResource(key) {
|
|
882
|
+
var parts = key.split(":");
|
|
883
|
+
return {
|
|
884
|
+
scopes: parts[0],
|
|
885
|
+
namespaces: parts[1],
|
|
886
|
+
groups: parts[2],
|
|
887
|
+
pods: parts[3],
|
|
888
|
+
containers: parts[4]
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
function parseResources(key) {
|
|
892
|
+
if (!key)
|
|
893
|
+
return [];
|
|
894
|
+
let ress = key.split(";");
|
|
895
|
+
let result = [];
|
|
896
|
+
for (var res of ress) {
|
|
897
|
+
result.push(parseResource(res));
|
|
898
|
+
}
|
|
899
|
+
return result;
|
|
900
|
+
}
|
|
901
|
+
function buildResource(scopes, namespaces, groups, pods, containers) {
|
|
902
|
+
return `${scopes.join(",")}:${namespaces.join(",")}:${groups.join(",")}:${pods.join(",")}:${containers.join(",")}`;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
// ../../common/dist/Global.js
|
|
908
|
+
var require_Global = __commonJS({
|
|
909
|
+
"../../common/dist/Global.js"(exports2) {
|
|
910
|
+
"use strict";
|
|
911
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
// ../../common/dist/Version.js
|
|
916
|
+
var require_Version = __commonJS({
|
|
917
|
+
"../../common/dist/Version.js"(exports2) {
|
|
918
|
+
"use strict";
|
|
919
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
920
|
+
exports2.versionGreaterThan = exports2.versionGreatOrEqualThan = void 0;
|
|
921
|
+
var versionGreatOrEqualThan = (version1, version2) => {
|
|
922
|
+
return versionGreaterThan(version1, version2) || version1 === version2;
|
|
923
|
+
};
|
|
924
|
+
exports2.versionGreatOrEqualThan = versionGreatOrEqualThan;
|
|
925
|
+
var versionGreaterThan = (version1, version2) => {
|
|
926
|
+
const v1 = version1.split(".").map(Number);
|
|
927
|
+
const v2 = version2.split(".").map(Number);
|
|
928
|
+
for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
|
|
929
|
+
const num1 = v1[i] || 0;
|
|
930
|
+
const num2 = v2[i] || 0;
|
|
931
|
+
if (num1 > num2)
|
|
932
|
+
return true;
|
|
933
|
+
else if (num1 < num2)
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
return false;
|
|
937
|
+
};
|
|
938
|
+
exports2.versionGreaterThan = versionGreaterThan;
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
// ../../common/dist/FrontChannel.js
|
|
943
|
+
var require_FrontChannel = __commonJS({
|
|
944
|
+
"../../common/dist/FrontChannel.js"(exports2) {
|
|
945
|
+
"use strict";
|
|
946
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
947
|
+
exports2.EChannelRefreshAction = exports2.ENotifyLevel = void 0;
|
|
948
|
+
var ENotifyLevel;
|
|
949
|
+
(function(ENotifyLevel2) {
|
|
950
|
+
ENotifyLevel2["INFO"] = "info";
|
|
951
|
+
ENotifyLevel2["ERROR"] = "error";
|
|
952
|
+
ENotifyLevel2["WARNING"] = "warning";
|
|
953
|
+
ENotifyLevel2["SUCCESS"] = "success";
|
|
954
|
+
})(ENotifyLevel || (exports2.ENotifyLevel = ENotifyLevel = {}));
|
|
955
|
+
var EChannelRefreshAction;
|
|
956
|
+
(function(EChannelRefreshAction2) {
|
|
957
|
+
EChannelRefreshAction2[EChannelRefreshAction2["NONE"] = 0] = "NONE";
|
|
958
|
+
EChannelRefreshAction2[EChannelRefreshAction2["REFRESH"] = 1] = "REFRESH";
|
|
959
|
+
EChannelRefreshAction2[EChannelRefreshAction2["STOP"] = 2] = "STOP";
|
|
960
|
+
})(EChannelRefreshAction || (exports2.EChannelRefreshAction = EChannelRefreshAction = {}));
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
// ../../common/dist/index.js
|
|
965
|
+
var require_dist = __commonJS({
|
|
966
|
+
"../../common/dist/index.js"(exports2) {
|
|
967
|
+
"use strict";
|
|
968
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
969
|
+
if (k2 === void 0) k2 = k;
|
|
970
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
971
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
972
|
+
desc = { enumerable: true, get: function() {
|
|
973
|
+
return m[k];
|
|
974
|
+
} };
|
|
975
|
+
}
|
|
976
|
+
Object.defineProperty(o, k2, desc);
|
|
977
|
+
}) : (function(o, m, k, k2) {
|
|
978
|
+
if (k2 === void 0) k2 = k;
|
|
979
|
+
o[k2] = m[k];
|
|
980
|
+
}));
|
|
981
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
982
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
983
|
+
};
|
|
984
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
985
|
+
__exportStar(require_Channel(), exports2);
|
|
986
|
+
__exportStar(require_InstanceMessage(), exports2);
|
|
987
|
+
__exportStar(require_InstanceConfig(), exports2);
|
|
988
|
+
__exportStar(require_RouteMessage(), exports2);
|
|
989
|
+
__exportStar(require_SignalMessage(), exports2);
|
|
990
|
+
__exportStar(require_ApiKey(), exports2);
|
|
991
|
+
__exportStar(require_AccessKey(), exports2);
|
|
992
|
+
__exportStar(require_Global(), exports2);
|
|
993
|
+
__exportStar(require_Version(), exports2);
|
|
994
|
+
__exportStar(require_FrontChannel(), exports2);
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
|
|
998
|
+
// src/back/index.ts
|
|
999
|
+
var index_exports = {};
|
|
1000
|
+
__export(index_exports, {
|
|
1001
|
+
TopologyChannel: () => TopologyChannel,
|
|
1002
|
+
default: () => index_default
|
|
1003
|
+
});
|
|
1004
|
+
module.exports = __toCommonJS(index_exports);
|
|
1005
|
+
var import_kwirth_common = __toESM(require_dist(), 1);
|
|
1006
|
+
function podStatus(p) {
|
|
1007
|
+
if (p.metadata?.deletionTimestamp) return "Terminating";
|
|
1008
|
+
switch (p.status?.phase) {
|
|
1009
|
+
case "Running":
|
|
1010
|
+
return "Running";
|
|
1011
|
+
case "Pending":
|
|
1012
|
+
return "Pending";
|
|
1013
|
+
case "Succeeded":
|
|
1014
|
+
return "Succeeded";
|
|
1015
|
+
case "Failed":
|
|
1016
|
+
return "Failed";
|
|
1017
|
+
default:
|
|
1018
|
+
return "Unknown";
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
function controllerStatus(ready, desired) {
|
|
1022
|
+
if (desired === void 0 || desired === 0) return "Unknown";
|
|
1023
|
+
if ((ready ?? 0) >= desired) return "Running";
|
|
1024
|
+
if ((ready ?? 0) > 0) return "Pending";
|
|
1025
|
+
return "Failed";
|
|
1026
|
+
}
|
|
1027
|
+
function pvcStatus(p) {
|
|
1028
|
+
switch (p.status?.phase) {
|
|
1029
|
+
case "Bound":
|
|
1030
|
+
return "Bound";
|
|
1031
|
+
case "Pending":
|
|
1032
|
+
return "Pending";
|
|
1033
|
+
case "Released":
|
|
1034
|
+
return "Released";
|
|
1035
|
+
case "Lost":
|
|
1036
|
+
return "Lost";
|
|
1037
|
+
default:
|
|
1038
|
+
return "Unknown";
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
var TopologyChannel = class {
|
|
1042
|
+
constructor(clusterInfo, backChannelObject) {
|
|
1043
|
+
this.channelId = "topology";
|
|
1044
|
+
this.requirements = {
|
|
1045
|
+
storage: false,
|
|
1046
|
+
providers: ["events"]
|
|
1047
|
+
};
|
|
1048
|
+
this.webSockets = [];
|
|
1049
|
+
this.serviceCache = /* @__PURE__ */ new Map();
|
|
1050
|
+
this.pvcCache = /* @__PURE__ */ new Map();
|
|
1051
|
+
this.startChannel = async () => {
|
|
1052
|
+
this.clusterInfo.addSubscriber("events", this, {
|
|
1053
|
+
kinds: ["Pod", "Service", "Deployment", "StatefulSet", "DaemonSet", "ReplicaSet", "Job", "CronJob", "Ingress", "PersistentVolumeClaim"],
|
|
1054
|
+
syncInstances: false
|
|
1055
|
+
});
|
|
1056
|
+
};
|
|
1057
|
+
this.addObject = async (ws, instanceConfig) => {
|
|
1058
|
+
try {
|
|
1059
|
+
let entry = this.webSockets.find((s) => s.ws === ws);
|
|
1060
|
+
if (!entry) {
|
|
1061
|
+
this.webSockets.push({ ws, lastRefresh: Date.now(), instances: [] });
|
|
1062
|
+
entry = this.webSockets[this.webSockets.length - 1];
|
|
1063
|
+
}
|
|
1064
|
+
if (entry.instances.some((i) => i.instanceId === instanceConfig.instance)) return true;
|
|
1065
|
+
const ns = instanceConfig.namespace;
|
|
1066
|
+
const namespaces = ns && ns !== "" && ns !== "*all" ? ns.split(",").filter(Boolean) : ["*all"];
|
|
1067
|
+
const data = instanceConfig.data;
|
|
1068
|
+
const toStrArray = (v) => Array.isArray(v) && v.length > 0 ? v : void 0;
|
|
1069
|
+
const pods = toStrArray(data?.pods);
|
|
1070
|
+
const services = toStrArray(data?.services);
|
|
1071
|
+
const ingresses = toStrArray(data?.ingresses);
|
|
1072
|
+
const groups = toStrArray(data?.groups);
|
|
1073
|
+
const inst = {
|
|
1074
|
+
instanceId: instanceConfig.instance,
|
|
1075
|
+
namespaces,
|
|
1076
|
+
pods,
|
|
1077
|
+
services,
|
|
1078
|
+
ingresses,
|
|
1079
|
+
groups,
|
|
1080
|
+
paused: false
|
|
1081
|
+
};
|
|
1082
|
+
entry.instances.push(inst);
|
|
1083
|
+
await this.sendSnapshot(ws, inst);
|
|
1084
|
+
} catch (err) {
|
|
1085
|
+
this.sendSignal(ws, instanceConfig, import_kwirth_common.ESignalMessageLevel.ERROR, err?.message ?? String(err));
|
|
1086
|
+
}
|
|
1087
|
+
return true;
|
|
1088
|
+
};
|
|
1089
|
+
this.deleteObject = async () => false;
|
|
1090
|
+
this.containsAsset = () => false;
|
|
1091
|
+
this.clusterInfo = clusterInfo;
|
|
1092
|
+
this.backChannelObject = backChannelObject;
|
|
1093
|
+
}
|
|
1094
|
+
getChannelData() {
|
|
1095
|
+
return {
|
|
1096
|
+
id: "topology",
|
|
1097
|
+
routable: false,
|
|
1098
|
+
pauseable: false,
|
|
1099
|
+
modifiable: false,
|
|
1100
|
+
reconnectable: true,
|
|
1101
|
+
metrics: false,
|
|
1102
|
+
sources: [import_kwirth_common.EClusterType.KUBERNETES],
|
|
1103
|
+
endpoints: [],
|
|
1104
|
+
websocket: false,
|
|
1105
|
+
cluster: true,
|
|
1106
|
+
resourced: true
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
getChannelScopeLevel(scope) {
|
|
1110
|
+
return ["", "filter", "view", "cluster"].indexOf(scope);
|
|
1111
|
+
}
|
|
1112
|
+
processProviderEvent(providerId, obj) {
|
|
1113
|
+
if (providerId !== "events") return;
|
|
1114
|
+
const type = obj.type;
|
|
1115
|
+
const resource = obj.obj;
|
|
1116
|
+
if (resource.kind === "Service") {
|
|
1117
|
+
if (type === "DELETED") this.serviceCache.delete(resource.metadata?.uid ?? "");
|
|
1118
|
+
else if (resource.metadata?.uid) this.serviceCache.set(resource.metadata.uid, resource);
|
|
1119
|
+
}
|
|
1120
|
+
if (resource.kind === "PersistentVolumeClaim") {
|
|
1121
|
+
if (type === "DELETED") this.pvcCache.delete(resource.metadata?.uid ?? "");
|
|
1122
|
+
else if (resource.metadata?.uid) this.pvcCache.set(resource.metadata.uid, resource);
|
|
1123
|
+
}
|
|
1124
|
+
const mapped = this.mapResource(resource);
|
|
1125
|
+
if (!mapped) return;
|
|
1126
|
+
if (type !== "DELETED") {
|
|
1127
|
+
const svcList = Array.from(this.serviceCache.values());
|
|
1128
|
+
const edges = this.computeEdges(resource, svcList);
|
|
1129
|
+
if (edges.length > 0) mapped.edges = edges;
|
|
1130
|
+
}
|
|
1131
|
+
for (const entry of this.webSockets) {
|
|
1132
|
+
for (const inst of entry.instances) {
|
|
1133
|
+
if (inst.paused) continue;
|
|
1134
|
+
const ns = resource.metadata?.namespace;
|
|
1135
|
+
if (!inst.namespaces.includes("*all") && ns && !inst.namespaces.includes(ns)) continue;
|
|
1136
|
+
if (inst.focusedUids && !inst.focusedUids.has(resource.metadata?.uid ?? "")) continue;
|
|
1137
|
+
this.emit(entry.ws, inst, mapped, type);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
async endpointRequest(_e, _req, _res) {
|
|
1142
|
+
}
|
|
1143
|
+
async websocketRequest(_ws) {
|
|
1144
|
+
}
|
|
1145
|
+
async processCommand(ws, msg) {
|
|
1146
|
+
const m = msg;
|
|
1147
|
+
try {
|
|
1148
|
+
switch (m.topoAction) {
|
|
1149
|
+
case "SCALE":
|
|
1150
|
+
await this.doScale(ws, msg, m.kind, m.namespace, m.name, m.replicas ?? 0);
|
|
1151
|
+
return true;
|
|
1152
|
+
case "RESTART":
|
|
1153
|
+
await this.doRestart(ws, msg, m.kind, m.namespace, m.name);
|
|
1154
|
+
return true;
|
|
1155
|
+
case "DELETE_POD":
|
|
1156
|
+
await this.clusterInfo.coreApi.deleteNamespacedPod({ name: m.name, namespace: m.namespace });
|
|
1157
|
+
this.sendSignal(ws, msg, import_kwirth_common.ESignalMessageLevel.INFO, `Pod ${m.name} deleted`);
|
|
1158
|
+
return true;
|
|
1159
|
+
default:
|
|
1160
|
+
return false;
|
|
1161
|
+
}
|
|
1162
|
+
} catch (err) {
|
|
1163
|
+
this.sendSignal(ws, msg, import_kwirth_common.ESignalMessageLevel.ERROR, err?.message ?? String(err));
|
|
1164
|
+
return false;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
containsInstance(instanceId) {
|
|
1168
|
+
return this.webSockets.some((s) => s.instances.some((i) => i.instanceId === instanceId));
|
|
1169
|
+
}
|
|
1170
|
+
containsConnection(ws) {
|
|
1171
|
+
return this.webSockets.some((s) => s.ws === ws);
|
|
1172
|
+
}
|
|
1173
|
+
removeConnection(ws) {
|
|
1174
|
+
this.webSockets = this.webSockets.filter((s) => s.ws !== ws);
|
|
1175
|
+
}
|
|
1176
|
+
refreshConnection(ws) {
|
|
1177
|
+
const entry = this.webSockets.find((s) => s.ws === ws);
|
|
1178
|
+
if (entry) {
|
|
1179
|
+
entry.lastRefresh = Date.now();
|
|
1180
|
+
return true;
|
|
1181
|
+
}
|
|
1182
|
+
return false;
|
|
1183
|
+
}
|
|
1184
|
+
updateConnection(ws, instanceId) {
|
|
1185
|
+
return this.webSockets.some((s) => s.ws === ws && s.instances.some((i) => i.instanceId === instanceId));
|
|
1186
|
+
}
|
|
1187
|
+
pauseContinueInstance(ws, instanceConfig, action) {
|
|
1188
|
+
const inst = this.findInstance(ws, instanceConfig.instance);
|
|
1189
|
+
if (!inst) return;
|
|
1190
|
+
inst.paused = action === import_kwirth_common.EInstanceMessageAction.PAUSE;
|
|
1191
|
+
this.sendInstanceConfig(
|
|
1192
|
+
ws,
|
|
1193
|
+
action,
|
|
1194
|
+
import_kwirth_common.EInstanceMessageFlow.RESPONSE,
|
|
1195
|
+
instanceConfig,
|
|
1196
|
+
inst.paused ? "Topology paused" : "Topology resumed"
|
|
1197
|
+
);
|
|
1198
|
+
}
|
|
1199
|
+
modifyInstance() {
|
|
1200
|
+
}
|
|
1201
|
+
stopInstance(ws, instanceConfig) {
|
|
1202
|
+
const entry = this.webSockets.find((s) => s.ws === ws);
|
|
1203
|
+
if (!entry) return;
|
|
1204
|
+
entry.instances = entry.instances.filter((i) => i.instanceId !== instanceConfig.instance);
|
|
1205
|
+
this.sendInstanceConfig(ws, import_kwirth_common.EInstanceMessageAction.STOP, import_kwirth_common.EInstanceMessageFlow.RESPONSE, instanceConfig, "Topology stopped");
|
|
1206
|
+
}
|
|
1207
|
+
removeInstance(ws, instanceId) {
|
|
1208
|
+
const entry = this.webSockets.find((s) => s.ws === ws);
|
|
1209
|
+
if (!entry) return;
|
|
1210
|
+
entry.instances = entry.instances.filter((i) => i.instanceId !== instanceId);
|
|
1211
|
+
}
|
|
1212
|
+
nsMatch(inst, ns) {
|
|
1213
|
+
return inst.namespaces.includes("*all") || !!ns && inst.namespaces.includes(ns);
|
|
1214
|
+
}
|
|
1215
|
+
async sendSnapshot(ws, inst) {
|
|
1216
|
+
const isFocused = !!(inst.pods?.length || inst.services?.length || inst.ingresses?.length || inst.groups?.length);
|
|
1217
|
+
if (isFocused) {
|
|
1218
|
+
await this.sendFocusedSnapshot(ws, inst);
|
|
1219
|
+
} else {
|
|
1220
|
+
await this.sendFullSnapshot(ws, inst);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
async sendFullSnapshot(ws, inst) {
|
|
1224
|
+
const [pods, svcs, deps, sts, ds, rs, jobs, crons, ings, pvcs] = await Promise.allSettled([
|
|
1225
|
+
this.clusterInfo.coreApi.listPodForAllNamespaces(),
|
|
1226
|
+
this.clusterInfo.coreApi.listServiceForAllNamespaces(),
|
|
1227
|
+
this.clusterInfo.appsApi.listDeploymentForAllNamespaces(),
|
|
1228
|
+
this.clusterInfo.appsApi.listStatefulSetForAllNamespaces(),
|
|
1229
|
+
this.clusterInfo.appsApi.listDaemonSetForAllNamespaces(),
|
|
1230
|
+
this.clusterInfo.appsApi.listReplicaSetForAllNamespaces(),
|
|
1231
|
+
this.clusterInfo.batchApi.listJobForAllNamespaces(),
|
|
1232
|
+
this.clusterInfo.batchApi.listCronJobForAllNamespaces(),
|
|
1233
|
+
this.clusterInfo.networkApi.listIngressForAllNamespaces(),
|
|
1234
|
+
this.clusterInfo.coreApi.listPersistentVolumeClaimForAllNamespaces()
|
|
1235
|
+
]);
|
|
1236
|
+
const svcList = svcs.status === "fulfilled" ? svcs.value.items.filter((s) => this.nsMatch(inst, s.metadata?.namespace)) : [];
|
|
1237
|
+
const pvcList = pvcs.status === "fulfilled" ? pvcs.value.items.filter((p) => this.nsMatch(inst, p.metadata?.namespace)) : [];
|
|
1238
|
+
svcList.forEach((s) => {
|
|
1239
|
+
if (s.metadata?.uid) this.serviceCache.set(s.metadata.uid, s);
|
|
1240
|
+
});
|
|
1241
|
+
pvcList.forEach((p) => {
|
|
1242
|
+
if (p.metadata?.uid) this.pvcCache.set(p.metadata.uid, p);
|
|
1243
|
+
});
|
|
1244
|
+
svcList.forEach((s) => this.emit(ws, inst, this.mapService(s), "ADDED"));
|
|
1245
|
+
if (deps.status === "fulfilled") deps.value.items.filter((d) => this.nsMatch(inst, d.metadata?.namespace)).forEach((d) => this.emit(ws, inst, { ...this.mapDeployment(d), edges: this.edgesForController(d.spec?.selector?.matchLabels, d.metadata?.namespace, svcList) }, "ADDED"));
|
|
1246
|
+
if (sts.status === "fulfilled") sts.value.items.filter((s) => this.nsMatch(inst, s.metadata?.namespace)).forEach((s) => this.emit(ws, inst, { ...this.mapStatefulSet(s), edges: this.edgesForController(s.spec?.selector?.matchLabels, s.metadata?.namespace, svcList) }, "ADDED"));
|
|
1247
|
+
if (ds.status === "fulfilled") ds.value.items.filter((d) => this.nsMatch(inst, d.metadata?.namespace)).forEach((d) => this.emit(ws, inst, { ...this.mapDaemonSet(d), edges: this.edgesForController(d.spec?.selector?.matchLabels, d.metadata?.namespace, svcList) }, "ADDED"));
|
|
1248
|
+
if (rs.status === "fulfilled") rs.value.items.filter((r) => this.nsMatch(inst, r.metadata?.namespace)).forEach((r) => this.emit(ws, inst, this.mapReplicaSet(r), "ADDED"));
|
|
1249
|
+
if (jobs.status === "fulfilled") jobs.value.items.filter((j) => this.nsMatch(inst, j.metadata?.namespace)).forEach((j) => this.emit(ws, inst, this.mapJob(j), "ADDED"));
|
|
1250
|
+
if (crons.status === "fulfilled") crons.value.items.filter((c) => this.nsMatch(inst, c.metadata?.namespace)).forEach((c) => this.emit(ws, inst, this.mapCronJob(c), "ADDED"));
|
|
1251
|
+
if (ings.status === "fulfilled") ings.value.items.filter((i) => this.nsMatch(inst, i.metadata?.namespace)).forEach((i) => this.emit(ws, inst, { ...this.mapIngress(i), edges: this.edgesForIngress(i, svcList) }, "ADDED"));
|
|
1252
|
+
if (pods.status === "fulfilled") pods.value.items.filter((p) => this.nsMatch(inst, p.metadata?.namespace)).forEach((p) => this.emit(ws, inst, this.mapPod(p), "ADDED"));
|
|
1253
|
+
pvcList.forEach((p) => this.emit(ws, inst, this.mapPvc(p), "ADDED"));
|
|
1254
|
+
}
|
|
1255
|
+
async sendFocusedSnapshot(ws, inst) {
|
|
1256
|
+
const [pods, svcs, deps, sts, ds, rs, jobs, crons, ings, pvcs] = await Promise.allSettled([
|
|
1257
|
+
this.clusterInfo.coreApi.listPodForAllNamespaces(),
|
|
1258
|
+
this.clusterInfo.coreApi.listServiceForAllNamespaces(),
|
|
1259
|
+
this.clusterInfo.appsApi.listDeploymentForAllNamespaces(),
|
|
1260
|
+
this.clusterInfo.appsApi.listStatefulSetForAllNamespaces(),
|
|
1261
|
+
this.clusterInfo.appsApi.listDaemonSetForAllNamespaces(),
|
|
1262
|
+
this.clusterInfo.appsApi.listReplicaSetForAllNamespaces(),
|
|
1263
|
+
this.clusterInfo.batchApi.listJobForAllNamespaces(),
|
|
1264
|
+
this.clusterInfo.batchApi.listCronJobForAllNamespaces(),
|
|
1265
|
+
this.clusterInfo.networkApi.listIngressForAllNamespaces(),
|
|
1266
|
+
this.clusterInfo.coreApi.listPersistentVolumeClaimForAllNamespaces()
|
|
1267
|
+
]);
|
|
1268
|
+
const ctx = {
|
|
1269
|
+
allPods: pods.status === "fulfilled" ? pods.value.items.filter((p) => this.nsMatch(inst, p.metadata?.namespace)) : [],
|
|
1270
|
+
allSvcs: svcs.status === "fulfilled" ? svcs.value.items.filter((s) => this.nsMatch(inst, s.metadata?.namespace)) : [],
|
|
1271
|
+
allDeps: deps.status === "fulfilled" ? deps.value.items.filter((d) => this.nsMatch(inst, d.metadata?.namespace)) : [],
|
|
1272
|
+
allSts: sts.status === "fulfilled" ? sts.value.items.filter((s) => this.nsMatch(inst, s.metadata?.namespace)) : [],
|
|
1273
|
+
allDs: ds.status === "fulfilled" ? ds.value.items.filter((d) => this.nsMatch(inst, d.metadata?.namespace)) : [],
|
|
1274
|
+
allRs: rs.status === "fulfilled" ? rs.value.items.filter((r) => this.nsMatch(inst, r.metadata?.namespace)) : [],
|
|
1275
|
+
allJobs: jobs.status === "fulfilled" ? jobs.value.items.filter((j) => this.nsMatch(inst, j.metadata?.namespace)) : [],
|
|
1276
|
+
allCrons: crons.status === "fulfilled" ? crons.value.items.filter((c) => this.nsMatch(inst, c.metadata?.namespace)) : [],
|
|
1277
|
+
allIngs: ings.status === "fulfilled" ? ings.value.items.filter((i) => this.nsMatch(inst, i.metadata?.namespace)) : [],
|
|
1278
|
+
allPvcs: pvcs.status === "fulfilled" ? pvcs.value.items.filter((p) => this.nsMatch(inst, p.metadata?.namespace)) : [],
|
|
1279
|
+
included: /* @__PURE__ */ new Set()
|
|
1280
|
+
};
|
|
1281
|
+
ctx.allSvcs.forEach((s) => {
|
|
1282
|
+
if (s.metadata?.uid) this.serviceCache.set(s.metadata.uid, s);
|
|
1283
|
+
});
|
|
1284
|
+
ctx.allPvcs.forEach((p) => {
|
|
1285
|
+
if (p.metadata?.uid) this.pvcCache.set(p.metadata.uid, p);
|
|
1286
|
+
});
|
|
1287
|
+
for (const name of inst.pods ?? []) {
|
|
1288
|
+
const pod = ctx.allPods.find((p) => p.metadata?.name === name);
|
|
1289
|
+
if (pod) this.addPodChain(pod, ctx);
|
|
1290
|
+
}
|
|
1291
|
+
for (const name of inst.services ?? []) {
|
|
1292
|
+
const svc = ctx.allSvcs.find((s) => s.metadata?.name === name);
|
|
1293
|
+
if (svc) this.addServiceChain(svc, ctx);
|
|
1294
|
+
}
|
|
1295
|
+
for (const name of inst.ingresses ?? []) {
|
|
1296
|
+
const ing = ctx.allIngs.find((i) => i.metadata?.name === name);
|
|
1297
|
+
if (ing) this.addIngressChain(ing, ctx);
|
|
1298
|
+
}
|
|
1299
|
+
for (const groupStr of inst.groups ?? []) {
|
|
1300
|
+
const sep = groupStr.indexOf("/");
|
|
1301
|
+
if (sep > 0) this.addGroupChain(groupStr.substring(0, sep), groupStr.substring(sep + 1), ctx);
|
|
1302
|
+
}
|
|
1303
|
+
inst.focusedUids = ctx.included;
|
|
1304
|
+
const inc = ctx.included;
|
|
1305
|
+
ctx.allSvcs.filter((s) => inc.has(s.metadata?.uid ?? "")).forEach((s) => this.emit(ws, inst, this.mapService(s), "ADDED"));
|
|
1306
|
+
ctx.allDeps.filter((d) => inc.has(d.metadata?.uid ?? "")).forEach((d) => this.emit(ws, inst, { ...this.mapDeployment(d), edges: this.edgesForController(d.spec?.selector?.matchLabels, d.metadata?.namespace, ctx.allSvcs) }, "ADDED"));
|
|
1307
|
+
ctx.allSts.filter((s) => inc.has(s.metadata?.uid ?? "")).forEach((s) => this.emit(ws, inst, { ...this.mapStatefulSet(s), edges: this.edgesForController(s.spec?.selector?.matchLabels, s.metadata?.namespace, ctx.allSvcs) }, "ADDED"));
|
|
1308
|
+
ctx.allDs.filter((d) => inc.has(d.metadata?.uid ?? "")).forEach((d) => this.emit(ws, inst, { ...this.mapDaemonSet(d), edges: this.edgesForController(d.spec?.selector?.matchLabels, d.metadata?.namespace, ctx.allSvcs) }, "ADDED"));
|
|
1309
|
+
ctx.allRs.filter((r) => inc.has(r.metadata?.uid ?? "")).forEach((r) => this.emit(ws, inst, this.mapReplicaSet(r), "ADDED"));
|
|
1310
|
+
ctx.allJobs.filter((j) => inc.has(j.metadata?.uid ?? "")).forEach((j) => this.emit(ws, inst, this.mapJob(j), "ADDED"));
|
|
1311
|
+
ctx.allCrons.filter((c) => inc.has(c.metadata?.uid ?? "")).forEach((c) => this.emit(ws, inst, this.mapCronJob(c), "ADDED"));
|
|
1312
|
+
ctx.allIngs.filter((i) => inc.has(i.metadata?.uid ?? "")).forEach((i) => this.emit(ws, inst, { ...this.mapIngress(i), edges: this.edgesForIngress(i, ctx.allSvcs) }, "ADDED"));
|
|
1313
|
+
ctx.allPods.filter((p) => inc.has(p.metadata?.uid ?? "")).forEach((p) => this.emit(ws, inst, this.mapPod(p), "ADDED"));
|
|
1314
|
+
ctx.allPvcs.filter((p) => inc.has(p.metadata?.uid ?? "")).forEach((p) => this.emit(ws, inst, this.mapPvc(p), "ADDED"));
|
|
1315
|
+
}
|
|
1316
|
+
addPodChain(pod, ctx) {
|
|
1317
|
+
const uid = pod.metadata?.uid ?? "";
|
|
1318
|
+
if (ctx.included.has(uid)) return;
|
|
1319
|
+
ctx.included.add(uid);
|
|
1320
|
+
const podNs = pod.metadata?.namespace;
|
|
1321
|
+
for (const vol of pod.spec?.volumes ?? []) {
|
|
1322
|
+
const claimName = vol.persistentVolumeClaim?.claimName;
|
|
1323
|
+
if (!claimName) continue;
|
|
1324
|
+
const pvc = ctx.allPvcs.find((p) => p.metadata?.name === claimName && p.metadata?.namespace === podNs);
|
|
1325
|
+
if (pvc?.metadata?.uid) ctx.included.add(pvc.metadata.uid);
|
|
1326
|
+
}
|
|
1327
|
+
for (const ownerRef of pod.metadata?.ownerReferences ?? []) {
|
|
1328
|
+
if (ownerRef.kind === "ReplicaSet") {
|
|
1329
|
+
const rs = ctx.allRs.find((r) => r.metadata?.uid === ownerRef.uid);
|
|
1330
|
+
if (rs) {
|
|
1331
|
+
ctx.included.add(rs.metadata?.uid ?? "");
|
|
1332
|
+
for (const rsOwner of rs.metadata?.ownerReferences ?? []) {
|
|
1333
|
+
if (rsOwner.kind === "Deployment") {
|
|
1334
|
+
const dep = ctx.allDeps.find((d) => d.metadata?.uid === rsOwner.uid);
|
|
1335
|
+
if (dep?.metadata?.uid) ctx.included.add(dep.metadata.uid);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
} else if (ownerRef.kind === "StatefulSet") {
|
|
1340
|
+
const sts = ctx.allSts.find((s) => s.metadata?.uid === ownerRef.uid);
|
|
1341
|
+
if (sts?.metadata?.uid) ctx.included.add(sts.metadata.uid);
|
|
1342
|
+
} else if (ownerRef.kind === "DaemonSet") {
|
|
1343
|
+
const ds = ctx.allDs.find((d) => d.metadata?.uid === ownerRef.uid);
|
|
1344
|
+
if (ds?.metadata?.uid) ctx.included.add(ds.metadata.uid);
|
|
1345
|
+
} else if (ownerRef.kind === "Job") {
|
|
1346
|
+
const job = ctx.allJobs.find((j) => j.metadata?.uid === ownerRef.uid);
|
|
1347
|
+
if (job) {
|
|
1348
|
+
ctx.included.add(job.metadata?.uid ?? "");
|
|
1349
|
+
for (const jobOwner of job.metadata?.ownerReferences ?? []) {
|
|
1350
|
+
if (jobOwner.kind === "CronJob") {
|
|
1351
|
+
const cron = ctx.allCrons.find((c) => c.metadata?.uid === jobOwner.uid);
|
|
1352
|
+
if (cron?.metadata?.uid) ctx.included.add(cron.metadata.uid);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
const podLabels = pod.metadata?.labels ?? {};
|
|
1359
|
+
for (const svc of ctx.allSvcs) {
|
|
1360
|
+
if (svc.metadata?.namespace !== podNs) continue;
|
|
1361
|
+
const sel = svc.spec?.selector ?? {};
|
|
1362
|
+
if (Object.keys(sel).length > 0 && Object.entries(sel).every(([k, v]) => podLabels[k] === v)) {
|
|
1363
|
+
ctx.included.add(svc.metadata?.uid ?? "");
|
|
1364
|
+
this.addIngressForService(svc, ctx);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
addIngressForService(svc, ctx) {
|
|
1369
|
+
for (const ing of ctx.allIngs) {
|
|
1370
|
+
if (ing.metadata?.namespace !== svc.metadata?.namespace) continue;
|
|
1371
|
+
for (const rule of ing.spec?.rules ?? []) {
|
|
1372
|
+
for (const path of rule.http?.paths ?? []) {
|
|
1373
|
+
if (path.backend?.service?.name === svc.metadata?.name) {
|
|
1374
|
+
ctx.included.add(ing.metadata?.uid ?? "");
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
addServiceChain(svc, ctx) {
|
|
1381
|
+
if (ctx.included.has(svc.metadata?.uid ?? "")) return;
|
|
1382
|
+
ctx.included.add(svc.metadata?.uid ?? "");
|
|
1383
|
+
this.addIngressForService(svc, ctx);
|
|
1384
|
+
const sel = svc.spec?.selector ?? {};
|
|
1385
|
+
if (Object.keys(sel).length === 0) return;
|
|
1386
|
+
const svcNs = svc.metadata?.namespace;
|
|
1387
|
+
for (const pod of ctx.allPods) {
|
|
1388
|
+
if (pod.metadata?.namespace !== svcNs) continue;
|
|
1389
|
+
const podLabels = pod.metadata?.labels ?? {};
|
|
1390
|
+
if (Object.entries(sel).every(([k, v]) => podLabels[k] === v)) {
|
|
1391
|
+
this.addPodChain(pod, ctx);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
addIngressChain(ing, ctx) {
|
|
1396
|
+
if (ctx.included.has(ing.metadata?.uid ?? "")) return;
|
|
1397
|
+
ctx.included.add(ing.metadata?.uid ?? "");
|
|
1398
|
+
const ingNs = ing.metadata?.namespace;
|
|
1399
|
+
for (const rule of ing.spec?.rules ?? []) {
|
|
1400
|
+
for (const path of rule.http?.paths ?? []) {
|
|
1401
|
+
const svcName = path.backend?.service?.name;
|
|
1402
|
+
const svc = ctx.allSvcs.find((s) => s.metadata?.namespace === ingNs && s.metadata?.name === svcName);
|
|
1403
|
+
if (svc) this.addServiceChain(svc, ctx);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
addGroupChain(kind, name, ctx) {
|
|
1408
|
+
switch (kind) {
|
|
1409
|
+
case "Deployment": {
|
|
1410
|
+
const dep = ctx.allDeps.find((d) => d.metadata?.name === name);
|
|
1411
|
+
if (!dep?.metadata?.uid) return;
|
|
1412
|
+
ctx.included.add(dep.metadata.uid);
|
|
1413
|
+
for (const rs of ctx.allRs) {
|
|
1414
|
+
if (!rs.metadata?.ownerReferences?.some((r) => r.uid === dep.metadata?.uid)) continue;
|
|
1415
|
+
ctx.included.add(rs.metadata?.uid ?? "");
|
|
1416
|
+
ctx.allPods.filter((p) => p.metadata?.ownerReferences?.some((r) => r.uid === rs.metadata?.uid)).forEach((p) => this.addPodChain(p, ctx));
|
|
1417
|
+
}
|
|
1418
|
+
break;
|
|
1419
|
+
}
|
|
1420
|
+
case "StatefulSet": {
|
|
1421
|
+
const sts = ctx.allSts.find((s) => s.metadata?.name === name);
|
|
1422
|
+
if (!sts?.metadata?.uid) return;
|
|
1423
|
+
ctx.included.add(sts.metadata.uid);
|
|
1424
|
+
ctx.allPods.filter((p) => p.metadata?.ownerReferences?.some((r) => r.uid === sts.metadata?.uid)).forEach((p) => this.addPodChain(p, ctx));
|
|
1425
|
+
break;
|
|
1426
|
+
}
|
|
1427
|
+
case "DaemonSet": {
|
|
1428
|
+
const ds = ctx.allDs.find((d) => d.metadata?.name === name);
|
|
1429
|
+
if (!ds?.metadata?.uid) return;
|
|
1430
|
+
ctx.included.add(ds.metadata.uid);
|
|
1431
|
+
ctx.allPods.filter((p) => p.metadata?.ownerReferences?.some((r) => r.uid === ds.metadata?.uid)).forEach((p) => this.addPodChain(p, ctx));
|
|
1432
|
+
break;
|
|
1433
|
+
}
|
|
1434
|
+
case "ReplicaSet": {
|
|
1435
|
+
const rs = ctx.allRs.find((r) => r.metadata?.name === name);
|
|
1436
|
+
if (!rs?.metadata?.uid) return;
|
|
1437
|
+
ctx.included.add(rs.metadata.uid);
|
|
1438
|
+
ctx.allPods.filter((p) => p.metadata?.ownerReferences?.some((r) => r.uid === rs.metadata?.uid)).forEach((p) => this.addPodChain(p, ctx));
|
|
1439
|
+
break;
|
|
1440
|
+
}
|
|
1441
|
+
case "Job": {
|
|
1442
|
+
const job = ctx.allJobs.find((j) => j.metadata?.name === name);
|
|
1443
|
+
if (!job?.metadata?.uid) return;
|
|
1444
|
+
ctx.included.add(job.metadata.uid);
|
|
1445
|
+
ctx.allPods.filter((p) => p.metadata?.ownerReferences?.some((r) => r.uid === job.metadata?.uid)).forEach((p) => this.addPodChain(p, ctx));
|
|
1446
|
+
break;
|
|
1447
|
+
}
|
|
1448
|
+
case "CronJob": {
|
|
1449
|
+
const cron = ctx.allCrons.find((c) => c.metadata?.name === name);
|
|
1450
|
+
if (!cron?.metadata?.uid) return;
|
|
1451
|
+
ctx.included.add(cron.metadata.uid);
|
|
1452
|
+
for (const job of ctx.allJobs.filter((j) => j.metadata?.ownerReferences?.some((r) => r.uid === cron.metadata?.uid))) {
|
|
1453
|
+
ctx.included.add(job.metadata?.uid ?? "");
|
|
1454
|
+
ctx.allPods.filter((p) => p.metadata?.ownerReferences?.some((r) => r.uid === job.metadata?.uid)).forEach((p) => this.addPodChain(p, ctx));
|
|
1455
|
+
}
|
|
1456
|
+
break;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
mapResource(resource) {
|
|
1461
|
+
switch (resource.kind) {
|
|
1462
|
+
case "Pod":
|
|
1463
|
+
return this.mapPod(resource);
|
|
1464
|
+
case "Service":
|
|
1465
|
+
return this.mapService(resource);
|
|
1466
|
+
case "Deployment":
|
|
1467
|
+
return this.mapDeployment(resource);
|
|
1468
|
+
case "StatefulSet":
|
|
1469
|
+
return this.mapStatefulSet(resource);
|
|
1470
|
+
case "DaemonSet":
|
|
1471
|
+
return this.mapDaemonSet(resource);
|
|
1472
|
+
case "ReplicaSet":
|
|
1473
|
+
return this.mapReplicaSet(resource);
|
|
1474
|
+
case "Job":
|
|
1475
|
+
return this.mapJob(resource);
|
|
1476
|
+
case "CronJob":
|
|
1477
|
+
return this.mapCronJob(resource);
|
|
1478
|
+
case "Ingress":
|
|
1479
|
+
return this.mapIngress(resource);
|
|
1480
|
+
case "PersistentVolumeClaim":
|
|
1481
|
+
return this.mapPvc(resource);
|
|
1482
|
+
default:
|
|
1483
|
+
return null;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
computeEdges(resource, svcList) {
|
|
1487
|
+
switch (resource.kind) {
|
|
1488
|
+
case "Deployment":
|
|
1489
|
+
case "StatefulSet":
|
|
1490
|
+
case "DaemonSet":
|
|
1491
|
+
return this.edgesForController(resource.spec?.selector?.matchLabels, resource.metadata?.namespace, svcList);
|
|
1492
|
+
case "Ingress":
|
|
1493
|
+
return this.edgesForIngress(resource, svcList);
|
|
1494
|
+
default:
|
|
1495
|
+
return [];
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
mapPod(p) {
|
|
1499
|
+
const ns = p.metadata?.namespace ?? "";
|
|
1500
|
+
const pvcEdges = [];
|
|
1501
|
+
for (const vol of p.spec?.volumes ?? []) {
|
|
1502
|
+
const claimName = vol.persistentVolumeClaim?.claimName;
|
|
1503
|
+
if (!claimName) continue;
|
|
1504
|
+
for (const pvc of this.pvcCache.values()) {
|
|
1505
|
+
if (pvc.metadata?.name === claimName && pvc.metadata?.namespace === ns && pvc.metadata?.uid) {
|
|
1506
|
+
pvcEdges.push({ targetUid: pvc.metadata.uid, label: vol.name });
|
|
1507
|
+
break;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
return {
|
|
1512
|
+
kind: "Pod",
|
|
1513
|
+
uid: p.metadata?.uid ?? "",
|
|
1514
|
+
name: p.metadata?.name ?? "",
|
|
1515
|
+
namespace: ns,
|
|
1516
|
+
status: podStatus(p),
|
|
1517
|
+
labels: p.metadata?.labels ?? {},
|
|
1518
|
+
image: p.spec?.containers?.[0]?.image,
|
|
1519
|
+
containers: p.spec?.containers?.map((c) => c.name) ?? [],
|
|
1520
|
+
ownerUids: p.metadata?.ownerReferences?.map((r) => r.uid) ?? [],
|
|
1521
|
+
edges: pvcEdges.length > 0 ? pvcEdges : void 0
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
mapService(s) {
|
|
1525
|
+
return {
|
|
1526
|
+
kind: "Service",
|
|
1527
|
+
uid: s.metadata?.uid ?? "",
|
|
1528
|
+
name: s.metadata?.name ?? "",
|
|
1529
|
+
namespace: s.metadata?.namespace ?? "",
|
|
1530
|
+
status: "Running",
|
|
1531
|
+
labels: s.metadata?.labels ?? {},
|
|
1532
|
+
ports: s.spec?.ports?.map((p) => p.port) ?? []
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
mapDeployment(d) {
|
|
1536
|
+
const ready = d.status?.readyReplicas ?? 0;
|
|
1537
|
+
const desired = d.spec?.replicas ?? 0;
|
|
1538
|
+
const avail = d.status?.availableReplicas ?? 0;
|
|
1539
|
+
const status = desired === 0 ? "Unknown" : ready === desired && avail === desired ? "Running" : ready > 0 ? "Pending" : "Failed";
|
|
1540
|
+
return {
|
|
1541
|
+
kind: "Deployment",
|
|
1542
|
+
uid: d.metadata?.uid ?? "",
|
|
1543
|
+
name: d.metadata?.name ?? "",
|
|
1544
|
+
namespace: d.metadata?.namespace ?? "",
|
|
1545
|
+
status,
|
|
1546
|
+
labels: d.metadata?.labels ?? {},
|
|
1547
|
+
replicas: desired,
|
|
1548
|
+
readyReplicas: ready
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
mapStatefulSet(s) {
|
|
1552
|
+
return {
|
|
1553
|
+
kind: "StatefulSet",
|
|
1554
|
+
uid: s.metadata?.uid ?? "",
|
|
1555
|
+
name: s.metadata?.name ?? "",
|
|
1556
|
+
namespace: s.metadata?.namespace ?? "",
|
|
1557
|
+
status: controllerStatus(s.status?.readyReplicas, s.spec?.replicas),
|
|
1558
|
+
labels: s.metadata?.labels ?? {},
|
|
1559
|
+
replicas: s.spec?.replicas ?? 0,
|
|
1560
|
+
readyReplicas: s.status?.readyReplicas ?? 0
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
mapDaemonSet(d) {
|
|
1564
|
+
return {
|
|
1565
|
+
kind: "DaemonSet",
|
|
1566
|
+
uid: d.metadata?.uid ?? "",
|
|
1567
|
+
name: d.metadata?.name ?? "",
|
|
1568
|
+
namespace: d.metadata?.namespace ?? "",
|
|
1569
|
+
status: controllerStatus(d.status?.numberReady, d.status?.desiredNumberScheduled),
|
|
1570
|
+
labels: d.metadata?.labels ?? {},
|
|
1571
|
+
replicas: d.status?.desiredNumberScheduled ?? 0,
|
|
1572
|
+
readyReplicas: d.status?.numberReady ?? 0
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
mapReplicaSet(r) {
|
|
1576
|
+
return {
|
|
1577
|
+
kind: "ReplicaSet",
|
|
1578
|
+
uid: r.metadata?.uid ?? "",
|
|
1579
|
+
name: r.metadata?.name ?? "",
|
|
1580
|
+
namespace: r.metadata?.namespace ?? "",
|
|
1581
|
+
status: controllerStatus(r.status?.readyReplicas, r.spec?.replicas),
|
|
1582
|
+
labels: r.metadata?.labels ?? {},
|
|
1583
|
+
replicas: r.spec?.replicas ?? 0,
|
|
1584
|
+
readyReplicas: r.status?.readyReplicas ?? 0,
|
|
1585
|
+
ownerUids: r.metadata?.ownerReferences?.map((ref) => ref.uid) ?? []
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
mapJob(j) {
|
|
1589
|
+
const status = (j.status?.succeeded ?? 0) > 0 ? "Succeeded" : (j.status?.active ?? 0) > 0 ? "Running" : "Unknown";
|
|
1590
|
+
return {
|
|
1591
|
+
kind: "Job",
|
|
1592
|
+
uid: j.metadata?.uid ?? "",
|
|
1593
|
+
name: j.metadata?.name ?? "",
|
|
1594
|
+
namespace: j.metadata?.namespace ?? "",
|
|
1595
|
+
status,
|
|
1596
|
+
labels: j.metadata?.labels ?? {},
|
|
1597
|
+
ownerUids: j.metadata?.ownerReferences?.map((ref) => ref.uid) ?? []
|
|
1598
|
+
};
|
|
1599
|
+
}
|
|
1600
|
+
mapCronJob(c) {
|
|
1601
|
+
return {
|
|
1602
|
+
kind: "CronJob",
|
|
1603
|
+
uid: c.metadata?.uid ?? "",
|
|
1604
|
+
name: c.metadata?.name ?? "",
|
|
1605
|
+
namespace: c.metadata?.namespace ?? "",
|
|
1606
|
+
status: (c.status?.active?.length ?? 0) > 0 ? "Running" : "Unknown",
|
|
1607
|
+
labels: c.metadata?.labels ?? {}
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
mapIngress(i) {
|
|
1611
|
+
return {
|
|
1612
|
+
kind: "Ingress",
|
|
1613
|
+
uid: i.metadata?.uid ?? "",
|
|
1614
|
+
name: i.metadata?.name ?? "",
|
|
1615
|
+
namespace: i.metadata?.namespace ?? "",
|
|
1616
|
+
status: "Running",
|
|
1617
|
+
labels: i.metadata?.labels ?? {},
|
|
1618
|
+
host: i.spec?.rules?.[0]?.host
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
mapPvc(p) {
|
|
1622
|
+
return {
|
|
1623
|
+
kind: "PersistentVolumeClaim",
|
|
1624
|
+
uid: p.metadata?.uid ?? "",
|
|
1625
|
+
name: p.metadata?.name ?? "",
|
|
1626
|
+
namespace: p.metadata?.namespace ?? "",
|
|
1627
|
+
status: pvcStatus(p),
|
|
1628
|
+
labels: p.metadata?.labels ?? {},
|
|
1629
|
+
storageClass: p.spec?.storageClassName,
|
|
1630
|
+
capacity: p.status?.capacity?.["storage"],
|
|
1631
|
+
accessModes: p.spec?.accessModes
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
edgesForController(matchLabels, namespace, services) {
|
|
1635
|
+
if (!matchLabels) return [];
|
|
1636
|
+
return services.filter((s) => {
|
|
1637
|
+
if (s.metadata?.namespace !== namespace) return false;
|
|
1638
|
+
const sel = s.spec?.selector ?? {};
|
|
1639
|
+
return Object.entries(sel).every(([k, v]) => matchLabels[k] === v);
|
|
1640
|
+
}).filter((s) => !!s.metadata?.uid).map((s) => ({ targetUid: s.metadata.uid, label: "exposes" }));
|
|
1641
|
+
}
|
|
1642
|
+
edgesForIngress(ingress, services) {
|
|
1643
|
+
const ns = ingress.metadata?.namespace;
|
|
1644
|
+
const edges = [];
|
|
1645
|
+
for (const rule of ingress.spec?.rules ?? []) {
|
|
1646
|
+
for (const path of rule.http?.paths ?? []) {
|
|
1647
|
+
const svcName = path.backend?.service?.name;
|
|
1648
|
+
const svc = services.find((s) => s.metadata?.namespace === ns && s.metadata?.name === svcName);
|
|
1649
|
+
if (svc?.metadata?.uid) edges.push({ targetUid: svc.metadata.uid, label: path.path ?? "/" });
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
return edges;
|
|
1653
|
+
}
|
|
1654
|
+
emit(ws, inst, partial, topoAction) {
|
|
1655
|
+
if (inst.paused) return;
|
|
1656
|
+
const msg = {
|
|
1657
|
+
action: import_kwirth_common.EInstanceMessageAction.NONE,
|
|
1658
|
+
flow: import_kwirth_common.EInstanceMessageFlow.UNSOLICITED,
|
|
1659
|
+
channel: "topology",
|
|
1660
|
+
instance: inst.instanceId,
|
|
1661
|
+
type: import_kwirth_common.EInstanceMessageType.DATA,
|
|
1662
|
+
topoAction,
|
|
1663
|
+
kind: partial.kind,
|
|
1664
|
+
uid: partial.uid,
|
|
1665
|
+
name: partial.name,
|
|
1666
|
+
namespace: partial.namespace,
|
|
1667
|
+
status: partial.status,
|
|
1668
|
+
labels: partial.labels ?? {},
|
|
1669
|
+
annotations: partial.annotations,
|
|
1670
|
+
replicas: partial.replicas,
|
|
1671
|
+
readyReplicas: partial.readyReplicas,
|
|
1672
|
+
image: partial.image,
|
|
1673
|
+
ports: partial.ports,
|
|
1674
|
+
host: partial.host,
|
|
1675
|
+
storageClass: partial.storageClass,
|
|
1676
|
+
capacity: partial.capacity,
|
|
1677
|
+
accessModes: partial.accessModes,
|
|
1678
|
+
edges: partial.edges,
|
|
1679
|
+
ownerUids: partial.ownerUids,
|
|
1680
|
+
containers: partial.containers
|
|
1681
|
+
};
|
|
1682
|
+
try {
|
|
1683
|
+
ws.send(JSON.stringify(msg));
|
|
1684
|
+
} catch (err) {
|
|
1685
|
+
this.backChannelObject.logWarning?.(`[topology] send error: ${err}`);
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
sendInstanceConfig(ws, action, flow, cfg, text) {
|
|
1689
|
+
const resp = {
|
|
1690
|
+
action,
|
|
1691
|
+
flow,
|
|
1692
|
+
channel: "topology",
|
|
1693
|
+
instance: cfg.instance,
|
|
1694
|
+
type: import_kwirth_common.EInstanceMessageType.SIGNAL,
|
|
1695
|
+
text
|
|
1696
|
+
};
|
|
1697
|
+
try {
|
|
1698
|
+
ws.send(JSON.stringify(resp));
|
|
1699
|
+
} catch (err) {
|
|
1700
|
+
this.backChannelObject.logWarning?.(`[topology] sendInstanceConfig error: ${err}`);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
sendSignal(ws, msg, level, text) {
|
|
1704
|
+
const sig = {
|
|
1705
|
+
action: import_kwirth_common.EInstanceMessageAction.NONE,
|
|
1706
|
+
flow: import_kwirth_common.EInstanceMessageFlow.RESPONSE,
|
|
1707
|
+
level,
|
|
1708
|
+
channel: "topology",
|
|
1709
|
+
instance: msg.instance,
|
|
1710
|
+
type: import_kwirth_common.EInstanceMessageType.SIGNAL,
|
|
1711
|
+
text
|
|
1712
|
+
};
|
|
1713
|
+
try {
|
|
1714
|
+
ws.send(JSON.stringify(sig));
|
|
1715
|
+
} catch (err) {
|
|
1716
|
+
this.backChannelObject.logWarning?.(`[topology] sendSignal error: ${err}`);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
async doScale(ws, msg, kind, ns, name, replicas) {
|
|
1720
|
+
const patch = [{ op: "replace", path: "/spec/replicas", value: replicas }];
|
|
1721
|
+
switch (kind) {
|
|
1722
|
+
case "Deployment":
|
|
1723
|
+
await this.clusterInfo.appsApi.patchNamespacedDeployment({ name, namespace: ns, body: patch });
|
|
1724
|
+
break;
|
|
1725
|
+
case "StatefulSet":
|
|
1726
|
+
await this.clusterInfo.appsApi.patchNamespacedStatefulSet({ name, namespace: ns, body: patch });
|
|
1727
|
+
break;
|
|
1728
|
+
case "ReplicaSet":
|
|
1729
|
+
await this.clusterInfo.appsApi.patchNamespacedReplicaSet({ name, namespace: ns, body: patch });
|
|
1730
|
+
break;
|
|
1731
|
+
}
|
|
1732
|
+
this.sendSignal(ws, msg, import_kwirth_common.ESignalMessageLevel.INFO, `${kind} ${name} scaled to ${replicas}`);
|
|
1733
|
+
}
|
|
1734
|
+
async doRestart(ws, msg, kind, ns, name) {
|
|
1735
|
+
const patch = [{ op: "add", path: "/spec/template/metadata/annotations", value: { "kubectl.kubernetes.io/restartedAt": (/* @__PURE__ */ new Date()).toISOString() } }];
|
|
1736
|
+
switch (kind) {
|
|
1737
|
+
case "Deployment":
|
|
1738
|
+
await this.clusterInfo.appsApi.patchNamespacedDeployment({ name, namespace: ns, body: patch });
|
|
1739
|
+
break;
|
|
1740
|
+
case "StatefulSet":
|
|
1741
|
+
await this.clusterInfo.appsApi.patchNamespacedStatefulSet({ name, namespace: ns, body: patch });
|
|
1742
|
+
break;
|
|
1743
|
+
case "DaemonSet":
|
|
1744
|
+
await this.clusterInfo.appsApi.patchNamespacedDaemonSet({ name, namespace: ns, body: patch });
|
|
1745
|
+
break;
|
|
1746
|
+
}
|
|
1747
|
+
this.sendSignal(ws, msg, import_kwirth_common.ESignalMessageLevel.INFO, `${kind} ${name} restart triggered`);
|
|
1748
|
+
}
|
|
1749
|
+
findInstance(ws, instanceId) {
|
|
1750
|
+
return this.webSockets.find((s) => s.ws === ws)?.instances.find((i) => i.instanceId === instanceId);
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
var index_default = TopologyChannel;
|
|
1754
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1755
|
+
0 && (module.exports = {
|
|
1756
|
+
TopologyChannel
|
|
1757
|
+
});
|