@kosdev-code/kos-ui-sdk 0.1.0-next.975 → 0.1.0-next.991
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/common/events/async-event-bus.d.ts.map +1 -1
- package/common/events/eventBus.d.ts.map +1 -1
- package/core/core/decorators/index.d.ts +0 -1
- package/core/core/decorators/index.d.ts.map +1 -1
- package/core/core/decorators/kos-logger-aware.d.ts.map +1 -1
- package/core/core/decorators/kosModel.d.ts.map +1 -1
- package/core/core/decorators/propKeys.d.ts +0 -1
- package/core/core/decorators/propKeys.d.ts.map +1 -1
- package/core/core/extension/extension-manager.d.ts.map +1 -1
- package/core/core/kos-container-index.d.ts.map +1 -1
- package/core/core/kos-registration.d.ts.map +1 -1
- package/core/core/kosModel.d.ts.map +1 -1
- package/core/core/lifecycle/kosCoreLifecycle.d.ts.map +1 -1
- package/core/core/lifecycle/model-machine.d.ts.map +1 -1
- package/core/core/log/index.d.ts +1 -0
- package/core/core/log/index.d.ts.map +1 -1
- package/core/core/log/log-groups.d.ts +25 -0
- package/core/core/log/log-groups.d.ts.map +1 -0
- package/core/core/log/log-override-match.d.ts +24 -0
- package/core/core/log/log-override-match.d.ts.map +1 -0
- package/core/core/log/log.d.ts +13 -9
- package/core/core/log/log.d.ts.map +1 -1
- package/core/core/model/kos-logger-factory.d.ts +6 -4
- package/core/core/model/kos-logger-factory.d.ts.map +1 -1
- package/core/core/model/kos-model-component-factory.d.ts.map +1 -1
- package/core/core/model/kos-service-request-manager.d.ts.map +1 -1
- package/core/core/registration/registration-manager.d.ts.map +1 -1
- package/core/core/transport/base-message-transport.d.ts.map +1 -1
- package/core/core/transport/bridge-transport.d.ts.map +1 -1
- package/core/core/transport/mock/future-simulator.d.ts.map +1 -1
- package/core/core/transport/mock/mock-config.d.ts.map +1 -1
- package/core/core/transport/mock/mock-fixtures.d.ts.map +1 -1
- package/core/core/transport/mock/mock-playback.d.ts.map +1 -1
- package/core/core/transport/mock/mock-recorder.d.ts.map +1 -1
- package/core/core/transport/mock/mock-registry.d.ts.map +1 -1
- package/core/core/transport/mock/mock-setups.d.ts.map +1 -1
- package/core/core/transport/mock/standalone-mock-socket.d.ts.map +1 -1
- package/core/core/transport/transport-factory.d.ts.map +1 -1
- package/core/core/transport/webSocketTransport.d.ts.map +1 -1
- package/core/types/global.d.ts +0 -6
- package/core/util/feature-flags.d.ts.map +1 -1
- package/core/util/kos-message-utils.d.ts.map +1 -1
- package/core/util/kos-model-utils.d.ts.map +1 -1
- package/core/util/kos-model-visitor.d.ts.map +1 -1
- package/core/util/kos-service-request.d.ts +6 -1
- package/core/util/kos-service-request.d.ts.map +1 -1
- package/core/util/log-utils.d.ts +0 -10
- package/core/util/log-utils.d.ts.map +1 -1
- package/core/util/model-error-utils.d.ts.map +1 -1
- package/core/util/model-utils.d.ts.map +1 -1
- package/core/util/promise-utils.d.ts.map +1 -1
- package/core/util/retry-with-exponential-backoff.d.ts.map +1 -1
- package/core/util/wait-for-request.d.ts.map +1 -1
- package/index.cjs +64 -313
- package/index.cjs.map +1 -1
- package/index.js +318 -567
- package/index.js.map +1 -1
- package/models/decorators/future-service.d.ts.map +1 -1
- package/models/models/config-bean/config-bean-model.d.ts.map +1 -1
- package/models/models/config-bean-prop/config-bean-prop-model.d.ts.map +1 -1
- package/models/models/future/future-aware.d.ts.map +1 -1
- package/models/models/future/future-model-builder.d.ts.map +1 -1
- package/models/models/future/future-model.d.ts.map +1 -1
- package/models/models/future-container/future-container-model.d.ts.map +1 -1
- package/models/models/gpio-chip/services/gpio-chip-services.d.ts +1 -1
- package/models/models/key-value/services/key-value-services.d.ts.map +1 -1
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts +43 -24
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts.map +1 -1
- package/models/models/kos-log-manager/services/kos-log-manager-services.d.ts +20 -1
- package/models/models/kos-log-manager/services/kos-log-manager-services.d.ts.map +1 -1
- package/models/models/kos-log-manager/types/index.d.ts +71 -6
- package/models/models/log-stream/services/log-stream-services.d.ts.map +1 -1
- package/models/models/network-interface/services/network-interface-services.d.ts.map +1 -1
- package/models/models/ota/services/ota-services.d.ts.map +1 -1
- package/models/models/software-info/services/software-info-services.d.ts.map +1 -1
- package/models/models/state-bean/services/state-bean-services.d.ts.map +1 -1
- package/models/models/state-prop/services/state-prop-services.d.ts.map +1 -1
- package/models/models/storage-device/services/storage-device-services.d.ts.map +1 -1
- package/models/models/studio-properties/services/studio-properties-services.d.ts.map +1 -1
- package/models/models/studio-properties/studio-properties-model.d.ts.map +1 -1
- package/models/models/translation/services/translation-services.d.ts.map +1 -1
- package/models/models/trouble/utils/trouble-data-extension.d.ts.map +1 -1
- package/models/models/trouble/utils/trouble-extension.d.ts.map +1 -1
- package/models/models/usb-update/services/usb-update-services.d.ts.map +1 -1
- package/models/models/ws-event/ws-event-model.d.ts.map +1 -1
- package/models/services/config-bean/index.d.ts.map +1 -1
- package/models/services/login/index.d.ts.map +1 -1
- package/models/utils/await-future-call.d.ts.map +1 -1
- package/models/utils/cancellable-future-call.d.ts.map +1 -1
- package/models/utils/client.d.ts +1 -1
- package/models/utils/core-registration-manager.d.ts +13 -2
- package/models/utils/core-registration-manager.d.ts.map +1 -1
- package/models/utils/get-kos-connection-id.d.ts.map +1 -1
- package/models/utils/service-accessor.d.ts +1 -1
- package/models/utils/service.d.ts +1 -1
- package/models/utils/services/kos/1.6.5/service.d.ts +1 -1
- package/models/utils/services/kos/1.8.1/service.d.ts +1 -1
- package/models/utils/services/kos/1.9.x/service.d.ts +1 -1
- package/models/utils/services/kos/daily/service.d.ts +1 -1
- package/models/utils/services/vfs/1.6.5/service.d.ts +1 -1
- package/models/utils/services/vfs/1.8.1/service.d.ts +1 -1
- package/models/utils/services/vfs/1.9.x/service.d.ts +1 -1
- package/models/utils/services/vfs/daily/service.d.ts +1 -1
- package/models/utils/timer-manager.d.ts.map +1 -1
- package/package.json +3 -3
- package/{software-info-registration-kSGacOka.js → software-info-registration-Bz_s3zOp.js} +1463 -1027
- package/software-info-registration-Bz_s3zOp.js.map +1 -0
- package/{software-info-registration-Le3V0a6v.cjs → software-info-registration-CagrRzH8.cjs} +1152 -716
- package/software-info-registration-CagrRzH8.cjs.map +1 -0
- package/testing.cjs +1 -2
- package/testing.cjs.map +1 -1
- package/testing.js +1 -2
- package/testing.js.map +1 -1
- package/ui/components/kos-model-loader/contexts/kos-model-hierarchy-context.d.ts.map +1 -1
- package/ui/components/kos-model-loader/kos-model-loader.d.ts.map +1 -1
- package/ui/contexts/kos-model-context.d.ts.map +1 -1
- package/ui/contexts/translation-container/kos-translations-provider.d.ts.map +1 -1
- package/ui/hooks/translation-container/use-translation.d.ts.map +1 -1
- package/ui/hooks/use-mutation-observer.d.ts.map +1 -1
- package/ui/hooks/use-press-gesture/use-press-gesture.d.ts.map +1 -1
- package/ui/policies/reload-on-disconnect-policy.d.ts.map +1 -1
- package/core/core/decorators/kos-log.d.ts +0 -14
- package/core/core/decorators/kos-log.d.ts.map +0 -1
- package/software-info-registration-Le3V0a6v.cjs.map +0 -1
- package/software-info-registration-kSGacOka.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const mobx = require("mobx");
|
|
3
|
-
const log$
|
|
3
|
+
const log$1h = require("loglevel");
|
|
4
4
|
const robot3 = require("robot3");
|
|
5
5
|
const dateFns = require("date-fns");
|
|
6
6
|
const HEADER_METHOD = `method`;
|
|
@@ -27,7 +27,140 @@ var KosWsEvents = /* @__PURE__ */ ((KosWsEvents2) => {
|
|
|
27
27
|
return KosWsEvents2;
|
|
28
28
|
})(KosWsEvents || {});
|
|
29
29
|
const EVENT_KOS_MODEL_READY = "/kos/model/ready/";
|
|
30
|
-
|
|
30
|
+
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
31
|
+
const [key, val] = pair.split("=");
|
|
32
|
+
return [key, decodeURIComponent(val || "")];
|
|
33
|
+
}).reduce((result, [key, val]) => {
|
|
34
|
+
result[key] = val;
|
|
35
|
+
return result;
|
|
36
|
+
}, {});
|
|
37
|
+
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
38
|
+
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
39
|
+
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
40
|
+
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
41
|
+
const PROFILE_LOG_INFO = "studio.log.info";
|
|
42
|
+
const defaultConfig = {
|
|
43
|
+
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
44
|
+
};
|
|
45
|
+
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
46
|
+
const configObj = JSON.parse(config);
|
|
47
|
+
const urlProfiles = () => {
|
|
48
|
+
if (typeof window === "undefined") {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const value = getQueryParams()?.["kosProfiles"];
|
|
52
|
+
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
53
|
+
};
|
|
54
|
+
configObj.profiles = [
|
|
55
|
+
...configObj.profiles ?? [],
|
|
56
|
+
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
57
|
+
];
|
|
58
|
+
globalThis.kosConfig = configObj;
|
|
59
|
+
const KosGlobalConfig = configObj;
|
|
60
|
+
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
61
|
+
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
62
|
+
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
63
|
+
const resolveLogLevelProfile = () => {
|
|
64
|
+
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
65
|
+
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
66
|
+
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
67
|
+
};
|
|
68
|
+
const getLogLevel = () => {
|
|
69
|
+
const params2 = getQueryParams();
|
|
70
|
+
const profileLogLevel = resolveLogLevelProfile();
|
|
71
|
+
const logLevelParam = params2["kosLogLevel"];
|
|
72
|
+
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
73
|
+
if (logLevel) {
|
|
74
|
+
return logLevel;
|
|
75
|
+
}
|
|
76
|
+
return "WARN";
|
|
77
|
+
};
|
|
78
|
+
const LogGroup = {
|
|
79
|
+
core: "core",
|
|
80
|
+
transport: "transport",
|
|
81
|
+
model: "model",
|
|
82
|
+
service: "service",
|
|
83
|
+
ui: "ui"
|
|
84
|
+
};
|
|
85
|
+
const UI_GROUP_OVERRIDE = "ui:group";
|
|
86
|
+
const UI_LOGGER_OVERRIDE = "ui:logger";
|
|
87
|
+
const LEVELS = ["trace", "debug", "info", "warn", "error"];
|
|
88
|
+
const getLoggerGroup = (loggerName) => {
|
|
89
|
+
const grouped = loggerName.indexOf(":::");
|
|
90
|
+
if (grouped >= 0) {
|
|
91
|
+
return loggerName.slice(0, grouped);
|
|
92
|
+
}
|
|
93
|
+
const ungrouped = loggerName.indexOf("::");
|
|
94
|
+
return ungrouped >= 0 ? loggerName.slice(0, ungrouped) : "";
|
|
95
|
+
};
|
|
96
|
+
const matchesPattern = (value, pattern) => {
|
|
97
|
+
const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
98
|
+
return new RegExp(`^${source}$`).test(value);
|
|
99
|
+
};
|
|
100
|
+
const matches = (loggerName, override) => {
|
|
101
|
+
const wildcard = override.name.includes("*");
|
|
102
|
+
if (override.type === UI_GROUP_OVERRIDE) {
|
|
103
|
+
const group = getLoggerGroup(loggerName);
|
|
104
|
+
return wildcard ? matchesPattern(group, override.name) : group === override.name;
|
|
105
|
+
}
|
|
106
|
+
if (override.type === UI_LOGGER_OVERRIDE) {
|
|
107
|
+
return wildcard ? matchesPattern(loggerName, override.name) : loggerName.startsWith(override.name);
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
};
|
|
111
|
+
const resolveOverrideLevel = (loggerName, overrides) => overrides.filter((override) => matches(loggerName, override)).map((override) => override.level.toLowerCase()).filter((level2) => LEVELS.includes(level2)).sort((a, b) => LEVELS.indexOf(a) - LEVELS.indexOf(b))[0];
|
|
112
|
+
const MESSAGE_LOGGER_NAME = "messages";
|
|
113
|
+
const MESSAGE_LOGGER = `${LogGroup.transport}:::${MESSAGE_LOGGER_NAME}`;
|
|
114
|
+
const originalFactory = log$1h.methodFactory;
|
|
115
|
+
log$1h.methodFactory = function(methodName, logLevel, loggerName) {
|
|
116
|
+
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
117
|
+
return function(...args) {
|
|
118
|
+
const _name = loggerName ? String(loggerName) : "";
|
|
119
|
+
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
120
|
+
const message = args.map(
|
|
121
|
+
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
122
|
+
).join(" ");
|
|
123
|
+
rawMethod(`${prefix}${message}`);
|
|
124
|
+
if (globalThis?.kosConfig?.logging && globalThis.kosLog && loggerName !== MESSAGE_LOGGER) {
|
|
125
|
+
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
let level = getLogLevel();
|
|
130
|
+
log$1h.setLevel(level);
|
|
131
|
+
window.setKosLogLevel = (_level) => {
|
|
132
|
+
level = _level;
|
|
133
|
+
log$1h.setLevel(_level);
|
|
134
|
+
};
|
|
135
|
+
const conditionallyLog = (level2) => (fn, logger = log$1h) => {
|
|
136
|
+
if (logger.getLevel() <= level2) {
|
|
137
|
+
fn();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const createLogger = ({ name, group }) => {
|
|
141
|
+
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
142
|
+
const _log = log$1h.getLogger(loggerName);
|
|
143
|
+
const _level = resolveOverrideLevel(
|
|
144
|
+
loggerName,
|
|
145
|
+
globalThis.kos?.logOverrides ?? []
|
|
146
|
+
);
|
|
147
|
+
if (_level) {
|
|
148
|
+
_log.setLevel(_level);
|
|
149
|
+
}
|
|
150
|
+
return _log;
|
|
151
|
+
};
|
|
152
|
+
const KosLog = {
|
|
153
|
+
...log$1h,
|
|
154
|
+
ifDebug: conditionallyLog(log$1h.levels.DEBUG),
|
|
155
|
+
ifInfo: conditionallyLog(log$1h.levels.INFO),
|
|
156
|
+
ifWarn: conditionallyLog(log$1h.levels.WARN),
|
|
157
|
+
ifError: conditionallyLog(log$1h.levels.ERROR),
|
|
158
|
+
getLogger: (name) => createLogger({ name }),
|
|
159
|
+
getLoggers: () => log$1h.getLoggers(),
|
|
160
|
+
createLogger
|
|
161
|
+
};
|
|
162
|
+
const log$1g = KosLog.createLogger({ group: LogGroup.core, name: "event-bus" });
|
|
163
|
+
log$1g.info("Initializing event bus");
|
|
31
164
|
globalThis.kos = globalThis.kos || {};
|
|
32
165
|
globalThis.kos.subscriptions = globalThis.kos.subscriptions || {};
|
|
33
166
|
const subscriptions = globalThis.kos.subscriptions;
|
|
@@ -38,15 +171,15 @@ function hasEventSubscriptions(eventType) {
|
|
|
38
171
|
function subscribe(eventType, callback) {
|
|
39
172
|
const id = getNextUniqueId();
|
|
40
173
|
if (!subscriptions[eventType]) {
|
|
41
|
-
log$
|
|
174
|
+
log$1g.debug(`Initializing subscription for ${eventType}`);
|
|
42
175
|
subscriptions[eventType] = {};
|
|
43
176
|
}
|
|
44
|
-
log$
|
|
177
|
+
log$1g.debug(`Subscribing to ${eventType} with id ${id.toString()}`);
|
|
45
178
|
subscriptions[eventType][id] = callback;
|
|
46
179
|
return {
|
|
47
180
|
count: subscriptions[eventType] ? Object.getOwnPropertySymbols(subscriptions[eventType]).length : 0,
|
|
48
181
|
unsubscribe: () => {
|
|
49
|
-
log$
|
|
182
|
+
log$1g.debug(`Unsubscribing from ${eventType} with id ${id.toString()}`);
|
|
50
183
|
if (subscriptions[eventType] && subscriptions[eventType][id]) {
|
|
51
184
|
delete subscriptions[eventType][id];
|
|
52
185
|
}
|
|
@@ -61,7 +194,7 @@ function subscribe(eventType, callback) {
|
|
|
61
194
|
}
|
|
62
195
|
function publish(eventType, msg, headers = {}) {
|
|
63
196
|
if (!subscriptions[eventType] || Object.getOwnPropertySymbols(subscriptions[eventType]).length === 0) {
|
|
64
|
-
log$
|
|
197
|
+
log$1g.debug(`No subscriptions for ${eventType}. Not publishing.`);
|
|
65
198
|
return {
|
|
66
199
|
eventType,
|
|
67
200
|
subscribers: 0
|
|
@@ -71,19 +204,19 @@ function publish(eventType, msg, headers = {}) {
|
|
|
71
204
|
Object.getOwnPropertySymbols(subscriptions[eventType]).forEach((id) => {
|
|
72
205
|
if (headers["sync"]) {
|
|
73
206
|
const responseId = headers["sync"];
|
|
74
|
-
log$
|
|
207
|
+
log$1g.debug(
|
|
75
208
|
`Performing sync publish for ${eventType} with sync id ${responseId}`
|
|
76
209
|
);
|
|
77
210
|
subscriptions[eventType][id]({ body: msg, headers }).then(
|
|
78
211
|
(response) => {
|
|
79
|
-
log$
|
|
212
|
+
log$1g.debug(
|
|
80
213
|
`Response recieved for ${responseId}, publishing back to source.`
|
|
81
214
|
);
|
|
82
215
|
publish(responseId, response);
|
|
83
216
|
}
|
|
84
217
|
);
|
|
85
218
|
} else {
|
|
86
|
-
log$
|
|
219
|
+
log$1g.debug(`Performing async publish for ${eventType}`);
|
|
87
220
|
subscriptions[eventType][id]({ body: msg, headers });
|
|
88
221
|
}
|
|
89
222
|
});
|
|
@@ -93,7 +226,7 @@ function publish(eventType, msg, headers = {}) {
|
|
|
93
226
|
};
|
|
94
227
|
}
|
|
95
228
|
function reset() {
|
|
96
|
-
log$
|
|
229
|
+
log$1g.warn("Resetting event bus");
|
|
97
230
|
Object.keys(subscriptions).forEach((key) => delete subscriptions[key]);
|
|
98
231
|
}
|
|
99
232
|
function once(eventType, callback) {
|
|
@@ -409,164 +542,11 @@ const eventBus_state = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defi
|
|
|
409
542
|
waitForAllWithState,
|
|
410
543
|
waitForOrGetState
|
|
411
544
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
412
|
-
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
413
|
-
const [key, val] = pair.split("=");
|
|
414
|
-
return [key, decodeURIComponent(val || "")];
|
|
415
|
-
}).reduce((result, [key, val]) => {
|
|
416
|
-
result[key] = val;
|
|
417
|
-
return result;
|
|
418
|
-
}, {});
|
|
419
|
-
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
420
|
-
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
421
|
-
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
422
|
-
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
423
|
-
const PROFILE_LOG_INFO = "studio.log.info";
|
|
424
|
-
const defaultConfig = {
|
|
425
|
-
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
426
|
-
};
|
|
427
|
-
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
428
|
-
const configObj = JSON.parse(config);
|
|
429
|
-
const urlProfiles = () => {
|
|
430
|
-
if (typeof window === "undefined") {
|
|
431
|
-
return [];
|
|
432
|
-
}
|
|
433
|
-
const value = getQueryParams()?.["kosProfiles"];
|
|
434
|
-
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
435
|
-
};
|
|
436
|
-
configObj.profiles = [
|
|
437
|
-
...configObj.profiles ?? [],
|
|
438
|
-
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
439
|
-
];
|
|
440
|
-
globalThis.kosConfig = configObj;
|
|
441
|
-
const KosGlobalConfig = configObj;
|
|
442
|
-
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
443
|
-
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
444
|
-
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
445
|
-
const resolveLogLevelProfile = () => {
|
|
446
|
-
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
447
|
-
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
448
|
-
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
449
|
-
};
|
|
450
|
-
const getLogLevel = () => {
|
|
451
|
-
const params2 = getQueryParams();
|
|
452
|
-
const profileLogLevel = resolveLogLevelProfile();
|
|
453
|
-
const logLevelParam = params2["kosLogLevel"];
|
|
454
|
-
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
455
|
-
if (logLevel) {
|
|
456
|
-
return logLevel;
|
|
457
|
-
}
|
|
458
|
-
return "WARN";
|
|
459
|
-
};
|
|
460
|
-
const getKosMessageLogging = () => {
|
|
461
|
-
const enableAll = window.kosMessageLogging || process.env.KOS_MESSAGE_LOGGING === "true";
|
|
462
|
-
return enableAll;
|
|
463
|
-
};
|
|
464
|
-
const getLogMessageToStudio = () => {
|
|
465
|
-
const enableAll = window.kosMessageStudioLogging || process.env.KOS_MESSAGE_STUDIO_LOGGING === "true";
|
|
466
|
-
return enableAll;
|
|
467
|
-
};
|
|
468
|
-
const WS_LOG = "ws-log";
|
|
469
|
-
const originalFactory = log$M.methodFactory;
|
|
470
|
-
const enableMessageLogging = getKosMessageLogging();
|
|
471
|
-
const enableStudioMessageLogging = getLogMessageToStudio();
|
|
472
|
-
log$M.methodFactory = function(methodName, logLevel, loggerName) {
|
|
473
|
-
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
474
|
-
return function(...args) {
|
|
475
|
-
const _name = loggerName ? String(loggerName) : "";
|
|
476
|
-
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
477
|
-
const message = args.map(
|
|
478
|
-
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
479
|
-
).join(" ");
|
|
480
|
-
rawMethod(`${prefix}${message}`);
|
|
481
|
-
if (globalThis?.kosConfig?.logging && globalThis.kosLog && (loggerName !== WS_LOG || enableMessageLogging && enableStudioMessageLogging)) {
|
|
482
|
-
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
483
|
-
}
|
|
484
|
-
};
|
|
485
|
-
};
|
|
486
|
-
let level = getLogLevel();
|
|
487
|
-
log$M.setLevel(level);
|
|
488
|
-
window.setKosLogLevel = (_level) => {
|
|
489
|
-
level = _level;
|
|
490
|
-
log$M.setLevel(_level);
|
|
491
|
-
};
|
|
492
|
-
const wsLog = log$M.getLogger(WS_LOG);
|
|
493
|
-
window.enableKosMessageLog = () => {
|
|
494
|
-
wsLog.setLevel(log$M.levels.INFO);
|
|
495
|
-
};
|
|
496
|
-
window.disableKosMessageLog = () => {
|
|
497
|
-
wsLog.setLevel(log$M.levels.ERROR);
|
|
498
|
-
};
|
|
499
|
-
if (enableMessageLogging) {
|
|
500
|
-
window.enableKosMessageLog();
|
|
501
|
-
} else {
|
|
502
|
-
window.disableKosMessageLog();
|
|
503
|
-
}
|
|
504
|
-
const styles = [
|
|
505
|
-
"color: black",
|
|
506
|
-
"display: block",
|
|
507
|
-
"background-color: lightgreen",
|
|
508
|
-
"padding: 4px",
|
|
509
|
-
"margin: 0",
|
|
510
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
511
|
-
"box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset",
|
|
512
|
-
"font-weight: bold"
|
|
513
|
-
].join(";");
|
|
514
|
-
const received = [
|
|
515
|
-
"color: black",
|
|
516
|
-
"display: block",
|
|
517
|
-
"padding: 4px",
|
|
518
|
-
"background-color: yellow",
|
|
519
|
-
"margin: 0",
|
|
520
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
521
|
-
"box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset",
|
|
522
|
-
"font-weight: bold"
|
|
523
|
-
].join(";");
|
|
524
|
-
const conditionallyLog = (level2) => (fn) => {
|
|
525
|
-
if (log$M.getLevel() <= level2) {
|
|
526
|
-
fn();
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
const KosLog = {
|
|
530
|
-
...log$M,
|
|
531
|
-
ifDebug: conditionallyLog(log$M.levels.DEBUG),
|
|
532
|
-
ifInfo: conditionallyLog(log$M.levels.INFO),
|
|
533
|
-
ifWarn: conditionallyLog(log$M.levels.WARN),
|
|
534
|
-
ifError: conditionallyLog(log$M.levels.ERROR),
|
|
535
|
-
getLogger: (name) => log$M.getLogger(`kos::${name}`),
|
|
536
|
-
getLoggers: () => log$M.getLoggers(),
|
|
537
|
-
createLogger: ({ name, group }) => {
|
|
538
|
-
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
539
|
-
const _log = log$M.getLogger(loggerName);
|
|
540
|
-
let _level = globalThis.kos.logOverrides?.find(
|
|
541
|
-
(override) => override.name === loggerName
|
|
542
|
-
)?.level;
|
|
543
|
-
if (_level) {
|
|
544
|
-
_log.setLevel(_level);
|
|
545
|
-
} else {
|
|
546
|
-
_level = globalThis.kos.logOverrides?.find(
|
|
547
|
-
(override) => loggerName.startsWith(override.name)
|
|
548
|
-
)?.level;
|
|
549
|
-
if (_level) {
|
|
550
|
-
_log.setLevel(_level);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
return _log;
|
|
554
|
-
},
|
|
555
|
-
wsSend: (...msg) => {
|
|
556
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
557
|
-
wsLog.info(`%c⬆ ${str}`, styles);
|
|
558
|
-
},
|
|
559
|
-
wsReceive: (...msg) => {
|
|
560
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
561
|
-
wsLog.info(`%c⬇ ${str}`, received);
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
545
|
const SubscriptionHandlers = /* @__PURE__ */ Symbol(`SubscriptionHandlers`);
|
|
565
546
|
const DependencyModels = /* @__PURE__ */ Symbol(`DependencyModels`);
|
|
566
547
|
const FutureService = /* @__PURE__ */ Symbol(`FutureService`);
|
|
567
548
|
const ChildModels = /* @__PURE__ */ Symbol(`ChildModels`);
|
|
568
549
|
const ParentModel = /* @__PURE__ */ Symbol(`ParentModel`);
|
|
569
|
-
const LogConfig = /* @__PURE__ */ Symbol(`LogConfig`);
|
|
570
550
|
const ReferenceConfig = /* @__PURE__ */ Symbol(`ReferenceConfig`);
|
|
571
551
|
const KosModelSymbol = /* @__PURE__ */ Symbol(`KosModelSymbol`);
|
|
572
552
|
const ModelEffects = /* @__PURE__ */ Symbol(`ModelEffects`);
|
|
@@ -588,7 +568,7 @@ const KosViewModelSymbol = /* @__PURE__ */ Symbol(`KosViewModelSymbol`);
|
|
|
588
568
|
const ViewModelConfig = /* @__PURE__ */ Symbol(`ViewModelConfig`);
|
|
589
569
|
const ReloadAwareSetup = /* @__PURE__ */ Symbol(`ReloadAwareSetup`);
|
|
590
570
|
const MixinModels = /* @__PURE__ */ Symbol(`MixinModels`);
|
|
591
|
-
const log$
|
|
571
|
+
const log$1f = KosLog.createLogger({ group: LogGroup.core, name: "fsm-injection" });
|
|
592
572
|
function injectStateMachineSupport(modelInstance) {
|
|
593
573
|
const fsmSetup = modelInstance[StateMachineSetup];
|
|
594
574
|
if (!fsmSetup) return;
|
|
@@ -632,7 +612,7 @@ function initializeFsmProperties(modelInstance, options) {
|
|
|
632
612
|
const config2 = modelInstance._fsmConfig;
|
|
633
613
|
const initialState = computeInitialState ? computeInitialState(modelInstance) : config2.initial;
|
|
634
614
|
if (computeInitialState && !config2.states[initialState]) {
|
|
635
|
-
log$
|
|
615
|
+
log$1f.warn(
|
|
636
616
|
`computeInitialState returned "${initialState}" which is not a valid state. Falling back to "${config2.initial}".`
|
|
637
617
|
);
|
|
638
618
|
modelInstance[stateProperty] = config2.initial;
|
|
@@ -762,7 +742,7 @@ function handleAsyncEntryResult(instance, state, stateProperty, result) {
|
|
|
762
742
|
if (stateConfig.onError && instance[stateProperty] === state) {
|
|
763
743
|
instance.transition(stateConfig.onError);
|
|
764
744
|
} else {
|
|
765
|
-
log$
|
|
745
|
+
log$1f.error(`Async entry handler for state "${state}" failed:`, err);
|
|
766
746
|
}
|
|
767
747
|
}
|
|
768
748
|
);
|
|
@@ -803,7 +783,7 @@ function initializeStateMachine(modelInstance, lifecycle) {
|
|
|
803
783
|
modelInstance._fsmInitialized = true;
|
|
804
784
|
trackInitialStateInHistory(modelInstance, config2.initial, options);
|
|
805
785
|
executeInitialStateEntryHandler(modelInstance, config2.initial);
|
|
806
|
-
log$
|
|
786
|
+
log$1f.debug(
|
|
807
787
|
`FSM initialized for model ${modelInstance.id} at lifecycle ${lifecycle} with initial state "${config2.initial}"`
|
|
808
788
|
);
|
|
809
789
|
}
|
|
@@ -927,9 +907,12 @@ function getHttpRouteHandlers(model) {
|
|
|
927
907
|
return model?.[HttpRouteHandlers] || [];
|
|
928
908
|
}
|
|
929
909
|
class KosLoggerFactory {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
910
|
+
/**
|
|
911
|
+
* The logger for a model type, `model:::{modelTypeName}`. Every instance of
|
|
912
|
+
* the type shares it; put the instance id in the message where it matters.
|
|
913
|
+
*/
|
|
914
|
+
static create({ modelTypeName }) {
|
|
915
|
+
return KosLog.createLogger({ group: LogGroup.model, name: modelTypeName });
|
|
933
916
|
}
|
|
934
917
|
}
|
|
935
918
|
function kosLoggerAware(options) {
|
|
@@ -947,8 +930,7 @@ function kosLoggerAware(options) {
|
|
|
947
930
|
if (!sharedLogger) {
|
|
948
931
|
const modelType = getModelType();
|
|
949
932
|
sharedLogger = KosLoggerFactory.create({
|
|
950
|
-
modelTypeName: loggerContext || modelType
|
|
951
|
-
component: "kos-model"
|
|
933
|
+
modelTypeName: loggerContext || modelType
|
|
952
934
|
});
|
|
953
935
|
}
|
|
954
936
|
return sharedLogger;
|
|
@@ -999,7 +981,7 @@ class ServiceRequestError extends Error {
|
|
|
999
981
|
this.responseHeaders = details.responseHeaders ?? {};
|
|
1000
982
|
}
|
|
1001
983
|
}
|
|
1002
|
-
const log$
|
|
984
|
+
const log$1e = KosLog.createLogger({ group: LogGroup.core, name: "resolve-parameters" });
|
|
1003
985
|
const resolveParameters = ({
|
|
1004
986
|
value,
|
|
1005
987
|
modelId,
|
|
@@ -1031,11 +1013,11 @@ const resolveParameters = ({
|
|
|
1031
1013
|
)) {
|
|
1032
1014
|
const prop = modelData[propName];
|
|
1033
1015
|
if (prop !== null && prop !== void 0) {
|
|
1034
|
-
log$
|
|
1016
|
+
log$1e.debug(`Resolved ${match} to ${prop}`);
|
|
1035
1017
|
return prop;
|
|
1036
1018
|
} else {
|
|
1037
1019
|
const logLevel2 = isOnlyPropKey ? "debug" : "warn";
|
|
1038
|
-
log$
|
|
1020
|
+
log$1e[logLevel2](
|
|
1039
1021
|
`Property ${propName} is null or undefined${isOnlyPropKey ? "" : " in composite string"}, marking for undefined return`
|
|
1040
1022
|
);
|
|
1041
1023
|
hasUnresolvedProp = true;
|
|
@@ -1043,7 +1025,7 @@ const resolveParameters = ({
|
|
|
1043
1025
|
}
|
|
1044
1026
|
}
|
|
1045
1027
|
const logLevel = isOnlyPropKey ? "debug" : "warn";
|
|
1046
|
-
log$
|
|
1028
|
+
log$1e[logLevel](
|
|
1047
1029
|
`Property ${propName} not found in modelData${isOnlyPropKey ? "" : " for composite string"}`
|
|
1048
1030
|
);
|
|
1049
1031
|
return match;
|
|
@@ -1058,7 +1040,7 @@ const resolveParameters = ({
|
|
|
1058
1040
|
}
|
|
1059
1041
|
return _value;
|
|
1060
1042
|
};
|
|
1061
|
-
const log$
|
|
1043
|
+
const log$1d = KosLog.createLogger({ group: LogGroup.core, name: "ServiceRequestHelpers" });
|
|
1062
1044
|
function resolveServiceRequestParameters(metadata, modelInstance, args, runtimeOptions) {
|
|
1063
1045
|
const resolvedPath = resolveParameters({
|
|
1064
1046
|
value: metadata.path,
|
|
@@ -1127,7 +1109,7 @@ function handleServiceRequestError(error, response, errorHandler, modelInstance,
|
|
|
1127
1109
|
});
|
|
1128
1110
|
switch (errorHandler.strategy) {
|
|
1129
1111
|
case "log":
|
|
1130
|
-
log$
|
|
1112
|
+
log$1d.error(`Service request status ${richError.status} error: ${error}`);
|
|
1131
1113
|
if (errorHandler.onError) {
|
|
1132
1114
|
errorHandler.onError(richError, modelInstance);
|
|
1133
1115
|
}
|
|
@@ -1240,7 +1222,7 @@ var ReplayStrategy = /* @__PURE__ */ ((ReplayStrategy2) => {
|
|
|
1240
1222
|
ReplayStrategy2["NONE"] = "none";
|
|
1241
1223
|
return ReplayStrategy2;
|
|
1242
1224
|
})(ReplayStrategy || {});
|
|
1243
|
-
const log$
|
|
1225
|
+
const log$1c = KosLog.createLogger({ group: LogGroup.core, name: "kos-state-machine" });
|
|
1244
1226
|
function kosStateMachine(config2, options) {
|
|
1245
1227
|
return (target) => {
|
|
1246
1228
|
target.prototype[StateMachineSetup] = {
|
|
@@ -1297,7 +1279,7 @@ function kosStateGuard(options) {
|
|
|
1297
1279
|
if (shouldThrow) {
|
|
1298
1280
|
throw new Error(message);
|
|
1299
1281
|
} else {
|
|
1300
|
-
log$
|
|
1282
|
+
log$1c.warn(message);
|
|
1301
1283
|
return void 0;
|
|
1302
1284
|
}
|
|
1303
1285
|
}
|
|
@@ -1323,6 +1305,10 @@ const kosDependency = ({
|
|
|
1323
1305
|
resolutionPolicy
|
|
1324
1306
|
};
|
|
1325
1307
|
};
|
|
1308
|
+
const log$1b = KosLog.createLogger({
|
|
1309
|
+
group: LogGroup.model,
|
|
1310
|
+
name: "future-aware"
|
|
1311
|
+
});
|
|
1326
1312
|
class MultipleFutureHandler {
|
|
1327
1313
|
futures;
|
|
1328
1314
|
defaultContext;
|
|
@@ -1413,7 +1399,7 @@ class FutureHandler {
|
|
|
1413
1399
|
try {
|
|
1414
1400
|
await this._future.cancelFuture();
|
|
1415
1401
|
} catch (e) {
|
|
1416
|
-
|
|
1402
|
+
log$1b.error(e);
|
|
1417
1403
|
throw e;
|
|
1418
1404
|
}
|
|
1419
1405
|
}
|
|
@@ -1538,6 +1524,10 @@ const ObservableData = (initialData) => {
|
|
|
1538
1524
|
const od = createObservableData(ObservableDataMap, initialData);
|
|
1539
1525
|
return new od(initialData);
|
|
1540
1526
|
};
|
|
1527
|
+
const log$1a = KosLog.createLogger({
|
|
1528
|
+
group: LogGroup.core,
|
|
1529
|
+
name: "extension-manager"
|
|
1530
|
+
});
|
|
1541
1531
|
const DEFAULT_EXTENSION_OPTIONS = {
|
|
1542
1532
|
failurePolicy: "throw"
|
|
1543
1533
|
};
|
|
@@ -1589,8 +1579,8 @@ const _ExtensionManager = {
|
|
|
1589
1579
|
return await loader(data);
|
|
1590
1580
|
} catch (e) {
|
|
1591
1581
|
if (options.failurePolicy === "continue") {
|
|
1592
|
-
|
|
1593
|
-
|
|
1582
|
+
log$1a.error(`Error executing data loader for id ${id}`);
|
|
1583
|
+
log$1a.error(e);
|
|
1594
1584
|
return void 0;
|
|
1595
1585
|
}
|
|
1596
1586
|
throw new ExtensionException(id, "dataLoader", e);
|
|
@@ -1615,8 +1605,8 @@ const _ExtensionManager = {
|
|
|
1615
1605
|
return mapper(data, context);
|
|
1616
1606
|
} catch (e) {
|
|
1617
1607
|
if (options.failurePolicy === "continue") {
|
|
1618
|
-
|
|
1619
|
-
|
|
1608
|
+
log$1a.error(`Error executing property mapper for id ${id}`);
|
|
1609
|
+
log$1a.error(e);
|
|
1620
1610
|
return "";
|
|
1621
1611
|
}
|
|
1622
1612
|
throw new ExtensionException(id, "propertyMapper", e);
|
|
@@ -1644,8 +1634,8 @@ const _ExtensionManager = {
|
|
|
1644
1634
|
Object.assign(result, _interim);
|
|
1645
1635
|
} catch (e) {
|
|
1646
1636
|
if (options.failurePolicy === "continue") {
|
|
1647
|
-
|
|
1648
|
-
|
|
1637
|
+
log$1a.error(`Error executing data mapper for id ${id}`);
|
|
1638
|
+
log$1a.error(e);
|
|
1649
1639
|
continue;
|
|
1650
1640
|
}
|
|
1651
1641
|
throw new ExtensionException(id, "dataMapper", e);
|
|
@@ -1657,7 +1647,7 @@ const _ExtensionManager = {
|
|
|
1657
1647
|
canvas: {
|
|
1658
1648
|
registerRenderer: (id, renderer) => {
|
|
1659
1649
|
if (!ExtensionManager[EXTENSION_CANVAS_RENDERER]) {
|
|
1660
|
-
|
|
1650
|
+
log$1a.warn(
|
|
1661
1651
|
`Canvas renderer extension point is not registered. Cannot register renderer "${id}".`
|
|
1662
1652
|
);
|
|
1663
1653
|
return;
|
|
@@ -1683,6 +1673,10 @@ const INDEX_COLLECTION_KEY = "@kosdev-code/kos-ui-sdk.collection";
|
|
|
1683
1673
|
function isIndexableItem(value) {
|
|
1684
1674
|
return typeof value === "object" && value !== null && INDEX_RECORD_SYMBOL in value;
|
|
1685
1675
|
}
|
|
1676
|
+
const log$19 = KosLog.createLogger({
|
|
1677
|
+
group: LogGroup.core,
|
|
1678
|
+
name: "kos-container-index"
|
|
1679
|
+
});
|
|
1686
1680
|
function isPromiseLike(value) {
|
|
1687
1681
|
return typeof value?.then === "function";
|
|
1688
1682
|
}
|
|
@@ -1734,7 +1728,7 @@ class KosContainerIndex {
|
|
|
1734
1728
|
const set = map.get(key) || /* @__PURE__ */ new Set();
|
|
1735
1729
|
this._map.set(key, set);
|
|
1736
1730
|
} else {
|
|
1737
|
-
|
|
1731
|
+
log$19.debug(`KosContainerIndex - Index ${key} is the same`);
|
|
1738
1732
|
}
|
|
1739
1733
|
});
|
|
1740
1734
|
}
|
|
@@ -1810,7 +1804,7 @@ function observeComputedProperties(model, callback, keys = []) {
|
|
|
1810
1804
|
);
|
|
1811
1805
|
return disposers;
|
|
1812
1806
|
}
|
|
1813
|
-
const log$
|
|
1807
|
+
const log$18 = KosLog.createLogger({ group: LogGroup.core, name: "kos-container-model" });
|
|
1814
1808
|
class KosModelContainer {
|
|
1815
1809
|
_data;
|
|
1816
1810
|
_sortKey;
|
|
@@ -1932,14 +1926,14 @@ class KosModelContainer {
|
|
|
1932
1926
|
async removeAndDestroy(id) {
|
|
1933
1927
|
const model = this.getModel(id);
|
|
1934
1928
|
if (!model) {
|
|
1935
|
-
log$
|
|
1929
|
+
log$18.debug(`Model ${id} not found in container, skipping destroy`);
|
|
1936
1930
|
return;
|
|
1937
1931
|
}
|
|
1938
1932
|
this.removeModel(id);
|
|
1939
1933
|
try {
|
|
1940
1934
|
await destroyKosModel(model);
|
|
1941
1935
|
} catch (error) {
|
|
1942
|
-
log$
|
|
1936
|
+
log$18.error(`Failed to destroy model ${id}:`, error);
|
|
1943
1937
|
throw error;
|
|
1944
1938
|
}
|
|
1945
1939
|
}
|
|
@@ -1956,7 +1950,7 @@ class KosModelContainer {
|
|
|
1956
1950
|
async removeAndDestroyAll(ids) {
|
|
1957
1951
|
const models2 = ids.map((id) => this.getModel(id)).filter((model) => model !== void 0);
|
|
1958
1952
|
if (models2.length === 0) {
|
|
1959
|
-
log$
|
|
1953
|
+
log$18.debug("No models found to destroy");
|
|
1960
1954
|
return;
|
|
1961
1955
|
}
|
|
1962
1956
|
this.removeAll(ids);
|
|
@@ -1965,7 +1959,7 @@ class KosModelContainer {
|
|
|
1965
1959
|
);
|
|
1966
1960
|
results.forEach((result, index) => {
|
|
1967
1961
|
if (result.status === "rejected") {
|
|
1968
|
-
log$
|
|
1962
|
+
log$18.error(
|
|
1969
1963
|
`Failed to destroy model ${models2[index].id}:`,
|
|
1970
1964
|
result.reason
|
|
1971
1965
|
);
|
|
@@ -2138,7 +2132,7 @@ class KosModelContainer {
|
|
|
2138
2132
|
const idx = this.index.get(indexName);
|
|
2139
2133
|
return idx.keys ?? [];
|
|
2140
2134
|
} else {
|
|
2141
|
-
log$
|
|
2135
|
+
log$18.info(
|
|
2142
2136
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2143
2137
|
);
|
|
2144
2138
|
return [];
|
|
@@ -2150,7 +2144,7 @@ class KosModelContainer {
|
|
|
2150
2144
|
if (idx.index.has(indexKey)) {
|
|
2151
2145
|
return idx.getByKey(indexKey);
|
|
2152
2146
|
} else {
|
|
2153
|
-
log$
|
|
2147
|
+
log$18.info(
|
|
2154
2148
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
2155
2149
|
idx.index.keys()
|
|
2156
2150
|
)}`
|
|
@@ -2158,7 +2152,7 @@ class KosModelContainer {
|
|
|
2158
2152
|
return [];
|
|
2159
2153
|
}
|
|
2160
2154
|
} else {
|
|
2161
|
-
log$
|
|
2155
|
+
log$18.info(
|
|
2162
2156
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2163
2157
|
);
|
|
2164
2158
|
return [];
|
|
@@ -2185,7 +2179,7 @@ class KosModelContainer {
|
|
|
2185
2179
|
* @private
|
|
2186
2180
|
*/
|
|
2187
2181
|
_logCapacityWarning(toEvict) {
|
|
2188
|
-
log$
|
|
2182
|
+
log$18.info(
|
|
2189
2183
|
`Container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${toEvict} models using ${this._evictionStrategy} strategy.`,
|
|
2190
2184
|
{ parentId: this._parentId }
|
|
2191
2185
|
);
|
|
@@ -2248,7 +2242,7 @@ class KosModelContainer {
|
|
|
2248
2242
|
const candidates = this._customEvictionFilter(this.data);
|
|
2249
2243
|
return candidates.slice(0, count);
|
|
2250
2244
|
}
|
|
2251
|
-
log$
|
|
2245
|
+
log$18.error(
|
|
2252
2246
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO.",
|
|
2253
2247
|
{ parentId: this._parentId }
|
|
2254
2248
|
);
|
|
@@ -2260,7 +2254,7 @@ class KosModelContainer {
|
|
|
2260
2254
|
*/
|
|
2261
2255
|
async _removeEvictedModels(models2) {
|
|
2262
2256
|
for (const model of models2) {
|
|
2263
|
-
log$
|
|
2257
|
+
log$18.info(
|
|
2264
2258
|
`Evicting model: ${model.id} (type: ${model.constructor.name})`,
|
|
2265
2259
|
{
|
|
2266
2260
|
modelId: model.id,
|
|
@@ -2270,7 +2264,7 @@ class KosModelContainer {
|
|
|
2270
2264
|
);
|
|
2271
2265
|
this.removeModel(model.id, true);
|
|
2272
2266
|
destroyKosModel(model).catch(
|
|
2273
|
-
(e) => log$
|
|
2267
|
+
(e) => log$18.error(`Failed to destroy evicted model ${model.id}:`, e)
|
|
2274
2268
|
);
|
|
2275
2269
|
}
|
|
2276
2270
|
}
|
|
@@ -2279,7 +2273,7 @@ class KosModelContainer {
|
|
|
2279
2273
|
* @private
|
|
2280
2274
|
*/
|
|
2281
2275
|
_logEvictionComplete(evictedCount) {
|
|
2282
|
-
log$
|
|
2276
|
+
log$18.info(
|
|
2283
2277
|
`Evicted ${evictedCount} models. Current size: ${this._data.size}/${this._maxCapacity}`,
|
|
2284
2278
|
{ parentId: this._parentId }
|
|
2285
2279
|
);
|
|
@@ -2288,9 +2282,9 @@ class KosModelContainer {
|
|
|
2288
2282
|
this._data.forEach((model) => {
|
|
2289
2283
|
const modelId = model.id;
|
|
2290
2284
|
destroyKosModel(model).then(() => {
|
|
2291
|
-
log$
|
|
2285
|
+
log$18.debug(`${modelId} destroyed, removing from map`);
|
|
2292
2286
|
this.removeModel(modelId, true);
|
|
2293
|
-
}).catch((e) => log$
|
|
2287
|
+
}).catch((e) => log$18.error(e));
|
|
2294
2288
|
});
|
|
2295
2289
|
this.increment();
|
|
2296
2290
|
}
|
|
@@ -2433,12 +2427,16 @@ const whenReady = async (dataModel) => {
|
|
|
2433
2427
|
}
|
|
2434
2428
|
return dataModel;
|
|
2435
2429
|
};
|
|
2430
|
+
const log$17 = KosLog.createLogger({
|
|
2431
|
+
group: LogGroup.core,
|
|
2432
|
+
name: "kos-model-utils"
|
|
2433
|
+
});
|
|
2436
2434
|
const destroyKosModel = async (model) => {
|
|
2437
2435
|
await KosCore.getInstance().whenReady();
|
|
2438
2436
|
await KosCore.getInstance().modelManager.initiateDestroyModel(model);
|
|
2439
2437
|
};
|
|
2440
2438
|
const unloadKosModel = async (dataModel) => {
|
|
2441
|
-
|
|
2439
|
+
log$17.warn(
|
|
2442
2440
|
`unloadKosModel(${dataModel?.id}) is deprecated and never resolves. Use destroyKosModel() to release a model, or reload() to refresh it.`
|
|
2443
2441
|
);
|
|
2444
2442
|
await KosCore.getInstance().whenReady();
|
|
@@ -2451,16 +2449,16 @@ const unloadKosModel = async (dataModel) => {
|
|
|
2451
2449
|
}
|
|
2452
2450
|
};
|
|
2453
2451
|
const resetKosModel = async (model) => {
|
|
2454
|
-
|
|
2452
|
+
log$17.warn(
|
|
2455
2453
|
`resetKosModel(${model?.id}) is deprecated: the reset route drops every topic handler registered at INIT or with no lifecycle. Implement reload() on the model and refetch and reconcile in place.`
|
|
2456
2454
|
);
|
|
2457
2455
|
await KosCore.getInstance().whenReady();
|
|
2458
2456
|
await KosCore.getInstance().modelManager.reloadModel(model);
|
|
2459
|
-
|
|
2457
|
+
log$17.debug(
|
|
2460
2458
|
`reload model initiated for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2461
2459
|
);
|
|
2462
2460
|
await whenReady(model);
|
|
2463
|
-
|
|
2461
|
+
log$17.debug(
|
|
2464
2462
|
`reload model complete for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2465
2463
|
);
|
|
2466
2464
|
};
|
|
@@ -2536,7 +2534,7 @@ const getObservableCompanions = (modelId) => {
|
|
|
2536
2534
|
const resolveKosCompanion = (modelId, resolver) => {
|
|
2537
2535
|
const model = KosCore.getInstance().modelManager.getModelById(modelId);
|
|
2538
2536
|
if (!model) {
|
|
2539
|
-
|
|
2537
|
+
log$17.info(`Model not found for id ${modelId}`);
|
|
2540
2538
|
return void 0;
|
|
2541
2539
|
}
|
|
2542
2540
|
const companionModel = Array.from(model.companionModels.all()).find(
|
|
@@ -2575,7 +2573,7 @@ const getKosModelActivationState = (model) => {
|
|
|
2575
2573
|
}
|
|
2576
2574
|
};
|
|
2577
2575
|
};
|
|
2578
|
-
const log$
|
|
2576
|
+
const log$16 = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-factory" });
|
|
2579
2577
|
const KosModelFactory = {
|
|
2580
2578
|
byModelType: (modelType) => KosCore.getInstance().modelManager.getModelFactory(
|
|
2581
2579
|
modelType
|
|
@@ -2583,7 +2581,7 @@ const KosModelFactory = {
|
|
|
2583
2581
|
getModelInstance: (id, modelType, options) => {
|
|
2584
2582
|
const factory = KosModelFactory.byModelType(modelType);
|
|
2585
2583
|
if (!factory) {
|
|
2586
|
-
log$
|
|
2584
|
+
log$16.error(
|
|
2587
2585
|
`No registered factory found for model type ${modelType}. Please register a factory for this model type. `
|
|
2588
2586
|
);
|
|
2589
2587
|
throw Error(`No factory found for model type ${modelType}`);
|
|
@@ -2622,6 +2620,10 @@ const Kos = {
|
|
|
2622
2620
|
instance: (modelType) => (id) => KosModelFactory.getModelInstance(id, modelType)
|
|
2623
2621
|
}
|
|
2624
2622
|
};
|
|
2623
|
+
const log$15 = KosLog.createLogger({
|
|
2624
|
+
group: LogGroup.core,
|
|
2625
|
+
name: "registration-manager"
|
|
2626
|
+
});
|
|
2625
2627
|
window.KosRegistry = window.KosRegistry || {
|
|
2626
2628
|
coreModels: /* @__PURE__ */ new Map(),
|
|
2627
2629
|
preloadModels: [],
|
|
@@ -2666,7 +2668,7 @@ const RegistrationManager = {
|
|
|
2666
2668
|
}
|
|
2667
2669
|
if (KosCore.getInstance().isReady) {
|
|
2668
2670
|
if (!KosCore.getInstance().modelManager.registry.models[register.type]) {
|
|
2669
|
-
|
|
2671
|
+
log$15.info(
|
|
2670
2672
|
`Model with type ${register.type} doesn't exist. Adding new registration`
|
|
2671
2673
|
);
|
|
2672
2674
|
KosCore.getInstance().modelManager.registry.models[register.type] = register.registration[register.type];
|
|
@@ -2898,7 +2900,7 @@ class SingletonKosModelRegistrationFactory extends KosBaseModelRegistration {
|
|
|
2898
2900
|
};
|
|
2899
2901
|
}
|
|
2900
2902
|
}
|
|
2901
|
-
const log$
|
|
2903
|
+
const log$14 = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
2902
2904
|
const FUTURE_CANCEL_END_STATE = "CANCEL";
|
|
2903
2905
|
function resolveParentContext(TargetClass, modelId, modelData) {
|
|
2904
2906
|
const parentIdRaw = TargetClass[ParentModel]?.parentId;
|
|
@@ -3193,7 +3195,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3193
3195
|
const { mode, parentProperty, excludeProperties } = companionConfig;
|
|
3194
3196
|
const parentModel = initialData.companionParent;
|
|
3195
3197
|
if (!parentModel) {
|
|
3196
|
-
log$
|
|
3198
|
+
log$14.warn(
|
|
3197
3199
|
`Companion decorator configured but no parent model found in initialData.companionParent`
|
|
3198
3200
|
);
|
|
3199
3201
|
return;
|
|
@@ -3267,7 +3269,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3267
3269
|
});
|
|
3268
3270
|
}
|
|
3269
3271
|
} catch (error) {
|
|
3270
|
-
log$
|
|
3272
|
+
log$14.debug(
|
|
3271
3273
|
`Skipping companion proxy for property ${propertyName}:`,
|
|
3272
3274
|
error
|
|
3273
3275
|
);
|
|
@@ -3304,7 +3306,7 @@ function makeSafeObservable(instance) {
|
|
|
3304
3306
|
try {
|
|
3305
3307
|
return mobx.makeAutoObservable(instance);
|
|
3306
3308
|
} catch (e) {
|
|
3307
|
-
log$
|
|
3309
|
+
log$14.error("Failed to make observable:", e);
|
|
3308
3310
|
return instance;
|
|
3309
3311
|
}
|
|
3310
3312
|
}
|
|
@@ -3314,9 +3316,8 @@ const modelConstructorProxy = {
|
|
|
3314
3316
|
const kosContext = KosContextManager.createContext(modelId);
|
|
3315
3317
|
resolveParentContext(TargetClass, modelId, initialData);
|
|
3316
3318
|
const hasLoggerAware = !!TargetClass.prototype[LoggerSetup];
|
|
3317
|
-
const logger = hasLoggerAware ? null :
|
|
3318
|
-
|
|
3319
|
-
group: TargetClass[LogConfig]?.group ?? "kos-model"
|
|
3319
|
+
const logger = hasLoggerAware ? null : KosLoggerFactory.create({
|
|
3320
|
+
modelTypeName: TargetClass.prototype.modelTypeId
|
|
3320
3321
|
});
|
|
3321
3322
|
const modelInstance = new TargetClass(modelId, initialData, {
|
|
3322
3323
|
logger,
|
|
@@ -3347,8 +3348,8 @@ function kosModel(config2) {
|
|
|
3347
3348
|
typedCtor.prototype[OptionsRequired] = true;
|
|
3348
3349
|
}
|
|
3349
3350
|
KosLog.ifDebug(() => {
|
|
3350
|
-
|
|
3351
|
-
});
|
|
3351
|
+
log$14.debug(`Registering model with id ${modelConfig.modelTypeId}`);
|
|
3352
|
+
}, log$14);
|
|
3352
3353
|
const proxiedCtor = new Proxy(typedCtor, modelConstructorProxy);
|
|
3353
3354
|
if (modelConfig.singleton !== void 0) {
|
|
3354
3355
|
let registration;
|
|
@@ -3644,7 +3645,7 @@ const KosDeletionManager = {
|
|
|
3644
3645
|
}
|
|
3645
3646
|
}
|
|
3646
3647
|
};
|
|
3647
|
-
const log$
|
|
3648
|
+
const log$13 = KosLog.createLogger({ group: LogGroup.core, name: "kos-dependency-manager" });
|
|
3648
3649
|
class KosDependencyManager {
|
|
3649
3650
|
_usedByCache = /* @__PURE__ */ new Map();
|
|
3650
3651
|
_usesCache = /* @__PURE__ */ new Map();
|
|
@@ -3699,7 +3700,7 @@ class KosDependencyManager {
|
|
|
3699
3700
|
canDestroy(modelId) {
|
|
3700
3701
|
const usedBy = this._usedByCache.get(modelId);
|
|
3701
3702
|
if (usedBy?.length) {
|
|
3702
|
-
log$
|
|
3703
|
+
log$13.info(`Model ${modelId} is still used by: ${usedBy.join(", ")}`);
|
|
3703
3704
|
return false;
|
|
3704
3705
|
}
|
|
3705
3706
|
return true;
|
|
@@ -3709,7 +3710,7 @@ class KosDependencyManager {
|
|
|
3709
3710
|
this._usesCache.clear();
|
|
3710
3711
|
}
|
|
3711
3712
|
}
|
|
3712
|
-
const log$
|
|
3713
|
+
const log$12 = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-cache" });
|
|
3713
3714
|
class KosModelCache {
|
|
3714
3715
|
constructor(preloadKeys = []) {
|
|
3715
3716
|
this.preloadKeys = preloadKeys;
|
|
@@ -3760,11 +3761,11 @@ class KosModelCache {
|
|
|
3760
3761
|
}
|
|
3761
3762
|
preload(createFn) {
|
|
3762
3763
|
if (this._isPreloaded) {
|
|
3763
|
-
log$
|
|
3764
|
+
log$12.debug("Returning cached preloaded models");
|
|
3764
3765
|
return this._preloaded;
|
|
3765
3766
|
}
|
|
3766
3767
|
this._preloaded = this.preloadKeys.map((key) => {
|
|
3767
|
-
log$
|
|
3768
|
+
log$12.debug(
|
|
3768
3769
|
`Preloading model: ${typeof key === "string" ? key : key.modelType}`
|
|
3769
3770
|
);
|
|
3770
3771
|
return createFn(key);
|
|
@@ -3786,6 +3787,10 @@ const clearModelHookCacheEntry = (modelId) => {
|
|
|
3786
3787
|
cache.delete(modelId);
|
|
3787
3788
|
}
|
|
3788
3789
|
};
|
|
3790
|
+
const log$11 = KosLog.createLogger({
|
|
3791
|
+
group: LogGroup.core,
|
|
3792
|
+
name: "model-error-utils"
|
|
3793
|
+
});
|
|
3789
3794
|
class KosModelError extends Error {
|
|
3790
3795
|
context;
|
|
3791
3796
|
originalCause;
|
|
@@ -3847,10 +3852,10 @@ function enrichError(error, context) {
|
|
|
3847
3852
|
}
|
|
3848
3853
|
function logErrorCollection(errors, summary) {
|
|
3849
3854
|
if (errors.length === 0) return;
|
|
3850
|
-
|
|
3855
|
+
log$11.error(`${summary} - ${errors.length} error(s) occurred:`);
|
|
3851
3856
|
errors.forEach(({ error, context }, index) => {
|
|
3852
3857
|
const enriched = error instanceof KosModelError ? error : enrichError(error, context);
|
|
3853
|
-
|
|
3858
|
+
log$11.error(
|
|
3854
3859
|
` [${index + 1}/${errors.length}] ${enriched.toDetailedString()}`
|
|
3855
3860
|
);
|
|
3856
3861
|
});
|
|
@@ -3866,7 +3871,7 @@ function logModelInstantiationError(error, context) {
|
|
|
3866
3871
|
});
|
|
3867
3872
|
}
|
|
3868
3873
|
const isKosCompanionTypeFactory = (obj) => typeof obj === "function";
|
|
3869
|
-
const log$
|
|
3874
|
+
const log$10 = KosLog.createLogger({ group: LogGroup.core, name: "kos-companion-instantiator" });
|
|
3870
3875
|
class KosCompanionInstantiator {
|
|
3871
3876
|
constructor(registry, cache2, createModel) {
|
|
3872
3877
|
this.registry = registry;
|
|
@@ -3888,7 +3893,7 @@ class KosCompanionInstantiator {
|
|
|
3888
3893
|
createCompanionModels(model, options, lifecycle) {
|
|
3889
3894
|
const companionDefs = this.getCompanionDefinitions(model.modelTypeName);
|
|
3890
3895
|
if (lifecycle !== void 0) {
|
|
3891
|
-
log$
|
|
3896
|
+
log$10.debug(
|
|
3892
3897
|
`Creating ${lifecycle} lifecycle companions for ${model.modelTypeName} [${model.modelId}]`
|
|
3893
3898
|
);
|
|
3894
3899
|
}
|
|
@@ -3940,7 +3945,7 @@ class KosCompanionInstantiator {
|
|
|
3940
3945
|
mobx.runInAction(() => {
|
|
3941
3946
|
model.modelData[property] = mixin.modelData;
|
|
3942
3947
|
});
|
|
3943
|
-
log$
|
|
3948
|
+
log$10.debug(
|
|
3944
3949
|
`Created mixin ${registration.type} for ${model.modelTypeName} [${model.modelId}]`
|
|
3945
3950
|
);
|
|
3946
3951
|
});
|
|
@@ -3972,7 +3977,7 @@ class KosCompanionInstantiator {
|
|
|
3972
3977
|
resolveFactoryCompanion(companionDef, model, options, requestedLifecycle) {
|
|
3973
3978
|
const companionType = companionDef.type(model.modelData, options);
|
|
3974
3979
|
if (!companionType) {
|
|
3975
|
-
log$
|
|
3980
|
+
log$10.debug(
|
|
3976
3981
|
`Companion factory returned undefined for ${model.modelTypeName} at ${requestedLifecycle || "INIT"} phase`
|
|
3977
3982
|
);
|
|
3978
3983
|
return null;
|
|
@@ -4031,7 +4036,7 @@ class KosCompanionInstantiator {
|
|
|
4031
4036
|
);
|
|
4032
4037
|
if (companion) {
|
|
4033
4038
|
this.attachCompanionToParent(companion, parentModel);
|
|
4034
|
-
log$
|
|
4039
|
+
log$10.debug(
|
|
4035
4040
|
`Created ${lifecycle || "INIT"} companion ${companionType} for ${parentModel.modelTypeName} [${parentModel.modelId}]`
|
|
4036
4041
|
);
|
|
4037
4042
|
}
|
|
@@ -4047,7 +4052,7 @@ class KosCompanionInstantiator {
|
|
|
4047
4052
|
*/
|
|
4048
4053
|
companionAlreadyExists(companionId, companionType, parentTypeName) {
|
|
4049
4054
|
if (this.cache.hasModel(companionId)) {
|
|
4050
|
-
log$
|
|
4055
|
+
log$10.debug(
|
|
4051
4056
|
`Companion ${companionType} already exists for ${parentTypeName}`
|
|
4052
4057
|
);
|
|
4053
4058
|
return true;
|
|
@@ -4132,6 +4137,10 @@ const TransitionMap = {
|
|
|
4132
4137
|
/* INIT */
|
|
4133
4138
|
]: transitionToInit
|
|
4134
4139
|
};
|
|
4140
|
+
const log$$ = KosLog.createLogger({
|
|
4141
|
+
group: LogGroup.core,
|
|
4142
|
+
name: "promise-utils"
|
|
4143
|
+
});
|
|
4135
4144
|
class ModelError extends Error {
|
|
4136
4145
|
model;
|
|
4137
4146
|
constructor(message, model) {
|
|
@@ -4143,7 +4152,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4143
4152
|
let timeoutId;
|
|
4144
4153
|
const promise = new Promise((_, reject) => {
|
|
4145
4154
|
timeoutId = setTimeout(() => {
|
|
4146
|
-
|
|
4155
|
+
log$$.error(
|
|
4147
4156
|
`Model ${model.modelId} - ${model.modelTypeName} - ${status} timed out after ${ms}ms`
|
|
4148
4157
|
);
|
|
4149
4158
|
reject(
|
|
@@ -4159,6 +4168,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4159
4168
|
};
|
|
4160
4169
|
return { promise, cancel };
|
|
4161
4170
|
};
|
|
4171
|
+
const log$_ = KosLog.createLogger({ group: LogGroup.core, name: "model-utils" });
|
|
4162
4172
|
const createModelDependency = (model, dependency) => {
|
|
4163
4173
|
const _dataModelId = dependency.id || dependency.modelType;
|
|
4164
4174
|
const dataModelId = resolveParameters({
|
|
@@ -4167,7 +4177,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4167
4177
|
modelId: model.modelId
|
|
4168
4178
|
});
|
|
4169
4179
|
const resolutionPolicy = dependency.resolutionPolicy || DependencyResolutionPolicy.CREATE;
|
|
4170
|
-
|
|
4180
|
+
log$_.debug(
|
|
4171
4181
|
`Resolving dependent model ${dependency.modelType} with id ${dataModelId} (policy: ${resolutionPolicy})`
|
|
4172
4182
|
);
|
|
4173
4183
|
const options = Object.keys(dependency?.options || {}).reduce((acc, curr) => {
|
|
@@ -4183,7 +4193,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4183
4193
|
const modelRegistry = modelManager.registry.models[dependency.modelType];
|
|
4184
4194
|
if (!modelRegistry) {
|
|
4185
4195
|
const errorMessage = `No model registered for type ${dependency.modelType}`;
|
|
4186
|
-
|
|
4196
|
+
log$_.error(
|
|
4187
4197
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4188
4198
|
- Dependency Type: ${dependency.modelType}
|
|
4189
4199
|
- Dependency ID: ${dataModelId}
|
|
@@ -4193,7 +4203,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4193
4203
|
- Error: ${errorMessage}`
|
|
4194
4204
|
);
|
|
4195
4205
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4196
|
-
|
|
4206
|
+
log$_.warn(
|
|
4197
4207
|
`Model type not registered (policy: CONTINUE) - Model ${model.modelId} will continue without dependency ${dependency.modelType} [${dataModelId}]`
|
|
4198
4208
|
);
|
|
4199
4209
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4206,7 +4216,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4206
4216
|
if (existingModel) {
|
|
4207
4217
|
if (existingModel.modelTypeName !== dependency.modelType) {
|
|
4208
4218
|
const errorMessage = `Model type mismatch: expected ${dependency.modelType}, found ${existingModel.modelTypeName}`;
|
|
4209
|
-
|
|
4219
|
+
log$_.error(
|
|
4210
4220
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4211
4221
|
- Dependency Type: ${dependency.modelType}
|
|
4212
4222
|
- Dependency ID: ${dataModelId}
|
|
@@ -4217,7 +4227,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4217
4227
|
- Error: ${errorMessage}`
|
|
4218
4228
|
);
|
|
4219
4229
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4220
|
-
|
|
4230
|
+
log$_.warn(
|
|
4221
4231
|
`Model type mismatch (policy: CONTINUE) - Model ${model.modelId} will continue without dependency`
|
|
4222
4232
|
);
|
|
4223
4233
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4226,7 +4236,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4226
4236
|
`Dependency resolution failed - Model ${model.modelId} cannot resolve dependency ${dependency.modelType} [${dataModelId}]: ${errorMessage}`
|
|
4227
4237
|
);
|
|
4228
4238
|
}
|
|
4229
|
-
|
|
4239
|
+
log$_.debug(
|
|
4230
4240
|
`Found existing dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4231
4241
|
);
|
|
4232
4242
|
return {
|
|
@@ -4235,18 +4245,18 @@ const createModelDependency = (model, dependency) => {
|
|
|
4235
4245
|
success: true
|
|
4236
4246
|
};
|
|
4237
4247
|
}
|
|
4238
|
-
|
|
4248
|
+
log$_.debug(
|
|
4239
4249
|
`Model ${dependency.modelType} [${dataModelId}] does not exist. Applying resolution policy: ${resolutionPolicy}`
|
|
4240
4250
|
);
|
|
4241
4251
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4242
|
-
|
|
4252
|
+
log$_.warn(
|
|
4243
4253
|
`Model ${dependency.modelType} [${dataModelId}] not found (policy: CONTINUE) - Model ${model.modelId} will continue without this dependency`
|
|
4244
4254
|
);
|
|
4245
4255
|
return { dependentModel: null, dataModelId, success: false };
|
|
4246
4256
|
}
|
|
4247
4257
|
if (resolutionPolicy === DependencyResolutionPolicy.FAIL) {
|
|
4248
4258
|
const errorMessage = `No ${dependency.modelType} model with id ${dataModelId} exists`;
|
|
4249
|
-
|
|
4259
|
+
log$_.error(
|
|
4250
4260
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4251
4261
|
- Dependency Type: ${dependency.modelType}
|
|
4252
4262
|
- Dependency ID: ${dataModelId}
|
|
@@ -4264,7 +4274,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4264
4274
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
4265
4275
|
if (requiresOptions && !hasOptions) {
|
|
4266
4276
|
const errorMessage = `Model ${dependency.modelType} requires options but none were provided`;
|
|
4267
|
-
|
|
4277
|
+
log$_.error(
|
|
4268
4278
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4269
4279
|
- Dependency Type: ${dependency.modelType}
|
|
4270
4280
|
- Dependency ID: ${dataModelId}
|
|
@@ -4285,13 +4295,13 @@ const createModelDependency = (model, dependency) => {
|
|
|
4285
4295
|
dataModelId,
|
|
4286
4296
|
options
|
|
4287
4297
|
);
|
|
4288
|
-
|
|
4298
|
+
log$_.debug(
|
|
4289
4299
|
`Successfully created dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4290
4300
|
);
|
|
4291
4301
|
return { dependentModel, dataModelId, success: true };
|
|
4292
4302
|
} catch (error) {
|
|
4293
4303
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4294
|
-
|
|
4304
|
+
log$_.error(
|
|
4295
4305
|
`Failed to create dependency for model ${model.modelId}:
|
|
4296
4306
|
- Dependency Type: ${dependency.modelType}
|
|
4297
4307
|
- Dependency ID: ${dataModelId}
|
|
@@ -4307,14 +4317,14 @@ const createModelDependency = (model, dependency) => {
|
|
|
4307
4317
|
const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY) => {
|
|
4308
4318
|
const dependencies = model.modelData?.[DependencyModels] || {};
|
|
4309
4319
|
if (Object.keys(dependencies).length === 0) {
|
|
4310
|
-
|
|
4320
|
+
log$_.debug(`${model.modelId} has no dependencies. Returning`);
|
|
4311
4321
|
return [];
|
|
4312
4322
|
}
|
|
4313
4323
|
const dependenciesByLifecycle = Object.keys(dependencies).filter((key) => dependencies[key].lifecycle === lifecycle).map((key) => {
|
|
4314
4324
|
const dependency = dependencies[key];
|
|
4315
4325
|
const resolutionResult = createModelDependency(model, dependency);
|
|
4316
4326
|
if (!resolutionResult.success || !resolutionResult.dependentModel) {
|
|
4317
|
-
|
|
4327
|
+
log$_.debug(
|
|
4318
4328
|
`Skipping dependency ${dependency.modelType} with id ${resolutionResult.dataModelId} - resolution failed with CONTINUE policy`
|
|
4319
4329
|
);
|
|
4320
4330
|
model.modelData[key] = void 0;
|
|
@@ -4322,12 +4332,12 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4322
4332
|
}
|
|
4323
4333
|
const { dependentModel, dataModelId } = resolutionResult;
|
|
4324
4334
|
model.modelData[key] = dependentModel.data;
|
|
4325
|
-
|
|
4335
|
+
log$_.debug(
|
|
4326
4336
|
`waiting for dependent model ${dependency.modelType} with id ${dataModelId} - waiting for WHENREADY`
|
|
4327
4337
|
);
|
|
4328
4338
|
const readyFn = async (dependentModel2, modelType, id) => {
|
|
4329
4339
|
await dependentModel2.whenReady?.();
|
|
4330
|
-
|
|
4340
|
+
log$_.debug(`dependent model ${modelType} with id ${id} - READY`);
|
|
4331
4341
|
};
|
|
4332
4342
|
const { promise, cancel } = rejectAfterDelay$1(
|
|
4333
4343
|
MODEL_PROMISE_TIMEOUT_MS,
|
|
@@ -4348,7 +4358,7 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4348
4358
|
lifecycle,
|
|
4349
4359
|
operation: "dependency whenReady()"
|
|
4350
4360
|
});
|
|
4351
|
-
|
|
4361
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4352
4362
|
cancel();
|
|
4353
4363
|
throw enrichedError;
|
|
4354
4364
|
}),
|
|
@@ -4358,13 +4368,13 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4358
4368
|
return dependenciesByLifecycle;
|
|
4359
4369
|
};
|
|
4360
4370
|
const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycle) => {
|
|
4361
|
-
|
|
4371
|
+
log$_.debug(`Execute lifecycle with ${models2.length} models`);
|
|
4362
4372
|
if (models2.length === 0) {
|
|
4363
|
-
|
|
4373
|
+
log$_.debug(`${sourceModel.modelId} has no children. Returning`);
|
|
4364
4374
|
return;
|
|
4365
4375
|
}
|
|
4366
4376
|
if (!target) {
|
|
4367
|
-
|
|
4377
|
+
log$_.error(
|
|
4368
4378
|
`${sourceModel.modelId} is not transitioning with a valid target ${target}`
|
|
4369
4379
|
);
|
|
4370
4380
|
return;
|
|
@@ -4375,12 +4385,10 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4375
4385
|
p = TransitionMap[target](model);
|
|
4376
4386
|
} else {
|
|
4377
4387
|
if (!model) {
|
|
4378
|
-
|
|
4388
|
+
log$_.error("model is undefined. This shouldn't happen");
|
|
4379
4389
|
}
|
|
4380
4390
|
if (!TransitionMap[target]) {
|
|
4381
|
-
|
|
4382
|
-
`There is no promise in the Transition Map for ${target}`
|
|
4383
|
-
);
|
|
4391
|
+
log$_.error(`There is no promise in the Transition Map for ${target}`);
|
|
4384
4392
|
}
|
|
4385
4393
|
}
|
|
4386
4394
|
return {
|
|
@@ -4392,11 +4400,11 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4392
4400
|
};
|
|
4393
4401
|
}).filter((modelPromise) => {
|
|
4394
4402
|
if (!modelPromise.promise) {
|
|
4395
|
-
|
|
4403
|
+
log$_.error(`No promise found ${modelPromise.modelId}`);
|
|
4396
4404
|
return false;
|
|
4397
4405
|
}
|
|
4398
4406
|
if (!modelPromise.model) {
|
|
4399
|
-
|
|
4407
|
+
log$_.error(`No model found ${modelPromise.modelId}`);
|
|
4400
4408
|
return false;
|
|
4401
4409
|
}
|
|
4402
4410
|
return true;
|
|
@@ -4425,7 +4433,7 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4425
4433
|
lifecycle: sourceLifecycle,
|
|
4426
4434
|
operation: `transition to ${target}`
|
|
4427
4435
|
});
|
|
4428
|
-
|
|
4436
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4429
4437
|
timeoutCancel();
|
|
4430
4438
|
throw enrichedError;
|
|
4431
4439
|
}),
|
|
@@ -4471,10 +4479,10 @@ const executeDependentModelLifecycle = async (model, lifecycle) => {
|
|
|
4471
4479
|
);
|
|
4472
4480
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
4473
4481
|
if (failed.length) {
|
|
4474
|
-
|
|
4482
|
+
log$_.error(
|
|
4475
4483
|
`There were ${failed.length} failed dependent models on ${lifecycle}`
|
|
4476
4484
|
);
|
|
4477
|
-
|
|
4485
|
+
log$_.error(failed);
|
|
4478
4486
|
}
|
|
4479
4487
|
};
|
|
4480
4488
|
function applyKosModelDevtoolsSupport(model) {
|
|
@@ -4738,7 +4746,7 @@ class KosEffectManager {
|
|
|
4738
4746
|
this.disposers = [];
|
|
4739
4747
|
}
|
|
4740
4748
|
}
|
|
4741
|
-
const log$
|
|
4749
|
+
const log$Z = KosLog.createLogger({ group: LogGroup.core, name: "model-active-machine" });
|
|
4742
4750
|
const activeMachine = (model) => {
|
|
4743
4751
|
const machine2 = robot3.createMachine(KosModelState.INACTIVE, {
|
|
4744
4752
|
[KosModelState.FAILED]: robot3.state(
|
|
@@ -4793,11 +4801,11 @@ const activeMachine = (model) => {
|
|
|
4793
4801
|
});
|
|
4794
4802
|
const service2 = robot3.interpret(
|
|
4795
4803
|
machine2,
|
|
4796
|
-
(_service) => log$
|
|
4804
|
+
(_service) => log$Z.debug(_service.machine.current)
|
|
4797
4805
|
);
|
|
4798
4806
|
return { service: service2, machine: machine2 };
|
|
4799
4807
|
};
|
|
4800
|
-
const log$
|
|
4808
|
+
const log$Y = KosLog.createLogger({ group: LogGroup.core, name: "model-online-machine" });
|
|
4801
4809
|
const onlineMachine = (model) => {
|
|
4802
4810
|
const machine2 = robot3.createMachine(KosModelState.OFFLINE, {
|
|
4803
4811
|
[KosModelState.ONLINE]: robot3.state(
|
|
@@ -4815,7 +4823,7 @@ const onlineMachine = (model) => {
|
|
|
4815
4823
|
KosModelEvents.GO_ONLINE,
|
|
4816
4824
|
KosModelState.ONLINE,
|
|
4817
4825
|
robot3.action(async () => {
|
|
4818
|
-
log$
|
|
4826
|
+
log$Y.debug(`Going online with model ${model.modelId}`);
|
|
4819
4827
|
await model.online();
|
|
4820
4828
|
model.onlineStatus = KosModelState.ONLINE;
|
|
4821
4829
|
await model.fsm.transitionTo(
|
|
@@ -4828,10 +4836,14 @@ const onlineMachine = (model) => {
|
|
|
4828
4836
|
});
|
|
4829
4837
|
const service2 = robot3.interpret(
|
|
4830
4838
|
machine2,
|
|
4831
|
-
(_service) => log$
|
|
4839
|
+
(_service) => log$Y.debug(_service.machine.current)
|
|
4832
4840
|
);
|
|
4833
4841
|
return { machine: machine2, service: service2 };
|
|
4834
4842
|
};
|
|
4843
|
+
const log$X = KosLog.createLogger({
|
|
4844
|
+
group: LogGroup.core,
|
|
4845
|
+
name: "model-machine"
|
|
4846
|
+
});
|
|
4835
4847
|
const machine = (model) => {
|
|
4836
4848
|
const active = activeMachine(model).service;
|
|
4837
4849
|
const online = onlineMachine(model).service;
|
|
@@ -4866,7 +4878,7 @@ const machine = (model) => {
|
|
|
4866
4878
|
`error`,
|
|
4867
4879
|
KosModelState.FAILED,
|
|
4868
4880
|
robot3.action(() => {
|
|
4869
|
-
|
|
4881
|
+
log$X.error(
|
|
4870
4882
|
`Model ${model.modelId} - ${model.modelTypeName} failed to initialize. Transitioning to FAILED state.`
|
|
4871
4883
|
);
|
|
4872
4884
|
model.status = KosModelState.FAILED;
|
|
@@ -4988,7 +5000,7 @@ const machine = (model) => {
|
|
|
4988
5000
|
`error`,
|
|
4989
5001
|
KosModelState.REATTACHING,
|
|
4990
5002
|
robot3.action((_ctx, event) => {
|
|
4991
|
-
|
|
5003
|
+
log$X.error(
|
|
4992
5004
|
`Model ${model.modelId} - ${model.modelTypeName} failed to reload; its data stays as it was. ${String(
|
|
4993
5005
|
event?.error
|
|
4994
5006
|
)}`
|
|
@@ -5025,11 +5037,11 @@ const machine = (model) => {
|
|
|
5025
5037
|
[KosModelState.FAILED]: robot3.state()
|
|
5026
5038
|
});
|
|
5027
5039
|
};
|
|
5028
|
-
const log$
|
|
5040
|
+
const log$W = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-lifecycle" });
|
|
5029
5041
|
const fsm = (model) => {
|
|
5030
5042
|
const service2 = robot3.interpret(
|
|
5031
5043
|
machine(model),
|
|
5032
|
-
(_service) => log$
|
|
5044
|
+
(_service) => log$W.debug(
|
|
5033
5045
|
`state machine for model ${model.modelId}: ${_service.machine.current});`
|
|
5034
5046
|
)
|
|
5035
5047
|
);
|
|
@@ -5631,6 +5643,10 @@ async function processRequestBody(body) {
|
|
|
5631
5643
|
}
|
|
5632
5644
|
throw new Error("Unsupported body type");
|
|
5633
5645
|
}
|
|
5646
|
+
const log$V = KosLog.createLogger({
|
|
5647
|
+
group: LogGroup.transport,
|
|
5648
|
+
name: "kos-message-utils"
|
|
5649
|
+
});
|
|
5634
5650
|
const createStudioMessage = ({
|
|
5635
5651
|
path,
|
|
5636
5652
|
requestId,
|
|
@@ -5844,10 +5860,10 @@ const sendKosMessage = (msg, options) => {
|
|
|
5844
5860
|
);
|
|
5845
5861
|
const socketTransport = KosCore.getInstance().transport.socket;
|
|
5846
5862
|
if (socketTransport) {
|
|
5847
|
-
|
|
5863
|
+
log$V.debug("Sending message", _msg);
|
|
5848
5864
|
socketTransport.socket.send(_msg);
|
|
5849
5865
|
} else {
|
|
5850
|
-
|
|
5866
|
+
log$V.error("socket transport is not initialized");
|
|
5851
5867
|
}
|
|
5852
5868
|
};
|
|
5853
5869
|
const createStudioMessageResponse = ({
|
|
@@ -5882,7 +5898,7 @@ const sendStudioMessageRequest = (msg, options) => {
|
|
|
5882
5898
|
if (socketTransport) {
|
|
5883
5899
|
socketTransport.socket.send(_msg);
|
|
5884
5900
|
} else {
|
|
5885
|
-
|
|
5901
|
+
log$V.error("socket transport is not initialized");
|
|
5886
5902
|
}
|
|
5887
5903
|
};
|
|
5888
5904
|
const sendStudioMessage = (msg, options) => {
|
|
@@ -5895,7 +5911,7 @@ const sendStudioMessage = (msg, options) => {
|
|
|
5895
5911
|
if (socketTransport) {
|
|
5896
5912
|
socketTransport.socket.send(_msg);
|
|
5897
5913
|
} else {
|
|
5898
|
-
|
|
5914
|
+
log$V.error("socket transport is not initialized");
|
|
5899
5915
|
}
|
|
5900
5916
|
};
|
|
5901
5917
|
const createBroadcastMessageResponse = ({
|
|
@@ -5965,7 +5981,7 @@ const sendBroadcastMessage = ({
|
|
|
5965
5981
|
if (socketTransport) {
|
|
5966
5982
|
socketTransport.socket.send(_msg);
|
|
5967
5983
|
} else {
|
|
5968
|
-
|
|
5984
|
+
log$V.error("socket transport is not initialized");
|
|
5969
5985
|
}
|
|
5970
5986
|
};
|
|
5971
5987
|
const sendKosMessageResponse = ({
|
|
@@ -5981,7 +5997,7 @@ const sendKosMessageResponse = ({
|
|
|
5981
5997
|
if (socketTransport) {
|
|
5982
5998
|
socketTransport.socket.send(_msg);
|
|
5983
5999
|
} else {
|
|
5984
|
-
|
|
6000
|
+
log$V.error("socket transport is not initialized");
|
|
5985
6001
|
}
|
|
5986
6002
|
};
|
|
5987
6003
|
const sendKosHttpMessageResponse = ({
|
|
@@ -5997,7 +6013,7 @@ const sendKosHttpMessageResponse = ({
|
|
|
5997
6013
|
if (socketTransport) {
|
|
5998
6014
|
socketTransport.socket.send(_msg);
|
|
5999
6015
|
} else {
|
|
6000
|
-
|
|
6016
|
+
log$V.error("socket transport is not initialized");
|
|
6001
6017
|
}
|
|
6002
6018
|
};
|
|
6003
6019
|
const getMessageBody = (payload, skipParse) => {
|
|
@@ -6029,7 +6045,7 @@ class TransportNotReadyError extends Error {
|
|
|
6029
6045
|
}
|
|
6030
6046
|
}
|
|
6031
6047
|
const isTransportNotReadyError = (error) => !!error && error.code === TRANSPORT_NOT_READY;
|
|
6032
|
-
const log$
|
|
6048
|
+
const log$U = KosLog.createLogger({ group: LogGroup.transport, name: "kos-fetch" });
|
|
6033
6049
|
const DEFAULT_WS_TIMEOUT = 3e4;
|
|
6034
6050
|
const WS_TIMEOUT = (() => {
|
|
6035
6051
|
const configured = process.env.KOS_WS_TIMEOUT ? parseInt(process.env.KOS_WS_TIMEOUT) : DEFAULT_WS_TIMEOUT;
|
|
@@ -6094,7 +6110,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6094
6110
|
const requestId = uuid();
|
|
6095
6111
|
const urlObj = new URL(url);
|
|
6096
6112
|
const path = `${urlObj.pathname}${urlObj.search}`;
|
|
6097
|
-
log$
|
|
6113
|
+
log$U.debug(`path: ${path}`);
|
|
6098
6114
|
const budget = resolveTimeoutBudget(options?.timeout);
|
|
6099
6115
|
const messageFactory = fetchMessageFactory(options);
|
|
6100
6116
|
const signal = createRequestSignal(budget, options?.signal);
|
|
@@ -6102,12 +6118,12 @@ const kosFetchWs = async (url, options) => {
|
|
|
6102
6118
|
await transport.whenReady({ signal });
|
|
6103
6119
|
} catch (error) {
|
|
6104
6120
|
if (isTimeoutReason(error)) {
|
|
6105
|
-
log$
|
|
6121
|
+
log$U.error(
|
|
6106
6122
|
`Transport not ready${budget === void 0 ? "" : ` after ${budget}ms`} - request not sent - url: ${url}`
|
|
6107
6123
|
);
|
|
6108
6124
|
throw new TransportNotReadyError({ timeout: budget, url });
|
|
6109
6125
|
}
|
|
6110
|
-
log$
|
|
6126
|
+
log$U.debug(`Request aborted while waiting for transport - url: ${url}`);
|
|
6111
6127
|
throw error;
|
|
6112
6128
|
}
|
|
6113
6129
|
const processedBody = await processRequestBody(options?.body);
|
|
@@ -6136,9 +6152,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6136
6152
|
if (signal.aborted) {
|
|
6137
6153
|
const reason = signal.reason;
|
|
6138
6154
|
if (reason?.name === "TimeoutError") {
|
|
6139
|
-
log$
|
|
6155
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6140
6156
|
} else {
|
|
6141
|
-
log$
|
|
6157
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6142
6158
|
}
|
|
6143
6159
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6144
6160
|
return;
|
|
@@ -6147,9 +6163,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6147
6163
|
if (unsubscribe) unsubscribe();
|
|
6148
6164
|
const reason = signal.reason;
|
|
6149
6165
|
if (reason?.name === "TimeoutError") {
|
|
6150
|
-
log$
|
|
6166
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6151
6167
|
} else {
|
|
6152
|
-
log$
|
|
6168
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6153
6169
|
}
|
|
6154
6170
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6155
6171
|
};
|
|
@@ -6165,7 +6181,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6165
6181
|
try {
|
|
6166
6182
|
bodyData = base64ToArrayBuffer(responseBody);
|
|
6167
6183
|
} catch (e) {
|
|
6168
|
-
log$
|
|
6184
|
+
log$U.error("Failed to decode base64 response", e);
|
|
6169
6185
|
}
|
|
6170
6186
|
}
|
|
6171
6187
|
const response = {
|
|
@@ -6219,7 +6235,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6219
6235
|
});
|
|
6220
6236
|
}
|
|
6221
6237
|
if (parsed.files) {
|
|
6222
|
-
log$
|
|
6238
|
+
log$U.warn(
|
|
6223
6239
|
"File reconstruction in FormData not fully implemented"
|
|
6224
6240
|
);
|
|
6225
6241
|
}
|
|
@@ -6270,7 +6286,7 @@ const resolveBaseUrl = () => {
|
|
|
6270
6286
|
const URL2 = exports.BASE_URL;
|
|
6271
6287
|
return { isMock: MOCK, URL: URL2 };
|
|
6272
6288
|
};
|
|
6273
|
-
const log$
|
|
6289
|
+
const log$T = KosLog.createLogger({ group: LogGroup.transport, name: "kos-service-request" });
|
|
6274
6290
|
const ERROR_UNKNOWN = "errUnknown";
|
|
6275
6291
|
const ERROR_TRANSPORT_NOT_READY = "Transport not ready";
|
|
6276
6292
|
const MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
@@ -6296,7 +6312,7 @@ async function clientRequest(endpoint, method, options, params2, body) {
|
|
|
6296
6312
|
)}`
|
|
6297
6313
|
).join("&") : "";
|
|
6298
6314
|
const fullUrl = `${resolveBaseUrl().URL}${url}${query ? `?${query}` : ""}`;
|
|
6299
|
-
log$
|
|
6315
|
+
log$T.debug(`fullUrl: ${fullUrl}`);
|
|
6300
6316
|
const fetchOptions = {
|
|
6301
6317
|
method: String(method).toUpperCase(),
|
|
6302
6318
|
body: null,
|
|
@@ -6330,20 +6346,20 @@ async function executeFetch(fullUrl, fetchOptions) {
|
|
|
6330
6346
|
return [null, payload.data ?? payload, responseContext(response)];
|
|
6331
6347
|
} catch (error) {
|
|
6332
6348
|
if (isTransportNotReadyError(error)) {
|
|
6333
|
-
log$
|
|
6349
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6334
6350
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6335
6351
|
}
|
|
6336
6352
|
if (error instanceof DOMException) {
|
|
6337
6353
|
if (error.name === "TimeoutError") {
|
|
6338
|
-
log$
|
|
6354
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6339
6355
|
return ["Request timed out", null];
|
|
6340
6356
|
}
|
|
6341
6357
|
if (error.name === "AbortError") {
|
|
6342
|
-
log$
|
|
6358
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6343
6359
|
return ["Request aborted", null];
|
|
6344
6360
|
}
|
|
6345
6361
|
}
|
|
6346
|
-
log$
|
|
6362
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6347
6363
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6348
6364
|
}
|
|
6349
6365
|
}
|
|
@@ -6363,38 +6379,38 @@ async function executeFetchWithRetry(fullUrl, fetchOptions, config2) {
|
|
|
6363
6379
|
errorContext
|
|
6364
6380
|
];
|
|
6365
6381
|
if (config2.retryOn && !config2.retryOn(response)) {
|
|
6366
|
-
log$
|
|
6382
|
+
log$T.debug(
|
|
6367
6383
|
`Retry predicate returned false for ${fullUrl} (status ${response.status}), stopping`
|
|
6368
6384
|
);
|
|
6369
6385
|
return lastResult;
|
|
6370
6386
|
}
|
|
6371
6387
|
if (attempt < config2.maxAttempts) {
|
|
6372
6388
|
const delayMs = config2.baseDelayMs * Math.pow(config2.backoffFactor, attempt - 1);
|
|
6373
|
-
log$
|
|
6389
|
+
log$T.warn(
|
|
6374
6390
|
`Request to ${fullUrl} failed (status ${response.status}), retrying in ${delayMs}ms (attempt ${attempt}/${config2.maxAttempts})`
|
|
6375
6391
|
);
|
|
6376
6392
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
6377
6393
|
}
|
|
6378
6394
|
} catch (error) {
|
|
6379
6395
|
if (isTransportNotReadyError(error)) {
|
|
6380
|
-
log$
|
|
6396
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6381
6397
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6382
6398
|
}
|
|
6383
6399
|
if (error instanceof DOMException) {
|
|
6384
6400
|
if (error.name === "TimeoutError") {
|
|
6385
|
-
log$
|
|
6401
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6386
6402
|
return ["Request timed out", null];
|
|
6387
6403
|
}
|
|
6388
6404
|
if (error.name === "AbortError") {
|
|
6389
|
-
log$
|
|
6405
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6390
6406
|
return ["Request aborted", null];
|
|
6391
6407
|
}
|
|
6392
6408
|
}
|
|
6393
|
-
log$
|
|
6409
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6394
6410
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6395
6411
|
}
|
|
6396
6412
|
}
|
|
6397
|
-
log$
|
|
6413
|
+
log$T.error(`All ${config2.maxAttempts} attempts failed for ${fullUrl}`);
|
|
6398
6414
|
return lastResult;
|
|
6399
6415
|
}
|
|
6400
6416
|
async function captureErrorResponseContext(response) {
|
|
@@ -6443,10 +6459,7 @@ const service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
6443
6459
|
default: api$1,
|
|
6444
6460
|
kosServiceRequest
|
|
6445
6461
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
6446
|
-
const log$
|
|
6447
|
-
name: "kos-service-request-manager",
|
|
6448
|
-
group: "Model"
|
|
6449
|
-
});
|
|
6462
|
+
const log$S = KosLog.createLogger({ group: LogGroup.core, name: "kos-service-request-manager" });
|
|
6450
6463
|
function shouldExecuteRequest(metadata, model) {
|
|
6451
6464
|
return !metadata.condition || metadata.condition(model);
|
|
6452
6465
|
}
|
|
@@ -6496,7 +6509,7 @@ function isValueMissing(value) {
|
|
|
6496
6509
|
}
|
|
6497
6510
|
function validateRequiredField(value, fieldName, path, isRequired) {
|
|
6498
6511
|
if (isRequired && isValueMissing(value)) {
|
|
6499
|
-
log$
|
|
6512
|
+
log$S.warn(
|
|
6500
6513
|
`Required field '${fieldName}' is missing in response for ${path}`
|
|
6501
6514
|
);
|
|
6502
6515
|
}
|
|
@@ -6531,7 +6544,7 @@ class ServiceRequestManager {
|
|
|
6531
6544
|
this.handlers.get(lifecycle).push(metadata);
|
|
6532
6545
|
});
|
|
6533
6546
|
if (Object.keys(handlerMetadata).length > 0) {
|
|
6534
|
-
log$
|
|
6547
|
+
log$S.debug(
|
|
6535
6548
|
`Discovered ${Object.keys(handlerMetadata).length} service request handlers for model ${this.model.id}`
|
|
6536
6549
|
);
|
|
6537
6550
|
}
|
|
@@ -6546,7 +6559,7 @@ class ServiceRequestManager {
|
|
|
6546
6559
|
if (!handlers || handlers.length === 0) {
|
|
6547
6560
|
return;
|
|
6548
6561
|
}
|
|
6549
|
-
log$
|
|
6562
|
+
log$S.debug(
|
|
6550
6563
|
`Executing ${handlers.length} service requests for lifecycle ${lifecycle}`
|
|
6551
6564
|
);
|
|
6552
6565
|
await Promise.all(handlers.map((handler) => this.executeHandler(handler)));
|
|
@@ -6581,7 +6594,7 @@ class ServiceRequestManager {
|
|
|
6581
6594
|
*/
|
|
6582
6595
|
shouldProcessRequest(metadata) {
|
|
6583
6596
|
if (!shouldExecuteRequest(metadata, this.model)) {
|
|
6584
|
-
log$
|
|
6597
|
+
log$S.debug(`Skipping request ${metadata.path} - condition returned false`);
|
|
6585
6598
|
return false;
|
|
6586
6599
|
}
|
|
6587
6600
|
return true;
|
|
@@ -6786,7 +6799,7 @@ class ServiceRequestManager {
|
|
|
6786
6799
|
case "json":
|
|
6787
6800
|
return typeof value === "string" ? JSON.parse(value) : value;
|
|
6788
6801
|
default:
|
|
6789
|
-
log$
|
|
6802
|
+
log$S.warn(`Unknown transformer: ${transform}`);
|
|
6790
6803
|
return value;
|
|
6791
6804
|
}
|
|
6792
6805
|
}
|
|
@@ -6797,7 +6810,7 @@ class ServiceRequestManager {
|
|
|
6797
6810
|
if (!metadata.iterateOver) return data;
|
|
6798
6811
|
const array = this.getNestedValue(data, metadata.iterateOver);
|
|
6799
6812
|
if (!Array.isArray(array)) {
|
|
6800
|
-
log$
|
|
6813
|
+
log$S.warn(
|
|
6801
6814
|
`iterateOver path '${metadata.iterateOver}' did not resolve to an array`
|
|
6802
6815
|
);
|
|
6803
6816
|
return [];
|
|
@@ -6840,7 +6853,7 @@ class ServiceRequestManager {
|
|
|
6840
6853
|
case "throw":
|
|
6841
6854
|
throw error;
|
|
6842
6855
|
case "log":
|
|
6843
|
-
log$
|
|
6856
|
+
log$S.error(
|
|
6844
6857
|
`Service request failed for ${metadata.path}:`,
|
|
6845
6858
|
error.message
|
|
6846
6859
|
);
|
|
@@ -6900,6 +6913,10 @@ class ServiceRequestManager {
|
|
|
6900
6913
|
}
|
|
6901
6914
|
}
|
|
6902
6915
|
}
|
|
6916
|
+
KosLog.createLogger({
|
|
6917
|
+
group: LogGroup.core,
|
|
6918
|
+
name: "async-event-bus"
|
|
6919
|
+
});
|
|
6903
6920
|
class AsyncEventIterator {
|
|
6904
6921
|
subscription;
|
|
6905
6922
|
unsubscribe;
|
|
@@ -7349,6 +7366,10 @@ function encodeFutureFrame(future) {
|
|
|
7349
7366
|
JSON.stringify(future)
|
|
7350
7367
|
);
|
|
7351
7368
|
}
|
|
7369
|
+
const log$R = KosLog.createLogger({
|
|
7370
|
+
group: LogGroup.transport,
|
|
7371
|
+
name: "future-simulator"
|
|
7372
|
+
});
|
|
7352
7373
|
const DEFAULT_DURATION_MS = 5e3;
|
|
7353
7374
|
const DEFAULT_INTERVAL_MS = 250;
|
|
7354
7375
|
class KosMockFutureHandle {
|
|
@@ -7459,7 +7480,7 @@ class KosMockFutureSimulator {
|
|
|
7459
7480
|
this.deps.ensureCancelRoutes();
|
|
7460
7481
|
}
|
|
7461
7482
|
if (!options.tracker) {
|
|
7462
|
-
|
|
7483
|
+
log$R.warn(
|
|
7463
7484
|
`KosMock future ${handle.id} has no tracker — models will not link it to their request; prefer futures.fromRequest`
|
|
7464
7485
|
);
|
|
7465
7486
|
}
|
|
@@ -7491,6 +7512,10 @@ class KosMockFutureSimulator {
|
|
|
7491
7512
|
this.futures.clear();
|
|
7492
7513
|
}
|
|
7493
7514
|
}
|
|
7515
|
+
const log$Q = KosLog.createLogger({
|
|
7516
|
+
group: LogGroup.transport,
|
|
7517
|
+
name: "mock-fixtures"
|
|
7518
|
+
});
|
|
7494
7519
|
const DEFAULT_FIXTURE_SERVER_URL = "http://localhost:5676";
|
|
7495
7520
|
const DB_NAME = "kos-mock-fixtures";
|
|
7496
7521
|
const STORE_NAME = "fixtures";
|
|
@@ -7643,7 +7668,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7643
7668
|
);
|
|
7644
7669
|
}
|
|
7645
7670
|
await target.save(name, named);
|
|
7646
|
-
|
|
7671
|
+
log$Q.info(`KosMock fixture "${name}" saved`);
|
|
7647
7672
|
return name;
|
|
7648
7673
|
},
|
|
7649
7674
|
saveRecording(name) {
|
|
@@ -7666,7 +7691,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7666
7691
|
(summary) => summaries.push({ ...summary, source: "server" })
|
|
7667
7692
|
);
|
|
7668
7693
|
} catch {
|
|
7669
|
-
|
|
7694
|
+
log$Q.warn(`KosMock fixture server unreachable at ${serverUrl}`);
|
|
7670
7695
|
}
|
|
7671
7696
|
}
|
|
7672
7697
|
try {
|
|
@@ -7687,7 +7712,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7687
7712
|
},
|
|
7688
7713
|
async import() {
|
|
7689
7714
|
if (typeof document === "undefined") {
|
|
7690
|
-
|
|
7715
|
+
log$Q.warn(`KosMock fixture import requires a browser environment`);
|
|
7691
7716
|
return void 0;
|
|
7692
7717
|
}
|
|
7693
7718
|
return new Promise((resolve) => {
|
|
@@ -7707,7 +7732,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7707
7732
|
});
|
|
7708
7733
|
resolve(name);
|
|
7709
7734
|
} catch (error) {
|
|
7710
|
-
|
|
7735
|
+
log$Q.error(`KosMock fixture import failed`, error?.message);
|
|
7711
7736
|
resolve(void 0);
|
|
7712
7737
|
}
|
|
7713
7738
|
};
|
|
@@ -7782,6 +7807,10 @@ function splitUrl(url) {
|
|
|
7782
7807
|
function methodMatches(routeMethod, requestMethod) {
|
|
7783
7808
|
return routeMethod === "*" || routeMethod.toUpperCase() === requestMethod.toUpperCase();
|
|
7784
7809
|
}
|
|
7810
|
+
const log$P = KosLog.createLogger({
|
|
7811
|
+
group: LogGroup.transport,
|
|
7812
|
+
name: "mock-playback"
|
|
7813
|
+
});
|
|
7785
7814
|
const rewriteTrackers = (raw, trackerMap) => {
|
|
7786
7815
|
let out = raw;
|
|
7787
7816
|
trackerMap.forEach((liveTracker, capturedTracker) => {
|
|
@@ -7943,7 +7972,7 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7943
7972
|
if ((options.pushes ?? "scheduled") === "scheduled") {
|
|
7944
7973
|
startPushes();
|
|
7945
7974
|
}
|
|
7946
|
-
|
|
7975
|
+
log$P.info(
|
|
7947
7976
|
`KosMock fixture${name ? ` "${name}"` : ""} loaded: ${groups.size} routes, ${fixture.pushes.length} pushes (${fixture.pushes.length - unanchored.length} anchored), consume: ${consume}`
|
|
7948
7977
|
);
|
|
7949
7978
|
return {
|
|
@@ -7957,6 +7986,10 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7957
7986
|
}
|
|
7958
7987
|
};
|
|
7959
7988
|
}
|
|
7989
|
+
const log$O = KosLog.createLogger({
|
|
7990
|
+
group: LogGroup.transport,
|
|
7991
|
+
name: "mock-recorder"
|
|
7992
|
+
});
|
|
7960
7993
|
class KosMockRecorder {
|
|
7961
7994
|
recording = false;
|
|
7962
7995
|
name;
|
|
@@ -7978,14 +8011,14 @@ class KosMockRecorder {
|
|
|
7978
8011
|
this.exchanges = [];
|
|
7979
8012
|
this.pushes = [];
|
|
7980
8013
|
this.sends = [];
|
|
7981
|
-
|
|
8014
|
+
log$O.info(
|
|
7982
8015
|
`KosMock recorder started${options.name ? ` (${options.name})` : ""}`
|
|
7983
8016
|
);
|
|
7984
8017
|
}
|
|
7985
8018
|
stop() {
|
|
7986
8019
|
const fixture = this.toFixture();
|
|
7987
8020
|
this.recording = false;
|
|
7988
|
-
|
|
8021
|
+
log$O.info(
|
|
7989
8022
|
`KosMock recorder stopped: ${fixture.exchanges.length} exchanges, ${fixture.pushes.length} pushes, ${fixture.sends?.length ?? 0} sends`
|
|
7990
8023
|
);
|
|
7991
8024
|
return fixture;
|
|
@@ -8002,7 +8035,7 @@ class KosMockRecorder {
|
|
|
8002
8035
|
}
|
|
8003
8036
|
download(filename) {
|
|
8004
8037
|
if (typeof document === "undefined") {
|
|
8005
|
-
|
|
8038
|
+
log$O.warn(`KosMock recorder download requires a browser environment`);
|
|
8006
8039
|
return;
|
|
8007
8040
|
}
|
|
8008
8041
|
const fixture = this.toFixture();
|
|
@@ -8117,6 +8150,10 @@ class KosMockRecorder {
|
|
|
8117
8150
|
}
|
|
8118
8151
|
}
|
|
8119
8152
|
}
|
|
8153
|
+
const log$N = KosLog.createLogger({
|
|
8154
|
+
group: LogGroup.transport,
|
|
8155
|
+
name: "mock-setups"
|
|
8156
|
+
});
|
|
8120
8157
|
const dynamicImport = (url) => import(
|
|
8121
8158
|
/* @vite-ignore */
|
|
8122
8159
|
/* webpackIgnore: true */
|
|
@@ -8149,7 +8186,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8149
8186
|
try {
|
|
8150
8187
|
entry.teardown?.();
|
|
8151
8188
|
} catch (error) {
|
|
8152
|
-
|
|
8189
|
+
log$N.error(`KosMock setup "${name}" teardown threw`, error?.message);
|
|
8153
8190
|
}
|
|
8154
8191
|
return true;
|
|
8155
8192
|
};
|
|
@@ -8176,7 +8213,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8176
8213
|
handle,
|
|
8177
8214
|
teardown: typeof result === "function" ? result : void 0
|
|
8178
8215
|
});
|
|
8179
|
-
|
|
8216
|
+
log$N.info(`KosMock setup "${name}" installed from ${url}`);
|
|
8180
8217
|
return handle;
|
|
8181
8218
|
},
|
|
8182
8219
|
async list() {
|
|
@@ -8199,6 +8236,10 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8199
8236
|
};
|
|
8200
8237
|
return store;
|
|
8201
8238
|
}
|
|
8239
|
+
const log$M = KosLog.createLogger({
|
|
8240
|
+
group: LogGroup.transport,
|
|
8241
|
+
name: "mock-config"
|
|
8242
|
+
});
|
|
8202
8243
|
const asWireValue = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
8203
8244
|
const configTopic = (beanId) => `/kos/config/${beanId}`;
|
|
8204
8245
|
const changeEnvelope = (props, previousValues = {}) => {
|
|
@@ -8266,7 +8307,7 @@ function createConfigFacade(registry) {
|
|
|
8266
8307
|
return void 0;
|
|
8267
8308
|
}
|
|
8268
8309
|
if (injectedKeys.length < keys.length) {
|
|
8269
|
-
|
|
8310
|
+
log$M.warn(
|
|
8270
8311
|
`KosMock config.inject ${beanId}: mixed write passes through; injected props will be rejected by the backend: ${injectedKeys.join(
|
|
8271
8312
|
", "
|
|
8272
8313
|
)}`
|
|
@@ -8301,6 +8342,10 @@ function createConfigFacade(registry) {
|
|
|
8301
8342
|
};
|
|
8302
8343
|
return { update, inject };
|
|
8303
8344
|
}
|
|
8345
|
+
const log$L = KosLog.createLogger({
|
|
8346
|
+
group: LogGroup.transport,
|
|
8347
|
+
name: "mock-registry"
|
|
8348
|
+
});
|
|
8304
8349
|
const PENDING_REQUEST_CAP = 500;
|
|
8305
8350
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8306
8351
|
const asHandler = (handler) => typeof handler === "function" ? handler : () => handler;
|
|
@@ -8406,7 +8451,7 @@ class KosMockRegistry {
|
|
|
8406
8451
|
changed = true;
|
|
8407
8452
|
}
|
|
8408
8453
|
} catch (error) {
|
|
8409
|
-
|
|
8454
|
+
log$L.error(
|
|
8410
8455
|
`KosMock transformer for ${transformer.method} ${transformer.pattern} threw`,
|
|
8411
8456
|
error?.message
|
|
8412
8457
|
);
|
|
@@ -8522,7 +8567,7 @@ class KosMockRegistry {
|
|
|
8522
8567
|
try {
|
|
8523
8568
|
notify();
|
|
8524
8569
|
} catch (error) {
|
|
8525
|
-
|
|
8570
|
+
log$L.error(`KosMock observer threw`, error?.message);
|
|
8526
8571
|
}
|
|
8527
8572
|
}
|
|
8528
8573
|
loadFixture(fixture, options) {
|
|
@@ -8545,13 +8590,13 @@ class KosMockRegistry {
|
|
|
8545
8590
|
enable() {
|
|
8546
8591
|
if (!this.enabledFlag) {
|
|
8547
8592
|
this.enabledFlag = true;
|
|
8548
|
-
|
|
8593
|
+
log$L.info(`KosMock enabled`);
|
|
8549
8594
|
}
|
|
8550
8595
|
}
|
|
8551
8596
|
disable() {
|
|
8552
8597
|
if (this.enabledFlag) {
|
|
8553
8598
|
this.enabledFlag = false;
|
|
8554
|
-
|
|
8599
|
+
log$L.info(`KosMock disabled`);
|
|
8555
8600
|
}
|
|
8556
8601
|
}
|
|
8557
8602
|
get standalone() {
|
|
@@ -8627,7 +8672,7 @@ class KosMockRegistry {
|
|
|
8627
8672
|
}
|
|
8628
8673
|
publishFrame(rawFrame) {
|
|
8629
8674
|
if (this.injectors.size === 0) {
|
|
8630
|
-
|
|
8675
|
+
log$L.warn(
|
|
8631
8676
|
`KosMock.publishFrame: no active transport to deliver the frame`
|
|
8632
8677
|
);
|
|
8633
8678
|
return;
|
|
@@ -8670,7 +8715,7 @@ class KosMockRegistry {
|
|
|
8670
8715
|
if (teardown) {
|
|
8671
8716
|
this.scenarioTeardowns.set(id, teardown);
|
|
8672
8717
|
}
|
|
8673
|
-
|
|
8718
|
+
log$L.info(`KosMock scenario "${scenario.name}" installed`);
|
|
8674
8719
|
const remove = () => {
|
|
8675
8720
|
const dispose = this.scenarioTeardowns.get(id);
|
|
8676
8721
|
this.scenarioTeardowns.delete(id);
|
|
@@ -8774,7 +8819,7 @@ class KosMockRegistry {
|
|
|
8774
8819
|
return true;
|
|
8775
8820
|
}
|
|
8776
8821
|
if (policy === "warn") {
|
|
8777
|
-
|
|
8822
|
+
log$L.warn(`KosMock: unmatched ${frame.method} ${path}`);
|
|
8778
8823
|
}
|
|
8779
8824
|
return false;
|
|
8780
8825
|
}
|
|
@@ -8810,7 +8855,7 @@ class KosMockRegistry {
|
|
|
8810
8855
|
try {
|
|
8811
8856
|
accepted = route.when(scopedRequest);
|
|
8812
8857
|
} catch (error) {
|
|
8813
|
-
|
|
8858
|
+
log$L.error(
|
|
8814
8859
|
`KosMock \`when\` guard for ${route.method} ${route.pattern} threw`,
|
|
8815
8860
|
error?.message
|
|
8816
8861
|
);
|
|
@@ -8823,7 +8868,7 @@ class KosMockRegistry {
|
|
|
8823
8868
|
try {
|
|
8824
8869
|
response = await route.handler(scopedRequest, this.context());
|
|
8825
8870
|
} catch (error) {
|
|
8826
|
-
|
|
8871
|
+
log$L.error(
|
|
8827
8872
|
`KosMock handler for ${route.method} ${route.pattern} threw`,
|
|
8828
8873
|
error?.message
|
|
8829
8874
|
);
|
|
@@ -8856,7 +8901,7 @@ class KosMockRegistry {
|
|
|
8856
8901
|
return;
|
|
8857
8902
|
}
|
|
8858
8903
|
if (policy === "warn") {
|
|
8859
|
-
|
|
8904
|
+
log$L.warn(
|
|
8860
8905
|
`KosMock: all routes declined ${request.method} ${request.path}`
|
|
8861
8906
|
);
|
|
8862
8907
|
}
|
|
@@ -8971,7 +9016,7 @@ if (typeof window !== "undefined") {
|
|
|
8971
9016
|
if (fixture) {
|
|
8972
9017
|
bootLoads.push(
|
|
8973
9018
|
KosMock.fixtures.play(fixture).then(() => void 0).catch(
|
|
8974
|
-
(error) =>
|
|
9019
|
+
(error) => log$L.error(
|
|
8975
9020
|
`KosMock: boot fixture "${fixture}" failed to load`,
|
|
8976
9021
|
error?.message
|
|
8977
9022
|
)
|
|
@@ -8982,7 +9027,7 @@ if (typeof window !== "undefined") {
|
|
|
8982
9027
|
for (const name of setups.split(",").filter(Boolean)) {
|
|
8983
9028
|
bootLoads.push(
|
|
8984
9029
|
KosMock.setups.load(name).then(() => void 0).catch(
|
|
8985
|
-
(error) =>
|
|
9030
|
+
(error) => log$L.error(
|
|
8986
9031
|
`KosMock: boot setup "${name}" failed to load`,
|
|
8987
9032
|
error?.message
|
|
8988
9033
|
)
|
|
@@ -9092,6 +9137,14 @@ class WebSocketBridgeTransport extends WebSocket {
|
|
|
9092
9137
|
super(address);
|
|
9093
9138
|
}
|
|
9094
9139
|
}
|
|
9140
|
+
const log$K = KosLog.createLogger({
|
|
9141
|
+
group: LogGroup.transport,
|
|
9142
|
+
name: "base-message-transport"
|
|
9143
|
+
});
|
|
9144
|
+
const messageLog = KosLog.createLogger({
|
|
9145
|
+
group: LogGroup.transport,
|
|
9146
|
+
name: MESSAGE_LOGGER_NAME
|
|
9147
|
+
});
|
|
9095
9148
|
var WebSocketEvents = /* @__PURE__ */ ((WebSocketEvents2) => {
|
|
9096
9149
|
WebSocketEvents2["CONNECTED"] = `websocket.connected`;
|
|
9097
9150
|
WebSocketEvents2["DISCONNECTED"] = `websocket.disconnected`;
|
|
@@ -9188,9 +9241,9 @@ class BaseTransport {
|
|
|
9188
9241
|
}
|
|
9189
9242
|
onMessage(event) {
|
|
9190
9243
|
try {
|
|
9191
|
-
|
|
9244
|
+
log$K.debug("webSocketTransport: onMessage received");
|
|
9192
9245
|
const { headers, body } = this.processMessageEvent(event);
|
|
9193
|
-
|
|
9246
|
+
messageLog.debug("received", event.data);
|
|
9194
9247
|
const subscriptionTopic = headers["subscription"] || headers[this.RESPONSE_ID_HEADER] || headers["topic"] || headers["type"];
|
|
9195
9248
|
if (subscriptionTopic) {
|
|
9196
9249
|
let msgBody = body;
|
|
@@ -9206,11 +9259,11 @@ class BaseTransport {
|
|
|
9206
9259
|
publish(subscriptionTopic, msgBody, msgHeaders);
|
|
9207
9260
|
}
|
|
9208
9261
|
} catch (ex) {
|
|
9209
|
-
|
|
9262
|
+
log$K.error(`onMessage exception`, ex.message, ex.stack);
|
|
9210
9263
|
}
|
|
9211
9264
|
}
|
|
9212
9265
|
onOpen(event) {
|
|
9213
|
-
|
|
9266
|
+
log$K.info(`websocket connection opened`);
|
|
9214
9267
|
this.socket = event.currentTarget;
|
|
9215
9268
|
mobx.runInAction(() => {
|
|
9216
9269
|
this.connectionEstablished = true;
|
|
@@ -9220,11 +9273,9 @@ alias:${this.alias}
|
|
|
9220
9273
|
|
|
9221
9274
|
`);
|
|
9222
9275
|
}
|
|
9223
|
-
|
|
9224
|
-
`sending ${this.offlineMessages.length} offline FOS messages`
|
|
9225
|
-
);
|
|
9276
|
+
log$K.debug(`sending ${this.offlineMessages.length} offline FOS messages`);
|
|
9226
9277
|
this.offlineMessages.forEach((msg) => {
|
|
9227
|
-
|
|
9278
|
+
log$K.debug(`sending offline message ${msg.msg}`);
|
|
9228
9279
|
this.socket?.send(msg.msg);
|
|
9229
9280
|
});
|
|
9230
9281
|
this.offlineMessages = [];
|
|
@@ -9233,7 +9284,7 @@ alias:${this.alias}
|
|
|
9233
9284
|
}
|
|
9234
9285
|
onClose(event) {
|
|
9235
9286
|
const { code, reason, wasClean } = event;
|
|
9236
|
-
|
|
9287
|
+
log$K.warn(
|
|
9237
9288
|
`WebSocket closed: code=${code}, reason=${reason || "none"}, wasClean=${wasClean}`
|
|
9238
9289
|
);
|
|
9239
9290
|
mobx.runInAction(() => {
|
|
@@ -9243,13 +9294,13 @@ alias:${this.alias}
|
|
|
9243
9294
|
if (this.shouldAttemptReconnection(code)) {
|
|
9244
9295
|
this.onConnectionLost?.();
|
|
9245
9296
|
} else {
|
|
9246
|
-
|
|
9297
|
+
log$K.info(
|
|
9247
9298
|
`Not reconnecting due to close code ${code} (intentional close or configuration error)`
|
|
9248
9299
|
);
|
|
9249
9300
|
}
|
|
9250
9301
|
}
|
|
9251
9302
|
onError(ev) {
|
|
9252
|
-
|
|
9303
|
+
log$K.error(`websocket error: `, ev);
|
|
9253
9304
|
publish("websocket.error", { event: ev });
|
|
9254
9305
|
}
|
|
9255
9306
|
/**
|
|
@@ -9294,7 +9345,7 @@ alias:${this.alias}
|
|
|
9294
9345
|
}
|
|
9295
9346
|
}
|
|
9296
9347
|
send(data) {
|
|
9297
|
-
|
|
9348
|
+
messageLog.debug("sent", data);
|
|
9298
9349
|
if (window.kosLogEvents) {
|
|
9299
9350
|
const { headers, body } = processKosMessage(String(data));
|
|
9300
9351
|
publish(KosWsEvents.SEND, { headers, body });
|
|
@@ -9302,6 +9353,10 @@ alias:${this.alias}
|
|
|
9302
9353
|
this.oldSend.call(this.socket, data);
|
|
9303
9354
|
}
|
|
9304
9355
|
}
|
|
9356
|
+
const log$J = KosLog.createLogger({
|
|
9357
|
+
group: LogGroup.transport,
|
|
9358
|
+
name: "bridge-transport"
|
|
9359
|
+
});
|
|
9305
9360
|
class BridgeTransport {
|
|
9306
9361
|
addEventListener;
|
|
9307
9362
|
dispatchEvent;
|
|
@@ -9313,7 +9368,7 @@ class BridgeTransport {
|
|
|
9313
9368
|
messageQueue = [];
|
|
9314
9369
|
isSending = false;
|
|
9315
9370
|
constructor(addr) {
|
|
9316
|
-
log$
|
|
9371
|
+
log$J.debug(`called Bridge Transport with addr ${addr}`);
|
|
9317
9372
|
const that = this;
|
|
9318
9373
|
globalThis.kosWindowWebsocketRecv = (msg) => {
|
|
9319
9374
|
if (that.onmessage) {
|
|
@@ -9321,19 +9376,19 @@ class BridgeTransport {
|
|
|
9321
9376
|
that.onmessage(data);
|
|
9322
9377
|
}
|
|
9323
9378
|
};
|
|
9324
|
-
log$
|
|
9379
|
+
log$J.debug("Opening bridge transport");
|
|
9325
9380
|
globalThis.kosWindowWebsocketOpen();
|
|
9326
|
-
log$
|
|
9381
|
+
log$J.debug("Opened bridge transport");
|
|
9327
9382
|
this._onclose = null;
|
|
9328
9383
|
this._onerror = null;
|
|
9329
9384
|
this._onmessage = null;
|
|
9330
9385
|
this._onopen = null;
|
|
9331
|
-
this.addEventListener = () => log$
|
|
9332
|
-
this.dispatchEvent = () => log$
|
|
9333
|
-
this.removeEventListener = () => log$
|
|
9386
|
+
this.addEventListener = () => log$J.debug("not implemented");
|
|
9387
|
+
this.dispatchEvent = () => log$J.debug("not implemented");
|
|
9388
|
+
this.removeEventListener = () => log$J.debug("not implemented");
|
|
9334
9389
|
}
|
|
9335
9390
|
close() {
|
|
9336
|
-
log$
|
|
9391
|
+
log$J.debug("closing");
|
|
9337
9392
|
}
|
|
9338
9393
|
sendNextMessage() {
|
|
9339
9394
|
if (this.messageQueue.length > 0) {
|
|
@@ -9420,6 +9475,10 @@ class KosTransport extends BaseTransport {
|
|
|
9420
9475
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9421
9476
|
}
|
|
9422
9477
|
}
|
|
9478
|
+
const log$I = KosLog.createLogger({
|
|
9479
|
+
group: LogGroup.transport,
|
|
9480
|
+
name: "standalone-mock-socket"
|
|
9481
|
+
});
|
|
9423
9482
|
const LOGGED_IN_FRAME = `topic:/studioServer/auth/LOGGED_IN
|
|
9424
9483
|
type:kos.broker.topic
|
|
9425
9484
|
|
|
@@ -9430,7 +9489,7 @@ class StandaloneMockSocket {
|
|
|
9430
9489
|
onmessage = null;
|
|
9431
9490
|
onopen = null;
|
|
9432
9491
|
constructor(url) {
|
|
9433
|
-
|
|
9492
|
+
log$I.info(`KosMock standalone socket replacing ${url}`);
|
|
9434
9493
|
setTimeout(async () => {
|
|
9435
9494
|
await kosMockRegistry.bootGate;
|
|
9436
9495
|
this.onopen?.({ currentTarget: this });
|
|
@@ -9441,7 +9500,7 @@ class StandaloneMockSocket {
|
|
|
9441
9500
|
}
|
|
9442
9501
|
send(data) {
|
|
9443
9502
|
if (peekFrameType(data) === KOS_HTTP_REQUEST_TYPE) {
|
|
9444
|
-
|
|
9503
|
+
log$I.warn(
|
|
9445
9504
|
`KosMock standalone: unmatched request reached the loopback socket and will hang — add a route or use onUnmatched: "respond404"`,
|
|
9446
9505
|
String(data).split("\n", 2).join(" ")
|
|
9447
9506
|
);
|
|
@@ -9479,6 +9538,10 @@ class MockMessageTransport extends BaseTransport {
|
|
|
9479
9538
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9480
9539
|
}
|
|
9481
9540
|
}
|
|
9541
|
+
const log$H = KosLog.createLogger({
|
|
9542
|
+
group: LogGroup.transport,
|
|
9543
|
+
name: "transport-factory"
|
|
9544
|
+
});
|
|
9482
9545
|
window.kosLogEvents = process.env.KOS_LOG_WS === "true";
|
|
9483
9546
|
class TransportFactory {
|
|
9484
9547
|
static build({
|
|
@@ -9490,13 +9553,13 @@ class TransportFactory {
|
|
|
9490
9553
|
onConnectionEstablished,
|
|
9491
9554
|
onConnectionLost
|
|
9492
9555
|
}) {
|
|
9493
|
-
|
|
9494
|
-
|
|
9556
|
+
log$H.debug(`initializing websocket connection`);
|
|
9557
|
+
log$H.warn(
|
|
9495
9558
|
`kosWindowWebsocketOpen: ${globalThis.kosWindowWebsocketOpen ? `true` : `false`}`
|
|
9496
9559
|
);
|
|
9497
|
-
|
|
9560
|
+
log$H.warn(`fos: ${fos ? `true` : `false`}`);
|
|
9498
9561
|
if (KosMock.standalone && !fos) {
|
|
9499
|
-
|
|
9562
|
+
log$H.warn(`Using KosMock standalone transport`);
|
|
9500
9563
|
return new MockMessageTransport({
|
|
9501
9564
|
host,
|
|
9502
9565
|
port,
|
|
@@ -9507,7 +9570,7 @@ class TransportFactory {
|
|
|
9507
9570
|
});
|
|
9508
9571
|
}
|
|
9509
9572
|
if (globalThis.kosWindowWebsocketOpen && !fos) {
|
|
9510
|
-
|
|
9573
|
+
log$H.warn(`Using bridged message transport`);
|
|
9511
9574
|
const transport = new BridgeMessageTransport({
|
|
9512
9575
|
host,
|
|
9513
9576
|
port,
|
|
@@ -9548,7 +9611,10 @@ if (params$1.fos) {
|
|
|
9548
9611
|
const fosPort = process.env.KOS_FOS_PORT;
|
|
9549
9612
|
window.kosUseFos = !!(window.kosUseFos || process.env.KOS_USE_FOS === "true");
|
|
9550
9613
|
window.kosFosPort = fosPort ? parseInt(fosPort) : 0;
|
|
9551
|
-
const log$
|
|
9614
|
+
const log$G = KosLog.createLogger({
|
|
9615
|
+
group: LogGroup.transport,
|
|
9616
|
+
name: "web-socket-transport"
|
|
9617
|
+
});
|
|
9552
9618
|
var KosWSTransportStatus = /* @__PURE__ */ ((KosWSTransportStatus2) => {
|
|
9553
9619
|
KosWSTransportStatus2["NOT_INITIALIZED"] = "not_initialized";
|
|
9554
9620
|
KosWSTransportStatus2["INITIALIZED"] = "initialized";
|
|
@@ -9605,7 +9671,7 @@ class WebSocketTransport {
|
|
|
9605
9671
|
() => this.connectionEstablished,
|
|
9606
9672
|
(connectionEstablished) => {
|
|
9607
9673
|
if (connectionEstablished) {
|
|
9608
|
-
log$
|
|
9674
|
+
log$G.warn("Connection Established");
|
|
9609
9675
|
this.reconnectAttempts = 0;
|
|
9610
9676
|
publish(WebSocketEvents.CONNECTED, {
|
|
9611
9677
|
reconnect: initialized
|
|
@@ -9637,7 +9703,7 @@ class WebSocketTransport {
|
|
|
9637
9703
|
return false;
|
|
9638
9704
|
}
|
|
9639
9705
|
init() {
|
|
9640
|
-
|
|
9706
|
+
log$G.warn(`Initializing WebSocketTransport on ${this.host}:${this.port}`);
|
|
9641
9707
|
if (this.useFosTransport) {
|
|
9642
9708
|
this.fosSocket = TransportFactory.build({
|
|
9643
9709
|
host: this.host,
|
|
@@ -9652,7 +9718,7 @@ class WebSocketTransport {
|
|
|
9652
9718
|
protocol: this.protocol,
|
|
9653
9719
|
alias: this.alias,
|
|
9654
9720
|
onConnectionLost: () => {
|
|
9655
|
-
log$
|
|
9721
|
+
log$G.error(`Connection Lost`);
|
|
9656
9722
|
this.scheduleReconnect();
|
|
9657
9723
|
}
|
|
9658
9724
|
});
|
|
@@ -9672,7 +9738,7 @@ class WebSocketTransport {
|
|
|
9672
9738
|
*/
|
|
9673
9739
|
scheduleReconnect() {
|
|
9674
9740
|
if (this.reconnectAttempts >= WebSocketTransport.MAX_RECONNECT_ATTEMPTS) {
|
|
9675
|
-
|
|
9741
|
+
log$G.error(
|
|
9676
9742
|
`Max reconnection attempts (${WebSocketTransport.MAX_RECONNECT_ATTEMPTS}) reached. Giving up.`
|
|
9677
9743
|
);
|
|
9678
9744
|
publish(WebSocketEvents.MAX_RETRIES_EXCEEDED, {
|
|
@@ -9681,7 +9747,7 @@ class WebSocketTransport {
|
|
|
9681
9747
|
return;
|
|
9682
9748
|
}
|
|
9683
9749
|
const delay2 = this.calculateBackoffDelay();
|
|
9684
|
-
|
|
9750
|
+
log$G.debug(
|
|
9685
9751
|
`Reconnecting in ${delay2}ms (attempt ${this.reconnectAttempts + 1}/${WebSocketTransport.MAX_RECONNECT_ATTEMPTS})`
|
|
9686
9752
|
);
|
|
9687
9753
|
setTimeout(() => {
|
|
@@ -9698,7 +9764,7 @@ class WebSocketTransport {
|
|
|
9698
9764
|
return Math.floor(exponentialDelay + jitter);
|
|
9699
9765
|
}
|
|
9700
9766
|
_sendSubscriptionMessage(topic, type, fos = false, bridge = false, connectionId, explicitDestination = false) {
|
|
9701
|
-
log$
|
|
9767
|
+
log$G.debug(`${type} to topic ${topic}`);
|
|
9702
9768
|
let connId;
|
|
9703
9769
|
if (explicitDestination) {
|
|
9704
9770
|
connId = connectionId;
|
|
@@ -9707,7 +9773,7 @@ class WebSocketTransport {
|
|
|
9707
9773
|
const connectionParam = params2?.connId;
|
|
9708
9774
|
connId = connectionId ?? connectionParam ?? window?.kosBridge?.("connId");
|
|
9709
9775
|
}
|
|
9710
|
-
log$
|
|
9776
|
+
log$G.debug(`subscribing with connId ${connId}`);
|
|
9711
9777
|
const dstAddr = connId ? `dst-addr:${connId}
|
|
9712
9778
|
` : "";
|
|
9713
9779
|
const msg = fos ? `subscribe:${topic}` : bridge ? `type:fos.broker
|
|
@@ -9721,7 +9787,7 @@ ${dstAddr}topics:${topic}
|
|
|
9721
9787
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9722
9788
|
socket?.socket?.send(msg);
|
|
9723
9789
|
} else {
|
|
9724
|
-
log$
|
|
9790
|
+
log$G.debug(`no connection adding to offline messages`);
|
|
9725
9791
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9726
9792
|
socket?.addOfflineMessage(msg);
|
|
9727
9793
|
}
|
|
@@ -9735,7 +9801,7 @@ ${dstAddr}topics:${topic}
|
|
|
9735
9801
|
explicitDestination
|
|
9736
9802
|
}) {
|
|
9737
9803
|
const { unsubscribe, count } = subscribe(topic, callback);
|
|
9738
|
-
log$
|
|
9804
|
+
log$G.debug(`Topic ${topic} currently has ${count} subscribers`);
|
|
9739
9805
|
this._sendSubscriptionMessage(
|
|
9740
9806
|
topic,
|
|
9741
9807
|
"subscribe",
|
|
@@ -9746,7 +9812,7 @@ ${dstAddr}topics:${topic}
|
|
|
9746
9812
|
);
|
|
9747
9813
|
return () => {
|
|
9748
9814
|
const { count: count2 } = unsubscribe();
|
|
9749
|
-
log$
|
|
9815
|
+
log$G.debug(`Topic ${topic} currently has ${count2} subscribers`);
|
|
9750
9816
|
if (count2 === 0) {
|
|
9751
9817
|
this._sendSubscriptionMessage(
|
|
9752
9818
|
topic,
|
|
@@ -9786,7 +9852,7 @@ ${dstAddr}topics:${topic}
|
|
|
9786
9852
|
}
|
|
9787
9853
|
dropConnection() {
|
|
9788
9854
|
if (!this.connectionEstablished) {
|
|
9789
|
-
log$
|
|
9855
|
+
log$G.debug("dropConnection ignored: the connection is already closed");
|
|
9790
9856
|
return;
|
|
9791
9857
|
}
|
|
9792
9858
|
this.socket?.socket.close(1e3);
|
|
@@ -10572,21 +10638,17 @@ class ServiceResponseStore {
|
|
|
10572
10638
|
class KosModelComponentFactory {
|
|
10573
10639
|
static createAll(model) {
|
|
10574
10640
|
const { modelId, modelTypeName, modelData } = model;
|
|
10575
|
-
const log3 = KosLoggerFactory.create({
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
const fsm2 = new KosFSMManager(model, createTaggedLogger(log3, "fsm"));
|
|
10580
|
-
const offlineQueue = new KosOfflineQueue(
|
|
10581
|
-
createTaggedLogger(log3, "offline-queue")
|
|
10582
|
-
);
|
|
10641
|
+
const log3 = KosLoggerFactory.create({ modelTypeName });
|
|
10642
|
+
const tagged = (tag) => createTaggedLogger(log3, `${modelId}:${tag}`);
|
|
10643
|
+
const fsm2 = new KosFSMManager(model, tagged("fsm"));
|
|
10644
|
+
const offlineQueue = new KosOfflineQueue(tagged("offline-queue"));
|
|
10583
10645
|
const companionManager = new KosCompanionModelManager(model);
|
|
10584
10646
|
const childResolver = new KosChildResolver(model);
|
|
10585
10647
|
const serviceResponseStore = new ServiceResponseStore();
|
|
10586
10648
|
modelData.serviceResponses = serviceResponseStore;
|
|
10587
10649
|
const onlineLifecycleManager = new KosOnlineLifecycleManager(
|
|
10588
10650
|
model,
|
|
10589
|
-
|
|
10651
|
+
tagged("online")
|
|
10590
10652
|
);
|
|
10591
10653
|
const components = {
|
|
10592
10654
|
fsm: fsm2,
|
|
@@ -10601,11 +10663,11 @@ class KosModelComponentFactory {
|
|
|
10601
10663
|
modelTypeName,
|
|
10602
10664
|
modelId,
|
|
10603
10665
|
modelData,
|
|
10604
|
-
|
|
10666
|
+
tagged("effect")
|
|
10605
10667
|
);
|
|
10606
10668
|
}
|
|
10607
10669
|
if (hasSubscriptionHandlers(modelData)) {
|
|
10608
|
-
const subLogger =
|
|
10670
|
+
const subLogger = tagged("subscription");
|
|
10609
10671
|
components.subscriptionManager = new KosSubscriptionManager(
|
|
10610
10672
|
model,
|
|
10611
10673
|
modelData,
|
|
@@ -10617,7 +10679,7 @@ class KosModelComponentFactory {
|
|
|
10617
10679
|
if (hasHttpRouteHandlers(modelData)) {
|
|
10618
10680
|
components.httpRouteManager = new KosHttpRouteManager(
|
|
10619
10681
|
modelData,
|
|
10620
|
-
|
|
10682
|
+
tagged("http-routes")
|
|
10621
10683
|
);
|
|
10622
10684
|
}
|
|
10623
10685
|
if (hasServiceRequestHandlers(modelData)) {
|
|
@@ -10630,7 +10692,7 @@ class KosModelComponentFactory {
|
|
|
10630
10692
|
return components;
|
|
10631
10693
|
}
|
|
10632
10694
|
}
|
|
10633
|
-
const log$
|
|
10695
|
+
const log$F = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
10634
10696
|
const MODEL_LOADER = "kos.extension.model.loader";
|
|
10635
10697
|
class KosModel {
|
|
10636
10698
|
_id;
|
|
@@ -10738,23 +10800,23 @@ class KosModel {
|
|
|
10738
10800
|
return this._status === KosModelState.READY;
|
|
10739
10801
|
}
|
|
10740
10802
|
async deactivate() {
|
|
10741
|
-
log$
|
|
10803
|
+
log$F.debug(
|
|
10742
10804
|
`deactivating model ${this.modelTypeName} with id ${this.modelId}`
|
|
10743
10805
|
);
|
|
10744
10806
|
try {
|
|
10745
10807
|
const context = KosContextManager.getContext(this.modelId);
|
|
10746
10808
|
await this.modelData?.deactivate?.(context);
|
|
10747
|
-
log$
|
|
10809
|
+
log$F.debug(
|
|
10748
10810
|
`Model ${this.modelTypeName} with id ${this.modelId} deactivated`
|
|
10749
10811
|
);
|
|
10750
10812
|
this.subscriptionManager?.deactivate();
|
|
10751
10813
|
} catch (e) {
|
|
10752
|
-
log$
|
|
10814
|
+
log$F.debug(`Model ${this.modelId} failed to deactivated`);
|
|
10753
10815
|
throw e;
|
|
10754
10816
|
}
|
|
10755
10817
|
}
|
|
10756
10818
|
async activate() {
|
|
10757
|
-
log$
|
|
10819
|
+
log$F.debug(`activating model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10758
10820
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ACTIVATE);
|
|
10759
10821
|
try {
|
|
10760
10822
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10763,16 +10825,16 @@ class KosModel {
|
|
|
10763
10825
|
const context = KosContextManager.getContext(this.modelId);
|
|
10764
10826
|
await this.modelData?.activate?.(context);
|
|
10765
10827
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.ACTIVATE);
|
|
10766
|
-
log$
|
|
10828
|
+
log$F.debug(
|
|
10767
10829
|
`Model ${this.modelTypeName} with id ${this.modelId} subscribing to all topics`
|
|
10768
10830
|
);
|
|
10769
10831
|
this.subscriptionManager?.registerAll(DependencyLifecycle.ACTIVATE);
|
|
10770
10832
|
this.createLifecycleCompanions(DependencyLifecycle.ACTIVATE);
|
|
10771
|
-
log$
|
|
10833
|
+
log$F.debug(
|
|
10772
10834
|
`Model ${this.modelTypeName} with id ${this.modelId} activated`
|
|
10773
10835
|
);
|
|
10774
10836
|
} catch (e) {
|
|
10775
|
-
log$
|
|
10837
|
+
log$F.debug(`Model ${this.modelId} failed to activate`);
|
|
10776
10838
|
throw e;
|
|
10777
10839
|
}
|
|
10778
10840
|
return;
|
|
@@ -10788,7 +10850,7 @@ class KosModel {
|
|
|
10788
10850
|
{
|
|
10789
10851
|
condition: () => this.loaded,
|
|
10790
10852
|
onMatch: () => {
|
|
10791
|
-
log$
|
|
10853
|
+
log$F.debug(`Model ${this.modelId} is loaded`);
|
|
10792
10854
|
}
|
|
10793
10855
|
}
|
|
10794
10856
|
]);
|
|
@@ -10804,7 +10866,7 @@ class KosModel {
|
|
|
10804
10866
|
{
|
|
10805
10867
|
condition: () => this.initialized,
|
|
10806
10868
|
onMatch: () => {
|
|
10807
|
-
log$
|
|
10869
|
+
log$F.debug(`Model ${this.modelId} is initialized`);
|
|
10808
10870
|
}
|
|
10809
10871
|
}
|
|
10810
10872
|
]);
|
|
@@ -10820,20 +10882,20 @@ class KosModel {
|
|
|
10820
10882
|
{
|
|
10821
10883
|
condition: () => this.status === KosModelState.READY,
|
|
10822
10884
|
onMatch: () => {
|
|
10823
|
-
log$
|
|
10885
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10824
10886
|
}
|
|
10825
10887
|
}
|
|
10826
10888
|
]);
|
|
10827
10889
|
}
|
|
10828
10890
|
async ready() {
|
|
10829
10891
|
if (this.fsm.current === KosModelState.READY) {
|
|
10830
|
-
log$
|
|
10892
|
+
log$F.debug(
|
|
10831
10893
|
`already readying model ${this.modelTypeName} with id ${this.modelId} returning`
|
|
10832
10894
|
);
|
|
10833
10895
|
return;
|
|
10834
10896
|
}
|
|
10835
10897
|
try {
|
|
10836
|
-
log$
|
|
10898
|
+
log$F.debug(`readying model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10837
10899
|
await executeDependentModelLifecycle(this, DependencyLifecycle.READY);
|
|
10838
10900
|
await executeChildrenModelLifecycle(
|
|
10839
10901
|
this,
|
|
@@ -10849,7 +10911,7 @@ class KosModel {
|
|
|
10849
10911
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.READY);
|
|
10850
10912
|
this.subscriptionManager?.registerAll(DependencyLifecycle.READY);
|
|
10851
10913
|
this.createLifecycleCompanions(DependencyLifecycle.READY);
|
|
10852
|
-
log$
|
|
10914
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10853
10915
|
const payload = {
|
|
10854
10916
|
modelId: this.modelId,
|
|
10855
10917
|
modelType: this.modelTypeName
|
|
@@ -10860,7 +10922,7 @@ class KosModel {
|
|
|
10860
10922
|
);
|
|
10861
10923
|
publish(modelTypeEventTopicFactory(this.modelTypeName), payload);
|
|
10862
10924
|
} catch (e) {
|
|
10863
|
-
log$
|
|
10925
|
+
log$F.error(e);
|
|
10864
10926
|
throw Error(e);
|
|
10865
10927
|
}
|
|
10866
10928
|
}
|
|
@@ -10871,18 +10933,18 @@ class KosModel {
|
|
|
10871
10933
|
}
|
|
10872
10934
|
const { modelTypeName, modelId } = this;
|
|
10873
10935
|
if (this.fsm.current === KosModelState.LOADED) {
|
|
10874
|
-
log$
|
|
10936
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} already loaded`);
|
|
10875
10937
|
return;
|
|
10876
10938
|
}
|
|
10877
10939
|
if (this._isLoadExecuting) {
|
|
10878
|
-
log$
|
|
10940
|
+
log$F.debug(
|
|
10879
10941
|
`Model ${modelTypeName} with id ${modelId} is currently executing load`
|
|
10880
10942
|
);
|
|
10881
10943
|
return;
|
|
10882
10944
|
}
|
|
10883
10945
|
this._isLoadExecuting = true;
|
|
10884
10946
|
try {
|
|
10885
|
-
log$
|
|
10947
|
+
log$F.debug(`Loading model ${modelTypeName} with id ${modelId}`);
|
|
10886
10948
|
await executeDependentModelLifecycle(this, DependencyLifecycle.LOAD);
|
|
10887
10949
|
const context = KosContextManager.getContext(modelId);
|
|
10888
10950
|
const MODEL_LOADER_TYPE = `${MODEL_LOADER}.${modelTypeName}`;
|
|
@@ -10891,7 +10953,7 @@ class KosModel {
|
|
|
10891
10953
|
{}
|
|
10892
10954
|
);
|
|
10893
10955
|
if (loadedContext) {
|
|
10894
|
-
log$
|
|
10956
|
+
log$F.info(
|
|
10895
10957
|
`Setting loaded context for ${modelId}, type: ${modelTypeName}`
|
|
10896
10958
|
);
|
|
10897
10959
|
context?.set(MODEL_LOADER_TYPE, loadedContext);
|
|
@@ -10903,7 +10965,7 @@ class KosModel {
|
|
|
10903
10965
|
kosAction(() => {
|
|
10904
10966
|
this.loaded = true;
|
|
10905
10967
|
});
|
|
10906
|
-
log$
|
|
10968
|
+
log$F.debug(
|
|
10907
10969
|
`Model ${modelTypeName} with id ${modelId} successfully loaded`
|
|
10908
10970
|
);
|
|
10909
10971
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.LOAD);
|
|
@@ -10912,14 +10974,14 @@ class KosModel {
|
|
|
10912
10974
|
this.effectManager?.setup();
|
|
10913
10975
|
this.createLifecycleCompanions(DependencyLifecycle.LOAD);
|
|
10914
10976
|
} catch (e) {
|
|
10915
|
-
log$
|
|
10977
|
+
log$F.error(`Model ${modelId} failed to load`, e);
|
|
10916
10978
|
throw e;
|
|
10917
10979
|
} finally {
|
|
10918
10980
|
this._isLoadExecuting = false;
|
|
10919
10981
|
}
|
|
10920
10982
|
}
|
|
10921
10983
|
async unload() {
|
|
10922
|
-
log$
|
|
10984
|
+
log$F.debug(`unloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10923
10985
|
try {
|
|
10924
10986
|
const childrenUnload = this.getChildren().map((child) => child.unload?.()).filter((p) => !!p);
|
|
10925
10987
|
await Promise.allSettled(childrenUnload);
|
|
@@ -10938,12 +11000,12 @@ class KosModel {
|
|
|
10938
11000
|
modelData.stateHistory = [];
|
|
10939
11001
|
}
|
|
10940
11002
|
}
|
|
10941
|
-
log$
|
|
11003
|
+
log$F.debug(`Model ${this.modelTypeName} with id ${this.modelId} unloaded`);
|
|
10942
11004
|
this.effectManager?.disposeAll();
|
|
10943
11005
|
this.subscriptionManager?.disposeAll();
|
|
10944
11006
|
this.httpRouteManager?.dispose();
|
|
10945
11007
|
} catch (e) {
|
|
10946
|
-
log$
|
|
11008
|
+
log$F.debug(`Model ${this.modelId} failed to unload`);
|
|
10947
11009
|
throw e;
|
|
10948
11010
|
}
|
|
10949
11011
|
}
|
|
@@ -10954,7 +11016,7 @@ class KosModel {
|
|
|
10954
11016
|
}
|
|
10955
11017
|
const { modelId, modelTypeName } = this;
|
|
10956
11018
|
const context = KosContextManager.getContext(modelId);
|
|
10957
|
-
log$
|
|
11019
|
+
log$F.debug(`Initializing model ${modelTypeName} with id ${modelId}`);
|
|
10958
11020
|
await executeDependentModelLifecycle(this, DependencyLifecycle.INIT);
|
|
10959
11021
|
try {
|
|
10960
11022
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10962,18 +11024,18 @@ class KosModel {
|
|
|
10962
11024
|
);
|
|
10963
11025
|
await this.modelData?.init?.(context);
|
|
10964
11026
|
this.initialized = true;
|
|
10965
|
-
log$
|
|
11027
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} initialized`);
|
|
10966
11028
|
this.onlineLifecycleManager?.register();
|
|
10967
11029
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.INIT);
|
|
10968
11030
|
this.registerSubscribers(DependencyLifecycle.INIT);
|
|
10969
11031
|
this.createLifecycleCompanions(DependencyLifecycle.INIT);
|
|
10970
11032
|
} catch (e) {
|
|
10971
|
-
log$
|
|
11033
|
+
log$F.error(`Model ${modelId} failed to initialize`, e);
|
|
10972
11034
|
throw e;
|
|
10973
11035
|
}
|
|
10974
11036
|
}
|
|
10975
11037
|
async registerSubscribers(lifecycle) {
|
|
10976
|
-
log$
|
|
11038
|
+
log$F.debug(
|
|
10977
11039
|
`registering subscribers in ${this.modelTypeName} with id ${this.modelId}`
|
|
10978
11040
|
);
|
|
10979
11041
|
this.subscriptionManager?.registerAll(lifecycle);
|
|
@@ -10990,7 +11052,7 @@ class KosModel {
|
|
|
10990
11052
|
}
|
|
10991
11053
|
/** @internal */
|
|
10992
11054
|
async reloadData() {
|
|
10993
|
-
log$
|
|
11055
|
+
log$F.info(`reloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10994
11056
|
this.suspendForReload();
|
|
10995
11057
|
const data = this.modelData;
|
|
10996
11058
|
if (typeof data?.reload === "function" && !data[SelfManagedReload]) {
|
|
@@ -10999,7 +11061,7 @@ class KosModel {
|
|
|
10999
11061
|
}
|
|
11000
11062
|
/** @internal */
|
|
11001
11063
|
async reattach() {
|
|
11002
|
-
log$
|
|
11064
|
+
log$F.info(`reattaching model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11003
11065
|
kosAction(() => {
|
|
11004
11066
|
this.loaded = true;
|
|
11005
11067
|
});
|
|
@@ -11030,7 +11092,7 @@ class KosModel {
|
|
|
11030
11092
|
]);
|
|
11031
11093
|
reloaded.forEach((result, index) => {
|
|
11032
11094
|
if (result.status === "rejected") {
|
|
11033
|
-
log$
|
|
11095
|
+
log$F.error(
|
|
11034
11096
|
`reload of child ${ready[index].modelId} of ${this.modelId} failed`,
|
|
11035
11097
|
result.reason
|
|
11036
11098
|
);
|
|
@@ -11061,7 +11123,7 @@ class KosModel {
|
|
|
11061
11123
|
* each time. A state machine with `initializeAt: ONLINE` starts once.
|
|
11062
11124
|
*/
|
|
11063
11125
|
async online() {
|
|
11064
|
-
log$
|
|
11126
|
+
log$F.debug(`online model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11065
11127
|
this.registerSubscribers();
|
|
11066
11128
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ONLINE);
|
|
11067
11129
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -11073,7 +11135,7 @@ class KosModel {
|
|
|
11073
11135
|
this.createLifecycleCompanions(DependencyLifecycle.ONLINE);
|
|
11074
11136
|
}
|
|
11075
11137
|
async offline() {
|
|
11076
|
-
log$
|
|
11138
|
+
log$F.debug(`offline model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11077
11139
|
this.subscriptionManager?.disposeAll();
|
|
11078
11140
|
const context = KosContextManager.getContext(this.modelId);
|
|
11079
11141
|
await this.modelData?.offline?.(context);
|
|
@@ -11091,7 +11153,7 @@ class KosModel {
|
|
|
11091
11153
|
this.companionManager.clear();
|
|
11092
11154
|
}
|
|
11093
11155
|
}
|
|
11094
|
-
const log$
|
|
11156
|
+
const log$E = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-instantiator" });
|
|
11095
11157
|
class KosModelInstantiator {
|
|
11096
11158
|
constructor(registry, cache2) {
|
|
11097
11159
|
this.registry = registry;
|
|
@@ -11109,7 +11171,7 @@ class KosModelInstantiator {
|
|
|
11109
11171
|
const modelRegistry = this.registry.models[typeId];
|
|
11110
11172
|
if (!modelRegistry) {
|
|
11111
11173
|
const errorMessage = `No model registered for type ${typeId}`;
|
|
11112
|
-
log$
|
|
11174
|
+
log$E.error(errorMessage, {
|
|
11113
11175
|
modelType: typeId,
|
|
11114
11176
|
requestedId: id,
|
|
11115
11177
|
providedOptions: options,
|
|
@@ -11128,7 +11190,7 @@ class KosModelInstantiator {
|
|
|
11128
11190
|
const modelId = modelRegistry.singleton ? typeId : id;
|
|
11129
11191
|
this.cache.restoreFromDeleteCache(modelId);
|
|
11130
11192
|
if (!this.cache.hasModel(modelId)) {
|
|
11131
|
-
log$
|
|
11193
|
+
log$E.debug(`Creating model instance: ${typeId} [${modelId}]`);
|
|
11132
11194
|
const hasOptions = options && Object.keys(options).length > 0;
|
|
11133
11195
|
const modelClass = modelRegistry.class || modelRegistry.create;
|
|
11134
11196
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
@@ -11174,7 +11236,7 @@ class KosModelInstantiator {
|
|
|
11174
11236
|
}
|
|
11175
11237
|
const activeModel = this.cache.getModelById(modelId);
|
|
11176
11238
|
if (!activeModel) {
|
|
11177
|
-
log$
|
|
11239
|
+
log$E.error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11178
11240
|
throw new Error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11179
11241
|
}
|
|
11180
11242
|
return { model: activeModel, data: activeModel.modelData };
|
|
@@ -11240,7 +11302,7 @@ let KosModelRegistry$1 = class KosModelRegistry {
|
|
|
11240
11302
|
}
|
|
11241
11303
|
};
|
|
11242
11304
|
const MODEL_DELETION_DELAY = 10;
|
|
11243
|
-
const log$
|
|
11305
|
+
const log$D = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-manager" });
|
|
11244
11306
|
class KosModelManager {
|
|
11245
11307
|
cache;
|
|
11246
11308
|
instantiator;
|
|
@@ -11283,7 +11345,7 @@ class KosModelManager {
|
|
|
11283
11345
|
}
|
|
11284
11346
|
static getInstance(reset2) {
|
|
11285
11347
|
if (!globalThis.kos?.modelManager || reset2) {
|
|
11286
|
-
log$
|
|
11348
|
+
log$D.debug("Creating new instance of KosModelManager");
|
|
11287
11349
|
new this();
|
|
11288
11350
|
}
|
|
11289
11351
|
return globalThis.kos?.modelManager;
|
|
@@ -11304,7 +11366,7 @@ class KosModelManager {
|
|
|
11304
11366
|
*/
|
|
11305
11367
|
get preloadedModels() {
|
|
11306
11368
|
return this.cache.preload((modelKey) => {
|
|
11307
|
-
log$
|
|
11369
|
+
log$D.debug(`preloading ${modelKey}`);
|
|
11308
11370
|
if (typeof modelKey === "string") {
|
|
11309
11371
|
return this.createModelInstance(modelKey).model;
|
|
11310
11372
|
} else {
|
|
@@ -11600,6 +11662,10 @@ class KosModelManager {
|
|
|
11600
11662
|
this._registry.registerModel(reg);
|
|
11601
11663
|
}
|
|
11602
11664
|
}
|
|
11665
|
+
const log$C = KosLog.createLogger({
|
|
11666
|
+
group: LogGroup.core,
|
|
11667
|
+
name: "kos-core-lifecycle"
|
|
11668
|
+
});
|
|
11603
11669
|
var KosCoreState = /* @__PURE__ */ ((KosCoreState2) => {
|
|
11604
11670
|
KosCoreState2["CREATING"] = `creating`;
|
|
11605
11671
|
KosCoreState2["CREATED"] = `created`;
|
|
@@ -11636,7 +11702,7 @@ const reportFailure = async (step, run) => {
|
|
|
11636
11702
|
return await run();
|
|
11637
11703
|
} catch (error) {
|
|
11638
11704
|
const detail = error instanceof Error ? error.stack ?? `${error.name}: ${error.message}` : String(error);
|
|
11639
|
-
log$
|
|
11705
|
+
log$C.error(`KOS Core lifecycle step "${step}" failed. ${detail}`);
|
|
11640
11706
|
throw error;
|
|
11641
11707
|
}
|
|
11642
11708
|
};
|
|
@@ -11675,7 +11741,7 @@ const coreFsm = (core) => {
|
|
|
11675
11741
|
});
|
|
11676
11742
|
const online = robot3.interpret(
|
|
11677
11743
|
onlineMachine2,
|
|
11678
|
-
(_service) => log$
|
|
11744
|
+
(_service) => log$C.debug(`KOS Core connection: ${_service.machine.current}`)
|
|
11679
11745
|
);
|
|
11680
11746
|
const syncOnline = () => online.send(
|
|
11681
11747
|
core.transport.connectionEstablished ? "go_online" : "go_offline"
|
|
@@ -11889,11 +11955,11 @@ const coreFsm = (core) => {
|
|
|
11889
11955
|
});
|
|
11890
11956
|
const service2 = robot3.interpret(
|
|
11891
11957
|
machine2,
|
|
11892
|
-
(_service) => log$
|
|
11958
|
+
(_service) => log$C.debug(`KOS Core state: ${_service.machine.current}`)
|
|
11893
11959
|
);
|
|
11894
11960
|
return { service: service2, online };
|
|
11895
11961
|
};
|
|
11896
|
-
const log$
|
|
11962
|
+
const log$B = KosLog.createLogger({ group: LogGroup.core, name: "kos-core" });
|
|
11897
11963
|
const getConnectionAlias = () => {
|
|
11898
11964
|
const params2 = getQueryParams();
|
|
11899
11965
|
const alias = params2?.alias;
|
|
@@ -11947,11 +12013,11 @@ const rejectAfterDelay = (ms, model) => {
|
|
|
11947
12013
|
const promise = new Promise((_, reject) => {
|
|
11948
12014
|
timeoutId = setTimeout(() => {
|
|
11949
12015
|
if (model) {
|
|
11950
|
-
|
|
12016
|
+
log$B.error(
|
|
11951
12017
|
`Model ${model.modelId} - ${model.modelTypeName} preloading - timed out after ${ms}ms`
|
|
11952
12018
|
);
|
|
11953
12019
|
} else {
|
|
11954
|
-
|
|
12020
|
+
log$B.error(`KOS Core preloading timed out after ${ms}ms`);
|
|
11955
12021
|
}
|
|
11956
12022
|
reject(
|
|
11957
12023
|
new Error(
|
|
@@ -12036,11 +12102,11 @@ class KosCore {
|
|
|
12036
12102
|
});
|
|
12037
12103
|
});
|
|
12038
12104
|
subscribe(WebSocketEvents.RELOAD, () => {
|
|
12039
|
-
log$
|
|
12105
|
+
log$B.warn("WebSocket requested reload");
|
|
12040
12106
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12041
12107
|
});
|
|
12042
12108
|
subscribe("/studio/project/reload", () => {
|
|
12043
|
-
log$
|
|
12109
|
+
log$B.warn("Project requested reload");
|
|
12044
12110
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12045
12111
|
});
|
|
12046
12112
|
const ws = WebSocketTransport.getInstance();
|
|
@@ -12069,7 +12135,7 @@ class KosCore {
|
|
|
12069
12135
|
applyConnectionAlias(connectionAlias) {
|
|
12070
12136
|
if (this._transport.alias) {
|
|
12071
12137
|
if (this.connectionAlias && this.connectionAlias !== connectionAlias) {
|
|
12072
|
-
log$
|
|
12138
|
+
log$B.warn(
|
|
12073
12139
|
`Connection alias ${connectionAlias} ignored; the connection already uses ${this._transport.alias}`
|
|
12074
12140
|
);
|
|
12075
12141
|
}
|
|
@@ -12107,13 +12173,13 @@ alias:${alias}
|
|
|
12107
12173
|
}
|
|
12108
12174
|
async reload() {
|
|
12109
12175
|
if (this._reloading) {
|
|
12110
|
-
log$
|
|
12176
|
+
log$B.info("reload already in progress");
|
|
12111
12177
|
return;
|
|
12112
12178
|
}
|
|
12113
12179
|
this._reloading = true;
|
|
12114
12180
|
try {
|
|
12115
|
-
log$
|
|
12116
|
-
log$
|
|
12181
|
+
log$B.warn("reloading KOS Core");
|
|
12182
|
+
log$B.warn("reloading preloaded models");
|
|
12117
12183
|
const modelManager = this.modelManager;
|
|
12118
12184
|
const preloaded = [...modelManager.preloadedModels];
|
|
12119
12185
|
const covered = /* @__PURE__ */ new Set();
|
|
@@ -12125,27 +12191,27 @@ alias:${alias}
|
|
|
12125
12191
|
for (const model of preloaded) {
|
|
12126
12192
|
if (isReloadable(model.modelData) && !covered.has(model)) {
|
|
12127
12193
|
if (isSelfManagedReload(model.modelData)) {
|
|
12128
|
-
log$
|
|
12194
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12129
12195
|
continue;
|
|
12130
12196
|
}
|
|
12131
|
-
log$
|
|
12197
|
+
log$B.info(`reloading model ${model.modelId}`);
|
|
12132
12198
|
await reloadRoot(model);
|
|
12133
|
-
log$
|
|
12199
|
+
log$B.info(`reloading model ${model.modelId} complete`);
|
|
12134
12200
|
}
|
|
12135
12201
|
}
|
|
12136
12202
|
for (const model of [...modelManager.models]) {
|
|
12137
12203
|
if (!preloaded.includes(model) && isReloadable(model.modelData) && !covered.has(model)) {
|
|
12138
12204
|
if (isSelfManagedReload(model.modelData)) {
|
|
12139
|
-
log$
|
|
12205
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12140
12206
|
continue;
|
|
12141
12207
|
}
|
|
12142
|
-
log$
|
|
12208
|
+
log$B.warn(`reloading model ${model.modelId}`);
|
|
12143
12209
|
await reloadRoot(model);
|
|
12144
12210
|
}
|
|
12145
12211
|
}
|
|
12146
12212
|
} finally {
|
|
12147
12213
|
mobx.runInAction(() => {
|
|
12148
|
-
log$
|
|
12214
|
+
log$B.warn("reloading KOS Core complete");
|
|
12149
12215
|
this._reloading = false;
|
|
12150
12216
|
});
|
|
12151
12217
|
}
|
|
@@ -12155,13 +12221,13 @@ alias:${alias}
|
|
|
12155
12221
|
try {
|
|
12156
12222
|
await model.fsm.reload();
|
|
12157
12223
|
} catch (e) {
|
|
12158
|
-
log$
|
|
12224
|
+
log$B.error(`reload of ${model.modelId} failed`, e);
|
|
12159
12225
|
}
|
|
12160
12226
|
}
|
|
12161
12227
|
async online() {
|
|
12162
|
-
log$
|
|
12228
|
+
log$B.debug("KOS Core going online");
|
|
12163
12229
|
await this._transport.whenReady();
|
|
12164
|
-
log$
|
|
12230
|
+
log$B.debug("KOS Transport Ready. Calling online() for models");
|
|
12165
12231
|
this.modelManager.models.forEach(
|
|
12166
12232
|
(model) => model.onlineLifecycleManager?.register()
|
|
12167
12233
|
);
|
|
@@ -12169,14 +12235,14 @@ alias:${alias}
|
|
|
12169
12235
|
console.timeEnd("kosCore:startup");
|
|
12170
12236
|
}
|
|
12171
12237
|
async offline() {
|
|
12172
|
-
log$
|
|
12238
|
+
log$B.debug("KOS Core going offline");
|
|
12173
12239
|
publish("/kosCore/offline", "/kosCore/offline");
|
|
12174
12240
|
}
|
|
12175
12241
|
async unload() {
|
|
12176
|
-
log$
|
|
12242
|
+
log$B.debug("Unloading KOS Core");
|
|
12177
12243
|
const currentTime = Date.now();
|
|
12178
12244
|
this._unloading = true;
|
|
12179
|
-
log$
|
|
12245
|
+
log$B.debug("unloading KOS Core");
|
|
12180
12246
|
const modelManager = this.modelManager;
|
|
12181
12247
|
for (const model of modelManager.models) {
|
|
12182
12248
|
if (isUnloadable(model.modelData)) {
|
|
@@ -12194,9 +12260,9 @@ alias:${alias}
|
|
|
12194
12260
|
await mobx.when(() => this.status === KosCoreState.READY);
|
|
12195
12261
|
}
|
|
12196
12262
|
async ready() {
|
|
12197
|
-
log$
|
|
12263
|
+
log$B.debug("Readying KOS Core");
|
|
12198
12264
|
await this._transport.whenReady();
|
|
12199
|
-
log$
|
|
12265
|
+
log$B.debug("KOS Transport ready. Preloading models");
|
|
12200
12266
|
if (!this.modelManager) {
|
|
12201
12267
|
throw new Error(
|
|
12202
12268
|
"KOS Core reached ready() with no model manager. Its lifecycle was started without a registry."
|
|
@@ -12209,7 +12275,7 @@ alias:${alias}
|
|
|
12209
12275
|
promise: model.whenReady()
|
|
12210
12276
|
};
|
|
12211
12277
|
});
|
|
12212
|
-
log$
|
|
12278
|
+
log$B.debug(`Preloaded ${promises.length} models`);
|
|
12213
12279
|
const settled = await Promise.allSettled(
|
|
12214
12280
|
promises.map((promise) => {
|
|
12215
12281
|
const { promise: timeoutPromise, cancel: timeoutCancel } = rejectAfterDelay(5e3, promise.model);
|
|
@@ -12223,14 +12289,14 @@ alias:${alias}
|
|
|
12223
12289
|
);
|
|
12224
12290
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
12225
12291
|
if (failed.length) {
|
|
12226
|
-
log$
|
|
12292
|
+
log$B.error(
|
|
12227
12293
|
`There were ${failed.length} failed models on model preloading`
|
|
12228
12294
|
);
|
|
12229
12295
|
throw Error(
|
|
12230
12296
|
`There were ${failed.length} failed models on model preloading`
|
|
12231
12297
|
);
|
|
12232
12298
|
}
|
|
12233
|
-
log$
|
|
12299
|
+
log$B.debug(`leaving kos-core ready() `);
|
|
12234
12300
|
}
|
|
12235
12301
|
get isReady() {
|
|
12236
12302
|
return this.status === KosCoreState.READY;
|
|
@@ -12248,19 +12314,19 @@ alias:${alias}
|
|
|
12248
12314
|
return this.loaded;
|
|
12249
12315
|
}
|
|
12250
12316
|
async init() {
|
|
12251
|
-
log$
|
|
12317
|
+
log$B.debug("entering kos-core init()");
|
|
12252
12318
|
console.time("kosCore:startup");
|
|
12253
12319
|
console.time("kosCore:init");
|
|
12254
12320
|
await this._transport.whenReady();
|
|
12255
12321
|
this.initialized = true;
|
|
12256
|
-
log$
|
|
12322
|
+
log$B.debug("initialized - leaving kos-core init()");
|
|
12257
12323
|
console.timeEnd("kosCore:init");
|
|
12258
12324
|
}
|
|
12259
12325
|
async load() {
|
|
12260
|
-
log$
|
|
12326
|
+
log$B.debug("entering kos-core load()");
|
|
12261
12327
|
console.time("kosCore:load");
|
|
12262
12328
|
this.loaded = true;
|
|
12263
|
-
log$
|
|
12329
|
+
log$B.debug("loaded - leaving kos-core load()");
|
|
12264
12330
|
console.timeEnd("kosCore:load");
|
|
12265
12331
|
}
|
|
12266
12332
|
static create(registry, reset2, connectionAlias) {
|
|
@@ -12350,10 +12416,7 @@ alias:${alias}
|
|
|
12350
12416
|
return this._instance;
|
|
12351
12417
|
}
|
|
12352
12418
|
}
|
|
12353
|
-
const log$
|
|
12354
|
-
name: "kos-model-visitor",
|
|
12355
|
-
group: "kos-ui-core"
|
|
12356
|
-
});
|
|
12419
|
+
const log$A = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-visitor" });
|
|
12357
12420
|
class KosModelVisitor {
|
|
12358
12421
|
/**
|
|
12359
12422
|
* A set to keep track of visited model IDs to prevent redundant visits.
|
|
@@ -12391,7 +12454,7 @@ class KosModelVisitor {
|
|
|
12391
12454
|
*/
|
|
12392
12455
|
visit(model) {
|
|
12393
12456
|
if (this.visitedModels.has(model.modelId)) {
|
|
12394
|
-
log$
|
|
12457
|
+
log$A.info(`model ${model.modelId} already visited`);
|
|
12395
12458
|
return;
|
|
12396
12459
|
}
|
|
12397
12460
|
const stopVisiting = !!this.visitModel(model.modelData, this);
|
|
@@ -12404,6 +12467,10 @@ class KosModelVisitor {
|
|
|
12404
12467
|
});
|
|
12405
12468
|
}
|
|
12406
12469
|
}
|
|
12470
|
+
const log$z = KosLog.createLogger({
|
|
12471
|
+
group: LogGroup.core,
|
|
12472
|
+
name: "feature-flags"
|
|
12473
|
+
});
|
|
12407
12474
|
const EXTENSION_FEATURE_FLAG_RESOLVER = "featureFlagResolver";
|
|
12408
12475
|
const flagResolvers = /* @__PURE__ */ new Map();
|
|
12409
12476
|
registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
@@ -12424,7 +12491,7 @@ registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
|
12424
12491
|
if (r.status === "fulfilled") {
|
|
12425
12492
|
return r.value;
|
|
12426
12493
|
} else {
|
|
12427
|
-
|
|
12494
|
+
log$z.info(`Feature flag resolver ${id} failed: ${r.reason}`);
|
|
12428
12495
|
return [];
|
|
12429
12496
|
}
|
|
12430
12497
|
}).flat();
|
|
@@ -12497,7 +12564,38 @@ const modelFactory = (typeId) => {
|
|
|
12497
12564
|
};
|
|
12498
12565
|
};
|
|
12499
12566
|
const pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);
|
|
12500
|
-
const log$
|
|
12567
|
+
const log$y = KosLog.createLogger({
|
|
12568
|
+
group: LogGroup.core,
|
|
12569
|
+
name: "retry-with-exponential-backoff"
|
|
12570
|
+
});
|
|
12571
|
+
const BASE_OPTIONS = {
|
|
12572
|
+
maxAttempts: 5,
|
|
12573
|
+
baseDelayMs: 100,
|
|
12574
|
+
backoffFactor: 1.5
|
|
12575
|
+
};
|
|
12576
|
+
async function retryWithExponentialBackoff(operation, options) {
|
|
12577
|
+
let attempt = 1;
|
|
12578
|
+
const _options = { ...BASE_OPTIONS, ...options };
|
|
12579
|
+
const { maxAttempts, baseDelayMs, backoffFactor } = _options;
|
|
12580
|
+
let delayMs = baseDelayMs;
|
|
12581
|
+
while (attempt <= maxAttempts) {
|
|
12582
|
+
try {
|
|
12583
|
+
const result = await operation();
|
|
12584
|
+
return result;
|
|
12585
|
+
} catch (error) {
|
|
12586
|
+
log$y.error(`Attempt ${attempt} failed: ${error}`);
|
|
12587
|
+
if (attempt < maxAttempts) {
|
|
12588
|
+
delayMs = baseDelayMs * Math.pow(backoffFactor, attempt);
|
|
12589
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
12590
|
+
attempt++;
|
|
12591
|
+
} else {
|
|
12592
|
+
throw error;
|
|
12593
|
+
}
|
|
12594
|
+
}
|
|
12595
|
+
}
|
|
12596
|
+
throw new Error("All attempts failed");
|
|
12597
|
+
}
|
|
12598
|
+
const log$x = KosLog.createLogger({ group: LogGroup.transport, name: "kos-service-request" });
|
|
12501
12599
|
const resolveServiceUrl = (_service) => {
|
|
12502
12600
|
const MOCK = false;
|
|
12503
12601
|
const URL2 = exports.BASE_URL;
|
|
@@ -12669,7 +12767,7 @@ const getOne$7 = (destinationAddress, url, _fetch) => async ({
|
|
|
12669
12767
|
destinationAddress: destinationAddressOverride
|
|
12670
12768
|
});
|
|
12671
12769
|
const resolvedUrl = urlOverride || url;
|
|
12672
|
-
log$
|
|
12770
|
+
log$x.debug(`resolvedUrl: ${resolvedUrl}`);
|
|
12673
12771
|
try {
|
|
12674
12772
|
const response = await _fetch(resolvedUrl, options);
|
|
12675
12773
|
if (!response.ok) {
|
|
@@ -12988,6 +13086,62 @@ const ServiceFactory = {
|
|
|
12988
13086
|
const _sessionKey = uuid();
|
|
12989
13087
|
const getKosSessionKey = () => `kos-${_sessionKey}`;
|
|
12990
13088
|
const isLocalRefId = (id) => !!id && !id.includes("VM_SERVICE") && id.startsWith(getKosSessionKey());
|
|
13089
|
+
const log$w = KosLog.createLogger({
|
|
13090
|
+
group: LogGroup.transport,
|
|
13091
|
+
name: "wait-for-request"
|
|
13092
|
+
});
|
|
13093
|
+
const waitForRequest = async (requestId, timeout = 6e4) => new Promise((resolve, reject) => {
|
|
13094
|
+
const { unsubscribe } = subscribe(requestId, (op) => {
|
|
13095
|
+
log$w.debug(`recieved response for refId ${requestId}: ${op}`);
|
|
13096
|
+
unsubscribe();
|
|
13097
|
+
clearTimeout(cancel);
|
|
13098
|
+
try {
|
|
13099
|
+
const body = op?.body ? JSON.parse(op.body) : {};
|
|
13100
|
+
resolve(body);
|
|
13101
|
+
} catch {
|
|
13102
|
+
const body = op?.body || {};
|
|
13103
|
+
resolve(body);
|
|
13104
|
+
}
|
|
13105
|
+
});
|
|
13106
|
+
const cancel = setTimeout(() => {
|
|
13107
|
+
unsubscribe();
|
|
13108
|
+
reject(Error(`Request with ID ${requestId} timed out. Cancelling.`));
|
|
13109
|
+
}, timeout);
|
|
13110
|
+
});
|
|
13111
|
+
const sendRequest = async (requestPromise, params2, refId) => {
|
|
13112
|
+
const op = waitForRequest(refId);
|
|
13113
|
+
const result = await Promise.allSettled([requestPromise(params2), op]);
|
|
13114
|
+
if (result[0].status === "fulfilled") {
|
|
13115
|
+
if (result[1].status === "rejected") {
|
|
13116
|
+
throw Error(result[1].reason);
|
|
13117
|
+
} else {
|
|
13118
|
+
if (result[0].value) {
|
|
13119
|
+
if (result[1].value.error) {
|
|
13120
|
+
throw Error(result[1].value.error);
|
|
13121
|
+
}
|
|
13122
|
+
result[0].value.data = result[1].value;
|
|
13123
|
+
return result[0].value;
|
|
13124
|
+
}
|
|
13125
|
+
}
|
|
13126
|
+
} else {
|
|
13127
|
+
throw Error(result[0].reason);
|
|
13128
|
+
}
|
|
13129
|
+
return void 0;
|
|
13130
|
+
};
|
|
13131
|
+
const syncPublish = async ({
|
|
13132
|
+
topic,
|
|
13133
|
+
msg,
|
|
13134
|
+
requestId
|
|
13135
|
+
}) => {
|
|
13136
|
+
const _requestId = requestId ?? uuid();
|
|
13137
|
+
const responsePromise = waitForRequest(_requestId);
|
|
13138
|
+
publish(topic, msg, { sync: _requestId });
|
|
13139
|
+
const response = await responsePromise;
|
|
13140
|
+
if (response.error) {
|
|
13141
|
+
throw Error(response.error);
|
|
13142
|
+
}
|
|
13143
|
+
return response;
|
|
13144
|
+
};
|
|
12991
13145
|
const contextMap = /* @__PURE__ */ new Map();
|
|
12992
13146
|
class KosContextBean {
|
|
12993
13147
|
_context;
|
|
@@ -13084,7 +13238,7 @@ const KosContextManager = {
|
|
|
13084
13238
|
};
|
|
13085
13239
|
KosContextManager.createContext("root");
|
|
13086
13240
|
const resolveKosContext = (model) => KosContextManager.getContext(model.id);
|
|
13087
|
-
const log$
|
|
13241
|
+
const log$v = KosLog.createLogger({ group: LogGroup.core, name: "kos-data-container" });
|
|
13088
13242
|
class KosDataContainer {
|
|
13089
13243
|
_data;
|
|
13090
13244
|
_sortKey;
|
|
@@ -13289,7 +13443,7 @@ class KosDataContainer {
|
|
|
13289
13443
|
const idx = this.index.get(indexName);
|
|
13290
13444
|
return idx.keys ?? [];
|
|
13291
13445
|
} else {
|
|
13292
|
-
log$
|
|
13446
|
+
log$v.info(
|
|
13293
13447
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13294
13448
|
);
|
|
13295
13449
|
return [];
|
|
@@ -13301,7 +13455,7 @@ class KosDataContainer {
|
|
|
13301
13455
|
if (idx.index.has(indexKey)) {
|
|
13302
13456
|
return idx.getByKey(indexKey);
|
|
13303
13457
|
} else {
|
|
13304
|
-
log$
|
|
13458
|
+
log$v.info(
|
|
13305
13459
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
13306
13460
|
idx.index.keys()
|
|
13307
13461
|
)}`
|
|
@@ -13309,7 +13463,7 @@ class KosDataContainer {
|
|
|
13309
13463
|
return [];
|
|
13310
13464
|
}
|
|
13311
13465
|
} else {
|
|
13312
|
-
log$
|
|
13466
|
+
log$v.info(
|
|
13313
13467
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13314
13468
|
);
|
|
13315
13469
|
return [];
|
|
@@ -13336,7 +13490,7 @@ class KosDataContainer {
|
|
|
13336
13490
|
* @private
|
|
13337
13491
|
*/
|
|
13338
13492
|
_logDataCapacityWarning(toEvict) {
|
|
13339
|
-
log$
|
|
13493
|
+
log$v.info(
|
|
13340
13494
|
`Data container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${toEvict} items using ${this._evictionStrategy} strategy. This may indicate missing cleanup handlers or data inconsistency.`
|
|
13341
13495
|
);
|
|
13342
13496
|
}
|
|
@@ -13396,7 +13550,7 @@ class KosDataContainer {
|
|
|
13396
13550
|
const candidates = this._customEvictionFilter(this.data);
|
|
13397
13551
|
return candidates.slice(0, count).map((item) => item.id);
|
|
13398
13552
|
}
|
|
13399
|
-
log$
|
|
13553
|
+
log$v.error(
|
|
13400
13554
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO."
|
|
13401
13555
|
);
|
|
13402
13556
|
return this._selectFifoData(count);
|
|
@@ -13408,7 +13562,7 @@ class KosDataContainer {
|
|
|
13408
13562
|
_removeEvictedData(ids) {
|
|
13409
13563
|
ids.forEach((id) => {
|
|
13410
13564
|
const item = this._data.get(id);
|
|
13411
|
-
log$
|
|
13565
|
+
log$v.info(`Evicting data item: ${id}`, {
|
|
13412
13566
|
itemId: id,
|
|
13413
13567
|
itemType: item ? item.constructor?.name : "unknown",
|
|
13414
13568
|
strategy: this._evictionStrategy
|
|
@@ -13421,7 +13575,7 @@ class KosDataContainer {
|
|
|
13421
13575
|
* @private
|
|
13422
13576
|
*/
|
|
13423
13577
|
_logDataEvictionComplete(evictedCount) {
|
|
13424
|
-
log$
|
|
13578
|
+
log$v.info(
|
|
13425
13579
|
`Evicted ${evictedCount} data items. Current size: ${this._data.size}/${this._maxCapacity}`
|
|
13426
13580
|
);
|
|
13427
13581
|
}
|
|
@@ -13593,14 +13747,14 @@ class BrowserKosRouter {
|
|
|
13593
13747
|
}, {});
|
|
13594
13748
|
}
|
|
13595
13749
|
}
|
|
13596
|
-
const log$
|
|
13750
|
+
const log$u = KosLog.createLogger({ group: LogGroup.core, name: "intent-service" });
|
|
13597
13751
|
const sendIntent = (intent) => {
|
|
13598
13752
|
if (hasEventSubscriptions(`/kos/intent/${intent.type}`)) {
|
|
13599
13753
|
publish(`/kos/intent/${intent.type}`, intent.options, {
|
|
13600
13754
|
"kos.intent.type": intent.type
|
|
13601
13755
|
});
|
|
13602
13756
|
} else {
|
|
13603
|
-
log$
|
|
13757
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13604
13758
|
}
|
|
13605
13759
|
};
|
|
13606
13760
|
const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
@@ -13630,11 +13784,11 @@ const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
|
13630
13784
|
sync: requestId
|
|
13631
13785
|
});
|
|
13632
13786
|
} else {
|
|
13633
|
-
log$
|
|
13787
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13634
13788
|
resolve([null, { body: void 0, payload: void 0 }]);
|
|
13635
13789
|
}
|
|
13636
13790
|
});
|
|
13637
|
-
const log$
|
|
13791
|
+
const log$t = KosLog.createLogger({ group: LogGroup.core, name: "app-startup-service" });
|
|
13638
13792
|
async function waitForAppsToStart(appIds, options = {}) {
|
|
13639
13793
|
const {
|
|
13640
13794
|
timeout = 3e4,
|
|
@@ -13642,10 +13796,10 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13642
13796
|
requirePostStarted = false
|
|
13643
13797
|
} = options;
|
|
13644
13798
|
if (appIds.length === 0) {
|
|
13645
|
-
log$
|
|
13799
|
+
log$t.warn("No app IDs provided to waitForAppsToStart");
|
|
13646
13800
|
return true;
|
|
13647
13801
|
}
|
|
13648
|
-
log$
|
|
13802
|
+
log$t.debug(`Waiting for apps to start: ${appIds.join(", ")}`);
|
|
13649
13803
|
try {
|
|
13650
13804
|
const eventTopics = appIds.map((appId) => `/kos/app/started/${appId}`);
|
|
13651
13805
|
const startedApps = await waitForAllWithState(eventTopics, {
|
|
@@ -13654,12 +13808,12 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13654
13808
|
const { default: api2 } = await Promise.resolve().then(() => service);
|
|
13655
13809
|
const [error, data] = await api2.get("/api/kos/apps/started");
|
|
13656
13810
|
if (error) {
|
|
13657
|
-
log$
|
|
13811
|
+
log$t.error("Error fetching started apps:", error);
|
|
13658
13812
|
return [];
|
|
13659
13813
|
}
|
|
13660
13814
|
return data;
|
|
13661
13815
|
} catch (error) {
|
|
13662
|
-
log$
|
|
13816
|
+
log$t.error("Failed to fetch app startup status:", error);
|
|
13663
13817
|
}
|
|
13664
13818
|
return [];
|
|
13665
13819
|
},
|
|
@@ -13681,17 +13835,17 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13681
13835
|
});
|
|
13682
13836
|
if (notStartedApps.length > 0) {
|
|
13683
13837
|
const message = `Apps not started: ${notStartedApps.join(", ")}`;
|
|
13684
|
-
log$
|
|
13838
|
+
log$t.error(message);
|
|
13685
13839
|
if (throwOnTimeout) {
|
|
13686
13840
|
throw new Error(`App startup timeout: ${message}`);
|
|
13687
13841
|
}
|
|
13688
13842
|
return false;
|
|
13689
13843
|
}
|
|
13690
|
-
log$
|
|
13844
|
+
log$t.info(`All apps started successfully: ${appIds.join(", ")}`);
|
|
13691
13845
|
return true;
|
|
13692
13846
|
} catch (error) {
|
|
13693
13847
|
const message = `Failed to wait for apps to start: ${appIds.join(", ")}`;
|
|
13694
|
-
log$
|
|
13848
|
+
log$t.error(message, error);
|
|
13695
13849
|
if (throwOnTimeout) {
|
|
13696
13850
|
throw new Error(
|
|
13697
13851
|
`${message} - ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -13718,7 +13872,7 @@ async function checkAppsStarted(appIds, requirePostStarted = false) {
|
|
|
13718
13872
|
result[appId] = app?.started === true && (!requirePostStarted || app?.postStarted === true);
|
|
13719
13873
|
});
|
|
13720
13874
|
} catch (error) {
|
|
13721
|
-
log$
|
|
13875
|
+
log$t.error("Failed to check app startup status:", error);
|
|
13722
13876
|
appIds.forEach((appId) => result[appId] = false);
|
|
13723
13877
|
}
|
|
13724
13878
|
return result;
|
|
@@ -13732,7 +13886,7 @@ async function getStartedApps() {
|
|
|
13732
13886
|
const result = await response.json();
|
|
13733
13887
|
return result?.data ?? [];
|
|
13734
13888
|
} catch (error) {
|
|
13735
|
-
log$
|
|
13889
|
+
log$t.error("Failed to fetch started apps:", error);
|
|
13736
13890
|
return [];
|
|
13737
13891
|
}
|
|
13738
13892
|
}
|
|
@@ -13759,10 +13913,7 @@ var Topics = /* @__PURE__ */ ((Topics2) => {
|
|
|
13759
13913
|
Topics2["TIMEZONE_CHANGE"] = "/kos/internal/time/timezone";
|
|
13760
13914
|
return Topics2;
|
|
13761
13915
|
})(Topics || {});
|
|
13762
|
-
const log$
|
|
13763
|
-
name: "config-bean-service",
|
|
13764
|
-
group: "Services"
|
|
13765
|
-
});
|
|
13916
|
+
const log$s = KosLog.createLogger({ group: LogGroup.service, name: "config-bean-service" });
|
|
13766
13917
|
const URL$e = exports.BASE_URL;
|
|
13767
13918
|
const hasDecimals = (option) => option?.decimals !== void 0;
|
|
13768
13919
|
const { postModel: postModel$5, getOne: getOne$6 } = ServiceFactory.build({
|
|
@@ -13770,7 +13921,7 @@ const { postModel: postModel$5, getOne: getOne$6 } = ServiceFactory.build({
|
|
|
13770
13921
|
basePath: `${URL$e}/kos/config/`
|
|
13771
13922
|
});
|
|
13772
13923
|
const modifyConfigBean = async (id, model, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13773
|
-
log$
|
|
13924
|
+
log$s.debug(`sending modify request for ConfigBean: ${id}`);
|
|
13774
13925
|
const response = postModel$5({
|
|
13775
13926
|
model,
|
|
13776
13927
|
urlOverride: `${URL$e}${path}/${id}`,
|
|
@@ -13779,7 +13930,7 @@ const modifyConfigBean = async (id, model, path = `/api/kos/config`, destination
|
|
|
13779
13930
|
return response;
|
|
13780
13931
|
};
|
|
13781
13932
|
const getConfigBean = async (id, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13782
|
-
log$
|
|
13933
|
+
log$s.debug(`sending get request for ConfigBean: ${id}`);
|
|
13783
13934
|
const response = await getOne$6({
|
|
13784
13935
|
urlOverride: `${URL$e}${path}/details/${id}/15`,
|
|
13785
13936
|
destinationAddress
|
|
@@ -13892,7 +14043,10 @@ function matchValue(patterns, value) {
|
|
|
13892
14043
|
return void 0;
|
|
13893
14044
|
}
|
|
13894
14045
|
const CONFIG_BEAN_MODEL_TYPE = "config-bean-model";
|
|
13895
|
-
const log$
|
|
14046
|
+
const log$r = KosLog.createLogger({
|
|
14047
|
+
group: LogGroup.model,
|
|
14048
|
+
name: CONFIG_BEAN_MODEL_TYPE
|
|
14049
|
+
});
|
|
13896
14050
|
const PATH_PROP$3 = createPropKey("path");
|
|
13897
14051
|
const DESTINATION_PROP$2 = createPropKey("destinationAddress");
|
|
13898
14052
|
function configBeanModelId(path, destinationAddress) {
|
|
@@ -13965,8 +14119,8 @@ let ConfigBeanModelImpl = class {
|
|
|
13965
14119
|
* @internal
|
|
13966
14120
|
*/
|
|
13967
14121
|
async ready() {
|
|
13968
|
-
log$
|
|
13969
|
-
log$
|
|
14122
|
+
log$r.debug(`readying config bean ${this.path}`);
|
|
14123
|
+
log$r.debug(`complete readying config bean ${this.path}`);
|
|
13970
14124
|
}
|
|
13971
14125
|
/**
|
|
13972
14126
|
* @internal
|
|
@@ -13975,7 +14129,7 @@ let ConfigBeanModelImpl = class {
|
|
|
13975
14129
|
* Fetches the bean's values and schema.
|
|
13976
14130
|
*/
|
|
13977
14131
|
async load() {
|
|
13978
|
-
log$
|
|
14132
|
+
log$r.debug(`loading config bean ${this.path}`);
|
|
13979
14133
|
await this.fetchBean();
|
|
13980
14134
|
}
|
|
13981
14135
|
/**
|
|
@@ -13986,7 +14140,7 @@ let ConfigBeanModelImpl = class {
|
|
|
13986
14140
|
* KOS Core reload after a reconnect leaves the same instance current.
|
|
13987
14141
|
*/
|
|
13988
14142
|
async reload() {
|
|
13989
|
-
log$
|
|
14143
|
+
log$r.debug(`reloading config bean ${this.path}`);
|
|
13990
14144
|
await this.fetchBean();
|
|
13991
14145
|
}
|
|
13992
14146
|
async fetchBean() {
|
|
@@ -13998,7 +14152,7 @@ let ConfigBeanModelImpl = class {
|
|
|
13998
14152
|
if (response?.data) {
|
|
13999
14153
|
const data = response.data;
|
|
14000
14154
|
mapDtoToConfigBeanModel(data, this);
|
|
14001
|
-
log$
|
|
14155
|
+
log$r.debug(this.values);
|
|
14002
14156
|
const schemaResponse = response?.data.details[0].schema;
|
|
14003
14157
|
kosAction(() => {
|
|
14004
14158
|
if (schemaResponse) {
|
|
@@ -14243,7 +14397,7 @@ var __decorateClass$u = (decorators, target, key, kind) => {
|
|
|
14243
14397
|
return result;
|
|
14244
14398
|
};
|
|
14245
14399
|
const MODEL_TYPE$r = "region-info-model";
|
|
14246
|
-
const log$
|
|
14400
|
+
const log$q = KosLog.createLogger({ group: LogGroup.model, name: "region-info-model" });
|
|
14247
14401
|
function servicePathMapper(regionInfoModel) {
|
|
14248
14402
|
const hasMapper = ExtensionManager.propertyMapper.hasMapper(
|
|
14249
14403
|
KosCoreModelPropertyMapper.RegionServicePath
|
|
@@ -14556,7 +14710,7 @@ let RegionInfoModelImpl = class {
|
|
|
14556
14710
|
}
|
|
14557
14711
|
toUnit = measureSystems[to.system]?.["default"];
|
|
14558
14712
|
if (!toUnit) {
|
|
14559
|
-
log$
|
|
14713
|
+
log$q.info("Could not find default unit for measure", to.measure);
|
|
14560
14714
|
}
|
|
14561
14715
|
}
|
|
14562
14716
|
if (!fromUnit && from.measure && from.system) {
|
|
@@ -14570,11 +14724,11 @@ let RegionInfoModelImpl = class {
|
|
|
14570
14724
|
}
|
|
14571
14725
|
fromUnit = measureSystems[from.system]?.["default"];
|
|
14572
14726
|
if (!fromUnit) {
|
|
14573
|
-
log$
|
|
14727
|
+
log$q.info("Could not find default unit for measure", from.measure);
|
|
14574
14728
|
}
|
|
14575
14729
|
}
|
|
14576
14730
|
if (!fromUnit || !toUnit) {
|
|
14577
|
-
log$
|
|
14731
|
+
log$q.warn("Could not find unit to convert to or from. Return value as is");
|
|
14578
14732
|
return String(value);
|
|
14579
14733
|
}
|
|
14580
14734
|
return this.convertByUnit(value, fromUnit, toUnit);
|
|
@@ -14584,13 +14738,13 @@ let RegionInfoModelImpl = class {
|
|
|
14584
14738
|
* @internal
|
|
14585
14739
|
*/
|
|
14586
14740
|
async init() {
|
|
14587
|
-
log$
|
|
14741
|
+
log$q.debug("initializing region info");
|
|
14588
14742
|
}
|
|
14589
14743
|
/**
|
|
14590
14744
|
* @internal
|
|
14591
14745
|
*/
|
|
14592
14746
|
async load() {
|
|
14593
|
-
log$
|
|
14747
|
+
log$q.debug("loading region info");
|
|
14594
14748
|
const regions = await getRegions(
|
|
14595
14749
|
this.serviceBasePath,
|
|
14596
14750
|
this.destinationAddress
|
|
@@ -14927,7 +15081,7 @@ function secondsToFormattedTime(secondsSinceMidnight, formatString) {
|
|
|
14927
15081
|
return dateFns.format(time, formatString);
|
|
14928
15082
|
}
|
|
14929
15083
|
const MODEL_TYPE$q = "config-bean-prop-model";
|
|
14930
|
-
const log$
|
|
15084
|
+
const log$p = KosLog.createLogger({ group: LogGroup.model, name: "config-bean-prop-model" });
|
|
14931
15085
|
const PATH_PROP$2 = createPropKey("path");
|
|
14932
15086
|
const SERVICE_PATH_PROP = createPropKey("serviceBasePath");
|
|
14933
15087
|
const DESTINATION_PROP = createPropKey("destinationAddress");
|
|
@@ -15114,7 +15268,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15114
15268
|
return Number(result2);
|
|
15115
15269
|
}
|
|
15116
15270
|
} catch (e) {
|
|
15117
|
-
log$
|
|
15271
|
+
log$p.info(`error formatting value ${_val}`, e);
|
|
15118
15272
|
}
|
|
15119
15273
|
const result = Number(_val).toFixed(decimals);
|
|
15120
15274
|
return result;
|
|
@@ -15146,7 +15300,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15146
15300
|
* @internal
|
|
15147
15301
|
*/
|
|
15148
15302
|
async activate() {
|
|
15149
|
-
log$
|
|
15303
|
+
log$p.debug(`activating config bean ${this.id}`);
|
|
15150
15304
|
}
|
|
15151
15305
|
/**
|
|
15152
15306
|
* The value formatted with its unit for the active locale, such as `"72.5 °F"`.
|
|
@@ -15173,7 +15327,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15173
15327
|
return result;
|
|
15174
15328
|
}
|
|
15175
15329
|
} catch (e) {
|
|
15176
|
-
log$
|
|
15330
|
+
log$p.error(`error formatting value ${_val}`, e);
|
|
15177
15331
|
}
|
|
15178
15332
|
}
|
|
15179
15333
|
return String(_val);
|
|
@@ -15265,13 +15419,13 @@ let KosConfigPropertyImpl = class {
|
|
|
15265
15419
|
try {
|
|
15266
15420
|
formatter = new Intl.NumberFormat(locale, { ...formatOptions });
|
|
15267
15421
|
} catch (e) {
|
|
15268
|
-
log$
|
|
15422
|
+
log$p.error(
|
|
15269
15423
|
`error creating formatter ${formatOptions}. Returning the raw value`,
|
|
15270
15424
|
e
|
|
15271
15425
|
);
|
|
15272
15426
|
}
|
|
15273
15427
|
} else {
|
|
15274
|
-
log$
|
|
15428
|
+
log$p.debug(
|
|
15275
15429
|
`no formatter found for config bean prop ${this.id}. Returning the raw value`
|
|
15276
15430
|
);
|
|
15277
15431
|
}
|
|
@@ -15332,7 +15486,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15332
15486
|
* @param value - The new value in display units
|
|
15333
15487
|
*/
|
|
15334
15488
|
async updateProperty(value) {
|
|
15335
|
-
log$
|
|
15489
|
+
log$p.debug(`updating property ${this.attribute} with value ${value}`);
|
|
15336
15490
|
let _value = value;
|
|
15337
15491
|
const converter = this.getConverter();
|
|
15338
15492
|
if (converter && !isNaN(_value)) {
|
|
@@ -15376,6 +15530,10 @@ const Registration = {
|
|
|
15376
15530
|
MODEL_TYPE$q
|
|
15377
15531
|
)
|
|
15378
15532
|
};
|
|
15533
|
+
const log$o = KosLog.createLogger({
|
|
15534
|
+
group: LogGroup.model,
|
|
15535
|
+
name: "future-model-builder"
|
|
15536
|
+
});
|
|
15379
15537
|
const mapDtoToFutureOptions = (dto) => {
|
|
15380
15538
|
const options = {
|
|
15381
15539
|
id: String(dto.id),
|
|
@@ -15391,10 +15549,10 @@ const mapDtoToFutureOptions = (dto) => {
|
|
|
15391
15549
|
return options;
|
|
15392
15550
|
};
|
|
15393
15551
|
const mapDtoToFutureModel = (dto, model) => {
|
|
15394
|
-
|
|
15395
|
-
|
|
15552
|
+
log$o.debug(`future dto ${dto.id} end state ${dto.endState}`);
|
|
15553
|
+
log$o.debug(`future model ${model.id} end state ${model.endState}`);
|
|
15396
15554
|
if (!model.endState) {
|
|
15397
|
-
|
|
15555
|
+
log$o.debug(`updating future model ${model.id}`);
|
|
15398
15556
|
mobx.runInAction(() => {
|
|
15399
15557
|
const options = mapDtoToFutureOptions(dto);
|
|
15400
15558
|
kosAction(() => {
|
|
@@ -15413,7 +15571,7 @@ const mapDtoToFutureModel = (dto, model) => {
|
|
|
15413
15571
|
});
|
|
15414
15572
|
});
|
|
15415
15573
|
} else {
|
|
15416
|
-
|
|
15574
|
+
log$o.debug(`future model ${model.id} is already complete`);
|
|
15417
15575
|
}
|
|
15418
15576
|
};
|
|
15419
15577
|
const buildFutureModel$1 = (factory) => (modelId) => (futureOptions) => {
|
|
@@ -15424,7 +15582,7 @@ const buildFuture = (factory) => (future) => pipe(
|
|
|
15424
15582
|
mapDtoToFutureOptions,
|
|
15425
15583
|
buildFutureModel$1(factory)(future.tracker || future.id)
|
|
15426
15584
|
)(future);
|
|
15427
|
-
const log$
|
|
15585
|
+
const log$n = KosLog.createLogger({ group: LogGroup.service, name: "future-service" });
|
|
15428
15586
|
const { isMock, URL: URL$c } = resolveServiceUrl();
|
|
15429
15587
|
var FutureEndState = /* @__PURE__ */ ((FutureEndState2) => {
|
|
15430
15588
|
FutureEndState2["Success"] = "SUCCESS";
|
|
@@ -15443,7 +15601,7 @@ const getFutures = async () => {
|
|
|
15443
15601
|
return response;
|
|
15444
15602
|
};
|
|
15445
15603
|
const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
15446
|
-
log$
|
|
15604
|
+
log$n.info(`sending delete request for Future: ${id}`);
|
|
15447
15605
|
const response = await deleteModel$1({
|
|
15448
15606
|
id,
|
|
15449
15607
|
urlOverride: `${URL$c}${path}/${id}`
|
|
@@ -15451,7 +15609,7 @@ const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
|
15451
15609
|
return response;
|
|
15452
15610
|
};
|
|
15453
15611
|
const addFuture = async (future, path = "/api/kos/future") => {
|
|
15454
|
-
log$
|
|
15612
|
+
log$n.info(`sending add request for Future`);
|
|
15455
15613
|
const response = await addModel({
|
|
15456
15614
|
model: future,
|
|
15457
15615
|
urlOverride: `${URL$c}${path}`
|
|
@@ -15459,7 +15617,7 @@ const addFuture = async (future, path = "/api/kos/future") => {
|
|
|
15459
15617
|
return response;
|
|
15460
15618
|
};
|
|
15461
15619
|
const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
15462
|
-
log$
|
|
15620
|
+
log$n.info(`sending modify request for Future: ${id}`);
|
|
15463
15621
|
const response = modifyModel({
|
|
15464
15622
|
model,
|
|
15465
15623
|
id,
|
|
@@ -15468,7 +15626,7 @@ const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
|
15468
15626
|
return response;
|
|
15469
15627
|
};
|
|
15470
15628
|
const cancelFuture = async (id, path = "/api/kos/future") => {
|
|
15471
|
-
log$
|
|
15629
|
+
log$n.info(`sending cancel request for Future: ${id}`);
|
|
15472
15630
|
const response = postModel$4({
|
|
15473
15631
|
urlOverride: `${URL$c}${path}/${id}/cancel`,
|
|
15474
15632
|
ordered: true,
|
|
@@ -15508,6 +15666,10 @@ const FutureManager = {
|
|
|
15508
15666
|
initiateFuture,
|
|
15509
15667
|
getFuture
|
|
15510
15668
|
};
|
|
15669
|
+
const log$m = KosLog.createLogger({
|
|
15670
|
+
group: LogGroup.model,
|
|
15671
|
+
name: "future-service"
|
|
15672
|
+
});
|
|
15511
15673
|
const isFutureResponse = (response) => !response || !response.data;
|
|
15512
15674
|
const resolveFutureHandler = (model) => {
|
|
15513
15675
|
const handlerProperty = model?.[MultipleFutureContainerSetup]?.handlerProperty ?? model?.[FutureContainerSetup]?.handlerProperty ?? "futureHandler";
|
|
@@ -15522,9 +15684,7 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15522
15684
|
} = props;
|
|
15523
15685
|
return async function(...args) {
|
|
15524
15686
|
const tracker = uuid();
|
|
15525
|
-
|
|
15526
|
-
`Calling future service ${methodName} with tracker ${tracker}`
|
|
15527
|
-
);
|
|
15687
|
+
log$m.debug(`Calling future service ${methodName} with tracker ${tracker}`);
|
|
15528
15688
|
let abortControllerInstance;
|
|
15529
15689
|
let effectDisposer;
|
|
15530
15690
|
if (abortController) {
|
|
@@ -15537,17 +15697,17 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15537
15697
|
if (namespace) {
|
|
15538
15698
|
future.namespace = namespace;
|
|
15539
15699
|
}
|
|
15540
|
-
|
|
15700
|
+
log$m.debug(`waiting for future ${future.id} to be ready`);
|
|
15541
15701
|
await whenReady(future);
|
|
15542
|
-
|
|
15702
|
+
log$m.debug(`future ${future.id} is ready`);
|
|
15543
15703
|
kosAction(() => {
|
|
15544
|
-
|
|
15704
|
+
log$m.debug(`Adding future ${future.id} to futureHandler`);
|
|
15545
15705
|
resolveFutureHandler(this).addFuture(future, alias);
|
|
15546
15706
|
});
|
|
15547
15707
|
if (abortController && abortControllerInstance) {
|
|
15548
15708
|
effectDisposer = kosAutoEffect(() => {
|
|
15549
15709
|
if (future.status === "CANCELLED" || future.endState === FutureEndState.Canceled) {
|
|
15550
|
-
|
|
15710
|
+
log$m.debug(`Future ${future.id} cancelled, aborting request`);
|
|
15551
15711
|
abortControllerInstance?.abort();
|
|
15552
15712
|
}
|
|
15553
15713
|
});
|
|
@@ -15555,13 +15715,13 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15555
15715
|
"abort",
|
|
15556
15716
|
async () => {
|
|
15557
15717
|
if (future.status !== "CANCELLED" && future.endState !== FutureEndState.Canceled && !future.endState) {
|
|
15558
|
-
|
|
15718
|
+
log$m.debug(
|
|
15559
15719
|
`AbortController aborted, cancelling future ${future.id}`
|
|
15560
15720
|
);
|
|
15561
15721
|
try {
|
|
15562
15722
|
await future.cancelFuture();
|
|
15563
15723
|
} catch (error) {
|
|
15564
|
-
|
|
15724
|
+
log$m.error(`Failed to cancel future ${future.id}:`, error);
|
|
15565
15725
|
}
|
|
15566
15726
|
}
|
|
15567
15727
|
},
|
|
@@ -15602,15 +15762,15 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15602
15762
|
// eslint-disable-next-line no-invalid-this
|
|
15603
15763
|
await original.apply(this, enhancedArgs)
|
|
15604
15764
|
);
|
|
15605
|
-
|
|
15765
|
+
log$m.debug(`received future response for ${tracker}`, futureResponse);
|
|
15606
15766
|
const response = isFutureResponse(futureResponse) ? futureResponse : futureResponse?.data;
|
|
15607
15767
|
if (response) {
|
|
15608
15768
|
response.progress = 1;
|
|
15609
|
-
|
|
15769
|
+
log$m.debug(`mapping future response to future model`);
|
|
15610
15770
|
if (!future.endState) {
|
|
15611
15771
|
mapDtoToFutureModel(response, future);
|
|
15612
15772
|
} else {
|
|
15613
|
-
|
|
15773
|
+
log$m.debug(
|
|
15614
15774
|
`future ${future.id} has already completed. Not updating the model`
|
|
15615
15775
|
);
|
|
15616
15776
|
}
|
|
@@ -15623,10 +15783,10 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15623
15783
|
cleanup();
|
|
15624
15784
|
if (abortController && abortControllerInstance?.signal.aborted) {
|
|
15625
15785
|
const cancelledError = new Error("Operation cancelled");
|
|
15626
|
-
|
|
15786
|
+
log$m.debug(`Operation ${methodName} was cancelled`);
|
|
15627
15787
|
throw cancelledError;
|
|
15628
15788
|
}
|
|
15629
|
-
|
|
15789
|
+
log$m.error(e);
|
|
15630
15790
|
throw e;
|
|
15631
15791
|
}
|
|
15632
15792
|
};
|
|
@@ -15655,12 +15815,9 @@ const { URL: URL$b } = resolveServiceUrl();
|
|
|
15655
15815
|
const { getOne: getOne$4 } = ServiceFactory.build({
|
|
15656
15816
|
basePath: `${URL$b}/api/kos/state`
|
|
15657
15817
|
});
|
|
15658
|
-
const log$
|
|
15659
|
-
name: "state-bean-service",
|
|
15660
|
-
group: "Services"
|
|
15661
|
-
});
|
|
15818
|
+
const log$l = KosLog.createLogger({ group: LogGroup.service, name: "state-bean-service" });
|
|
15662
15819
|
const getStateBeanData = async ({ path }) => {
|
|
15663
|
-
log$
|
|
15820
|
+
log$l.debug("sending GET for state-bean");
|
|
15664
15821
|
const response = await getOne$4({
|
|
15665
15822
|
urlOverride: `${URL$b}/api/kos/state/${path}`
|
|
15666
15823
|
});
|
|
@@ -15838,12 +15995,9 @@ const { URL: URL$a } = resolveServiceUrl();
|
|
|
15838
15995
|
const { getAll: getAll$5 } = ServiceFactory.build({
|
|
15839
15996
|
basePath: `${URL$a}/api/state-prop`
|
|
15840
15997
|
});
|
|
15841
|
-
const log$
|
|
15842
|
-
name: "state-prop-service",
|
|
15843
|
-
group: "Services"
|
|
15844
|
-
});
|
|
15998
|
+
const log$k = KosLog.createLogger({ group: LogGroup.service, name: "state-prop-service" });
|
|
15845
15999
|
const getStateProps = async () => {
|
|
15846
|
-
log$
|
|
16000
|
+
log$k.debug("sending GET for state-prop");
|
|
15847
16001
|
const response = await getAll$5({});
|
|
15848
16002
|
return response;
|
|
15849
16003
|
};
|
|
@@ -15985,7 +16139,7 @@ var __decorateClass$p = (decorators, target, key, kind) => {
|
|
|
15985
16139
|
if (kind && result) __defProp$l(target, key, result);
|
|
15986
16140
|
return result;
|
|
15987
16141
|
};
|
|
15988
|
-
const log$
|
|
16142
|
+
const log$j = KosLog.createLogger({ group: LogGroup.model, name: FutureFactory.type });
|
|
15989
16143
|
let FutureModel$1 = class FutureModel {
|
|
15990
16144
|
logger;
|
|
15991
16145
|
_cancelFuture;
|
|
@@ -16009,7 +16163,7 @@ let FutureModel$1 = class FutureModel {
|
|
|
16009
16163
|
kosWhen(
|
|
16010
16164
|
() => this.status === FutureEndState.Success || this.status === FutureEndState.Fail,
|
|
16011
16165
|
() => {
|
|
16012
|
-
log$
|
|
16166
|
+
log$j.info(`Future ${this.id} has completed with status ${this.status}`);
|
|
16013
16167
|
destroyKosModel(this);
|
|
16014
16168
|
}
|
|
16015
16169
|
);
|
|
@@ -16023,13 +16177,13 @@ let FutureModel$1 = class FutureModel {
|
|
|
16023
16177
|
* In future additional information about the workspace could be loaded
|
|
16024
16178
|
*/
|
|
16025
16179
|
async load() {
|
|
16026
|
-
log$
|
|
16180
|
+
log$j.debug(`loading Future ${this.id}`);
|
|
16027
16181
|
}
|
|
16028
16182
|
/**
|
|
16029
16183
|
* @internal
|
|
16030
16184
|
*/
|
|
16031
16185
|
unload() {
|
|
16032
|
-
log$
|
|
16186
|
+
log$j.info(`unloading Future ${this.id}`);
|
|
16033
16187
|
}
|
|
16034
16188
|
// -------------------ACTIONS----------------------------
|
|
16035
16189
|
/**
|
|
@@ -16048,7 +16202,7 @@ let FutureModel$1 = class FutureModel {
|
|
|
16048
16202
|
await kosWhen(() => this.futureId !== FUTURE_NOT_ASSIGNED);
|
|
16049
16203
|
const response = await this._cancelFuture(this.futureId, path);
|
|
16050
16204
|
if (response?.status !== 200) {
|
|
16051
|
-
log$
|
|
16205
|
+
log$j.error(
|
|
16052
16206
|
`Failed to cancel Future ${this.id}. Response: ${JSON.stringify(
|
|
16053
16207
|
response
|
|
16054
16208
|
)}`
|
|
@@ -16117,7 +16271,7 @@ var __decorateClass$o = (decorators, target, key, kind) => {
|
|
|
16117
16271
|
if (kind && result) __defProp$k(target, key, result);
|
|
16118
16272
|
return result;
|
|
16119
16273
|
};
|
|
16120
|
-
const log$
|
|
16274
|
+
const log$i = KosLog.createLogger({ group: LogGroup.model, name: FutureContainerFactory.type });
|
|
16121
16275
|
let FutureContainerModel$1 = class FutureContainerModel {
|
|
16122
16276
|
id;
|
|
16123
16277
|
logger;
|
|
@@ -16232,8 +16386,8 @@ let FutureContainerModel$1 = class FutureContainerModel {
|
|
|
16232
16386
|
try {
|
|
16233
16387
|
await this._deleteFuture(id);
|
|
16234
16388
|
} catch (e) {
|
|
16235
|
-
log$
|
|
16236
|
-
log$
|
|
16389
|
+
log$i.error(`error deleting a Future`);
|
|
16390
|
+
log$i.error(e);
|
|
16237
16391
|
}
|
|
16238
16392
|
}
|
|
16239
16393
|
/**
|
|
@@ -16260,8 +16414,8 @@ let FutureContainerModel$1 = class FutureContainerModel {
|
|
|
16260
16414
|
return model2;
|
|
16261
16415
|
}
|
|
16262
16416
|
} catch (e) {
|
|
16263
|
-
log$
|
|
16264
|
-
log$
|
|
16417
|
+
log$i.error(`error creating a Future`);
|
|
16418
|
+
log$i.error(e);
|
|
16265
16419
|
throw e;
|
|
16266
16420
|
}
|
|
16267
16421
|
return void 0;
|
|
@@ -16290,10 +16444,7 @@ const { URL: URL$9 } = resolveServiceUrl();
|
|
|
16290
16444
|
const { getOne: getOne$3, postModel: postModel$3, deleteModel } = ServiceFactory.build({
|
|
16291
16445
|
basePath: `${URL$9}/api/keyVal`
|
|
16292
16446
|
});
|
|
16293
|
-
const log$
|
|
16294
|
-
name: "key-value-service",
|
|
16295
|
-
group: "Services"
|
|
16296
|
-
});
|
|
16447
|
+
const log$h = KosLog.createLogger({ group: LogGroup.service, name: "key-value-service" });
|
|
16297
16448
|
const deleteKeyValue = async (namespace, key) => {
|
|
16298
16449
|
await deleteModel({
|
|
16299
16450
|
urlOverride: `${URL$9}/api/keyVal/${namespace}/${key}`,
|
|
@@ -16306,7 +16457,7 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16306
16457
|
model: value.toString()
|
|
16307
16458
|
});
|
|
16308
16459
|
if (response?.status !== 200) {
|
|
16309
|
-
log$
|
|
16460
|
+
log$h.error("Failed to update key-value data", response);
|
|
16310
16461
|
throw new Error(
|
|
16311
16462
|
`Failed to update key-value data for namespace ${namespace}`
|
|
16312
16463
|
);
|
|
@@ -16314,12 +16465,12 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16314
16465
|
return response.data;
|
|
16315
16466
|
};
|
|
16316
16467
|
const getKeyValue = async (namespace = "studio") => {
|
|
16317
|
-
log$
|
|
16468
|
+
log$h.debug(`Retrieving all key-value data for namespace: ${namespace}`);
|
|
16318
16469
|
const response = await getOne$3({
|
|
16319
16470
|
urlOverride: `${URL$9}/api/keyVal/${namespace}`
|
|
16320
16471
|
});
|
|
16321
16472
|
if (response?.status !== 200) {
|
|
16322
|
-
log$
|
|
16473
|
+
log$h.error("Failed to retrieve key-value data", response);
|
|
16323
16474
|
throw new Error(
|
|
16324
16475
|
`Failed to retrieve key-value data for namespace ${namespace}`
|
|
16325
16476
|
);
|
|
@@ -18395,14 +18546,43 @@ KosExpressionEvaluatorModelImpl = __decorateClass$m([
|
|
|
18395
18546
|
kosModel({ modelTypeId: MODEL_TYPE$l, singleton: false })
|
|
18396
18547
|
], KosExpressionEvaluatorModelImpl);
|
|
18397
18548
|
const KosExpressionEvaluator = KosExpressionEvaluatorModelImpl.Registration;
|
|
18398
|
-
const log$
|
|
18399
|
-
|
|
18400
|
-
|
|
18549
|
+
const log$g = KosLog.createLogger({
|
|
18550
|
+
group: LogGroup.transport,
|
|
18551
|
+
name: "get-kos-connection-id"
|
|
18401
18552
|
});
|
|
18553
|
+
const getKosConnectionId = () => {
|
|
18554
|
+
const params2 = getQueryParams();
|
|
18555
|
+
const connId = params2?.connId;
|
|
18556
|
+
const result = connId || window?.kosBridge?.("connId");
|
|
18557
|
+
log$g.debug(`getKosConnectionId: ${result}`);
|
|
18558
|
+
return result;
|
|
18559
|
+
};
|
|
18560
|
+
const log$f = KosLog.createLogger({ group: LogGroup.service, name: "kos-log-manager-service" });
|
|
18402
18561
|
const SERVICE_PATH$1 = "/api/kos/logs/overrides";
|
|
18562
|
+
const GROUPS_PATH = "/api/kos/logs/groups";
|
|
18403
18563
|
const getLogOverrides = async () => {
|
|
18404
|
-
log$
|
|
18405
|
-
return await api$1.get(SERVICE_PATH$1
|
|
18564
|
+
log$f.debug("sending GET for kos-log-manager");
|
|
18565
|
+
return await api$1.get(SERVICE_PATH$1, void 0, {
|
|
18566
|
+
destinationAddress: getKosConnectionId()
|
|
18567
|
+
});
|
|
18568
|
+
};
|
|
18569
|
+
const getLogGroups = async () => {
|
|
18570
|
+
log$f.debug("sending GET for log groups");
|
|
18571
|
+
return await api$1.get(GROUPS_PATH, void 0, {
|
|
18572
|
+
destinationAddress: getKosConnectionId()
|
|
18573
|
+
});
|
|
18574
|
+
};
|
|
18575
|
+
const addLogOverride = async (override) => {
|
|
18576
|
+
log$f.debug(`sending POST for log override ${override.name}`);
|
|
18577
|
+
return await api$1.post(SERVICE_PATH$1, void 0, override, {
|
|
18578
|
+
destinationAddress: getKosConnectionId()
|
|
18579
|
+
});
|
|
18580
|
+
};
|
|
18581
|
+
const removeLogOverride = async (override) => {
|
|
18582
|
+
log$f.debug(`sending DELETE for log override ${override.name}`);
|
|
18583
|
+
return await api$1.delete(SERVICE_PATH$1, void 0, override, {
|
|
18584
|
+
destinationAddress: getKosConnectionId()
|
|
18585
|
+
});
|
|
18406
18586
|
};
|
|
18407
18587
|
var __defProp$h = Object.defineProperty;
|
|
18408
18588
|
var __getOwnPropDesc$l = Object.getOwnPropertyDescriptor;
|
|
@@ -18439,17 +18619,139 @@ const getLogLevelName = (level2) => {
|
|
|
18439
18619
|
}
|
|
18440
18620
|
return "info";
|
|
18441
18621
|
};
|
|
18622
|
+
const toDeviceOverride = (data) => {
|
|
18623
|
+
const nodeType = data.nodeType ?? "";
|
|
18624
|
+
const type = data.type ?? "";
|
|
18625
|
+
const name = data.name ?? "";
|
|
18626
|
+
return {
|
|
18627
|
+
id: `${nodeType}:${type}:${name}`,
|
|
18628
|
+
nodeType,
|
|
18629
|
+
type,
|
|
18630
|
+
name,
|
|
18631
|
+
level: data.level ?? "INFO"
|
|
18632
|
+
};
|
|
18633
|
+
};
|
|
18634
|
+
const isUiOverride = (override) => override.type === UI_GROUP_OVERRIDE || override.type === UI_LOGGER_OVERRIDE;
|
|
18635
|
+
const toUiLevel = (level2) => {
|
|
18636
|
+
const name = level2.toLowerCase();
|
|
18637
|
+
return name === "fatal" ? "error" : name;
|
|
18638
|
+
};
|
|
18639
|
+
const toUiOverride = (override) => {
|
|
18640
|
+
return {
|
|
18641
|
+
name: override.name ?? "",
|
|
18642
|
+
type: override.type ?? "",
|
|
18643
|
+
level: toUiLevel(override.level ?? "INFO"),
|
|
18644
|
+
id: `${override.type ?? ""}:${override.name ?? ""}`
|
|
18645
|
+
};
|
|
18646
|
+
};
|
|
18442
18647
|
let KosLogManagerModelImpl = class {
|
|
18443
18648
|
id;
|
|
18444
18649
|
logger;
|
|
18445
18650
|
_overrides;
|
|
18651
|
+
_deviceOverrides;
|
|
18652
|
+
_overriddenLoggers;
|
|
18653
|
+
groups;
|
|
18446
18654
|
constructor(modelId, options, context) {
|
|
18447
18655
|
this.id = modelId;
|
|
18448
18656
|
this.logger = context.logger;
|
|
18449
18657
|
this._overrides = new KosDataContainer();
|
|
18658
|
+
this._deviceOverrides = new KosDataContainer();
|
|
18659
|
+
this._overriddenLoggers = /* @__PURE__ */ new Set();
|
|
18660
|
+
this.groups = [];
|
|
18450
18661
|
}
|
|
18451
18662
|
updateModel(_options) {
|
|
18452
18663
|
}
|
|
18664
|
+
/**
|
|
18665
|
+
* Overrides stored on the device, for every node type.
|
|
18666
|
+
*/
|
|
18667
|
+
get deviceOverrides() {
|
|
18668
|
+
return this._deviceOverrides.data;
|
|
18669
|
+
}
|
|
18670
|
+
/**
|
|
18671
|
+
* Creates an override on the device, or changes the level of the override
|
|
18672
|
+
* with the same node type, type and name.
|
|
18673
|
+
*/
|
|
18674
|
+
async addOverride(override) {
|
|
18675
|
+
const [error] = await addLogOverride(override);
|
|
18676
|
+
if (error) {
|
|
18677
|
+
throw new Error(error);
|
|
18678
|
+
}
|
|
18679
|
+
await this.refreshOverrides();
|
|
18680
|
+
}
|
|
18681
|
+
/**
|
|
18682
|
+
* Removes the device override with the given id.
|
|
18683
|
+
*/
|
|
18684
|
+
async removeOverride(id) {
|
|
18685
|
+
const override = this._deviceOverrides.getModel(id);
|
|
18686
|
+
if (!override) {
|
|
18687
|
+
throw new Error(`Unable to delete: Override id "${id}" not found.`);
|
|
18688
|
+
}
|
|
18689
|
+
const { nodeType, type, name, level: level2 } = override;
|
|
18690
|
+
const [error] = await removeLogOverride({ nodeType, type, name, level: level2 });
|
|
18691
|
+
if (error) {
|
|
18692
|
+
throw new Error(error);
|
|
18693
|
+
}
|
|
18694
|
+
this._deviceOverrides.removeModel(id);
|
|
18695
|
+
this.applyUiOverrides();
|
|
18696
|
+
}
|
|
18697
|
+
/**
|
|
18698
|
+
* Reloads the device's overrides.
|
|
18699
|
+
*/
|
|
18700
|
+
async refreshOverrides() {
|
|
18701
|
+
const [error, overrides] = await getLogOverrides();
|
|
18702
|
+
if (error) {
|
|
18703
|
+
this.logger.error("Failed to load log overrides", error);
|
|
18704
|
+
return;
|
|
18705
|
+
}
|
|
18706
|
+
this.applyDeviceOverrides(overrides ?? []);
|
|
18707
|
+
}
|
|
18708
|
+
/**
|
|
18709
|
+
* Reloads the java log groups registered on the primary node. Groups appear
|
|
18710
|
+
* as the classes that join them load.
|
|
18711
|
+
*/
|
|
18712
|
+
async refreshGroups() {
|
|
18713
|
+
const [error, groups] = await getLogGroups();
|
|
18714
|
+
if (error) {
|
|
18715
|
+
this.logger.error("Failed to load log groups", error);
|
|
18716
|
+
return;
|
|
18717
|
+
}
|
|
18718
|
+
this.groups = [...groups ?? []].sort();
|
|
18719
|
+
}
|
|
18720
|
+
applyDeviceOverrides(overrides) {
|
|
18721
|
+
const next = overrides.map(toDeviceOverride);
|
|
18722
|
+
const ids = new Set(next.map((override) => override.id));
|
|
18723
|
+
this._deviceOverrides.data.filter((override) => !ids.has(override.id)).forEach((override) => this._deviceOverrides.removeModel(override.id));
|
|
18724
|
+
next.forEach((override) => {
|
|
18725
|
+
if (this._deviceOverrides.getModel(override.id)) {
|
|
18726
|
+
this._deviceOverrides.updateModel(override);
|
|
18727
|
+
} else {
|
|
18728
|
+
this._deviceOverrides.addModel(override);
|
|
18729
|
+
}
|
|
18730
|
+
});
|
|
18731
|
+
this.applyUiOverrides();
|
|
18732
|
+
}
|
|
18733
|
+
applyUiOverrides() {
|
|
18734
|
+
const next = this._deviceOverrides.data.filter(isUiOverride).map(toUiOverride);
|
|
18735
|
+
const ids = new Set(next.map((override) => override.id));
|
|
18736
|
+
this._overrides.data.filter((override) => !ids.has(override.id)).forEach((override) => this._overrides.removeModel(override.id));
|
|
18737
|
+
next.forEach((override) => {
|
|
18738
|
+
if (this._overrides.getModel(override.id)) {
|
|
18739
|
+
this._overrides.updateModel(override);
|
|
18740
|
+
} else {
|
|
18741
|
+
this._overrides.addModel(override);
|
|
18742
|
+
}
|
|
18743
|
+
});
|
|
18744
|
+
globalThis.kos.logOverrides = this._overrides.data;
|
|
18745
|
+
Object.entries(KosLog.getLoggers()).forEach(([name, logger]) => {
|
|
18746
|
+
const level2 = resolveOverrideLevel(name, next);
|
|
18747
|
+
if (level2) {
|
|
18748
|
+
logger.setLevel(level2);
|
|
18749
|
+
this._overriddenLoggers.add(name);
|
|
18750
|
+
} else if (this._overriddenLoggers.delete(name)) {
|
|
18751
|
+
logger.resetLevel();
|
|
18752
|
+
}
|
|
18753
|
+
});
|
|
18754
|
+
}
|
|
18453
18755
|
// -------------------LIFECYCLE----------------------------
|
|
18454
18756
|
/**
|
|
18455
18757
|
* Resolves all registered loggers and their current log levels.
|
|
@@ -18481,68 +18783,33 @@ let KosLogManagerModelImpl = class {
|
|
|
18481
18783
|
res?.send(loggers);
|
|
18482
18784
|
return loggers;
|
|
18483
18785
|
}
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
* whose names start with the override name.
|
|
18488
|
-
* @param override - The log override configuration to apply
|
|
18489
|
-
* @private
|
|
18490
|
-
*/
|
|
18491
|
-
setLogLevels(override) {
|
|
18492
|
-
const loggers = Object.values(this.resolveLoggers()).filter(
|
|
18493
|
-
(logger) => logger.name.startsWith(override.name)
|
|
18786
|
+
handleOverrideAdded(override, payload) {
|
|
18787
|
+
this.logger.debug(
|
|
18788
|
+
`Override received for node type ${payload.wildcardCapture?.nodeType ?? "unknown"}`
|
|
18494
18789
|
);
|
|
18495
|
-
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
this.logger.debug(`Logger ${logger.name} not found`);
|
|
18499
|
-
return;
|
|
18500
|
-
}
|
|
18501
|
-
_logger2.setLevel(override.level);
|
|
18790
|
+
const deviceOverride = toDeviceOverride({
|
|
18791
|
+
nodeType: payload.wildcardCapture?.nodeType,
|
|
18792
|
+
...override
|
|
18502
18793
|
});
|
|
18503
|
-
|
|
18504
|
-
|
|
18505
|
-
|
|
18506
|
-
|
|
18794
|
+
if (this._deviceOverrides.getModel(deviceOverride.id)) {
|
|
18795
|
+
this._deviceOverrides.updateModel(deviceOverride);
|
|
18796
|
+
} else {
|
|
18797
|
+
this._deviceOverrides.addModel(deviceOverride);
|
|
18507
18798
|
}
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
}
|
|
18511
|
-
/**
|
|
18512
|
-
* Resets log levels to their defaults for matching loggers.
|
|
18513
|
-
* Removes the override for the logger and all child loggers
|
|
18514
|
-
* whose names start with the override name.
|
|
18515
|
-
* @param override - The log override configuration to reset
|
|
18516
|
-
* @private
|
|
18517
|
-
*/
|
|
18518
|
-
resetLogLevels(override) {
|
|
18519
|
-
const loggers = Object.values(this.resolveLoggers()).filter(
|
|
18520
|
-
(logger) => logger.name.startsWith(override.name)
|
|
18521
|
-
);
|
|
18522
|
-
loggers.forEach((logger) => {
|
|
18523
|
-
const _logger2 = KosLog.getLoggers()[logger.name];
|
|
18524
|
-
if (!_logger2) {
|
|
18525
|
-
this.logger.debug(`Logger ${logger.name} not found`);
|
|
18526
|
-
}
|
|
18527
|
-
_logger2?.resetLevel();
|
|
18528
|
-
});
|
|
18529
|
-
const _logger = KosLog.getLoggers()[override.name];
|
|
18530
|
-
if (!_logger) {
|
|
18531
|
-
this.logger.debug(`Logger ${override.name} not found`);
|
|
18799
|
+
if (isUiOverride(override)) {
|
|
18800
|
+
this.applyUiOverrides();
|
|
18532
18801
|
}
|
|
18533
|
-
_logger?.resetLevel();
|
|
18534
|
-
globalThis.kos.logOverrides = this._overrides.data;
|
|
18535
18802
|
}
|
|
18536
|
-
|
|
18537
|
-
this.
|
|
18538
|
-
|
|
18803
|
+
handleOverrideRemoved(override, payload) {
|
|
18804
|
+
this._deviceOverrides.removeModel(
|
|
18805
|
+
toDeviceOverride({
|
|
18806
|
+
nodeType: payload.wildcardCapture?.nodeType,
|
|
18807
|
+
...override
|
|
18808
|
+
}).id
|
|
18539
18809
|
);
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18543
|
-
handleOverrideRemoved(override) {
|
|
18544
|
-
this._overrides.removeModel(override.name);
|
|
18545
|
-
this.resetLogLevels(override);
|
|
18810
|
+
if (isUiOverride(override)) {
|
|
18811
|
+
this.applyUiOverrides();
|
|
18812
|
+
}
|
|
18546
18813
|
}
|
|
18547
18814
|
/**
|
|
18548
18815
|
* Initializes the log manager model.
|
|
@@ -18553,30 +18820,15 @@ let KosLogManagerModelImpl = class {
|
|
|
18553
18820
|
this.logger.debug(`initializing kos-log-manager ${this.id}`);
|
|
18554
18821
|
}
|
|
18555
18822
|
/**
|
|
18556
|
-
* Loads
|
|
18557
|
-
*
|
|
18823
|
+
* Loads the java log groups and the device's overrides, and applies the
|
|
18824
|
+
* UI overrides to the current loggers.
|
|
18558
18825
|
* Called after model initialization.
|
|
18559
18826
|
* @internal
|
|
18560
18827
|
*/
|
|
18561
18828
|
async load() {
|
|
18562
18829
|
this.logger.debug(`loading kos-log-manager ${this.id}`);
|
|
18563
|
-
|
|
18564
|
-
|
|
18565
|
-
this.logger.error("Failed to load log overrides", error);
|
|
18566
|
-
return;
|
|
18567
|
-
}
|
|
18568
|
-
const uiOverrides = overrides?.filter((override) => override.type?.toUpperCase() === "UI").map((override) => {
|
|
18569
|
-
return {
|
|
18570
|
-
name: override.name ?? "",
|
|
18571
|
-
type: override.type ?? "",
|
|
18572
|
-
level: override.level ?? "info",
|
|
18573
|
-
id: override.name || ""
|
|
18574
|
-
};
|
|
18575
|
-
}) ?? [];
|
|
18576
|
-
this._overrides.addAll(uiOverrides);
|
|
18577
|
-
uiOverrides.forEach((override) => {
|
|
18578
|
-
this.setLogLevels(override);
|
|
18579
|
-
});
|
|
18830
|
+
await this.refreshGroups();
|
|
18831
|
+
await this.refreshOverrides();
|
|
18580
18832
|
}
|
|
18581
18833
|
};
|
|
18582
18834
|
__decorateClass$l([
|
|
@@ -18805,21 +19057,11 @@ __decorateClass$j([
|
|
|
18805
19057
|
LogBlockContainerModelImpl = __decorateClass$j([
|
|
18806
19058
|
kosModel(MODEL_TYPE$i)
|
|
18807
19059
|
], LogBlockContainerModelImpl);
|
|
18808
|
-
const
|
|
18809
|
-
const params2 = getQueryParams();
|
|
18810
|
-
const connId = params2?.connId;
|
|
18811
|
-
const result = connId || window?.kosBridge?.("connId");
|
|
18812
|
-
KosLog.debug(`getKosConnectionId: ${result}`);
|
|
18813
|
-
return result;
|
|
18814
|
-
};
|
|
18815
|
-
const log$a = KosLog.createLogger({
|
|
18816
|
-
name: "log-stream-container-service",
|
|
18817
|
-
group: "Services"
|
|
18818
|
-
});
|
|
19060
|
+
const log$e = KosLog.createLogger({ group: LogGroup.service, name: "log-stream-container-service" });
|
|
18819
19061
|
const SERVICE_PATH = "/api/kos/logs/node/{nodeId}/streams";
|
|
18820
19062
|
const getLogStreams = async () => {
|
|
18821
19063
|
const destinationAddress = getKosConnectionId();
|
|
18822
|
-
log$
|
|
19064
|
+
log$e.debug("sending GET for log-stream-container");
|
|
18823
19065
|
return await api$1.get(
|
|
18824
19066
|
SERVICE_PATH,
|
|
18825
19067
|
{
|
|
@@ -19391,11 +19633,11 @@ const { URL: URL$7 } = resolveServiceUrl();
|
|
|
19391
19633
|
const { getAll: getAll$4, postModel: postModel$1 } = ServiceFactory.build({
|
|
19392
19634
|
basePath: `${URL$7}/api/kos/troubles`
|
|
19393
19635
|
});
|
|
19394
|
-
const log$
|
|
19636
|
+
const log$d = KosLog.createLogger({ group: LogGroup.service, name: "trouble-services" });
|
|
19395
19637
|
const getTroubles = async (servicePath) => {
|
|
19396
19638
|
const isKosTroubles = servicePath.includes("/kos/troubles");
|
|
19397
19639
|
const destinationAddress = getKosConnectionId();
|
|
19398
|
-
log$
|
|
19640
|
+
log$d.info(
|
|
19399
19641
|
`Fetching troubles from ${servicePath} with destination address: ${isKosTroubles ? destinationAddress : "N/A (not a kos troubles path)"}`
|
|
19400
19642
|
);
|
|
19401
19643
|
const response = await getAll$4({
|
|
@@ -19477,6 +19719,10 @@ const defaultTroubleRoleMapper = (trouble) => {
|
|
|
19477
19719
|
}
|
|
19478
19720
|
return "TECHNICIAN";
|
|
19479
19721
|
};
|
|
19722
|
+
const log$c = KosLog.createLogger({
|
|
19723
|
+
group: LogGroup.model,
|
|
19724
|
+
name: "trouble-data-extension"
|
|
19725
|
+
});
|
|
19480
19726
|
const EXTENSION_TROUBLE_DATA_MAPPER = "troubleDataMapper";
|
|
19481
19727
|
const troubleMappers$1 = /* @__PURE__ */ new Map();
|
|
19482
19728
|
registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
@@ -19500,7 +19746,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19500
19746
|
if (r.status === "fulfilled") {
|
|
19501
19747
|
acc = { ...acc, ...r.value };
|
|
19502
19748
|
} else {
|
|
19503
|
-
|
|
19749
|
+
log$c.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19504
19750
|
}
|
|
19505
19751
|
return acc;
|
|
19506
19752
|
},
|
|
@@ -19509,6 +19755,10 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19509
19755
|
return data;
|
|
19510
19756
|
}
|
|
19511
19757
|
});
|
|
19758
|
+
const log$b = KosLog.createLogger({
|
|
19759
|
+
group: LogGroup.model,
|
|
19760
|
+
name: "trouble-extension"
|
|
19761
|
+
});
|
|
19512
19762
|
const EXTENSION_TROUBLE_MAPPER = "troubleMapper";
|
|
19513
19763
|
const troubleMappers = /* @__PURE__ */ new Map();
|
|
19514
19764
|
registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
@@ -19529,7 +19779,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
|
19529
19779
|
if (r.status === "fulfilled") {
|
|
19530
19780
|
return r.value;
|
|
19531
19781
|
} else {
|
|
19532
|
-
|
|
19782
|
+
log$b.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19533
19783
|
return [];
|
|
19534
19784
|
}
|
|
19535
19785
|
}).flat();
|
|
@@ -19918,16 +20168,13 @@ const { URL: URL$6 } = resolveServiceUrl();
|
|
|
19918
20168
|
const { getAll: getAll$3 } = ServiceFactory.build({
|
|
19919
20169
|
basePath: `${URL$6}/api/kos/ota`
|
|
19920
20170
|
});
|
|
19921
|
-
const log$
|
|
19922
|
-
name: "ota-service",
|
|
19923
|
-
group: "Services"
|
|
19924
|
-
});
|
|
20171
|
+
const log$a = KosLog.createLogger({ group: LogGroup.service, name: "ota-service" });
|
|
19925
20172
|
const getArtifacts = async () => {
|
|
19926
|
-
log$
|
|
20173
|
+
log$a.debug("sending GET request to /api/kos/ota/artifacts");
|
|
19927
20174
|
const response = await getAll$3({
|
|
19928
20175
|
urlOverride: `${URL$6}/api/kos/ota/artifacts`
|
|
19929
20176
|
});
|
|
19930
|
-
log$
|
|
20177
|
+
log$a.debug("getArtifacts - response:", response);
|
|
19931
20178
|
return response?.data;
|
|
19932
20179
|
};
|
|
19933
20180
|
var __defProp$a = Object.defineProperty;
|
|
@@ -20111,7 +20358,10 @@ const Ota = new SingletonKosModelRegistrationFactory({
|
|
|
20111
20358
|
class: OtaModelImpl,
|
|
20112
20359
|
type: MODEL_TYPE$c
|
|
20113
20360
|
});
|
|
20114
|
-
const log$
|
|
20361
|
+
const log$9 = KosLog.createLogger({
|
|
20362
|
+
group: LogGroup.model,
|
|
20363
|
+
name: "await-future-call"
|
|
20364
|
+
});
|
|
20115
20365
|
class FutureCallError extends Error {
|
|
20116
20366
|
endState;
|
|
20117
20367
|
reason;
|
|
@@ -20162,7 +20412,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20162
20412
|
const watchTracked = (future) => {
|
|
20163
20413
|
tracked = future;
|
|
20164
20414
|
if (cancelRequested) {
|
|
20165
|
-
future.cancelFuture().catch((e) => log$
|
|
20415
|
+
future.cancelFuture().catch((e) => log$9.error(e));
|
|
20166
20416
|
}
|
|
20167
20417
|
disposers.push(
|
|
20168
20418
|
mobx.reaction(
|
|
@@ -20179,7 +20429,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20179
20429
|
try {
|
|
20180
20430
|
cb(progress, status);
|
|
20181
20431
|
} catch (e) {
|
|
20182
|
-
log$
|
|
20432
|
+
log$9.warn("progress callback error", e);
|
|
20183
20433
|
}
|
|
20184
20434
|
});
|
|
20185
20435
|
},
|
|
@@ -20255,6 +20505,189 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20255
20505
|
};
|
|
20256
20506
|
return promise;
|
|
20257
20507
|
}
|
|
20508
|
+
function createCancellablePromise(promiseOrOptions, abortController, cancelFuture2, future) {
|
|
20509
|
+
const options = promiseOrOptions instanceof Promise ? { promise: promiseOrOptions, abortController, cancelFuture: cancelFuture2, future } : promiseOrOptions;
|
|
20510
|
+
const {
|
|
20511
|
+
promise,
|
|
20512
|
+
abortController: controller,
|
|
20513
|
+
cancelFuture: cancelFn,
|
|
20514
|
+
future: futureRef
|
|
20515
|
+
} = options;
|
|
20516
|
+
const cancellablePromise = promise;
|
|
20517
|
+
let currentProgress = 0;
|
|
20518
|
+
let currentStatus = "PENDING";
|
|
20519
|
+
let isRunning = true;
|
|
20520
|
+
const progressCallbacks = /* @__PURE__ */ new Set();
|
|
20521
|
+
let effectDisposer;
|
|
20522
|
+
if (futureRef && typeof futureRef === "object") {
|
|
20523
|
+
effectDisposer = mobx.autorun(() => {
|
|
20524
|
+
const newProgress = futureRef.progress || 0;
|
|
20525
|
+
const newStatus = futureRef.status || "PENDING";
|
|
20526
|
+
const newIsRunning = !futureRef.endState;
|
|
20527
|
+
if (newProgress !== currentProgress || newStatus !== currentStatus || newIsRunning !== isRunning) {
|
|
20528
|
+
currentProgress = newProgress;
|
|
20529
|
+
currentStatus = newStatus;
|
|
20530
|
+
isRunning = newIsRunning;
|
|
20531
|
+
progressCallbacks.forEach((callback) => {
|
|
20532
|
+
try {
|
|
20533
|
+
callback(currentProgress, currentStatus);
|
|
20534
|
+
} catch (error) {
|
|
20535
|
+
console.warn("Progress callback error:", error);
|
|
20536
|
+
}
|
|
20537
|
+
});
|
|
20538
|
+
}
|
|
20539
|
+
});
|
|
20540
|
+
}
|
|
20541
|
+
promise.finally(() => {
|
|
20542
|
+
isRunning = false;
|
|
20543
|
+
if (!controller?.signal.aborted) {
|
|
20544
|
+
currentStatus = "COMPLETED";
|
|
20545
|
+
progressCallbacks.forEach((callback) => {
|
|
20546
|
+
try {
|
|
20547
|
+
callback(currentProgress, currentStatus);
|
|
20548
|
+
} catch (error) {
|
|
20549
|
+
console.warn("Progress callback error:", error);
|
|
20550
|
+
}
|
|
20551
|
+
});
|
|
20552
|
+
}
|
|
20553
|
+
if (effectDisposer) {
|
|
20554
|
+
effectDisposer();
|
|
20555
|
+
}
|
|
20556
|
+
progressCallbacks.clear();
|
|
20557
|
+
});
|
|
20558
|
+
cancellablePromise.cancel = async () => {
|
|
20559
|
+
if (controller && !controller.signal.aborted) {
|
|
20560
|
+
controller.abort();
|
|
20561
|
+
}
|
|
20562
|
+
if (cancelFn) {
|
|
20563
|
+
await cancelFn();
|
|
20564
|
+
}
|
|
20565
|
+
isRunning = false;
|
|
20566
|
+
currentStatus = "CANCELLED";
|
|
20567
|
+
progressCallbacks.forEach((callback) => {
|
|
20568
|
+
try {
|
|
20569
|
+
callback(currentProgress, currentStatus);
|
|
20570
|
+
} catch (error) {
|
|
20571
|
+
console.warn("Progress callback error:", error);
|
|
20572
|
+
}
|
|
20573
|
+
});
|
|
20574
|
+
if (effectDisposer) {
|
|
20575
|
+
effectDisposer();
|
|
20576
|
+
}
|
|
20577
|
+
};
|
|
20578
|
+
cancellablePromise.getController = () => controller;
|
|
20579
|
+
cancellablePromise.isCancelled = () => controller?.signal.aborted ?? false;
|
|
20580
|
+
Object.defineProperty(cancellablePromise, "progress", {
|
|
20581
|
+
get: () => currentProgress,
|
|
20582
|
+
enumerable: true
|
|
20583
|
+
});
|
|
20584
|
+
Object.defineProperty(cancellablePromise, "status", {
|
|
20585
|
+
get: () => currentStatus,
|
|
20586
|
+
enumerable: true
|
|
20587
|
+
});
|
|
20588
|
+
Object.defineProperty(cancellablePromise, "isRunning", {
|
|
20589
|
+
get: () => isRunning,
|
|
20590
|
+
enumerable: true
|
|
20591
|
+
});
|
|
20592
|
+
cancellablePromise.onProgressUpdate = (callback) => {
|
|
20593
|
+
progressCallbacks.add(callback);
|
|
20594
|
+
callback(currentProgress, currentStatus);
|
|
20595
|
+
return () => progressCallbacks.delete(callback);
|
|
20596
|
+
};
|
|
20597
|
+
return cancellablePromise;
|
|
20598
|
+
}
|
|
20599
|
+
const log$8 = KosLog.createLogger({
|
|
20600
|
+
group: LogGroup.model,
|
|
20601
|
+
name: "cancellable-future-call"
|
|
20602
|
+
});
|
|
20603
|
+
function makeCancellable(model, methodCall) {
|
|
20604
|
+
const initialFuture = model.futureHandler.future;
|
|
20605
|
+
const promise = methodCall(model);
|
|
20606
|
+
let newFuture = null;
|
|
20607
|
+
setTimeout(() => {
|
|
20608
|
+
newFuture = model.futureHandler.future;
|
|
20609
|
+
if (newFuture === initialFuture) {
|
|
20610
|
+
newFuture = null;
|
|
20611
|
+
}
|
|
20612
|
+
}, 0);
|
|
20613
|
+
return createCancellablePromise({
|
|
20614
|
+
promise,
|
|
20615
|
+
abortController: void 0,
|
|
20616
|
+
// No direct AbortController access
|
|
20617
|
+
cancelFuture: async () => {
|
|
20618
|
+
if (newFuture) {
|
|
20619
|
+
await newFuture.cancelFuture();
|
|
20620
|
+
} else {
|
|
20621
|
+
const currentFuture = model.futureHandler.future;
|
|
20622
|
+
if (currentFuture) {
|
|
20623
|
+
await currentFuture.cancelFuture();
|
|
20624
|
+
}
|
|
20625
|
+
}
|
|
20626
|
+
},
|
|
20627
|
+
future: newFuture
|
|
20628
|
+
// Pass the future for progress tracking
|
|
20629
|
+
});
|
|
20630
|
+
}
|
|
20631
|
+
function withCancellation(model, methodName, ...args) {
|
|
20632
|
+
const method = model[methodName];
|
|
20633
|
+
if (typeof method !== "function") {
|
|
20634
|
+
throw new Error(`${String(methodName)} is not a method`);
|
|
20635
|
+
}
|
|
20636
|
+
const initialFuture = model.futureHandler.future;
|
|
20637
|
+
const promise = method.apply(model, args);
|
|
20638
|
+
let targetFuture = null;
|
|
20639
|
+
setTimeout(() => {
|
|
20640
|
+
const currentFuture = model.futureHandler.future;
|
|
20641
|
+
if (currentFuture && currentFuture !== initialFuture) {
|
|
20642
|
+
targetFuture = currentFuture;
|
|
20643
|
+
}
|
|
20644
|
+
}, 0);
|
|
20645
|
+
return createCancellablePromise({
|
|
20646
|
+
promise,
|
|
20647
|
+
abortController: void 0,
|
|
20648
|
+
cancelFuture: async () => {
|
|
20649
|
+
if (targetFuture) {
|
|
20650
|
+
await targetFuture.cancelFuture();
|
|
20651
|
+
} else {
|
|
20652
|
+
const fallbackFuture = model.futureHandler.future;
|
|
20653
|
+
if (fallbackFuture) {
|
|
20654
|
+
await fallbackFuture.cancelFuture();
|
|
20655
|
+
}
|
|
20656
|
+
}
|
|
20657
|
+
},
|
|
20658
|
+
future: targetFuture
|
|
20659
|
+
// Pass the future for progress tracking
|
|
20660
|
+
});
|
|
20661
|
+
}
|
|
20662
|
+
class CancellationBatch {
|
|
20663
|
+
operations = [];
|
|
20664
|
+
add(model, methodCall) {
|
|
20665
|
+
const cancellable = makeCancellable(model, methodCall);
|
|
20666
|
+
this.operations.push(cancellable);
|
|
20667
|
+
return cancellable;
|
|
20668
|
+
}
|
|
20669
|
+
async cancelAll() {
|
|
20670
|
+
await Promise.all(
|
|
20671
|
+
this.operations.map(
|
|
20672
|
+
(op) => op.cancel().catch(() => {
|
|
20673
|
+
log$8.warn("Cancellation failed for operation:", op);
|
|
20674
|
+
})
|
|
20675
|
+
)
|
|
20676
|
+
);
|
|
20677
|
+
}
|
|
20678
|
+
getAllControllers() {
|
|
20679
|
+
return this.operations.map((op) => op.getController());
|
|
20680
|
+
}
|
|
20681
|
+
getActiveCount() {
|
|
20682
|
+
return this.operations.filter((op) => !op.isCancelled()).length;
|
|
20683
|
+
}
|
|
20684
|
+
clear() {
|
|
20685
|
+
this.operations = [];
|
|
20686
|
+
}
|
|
20687
|
+
}
|
|
20688
|
+
function createCancellationBatch() {
|
|
20689
|
+
return new CancellationBatch();
|
|
20690
|
+
}
|
|
20258
20691
|
function createCancellableService(serviceFunction) {
|
|
20259
20692
|
let controller;
|
|
20260
20693
|
const wrappedFunction = async (...args) => {
|
|
@@ -22611,9 +23044,9 @@ const { URL: URL$5 } = resolveServiceUrl();
|
|
|
22611
23044
|
const { getOne: getOne$1 } = ServiceFactory.build({
|
|
22612
23045
|
basePath: `${URL$5}/api/device`
|
|
22613
23046
|
});
|
|
22614
|
-
const log$
|
|
23047
|
+
const log$7 = KosLog.createLogger({ group: LogGroup.service, name: "device-service" });
|
|
22615
23048
|
const getSerialNumber = async () => {
|
|
22616
|
-
log$
|
|
23049
|
+
log$7.debug("sending GET for device serial number");
|
|
22617
23050
|
try {
|
|
22618
23051
|
const response = await getOne$1({
|
|
22619
23052
|
urlOverride: `${URL$5}/api/kos/device/serialNumber`
|
|
@@ -22621,14 +23054,14 @@ const getSerialNumber = async () => {
|
|
|
22621
23054
|
return [void 0, response?.data.serialNumber];
|
|
22622
23055
|
} catch (error) {
|
|
22623
23056
|
if (error instanceof FetchError) {
|
|
22624
|
-
log$
|
|
23057
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22625
23058
|
return [error.payload.error, void 0];
|
|
22626
23059
|
}
|
|
22627
23060
|
}
|
|
22628
23061
|
return ["unknownError", void 0];
|
|
22629
23062
|
};
|
|
22630
23063
|
const getDeviceDetails = async () => {
|
|
22631
|
-
log$
|
|
23064
|
+
log$7.debug("sending GET for device details");
|
|
22632
23065
|
try {
|
|
22633
23066
|
const response = await getOne$1({
|
|
22634
23067
|
urlOverride: `${URL$5}/api/kos/device`
|
|
@@ -22639,7 +23072,7 @@ const getDeviceDetails = async () => {
|
|
|
22639
23072
|
return [void 0, response.data];
|
|
22640
23073
|
} catch (error) {
|
|
22641
23074
|
if (error instanceof FetchError) {
|
|
22642
|
-
log$
|
|
23075
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22643
23076
|
return [error.payload.error, void 0];
|
|
22644
23077
|
}
|
|
22645
23078
|
}
|
|
@@ -22850,13 +23283,10 @@ const { URL: URL$4 } = resolveServiceUrl();
|
|
|
22850
23283
|
const { getAll: getAll$2 } = ServiceFactory.build({
|
|
22851
23284
|
basePath: `${URL$4}/api/kos/network/interfaces`
|
|
22852
23285
|
});
|
|
22853
|
-
const log$
|
|
22854
|
-
name: "network-interface-service",
|
|
22855
|
-
group: "Services"
|
|
22856
|
-
});
|
|
23286
|
+
const log$6 = KosLog.createLogger({ group: LogGroup.service, name: "network-interface-service" });
|
|
22857
23287
|
const getNetworkInterfaces = async () => {
|
|
22858
23288
|
const destinationAddress = getKosConnectionId();
|
|
22859
|
-
log$
|
|
23289
|
+
log$6.debug("sending GET for copy-logs");
|
|
22860
23290
|
try {
|
|
22861
23291
|
const response = await getAll$2({
|
|
22862
23292
|
destinationAddress
|
|
@@ -22864,7 +23294,7 @@ const getNetworkInterfaces = async () => {
|
|
|
22864
23294
|
return [void 0, response?.data];
|
|
22865
23295
|
} catch (error) {
|
|
22866
23296
|
if (error instanceof FetchError) {
|
|
22867
|
-
log$
|
|
23297
|
+
log$6.error(`Error fetching log file size: ${error.payload.error}`);
|
|
22868
23298
|
return [error.payload.error, void 0];
|
|
22869
23299
|
}
|
|
22870
23300
|
}
|
|
@@ -22962,15 +23392,12 @@ const { URL: URL$3 } = resolveServiceUrl();
|
|
|
22962
23392
|
const { getAll: getAll$1 } = ServiceFactory.build({
|
|
22963
23393
|
basePath: `${URL$3}/api/kos/storage/devices`
|
|
22964
23394
|
});
|
|
22965
|
-
const log$
|
|
22966
|
-
name: "storage-device-service",
|
|
22967
|
-
group: "Services"
|
|
22968
|
-
});
|
|
23395
|
+
const log$5 = KosLog.createLogger({ group: LogGroup.service, name: "storage-device-service" });
|
|
22969
23396
|
const getStorageDevices = async () => {
|
|
22970
|
-
log$
|
|
23397
|
+
log$5.debug("sending GET for storage-device");
|
|
22971
23398
|
const response = await getAll$1({});
|
|
22972
23399
|
if (!response?.data || response.status !== 200) {
|
|
22973
|
-
log$
|
|
23400
|
+
log$5.error("Failed to retrieve storage-device data", response);
|
|
22974
23401
|
return [];
|
|
22975
23402
|
}
|
|
22976
23403
|
return response.data;
|
|
@@ -23168,17 +23595,14 @@ const { URL: URL$2 } = resolveServiceUrl();
|
|
|
23168
23595
|
const { getAll, postModel } = ServiceFactory.build({
|
|
23169
23596
|
basePath: `${URL$2}/api/kos/update/available`
|
|
23170
23597
|
});
|
|
23171
|
-
const log$
|
|
23172
|
-
name: "usb-update-service",
|
|
23173
|
-
group: "Services"
|
|
23174
|
-
});
|
|
23598
|
+
const log$4 = KosLog.createLogger({ group: LogGroup.service, name: "usb-update-service" });
|
|
23175
23599
|
const getAvailableUpdates = async () => {
|
|
23176
|
-
log$
|
|
23600
|
+
log$4.debug("sending GET for usb-update");
|
|
23177
23601
|
const response = await getAll({
|
|
23178
23602
|
urlOverride: `${URL$2}/api/kos/update/available`
|
|
23179
23603
|
});
|
|
23180
23604
|
if (!response?.data || response?.status !== 200) {
|
|
23181
|
-
log$
|
|
23605
|
+
log$4.error("Failed to retrieve usb-update data", response);
|
|
23182
23606
|
return [];
|
|
23183
23607
|
}
|
|
23184
23608
|
return response.data;
|
|
@@ -23419,10 +23843,7 @@ const { URL: URL$1 } = resolveServiceUrl();
|
|
|
23419
23843
|
const { getOne } = ServiceFactory.build({
|
|
23420
23844
|
basePath: `${URL$1}/api/translation`
|
|
23421
23845
|
});
|
|
23422
|
-
const log$
|
|
23423
|
-
name: "translation-service",
|
|
23424
|
-
group: "Services"
|
|
23425
|
-
});
|
|
23846
|
+
const log$3 = KosLog.createLogger({ group: LogGroup.service, name: "translation-service" });
|
|
23426
23847
|
const getDefaultHost = () => {
|
|
23427
23848
|
const defaultHost = window.location.origin;
|
|
23428
23849
|
const params2 = getQueryParams();
|
|
@@ -23431,23 +23852,23 @@ const getDefaultHost = () => {
|
|
|
23431
23852
|
return result;
|
|
23432
23853
|
};
|
|
23433
23854
|
const getTranslations = async (url, root) => {
|
|
23434
|
-
log$
|
|
23855
|
+
log$3.debug(`Loading translations from: ${url}`);
|
|
23435
23856
|
const rootUrl = root ?? getDefaultHost();
|
|
23436
23857
|
try {
|
|
23437
23858
|
const response = await fetch(`${rootUrl}${url}`);
|
|
23438
23859
|
if (response.status !== 200) {
|
|
23439
|
-
log$
|
|
23860
|
+
log$3.warn(`Failed to fetch translations at ${url}: ${response.status}`);
|
|
23440
23861
|
return {};
|
|
23441
23862
|
}
|
|
23442
23863
|
const json = await response.json();
|
|
23443
23864
|
return json;
|
|
23444
23865
|
} catch (error) {
|
|
23445
|
-
log$
|
|
23866
|
+
log$3.error("Error fetching translations", error);
|
|
23446
23867
|
throw error;
|
|
23447
23868
|
}
|
|
23448
23869
|
};
|
|
23449
23870
|
const getLocalizationDescriptor = async () => {
|
|
23450
|
-
log$
|
|
23871
|
+
log$3.debug("Getting system localization descriptor");
|
|
23451
23872
|
const response = await getOne({
|
|
23452
23873
|
urlOverride: `${URL$1}/api/system/kos/localization`
|
|
23453
23874
|
});
|
|
@@ -23459,7 +23880,7 @@ const getLocalizationDescriptor = async () => {
|
|
|
23459
23880
|
return response.data;
|
|
23460
23881
|
};
|
|
23461
23882
|
const getKosLocalizationDescriptor = (context) => async () => {
|
|
23462
|
-
log$
|
|
23883
|
+
log$3.debug(`Getting KOS localization descriptor for context: ${context}`);
|
|
23463
23884
|
const response = await getOne({
|
|
23464
23885
|
urlOverride: `${URL$1}/api/kos/localization/contexts`
|
|
23465
23886
|
});
|
|
@@ -23948,6 +24369,10 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
23948
24369
|
if (kind && result) __defProp(target, key, result);
|
|
23949
24370
|
return result;
|
|
23950
24371
|
};
|
|
24372
|
+
const log$2 = KosLog.createLogger({
|
|
24373
|
+
group: LogGroup.model,
|
|
24374
|
+
name: "ws-event-model"
|
|
24375
|
+
});
|
|
23951
24376
|
const stringify = ({ headers, body }) => {
|
|
23952
24377
|
const headText = Object.entries(headers).map(([key, value]) => `${key}:${value}`).join("\\n");
|
|
23953
24378
|
return headText + "\\n\\n" + body;
|
|
@@ -23971,7 +24396,7 @@ exports.WsEventModel = class WsEventModel {
|
|
|
23971
24396
|
this.processEvent(payload);
|
|
23972
24397
|
}
|
|
23973
24398
|
processEvent(data, isSend = false) {
|
|
23974
|
-
|
|
24399
|
+
log$2.debug("kos event received");
|
|
23975
24400
|
const { body, headers } = data.body;
|
|
23976
24401
|
const isUnique = headers["request-id"] || headers["response-id"];
|
|
23977
24402
|
const msgId = headers["request-id"] || headers["response-id"] || headers["topic"] || headers["type"];
|
|
@@ -23995,7 +24420,7 @@ exports.WsEventModel = class WsEventModel {
|
|
|
23995
24420
|
mocked: !!headers["mocked"]
|
|
23996
24421
|
};
|
|
23997
24422
|
this.events.set(rawKey, rawData);
|
|
23998
|
-
|
|
24423
|
+
log$2.debug(`logged ${this.events.size} events`);
|
|
23999
24424
|
}
|
|
24000
24425
|
}
|
|
24001
24426
|
};
|
|
@@ -24042,9 +24467,9 @@ const Registry = {
|
|
|
24042
24467
|
preloadModels: []
|
|
24043
24468
|
};
|
|
24044
24469
|
const PRELOAD = true;
|
|
24045
|
-
const registerCoreModels = (root) => () => {
|
|
24470
|
+
const registerCoreModels = (root) => ({ preloadLogManager = true } = {}) => {
|
|
24046
24471
|
const coreModels2 = CoreModels;
|
|
24047
|
-
registerKosModel(KosModelRegistry2)(Trouble).model(TroubleContainer).model(StorageDeviceContainer).model(UsbUpdateContainer).model(Device).model(Ota).model(ConfigBean).model(SoftwareInfo).model(KeyValue).model(NetworkInterfaceContainer).model(CanvasDispatcher).model(CanvasRenderer).model(KosExpressionEvaluator).model(BrowserRouter, PRELOAD).model(LogStreamContainer).model(KosLogManager);
|
|
24472
|
+
registerKosModel(KosModelRegistry2)(Trouble).model(TroubleContainer).model(StorageDeviceContainer).model(UsbUpdateContainer).model(Device).model(Ota).model(ConfigBean).model(SoftwareInfo).model(KeyValue).model(NetworkInterfaceContainer).model(CanvasDispatcher).model(CanvasRenderer).model(KosExpressionEvaluator).model(BrowserRouter, PRELOAD).model(LogStreamContainer).model(KosLogManager, preloadLogManager);
|
|
24048
24473
|
Object.keys(coreModels2).forEach((key) => {
|
|
24049
24474
|
const model = coreModels2[key];
|
|
24050
24475
|
registerLegacyModel(KosModelRegistry2)(key, model);
|
|
@@ -24068,7 +24493,10 @@ const KosModelRegistry2 = _KosModelRegistry;
|
|
|
24068
24493
|
const TIMER_EVENT = `/kos-timer-event`;
|
|
24069
24494
|
const TOPIC_TIMER_TICK_EVENT = `/kos-timer-event/tick`;
|
|
24070
24495
|
const TIMER_END = "defaultTimerEnd";
|
|
24071
|
-
const log$1 = KosLog.createLogger({
|
|
24496
|
+
const log$1 = KosLog.createLogger({
|
|
24497
|
+
group: LogGroup.model,
|
|
24498
|
+
name: "timer-manager"
|
|
24499
|
+
});
|
|
24072
24500
|
const isConfigProperty = (value) => value.updateProperty !== void 0;
|
|
24073
24501
|
class KosTimer {
|
|
24074
24502
|
name;
|
|
@@ -24095,7 +24523,7 @@ class KosTimer {
|
|
|
24095
24523
|
this.remainingTime = timeoutValue;
|
|
24096
24524
|
if (isConfigProperty(timeout)) {
|
|
24097
24525
|
kosAutoEffect(() => {
|
|
24098
|
-
|
|
24526
|
+
log$1.info(
|
|
24099
24527
|
`Updating config value timer ${name} with new timeout value ${timeout.value}`
|
|
24100
24528
|
);
|
|
24101
24529
|
const newValue = timeout.value || 60;
|
|
@@ -24332,10 +24760,7 @@ const TimerManager = {
|
|
|
24332
24760
|
executeOnTimer(name, (timer) => timer.start());
|
|
24333
24761
|
}
|
|
24334
24762
|
};
|
|
24335
|
-
const log = KosLog.createLogger({
|
|
24336
|
-
name: "software-info-service",
|
|
24337
|
-
group: "Services"
|
|
24338
|
-
});
|
|
24763
|
+
const log = KosLog.createLogger({ group: LogGroup.service, name: "software-info-service" });
|
|
24339
24764
|
const getSoftwareInfos = async (signal) => {
|
|
24340
24765
|
const destinationAddress = getKosConnectionId();
|
|
24341
24766
|
log.debug("sending GET for software-info");
|
|
@@ -24443,6 +24868,7 @@ exports.AuthState = AuthState;
|
|
|
24443
24868
|
exports.BrowserKosRouter = BrowserKosRouter;
|
|
24444
24869
|
exports.BrowserRouter = BrowserRouter;
|
|
24445
24870
|
exports.CancellableServiceManager = CancellableServiceManager;
|
|
24871
|
+
exports.CancellationBatch = CancellationBatch;
|
|
24446
24872
|
exports.CanvasDispatcher = CanvasDispatcher;
|
|
24447
24873
|
exports.CanvasRenderer = CanvasRenderer;
|
|
24448
24874
|
exports.ChildModels = ChildModels;
|
|
@@ -24537,10 +24963,11 @@ exports.LOGIN_HOST = LOGIN_HOST;
|
|
|
24537
24963
|
exports.LOGIN_URL = LOGIN_URL;
|
|
24538
24964
|
exports.LogBlock = LogBlock;
|
|
24539
24965
|
exports.LogBlockContainer = LogBlockContainer;
|
|
24540
|
-
exports.
|
|
24966
|
+
exports.LogGroup = LogGroup;
|
|
24541
24967
|
exports.LogStream = LogStream;
|
|
24542
24968
|
exports.LogStreamContainer = LogStreamContainer;
|
|
24543
24969
|
exports.LoggerSetup = LoggerSetup;
|
|
24970
|
+
exports.MESSAGE_LOGGER_NAME = MESSAGE_LOGGER_NAME;
|
|
24544
24971
|
exports.MODEL_DELETION_DELAY = MODEL_DELETION_DELAY;
|
|
24545
24972
|
exports.MixinModels = MixinModels;
|
|
24546
24973
|
exports.ModelEffects = ModelEffects;
|
|
@@ -24607,6 +25034,7 @@ exports.WebSocketEvents = WebSocketEvents;
|
|
|
24607
25034
|
exports.WebSocketTransport = WebSocketTransport;
|
|
24608
25035
|
exports.WsEventFactory = WsEventFactory;
|
|
24609
25036
|
exports.addFuture = addFuture;
|
|
25037
|
+
exports.addLogOverride = addLogOverride;
|
|
24610
25038
|
exports.api = api$1;
|
|
24611
25039
|
exports.api$1 = api;
|
|
24612
25040
|
exports.applyFunctionalEnhancements = applyFunctionalEnhancements;
|
|
@@ -24624,7 +25052,9 @@ exports.convert = convert;
|
|
|
24624
25052
|
exports.convertWithUnits = convertWithUnits;
|
|
24625
25053
|
exports.createBaseMessage = createBaseMessage;
|
|
24626
25054
|
exports.createBroadcastMessageResponse = createBroadcastMessageResponse;
|
|
25055
|
+
exports.createCancellablePromise = createCancellablePromise;
|
|
24627
25056
|
exports.createCancellableService = createCancellableService;
|
|
25057
|
+
exports.createCancellationBatch = createCancellationBatch;
|
|
24628
25058
|
exports.createClient = createClient;
|
|
24629
25059
|
exports.createFosBaseMessage = createFosBaseMessage;
|
|
24630
25060
|
exports.createHeaders = createHeaders;
|
|
@@ -24666,15 +25096,14 @@ exports.getKeyValue = getKeyValue;
|
|
|
24666
25096
|
exports.getKosCompanionModel = getKosCompanionModel;
|
|
24667
25097
|
exports.getKosConnectionId = getKosConnectionId;
|
|
24668
25098
|
exports.getKosLocalizationDescriptor = getKosLocalizationDescriptor;
|
|
24669
|
-
exports.getKosMessageLogging = getKosMessageLogging;
|
|
24670
25099
|
exports.getKosModel = getKosModel$1;
|
|
24671
25100
|
exports.getKosModelActivationState = getKosModelActivationState;
|
|
24672
25101
|
exports.getKosModelSync = getKosModelSync;
|
|
24673
25102
|
exports.getKosModelType = getKosModelType;
|
|
24674
25103
|
exports.getKosSessionKey = getKosSessionKey;
|
|
24675
25104
|
exports.getLocalizationDescriptor = getLocalizationDescriptor;
|
|
25105
|
+
exports.getLogGroups = getLogGroups;
|
|
24676
25106
|
exports.getLogLevel = getLogLevel;
|
|
24677
|
-
exports.getLogMessageToStudio = getLogMessageToStudio;
|
|
24678
25107
|
exports.getLogOverrides = getLogOverrides;
|
|
24679
25108
|
exports.getLogStreamBlock = getLogStreamBlock;
|
|
24680
25109
|
exports.getLogStreamBlocks = getLogStreamBlocks;
|
|
@@ -24740,6 +25169,7 @@ exports.kosStateGuard = kosStateGuard;
|
|
|
24740
25169
|
exports.kosStateMachine = kosStateMachine;
|
|
24741
25170
|
exports.kosTopicHandler = kosTopicHandler;
|
|
24742
25171
|
exports.kosWhen = kosWhen;
|
|
25172
|
+
exports.makeCancellable = makeCancellable;
|
|
24743
25173
|
exports.mapConfigBeanModelToDto = mapConfigBeanModelToDto;
|
|
24744
25174
|
exports.mapDataToModel = mapDataToModel;
|
|
24745
25175
|
exports.mapDtoToConfigBeanModel = mapDtoToConfigBeanModel;
|
|
@@ -24765,6 +25195,7 @@ exports.registerExtensionPoint = registerExtensionPoint;
|
|
|
24765
25195
|
exports.registerHttpRoutes = registerHttpRoutes;
|
|
24766
25196
|
exports.registerKosModel = registerKosModel;
|
|
24767
25197
|
exports.registerLegacyModel = registerLegacyModel;
|
|
25198
|
+
exports.removeLogOverride = removeLogOverride;
|
|
24768
25199
|
exports.resetKosModel = resetKosModel;
|
|
24769
25200
|
exports.resolveBaseUrl = resolveBaseUrl;
|
|
24770
25201
|
exports.resolveChild = resolveChild;
|
|
@@ -24777,6 +25208,7 @@ exports.resolveListDeltas = resolveListDeltas;
|
|
|
24777
25208
|
exports.resolveServiceRequestParameters = resolveServiceRequestParameters;
|
|
24778
25209
|
exports.resolveServiceUrl = resolveServiceUrl;
|
|
24779
25210
|
exports.resolveTrouble = resolveTrouble;
|
|
25211
|
+
exports.retryWithExponentialBackoff = retryWithExponentialBackoff;
|
|
24780
25212
|
exports.sendAsyncIntent = sendAsyncIntent;
|
|
24781
25213
|
exports.sendBroadcastMessage = sendBroadcastMessage;
|
|
24782
25214
|
exports.sendCanvasData = sendCanvasData;
|
|
@@ -24784,6 +25216,7 @@ exports.sendIntent = sendIntent;
|
|
|
24784
25216
|
exports.sendKosHttpMessageResponse = sendKosHttpMessageResponse;
|
|
24785
25217
|
exports.sendKosMessage = sendKosMessage;
|
|
24786
25218
|
exports.sendKosMessageResponse = sendKosMessageResponse;
|
|
25219
|
+
exports.sendRequest = sendRequest;
|
|
24787
25220
|
exports.sendStudioMessage = sendStudioMessage;
|
|
24788
25221
|
exports.sendStudioMessageRequest = sendStudioMessageRequest;
|
|
24789
25222
|
exports.service = service;
|
|
@@ -24792,6 +25225,7 @@ exports.setTime = setTime;
|
|
|
24792
25225
|
exports.setTimezone = setTimezone;
|
|
24793
25226
|
exports.subscribe = subscribe;
|
|
24794
25227
|
exports.subscribeToLogStream = subscribeToLogStream;
|
|
25228
|
+
exports.syncPublish = syncPublish;
|
|
24795
25229
|
exports.troubleByTypeReducer = troubleByTypeReducer;
|
|
24796
25230
|
exports.troubleDataFactory = troubleDataFactory;
|
|
24797
25231
|
exports.unloadKosModel = unloadKosModel;
|
|
@@ -24800,6 +25234,8 @@ exports.updateKeyValue = updateKeyValue;
|
|
|
24800
25234
|
exports.uuid = uuid;
|
|
24801
25235
|
exports.waitForAppToStart = waitForAppToStart;
|
|
24802
25236
|
exports.waitForAppsToStart = waitForAppsToStart;
|
|
25237
|
+
exports.waitForRequest = waitForRequest;
|
|
24803
25238
|
exports.whenReady = whenReady;
|
|
25239
|
+
exports.withCancellation = withCancellation;
|
|
24804
25240
|
exports.wrapWithFutureLifecycle = wrapWithFutureLifecycle;
|
|
24805
|
-
//# sourceMappingURL=software-info-registration-
|
|
25241
|
+
//# sourceMappingURL=software-info-registration-CagrRzH8.cjs.map
|