@kosdev-code/kos-ddk-models 0.1.0-dev.61 → 0.1.0-dev.64
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/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +158 -31
- package/index.js.map +1 -1
- package/index.mjs +159 -32
- package/index.mjs.map +1 -1
- package/lib/mock/ddk-mock.d.ts +60 -0
- package/lib/mock/ddk-mock.d.ts.map +1 -0
- package/lib/mock/index.d.ts +3 -0
- package/lib/mock/index.d.ts.map +1 -0
- package/lib/mock/ncui-mock-data.d.ts +29 -0
- package/lib/mock/ncui-mock-data.d.ts.map +1 -0
- package/package.json +2 -2
package/index.mjs
CHANGED
|
@@ -7,16 +7,16 @@ const { URL: URL$d } = resolveServiceUrl("AUTH_SERVICE");
|
|
|
7
7
|
const { getOne: getOne$4, postModel: postModel$4 } = ServiceFactory.build({
|
|
8
8
|
basePath: `${URL$d}/api/auth`
|
|
9
9
|
});
|
|
10
|
-
const log$
|
|
10
|
+
const log$f = KosLog.createLogger({ name: "auth-service", group: "Services" });
|
|
11
11
|
const getCurrentRole = async () => {
|
|
12
|
-
log$
|
|
12
|
+
log$f.debug("sending GET for auth");
|
|
13
13
|
const response = await getOne$4({
|
|
14
14
|
urlOverride: `${URL$d}/api/app/kosdev.ddk/auth/role`
|
|
15
15
|
});
|
|
16
16
|
return response;
|
|
17
17
|
};
|
|
18
18
|
const sendPinCode = async (pinCode) => {
|
|
19
|
-
log$
|
|
19
|
+
log$f.debug("sending POST for auth");
|
|
20
20
|
const response = await postModel$4({
|
|
21
21
|
urlOverride: `${URL$d}/api/app/kosdev.ddk/auth/pincode/${pinCode}`,
|
|
22
22
|
model: {}
|
|
@@ -162,19 +162,19 @@ const { URL: URL$c } = resolveServiceUrl("SETUP-STEP_SERVICE");
|
|
|
162
162
|
const { getAll: getAll$9, postModel: postModel$3 } = ServiceFactory.build({
|
|
163
163
|
basePath: `${URL$c}/api/setup-step`
|
|
164
164
|
});
|
|
165
|
-
const log$
|
|
165
|
+
const log$e = KosLog.createLogger({
|
|
166
166
|
name: "setup-step-service",
|
|
167
167
|
group: "Services"
|
|
168
168
|
});
|
|
169
169
|
const getSetupSteps = async () => {
|
|
170
|
-
log$
|
|
170
|
+
log$e.debug("sending GET for setup-step");
|
|
171
171
|
const response = await getAll$9({
|
|
172
172
|
urlOverride: `${URL$c}/api/app/kosdev.ddk/setup/steps`
|
|
173
173
|
});
|
|
174
174
|
return response;
|
|
175
175
|
};
|
|
176
176
|
const markStepComplete = async (stepId) => {
|
|
177
|
-
log$
|
|
177
|
+
log$e.debug("sending POST for setup-step");
|
|
178
178
|
const response = await postModel$3({
|
|
179
179
|
urlOverride: `${URL$c}/api/app/kosdev.ddk/setup/complete/${stepId}`,
|
|
180
180
|
model: {}
|
|
@@ -408,9 +408,9 @@ const { URL: URL$b } = resolveServiceUrl("AUTH_SERVICE");
|
|
|
408
408
|
const { getOne: getOne$3, getAll: getAll$8 } = ServiceFactory.build({
|
|
409
409
|
basePath: `${URL$b}/api/app/kosdev.ddk/ncui/`
|
|
410
410
|
});
|
|
411
|
-
const log$
|
|
411
|
+
const log$d = KosLog.createLogger({ name: "auth-service", group: "Services" });
|
|
412
412
|
const getCuis = async () => {
|
|
413
|
-
log$
|
|
413
|
+
log$d.debug("sending GET for cuis");
|
|
414
414
|
const response = await getAll$8({
|
|
415
415
|
urlOverride: `${URL$b}/api/app/kosdev.ddk/cui`
|
|
416
416
|
});
|
|
@@ -420,13 +420,13 @@ const getCuis = async () => {
|
|
|
420
420
|
return response.data;
|
|
421
421
|
};
|
|
422
422
|
const getNavigation = async () => {
|
|
423
|
-
log$
|
|
423
|
+
log$d.debug("sending GET for navigation");
|
|
424
424
|
try {
|
|
425
425
|
const extensionResponse = await getAll$8({
|
|
426
426
|
urlOverride: `${URL$b}/api/kos/descriptor/app:kosdev.ddk:ncuiDescriptor/kondra.ncui.navigations`
|
|
427
427
|
});
|
|
428
428
|
if (extensionResponse?.status !== 200) {
|
|
429
|
-
log$
|
|
429
|
+
log$d.info(`no extensions found, using base data`);
|
|
430
430
|
const response = await getAll$8({
|
|
431
431
|
urlOverride: `${URL$b}/api/kos/descriptor/system:app/kondra.ncui.navigations`
|
|
432
432
|
});
|
|
@@ -441,14 +441,14 @@ const getNavigation = async () => {
|
|
|
441
441
|
}
|
|
442
442
|
};
|
|
443
443
|
const navigateToCui = async () => {
|
|
444
|
-
log$
|
|
444
|
+
log$d.debug("navigating to CUI");
|
|
445
445
|
const response = await getOne$3({
|
|
446
446
|
urlOverride: `${URL$b}/api/app/kosdev.ddk/cui/open`
|
|
447
447
|
});
|
|
448
448
|
return response;
|
|
449
449
|
};
|
|
450
450
|
const navigateToNCui$1 = async () => {
|
|
451
|
-
log$
|
|
451
|
+
log$d.debug("navigating to NCUI");
|
|
452
452
|
const response = await getOne$3({
|
|
453
453
|
urlOverride: `${URL$b}/api/app/kosdev.ddk/ncui/open`
|
|
454
454
|
});
|
|
@@ -865,12 +865,12 @@ const { URL: URL$a } = resolveServiceUrl("ANIMATION_SERVICE");
|
|
|
865
865
|
const { getAll: getAll$7 } = ServiceFactory.build({
|
|
866
866
|
basePath: `${URL$a}/api/animation`
|
|
867
867
|
});
|
|
868
|
-
const log$
|
|
868
|
+
const log$c = KosLog.createLogger({
|
|
869
869
|
name: "animation-service",
|
|
870
870
|
group: "Services"
|
|
871
871
|
});
|
|
872
872
|
const getAnimations = async () => {
|
|
873
|
-
log$
|
|
873
|
+
log$c.debug("sending GET for animation");
|
|
874
874
|
const response = await getAll$7({});
|
|
875
875
|
return response;
|
|
876
876
|
};
|
|
@@ -932,7 +932,7 @@ const { URL: URL$9 } = resolveServiceUrl("COPY-LOGS_SERVICE");
|
|
|
932
932
|
const { getAll: getAll$6, getOne: getOne$2, postModel: postModel$2, deleteModel } = ServiceFactory.build({
|
|
933
933
|
basePath: `${URL$9}/api/copy-logs`
|
|
934
934
|
});
|
|
935
|
-
const log$
|
|
935
|
+
const log$b = KosLog.createLogger({
|
|
936
936
|
name: "copy-logs-service",
|
|
937
937
|
group: "Services"
|
|
938
938
|
});
|
|
@@ -970,7 +970,7 @@ const copyLogFromVolume = async (volumeId, tracker) => {
|
|
|
970
970
|
return response.data;
|
|
971
971
|
};
|
|
972
972
|
const getVolumes = async () => {
|
|
973
|
-
log$
|
|
973
|
+
log$b.debug("sending GET for copy-logs");
|
|
974
974
|
try {
|
|
975
975
|
const response = await getAll$6({
|
|
976
976
|
urlOverride: `${URL$9}/api/app/kosdev.ddk/copyLogs/volumes/size`
|
|
@@ -978,14 +978,14 @@ const getVolumes = async () => {
|
|
|
978
978
|
return [void 0, response?.data];
|
|
979
979
|
} catch (error) {
|
|
980
980
|
if (error instanceof FetchError) {
|
|
981
|
-
log$
|
|
981
|
+
log$b.error(`Error fetching log file size: ${error.payload.error}`);
|
|
982
982
|
return [error.payload.error, void 0];
|
|
983
983
|
}
|
|
984
984
|
}
|
|
985
985
|
return ["unknownError", void 0];
|
|
986
986
|
};
|
|
987
987
|
const getLogFileSize = async () => {
|
|
988
|
-
log$
|
|
988
|
+
log$b.debug("sending GET for log file size");
|
|
989
989
|
try {
|
|
990
990
|
const response = await getOne$2({
|
|
991
991
|
urlOverride: `${URL$9}/api/app/kosdev.ddk/copyLogs/files/size`
|
|
@@ -993,7 +993,7 @@ const getLogFileSize = async () => {
|
|
|
993
993
|
return [void 0, response?.data];
|
|
994
994
|
} catch (error) {
|
|
995
995
|
if (error instanceof FetchError) {
|
|
996
|
-
log$
|
|
996
|
+
log$b.error(`Error fetching log file size: ${error.payload.error}`);
|
|
997
997
|
return [error.payload.error, void 0];
|
|
998
998
|
}
|
|
999
999
|
}
|
|
@@ -1230,12 +1230,12 @@ CopyLogsModelImpl = __decorateClass$h([
|
|
|
1230
1230
|
kosLoggerAware()
|
|
1231
1231
|
], CopyLogsModelImpl);
|
|
1232
1232
|
const CopyLogs = CopyLogsModelImpl.Registration;
|
|
1233
|
-
const log$
|
|
1233
|
+
const log$a = KosLog.createLogger({
|
|
1234
1234
|
name: "dashboard-operations-service",
|
|
1235
1235
|
group: "Services"
|
|
1236
1236
|
});
|
|
1237
1237
|
const resolveAll = async (troubleIds, tracker) => {
|
|
1238
|
-
log$
|
|
1238
|
+
log$a.debug("resolveAll");
|
|
1239
1239
|
const response = await TroubleServices.bulkResolveTroubles(
|
|
1240
1240
|
troubleIds,
|
|
1241
1241
|
void 0,
|
|
@@ -1244,7 +1244,7 @@ const resolveAll = async (troubleIds, tracker) => {
|
|
|
1244
1244
|
return response;
|
|
1245
1245
|
};
|
|
1246
1246
|
const resolveTrouble = async (troubleId, tracker) => {
|
|
1247
|
-
log$
|
|
1247
|
+
log$a.debug("resolveTrouble");
|
|
1248
1248
|
const response = await TroubleServices.resolveTrouble(
|
|
1249
1249
|
troubleId,
|
|
1250
1250
|
void 0,
|
|
@@ -1424,12 +1424,12 @@ const { URL: URL$8 } = resolveServiceUrl("DISPENSER_SERVICE");
|
|
|
1424
1424
|
const { getAll: getAll$5 } = ServiceFactory.build({
|
|
1425
1425
|
basePath: `${URL$8}/api/dispenser`
|
|
1426
1426
|
});
|
|
1427
|
-
const log$
|
|
1427
|
+
const log$9 = KosLog.createLogger({
|
|
1428
1428
|
name: "dispenser-service",
|
|
1429
1429
|
group: "Services"
|
|
1430
1430
|
});
|
|
1431
1431
|
const getDispensers = async () => {
|
|
1432
|
-
log$
|
|
1432
|
+
log$9.debug("sending GET for dispenser");
|
|
1433
1433
|
const response = await getAll$5({});
|
|
1434
1434
|
return response;
|
|
1435
1435
|
};
|
|
@@ -1490,12 +1490,12 @@ const { URL: URL$7 } = resolveServiceUrl("DISPENSER-INFO_SERVICE");
|
|
|
1490
1490
|
const { getAll: getAll$4 } = ServiceFactory.build({
|
|
1491
1491
|
basePath: `${URL$7}/api/dispenser-info`
|
|
1492
1492
|
});
|
|
1493
|
-
const log$
|
|
1493
|
+
const log$8 = KosLog.createLogger({
|
|
1494
1494
|
name: "dispenser-info-service",
|
|
1495
1495
|
group: "Services"
|
|
1496
1496
|
});
|
|
1497
1497
|
const getDispenserInfos = async () => {
|
|
1498
|
-
log$
|
|
1498
|
+
log$8.debug("sending GET for dispenser-info");
|
|
1499
1499
|
const response = await getAll$4({});
|
|
1500
1500
|
return response;
|
|
1501
1501
|
};
|
|
@@ -1550,12 +1550,12 @@ const { URL: URL$6 } = resolveServiceUrl("ENROLLMENT_SERVICE");
|
|
|
1550
1550
|
const { getAll: getAll$3 } = ServiceFactory.build({
|
|
1551
1551
|
basePath: `${URL$6}/api/enrollment`
|
|
1552
1552
|
});
|
|
1553
|
-
const log$
|
|
1553
|
+
const log$7 = KosLog.createLogger({
|
|
1554
1554
|
name: "enrollment-service",
|
|
1555
1555
|
group: "Services"
|
|
1556
1556
|
});
|
|
1557
1557
|
const getEnrollments = async () => {
|
|
1558
|
-
log$
|
|
1558
|
+
log$7.debug("sending GET for enrollment");
|
|
1559
1559
|
const response = await getAll$3({});
|
|
1560
1560
|
return response;
|
|
1561
1561
|
};
|
|
@@ -1724,9 +1724,9 @@ const { URL: URL$5 } = resolveServiceUrl("LOCKOUT_SERVICE");
|
|
|
1724
1724
|
const { postModel: postModel$1 } = ServiceFactory.build({
|
|
1725
1725
|
basePath: `${URL$5}/api/app/kosdev.ddk/lockout`
|
|
1726
1726
|
});
|
|
1727
|
-
const log$
|
|
1727
|
+
const log$6 = KosLog.createLogger({ name: "lockout-service", group: "Services" });
|
|
1728
1728
|
const lock = async () => {
|
|
1729
|
-
log$
|
|
1729
|
+
log$6.info("lock");
|
|
1730
1730
|
const response = await postModel$1({
|
|
1731
1731
|
model: {},
|
|
1732
1732
|
urlOverride: `${URL$5}/api/app/kosdev.ddk/lockout/lockNow`
|
|
@@ -1734,7 +1734,7 @@ const lock = async () => {
|
|
|
1734
1734
|
return response;
|
|
1735
1735
|
};
|
|
1736
1736
|
const unlock = async (pin) => {
|
|
1737
|
-
log$
|
|
1737
|
+
log$6.info("unlock");
|
|
1738
1738
|
const response = await postModel$1({
|
|
1739
1739
|
model: {},
|
|
1740
1740
|
urlOverride: `${URL$5}/api/app/kosdev.ddk/lockout/unlock/${pin}`
|
|
@@ -2041,6 +2041,126 @@ const MacroAssignment = {
|
|
|
2041
2041
|
MODEL_TYPE$a
|
|
2042
2042
|
)
|
|
2043
2043
|
};
|
|
2044
|
+
const descriptorValue = (ncui, path) => path.split(".").reduce(
|
|
2045
|
+
(value, key) => value && typeof value === "object" ? value[key] : void 0,
|
|
2046
|
+
{ kondra: { ncui } }
|
|
2047
|
+
);
|
|
2048
|
+
const descriptorSetupSteps = (steps, backend) => steps.map((step) => ({
|
|
2049
|
+
complete: false,
|
|
2050
|
+
preStep: false,
|
|
2051
|
+
exclusive: false,
|
|
2052
|
+
...backend.find((existing) => existing.name === step.name),
|
|
2053
|
+
...step
|
|
2054
|
+
}));
|
|
2055
|
+
const withUtility = (columns, entry, column = columns.length - 1) => columns.length === 0 ? [[entry]] : columns.map((items, i) => i === column ? [...items, entry] : items);
|
|
2056
|
+
const withNavigation = (items, entry, parent) => {
|
|
2057
|
+
if (!parent) return [...items, entry];
|
|
2058
|
+
const [head, ...rest] = parent.split(".");
|
|
2059
|
+
return items.map(
|
|
2060
|
+
(item) => item.name === head ? {
|
|
2061
|
+
...item,
|
|
2062
|
+
children: withNavigation(
|
|
2063
|
+
item.children ?? [],
|
|
2064
|
+
entry,
|
|
2065
|
+
rest.join(".") || void 0
|
|
2066
|
+
)
|
|
2067
|
+
} : item
|
|
2068
|
+
);
|
|
2069
|
+
};
|
|
2070
|
+
const withSetupStep = (steps, entry, before) => {
|
|
2071
|
+
const step = { complete: false, preStep: false, exclusive: false, ...entry };
|
|
2072
|
+
const at = before ? steps.findIndex((s) => s.name === before) : -1;
|
|
2073
|
+
return at < 0 ? [...steps, step] : [...steps.slice(0, at), step, ...steps.slice(at)];
|
|
2074
|
+
};
|
|
2075
|
+
const log$5 = KosLog.createLogger({ name: "ddk-mock" });
|
|
2076
|
+
const NCUI_DESCRIPTOR = "/api/kos/descriptor/app:kosdev.ddk:ncuiDescriptor";
|
|
2077
|
+
const ANY_DESCRIPTOR = "/api/kos/descriptor/:descriptor";
|
|
2078
|
+
const SETUP_STEPS = "/api/app/kosdev.ddk/setup/steps";
|
|
2079
|
+
const onData = (change) => (body) => {
|
|
2080
|
+
const envelope = body;
|
|
2081
|
+
if (envelope?.data === void 0) return body;
|
|
2082
|
+
return { ...envelope, data: change(envelope.data) };
|
|
2083
|
+
};
|
|
2084
|
+
const lastSegment = (path) => path.split("/").pop() ?? "";
|
|
2085
|
+
const createDdkMockHelpers = (kosMock) => {
|
|
2086
|
+
const removeAll = (...handles) => () => handles.forEach((handle) => handle.remove());
|
|
2087
|
+
return {
|
|
2088
|
+
useDescriptor(descriptor) {
|
|
2089
|
+
const ncui = "kondra" in descriptor ? descriptor.kondra.ncui : descriptor;
|
|
2090
|
+
const handles = [
|
|
2091
|
+
kosMock.get(
|
|
2092
|
+
`${NCUI_DESCRIPTOR}/:path`,
|
|
2093
|
+
(req) => ({ data: descriptorValue(ncui, lastSegment(req.path)) }),
|
|
2094
|
+
{
|
|
2095
|
+
id: "ddk-ncui-descriptor",
|
|
2096
|
+
description: "DDK: the descriptor project as the installed NCUI descriptor",
|
|
2097
|
+
// Paths the descriptor does not have reach the backend.
|
|
2098
|
+
when: (req) => descriptorValue(ncui, lastSegment(req.path)) !== void 0
|
|
2099
|
+
}
|
|
2100
|
+
)
|
|
2101
|
+
];
|
|
2102
|
+
const steps = ncui.setup?.steps;
|
|
2103
|
+
if (steps) {
|
|
2104
|
+
handles.push(
|
|
2105
|
+
kosMock.transformResponse(
|
|
2106
|
+
"GET",
|
|
2107
|
+
SETUP_STEPS,
|
|
2108
|
+
onData(
|
|
2109
|
+
(backend) => descriptorSetupSteps(steps, backend)
|
|
2110
|
+
),
|
|
2111
|
+
{ description: "DDK: the descriptor project's setup steps" }
|
|
2112
|
+
)
|
|
2113
|
+
);
|
|
2114
|
+
}
|
|
2115
|
+
return removeAll(...handles);
|
|
2116
|
+
},
|
|
2117
|
+
addUtility(entry, { column } = {}) {
|
|
2118
|
+
return removeAll(
|
|
2119
|
+
kosMock.transformResponse(
|
|
2120
|
+
"GET",
|
|
2121
|
+
`${ANY_DESCRIPTOR}/kondra.ncui.utilities`,
|
|
2122
|
+
onData(
|
|
2123
|
+
(columns) => withUtility(columns, entry, column)
|
|
2124
|
+
),
|
|
2125
|
+
{ description: `DDK: utility ${entry.name}` }
|
|
2126
|
+
)
|
|
2127
|
+
);
|
|
2128
|
+
},
|
|
2129
|
+
addNavigation(entry, { parent } = {}) {
|
|
2130
|
+
return removeAll(
|
|
2131
|
+
kosMock.transformResponse(
|
|
2132
|
+
"GET",
|
|
2133
|
+
`${ANY_DESCRIPTOR}/kondra.ncui.navigations`,
|
|
2134
|
+
onData(
|
|
2135
|
+
(items) => withNavigation(items, entry, parent)
|
|
2136
|
+
),
|
|
2137
|
+
{ description: `DDK: navigation ${entry.name}` }
|
|
2138
|
+
)
|
|
2139
|
+
);
|
|
2140
|
+
},
|
|
2141
|
+
addSetupStep(entry, { before } = {}) {
|
|
2142
|
+
return removeAll(
|
|
2143
|
+
kosMock.transformResponse(
|
|
2144
|
+
"GET",
|
|
2145
|
+
SETUP_STEPS,
|
|
2146
|
+
onData(
|
|
2147
|
+
(steps) => withSetupStep(steps, entry, before)
|
|
2148
|
+
),
|
|
2149
|
+
{ description: `DDK: setup step ${entry.name}` }
|
|
2150
|
+
)
|
|
2151
|
+
);
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
};
|
|
2155
|
+
const registerDdkMock = () => {
|
|
2156
|
+
const kosMock = globalThis.KosMock;
|
|
2157
|
+
if (typeof kosMock?.extend !== "function") return;
|
|
2158
|
+
try {
|
|
2159
|
+
kosMock.extend("ddk", createDdkMockHelpers);
|
|
2160
|
+
} catch (error) {
|
|
2161
|
+
log$5.warn("kosMock.ddk not registered", error?.message);
|
|
2162
|
+
}
|
|
2163
|
+
};
|
|
2044
2164
|
var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
|
|
2045
2165
|
var __decorateClass$9 = (decorators, target, key, kind) => {
|
|
2046
2166
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
|
|
@@ -3085,13 +3205,20 @@ export {
|
|
|
3085
3205
|
UtilitiesContainer,
|
|
3086
3206
|
index$1 as UtilitiesServices,
|
|
3087
3207
|
calculateTimeDifference,
|
|
3208
|
+
createDdkMockHelpers,
|
|
3209
|
+
descriptorSetupSteps,
|
|
3210
|
+
descriptorValue,
|
|
3088
3211
|
executeDashboardKeyFactory,
|
|
3089
3212
|
isMacroGroup,
|
|
3090
3213
|
isMicroGroup,
|
|
3091
3214
|
macroHolderMap,
|
|
3092
3215
|
registerDashboardKeyFactory,
|
|
3216
|
+
registerDdkMock,
|
|
3093
3217
|
toSeconds,
|
|
3094
3218
|
toTimeComponents,
|
|
3095
|
-
troubleVisibilityFilter
|
|
3219
|
+
troubleVisibilityFilter,
|
|
3220
|
+
withNavigation,
|
|
3221
|
+
withSetupStep,
|
|
3222
|
+
withUtility
|
|
3096
3223
|
};
|
|
3097
3224
|
//# sourceMappingURL=index.mjs.map
|