@kosdev-code/kos-ui-sdk 0.1.0-next.979 → 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.d.ts +10 -6
- 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/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 +60 -312
- package/index.cjs.map +1 -1
- package/index.js +236 -488
- 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/key-value/services/key-value-services.d.ts.map +1 -1
- package/models/models/kos-log-manager/services/kos-log-manager-services.d.ts.map +1 -1
- 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/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/timer-manager.d.ts.map +1 -1
- package/package.json +3 -3
- package/{software-info-registration-Cbvzr2Q-.js → software-info-registration-Bz_s3zOp.js} +1244 -925
- package/software-info-registration-Bz_s3zOp.js.map +1 -0
- package/{software-info-registration-rg4pjrxg.cjs → software-info-registration-CagrRzH8.cjs} +978 -659
- 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-Cbvzr2Q-.js.map +0 -1
- package/software-info-registration-rg4pjrxg.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { makeAutoObservable, observable, makeObservable, action, createAtom, autorun, runInAction, observe, isComputedProp, reaction, ObservableMap, when, computed, isObservable } from "mobx";
|
|
2
|
-
import log$
|
|
2
|
+
import log$1h from "loglevel";
|
|
3
3
|
import { createMachine, invoke, transition, action as action$1, state, interpret, immediate } from "robot3";
|
|
4
4
|
import { format } from "date-fns";
|
|
5
5
|
const HEADER_METHOD = `method`;
|
|
@@ -26,7 +26,140 @@ var KosWsEvents = /* @__PURE__ */ ((KosWsEvents2) => {
|
|
|
26
26
|
return KosWsEvents2;
|
|
27
27
|
})(KosWsEvents || {});
|
|
28
28
|
const EVENT_KOS_MODEL_READY = "/kos/model/ready/";
|
|
29
|
-
|
|
29
|
+
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
30
|
+
const [key, val] = pair.split("=");
|
|
31
|
+
return [key, decodeURIComponent(val || "")];
|
|
32
|
+
}).reduce((result, [key, val]) => {
|
|
33
|
+
result[key] = val;
|
|
34
|
+
return result;
|
|
35
|
+
}, {});
|
|
36
|
+
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
37
|
+
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
38
|
+
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
39
|
+
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
40
|
+
const PROFILE_LOG_INFO = "studio.log.info";
|
|
41
|
+
const defaultConfig = {
|
|
42
|
+
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
43
|
+
};
|
|
44
|
+
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
45
|
+
const configObj = JSON.parse(config);
|
|
46
|
+
const urlProfiles = () => {
|
|
47
|
+
if (typeof window === "undefined") {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const value = getQueryParams()?.["kosProfiles"];
|
|
51
|
+
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
52
|
+
};
|
|
53
|
+
configObj.profiles = [
|
|
54
|
+
...configObj.profiles ?? [],
|
|
55
|
+
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
56
|
+
];
|
|
57
|
+
globalThis.kosConfig = configObj;
|
|
58
|
+
const KosGlobalConfig = configObj;
|
|
59
|
+
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
60
|
+
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
61
|
+
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
62
|
+
const resolveLogLevelProfile = () => {
|
|
63
|
+
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
64
|
+
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
65
|
+
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
66
|
+
};
|
|
67
|
+
const getLogLevel = () => {
|
|
68
|
+
const params2 = getQueryParams();
|
|
69
|
+
const profileLogLevel = resolveLogLevelProfile();
|
|
70
|
+
const logLevelParam = params2["kosLogLevel"];
|
|
71
|
+
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
72
|
+
if (logLevel) {
|
|
73
|
+
return logLevel;
|
|
74
|
+
}
|
|
75
|
+
return "WARN";
|
|
76
|
+
};
|
|
77
|
+
const LogGroup = {
|
|
78
|
+
core: "core",
|
|
79
|
+
transport: "transport",
|
|
80
|
+
model: "model",
|
|
81
|
+
service: "service",
|
|
82
|
+
ui: "ui"
|
|
83
|
+
};
|
|
84
|
+
const UI_GROUP_OVERRIDE = "ui:group";
|
|
85
|
+
const UI_LOGGER_OVERRIDE = "ui:logger";
|
|
86
|
+
const LEVELS = ["trace", "debug", "info", "warn", "error"];
|
|
87
|
+
const getLoggerGroup = (loggerName) => {
|
|
88
|
+
const grouped = loggerName.indexOf(":::");
|
|
89
|
+
if (grouped >= 0) {
|
|
90
|
+
return loggerName.slice(0, grouped);
|
|
91
|
+
}
|
|
92
|
+
const ungrouped = loggerName.indexOf("::");
|
|
93
|
+
return ungrouped >= 0 ? loggerName.slice(0, ungrouped) : "";
|
|
94
|
+
};
|
|
95
|
+
const matchesPattern = (value, pattern) => {
|
|
96
|
+
const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
97
|
+
return new RegExp(`^${source}$`).test(value);
|
|
98
|
+
};
|
|
99
|
+
const matches = (loggerName, override) => {
|
|
100
|
+
const wildcard = override.name.includes("*");
|
|
101
|
+
if (override.type === UI_GROUP_OVERRIDE) {
|
|
102
|
+
const group = getLoggerGroup(loggerName);
|
|
103
|
+
return wildcard ? matchesPattern(group, override.name) : group === override.name;
|
|
104
|
+
}
|
|
105
|
+
if (override.type === UI_LOGGER_OVERRIDE) {
|
|
106
|
+
return wildcard ? matchesPattern(loggerName, override.name) : loggerName.startsWith(override.name);
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
};
|
|
110
|
+
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];
|
|
111
|
+
const MESSAGE_LOGGER_NAME = "messages";
|
|
112
|
+
const MESSAGE_LOGGER = `${LogGroup.transport}:::${MESSAGE_LOGGER_NAME}`;
|
|
113
|
+
const originalFactory = log$1h.methodFactory;
|
|
114
|
+
log$1h.methodFactory = function(methodName, logLevel, loggerName) {
|
|
115
|
+
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
116
|
+
return function(...args) {
|
|
117
|
+
const _name = loggerName ? String(loggerName) : "";
|
|
118
|
+
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
119
|
+
const message = args.map(
|
|
120
|
+
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
121
|
+
).join(" ");
|
|
122
|
+
rawMethod(`${prefix}${message}`);
|
|
123
|
+
if (globalThis?.kosConfig?.logging && globalThis.kosLog && loggerName !== MESSAGE_LOGGER) {
|
|
124
|
+
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
let level = getLogLevel();
|
|
129
|
+
log$1h.setLevel(level);
|
|
130
|
+
window.setKosLogLevel = (_level) => {
|
|
131
|
+
level = _level;
|
|
132
|
+
log$1h.setLevel(_level);
|
|
133
|
+
};
|
|
134
|
+
const conditionallyLog = (level2) => (fn, logger = log$1h) => {
|
|
135
|
+
if (logger.getLevel() <= level2) {
|
|
136
|
+
fn();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const createLogger = ({ name, group }) => {
|
|
140
|
+
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
141
|
+
const _log = log$1h.getLogger(loggerName);
|
|
142
|
+
const _level = resolveOverrideLevel(
|
|
143
|
+
loggerName,
|
|
144
|
+
globalThis.kos?.logOverrides ?? []
|
|
145
|
+
);
|
|
146
|
+
if (_level) {
|
|
147
|
+
_log.setLevel(_level);
|
|
148
|
+
}
|
|
149
|
+
return _log;
|
|
150
|
+
};
|
|
151
|
+
const KosLog = {
|
|
152
|
+
...log$1h,
|
|
153
|
+
ifDebug: conditionallyLog(log$1h.levels.DEBUG),
|
|
154
|
+
ifInfo: conditionallyLog(log$1h.levels.INFO),
|
|
155
|
+
ifWarn: conditionallyLog(log$1h.levels.WARN),
|
|
156
|
+
ifError: conditionallyLog(log$1h.levels.ERROR),
|
|
157
|
+
getLogger: (name) => createLogger({ name }),
|
|
158
|
+
getLoggers: () => log$1h.getLoggers(),
|
|
159
|
+
createLogger
|
|
160
|
+
};
|
|
161
|
+
const log$1g = KosLog.createLogger({ group: LogGroup.core, name: "event-bus" });
|
|
162
|
+
log$1g.info("Initializing event bus");
|
|
30
163
|
globalThis.kos = globalThis.kos || {};
|
|
31
164
|
globalThis.kos.subscriptions = globalThis.kos.subscriptions || {};
|
|
32
165
|
const subscriptions = globalThis.kos.subscriptions;
|
|
@@ -37,15 +170,15 @@ function hasEventSubscriptions(eventType) {
|
|
|
37
170
|
function subscribe(eventType, callback) {
|
|
38
171
|
const id = getNextUniqueId();
|
|
39
172
|
if (!subscriptions[eventType]) {
|
|
40
|
-
log$
|
|
173
|
+
log$1g.debug(`Initializing subscription for ${eventType}`);
|
|
41
174
|
subscriptions[eventType] = {};
|
|
42
175
|
}
|
|
43
|
-
log$
|
|
176
|
+
log$1g.debug(`Subscribing to ${eventType} with id ${id.toString()}`);
|
|
44
177
|
subscriptions[eventType][id] = callback;
|
|
45
178
|
return {
|
|
46
179
|
count: subscriptions[eventType] ? Object.getOwnPropertySymbols(subscriptions[eventType]).length : 0,
|
|
47
180
|
unsubscribe: () => {
|
|
48
|
-
log$
|
|
181
|
+
log$1g.debug(`Unsubscribing from ${eventType} with id ${id.toString()}`);
|
|
49
182
|
if (subscriptions[eventType] && subscriptions[eventType][id]) {
|
|
50
183
|
delete subscriptions[eventType][id];
|
|
51
184
|
}
|
|
@@ -60,7 +193,7 @@ function subscribe(eventType, callback) {
|
|
|
60
193
|
}
|
|
61
194
|
function publish(eventType, msg, headers = {}) {
|
|
62
195
|
if (!subscriptions[eventType] || Object.getOwnPropertySymbols(subscriptions[eventType]).length === 0) {
|
|
63
|
-
log$
|
|
196
|
+
log$1g.debug(`No subscriptions for ${eventType}. Not publishing.`);
|
|
64
197
|
return {
|
|
65
198
|
eventType,
|
|
66
199
|
subscribers: 0
|
|
@@ -70,19 +203,19 @@ function publish(eventType, msg, headers = {}) {
|
|
|
70
203
|
Object.getOwnPropertySymbols(subscriptions[eventType]).forEach((id) => {
|
|
71
204
|
if (headers["sync"]) {
|
|
72
205
|
const responseId = headers["sync"];
|
|
73
|
-
log$
|
|
206
|
+
log$1g.debug(
|
|
74
207
|
`Performing sync publish for ${eventType} with sync id ${responseId}`
|
|
75
208
|
);
|
|
76
209
|
subscriptions[eventType][id]({ body: msg, headers }).then(
|
|
77
210
|
(response) => {
|
|
78
|
-
log$
|
|
211
|
+
log$1g.debug(
|
|
79
212
|
`Response recieved for ${responseId}, publishing back to source.`
|
|
80
213
|
);
|
|
81
214
|
publish(responseId, response);
|
|
82
215
|
}
|
|
83
216
|
);
|
|
84
217
|
} else {
|
|
85
|
-
log$
|
|
218
|
+
log$1g.debug(`Performing async publish for ${eventType}`);
|
|
86
219
|
subscriptions[eventType][id]({ body: msg, headers });
|
|
87
220
|
}
|
|
88
221
|
});
|
|
@@ -92,7 +225,7 @@ function publish(eventType, msg, headers = {}) {
|
|
|
92
225
|
};
|
|
93
226
|
}
|
|
94
227
|
function reset() {
|
|
95
|
-
log$
|
|
228
|
+
log$1g.warn("Resetting event bus");
|
|
96
229
|
Object.keys(subscriptions).forEach((key) => delete subscriptions[key]);
|
|
97
230
|
}
|
|
98
231
|
function once(eventType, callback) {
|
|
@@ -408,185 +541,11 @@ const eventBus_state = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defi
|
|
|
408
541
|
waitForAllWithState,
|
|
409
542
|
waitForOrGetState
|
|
410
543
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
411
|
-
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
412
|
-
const [key, val] = pair.split("=");
|
|
413
|
-
return [key, decodeURIComponent(val || "")];
|
|
414
|
-
}).reduce((result, [key, val]) => {
|
|
415
|
-
result[key] = val;
|
|
416
|
-
return result;
|
|
417
|
-
}, {});
|
|
418
|
-
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
419
|
-
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
420
|
-
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
421
|
-
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
422
|
-
const PROFILE_LOG_INFO = "studio.log.info";
|
|
423
|
-
const defaultConfig = {
|
|
424
|
-
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
425
|
-
};
|
|
426
|
-
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
427
|
-
const configObj = JSON.parse(config);
|
|
428
|
-
const urlProfiles = () => {
|
|
429
|
-
if (typeof window === "undefined") {
|
|
430
|
-
return [];
|
|
431
|
-
}
|
|
432
|
-
const value = getQueryParams()?.["kosProfiles"];
|
|
433
|
-
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
434
|
-
};
|
|
435
|
-
configObj.profiles = [
|
|
436
|
-
...configObj.profiles ?? [],
|
|
437
|
-
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
438
|
-
];
|
|
439
|
-
globalThis.kosConfig = configObj;
|
|
440
|
-
const KosGlobalConfig = configObj;
|
|
441
|
-
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
442
|
-
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
443
|
-
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
444
|
-
const resolveLogLevelProfile = () => {
|
|
445
|
-
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
446
|
-
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
447
|
-
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
448
|
-
};
|
|
449
|
-
const getLogLevel = () => {
|
|
450
|
-
const params2 = getQueryParams();
|
|
451
|
-
const profileLogLevel = resolveLogLevelProfile();
|
|
452
|
-
const logLevelParam = params2["kosLogLevel"];
|
|
453
|
-
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
454
|
-
if (logLevel) {
|
|
455
|
-
return logLevel;
|
|
456
|
-
}
|
|
457
|
-
return "WARN";
|
|
458
|
-
};
|
|
459
|
-
const getKosMessageLogging = () => {
|
|
460
|
-
const enableAll = window.kosMessageLogging || process.env.KOS_MESSAGE_LOGGING === "true";
|
|
461
|
-
return enableAll;
|
|
462
|
-
};
|
|
463
|
-
const getLogMessageToStudio = () => {
|
|
464
|
-
const enableAll = window.kosMessageStudioLogging || process.env.KOS_MESSAGE_STUDIO_LOGGING === "true";
|
|
465
|
-
return enableAll;
|
|
466
|
-
};
|
|
467
|
-
const UI_GROUP_OVERRIDE = "ui:group";
|
|
468
|
-
const UI_LOGGER_OVERRIDE = "ui:logger";
|
|
469
|
-
const LEVELS = ["trace", "debug", "info", "warn", "error"];
|
|
470
|
-
const getLoggerGroup = (loggerName) => {
|
|
471
|
-
const grouped = loggerName.indexOf(":::");
|
|
472
|
-
if (grouped >= 0) {
|
|
473
|
-
return loggerName.slice(0, grouped);
|
|
474
|
-
}
|
|
475
|
-
const ungrouped = loggerName.indexOf("::");
|
|
476
|
-
return ungrouped >= 0 ? loggerName.slice(0, ungrouped) : "";
|
|
477
|
-
};
|
|
478
|
-
const matchesPattern = (value, pattern) => {
|
|
479
|
-
const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
480
|
-
return new RegExp(`^${source}$`).test(value);
|
|
481
|
-
};
|
|
482
|
-
const matches = (loggerName, override) => {
|
|
483
|
-
const wildcard = override.name.includes("*");
|
|
484
|
-
if (override.type === UI_GROUP_OVERRIDE) {
|
|
485
|
-
const group = getLoggerGroup(loggerName);
|
|
486
|
-
return wildcard ? matchesPattern(group, override.name) : group === override.name;
|
|
487
|
-
}
|
|
488
|
-
if (override.type === UI_LOGGER_OVERRIDE) {
|
|
489
|
-
return wildcard ? matchesPattern(loggerName, override.name) : loggerName.startsWith(override.name);
|
|
490
|
-
}
|
|
491
|
-
return false;
|
|
492
|
-
};
|
|
493
|
-
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];
|
|
494
|
-
const WS_LOG = "ws-log";
|
|
495
|
-
const originalFactory = log$M.methodFactory;
|
|
496
|
-
const enableMessageLogging = getKosMessageLogging();
|
|
497
|
-
const enableStudioMessageLogging = getLogMessageToStudio();
|
|
498
|
-
log$M.methodFactory = function(methodName, logLevel, loggerName) {
|
|
499
|
-
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
500
|
-
return function(...args) {
|
|
501
|
-
const _name = loggerName ? String(loggerName) : "";
|
|
502
|
-
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
503
|
-
const message = args.map(
|
|
504
|
-
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
505
|
-
).join(" ");
|
|
506
|
-
rawMethod(`${prefix}${message}`);
|
|
507
|
-
if (globalThis?.kosConfig?.logging && globalThis.kosLog && (loggerName !== WS_LOG || enableMessageLogging && enableStudioMessageLogging)) {
|
|
508
|
-
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
};
|
|
512
|
-
let level = getLogLevel();
|
|
513
|
-
log$M.setLevel(level);
|
|
514
|
-
window.setKosLogLevel = (_level) => {
|
|
515
|
-
level = _level;
|
|
516
|
-
log$M.setLevel(_level);
|
|
517
|
-
};
|
|
518
|
-
const wsLog = log$M.getLogger(WS_LOG);
|
|
519
|
-
window.enableKosMessageLog = () => {
|
|
520
|
-
wsLog.setLevel(log$M.levels.INFO);
|
|
521
|
-
};
|
|
522
|
-
window.disableKosMessageLog = () => {
|
|
523
|
-
wsLog.setLevel(log$M.levels.ERROR);
|
|
524
|
-
};
|
|
525
|
-
if (enableMessageLogging) {
|
|
526
|
-
window.enableKosMessageLog();
|
|
527
|
-
} else {
|
|
528
|
-
window.disableKosMessageLog();
|
|
529
|
-
}
|
|
530
|
-
const styles = [
|
|
531
|
-
"color: black",
|
|
532
|
-
"display: block",
|
|
533
|
-
"background-color: lightgreen",
|
|
534
|
-
"padding: 4px",
|
|
535
|
-
"margin: 0",
|
|
536
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
537
|
-
"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",
|
|
538
|
-
"font-weight: bold"
|
|
539
|
-
].join(";");
|
|
540
|
-
const received = [
|
|
541
|
-
"color: black",
|
|
542
|
-
"display: block",
|
|
543
|
-
"padding: 4px",
|
|
544
|
-
"background-color: yellow",
|
|
545
|
-
"margin: 0",
|
|
546
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
547
|
-
"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",
|
|
548
|
-
"font-weight: bold"
|
|
549
|
-
].join(";");
|
|
550
|
-
const conditionallyLog = (level2) => (fn) => {
|
|
551
|
-
if (log$M.getLevel() <= level2) {
|
|
552
|
-
fn();
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
const KosLog = {
|
|
556
|
-
...log$M,
|
|
557
|
-
ifDebug: conditionallyLog(log$M.levels.DEBUG),
|
|
558
|
-
ifInfo: conditionallyLog(log$M.levels.INFO),
|
|
559
|
-
ifWarn: conditionallyLog(log$M.levels.WARN),
|
|
560
|
-
ifError: conditionallyLog(log$M.levels.ERROR),
|
|
561
|
-
getLogger: (name) => log$M.getLogger(`kos::${name}`),
|
|
562
|
-
getLoggers: () => log$M.getLoggers(),
|
|
563
|
-
createLogger: ({ name, group }) => {
|
|
564
|
-
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
565
|
-
const _log = log$M.getLogger(loggerName);
|
|
566
|
-
const _level = resolveOverrideLevel(
|
|
567
|
-
loggerName,
|
|
568
|
-
globalThis.kos?.logOverrides ?? []
|
|
569
|
-
);
|
|
570
|
-
if (_level) {
|
|
571
|
-
_log.setLevel(_level);
|
|
572
|
-
}
|
|
573
|
-
return _log;
|
|
574
|
-
},
|
|
575
|
-
wsSend: (...msg) => {
|
|
576
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
577
|
-
wsLog.info(`%c⬆ ${str}`, styles);
|
|
578
|
-
},
|
|
579
|
-
wsReceive: (...msg) => {
|
|
580
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
581
|
-
wsLog.info(`%c⬇ ${str}`, received);
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
544
|
const SubscriptionHandlers = /* @__PURE__ */ Symbol(`SubscriptionHandlers`);
|
|
585
545
|
const DependencyModels = /* @__PURE__ */ Symbol(`DependencyModels`);
|
|
586
546
|
const FutureService = /* @__PURE__ */ Symbol(`FutureService`);
|
|
587
547
|
const ChildModels = /* @__PURE__ */ Symbol(`ChildModels`);
|
|
588
548
|
const ParentModel = /* @__PURE__ */ Symbol(`ParentModel`);
|
|
589
|
-
const LogConfig = /* @__PURE__ */ Symbol(`LogConfig`);
|
|
590
549
|
const ReferenceConfig = /* @__PURE__ */ Symbol(`ReferenceConfig`);
|
|
591
550
|
const KosModelSymbol = /* @__PURE__ */ Symbol(`KosModelSymbol`);
|
|
592
551
|
const ModelEffects = /* @__PURE__ */ Symbol(`ModelEffects`);
|
|
@@ -608,7 +567,7 @@ const KosViewModelSymbol = /* @__PURE__ */ Symbol(`KosViewModelSymbol`);
|
|
|
608
567
|
const ViewModelConfig = /* @__PURE__ */ Symbol(`ViewModelConfig`);
|
|
609
568
|
const ReloadAwareSetup = /* @__PURE__ */ Symbol(`ReloadAwareSetup`);
|
|
610
569
|
const MixinModels = /* @__PURE__ */ Symbol(`MixinModels`);
|
|
611
|
-
const log$
|
|
570
|
+
const log$1f = KosLog.createLogger({ group: LogGroup.core, name: "fsm-injection" });
|
|
612
571
|
function injectStateMachineSupport(modelInstance) {
|
|
613
572
|
const fsmSetup = modelInstance[StateMachineSetup];
|
|
614
573
|
if (!fsmSetup) return;
|
|
@@ -652,7 +611,7 @@ function initializeFsmProperties(modelInstance, options) {
|
|
|
652
611
|
const config2 = modelInstance._fsmConfig;
|
|
653
612
|
const initialState = computeInitialState ? computeInitialState(modelInstance) : config2.initial;
|
|
654
613
|
if (computeInitialState && !config2.states[initialState]) {
|
|
655
|
-
log$
|
|
614
|
+
log$1f.warn(
|
|
656
615
|
`computeInitialState returned "${initialState}" which is not a valid state. Falling back to "${config2.initial}".`
|
|
657
616
|
);
|
|
658
617
|
modelInstance[stateProperty] = config2.initial;
|
|
@@ -782,7 +741,7 @@ function handleAsyncEntryResult(instance, state2, stateProperty, result) {
|
|
|
782
741
|
if (stateConfig.onError && instance[stateProperty] === state2) {
|
|
783
742
|
instance.transition(stateConfig.onError);
|
|
784
743
|
} else {
|
|
785
|
-
log$
|
|
744
|
+
log$1f.error(`Async entry handler for state "${state2}" failed:`, err);
|
|
786
745
|
}
|
|
787
746
|
}
|
|
788
747
|
);
|
|
@@ -823,7 +782,7 @@ function initializeStateMachine(modelInstance, lifecycle) {
|
|
|
823
782
|
modelInstance._fsmInitialized = true;
|
|
824
783
|
trackInitialStateInHistory(modelInstance, config2.initial, options);
|
|
825
784
|
executeInitialStateEntryHandler(modelInstance, config2.initial);
|
|
826
|
-
log$
|
|
785
|
+
log$1f.debug(
|
|
827
786
|
`FSM initialized for model ${modelInstance.id} at lifecycle ${lifecycle} with initial state "${config2.initial}"`
|
|
828
787
|
);
|
|
829
788
|
}
|
|
@@ -947,9 +906,12 @@ function getHttpRouteHandlers(model) {
|
|
|
947
906
|
return model?.[HttpRouteHandlers] || [];
|
|
948
907
|
}
|
|
949
908
|
class KosLoggerFactory {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
909
|
+
/**
|
|
910
|
+
* The logger for a model type, `model:::{modelTypeName}`. Every instance of
|
|
911
|
+
* the type shares it; put the instance id in the message where it matters.
|
|
912
|
+
*/
|
|
913
|
+
static create({ modelTypeName }) {
|
|
914
|
+
return KosLog.createLogger({ group: LogGroup.model, name: modelTypeName });
|
|
953
915
|
}
|
|
954
916
|
}
|
|
955
917
|
function kosLoggerAware(options) {
|
|
@@ -967,8 +929,7 @@ function kosLoggerAware(options) {
|
|
|
967
929
|
if (!sharedLogger) {
|
|
968
930
|
const modelType = getModelType();
|
|
969
931
|
sharedLogger = KosLoggerFactory.create({
|
|
970
|
-
modelTypeName: loggerContext || modelType
|
|
971
|
-
component: "kos-model"
|
|
932
|
+
modelTypeName: loggerContext || modelType
|
|
972
933
|
});
|
|
973
934
|
}
|
|
974
935
|
return sharedLogger;
|
|
@@ -1019,7 +980,7 @@ class ServiceRequestError extends Error {
|
|
|
1019
980
|
this.responseHeaders = details.responseHeaders ?? {};
|
|
1020
981
|
}
|
|
1021
982
|
}
|
|
1022
|
-
const log$
|
|
983
|
+
const log$1e = KosLog.createLogger({ group: LogGroup.core, name: "resolve-parameters" });
|
|
1023
984
|
const resolveParameters = ({
|
|
1024
985
|
value,
|
|
1025
986
|
modelId,
|
|
@@ -1051,11 +1012,11 @@ const resolveParameters = ({
|
|
|
1051
1012
|
)) {
|
|
1052
1013
|
const prop = modelData[propName];
|
|
1053
1014
|
if (prop !== null && prop !== void 0) {
|
|
1054
|
-
log$
|
|
1015
|
+
log$1e.debug(`Resolved ${match} to ${prop}`);
|
|
1055
1016
|
return prop;
|
|
1056
1017
|
} else {
|
|
1057
1018
|
const logLevel2 = isOnlyPropKey ? "debug" : "warn";
|
|
1058
|
-
log$
|
|
1019
|
+
log$1e[logLevel2](
|
|
1059
1020
|
`Property ${propName} is null or undefined${isOnlyPropKey ? "" : " in composite string"}, marking for undefined return`
|
|
1060
1021
|
);
|
|
1061
1022
|
hasUnresolvedProp = true;
|
|
@@ -1063,7 +1024,7 @@ const resolveParameters = ({
|
|
|
1063
1024
|
}
|
|
1064
1025
|
}
|
|
1065
1026
|
const logLevel = isOnlyPropKey ? "debug" : "warn";
|
|
1066
|
-
log$
|
|
1027
|
+
log$1e[logLevel](
|
|
1067
1028
|
`Property ${propName} not found in modelData${isOnlyPropKey ? "" : " for composite string"}`
|
|
1068
1029
|
);
|
|
1069
1030
|
return match;
|
|
@@ -1078,7 +1039,7 @@ const resolveParameters = ({
|
|
|
1078
1039
|
}
|
|
1079
1040
|
return _value;
|
|
1080
1041
|
};
|
|
1081
|
-
const log$
|
|
1042
|
+
const log$1d = KosLog.createLogger({ group: LogGroup.core, name: "ServiceRequestHelpers" });
|
|
1082
1043
|
function resolveServiceRequestParameters(metadata, modelInstance, args, runtimeOptions) {
|
|
1083
1044
|
const resolvedPath = resolveParameters({
|
|
1084
1045
|
value: metadata.path,
|
|
@@ -1147,7 +1108,7 @@ function handleServiceRequestError(error, response, errorHandler, modelInstance,
|
|
|
1147
1108
|
});
|
|
1148
1109
|
switch (errorHandler.strategy) {
|
|
1149
1110
|
case "log":
|
|
1150
|
-
log$
|
|
1111
|
+
log$1d.error(`Service request status ${richError.status} error: ${error}`);
|
|
1151
1112
|
if (errorHandler.onError) {
|
|
1152
1113
|
errorHandler.onError(richError, modelInstance);
|
|
1153
1114
|
}
|
|
@@ -1260,7 +1221,7 @@ var ReplayStrategy = /* @__PURE__ */ ((ReplayStrategy2) => {
|
|
|
1260
1221
|
ReplayStrategy2["NONE"] = "none";
|
|
1261
1222
|
return ReplayStrategy2;
|
|
1262
1223
|
})(ReplayStrategy || {});
|
|
1263
|
-
const log$
|
|
1224
|
+
const log$1c = KosLog.createLogger({ group: LogGroup.core, name: "kos-state-machine" });
|
|
1264
1225
|
function kosStateMachine(config2, options) {
|
|
1265
1226
|
return (target) => {
|
|
1266
1227
|
target.prototype[StateMachineSetup] = {
|
|
@@ -1317,7 +1278,7 @@ function kosStateGuard(options) {
|
|
|
1317
1278
|
if (shouldThrow) {
|
|
1318
1279
|
throw new Error(message);
|
|
1319
1280
|
} else {
|
|
1320
|
-
log$
|
|
1281
|
+
log$1c.warn(message);
|
|
1321
1282
|
return void 0;
|
|
1322
1283
|
}
|
|
1323
1284
|
}
|
|
@@ -1343,6 +1304,10 @@ const kosDependency = ({
|
|
|
1343
1304
|
resolutionPolicy
|
|
1344
1305
|
};
|
|
1345
1306
|
};
|
|
1307
|
+
const log$1b = KosLog.createLogger({
|
|
1308
|
+
group: LogGroup.model,
|
|
1309
|
+
name: "future-aware"
|
|
1310
|
+
});
|
|
1346
1311
|
class MultipleFutureHandler {
|
|
1347
1312
|
futures;
|
|
1348
1313
|
defaultContext;
|
|
@@ -1433,7 +1398,7 @@ class FutureHandler {
|
|
|
1433
1398
|
try {
|
|
1434
1399
|
await this._future.cancelFuture();
|
|
1435
1400
|
} catch (e) {
|
|
1436
|
-
|
|
1401
|
+
log$1b.error(e);
|
|
1437
1402
|
throw e;
|
|
1438
1403
|
}
|
|
1439
1404
|
}
|
|
@@ -1558,6 +1523,10 @@ const ObservableData = (initialData) => {
|
|
|
1558
1523
|
const od = createObservableData(ObservableDataMap, initialData);
|
|
1559
1524
|
return new od(initialData);
|
|
1560
1525
|
};
|
|
1526
|
+
const log$1a = KosLog.createLogger({
|
|
1527
|
+
group: LogGroup.core,
|
|
1528
|
+
name: "extension-manager"
|
|
1529
|
+
});
|
|
1561
1530
|
const DEFAULT_EXTENSION_OPTIONS = {
|
|
1562
1531
|
failurePolicy: "throw"
|
|
1563
1532
|
};
|
|
@@ -1609,8 +1578,8 @@ const _ExtensionManager = {
|
|
|
1609
1578
|
return await loader(data);
|
|
1610
1579
|
} catch (e) {
|
|
1611
1580
|
if (options.failurePolicy === "continue") {
|
|
1612
|
-
|
|
1613
|
-
|
|
1581
|
+
log$1a.error(`Error executing data loader for id ${id}`);
|
|
1582
|
+
log$1a.error(e);
|
|
1614
1583
|
return void 0;
|
|
1615
1584
|
}
|
|
1616
1585
|
throw new ExtensionException(id, "dataLoader", e);
|
|
@@ -1635,8 +1604,8 @@ const _ExtensionManager = {
|
|
|
1635
1604
|
return mapper(data, context);
|
|
1636
1605
|
} catch (e) {
|
|
1637
1606
|
if (options.failurePolicy === "continue") {
|
|
1638
|
-
|
|
1639
|
-
|
|
1607
|
+
log$1a.error(`Error executing property mapper for id ${id}`);
|
|
1608
|
+
log$1a.error(e);
|
|
1640
1609
|
return "";
|
|
1641
1610
|
}
|
|
1642
1611
|
throw new ExtensionException(id, "propertyMapper", e);
|
|
@@ -1664,8 +1633,8 @@ const _ExtensionManager = {
|
|
|
1664
1633
|
Object.assign(result, _interim);
|
|
1665
1634
|
} catch (e) {
|
|
1666
1635
|
if (options.failurePolicy === "continue") {
|
|
1667
|
-
|
|
1668
|
-
|
|
1636
|
+
log$1a.error(`Error executing data mapper for id ${id}`);
|
|
1637
|
+
log$1a.error(e);
|
|
1669
1638
|
continue;
|
|
1670
1639
|
}
|
|
1671
1640
|
throw new ExtensionException(id, "dataMapper", e);
|
|
@@ -1677,7 +1646,7 @@ const _ExtensionManager = {
|
|
|
1677
1646
|
canvas: {
|
|
1678
1647
|
registerRenderer: (id, renderer) => {
|
|
1679
1648
|
if (!ExtensionManager[EXTENSION_CANVAS_RENDERER]) {
|
|
1680
|
-
|
|
1649
|
+
log$1a.warn(
|
|
1681
1650
|
`Canvas renderer extension point is not registered. Cannot register renderer "${id}".`
|
|
1682
1651
|
);
|
|
1683
1652
|
return;
|
|
@@ -1703,6 +1672,10 @@ const INDEX_COLLECTION_KEY = "@kosdev-code/kos-ui-sdk.collection";
|
|
|
1703
1672
|
function isIndexableItem(value) {
|
|
1704
1673
|
return typeof value === "object" && value !== null && INDEX_RECORD_SYMBOL in value;
|
|
1705
1674
|
}
|
|
1675
|
+
const log$19 = KosLog.createLogger({
|
|
1676
|
+
group: LogGroup.core,
|
|
1677
|
+
name: "kos-container-index"
|
|
1678
|
+
});
|
|
1706
1679
|
function isPromiseLike(value) {
|
|
1707
1680
|
return typeof value?.then === "function";
|
|
1708
1681
|
}
|
|
@@ -1754,7 +1727,7 @@ class KosContainerIndex {
|
|
|
1754
1727
|
const set = map.get(key) || /* @__PURE__ */ new Set();
|
|
1755
1728
|
this._map.set(key, set);
|
|
1756
1729
|
} else {
|
|
1757
|
-
|
|
1730
|
+
log$19.debug(`KosContainerIndex - Index ${key} is the same`);
|
|
1758
1731
|
}
|
|
1759
1732
|
});
|
|
1760
1733
|
}
|
|
@@ -1830,7 +1803,7 @@ function observeComputedProperties(model, callback, keys = []) {
|
|
|
1830
1803
|
);
|
|
1831
1804
|
return disposers;
|
|
1832
1805
|
}
|
|
1833
|
-
const log$
|
|
1806
|
+
const log$18 = KosLog.createLogger({ group: LogGroup.core, name: "kos-container-model" });
|
|
1834
1807
|
class KosModelContainer {
|
|
1835
1808
|
_data;
|
|
1836
1809
|
_sortKey;
|
|
@@ -1952,14 +1925,14 @@ class KosModelContainer {
|
|
|
1952
1925
|
async removeAndDestroy(id) {
|
|
1953
1926
|
const model = this.getModel(id);
|
|
1954
1927
|
if (!model) {
|
|
1955
|
-
log$
|
|
1928
|
+
log$18.debug(`Model ${id} not found in container, skipping destroy`);
|
|
1956
1929
|
return;
|
|
1957
1930
|
}
|
|
1958
1931
|
this.removeModel(id);
|
|
1959
1932
|
try {
|
|
1960
1933
|
await destroyKosModel(model);
|
|
1961
1934
|
} catch (error) {
|
|
1962
|
-
log$
|
|
1935
|
+
log$18.error(`Failed to destroy model ${id}:`, error);
|
|
1963
1936
|
throw error;
|
|
1964
1937
|
}
|
|
1965
1938
|
}
|
|
@@ -1976,7 +1949,7 @@ class KosModelContainer {
|
|
|
1976
1949
|
async removeAndDestroyAll(ids) {
|
|
1977
1950
|
const models2 = ids.map((id) => this.getModel(id)).filter((model) => model !== void 0);
|
|
1978
1951
|
if (models2.length === 0) {
|
|
1979
|
-
log$
|
|
1952
|
+
log$18.debug("No models found to destroy");
|
|
1980
1953
|
return;
|
|
1981
1954
|
}
|
|
1982
1955
|
this.removeAll(ids);
|
|
@@ -1985,7 +1958,7 @@ class KosModelContainer {
|
|
|
1985
1958
|
);
|
|
1986
1959
|
results.forEach((result, index) => {
|
|
1987
1960
|
if (result.status === "rejected") {
|
|
1988
|
-
log$
|
|
1961
|
+
log$18.error(
|
|
1989
1962
|
`Failed to destroy model ${models2[index].id}:`,
|
|
1990
1963
|
result.reason
|
|
1991
1964
|
);
|
|
@@ -2158,7 +2131,7 @@ class KosModelContainer {
|
|
|
2158
2131
|
const idx = this.index.get(indexName);
|
|
2159
2132
|
return idx.keys ?? [];
|
|
2160
2133
|
} else {
|
|
2161
|
-
log$
|
|
2134
|
+
log$18.info(
|
|
2162
2135
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2163
2136
|
);
|
|
2164
2137
|
return [];
|
|
@@ -2170,7 +2143,7 @@ class KosModelContainer {
|
|
|
2170
2143
|
if (idx.index.has(indexKey)) {
|
|
2171
2144
|
return idx.getByKey(indexKey);
|
|
2172
2145
|
} else {
|
|
2173
|
-
log$
|
|
2146
|
+
log$18.info(
|
|
2174
2147
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
2175
2148
|
idx.index.keys()
|
|
2176
2149
|
)}`
|
|
@@ -2178,7 +2151,7 @@ class KosModelContainer {
|
|
|
2178
2151
|
return [];
|
|
2179
2152
|
}
|
|
2180
2153
|
} else {
|
|
2181
|
-
log$
|
|
2154
|
+
log$18.info(
|
|
2182
2155
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2183
2156
|
);
|
|
2184
2157
|
return [];
|
|
@@ -2205,7 +2178,7 @@ class KosModelContainer {
|
|
|
2205
2178
|
* @private
|
|
2206
2179
|
*/
|
|
2207
2180
|
_logCapacityWarning(toEvict) {
|
|
2208
|
-
log$
|
|
2181
|
+
log$18.info(
|
|
2209
2182
|
`Container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${toEvict} models using ${this._evictionStrategy} strategy.`,
|
|
2210
2183
|
{ parentId: this._parentId }
|
|
2211
2184
|
);
|
|
@@ -2268,7 +2241,7 @@ class KosModelContainer {
|
|
|
2268
2241
|
const candidates = this._customEvictionFilter(this.data);
|
|
2269
2242
|
return candidates.slice(0, count);
|
|
2270
2243
|
}
|
|
2271
|
-
log$
|
|
2244
|
+
log$18.error(
|
|
2272
2245
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO.",
|
|
2273
2246
|
{ parentId: this._parentId }
|
|
2274
2247
|
);
|
|
@@ -2280,7 +2253,7 @@ class KosModelContainer {
|
|
|
2280
2253
|
*/
|
|
2281
2254
|
async _removeEvictedModels(models2) {
|
|
2282
2255
|
for (const model of models2) {
|
|
2283
|
-
log$
|
|
2256
|
+
log$18.info(
|
|
2284
2257
|
`Evicting model: ${model.id} (type: ${model.constructor.name})`,
|
|
2285
2258
|
{
|
|
2286
2259
|
modelId: model.id,
|
|
@@ -2290,7 +2263,7 @@ class KosModelContainer {
|
|
|
2290
2263
|
);
|
|
2291
2264
|
this.removeModel(model.id, true);
|
|
2292
2265
|
destroyKosModel(model).catch(
|
|
2293
|
-
(e) => log$
|
|
2266
|
+
(e) => log$18.error(`Failed to destroy evicted model ${model.id}:`, e)
|
|
2294
2267
|
);
|
|
2295
2268
|
}
|
|
2296
2269
|
}
|
|
@@ -2299,7 +2272,7 @@ class KosModelContainer {
|
|
|
2299
2272
|
* @private
|
|
2300
2273
|
*/
|
|
2301
2274
|
_logEvictionComplete(evictedCount) {
|
|
2302
|
-
log$
|
|
2275
|
+
log$18.info(
|
|
2303
2276
|
`Evicted ${evictedCount} models. Current size: ${this._data.size}/${this._maxCapacity}`,
|
|
2304
2277
|
{ parentId: this._parentId }
|
|
2305
2278
|
);
|
|
@@ -2308,9 +2281,9 @@ class KosModelContainer {
|
|
|
2308
2281
|
this._data.forEach((model) => {
|
|
2309
2282
|
const modelId = model.id;
|
|
2310
2283
|
destroyKosModel(model).then(() => {
|
|
2311
|
-
log$
|
|
2284
|
+
log$18.debug(`${modelId} destroyed, removing from map`);
|
|
2312
2285
|
this.removeModel(modelId, true);
|
|
2313
|
-
}).catch((e) => log$
|
|
2286
|
+
}).catch((e) => log$18.error(e));
|
|
2314
2287
|
});
|
|
2315
2288
|
this.increment();
|
|
2316
2289
|
}
|
|
@@ -2453,12 +2426,16 @@ const whenReady = async (dataModel) => {
|
|
|
2453
2426
|
}
|
|
2454
2427
|
return dataModel;
|
|
2455
2428
|
};
|
|
2429
|
+
const log$17 = KosLog.createLogger({
|
|
2430
|
+
group: LogGroup.core,
|
|
2431
|
+
name: "kos-model-utils"
|
|
2432
|
+
});
|
|
2456
2433
|
const destroyKosModel = async (model) => {
|
|
2457
2434
|
await KosCore.getInstance().whenReady();
|
|
2458
2435
|
await KosCore.getInstance().modelManager.initiateDestroyModel(model);
|
|
2459
2436
|
};
|
|
2460
2437
|
const unloadKosModel = async (dataModel) => {
|
|
2461
|
-
|
|
2438
|
+
log$17.warn(
|
|
2462
2439
|
`unloadKosModel(${dataModel?.id}) is deprecated and never resolves. Use destroyKosModel() to release a model, or reload() to refresh it.`
|
|
2463
2440
|
);
|
|
2464
2441
|
await KosCore.getInstance().whenReady();
|
|
@@ -2471,16 +2448,16 @@ const unloadKosModel = async (dataModel) => {
|
|
|
2471
2448
|
}
|
|
2472
2449
|
};
|
|
2473
2450
|
const resetKosModel = async (model) => {
|
|
2474
|
-
|
|
2451
|
+
log$17.warn(
|
|
2475
2452
|
`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.`
|
|
2476
2453
|
);
|
|
2477
2454
|
await KosCore.getInstance().whenReady();
|
|
2478
2455
|
await KosCore.getInstance().modelManager.reloadModel(model);
|
|
2479
|
-
|
|
2456
|
+
log$17.debug(
|
|
2480
2457
|
`reload model initiated for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2481
2458
|
);
|
|
2482
2459
|
await whenReady(model);
|
|
2483
|
-
|
|
2460
|
+
log$17.debug(
|
|
2484
2461
|
`reload model complete for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2485
2462
|
);
|
|
2486
2463
|
};
|
|
@@ -2556,7 +2533,7 @@ const getObservableCompanions = (modelId) => {
|
|
|
2556
2533
|
const resolveKosCompanion = (modelId, resolver) => {
|
|
2557
2534
|
const model = KosCore.getInstance().modelManager.getModelById(modelId);
|
|
2558
2535
|
if (!model) {
|
|
2559
|
-
|
|
2536
|
+
log$17.info(`Model not found for id ${modelId}`);
|
|
2560
2537
|
return void 0;
|
|
2561
2538
|
}
|
|
2562
2539
|
const companionModel = Array.from(model.companionModels.all()).find(
|
|
@@ -2595,7 +2572,7 @@ const getKosModelActivationState = (model) => {
|
|
|
2595
2572
|
}
|
|
2596
2573
|
};
|
|
2597
2574
|
};
|
|
2598
|
-
const log$
|
|
2575
|
+
const log$16 = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-factory" });
|
|
2599
2576
|
const KosModelFactory = {
|
|
2600
2577
|
byModelType: (modelType) => KosCore.getInstance().modelManager.getModelFactory(
|
|
2601
2578
|
modelType
|
|
@@ -2603,7 +2580,7 @@ const KosModelFactory = {
|
|
|
2603
2580
|
getModelInstance: (id, modelType, options) => {
|
|
2604
2581
|
const factory = KosModelFactory.byModelType(modelType);
|
|
2605
2582
|
if (!factory) {
|
|
2606
|
-
log$
|
|
2583
|
+
log$16.error(
|
|
2607
2584
|
`No registered factory found for model type ${modelType}. Please register a factory for this model type. `
|
|
2608
2585
|
);
|
|
2609
2586
|
throw Error(`No factory found for model type ${modelType}`);
|
|
@@ -2642,6 +2619,10 @@ const Kos = {
|
|
|
2642
2619
|
instance: (modelType) => (id) => KosModelFactory.getModelInstance(id, modelType)
|
|
2643
2620
|
}
|
|
2644
2621
|
};
|
|
2622
|
+
const log$15 = KosLog.createLogger({
|
|
2623
|
+
group: LogGroup.core,
|
|
2624
|
+
name: "registration-manager"
|
|
2625
|
+
});
|
|
2645
2626
|
window.KosRegistry = window.KosRegistry || {
|
|
2646
2627
|
coreModels: /* @__PURE__ */ new Map(),
|
|
2647
2628
|
preloadModels: [],
|
|
@@ -2686,7 +2667,7 @@ const RegistrationManager = {
|
|
|
2686
2667
|
}
|
|
2687
2668
|
if (KosCore.getInstance().isReady) {
|
|
2688
2669
|
if (!KosCore.getInstance().modelManager.registry.models[register.type]) {
|
|
2689
|
-
|
|
2670
|
+
log$15.info(
|
|
2690
2671
|
`Model with type ${register.type} doesn't exist. Adding new registration`
|
|
2691
2672
|
);
|
|
2692
2673
|
KosCore.getInstance().modelManager.registry.models[register.type] = register.registration[register.type];
|
|
@@ -2918,7 +2899,7 @@ class SingletonKosModelRegistrationFactory extends KosBaseModelRegistration {
|
|
|
2918
2899
|
};
|
|
2919
2900
|
}
|
|
2920
2901
|
}
|
|
2921
|
-
const log$
|
|
2902
|
+
const log$14 = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
2922
2903
|
const FUTURE_CANCEL_END_STATE = "CANCEL";
|
|
2923
2904
|
function resolveParentContext(TargetClass, modelId, modelData) {
|
|
2924
2905
|
const parentIdRaw = TargetClass[ParentModel]?.parentId;
|
|
@@ -3213,7 +3194,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3213
3194
|
const { mode, parentProperty, excludeProperties } = companionConfig;
|
|
3214
3195
|
const parentModel = initialData.companionParent;
|
|
3215
3196
|
if (!parentModel) {
|
|
3216
|
-
log$
|
|
3197
|
+
log$14.warn(
|
|
3217
3198
|
`Companion decorator configured but no parent model found in initialData.companionParent`
|
|
3218
3199
|
);
|
|
3219
3200
|
return;
|
|
@@ -3287,7 +3268,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3287
3268
|
});
|
|
3288
3269
|
}
|
|
3289
3270
|
} catch (error) {
|
|
3290
|
-
log$
|
|
3271
|
+
log$14.debug(
|
|
3291
3272
|
`Skipping companion proxy for property ${propertyName}:`,
|
|
3292
3273
|
error
|
|
3293
3274
|
);
|
|
@@ -3324,7 +3305,7 @@ function makeSafeObservable(instance) {
|
|
|
3324
3305
|
try {
|
|
3325
3306
|
return makeAutoObservable(instance);
|
|
3326
3307
|
} catch (e) {
|
|
3327
|
-
log$
|
|
3308
|
+
log$14.error("Failed to make observable:", e);
|
|
3328
3309
|
return instance;
|
|
3329
3310
|
}
|
|
3330
3311
|
}
|
|
@@ -3334,9 +3315,8 @@ const modelConstructorProxy = {
|
|
|
3334
3315
|
const kosContext = KosContextManager.createContext(modelId);
|
|
3335
3316
|
resolveParentContext(TargetClass, modelId, initialData);
|
|
3336
3317
|
const hasLoggerAware = !!TargetClass.prototype[LoggerSetup];
|
|
3337
|
-
const logger = hasLoggerAware ? null :
|
|
3338
|
-
|
|
3339
|
-
group: TargetClass[LogConfig]?.group ?? "kos-model"
|
|
3318
|
+
const logger = hasLoggerAware ? null : KosLoggerFactory.create({
|
|
3319
|
+
modelTypeName: TargetClass.prototype.modelTypeId
|
|
3340
3320
|
});
|
|
3341
3321
|
const modelInstance = new TargetClass(modelId, initialData, {
|
|
3342
3322
|
logger,
|
|
@@ -3367,8 +3347,8 @@ function kosModel(config2) {
|
|
|
3367
3347
|
typedCtor.prototype[OptionsRequired] = true;
|
|
3368
3348
|
}
|
|
3369
3349
|
KosLog.ifDebug(() => {
|
|
3370
|
-
|
|
3371
|
-
});
|
|
3350
|
+
log$14.debug(`Registering model with id ${modelConfig.modelTypeId}`);
|
|
3351
|
+
}, log$14);
|
|
3372
3352
|
const proxiedCtor = new Proxy(typedCtor, modelConstructorProxy);
|
|
3373
3353
|
if (modelConfig.singleton !== void 0) {
|
|
3374
3354
|
let registration;
|
|
@@ -3664,7 +3644,7 @@ const KosDeletionManager = {
|
|
|
3664
3644
|
}
|
|
3665
3645
|
}
|
|
3666
3646
|
};
|
|
3667
|
-
const log$
|
|
3647
|
+
const log$13 = KosLog.createLogger({ group: LogGroup.core, name: "kos-dependency-manager" });
|
|
3668
3648
|
class KosDependencyManager {
|
|
3669
3649
|
_usedByCache = /* @__PURE__ */ new Map();
|
|
3670
3650
|
_usesCache = /* @__PURE__ */ new Map();
|
|
@@ -3719,7 +3699,7 @@ class KosDependencyManager {
|
|
|
3719
3699
|
canDestroy(modelId) {
|
|
3720
3700
|
const usedBy = this._usedByCache.get(modelId);
|
|
3721
3701
|
if (usedBy?.length) {
|
|
3722
|
-
log$
|
|
3702
|
+
log$13.info(`Model ${modelId} is still used by: ${usedBy.join(", ")}`);
|
|
3723
3703
|
return false;
|
|
3724
3704
|
}
|
|
3725
3705
|
return true;
|
|
@@ -3729,7 +3709,7 @@ class KosDependencyManager {
|
|
|
3729
3709
|
this._usesCache.clear();
|
|
3730
3710
|
}
|
|
3731
3711
|
}
|
|
3732
|
-
const log$
|
|
3712
|
+
const log$12 = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-cache" });
|
|
3733
3713
|
class KosModelCache {
|
|
3734
3714
|
constructor(preloadKeys = []) {
|
|
3735
3715
|
this.preloadKeys = preloadKeys;
|
|
@@ -3780,11 +3760,11 @@ class KosModelCache {
|
|
|
3780
3760
|
}
|
|
3781
3761
|
preload(createFn) {
|
|
3782
3762
|
if (this._isPreloaded) {
|
|
3783
|
-
log$
|
|
3763
|
+
log$12.debug("Returning cached preloaded models");
|
|
3784
3764
|
return this._preloaded;
|
|
3785
3765
|
}
|
|
3786
3766
|
this._preloaded = this.preloadKeys.map((key) => {
|
|
3787
|
-
log$
|
|
3767
|
+
log$12.debug(
|
|
3788
3768
|
`Preloading model: ${typeof key === "string" ? key : key.modelType}`
|
|
3789
3769
|
);
|
|
3790
3770
|
return createFn(key);
|
|
@@ -3806,6 +3786,10 @@ const clearModelHookCacheEntry = (modelId) => {
|
|
|
3806
3786
|
cache.delete(modelId);
|
|
3807
3787
|
}
|
|
3808
3788
|
};
|
|
3789
|
+
const log$11 = KosLog.createLogger({
|
|
3790
|
+
group: LogGroup.core,
|
|
3791
|
+
name: "model-error-utils"
|
|
3792
|
+
});
|
|
3809
3793
|
class KosModelError extends Error {
|
|
3810
3794
|
context;
|
|
3811
3795
|
originalCause;
|
|
@@ -3867,10 +3851,10 @@ function enrichError(error, context) {
|
|
|
3867
3851
|
}
|
|
3868
3852
|
function logErrorCollection(errors, summary) {
|
|
3869
3853
|
if (errors.length === 0) return;
|
|
3870
|
-
|
|
3854
|
+
log$11.error(`${summary} - ${errors.length} error(s) occurred:`);
|
|
3871
3855
|
errors.forEach(({ error, context }, index) => {
|
|
3872
3856
|
const enriched = error instanceof KosModelError ? error : enrichError(error, context);
|
|
3873
|
-
|
|
3857
|
+
log$11.error(
|
|
3874
3858
|
` [${index + 1}/${errors.length}] ${enriched.toDetailedString()}`
|
|
3875
3859
|
);
|
|
3876
3860
|
});
|
|
@@ -3886,7 +3870,7 @@ function logModelInstantiationError(error, context) {
|
|
|
3886
3870
|
});
|
|
3887
3871
|
}
|
|
3888
3872
|
const isKosCompanionTypeFactory = (obj) => typeof obj === "function";
|
|
3889
|
-
const log$
|
|
3873
|
+
const log$10 = KosLog.createLogger({ group: LogGroup.core, name: "kos-companion-instantiator" });
|
|
3890
3874
|
class KosCompanionInstantiator {
|
|
3891
3875
|
constructor(registry, cache2, createModel) {
|
|
3892
3876
|
this.registry = registry;
|
|
@@ -3908,7 +3892,7 @@ class KosCompanionInstantiator {
|
|
|
3908
3892
|
createCompanionModels(model, options, lifecycle) {
|
|
3909
3893
|
const companionDefs = this.getCompanionDefinitions(model.modelTypeName);
|
|
3910
3894
|
if (lifecycle !== void 0) {
|
|
3911
|
-
log$
|
|
3895
|
+
log$10.debug(
|
|
3912
3896
|
`Creating ${lifecycle} lifecycle companions for ${model.modelTypeName} [${model.modelId}]`
|
|
3913
3897
|
);
|
|
3914
3898
|
}
|
|
@@ -3960,7 +3944,7 @@ class KosCompanionInstantiator {
|
|
|
3960
3944
|
runInAction(() => {
|
|
3961
3945
|
model.modelData[property] = mixin.modelData;
|
|
3962
3946
|
});
|
|
3963
|
-
log$
|
|
3947
|
+
log$10.debug(
|
|
3964
3948
|
`Created mixin ${registration.type} for ${model.modelTypeName} [${model.modelId}]`
|
|
3965
3949
|
);
|
|
3966
3950
|
});
|
|
@@ -3992,7 +3976,7 @@ class KosCompanionInstantiator {
|
|
|
3992
3976
|
resolveFactoryCompanion(companionDef, model, options, requestedLifecycle) {
|
|
3993
3977
|
const companionType = companionDef.type(model.modelData, options);
|
|
3994
3978
|
if (!companionType) {
|
|
3995
|
-
log$
|
|
3979
|
+
log$10.debug(
|
|
3996
3980
|
`Companion factory returned undefined for ${model.modelTypeName} at ${requestedLifecycle || "INIT"} phase`
|
|
3997
3981
|
);
|
|
3998
3982
|
return null;
|
|
@@ -4051,7 +4035,7 @@ class KosCompanionInstantiator {
|
|
|
4051
4035
|
);
|
|
4052
4036
|
if (companion) {
|
|
4053
4037
|
this.attachCompanionToParent(companion, parentModel);
|
|
4054
|
-
log$
|
|
4038
|
+
log$10.debug(
|
|
4055
4039
|
`Created ${lifecycle || "INIT"} companion ${companionType} for ${parentModel.modelTypeName} [${parentModel.modelId}]`
|
|
4056
4040
|
);
|
|
4057
4041
|
}
|
|
@@ -4067,7 +4051,7 @@ class KosCompanionInstantiator {
|
|
|
4067
4051
|
*/
|
|
4068
4052
|
companionAlreadyExists(companionId, companionType, parentTypeName) {
|
|
4069
4053
|
if (this.cache.hasModel(companionId)) {
|
|
4070
|
-
log$
|
|
4054
|
+
log$10.debug(
|
|
4071
4055
|
`Companion ${companionType} already exists for ${parentTypeName}`
|
|
4072
4056
|
);
|
|
4073
4057
|
return true;
|
|
@@ -4152,6 +4136,10 @@ const TransitionMap = {
|
|
|
4152
4136
|
/* INIT */
|
|
4153
4137
|
]: transitionToInit
|
|
4154
4138
|
};
|
|
4139
|
+
const log$$ = KosLog.createLogger({
|
|
4140
|
+
group: LogGroup.core,
|
|
4141
|
+
name: "promise-utils"
|
|
4142
|
+
});
|
|
4155
4143
|
class ModelError extends Error {
|
|
4156
4144
|
model;
|
|
4157
4145
|
constructor(message, model) {
|
|
@@ -4163,7 +4151,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4163
4151
|
let timeoutId;
|
|
4164
4152
|
const promise = new Promise((_, reject) => {
|
|
4165
4153
|
timeoutId = setTimeout(() => {
|
|
4166
|
-
|
|
4154
|
+
log$$.error(
|
|
4167
4155
|
`Model ${model.modelId} - ${model.modelTypeName} - ${status} timed out after ${ms}ms`
|
|
4168
4156
|
);
|
|
4169
4157
|
reject(
|
|
@@ -4179,6 +4167,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4179
4167
|
};
|
|
4180
4168
|
return { promise, cancel };
|
|
4181
4169
|
};
|
|
4170
|
+
const log$_ = KosLog.createLogger({ group: LogGroup.core, name: "model-utils" });
|
|
4182
4171
|
const createModelDependency = (model, dependency) => {
|
|
4183
4172
|
const _dataModelId = dependency.id || dependency.modelType;
|
|
4184
4173
|
const dataModelId = resolveParameters({
|
|
@@ -4187,7 +4176,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4187
4176
|
modelId: model.modelId
|
|
4188
4177
|
});
|
|
4189
4178
|
const resolutionPolicy = dependency.resolutionPolicy || DependencyResolutionPolicy.CREATE;
|
|
4190
|
-
|
|
4179
|
+
log$_.debug(
|
|
4191
4180
|
`Resolving dependent model ${dependency.modelType} with id ${dataModelId} (policy: ${resolutionPolicy})`
|
|
4192
4181
|
);
|
|
4193
4182
|
const options = Object.keys(dependency?.options || {}).reduce((acc, curr) => {
|
|
@@ -4203,7 +4192,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4203
4192
|
const modelRegistry = modelManager.registry.models[dependency.modelType];
|
|
4204
4193
|
if (!modelRegistry) {
|
|
4205
4194
|
const errorMessage = `No model registered for type ${dependency.modelType}`;
|
|
4206
|
-
|
|
4195
|
+
log$_.error(
|
|
4207
4196
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4208
4197
|
- Dependency Type: ${dependency.modelType}
|
|
4209
4198
|
- Dependency ID: ${dataModelId}
|
|
@@ -4213,7 +4202,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4213
4202
|
- Error: ${errorMessage}`
|
|
4214
4203
|
);
|
|
4215
4204
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4216
|
-
|
|
4205
|
+
log$_.warn(
|
|
4217
4206
|
`Model type not registered (policy: CONTINUE) - Model ${model.modelId} will continue without dependency ${dependency.modelType} [${dataModelId}]`
|
|
4218
4207
|
);
|
|
4219
4208
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4226,7 +4215,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4226
4215
|
if (existingModel) {
|
|
4227
4216
|
if (existingModel.modelTypeName !== dependency.modelType) {
|
|
4228
4217
|
const errorMessage = `Model type mismatch: expected ${dependency.modelType}, found ${existingModel.modelTypeName}`;
|
|
4229
|
-
|
|
4218
|
+
log$_.error(
|
|
4230
4219
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4231
4220
|
- Dependency Type: ${dependency.modelType}
|
|
4232
4221
|
- Dependency ID: ${dataModelId}
|
|
@@ -4237,7 +4226,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4237
4226
|
- Error: ${errorMessage}`
|
|
4238
4227
|
);
|
|
4239
4228
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4240
|
-
|
|
4229
|
+
log$_.warn(
|
|
4241
4230
|
`Model type mismatch (policy: CONTINUE) - Model ${model.modelId} will continue without dependency`
|
|
4242
4231
|
);
|
|
4243
4232
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4246,7 +4235,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4246
4235
|
`Dependency resolution failed - Model ${model.modelId} cannot resolve dependency ${dependency.modelType} [${dataModelId}]: ${errorMessage}`
|
|
4247
4236
|
);
|
|
4248
4237
|
}
|
|
4249
|
-
|
|
4238
|
+
log$_.debug(
|
|
4250
4239
|
`Found existing dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4251
4240
|
);
|
|
4252
4241
|
return {
|
|
@@ -4255,18 +4244,18 @@ const createModelDependency = (model, dependency) => {
|
|
|
4255
4244
|
success: true
|
|
4256
4245
|
};
|
|
4257
4246
|
}
|
|
4258
|
-
|
|
4247
|
+
log$_.debug(
|
|
4259
4248
|
`Model ${dependency.modelType} [${dataModelId}] does not exist. Applying resolution policy: ${resolutionPolicy}`
|
|
4260
4249
|
);
|
|
4261
4250
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4262
|
-
|
|
4251
|
+
log$_.warn(
|
|
4263
4252
|
`Model ${dependency.modelType} [${dataModelId}] not found (policy: CONTINUE) - Model ${model.modelId} will continue without this dependency`
|
|
4264
4253
|
);
|
|
4265
4254
|
return { dependentModel: null, dataModelId, success: false };
|
|
4266
4255
|
}
|
|
4267
4256
|
if (resolutionPolicy === DependencyResolutionPolicy.FAIL) {
|
|
4268
4257
|
const errorMessage = `No ${dependency.modelType} model with id ${dataModelId} exists`;
|
|
4269
|
-
|
|
4258
|
+
log$_.error(
|
|
4270
4259
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4271
4260
|
- Dependency Type: ${dependency.modelType}
|
|
4272
4261
|
- Dependency ID: ${dataModelId}
|
|
@@ -4284,7 +4273,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4284
4273
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
4285
4274
|
if (requiresOptions && !hasOptions) {
|
|
4286
4275
|
const errorMessage = `Model ${dependency.modelType} requires options but none were provided`;
|
|
4287
|
-
|
|
4276
|
+
log$_.error(
|
|
4288
4277
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4289
4278
|
- Dependency Type: ${dependency.modelType}
|
|
4290
4279
|
- Dependency ID: ${dataModelId}
|
|
@@ -4305,13 +4294,13 @@ const createModelDependency = (model, dependency) => {
|
|
|
4305
4294
|
dataModelId,
|
|
4306
4295
|
options
|
|
4307
4296
|
);
|
|
4308
|
-
|
|
4297
|
+
log$_.debug(
|
|
4309
4298
|
`Successfully created dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4310
4299
|
);
|
|
4311
4300
|
return { dependentModel, dataModelId, success: true };
|
|
4312
4301
|
} catch (error) {
|
|
4313
4302
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4314
|
-
|
|
4303
|
+
log$_.error(
|
|
4315
4304
|
`Failed to create dependency for model ${model.modelId}:
|
|
4316
4305
|
- Dependency Type: ${dependency.modelType}
|
|
4317
4306
|
- Dependency ID: ${dataModelId}
|
|
@@ -4327,14 +4316,14 @@ const createModelDependency = (model, dependency) => {
|
|
|
4327
4316
|
const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY) => {
|
|
4328
4317
|
const dependencies = model.modelData?.[DependencyModels] || {};
|
|
4329
4318
|
if (Object.keys(dependencies).length === 0) {
|
|
4330
|
-
|
|
4319
|
+
log$_.debug(`${model.modelId} has no dependencies. Returning`);
|
|
4331
4320
|
return [];
|
|
4332
4321
|
}
|
|
4333
4322
|
const dependenciesByLifecycle = Object.keys(dependencies).filter((key) => dependencies[key].lifecycle === lifecycle).map((key) => {
|
|
4334
4323
|
const dependency = dependencies[key];
|
|
4335
4324
|
const resolutionResult = createModelDependency(model, dependency);
|
|
4336
4325
|
if (!resolutionResult.success || !resolutionResult.dependentModel) {
|
|
4337
|
-
|
|
4326
|
+
log$_.debug(
|
|
4338
4327
|
`Skipping dependency ${dependency.modelType} with id ${resolutionResult.dataModelId} - resolution failed with CONTINUE policy`
|
|
4339
4328
|
);
|
|
4340
4329
|
model.modelData[key] = void 0;
|
|
@@ -4342,12 +4331,12 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4342
4331
|
}
|
|
4343
4332
|
const { dependentModel, dataModelId } = resolutionResult;
|
|
4344
4333
|
model.modelData[key] = dependentModel.data;
|
|
4345
|
-
|
|
4334
|
+
log$_.debug(
|
|
4346
4335
|
`waiting for dependent model ${dependency.modelType} with id ${dataModelId} - waiting for WHENREADY`
|
|
4347
4336
|
);
|
|
4348
4337
|
const readyFn = async (dependentModel2, modelType, id) => {
|
|
4349
4338
|
await dependentModel2.whenReady?.();
|
|
4350
|
-
|
|
4339
|
+
log$_.debug(`dependent model ${modelType} with id ${id} - READY`);
|
|
4351
4340
|
};
|
|
4352
4341
|
const { promise, cancel } = rejectAfterDelay$1(
|
|
4353
4342
|
MODEL_PROMISE_TIMEOUT_MS,
|
|
@@ -4368,7 +4357,7 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4368
4357
|
lifecycle,
|
|
4369
4358
|
operation: "dependency whenReady()"
|
|
4370
4359
|
});
|
|
4371
|
-
|
|
4360
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4372
4361
|
cancel();
|
|
4373
4362
|
throw enrichedError;
|
|
4374
4363
|
}),
|
|
@@ -4378,13 +4367,13 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4378
4367
|
return dependenciesByLifecycle;
|
|
4379
4368
|
};
|
|
4380
4369
|
const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycle) => {
|
|
4381
|
-
|
|
4370
|
+
log$_.debug(`Execute lifecycle with ${models2.length} models`);
|
|
4382
4371
|
if (models2.length === 0) {
|
|
4383
|
-
|
|
4372
|
+
log$_.debug(`${sourceModel.modelId} has no children. Returning`);
|
|
4384
4373
|
return;
|
|
4385
4374
|
}
|
|
4386
4375
|
if (!target) {
|
|
4387
|
-
|
|
4376
|
+
log$_.error(
|
|
4388
4377
|
`${sourceModel.modelId} is not transitioning with a valid target ${target}`
|
|
4389
4378
|
);
|
|
4390
4379
|
return;
|
|
@@ -4395,12 +4384,10 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4395
4384
|
p = TransitionMap[target](model);
|
|
4396
4385
|
} else {
|
|
4397
4386
|
if (!model) {
|
|
4398
|
-
|
|
4387
|
+
log$_.error("model is undefined. This shouldn't happen");
|
|
4399
4388
|
}
|
|
4400
4389
|
if (!TransitionMap[target]) {
|
|
4401
|
-
|
|
4402
|
-
`There is no promise in the Transition Map for ${target}`
|
|
4403
|
-
);
|
|
4390
|
+
log$_.error(`There is no promise in the Transition Map for ${target}`);
|
|
4404
4391
|
}
|
|
4405
4392
|
}
|
|
4406
4393
|
return {
|
|
@@ -4412,11 +4399,11 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4412
4399
|
};
|
|
4413
4400
|
}).filter((modelPromise) => {
|
|
4414
4401
|
if (!modelPromise.promise) {
|
|
4415
|
-
|
|
4402
|
+
log$_.error(`No promise found ${modelPromise.modelId}`);
|
|
4416
4403
|
return false;
|
|
4417
4404
|
}
|
|
4418
4405
|
if (!modelPromise.model) {
|
|
4419
|
-
|
|
4406
|
+
log$_.error(`No model found ${modelPromise.modelId}`);
|
|
4420
4407
|
return false;
|
|
4421
4408
|
}
|
|
4422
4409
|
return true;
|
|
@@ -4445,7 +4432,7 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4445
4432
|
lifecycle: sourceLifecycle,
|
|
4446
4433
|
operation: `transition to ${target}`
|
|
4447
4434
|
});
|
|
4448
|
-
|
|
4435
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4449
4436
|
timeoutCancel();
|
|
4450
4437
|
throw enrichedError;
|
|
4451
4438
|
}),
|
|
@@ -4491,10 +4478,10 @@ const executeDependentModelLifecycle = async (model, lifecycle) => {
|
|
|
4491
4478
|
);
|
|
4492
4479
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
4493
4480
|
if (failed.length) {
|
|
4494
|
-
|
|
4481
|
+
log$_.error(
|
|
4495
4482
|
`There were ${failed.length} failed dependent models on ${lifecycle}`
|
|
4496
4483
|
);
|
|
4497
|
-
|
|
4484
|
+
log$_.error(failed);
|
|
4498
4485
|
}
|
|
4499
4486
|
};
|
|
4500
4487
|
function applyKosModelDevtoolsSupport(model) {
|
|
@@ -4758,7 +4745,7 @@ class KosEffectManager {
|
|
|
4758
4745
|
this.disposers = [];
|
|
4759
4746
|
}
|
|
4760
4747
|
}
|
|
4761
|
-
const log$
|
|
4748
|
+
const log$Z = KosLog.createLogger({ group: LogGroup.core, name: "model-active-machine" });
|
|
4762
4749
|
const activeMachine = (model) => {
|
|
4763
4750
|
const machine2 = createMachine(KosModelState.INACTIVE, {
|
|
4764
4751
|
[KosModelState.FAILED]: state(
|
|
@@ -4813,11 +4800,11 @@ const activeMachine = (model) => {
|
|
|
4813
4800
|
});
|
|
4814
4801
|
const service2 = interpret(
|
|
4815
4802
|
machine2,
|
|
4816
|
-
(_service) => log$
|
|
4803
|
+
(_service) => log$Z.debug(_service.machine.current)
|
|
4817
4804
|
);
|
|
4818
4805
|
return { service: service2, machine: machine2 };
|
|
4819
4806
|
};
|
|
4820
|
-
const log$
|
|
4807
|
+
const log$Y = KosLog.createLogger({ group: LogGroup.core, name: "model-online-machine" });
|
|
4821
4808
|
const onlineMachine = (model) => {
|
|
4822
4809
|
const machine2 = createMachine(KosModelState.OFFLINE, {
|
|
4823
4810
|
[KosModelState.ONLINE]: state(
|
|
@@ -4835,7 +4822,7 @@ const onlineMachine = (model) => {
|
|
|
4835
4822
|
KosModelEvents.GO_ONLINE,
|
|
4836
4823
|
KosModelState.ONLINE,
|
|
4837
4824
|
action$1(async () => {
|
|
4838
|
-
log$
|
|
4825
|
+
log$Y.debug(`Going online with model ${model.modelId}`);
|
|
4839
4826
|
await model.online();
|
|
4840
4827
|
model.onlineStatus = KosModelState.ONLINE;
|
|
4841
4828
|
await model.fsm.transitionTo(
|
|
@@ -4848,10 +4835,14 @@ const onlineMachine = (model) => {
|
|
|
4848
4835
|
});
|
|
4849
4836
|
const service2 = interpret(
|
|
4850
4837
|
machine2,
|
|
4851
|
-
(_service) => log$
|
|
4838
|
+
(_service) => log$Y.debug(_service.machine.current)
|
|
4852
4839
|
);
|
|
4853
4840
|
return { machine: machine2, service: service2 };
|
|
4854
4841
|
};
|
|
4842
|
+
const log$X = KosLog.createLogger({
|
|
4843
|
+
group: LogGroup.core,
|
|
4844
|
+
name: "model-machine"
|
|
4845
|
+
});
|
|
4855
4846
|
const machine = (model) => {
|
|
4856
4847
|
const active = activeMachine(model).service;
|
|
4857
4848
|
const online = onlineMachine(model).service;
|
|
@@ -4886,7 +4877,7 @@ const machine = (model) => {
|
|
|
4886
4877
|
`error`,
|
|
4887
4878
|
KosModelState.FAILED,
|
|
4888
4879
|
action$1(() => {
|
|
4889
|
-
|
|
4880
|
+
log$X.error(
|
|
4890
4881
|
`Model ${model.modelId} - ${model.modelTypeName} failed to initialize. Transitioning to FAILED state.`
|
|
4891
4882
|
);
|
|
4892
4883
|
model.status = KosModelState.FAILED;
|
|
@@ -5008,7 +4999,7 @@ const machine = (model) => {
|
|
|
5008
4999
|
`error`,
|
|
5009
5000
|
KosModelState.REATTACHING,
|
|
5010
5001
|
action$1((_ctx, event) => {
|
|
5011
|
-
|
|
5002
|
+
log$X.error(
|
|
5012
5003
|
`Model ${model.modelId} - ${model.modelTypeName} failed to reload; its data stays as it was. ${String(
|
|
5013
5004
|
event?.error
|
|
5014
5005
|
)}`
|
|
@@ -5045,11 +5036,11 @@ const machine = (model) => {
|
|
|
5045
5036
|
[KosModelState.FAILED]: state()
|
|
5046
5037
|
});
|
|
5047
5038
|
};
|
|
5048
|
-
const log$
|
|
5039
|
+
const log$W = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-lifecycle" });
|
|
5049
5040
|
const fsm = (model) => {
|
|
5050
5041
|
const service2 = interpret(
|
|
5051
5042
|
machine(model),
|
|
5052
|
-
(_service) => log$
|
|
5043
|
+
(_service) => log$W.debug(
|
|
5053
5044
|
`state machine for model ${model.modelId}: ${_service.machine.current});`
|
|
5054
5045
|
)
|
|
5055
5046
|
);
|
|
@@ -5651,6 +5642,10 @@ async function processRequestBody(body) {
|
|
|
5651
5642
|
}
|
|
5652
5643
|
throw new Error("Unsupported body type");
|
|
5653
5644
|
}
|
|
5645
|
+
const log$V = KosLog.createLogger({
|
|
5646
|
+
group: LogGroup.transport,
|
|
5647
|
+
name: "kos-message-utils"
|
|
5648
|
+
});
|
|
5654
5649
|
const createStudioMessage = ({
|
|
5655
5650
|
path,
|
|
5656
5651
|
requestId,
|
|
@@ -5864,10 +5859,10 @@ const sendKosMessage = (msg, options) => {
|
|
|
5864
5859
|
);
|
|
5865
5860
|
const socketTransport = KosCore.getInstance().transport.socket;
|
|
5866
5861
|
if (socketTransport) {
|
|
5867
|
-
|
|
5862
|
+
log$V.debug("Sending message", _msg);
|
|
5868
5863
|
socketTransport.socket.send(_msg);
|
|
5869
5864
|
} else {
|
|
5870
|
-
|
|
5865
|
+
log$V.error("socket transport is not initialized");
|
|
5871
5866
|
}
|
|
5872
5867
|
};
|
|
5873
5868
|
const createStudioMessageResponse = ({
|
|
@@ -5902,7 +5897,7 @@ const sendStudioMessageRequest = (msg, options) => {
|
|
|
5902
5897
|
if (socketTransport) {
|
|
5903
5898
|
socketTransport.socket.send(_msg);
|
|
5904
5899
|
} else {
|
|
5905
|
-
|
|
5900
|
+
log$V.error("socket transport is not initialized");
|
|
5906
5901
|
}
|
|
5907
5902
|
};
|
|
5908
5903
|
const sendStudioMessage = (msg, options) => {
|
|
@@ -5915,7 +5910,7 @@ const sendStudioMessage = (msg, options) => {
|
|
|
5915
5910
|
if (socketTransport) {
|
|
5916
5911
|
socketTransport.socket.send(_msg);
|
|
5917
5912
|
} else {
|
|
5918
|
-
|
|
5913
|
+
log$V.error("socket transport is not initialized");
|
|
5919
5914
|
}
|
|
5920
5915
|
};
|
|
5921
5916
|
const createBroadcastMessageResponse = ({
|
|
@@ -5985,7 +5980,7 @@ const sendBroadcastMessage = ({
|
|
|
5985
5980
|
if (socketTransport) {
|
|
5986
5981
|
socketTransport.socket.send(_msg);
|
|
5987
5982
|
} else {
|
|
5988
|
-
|
|
5983
|
+
log$V.error("socket transport is not initialized");
|
|
5989
5984
|
}
|
|
5990
5985
|
};
|
|
5991
5986
|
const sendKosMessageResponse = ({
|
|
@@ -6001,7 +5996,7 @@ const sendKosMessageResponse = ({
|
|
|
6001
5996
|
if (socketTransport) {
|
|
6002
5997
|
socketTransport.socket.send(_msg);
|
|
6003
5998
|
} else {
|
|
6004
|
-
|
|
5999
|
+
log$V.error("socket transport is not initialized");
|
|
6005
6000
|
}
|
|
6006
6001
|
};
|
|
6007
6002
|
const sendKosHttpMessageResponse = ({
|
|
@@ -6017,7 +6012,7 @@ const sendKosHttpMessageResponse = ({
|
|
|
6017
6012
|
if (socketTransport) {
|
|
6018
6013
|
socketTransport.socket.send(_msg);
|
|
6019
6014
|
} else {
|
|
6020
|
-
|
|
6015
|
+
log$V.error("socket transport is not initialized");
|
|
6021
6016
|
}
|
|
6022
6017
|
};
|
|
6023
6018
|
const getMessageBody = (payload, skipParse) => {
|
|
@@ -6049,7 +6044,7 @@ class TransportNotReadyError extends Error {
|
|
|
6049
6044
|
}
|
|
6050
6045
|
}
|
|
6051
6046
|
const isTransportNotReadyError = (error) => !!error && error.code === TRANSPORT_NOT_READY;
|
|
6052
|
-
const log$
|
|
6047
|
+
const log$U = KosLog.createLogger({ group: LogGroup.transport, name: "kos-fetch" });
|
|
6053
6048
|
const DEFAULT_WS_TIMEOUT = 3e4;
|
|
6054
6049
|
const WS_TIMEOUT = (() => {
|
|
6055
6050
|
const configured = process.env.KOS_WS_TIMEOUT ? parseInt(process.env.KOS_WS_TIMEOUT) : DEFAULT_WS_TIMEOUT;
|
|
@@ -6114,7 +6109,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6114
6109
|
const requestId = uuid();
|
|
6115
6110
|
const urlObj = new URL(url);
|
|
6116
6111
|
const path = `${urlObj.pathname}${urlObj.search}`;
|
|
6117
|
-
log$
|
|
6112
|
+
log$U.debug(`path: ${path}`);
|
|
6118
6113
|
const budget = resolveTimeoutBudget(options?.timeout);
|
|
6119
6114
|
const messageFactory = fetchMessageFactory(options);
|
|
6120
6115
|
const signal = createRequestSignal(budget, options?.signal);
|
|
@@ -6122,12 +6117,12 @@ const kosFetchWs = async (url, options) => {
|
|
|
6122
6117
|
await transport.whenReady({ signal });
|
|
6123
6118
|
} catch (error) {
|
|
6124
6119
|
if (isTimeoutReason(error)) {
|
|
6125
|
-
log$
|
|
6120
|
+
log$U.error(
|
|
6126
6121
|
`Transport not ready${budget === void 0 ? "" : ` after ${budget}ms`} - request not sent - url: ${url}`
|
|
6127
6122
|
);
|
|
6128
6123
|
throw new TransportNotReadyError({ timeout: budget, url });
|
|
6129
6124
|
}
|
|
6130
|
-
log$
|
|
6125
|
+
log$U.debug(`Request aborted while waiting for transport - url: ${url}`);
|
|
6131
6126
|
throw error;
|
|
6132
6127
|
}
|
|
6133
6128
|
const processedBody = await processRequestBody(options?.body);
|
|
@@ -6156,9 +6151,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6156
6151
|
if (signal.aborted) {
|
|
6157
6152
|
const reason = signal.reason;
|
|
6158
6153
|
if (reason?.name === "TimeoutError") {
|
|
6159
|
-
log$
|
|
6154
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6160
6155
|
} else {
|
|
6161
|
-
log$
|
|
6156
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6162
6157
|
}
|
|
6163
6158
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6164
6159
|
return;
|
|
@@ -6167,9 +6162,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6167
6162
|
if (unsubscribe) unsubscribe();
|
|
6168
6163
|
const reason = signal.reason;
|
|
6169
6164
|
if (reason?.name === "TimeoutError") {
|
|
6170
|
-
log$
|
|
6165
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6171
6166
|
} else {
|
|
6172
|
-
log$
|
|
6167
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6173
6168
|
}
|
|
6174
6169
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6175
6170
|
};
|
|
@@ -6185,7 +6180,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6185
6180
|
try {
|
|
6186
6181
|
bodyData = base64ToArrayBuffer(responseBody);
|
|
6187
6182
|
} catch (e) {
|
|
6188
|
-
log$
|
|
6183
|
+
log$U.error("Failed to decode base64 response", e);
|
|
6189
6184
|
}
|
|
6190
6185
|
}
|
|
6191
6186
|
const response = {
|
|
@@ -6239,7 +6234,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6239
6234
|
});
|
|
6240
6235
|
}
|
|
6241
6236
|
if (parsed.files) {
|
|
6242
|
-
log$
|
|
6237
|
+
log$U.warn(
|
|
6243
6238
|
"File reconstruction in FormData not fully implemented"
|
|
6244
6239
|
);
|
|
6245
6240
|
}
|
|
@@ -6290,7 +6285,7 @@ const resolveBaseUrl = () => {
|
|
|
6290
6285
|
const URL2 = BASE_URL;
|
|
6291
6286
|
return { isMock: MOCK, URL: URL2 };
|
|
6292
6287
|
};
|
|
6293
|
-
const log$
|
|
6288
|
+
const log$T = KosLog.createLogger({ group: LogGroup.transport, name: "kos-service-request" });
|
|
6294
6289
|
const ERROR_UNKNOWN = "errUnknown";
|
|
6295
6290
|
const ERROR_TRANSPORT_NOT_READY = "Transport not ready";
|
|
6296
6291
|
const MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
@@ -6316,7 +6311,7 @@ async function clientRequest(endpoint, method, options, params2, body) {
|
|
|
6316
6311
|
)}`
|
|
6317
6312
|
).join("&") : "";
|
|
6318
6313
|
const fullUrl = `${resolveBaseUrl().URL}${url}${query ? `?${query}` : ""}`;
|
|
6319
|
-
log$
|
|
6314
|
+
log$T.debug(`fullUrl: ${fullUrl}`);
|
|
6320
6315
|
const fetchOptions = {
|
|
6321
6316
|
method: String(method).toUpperCase(),
|
|
6322
6317
|
body: null,
|
|
@@ -6350,20 +6345,20 @@ async function executeFetch(fullUrl, fetchOptions) {
|
|
|
6350
6345
|
return [null, payload.data ?? payload, responseContext(response)];
|
|
6351
6346
|
} catch (error) {
|
|
6352
6347
|
if (isTransportNotReadyError(error)) {
|
|
6353
|
-
log$
|
|
6348
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6354
6349
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6355
6350
|
}
|
|
6356
6351
|
if (error instanceof DOMException) {
|
|
6357
6352
|
if (error.name === "TimeoutError") {
|
|
6358
|
-
log$
|
|
6353
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6359
6354
|
return ["Request timed out", null];
|
|
6360
6355
|
}
|
|
6361
6356
|
if (error.name === "AbortError") {
|
|
6362
|
-
log$
|
|
6357
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6363
6358
|
return ["Request aborted", null];
|
|
6364
6359
|
}
|
|
6365
6360
|
}
|
|
6366
|
-
log$
|
|
6361
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6367
6362
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6368
6363
|
}
|
|
6369
6364
|
}
|
|
@@ -6383,38 +6378,38 @@ async function executeFetchWithRetry(fullUrl, fetchOptions, config2) {
|
|
|
6383
6378
|
errorContext
|
|
6384
6379
|
];
|
|
6385
6380
|
if (config2.retryOn && !config2.retryOn(response)) {
|
|
6386
|
-
log$
|
|
6381
|
+
log$T.debug(
|
|
6387
6382
|
`Retry predicate returned false for ${fullUrl} (status ${response.status}), stopping`
|
|
6388
6383
|
);
|
|
6389
6384
|
return lastResult;
|
|
6390
6385
|
}
|
|
6391
6386
|
if (attempt < config2.maxAttempts) {
|
|
6392
6387
|
const delayMs = config2.baseDelayMs * Math.pow(config2.backoffFactor, attempt - 1);
|
|
6393
|
-
log$
|
|
6388
|
+
log$T.warn(
|
|
6394
6389
|
`Request to ${fullUrl} failed (status ${response.status}), retrying in ${delayMs}ms (attempt ${attempt}/${config2.maxAttempts})`
|
|
6395
6390
|
);
|
|
6396
6391
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
6397
6392
|
}
|
|
6398
6393
|
} catch (error) {
|
|
6399
6394
|
if (isTransportNotReadyError(error)) {
|
|
6400
|
-
log$
|
|
6395
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6401
6396
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6402
6397
|
}
|
|
6403
6398
|
if (error instanceof DOMException) {
|
|
6404
6399
|
if (error.name === "TimeoutError") {
|
|
6405
|
-
log$
|
|
6400
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6406
6401
|
return ["Request timed out", null];
|
|
6407
6402
|
}
|
|
6408
6403
|
if (error.name === "AbortError") {
|
|
6409
|
-
log$
|
|
6404
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6410
6405
|
return ["Request aborted", null];
|
|
6411
6406
|
}
|
|
6412
6407
|
}
|
|
6413
|
-
log$
|
|
6408
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6414
6409
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6415
6410
|
}
|
|
6416
6411
|
}
|
|
6417
|
-
log$
|
|
6412
|
+
log$T.error(`All ${config2.maxAttempts} attempts failed for ${fullUrl}`);
|
|
6418
6413
|
return lastResult;
|
|
6419
6414
|
}
|
|
6420
6415
|
async function captureErrorResponseContext(response) {
|
|
@@ -6463,10 +6458,7 @@ const service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
6463
6458
|
default: api$1,
|
|
6464
6459
|
kosServiceRequest
|
|
6465
6460
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
6466
|
-
const log$
|
|
6467
|
-
name: "kos-service-request-manager",
|
|
6468
|
-
group: "Model"
|
|
6469
|
-
});
|
|
6461
|
+
const log$S = KosLog.createLogger({ group: LogGroup.core, name: "kos-service-request-manager" });
|
|
6470
6462
|
function shouldExecuteRequest(metadata, model) {
|
|
6471
6463
|
return !metadata.condition || metadata.condition(model);
|
|
6472
6464
|
}
|
|
@@ -6516,7 +6508,7 @@ function isValueMissing(value) {
|
|
|
6516
6508
|
}
|
|
6517
6509
|
function validateRequiredField(value, fieldName, path, isRequired) {
|
|
6518
6510
|
if (isRequired && isValueMissing(value)) {
|
|
6519
|
-
log$
|
|
6511
|
+
log$S.warn(
|
|
6520
6512
|
`Required field '${fieldName}' is missing in response for ${path}`
|
|
6521
6513
|
);
|
|
6522
6514
|
}
|
|
@@ -6551,7 +6543,7 @@ class ServiceRequestManager {
|
|
|
6551
6543
|
this.handlers.get(lifecycle).push(metadata);
|
|
6552
6544
|
});
|
|
6553
6545
|
if (Object.keys(handlerMetadata).length > 0) {
|
|
6554
|
-
log$
|
|
6546
|
+
log$S.debug(
|
|
6555
6547
|
`Discovered ${Object.keys(handlerMetadata).length} service request handlers for model ${this.model.id}`
|
|
6556
6548
|
);
|
|
6557
6549
|
}
|
|
@@ -6566,7 +6558,7 @@ class ServiceRequestManager {
|
|
|
6566
6558
|
if (!handlers || handlers.length === 0) {
|
|
6567
6559
|
return;
|
|
6568
6560
|
}
|
|
6569
|
-
log$
|
|
6561
|
+
log$S.debug(
|
|
6570
6562
|
`Executing ${handlers.length} service requests for lifecycle ${lifecycle}`
|
|
6571
6563
|
);
|
|
6572
6564
|
await Promise.all(handlers.map((handler) => this.executeHandler(handler)));
|
|
@@ -6601,7 +6593,7 @@ class ServiceRequestManager {
|
|
|
6601
6593
|
*/
|
|
6602
6594
|
shouldProcessRequest(metadata) {
|
|
6603
6595
|
if (!shouldExecuteRequest(metadata, this.model)) {
|
|
6604
|
-
log$
|
|
6596
|
+
log$S.debug(`Skipping request ${metadata.path} - condition returned false`);
|
|
6605
6597
|
return false;
|
|
6606
6598
|
}
|
|
6607
6599
|
return true;
|
|
@@ -6806,7 +6798,7 @@ class ServiceRequestManager {
|
|
|
6806
6798
|
case "json":
|
|
6807
6799
|
return typeof value === "string" ? JSON.parse(value) : value;
|
|
6808
6800
|
default:
|
|
6809
|
-
log$
|
|
6801
|
+
log$S.warn(`Unknown transformer: ${transform}`);
|
|
6810
6802
|
return value;
|
|
6811
6803
|
}
|
|
6812
6804
|
}
|
|
@@ -6817,7 +6809,7 @@ class ServiceRequestManager {
|
|
|
6817
6809
|
if (!metadata.iterateOver) return data;
|
|
6818
6810
|
const array = this.getNestedValue(data, metadata.iterateOver);
|
|
6819
6811
|
if (!Array.isArray(array)) {
|
|
6820
|
-
log$
|
|
6812
|
+
log$S.warn(
|
|
6821
6813
|
`iterateOver path '${metadata.iterateOver}' did not resolve to an array`
|
|
6822
6814
|
);
|
|
6823
6815
|
return [];
|
|
@@ -6860,7 +6852,7 @@ class ServiceRequestManager {
|
|
|
6860
6852
|
case "throw":
|
|
6861
6853
|
throw error;
|
|
6862
6854
|
case "log":
|
|
6863
|
-
log$
|
|
6855
|
+
log$S.error(
|
|
6864
6856
|
`Service request failed for ${metadata.path}:`,
|
|
6865
6857
|
error.message
|
|
6866
6858
|
);
|
|
@@ -6920,6 +6912,10 @@ class ServiceRequestManager {
|
|
|
6920
6912
|
}
|
|
6921
6913
|
}
|
|
6922
6914
|
}
|
|
6915
|
+
KosLog.createLogger({
|
|
6916
|
+
group: LogGroup.core,
|
|
6917
|
+
name: "async-event-bus"
|
|
6918
|
+
});
|
|
6923
6919
|
class AsyncEventIterator {
|
|
6924
6920
|
subscription;
|
|
6925
6921
|
unsubscribe;
|
|
@@ -7369,6 +7365,10 @@ function encodeFutureFrame(future) {
|
|
|
7369
7365
|
JSON.stringify(future)
|
|
7370
7366
|
);
|
|
7371
7367
|
}
|
|
7368
|
+
const log$R = KosLog.createLogger({
|
|
7369
|
+
group: LogGroup.transport,
|
|
7370
|
+
name: "future-simulator"
|
|
7371
|
+
});
|
|
7372
7372
|
const DEFAULT_DURATION_MS = 5e3;
|
|
7373
7373
|
const DEFAULT_INTERVAL_MS = 250;
|
|
7374
7374
|
class KosMockFutureHandle {
|
|
@@ -7479,7 +7479,7 @@ class KosMockFutureSimulator {
|
|
|
7479
7479
|
this.deps.ensureCancelRoutes();
|
|
7480
7480
|
}
|
|
7481
7481
|
if (!options.tracker) {
|
|
7482
|
-
|
|
7482
|
+
log$R.warn(
|
|
7483
7483
|
`KosMock future ${handle.id} has no tracker — models will not link it to their request; prefer futures.fromRequest`
|
|
7484
7484
|
);
|
|
7485
7485
|
}
|
|
@@ -7511,6 +7511,10 @@ class KosMockFutureSimulator {
|
|
|
7511
7511
|
this.futures.clear();
|
|
7512
7512
|
}
|
|
7513
7513
|
}
|
|
7514
|
+
const log$Q = KosLog.createLogger({
|
|
7515
|
+
group: LogGroup.transport,
|
|
7516
|
+
name: "mock-fixtures"
|
|
7517
|
+
});
|
|
7514
7518
|
const DEFAULT_FIXTURE_SERVER_URL = "http://localhost:5676";
|
|
7515
7519
|
const DB_NAME = "kos-mock-fixtures";
|
|
7516
7520
|
const STORE_NAME = "fixtures";
|
|
@@ -7663,7 +7667,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7663
7667
|
);
|
|
7664
7668
|
}
|
|
7665
7669
|
await target.save(name, named);
|
|
7666
|
-
|
|
7670
|
+
log$Q.info(`KosMock fixture "${name}" saved`);
|
|
7667
7671
|
return name;
|
|
7668
7672
|
},
|
|
7669
7673
|
saveRecording(name) {
|
|
@@ -7686,7 +7690,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7686
7690
|
(summary) => summaries.push({ ...summary, source: "server" })
|
|
7687
7691
|
);
|
|
7688
7692
|
} catch {
|
|
7689
|
-
|
|
7693
|
+
log$Q.warn(`KosMock fixture server unreachable at ${serverUrl}`);
|
|
7690
7694
|
}
|
|
7691
7695
|
}
|
|
7692
7696
|
try {
|
|
@@ -7707,7 +7711,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7707
7711
|
},
|
|
7708
7712
|
async import() {
|
|
7709
7713
|
if (typeof document === "undefined") {
|
|
7710
|
-
|
|
7714
|
+
log$Q.warn(`KosMock fixture import requires a browser environment`);
|
|
7711
7715
|
return void 0;
|
|
7712
7716
|
}
|
|
7713
7717
|
return new Promise((resolve) => {
|
|
@@ -7727,7 +7731,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7727
7731
|
});
|
|
7728
7732
|
resolve(name);
|
|
7729
7733
|
} catch (error) {
|
|
7730
|
-
|
|
7734
|
+
log$Q.error(`KosMock fixture import failed`, error?.message);
|
|
7731
7735
|
resolve(void 0);
|
|
7732
7736
|
}
|
|
7733
7737
|
};
|
|
@@ -7802,6 +7806,10 @@ function splitUrl(url) {
|
|
|
7802
7806
|
function methodMatches(routeMethod, requestMethod) {
|
|
7803
7807
|
return routeMethod === "*" || routeMethod.toUpperCase() === requestMethod.toUpperCase();
|
|
7804
7808
|
}
|
|
7809
|
+
const log$P = KosLog.createLogger({
|
|
7810
|
+
group: LogGroup.transport,
|
|
7811
|
+
name: "mock-playback"
|
|
7812
|
+
});
|
|
7805
7813
|
const rewriteTrackers = (raw, trackerMap) => {
|
|
7806
7814
|
let out = raw;
|
|
7807
7815
|
trackerMap.forEach((liveTracker, capturedTracker) => {
|
|
@@ -7963,7 +7971,7 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7963
7971
|
if ((options.pushes ?? "scheduled") === "scheduled") {
|
|
7964
7972
|
startPushes();
|
|
7965
7973
|
}
|
|
7966
|
-
|
|
7974
|
+
log$P.info(
|
|
7967
7975
|
`KosMock fixture${name ? ` "${name}"` : ""} loaded: ${groups.size} routes, ${fixture.pushes.length} pushes (${fixture.pushes.length - unanchored.length} anchored), consume: ${consume}`
|
|
7968
7976
|
);
|
|
7969
7977
|
return {
|
|
@@ -7977,6 +7985,10 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7977
7985
|
}
|
|
7978
7986
|
};
|
|
7979
7987
|
}
|
|
7988
|
+
const log$O = KosLog.createLogger({
|
|
7989
|
+
group: LogGroup.transport,
|
|
7990
|
+
name: "mock-recorder"
|
|
7991
|
+
});
|
|
7980
7992
|
class KosMockRecorder {
|
|
7981
7993
|
recording = false;
|
|
7982
7994
|
name;
|
|
@@ -7998,14 +8010,14 @@ class KosMockRecorder {
|
|
|
7998
8010
|
this.exchanges = [];
|
|
7999
8011
|
this.pushes = [];
|
|
8000
8012
|
this.sends = [];
|
|
8001
|
-
|
|
8013
|
+
log$O.info(
|
|
8002
8014
|
`KosMock recorder started${options.name ? ` (${options.name})` : ""}`
|
|
8003
8015
|
);
|
|
8004
8016
|
}
|
|
8005
8017
|
stop() {
|
|
8006
8018
|
const fixture = this.toFixture();
|
|
8007
8019
|
this.recording = false;
|
|
8008
|
-
|
|
8020
|
+
log$O.info(
|
|
8009
8021
|
`KosMock recorder stopped: ${fixture.exchanges.length} exchanges, ${fixture.pushes.length} pushes, ${fixture.sends?.length ?? 0} sends`
|
|
8010
8022
|
);
|
|
8011
8023
|
return fixture;
|
|
@@ -8022,7 +8034,7 @@ class KosMockRecorder {
|
|
|
8022
8034
|
}
|
|
8023
8035
|
download(filename) {
|
|
8024
8036
|
if (typeof document === "undefined") {
|
|
8025
|
-
|
|
8037
|
+
log$O.warn(`KosMock recorder download requires a browser environment`);
|
|
8026
8038
|
return;
|
|
8027
8039
|
}
|
|
8028
8040
|
const fixture = this.toFixture();
|
|
@@ -8137,6 +8149,10 @@ class KosMockRecorder {
|
|
|
8137
8149
|
}
|
|
8138
8150
|
}
|
|
8139
8151
|
}
|
|
8152
|
+
const log$N = KosLog.createLogger({
|
|
8153
|
+
group: LogGroup.transport,
|
|
8154
|
+
name: "mock-setups"
|
|
8155
|
+
});
|
|
8140
8156
|
const dynamicImport = (url) => import(
|
|
8141
8157
|
/* @vite-ignore */
|
|
8142
8158
|
/* webpackIgnore: true */
|
|
@@ -8169,7 +8185,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8169
8185
|
try {
|
|
8170
8186
|
entry.teardown?.();
|
|
8171
8187
|
} catch (error) {
|
|
8172
|
-
|
|
8188
|
+
log$N.error(`KosMock setup "${name}" teardown threw`, error?.message);
|
|
8173
8189
|
}
|
|
8174
8190
|
return true;
|
|
8175
8191
|
};
|
|
@@ -8196,7 +8212,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8196
8212
|
handle,
|
|
8197
8213
|
teardown: typeof result === "function" ? result : void 0
|
|
8198
8214
|
});
|
|
8199
|
-
|
|
8215
|
+
log$N.info(`KosMock setup "${name}" installed from ${url}`);
|
|
8200
8216
|
return handle;
|
|
8201
8217
|
},
|
|
8202
8218
|
async list() {
|
|
@@ -8219,6 +8235,10 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8219
8235
|
};
|
|
8220
8236
|
return store;
|
|
8221
8237
|
}
|
|
8238
|
+
const log$M = KosLog.createLogger({
|
|
8239
|
+
group: LogGroup.transport,
|
|
8240
|
+
name: "mock-config"
|
|
8241
|
+
});
|
|
8222
8242
|
const asWireValue = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
8223
8243
|
const configTopic = (beanId) => `/kos/config/${beanId}`;
|
|
8224
8244
|
const changeEnvelope = (props, previousValues = {}) => {
|
|
@@ -8286,7 +8306,7 @@ function createConfigFacade(registry) {
|
|
|
8286
8306
|
return void 0;
|
|
8287
8307
|
}
|
|
8288
8308
|
if (injectedKeys.length < keys.length) {
|
|
8289
|
-
|
|
8309
|
+
log$M.warn(
|
|
8290
8310
|
`KosMock config.inject ${beanId}: mixed write passes through; injected props will be rejected by the backend: ${injectedKeys.join(
|
|
8291
8311
|
", "
|
|
8292
8312
|
)}`
|
|
@@ -8321,6 +8341,10 @@ function createConfigFacade(registry) {
|
|
|
8321
8341
|
};
|
|
8322
8342
|
return { update, inject };
|
|
8323
8343
|
}
|
|
8344
|
+
const log$L = KosLog.createLogger({
|
|
8345
|
+
group: LogGroup.transport,
|
|
8346
|
+
name: "mock-registry"
|
|
8347
|
+
});
|
|
8324
8348
|
const PENDING_REQUEST_CAP = 500;
|
|
8325
8349
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8326
8350
|
const asHandler = (handler) => typeof handler === "function" ? handler : () => handler;
|
|
@@ -8426,7 +8450,7 @@ class KosMockRegistry {
|
|
|
8426
8450
|
changed = true;
|
|
8427
8451
|
}
|
|
8428
8452
|
} catch (error) {
|
|
8429
|
-
|
|
8453
|
+
log$L.error(
|
|
8430
8454
|
`KosMock transformer for ${transformer.method} ${transformer.pattern} threw`,
|
|
8431
8455
|
error?.message
|
|
8432
8456
|
);
|
|
@@ -8542,7 +8566,7 @@ class KosMockRegistry {
|
|
|
8542
8566
|
try {
|
|
8543
8567
|
notify();
|
|
8544
8568
|
} catch (error) {
|
|
8545
|
-
|
|
8569
|
+
log$L.error(`KosMock observer threw`, error?.message);
|
|
8546
8570
|
}
|
|
8547
8571
|
}
|
|
8548
8572
|
loadFixture(fixture, options) {
|
|
@@ -8565,13 +8589,13 @@ class KosMockRegistry {
|
|
|
8565
8589
|
enable() {
|
|
8566
8590
|
if (!this.enabledFlag) {
|
|
8567
8591
|
this.enabledFlag = true;
|
|
8568
|
-
|
|
8592
|
+
log$L.info(`KosMock enabled`);
|
|
8569
8593
|
}
|
|
8570
8594
|
}
|
|
8571
8595
|
disable() {
|
|
8572
8596
|
if (this.enabledFlag) {
|
|
8573
8597
|
this.enabledFlag = false;
|
|
8574
|
-
|
|
8598
|
+
log$L.info(`KosMock disabled`);
|
|
8575
8599
|
}
|
|
8576
8600
|
}
|
|
8577
8601
|
get standalone() {
|
|
@@ -8647,7 +8671,7 @@ class KosMockRegistry {
|
|
|
8647
8671
|
}
|
|
8648
8672
|
publishFrame(rawFrame) {
|
|
8649
8673
|
if (this.injectors.size === 0) {
|
|
8650
|
-
|
|
8674
|
+
log$L.warn(
|
|
8651
8675
|
`KosMock.publishFrame: no active transport to deliver the frame`
|
|
8652
8676
|
);
|
|
8653
8677
|
return;
|
|
@@ -8690,7 +8714,7 @@ class KosMockRegistry {
|
|
|
8690
8714
|
if (teardown) {
|
|
8691
8715
|
this.scenarioTeardowns.set(id, teardown);
|
|
8692
8716
|
}
|
|
8693
|
-
|
|
8717
|
+
log$L.info(`KosMock scenario "${scenario.name}" installed`);
|
|
8694
8718
|
const remove = () => {
|
|
8695
8719
|
const dispose = this.scenarioTeardowns.get(id);
|
|
8696
8720
|
this.scenarioTeardowns.delete(id);
|
|
@@ -8794,7 +8818,7 @@ class KosMockRegistry {
|
|
|
8794
8818
|
return true;
|
|
8795
8819
|
}
|
|
8796
8820
|
if (policy === "warn") {
|
|
8797
|
-
|
|
8821
|
+
log$L.warn(`KosMock: unmatched ${frame.method} ${path}`);
|
|
8798
8822
|
}
|
|
8799
8823
|
return false;
|
|
8800
8824
|
}
|
|
@@ -8830,7 +8854,7 @@ class KosMockRegistry {
|
|
|
8830
8854
|
try {
|
|
8831
8855
|
accepted = route.when(scopedRequest);
|
|
8832
8856
|
} catch (error) {
|
|
8833
|
-
|
|
8857
|
+
log$L.error(
|
|
8834
8858
|
`KosMock \`when\` guard for ${route.method} ${route.pattern} threw`,
|
|
8835
8859
|
error?.message
|
|
8836
8860
|
);
|
|
@@ -8843,7 +8867,7 @@ class KosMockRegistry {
|
|
|
8843
8867
|
try {
|
|
8844
8868
|
response = await route.handler(scopedRequest, this.context());
|
|
8845
8869
|
} catch (error) {
|
|
8846
|
-
|
|
8870
|
+
log$L.error(
|
|
8847
8871
|
`KosMock handler for ${route.method} ${route.pattern} threw`,
|
|
8848
8872
|
error?.message
|
|
8849
8873
|
);
|
|
@@ -8876,7 +8900,7 @@ class KosMockRegistry {
|
|
|
8876
8900
|
return;
|
|
8877
8901
|
}
|
|
8878
8902
|
if (policy === "warn") {
|
|
8879
|
-
|
|
8903
|
+
log$L.warn(
|
|
8880
8904
|
`KosMock: all routes declined ${request.method} ${request.path}`
|
|
8881
8905
|
);
|
|
8882
8906
|
}
|
|
@@ -8991,7 +9015,7 @@ if (typeof window !== "undefined") {
|
|
|
8991
9015
|
if (fixture) {
|
|
8992
9016
|
bootLoads.push(
|
|
8993
9017
|
KosMock.fixtures.play(fixture).then(() => void 0).catch(
|
|
8994
|
-
(error) =>
|
|
9018
|
+
(error) => log$L.error(
|
|
8995
9019
|
`KosMock: boot fixture "${fixture}" failed to load`,
|
|
8996
9020
|
error?.message
|
|
8997
9021
|
)
|
|
@@ -9002,7 +9026,7 @@ if (typeof window !== "undefined") {
|
|
|
9002
9026
|
for (const name of setups.split(",").filter(Boolean)) {
|
|
9003
9027
|
bootLoads.push(
|
|
9004
9028
|
KosMock.setups.load(name).then(() => void 0).catch(
|
|
9005
|
-
(error) =>
|
|
9029
|
+
(error) => log$L.error(
|
|
9006
9030
|
`KosMock: boot setup "${name}" failed to load`,
|
|
9007
9031
|
error?.message
|
|
9008
9032
|
)
|
|
@@ -9112,6 +9136,14 @@ class WebSocketBridgeTransport extends WebSocket {
|
|
|
9112
9136
|
super(address);
|
|
9113
9137
|
}
|
|
9114
9138
|
}
|
|
9139
|
+
const log$K = KosLog.createLogger({
|
|
9140
|
+
group: LogGroup.transport,
|
|
9141
|
+
name: "base-message-transport"
|
|
9142
|
+
});
|
|
9143
|
+
const messageLog = KosLog.createLogger({
|
|
9144
|
+
group: LogGroup.transport,
|
|
9145
|
+
name: MESSAGE_LOGGER_NAME
|
|
9146
|
+
});
|
|
9115
9147
|
var WebSocketEvents = /* @__PURE__ */ ((WebSocketEvents2) => {
|
|
9116
9148
|
WebSocketEvents2["CONNECTED"] = `websocket.connected`;
|
|
9117
9149
|
WebSocketEvents2["DISCONNECTED"] = `websocket.disconnected`;
|
|
@@ -9208,9 +9240,9 @@ class BaseTransport {
|
|
|
9208
9240
|
}
|
|
9209
9241
|
onMessage(event) {
|
|
9210
9242
|
try {
|
|
9211
|
-
|
|
9243
|
+
log$K.debug("webSocketTransport: onMessage received");
|
|
9212
9244
|
const { headers, body } = this.processMessageEvent(event);
|
|
9213
|
-
|
|
9245
|
+
messageLog.debug("received", event.data);
|
|
9214
9246
|
const subscriptionTopic = headers["subscription"] || headers[this.RESPONSE_ID_HEADER] || headers["topic"] || headers["type"];
|
|
9215
9247
|
if (subscriptionTopic) {
|
|
9216
9248
|
let msgBody = body;
|
|
@@ -9226,11 +9258,11 @@ class BaseTransport {
|
|
|
9226
9258
|
publish(subscriptionTopic, msgBody, msgHeaders);
|
|
9227
9259
|
}
|
|
9228
9260
|
} catch (ex) {
|
|
9229
|
-
|
|
9261
|
+
log$K.error(`onMessage exception`, ex.message, ex.stack);
|
|
9230
9262
|
}
|
|
9231
9263
|
}
|
|
9232
9264
|
onOpen(event) {
|
|
9233
|
-
|
|
9265
|
+
log$K.info(`websocket connection opened`);
|
|
9234
9266
|
this.socket = event.currentTarget;
|
|
9235
9267
|
runInAction(() => {
|
|
9236
9268
|
this.connectionEstablished = true;
|
|
@@ -9240,11 +9272,9 @@ alias:${this.alias}
|
|
|
9240
9272
|
|
|
9241
9273
|
`);
|
|
9242
9274
|
}
|
|
9243
|
-
|
|
9244
|
-
`sending ${this.offlineMessages.length} offline FOS messages`
|
|
9245
|
-
);
|
|
9275
|
+
log$K.debug(`sending ${this.offlineMessages.length} offline FOS messages`);
|
|
9246
9276
|
this.offlineMessages.forEach((msg) => {
|
|
9247
|
-
|
|
9277
|
+
log$K.debug(`sending offline message ${msg.msg}`);
|
|
9248
9278
|
this.socket?.send(msg.msg);
|
|
9249
9279
|
});
|
|
9250
9280
|
this.offlineMessages = [];
|
|
@@ -9253,7 +9283,7 @@ alias:${this.alias}
|
|
|
9253
9283
|
}
|
|
9254
9284
|
onClose(event) {
|
|
9255
9285
|
const { code, reason, wasClean } = event;
|
|
9256
|
-
|
|
9286
|
+
log$K.warn(
|
|
9257
9287
|
`WebSocket closed: code=${code}, reason=${reason || "none"}, wasClean=${wasClean}`
|
|
9258
9288
|
);
|
|
9259
9289
|
runInAction(() => {
|
|
@@ -9263,13 +9293,13 @@ alias:${this.alias}
|
|
|
9263
9293
|
if (this.shouldAttemptReconnection(code)) {
|
|
9264
9294
|
this.onConnectionLost?.();
|
|
9265
9295
|
} else {
|
|
9266
|
-
|
|
9296
|
+
log$K.info(
|
|
9267
9297
|
`Not reconnecting due to close code ${code} (intentional close or configuration error)`
|
|
9268
9298
|
);
|
|
9269
9299
|
}
|
|
9270
9300
|
}
|
|
9271
9301
|
onError(ev) {
|
|
9272
|
-
|
|
9302
|
+
log$K.error(`websocket error: `, ev);
|
|
9273
9303
|
publish("websocket.error", { event: ev });
|
|
9274
9304
|
}
|
|
9275
9305
|
/**
|
|
@@ -9314,7 +9344,7 @@ alias:${this.alias}
|
|
|
9314
9344
|
}
|
|
9315
9345
|
}
|
|
9316
9346
|
send(data) {
|
|
9317
|
-
|
|
9347
|
+
messageLog.debug("sent", data);
|
|
9318
9348
|
if (window.kosLogEvents) {
|
|
9319
9349
|
const { headers, body } = processKosMessage(String(data));
|
|
9320
9350
|
publish(KosWsEvents.SEND, { headers, body });
|
|
@@ -9322,6 +9352,10 @@ alias:${this.alias}
|
|
|
9322
9352
|
this.oldSend.call(this.socket, data);
|
|
9323
9353
|
}
|
|
9324
9354
|
}
|
|
9355
|
+
const log$J = KosLog.createLogger({
|
|
9356
|
+
group: LogGroup.transport,
|
|
9357
|
+
name: "bridge-transport"
|
|
9358
|
+
});
|
|
9325
9359
|
class BridgeTransport {
|
|
9326
9360
|
addEventListener;
|
|
9327
9361
|
dispatchEvent;
|
|
@@ -9333,7 +9367,7 @@ class BridgeTransport {
|
|
|
9333
9367
|
messageQueue = [];
|
|
9334
9368
|
isSending = false;
|
|
9335
9369
|
constructor(addr) {
|
|
9336
|
-
log$
|
|
9370
|
+
log$J.debug(`called Bridge Transport with addr ${addr}`);
|
|
9337
9371
|
const that = this;
|
|
9338
9372
|
globalThis.kosWindowWebsocketRecv = (msg) => {
|
|
9339
9373
|
if (that.onmessage) {
|
|
@@ -9341,19 +9375,19 @@ class BridgeTransport {
|
|
|
9341
9375
|
that.onmessage(data);
|
|
9342
9376
|
}
|
|
9343
9377
|
};
|
|
9344
|
-
log$
|
|
9378
|
+
log$J.debug("Opening bridge transport");
|
|
9345
9379
|
globalThis.kosWindowWebsocketOpen();
|
|
9346
|
-
log$
|
|
9380
|
+
log$J.debug("Opened bridge transport");
|
|
9347
9381
|
this._onclose = null;
|
|
9348
9382
|
this._onerror = null;
|
|
9349
9383
|
this._onmessage = null;
|
|
9350
9384
|
this._onopen = null;
|
|
9351
|
-
this.addEventListener = () => log$
|
|
9352
|
-
this.dispatchEvent = () => log$
|
|
9353
|
-
this.removeEventListener = () => log$
|
|
9385
|
+
this.addEventListener = () => log$J.debug("not implemented");
|
|
9386
|
+
this.dispatchEvent = () => log$J.debug("not implemented");
|
|
9387
|
+
this.removeEventListener = () => log$J.debug("not implemented");
|
|
9354
9388
|
}
|
|
9355
9389
|
close() {
|
|
9356
|
-
log$
|
|
9390
|
+
log$J.debug("closing");
|
|
9357
9391
|
}
|
|
9358
9392
|
sendNextMessage() {
|
|
9359
9393
|
if (this.messageQueue.length > 0) {
|
|
@@ -9440,6 +9474,10 @@ class KosTransport extends BaseTransport {
|
|
|
9440
9474
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9441
9475
|
}
|
|
9442
9476
|
}
|
|
9477
|
+
const log$I = KosLog.createLogger({
|
|
9478
|
+
group: LogGroup.transport,
|
|
9479
|
+
name: "standalone-mock-socket"
|
|
9480
|
+
});
|
|
9443
9481
|
const LOGGED_IN_FRAME = `topic:/studioServer/auth/LOGGED_IN
|
|
9444
9482
|
type:kos.broker.topic
|
|
9445
9483
|
|
|
@@ -9450,7 +9488,7 @@ class StandaloneMockSocket {
|
|
|
9450
9488
|
onmessage = null;
|
|
9451
9489
|
onopen = null;
|
|
9452
9490
|
constructor(url) {
|
|
9453
|
-
|
|
9491
|
+
log$I.info(`KosMock standalone socket replacing ${url}`);
|
|
9454
9492
|
setTimeout(async () => {
|
|
9455
9493
|
await kosMockRegistry.bootGate;
|
|
9456
9494
|
this.onopen?.({ currentTarget: this });
|
|
@@ -9461,7 +9499,7 @@ class StandaloneMockSocket {
|
|
|
9461
9499
|
}
|
|
9462
9500
|
send(data) {
|
|
9463
9501
|
if (peekFrameType(data) === KOS_HTTP_REQUEST_TYPE) {
|
|
9464
|
-
|
|
9502
|
+
log$I.warn(
|
|
9465
9503
|
`KosMock standalone: unmatched request reached the loopback socket and will hang — add a route or use onUnmatched: "respond404"`,
|
|
9466
9504
|
String(data).split("\n", 2).join(" ")
|
|
9467
9505
|
);
|
|
@@ -9499,6 +9537,10 @@ class MockMessageTransport extends BaseTransport {
|
|
|
9499
9537
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9500
9538
|
}
|
|
9501
9539
|
}
|
|
9540
|
+
const log$H = KosLog.createLogger({
|
|
9541
|
+
group: LogGroup.transport,
|
|
9542
|
+
name: "transport-factory"
|
|
9543
|
+
});
|
|
9502
9544
|
window.kosLogEvents = process.env.KOS_LOG_WS === "true";
|
|
9503
9545
|
class TransportFactory {
|
|
9504
9546
|
static build({
|
|
@@ -9510,13 +9552,13 @@ class TransportFactory {
|
|
|
9510
9552
|
onConnectionEstablished,
|
|
9511
9553
|
onConnectionLost
|
|
9512
9554
|
}) {
|
|
9513
|
-
|
|
9514
|
-
|
|
9555
|
+
log$H.debug(`initializing websocket connection`);
|
|
9556
|
+
log$H.warn(
|
|
9515
9557
|
`kosWindowWebsocketOpen: ${globalThis.kosWindowWebsocketOpen ? `true` : `false`}`
|
|
9516
9558
|
);
|
|
9517
|
-
|
|
9559
|
+
log$H.warn(`fos: ${fos ? `true` : `false`}`);
|
|
9518
9560
|
if (KosMock.standalone && !fos) {
|
|
9519
|
-
|
|
9561
|
+
log$H.warn(`Using KosMock standalone transport`);
|
|
9520
9562
|
return new MockMessageTransport({
|
|
9521
9563
|
host,
|
|
9522
9564
|
port,
|
|
@@ -9527,7 +9569,7 @@ class TransportFactory {
|
|
|
9527
9569
|
});
|
|
9528
9570
|
}
|
|
9529
9571
|
if (globalThis.kosWindowWebsocketOpen && !fos) {
|
|
9530
|
-
|
|
9572
|
+
log$H.warn(`Using bridged message transport`);
|
|
9531
9573
|
const transport = new BridgeMessageTransport({
|
|
9532
9574
|
host,
|
|
9533
9575
|
port,
|
|
@@ -9568,7 +9610,10 @@ if (params$1.fos) {
|
|
|
9568
9610
|
const fosPort = process.env.KOS_FOS_PORT;
|
|
9569
9611
|
window.kosUseFos = !!(window.kosUseFos || process.env.KOS_USE_FOS === "true");
|
|
9570
9612
|
window.kosFosPort = fosPort ? parseInt(fosPort) : 0;
|
|
9571
|
-
const log$
|
|
9613
|
+
const log$G = KosLog.createLogger({
|
|
9614
|
+
group: LogGroup.transport,
|
|
9615
|
+
name: "web-socket-transport"
|
|
9616
|
+
});
|
|
9572
9617
|
var KosWSTransportStatus = /* @__PURE__ */ ((KosWSTransportStatus2) => {
|
|
9573
9618
|
KosWSTransportStatus2["NOT_INITIALIZED"] = "not_initialized";
|
|
9574
9619
|
KosWSTransportStatus2["INITIALIZED"] = "initialized";
|
|
@@ -9625,7 +9670,7 @@ class WebSocketTransport {
|
|
|
9625
9670
|
() => this.connectionEstablished,
|
|
9626
9671
|
(connectionEstablished) => {
|
|
9627
9672
|
if (connectionEstablished) {
|
|
9628
|
-
log$
|
|
9673
|
+
log$G.warn("Connection Established");
|
|
9629
9674
|
this.reconnectAttempts = 0;
|
|
9630
9675
|
publish(WebSocketEvents.CONNECTED, {
|
|
9631
9676
|
reconnect: initialized
|
|
@@ -9657,7 +9702,7 @@ class WebSocketTransport {
|
|
|
9657
9702
|
return false;
|
|
9658
9703
|
}
|
|
9659
9704
|
init() {
|
|
9660
|
-
|
|
9705
|
+
log$G.warn(`Initializing WebSocketTransport on ${this.host}:${this.port}`);
|
|
9661
9706
|
if (this.useFosTransport) {
|
|
9662
9707
|
this.fosSocket = TransportFactory.build({
|
|
9663
9708
|
host: this.host,
|
|
@@ -9672,7 +9717,7 @@ class WebSocketTransport {
|
|
|
9672
9717
|
protocol: this.protocol,
|
|
9673
9718
|
alias: this.alias,
|
|
9674
9719
|
onConnectionLost: () => {
|
|
9675
|
-
log$
|
|
9720
|
+
log$G.error(`Connection Lost`);
|
|
9676
9721
|
this.scheduleReconnect();
|
|
9677
9722
|
}
|
|
9678
9723
|
});
|
|
@@ -9692,7 +9737,7 @@ class WebSocketTransport {
|
|
|
9692
9737
|
*/
|
|
9693
9738
|
scheduleReconnect() {
|
|
9694
9739
|
if (this.reconnectAttempts >= WebSocketTransport.MAX_RECONNECT_ATTEMPTS) {
|
|
9695
|
-
|
|
9740
|
+
log$G.error(
|
|
9696
9741
|
`Max reconnection attempts (${WebSocketTransport.MAX_RECONNECT_ATTEMPTS}) reached. Giving up.`
|
|
9697
9742
|
);
|
|
9698
9743
|
publish(WebSocketEvents.MAX_RETRIES_EXCEEDED, {
|
|
@@ -9701,7 +9746,7 @@ class WebSocketTransport {
|
|
|
9701
9746
|
return;
|
|
9702
9747
|
}
|
|
9703
9748
|
const delay2 = this.calculateBackoffDelay();
|
|
9704
|
-
|
|
9749
|
+
log$G.debug(
|
|
9705
9750
|
`Reconnecting in ${delay2}ms (attempt ${this.reconnectAttempts + 1}/${WebSocketTransport.MAX_RECONNECT_ATTEMPTS})`
|
|
9706
9751
|
);
|
|
9707
9752
|
setTimeout(() => {
|
|
@@ -9718,7 +9763,7 @@ class WebSocketTransport {
|
|
|
9718
9763
|
return Math.floor(exponentialDelay + jitter);
|
|
9719
9764
|
}
|
|
9720
9765
|
_sendSubscriptionMessage(topic, type, fos = false, bridge = false, connectionId, explicitDestination = false) {
|
|
9721
|
-
log$
|
|
9766
|
+
log$G.debug(`${type} to topic ${topic}`);
|
|
9722
9767
|
let connId;
|
|
9723
9768
|
if (explicitDestination) {
|
|
9724
9769
|
connId = connectionId;
|
|
@@ -9727,7 +9772,7 @@ class WebSocketTransport {
|
|
|
9727
9772
|
const connectionParam = params2?.connId;
|
|
9728
9773
|
connId = connectionId ?? connectionParam ?? window?.kosBridge?.("connId");
|
|
9729
9774
|
}
|
|
9730
|
-
log$
|
|
9775
|
+
log$G.debug(`subscribing with connId ${connId}`);
|
|
9731
9776
|
const dstAddr = connId ? `dst-addr:${connId}
|
|
9732
9777
|
` : "";
|
|
9733
9778
|
const msg = fos ? `subscribe:${topic}` : bridge ? `type:fos.broker
|
|
@@ -9741,7 +9786,7 @@ ${dstAddr}topics:${topic}
|
|
|
9741
9786
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9742
9787
|
socket?.socket?.send(msg);
|
|
9743
9788
|
} else {
|
|
9744
|
-
log$
|
|
9789
|
+
log$G.debug(`no connection adding to offline messages`);
|
|
9745
9790
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9746
9791
|
socket?.addOfflineMessage(msg);
|
|
9747
9792
|
}
|
|
@@ -9755,7 +9800,7 @@ ${dstAddr}topics:${topic}
|
|
|
9755
9800
|
explicitDestination
|
|
9756
9801
|
}) {
|
|
9757
9802
|
const { unsubscribe, count } = subscribe(topic, callback);
|
|
9758
|
-
log$
|
|
9803
|
+
log$G.debug(`Topic ${topic} currently has ${count} subscribers`);
|
|
9759
9804
|
this._sendSubscriptionMessage(
|
|
9760
9805
|
topic,
|
|
9761
9806
|
"subscribe",
|
|
@@ -9766,7 +9811,7 @@ ${dstAddr}topics:${topic}
|
|
|
9766
9811
|
);
|
|
9767
9812
|
return () => {
|
|
9768
9813
|
const { count: count2 } = unsubscribe();
|
|
9769
|
-
log$
|
|
9814
|
+
log$G.debug(`Topic ${topic} currently has ${count2} subscribers`);
|
|
9770
9815
|
if (count2 === 0) {
|
|
9771
9816
|
this._sendSubscriptionMessage(
|
|
9772
9817
|
topic,
|
|
@@ -9806,7 +9851,7 @@ ${dstAddr}topics:${topic}
|
|
|
9806
9851
|
}
|
|
9807
9852
|
dropConnection() {
|
|
9808
9853
|
if (!this.connectionEstablished) {
|
|
9809
|
-
log$
|
|
9854
|
+
log$G.debug("dropConnection ignored: the connection is already closed");
|
|
9810
9855
|
return;
|
|
9811
9856
|
}
|
|
9812
9857
|
this.socket?.socket.close(1e3);
|
|
@@ -10592,21 +10637,17 @@ class ServiceResponseStore {
|
|
|
10592
10637
|
class KosModelComponentFactory {
|
|
10593
10638
|
static createAll(model) {
|
|
10594
10639
|
const { modelId, modelTypeName, modelData } = model;
|
|
10595
|
-
const log3 = KosLoggerFactory.create({
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
const fsm2 = new KosFSMManager(model, createTaggedLogger(log3, "fsm"));
|
|
10600
|
-
const offlineQueue = new KosOfflineQueue(
|
|
10601
|
-
createTaggedLogger(log3, "offline-queue")
|
|
10602
|
-
);
|
|
10640
|
+
const log3 = KosLoggerFactory.create({ modelTypeName });
|
|
10641
|
+
const tagged = (tag) => createTaggedLogger(log3, `${modelId}:${tag}`);
|
|
10642
|
+
const fsm2 = new KosFSMManager(model, tagged("fsm"));
|
|
10643
|
+
const offlineQueue = new KosOfflineQueue(tagged("offline-queue"));
|
|
10603
10644
|
const companionManager = new KosCompanionModelManager(model);
|
|
10604
10645
|
const childResolver = new KosChildResolver(model);
|
|
10605
10646
|
const serviceResponseStore = new ServiceResponseStore();
|
|
10606
10647
|
modelData.serviceResponses = serviceResponseStore;
|
|
10607
10648
|
const onlineLifecycleManager = new KosOnlineLifecycleManager(
|
|
10608
10649
|
model,
|
|
10609
|
-
|
|
10650
|
+
tagged("online")
|
|
10610
10651
|
);
|
|
10611
10652
|
const components = {
|
|
10612
10653
|
fsm: fsm2,
|
|
@@ -10621,11 +10662,11 @@ class KosModelComponentFactory {
|
|
|
10621
10662
|
modelTypeName,
|
|
10622
10663
|
modelId,
|
|
10623
10664
|
modelData,
|
|
10624
|
-
|
|
10665
|
+
tagged("effect")
|
|
10625
10666
|
);
|
|
10626
10667
|
}
|
|
10627
10668
|
if (hasSubscriptionHandlers(modelData)) {
|
|
10628
|
-
const subLogger =
|
|
10669
|
+
const subLogger = tagged("subscription");
|
|
10629
10670
|
components.subscriptionManager = new KosSubscriptionManager(
|
|
10630
10671
|
model,
|
|
10631
10672
|
modelData,
|
|
@@ -10637,7 +10678,7 @@ class KosModelComponentFactory {
|
|
|
10637
10678
|
if (hasHttpRouteHandlers(modelData)) {
|
|
10638
10679
|
components.httpRouteManager = new KosHttpRouteManager(
|
|
10639
10680
|
modelData,
|
|
10640
|
-
|
|
10681
|
+
tagged("http-routes")
|
|
10641
10682
|
);
|
|
10642
10683
|
}
|
|
10643
10684
|
if (hasServiceRequestHandlers(modelData)) {
|
|
@@ -10650,7 +10691,7 @@ class KosModelComponentFactory {
|
|
|
10650
10691
|
return components;
|
|
10651
10692
|
}
|
|
10652
10693
|
}
|
|
10653
|
-
const log$
|
|
10694
|
+
const log$F = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
10654
10695
|
const MODEL_LOADER = "kos.extension.model.loader";
|
|
10655
10696
|
class KosModel {
|
|
10656
10697
|
_id;
|
|
@@ -10758,23 +10799,23 @@ class KosModel {
|
|
|
10758
10799
|
return this._status === KosModelState.READY;
|
|
10759
10800
|
}
|
|
10760
10801
|
async deactivate() {
|
|
10761
|
-
log$
|
|
10802
|
+
log$F.debug(
|
|
10762
10803
|
`deactivating model ${this.modelTypeName} with id ${this.modelId}`
|
|
10763
10804
|
);
|
|
10764
10805
|
try {
|
|
10765
10806
|
const context = KosContextManager.getContext(this.modelId);
|
|
10766
10807
|
await this.modelData?.deactivate?.(context);
|
|
10767
|
-
log$
|
|
10808
|
+
log$F.debug(
|
|
10768
10809
|
`Model ${this.modelTypeName} with id ${this.modelId} deactivated`
|
|
10769
10810
|
);
|
|
10770
10811
|
this.subscriptionManager?.deactivate();
|
|
10771
10812
|
} catch (e) {
|
|
10772
|
-
log$
|
|
10813
|
+
log$F.debug(`Model ${this.modelId} failed to deactivated`);
|
|
10773
10814
|
throw e;
|
|
10774
10815
|
}
|
|
10775
10816
|
}
|
|
10776
10817
|
async activate() {
|
|
10777
|
-
log$
|
|
10818
|
+
log$F.debug(`activating model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10778
10819
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ACTIVATE);
|
|
10779
10820
|
try {
|
|
10780
10821
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10783,16 +10824,16 @@ class KosModel {
|
|
|
10783
10824
|
const context = KosContextManager.getContext(this.modelId);
|
|
10784
10825
|
await this.modelData?.activate?.(context);
|
|
10785
10826
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.ACTIVATE);
|
|
10786
|
-
log$
|
|
10827
|
+
log$F.debug(
|
|
10787
10828
|
`Model ${this.modelTypeName} with id ${this.modelId} subscribing to all topics`
|
|
10788
10829
|
);
|
|
10789
10830
|
this.subscriptionManager?.registerAll(DependencyLifecycle.ACTIVATE);
|
|
10790
10831
|
this.createLifecycleCompanions(DependencyLifecycle.ACTIVATE);
|
|
10791
|
-
log$
|
|
10832
|
+
log$F.debug(
|
|
10792
10833
|
`Model ${this.modelTypeName} with id ${this.modelId} activated`
|
|
10793
10834
|
);
|
|
10794
10835
|
} catch (e) {
|
|
10795
|
-
log$
|
|
10836
|
+
log$F.debug(`Model ${this.modelId} failed to activate`);
|
|
10796
10837
|
throw e;
|
|
10797
10838
|
}
|
|
10798
10839
|
return;
|
|
@@ -10808,7 +10849,7 @@ class KosModel {
|
|
|
10808
10849
|
{
|
|
10809
10850
|
condition: () => this.loaded,
|
|
10810
10851
|
onMatch: () => {
|
|
10811
|
-
log$
|
|
10852
|
+
log$F.debug(`Model ${this.modelId} is loaded`);
|
|
10812
10853
|
}
|
|
10813
10854
|
}
|
|
10814
10855
|
]);
|
|
@@ -10824,7 +10865,7 @@ class KosModel {
|
|
|
10824
10865
|
{
|
|
10825
10866
|
condition: () => this.initialized,
|
|
10826
10867
|
onMatch: () => {
|
|
10827
|
-
log$
|
|
10868
|
+
log$F.debug(`Model ${this.modelId} is initialized`);
|
|
10828
10869
|
}
|
|
10829
10870
|
}
|
|
10830
10871
|
]);
|
|
@@ -10840,20 +10881,20 @@ class KosModel {
|
|
|
10840
10881
|
{
|
|
10841
10882
|
condition: () => this.status === KosModelState.READY,
|
|
10842
10883
|
onMatch: () => {
|
|
10843
|
-
log$
|
|
10884
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10844
10885
|
}
|
|
10845
10886
|
}
|
|
10846
10887
|
]);
|
|
10847
10888
|
}
|
|
10848
10889
|
async ready() {
|
|
10849
10890
|
if (this.fsm.current === KosModelState.READY) {
|
|
10850
|
-
log$
|
|
10891
|
+
log$F.debug(
|
|
10851
10892
|
`already readying model ${this.modelTypeName} with id ${this.modelId} returning`
|
|
10852
10893
|
);
|
|
10853
10894
|
return;
|
|
10854
10895
|
}
|
|
10855
10896
|
try {
|
|
10856
|
-
log$
|
|
10897
|
+
log$F.debug(`readying model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10857
10898
|
await executeDependentModelLifecycle(this, DependencyLifecycle.READY);
|
|
10858
10899
|
await executeChildrenModelLifecycle(
|
|
10859
10900
|
this,
|
|
@@ -10869,7 +10910,7 @@ class KosModel {
|
|
|
10869
10910
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.READY);
|
|
10870
10911
|
this.subscriptionManager?.registerAll(DependencyLifecycle.READY);
|
|
10871
10912
|
this.createLifecycleCompanions(DependencyLifecycle.READY);
|
|
10872
|
-
log$
|
|
10913
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10873
10914
|
const payload = {
|
|
10874
10915
|
modelId: this.modelId,
|
|
10875
10916
|
modelType: this.modelTypeName
|
|
@@ -10880,7 +10921,7 @@ class KosModel {
|
|
|
10880
10921
|
);
|
|
10881
10922
|
publish(modelTypeEventTopicFactory(this.modelTypeName), payload);
|
|
10882
10923
|
} catch (e) {
|
|
10883
|
-
log$
|
|
10924
|
+
log$F.error(e);
|
|
10884
10925
|
throw Error(e);
|
|
10885
10926
|
}
|
|
10886
10927
|
}
|
|
@@ -10891,18 +10932,18 @@ class KosModel {
|
|
|
10891
10932
|
}
|
|
10892
10933
|
const { modelTypeName, modelId } = this;
|
|
10893
10934
|
if (this.fsm.current === KosModelState.LOADED) {
|
|
10894
|
-
log$
|
|
10935
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} already loaded`);
|
|
10895
10936
|
return;
|
|
10896
10937
|
}
|
|
10897
10938
|
if (this._isLoadExecuting) {
|
|
10898
|
-
log$
|
|
10939
|
+
log$F.debug(
|
|
10899
10940
|
`Model ${modelTypeName} with id ${modelId} is currently executing load`
|
|
10900
10941
|
);
|
|
10901
10942
|
return;
|
|
10902
10943
|
}
|
|
10903
10944
|
this._isLoadExecuting = true;
|
|
10904
10945
|
try {
|
|
10905
|
-
log$
|
|
10946
|
+
log$F.debug(`Loading model ${modelTypeName} with id ${modelId}`);
|
|
10906
10947
|
await executeDependentModelLifecycle(this, DependencyLifecycle.LOAD);
|
|
10907
10948
|
const context = KosContextManager.getContext(modelId);
|
|
10908
10949
|
const MODEL_LOADER_TYPE = `${MODEL_LOADER}.${modelTypeName}`;
|
|
@@ -10911,7 +10952,7 @@ class KosModel {
|
|
|
10911
10952
|
{}
|
|
10912
10953
|
);
|
|
10913
10954
|
if (loadedContext) {
|
|
10914
|
-
log$
|
|
10955
|
+
log$F.info(
|
|
10915
10956
|
`Setting loaded context for ${modelId}, type: ${modelTypeName}`
|
|
10916
10957
|
);
|
|
10917
10958
|
context?.set(MODEL_LOADER_TYPE, loadedContext);
|
|
@@ -10923,7 +10964,7 @@ class KosModel {
|
|
|
10923
10964
|
kosAction(() => {
|
|
10924
10965
|
this.loaded = true;
|
|
10925
10966
|
});
|
|
10926
|
-
log$
|
|
10967
|
+
log$F.debug(
|
|
10927
10968
|
`Model ${modelTypeName} with id ${modelId} successfully loaded`
|
|
10928
10969
|
);
|
|
10929
10970
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.LOAD);
|
|
@@ -10932,14 +10973,14 @@ class KosModel {
|
|
|
10932
10973
|
this.effectManager?.setup();
|
|
10933
10974
|
this.createLifecycleCompanions(DependencyLifecycle.LOAD);
|
|
10934
10975
|
} catch (e) {
|
|
10935
|
-
log$
|
|
10976
|
+
log$F.error(`Model ${modelId} failed to load`, e);
|
|
10936
10977
|
throw e;
|
|
10937
10978
|
} finally {
|
|
10938
10979
|
this._isLoadExecuting = false;
|
|
10939
10980
|
}
|
|
10940
10981
|
}
|
|
10941
10982
|
async unload() {
|
|
10942
|
-
log$
|
|
10983
|
+
log$F.debug(`unloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10943
10984
|
try {
|
|
10944
10985
|
const childrenUnload = this.getChildren().map((child) => child.unload?.()).filter((p) => !!p);
|
|
10945
10986
|
await Promise.allSettled(childrenUnload);
|
|
@@ -10958,12 +10999,12 @@ class KosModel {
|
|
|
10958
10999
|
modelData.stateHistory = [];
|
|
10959
11000
|
}
|
|
10960
11001
|
}
|
|
10961
|
-
log$
|
|
11002
|
+
log$F.debug(`Model ${this.modelTypeName} with id ${this.modelId} unloaded`);
|
|
10962
11003
|
this.effectManager?.disposeAll();
|
|
10963
11004
|
this.subscriptionManager?.disposeAll();
|
|
10964
11005
|
this.httpRouteManager?.dispose();
|
|
10965
11006
|
} catch (e) {
|
|
10966
|
-
log$
|
|
11007
|
+
log$F.debug(`Model ${this.modelId} failed to unload`);
|
|
10967
11008
|
throw e;
|
|
10968
11009
|
}
|
|
10969
11010
|
}
|
|
@@ -10974,7 +11015,7 @@ class KosModel {
|
|
|
10974
11015
|
}
|
|
10975
11016
|
const { modelId, modelTypeName } = this;
|
|
10976
11017
|
const context = KosContextManager.getContext(modelId);
|
|
10977
|
-
log$
|
|
11018
|
+
log$F.debug(`Initializing model ${modelTypeName} with id ${modelId}`);
|
|
10978
11019
|
await executeDependentModelLifecycle(this, DependencyLifecycle.INIT);
|
|
10979
11020
|
try {
|
|
10980
11021
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10982,18 +11023,18 @@ class KosModel {
|
|
|
10982
11023
|
);
|
|
10983
11024
|
await this.modelData?.init?.(context);
|
|
10984
11025
|
this.initialized = true;
|
|
10985
|
-
log$
|
|
11026
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} initialized`);
|
|
10986
11027
|
this.onlineLifecycleManager?.register();
|
|
10987
11028
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.INIT);
|
|
10988
11029
|
this.registerSubscribers(DependencyLifecycle.INIT);
|
|
10989
11030
|
this.createLifecycleCompanions(DependencyLifecycle.INIT);
|
|
10990
11031
|
} catch (e) {
|
|
10991
|
-
log$
|
|
11032
|
+
log$F.error(`Model ${modelId} failed to initialize`, e);
|
|
10992
11033
|
throw e;
|
|
10993
11034
|
}
|
|
10994
11035
|
}
|
|
10995
11036
|
async registerSubscribers(lifecycle) {
|
|
10996
|
-
log$
|
|
11037
|
+
log$F.debug(
|
|
10997
11038
|
`registering subscribers in ${this.modelTypeName} with id ${this.modelId}`
|
|
10998
11039
|
);
|
|
10999
11040
|
this.subscriptionManager?.registerAll(lifecycle);
|
|
@@ -11010,7 +11051,7 @@ class KosModel {
|
|
|
11010
11051
|
}
|
|
11011
11052
|
/** @internal */
|
|
11012
11053
|
async reloadData() {
|
|
11013
|
-
log$
|
|
11054
|
+
log$F.info(`reloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11014
11055
|
this.suspendForReload();
|
|
11015
11056
|
const data = this.modelData;
|
|
11016
11057
|
if (typeof data?.reload === "function" && !data[SelfManagedReload]) {
|
|
@@ -11019,7 +11060,7 @@ class KosModel {
|
|
|
11019
11060
|
}
|
|
11020
11061
|
/** @internal */
|
|
11021
11062
|
async reattach() {
|
|
11022
|
-
log$
|
|
11063
|
+
log$F.info(`reattaching model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11023
11064
|
kosAction(() => {
|
|
11024
11065
|
this.loaded = true;
|
|
11025
11066
|
});
|
|
@@ -11050,7 +11091,7 @@ class KosModel {
|
|
|
11050
11091
|
]);
|
|
11051
11092
|
reloaded.forEach((result, index) => {
|
|
11052
11093
|
if (result.status === "rejected") {
|
|
11053
|
-
log$
|
|
11094
|
+
log$F.error(
|
|
11054
11095
|
`reload of child ${ready[index].modelId} of ${this.modelId} failed`,
|
|
11055
11096
|
result.reason
|
|
11056
11097
|
);
|
|
@@ -11081,7 +11122,7 @@ class KosModel {
|
|
|
11081
11122
|
* each time. A state machine with `initializeAt: ONLINE` starts once.
|
|
11082
11123
|
*/
|
|
11083
11124
|
async online() {
|
|
11084
|
-
log$
|
|
11125
|
+
log$F.debug(`online model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11085
11126
|
this.registerSubscribers();
|
|
11086
11127
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ONLINE);
|
|
11087
11128
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -11093,7 +11134,7 @@ class KosModel {
|
|
|
11093
11134
|
this.createLifecycleCompanions(DependencyLifecycle.ONLINE);
|
|
11094
11135
|
}
|
|
11095
11136
|
async offline() {
|
|
11096
|
-
log$
|
|
11137
|
+
log$F.debug(`offline model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11097
11138
|
this.subscriptionManager?.disposeAll();
|
|
11098
11139
|
const context = KosContextManager.getContext(this.modelId);
|
|
11099
11140
|
await this.modelData?.offline?.(context);
|
|
@@ -11111,7 +11152,7 @@ class KosModel {
|
|
|
11111
11152
|
this.companionManager.clear();
|
|
11112
11153
|
}
|
|
11113
11154
|
}
|
|
11114
|
-
const log$
|
|
11155
|
+
const log$E = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-instantiator" });
|
|
11115
11156
|
class KosModelInstantiator {
|
|
11116
11157
|
constructor(registry, cache2) {
|
|
11117
11158
|
this.registry = registry;
|
|
@@ -11129,7 +11170,7 @@ class KosModelInstantiator {
|
|
|
11129
11170
|
const modelRegistry = this.registry.models[typeId];
|
|
11130
11171
|
if (!modelRegistry) {
|
|
11131
11172
|
const errorMessage = `No model registered for type ${typeId}`;
|
|
11132
|
-
log$
|
|
11173
|
+
log$E.error(errorMessage, {
|
|
11133
11174
|
modelType: typeId,
|
|
11134
11175
|
requestedId: id,
|
|
11135
11176
|
providedOptions: options,
|
|
@@ -11148,7 +11189,7 @@ class KosModelInstantiator {
|
|
|
11148
11189
|
const modelId = modelRegistry.singleton ? typeId : id;
|
|
11149
11190
|
this.cache.restoreFromDeleteCache(modelId);
|
|
11150
11191
|
if (!this.cache.hasModel(modelId)) {
|
|
11151
|
-
log$
|
|
11192
|
+
log$E.debug(`Creating model instance: ${typeId} [${modelId}]`);
|
|
11152
11193
|
const hasOptions = options && Object.keys(options).length > 0;
|
|
11153
11194
|
const modelClass = modelRegistry.class || modelRegistry.create;
|
|
11154
11195
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
@@ -11194,7 +11235,7 @@ class KosModelInstantiator {
|
|
|
11194
11235
|
}
|
|
11195
11236
|
const activeModel = this.cache.getModelById(modelId);
|
|
11196
11237
|
if (!activeModel) {
|
|
11197
|
-
log$
|
|
11238
|
+
log$E.error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11198
11239
|
throw new Error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11199
11240
|
}
|
|
11200
11241
|
return { model: activeModel, data: activeModel.modelData };
|
|
@@ -11260,7 +11301,7 @@ let KosModelRegistry$1 = class KosModelRegistry {
|
|
|
11260
11301
|
}
|
|
11261
11302
|
};
|
|
11262
11303
|
const MODEL_DELETION_DELAY = 10;
|
|
11263
|
-
const log$
|
|
11304
|
+
const log$D = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-manager" });
|
|
11264
11305
|
class KosModelManager {
|
|
11265
11306
|
cache;
|
|
11266
11307
|
instantiator;
|
|
@@ -11303,7 +11344,7 @@ class KosModelManager {
|
|
|
11303
11344
|
}
|
|
11304
11345
|
static getInstance(reset2) {
|
|
11305
11346
|
if (!globalThis.kos?.modelManager || reset2) {
|
|
11306
|
-
log$
|
|
11347
|
+
log$D.debug("Creating new instance of KosModelManager");
|
|
11307
11348
|
new this();
|
|
11308
11349
|
}
|
|
11309
11350
|
return globalThis.kos?.modelManager;
|
|
@@ -11324,7 +11365,7 @@ class KosModelManager {
|
|
|
11324
11365
|
*/
|
|
11325
11366
|
get preloadedModels() {
|
|
11326
11367
|
return this.cache.preload((modelKey) => {
|
|
11327
|
-
log$
|
|
11368
|
+
log$D.debug(`preloading ${modelKey}`);
|
|
11328
11369
|
if (typeof modelKey === "string") {
|
|
11329
11370
|
return this.createModelInstance(modelKey).model;
|
|
11330
11371
|
} else {
|
|
@@ -11620,6 +11661,10 @@ class KosModelManager {
|
|
|
11620
11661
|
this._registry.registerModel(reg);
|
|
11621
11662
|
}
|
|
11622
11663
|
}
|
|
11664
|
+
const log$C = KosLog.createLogger({
|
|
11665
|
+
group: LogGroup.core,
|
|
11666
|
+
name: "kos-core-lifecycle"
|
|
11667
|
+
});
|
|
11623
11668
|
var KosCoreState = /* @__PURE__ */ ((KosCoreState2) => {
|
|
11624
11669
|
KosCoreState2["CREATING"] = `creating`;
|
|
11625
11670
|
KosCoreState2["CREATED"] = `created`;
|
|
@@ -11656,7 +11701,7 @@ const reportFailure = async (step, run) => {
|
|
|
11656
11701
|
return await run();
|
|
11657
11702
|
} catch (error) {
|
|
11658
11703
|
const detail = error instanceof Error ? error.stack ?? `${error.name}: ${error.message}` : String(error);
|
|
11659
|
-
log$
|
|
11704
|
+
log$C.error(`KOS Core lifecycle step "${step}" failed. ${detail}`);
|
|
11660
11705
|
throw error;
|
|
11661
11706
|
}
|
|
11662
11707
|
};
|
|
@@ -11695,7 +11740,7 @@ const coreFsm = (core) => {
|
|
|
11695
11740
|
});
|
|
11696
11741
|
const online = interpret(
|
|
11697
11742
|
onlineMachine2,
|
|
11698
|
-
(_service) => log$
|
|
11743
|
+
(_service) => log$C.debug(`KOS Core connection: ${_service.machine.current}`)
|
|
11699
11744
|
);
|
|
11700
11745
|
const syncOnline = () => online.send(
|
|
11701
11746
|
core.transport.connectionEstablished ? "go_online" : "go_offline"
|
|
@@ -11909,11 +11954,11 @@ const coreFsm = (core) => {
|
|
|
11909
11954
|
});
|
|
11910
11955
|
const service2 = interpret(
|
|
11911
11956
|
machine2,
|
|
11912
|
-
(_service) => log$
|
|
11957
|
+
(_service) => log$C.debug(`KOS Core state: ${_service.machine.current}`)
|
|
11913
11958
|
);
|
|
11914
11959
|
return { service: service2, online };
|
|
11915
11960
|
};
|
|
11916
|
-
const log$
|
|
11961
|
+
const log$B = KosLog.createLogger({ group: LogGroup.core, name: "kos-core" });
|
|
11917
11962
|
const getConnectionAlias = () => {
|
|
11918
11963
|
const params2 = getQueryParams();
|
|
11919
11964
|
const alias = params2?.alias;
|
|
@@ -11967,11 +12012,11 @@ const rejectAfterDelay = (ms, model) => {
|
|
|
11967
12012
|
const promise = new Promise((_, reject) => {
|
|
11968
12013
|
timeoutId = setTimeout(() => {
|
|
11969
12014
|
if (model) {
|
|
11970
|
-
|
|
12015
|
+
log$B.error(
|
|
11971
12016
|
`Model ${model.modelId} - ${model.modelTypeName} preloading - timed out after ${ms}ms`
|
|
11972
12017
|
);
|
|
11973
12018
|
} else {
|
|
11974
|
-
|
|
12019
|
+
log$B.error(`KOS Core preloading timed out after ${ms}ms`);
|
|
11975
12020
|
}
|
|
11976
12021
|
reject(
|
|
11977
12022
|
new Error(
|
|
@@ -12056,11 +12101,11 @@ class KosCore {
|
|
|
12056
12101
|
});
|
|
12057
12102
|
});
|
|
12058
12103
|
subscribe(WebSocketEvents.RELOAD, () => {
|
|
12059
|
-
log$
|
|
12104
|
+
log$B.warn("WebSocket requested reload");
|
|
12060
12105
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12061
12106
|
});
|
|
12062
12107
|
subscribe("/studio/project/reload", () => {
|
|
12063
|
-
log$
|
|
12108
|
+
log$B.warn("Project requested reload");
|
|
12064
12109
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12065
12110
|
});
|
|
12066
12111
|
const ws = WebSocketTransport.getInstance();
|
|
@@ -12089,7 +12134,7 @@ class KosCore {
|
|
|
12089
12134
|
applyConnectionAlias(connectionAlias) {
|
|
12090
12135
|
if (this._transport.alias) {
|
|
12091
12136
|
if (this.connectionAlias && this.connectionAlias !== connectionAlias) {
|
|
12092
|
-
log$
|
|
12137
|
+
log$B.warn(
|
|
12093
12138
|
`Connection alias ${connectionAlias} ignored; the connection already uses ${this._transport.alias}`
|
|
12094
12139
|
);
|
|
12095
12140
|
}
|
|
@@ -12127,13 +12172,13 @@ alias:${alias}
|
|
|
12127
12172
|
}
|
|
12128
12173
|
async reload() {
|
|
12129
12174
|
if (this._reloading) {
|
|
12130
|
-
log$
|
|
12175
|
+
log$B.info("reload already in progress");
|
|
12131
12176
|
return;
|
|
12132
12177
|
}
|
|
12133
12178
|
this._reloading = true;
|
|
12134
12179
|
try {
|
|
12135
|
-
log$
|
|
12136
|
-
log$
|
|
12180
|
+
log$B.warn("reloading KOS Core");
|
|
12181
|
+
log$B.warn("reloading preloaded models");
|
|
12137
12182
|
const modelManager = this.modelManager;
|
|
12138
12183
|
const preloaded = [...modelManager.preloadedModels];
|
|
12139
12184
|
const covered = /* @__PURE__ */ new Set();
|
|
@@ -12145,27 +12190,27 @@ alias:${alias}
|
|
|
12145
12190
|
for (const model of preloaded) {
|
|
12146
12191
|
if (isReloadable(model.modelData) && !covered.has(model)) {
|
|
12147
12192
|
if (isSelfManagedReload(model.modelData)) {
|
|
12148
|
-
log$
|
|
12193
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12149
12194
|
continue;
|
|
12150
12195
|
}
|
|
12151
|
-
log$
|
|
12196
|
+
log$B.info(`reloading model ${model.modelId}`);
|
|
12152
12197
|
await reloadRoot(model);
|
|
12153
|
-
log$
|
|
12198
|
+
log$B.info(`reloading model ${model.modelId} complete`);
|
|
12154
12199
|
}
|
|
12155
12200
|
}
|
|
12156
12201
|
for (const model of [...modelManager.models]) {
|
|
12157
12202
|
if (!preloaded.includes(model) && isReloadable(model.modelData) && !covered.has(model)) {
|
|
12158
12203
|
if (isSelfManagedReload(model.modelData)) {
|
|
12159
|
-
log$
|
|
12204
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12160
12205
|
continue;
|
|
12161
12206
|
}
|
|
12162
|
-
log$
|
|
12207
|
+
log$B.warn(`reloading model ${model.modelId}`);
|
|
12163
12208
|
await reloadRoot(model);
|
|
12164
12209
|
}
|
|
12165
12210
|
}
|
|
12166
12211
|
} finally {
|
|
12167
12212
|
runInAction(() => {
|
|
12168
|
-
log$
|
|
12213
|
+
log$B.warn("reloading KOS Core complete");
|
|
12169
12214
|
this._reloading = false;
|
|
12170
12215
|
});
|
|
12171
12216
|
}
|
|
@@ -12175,13 +12220,13 @@ alias:${alias}
|
|
|
12175
12220
|
try {
|
|
12176
12221
|
await model.fsm.reload();
|
|
12177
12222
|
} catch (e) {
|
|
12178
|
-
log$
|
|
12223
|
+
log$B.error(`reload of ${model.modelId} failed`, e);
|
|
12179
12224
|
}
|
|
12180
12225
|
}
|
|
12181
12226
|
async online() {
|
|
12182
|
-
log$
|
|
12227
|
+
log$B.debug("KOS Core going online");
|
|
12183
12228
|
await this._transport.whenReady();
|
|
12184
|
-
log$
|
|
12229
|
+
log$B.debug("KOS Transport Ready. Calling online() for models");
|
|
12185
12230
|
this.modelManager.models.forEach(
|
|
12186
12231
|
(model) => model.onlineLifecycleManager?.register()
|
|
12187
12232
|
);
|
|
@@ -12189,14 +12234,14 @@ alias:${alias}
|
|
|
12189
12234
|
console.timeEnd("kosCore:startup");
|
|
12190
12235
|
}
|
|
12191
12236
|
async offline() {
|
|
12192
|
-
log$
|
|
12237
|
+
log$B.debug("KOS Core going offline");
|
|
12193
12238
|
publish("/kosCore/offline", "/kosCore/offline");
|
|
12194
12239
|
}
|
|
12195
12240
|
async unload() {
|
|
12196
|
-
log$
|
|
12241
|
+
log$B.debug("Unloading KOS Core");
|
|
12197
12242
|
const currentTime = Date.now();
|
|
12198
12243
|
this._unloading = true;
|
|
12199
|
-
log$
|
|
12244
|
+
log$B.debug("unloading KOS Core");
|
|
12200
12245
|
const modelManager = this.modelManager;
|
|
12201
12246
|
for (const model of modelManager.models) {
|
|
12202
12247
|
if (isUnloadable(model.modelData)) {
|
|
@@ -12214,9 +12259,9 @@ alias:${alias}
|
|
|
12214
12259
|
await when(() => this.status === KosCoreState.READY);
|
|
12215
12260
|
}
|
|
12216
12261
|
async ready() {
|
|
12217
|
-
log$
|
|
12262
|
+
log$B.debug("Readying KOS Core");
|
|
12218
12263
|
await this._transport.whenReady();
|
|
12219
|
-
log$
|
|
12264
|
+
log$B.debug("KOS Transport ready. Preloading models");
|
|
12220
12265
|
if (!this.modelManager) {
|
|
12221
12266
|
throw new Error(
|
|
12222
12267
|
"KOS Core reached ready() with no model manager. Its lifecycle was started without a registry."
|
|
@@ -12229,7 +12274,7 @@ alias:${alias}
|
|
|
12229
12274
|
promise: model.whenReady()
|
|
12230
12275
|
};
|
|
12231
12276
|
});
|
|
12232
|
-
log$
|
|
12277
|
+
log$B.debug(`Preloaded ${promises.length} models`);
|
|
12233
12278
|
const settled = await Promise.allSettled(
|
|
12234
12279
|
promises.map((promise) => {
|
|
12235
12280
|
const { promise: timeoutPromise, cancel: timeoutCancel } = rejectAfterDelay(5e3, promise.model);
|
|
@@ -12243,14 +12288,14 @@ alias:${alias}
|
|
|
12243
12288
|
);
|
|
12244
12289
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
12245
12290
|
if (failed.length) {
|
|
12246
|
-
log$
|
|
12291
|
+
log$B.error(
|
|
12247
12292
|
`There were ${failed.length} failed models on model preloading`
|
|
12248
12293
|
);
|
|
12249
12294
|
throw Error(
|
|
12250
12295
|
`There were ${failed.length} failed models on model preloading`
|
|
12251
12296
|
);
|
|
12252
12297
|
}
|
|
12253
|
-
log$
|
|
12298
|
+
log$B.debug(`leaving kos-core ready() `);
|
|
12254
12299
|
}
|
|
12255
12300
|
get isReady() {
|
|
12256
12301
|
return this.status === KosCoreState.READY;
|
|
@@ -12268,19 +12313,19 @@ alias:${alias}
|
|
|
12268
12313
|
return this.loaded;
|
|
12269
12314
|
}
|
|
12270
12315
|
async init() {
|
|
12271
|
-
log$
|
|
12316
|
+
log$B.debug("entering kos-core init()");
|
|
12272
12317
|
console.time("kosCore:startup");
|
|
12273
12318
|
console.time("kosCore:init");
|
|
12274
12319
|
await this._transport.whenReady();
|
|
12275
12320
|
this.initialized = true;
|
|
12276
|
-
log$
|
|
12321
|
+
log$B.debug("initialized - leaving kos-core init()");
|
|
12277
12322
|
console.timeEnd("kosCore:init");
|
|
12278
12323
|
}
|
|
12279
12324
|
async load() {
|
|
12280
|
-
log$
|
|
12325
|
+
log$B.debug("entering kos-core load()");
|
|
12281
12326
|
console.time("kosCore:load");
|
|
12282
12327
|
this.loaded = true;
|
|
12283
|
-
log$
|
|
12328
|
+
log$B.debug("loaded - leaving kos-core load()");
|
|
12284
12329
|
console.timeEnd("kosCore:load");
|
|
12285
12330
|
}
|
|
12286
12331
|
static create(registry, reset2, connectionAlias) {
|
|
@@ -12370,10 +12415,7 @@ alias:${alias}
|
|
|
12370
12415
|
return this._instance;
|
|
12371
12416
|
}
|
|
12372
12417
|
}
|
|
12373
|
-
const log$
|
|
12374
|
-
name: "kos-model-visitor",
|
|
12375
|
-
group: "kos-ui-core"
|
|
12376
|
-
});
|
|
12418
|
+
const log$A = KosLog.createLogger({ group: LogGroup.core, name: "kos-model-visitor" });
|
|
12377
12419
|
class KosModelVisitor {
|
|
12378
12420
|
/**
|
|
12379
12421
|
* A set to keep track of visited model IDs to prevent redundant visits.
|
|
@@ -12411,7 +12453,7 @@ class KosModelVisitor {
|
|
|
12411
12453
|
*/
|
|
12412
12454
|
visit(model) {
|
|
12413
12455
|
if (this.visitedModels.has(model.modelId)) {
|
|
12414
|
-
log$
|
|
12456
|
+
log$A.info(`model ${model.modelId} already visited`);
|
|
12415
12457
|
return;
|
|
12416
12458
|
}
|
|
12417
12459
|
const stopVisiting = !!this.visitModel(model.modelData, this);
|
|
@@ -12424,6 +12466,10 @@ class KosModelVisitor {
|
|
|
12424
12466
|
});
|
|
12425
12467
|
}
|
|
12426
12468
|
}
|
|
12469
|
+
const log$z = KosLog.createLogger({
|
|
12470
|
+
group: LogGroup.core,
|
|
12471
|
+
name: "feature-flags"
|
|
12472
|
+
});
|
|
12427
12473
|
const EXTENSION_FEATURE_FLAG_RESOLVER = "featureFlagResolver";
|
|
12428
12474
|
const flagResolvers = /* @__PURE__ */ new Map();
|
|
12429
12475
|
registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
@@ -12444,7 +12490,7 @@ registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
|
12444
12490
|
if (r.status === "fulfilled") {
|
|
12445
12491
|
return r.value;
|
|
12446
12492
|
} else {
|
|
12447
|
-
|
|
12493
|
+
log$z.info(`Feature flag resolver ${id} failed: ${r.reason}`);
|
|
12448
12494
|
return [];
|
|
12449
12495
|
}
|
|
12450
12496
|
}).flat();
|
|
@@ -12517,7 +12563,38 @@ const modelFactory = (typeId) => {
|
|
|
12517
12563
|
};
|
|
12518
12564
|
};
|
|
12519
12565
|
const pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);
|
|
12520
|
-
const log$
|
|
12566
|
+
const log$y = KosLog.createLogger({
|
|
12567
|
+
group: LogGroup.core,
|
|
12568
|
+
name: "retry-with-exponential-backoff"
|
|
12569
|
+
});
|
|
12570
|
+
const BASE_OPTIONS = {
|
|
12571
|
+
maxAttempts: 5,
|
|
12572
|
+
baseDelayMs: 100,
|
|
12573
|
+
backoffFactor: 1.5
|
|
12574
|
+
};
|
|
12575
|
+
async function retryWithExponentialBackoff(operation, options) {
|
|
12576
|
+
let attempt = 1;
|
|
12577
|
+
const _options = { ...BASE_OPTIONS, ...options };
|
|
12578
|
+
const { maxAttempts, baseDelayMs, backoffFactor } = _options;
|
|
12579
|
+
let delayMs = baseDelayMs;
|
|
12580
|
+
while (attempt <= maxAttempts) {
|
|
12581
|
+
try {
|
|
12582
|
+
const result = await operation();
|
|
12583
|
+
return result;
|
|
12584
|
+
} catch (error) {
|
|
12585
|
+
log$y.error(`Attempt ${attempt} failed: ${error}`);
|
|
12586
|
+
if (attempt < maxAttempts) {
|
|
12587
|
+
delayMs = baseDelayMs * Math.pow(backoffFactor, attempt);
|
|
12588
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
12589
|
+
attempt++;
|
|
12590
|
+
} else {
|
|
12591
|
+
throw error;
|
|
12592
|
+
}
|
|
12593
|
+
}
|
|
12594
|
+
}
|
|
12595
|
+
throw new Error("All attempts failed");
|
|
12596
|
+
}
|
|
12597
|
+
const log$x = KosLog.createLogger({ group: LogGroup.transport, name: "kos-service-request" });
|
|
12521
12598
|
const resolveServiceUrl = (_service) => {
|
|
12522
12599
|
const MOCK = false;
|
|
12523
12600
|
const URL2 = BASE_URL;
|
|
@@ -12689,7 +12766,7 @@ const getOne$7 = (destinationAddress, url, _fetch) => async ({
|
|
|
12689
12766
|
destinationAddress: destinationAddressOverride
|
|
12690
12767
|
});
|
|
12691
12768
|
const resolvedUrl = urlOverride || url;
|
|
12692
|
-
log$
|
|
12769
|
+
log$x.debug(`resolvedUrl: ${resolvedUrl}`);
|
|
12693
12770
|
try {
|
|
12694
12771
|
const response = await _fetch(resolvedUrl, options);
|
|
12695
12772
|
if (!response.ok) {
|
|
@@ -13008,6 +13085,62 @@ const ServiceFactory = {
|
|
|
13008
13085
|
const _sessionKey = uuid();
|
|
13009
13086
|
const getKosSessionKey = () => `kos-${_sessionKey}`;
|
|
13010
13087
|
const isLocalRefId = (id) => !!id && !id.includes("VM_SERVICE") && id.startsWith(getKosSessionKey());
|
|
13088
|
+
const log$w = KosLog.createLogger({
|
|
13089
|
+
group: LogGroup.transport,
|
|
13090
|
+
name: "wait-for-request"
|
|
13091
|
+
});
|
|
13092
|
+
const waitForRequest = async (requestId, timeout = 6e4) => new Promise((resolve, reject) => {
|
|
13093
|
+
const { unsubscribe } = subscribe(requestId, (op) => {
|
|
13094
|
+
log$w.debug(`recieved response for refId ${requestId}: ${op}`);
|
|
13095
|
+
unsubscribe();
|
|
13096
|
+
clearTimeout(cancel);
|
|
13097
|
+
try {
|
|
13098
|
+
const body = op?.body ? JSON.parse(op.body) : {};
|
|
13099
|
+
resolve(body);
|
|
13100
|
+
} catch {
|
|
13101
|
+
const body = op?.body || {};
|
|
13102
|
+
resolve(body);
|
|
13103
|
+
}
|
|
13104
|
+
});
|
|
13105
|
+
const cancel = setTimeout(() => {
|
|
13106
|
+
unsubscribe();
|
|
13107
|
+
reject(Error(`Request with ID ${requestId} timed out. Cancelling.`));
|
|
13108
|
+
}, timeout);
|
|
13109
|
+
});
|
|
13110
|
+
const sendRequest = async (requestPromise, params2, refId) => {
|
|
13111
|
+
const op = waitForRequest(refId);
|
|
13112
|
+
const result = await Promise.allSettled([requestPromise(params2), op]);
|
|
13113
|
+
if (result[0].status === "fulfilled") {
|
|
13114
|
+
if (result[1].status === "rejected") {
|
|
13115
|
+
throw Error(result[1].reason);
|
|
13116
|
+
} else {
|
|
13117
|
+
if (result[0].value) {
|
|
13118
|
+
if (result[1].value.error) {
|
|
13119
|
+
throw Error(result[1].value.error);
|
|
13120
|
+
}
|
|
13121
|
+
result[0].value.data = result[1].value;
|
|
13122
|
+
return result[0].value;
|
|
13123
|
+
}
|
|
13124
|
+
}
|
|
13125
|
+
} else {
|
|
13126
|
+
throw Error(result[0].reason);
|
|
13127
|
+
}
|
|
13128
|
+
return void 0;
|
|
13129
|
+
};
|
|
13130
|
+
const syncPublish = async ({
|
|
13131
|
+
topic,
|
|
13132
|
+
msg,
|
|
13133
|
+
requestId
|
|
13134
|
+
}) => {
|
|
13135
|
+
const _requestId = requestId ?? uuid();
|
|
13136
|
+
const responsePromise = waitForRequest(_requestId);
|
|
13137
|
+
publish(topic, msg, { sync: _requestId });
|
|
13138
|
+
const response = await responsePromise;
|
|
13139
|
+
if (response.error) {
|
|
13140
|
+
throw Error(response.error);
|
|
13141
|
+
}
|
|
13142
|
+
return response;
|
|
13143
|
+
};
|
|
13011
13144
|
const contextMap = /* @__PURE__ */ new Map();
|
|
13012
13145
|
class KosContextBean {
|
|
13013
13146
|
_context;
|
|
@@ -13104,7 +13237,7 @@ const KosContextManager = {
|
|
|
13104
13237
|
};
|
|
13105
13238
|
KosContextManager.createContext("root");
|
|
13106
13239
|
const resolveKosContext = (model) => KosContextManager.getContext(model.id);
|
|
13107
|
-
const log$
|
|
13240
|
+
const log$v = KosLog.createLogger({ group: LogGroup.core, name: "kos-data-container" });
|
|
13108
13241
|
class KosDataContainer {
|
|
13109
13242
|
_data;
|
|
13110
13243
|
_sortKey;
|
|
@@ -13309,7 +13442,7 @@ class KosDataContainer {
|
|
|
13309
13442
|
const idx = this.index.get(indexName);
|
|
13310
13443
|
return idx.keys ?? [];
|
|
13311
13444
|
} else {
|
|
13312
|
-
log$
|
|
13445
|
+
log$v.info(
|
|
13313
13446
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13314
13447
|
);
|
|
13315
13448
|
return [];
|
|
@@ -13321,7 +13454,7 @@ class KosDataContainer {
|
|
|
13321
13454
|
if (idx.index.has(indexKey)) {
|
|
13322
13455
|
return idx.getByKey(indexKey);
|
|
13323
13456
|
} else {
|
|
13324
|
-
log$
|
|
13457
|
+
log$v.info(
|
|
13325
13458
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
13326
13459
|
idx.index.keys()
|
|
13327
13460
|
)}`
|
|
@@ -13329,7 +13462,7 @@ class KosDataContainer {
|
|
|
13329
13462
|
return [];
|
|
13330
13463
|
}
|
|
13331
13464
|
} else {
|
|
13332
|
-
log$
|
|
13465
|
+
log$v.info(
|
|
13333
13466
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13334
13467
|
);
|
|
13335
13468
|
return [];
|
|
@@ -13356,7 +13489,7 @@ class KosDataContainer {
|
|
|
13356
13489
|
* @private
|
|
13357
13490
|
*/
|
|
13358
13491
|
_logDataCapacityWarning(toEvict) {
|
|
13359
|
-
log$
|
|
13492
|
+
log$v.info(
|
|
13360
13493
|
`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.`
|
|
13361
13494
|
);
|
|
13362
13495
|
}
|
|
@@ -13416,7 +13549,7 @@ class KosDataContainer {
|
|
|
13416
13549
|
const candidates = this._customEvictionFilter(this.data);
|
|
13417
13550
|
return candidates.slice(0, count).map((item) => item.id);
|
|
13418
13551
|
}
|
|
13419
|
-
log$
|
|
13552
|
+
log$v.error(
|
|
13420
13553
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO."
|
|
13421
13554
|
);
|
|
13422
13555
|
return this._selectFifoData(count);
|
|
@@ -13428,7 +13561,7 @@ class KosDataContainer {
|
|
|
13428
13561
|
_removeEvictedData(ids) {
|
|
13429
13562
|
ids.forEach((id) => {
|
|
13430
13563
|
const item = this._data.get(id);
|
|
13431
|
-
log$
|
|
13564
|
+
log$v.info(`Evicting data item: ${id}`, {
|
|
13432
13565
|
itemId: id,
|
|
13433
13566
|
itemType: item ? item.constructor?.name : "unknown",
|
|
13434
13567
|
strategy: this._evictionStrategy
|
|
@@ -13441,7 +13574,7 @@ class KosDataContainer {
|
|
|
13441
13574
|
* @private
|
|
13442
13575
|
*/
|
|
13443
13576
|
_logDataEvictionComplete(evictedCount) {
|
|
13444
|
-
log$
|
|
13577
|
+
log$v.info(
|
|
13445
13578
|
`Evicted ${evictedCount} data items. Current size: ${this._data.size}/${this._maxCapacity}`
|
|
13446
13579
|
);
|
|
13447
13580
|
}
|
|
@@ -13613,14 +13746,14 @@ class BrowserKosRouter {
|
|
|
13613
13746
|
}, {});
|
|
13614
13747
|
}
|
|
13615
13748
|
}
|
|
13616
|
-
const log$
|
|
13749
|
+
const log$u = KosLog.createLogger({ group: LogGroup.core, name: "intent-service" });
|
|
13617
13750
|
const sendIntent = (intent) => {
|
|
13618
13751
|
if (hasEventSubscriptions(`/kos/intent/${intent.type}`)) {
|
|
13619
13752
|
publish(`/kos/intent/${intent.type}`, intent.options, {
|
|
13620
13753
|
"kos.intent.type": intent.type
|
|
13621
13754
|
});
|
|
13622
13755
|
} else {
|
|
13623
|
-
log$
|
|
13756
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13624
13757
|
}
|
|
13625
13758
|
};
|
|
13626
13759
|
const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
@@ -13650,11 +13783,11 @@ const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
|
13650
13783
|
sync: requestId
|
|
13651
13784
|
});
|
|
13652
13785
|
} else {
|
|
13653
|
-
log$
|
|
13786
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13654
13787
|
resolve([null, { body: void 0, payload: void 0 }]);
|
|
13655
13788
|
}
|
|
13656
13789
|
});
|
|
13657
|
-
const log$
|
|
13790
|
+
const log$t = KosLog.createLogger({ group: LogGroup.core, name: "app-startup-service" });
|
|
13658
13791
|
async function waitForAppsToStart(appIds, options = {}) {
|
|
13659
13792
|
const {
|
|
13660
13793
|
timeout = 3e4,
|
|
@@ -13662,10 +13795,10 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13662
13795
|
requirePostStarted = false
|
|
13663
13796
|
} = options;
|
|
13664
13797
|
if (appIds.length === 0) {
|
|
13665
|
-
log$
|
|
13798
|
+
log$t.warn("No app IDs provided to waitForAppsToStart");
|
|
13666
13799
|
return true;
|
|
13667
13800
|
}
|
|
13668
|
-
log$
|
|
13801
|
+
log$t.debug(`Waiting for apps to start: ${appIds.join(", ")}`);
|
|
13669
13802
|
try {
|
|
13670
13803
|
const eventTopics = appIds.map((appId) => `/kos/app/started/${appId}`);
|
|
13671
13804
|
const startedApps = await waitForAllWithState(eventTopics, {
|
|
@@ -13674,12 +13807,12 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13674
13807
|
const { default: api2 } = await Promise.resolve().then(() => service);
|
|
13675
13808
|
const [error, data] = await api2.get("/api/kos/apps/started");
|
|
13676
13809
|
if (error) {
|
|
13677
|
-
log$
|
|
13810
|
+
log$t.error("Error fetching started apps:", error);
|
|
13678
13811
|
return [];
|
|
13679
13812
|
}
|
|
13680
13813
|
return data;
|
|
13681
13814
|
} catch (error) {
|
|
13682
|
-
log$
|
|
13815
|
+
log$t.error("Failed to fetch app startup status:", error);
|
|
13683
13816
|
}
|
|
13684
13817
|
return [];
|
|
13685
13818
|
},
|
|
@@ -13701,17 +13834,17 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13701
13834
|
});
|
|
13702
13835
|
if (notStartedApps.length > 0) {
|
|
13703
13836
|
const message = `Apps not started: ${notStartedApps.join(", ")}`;
|
|
13704
|
-
log$
|
|
13837
|
+
log$t.error(message);
|
|
13705
13838
|
if (throwOnTimeout) {
|
|
13706
13839
|
throw new Error(`App startup timeout: ${message}`);
|
|
13707
13840
|
}
|
|
13708
13841
|
return false;
|
|
13709
13842
|
}
|
|
13710
|
-
log$
|
|
13843
|
+
log$t.info(`All apps started successfully: ${appIds.join(", ")}`);
|
|
13711
13844
|
return true;
|
|
13712
13845
|
} catch (error) {
|
|
13713
13846
|
const message = `Failed to wait for apps to start: ${appIds.join(", ")}`;
|
|
13714
|
-
log$
|
|
13847
|
+
log$t.error(message, error);
|
|
13715
13848
|
if (throwOnTimeout) {
|
|
13716
13849
|
throw new Error(
|
|
13717
13850
|
`${message} - ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -13738,7 +13871,7 @@ async function checkAppsStarted(appIds, requirePostStarted = false) {
|
|
|
13738
13871
|
result[appId] = app?.started === true && (!requirePostStarted || app?.postStarted === true);
|
|
13739
13872
|
});
|
|
13740
13873
|
} catch (error) {
|
|
13741
|
-
log$
|
|
13874
|
+
log$t.error("Failed to check app startup status:", error);
|
|
13742
13875
|
appIds.forEach((appId) => result[appId] = false);
|
|
13743
13876
|
}
|
|
13744
13877
|
return result;
|
|
@@ -13752,7 +13885,7 @@ async function getStartedApps() {
|
|
|
13752
13885
|
const result = await response.json();
|
|
13753
13886
|
return result?.data ?? [];
|
|
13754
13887
|
} catch (error) {
|
|
13755
|
-
log$
|
|
13888
|
+
log$t.error("Failed to fetch started apps:", error);
|
|
13756
13889
|
return [];
|
|
13757
13890
|
}
|
|
13758
13891
|
}
|
|
@@ -13779,10 +13912,7 @@ var Topics = /* @__PURE__ */ ((Topics2) => {
|
|
|
13779
13912
|
Topics2["TIMEZONE_CHANGE"] = "/kos/internal/time/timezone";
|
|
13780
13913
|
return Topics2;
|
|
13781
13914
|
})(Topics || {});
|
|
13782
|
-
const log$
|
|
13783
|
-
name: "config-bean-service",
|
|
13784
|
-
group: "Services"
|
|
13785
|
-
});
|
|
13915
|
+
const log$s = KosLog.createLogger({ group: LogGroup.service, name: "config-bean-service" });
|
|
13786
13916
|
const URL$e = BASE_URL;
|
|
13787
13917
|
const hasDecimals = (option) => option?.decimals !== void 0;
|
|
13788
13918
|
const { postModel: postModel$5, getOne: getOne$6 } = ServiceFactory.build({
|
|
@@ -13790,7 +13920,7 @@ const { postModel: postModel$5, getOne: getOne$6 } = ServiceFactory.build({
|
|
|
13790
13920
|
basePath: `${URL$e}/kos/config/`
|
|
13791
13921
|
});
|
|
13792
13922
|
const modifyConfigBean = async (id, model, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13793
|
-
log$
|
|
13923
|
+
log$s.debug(`sending modify request for ConfigBean: ${id}`);
|
|
13794
13924
|
const response = postModel$5({
|
|
13795
13925
|
model,
|
|
13796
13926
|
urlOverride: `${URL$e}${path}/${id}`,
|
|
@@ -13799,7 +13929,7 @@ const modifyConfigBean = async (id, model, path = `/api/kos/config`, destination
|
|
|
13799
13929
|
return response;
|
|
13800
13930
|
};
|
|
13801
13931
|
const getConfigBean = async (id, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13802
|
-
log$
|
|
13932
|
+
log$s.debug(`sending get request for ConfigBean: ${id}`);
|
|
13803
13933
|
const response = await getOne$6({
|
|
13804
13934
|
urlOverride: `${URL$e}${path}/details/${id}/15`,
|
|
13805
13935
|
destinationAddress
|
|
@@ -13912,7 +14042,10 @@ function matchValue(patterns, value) {
|
|
|
13912
14042
|
return void 0;
|
|
13913
14043
|
}
|
|
13914
14044
|
const CONFIG_BEAN_MODEL_TYPE = "config-bean-model";
|
|
13915
|
-
const log$
|
|
14045
|
+
const log$r = KosLog.createLogger({
|
|
14046
|
+
group: LogGroup.model,
|
|
14047
|
+
name: CONFIG_BEAN_MODEL_TYPE
|
|
14048
|
+
});
|
|
13916
14049
|
const PATH_PROP$3 = createPropKey("path");
|
|
13917
14050
|
const DESTINATION_PROP$2 = createPropKey("destinationAddress");
|
|
13918
14051
|
function configBeanModelId(path, destinationAddress) {
|
|
@@ -13985,8 +14118,8 @@ let ConfigBeanModelImpl = class {
|
|
|
13985
14118
|
* @internal
|
|
13986
14119
|
*/
|
|
13987
14120
|
async ready() {
|
|
13988
|
-
log$
|
|
13989
|
-
log$
|
|
14121
|
+
log$r.debug(`readying config bean ${this.path}`);
|
|
14122
|
+
log$r.debug(`complete readying config bean ${this.path}`);
|
|
13990
14123
|
}
|
|
13991
14124
|
/**
|
|
13992
14125
|
* @internal
|
|
@@ -13995,7 +14128,7 @@ let ConfigBeanModelImpl = class {
|
|
|
13995
14128
|
* Fetches the bean's values and schema.
|
|
13996
14129
|
*/
|
|
13997
14130
|
async load() {
|
|
13998
|
-
log$
|
|
14131
|
+
log$r.debug(`loading config bean ${this.path}`);
|
|
13999
14132
|
await this.fetchBean();
|
|
14000
14133
|
}
|
|
14001
14134
|
/**
|
|
@@ -14006,7 +14139,7 @@ let ConfigBeanModelImpl = class {
|
|
|
14006
14139
|
* KOS Core reload after a reconnect leaves the same instance current.
|
|
14007
14140
|
*/
|
|
14008
14141
|
async reload() {
|
|
14009
|
-
log$
|
|
14142
|
+
log$r.debug(`reloading config bean ${this.path}`);
|
|
14010
14143
|
await this.fetchBean();
|
|
14011
14144
|
}
|
|
14012
14145
|
async fetchBean() {
|
|
@@ -14018,7 +14151,7 @@ let ConfigBeanModelImpl = class {
|
|
|
14018
14151
|
if (response?.data) {
|
|
14019
14152
|
const data = response.data;
|
|
14020
14153
|
mapDtoToConfigBeanModel(data, this);
|
|
14021
|
-
log$
|
|
14154
|
+
log$r.debug(this.values);
|
|
14022
14155
|
const schemaResponse = response?.data.details[0].schema;
|
|
14023
14156
|
kosAction(() => {
|
|
14024
14157
|
if (schemaResponse) {
|
|
@@ -14263,7 +14396,7 @@ var __decorateClass$u = (decorators, target, key, kind) => {
|
|
|
14263
14396
|
return result;
|
|
14264
14397
|
};
|
|
14265
14398
|
const MODEL_TYPE$r = "region-info-model";
|
|
14266
|
-
const log$
|
|
14399
|
+
const log$q = KosLog.createLogger({ group: LogGroup.model, name: "region-info-model" });
|
|
14267
14400
|
function servicePathMapper(regionInfoModel) {
|
|
14268
14401
|
const hasMapper = ExtensionManager.propertyMapper.hasMapper(
|
|
14269
14402
|
KosCoreModelPropertyMapper.RegionServicePath
|
|
@@ -14576,7 +14709,7 @@ let RegionInfoModelImpl = class {
|
|
|
14576
14709
|
}
|
|
14577
14710
|
toUnit = measureSystems[to.system]?.["default"];
|
|
14578
14711
|
if (!toUnit) {
|
|
14579
|
-
log$
|
|
14712
|
+
log$q.info("Could not find default unit for measure", to.measure);
|
|
14580
14713
|
}
|
|
14581
14714
|
}
|
|
14582
14715
|
if (!fromUnit && from.measure && from.system) {
|
|
@@ -14590,11 +14723,11 @@ let RegionInfoModelImpl = class {
|
|
|
14590
14723
|
}
|
|
14591
14724
|
fromUnit = measureSystems[from.system]?.["default"];
|
|
14592
14725
|
if (!fromUnit) {
|
|
14593
|
-
log$
|
|
14726
|
+
log$q.info("Could not find default unit for measure", from.measure);
|
|
14594
14727
|
}
|
|
14595
14728
|
}
|
|
14596
14729
|
if (!fromUnit || !toUnit) {
|
|
14597
|
-
log$
|
|
14730
|
+
log$q.warn("Could not find unit to convert to or from. Return value as is");
|
|
14598
14731
|
return String(value);
|
|
14599
14732
|
}
|
|
14600
14733
|
return this.convertByUnit(value, fromUnit, toUnit);
|
|
@@ -14604,13 +14737,13 @@ let RegionInfoModelImpl = class {
|
|
|
14604
14737
|
* @internal
|
|
14605
14738
|
*/
|
|
14606
14739
|
async init() {
|
|
14607
|
-
log$
|
|
14740
|
+
log$q.debug("initializing region info");
|
|
14608
14741
|
}
|
|
14609
14742
|
/**
|
|
14610
14743
|
* @internal
|
|
14611
14744
|
*/
|
|
14612
14745
|
async load() {
|
|
14613
|
-
log$
|
|
14746
|
+
log$q.debug("loading region info");
|
|
14614
14747
|
const regions = await getRegions(
|
|
14615
14748
|
this.serviceBasePath,
|
|
14616
14749
|
this.destinationAddress
|
|
@@ -14947,7 +15080,7 @@ function secondsToFormattedTime(secondsSinceMidnight, formatString) {
|
|
|
14947
15080
|
return format(time, formatString);
|
|
14948
15081
|
}
|
|
14949
15082
|
const MODEL_TYPE$q = "config-bean-prop-model";
|
|
14950
|
-
const log$
|
|
15083
|
+
const log$p = KosLog.createLogger({ group: LogGroup.model, name: "config-bean-prop-model" });
|
|
14951
15084
|
const PATH_PROP$2 = createPropKey("path");
|
|
14952
15085
|
const SERVICE_PATH_PROP = createPropKey("serviceBasePath");
|
|
14953
15086
|
const DESTINATION_PROP = createPropKey("destinationAddress");
|
|
@@ -15134,7 +15267,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15134
15267
|
return Number(result2);
|
|
15135
15268
|
}
|
|
15136
15269
|
} catch (e) {
|
|
15137
|
-
log$
|
|
15270
|
+
log$p.info(`error formatting value ${_val}`, e);
|
|
15138
15271
|
}
|
|
15139
15272
|
const result = Number(_val).toFixed(decimals);
|
|
15140
15273
|
return result;
|
|
@@ -15166,7 +15299,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15166
15299
|
* @internal
|
|
15167
15300
|
*/
|
|
15168
15301
|
async activate() {
|
|
15169
|
-
log$
|
|
15302
|
+
log$p.debug(`activating config bean ${this.id}`);
|
|
15170
15303
|
}
|
|
15171
15304
|
/**
|
|
15172
15305
|
* The value formatted with its unit for the active locale, such as `"72.5 °F"`.
|
|
@@ -15193,7 +15326,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15193
15326
|
return result;
|
|
15194
15327
|
}
|
|
15195
15328
|
} catch (e) {
|
|
15196
|
-
log$
|
|
15329
|
+
log$p.error(`error formatting value ${_val}`, e);
|
|
15197
15330
|
}
|
|
15198
15331
|
}
|
|
15199
15332
|
return String(_val);
|
|
@@ -15285,13 +15418,13 @@ let KosConfigPropertyImpl = class {
|
|
|
15285
15418
|
try {
|
|
15286
15419
|
formatter = new Intl.NumberFormat(locale, { ...formatOptions });
|
|
15287
15420
|
} catch (e) {
|
|
15288
|
-
log$
|
|
15421
|
+
log$p.error(
|
|
15289
15422
|
`error creating formatter ${formatOptions}. Returning the raw value`,
|
|
15290
15423
|
e
|
|
15291
15424
|
);
|
|
15292
15425
|
}
|
|
15293
15426
|
} else {
|
|
15294
|
-
log$
|
|
15427
|
+
log$p.debug(
|
|
15295
15428
|
`no formatter found for config bean prop ${this.id}. Returning the raw value`
|
|
15296
15429
|
);
|
|
15297
15430
|
}
|
|
@@ -15352,7 +15485,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15352
15485
|
* @param value - The new value in display units
|
|
15353
15486
|
*/
|
|
15354
15487
|
async updateProperty(value) {
|
|
15355
|
-
log$
|
|
15488
|
+
log$p.debug(`updating property ${this.attribute} with value ${value}`);
|
|
15356
15489
|
let _value = value;
|
|
15357
15490
|
const converter = this.getConverter();
|
|
15358
15491
|
if (converter && !isNaN(_value)) {
|
|
@@ -15396,6 +15529,10 @@ const Registration = {
|
|
|
15396
15529
|
MODEL_TYPE$q
|
|
15397
15530
|
)
|
|
15398
15531
|
};
|
|
15532
|
+
const log$o = KosLog.createLogger({
|
|
15533
|
+
group: LogGroup.model,
|
|
15534
|
+
name: "future-model-builder"
|
|
15535
|
+
});
|
|
15399
15536
|
const mapDtoToFutureOptions = (dto) => {
|
|
15400
15537
|
const options = {
|
|
15401
15538
|
id: String(dto.id),
|
|
@@ -15411,10 +15548,10 @@ const mapDtoToFutureOptions = (dto) => {
|
|
|
15411
15548
|
return options;
|
|
15412
15549
|
};
|
|
15413
15550
|
const mapDtoToFutureModel = (dto, model) => {
|
|
15414
|
-
|
|
15415
|
-
|
|
15551
|
+
log$o.debug(`future dto ${dto.id} end state ${dto.endState}`);
|
|
15552
|
+
log$o.debug(`future model ${model.id} end state ${model.endState}`);
|
|
15416
15553
|
if (!model.endState) {
|
|
15417
|
-
|
|
15554
|
+
log$o.debug(`updating future model ${model.id}`);
|
|
15418
15555
|
runInAction(() => {
|
|
15419
15556
|
const options = mapDtoToFutureOptions(dto);
|
|
15420
15557
|
kosAction(() => {
|
|
@@ -15433,7 +15570,7 @@ const mapDtoToFutureModel = (dto, model) => {
|
|
|
15433
15570
|
});
|
|
15434
15571
|
});
|
|
15435
15572
|
} else {
|
|
15436
|
-
|
|
15573
|
+
log$o.debug(`future model ${model.id} is already complete`);
|
|
15437
15574
|
}
|
|
15438
15575
|
};
|
|
15439
15576
|
const buildFutureModel$1 = (factory) => (modelId) => (futureOptions) => {
|
|
@@ -15444,7 +15581,7 @@ const buildFuture = (factory) => (future) => pipe(
|
|
|
15444
15581
|
mapDtoToFutureOptions,
|
|
15445
15582
|
buildFutureModel$1(factory)(future.tracker || future.id)
|
|
15446
15583
|
)(future);
|
|
15447
|
-
const log$
|
|
15584
|
+
const log$n = KosLog.createLogger({ group: LogGroup.service, name: "future-service" });
|
|
15448
15585
|
const { isMock, URL: URL$c } = resolveServiceUrl();
|
|
15449
15586
|
var FutureEndState = /* @__PURE__ */ ((FutureEndState2) => {
|
|
15450
15587
|
FutureEndState2["Success"] = "SUCCESS";
|
|
@@ -15463,7 +15600,7 @@ const getFutures = async () => {
|
|
|
15463
15600
|
return response;
|
|
15464
15601
|
};
|
|
15465
15602
|
const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
15466
|
-
log$
|
|
15603
|
+
log$n.info(`sending delete request for Future: ${id}`);
|
|
15467
15604
|
const response = await deleteModel$1({
|
|
15468
15605
|
id,
|
|
15469
15606
|
urlOverride: `${URL$c}${path}/${id}`
|
|
@@ -15471,7 +15608,7 @@ const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
|
15471
15608
|
return response;
|
|
15472
15609
|
};
|
|
15473
15610
|
const addFuture = async (future, path = "/api/kos/future") => {
|
|
15474
|
-
log$
|
|
15611
|
+
log$n.info(`sending add request for Future`);
|
|
15475
15612
|
const response = await addModel({
|
|
15476
15613
|
model: future,
|
|
15477
15614
|
urlOverride: `${URL$c}${path}`
|
|
@@ -15479,7 +15616,7 @@ const addFuture = async (future, path = "/api/kos/future") => {
|
|
|
15479
15616
|
return response;
|
|
15480
15617
|
};
|
|
15481
15618
|
const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
15482
|
-
log$
|
|
15619
|
+
log$n.info(`sending modify request for Future: ${id}`);
|
|
15483
15620
|
const response = modifyModel({
|
|
15484
15621
|
model,
|
|
15485
15622
|
id,
|
|
@@ -15488,7 +15625,7 @@ const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
|
15488
15625
|
return response;
|
|
15489
15626
|
};
|
|
15490
15627
|
const cancelFuture = async (id, path = "/api/kos/future") => {
|
|
15491
|
-
log$
|
|
15628
|
+
log$n.info(`sending cancel request for Future: ${id}`);
|
|
15492
15629
|
const response = postModel$4({
|
|
15493
15630
|
urlOverride: `${URL$c}${path}/${id}/cancel`,
|
|
15494
15631
|
ordered: true,
|
|
@@ -15528,6 +15665,10 @@ const FutureManager = {
|
|
|
15528
15665
|
initiateFuture,
|
|
15529
15666
|
getFuture
|
|
15530
15667
|
};
|
|
15668
|
+
const log$m = KosLog.createLogger({
|
|
15669
|
+
group: LogGroup.model,
|
|
15670
|
+
name: "future-service"
|
|
15671
|
+
});
|
|
15531
15672
|
const isFutureResponse = (response) => !response || !response.data;
|
|
15532
15673
|
const resolveFutureHandler = (model) => {
|
|
15533
15674
|
const handlerProperty = model?.[MultipleFutureContainerSetup]?.handlerProperty ?? model?.[FutureContainerSetup]?.handlerProperty ?? "futureHandler";
|
|
@@ -15542,9 +15683,7 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15542
15683
|
} = props;
|
|
15543
15684
|
return async function(...args) {
|
|
15544
15685
|
const tracker = uuid();
|
|
15545
|
-
|
|
15546
|
-
`Calling future service ${methodName} with tracker ${tracker}`
|
|
15547
|
-
);
|
|
15686
|
+
log$m.debug(`Calling future service ${methodName} with tracker ${tracker}`);
|
|
15548
15687
|
let abortControllerInstance;
|
|
15549
15688
|
let effectDisposer;
|
|
15550
15689
|
if (abortController) {
|
|
@@ -15557,17 +15696,17 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15557
15696
|
if (namespace) {
|
|
15558
15697
|
future.namespace = namespace;
|
|
15559
15698
|
}
|
|
15560
|
-
|
|
15699
|
+
log$m.debug(`waiting for future ${future.id} to be ready`);
|
|
15561
15700
|
await whenReady(future);
|
|
15562
|
-
|
|
15701
|
+
log$m.debug(`future ${future.id} is ready`);
|
|
15563
15702
|
kosAction(() => {
|
|
15564
|
-
|
|
15703
|
+
log$m.debug(`Adding future ${future.id} to futureHandler`);
|
|
15565
15704
|
resolveFutureHandler(this).addFuture(future, alias);
|
|
15566
15705
|
});
|
|
15567
15706
|
if (abortController && abortControllerInstance) {
|
|
15568
15707
|
effectDisposer = kosAutoEffect(() => {
|
|
15569
15708
|
if (future.status === "CANCELLED" || future.endState === FutureEndState.Canceled) {
|
|
15570
|
-
|
|
15709
|
+
log$m.debug(`Future ${future.id} cancelled, aborting request`);
|
|
15571
15710
|
abortControllerInstance?.abort();
|
|
15572
15711
|
}
|
|
15573
15712
|
});
|
|
@@ -15575,13 +15714,13 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15575
15714
|
"abort",
|
|
15576
15715
|
async () => {
|
|
15577
15716
|
if (future.status !== "CANCELLED" && future.endState !== FutureEndState.Canceled && !future.endState) {
|
|
15578
|
-
|
|
15717
|
+
log$m.debug(
|
|
15579
15718
|
`AbortController aborted, cancelling future ${future.id}`
|
|
15580
15719
|
);
|
|
15581
15720
|
try {
|
|
15582
15721
|
await future.cancelFuture();
|
|
15583
15722
|
} catch (error) {
|
|
15584
|
-
|
|
15723
|
+
log$m.error(`Failed to cancel future ${future.id}:`, error);
|
|
15585
15724
|
}
|
|
15586
15725
|
}
|
|
15587
15726
|
},
|
|
@@ -15622,15 +15761,15 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15622
15761
|
// eslint-disable-next-line no-invalid-this
|
|
15623
15762
|
await original.apply(this, enhancedArgs)
|
|
15624
15763
|
);
|
|
15625
|
-
|
|
15764
|
+
log$m.debug(`received future response for ${tracker}`, futureResponse);
|
|
15626
15765
|
const response = isFutureResponse(futureResponse) ? futureResponse : futureResponse?.data;
|
|
15627
15766
|
if (response) {
|
|
15628
15767
|
response.progress = 1;
|
|
15629
|
-
|
|
15768
|
+
log$m.debug(`mapping future response to future model`);
|
|
15630
15769
|
if (!future.endState) {
|
|
15631
15770
|
mapDtoToFutureModel(response, future);
|
|
15632
15771
|
} else {
|
|
15633
|
-
|
|
15772
|
+
log$m.debug(
|
|
15634
15773
|
`future ${future.id} has already completed. Not updating the model`
|
|
15635
15774
|
);
|
|
15636
15775
|
}
|
|
@@ -15643,10 +15782,10 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15643
15782
|
cleanup();
|
|
15644
15783
|
if (abortController && abortControllerInstance?.signal.aborted) {
|
|
15645
15784
|
const cancelledError = new Error("Operation cancelled");
|
|
15646
|
-
|
|
15785
|
+
log$m.debug(`Operation ${methodName} was cancelled`);
|
|
15647
15786
|
throw cancelledError;
|
|
15648
15787
|
}
|
|
15649
|
-
|
|
15788
|
+
log$m.error(e);
|
|
15650
15789
|
throw e;
|
|
15651
15790
|
}
|
|
15652
15791
|
};
|
|
@@ -15675,12 +15814,9 @@ const { URL: URL$b } = resolveServiceUrl();
|
|
|
15675
15814
|
const { getOne: getOne$4 } = ServiceFactory.build({
|
|
15676
15815
|
basePath: `${URL$b}/api/kos/state`
|
|
15677
15816
|
});
|
|
15678
|
-
const log$
|
|
15679
|
-
name: "state-bean-service",
|
|
15680
|
-
group: "Services"
|
|
15681
|
-
});
|
|
15817
|
+
const log$l = KosLog.createLogger({ group: LogGroup.service, name: "state-bean-service" });
|
|
15682
15818
|
const getStateBeanData = async ({ path }) => {
|
|
15683
|
-
log$
|
|
15819
|
+
log$l.debug("sending GET for state-bean");
|
|
15684
15820
|
const response = await getOne$4({
|
|
15685
15821
|
urlOverride: `${URL$b}/api/kos/state/${path}`
|
|
15686
15822
|
});
|
|
@@ -15858,12 +15994,9 @@ const { URL: URL$a } = resolveServiceUrl();
|
|
|
15858
15994
|
const { getAll: getAll$5 } = ServiceFactory.build({
|
|
15859
15995
|
basePath: `${URL$a}/api/state-prop`
|
|
15860
15996
|
});
|
|
15861
|
-
const log$
|
|
15862
|
-
name: "state-prop-service",
|
|
15863
|
-
group: "Services"
|
|
15864
|
-
});
|
|
15997
|
+
const log$k = KosLog.createLogger({ group: LogGroup.service, name: "state-prop-service" });
|
|
15865
15998
|
const getStateProps = async () => {
|
|
15866
|
-
log$
|
|
15999
|
+
log$k.debug("sending GET for state-prop");
|
|
15867
16000
|
const response = await getAll$5({});
|
|
15868
16001
|
return response;
|
|
15869
16002
|
};
|
|
@@ -16005,7 +16138,7 @@ var __decorateClass$p = (decorators, target, key, kind) => {
|
|
|
16005
16138
|
if (kind && result) __defProp$l(target, key, result);
|
|
16006
16139
|
return result;
|
|
16007
16140
|
};
|
|
16008
|
-
const log$
|
|
16141
|
+
const log$j = KosLog.createLogger({ group: LogGroup.model, name: FutureFactory.type });
|
|
16009
16142
|
let FutureModel = class {
|
|
16010
16143
|
logger;
|
|
16011
16144
|
_cancelFuture;
|
|
@@ -16029,7 +16162,7 @@ let FutureModel = class {
|
|
|
16029
16162
|
kosWhen(
|
|
16030
16163
|
() => this.status === FutureEndState.Success || this.status === FutureEndState.Fail,
|
|
16031
16164
|
() => {
|
|
16032
|
-
log$
|
|
16165
|
+
log$j.info(`Future ${this.id} has completed with status ${this.status}`);
|
|
16033
16166
|
destroyKosModel(this);
|
|
16034
16167
|
}
|
|
16035
16168
|
);
|
|
@@ -16043,13 +16176,13 @@ let FutureModel = class {
|
|
|
16043
16176
|
* In future additional information about the workspace could be loaded
|
|
16044
16177
|
*/
|
|
16045
16178
|
async load() {
|
|
16046
|
-
log$
|
|
16179
|
+
log$j.debug(`loading Future ${this.id}`);
|
|
16047
16180
|
}
|
|
16048
16181
|
/**
|
|
16049
16182
|
* @internal
|
|
16050
16183
|
*/
|
|
16051
16184
|
unload() {
|
|
16052
|
-
log$
|
|
16185
|
+
log$j.info(`unloading Future ${this.id}`);
|
|
16053
16186
|
}
|
|
16054
16187
|
// -------------------ACTIONS----------------------------
|
|
16055
16188
|
/**
|
|
@@ -16068,7 +16201,7 @@ let FutureModel = class {
|
|
|
16068
16201
|
await kosWhen(() => this.futureId !== FUTURE_NOT_ASSIGNED);
|
|
16069
16202
|
const response = await this._cancelFuture(this.futureId, path);
|
|
16070
16203
|
if (response?.status !== 200) {
|
|
16071
|
-
log$
|
|
16204
|
+
log$j.error(
|
|
16072
16205
|
`Failed to cancel Future ${this.id}. Response: ${JSON.stringify(
|
|
16073
16206
|
response
|
|
16074
16207
|
)}`
|
|
@@ -16137,7 +16270,7 @@ var __decorateClass$o = (decorators, target, key, kind) => {
|
|
|
16137
16270
|
if (kind && result) __defProp$k(target, key, result);
|
|
16138
16271
|
return result;
|
|
16139
16272
|
};
|
|
16140
|
-
const log$
|
|
16273
|
+
const log$i = KosLog.createLogger({ group: LogGroup.model, name: FutureContainerFactory.type });
|
|
16141
16274
|
let FutureContainerModel = class {
|
|
16142
16275
|
id;
|
|
16143
16276
|
logger;
|
|
@@ -16252,8 +16385,8 @@ let FutureContainerModel = class {
|
|
|
16252
16385
|
try {
|
|
16253
16386
|
await this._deleteFuture(id);
|
|
16254
16387
|
} catch (e) {
|
|
16255
|
-
log$
|
|
16256
|
-
log$
|
|
16388
|
+
log$i.error(`error deleting a Future`);
|
|
16389
|
+
log$i.error(e);
|
|
16257
16390
|
}
|
|
16258
16391
|
}
|
|
16259
16392
|
/**
|
|
@@ -16280,8 +16413,8 @@ let FutureContainerModel = class {
|
|
|
16280
16413
|
return model2;
|
|
16281
16414
|
}
|
|
16282
16415
|
} catch (e) {
|
|
16283
|
-
log$
|
|
16284
|
-
log$
|
|
16416
|
+
log$i.error(`error creating a Future`);
|
|
16417
|
+
log$i.error(e);
|
|
16285
16418
|
throw e;
|
|
16286
16419
|
}
|
|
16287
16420
|
return void 0;
|
|
@@ -16310,10 +16443,7 @@ const { URL: URL$9 } = resolveServiceUrl();
|
|
|
16310
16443
|
const { getOne: getOne$3, postModel: postModel$3, deleteModel } = ServiceFactory.build({
|
|
16311
16444
|
basePath: `${URL$9}/api/keyVal`
|
|
16312
16445
|
});
|
|
16313
|
-
const log$
|
|
16314
|
-
name: "key-value-service",
|
|
16315
|
-
group: "Services"
|
|
16316
|
-
});
|
|
16446
|
+
const log$h = KosLog.createLogger({ group: LogGroup.service, name: "key-value-service" });
|
|
16317
16447
|
const deleteKeyValue = async (namespace, key) => {
|
|
16318
16448
|
await deleteModel({
|
|
16319
16449
|
urlOverride: `${URL$9}/api/keyVal/${namespace}/${key}`,
|
|
@@ -16326,7 +16456,7 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16326
16456
|
model: value.toString()
|
|
16327
16457
|
});
|
|
16328
16458
|
if (response?.status !== 200) {
|
|
16329
|
-
log$
|
|
16459
|
+
log$h.error("Failed to update key-value data", response);
|
|
16330
16460
|
throw new Error(
|
|
16331
16461
|
`Failed to update key-value data for namespace ${namespace}`
|
|
16332
16462
|
);
|
|
@@ -16334,12 +16464,12 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16334
16464
|
return response.data;
|
|
16335
16465
|
};
|
|
16336
16466
|
const getKeyValue = async (namespace = "studio") => {
|
|
16337
|
-
log$
|
|
16467
|
+
log$h.debug(`Retrieving all key-value data for namespace: ${namespace}`);
|
|
16338
16468
|
const response = await getOne$3({
|
|
16339
16469
|
urlOverride: `${URL$9}/api/keyVal/${namespace}`
|
|
16340
16470
|
});
|
|
16341
16471
|
if (response?.status !== 200) {
|
|
16342
|
-
log$
|
|
16472
|
+
log$h.error("Failed to retrieve key-value data", response);
|
|
16343
16473
|
throw new Error(
|
|
16344
16474
|
`Failed to retrieve key-value data for namespace ${namespace}`
|
|
16345
16475
|
);
|
|
@@ -18415,39 +18545,40 @@ KosExpressionEvaluatorModelImpl = __decorateClass$m([
|
|
|
18415
18545
|
kosModel({ modelTypeId: MODEL_TYPE$l, singleton: false })
|
|
18416
18546
|
], KosExpressionEvaluatorModelImpl);
|
|
18417
18547
|
const KosExpressionEvaluator = KosExpressionEvaluatorModelImpl.Registration;
|
|
18548
|
+
const log$g = KosLog.createLogger({
|
|
18549
|
+
group: LogGroup.transport,
|
|
18550
|
+
name: "get-kos-connection-id"
|
|
18551
|
+
});
|
|
18418
18552
|
const getKosConnectionId = () => {
|
|
18419
18553
|
const params2 = getQueryParams();
|
|
18420
18554
|
const connId = params2?.connId;
|
|
18421
18555
|
const result = connId || window?.kosBridge?.("connId");
|
|
18422
|
-
|
|
18556
|
+
log$g.debug(`getKosConnectionId: ${result}`);
|
|
18423
18557
|
return result;
|
|
18424
18558
|
};
|
|
18425
|
-
const log$
|
|
18426
|
-
name: "kos-log-manager-service",
|
|
18427
|
-
group: "Services"
|
|
18428
|
-
});
|
|
18559
|
+
const log$f = KosLog.createLogger({ group: LogGroup.service, name: "kos-log-manager-service" });
|
|
18429
18560
|
const SERVICE_PATH$1 = "/api/kos/logs/overrides";
|
|
18430
18561
|
const GROUPS_PATH = "/api/kos/logs/groups";
|
|
18431
18562
|
const getLogOverrides = async () => {
|
|
18432
|
-
log$
|
|
18563
|
+
log$f.debug("sending GET for kos-log-manager");
|
|
18433
18564
|
return await api$1.get(SERVICE_PATH$1, void 0, {
|
|
18434
18565
|
destinationAddress: getKosConnectionId()
|
|
18435
18566
|
});
|
|
18436
18567
|
};
|
|
18437
18568
|
const getLogGroups = async () => {
|
|
18438
|
-
log$
|
|
18569
|
+
log$f.debug("sending GET for log groups");
|
|
18439
18570
|
return await api$1.get(GROUPS_PATH, void 0, {
|
|
18440
18571
|
destinationAddress: getKosConnectionId()
|
|
18441
18572
|
});
|
|
18442
18573
|
};
|
|
18443
18574
|
const addLogOverride = async (override) => {
|
|
18444
|
-
log$
|
|
18575
|
+
log$f.debug(`sending POST for log override ${override.name}`);
|
|
18445
18576
|
return await api$1.post(SERVICE_PATH$1, void 0, override, {
|
|
18446
18577
|
destinationAddress: getKosConnectionId()
|
|
18447
18578
|
});
|
|
18448
18579
|
};
|
|
18449
18580
|
const removeLogOverride = async (override) => {
|
|
18450
|
-
log$
|
|
18581
|
+
log$f.debug(`sending DELETE for log override ${override.name}`);
|
|
18451
18582
|
return await api$1.delete(SERVICE_PATH$1, void 0, override, {
|
|
18452
18583
|
destinationAddress: getKosConnectionId()
|
|
18453
18584
|
});
|
|
@@ -18925,14 +19056,11 @@ __decorateClass$j([
|
|
|
18925
19056
|
LogBlockContainerModelImpl = __decorateClass$j([
|
|
18926
19057
|
kosModel(MODEL_TYPE$i)
|
|
18927
19058
|
], LogBlockContainerModelImpl);
|
|
18928
|
-
const log$
|
|
18929
|
-
name: "log-stream-container-service",
|
|
18930
|
-
group: "Services"
|
|
18931
|
-
});
|
|
19059
|
+
const log$e = KosLog.createLogger({ group: LogGroup.service, name: "log-stream-container-service" });
|
|
18932
19060
|
const SERVICE_PATH = "/api/kos/logs/node/{nodeId}/streams";
|
|
18933
19061
|
const getLogStreams = async () => {
|
|
18934
19062
|
const destinationAddress = getKosConnectionId();
|
|
18935
|
-
log$
|
|
19063
|
+
log$e.debug("sending GET for log-stream-container");
|
|
18936
19064
|
return await api$1.get(
|
|
18937
19065
|
SERVICE_PATH,
|
|
18938
19066
|
{
|
|
@@ -19504,11 +19632,11 @@ const { URL: URL$7 } = resolveServiceUrl();
|
|
|
19504
19632
|
const { getAll: getAll$4, postModel: postModel$1 } = ServiceFactory.build({
|
|
19505
19633
|
basePath: `${URL$7}/api/kos/troubles`
|
|
19506
19634
|
});
|
|
19507
|
-
const log$
|
|
19635
|
+
const log$d = KosLog.createLogger({ group: LogGroup.service, name: "trouble-services" });
|
|
19508
19636
|
const getTroubles = async (servicePath) => {
|
|
19509
19637
|
const isKosTroubles = servicePath.includes("/kos/troubles");
|
|
19510
19638
|
const destinationAddress = getKosConnectionId();
|
|
19511
|
-
log$
|
|
19639
|
+
log$d.info(
|
|
19512
19640
|
`Fetching troubles from ${servicePath} with destination address: ${isKosTroubles ? destinationAddress : "N/A (not a kos troubles path)"}`
|
|
19513
19641
|
);
|
|
19514
19642
|
const response = await getAll$4({
|
|
@@ -19590,6 +19718,10 @@ const defaultTroubleRoleMapper = (trouble) => {
|
|
|
19590
19718
|
}
|
|
19591
19719
|
return "TECHNICIAN";
|
|
19592
19720
|
};
|
|
19721
|
+
const log$c = KosLog.createLogger({
|
|
19722
|
+
group: LogGroup.model,
|
|
19723
|
+
name: "trouble-data-extension"
|
|
19724
|
+
});
|
|
19593
19725
|
const EXTENSION_TROUBLE_DATA_MAPPER = "troubleDataMapper";
|
|
19594
19726
|
const troubleMappers$1 = /* @__PURE__ */ new Map();
|
|
19595
19727
|
registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
@@ -19613,7 +19745,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19613
19745
|
if (r.status === "fulfilled") {
|
|
19614
19746
|
acc = { ...acc, ...r.value };
|
|
19615
19747
|
} else {
|
|
19616
|
-
|
|
19748
|
+
log$c.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19617
19749
|
}
|
|
19618
19750
|
return acc;
|
|
19619
19751
|
},
|
|
@@ -19622,6 +19754,10 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19622
19754
|
return data;
|
|
19623
19755
|
}
|
|
19624
19756
|
});
|
|
19757
|
+
const log$b = KosLog.createLogger({
|
|
19758
|
+
group: LogGroup.model,
|
|
19759
|
+
name: "trouble-extension"
|
|
19760
|
+
});
|
|
19625
19761
|
const EXTENSION_TROUBLE_MAPPER = "troubleMapper";
|
|
19626
19762
|
const troubleMappers = /* @__PURE__ */ new Map();
|
|
19627
19763
|
registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
@@ -19642,7 +19778,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
|
19642
19778
|
if (r.status === "fulfilled") {
|
|
19643
19779
|
return r.value;
|
|
19644
19780
|
} else {
|
|
19645
|
-
|
|
19781
|
+
log$b.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19646
19782
|
return [];
|
|
19647
19783
|
}
|
|
19648
19784
|
}).flat();
|
|
@@ -20031,16 +20167,13 @@ const { URL: URL$6 } = resolveServiceUrl();
|
|
|
20031
20167
|
const { getAll: getAll$3 } = ServiceFactory.build({
|
|
20032
20168
|
basePath: `${URL$6}/api/kos/ota`
|
|
20033
20169
|
});
|
|
20034
|
-
const log$
|
|
20035
|
-
name: "ota-service",
|
|
20036
|
-
group: "Services"
|
|
20037
|
-
});
|
|
20170
|
+
const log$a = KosLog.createLogger({ group: LogGroup.service, name: "ota-service" });
|
|
20038
20171
|
const getArtifacts = async () => {
|
|
20039
|
-
log$
|
|
20172
|
+
log$a.debug("sending GET request to /api/kos/ota/artifacts");
|
|
20040
20173
|
const response = await getAll$3({
|
|
20041
20174
|
urlOverride: `${URL$6}/api/kos/ota/artifacts`
|
|
20042
20175
|
});
|
|
20043
|
-
log$
|
|
20176
|
+
log$a.debug("getArtifacts - response:", response);
|
|
20044
20177
|
return response?.data;
|
|
20045
20178
|
};
|
|
20046
20179
|
var __defProp$a = Object.defineProperty;
|
|
@@ -20224,7 +20357,10 @@ const Ota = new SingletonKosModelRegistrationFactory({
|
|
|
20224
20357
|
class: OtaModelImpl,
|
|
20225
20358
|
type: MODEL_TYPE$c
|
|
20226
20359
|
});
|
|
20227
|
-
const log$
|
|
20360
|
+
const log$9 = KosLog.createLogger({
|
|
20361
|
+
group: LogGroup.model,
|
|
20362
|
+
name: "await-future-call"
|
|
20363
|
+
});
|
|
20228
20364
|
class FutureCallError extends Error {
|
|
20229
20365
|
endState;
|
|
20230
20366
|
reason;
|
|
@@ -20275,7 +20411,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20275
20411
|
const watchTracked = (future) => {
|
|
20276
20412
|
tracked = future;
|
|
20277
20413
|
if (cancelRequested) {
|
|
20278
|
-
future.cancelFuture().catch((e) => log$
|
|
20414
|
+
future.cancelFuture().catch((e) => log$9.error(e));
|
|
20279
20415
|
}
|
|
20280
20416
|
disposers.push(
|
|
20281
20417
|
reaction(
|
|
@@ -20292,7 +20428,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20292
20428
|
try {
|
|
20293
20429
|
cb(progress, status);
|
|
20294
20430
|
} catch (e) {
|
|
20295
|
-
log$
|
|
20431
|
+
log$9.warn("progress callback error", e);
|
|
20296
20432
|
}
|
|
20297
20433
|
});
|
|
20298
20434
|
},
|
|
@@ -20368,6 +20504,189 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20368
20504
|
};
|
|
20369
20505
|
return promise;
|
|
20370
20506
|
}
|
|
20507
|
+
function createCancellablePromise(promiseOrOptions, abortController, cancelFuture2, future) {
|
|
20508
|
+
const options = promiseOrOptions instanceof Promise ? { promise: promiseOrOptions, abortController, cancelFuture: cancelFuture2, future } : promiseOrOptions;
|
|
20509
|
+
const {
|
|
20510
|
+
promise,
|
|
20511
|
+
abortController: controller,
|
|
20512
|
+
cancelFuture: cancelFn,
|
|
20513
|
+
future: futureRef
|
|
20514
|
+
} = options;
|
|
20515
|
+
const cancellablePromise = promise;
|
|
20516
|
+
let currentProgress = 0;
|
|
20517
|
+
let currentStatus = "PENDING";
|
|
20518
|
+
let isRunning = true;
|
|
20519
|
+
const progressCallbacks = /* @__PURE__ */ new Set();
|
|
20520
|
+
let effectDisposer;
|
|
20521
|
+
if (futureRef && typeof futureRef === "object") {
|
|
20522
|
+
effectDisposer = autorun(() => {
|
|
20523
|
+
const newProgress = futureRef.progress || 0;
|
|
20524
|
+
const newStatus = futureRef.status || "PENDING";
|
|
20525
|
+
const newIsRunning = !futureRef.endState;
|
|
20526
|
+
if (newProgress !== currentProgress || newStatus !== currentStatus || newIsRunning !== isRunning) {
|
|
20527
|
+
currentProgress = newProgress;
|
|
20528
|
+
currentStatus = newStatus;
|
|
20529
|
+
isRunning = newIsRunning;
|
|
20530
|
+
progressCallbacks.forEach((callback) => {
|
|
20531
|
+
try {
|
|
20532
|
+
callback(currentProgress, currentStatus);
|
|
20533
|
+
} catch (error) {
|
|
20534
|
+
console.warn("Progress callback error:", error);
|
|
20535
|
+
}
|
|
20536
|
+
});
|
|
20537
|
+
}
|
|
20538
|
+
});
|
|
20539
|
+
}
|
|
20540
|
+
promise.finally(() => {
|
|
20541
|
+
isRunning = false;
|
|
20542
|
+
if (!controller?.signal.aborted) {
|
|
20543
|
+
currentStatus = "COMPLETED";
|
|
20544
|
+
progressCallbacks.forEach((callback) => {
|
|
20545
|
+
try {
|
|
20546
|
+
callback(currentProgress, currentStatus);
|
|
20547
|
+
} catch (error) {
|
|
20548
|
+
console.warn("Progress callback error:", error);
|
|
20549
|
+
}
|
|
20550
|
+
});
|
|
20551
|
+
}
|
|
20552
|
+
if (effectDisposer) {
|
|
20553
|
+
effectDisposer();
|
|
20554
|
+
}
|
|
20555
|
+
progressCallbacks.clear();
|
|
20556
|
+
});
|
|
20557
|
+
cancellablePromise.cancel = async () => {
|
|
20558
|
+
if (controller && !controller.signal.aborted) {
|
|
20559
|
+
controller.abort();
|
|
20560
|
+
}
|
|
20561
|
+
if (cancelFn) {
|
|
20562
|
+
await cancelFn();
|
|
20563
|
+
}
|
|
20564
|
+
isRunning = false;
|
|
20565
|
+
currentStatus = "CANCELLED";
|
|
20566
|
+
progressCallbacks.forEach((callback) => {
|
|
20567
|
+
try {
|
|
20568
|
+
callback(currentProgress, currentStatus);
|
|
20569
|
+
} catch (error) {
|
|
20570
|
+
console.warn("Progress callback error:", error);
|
|
20571
|
+
}
|
|
20572
|
+
});
|
|
20573
|
+
if (effectDisposer) {
|
|
20574
|
+
effectDisposer();
|
|
20575
|
+
}
|
|
20576
|
+
};
|
|
20577
|
+
cancellablePromise.getController = () => controller;
|
|
20578
|
+
cancellablePromise.isCancelled = () => controller?.signal.aborted ?? false;
|
|
20579
|
+
Object.defineProperty(cancellablePromise, "progress", {
|
|
20580
|
+
get: () => currentProgress,
|
|
20581
|
+
enumerable: true
|
|
20582
|
+
});
|
|
20583
|
+
Object.defineProperty(cancellablePromise, "status", {
|
|
20584
|
+
get: () => currentStatus,
|
|
20585
|
+
enumerable: true
|
|
20586
|
+
});
|
|
20587
|
+
Object.defineProperty(cancellablePromise, "isRunning", {
|
|
20588
|
+
get: () => isRunning,
|
|
20589
|
+
enumerable: true
|
|
20590
|
+
});
|
|
20591
|
+
cancellablePromise.onProgressUpdate = (callback) => {
|
|
20592
|
+
progressCallbacks.add(callback);
|
|
20593
|
+
callback(currentProgress, currentStatus);
|
|
20594
|
+
return () => progressCallbacks.delete(callback);
|
|
20595
|
+
};
|
|
20596
|
+
return cancellablePromise;
|
|
20597
|
+
}
|
|
20598
|
+
const log$8 = KosLog.createLogger({
|
|
20599
|
+
group: LogGroup.model,
|
|
20600
|
+
name: "cancellable-future-call"
|
|
20601
|
+
});
|
|
20602
|
+
function makeCancellable(model, methodCall) {
|
|
20603
|
+
const initialFuture = model.futureHandler.future;
|
|
20604
|
+
const promise = methodCall(model);
|
|
20605
|
+
let newFuture = null;
|
|
20606
|
+
setTimeout(() => {
|
|
20607
|
+
newFuture = model.futureHandler.future;
|
|
20608
|
+
if (newFuture === initialFuture) {
|
|
20609
|
+
newFuture = null;
|
|
20610
|
+
}
|
|
20611
|
+
}, 0);
|
|
20612
|
+
return createCancellablePromise({
|
|
20613
|
+
promise,
|
|
20614
|
+
abortController: void 0,
|
|
20615
|
+
// No direct AbortController access
|
|
20616
|
+
cancelFuture: async () => {
|
|
20617
|
+
if (newFuture) {
|
|
20618
|
+
await newFuture.cancelFuture();
|
|
20619
|
+
} else {
|
|
20620
|
+
const currentFuture = model.futureHandler.future;
|
|
20621
|
+
if (currentFuture) {
|
|
20622
|
+
await currentFuture.cancelFuture();
|
|
20623
|
+
}
|
|
20624
|
+
}
|
|
20625
|
+
},
|
|
20626
|
+
future: newFuture
|
|
20627
|
+
// Pass the future for progress tracking
|
|
20628
|
+
});
|
|
20629
|
+
}
|
|
20630
|
+
function withCancellation(model, methodName, ...args) {
|
|
20631
|
+
const method = model[methodName];
|
|
20632
|
+
if (typeof method !== "function") {
|
|
20633
|
+
throw new Error(`${String(methodName)} is not a method`);
|
|
20634
|
+
}
|
|
20635
|
+
const initialFuture = model.futureHandler.future;
|
|
20636
|
+
const promise = method.apply(model, args);
|
|
20637
|
+
let targetFuture = null;
|
|
20638
|
+
setTimeout(() => {
|
|
20639
|
+
const currentFuture = model.futureHandler.future;
|
|
20640
|
+
if (currentFuture && currentFuture !== initialFuture) {
|
|
20641
|
+
targetFuture = currentFuture;
|
|
20642
|
+
}
|
|
20643
|
+
}, 0);
|
|
20644
|
+
return createCancellablePromise({
|
|
20645
|
+
promise,
|
|
20646
|
+
abortController: void 0,
|
|
20647
|
+
cancelFuture: async () => {
|
|
20648
|
+
if (targetFuture) {
|
|
20649
|
+
await targetFuture.cancelFuture();
|
|
20650
|
+
} else {
|
|
20651
|
+
const fallbackFuture = model.futureHandler.future;
|
|
20652
|
+
if (fallbackFuture) {
|
|
20653
|
+
await fallbackFuture.cancelFuture();
|
|
20654
|
+
}
|
|
20655
|
+
}
|
|
20656
|
+
},
|
|
20657
|
+
future: targetFuture
|
|
20658
|
+
// Pass the future for progress tracking
|
|
20659
|
+
});
|
|
20660
|
+
}
|
|
20661
|
+
class CancellationBatch {
|
|
20662
|
+
operations = [];
|
|
20663
|
+
add(model, methodCall) {
|
|
20664
|
+
const cancellable = makeCancellable(model, methodCall);
|
|
20665
|
+
this.operations.push(cancellable);
|
|
20666
|
+
return cancellable;
|
|
20667
|
+
}
|
|
20668
|
+
async cancelAll() {
|
|
20669
|
+
await Promise.all(
|
|
20670
|
+
this.operations.map(
|
|
20671
|
+
(op) => op.cancel().catch(() => {
|
|
20672
|
+
log$8.warn("Cancellation failed for operation:", op);
|
|
20673
|
+
})
|
|
20674
|
+
)
|
|
20675
|
+
);
|
|
20676
|
+
}
|
|
20677
|
+
getAllControllers() {
|
|
20678
|
+
return this.operations.map((op) => op.getController());
|
|
20679
|
+
}
|
|
20680
|
+
getActiveCount() {
|
|
20681
|
+
return this.operations.filter((op) => !op.isCancelled()).length;
|
|
20682
|
+
}
|
|
20683
|
+
clear() {
|
|
20684
|
+
this.operations = [];
|
|
20685
|
+
}
|
|
20686
|
+
}
|
|
20687
|
+
function createCancellationBatch() {
|
|
20688
|
+
return new CancellationBatch();
|
|
20689
|
+
}
|
|
20371
20690
|
function createCancellableService(serviceFunction) {
|
|
20372
20691
|
let controller;
|
|
20373
20692
|
const wrappedFunction = async (...args) => {
|
|
@@ -22724,9 +23043,9 @@ const { URL: URL$5 } = resolveServiceUrl();
|
|
|
22724
23043
|
const { getOne: getOne$1 } = ServiceFactory.build({
|
|
22725
23044
|
basePath: `${URL$5}/api/device`
|
|
22726
23045
|
});
|
|
22727
|
-
const log$
|
|
23046
|
+
const log$7 = KosLog.createLogger({ group: LogGroup.service, name: "device-service" });
|
|
22728
23047
|
const getSerialNumber = async () => {
|
|
22729
|
-
log$
|
|
23048
|
+
log$7.debug("sending GET for device serial number");
|
|
22730
23049
|
try {
|
|
22731
23050
|
const response = await getOne$1({
|
|
22732
23051
|
urlOverride: `${URL$5}/api/kos/device/serialNumber`
|
|
@@ -22734,14 +23053,14 @@ const getSerialNumber = async () => {
|
|
|
22734
23053
|
return [void 0, response?.data.serialNumber];
|
|
22735
23054
|
} catch (error) {
|
|
22736
23055
|
if (error instanceof FetchError) {
|
|
22737
|
-
log$
|
|
23056
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22738
23057
|
return [error.payload.error, void 0];
|
|
22739
23058
|
}
|
|
22740
23059
|
}
|
|
22741
23060
|
return ["unknownError", void 0];
|
|
22742
23061
|
};
|
|
22743
23062
|
const getDeviceDetails = async () => {
|
|
22744
|
-
log$
|
|
23063
|
+
log$7.debug("sending GET for device details");
|
|
22745
23064
|
try {
|
|
22746
23065
|
const response = await getOne$1({
|
|
22747
23066
|
urlOverride: `${URL$5}/api/kos/device`
|
|
@@ -22752,7 +23071,7 @@ const getDeviceDetails = async () => {
|
|
|
22752
23071
|
return [void 0, response.data];
|
|
22753
23072
|
} catch (error) {
|
|
22754
23073
|
if (error instanceof FetchError) {
|
|
22755
|
-
log$
|
|
23074
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22756
23075
|
return [error.payload.error, void 0];
|
|
22757
23076
|
}
|
|
22758
23077
|
}
|
|
@@ -22963,13 +23282,10 @@ const { URL: URL$4 } = resolveServiceUrl();
|
|
|
22963
23282
|
const { getAll: getAll$2 } = ServiceFactory.build({
|
|
22964
23283
|
basePath: `${URL$4}/api/kos/network/interfaces`
|
|
22965
23284
|
});
|
|
22966
|
-
const log$
|
|
22967
|
-
name: "network-interface-service",
|
|
22968
|
-
group: "Services"
|
|
22969
|
-
});
|
|
23285
|
+
const log$6 = KosLog.createLogger({ group: LogGroup.service, name: "network-interface-service" });
|
|
22970
23286
|
const getNetworkInterfaces = async () => {
|
|
22971
23287
|
const destinationAddress = getKosConnectionId();
|
|
22972
|
-
log$
|
|
23288
|
+
log$6.debug("sending GET for copy-logs");
|
|
22973
23289
|
try {
|
|
22974
23290
|
const response = await getAll$2({
|
|
22975
23291
|
destinationAddress
|
|
@@ -22977,7 +23293,7 @@ const getNetworkInterfaces = async () => {
|
|
|
22977
23293
|
return [void 0, response?.data];
|
|
22978
23294
|
} catch (error) {
|
|
22979
23295
|
if (error instanceof FetchError) {
|
|
22980
|
-
log$
|
|
23296
|
+
log$6.error(`Error fetching log file size: ${error.payload.error}`);
|
|
22981
23297
|
return [error.payload.error, void 0];
|
|
22982
23298
|
}
|
|
22983
23299
|
}
|
|
@@ -23075,15 +23391,12 @@ const { URL: URL$3 } = resolveServiceUrl();
|
|
|
23075
23391
|
const { getAll: getAll$1 } = ServiceFactory.build({
|
|
23076
23392
|
basePath: `${URL$3}/api/kos/storage/devices`
|
|
23077
23393
|
});
|
|
23078
|
-
const log$
|
|
23079
|
-
name: "storage-device-service",
|
|
23080
|
-
group: "Services"
|
|
23081
|
-
});
|
|
23394
|
+
const log$5 = KosLog.createLogger({ group: LogGroup.service, name: "storage-device-service" });
|
|
23082
23395
|
const getStorageDevices = async () => {
|
|
23083
|
-
log$
|
|
23396
|
+
log$5.debug("sending GET for storage-device");
|
|
23084
23397
|
const response = await getAll$1({});
|
|
23085
23398
|
if (!response?.data || response.status !== 200) {
|
|
23086
|
-
log$
|
|
23399
|
+
log$5.error("Failed to retrieve storage-device data", response);
|
|
23087
23400
|
return [];
|
|
23088
23401
|
}
|
|
23089
23402
|
return response.data;
|
|
@@ -23281,17 +23594,14 @@ const { URL: URL$2 } = resolveServiceUrl();
|
|
|
23281
23594
|
const { getAll, postModel } = ServiceFactory.build({
|
|
23282
23595
|
basePath: `${URL$2}/api/kos/update/available`
|
|
23283
23596
|
});
|
|
23284
|
-
const log$
|
|
23285
|
-
name: "usb-update-service",
|
|
23286
|
-
group: "Services"
|
|
23287
|
-
});
|
|
23597
|
+
const log$4 = KosLog.createLogger({ group: LogGroup.service, name: "usb-update-service" });
|
|
23288
23598
|
const getAvailableUpdates = async () => {
|
|
23289
|
-
log$
|
|
23599
|
+
log$4.debug("sending GET for usb-update");
|
|
23290
23600
|
const response = await getAll({
|
|
23291
23601
|
urlOverride: `${URL$2}/api/kos/update/available`
|
|
23292
23602
|
});
|
|
23293
23603
|
if (!response?.data || response?.status !== 200) {
|
|
23294
|
-
log$
|
|
23604
|
+
log$4.error("Failed to retrieve usb-update data", response);
|
|
23295
23605
|
return [];
|
|
23296
23606
|
}
|
|
23297
23607
|
return response.data;
|
|
@@ -23532,10 +23842,7 @@ const { URL: URL$1 } = resolveServiceUrl();
|
|
|
23532
23842
|
const { getOne } = ServiceFactory.build({
|
|
23533
23843
|
basePath: `${URL$1}/api/translation`
|
|
23534
23844
|
});
|
|
23535
|
-
const log$
|
|
23536
|
-
name: "translation-service",
|
|
23537
|
-
group: "Services"
|
|
23538
|
-
});
|
|
23845
|
+
const log$3 = KosLog.createLogger({ group: LogGroup.service, name: "translation-service" });
|
|
23539
23846
|
const getDefaultHost = () => {
|
|
23540
23847
|
const defaultHost = window.location.origin;
|
|
23541
23848
|
const params2 = getQueryParams();
|
|
@@ -23544,23 +23851,23 @@ const getDefaultHost = () => {
|
|
|
23544
23851
|
return result;
|
|
23545
23852
|
};
|
|
23546
23853
|
const getTranslations = async (url, root) => {
|
|
23547
|
-
log$
|
|
23854
|
+
log$3.debug(`Loading translations from: ${url}`);
|
|
23548
23855
|
const rootUrl = root ?? getDefaultHost();
|
|
23549
23856
|
try {
|
|
23550
23857
|
const response = await fetch(`${rootUrl}${url}`);
|
|
23551
23858
|
if (response.status !== 200) {
|
|
23552
|
-
log$
|
|
23859
|
+
log$3.warn(`Failed to fetch translations at ${url}: ${response.status}`);
|
|
23553
23860
|
return {};
|
|
23554
23861
|
}
|
|
23555
23862
|
const json = await response.json();
|
|
23556
23863
|
return json;
|
|
23557
23864
|
} catch (error) {
|
|
23558
|
-
log$
|
|
23865
|
+
log$3.error("Error fetching translations", error);
|
|
23559
23866
|
throw error;
|
|
23560
23867
|
}
|
|
23561
23868
|
};
|
|
23562
23869
|
const getLocalizationDescriptor = async () => {
|
|
23563
|
-
log$
|
|
23870
|
+
log$3.debug("Getting system localization descriptor");
|
|
23564
23871
|
const response = await getOne({
|
|
23565
23872
|
urlOverride: `${URL$1}/api/system/kos/localization`
|
|
23566
23873
|
});
|
|
@@ -23572,7 +23879,7 @@ const getLocalizationDescriptor = async () => {
|
|
|
23572
23879
|
return response.data;
|
|
23573
23880
|
};
|
|
23574
23881
|
const getKosLocalizationDescriptor = (context) => async () => {
|
|
23575
|
-
log$
|
|
23882
|
+
log$3.debug(`Getting KOS localization descriptor for context: ${context}`);
|
|
23576
23883
|
const response = await getOne({
|
|
23577
23884
|
urlOverride: `${URL$1}/api/kos/localization/contexts`
|
|
23578
23885
|
});
|
|
@@ -24061,6 +24368,10 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
24061
24368
|
if (kind && result) __defProp(target, key, result);
|
|
24062
24369
|
return result;
|
|
24063
24370
|
};
|
|
24371
|
+
const log$2 = KosLog.createLogger({
|
|
24372
|
+
group: LogGroup.model,
|
|
24373
|
+
name: "ws-event-model"
|
|
24374
|
+
});
|
|
24064
24375
|
const stringify = ({ headers, body }) => {
|
|
24065
24376
|
const headText = Object.entries(headers).map(([key, value]) => `${key}:${value}`).join("\\n");
|
|
24066
24377
|
return headText + "\\n\\n" + body;
|
|
@@ -24084,7 +24395,7 @@ let WsEventModel = class {
|
|
|
24084
24395
|
this.processEvent(payload);
|
|
24085
24396
|
}
|
|
24086
24397
|
processEvent(data, isSend = false) {
|
|
24087
|
-
|
|
24398
|
+
log$2.debug("kos event received");
|
|
24088
24399
|
const { body, headers } = data.body;
|
|
24089
24400
|
const isUnique = headers["request-id"] || headers["response-id"];
|
|
24090
24401
|
const msgId = headers["request-id"] || headers["response-id"] || headers["topic"] || headers["type"];
|
|
@@ -24108,7 +24419,7 @@ let WsEventModel = class {
|
|
|
24108
24419
|
mocked: !!headers["mocked"]
|
|
24109
24420
|
};
|
|
24110
24421
|
this.events.set(rawKey, rawData);
|
|
24111
|
-
|
|
24422
|
+
log$2.debug(`logged ${this.events.size} events`);
|
|
24112
24423
|
}
|
|
24113
24424
|
}
|
|
24114
24425
|
};
|
|
@@ -24155,9 +24466,9 @@ const Registry = {
|
|
|
24155
24466
|
preloadModels: []
|
|
24156
24467
|
};
|
|
24157
24468
|
const PRELOAD = true;
|
|
24158
|
-
const registerCoreModels = (root) => () => {
|
|
24469
|
+
const registerCoreModels = (root) => ({ preloadLogManager = true } = {}) => {
|
|
24159
24470
|
const coreModels2 = CoreModels;
|
|
24160
|
-
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,
|
|
24471
|
+
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);
|
|
24161
24472
|
Object.keys(coreModels2).forEach((key) => {
|
|
24162
24473
|
const model = coreModels2[key];
|
|
24163
24474
|
registerLegacyModel(KosModelRegistry2)(key, model);
|
|
@@ -24181,7 +24492,10 @@ const KosModelRegistry2 = _KosModelRegistry;
|
|
|
24181
24492
|
const TIMER_EVENT = `/kos-timer-event`;
|
|
24182
24493
|
const TOPIC_TIMER_TICK_EVENT = `/kos-timer-event/tick`;
|
|
24183
24494
|
const TIMER_END = "defaultTimerEnd";
|
|
24184
|
-
const log$1 = KosLog.createLogger({
|
|
24495
|
+
const log$1 = KosLog.createLogger({
|
|
24496
|
+
group: LogGroup.model,
|
|
24497
|
+
name: "timer-manager"
|
|
24498
|
+
});
|
|
24185
24499
|
const isConfigProperty = (value) => value.updateProperty !== void 0;
|
|
24186
24500
|
class KosTimer {
|
|
24187
24501
|
name;
|
|
@@ -24208,7 +24522,7 @@ class KosTimer {
|
|
|
24208
24522
|
this.remainingTime = timeoutValue;
|
|
24209
24523
|
if (isConfigProperty(timeout)) {
|
|
24210
24524
|
kosAutoEffect(() => {
|
|
24211
|
-
|
|
24525
|
+
log$1.info(
|
|
24212
24526
|
`Updating config value timer ${name} with new timeout value ${timeout.value}`
|
|
24213
24527
|
);
|
|
24214
24528
|
const newValue = timeout.value || 60;
|
|
@@ -24445,10 +24759,7 @@ const TimerManager = {
|
|
|
24445
24759
|
executeOnTimer(name, (timer) => timer.start());
|
|
24446
24760
|
}
|
|
24447
24761
|
};
|
|
24448
|
-
const log = KosLog.createLogger({
|
|
24449
|
-
name: "software-info-service",
|
|
24450
|
-
group: "Services"
|
|
24451
|
-
});
|
|
24762
|
+
const log = KosLog.createLogger({ group: LogGroup.service, name: "software-info-service" });
|
|
24452
24763
|
const getSoftwareInfos = async (signal) => {
|
|
24453
24764
|
const destinationAddress = getKosConnectionId();
|
|
24454
24765
|
log.debug("sending GET for software-info");
|
|
@@ -24553,99 +24864,99 @@ const SoftwareInfo = {
|
|
|
24553
24864
|
)
|
|
24554
24865
|
};
|
|
24555
24866
|
export {
|
|
24556
|
-
|
|
24557
|
-
|
|
24558
|
-
|
|
24867
|
+
subscribeToLogStream as $,
|
|
24868
|
+
StateProp as A,
|
|
24869
|
+
deleteKeyValue as B,
|
|
24559
24870
|
CompanionParentModel as C,
|
|
24560
24871
|
DependencyModels as D,
|
|
24561
24872
|
ExtensionManager as E,
|
|
24562
|
-
|
|
24563
|
-
|
|
24564
|
-
|
|
24873
|
+
deleteKeyValueNamespace as F,
|
|
24874
|
+
getKeyValue as G,
|
|
24875
|
+
updateKeyValue as H,
|
|
24565
24876
|
INDEX_RECORD_SYMBOL as I,
|
|
24566
|
-
|
|
24877
|
+
addLogOverride as J,
|
|
24567
24878
|
KosContextManager as K,
|
|
24568
|
-
|
|
24879
|
+
getLogGroups as L,
|
|
24569
24880
|
MultipleFutureContainerSetup as M,
|
|
24570
|
-
|
|
24571
|
-
|
|
24572
|
-
|
|
24573
|
-
|
|
24881
|
+
getLogOverrides as N,
|
|
24882
|
+
removeLogOverride as O,
|
|
24883
|
+
getTimezone as P,
|
|
24884
|
+
setDate as Q,
|
|
24574
24885
|
ReferenceConfig as R,
|
|
24575
24886
|
SubscriptionHandlers as S,
|
|
24576
24887
|
TroubleAwareSetup as T,
|
|
24577
|
-
|
|
24888
|
+
setTime as U,
|
|
24578
24889
|
ViewModelConfig as V,
|
|
24579
|
-
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
24890
|
+
setTimezone as W,
|
|
24891
|
+
createOverride as X,
|
|
24892
|
+
getLogStreamBlock as Y,
|
|
24893
|
+
getLogStreamBlocks as Z,
|
|
24894
|
+
getLogStreams as _,
|
|
24584
24895
|
MixinModels as a,
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
24597
|
-
|
|
24598
|
-
|
|
24599
|
-
|
|
24600
|
-
|
|
24601
|
-
|
|
24602
|
-
|
|
24603
|
-
|
|
24604
|
-
|
|
24605
|
-
|
|
24606
|
-
|
|
24607
|
-
|
|
24608
|
-
|
|
24609
|
-
|
|
24610
|
-
|
|
24611
|
-
|
|
24612
|
-
|
|
24613
|
-
|
|
24614
|
-
|
|
24615
|
-
|
|
24616
|
-
|
|
24617
|
-
|
|
24618
|
-
|
|
24619
|
-
|
|
24620
|
-
|
|
24621
|
-
|
|
24622
|
-
|
|
24623
|
-
|
|
24624
|
-
|
|
24625
|
-
|
|
24626
|
-
|
|
24627
|
-
|
|
24628
|
-
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
|
|
24637
|
-
|
|
24638
|
-
|
|
24639
|
-
|
|
24640
|
-
|
|
24641
|
-
|
|
24642
|
-
|
|
24643
|
-
|
|
24644
|
-
|
|
24645
|
-
|
|
24646
|
-
|
|
24647
|
-
|
|
24648
|
-
|
|
24896
|
+
CancellationBatch as a$,
|
|
24897
|
+
unsubscribeFromLogStream as a0,
|
|
24898
|
+
bulkResolveTroubles as a1,
|
|
24899
|
+
getTroubles as a2,
|
|
24900
|
+
resolveTrouble as a3,
|
|
24901
|
+
sendCanvasData as a4,
|
|
24902
|
+
getDeviceDetails as a5,
|
|
24903
|
+
getSerialNumber as a6,
|
|
24904
|
+
getNetworkInterfaces as a7,
|
|
24905
|
+
getStorageDevices as a8,
|
|
24906
|
+
getAvailableUpdates as a9,
|
|
24907
|
+
WebSocketEvents as aA,
|
|
24908
|
+
modelHookCache as aB,
|
|
24909
|
+
isUpdateable as aC,
|
|
24910
|
+
KosModelState as aD,
|
|
24911
|
+
KosModelEvents as aE,
|
|
24912
|
+
clearModelHookCacheEntry as aF,
|
|
24913
|
+
KosTime as aG,
|
|
24914
|
+
SoftwareInfo as aH,
|
|
24915
|
+
getQueryParams as aI,
|
|
24916
|
+
getKosLocalizationDescriptor as aJ,
|
|
24917
|
+
Device as aK,
|
|
24918
|
+
NetworkInterfaceContainer as aL,
|
|
24919
|
+
Ota as aM,
|
|
24920
|
+
StorageDeviceContainer as aN,
|
|
24921
|
+
TimerManager as aO,
|
|
24922
|
+
TIMER_END as aP,
|
|
24923
|
+
TIMER_EVENT as aQ,
|
|
24924
|
+
TOPIC_TIMER_TICK_EVENT as aR,
|
|
24925
|
+
getKosModel$1 as aS,
|
|
24926
|
+
Trouble as aT,
|
|
24927
|
+
TroubleContainer as aU,
|
|
24928
|
+
UsbUpdateContainer as aV,
|
|
24929
|
+
Registration$1 as aW,
|
|
24930
|
+
AuthState as aX,
|
|
24931
|
+
BrowserKosRouter as aY,
|
|
24932
|
+
BrowserRouter as aZ,
|
|
24933
|
+
CancellableServiceManager as a_,
|
|
24934
|
+
installUpdate as aa,
|
|
24935
|
+
TranslationContainer as ab,
|
|
24936
|
+
whenReady as ac,
|
|
24937
|
+
KosCoreModelPropertyMapper as ad,
|
|
24938
|
+
CanvasDispatcher as ae,
|
|
24939
|
+
KeyValue as af,
|
|
24940
|
+
destroyKosModel as ag,
|
|
24941
|
+
createClient as ah,
|
|
24942
|
+
kosServiceRequest$1 as ai,
|
|
24943
|
+
getSoftwareInfos as aj,
|
|
24944
|
+
getSoftwareInfosWithCancel as ak,
|
|
24945
|
+
KosLog as al,
|
|
24946
|
+
LogGroup as am,
|
|
24947
|
+
BASE_URL as an,
|
|
24948
|
+
kosFetch as ao,
|
|
24949
|
+
kosModel as ap,
|
|
24950
|
+
kosLoggerAware as aq,
|
|
24951
|
+
kosContainerAware as ar,
|
|
24952
|
+
kosChild as as,
|
|
24953
|
+
api$1 as at,
|
|
24954
|
+
ObservableData as au,
|
|
24955
|
+
WebSocketTransport as av,
|
|
24956
|
+
kosComputed as aw,
|
|
24957
|
+
KosModelRegistrationFactory as ax,
|
|
24958
|
+
getKosModelSync as ay,
|
|
24959
|
+
kosAutoEffect as az,
|
|
24649
24960
|
KosViewModelSymbol as b,
|
|
24650
24961
|
KosModelManager as b$,
|
|
24651
24962
|
CanvasRenderer as b0,
|
|
@@ -24712,7 +25023,7 @@ export {
|
|
|
24712
25023
|
HEADER_CONTENT_TYPE as by,
|
|
24713
25024
|
HEADER_DESTINATION_ADDR as bz,
|
|
24714
25025
|
StateMachineSetup as c,
|
|
24715
|
-
|
|
25026
|
+
checkWildcardPattern as c$,
|
|
24716
25027
|
KosModelRegistry2 as c0,
|
|
24717
25028
|
KosModelSymbol as c1,
|
|
24718
25029
|
KosObservableData as c2,
|
|
@@ -24723,204 +25034,212 @@ export {
|
|
|
24723
25034
|
LOGIN_HOST as c7,
|
|
24724
25035
|
LOGIN_URL as c8,
|
|
24725
25036
|
LogBlock as c9,
|
|
24726
|
-
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
|
|
24732
|
-
|
|
24733
|
-
|
|
24734
|
-
|
|
24735
|
-
|
|
24736
|
-
|
|
24737
|
-
|
|
24738
|
-
|
|
24739
|
-
|
|
24740
|
-
|
|
24741
|
-
|
|
24742
|
-
|
|
24743
|
-
|
|
24744
|
-
|
|
24745
|
-
|
|
24746
|
-
|
|
24747
|
-
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
|
|
24751
|
-
|
|
24752
|
-
|
|
25037
|
+
ServiceRequestHandlers as cA,
|
|
25038
|
+
SingletonKosModelRegistrationFactory as cB,
|
|
25039
|
+
StateActionHandlers as cC,
|
|
25040
|
+
StateEntryHandlers as cD,
|
|
25041
|
+
StateExitHandlers as cE,
|
|
25042
|
+
StorageDevice as cF,
|
|
25043
|
+
TRANSPORT_NOT_READY as cG,
|
|
25044
|
+
Topics as cH,
|
|
25045
|
+
TransitionMap as cI,
|
|
25046
|
+
Transitions as cJ,
|
|
25047
|
+
Translation as cK,
|
|
25048
|
+
TransportFactory as cL,
|
|
25049
|
+
TransportNotReadyError as cM,
|
|
25050
|
+
Troubles as cN,
|
|
25051
|
+
UsbUpdate as cO,
|
|
25052
|
+
WS_EVENT_TYPE as cP,
|
|
25053
|
+
WsEventFactory as cQ,
|
|
25054
|
+
WsEventModel as cR,
|
|
25055
|
+
addFuture as cS,
|
|
25056
|
+
api as cT,
|
|
25057
|
+
applyFunctionalEnhancements as cU,
|
|
25058
|
+
awaitFutureCall as cV,
|
|
25059
|
+
buildConfigBeanModel as cW,
|
|
25060
|
+
buildFuture as cX,
|
|
25061
|
+
buildFutureModel$1 as cY,
|
|
25062
|
+
cancelFuture as cZ,
|
|
25063
|
+
checkAppsStarted as c_,
|
|
24753
25064
|
LogBlockContainer as ca,
|
|
24754
25065
|
LogStream as cb,
|
|
24755
25066
|
LogStreamContainer as cc,
|
|
24756
25067
|
LoggerSetup as cd,
|
|
24757
|
-
|
|
24758
|
-
|
|
24759
|
-
|
|
24760
|
-
|
|
24761
|
-
|
|
24762
|
-
|
|
24763
|
-
|
|
24764
|
-
|
|
24765
|
-
|
|
24766
|
-
|
|
24767
|
-
|
|
24768
|
-
|
|
24769
|
-
|
|
24770
|
-
|
|
24771
|
-
|
|
24772
|
-
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
24778
|
-
|
|
25068
|
+
MESSAGE_LOGGER_NAME as ce,
|
|
25069
|
+
MODEL_DELETION_DELAY as cf,
|
|
25070
|
+
ModelError as cg,
|
|
25071
|
+
MultipleFutureHandler as ch,
|
|
25072
|
+
NetworkInterface as ci,
|
|
25073
|
+
OptionsRequired as cj,
|
|
25074
|
+
PORT as ck,
|
|
25075
|
+
PROFILE_ENABLE_RELEASES as cl,
|
|
25076
|
+
PROFILE_LOG_DEBUG as cm,
|
|
25077
|
+
PROFILE_LOG_INFO as cn,
|
|
25078
|
+
PROFILE_RELAX_STORE_VALIDATION as co,
|
|
25079
|
+
PROFILE_TOOLS_PREVIEW as cp,
|
|
25080
|
+
ParentModel as cq,
|
|
25081
|
+
RegistrationManager as cr,
|
|
25082
|
+
Registry as cs,
|
|
25083
|
+
ReloadAwareSetup as ct,
|
|
25084
|
+
ReplayStrategy as cu,
|
|
25085
|
+
ResponseRetention as cv,
|
|
25086
|
+
STATUS as cw,
|
|
25087
|
+
SelfManagedReload as cx,
|
|
25088
|
+
ServiceFactory as cy,
|
|
25089
|
+
ServiceRequestError as cz,
|
|
24779
25090
|
DependencyLifecycle as d,
|
|
24780
|
-
|
|
24781
|
-
|
|
24782
|
-
|
|
24783
|
-
|
|
24784
|
-
|
|
24785
|
-
|
|
24786
|
-
|
|
24787
|
-
|
|
24788
|
-
|
|
24789
|
-
|
|
24790
|
-
|
|
24791
|
-
|
|
24792
|
-
|
|
24793
|
-
|
|
24794
|
-
|
|
24795
|
-
|
|
24796
|
-
|
|
24797
|
-
|
|
24798
|
-
|
|
24799
|
-
|
|
24800
|
-
|
|
24801
|
-
|
|
24802
|
-
|
|
24803
|
-
|
|
24804
|
-
|
|
24805
|
-
|
|
24806
|
-
|
|
24807
|
-
|
|
24808
|
-
|
|
24809
|
-
|
|
24810
|
-
|
|
24811
|
-
|
|
24812
|
-
|
|
24813
|
-
|
|
24814
|
-
|
|
24815
|
-
|
|
24816
|
-
|
|
24817
|
-
|
|
24818
|
-
|
|
24819
|
-
|
|
24820
|
-
|
|
24821
|
-
|
|
24822
|
-
|
|
24823
|
-
|
|
24824
|
-
|
|
24825
|
-
|
|
24826
|
-
|
|
24827
|
-
|
|
24828
|
-
|
|
24829
|
-
|
|
24830
|
-
|
|
24831
|
-
|
|
24832
|
-
|
|
24833
|
-
|
|
24834
|
-
|
|
24835
|
-
|
|
24836
|
-
|
|
24837
|
-
|
|
24838
|
-
|
|
24839
|
-
|
|
24840
|
-
|
|
24841
|
-
|
|
24842
|
-
|
|
25091
|
+
kosAction as d$,
|
|
25092
|
+
convert as d0,
|
|
25093
|
+
convertWithUnits as d1,
|
|
25094
|
+
createBaseMessage as d2,
|
|
25095
|
+
createBroadcastMessageResponse as d3,
|
|
25096
|
+
createCancellablePromise as d4,
|
|
25097
|
+
createCancellableService as d5,
|
|
25098
|
+
createCancellationBatch as d6,
|
|
25099
|
+
createFosBaseMessage as d7,
|
|
25100
|
+
createHeaders as d8,
|
|
25101
|
+
createKosHtpMessageResponse as d9,
|
|
25102
|
+
getKosCompanionModel as dA,
|
|
25103
|
+
getKosConnectionId as dB,
|
|
25104
|
+
getKosModelActivationState as dC,
|
|
25105
|
+
getKosModelType as dD,
|
|
25106
|
+
getKosSessionKey as dE,
|
|
25107
|
+
getLocalizationDescriptor as dF,
|
|
25108
|
+
getLogLevel as dG,
|
|
25109
|
+
getMessageBody as dH,
|
|
25110
|
+
getObservableCompanions as dI,
|
|
25111
|
+
getStartedApps as dJ,
|
|
25112
|
+
getTranslations as dK,
|
|
25113
|
+
handleServiceRequestError as dL,
|
|
25114
|
+
hasDecimals as dM,
|
|
25115
|
+
hasHttpRouteHandlers$1 as dN,
|
|
25116
|
+
hasKosProfile as dO,
|
|
25117
|
+
httpDelete as dP,
|
|
25118
|
+
isBoolean as dQ,
|
|
25119
|
+
isKosCompanionTypeFactory as dR,
|
|
25120
|
+
isKosDataModel as dS,
|
|
25121
|
+
isKosExecutionContext as dT,
|
|
25122
|
+
isKosLoggingEnabled as dU,
|
|
25123
|
+
isKosModelContainer as dV,
|
|
25124
|
+
isKosModelReady as dW,
|
|
25125
|
+
isLocalRefId as dX,
|
|
25126
|
+
isNumber as dY,
|
|
25127
|
+
isPrintable as dZ,
|
|
25128
|
+
isTransportNotReadyError as d_,
|
|
25129
|
+
createKosMessage as da,
|
|
25130
|
+
createKosMessageResponse as db,
|
|
25131
|
+
createMessageBody as dc,
|
|
25132
|
+
createModelDependency as dd,
|
|
25133
|
+
createOptionKey as de,
|
|
25134
|
+
createPropKey as df,
|
|
25135
|
+
createReadableStream as dg,
|
|
25136
|
+
createStudioMessage as dh,
|
|
25137
|
+
createStudioMessageRequest as di,
|
|
25138
|
+
createStudioMessageResponse as dj,
|
|
25139
|
+
del as dk,
|
|
25140
|
+
deleteFuture as dl,
|
|
25141
|
+
evaluateScopes as dm,
|
|
25142
|
+
executeApiMethod as dn,
|
|
25143
|
+
executeChildrenModelLifecycle as dp,
|
|
25144
|
+
executeDependentModelLifecycle as dq,
|
|
25145
|
+
executeListLifecycle as dr,
|
|
25146
|
+
findModel as ds,
|
|
25147
|
+
findModels as dt,
|
|
25148
|
+
get as du,
|
|
25149
|
+
getAllKosCompanionModels as dv,
|
|
25150
|
+
getConfigBean as dw,
|
|
25151
|
+
getDependenciesByLifecycle as dx,
|
|
25152
|
+
getFutures as dy,
|
|
25153
|
+
getHttpRouteHandlers as dz,
|
|
24843
25154
|
initializeStateMachine as e,
|
|
24844
|
-
|
|
24845
|
-
|
|
24846
|
-
|
|
24847
|
-
|
|
24848
|
-
|
|
24849
|
-
|
|
24850
|
-
|
|
24851
|
-
|
|
24852
|
-
|
|
24853
|
-
|
|
24854
|
-
|
|
24855
|
-
|
|
24856
|
-
|
|
24857
|
-
|
|
24858
|
-
|
|
24859
|
-
|
|
24860
|
-
|
|
24861
|
-
|
|
24862
|
-
|
|
24863
|
-
|
|
24864
|
-
|
|
24865
|
-
|
|
24866
|
-
|
|
24867
|
-
|
|
24868
|
-
|
|
24869
|
-
|
|
24870
|
-
|
|
24871
|
-
|
|
24872
|
-
|
|
24873
|
-
|
|
24874
|
-
|
|
24875
|
-
|
|
24876
|
-
|
|
24877
|
-
|
|
24878
|
-
|
|
24879
|
-
|
|
24880
|
-
|
|
24881
|
-
|
|
24882
|
-
|
|
24883
|
-
|
|
24884
|
-
|
|
24885
|
-
|
|
24886
|
-
|
|
24887
|
-
|
|
24888
|
-
|
|
24889
|
-
|
|
24890
|
-
|
|
24891
|
-
|
|
24892
|
-
|
|
24893
|
-
|
|
24894
|
-
|
|
24895
|
-
|
|
24896
|
-
|
|
24897
|
-
|
|
24898
|
-
|
|
24899
|
-
|
|
24900
|
-
|
|
24901
|
-
|
|
24902
|
-
|
|
24903
|
-
|
|
25155
|
+
waitForAppsToStart as e$,
|
|
25156
|
+
kosDependency as e0,
|
|
25157
|
+
kosEffect as e1,
|
|
25158
|
+
kosFuture as e2,
|
|
25159
|
+
kosFutureAware as e3,
|
|
25160
|
+
kosModelEffect as e4,
|
|
25161
|
+
kosObservable as e5,
|
|
25162
|
+
kosReloadAware as e6,
|
|
25163
|
+
kosStateEntry as e7,
|
|
25164
|
+
kosStateExit as e8,
|
|
25165
|
+
kosStateGuard as e9,
|
|
25166
|
+
registerLegacyModel as eA,
|
|
25167
|
+
resetKosModel as eB,
|
|
25168
|
+
resolveBaseUrl as eC,
|
|
25169
|
+
resolveChild as eD,
|
|
25170
|
+
resolveContainerDeltas as eE,
|
|
25171
|
+
resolveItemListDeltas as eF,
|
|
25172
|
+
resolveKosCompanion as eG,
|
|
25173
|
+
resolveKosContext as eH,
|
|
25174
|
+
resolveKosProfiles as eI,
|
|
25175
|
+
resolveListDeltas as eJ,
|
|
25176
|
+
resolveServiceRequestParameters as eK,
|
|
25177
|
+
resolveServiceUrl as eL,
|
|
25178
|
+
retryWithExponentialBackoff as eM,
|
|
25179
|
+
sendAsyncIntent as eN,
|
|
25180
|
+
sendBroadcastMessage as eO,
|
|
25181
|
+
sendIntent as eP,
|
|
25182
|
+
sendKosHttpMessageResponse as eQ,
|
|
25183
|
+
sendKosMessage as eR,
|
|
25184
|
+
sendRequest as eS,
|
|
25185
|
+
sendStudioMessage as eT,
|
|
25186
|
+
sendStudioMessageRequest as eU,
|
|
25187
|
+
syncPublish as eV,
|
|
25188
|
+
troubleByTypeReducer as eW,
|
|
25189
|
+
troubleDataFactory as eX,
|
|
25190
|
+
unloadKosModel as eY,
|
|
25191
|
+
uuid as eZ,
|
|
25192
|
+
waitForAppToStart as e_,
|
|
25193
|
+
kosStateMachine as ea,
|
|
25194
|
+
kosTopicHandler as eb,
|
|
25195
|
+
kosWhen as ec,
|
|
25196
|
+
makeCancellable as ed,
|
|
25197
|
+
mapConfigBeanModelToDto as ee,
|
|
25198
|
+
mapDataToModel as ef,
|
|
25199
|
+
mapDtoToConfigBeanModel as eg,
|
|
25200
|
+
mapDtoToFutureModel as eh,
|
|
25201
|
+
mapDtoToFutureOptions as ei,
|
|
25202
|
+
mapUpdateDtoToConfigBeanModel as ej,
|
|
25203
|
+
modelEventTopicFactory as ek,
|
|
25204
|
+
modelFactory as el,
|
|
25205
|
+
modelTypeEventTopicFactory as em,
|
|
25206
|
+
modifyConfigBean as en,
|
|
25207
|
+
modifyFuture as eo,
|
|
25208
|
+
parseWildcardSegment as ep,
|
|
25209
|
+
pipe as eq,
|
|
25210
|
+
post as er,
|
|
25211
|
+
preloadKosModel as es,
|
|
25212
|
+
processId as et,
|
|
25213
|
+
put as eu,
|
|
25214
|
+
registerCompanionModel as ev,
|
|
25215
|
+
registerCoreModels as ew,
|
|
25216
|
+
registerExtensionPoint as ex,
|
|
25217
|
+
registerHttpRoutes as ey,
|
|
25218
|
+
registerKosModel as ez,
|
|
24904
25219
|
ModelEffects as f,
|
|
25220
|
+
waitForRequest as f0,
|
|
25221
|
+
withCancellation as f1,
|
|
25222
|
+
wrapWithFutureLifecycle as f2,
|
|
25223
|
+
service as f3,
|
|
24905
25224
|
KosModelVisitor as g,
|
|
24906
25225
|
KosCore as h,
|
|
24907
25226
|
injectStateMachineSupport as i,
|
|
24908
25227
|
sendKosMessageResponse as j,
|
|
24909
25228
|
kosParentAware as k,
|
|
24910
|
-
|
|
24911
|
-
|
|
24912
|
-
|
|
24913
|
-
|
|
25229
|
+
INDEX_COLLECTION_KEY as l,
|
|
25230
|
+
KosContainerIndexEvents as m,
|
|
25231
|
+
isIndexableItem as n,
|
|
25232
|
+
Kos as o,
|
|
24914
25233
|
publish as p,
|
|
24915
|
-
|
|
24916
|
-
|
|
25234
|
+
isKosModel as q,
|
|
25235
|
+
ConfigBean as r,
|
|
24917
25236
|
subscribe as s,
|
|
24918
|
-
|
|
24919
|
-
|
|
24920
|
-
|
|
24921
|
-
|
|
24922
|
-
|
|
24923
|
-
|
|
24924
|
-
|
|
24925
|
-
};
|
|
24926
|
-
//# sourceMappingURL=software-info-registration-
|
|
25237
|
+
configBeanModelId as t,
|
|
25238
|
+
getRegionInfo as u,
|
|
25239
|
+
getRegions as v,
|
|
25240
|
+
Registration as w,
|
|
25241
|
+
getStateBeanData as x,
|
|
25242
|
+
StateBean as y,
|
|
25243
|
+
getStateProps as z
|
|
25244
|
+
};
|
|
25245
|
+
//# sourceMappingURL=software-info-registration-Bz_s3zOp.js.map
|