@kosdev-code/kos-ui-sdk 0.1.0-next.979 → 0.1.0-next.994
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/companion-instantiator.d.ts.map +1 -1
- package/core/core/decorators/fsm-injection-utils.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-container-aware.d.ts +104 -3
- package/core/core/decorators/kos-container-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-logger-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-service-request-helpers.d.ts.map +1 -1
- package/core/core/decorators/kos-state-machine.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/decorators/resolve-parameters.d.ts.map +1 -1
- package/core/core/dependency-manager.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-container-model.d.ts.map +1 -1
- package/core/core/kos-data-container.d.ts.map +1 -1
- package/core/core/kos-model-factory.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/kosModelManager.d.ts.map +1 -1
- package/core/core/lifecycle/kosCoreLifecycle.d.ts.map +1 -1
- package/core/core/lifecycle/kosModelLifecycle.d.ts.map +1 -1
- package/core/core/lifecycle/model-active-machine.d.ts.map +1 -1
- package/core/core/lifecycle/model-machine.d.ts.map +1 -1
- package/core/core/lifecycle/model-online-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-cache.d.ts.map +1 -1
- package/core/core/model-instantiator.d.ts.map +1 -1
- package/core/core/registration/registration-manager.d.ts.map +1 -1
- package/core/core/services/app-startup-service.d.ts.map +1 -1
- package/core/core/services/intent-service.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-core-utils.d.ts.map +1 -1
- package/core/util/kos-fetch.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-service-request.d.ts.map +1 -1
- package/core/util/log-utils.d.ts +0 -10
- package/core/util/log-utils.d.ts.map +1 -1
- package/core/util/model-error-utils.d.ts.map +1 -1
- package/core/util/model-utils.d.ts.map +1 -1
- package/core/util/promise-utils.d.ts.map +1 -1
- package/core/util/retry-with-exponential-backoff.d.ts.map +1 -1
- package/core/util/service-factory.d.ts.map +1 -1
- package/core/util/wait-for-request.d.ts.map +1 -1
- package/index.cjs +73 -320
- package/index.cjs.map +1 -1
- package/index.js +249 -496
- 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/device/services/device-services.d.ts.map +1 -1
- package/models/models/future/future-aware.d.ts.map +1 -1
- package/models/models/future/future-model-builder.d.ts.map +1 -1
- package/models/models/future/future-model.d.ts.map +1 -1
- package/models/models/future-container/future-container-model.d.ts.map +1 -1
- package/models/models/gpio-chip/gpio-chip-builders.d.ts +0 -3
- package/models/models/gpio-chip/gpio-chip-builders.d.ts.map +1 -1
- package/models/models/gpio-chip/gpio-chip-container-model.d.ts.map +1 -1
- package/models/models/key-value/services/key-value-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/region-info/region-info-model.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/services/trouble-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/future/index.d.ts.map +1 -1
- package/models/services/login/index.d.ts.map +1 -1
- package/models/services/trouble/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-rg4pjrxg.cjs → software-info-registration-CA13_Qc_.cjs} +1110 -645
- package/software-info-registration-CA13_Qc_.cjs.map +1 -0
- package/{software-info-registration-Cbvzr2Q-.js → software-info-registration-CKRUzp_3.js} +1376 -911
- package/software-info-registration-CKRUzp_3.js.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/features/canvas/components/canvas-streamer/canvas-streamer.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/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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const mobx = require("mobx");
|
|
3
|
-
const log$
|
|
3
|
+
const log$1h = require("loglevel");
|
|
4
4
|
const robot3 = require("robot3");
|
|
5
5
|
const dateFns = require("date-fns");
|
|
6
6
|
const HEADER_METHOD = `method`;
|
|
@@ -27,7 +27,140 @@ var KosWsEvents = /* @__PURE__ */ ((KosWsEvents2) => {
|
|
|
27
27
|
return KosWsEvents2;
|
|
28
28
|
})(KosWsEvents || {});
|
|
29
29
|
const EVENT_KOS_MODEL_READY = "/kos/model/ready/";
|
|
30
|
-
|
|
30
|
+
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
31
|
+
const [key, val] = pair.split("=");
|
|
32
|
+
return [key, decodeURIComponent(val || "")];
|
|
33
|
+
}).reduce((result, [key, val]) => {
|
|
34
|
+
result[key] = val;
|
|
35
|
+
return result;
|
|
36
|
+
}, {});
|
|
37
|
+
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
38
|
+
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
39
|
+
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
40
|
+
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
41
|
+
const PROFILE_LOG_INFO = "studio.log.info";
|
|
42
|
+
const defaultConfig = {
|
|
43
|
+
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
44
|
+
};
|
|
45
|
+
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
46
|
+
const configObj = JSON.parse(config);
|
|
47
|
+
const urlProfiles = () => {
|
|
48
|
+
if (typeof window === "undefined") {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const value = getQueryParams()?.["kosProfiles"];
|
|
52
|
+
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
53
|
+
};
|
|
54
|
+
configObj.profiles = [
|
|
55
|
+
...configObj.profiles ?? [],
|
|
56
|
+
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
57
|
+
];
|
|
58
|
+
globalThis.kosConfig = configObj;
|
|
59
|
+
const KosGlobalConfig = configObj;
|
|
60
|
+
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
61
|
+
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
62
|
+
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
63
|
+
const resolveLogLevelProfile = () => {
|
|
64
|
+
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
65
|
+
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
66
|
+
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
67
|
+
};
|
|
68
|
+
const getLogLevel = () => {
|
|
69
|
+
const params2 = getQueryParams();
|
|
70
|
+
const profileLogLevel = resolveLogLevelProfile();
|
|
71
|
+
const logLevelParam = params2["kosLogLevel"];
|
|
72
|
+
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
73
|
+
if (logLevel) {
|
|
74
|
+
return logLevel;
|
|
75
|
+
}
|
|
76
|
+
return "WARN";
|
|
77
|
+
};
|
|
78
|
+
const LogGroup = {
|
|
79
|
+
core: "core",
|
|
80
|
+
transport: "transport",
|
|
81
|
+
model: "model",
|
|
82
|
+
service: "service",
|
|
83
|
+
ui: "ui"
|
|
84
|
+
};
|
|
85
|
+
const UI_GROUP_OVERRIDE = "ui:group";
|
|
86
|
+
const UI_LOGGER_OVERRIDE = "ui:logger";
|
|
87
|
+
const LEVELS = ["trace", "debug", "info", "warn", "error"];
|
|
88
|
+
const getLoggerGroup = (loggerName) => {
|
|
89
|
+
const grouped = loggerName.indexOf(":::");
|
|
90
|
+
if (grouped >= 0) {
|
|
91
|
+
return loggerName.slice(0, grouped);
|
|
92
|
+
}
|
|
93
|
+
const ungrouped = loggerName.indexOf("::");
|
|
94
|
+
return ungrouped >= 0 ? loggerName.slice(0, ungrouped) : "";
|
|
95
|
+
};
|
|
96
|
+
const matchesPattern = (value, pattern) => {
|
|
97
|
+
const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
98
|
+
return new RegExp(`^${source}$`).test(value);
|
|
99
|
+
};
|
|
100
|
+
const matches = (loggerName, override) => {
|
|
101
|
+
const wildcard = override.name.includes("*");
|
|
102
|
+
if (override.type === UI_GROUP_OVERRIDE) {
|
|
103
|
+
const group = getLoggerGroup(loggerName);
|
|
104
|
+
return wildcard ? matchesPattern(group, override.name) : group === override.name;
|
|
105
|
+
}
|
|
106
|
+
if (override.type === UI_LOGGER_OVERRIDE) {
|
|
107
|
+
return wildcard ? matchesPattern(loggerName, override.name) : loggerName.startsWith(override.name);
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
};
|
|
111
|
+
const resolveOverrideLevel = (loggerName, overrides) => overrides.filter((override) => matches(loggerName, override)).map((override) => override.level.toLowerCase()).filter((level2) => LEVELS.includes(level2)).sort((a, b) => LEVELS.indexOf(a) - LEVELS.indexOf(b))[0];
|
|
112
|
+
const MESSAGE_LOGGER_NAME = "messages";
|
|
113
|
+
const MESSAGE_LOGGER = `${LogGroup.transport}:::${MESSAGE_LOGGER_NAME}`;
|
|
114
|
+
const originalFactory = log$1h.methodFactory;
|
|
115
|
+
log$1h.methodFactory = function(methodName, logLevel, loggerName) {
|
|
116
|
+
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
117
|
+
return function(...args) {
|
|
118
|
+
const _name = loggerName ? String(loggerName) : "";
|
|
119
|
+
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
120
|
+
const message = args.map(
|
|
121
|
+
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
122
|
+
).join(" ");
|
|
123
|
+
rawMethod(`${prefix}${message}`);
|
|
124
|
+
if (globalThis?.kosConfig?.logging && globalThis.kosLog && loggerName !== MESSAGE_LOGGER) {
|
|
125
|
+
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
let level = getLogLevel();
|
|
130
|
+
log$1h.setLevel(level);
|
|
131
|
+
window.setKosLogLevel = (_level) => {
|
|
132
|
+
level = _level;
|
|
133
|
+
log$1h.setLevel(_level);
|
|
134
|
+
};
|
|
135
|
+
const conditionallyLog = (level2) => (fn, logger = log$1h) => {
|
|
136
|
+
if (logger.getLevel() <= level2) {
|
|
137
|
+
fn();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const createLogger = ({ name, group }) => {
|
|
141
|
+
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
142
|
+
const _log = log$1h.getLogger(loggerName);
|
|
143
|
+
const _level = resolveOverrideLevel(
|
|
144
|
+
loggerName,
|
|
145
|
+
globalThis.kos?.logOverrides ?? []
|
|
146
|
+
);
|
|
147
|
+
if (_level) {
|
|
148
|
+
_log.setLevel(_level);
|
|
149
|
+
}
|
|
150
|
+
return _log;
|
|
151
|
+
};
|
|
152
|
+
const KosLog = {
|
|
153
|
+
...log$1h,
|
|
154
|
+
ifDebug: conditionallyLog(log$1h.levels.DEBUG),
|
|
155
|
+
ifInfo: conditionallyLog(log$1h.levels.INFO),
|
|
156
|
+
ifWarn: conditionallyLog(log$1h.levels.WARN),
|
|
157
|
+
ifError: conditionallyLog(log$1h.levels.ERROR),
|
|
158
|
+
getLogger: (name) => createLogger({ name }),
|
|
159
|
+
getLoggers: () => log$1h.getLoggers(),
|
|
160
|
+
createLogger
|
|
161
|
+
};
|
|
162
|
+
const log$1g = KosLog.createLogger({ group: LogGroup.core, name: "event-bus" });
|
|
163
|
+
log$1g.info("Initializing event bus");
|
|
31
164
|
globalThis.kos = globalThis.kos || {};
|
|
32
165
|
globalThis.kos.subscriptions = globalThis.kos.subscriptions || {};
|
|
33
166
|
const subscriptions = globalThis.kos.subscriptions;
|
|
@@ -38,15 +171,15 @@ function hasEventSubscriptions(eventType) {
|
|
|
38
171
|
function subscribe(eventType, callback) {
|
|
39
172
|
const id = getNextUniqueId();
|
|
40
173
|
if (!subscriptions[eventType]) {
|
|
41
|
-
log$
|
|
174
|
+
log$1g.debug(`Initializing subscription for ${eventType}`);
|
|
42
175
|
subscriptions[eventType] = {};
|
|
43
176
|
}
|
|
44
|
-
log$
|
|
177
|
+
log$1g.debug(`Subscribing to ${eventType} with id ${id.toString()}`);
|
|
45
178
|
subscriptions[eventType][id] = callback;
|
|
46
179
|
return {
|
|
47
180
|
count: subscriptions[eventType] ? Object.getOwnPropertySymbols(subscriptions[eventType]).length : 0,
|
|
48
181
|
unsubscribe: () => {
|
|
49
|
-
log$
|
|
182
|
+
log$1g.debug(`Unsubscribing from ${eventType} with id ${id.toString()}`);
|
|
50
183
|
if (subscriptions[eventType] && subscriptions[eventType][id]) {
|
|
51
184
|
delete subscriptions[eventType][id];
|
|
52
185
|
}
|
|
@@ -61,7 +194,7 @@ function subscribe(eventType, callback) {
|
|
|
61
194
|
}
|
|
62
195
|
function publish(eventType, msg, headers = {}) {
|
|
63
196
|
if (!subscriptions[eventType] || Object.getOwnPropertySymbols(subscriptions[eventType]).length === 0) {
|
|
64
|
-
log$
|
|
197
|
+
log$1g.debug(`No subscriptions for ${eventType}. Not publishing.`);
|
|
65
198
|
return {
|
|
66
199
|
eventType,
|
|
67
200
|
subscribers: 0
|
|
@@ -71,19 +204,19 @@ function publish(eventType, msg, headers = {}) {
|
|
|
71
204
|
Object.getOwnPropertySymbols(subscriptions[eventType]).forEach((id) => {
|
|
72
205
|
if (headers["sync"]) {
|
|
73
206
|
const responseId = headers["sync"];
|
|
74
|
-
log$
|
|
207
|
+
log$1g.debug(
|
|
75
208
|
`Performing sync publish for ${eventType} with sync id ${responseId}`
|
|
76
209
|
);
|
|
77
210
|
subscriptions[eventType][id]({ body: msg, headers }).then(
|
|
78
211
|
(response) => {
|
|
79
|
-
log$
|
|
212
|
+
log$1g.debug(
|
|
80
213
|
`Response recieved for ${responseId}, publishing back to source.`
|
|
81
214
|
);
|
|
82
215
|
publish(responseId, response);
|
|
83
216
|
}
|
|
84
217
|
);
|
|
85
218
|
} else {
|
|
86
|
-
log$
|
|
219
|
+
log$1g.debug(`Performing async publish for ${eventType}`);
|
|
87
220
|
subscriptions[eventType][id]({ body: msg, headers });
|
|
88
221
|
}
|
|
89
222
|
});
|
|
@@ -93,7 +226,7 @@ function publish(eventType, msg, headers = {}) {
|
|
|
93
226
|
};
|
|
94
227
|
}
|
|
95
228
|
function reset() {
|
|
96
|
-
log$
|
|
229
|
+
log$1g.warn("Resetting event bus");
|
|
97
230
|
Object.keys(subscriptions).forEach((key) => delete subscriptions[key]);
|
|
98
231
|
}
|
|
99
232
|
function once(eventType, callback) {
|
|
@@ -409,185 +542,11 @@ const eventBus_state = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defi
|
|
|
409
542
|
waitForAllWithState,
|
|
410
543
|
waitForOrGetState
|
|
411
544
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
412
|
-
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
413
|
-
const [key, val] = pair.split("=");
|
|
414
|
-
return [key, decodeURIComponent(val || "")];
|
|
415
|
-
}).reduce((result, [key, val]) => {
|
|
416
|
-
result[key] = val;
|
|
417
|
-
return result;
|
|
418
|
-
}, {});
|
|
419
|
-
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
420
|
-
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
421
|
-
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
422
|
-
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
423
|
-
const PROFILE_LOG_INFO = "studio.log.info";
|
|
424
|
-
const defaultConfig = {
|
|
425
|
-
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
426
|
-
};
|
|
427
|
-
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
428
|
-
const configObj = JSON.parse(config);
|
|
429
|
-
const urlProfiles = () => {
|
|
430
|
-
if (typeof window === "undefined") {
|
|
431
|
-
return [];
|
|
432
|
-
}
|
|
433
|
-
const value = getQueryParams()?.["kosProfiles"];
|
|
434
|
-
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
435
|
-
};
|
|
436
|
-
configObj.profiles = [
|
|
437
|
-
...configObj.profiles ?? [],
|
|
438
|
-
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
439
|
-
];
|
|
440
|
-
globalThis.kosConfig = configObj;
|
|
441
|
-
const KosGlobalConfig = configObj;
|
|
442
|
-
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
443
|
-
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
444
|
-
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
445
|
-
const resolveLogLevelProfile = () => {
|
|
446
|
-
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
447
|
-
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
448
|
-
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
449
|
-
};
|
|
450
|
-
const getLogLevel = () => {
|
|
451
|
-
const params2 = getQueryParams();
|
|
452
|
-
const profileLogLevel = resolveLogLevelProfile();
|
|
453
|
-
const logLevelParam = params2["kosLogLevel"];
|
|
454
|
-
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
455
|
-
if (logLevel) {
|
|
456
|
-
return logLevel;
|
|
457
|
-
}
|
|
458
|
-
return "WARN";
|
|
459
|
-
};
|
|
460
|
-
const getKosMessageLogging = () => {
|
|
461
|
-
const enableAll = window.kosMessageLogging || process.env.KOS_MESSAGE_LOGGING === "true";
|
|
462
|
-
return enableAll;
|
|
463
|
-
};
|
|
464
|
-
const getLogMessageToStudio = () => {
|
|
465
|
-
const enableAll = window.kosMessageStudioLogging || process.env.KOS_MESSAGE_STUDIO_LOGGING === "true";
|
|
466
|
-
return enableAll;
|
|
467
|
-
};
|
|
468
|
-
const UI_GROUP_OVERRIDE = "ui:group";
|
|
469
|
-
const UI_LOGGER_OVERRIDE = "ui:logger";
|
|
470
|
-
const LEVELS = ["trace", "debug", "info", "warn", "error"];
|
|
471
|
-
const getLoggerGroup = (loggerName) => {
|
|
472
|
-
const grouped = loggerName.indexOf(":::");
|
|
473
|
-
if (grouped >= 0) {
|
|
474
|
-
return loggerName.slice(0, grouped);
|
|
475
|
-
}
|
|
476
|
-
const ungrouped = loggerName.indexOf("::");
|
|
477
|
-
return ungrouped >= 0 ? loggerName.slice(0, ungrouped) : "";
|
|
478
|
-
};
|
|
479
|
-
const matchesPattern = (value, pattern) => {
|
|
480
|
-
const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
481
|
-
return new RegExp(`^${source}$`).test(value);
|
|
482
|
-
};
|
|
483
|
-
const matches = (loggerName, override) => {
|
|
484
|
-
const wildcard = override.name.includes("*");
|
|
485
|
-
if (override.type === UI_GROUP_OVERRIDE) {
|
|
486
|
-
const group = getLoggerGroup(loggerName);
|
|
487
|
-
return wildcard ? matchesPattern(group, override.name) : group === override.name;
|
|
488
|
-
}
|
|
489
|
-
if (override.type === UI_LOGGER_OVERRIDE) {
|
|
490
|
-
return wildcard ? matchesPattern(loggerName, override.name) : loggerName.startsWith(override.name);
|
|
491
|
-
}
|
|
492
|
-
return false;
|
|
493
|
-
};
|
|
494
|
-
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];
|
|
495
|
-
const WS_LOG = "ws-log";
|
|
496
|
-
const originalFactory = log$M.methodFactory;
|
|
497
|
-
const enableMessageLogging = getKosMessageLogging();
|
|
498
|
-
const enableStudioMessageLogging = getLogMessageToStudio();
|
|
499
|
-
log$M.methodFactory = function(methodName, logLevel, loggerName) {
|
|
500
|
-
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
501
|
-
return function(...args) {
|
|
502
|
-
const _name = loggerName ? String(loggerName) : "";
|
|
503
|
-
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
504
|
-
const message = args.map(
|
|
505
|
-
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
506
|
-
).join(" ");
|
|
507
|
-
rawMethod(`${prefix}${message}`);
|
|
508
|
-
if (globalThis?.kosConfig?.logging && globalThis.kosLog && (loggerName !== WS_LOG || enableMessageLogging && enableStudioMessageLogging)) {
|
|
509
|
-
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
};
|
|
513
|
-
let level = getLogLevel();
|
|
514
|
-
log$M.setLevel(level);
|
|
515
|
-
window.setKosLogLevel = (_level) => {
|
|
516
|
-
level = _level;
|
|
517
|
-
log$M.setLevel(_level);
|
|
518
|
-
};
|
|
519
|
-
const wsLog = log$M.getLogger(WS_LOG);
|
|
520
|
-
window.enableKosMessageLog = () => {
|
|
521
|
-
wsLog.setLevel(log$M.levels.INFO);
|
|
522
|
-
};
|
|
523
|
-
window.disableKosMessageLog = () => {
|
|
524
|
-
wsLog.setLevel(log$M.levels.ERROR);
|
|
525
|
-
};
|
|
526
|
-
if (enableMessageLogging) {
|
|
527
|
-
window.enableKosMessageLog();
|
|
528
|
-
} else {
|
|
529
|
-
window.disableKosMessageLog();
|
|
530
|
-
}
|
|
531
|
-
const styles = [
|
|
532
|
-
"color: black",
|
|
533
|
-
"display: block",
|
|
534
|
-
"background-color: lightgreen",
|
|
535
|
-
"padding: 4px",
|
|
536
|
-
"margin: 0",
|
|
537
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
538
|
-
"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",
|
|
539
|
-
"font-weight: bold"
|
|
540
|
-
].join(";");
|
|
541
|
-
const received = [
|
|
542
|
-
"color: black",
|
|
543
|
-
"display: block",
|
|
544
|
-
"padding: 4px",
|
|
545
|
-
"background-color: yellow",
|
|
546
|
-
"margin: 0",
|
|
547
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
548
|
-
"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",
|
|
549
|
-
"font-weight: bold"
|
|
550
|
-
].join(";");
|
|
551
|
-
const conditionallyLog = (level2) => (fn) => {
|
|
552
|
-
if (log$M.getLevel() <= level2) {
|
|
553
|
-
fn();
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
const KosLog = {
|
|
557
|
-
...log$M,
|
|
558
|
-
ifDebug: conditionallyLog(log$M.levels.DEBUG),
|
|
559
|
-
ifInfo: conditionallyLog(log$M.levels.INFO),
|
|
560
|
-
ifWarn: conditionallyLog(log$M.levels.WARN),
|
|
561
|
-
ifError: conditionallyLog(log$M.levels.ERROR),
|
|
562
|
-
getLogger: (name) => log$M.getLogger(`kos::${name}`),
|
|
563
|
-
getLoggers: () => log$M.getLoggers(),
|
|
564
|
-
createLogger: ({ name, group }) => {
|
|
565
|
-
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
566
|
-
const _log = log$M.getLogger(loggerName);
|
|
567
|
-
const _level = resolveOverrideLevel(
|
|
568
|
-
loggerName,
|
|
569
|
-
globalThis.kos?.logOverrides ?? []
|
|
570
|
-
);
|
|
571
|
-
if (_level) {
|
|
572
|
-
_log.setLevel(_level);
|
|
573
|
-
}
|
|
574
|
-
return _log;
|
|
575
|
-
},
|
|
576
|
-
wsSend: (...msg) => {
|
|
577
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
578
|
-
wsLog.info(`%c⬆ ${str}`, styles);
|
|
579
|
-
},
|
|
580
|
-
wsReceive: (...msg) => {
|
|
581
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
582
|
-
wsLog.info(`%c⬇ ${str}`, received);
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
545
|
const SubscriptionHandlers = /* @__PURE__ */ Symbol(`SubscriptionHandlers`);
|
|
586
546
|
const DependencyModels = /* @__PURE__ */ Symbol(`DependencyModels`);
|
|
587
547
|
const FutureService = /* @__PURE__ */ Symbol(`FutureService`);
|
|
588
548
|
const ChildModels = /* @__PURE__ */ Symbol(`ChildModels`);
|
|
589
549
|
const ParentModel = /* @__PURE__ */ Symbol(`ParentModel`);
|
|
590
|
-
const LogConfig = /* @__PURE__ */ Symbol(`LogConfig`);
|
|
591
550
|
const ReferenceConfig = /* @__PURE__ */ Symbol(`ReferenceConfig`);
|
|
592
551
|
const KosModelSymbol = /* @__PURE__ */ Symbol(`KosModelSymbol`);
|
|
593
552
|
const ModelEffects = /* @__PURE__ */ Symbol(`ModelEffects`);
|
|
@@ -609,7 +568,10 @@ const KosViewModelSymbol = /* @__PURE__ */ Symbol(`KosViewModelSymbol`);
|
|
|
609
568
|
const ViewModelConfig = /* @__PURE__ */ Symbol(`ViewModelConfig`);
|
|
610
569
|
const ReloadAwareSetup = /* @__PURE__ */ Symbol(`ReloadAwareSetup`);
|
|
611
570
|
const MixinModels = /* @__PURE__ */ Symbol(`MixinModels`);
|
|
612
|
-
const log$
|
|
571
|
+
const log$1f = KosLog.createLogger({
|
|
572
|
+
group: LogGroup.core,
|
|
573
|
+
name: "fsm-injection"
|
|
574
|
+
});
|
|
613
575
|
function injectStateMachineSupport(modelInstance) {
|
|
614
576
|
const fsmSetup = modelInstance[StateMachineSetup];
|
|
615
577
|
if (!fsmSetup) return;
|
|
@@ -653,7 +615,7 @@ function initializeFsmProperties(modelInstance, options) {
|
|
|
653
615
|
const config2 = modelInstance._fsmConfig;
|
|
654
616
|
const initialState = computeInitialState ? computeInitialState(modelInstance) : config2.initial;
|
|
655
617
|
if (computeInitialState && !config2.states[initialState]) {
|
|
656
|
-
log$
|
|
618
|
+
log$1f.warn(
|
|
657
619
|
`computeInitialState returned "${initialState}" which is not a valid state. Falling back to "${config2.initial}".`
|
|
658
620
|
);
|
|
659
621
|
modelInstance[stateProperty] = config2.initial;
|
|
@@ -783,7 +745,7 @@ function handleAsyncEntryResult(instance, state, stateProperty, result) {
|
|
|
783
745
|
if (stateConfig.onError && instance[stateProperty] === state) {
|
|
784
746
|
instance.transition(stateConfig.onError);
|
|
785
747
|
} else {
|
|
786
|
-
log$
|
|
748
|
+
log$1f.error(`Async entry handler for state "${state}" failed:`, err);
|
|
787
749
|
}
|
|
788
750
|
}
|
|
789
751
|
);
|
|
@@ -824,7 +786,7 @@ function initializeStateMachine(modelInstance, lifecycle) {
|
|
|
824
786
|
modelInstance._fsmInitialized = true;
|
|
825
787
|
trackInitialStateInHistory(modelInstance, config2.initial, options);
|
|
826
788
|
executeInitialStateEntryHandler(modelInstance, config2.initial);
|
|
827
|
-
log$
|
|
789
|
+
log$1f.debug(
|
|
828
790
|
`FSM initialized for model ${modelInstance.id} at lifecycle ${lifecycle} with initial state "${config2.initial}"`
|
|
829
791
|
);
|
|
830
792
|
}
|
|
@@ -948,9 +910,12 @@ function getHttpRouteHandlers(model) {
|
|
|
948
910
|
return model?.[HttpRouteHandlers] || [];
|
|
949
911
|
}
|
|
950
912
|
class KosLoggerFactory {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
913
|
+
/**
|
|
914
|
+
* The logger for a model type, `model:::{modelTypeName}`. Every instance of
|
|
915
|
+
* the type shares it; put the instance id in the message where it matters.
|
|
916
|
+
*/
|
|
917
|
+
static create({ modelTypeName }) {
|
|
918
|
+
return KosLog.createLogger({ group: LogGroup.model, name: modelTypeName });
|
|
954
919
|
}
|
|
955
920
|
}
|
|
956
921
|
function kosLoggerAware(options) {
|
|
@@ -968,8 +933,7 @@ function kosLoggerAware(options) {
|
|
|
968
933
|
if (!sharedLogger) {
|
|
969
934
|
const modelType = getModelType();
|
|
970
935
|
sharedLogger = KosLoggerFactory.create({
|
|
971
|
-
modelTypeName: loggerContext || modelType
|
|
972
|
-
component: "kos-model"
|
|
936
|
+
modelTypeName: loggerContext || modelType
|
|
973
937
|
});
|
|
974
938
|
}
|
|
975
939
|
return sharedLogger;
|
|
@@ -1020,7 +984,10 @@ class ServiceRequestError extends Error {
|
|
|
1020
984
|
this.responseHeaders = details.responseHeaders ?? {};
|
|
1021
985
|
}
|
|
1022
986
|
}
|
|
1023
|
-
const log$
|
|
987
|
+
const log$1e = KosLog.createLogger({
|
|
988
|
+
group: LogGroup.core,
|
|
989
|
+
name: "resolve-parameters"
|
|
990
|
+
});
|
|
1024
991
|
const resolveParameters = ({
|
|
1025
992
|
value,
|
|
1026
993
|
modelId,
|
|
@@ -1052,11 +1019,11 @@ const resolveParameters = ({
|
|
|
1052
1019
|
)) {
|
|
1053
1020
|
const prop = modelData[propName];
|
|
1054
1021
|
if (prop !== null && prop !== void 0) {
|
|
1055
|
-
log$
|
|
1022
|
+
log$1e.debug(`Resolved ${match} to ${prop}`);
|
|
1056
1023
|
return prop;
|
|
1057
1024
|
} else {
|
|
1058
1025
|
const logLevel2 = isOnlyPropKey ? "debug" : "warn";
|
|
1059
|
-
log$
|
|
1026
|
+
log$1e[logLevel2](
|
|
1060
1027
|
`Property ${propName} is null or undefined${isOnlyPropKey ? "" : " in composite string"}, marking for undefined return`
|
|
1061
1028
|
);
|
|
1062
1029
|
hasUnresolvedProp = true;
|
|
@@ -1064,7 +1031,7 @@ const resolveParameters = ({
|
|
|
1064
1031
|
}
|
|
1065
1032
|
}
|
|
1066
1033
|
const logLevel = isOnlyPropKey ? "debug" : "warn";
|
|
1067
|
-
log$
|
|
1034
|
+
log$1e[logLevel](
|
|
1068
1035
|
`Property ${propName} not found in modelData${isOnlyPropKey ? "" : " for composite string"}`
|
|
1069
1036
|
);
|
|
1070
1037
|
return match;
|
|
@@ -1079,7 +1046,10 @@ const resolveParameters = ({
|
|
|
1079
1046
|
}
|
|
1080
1047
|
return _value;
|
|
1081
1048
|
};
|
|
1082
|
-
const log$
|
|
1049
|
+
const log$1d = KosLog.createLogger({
|
|
1050
|
+
group: LogGroup.core,
|
|
1051
|
+
name: "ServiceRequestHelpers"
|
|
1052
|
+
});
|
|
1083
1053
|
function resolveServiceRequestParameters(metadata, modelInstance, args, runtimeOptions) {
|
|
1084
1054
|
const resolvedPath = resolveParameters({
|
|
1085
1055
|
value: metadata.path,
|
|
@@ -1148,7 +1118,7 @@ function handleServiceRequestError(error, response, errorHandler, modelInstance,
|
|
|
1148
1118
|
});
|
|
1149
1119
|
switch (errorHandler.strategy) {
|
|
1150
1120
|
case "log":
|
|
1151
|
-
log$
|
|
1121
|
+
log$1d.error(`Service request status ${richError.status} error: ${error}`);
|
|
1152
1122
|
if (errorHandler.onError) {
|
|
1153
1123
|
errorHandler.onError(richError, modelInstance);
|
|
1154
1124
|
}
|
|
@@ -1261,7 +1231,10 @@ var ReplayStrategy = /* @__PURE__ */ ((ReplayStrategy2) => {
|
|
|
1261
1231
|
ReplayStrategy2["NONE"] = "none";
|
|
1262
1232
|
return ReplayStrategy2;
|
|
1263
1233
|
})(ReplayStrategy || {});
|
|
1264
|
-
const log$
|
|
1234
|
+
const log$1c = KosLog.createLogger({
|
|
1235
|
+
group: LogGroup.core,
|
|
1236
|
+
name: "kos-state-machine"
|
|
1237
|
+
});
|
|
1265
1238
|
function kosStateMachine(config2, options) {
|
|
1266
1239
|
return (target) => {
|
|
1267
1240
|
target.prototype[StateMachineSetup] = {
|
|
@@ -1318,7 +1291,7 @@ function kosStateGuard(options) {
|
|
|
1318
1291
|
if (shouldThrow) {
|
|
1319
1292
|
throw new Error(message);
|
|
1320
1293
|
} else {
|
|
1321
|
-
log$
|
|
1294
|
+
log$1c.warn(message);
|
|
1322
1295
|
return void 0;
|
|
1323
1296
|
}
|
|
1324
1297
|
}
|
|
@@ -1344,6 +1317,10 @@ const kosDependency = ({
|
|
|
1344
1317
|
resolutionPolicy
|
|
1345
1318
|
};
|
|
1346
1319
|
};
|
|
1320
|
+
const log$1b = KosLog.createLogger({
|
|
1321
|
+
group: LogGroup.model,
|
|
1322
|
+
name: "future-aware"
|
|
1323
|
+
});
|
|
1347
1324
|
class MultipleFutureHandler {
|
|
1348
1325
|
futures;
|
|
1349
1326
|
defaultContext;
|
|
@@ -1434,7 +1411,7 @@ class FutureHandler {
|
|
|
1434
1411
|
try {
|
|
1435
1412
|
await this._future.cancelFuture();
|
|
1436
1413
|
} catch (e) {
|
|
1437
|
-
|
|
1414
|
+
log$1b.error(e);
|
|
1438
1415
|
throw e;
|
|
1439
1416
|
}
|
|
1440
1417
|
}
|
|
@@ -1559,6 +1536,10 @@ const ObservableData = (initialData) => {
|
|
|
1559
1536
|
const od = createObservableData(ObservableDataMap, initialData);
|
|
1560
1537
|
return new od(initialData);
|
|
1561
1538
|
};
|
|
1539
|
+
const log$1a = KosLog.createLogger({
|
|
1540
|
+
group: LogGroup.core,
|
|
1541
|
+
name: "extension-manager"
|
|
1542
|
+
});
|
|
1562
1543
|
const DEFAULT_EXTENSION_OPTIONS = {
|
|
1563
1544
|
failurePolicy: "throw"
|
|
1564
1545
|
};
|
|
@@ -1610,8 +1591,8 @@ const _ExtensionManager = {
|
|
|
1610
1591
|
return await loader(data);
|
|
1611
1592
|
} catch (e) {
|
|
1612
1593
|
if (options.failurePolicy === "continue") {
|
|
1613
|
-
|
|
1614
|
-
|
|
1594
|
+
log$1a.error(`Error executing data loader for id ${id}`);
|
|
1595
|
+
log$1a.error(e);
|
|
1615
1596
|
return void 0;
|
|
1616
1597
|
}
|
|
1617
1598
|
throw new ExtensionException(id, "dataLoader", e);
|
|
@@ -1636,8 +1617,8 @@ const _ExtensionManager = {
|
|
|
1636
1617
|
return mapper(data, context);
|
|
1637
1618
|
} catch (e) {
|
|
1638
1619
|
if (options.failurePolicy === "continue") {
|
|
1639
|
-
|
|
1640
|
-
|
|
1620
|
+
log$1a.error(`Error executing property mapper for id ${id}`);
|
|
1621
|
+
log$1a.error(e);
|
|
1641
1622
|
return "";
|
|
1642
1623
|
}
|
|
1643
1624
|
throw new ExtensionException(id, "propertyMapper", e);
|
|
@@ -1665,8 +1646,8 @@ const _ExtensionManager = {
|
|
|
1665
1646
|
Object.assign(result, _interim);
|
|
1666
1647
|
} catch (e) {
|
|
1667
1648
|
if (options.failurePolicy === "continue") {
|
|
1668
|
-
|
|
1669
|
-
|
|
1649
|
+
log$1a.error(`Error executing data mapper for id ${id}`);
|
|
1650
|
+
log$1a.error(e);
|
|
1670
1651
|
continue;
|
|
1671
1652
|
}
|
|
1672
1653
|
throw new ExtensionException(id, "dataMapper", e);
|
|
@@ -1678,7 +1659,7 @@ const _ExtensionManager = {
|
|
|
1678
1659
|
canvas: {
|
|
1679
1660
|
registerRenderer: (id, renderer) => {
|
|
1680
1661
|
if (!ExtensionManager[EXTENSION_CANVAS_RENDERER]) {
|
|
1681
|
-
|
|
1662
|
+
log$1a.warn(
|
|
1682
1663
|
`Canvas renderer extension point is not registered. Cannot register renderer "${id}".`
|
|
1683
1664
|
);
|
|
1684
1665
|
return;
|
|
@@ -1704,6 +1685,10 @@ const INDEX_COLLECTION_KEY = "@kosdev-code/kos-ui-sdk.collection";
|
|
|
1704
1685
|
function isIndexableItem(value) {
|
|
1705
1686
|
return typeof value === "object" && value !== null && INDEX_RECORD_SYMBOL in value;
|
|
1706
1687
|
}
|
|
1688
|
+
const log$19 = KosLog.createLogger({
|
|
1689
|
+
group: LogGroup.core,
|
|
1690
|
+
name: "kos-container-index"
|
|
1691
|
+
});
|
|
1707
1692
|
function isPromiseLike(value) {
|
|
1708
1693
|
return typeof value?.then === "function";
|
|
1709
1694
|
}
|
|
@@ -1755,7 +1740,7 @@ class KosContainerIndex {
|
|
|
1755
1740
|
const set = map.get(key) || /* @__PURE__ */ new Set();
|
|
1756
1741
|
this._map.set(key, set);
|
|
1757
1742
|
} else {
|
|
1758
|
-
|
|
1743
|
+
log$19.debug(`KosContainerIndex - Index ${key} is the same`);
|
|
1759
1744
|
}
|
|
1760
1745
|
});
|
|
1761
1746
|
}
|
|
@@ -1831,7 +1816,10 @@ function observeComputedProperties(model, callback, keys = []) {
|
|
|
1831
1816
|
);
|
|
1832
1817
|
return disposers;
|
|
1833
1818
|
}
|
|
1834
|
-
const log$
|
|
1819
|
+
const log$18 = KosLog.createLogger({
|
|
1820
|
+
group: LogGroup.core,
|
|
1821
|
+
name: "kos-container-model"
|
|
1822
|
+
});
|
|
1835
1823
|
class KosModelContainer {
|
|
1836
1824
|
_data;
|
|
1837
1825
|
_sortKey;
|
|
@@ -1953,14 +1941,14 @@ class KosModelContainer {
|
|
|
1953
1941
|
async removeAndDestroy(id) {
|
|
1954
1942
|
const model = this.getModel(id);
|
|
1955
1943
|
if (!model) {
|
|
1956
|
-
log$
|
|
1944
|
+
log$18.debug(`Model ${id} not found in container, skipping destroy`);
|
|
1957
1945
|
return;
|
|
1958
1946
|
}
|
|
1959
1947
|
this.removeModel(id);
|
|
1960
1948
|
try {
|
|
1961
1949
|
await destroyKosModel(model);
|
|
1962
1950
|
} catch (error) {
|
|
1963
|
-
log$
|
|
1951
|
+
log$18.error(`Failed to destroy model ${id}:`, error);
|
|
1964
1952
|
throw error;
|
|
1965
1953
|
}
|
|
1966
1954
|
}
|
|
@@ -1977,7 +1965,7 @@ class KosModelContainer {
|
|
|
1977
1965
|
async removeAndDestroyAll(ids) {
|
|
1978
1966
|
const models2 = ids.map((id) => this.getModel(id)).filter((model) => model !== void 0);
|
|
1979
1967
|
if (models2.length === 0) {
|
|
1980
|
-
log$
|
|
1968
|
+
log$18.debug("No models found to destroy");
|
|
1981
1969
|
return;
|
|
1982
1970
|
}
|
|
1983
1971
|
this.removeAll(ids);
|
|
@@ -1986,7 +1974,7 @@ class KosModelContainer {
|
|
|
1986
1974
|
);
|
|
1987
1975
|
results.forEach((result, index) => {
|
|
1988
1976
|
if (result.status === "rejected") {
|
|
1989
|
-
log$
|
|
1977
|
+
log$18.error(
|
|
1990
1978
|
`Failed to destroy model ${models2[index].id}:`,
|
|
1991
1979
|
result.reason
|
|
1992
1980
|
);
|
|
@@ -2159,7 +2147,7 @@ class KosModelContainer {
|
|
|
2159
2147
|
const idx = this.index.get(indexName);
|
|
2160
2148
|
return idx.keys ?? [];
|
|
2161
2149
|
} else {
|
|
2162
|
-
log$
|
|
2150
|
+
log$18.info(
|
|
2163
2151
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2164
2152
|
);
|
|
2165
2153
|
return [];
|
|
@@ -2171,7 +2159,7 @@ class KosModelContainer {
|
|
|
2171
2159
|
if (idx.index.has(indexKey)) {
|
|
2172
2160
|
return idx.getByKey(indexKey);
|
|
2173
2161
|
} else {
|
|
2174
|
-
log$
|
|
2162
|
+
log$18.info(
|
|
2175
2163
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
2176
2164
|
idx.index.keys()
|
|
2177
2165
|
)}`
|
|
@@ -2179,7 +2167,7 @@ class KosModelContainer {
|
|
|
2179
2167
|
return [];
|
|
2180
2168
|
}
|
|
2181
2169
|
} else {
|
|
2182
|
-
log$
|
|
2170
|
+
log$18.info(
|
|
2183
2171
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2184
2172
|
);
|
|
2185
2173
|
return [];
|
|
@@ -2206,7 +2194,7 @@ class KosModelContainer {
|
|
|
2206
2194
|
* @private
|
|
2207
2195
|
*/
|
|
2208
2196
|
_logCapacityWarning(toEvict) {
|
|
2209
|
-
log$
|
|
2197
|
+
log$18.info(
|
|
2210
2198
|
`Container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${toEvict} models using ${this._evictionStrategy} strategy.`,
|
|
2211
2199
|
{ parentId: this._parentId }
|
|
2212
2200
|
);
|
|
@@ -2269,7 +2257,7 @@ class KosModelContainer {
|
|
|
2269
2257
|
const candidates = this._customEvictionFilter(this.data);
|
|
2270
2258
|
return candidates.slice(0, count);
|
|
2271
2259
|
}
|
|
2272
|
-
log$
|
|
2260
|
+
log$18.error(
|
|
2273
2261
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO.",
|
|
2274
2262
|
{ parentId: this._parentId }
|
|
2275
2263
|
);
|
|
@@ -2281,7 +2269,7 @@ class KosModelContainer {
|
|
|
2281
2269
|
*/
|
|
2282
2270
|
async _removeEvictedModels(models2) {
|
|
2283
2271
|
for (const model of models2) {
|
|
2284
|
-
log$
|
|
2272
|
+
log$18.info(
|
|
2285
2273
|
`Evicting model: ${model.id} (type: ${model.constructor.name})`,
|
|
2286
2274
|
{
|
|
2287
2275
|
modelId: model.id,
|
|
@@ -2291,7 +2279,7 @@ class KosModelContainer {
|
|
|
2291
2279
|
);
|
|
2292
2280
|
this.removeModel(model.id, true);
|
|
2293
2281
|
destroyKosModel(model).catch(
|
|
2294
|
-
(e) => log$
|
|
2282
|
+
(e) => log$18.error(`Failed to destroy evicted model ${model.id}:`, e)
|
|
2295
2283
|
);
|
|
2296
2284
|
}
|
|
2297
2285
|
}
|
|
@@ -2300,7 +2288,7 @@ class KosModelContainer {
|
|
|
2300
2288
|
* @private
|
|
2301
2289
|
*/
|
|
2302
2290
|
_logEvictionComplete(evictedCount) {
|
|
2303
|
-
log$
|
|
2291
|
+
log$18.info(
|
|
2304
2292
|
`Evicted ${evictedCount} models. Current size: ${this._data.size}/${this._maxCapacity}`,
|
|
2305
2293
|
{ parentId: this._parentId }
|
|
2306
2294
|
);
|
|
@@ -2309,9 +2297,9 @@ class KosModelContainer {
|
|
|
2309
2297
|
this._data.forEach((model) => {
|
|
2310
2298
|
const modelId = model.id;
|
|
2311
2299
|
destroyKosModel(model).then(() => {
|
|
2312
|
-
log$
|
|
2300
|
+
log$18.debug(`${modelId} destroyed, removing from map`);
|
|
2313
2301
|
this.removeModel(modelId, true);
|
|
2314
|
-
}).catch((e) => log$
|
|
2302
|
+
}).catch((e) => log$18.error(e));
|
|
2315
2303
|
});
|
|
2316
2304
|
this.increment();
|
|
2317
2305
|
}
|
|
@@ -2454,12 +2442,16 @@ const whenReady = async (dataModel) => {
|
|
|
2454
2442
|
}
|
|
2455
2443
|
return dataModel;
|
|
2456
2444
|
};
|
|
2445
|
+
const log$17 = KosLog.createLogger({
|
|
2446
|
+
group: LogGroup.core,
|
|
2447
|
+
name: "kos-model-utils"
|
|
2448
|
+
});
|
|
2457
2449
|
const destroyKosModel = async (model) => {
|
|
2458
2450
|
await KosCore.getInstance().whenReady();
|
|
2459
2451
|
await KosCore.getInstance().modelManager.initiateDestroyModel(model);
|
|
2460
2452
|
};
|
|
2461
2453
|
const unloadKosModel = async (dataModel) => {
|
|
2462
|
-
|
|
2454
|
+
log$17.warn(
|
|
2463
2455
|
`unloadKosModel(${dataModel?.id}) is deprecated and never resolves. Use destroyKosModel() to release a model, or reload() to refresh it.`
|
|
2464
2456
|
);
|
|
2465
2457
|
await KosCore.getInstance().whenReady();
|
|
@@ -2472,16 +2464,16 @@ const unloadKosModel = async (dataModel) => {
|
|
|
2472
2464
|
}
|
|
2473
2465
|
};
|
|
2474
2466
|
const resetKosModel = async (model) => {
|
|
2475
|
-
|
|
2467
|
+
log$17.warn(
|
|
2476
2468
|
`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.`
|
|
2477
2469
|
);
|
|
2478
2470
|
await KosCore.getInstance().whenReady();
|
|
2479
2471
|
await KosCore.getInstance().modelManager.reloadModel(model);
|
|
2480
|
-
|
|
2472
|
+
log$17.debug(
|
|
2481
2473
|
`reload model initiated for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2482
2474
|
);
|
|
2483
2475
|
await whenReady(model);
|
|
2484
|
-
|
|
2476
|
+
log$17.debug(
|
|
2485
2477
|
`reload model complete for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2486
2478
|
);
|
|
2487
2479
|
};
|
|
@@ -2557,7 +2549,7 @@ const getObservableCompanions = (modelId) => {
|
|
|
2557
2549
|
const resolveKosCompanion = (modelId, resolver) => {
|
|
2558
2550
|
const model = KosCore.getInstance().modelManager.getModelById(modelId);
|
|
2559
2551
|
if (!model) {
|
|
2560
|
-
|
|
2552
|
+
log$17.info(`Model not found for id ${modelId}`);
|
|
2561
2553
|
return void 0;
|
|
2562
2554
|
}
|
|
2563
2555
|
const companionModel = Array.from(model.companionModels.all()).find(
|
|
@@ -2596,7 +2588,10 @@ const getKosModelActivationState = (model) => {
|
|
|
2596
2588
|
}
|
|
2597
2589
|
};
|
|
2598
2590
|
};
|
|
2599
|
-
const log$
|
|
2591
|
+
const log$16 = KosLog.createLogger({
|
|
2592
|
+
group: LogGroup.core,
|
|
2593
|
+
name: "kos-model-factory"
|
|
2594
|
+
});
|
|
2600
2595
|
const KosModelFactory = {
|
|
2601
2596
|
byModelType: (modelType) => KosCore.getInstance().modelManager.getModelFactory(
|
|
2602
2597
|
modelType
|
|
@@ -2604,7 +2599,7 @@ const KosModelFactory = {
|
|
|
2604
2599
|
getModelInstance: (id, modelType, options) => {
|
|
2605
2600
|
const factory = KosModelFactory.byModelType(modelType);
|
|
2606
2601
|
if (!factory) {
|
|
2607
|
-
log$
|
|
2602
|
+
log$16.error(
|
|
2608
2603
|
`No registered factory found for model type ${modelType}. Please register a factory for this model type. `
|
|
2609
2604
|
);
|
|
2610
2605
|
throw Error(`No factory found for model type ${modelType}`);
|
|
@@ -2643,6 +2638,10 @@ const Kos = {
|
|
|
2643
2638
|
instance: (modelType) => (id) => KosModelFactory.getModelInstance(id, modelType)
|
|
2644
2639
|
}
|
|
2645
2640
|
};
|
|
2641
|
+
const log$15 = KosLog.createLogger({
|
|
2642
|
+
group: LogGroup.core,
|
|
2643
|
+
name: "registration-manager"
|
|
2644
|
+
});
|
|
2646
2645
|
window.KosRegistry = window.KosRegistry || {
|
|
2647
2646
|
coreModels: /* @__PURE__ */ new Map(),
|
|
2648
2647
|
preloadModels: [],
|
|
@@ -2687,7 +2686,7 @@ const RegistrationManager = {
|
|
|
2687
2686
|
}
|
|
2688
2687
|
if (KosCore.getInstance().isReady) {
|
|
2689
2688
|
if (!KosCore.getInstance().modelManager.registry.models[register.type]) {
|
|
2690
|
-
|
|
2689
|
+
log$15.info(
|
|
2691
2690
|
`Model with type ${register.type} doesn't exist. Adding new registration`
|
|
2692
2691
|
);
|
|
2693
2692
|
KosCore.getInstance().modelManager.registry.models[register.type] = register.registration[register.type];
|
|
@@ -2919,7 +2918,7 @@ class SingletonKosModelRegistrationFactory extends KosBaseModelRegistration {
|
|
|
2919
2918
|
};
|
|
2920
2919
|
}
|
|
2921
2920
|
}
|
|
2922
|
-
const log$
|
|
2921
|
+
const log$14 = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
2923
2922
|
const FUTURE_CANCEL_END_STATE = "CANCEL";
|
|
2924
2923
|
function resolveParentContext(TargetClass, modelId, modelData) {
|
|
2925
2924
|
const parentIdRaw = TargetClass[ParentModel]?.parentId;
|
|
@@ -3131,8 +3130,31 @@ function injectTroubleAwareSupport(modelInstance) {
|
|
|
3131
3130
|
configurable: true
|
|
3132
3131
|
});
|
|
3133
3132
|
}
|
|
3133
|
+
function registrationBuilders(model) {
|
|
3134
|
+
const registration = () => {
|
|
3135
|
+
const resolved = typeof model === "function" ? model() : model;
|
|
3136
|
+
if (!resolved) {
|
|
3137
|
+
throw new Error(
|
|
3138
|
+
"reconcile.model is undefined: the registration was not yet defined when @kosContainerAware ran. Pass model: () => Registration."
|
|
3139
|
+
);
|
|
3140
|
+
}
|
|
3141
|
+
return resolved;
|
|
3142
|
+
};
|
|
3143
|
+
return {
|
|
3144
|
+
create: (dto) => registration().instance(dto.id).options(dto).build(),
|
|
3145
|
+
update: (dto, existing) => {
|
|
3146
|
+
if (!isUpdateable(existing)) {
|
|
3147
|
+
throw new Error(
|
|
3148
|
+
`Model ${existing.id} is not updateable. reconcile.model needs the child to implement UpdateAware.`
|
|
3149
|
+
);
|
|
3150
|
+
}
|
|
3151
|
+
existing.updateModel(dto);
|
|
3152
|
+
}
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3134
3155
|
function createContainerReconcile(container, reconcile) {
|
|
3135
|
-
const {
|
|
3156
|
+
const { idMapper, filter, afterCreate } = reconcile;
|
|
3157
|
+
const { create, update } = "model" in reconcile && !reconcile.create ? registrationBuilders(reconcile.model) : reconcile;
|
|
3136
3158
|
const apply = resolveContainerDeltas({
|
|
3137
3159
|
container,
|
|
3138
3160
|
onAddItem: (dto) => {
|
|
@@ -3214,7 +3236,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3214
3236
|
const { mode, parentProperty, excludeProperties } = companionConfig;
|
|
3215
3237
|
const parentModel = initialData.companionParent;
|
|
3216
3238
|
if (!parentModel) {
|
|
3217
|
-
log$
|
|
3239
|
+
log$14.warn(
|
|
3218
3240
|
`Companion decorator configured but no parent model found in initialData.companionParent`
|
|
3219
3241
|
);
|
|
3220
3242
|
return;
|
|
@@ -3288,7 +3310,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3288
3310
|
});
|
|
3289
3311
|
}
|
|
3290
3312
|
} catch (error) {
|
|
3291
|
-
log$
|
|
3313
|
+
log$14.debug(
|
|
3292
3314
|
`Skipping companion proxy for property ${propertyName}:`,
|
|
3293
3315
|
error
|
|
3294
3316
|
);
|
|
@@ -3325,7 +3347,7 @@ function makeSafeObservable(instance) {
|
|
|
3325
3347
|
try {
|
|
3326
3348
|
return mobx.makeAutoObservable(instance);
|
|
3327
3349
|
} catch (e) {
|
|
3328
|
-
log$
|
|
3350
|
+
log$14.error("Failed to make observable:", e);
|
|
3329
3351
|
return instance;
|
|
3330
3352
|
}
|
|
3331
3353
|
}
|
|
@@ -3335,9 +3357,8 @@ const modelConstructorProxy = {
|
|
|
3335
3357
|
const kosContext = KosContextManager.createContext(modelId);
|
|
3336
3358
|
resolveParentContext(TargetClass, modelId, initialData);
|
|
3337
3359
|
const hasLoggerAware = !!TargetClass.prototype[LoggerSetup];
|
|
3338
|
-
const logger = hasLoggerAware ? null :
|
|
3339
|
-
|
|
3340
|
-
group: TargetClass[LogConfig]?.group ?? "kos-model"
|
|
3360
|
+
const logger = hasLoggerAware ? null : KosLoggerFactory.create({
|
|
3361
|
+
modelTypeName: TargetClass.prototype.modelTypeId
|
|
3341
3362
|
});
|
|
3342
3363
|
const modelInstance = new TargetClass(modelId, initialData, {
|
|
3343
3364
|
logger,
|
|
@@ -3368,8 +3389,8 @@ function kosModel(config2) {
|
|
|
3368
3389
|
typedCtor.prototype[OptionsRequired] = true;
|
|
3369
3390
|
}
|
|
3370
3391
|
KosLog.ifDebug(() => {
|
|
3371
|
-
|
|
3372
|
-
});
|
|
3392
|
+
log$14.debug(`Registering model with id ${modelConfig.modelTypeId}`);
|
|
3393
|
+
}, log$14);
|
|
3373
3394
|
const proxiedCtor = new Proxy(typedCtor, modelConstructorProxy);
|
|
3374
3395
|
if (modelConfig.singleton !== void 0) {
|
|
3375
3396
|
let registration;
|
|
@@ -3665,7 +3686,10 @@ const KosDeletionManager = {
|
|
|
3665
3686
|
}
|
|
3666
3687
|
}
|
|
3667
3688
|
};
|
|
3668
|
-
const log$
|
|
3689
|
+
const log$13 = KosLog.createLogger({
|
|
3690
|
+
group: LogGroup.core,
|
|
3691
|
+
name: "kos-dependency-manager"
|
|
3692
|
+
});
|
|
3669
3693
|
class KosDependencyManager {
|
|
3670
3694
|
_usedByCache = /* @__PURE__ */ new Map();
|
|
3671
3695
|
_usesCache = /* @__PURE__ */ new Map();
|
|
@@ -3720,7 +3744,7 @@ class KosDependencyManager {
|
|
|
3720
3744
|
canDestroy(modelId) {
|
|
3721
3745
|
const usedBy = this._usedByCache.get(modelId);
|
|
3722
3746
|
if (usedBy?.length) {
|
|
3723
|
-
log$
|
|
3747
|
+
log$13.info(`Model ${modelId} is still used by: ${usedBy.join(", ")}`);
|
|
3724
3748
|
return false;
|
|
3725
3749
|
}
|
|
3726
3750
|
return true;
|
|
@@ -3730,7 +3754,10 @@ class KosDependencyManager {
|
|
|
3730
3754
|
this._usesCache.clear();
|
|
3731
3755
|
}
|
|
3732
3756
|
}
|
|
3733
|
-
const log$
|
|
3757
|
+
const log$12 = KosLog.createLogger({
|
|
3758
|
+
group: LogGroup.core,
|
|
3759
|
+
name: "kos-model-cache"
|
|
3760
|
+
});
|
|
3734
3761
|
class KosModelCache {
|
|
3735
3762
|
constructor(preloadKeys = []) {
|
|
3736
3763
|
this.preloadKeys = preloadKeys;
|
|
@@ -3781,11 +3808,11 @@ class KosModelCache {
|
|
|
3781
3808
|
}
|
|
3782
3809
|
preload(createFn) {
|
|
3783
3810
|
if (this._isPreloaded) {
|
|
3784
|
-
log$
|
|
3811
|
+
log$12.debug("Returning cached preloaded models");
|
|
3785
3812
|
return this._preloaded;
|
|
3786
3813
|
}
|
|
3787
3814
|
this._preloaded = this.preloadKeys.map((key) => {
|
|
3788
|
-
log$
|
|
3815
|
+
log$12.debug(
|
|
3789
3816
|
`Preloading model: ${typeof key === "string" ? key : key.modelType}`
|
|
3790
3817
|
);
|
|
3791
3818
|
return createFn(key);
|
|
@@ -3807,6 +3834,10 @@ const clearModelHookCacheEntry = (modelId) => {
|
|
|
3807
3834
|
cache.delete(modelId);
|
|
3808
3835
|
}
|
|
3809
3836
|
};
|
|
3837
|
+
const log$11 = KosLog.createLogger({
|
|
3838
|
+
group: LogGroup.core,
|
|
3839
|
+
name: "model-error-utils"
|
|
3840
|
+
});
|
|
3810
3841
|
class KosModelError extends Error {
|
|
3811
3842
|
context;
|
|
3812
3843
|
originalCause;
|
|
@@ -3868,10 +3899,10 @@ function enrichError(error, context) {
|
|
|
3868
3899
|
}
|
|
3869
3900
|
function logErrorCollection(errors, summary) {
|
|
3870
3901
|
if (errors.length === 0) return;
|
|
3871
|
-
|
|
3902
|
+
log$11.error(`${summary} - ${errors.length} error(s) occurred:`);
|
|
3872
3903
|
errors.forEach(({ error, context }, index) => {
|
|
3873
3904
|
const enriched = error instanceof KosModelError ? error : enrichError(error, context);
|
|
3874
|
-
|
|
3905
|
+
log$11.error(
|
|
3875
3906
|
` [${index + 1}/${errors.length}] ${enriched.toDetailedString()}`
|
|
3876
3907
|
);
|
|
3877
3908
|
});
|
|
@@ -3887,7 +3918,10 @@ function logModelInstantiationError(error, context) {
|
|
|
3887
3918
|
});
|
|
3888
3919
|
}
|
|
3889
3920
|
const isKosCompanionTypeFactory = (obj) => typeof obj === "function";
|
|
3890
|
-
const log$
|
|
3921
|
+
const log$10 = KosLog.createLogger({
|
|
3922
|
+
group: LogGroup.core,
|
|
3923
|
+
name: "kos-companion-instantiator"
|
|
3924
|
+
});
|
|
3891
3925
|
class KosCompanionInstantiator {
|
|
3892
3926
|
constructor(registry, cache2, createModel) {
|
|
3893
3927
|
this.registry = registry;
|
|
@@ -3909,7 +3943,7 @@ class KosCompanionInstantiator {
|
|
|
3909
3943
|
createCompanionModels(model, options, lifecycle) {
|
|
3910
3944
|
const companionDefs = this.getCompanionDefinitions(model.modelTypeName);
|
|
3911
3945
|
if (lifecycle !== void 0) {
|
|
3912
|
-
log$
|
|
3946
|
+
log$10.debug(
|
|
3913
3947
|
`Creating ${lifecycle} lifecycle companions for ${model.modelTypeName} [${model.modelId}]`
|
|
3914
3948
|
);
|
|
3915
3949
|
}
|
|
@@ -3961,7 +3995,7 @@ class KosCompanionInstantiator {
|
|
|
3961
3995
|
mobx.runInAction(() => {
|
|
3962
3996
|
model.modelData[property] = mixin.modelData;
|
|
3963
3997
|
});
|
|
3964
|
-
log$
|
|
3998
|
+
log$10.debug(
|
|
3965
3999
|
`Created mixin ${registration.type} for ${model.modelTypeName} [${model.modelId}]`
|
|
3966
4000
|
);
|
|
3967
4001
|
});
|
|
@@ -3993,7 +4027,7 @@ class KosCompanionInstantiator {
|
|
|
3993
4027
|
resolveFactoryCompanion(companionDef, model, options, requestedLifecycle) {
|
|
3994
4028
|
const companionType = companionDef.type(model.modelData, options);
|
|
3995
4029
|
if (!companionType) {
|
|
3996
|
-
log$
|
|
4030
|
+
log$10.debug(
|
|
3997
4031
|
`Companion factory returned undefined for ${model.modelTypeName} at ${requestedLifecycle || "INIT"} phase`
|
|
3998
4032
|
);
|
|
3999
4033
|
return null;
|
|
@@ -4052,7 +4086,7 @@ class KosCompanionInstantiator {
|
|
|
4052
4086
|
);
|
|
4053
4087
|
if (companion) {
|
|
4054
4088
|
this.attachCompanionToParent(companion, parentModel);
|
|
4055
|
-
log$
|
|
4089
|
+
log$10.debug(
|
|
4056
4090
|
`Created ${lifecycle || "INIT"} companion ${companionType} for ${parentModel.modelTypeName} [${parentModel.modelId}]`
|
|
4057
4091
|
);
|
|
4058
4092
|
}
|
|
@@ -4068,7 +4102,7 @@ class KosCompanionInstantiator {
|
|
|
4068
4102
|
*/
|
|
4069
4103
|
companionAlreadyExists(companionId, companionType, parentTypeName) {
|
|
4070
4104
|
if (this.cache.hasModel(companionId)) {
|
|
4071
|
-
log$
|
|
4105
|
+
log$10.debug(
|
|
4072
4106
|
`Companion ${companionType} already exists for ${parentTypeName}`
|
|
4073
4107
|
);
|
|
4074
4108
|
return true;
|
|
@@ -4153,6 +4187,10 @@ const TransitionMap = {
|
|
|
4153
4187
|
/* INIT */
|
|
4154
4188
|
]: transitionToInit
|
|
4155
4189
|
};
|
|
4190
|
+
const log$$ = KosLog.createLogger({
|
|
4191
|
+
group: LogGroup.core,
|
|
4192
|
+
name: "promise-utils"
|
|
4193
|
+
});
|
|
4156
4194
|
class ModelError extends Error {
|
|
4157
4195
|
model;
|
|
4158
4196
|
constructor(message, model) {
|
|
@@ -4164,7 +4202,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4164
4202
|
let timeoutId;
|
|
4165
4203
|
const promise = new Promise((_, reject) => {
|
|
4166
4204
|
timeoutId = setTimeout(() => {
|
|
4167
|
-
|
|
4205
|
+
log$$.error(
|
|
4168
4206
|
`Model ${model.modelId} - ${model.modelTypeName} - ${status} timed out after ${ms}ms`
|
|
4169
4207
|
);
|
|
4170
4208
|
reject(
|
|
@@ -4180,6 +4218,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4180
4218
|
};
|
|
4181
4219
|
return { promise, cancel };
|
|
4182
4220
|
};
|
|
4221
|
+
const log$_ = KosLog.createLogger({ group: LogGroup.core, name: "model-utils" });
|
|
4183
4222
|
const createModelDependency = (model, dependency) => {
|
|
4184
4223
|
const _dataModelId = dependency.id || dependency.modelType;
|
|
4185
4224
|
const dataModelId = resolveParameters({
|
|
@@ -4188,7 +4227,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4188
4227
|
modelId: model.modelId
|
|
4189
4228
|
});
|
|
4190
4229
|
const resolutionPolicy = dependency.resolutionPolicy || DependencyResolutionPolicy.CREATE;
|
|
4191
|
-
|
|
4230
|
+
log$_.debug(
|
|
4192
4231
|
`Resolving dependent model ${dependency.modelType} with id ${dataModelId} (policy: ${resolutionPolicy})`
|
|
4193
4232
|
);
|
|
4194
4233
|
const options = Object.keys(dependency?.options || {}).reduce((acc, curr) => {
|
|
@@ -4204,7 +4243,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4204
4243
|
const modelRegistry = modelManager.registry.models[dependency.modelType];
|
|
4205
4244
|
if (!modelRegistry) {
|
|
4206
4245
|
const errorMessage = `No model registered for type ${dependency.modelType}`;
|
|
4207
|
-
|
|
4246
|
+
log$_.error(
|
|
4208
4247
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4209
4248
|
- Dependency Type: ${dependency.modelType}
|
|
4210
4249
|
- Dependency ID: ${dataModelId}
|
|
@@ -4214,7 +4253,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4214
4253
|
- Error: ${errorMessage}`
|
|
4215
4254
|
);
|
|
4216
4255
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4217
|
-
|
|
4256
|
+
log$_.warn(
|
|
4218
4257
|
`Model type not registered (policy: CONTINUE) - Model ${model.modelId} will continue without dependency ${dependency.modelType} [${dataModelId}]`
|
|
4219
4258
|
);
|
|
4220
4259
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4227,7 +4266,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4227
4266
|
if (existingModel) {
|
|
4228
4267
|
if (existingModel.modelTypeName !== dependency.modelType) {
|
|
4229
4268
|
const errorMessage = `Model type mismatch: expected ${dependency.modelType}, found ${existingModel.modelTypeName}`;
|
|
4230
|
-
|
|
4269
|
+
log$_.error(
|
|
4231
4270
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4232
4271
|
- Dependency Type: ${dependency.modelType}
|
|
4233
4272
|
- Dependency ID: ${dataModelId}
|
|
@@ -4238,7 +4277,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4238
4277
|
- Error: ${errorMessage}`
|
|
4239
4278
|
);
|
|
4240
4279
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4241
|
-
|
|
4280
|
+
log$_.warn(
|
|
4242
4281
|
`Model type mismatch (policy: CONTINUE) - Model ${model.modelId} will continue without dependency`
|
|
4243
4282
|
);
|
|
4244
4283
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4247,7 +4286,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4247
4286
|
`Dependency resolution failed - Model ${model.modelId} cannot resolve dependency ${dependency.modelType} [${dataModelId}]: ${errorMessage}`
|
|
4248
4287
|
);
|
|
4249
4288
|
}
|
|
4250
|
-
|
|
4289
|
+
log$_.debug(
|
|
4251
4290
|
`Found existing dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4252
4291
|
);
|
|
4253
4292
|
return {
|
|
@@ -4256,18 +4295,18 @@ const createModelDependency = (model, dependency) => {
|
|
|
4256
4295
|
success: true
|
|
4257
4296
|
};
|
|
4258
4297
|
}
|
|
4259
|
-
|
|
4298
|
+
log$_.debug(
|
|
4260
4299
|
`Model ${dependency.modelType} [${dataModelId}] does not exist. Applying resolution policy: ${resolutionPolicy}`
|
|
4261
4300
|
);
|
|
4262
4301
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4263
|
-
|
|
4302
|
+
log$_.warn(
|
|
4264
4303
|
`Model ${dependency.modelType} [${dataModelId}] not found (policy: CONTINUE) - Model ${model.modelId} will continue without this dependency`
|
|
4265
4304
|
);
|
|
4266
4305
|
return { dependentModel: null, dataModelId, success: false };
|
|
4267
4306
|
}
|
|
4268
4307
|
if (resolutionPolicy === DependencyResolutionPolicy.FAIL) {
|
|
4269
4308
|
const errorMessage = `No ${dependency.modelType} model with id ${dataModelId} exists`;
|
|
4270
|
-
|
|
4309
|
+
log$_.error(
|
|
4271
4310
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4272
4311
|
- Dependency Type: ${dependency.modelType}
|
|
4273
4312
|
- Dependency ID: ${dataModelId}
|
|
@@ -4285,7 +4324,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4285
4324
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
4286
4325
|
if (requiresOptions && !hasOptions) {
|
|
4287
4326
|
const errorMessage = `Model ${dependency.modelType} requires options but none were provided`;
|
|
4288
|
-
|
|
4327
|
+
log$_.error(
|
|
4289
4328
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4290
4329
|
- Dependency Type: ${dependency.modelType}
|
|
4291
4330
|
- Dependency ID: ${dataModelId}
|
|
@@ -4306,13 +4345,13 @@ const createModelDependency = (model, dependency) => {
|
|
|
4306
4345
|
dataModelId,
|
|
4307
4346
|
options
|
|
4308
4347
|
);
|
|
4309
|
-
|
|
4348
|
+
log$_.debug(
|
|
4310
4349
|
`Successfully created dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4311
4350
|
);
|
|
4312
4351
|
return { dependentModel, dataModelId, success: true };
|
|
4313
4352
|
} catch (error) {
|
|
4314
4353
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4315
|
-
|
|
4354
|
+
log$_.error(
|
|
4316
4355
|
`Failed to create dependency for model ${model.modelId}:
|
|
4317
4356
|
- Dependency Type: ${dependency.modelType}
|
|
4318
4357
|
- Dependency ID: ${dataModelId}
|
|
@@ -4328,14 +4367,14 @@ const createModelDependency = (model, dependency) => {
|
|
|
4328
4367
|
const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY) => {
|
|
4329
4368
|
const dependencies = model.modelData?.[DependencyModels] || {};
|
|
4330
4369
|
if (Object.keys(dependencies).length === 0) {
|
|
4331
|
-
|
|
4370
|
+
log$_.debug(`${model.modelId} has no dependencies. Returning`);
|
|
4332
4371
|
return [];
|
|
4333
4372
|
}
|
|
4334
4373
|
const dependenciesByLifecycle = Object.keys(dependencies).filter((key) => dependencies[key].lifecycle === lifecycle).map((key) => {
|
|
4335
4374
|
const dependency = dependencies[key];
|
|
4336
4375
|
const resolutionResult = createModelDependency(model, dependency);
|
|
4337
4376
|
if (!resolutionResult.success || !resolutionResult.dependentModel) {
|
|
4338
|
-
|
|
4377
|
+
log$_.debug(
|
|
4339
4378
|
`Skipping dependency ${dependency.modelType} with id ${resolutionResult.dataModelId} - resolution failed with CONTINUE policy`
|
|
4340
4379
|
);
|
|
4341
4380
|
model.modelData[key] = void 0;
|
|
@@ -4343,12 +4382,12 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4343
4382
|
}
|
|
4344
4383
|
const { dependentModel, dataModelId } = resolutionResult;
|
|
4345
4384
|
model.modelData[key] = dependentModel.data;
|
|
4346
|
-
|
|
4385
|
+
log$_.debug(
|
|
4347
4386
|
`waiting for dependent model ${dependency.modelType} with id ${dataModelId} - waiting for WHENREADY`
|
|
4348
4387
|
);
|
|
4349
4388
|
const readyFn = async (dependentModel2, modelType, id) => {
|
|
4350
4389
|
await dependentModel2.whenReady?.();
|
|
4351
|
-
|
|
4390
|
+
log$_.debug(`dependent model ${modelType} with id ${id} - READY`);
|
|
4352
4391
|
};
|
|
4353
4392
|
const { promise, cancel } = rejectAfterDelay$1(
|
|
4354
4393
|
MODEL_PROMISE_TIMEOUT_MS,
|
|
@@ -4369,7 +4408,7 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4369
4408
|
lifecycle,
|
|
4370
4409
|
operation: "dependency whenReady()"
|
|
4371
4410
|
});
|
|
4372
|
-
|
|
4411
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4373
4412
|
cancel();
|
|
4374
4413
|
throw enrichedError;
|
|
4375
4414
|
}),
|
|
@@ -4379,13 +4418,13 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4379
4418
|
return dependenciesByLifecycle;
|
|
4380
4419
|
};
|
|
4381
4420
|
const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycle) => {
|
|
4382
|
-
|
|
4421
|
+
log$_.debug(`Execute lifecycle with ${models2.length} models`);
|
|
4383
4422
|
if (models2.length === 0) {
|
|
4384
|
-
|
|
4423
|
+
log$_.debug(`${sourceModel.modelId} has no children. Returning`);
|
|
4385
4424
|
return;
|
|
4386
4425
|
}
|
|
4387
4426
|
if (!target) {
|
|
4388
|
-
|
|
4427
|
+
log$_.error(
|
|
4389
4428
|
`${sourceModel.modelId} is not transitioning with a valid target ${target}`
|
|
4390
4429
|
);
|
|
4391
4430
|
return;
|
|
@@ -4396,12 +4435,10 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4396
4435
|
p = TransitionMap[target](model);
|
|
4397
4436
|
} else {
|
|
4398
4437
|
if (!model) {
|
|
4399
|
-
|
|
4438
|
+
log$_.error("model is undefined. This shouldn't happen");
|
|
4400
4439
|
}
|
|
4401
4440
|
if (!TransitionMap[target]) {
|
|
4402
|
-
|
|
4403
|
-
`There is no promise in the Transition Map for ${target}`
|
|
4404
|
-
);
|
|
4441
|
+
log$_.error(`There is no promise in the Transition Map for ${target}`);
|
|
4405
4442
|
}
|
|
4406
4443
|
}
|
|
4407
4444
|
return {
|
|
@@ -4413,11 +4450,11 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4413
4450
|
};
|
|
4414
4451
|
}).filter((modelPromise) => {
|
|
4415
4452
|
if (!modelPromise.promise) {
|
|
4416
|
-
|
|
4453
|
+
log$_.error(`No promise found ${modelPromise.modelId}`);
|
|
4417
4454
|
return false;
|
|
4418
4455
|
}
|
|
4419
4456
|
if (!modelPromise.model) {
|
|
4420
|
-
|
|
4457
|
+
log$_.error(`No model found ${modelPromise.modelId}`);
|
|
4421
4458
|
return false;
|
|
4422
4459
|
}
|
|
4423
4460
|
return true;
|
|
@@ -4446,7 +4483,7 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4446
4483
|
lifecycle: sourceLifecycle,
|
|
4447
4484
|
operation: `transition to ${target}`
|
|
4448
4485
|
});
|
|
4449
|
-
|
|
4486
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4450
4487
|
timeoutCancel();
|
|
4451
4488
|
throw enrichedError;
|
|
4452
4489
|
}),
|
|
@@ -4492,10 +4529,10 @@ const executeDependentModelLifecycle = async (model, lifecycle) => {
|
|
|
4492
4529
|
);
|
|
4493
4530
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
4494
4531
|
if (failed.length) {
|
|
4495
|
-
|
|
4532
|
+
log$_.error(
|
|
4496
4533
|
`There were ${failed.length} failed dependent models on ${lifecycle}`
|
|
4497
4534
|
);
|
|
4498
|
-
|
|
4535
|
+
log$_.error(failed);
|
|
4499
4536
|
}
|
|
4500
4537
|
};
|
|
4501
4538
|
function applyKosModelDevtoolsSupport(model) {
|
|
@@ -4759,7 +4796,10 @@ class KosEffectManager {
|
|
|
4759
4796
|
this.disposers = [];
|
|
4760
4797
|
}
|
|
4761
4798
|
}
|
|
4762
|
-
const log$
|
|
4799
|
+
const log$Z = KosLog.createLogger({
|
|
4800
|
+
group: LogGroup.core,
|
|
4801
|
+
name: "model-active-machine"
|
|
4802
|
+
});
|
|
4763
4803
|
const activeMachine = (model) => {
|
|
4764
4804
|
const machine2 = robot3.createMachine(KosModelState.INACTIVE, {
|
|
4765
4805
|
[KosModelState.FAILED]: robot3.state(
|
|
@@ -4814,11 +4854,14 @@ const activeMachine = (model) => {
|
|
|
4814
4854
|
});
|
|
4815
4855
|
const service2 = robot3.interpret(
|
|
4816
4856
|
machine2,
|
|
4817
|
-
(_service) => log$
|
|
4857
|
+
(_service) => log$Z.debug(_service.machine.current)
|
|
4818
4858
|
);
|
|
4819
4859
|
return { service: service2, machine: machine2 };
|
|
4820
4860
|
};
|
|
4821
|
-
const log$
|
|
4861
|
+
const log$Y = KosLog.createLogger({
|
|
4862
|
+
group: LogGroup.core,
|
|
4863
|
+
name: "model-online-machine"
|
|
4864
|
+
});
|
|
4822
4865
|
const onlineMachine = (model) => {
|
|
4823
4866
|
const machine2 = robot3.createMachine(KosModelState.OFFLINE, {
|
|
4824
4867
|
[KosModelState.ONLINE]: robot3.state(
|
|
@@ -4836,7 +4879,7 @@ const onlineMachine = (model) => {
|
|
|
4836
4879
|
KosModelEvents.GO_ONLINE,
|
|
4837
4880
|
KosModelState.ONLINE,
|
|
4838
4881
|
robot3.action(async () => {
|
|
4839
|
-
log$
|
|
4882
|
+
log$Y.debug(`Going online with model ${model.modelId}`);
|
|
4840
4883
|
await model.online();
|
|
4841
4884
|
model.onlineStatus = KosModelState.ONLINE;
|
|
4842
4885
|
await model.fsm.transitionTo(
|
|
@@ -4849,10 +4892,14 @@ const onlineMachine = (model) => {
|
|
|
4849
4892
|
});
|
|
4850
4893
|
const service2 = robot3.interpret(
|
|
4851
4894
|
machine2,
|
|
4852
|
-
(_service) => log$
|
|
4895
|
+
(_service) => log$Y.debug(_service.machine.current)
|
|
4853
4896
|
);
|
|
4854
4897
|
return { machine: machine2, service: service2 };
|
|
4855
4898
|
};
|
|
4899
|
+
const log$X = KosLog.createLogger({
|
|
4900
|
+
group: LogGroup.core,
|
|
4901
|
+
name: "model-machine"
|
|
4902
|
+
});
|
|
4856
4903
|
const machine = (model) => {
|
|
4857
4904
|
const active = activeMachine(model).service;
|
|
4858
4905
|
const online = onlineMachine(model).service;
|
|
@@ -4887,7 +4934,7 @@ const machine = (model) => {
|
|
|
4887
4934
|
`error`,
|
|
4888
4935
|
KosModelState.FAILED,
|
|
4889
4936
|
robot3.action(() => {
|
|
4890
|
-
|
|
4937
|
+
log$X.error(
|
|
4891
4938
|
`Model ${model.modelId} - ${model.modelTypeName} failed to initialize. Transitioning to FAILED state.`
|
|
4892
4939
|
);
|
|
4893
4940
|
model.status = KosModelState.FAILED;
|
|
@@ -5009,7 +5056,7 @@ const machine = (model) => {
|
|
|
5009
5056
|
`error`,
|
|
5010
5057
|
KosModelState.REATTACHING,
|
|
5011
5058
|
robot3.action((_ctx, event) => {
|
|
5012
|
-
|
|
5059
|
+
log$X.error(
|
|
5013
5060
|
`Model ${model.modelId} - ${model.modelTypeName} failed to reload; its data stays as it was. ${String(
|
|
5014
5061
|
event?.error
|
|
5015
5062
|
)}`
|
|
@@ -5046,11 +5093,14 @@ const machine = (model) => {
|
|
|
5046
5093
|
[KosModelState.FAILED]: robot3.state()
|
|
5047
5094
|
});
|
|
5048
5095
|
};
|
|
5049
|
-
const log$
|
|
5096
|
+
const log$W = KosLog.createLogger({
|
|
5097
|
+
group: LogGroup.core,
|
|
5098
|
+
name: "kos-model-lifecycle"
|
|
5099
|
+
});
|
|
5050
5100
|
const fsm = (model) => {
|
|
5051
5101
|
const service2 = robot3.interpret(
|
|
5052
5102
|
machine(model),
|
|
5053
|
-
(_service) => log$
|
|
5103
|
+
(_service) => log$W.debug(
|
|
5054
5104
|
`state machine for model ${model.modelId}: ${_service.machine.current});`
|
|
5055
5105
|
)
|
|
5056
5106
|
);
|
|
@@ -5652,6 +5702,10 @@ async function processRequestBody(body) {
|
|
|
5652
5702
|
}
|
|
5653
5703
|
throw new Error("Unsupported body type");
|
|
5654
5704
|
}
|
|
5705
|
+
const log$V = KosLog.createLogger({
|
|
5706
|
+
group: LogGroup.transport,
|
|
5707
|
+
name: "kos-message-utils"
|
|
5708
|
+
});
|
|
5655
5709
|
const createStudioMessage = ({
|
|
5656
5710
|
path,
|
|
5657
5711
|
requestId,
|
|
@@ -5865,10 +5919,10 @@ const sendKosMessage = (msg, options) => {
|
|
|
5865
5919
|
);
|
|
5866
5920
|
const socketTransport = KosCore.getInstance().transport.socket;
|
|
5867
5921
|
if (socketTransport) {
|
|
5868
|
-
|
|
5922
|
+
log$V.debug("Sending message", _msg);
|
|
5869
5923
|
socketTransport.socket.send(_msg);
|
|
5870
5924
|
} else {
|
|
5871
|
-
|
|
5925
|
+
log$V.error("socket transport is not initialized");
|
|
5872
5926
|
}
|
|
5873
5927
|
};
|
|
5874
5928
|
const createStudioMessageResponse = ({
|
|
@@ -5903,7 +5957,7 @@ const sendStudioMessageRequest = (msg, options) => {
|
|
|
5903
5957
|
if (socketTransport) {
|
|
5904
5958
|
socketTransport.socket.send(_msg);
|
|
5905
5959
|
} else {
|
|
5906
|
-
|
|
5960
|
+
log$V.error("socket transport is not initialized");
|
|
5907
5961
|
}
|
|
5908
5962
|
};
|
|
5909
5963
|
const sendStudioMessage = (msg, options) => {
|
|
@@ -5916,7 +5970,7 @@ const sendStudioMessage = (msg, options) => {
|
|
|
5916
5970
|
if (socketTransport) {
|
|
5917
5971
|
socketTransport.socket.send(_msg);
|
|
5918
5972
|
} else {
|
|
5919
|
-
|
|
5973
|
+
log$V.error("socket transport is not initialized");
|
|
5920
5974
|
}
|
|
5921
5975
|
};
|
|
5922
5976
|
const createBroadcastMessageResponse = ({
|
|
@@ -5986,7 +6040,7 @@ const sendBroadcastMessage = ({
|
|
|
5986
6040
|
if (socketTransport) {
|
|
5987
6041
|
socketTransport.socket.send(_msg);
|
|
5988
6042
|
} else {
|
|
5989
|
-
|
|
6043
|
+
log$V.error("socket transport is not initialized");
|
|
5990
6044
|
}
|
|
5991
6045
|
};
|
|
5992
6046
|
const sendKosMessageResponse = ({
|
|
@@ -6002,7 +6056,7 @@ const sendKosMessageResponse = ({
|
|
|
6002
6056
|
if (socketTransport) {
|
|
6003
6057
|
socketTransport.socket.send(_msg);
|
|
6004
6058
|
} else {
|
|
6005
|
-
|
|
6059
|
+
log$V.error("socket transport is not initialized");
|
|
6006
6060
|
}
|
|
6007
6061
|
};
|
|
6008
6062
|
const sendKosHttpMessageResponse = ({
|
|
@@ -6018,7 +6072,7 @@ const sendKosHttpMessageResponse = ({
|
|
|
6018
6072
|
if (socketTransport) {
|
|
6019
6073
|
socketTransport.socket.send(_msg);
|
|
6020
6074
|
} else {
|
|
6021
|
-
|
|
6075
|
+
log$V.error("socket transport is not initialized");
|
|
6022
6076
|
}
|
|
6023
6077
|
};
|
|
6024
6078
|
const getMessageBody = (payload, skipParse) => {
|
|
@@ -6050,7 +6104,10 @@ class TransportNotReadyError extends Error {
|
|
|
6050
6104
|
}
|
|
6051
6105
|
}
|
|
6052
6106
|
const isTransportNotReadyError = (error) => !!error && error.code === TRANSPORT_NOT_READY;
|
|
6053
|
-
const log$
|
|
6107
|
+
const log$U = KosLog.createLogger({
|
|
6108
|
+
group: LogGroup.transport,
|
|
6109
|
+
name: "kos-fetch"
|
|
6110
|
+
});
|
|
6054
6111
|
const DEFAULT_WS_TIMEOUT = 3e4;
|
|
6055
6112
|
const WS_TIMEOUT = (() => {
|
|
6056
6113
|
const configured = process.env.KOS_WS_TIMEOUT ? parseInt(process.env.KOS_WS_TIMEOUT) : DEFAULT_WS_TIMEOUT;
|
|
@@ -6115,7 +6172,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6115
6172
|
const requestId = uuid();
|
|
6116
6173
|
const urlObj = new URL(url);
|
|
6117
6174
|
const path = `${urlObj.pathname}${urlObj.search}`;
|
|
6118
|
-
log$
|
|
6175
|
+
log$U.debug(`path: ${path}`);
|
|
6119
6176
|
const budget = resolveTimeoutBudget(options?.timeout);
|
|
6120
6177
|
const messageFactory = fetchMessageFactory(options);
|
|
6121
6178
|
const signal = createRequestSignal(budget, options?.signal);
|
|
@@ -6123,12 +6180,12 @@ const kosFetchWs = async (url, options) => {
|
|
|
6123
6180
|
await transport.whenReady({ signal });
|
|
6124
6181
|
} catch (error) {
|
|
6125
6182
|
if (isTimeoutReason(error)) {
|
|
6126
|
-
log$
|
|
6183
|
+
log$U.error(
|
|
6127
6184
|
`Transport not ready${budget === void 0 ? "" : ` after ${budget}ms`} - request not sent - url: ${url}`
|
|
6128
6185
|
);
|
|
6129
6186
|
throw new TransportNotReadyError({ timeout: budget, url });
|
|
6130
6187
|
}
|
|
6131
|
-
log$
|
|
6188
|
+
log$U.debug(`Request aborted while waiting for transport - url: ${url}`);
|
|
6132
6189
|
throw error;
|
|
6133
6190
|
}
|
|
6134
6191
|
const processedBody = await processRequestBody(options?.body);
|
|
@@ -6157,9 +6214,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6157
6214
|
if (signal.aborted) {
|
|
6158
6215
|
const reason = signal.reason;
|
|
6159
6216
|
if (reason?.name === "TimeoutError") {
|
|
6160
|
-
log$
|
|
6217
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6161
6218
|
} else {
|
|
6162
|
-
log$
|
|
6219
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6163
6220
|
}
|
|
6164
6221
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6165
6222
|
return;
|
|
@@ -6168,9 +6225,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6168
6225
|
if (unsubscribe) unsubscribe();
|
|
6169
6226
|
const reason = signal.reason;
|
|
6170
6227
|
if (reason?.name === "TimeoutError") {
|
|
6171
|
-
log$
|
|
6228
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6172
6229
|
} else {
|
|
6173
|
-
log$
|
|
6230
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6174
6231
|
}
|
|
6175
6232
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6176
6233
|
};
|
|
@@ -6186,7 +6243,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6186
6243
|
try {
|
|
6187
6244
|
bodyData = base64ToArrayBuffer(responseBody);
|
|
6188
6245
|
} catch (e) {
|
|
6189
|
-
log$
|
|
6246
|
+
log$U.error("Failed to decode base64 response", e);
|
|
6190
6247
|
}
|
|
6191
6248
|
}
|
|
6192
6249
|
const response = {
|
|
@@ -6240,7 +6297,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6240
6297
|
});
|
|
6241
6298
|
}
|
|
6242
6299
|
if (parsed.files) {
|
|
6243
|
-
log$
|
|
6300
|
+
log$U.warn(
|
|
6244
6301
|
"File reconstruction in FormData not fully implemented"
|
|
6245
6302
|
);
|
|
6246
6303
|
}
|
|
@@ -6291,7 +6348,10 @@ const resolveBaseUrl = () => {
|
|
|
6291
6348
|
const URL2 = exports.BASE_URL;
|
|
6292
6349
|
return { isMock: MOCK, URL: URL2 };
|
|
6293
6350
|
};
|
|
6294
|
-
const log$
|
|
6351
|
+
const log$T = KosLog.createLogger({
|
|
6352
|
+
group: LogGroup.transport,
|
|
6353
|
+
name: "kos-service-request"
|
|
6354
|
+
});
|
|
6295
6355
|
const ERROR_UNKNOWN = "errUnknown";
|
|
6296
6356
|
const ERROR_TRANSPORT_NOT_READY = "Transport not ready";
|
|
6297
6357
|
const MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
@@ -6317,7 +6377,7 @@ async function clientRequest(endpoint, method, options, params2, body) {
|
|
|
6317
6377
|
)}`
|
|
6318
6378
|
).join("&") : "";
|
|
6319
6379
|
const fullUrl = `${resolveBaseUrl().URL}${url}${query ? `?${query}` : ""}`;
|
|
6320
|
-
log$
|
|
6380
|
+
log$T.debug(`fullUrl: ${fullUrl}`);
|
|
6321
6381
|
const fetchOptions = {
|
|
6322
6382
|
method: String(method).toUpperCase(),
|
|
6323
6383
|
body: null,
|
|
@@ -6351,20 +6411,20 @@ async function executeFetch(fullUrl, fetchOptions) {
|
|
|
6351
6411
|
return [null, payload.data ?? payload, responseContext(response)];
|
|
6352
6412
|
} catch (error) {
|
|
6353
6413
|
if (isTransportNotReadyError(error)) {
|
|
6354
|
-
log$
|
|
6414
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6355
6415
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6356
6416
|
}
|
|
6357
6417
|
if (error instanceof DOMException) {
|
|
6358
6418
|
if (error.name === "TimeoutError") {
|
|
6359
|
-
log$
|
|
6419
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6360
6420
|
return ["Request timed out", null];
|
|
6361
6421
|
}
|
|
6362
6422
|
if (error.name === "AbortError") {
|
|
6363
|
-
log$
|
|
6423
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6364
6424
|
return ["Request aborted", null];
|
|
6365
6425
|
}
|
|
6366
6426
|
}
|
|
6367
|
-
log$
|
|
6427
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6368
6428
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6369
6429
|
}
|
|
6370
6430
|
}
|
|
@@ -6384,38 +6444,38 @@ async function executeFetchWithRetry(fullUrl, fetchOptions, config2) {
|
|
|
6384
6444
|
errorContext
|
|
6385
6445
|
];
|
|
6386
6446
|
if (config2.retryOn && !config2.retryOn(response)) {
|
|
6387
|
-
log$
|
|
6447
|
+
log$T.debug(
|
|
6388
6448
|
`Retry predicate returned false for ${fullUrl} (status ${response.status}), stopping`
|
|
6389
6449
|
);
|
|
6390
6450
|
return lastResult;
|
|
6391
6451
|
}
|
|
6392
6452
|
if (attempt < config2.maxAttempts) {
|
|
6393
6453
|
const delayMs = config2.baseDelayMs * Math.pow(config2.backoffFactor, attempt - 1);
|
|
6394
|
-
log$
|
|
6454
|
+
log$T.warn(
|
|
6395
6455
|
`Request to ${fullUrl} failed (status ${response.status}), retrying in ${delayMs}ms (attempt ${attempt}/${config2.maxAttempts})`
|
|
6396
6456
|
);
|
|
6397
6457
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
6398
6458
|
}
|
|
6399
6459
|
} catch (error) {
|
|
6400
6460
|
if (isTransportNotReadyError(error)) {
|
|
6401
|
-
log$
|
|
6461
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6402
6462
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6403
6463
|
}
|
|
6404
6464
|
if (error instanceof DOMException) {
|
|
6405
6465
|
if (error.name === "TimeoutError") {
|
|
6406
|
-
log$
|
|
6466
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6407
6467
|
return ["Request timed out", null];
|
|
6408
6468
|
}
|
|
6409
6469
|
if (error.name === "AbortError") {
|
|
6410
|
-
log$
|
|
6470
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6411
6471
|
return ["Request aborted", null];
|
|
6412
6472
|
}
|
|
6413
6473
|
}
|
|
6414
|
-
log$
|
|
6474
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6415
6475
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6416
6476
|
}
|
|
6417
6477
|
}
|
|
6418
|
-
log$
|
|
6478
|
+
log$T.error(`All ${config2.maxAttempts} attempts failed for ${fullUrl}`);
|
|
6419
6479
|
return lastResult;
|
|
6420
6480
|
}
|
|
6421
6481
|
async function captureErrorResponseContext(response) {
|
|
@@ -6464,9 +6524,9 @@ const service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
6464
6524
|
default: api$1,
|
|
6465
6525
|
kosServiceRequest
|
|
6466
6526
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
6467
|
-
const log$
|
|
6468
|
-
|
|
6469
|
-
|
|
6527
|
+
const log$S = KosLog.createLogger({
|
|
6528
|
+
group: LogGroup.core,
|
|
6529
|
+
name: "kos-service-request-manager"
|
|
6470
6530
|
});
|
|
6471
6531
|
function shouldExecuteRequest(metadata, model) {
|
|
6472
6532
|
return !metadata.condition || metadata.condition(model);
|
|
@@ -6517,7 +6577,7 @@ function isValueMissing(value) {
|
|
|
6517
6577
|
}
|
|
6518
6578
|
function validateRequiredField(value, fieldName, path, isRequired) {
|
|
6519
6579
|
if (isRequired && isValueMissing(value)) {
|
|
6520
|
-
log$
|
|
6580
|
+
log$S.warn(
|
|
6521
6581
|
`Required field '${fieldName}' is missing in response for ${path}`
|
|
6522
6582
|
);
|
|
6523
6583
|
}
|
|
@@ -6552,7 +6612,7 @@ class ServiceRequestManager {
|
|
|
6552
6612
|
this.handlers.get(lifecycle).push(metadata);
|
|
6553
6613
|
});
|
|
6554
6614
|
if (Object.keys(handlerMetadata).length > 0) {
|
|
6555
|
-
log$
|
|
6615
|
+
log$S.debug(
|
|
6556
6616
|
`Discovered ${Object.keys(handlerMetadata).length} service request handlers for model ${this.model.id}`
|
|
6557
6617
|
);
|
|
6558
6618
|
}
|
|
@@ -6567,7 +6627,7 @@ class ServiceRequestManager {
|
|
|
6567
6627
|
if (!handlers || handlers.length === 0) {
|
|
6568
6628
|
return;
|
|
6569
6629
|
}
|
|
6570
|
-
log$
|
|
6630
|
+
log$S.debug(
|
|
6571
6631
|
`Executing ${handlers.length} service requests for lifecycle ${lifecycle}`
|
|
6572
6632
|
);
|
|
6573
6633
|
await Promise.all(handlers.map((handler) => this.executeHandler(handler)));
|
|
@@ -6602,7 +6662,7 @@ class ServiceRequestManager {
|
|
|
6602
6662
|
*/
|
|
6603
6663
|
shouldProcessRequest(metadata) {
|
|
6604
6664
|
if (!shouldExecuteRequest(metadata, this.model)) {
|
|
6605
|
-
log$
|
|
6665
|
+
log$S.debug(`Skipping request ${metadata.path} - condition returned false`);
|
|
6606
6666
|
return false;
|
|
6607
6667
|
}
|
|
6608
6668
|
return true;
|
|
@@ -6807,7 +6867,7 @@ class ServiceRequestManager {
|
|
|
6807
6867
|
case "json":
|
|
6808
6868
|
return typeof value === "string" ? JSON.parse(value) : value;
|
|
6809
6869
|
default:
|
|
6810
|
-
log$
|
|
6870
|
+
log$S.warn(`Unknown transformer: ${transform}`);
|
|
6811
6871
|
return value;
|
|
6812
6872
|
}
|
|
6813
6873
|
}
|
|
@@ -6818,7 +6878,7 @@ class ServiceRequestManager {
|
|
|
6818
6878
|
if (!metadata.iterateOver) return data;
|
|
6819
6879
|
const array = this.getNestedValue(data, metadata.iterateOver);
|
|
6820
6880
|
if (!Array.isArray(array)) {
|
|
6821
|
-
log$
|
|
6881
|
+
log$S.warn(
|
|
6822
6882
|
`iterateOver path '${metadata.iterateOver}' did not resolve to an array`
|
|
6823
6883
|
);
|
|
6824
6884
|
return [];
|
|
@@ -6861,7 +6921,7 @@ class ServiceRequestManager {
|
|
|
6861
6921
|
case "throw":
|
|
6862
6922
|
throw error;
|
|
6863
6923
|
case "log":
|
|
6864
|
-
log$
|
|
6924
|
+
log$S.error(
|
|
6865
6925
|
`Service request failed for ${metadata.path}:`,
|
|
6866
6926
|
error.message
|
|
6867
6927
|
);
|
|
@@ -6921,6 +6981,10 @@ class ServiceRequestManager {
|
|
|
6921
6981
|
}
|
|
6922
6982
|
}
|
|
6923
6983
|
}
|
|
6984
|
+
KosLog.createLogger({
|
|
6985
|
+
group: LogGroup.core,
|
|
6986
|
+
name: "async-event-bus"
|
|
6987
|
+
});
|
|
6924
6988
|
class AsyncEventIterator {
|
|
6925
6989
|
subscription;
|
|
6926
6990
|
unsubscribe;
|
|
@@ -7370,6 +7434,10 @@ function encodeFutureFrame(future) {
|
|
|
7370
7434
|
JSON.stringify(future)
|
|
7371
7435
|
);
|
|
7372
7436
|
}
|
|
7437
|
+
const log$R = KosLog.createLogger({
|
|
7438
|
+
group: LogGroup.transport,
|
|
7439
|
+
name: "future-simulator"
|
|
7440
|
+
});
|
|
7373
7441
|
const DEFAULT_DURATION_MS = 5e3;
|
|
7374
7442
|
const DEFAULT_INTERVAL_MS = 250;
|
|
7375
7443
|
class KosMockFutureHandle {
|
|
@@ -7480,7 +7548,7 @@ class KosMockFutureSimulator {
|
|
|
7480
7548
|
this.deps.ensureCancelRoutes();
|
|
7481
7549
|
}
|
|
7482
7550
|
if (!options.tracker) {
|
|
7483
|
-
|
|
7551
|
+
log$R.warn(
|
|
7484
7552
|
`KosMock future ${handle.id} has no tracker — models will not link it to their request; prefer futures.fromRequest`
|
|
7485
7553
|
);
|
|
7486
7554
|
}
|
|
@@ -7512,6 +7580,10 @@ class KosMockFutureSimulator {
|
|
|
7512
7580
|
this.futures.clear();
|
|
7513
7581
|
}
|
|
7514
7582
|
}
|
|
7583
|
+
const log$Q = KosLog.createLogger({
|
|
7584
|
+
group: LogGroup.transport,
|
|
7585
|
+
name: "mock-fixtures"
|
|
7586
|
+
});
|
|
7515
7587
|
const DEFAULT_FIXTURE_SERVER_URL = "http://localhost:5676";
|
|
7516
7588
|
const DB_NAME = "kos-mock-fixtures";
|
|
7517
7589
|
const STORE_NAME = "fixtures";
|
|
@@ -7664,7 +7736,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7664
7736
|
);
|
|
7665
7737
|
}
|
|
7666
7738
|
await target.save(name, named);
|
|
7667
|
-
|
|
7739
|
+
log$Q.info(`KosMock fixture "${name}" saved`);
|
|
7668
7740
|
return name;
|
|
7669
7741
|
},
|
|
7670
7742
|
saveRecording(name) {
|
|
@@ -7687,7 +7759,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7687
7759
|
(summary) => summaries.push({ ...summary, source: "server" })
|
|
7688
7760
|
);
|
|
7689
7761
|
} catch {
|
|
7690
|
-
|
|
7762
|
+
log$Q.warn(`KosMock fixture server unreachable at ${serverUrl}`);
|
|
7691
7763
|
}
|
|
7692
7764
|
}
|
|
7693
7765
|
try {
|
|
@@ -7708,7 +7780,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7708
7780
|
},
|
|
7709
7781
|
async import() {
|
|
7710
7782
|
if (typeof document === "undefined") {
|
|
7711
|
-
|
|
7783
|
+
log$Q.warn(`KosMock fixture import requires a browser environment`);
|
|
7712
7784
|
return void 0;
|
|
7713
7785
|
}
|
|
7714
7786
|
return new Promise((resolve) => {
|
|
@@ -7728,7 +7800,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7728
7800
|
});
|
|
7729
7801
|
resolve(name);
|
|
7730
7802
|
} catch (error) {
|
|
7731
|
-
|
|
7803
|
+
log$Q.error(`KosMock fixture import failed`, error?.message);
|
|
7732
7804
|
resolve(void 0);
|
|
7733
7805
|
}
|
|
7734
7806
|
};
|
|
@@ -7803,6 +7875,10 @@ function splitUrl(url) {
|
|
|
7803
7875
|
function methodMatches(routeMethod, requestMethod) {
|
|
7804
7876
|
return routeMethod === "*" || routeMethod.toUpperCase() === requestMethod.toUpperCase();
|
|
7805
7877
|
}
|
|
7878
|
+
const log$P = KosLog.createLogger({
|
|
7879
|
+
group: LogGroup.transport,
|
|
7880
|
+
name: "mock-playback"
|
|
7881
|
+
});
|
|
7806
7882
|
const rewriteTrackers = (raw, trackerMap) => {
|
|
7807
7883
|
let out = raw;
|
|
7808
7884
|
trackerMap.forEach((liveTracker, capturedTracker) => {
|
|
@@ -7964,7 +8040,7 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7964
8040
|
if ((options.pushes ?? "scheduled") === "scheduled") {
|
|
7965
8041
|
startPushes();
|
|
7966
8042
|
}
|
|
7967
|
-
|
|
8043
|
+
log$P.info(
|
|
7968
8044
|
`KosMock fixture${name ? ` "${name}"` : ""} loaded: ${groups.size} routes, ${fixture.pushes.length} pushes (${fixture.pushes.length - unanchored.length} anchored), consume: ${consume}`
|
|
7969
8045
|
);
|
|
7970
8046
|
return {
|
|
@@ -7978,6 +8054,10 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7978
8054
|
}
|
|
7979
8055
|
};
|
|
7980
8056
|
}
|
|
8057
|
+
const log$O = KosLog.createLogger({
|
|
8058
|
+
group: LogGroup.transport,
|
|
8059
|
+
name: "mock-recorder"
|
|
8060
|
+
});
|
|
7981
8061
|
class KosMockRecorder {
|
|
7982
8062
|
recording = false;
|
|
7983
8063
|
name;
|
|
@@ -7999,14 +8079,14 @@ class KosMockRecorder {
|
|
|
7999
8079
|
this.exchanges = [];
|
|
8000
8080
|
this.pushes = [];
|
|
8001
8081
|
this.sends = [];
|
|
8002
|
-
|
|
8082
|
+
log$O.info(
|
|
8003
8083
|
`KosMock recorder started${options.name ? ` (${options.name})` : ""}`
|
|
8004
8084
|
);
|
|
8005
8085
|
}
|
|
8006
8086
|
stop() {
|
|
8007
8087
|
const fixture = this.toFixture();
|
|
8008
8088
|
this.recording = false;
|
|
8009
|
-
|
|
8089
|
+
log$O.info(
|
|
8010
8090
|
`KosMock recorder stopped: ${fixture.exchanges.length} exchanges, ${fixture.pushes.length} pushes, ${fixture.sends?.length ?? 0} sends`
|
|
8011
8091
|
);
|
|
8012
8092
|
return fixture;
|
|
@@ -8023,7 +8103,7 @@ class KosMockRecorder {
|
|
|
8023
8103
|
}
|
|
8024
8104
|
download(filename) {
|
|
8025
8105
|
if (typeof document === "undefined") {
|
|
8026
|
-
|
|
8106
|
+
log$O.warn(`KosMock recorder download requires a browser environment`);
|
|
8027
8107
|
return;
|
|
8028
8108
|
}
|
|
8029
8109
|
const fixture = this.toFixture();
|
|
@@ -8138,6 +8218,10 @@ class KosMockRecorder {
|
|
|
8138
8218
|
}
|
|
8139
8219
|
}
|
|
8140
8220
|
}
|
|
8221
|
+
const log$N = KosLog.createLogger({
|
|
8222
|
+
group: LogGroup.transport,
|
|
8223
|
+
name: "mock-setups"
|
|
8224
|
+
});
|
|
8141
8225
|
const dynamicImport = (url) => import(
|
|
8142
8226
|
/* @vite-ignore */
|
|
8143
8227
|
/* webpackIgnore: true */
|
|
@@ -8170,7 +8254,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8170
8254
|
try {
|
|
8171
8255
|
entry.teardown?.();
|
|
8172
8256
|
} catch (error) {
|
|
8173
|
-
|
|
8257
|
+
log$N.error(`KosMock setup "${name}" teardown threw`, error?.message);
|
|
8174
8258
|
}
|
|
8175
8259
|
return true;
|
|
8176
8260
|
};
|
|
@@ -8197,7 +8281,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8197
8281
|
handle,
|
|
8198
8282
|
teardown: typeof result === "function" ? result : void 0
|
|
8199
8283
|
});
|
|
8200
|
-
|
|
8284
|
+
log$N.info(`KosMock setup "${name}" installed from ${url}`);
|
|
8201
8285
|
return handle;
|
|
8202
8286
|
},
|
|
8203
8287
|
async list() {
|
|
@@ -8220,6 +8304,10 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8220
8304
|
};
|
|
8221
8305
|
return store;
|
|
8222
8306
|
}
|
|
8307
|
+
const log$M = KosLog.createLogger({
|
|
8308
|
+
group: LogGroup.transport,
|
|
8309
|
+
name: "mock-config"
|
|
8310
|
+
});
|
|
8223
8311
|
const asWireValue = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
8224
8312
|
const configTopic = (beanId) => `/kos/config/${beanId}`;
|
|
8225
8313
|
const changeEnvelope = (props, previousValues = {}) => {
|
|
@@ -8287,7 +8375,7 @@ function createConfigFacade(registry) {
|
|
|
8287
8375
|
return void 0;
|
|
8288
8376
|
}
|
|
8289
8377
|
if (injectedKeys.length < keys.length) {
|
|
8290
|
-
|
|
8378
|
+
log$M.warn(
|
|
8291
8379
|
`KosMock config.inject ${beanId}: mixed write passes through; injected props will be rejected by the backend: ${injectedKeys.join(
|
|
8292
8380
|
", "
|
|
8293
8381
|
)}`
|
|
@@ -8322,6 +8410,10 @@ function createConfigFacade(registry) {
|
|
|
8322
8410
|
};
|
|
8323
8411
|
return { update, inject };
|
|
8324
8412
|
}
|
|
8413
|
+
const log$L = KosLog.createLogger({
|
|
8414
|
+
group: LogGroup.transport,
|
|
8415
|
+
name: "mock-registry"
|
|
8416
|
+
});
|
|
8325
8417
|
const PENDING_REQUEST_CAP = 500;
|
|
8326
8418
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8327
8419
|
const asHandler = (handler) => typeof handler === "function" ? handler : () => handler;
|
|
@@ -8427,7 +8519,7 @@ class KosMockRegistry {
|
|
|
8427
8519
|
changed = true;
|
|
8428
8520
|
}
|
|
8429
8521
|
} catch (error) {
|
|
8430
|
-
|
|
8522
|
+
log$L.error(
|
|
8431
8523
|
`KosMock transformer for ${transformer.method} ${transformer.pattern} threw`,
|
|
8432
8524
|
error?.message
|
|
8433
8525
|
);
|
|
@@ -8543,7 +8635,7 @@ class KosMockRegistry {
|
|
|
8543
8635
|
try {
|
|
8544
8636
|
notify();
|
|
8545
8637
|
} catch (error) {
|
|
8546
|
-
|
|
8638
|
+
log$L.error(`KosMock observer threw`, error?.message);
|
|
8547
8639
|
}
|
|
8548
8640
|
}
|
|
8549
8641
|
loadFixture(fixture, options) {
|
|
@@ -8566,13 +8658,13 @@ class KosMockRegistry {
|
|
|
8566
8658
|
enable() {
|
|
8567
8659
|
if (!this.enabledFlag) {
|
|
8568
8660
|
this.enabledFlag = true;
|
|
8569
|
-
|
|
8661
|
+
log$L.info(`KosMock enabled`);
|
|
8570
8662
|
}
|
|
8571
8663
|
}
|
|
8572
8664
|
disable() {
|
|
8573
8665
|
if (this.enabledFlag) {
|
|
8574
8666
|
this.enabledFlag = false;
|
|
8575
|
-
|
|
8667
|
+
log$L.info(`KosMock disabled`);
|
|
8576
8668
|
}
|
|
8577
8669
|
}
|
|
8578
8670
|
get standalone() {
|
|
@@ -8648,7 +8740,7 @@ class KosMockRegistry {
|
|
|
8648
8740
|
}
|
|
8649
8741
|
publishFrame(rawFrame) {
|
|
8650
8742
|
if (this.injectors.size === 0) {
|
|
8651
|
-
|
|
8743
|
+
log$L.warn(
|
|
8652
8744
|
`KosMock.publishFrame: no active transport to deliver the frame`
|
|
8653
8745
|
);
|
|
8654
8746
|
return;
|
|
@@ -8691,7 +8783,7 @@ class KosMockRegistry {
|
|
|
8691
8783
|
if (teardown) {
|
|
8692
8784
|
this.scenarioTeardowns.set(id, teardown);
|
|
8693
8785
|
}
|
|
8694
|
-
|
|
8786
|
+
log$L.info(`KosMock scenario "${scenario.name}" installed`);
|
|
8695
8787
|
const remove = () => {
|
|
8696
8788
|
const dispose = this.scenarioTeardowns.get(id);
|
|
8697
8789
|
this.scenarioTeardowns.delete(id);
|
|
@@ -8795,7 +8887,7 @@ class KosMockRegistry {
|
|
|
8795
8887
|
return true;
|
|
8796
8888
|
}
|
|
8797
8889
|
if (policy === "warn") {
|
|
8798
|
-
|
|
8890
|
+
log$L.warn(`KosMock: unmatched ${frame.method} ${path}`);
|
|
8799
8891
|
}
|
|
8800
8892
|
return false;
|
|
8801
8893
|
}
|
|
@@ -8831,7 +8923,7 @@ class KosMockRegistry {
|
|
|
8831
8923
|
try {
|
|
8832
8924
|
accepted = route.when(scopedRequest);
|
|
8833
8925
|
} catch (error) {
|
|
8834
|
-
|
|
8926
|
+
log$L.error(
|
|
8835
8927
|
`KosMock \`when\` guard for ${route.method} ${route.pattern} threw`,
|
|
8836
8928
|
error?.message
|
|
8837
8929
|
);
|
|
@@ -8844,7 +8936,7 @@ class KosMockRegistry {
|
|
|
8844
8936
|
try {
|
|
8845
8937
|
response = await route.handler(scopedRequest, this.context());
|
|
8846
8938
|
} catch (error) {
|
|
8847
|
-
|
|
8939
|
+
log$L.error(
|
|
8848
8940
|
`KosMock handler for ${route.method} ${route.pattern} threw`,
|
|
8849
8941
|
error?.message
|
|
8850
8942
|
);
|
|
@@ -8877,7 +8969,7 @@ class KosMockRegistry {
|
|
|
8877
8969
|
return;
|
|
8878
8970
|
}
|
|
8879
8971
|
if (policy === "warn") {
|
|
8880
|
-
|
|
8972
|
+
log$L.warn(
|
|
8881
8973
|
`KosMock: all routes declined ${request.method} ${request.path}`
|
|
8882
8974
|
);
|
|
8883
8975
|
}
|
|
@@ -8992,7 +9084,7 @@ if (typeof window !== "undefined") {
|
|
|
8992
9084
|
if (fixture) {
|
|
8993
9085
|
bootLoads.push(
|
|
8994
9086
|
KosMock.fixtures.play(fixture).then(() => void 0).catch(
|
|
8995
|
-
(error) =>
|
|
9087
|
+
(error) => log$L.error(
|
|
8996
9088
|
`KosMock: boot fixture "${fixture}" failed to load`,
|
|
8997
9089
|
error?.message
|
|
8998
9090
|
)
|
|
@@ -9003,7 +9095,7 @@ if (typeof window !== "undefined") {
|
|
|
9003
9095
|
for (const name of setups.split(",").filter(Boolean)) {
|
|
9004
9096
|
bootLoads.push(
|
|
9005
9097
|
KosMock.setups.load(name).then(() => void 0).catch(
|
|
9006
|
-
(error) =>
|
|
9098
|
+
(error) => log$L.error(
|
|
9007
9099
|
`KosMock: boot setup "${name}" failed to load`,
|
|
9008
9100
|
error?.message
|
|
9009
9101
|
)
|
|
@@ -9113,6 +9205,14 @@ class WebSocketBridgeTransport extends WebSocket {
|
|
|
9113
9205
|
super(address);
|
|
9114
9206
|
}
|
|
9115
9207
|
}
|
|
9208
|
+
const log$K = KosLog.createLogger({
|
|
9209
|
+
group: LogGroup.transport,
|
|
9210
|
+
name: "base-message-transport"
|
|
9211
|
+
});
|
|
9212
|
+
const messageLog = KosLog.createLogger({
|
|
9213
|
+
group: LogGroup.transport,
|
|
9214
|
+
name: MESSAGE_LOGGER_NAME
|
|
9215
|
+
});
|
|
9116
9216
|
var WebSocketEvents = /* @__PURE__ */ ((WebSocketEvents2) => {
|
|
9117
9217
|
WebSocketEvents2["CONNECTED"] = `websocket.connected`;
|
|
9118
9218
|
WebSocketEvents2["DISCONNECTED"] = `websocket.disconnected`;
|
|
@@ -9209,9 +9309,9 @@ class BaseTransport {
|
|
|
9209
9309
|
}
|
|
9210
9310
|
onMessage(event) {
|
|
9211
9311
|
try {
|
|
9212
|
-
|
|
9312
|
+
log$K.debug("webSocketTransport: onMessage received");
|
|
9213
9313
|
const { headers, body } = this.processMessageEvent(event);
|
|
9214
|
-
|
|
9314
|
+
messageLog.debug("received", event.data);
|
|
9215
9315
|
const subscriptionTopic = headers["subscription"] || headers[this.RESPONSE_ID_HEADER] || headers["topic"] || headers["type"];
|
|
9216
9316
|
if (subscriptionTopic) {
|
|
9217
9317
|
let msgBody = body;
|
|
@@ -9227,11 +9327,11 @@ class BaseTransport {
|
|
|
9227
9327
|
publish(subscriptionTopic, msgBody, msgHeaders);
|
|
9228
9328
|
}
|
|
9229
9329
|
} catch (ex) {
|
|
9230
|
-
|
|
9330
|
+
log$K.error(`onMessage exception`, ex.message, ex.stack);
|
|
9231
9331
|
}
|
|
9232
9332
|
}
|
|
9233
9333
|
onOpen(event) {
|
|
9234
|
-
|
|
9334
|
+
log$K.info(`websocket connection opened`);
|
|
9235
9335
|
this.socket = event.currentTarget;
|
|
9236
9336
|
mobx.runInAction(() => {
|
|
9237
9337
|
this.connectionEstablished = true;
|
|
@@ -9241,11 +9341,9 @@ alias:${this.alias}
|
|
|
9241
9341
|
|
|
9242
9342
|
`);
|
|
9243
9343
|
}
|
|
9244
|
-
|
|
9245
|
-
`sending ${this.offlineMessages.length} offline FOS messages`
|
|
9246
|
-
);
|
|
9344
|
+
log$K.debug(`sending ${this.offlineMessages.length} offline FOS messages`);
|
|
9247
9345
|
this.offlineMessages.forEach((msg) => {
|
|
9248
|
-
|
|
9346
|
+
log$K.debug(`sending offline message ${msg.msg}`);
|
|
9249
9347
|
this.socket?.send(msg.msg);
|
|
9250
9348
|
});
|
|
9251
9349
|
this.offlineMessages = [];
|
|
@@ -9254,7 +9352,7 @@ alias:${this.alias}
|
|
|
9254
9352
|
}
|
|
9255
9353
|
onClose(event) {
|
|
9256
9354
|
const { code, reason, wasClean } = event;
|
|
9257
|
-
|
|
9355
|
+
log$K.warn(
|
|
9258
9356
|
`WebSocket closed: code=${code}, reason=${reason || "none"}, wasClean=${wasClean}`
|
|
9259
9357
|
);
|
|
9260
9358
|
mobx.runInAction(() => {
|
|
@@ -9264,13 +9362,13 @@ alias:${this.alias}
|
|
|
9264
9362
|
if (this.shouldAttemptReconnection(code)) {
|
|
9265
9363
|
this.onConnectionLost?.();
|
|
9266
9364
|
} else {
|
|
9267
|
-
|
|
9365
|
+
log$K.info(
|
|
9268
9366
|
`Not reconnecting due to close code ${code} (intentional close or configuration error)`
|
|
9269
9367
|
);
|
|
9270
9368
|
}
|
|
9271
9369
|
}
|
|
9272
9370
|
onError(ev) {
|
|
9273
|
-
|
|
9371
|
+
log$K.error(`websocket error: `, ev);
|
|
9274
9372
|
publish("websocket.error", { event: ev });
|
|
9275
9373
|
}
|
|
9276
9374
|
/**
|
|
@@ -9315,7 +9413,7 @@ alias:${this.alias}
|
|
|
9315
9413
|
}
|
|
9316
9414
|
}
|
|
9317
9415
|
send(data) {
|
|
9318
|
-
|
|
9416
|
+
messageLog.debug("sent", data);
|
|
9319
9417
|
if (window.kosLogEvents) {
|
|
9320
9418
|
const { headers, body } = processKosMessage(String(data));
|
|
9321
9419
|
publish(KosWsEvents.SEND, { headers, body });
|
|
@@ -9323,6 +9421,10 @@ alias:${this.alias}
|
|
|
9323
9421
|
this.oldSend.call(this.socket, data);
|
|
9324
9422
|
}
|
|
9325
9423
|
}
|
|
9424
|
+
const log$J = KosLog.createLogger({
|
|
9425
|
+
group: LogGroup.transport,
|
|
9426
|
+
name: "bridge-transport"
|
|
9427
|
+
});
|
|
9326
9428
|
class BridgeTransport {
|
|
9327
9429
|
addEventListener;
|
|
9328
9430
|
dispatchEvent;
|
|
@@ -9334,7 +9436,7 @@ class BridgeTransport {
|
|
|
9334
9436
|
messageQueue = [];
|
|
9335
9437
|
isSending = false;
|
|
9336
9438
|
constructor(addr) {
|
|
9337
|
-
log$
|
|
9439
|
+
log$J.debug(`called Bridge Transport with addr ${addr}`);
|
|
9338
9440
|
const that = this;
|
|
9339
9441
|
globalThis.kosWindowWebsocketRecv = (msg) => {
|
|
9340
9442
|
if (that.onmessage) {
|
|
@@ -9342,19 +9444,19 @@ class BridgeTransport {
|
|
|
9342
9444
|
that.onmessage(data);
|
|
9343
9445
|
}
|
|
9344
9446
|
};
|
|
9345
|
-
log$
|
|
9447
|
+
log$J.debug("Opening bridge transport");
|
|
9346
9448
|
globalThis.kosWindowWebsocketOpen();
|
|
9347
|
-
log$
|
|
9449
|
+
log$J.debug("Opened bridge transport");
|
|
9348
9450
|
this._onclose = null;
|
|
9349
9451
|
this._onerror = null;
|
|
9350
9452
|
this._onmessage = null;
|
|
9351
9453
|
this._onopen = null;
|
|
9352
|
-
this.addEventListener = () => log$
|
|
9353
|
-
this.dispatchEvent = () => log$
|
|
9354
|
-
this.removeEventListener = () => log$
|
|
9454
|
+
this.addEventListener = () => log$J.debug("not implemented");
|
|
9455
|
+
this.dispatchEvent = () => log$J.debug("not implemented");
|
|
9456
|
+
this.removeEventListener = () => log$J.debug("not implemented");
|
|
9355
9457
|
}
|
|
9356
9458
|
close() {
|
|
9357
|
-
log$
|
|
9459
|
+
log$J.debug("closing");
|
|
9358
9460
|
}
|
|
9359
9461
|
sendNextMessage() {
|
|
9360
9462
|
if (this.messageQueue.length > 0) {
|
|
@@ -9441,6 +9543,10 @@ class KosTransport extends BaseTransport {
|
|
|
9441
9543
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9442
9544
|
}
|
|
9443
9545
|
}
|
|
9546
|
+
const log$I = KosLog.createLogger({
|
|
9547
|
+
group: LogGroup.transport,
|
|
9548
|
+
name: "standalone-mock-socket"
|
|
9549
|
+
});
|
|
9444
9550
|
const LOGGED_IN_FRAME = `topic:/studioServer/auth/LOGGED_IN
|
|
9445
9551
|
type:kos.broker.topic
|
|
9446
9552
|
|
|
@@ -9451,7 +9557,7 @@ class StandaloneMockSocket {
|
|
|
9451
9557
|
onmessage = null;
|
|
9452
9558
|
onopen = null;
|
|
9453
9559
|
constructor(url) {
|
|
9454
|
-
|
|
9560
|
+
log$I.info(`KosMock standalone socket replacing ${url}`);
|
|
9455
9561
|
setTimeout(async () => {
|
|
9456
9562
|
await kosMockRegistry.bootGate;
|
|
9457
9563
|
this.onopen?.({ currentTarget: this });
|
|
@@ -9462,7 +9568,7 @@ class StandaloneMockSocket {
|
|
|
9462
9568
|
}
|
|
9463
9569
|
send(data) {
|
|
9464
9570
|
if (peekFrameType(data) === KOS_HTTP_REQUEST_TYPE) {
|
|
9465
|
-
|
|
9571
|
+
log$I.warn(
|
|
9466
9572
|
`KosMock standalone: unmatched request reached the loopback socket and will hang — add a route or use onUnmatched: "respond404"`,
|
|
9467
9573
|
String(data).split("\n", 2).join(" ")
|
|
9468
9574
|
);
|
|
@@ -9500,6 +9606,10 @@ class MockMessageTransport extends BaseTransport {
|
|
|
9500
9606
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9501
9607
|
}
|
|
9502
9608
|
}
|
|
9609
|
+
const log$H = KosLog.createLogger({
|
|
9610
|
+
group: LogGroup.transport,
|
|
9611
|
+
name: "transport-factory"
|
|
9612
|
+
});
|
|
9503
9613
|
window.kosLogEvents = process.env.KOS_LOG_WS === "true";
|
|
9504
9614
|
class TransportFactory {
|
|
9505
9615
|
static build({
|
|
@@ -9511,13 +9621,13 @@ class TransportFactory {
|
|
|
9511
9621
|
onConnectionEstablished,
|
|
9512
9622
|
onConnectionLost
|
|
9513
9623
|
}) {
|
|
9514
|
-
|
|
9515
|
-
|
|
9624
|
+
log$H.debug(`initializing websocket connection`);
|
|
9625
|
+
log$H.warn(
|
|
9516
9626
|
`kosWindowWebsocketOpen: ${globalThis.kosWindowWebsocketOpen ? `true` : `false`}`
|
|
9517
9627
|
);
|
|
9518
|
-
|
|
9628
|
+
log$H.warn(`fos: ${fos ? `true` : `false`}`);
|
|
9519
9629
|
if (KosMock.standalone && !fos) {
|
|
9520
|
-
|
|
9630
|
+
log$H.warn(`Using KosMock standalone transport`);
|
|
9521
9631
|
return new MockMessageTransport({
|
|
9522
9632
|
host,
|
|
9523
9633
|
port,
|
|
@@ -9528,7 +9638,7 @@ class TransportFactory {
|
|
|
9528
9638
|
});
|
|
9529
9639
|
}
|
|
9530
9640
|
if (globalThis.kosWindowWebsocketOpen && !fos) {
|
|
9531
|
-
|
|
9641
|
+
log$H.warn(`Using bridged message transport`);
|
|
9532
9642
|
const transport = new BridgeMessageTransport({
|
|
9533
9643
|
host,
|
|
9534
9644
|
port,
|
|
@@ -9569,7 +9679,10 @@ if (params$1.fos) {
|
|
|
9569
9679
|
const fosPort = process.env.KOS_FOS_PORT;
|
|
9570
9680
|
window.kosUseFos = !!(window.kosUseFos || process.env.KOS_USE_FOS === "true");
|
|
9571
9681
|
window.kosFosPort = fosPort ? parseInt(fosPort) : 0;
|
|
9572
|
-
const log$
|
|
9682
|
+
const log$G = KosLog.createLogger({
|
|
9683
|
+
group: LogGroup.transport,
|
|
9684
|
+
name: "web-socket-transport"
|
|
9685
|
+
});
|
|
9573
9686
|
var KosWSTransportStatus = /* @__PURE__ */ ((KosWSTransportStatus2) => {
|
|
9574
9687
|
KosWSTransportStatus2["NOT_INITIALIZED"] = "not_initialized";
|
|
9575
9688
|
KosWSTransportStatus2["INITIALIZED"] = "initialized";
|
|
@@ -9626,7 +9739,7 @@ class WebSocketTransport {
|
|
|
9626
9739
|
() => this.connectionEstablished,
|
|
9627
9740
|
(connectionEstablished) => {
|
|
9628
9741
|
if (connectionEstablished) {
|
|
9629
|
-
log$
|
|
9742
|
+
log$G.warn("Connection Established");
|
|
9630
9743
|
this.reconnectAttempts = 0;
|
|
9631
9744
|
publish(WebSocketEvents.CONNECTED, {
|
|
9632
9745
|
reconnect: initialized
|
|
@@ -9658,7 +9771,7 @@ class WebSocketTransport {
|
|
|
9658
9771
|
return false;
|
|
9659
9772
|
}
|
|
9660
9773
|
init() {
|
|
9661
|
-
|
|
9774
|
+
log$G.warn(`Initializing WebSocketTransport on ${this.host}:${this.port}`);
|
|
9662
9775
|
if (this.useFosTransport) {
|
|
9663
9776
|
this.fosSocket = TransportFactory.build({
|
|
9664
9777
|
host: this.host,
|
|
@@ -9673,7 +9786,7 @@ class WebSocketTransport {
|
|
|
9673
9786
|
protocol: this.protocol,
|
|
9674
9787
|
alias: this.alias,
|
|
9675
9788
|
onConnectionLost: () => {
|
|
9676
|
-
log$
|
|
9789
|
+
log$G.error(`Connection Lost`);
|
|
9677
9790
|
this.scheduleReconnect();
|
|
9678
9791
|
}
|
|
9679
9792
|
});
|
|
@@ -9693,7 +9806,7 @@ class WebSocketTransport {
|
|
|
9693
9806
|
*/
|
|
9694
9807
|
scheduleReconnect() {
|
|
9695
9808
|
if (this.reconnectAttempts >= WebSocketTransport.MAX_RECONNECT_ATTEMPTS) {
|
|
9696
|
-
|
|
9809
|
+
log$G.error(
|
|
9697
9810
|
`Max reconnection attempts (${WebSocketTransport.MAX_RECONNECT_ATTEMPTS}) reached. Giving up.`
|
|
9698
9811
|
);
|
|
9699
9812
|
publish(WebSocketEvents.MAX_RETRIES_EXCEEDED, {
|
|
@@ -9702,7 +9815,7 @@ class WebSocketTransport {
|
|
|
9702
9815
|
return;
|
|
9703
9816
|
}
|
|
9704
9817
|
const delay2 = this.calculateBackoffDelay();
|
|
9705
|
-
|
|
9818
|
+
log$G.debug(
|
|
9706
9819
|
`Reconnecting in ${delay2}ms (attempt ${this.reconnectAttempts + 1}/${WebSocketTransport.MAX_RECONNECT_ATTEMPTS})`
|
|
9707
9820
|
);
|
|
9708
9821
|
setTimeout(() => {
|
|
@@ -9719,7 +9832,7 @@ class WebSocketTransport {
|
|
|
9719
9832
|
return Math.floor(exponentialDelay + jitter);
|
|
9720
9833
|
}
|
|
9721
9834
|
_sendSubscriptionMessage(topic, type, fos = false, bridge = false, connectionId, explicitDestination = false) {
|
|
9722
|
-
log$
|
|
9835
|
+
log$G.debug(`${type} to topic ${topic}`);
|
|
9723
9836
|
let connId;
|
|
9724
9837
|
if (explicitDestination) {
|
|
9725
9838
|
connId = connectionId;
|
|
@@ -9728,7 +9841,7 @@ class WebSocketTransport {
|
|
|
9728
9841
|
const connectionParam = params2?.connId;
|
|
9729
9842
|
connId = connectionId ?? connectionParam ?? window?.kosBridge?.("connId");
|
|
9730
9843
|
}
|
|
9731
|
-
log$
|
|
9844
|
+
log$G.debug(`subscribing with connId ${connId}`);
|
|
9732
9845
|
const dstAddr = connId ? `dst-addr:${connId}
|
|
9733
9846
|
` : "";
|
|
9734
9847
|
const msg = fos ? `subscribe:${topic}` : bridge ? `type:fos.broker
|
|
@@ -9742,7 +9855,7 @@ ${dstAddr}topics:${topic}
|
|
|
9742
9855
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9743
9856
|
socket?.socket?.send(msg);
|
|
9744
9857
|
} else {
|
|
9745
|
-
log$
|
|
9858
|
+
log$G.debug(`no connection adding to offline messages`);
|
|
9746
9859
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9747
9860
|
socket?.addOfflineMessage(msg);
|
|
9748
9861
|
}
|
|
@@ -9756,7 +9869,7 @@ ${dstAddr}topics:${topic}
|
|
|
9756
9869
|
explicitDestination
|
|
9757
9870
|
}) {
|
|
9758
9871
|
const { unsubscribe, count } = subscribe(topic, callback);
|
|
9759
|
-
log$
|
|
9872
|
+
log$G.debug(`Topic ${topic} currently has ${count} subscribers`);
|
|
9760
9873
|
this._sendSubscriptionMessage(
|
|
9761
9874
|
topic,
|
|
9762
9875
|
"subscribe",
|
|
@@ -9767,7 +9880,7 @@ ${dstAddr}topics:${topic}
|
|
|
9767
9880
|
);
|
|
9768
9881
|
return () => {
|
|
9769
9882
|
const { count: count2 } = unsubscribe();
|
|
9770
|
-
log$
|
|
9883
|
+
log$G.debug(`Topic ${topic} currently has ${count2} subscribers`);
|
|
9771
9884
|
if (count2 === 0) {
|
|
9772
9885
|
this._sendSubscriptionMessage(
|
|
9773
9886
|
topic,
|
|
@@ -9807,7 +9920,7 @@ ${dstAddr}topics:${topic}
|
|
|
9807
9920
|
}
|
|
9808
9921
|
dropConnection() {
|
|
9809
9922
|
if (!this.connectionEstablished) {
|
|
9810
|
-
log$
|
|
9923
|
+
log$G.debug("dropConnection ignored: the connection is already closed");
|
|
9811
9924
|
return;
|
|
9812
9925
|
}
|
|
9813
9926
|
this.socket?.socket.close(1e3);
|
|
@@ -10593,21 +10706,17 @@ class ServiceResponseStore {
|
|
|
10593
10706
|
class KosModelComponentFactory {
|
|
10594
10707
|
static createAll(model) {
|
|
10595
10708
|
const { modelId, modelTypeName, modelData } = model;
|
|
10596
|
-
const log3 = KosLoggerFactory.create({
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
const fsm2 = new KosFSMManager(model, createTaggedLogger(log3, "fsm"));
|
|
10601
|
-
const offlineQueue = new KosOfflineQueue(
|
|
10602
|
-
createTaggedLogger(log3, "offline-queue")
|
|
10603
|
-
);
|
|
10709
|
+
const log3 = KosLoggerFactory.create({ modelTypeName });
|
|
10710
|
+
const tagged = (tag) => createTaggedLogger(log3, `${modelId}:${tag}`);
|
|
10711
|
+
const fsm2 = new KosFSMManager(model, tagged("fsm"));
|
|
10712
|
+
const offlineQueue = new KosOfflineQueue(tagged("offline-queue"));
|
|
10604
10713
|
const companionManager = new KosCompanionModelManager(model);
|
|
10605
10714
|
const childResolver = new KosChildResolver(model);
|
|
10606
10715
|
const serviceResponseStore = new ServiceResponseStore();
|
|
10607
10716
|
modelData.serviceResponses = serviceResponseStore;
|
|
10608
10717
|
const onlineLifecycleManager = new KosOnlineLifecycleManager(
|
|
10609
10718
|
model,
|
|
10610
|
-
|
|
10719
|
+
tagged("online")
|
|
10611
10720
|
);
|
|
10612
10721
|
const components = {
|
|
10613
10722
|
fsm: fsm2,
|
|
@@ -10622,11 +10731,11 @@ class KosModelComponentFactory {
|
|
|
10622
10731
|
modelTypeName,
|
|
10623
10732
|
modelId,
|
|
10624
10733
|
modelData,
|
|
10625
|
-
|
|
10734
|
+
tagged("effect")
|
|
10626
10735
|
);
|
|
10627
10736
|
}
|
|
10628
10737
|
if (hasSubscriptionHandlers(modelData)) {
|
|
10629
|
-
const subLogger =
|
|
10738
|
+
const subLogger = tagged("subscription");
|
|
10630
10739
|
components.subscriptionManager = new KosSubscriptionManager(
|
|
10631
10740
|
model,
|
|
10632
10741
|
modelData,
|
|
@@ -10638,7 +10747,7 @@ class KosModelComponentFactory {
|
|
|
10638
10747
|
if (hasHttpRouteHandlers(modelData)) {
|
|
10639
10748
|
components.httpRouteManager = new KosHttpRouteManager(
|
|
10640
10749
|
modelData,
|
|
10641
|
-
|
|
10750
|
+
tagged("http-routes")
|
|
10642
10751
|
);
|
|
10643
10752
|
}
|
|
10644
10753
|
if (hasServiceRequestHandlers(modelData)) {
|
|
@@ -10651,7 +10760,7 @@ class KosModelComponentFactory {
|
|
|
10651
10760
|
return components;
|
|
10652
10761
|
}
|
|
10653
10762
|
}
|
|
10654
|
-
const log$
|
|
10763
|
+
const log$F = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
10655
10764
|
const MODEL_LOADER = "kos.extension.model.loader";
|
|
10656
10765
|
class KosModel {
|
|
10657
10766
|
_id;
|
|
@@ -10759,23 +10868,23 @@ class KosModel {
|
|
|
10759
10868
|
return this._status === KosModelState.READY;
|
|
10760
10869
|
}
|
|
10761
10870
|
async deactivate() {
|
|
10762
|
-
log$
|
|
10871
|
+
log$F.debug(
|
|
10763
10872
|
`deactivating model ${this.modelTypeName} with id ${this.modelId}`
|
|
10764
10873
|
);
|
|
10765
10874
|
try {
|
|
10766
10875
|
const context = KosContextManager.getContext(this.modelId);
|
|
10767
10876
|
await this.modelData?.deactivate?.(context);
|
|
10768
|
-
log$
|
|
10877
|
+
log$F.debug(
|
|
10769
10878
|
`Model ${this.modelTypeName} with id ${this.modelId} deactivated`
|
|
10770
10879
|
);
|
|
10771
10880
|
this.subscriptionManager?.deactivate();
|
|
10772
10881
|
} catch (e) {
|
|
10773
|
-
log$
|
|
10882
|
+
log$F.debug(`Model ${this.modelId} failed to deactivated`);
|
|
10774
10883
|
throw e;
|
|
10775
10884
|
}
|
|
10776
10885
|
}
|
|
10777
10886
|
async activate() {
|
|
10778
|
-
log$
|
|
10887
|
+
log$F.debug(`activating model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10779
10888
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ACTIVATE);
|
|
10780
10889
|
try {
|
|
10781
10890
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10784,16 +10893,16 @@ class KosModel {
|
|
|
10784
10893
|
const context = KosContextManager.getContext(this.modelId);
|
|
10785
10894
|
await this.modelData?.activate?.(context);
|
|
10786
10895
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.ACTIVATE);
|
|
10787
|
-
log$
|
|
10896
|
+
log$F.debug(
|
|
10788
10897
|
`Model ${this.modelTypeName} with id ${this.modelId} subscribing to all topics`
|
|
10789
10898
|
);
|
|
10790
10899
|
this.subscriptionManager?.registerAll(DependencyLifecycle.ACTIVATE);
|
|
10791
10900
|
this.createLifecycleCompanions(DependencyLifecycle.ACTIVATE);
|
|
10792
|
-
log$
|
|
10901
|
+
log$F.debug(
|
|
10793
10902
|
`Model ${this.modelTypeName} with id ${this.modelId} activated`
|
|
10794
10903
|
);
|
|
10795
10904
|
} catch (e) {
|
|
10796
|
-
log$
|
|
10905
|
+
log$F.debug(`Model ${this.modelId} failed to activate`);
|
|
10797
10906
|
throw e;
|
|
10798
10907
|
}
|
|
10799
10908
|
return;
|
|
@@ -10809,7 +10918,7 @@ class KosModel {
|
|
|
10809
10918
|
{
|
|
10810
10919
|
condition: () => this.loaded,
|
|
10811
10920
|
onMatch: () => {
|
|
10812
|
-
log$
|
|
10921
|
+
log$F.debug(`Model ${this.modelId} is loaded`);
|
|
10813
10922
|
}
|
|
10814
10923
|
}
|
|
10815
10924
|
]);
|
|
@@ -10825,7 +10934,7 @@ class KosModel {
|
|
|
10825
10934
|
{
|
|
10826
10935
|
condition: () => this.initialized,
|
|
10827
10936
|
onMatch: () => {
|
|
10828
|
-
log$
|
|
10937
|
+
log$F.debug(`Model ${this.modelId} is initialized`);
|
|
10829
10938
|
}
|
|
10830
10939
|
}
|
|
10831
10940
|
]);
|
|
@@ -10841,20 +10950,20 @@ class KosModel {
|
|
|
10841
10950
|
{
|
|
10842
10951
|
condition: () => this.status === KosModelState.READY,
|
|
10843
10952
|
onMatch: () => {
|
|
10844
|
-
log$
|
|
10953
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10845
10954
|
}
|
|
10846
10955
|
}
|
|
10847
10956
|
]);
|
|
10848
10957
|
}
|
|
10849
10958
|
async ready() {
|
|
10850
10959
|
if (this.fsm.current === KosModelState.READY) {
|
|
10851
|
-
log$
|
|
10960
|
+
log$F.debug(
|
|
10852
10961
|
`already readying model ${this.modelTypeName} with id ${this.modelId} returning`
|
|
10853
10962
|
);
|
|
10854
10963
|
return;
|
|
10855
10964
|
}
|
|
10856
10965
|
try {
|
|
10857
|
-
log$
|
|
10966
|
+
log$F.debug(`readying model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10858
10967
|
await executeDependentModelLifecycle(this, DependencyLifecycle.READY);
|
|
10859
10968
|
await executeChildrenModelLifecycle(
|
|
10860
10969
|
this,
|
|
@@ -10870,7 +10979,7 @@ class KosModel {
|
|
|
10870
10979
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.READY);
|
|
10871
10980
|
this.subscriptionManager?.registerAll(DependencyLifecycle.READY);
|
|
10872
10981
|
this.createLifecycleCompanions(DependencyLifecycle.READY);
|
|
10873
|
-
log$
|
|
10982
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10874
10983
|
const payload = {
|
|
10875
10984
|
modelId: this.modelId,
|
|
10876
10985
|
modelType: this.modelTypeName
|
|
@@ -10881,7 +10990,7 @@ class KosModel {
|
|
|
10881
10990
|
);
|
|
10882
10991
|
publish(modelTypeEventTopicFactory(this.modelTypeName), payload);
|
|
10883
10992
|
} catch (e) {
|
|
10884
|
-
log$
|
|
10993
|
+
log$F.error(e);
|
|
10885
10994
|
throw Error(e);
|
|
10886
10995
|
}
|
|
10887
10996
|
}
|
|
@@ -10892,18 +11001,18 @@ class KosModel {
|
|
|
10892
11001
|
}
|
|
10893
11002
|
const { modelTypeName, modelId } = this;
|
|
10894
11003
|
if (this.fsm.current === KosModelState.LOADED) {
|
|
10895
|
-
log$
|
|
11004
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} already loaded`);
|
|
10896
11005
|
return;
|
|
10897
11006
|
}
|
|
10898
11007
|
if (this._isLoadExecuting) {
|
|
10899
|
-
log$
|
|
11008
|
+
log$F.debug(
|
|
10900
11009
|
`Model ${modelTypeName} with id ${modelId} is currently executing load`
|
|
10901
11010
|
);
|
|
10902
11011
|
return;
|
|
10903
11012
|
}
|
|
10904
11013
|
this._isLoadExecuting = true;
|
|
10905
11014
|
try {
|
|
10906
|
-
log$
|
|
11015
|
+
log$F.debug(`Loading model ${modelTypeName} with id ${modelId}`);
|
|
10907
11016
|
await executeDependentModelLifecycle(this, DependencyLifecycle.LOAD);
|
|
10908
11017
|
const context = KosContextManager.getContext(modelId);
|
|
10909
11018
|
const MODEL_LOADER_TYPE = `${MODEL_LOADER}.${modelTypeName}`;
|
|
@@ -10912,7 +11021,7 @@ class KosModel {
|
|
|
10912
11021
|
{}
|
|
10913
11022
|
);
|
|
10914
11023
|
if (loadedContext) {
|
|
10915
|
-
log$
|
|
11024
|
+
log$F.info(
|
|
10916
11025
|
`Setting loaded context for ${modelId}, type: ${modelTypeName}`
|
|
10917
11026
|
);
|
|
10918
11027
|
context?.set(MODEL_LOADER_TYPE, loadedContext);
|
|
@@ -10924,7 +11033,7 @@ class KosModel {
|
|
|
10924
11033
|
kosAction(() => {
|
|
10925
11034
|
this.loaded = true;
|
|
10926
11035
|
});
|
|
10927
|
-
log$
|
|
11036
|
+
log$F.debug(
|
|
10928
11037
|
`Model ${modelTypeName} with id ${modelId} successfully loaded`
|
|
10929
11038
|
);
|
|
10930
11039
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.LOAD);
|
|
@@ -10933,14 +11042,14 @@ class KosModel {
|
|
|
10933
11042
|
this.effectManager?.setup();
|
|
10934
11043
|
this.createLifecycleCompanions(DependencyLifecycle.LOAD);
|
|
10935
11044
|
} catch (e) {
|
|
10936
|
-
log$
|
|
11045
|
+
log$F.error(`Model ${modelId} failed to load`, e);
|
|
10937
11046
|
throw e;
|
|
10938
11047
|
} finally {
|
|
10939
11048
|
this._isLoadExecuting = false;
|
|
10940
11049
|
}
|
|
10941
11050
|
}
|
|
10942
11051
|
async unload() {
|
|
10943
|
-
log$
|
|
11052
|
+
log$F.debug(`unloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10944
11053
|
try {
|
|
10945
11054
|
const childrenUnload = this.getChildren().map((child) => child.unload?.()).filter((p) => !!p);
|
|
10946
11055
|
await Promise.allSettled(childrenUnload);
|
|
@@ -10959,12 +11068,12 @@ class KosModel {
|
|
|
10959
11068
|
modelData.stateHistory = [];
|
|
10960
11069
|
}
|
|
10961
11070
|
}
|
|
10962
|
-
log$
|
|
11071
|
+
log$F.debug(`Model ${this.modelTypeName} with id ${this.modelId} unloaded`);
|
|
10963
11072
|
this.effectManager?.disposeAll();
|
|
10964
11073
|
this.subscriptionManager?.disposeAll();
|
|
10965
11074
|
this.httpRouteManager?.dispose();
|
|
10966
11075
|
} catch (e) {
|
|
10967
|
-
log$
|
|
11076
|
+
log$F.debug(`Model ${this.modelId} failed to unload`);
|
|
10968
11077
|
throw e;
|
|
10969
11078
|
}
|
|
10970
11079
|
}
|
|
@@ -10975,7 +11084,7 @@ class KosModel {
|
|
|
10975
11084
|
}
|
|
10976
11085
|
const { modelId, modelTypeName } = this;
|
|
10977
11086
|
const context = KosContextManager.getContext(modelId);
|
|
10978
|
-
log$
|
|
11087
|
+
log$F.debug(`Initializing model ${modelTypeName} with id ${modelId}`);
|
|
10979
11088
|
await executeDependentModelLifecycle(this, DependencyLifecycle.INIT);
|
|
10980
11089
|
try {
|
|
10981
11090
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10983,18 +11092,18 @@ class KosModel {
|
|
|
10983
11092
|
);
|
|
10984
11093
|
await this.modelData?.init?.(context);
|
|
10985
11094
|
this.initialized = true;
|
|
10986
|
-
log$
|
|
11095
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} initialized`);
|
|
10987
11096
|
this.onlineLifecycleManager?.register();
|
|
10988
11097
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.INIT);
|
|
10989
11098
|
this.registerSubscribers(DependencyLifecycle.INIT);
|
|
10990
11099
|
this.createLifecycleCompanions(DependencyLifecycle.INIT);
|
|
10991
11100
|
} catch (e) {
|
|
10992
|
-
log$
|
|
11101
|
+
log$F.error(`Model ${modelId} failed to initialize`, e);
|
|
10993
11102
|
throw e;
|
|
10994
11103
|
}
|
|
10995
11104
|
}
|
|
10996
11105
|
async registerSubscribers(lifecycle) {
|
|
10997
|
-
log$
|
|
11106
|
+
log$F.debug(
|
|
10998
11107
|
`registering subscribers in ${this.modelTypeName} with id ${this.modelId}`
|
|
10999
11108
|
);
|
|
11000
11109
|
this.subscriptionManager?.registerAll(lifecycle);
|
|
@@ -11011,7 +11120,7 @@ class KosModel {
|
|
|
11011
11120
|
}
|
|
11012
11121
|
/** @internal */
|
|
11013
11122
|
async reloadData() {
|
|
11014
|
-
log$
|
|
11123
|
+
log$F.info(`reloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11015
11124
|
this.suspendForReload();
|
|
11016
11125
|
const data = this.modelData;
|
|
11017
11126
|
if (typeof data?.reload === "function" && !data[SelfManagedReload]) {
|
|
@@ -11020,7 +11129,7 @@ class KosModel {
|
|
|
11020
11129
|
}
|
|
11021
11130
|
/** @internal */
|
|
11022
11131
|
async reattach() {
|
|
11023
|
-
log$
|
|
11132
|
+
log$F.info(`reattaching model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11024
11133
|
kosAction(() => {
|
|
11025
11134
|
this.loaded = true;
|
|
11026
11135
|
});
|
|
@@ -11051,7 +11160,7 @@ class KosModel {
|
|
|
11051
11160
|
]);
|
|
11052
11161
|
reloaded.forEach((result, index) => {
|
|
11053
11162
|
if (result.status === "rejected") {
|
|
11054
|
-
log$
|
|
11163
|
+
log$F.error(
|
|
11055
11164
|
`reload of child ${ready[index].modelId} of ${this.modelId} failed`,
|
|
11056
11165
|
result.reason
|
|
11057
11166
|
);
|
|
@@ -11082,7 +11191,7 @@ class KosModel {
|
|
|
11082
11191
|
* each time. A state machine with `initializeAt: ONLINE` starts once.
|
|
11083
11192
|
*/
|
|
11084
11193
|
async online() {
|
|
11085
|
-
log$
|
|
11194
|
+
log$F.debug(`online model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11086
11195
|
this.registerSubscribers();
|
|
11087
11196
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ONLINE);
|
|
11088
11197
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -11094,7 +11203,7 @@ class KosModel {
|
|
|
11094
11203
|
this.createLifecycleCompanions(DependencyLifecycle.ONLINE);
|
|
11095
11204
|
}
|
|
11096
11205
|
async offline() {
|
|
11097
|
-
log$
|
|
11206
|
+
log$F.debug(`offline model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11098
11207
|
this.subscriptionManager?.disposeAll();
|
|
11099
11208
|
const context = KosContextManager.getContext(this.modelId);
|
|
11100
11209
|
await this.modelData?.offline?.(context);
|
|
@@ -11112,7 +11221,10 @@ class KosModel {
|
|
|
11112
11221
|
this.companionManager.clear();
|
|
11113
11222
|
}
|
|
11114
11223
|
}
|
|
11115
|
-
const log$
|
|
11224
|
+
const log$E = KosLog.createLogger({
|
|
11225
|
+
group: LogGroup.core,
|
|
11226
|
+
name: "kos-model-instantiator"
|
|
11227
|
+
});
|
|
11116
11228
|
class KosModelInstantiator {
|
|
11117
11229
|
constructor(registry, cache2) {
|
|
11118
11230
|
this.registry = registry;
|
|
@@ -11130,7 +11242,7 @@ class KosModelInstantiator {
|
|
|
11130
11242
|
const modelRegistry = this.registry.models[typeId];
|
|
11131
11243
|
if (!modelRegistry) {
|
|
11132
11244
|
const errorMessage = `No model registered for type ${typeId}`;
|
|
11133
|
-
log$
|
|
11245
|
+
log$E.error(errorMessage, {
|
|
11134
11246
|
modelType: typeId,
|
|
11135
11247
|
requestedId: id,
|
|
11136
11248
|
providedOptions: options,
|
|
@@ -11149,7 +11261,7 @@ class KosModelInstantiator {
|
|
|
11149
11261
|
const modelId = modelRegistry.singleton ? typeId : id;
|
|
11150
11262
|
this.cache.restoreFromDeleteCache(modelId);
|
|
11151
11263
|
if (!this.cache.hasModel(modelId)) {
|
|
11152
|
-
log$
|
|
11264
|
+
log$E.debug(`Creating model instance: ${typeId} [${modelId}]`);
|
|
11153
11265
|
const hasOptions = options && Object.keys(options).length > 0;
|
|
11154
11266
|
const modelClass = modelRegistry.class || modelRegistry.create;
|
|
11155
11267
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
@@ -11195,7 +11307,7 @@ class KosModelInstantiator {
|
|
|
11195
11307
|
}
|
|
11196
11308
|
const activeModel = this.cache.getModelById(modelId);
|
|
11197
11309
|
if (!activeModel) {
|
|
11198
|
-
log$
|
|
11310
|
+
log$E.error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11199
11311
|
throw new Error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11200
11312
|
}
|
|
11201
11313
|
return { model: activeModel, data: activeModel.modelData };
|
|
@@ -11261,7 +11373,10 @@ let KosModelRegistry$1 = class KosModelRegistry {
|
|
|
11261
11373
|
}
|
|
11262
11374
|
};
|
|
11263
11375
|
const MODEL_DELETION_DELAY = 10;
|
|
11264
|
-
const log$
|
|
11376
|
+
const log$D = KosLog.createLogger({
|
|
11377
|
+
group: LogGroup.core,
|
|
11378
|
+
name: "kos-model-manager"
|
|
11379
|
+
});
|
|
11265
11380
|
class KosModelManager {
|
|
11266
11381
|
cache;
|
|
11267
11382
|
instantiator;
|
|
@@ -11304,7 +11419,7 @@ class KosModelManager {
|
|
|
11304
11419
|
}
|
|
11305
11420
|
static getInstance(reset2) {
|
|
11306
11421
|
if (!globalThis.kos?.modelManager || reset2) {
|
|
11307
|
-
log$
|
|
11422
|
+
log$D.debug("Creating new instance of KosModelManager");
|
|
11308
11423
|
new this();
|
|
11309
11424
|
}
|
|
11310
11425
|
return globalThis.kos?.modelManager;
|
|
@@ -11325,7 +11440,7 @@ class KosModelManager {
|
|
|
11325
11440
|
*/
|
|
11326
11441
|
get preloadedModels() {
|
|
11327
11442
|
return this.cache.preload((modelKey) => {
|
|
11328
|
-
log$
|
|
11443
|
+
log$D.debug(`preloading ${modelKey}`);
|
|
11329
11444
|
if (typeof modelKey === "string") {
|
|
11330
11445
|
return this.createModelInstance(modelKey).model;
|
|
11331
11446
|
} else {
|
|
@@ -11621,6 +11736,10 @@ class KosModelManager {
|
|
|
11621
11736
|
this._registry.registerModel(reg);
|
|
11622
11737
|
}
|
|
11623
11738
|
}
|
|
11739
|
+
const log$C = KosLog.createLogger({
|
|
11740
|
+
group: LogGroup.core,
|
|
11741
|
+
name: "kos-core-lifecycle"
|
|
11742
|
+
});
|
|
11624
11743
|
var KosCoreState = /* @__PURE__ */ ((KosCoreState2) => {
|
|
11625
11744
|
KosCoreState2["CREATING"] = `creating`;
|
|
11626
11745
|
KosCoreState2["CREATED"] = `created`;
|
|
@@ -11657,7 +11776,7 @@ const reportFailure = async (step, run) => {
|
|
|
11657
11776
|
return await run();
|
|
11658
11777
|
} catch (error) {
|
|
11659
11778
|
const detail = error instanceof Error ? error.stack ?? `${error.name}: ${error.message}` : String(error);
|
|
11660
|
-
log$
|
|
11779
|
+
log$C.error(`KOS Core lifecycle step "${step}" failed. ${detail}`);
|
|
11661
11780
|
throw error;
|
|
11662
11781
|
}
|
|
11663
11782
|
};
|
|
@@ -11696,7 +11815,7 @@ const coreFsm = (core) => {
|
|
|
11696
11815
|
});
|
|
11697
11816
|
const online = robot3.interpret(
|
|
11698
11817
|
onlineMachine2,
|
|
11699
|
-
(_service) => log$
|
|
11818
|
+
(_service) => log$C.debug(`KOS Core connection: ${_service.machine.current}`)
|
|
11700
11819
|
);
|
|
11701
11820
|
const syncOnline = () => online.send(
|
|
11702
11821
|
core.transport.connectionEstablished ? "go_online" : "go_offline"
|
|
@@ -11910,11 +12029,11 @@ const coreFsm = (core) => {
|
|
|
11910
12029
|
});
|
|
11911
12030
|
const service2 = robot3.interpret(
|
|
11912
12031
|
machine2,
|
|
11913
|
-
(_service) => log$
|
|
12032
|
+
(_service) => log$C.debug(`KOS Core state: ${_service.machine.current}`)
|
|
11914
12033
|
);
|
|
11915
12034
|
return { service: service2, online };
|
|
11916
12035
|
};
|
|
11917
|
-
const log$
|
|
12036
|
+
const log$B = KosLog.createLogger({ group: LogGroup.core, name: "kos-core" });
|
|
11918
12037
|
const getConnectionAlias = () => {
|
|
11919
12038
|
const params2 = getQueryParams();
|
|
11920
12039
|
const alias = params2?.alias;
|
|
@@ -11968,11 +12087,11 @@ const rejectAfterDelay = (ms, model) => {
|
|
|
11968
12087
|
const promise = new Promise((_, reject) => {
|
|
11969
12088
|
timeoutId = setTimeout(() => {
|
|
11970
12089
|
if (model) {
|
|
11971
|
-
|
|
12090
|
+
log$B.error(
|
|
11972
12091
|
`Model ${model.modelId} - ${model.modelTypeName} preloading - timed out after ${ms}ms`
|
|
11973
12092
|
);
|
|
11974
12093
|
} else {
|
|
11975
|
-
|
|
12094
|
+
log$B.error(`KOS Core preloading timed out after ${ms}ms`);
|
|
11976
12095
|
}
|
|
11977
12096
|
reject(
|
|
11978
12097
|
new Error(
|
|
@@ -12057,11 +12176,11 @@ class KosCore {
|
|
|
12057
12176
|
});
|
|
12058
12177
|
});
|
|
12059
12178
|
subscribe(WebSocketEvents.RELOAD, () => {
|
|
12060
|
-
log$
|
|
12179
|
+
log$B.warn("WebSocket requested reload");
|
|
12061
12180
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12062
12181
|
});
|
|
12063
12182
|
subscribe("/studio/project/reload", () => {
|
|
12064
|
-
log$
|
|
12183
|
+
log$B.warn("Project requested reload");
|
|
12065
12184
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12066
12185
|
});
|
|
12067
12186
|
const ws = WebSocketTransport.getInstance();
|
|
@@ -12090,7 +12209,7 @@ class KosCore {
|
|
|
12090
12209
|
applyConnectionAlias(connectionAlias) {
|
|
12091
12210
|
if (this._transport.alias) {
|
|
12092
12211
|
if (this.connectionAlias && this.connectionAlias !== connectionAlias) {
|
|
12093
|
-
log$
|
|
12212
|
+
log$B.warn(
|
|
12094
12213
|
`Connection alias ${connectionAlias} ignored; the connection already uses ${this._transport.alias}`
|
|
12095
12214
|
);
|
|
12096
12215
|
}
|
|
@@ -12128,13 +12247,13 @@ alias:${alias}
|
|
|
12128
12247
|
}
|
|
12129
12248
|
async reload() {
|
|
12130
12249
|
if (this._reloading) {
|
|
12131
|
-
log$
|
|
12250
|
+
log$B.info("reload already in progress");
|
|
12132
12251
|
return;
|
|
12133
12252
|
}
|
|
12134
12253
|
this._reloading = true;
|
|
12135
12254
|
try {
|
|
12136
|
-
log$
|
|
12137
|
-
log$
|
|
12255
|
+
log$B.warn("reloading KOS Core");
|
|
12256
|
+
log$B.warn("reloading preloaded models");
|
|
12138
12257
|
const modelManager = this.modelManager;
|
|
12139
12258
|
const preloaded = [...modelManager.preloadedModels];
|
|
12140
12259
|
const covered = /* @__PURE__ */ new Set();
|
|
@@ -12146,27 +12265,27 @@ alias:${alias}
|
|
|
12146
12265
|
for (const model of preloaded) {
|
|
12147
12266
|
if (isReloadable(model.modelData) && !covered.has(model)) {
|
|
12148
12267
|
if (isSelfManagedReload(model.modelData)) {
|
|
12149
|
-
log$
|
|
12268
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12150
12269
|
continue;
|
|
12151
12270
|
}
|
|
12152
|
-
log$
|
|
12271
|
+
log$B.info(`reloading model ${model.modelId}`);
|
|
12153
12272
|
await reloadRoot(model);
|
|
12154
|
-
log$
|
|
12273
|
+
log$B.info(`reloading model ${model.modelId} complete`);
|
|
12155
12274
|
}
|
|
12156
12275
|
}
|
|
12157
12276
|
for (const model of [...modelManager.models]) {
|
|
12158
12277
|
if (!preloaded.includes(model) && isReloadable(model.modelData) && !covered.has(model)) {
|
|
12159
12278
|
if (isSelfManagedReload(model.modelData)) {
|
|
12160
|
-
log$
|
|
12279
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12161
12280
|
continue;
|
|
12162
12281
|
}
|
|
12163
|
-
log$
|
|
12282
|
+
log$B.warn(`reloading model ${model.modelId}`);
|
|
12164
12283
|
await reloadRoot(model);
|
|
12165
12284
|
}
|
|
12166
12285
|
}
|
|
12167
12286
|
} finally {
|
|
12168
12287
|
mobx.runInAction(() => {
|
|
12169
|
-
log$
|
|
12288
|
+
log$B.warn("reloading KOS Core complete");
|
|
12170
12289
|
this._reloading = false;
|
|
12171
12290
|
});
|
|
12172
12291
|
}
|
|
@@ -12176,13 +12295,13 @@ alias:${alias}
|
|
|
12176
12295
|
try {
|
|
12177
12296
|
await model.fsm.reload();
|
|
12178
12297
|
} catch (e) {
|
|
12179
|
-
log$
|
|
12298
|
+
log$B.error(`reload of ${model.modelId} failed`, e);
|
|
12180
12299
|
}
|
|
12181
12300
|
}
|
|
12182
12301
|
async online() {
|
|
12183
|
-
log$
|
|
12302
|
+
log$B.debug("KOS Core going online");
|
|
12184
12303
|
await this._transport.whenReady();
|
|
12185
|
-
log$
|
|
12304
|
+
log$B.debug("KOS Transport Ready. Calling online() for models");
|
|
12186
12305
|
this.modelManager.models.forEach(
|
|
12187
12306
|
(model) => model.onlineLifecycleManager?.register()
|
|
12188
12307
|
);
|
|
@@ -12190,14 +12309,14 @@ alias:${alias}
|
|
|
12190
12309
|
console.timeEnd("kosCore:startup");
|
|
12191
12310
|
}
|
|
12192
12311
|
async offline() {
|
|
12193
|
-
log$
|
|
12312
|
+
log$B.debug("KOS Core going offline");
|
|
12194
12313
|
publish("/kosCore/offline", "/kosCore/offline");
|
|
12195
12314
|
}
|
|
12196
12315
|
async unload() {
|
|
12197
|
-
log$
|
|
12316
|
+
log$B.debug("Unloading KOS Core");
|
|
12198
12317
|
const currentTime = Date.now();
|
|
12199
12318
|
this._unloading = true;
|
|
12200
|
-
log$
|
|
12319
|
+
log$B.debug("unloading KOS Core");
|
|
12201
12320
|
const modelManager = this.modelManager;
|
|
12202
12321
|
for (const model of modelManager.models) {
|
|
12203
12322
|
if (isUnloadable(model.modelData)) {
|
|
@@ -12215,9 +12334,9 @@ alias:${alias}
|
|
|
12215
12334
|
await mobx.when(() => this.status === KosCoreState.READY);
|
|
12216
12335
|
}
|
|
12217
12336
|
async ready() {
|
|
12218
|
-
log$
|
|
12337
|
+
log$B.debug("Readying KOS Core");
|
|
12219
12338
|
await this._transport.whenReady();
|
|
12220
|
-
log$
|
|
12339
|
+
log$B.debug("KOS Transport ready. Preloading models");
|
|
12221
12340
|
if (!this.modelManager) {
|
|
12222
12341
|
throw new Error(
|
|
12223
12342
|
"KOS Core reached ready() with no model manager. Its lifecycle was started without a registry."
|
|
@@ -12230,7 +12349,7 @@ alias:${alias}
|
|
|
12230
12349
|
promise: model.whenReady()
|
|
12231
12350
|
};
|
|
12232
12351
|
});
|
|
12233
|
-
log$
|
|
12352
|
+
log$B.debug(`Preloaded ${promises.length} models`);
|
|
12234
12353
|
const settled = await Promise.allSettled(
|
|
12235
12354
|
promises.map((promise) => {
|
|
12236
12355
|
const { promise: timeoutPromise, cancel: timeoutCancel } = rejectAfterDelay(5e3, promise.model);
|
|
@@ -12244,14 +12363,14 @@ alias:${alias}
|
|
|
12244
12363
|
);
|
|
12245
12364
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
12246
12365
|
if (failed.length) {
|
|
12247
|
-
log$
|
|
12366
|
+
log$B.error(
|
|
12248
12367
|
`There were ${failed.length} failed models on model preloading`
|
|
12249
12368
|
);
|
|
12250
12369
|
throw Error(
|
|
12251
12370
|
`There were ${failed.length} failed models on model preloading`
|
|
12252
12371
|
);
|
|
12253
12372
|
}
|
|
12254
|
-
log$
|
|
12373
|
+
log$B.debug(`leaving kos-core ready() `);
|
|
12255
12374
|
}
|
|
12256
12375
|
get isReady() {
|
|
12257
12376
|
return this.status === KosCoreState.READY;
|
|
@@ -12269,19 +12388,19 @@ alias:${alias}
|
|
|
12269
12388
|
return this.loaded;
|
|
12270
12389
|
}
|
|
12271
12390
|
async init() {
|
|
12272
|
-
log$
|
|
12391
|
+
log$B.debug("entering kos-core init()");
|
|
12273
12392
|
console.time("kosCore:startup");
|
|
12274
12393
|
console.time("kosCore:init");
|
|
12275
12394
|
await this._transport.whenReady();
|
|
12276
12395
|
this.initialized = true;
|
|
12277
|
-
log$
|
|
12396
|
+
log$B.debug("initialized - leaving kos-core init()");
|
|
12278
12397
|
console.timeEnd("kosCore:init");
|
|
12279
12398
|
}
|
|
12280
12399
|
async load() {
|
|
12281
|
-
log$
|
|
12400
|
+
log$B.debug("entering kos-core load()");
|
|
12282
12401
|
console.time("kosCore:load");
|
|
12283
12402
|
this.loaded = true;
|
|
12284
|
-
log$
|
|
12403
|
+
log$B.debug("loaded - leaving kos-core load()");
|
|
12285
12404
|
console.timeEnd("kosCore:load");
|
|
12286
12405
|
}
|
|
12287
12406
|
static create(registry, reset2, connectionAlias) {
|
|
@@ -12371,9 +12490,9 @@ alias:${alias}
|
|
|
12371
12490
|
return this._instance;
|
|
12372
12491
|
}
|
|
12373
12492
|
}
|
|
12374
|
-
const log$
|
|
12375
|
-
|
|
12376
|
-
|
|
12493
|
+
const log$A = KosLog.createLogger({
|
|
12494
|
+
group: LogGroup.core,
|
|
12495
|
+
name: "kos-model-visitor"
|
|
12377
12496
|
});
|
|
12378
12497
|
class KosModelVisitor {
|
|
12379
12498
|
/**
|
|
@@ -12412,7 +12531,7 @@ class KosModelVisitor {
|
|
|
12412
12531
|
*/
|
|
12413
12532
|
visit(model) {
|
|
12414
12533
|
if (this.visitedModels.has(model.modelId)) {
|
|
12415
|
-
log$
|
|
12534
|
+
log$A.info(`model ${model.modelId} already visited`);
|
|
12416
12535
|
return;
|
|
12417
12536
|
}
|
|
12418
12537
|
const stopVisiting = !!this.visitModel(model.modelData, this);
|
|
@@ -12425,6 +12544,10 @@ class KosModelVisitor {
|
|
|
12425
12544
|
});
|
|
12426
12545
|
}
|
|
12427
12546
|
}
|
|
12547
|
+
const log$z = KosLog.createLogger({
|
|
12548
|
+
group: LogGroup.core,
|
|
12549
|
+
name: "feature-flags"
|
|
12550
|
+
});
|
|
12428
12551
|
const EXTENSION_FEATURE_FLAG_RESOLVER = "featureFlagResolver";
|
|
12429
12552
|
const flagResolvers = /* @__PURE__ */ new Map();
|
|
12430
12553
|
registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
@@ -12445,7 +12568,7 @@ registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
|
12445
12568
|
if (r.status === "fulfilled") {
|
|
12446
12569
|
return r.value;
|
|
12447
12570
|
} else {
|
|
12448
|
-
|
|
12571
|
+
log$z.info(`Feature flag resolver ${id} failed: ${r.reason}`);
|
|
12449
12572
|
return [];
|
|
12450
12573
|
}
|
|
12451
12574
|
}).flat();
|
|
@@ -12518,7 +12641,41 @@ const modelFactory = (typeId) => {
|
|
|
12518
12641
|
};
|
|
12519
12642
|
};
|
|
12520
12643
|
const pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);
|
|
12521
|
-
const log$
|
|
12644
|
+
const log$y = KosLog.createLogger({
|
|
12645
|
+
group: LogGroup.core,
|
|
12646
|
+
name: "retry-with-exponential-backoff"
|
|
12647
|
+
});
|
|
12648
|
+
const BASE_OPTIONS = {
|
|
12649
|
+
maxAttempts: 5,
|
|
12650
|
+
baseDelayMs: 100,
|
|
12651
|
+
backoffFactor: 1.5
|
|
12652
|
+
};
|
|
12653
|
+
async function retryWithExponentialBackoff(operation, options) {
|
|
12654
|
+
let attempt = 1;
|
|
12655
|
+
const _options = { ...BASE_OPTIONS, ...options };
|
|
12656
|
+
const { maxAttempts, baseDelayMs, backoffFactor } = _options;
|
|
12657
|
+
let delayMs = baseDelayMs;
|
|
12658
|
+
while (attempt <= maxAttempts) {
|
|
12659
|
+
try {
|
|
12660
|
+
const result = await operation();
|
|
12661
|
+
return result;
|
|
12662
|
+
} catch (error) {
|
|
12663
|
+
log$y.error(`Attempt ${attempt} failed: ${error}`);
|
|
12664
|
+
if (attempt < maxAttempts) {
|
|
12665
|
+
delayMs = baseDelayMs * Math.pow(backoffFactor, attempt);
|
|
12666
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
12667
|
+
attempt++;
|
|
12668
|
+
} else {
|
|
12669
|
+
throw error;
|
|
12670
|
+
}
|
|
12671
|
+
}
|
|
12672
|
+
}
|
|
12673
|
+
throw new Error("All attempts failed");
|
|
12674
|
+
}
|
|
12675
|
+
const log$x = KosLog.createLogger({
|
|
12676
|
+
group: LogGroup.transport,
|
|
12677
|
+
name: "kos-service-request"
|
|
12678
|
+
});
|
|
12522
12679
|
const resolveServiceUrl = (_service) => {
|
|
12523
12680
|
const MOCK = false;
|
|
12524
12681
|
const URL2 = exports.BASE_URL;
|
|
@@ -12690,7 +12847,7 @@ const getOne$7 = (destinationAddress, url, _fetch) => async ({
|
|
|
12690
12847
|
destinationAddress: destinationAddressOverride
|
|
12691
12848
|
});
|
|
12692
12849
|
const resolvedUrl = urlOverride || url;
|
|
12693
|
-
log$
|
|
12850
|
+
log$x.debug(`resolvedUrl: ${resolvedUrl}`);
|
|
12694
12851
|
try {
|
|
12695
12852
|
const response = await _fetch(resolvedUrl, options);
|
|
12696
12853
|
if (!response.ok) {
|
|
@@ -13009,6 +13166,62 @@ const ServiceFactory = {
|
|
|
13009
13166
|
const _sessionKey = uuid();
|
|
13010
13167
|
const getKosSessionKey = () => `kos-${_sessionKey}`;
|
|
13011
13168
|
const isLocalRefId = (id) => !!id && !id.includes("VM_SERVICE") && id.startsWith(getKosSessionKey());
|
|
13169
|
+
const log$w = KosLog.createLogger({
|
|
13170
|
+
group: LogGroup.transport,
|
|
13171
|
+
name: "wait-for-request"
|
|
13172
|
+
});
|
|
13173
|
+
const waitForRequest = async (requestId, timeout = 6e4) => new Promise((resolve, reject) => {
|
|
13174
|
+
const { unsubscribe } = subscribe(requestId, (op) => {
|
|
13175
|
+
log$w.debug(`recieved response for refId ${requestId}: ${op}`);
|
|
13176
|
+
unsubscribe();
|
|
13177
|
+
clearTimeout(cancel);
|
|
13178
|
+
try {
|
|
13179
|
+
const body = op?.body ? JSON.parse(op.body) : {};
|
|
13180
|
+
resolve(body);
|
|
13181
|
+
} catch {
|
|
13182
|
+
const body = op?.body || {};
|
|
13183
|
+
resolve(body);
|
|
13184
|
+
}
|
|
13185
|
+
});
|
|
13186
|
+
const cancel = setTimeout(() => {
|
|
13187
|
+
unsubscribe();
|
|
13188
|
+
reject(Error(`Request with ID ${requestId} timed out. Cancelling.`));
|
|
13189
|
+
}, timeout);
|
|
13190
|
+
});
|
|
13191
|
+
const sendRequest = async (requestPromise, params2, refId) => {
|
|
13192
|
+
const op = waitForRequest(refId);
|
|
13193
|
+
const result = await Promise.allSettled([requestPromise(params2), op]);
|
|
13194
|
+
if (result[0].status === "fulfilled") {
|
|
13195
|
+
if (result[1].status === "rejected") {
|
|
13196
|
+
throw Error(result[1].reason);
|
|
13197
|
+
} else {
|
|
13198
|
+
if (result[0].value) {
|
|
13199
|
+
if (result[1].value.error) {
|
|
13200
|
+
throw Error(result[1].value.error);
|
|
13201
|
+
}
|
|
13202
|
+
result[0].value.data = result[1].value;
|
|
13203
|
+
return result[0].value;
|
|
13204
|
+
}
|
|
13205
|
+
}
|
|
13206
|
+
} else {
|
|
13207
|
+
throw Error(result[0].reason);
|
|
13208
|
+
}
|
|
13209
|
+
return void 0;
|
|
13210
|
+
};
|
|
13211
|
+
const syncPublish = async ({
|
|
13212
|
+
topic,
|
|
13213
|
+
msg,
|
|
13214
|
+
requestId
|
|
13215
|
+
}) => {
|
|
13216
|
+
const _requestId = requestId ?? uuid();
|
|
13217
|
+
const responsePromise = waitForRequest(_requestId);
|
|
13218
|
+
publish(topic, msg, { sync: _requestId });
|
|
13219
|
+
const response = await responsePromise;
|
|
13220
|
+
if (response.error) {
|
|
13221
|
+
throw Error(response.error);
|
|
13222
|
+
}
|
|
13223
|
+
return response;
|
|
13224
|
+
};
|
|
13012
13225
|
const contextMap = /* @__PURE__ */ new Map();
|
|
13013
13226
|
class KosContextBean {
|
|
13014
13227
|
_context;
|
|
@@ -13105,7 +13318,10 @@ const KosContextManager = {
|
|
|
13105
13318
|
};
|
|
13106
13319
|
KosContextManager.createContext("root");
|
|
13107
13320
|
const resolveKosContext = (model) => KosContextManager.getContext(model.id);
|
|
13108
|
-
const log$
|
|
13321
|
+
const log$v = KosLog.createLogger({
|
|
13322
|
+
group: LogGroup.core,
|
|
13323
|
+
name: "kos-data-container"
|
|
13324
|
+
});
|
|
13109
13325
|
class KosDataContainer {
|
|
13110
13326
|
_data;
|
|
13111
13327
|
_sortKey;
|
|
@@ -13310,7 +13526,7 @@ class KosDataContainer {
|
|
|
13310
13526
|
const idx = this.index.get(indexName);
|
|
13311
13527
|
return idx.keys ?? [];
|
|
13312
13528
|
} else {
|
|
13313
|
-
log$
|
|
13529
|
+
log$v.info(
|
|
13314
13530
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13315
13531
|
);
|
|
13316
13532
|
return [];
|
|
@@ -13322,7 +13538,7 @@ class KosDataContainer {
|
|
|
13322
13538
|
if (idx.index.has(indexKey)) {
|
|
13323
13539
|
return idx.getByKey(indexKey);
|
|
13324
13540
|
} else {
|
|
13325
|
-
log$
|
|
13541
|
+
log$v.info(
|
|
13326
13542
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
13327
13543
|
idx.index.keys()
|
|
13328
13544
|
)}`
|
|
@@ -13330,7 +13546,7 @@ class KosDataContainer {
|
|
|
13330
13546
|
return [];
|
|
13331
13547
|
}
|
|
13332
13548
|
} else {
|
|
13333
|
-
log$
|
|
13549
|
+
log$v.info(
|
|
13334
13550
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13335
13551
|
);
|
|
13336
13552
|
return [];
|
|
@@ -13357,7 +13573,7 @@ class KosDataContainer {
|
|
|
13357
13573
|
* @private
|
|
13358
13574
|
*/
|
|
13359
13575
|
_logDataCapacityWarning(toEvict) {
|
|
13360
|
-
log$
|
|
13576
|
+
log$v.info(
|
|
13361
13577
|
`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.`
|
|
13362
13578
|
);
|
|
13363
13579
|
}
|
|
@@ -13417,7 +13633,7 @@ class KosDataContainer {
|
|
|
13417
13633
|
const candidates = this._customEvictionFilter(this.data);
|
|
13418
13634
|
return candidates.slice(0, count).map((item) => item.id);
|
|
13419
13635
|
}
|
|
13420
|
-
log$
|
|
13636
|
+
log$v.error(
|
|
13421
13637
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO."
|
|
13422
13638
|
);
|
|
13423
13639
|
return this._selectFifoData(count);
|
|
@@ -13429,7 +13645,7 @@ class KosDataContainer {
|
|
|
13429
13645
|
_removeEvictedData(ids) {
|
|
13430
13646
|
ids.forEach((id) => {
|
|
13431
13647
|
const item = this._data.get(id);
|
|
13432
|
-
log$
|
|
13648
|
+
log$v.info(`Evicting data item: ${id}`, {
|
|
13433
13649
|
itemId: id,
|
|
13434
13650
|
itemType: item ? item.constructor?.name : "unknown",
|
|
13435
13651
|
strategy: this._evictionStrategy
|
|
@@ -13442,7 +13658,7 @@ class KosDataContainer {
|
|
|
13442
13658
|
* @private
|
|
13443
13659
|
*/
|
|
13444
13660
|
_logDataEvictionComplete(evictedCount) {
|
|
13445
|
-
log$
|
|
13661
|
+
log$v.info(
|
|
13446
13662
|
`Evicted ${evictedCount} data items. Current size: ${this._data.size}/${this._maxCapacity}`
|
|
13447
13663
|
);
|
|
13448
13664
|
}
|
|
@@ -13614,14 +13830,17 @@ class BrowserKosRouter {
|
|
|
13614
13830
|
}, {});
|
|
13615
13831
|
}
|
|
13616
13832
|
}
|
|
13617
|
-
const log$
|
|
13833
|
+
const log$u = KosLog.createLogger({
|
|
13834
|
+
group: LogGroup.core,
|
|
13835
|
+
name: "intent-service"
|
|
13836
|
+
});
|
|
13618
13837
|
const sendIntent = (intent) => {
|
|
13619
13838
|
if (hasEventSubscriptions(`/kos/intent/${intent.type}`)) {
|
|
13620
13839
|
publish(`/kos/intent/${intent.type}`, intent.options, {
|
|
13621
13840
|
"kos.intent.type": intent.type
|
|
13622
13841
|
});
|
|
13623
13842
|
} else {
|
|
13624
|
-
log$
|
|
13843
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13625
13844
|
}
|
|
13626
13845
|
};
|
|
13627
13846
|
const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
@@ -13651,11 +13870,14 @@ const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
|
13651
13870
|
sync: requestId
|
|
13652
13871
|
});
|
|
13653
13872
|
} else {
|
|
13654
|
-
log$
|
|
13873
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13655
13874
|
resolve([null, { body: void 0, payload: void 0 }]);
|
|
13656
13875
|
}
|
|
13657
13876
|
});
|
|
13658
|
-
const log$
|
|
13877
|
+
const log$t = KosLog.createLogger({
|
|
13878
|
+
group: LogGroup.core,
|
|
13879
|
+
name: "app-startup-service"
|
|
13880
|
+
});
|
|
13659
13881
|
async function waitForAppsToStart(appIds, options = {}) {
|
|
13660
13882
|
const {
|
|
13661
13883
|
timeout = 3e4,
|
|
@@ -13663,10 +13885,10 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13663
13885
|
requirePostStarted = false
|
|
13664
13886
|
} = options;
|
|
13665
13887
|
if (appIds.length === 0) {
|
|
13666
|
-
log$
|
|
13888
|
+
log$t.warn("No app IDs provided to waitForAppsToStart");
|
|
13667
13889
|
return true;
|
|
13668
13890
|
}
|
|
13669
|
-
log$
|
|
13891
|
+
log$t.debug(`Waiting for apps to start: ${appIds.join(", ")}`);
|
|
13670
13892
|
try {
|
|
13671
13893
|
const eventTopics = appIds.map((appId) => `/kos/app/started/${appId}`);
|
|
13672
13894
|
const startedApps = await waitForAllWithState(eventTopics, {
|
|
@@ -13675,12 +13897,12 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13675
13897
|
const { default: api2 } = await Promise.resolve().then(() => service);
|
|
13676
13898
|
const [error, data] = await api2.get("/api/kos/apps/started");
|
|
13677
13899
|
if (error) {
|
|
13678
|
-
log$
|
|
13900
|
+
log$t.error("Error fetching started apps:", error);
|
|
13679
13901
|
return [];
|
|
13680
13902
|
}
|
|
13681
13903
|
return data;
|
|
13682
13904
|
} catch (error) {
|
|
13683
|
-
log$
|
|
13905
|
+
log$t.error("Failed to fetch app startup status:", error);
|
|
13684
13906
|
}
|
|
13685
13907
|
return [];
|
|
13686
13908
|
},
|
|
@@ -13702,17 +13924,17 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13702
13924
|
});
|
|
13703
13925
|
if (notStartedApps.length > 0) {
|
|
13704
13926
|
const message = `Apps not started: ${notStartedApps.join(", ")}`;
|
|
13705
|
-
log$
|
|
13927
|
+
log$t.error(message);
|
|
13706
13928
|
if (throwOnTimeout) {
|
|
13707
13929
|
throw new Error(`App startup timeout: ${message}`);
|
|
13708
13930
|
}
|
|
13709
13931
|
return false;
|
|
13710
13932
|
}
|
|
13711
|
-
log$
|
|
13933
|
+
log$t.info(`All apps started successfully: ${appIds.join(", ")}`);
|
|
13712
13934
|
return true;
|
|
13713
13935
|
} catch (error) {
|
|
13714
13936
|
const message = `Failed to wait for apps to start: ${appIds.join(", ")}`;
|
|
13715
|
-
log$
|
|
13937
|
+
log$t.error(message, error);
|
|
13716
13938
|
if (throwOnTimeout) {
|
|
13717
13939
|
throw new Error(
|
|
13718
13940
|
`${message} - ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -13739,7 +13961,7 @@ async function checkAppsStarted(appIds, requirePostStarted = false) {
|
|
|
13739
13961
|
result[appId] = app?.started === true && (!requirePostStarted || app?.postStarted === true);
|
|
13740
13962
|
});
|
|
13741
13963
|
} catch (error) {
|
|
13742
|
-
log$
|
|
13964
|
+
log$t.error("Failed to check app startup status:", error);
|
|
13743
13965
|
appIds.forEach((appId) => result[appId] = false);
|
|
13744
13966
|
}
|
|
13745
13967
|
return result;
|
|
@@ -13753,7 +13975,7 @@ async function getStartedApps() {
|
|
|
13753
13975
|
const result = await response.json();
|
|
13754
13976
|
return result?.data ?? [];
|
|
13755
13977
|
} catch (error) {
|
|
13756
|
-
log$
|
|
13978
|
+
log$t.error("Failed to fetch started apps:", error);
|
|
13757
13979
|
return [];
|
|
13758
13980
|
}
|
|
13759
13981
|
}
|
|
@@ -13780,9 +14002,9 @@ var Topics = /* @__PURE__ */ ((Topics2) => {
|
|
|
13780
14002
|
Topics2["TIMEZONE_CHANGE"] = "/kos/internal/time/timezone";
|
|
13781
14003
|
return Topics2;
|
|
13782
14004
|
})(Topics || {});
|
|
13783
|
-
const log$
|
|
13784
|
-
|
|
13785
|
-
|
|
14005
|
+
const log$s = KosLog.createLogger({
|
|
14006
|
+
group: LogGroup.service,
|
|
14007
|
+
name: "config-bean-service"
|
|
13786
14008
|
});
|
|
13787
14009
|
const URL$e = exports.BASE_URL;
|
|
13788
14010
|
const hasDecimals = (option) => option?.decimals !== void 0;
|
|
@@ -13791,7 +14013,7 @@ const { postModel: postModel$5, getOne: getOne$6 } = ServiceFactory.build({
|
|
|
13791
14013
|
basePath: `${URL$e}/kos/config/`
|
|
13792
14014
|
});
|
|
13793
14015
|
const modifyConfigBean = async (id, model, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13794
|
-
log$
|
|
14016
|
+
log$s.debug(`sending modify request for ConfigBean: ${id}`);
|
|
13795
14017
|
const response = postModel$5({
|
|
13796
14018
|
model,
|
|
13797
14019
|
urlOverride: `${URL$e}${path}/${id}`,
|
|
@@ -13800,7 +14022,7 @@ const modifyConfigBean = async (id, model, path = `/api/kos/config`, destination
|
|
|
13800
14022
|
return response;
|
|
13801
14023
|
};
|
|
13802
14024
|
const getConfigBean = async (id, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13803
|
-
log$
|
|
14025
|
+
log$s.debug(`sending get request for ConfigBean: ${id}`);
|
|
13804
14026
|
const response = await getOne$6({
|
|
13805
14027
|
urlOverride: `${URL$e}${path}/details/${id}/15`,
|
|
13806
14028
|
destinationAddress
|
|
@@ -13913,7 +14135,10 @@ function matchValue(patterns, value) {
|
|
|
13913
14135
|
return void 0;
|
|
13914
14136
|
}
|
|
13915
14137
|
const CONFIG_BEAN_MODEL_TYPE = "config-bean-model";
|
|
13916
|
-
const log$
|
|
14138
|
+
const log$r = KosLog.createLogger({
|
|
14139
|
+
group: LogGroup.model,
|
|
14140
|
+
name: CONFIG_BEAN_MODEL_TYPE
|
|
14141
|
+
});
|
|
13917
14142
|
const PATH_PROP$3 = createPropKey("path");
|
|
13918
14143
|
const DESTINATION_PROP$2 = createPropKey("destinationAddress");
|
|
13919
14144
|
function configBeanModelId(path, destinationAddress) {
|
|
@@ -13986,8 +14211,8 @@ let ConfigBeanModelImpl = class {
|
|
|
13986
14211
|
* @internal
|
|
13987
14212
|
*/
|
|
13988
14213
|
async ready() {
|
|
13989
|
-
log$
|
|
13990
|
-
log$
|
|
14214
|
+
log$r.debug(`readying config bean ${this.path}`);
|
|
14215
|
+
log$r.debug(`complete readying config bean ${this.path}`);
|
|
13991
14216
|
}
|
|
13992
14217
|
/**
|
|
13993
14218
|
* @internal
|
|
@@ -13996,7 +14221,7 @@ let ConfigBeanModelImpl = class {
|
|
|
13996
14221
|
* Fetches the bean's values and schema.
|
|
13997
14222
|
*/
|
|
13998
14223
|
async load() {
|
|
13999
|
-
log$
|
|
14224
|
+
log$r.debug(`loading config bean ${this.path}`);
|
|
14000
14225
|
await this.fetchBean();
|
|
14001
14226
|
}
|
|
14002
14227
|
/**
|
|
@@ -14007,7 +14232,7 @@ let ConfigBeanModelImpl = class {
|
|
|
14007
14232
|
* KOS Core reload after a reconnect leaves the same instance current.
|
|
14008
14233
|
*/
|
|
14009
14234
|
async reload() {
|
|
14010
|
-
log$
|
|
14235
|
+
log$r.debug(`reloading config bean ${this.path}`);
|
|
14011
14236
|
await this.fetchBean();
|
|
14012
14237
|
}
|
|
14013
14238
|
async fetchBean() {
|
|
@@ -14019,7 +14244,7 @@ let ConfigBeanModelImpl = class {
|
|
|
14019
14244
|
if (response?.data) {
|
|
14020
14245
|
const data = response.data;
|
|
14021
14246
|
mapDtoToConfigBeanModel(data, this);
|
|
14022
|
-
log$
|
|
14247
|
+
log$r.debug(this.values);
|
|
14023
14248
|
const schemaResponse = response?.data.details[0].schema;
|
|
14024
14249
|
kosAction(() => {
|
|
14025
14250
|
if (schemaResponse) {
|
|
@@ -14264,7 +14489,10 @@ var __decorateClass$u = (decorators, target, key, kind) => {
|
|
|
14264
14489
|
return result;
|
|
14265
14490
|
};
|
|
14266
14491
|
const MODEL_TYPE$r = "region-info-model";
|
|
14267
|
-
const log$
|
|
14492
|
+
const log$q = KosLog.createLogger({
|
|
14493
|
+
group: LogGroup.model,
|
|
14494
|
+
name: "region-info-model"
|
|
14495
|
+
});
|
|
14268
14496
|
function servicePathMapper(regionInfoModel) {
|
|
14269
14497
|
const hasMapper = ExtensionManager.propertyMapper.hasMapper(
|
|
14270
14498
|
KosCoreModelPropertyMapper.RegionServicePath
|
|
@@ -14577,7 +14805,7 @@ let RegionInfoModelImpl = class {
|
|
|
14577
14805
|
}
|
|
14578
14806
|
toUnit = measureSystems[to.system]?.["default"];
|
|
14579
14807
|
if (!toUnit) {
|
|
14580
|
-
log$
|
|
14808
|
+
log$q.info("Could not find default unit for measure", to.measure);
|
|
14581
14809
|
}
|
|
14582
14810
|
}
|
|
14583
14811
|
if (!fromUnit && from.measure && from.system) {
|
|
@@ -14591,11 +14819,11 @@ let RegionInfoModelImpl = class {
|
|
|
14591
14819
|
}
|
|
14592
14820
|
fromUnit = measureSystems[from.system]?.["default"];
|
|
14593
14821
|
if (!fromUnit) {
|
|
14594
|
-
log$
|
|
14822
|
+
log$q.info("Could not find default unit for measure", from.measure);
|
|
14595
14823
|
}
|
|
14596
14824
|
}
|
|
14597
14825
|
if (!fromUnit || !toUnit) {
|
|
14598
|
-
log$
|
|
14826
|
+
log$q.warn("Could not find unit to convert to or from. Return value as is");
|
|
14599
14827
|
return String(value);
|
|
14600
14828
|
}
|
|
14601
14829
|
return this.convertByUnit(value, fromUnit, toUnit);
|
|
@@ -14605,13 +14833,13 @@ let RegionInfoModelImpl = class {
|
|
|
14605
14833
|
* @internal
|
|
14606
14834
|
*/
|
|
14607
14835
|
async init() {
|
|
14608
|
-
log$
|
|
14836
|
+
log$q.debug("initializing region info");
|
|
14609
14837
|
}
|
|
14610
14838
|
/**
|
|
14611
14839
|
* @internal
|
|
14612
14840
|
*/
|
|
14613
14841
|
async load() {
|
|
14614
|
-
log$
|
|
14842
|
+
log$q.debug("loading region info");
|
|
14615
14843
|
const regions = await getRegions(
|
|
14616
14844
|
this.serviceBasePath,
|
|
14617
14845
|
this.destinationAddress
|
|
@@ -14948,7 +15176,10 @@ function secondsToFormattedTime(secondsSinceMidnight, formatString) {
|
|
|
14948
15176
|
return dateFns.format(time, formatString);
|
|
14949
15177
|
}
|
|
14950
15178
|
const MODEL_TYPE$q = "config-bean-prop-model";
|
|
14951
|
-
const log$
|
|
15179
|
+
const log$p = KosLog.createLogger({
|
|
15180
|
+
group: LogGroup.model,
|
|
15181
|
+
name: "config-bean-prop-model"
|
|
15182
|
+
});
|
|
14952
15183
|
const PATH_PROP$2 = createPropKey("path");
|
|
14953
15184
|
const SERVICE_PATH_PROP = createPropKey("serviceBasePath");
|
|
14954
15185
|
const DESTINATION_PROP = createPropKey("destinationAddress");
|
|
@@ -15135,7 +15366,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15135
15366
|
return Number(result2);
|
|
15136
15367
|
}
|
|
15137
15368
|
} catch (e) {
|
|
15138
|
-
log$
|
|
15369
|
+
log$p.info(`error formatting value ${_val}`, e);
|
|
15139
15370
|
}
|
|
15140
15371
|
const result = Number(_val).toFixed(decimals);
|
|
15141
15372
|
return result;
|
|
@@ -15167,7 +15398,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15167
15398
|
* @internal
|
|
15168
15399
|
*/
|
|
15169
15400
|
async activate() {
|
|
15170
|
-
log$
|
|
15401
|
+
log$p.debug(`activating config bean ${this.id}`);
|
|
15171
15402
|
}
|
|
15172
15403
|
/**
|
|
15173
15404
|
* The value formatted with its unit for the active locale, such as `"72.5 °F"`.
|
|
@@ -15194,7 +15425,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15194
15425
|
return result;
|
|
15195
15426
|
}
|
|
15196
15427
|
} catch (e) {
|
|
15197
|
-
log$
|
|
15428
|
+
log$p.error(`error formatting value ${_val}`, e);
|
|
15198
15429
|
}
|
|
15199
15430
|
}
|
|
15200
15431
|
return String(_val);
|
|
@@ -15286,13 +15517,13 @@ let KosConfigPropertyImpl = class {
|
|
|
15286
15517
|
try {
|
|
15287
15518
|
formatter = new Intl.NumberFormat(locale, { ...formatOptions });
|
|
15288
15519
|
} catch (e) {
|
|
15289
|
-
log$
|
|
15520
|
+
log$p.error(
|
|
15290
15521
|
`error creating formatter ${formatOptions}. Returning the raw value`,
|
|
15291
15522
|
e
|
|
15292
15523
|
);
|
|
15293
15524
|
}
|
|
15294
15525
|
} else {
|
|
15295
|
-
log$
|
|
15526
|
+
log$p.debug(
|
|
15296
15527
|
`no formatter found for config bean prop ${this.id}. Returning the raw value`
|
|
15297
15528
|
);
|
|
15298
15529
|
}
|
|
@@ -15353,7 +15584,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15353
15584
|
* @param value - The new value in display units
|
|
15354
15585
|
*/
|
|
15355
15586
|
async updateProperty(value) {
|
|
15356
|
-
log$
|
|
15587
|
+
log$p.debug(`updating property ${this.attribute} with value ${value}`);
|
|
15357
15588
|
let _value = value;
|
|
15358
15589
|
const converter = this.getConverter();
|
|
15359
15590
|
if (converter && !isNaN(_value)) {
|
|
@@ -15397,6 +15628,10 @@ const Registration = {
|
|
|
15397
15628
|
MODEL_TYPE$q
|
|
15398
15629
|
)
|
|
15399
15630
|
};
|
|
15631
|
+
const log$o = KosLog.createLogger({
|
|
15632
|
+
group: LogGroup.model,
|
|
15633
|
+
name: "future-model-builder"
|
|
15634
|
+
});
|
|
15400
15635
|
const mapDtoToFutureOptions = (dto) => {
|
|
15401
15636
|
const options = {
|
|
15402
15637
|
id: String(dto.id),
|
|
@@ -15412,10 +15647,10 @@ const mapDtoToFutureOptions = (dto) => {
|
|
|
15412
15647
|
return options;
|
|
15413
15648
|
};
|
|
15414
15649
|
const mapDtoToFutureModel = (dto, model) => {
|
|
15415
|
-
|
|
15416
|
-
|
|
15650
|
+
log$o.debug(`future dto ${dto.id} end state ${dto.endState}`);
|
|
15651
|
+
log$o.debug(`future model ${model.id} end state ${model.endState}`);
|
|
15417
15652
|
if (!model.endState) {
|
|
15418
|
-
|
|
15653
|
+
log$o.debug(`updating future model ${model.id}`);
|
|
15419
15654
|
mobx.runInAction(() => {
|
|
15420
15655
|
const options = mapDtoToFutureOptions(dto);
|
|
15421
15656
|
kosAction(() => {
|
|
@@ -15434,7 +15669,7 @@ const mapDtoToFutureModel = (dto, model) => {
|
|
|
15434
15669
|
});
|
|
15435
15670
|
});
|
|
15436
15671
|
} else {
|
|
15437
|
-
|
|
15672
|
+
log$o.debug(`future model ${model.id} is already complete`);
|
|
15438
15673
|
}
|
|
15439
15674
|
};
|
|
15440
15675
|
const buildFutureModel$1 = (factory) => (modelId) => (futureOptions) => {
|
|
@@ -15445,7 +15680,10 @@ const buildFuture = (factory) => (future) => pipe(
|
|
|
15445
15680
|
mapDtoToFutureOptions,
|
|
15446
15681
|
buildFutureModel$1(factory)(future.tracker || future.id)
|
|
15447
15682
|
)(future);
|
|
15448
|
-
const log$
|
|
15683
|
+
const log$n = KosLog.createLogger({
|
|
15684
|
+
group: LogGroup.service,
|
|
15685
|
+
name: "future-service"
|
|
15686
|
+
});
|
|
15449
15687
|
const { isMock, URL: URL$c } = resolveServiceUrl();
|
|
15450
15688
|
var FutureEndState = /* @__PURE__ */ ((FutureEndState2) => {
|
|
15451
15689
|
FutureEndState2["Success"] = "SUCCESS";
|
|
@@ -15464,7 +15702,7 @@ const getFutures = async () => {
|
|
|
15464
15702
|
return response;
|
|
15465
15703
|
};
|
|
15466
15704
|
const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
15467
|
-
log$
|
|
15705
|
+
log$n.info(`sending delete request for Future: ${id}`);
|
|
15468
15706
|
const response = await deleteModel$1({
|
|
15469
15707
|
id,
|
|
15470
15708
|
urlOverride: `${URL$c}${path}/${id}`
|
|
@@ -15472,7 +15710,7 @@ const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
|
15472
15710
|
return response;
|
|
15473
15711
|
};
|
|
15474
15712
|
const addFuture = async (future, path = "/api/kos/future") => {
|
|
15475
|
-
log$
|
|
15713
|
+
log$n.info(`sending add request for Future`);
|
|
15476
15714
|
const response = await addModel({
|
|
15477
15715
|
model: future,
|
|
15478
15716
|
urlOverride: `${URL$c}${path}`
|
|
@@ -15480,7 +15718,7 @@ const addFuture = async (future, path = "/api/kos/future") => {
|
|
|
15480
15718
|
return response;
|
|
15481
15719
|
};
|
|
15482
15720
|
const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
15483
|
-
log$
|
|
15721
|
+
log$n.info(`sending modify request for Future: ${id}`);
|
|
15484
15722
|
const response = modifyModel({
|
|
15485
15723
|
model,
|
|
15486
15724
|
id,
|
|
@@ -15489,7 +15727,7 @@ const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
|
15489
15727
|
return response;
|
|
15490
15728
|
};
|
|
15491
15729
|
const cancelFuture = async (id, path = "/api/kos/future") => {
|
|
15492
|
-
log$
|
|
15730
|
+
log$n.info(`sending cancel request for Future: ${id}`);
|
|
15493
15731
|
const response = postModel$4({
|
|
15494
15732
|
urlOverride: `${URL$c}${path}/${id}/cancel`,
|
|
15495
15733
|
ordered: true,
|
|
@@ -15529,6 +15767,10 @@ const FutureManager = {
|
|
|
15529
15767
|
initiateFuture,
|
|
15530
15768
|
getFuture
|
|
15531
15769
|
};
|
|
15770
|
+
const log$m = KosLog.createLogger({
|
|
15771
|
+
group: LogGroup.model,
|
|
15772
|
+
name: "future-service"
|
|
15773
|
+
});
|
|
15532
15774
|
const isFutureResponse = (response) => !response || !response.data;
|
|
15533
15775
|
const resolveFutureHandler = (model) => {
|
|
15534
15776
|
const handlerProperty = model?.[MultipleFutureContainerSetup]?.handlerProperty ?? model?.[FutureContainerSetup]?.handlerProperty ?? "futureHandler";
|
|
@@ -15543,9 +15785,7 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15543
15785
|
} = props;
|
|
15544
15786
|
return async function(...args) {
|
|
15545
15787
|
const tracker = uuid();
|
|
15546
|
-
|
|
15547
|
-
`Calling future service ${methodName} with tracker ${tracker}`
|
|
15548
|
-
);
|
|
15788
|
+
log$m.debug(`Calling future service ${methodName} with tracker ${tracker}`);
|
|
15549
15789
|
let abortControllerInstance;
|
|
15550
15790
|
let effectDisposer;
|
|
15551
15791
|
if (abortController) {
|
|
@@ -15558,17 +15798,17 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15558
15798
|
if (namespace) {
|
|
15559
15799
|
future.namespace = namespace;
|
|
15560
15800
|
}
|
|
15561
|
-
|
|
15801
|
+
log$m.debug(`waiting for future ${future.id} to be ready`);
|
|
15562
15802
|
await whenReady(future);
|
|
15563
|
-
|
|
15803
|
+
log$m.debug(`future ${future.id} is ready`);
|
|
15564
15804
|
kosAction(() => {
|
|
15565
|
-
|
|
15805
|
+
log$m.debug(`Adding future ${future.id} to futureHandler`);
|
|
15566
15806
|
resolveFutureHandler(this).addFuture(future, alias);
|
|
15567
15807
|
});
|
|
15568
15808
|
if (abortController && abortControllerInstance) {
|
|
15569
15809
|
effectDisposer = kosAutoEffect(() => {
|
|
15570
15810
|
if (future.status === "CANCELLED" || future.endState === FutureEndState.Canceled) {
|
|
15571
|
-
|
|
15811
|
+
log$m.debug(`Future ${future.id} cancelled, aborting request`);
|
|
15572
15812
|
abortControllerInstance?.abort();
|
|
15573
15813
|
}
|
|
15574
15814
|
});
|
|
@@ -15576,13 +15816,13 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15576
15816
|
"abort",
|
|
15577
15817
|
async () => {
|
|
15578
15818
|
if (future.status !== "CANCELLED" && future.endState !== FutureEndState.Canceled && !future.endState) {
|
|
15579
|
-
|
|
15819
|
+
log$m.debug(
|
|
15580
15820
|
`AbortController aborted, cancelling future ${future.id}`
|
|
15581
15821
|
);
|
|
15582
15822
|
try {
|
|
15583
15823
|
await future.cancelFuture();
|
|
15584
15824
|
} catch (error) {
|
|
15585
|
-
|
|
15825
|
+
log$m.error(`Failed to cancel future ${future.id}:`, error);
|
|
15586
15826
|
}
|
|
15587
15827
|
}
|
|
15588
15828
|
},
|
|
@@ -15623,15 +15863,15 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15623
15863
|
// eslint-disable-next-line no-invalid-this
|
|
15624
15864
|
await original.apply(this, enhancedArgs)
|
|
15625
15865
|
);
|
|
15626
|
-
|
|
15866
|
+
log$m.debug(`received future response for ${tracker}`, futureResponse);
|
|
15627
15867
|
const response = isFutureResponse(futureResponse) ? futureResponse : futureResponse?.data;
|
|
15628
15868
|
if (response) {
|
|
15629
15869
|
response.progress = 1;
|
|
15630
|
-
|
|
15870
|
+
log$m.debug(`mapping future response to future model`);
|
|
15631
15871
|
if (!future.endState) {
|
|
15632
15872
|
mapDtoToFutureModel(response, future);
|
|
15633
15873
|
} else {
|
|
15634
|
-
|
|
15874
|
+
log$m.debug(
|
|
15635
15875
|
`future ${future.id} has already completed. Not updating the model`
|
|
15636
15876
|
);
|
|
15637
15877
|
}
|
|
@@ -15644,10 +15884,10 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15644
15884
|
cleanup();
|
|
15645
15885
|
if (abortController && abortControllerInstance?.signal.aborted) {
|
|
15646
15886
|
const cancelledError = new Error("Operation cancelled");
|
|
15647
|
-
|
|
15887
|
+
log$m.debug(`Operation ${methodName} was cancelled`);
|
|
15648
15888
|
throw cancelledError;
|
|
15649
15889
|
}
|
|
15650
|
-
|
|
15890
|
+
log$m.error(e);
|
|
15651
15891
|
throw e;
|
|
15652
15892
|
}
|
|
15653
15893
|
};
|
|
@@ -15676,12 +15916,12 @@ const { URL: URL$b } = resolveServiceUrl();
|
|
|
15676
15916
|
const { getOne: getOne$4 } = ServiceFactory.build({
|
|
15677
15917
|
basePath: `${URL$b}/api/kos/state`
|
|
15678
15918
|
});
|
|
15679
|
-
const log$
|
|
15680
|
-
|
|
15681
|
-
|
|
15919
|
+
const log$l = KosLog.createLogger({
|
|
15920
|
+
group: LogGroup.service,
|
|
15921
|
+
name: "state-bean-service"
|
|
15682
15922
|
});
|
|
15683
15923
|
const getStateBeanData = async ({ path }) => {
|
|
15684
|
-
log$
|
|
15924
|
+
log$l.debug("sending GET for state-bean");
|
|
15685
15925
|
const response = await getOne$4({
|
|
15686
15926
|
urlOverride: `${URL$b}/api/kos/state/${path}`
|
|
15687
15927
|
});
|
|
@@ -15859,12 +16099,12 @@ const { URL: URL$a } = resolveServiceUrl();
|
|
|
15859
16099
|
const { getAll: getAll$5 } = ServiceFactory.build({
|
|
15860
16100
|
basePath: `${URL$a}/api/state-prop`
|
|
15861
16101
|
});
|
|
15862
|
-
const log$
|
|
15863
|
-
|
|
15864
|
-
|
|
16102
|
+
const log$k = KosLog.createLogger({
|
|
16103
|
+
group: LogGroup.service,
|
|
16104
|
+
name: "state-prop-service"
|
|
15865
16105
|
});
|
|
15866
16106
|
const getStateProps = async () => {
|
|
15867
|
-
log$
|
|
16107
|
+
log$k.debug("sending GET for state-prop");
|
|
15868
16108
|
const response = await getAll$5({});
|
|
15869
16109
|
return response;
|
|
15870
16110
|
};
|
|
@@ -16006,7 +16246,10 @@ var __decorateClass$p = (decorators, target, key, kind) => {
|
|
|
16006
16246
|
if (kind && result) __defProp$l(target, key, result);
|
|
16007
16247
|
return result;
|
|
16008
16248
|
};
|
|
16009
|
-
const log$
|
|
16249
|
+
const log$j = KosLog.createLogger({
|
|
16250
|
+
group: LogGroup.model,
|
|
16251
|
+
name: FutureFactory.type
|
|
16252
|
+
});
|
|
16010
16253
|
let FutureModel$1 = class FutureModel {
|
|
16011
16254
|
logger;
|
|
16012
16255
|
_cancelFuture;
|
|
@@ -16030,7 +16273,7 @@ let FutureModel$1 = class FutureModel {
|
|
|
16030
16273
|
kosWhen(
|
|
16031
16274
|
() => this.status === FutureEndState.Success || this.status === FutureEndState.Fail,
|
|
16032
16275
|
() => {
|
|
16033
|
-
log$
|
|
16276
|
+
log$j.info(`Future ${this.id} has completed with status ${this.status}`);
|
|
16034
16277
|
destroyKosModel(this);
|
|
16035
16278
|
}
|
|
16036
16279
|
);
|
|
@@ -16044,13 +16287,13 @@ let FutureModel$1 = class FutureModel {
|
|
|
16044
16287
|
* In future additional information about the workspace could be loaded
|
|
16045
16288
|
*/
|
|
16046
16289
|
async load() {
|
|
16047
|
-
log$
|
|
16290
|
+
log$j.debug(`loading Future ${this.id}`);
|
|
16048
16291
|
}
|
|
16049
16292
|
/**
|
|
16050
16293
|
* @internal
|
|
16051
16294
|
*/
|
|
16052
16295
|
unload() {
|
|
16053
|
-
log$
|
|
16296
|
+
log$j.info(`unloading Future ${this.id}`);
|
|
16054
16297
|
}
|
|
16055
16298
|
// -------------------ACTIONS----------------------------
|
|
16056
16299
|
/**
|
|
@@ -16069,7 +16312,7 @@ let FutureModel$1 = class FutureModel {
|
|
|
16069
16312
|
await kosWhen(() => this.futureId !== FUTURE_NOT_ASSIGNED);
|
|
16070
16313
|
const response = await this._cancelFuture(this.futureId, path);
|
|
16071
16314
|
if (response?.status !== 200) {
|
|
16072
|
-
log$
|
|
16315
|
+
log$j.error(
|
|
16073
16316
|
`Failed to cancel Future ${this.id}. Response: ${JSON.stringify(
|
|
16074
16317
|
response
|
|
16075
16318
|
)}`
|
|
@@ -16138,7 +16381,10 @@ var __decorateClass$o = (decorators, target, key, kind) => {
|
|
|
16138
16381
|
if (kind && result) __defProp$k(target, key, result);
|
|
16139
16382
|
return result;
|
|
16140
16383
|
};
|
|
16141
|
-
const log$
|
|
16384
|
+
const log$i = KosLog.createLogger({
|
|
16385
|
+
group: LogGroup.model,
|
|
16386
|
+
name: FutureContainerFactory.type
|
|
16387
|
+
});
|
|
16142
16388
|
let FutureContainerModel$1 = class FutureContainerModel {
|
|
16143
16389
|
id;
|
|
16144
16390
|
logger;
|
|
@@ -16253,8 +16499,8 @@ let FutureContainerModel$1 = class FutureContainerModel {
|
|
|
16253
16499
|
try {
|
|
16254
16500
|
await this._deleteFuture(id);
|
|
16255
16501
|
} catch (e) {
|
|
16256
|
-
log$
|
|
16257
|
-
log$
|
|
16502
|
+
log$i.error(`error deleting a Future`);
|
|
16503
|
+
log$i.error(e);
|
|
16258
16504
|
}
|
|
16259
16505
|
}
|
|
16260
16506
|
/**
|
|
@@ -16281,8 +16527,8 @@ let FutureContainerModel$1 = class FutureContainerModel {
|
|
|
16281
16527
|
return model2;
|
|
16282
16528
|
}
|
|
16283
16529
|
} catch (e) {
|
|
16284
|
-
log$
|
|
16285
|
-
log$
|
|
16530
|
+
log$i.error(`error creating a Future`);
|
|
16531
|
+
log$i.error(e);
|
|
16286
16532
|
throw e;
|
|
16287
16533
|
}
|
|
16288
16534
|
return void 0;
|
|
@@ -16311,9 +16557,9 @@ const { URL: URL$9 } = resolveServiceUrl();
|
|
|
16311
16557
|
const { getOne: getOne$3, postModel: postModel$3, deleteModel } = ServiceFactory.build({
|
|
16312
16558
|
basePath: `${URL$9}/api/keyVal`
|
|
16313
16559
|
});
|
|
16314
|
-
const log$
|
|
16315
|
-
|
|
16316
|
-
|
|
16560
|
+
const log$h = KosLog.createLogger({
|
|
16561
|
+
group: LogGroup.service,
|
|
16562
|
+
name: "key-value-service"
|
|
16317
16563
|
});
|
|
16318
16564
|
const deleteKeyValue = async (namespace, key) => {
|
|
16319
16565
|
await deleteModel({
|
|
@@ -16327,7 +16573,7 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16327
16573
|
model: value.toString()
|
|
16328
16574
|
});
|
|
16329
16575
|
if (response?.status !== 200) {
|
|
16330
|
-
log$
|
|
16576
|
+
log$h.error("Failed to update key-value data", response);
|
|
16331
16577
|
throw new Error(
|
|
16332
16578
|
`Failed to update key-value data for namespace ${namespace}`
|
|
16333
16579
|
);
|
|
@@ -16335,12 +16581,12 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16335
16581
|
return response.data;
|
|
16336
16582
|
};
|
|
16337
16583
|
const getKeyValue = async (namespace = "studio") => {
|
|
16338
|
-
log$
|
|
16584
|
+
log$h.debug(`Retrieving all key-value data for namespace: ${namespace}`);
|
|
16339
16585
|
const response = await getOne$3({
|
|
16340
16586
|
urlOverride: `${URL$9}/api/keyVal/${namespace}`
|
|
16341
16587
|
});
|
|
16342
16588
|
if (response?.status !== 200) {
|
|
16343
|
-
log$
|
|
16589
|
+
log$h.error("Failed to retrieve key-value data", response);
|
|
16344
16590
|
throw new Error(
|
|
16345
16591
|
`Failed to retrieve key-value data for namespace ${namespace}`
|
|
16346
16592
|
);
|
|
@@ -18416,39 +18662,43 @@ KosExpressionEvaluatorModelImpl = __decorateClass$m([
|
|
|
18416
18662
|
kosModel({ modelTypeId: MODEL_TYPE$l, singleton: false })
|
|
18417
18663
|
], KosExpressionEvaluatorModelImpl);
|
|
18418
18664
|
const KosExpressionEvaluator = KosExpressionEvaluatorModelImpl.Registration;
|
|
18665
|
+
const log$g = KosLog.createLogger({
|
|
18666
|
+
group: LogGroup.transport,
|
|
18667
|
+
name: "get-kos-connection-id"
|
|
18668
|
+
});
|
|
18419
18669
|
const getKosConnectionId = () => {
|
|
18420
18670
|
const params2 = getQueryParams();
|
|
18421
18671
|
const connId = params2?.connId;
|
|
18422
18672
|
const result = connId || window?.kosBridge?.("connId");
|
|
18423
|
-
|
|
18673
|
+
log$g.debug(`getKosConnectionId: ${result}`);
|
|
18424
18674
|
return result;
|
|
18425
18675
|
};
|
|
18426
|
-
const log$
|
|
18427
|
-
|
|
18428
|
-
|
|
18676
|
+
const log$f = KosLog.createLogger({
|
|
18677
|
+
group: LogGroup.service,
|
|
18678
|
+
name: "kos-log-manager-service"
|
|
18429
18679
|
});
|
|
18430
18680
|
const SERVICE_PATH$1 = "/api/kos/logs/overrides";
|
|
18431
18681
|
const GROUPS_PATH = "/api/kos/logs/groups";
|
|
18432
18682
|
const getLogOverrides = async () => {
|
|
18433
|
-
log$
|
|
18683
|
+
log$f.debug("sending GET for kos-log-manager");
|
|
18434
18684
|
return await api$1.get(SERVICE_PATH$1, void 0, {
|
|
18435
18685
|
destinationAddress: getKosConnectionId()
|
|
18436
18686
|
});
|
|
18437
18687
|
};
|
|
18438
18688
|
const getLogGroups = async () => {
|
|
18439
|
-
log$
|
|
18689
|
+
log$f.debug("sending GET for log groups");
|
|
18440
18690
|
return await api$1.get(GROUPS_PATH, void 0, {
|
|
18441
18691
|
destinationAddress: getKosConnectionId()
|
|
18442
18692
|
});
|
|
18443
18693
|
};
|
|
18444
18694
|
const addLogOverride = async (override) => {
|
|
18445
|
-
log$
|
|
18695
|
+
log$f.debug(`sending POST for log override ${override.name}`);
|
|
18446
18696
|
return await api$1.post(SERVICE_PATH$1, void 0, override, {
|
|
18447
18697
|
destinationAddress: getKosConnectionId()
|
|
18448
18698
|
});
|
|
18449
18699
|
};
|
|
18450
18700
|
const removeLogOverride = async (override) => {
|
|
18451
|
-
log$
|
|
18701
|
+
log$f.debug(`sending DELETE for log override ${override.name}`);
|
|
18452
18702
|
return await api$1.delete(SERVICE_PATH$1, void 0, override, {
|
|
18453
18703
|
destinationAddress: getKosConnectionId()
|
|
18454
18704
|
});
|
|
@@ -18926,14 +19176,14 @@ __decorateClass$j([
|
|
|
18926
19176
|
LogBlockContainerModelImpl = __decorateClass$j([
|
|
18927
19177
|
kosModel(MODEL_TYPE$i)
|
|
18928
19178
|
], LogBlockContainerModelImpl);
|
|
18929
|
-
const log$
|
|
18930
|
-
|
|
18931
|
-
|
|
19179
|
+
const log$e = KosLog.createLogger({
|
|
19180
|
+
group: LogGroup.service,
|
|
19181
|
+
name: "log-stream-container-service"
|
|
18932
19182
|
});
|
|
18933
19183
|
const SERVICE_PATH = "/api/kos/logs/node/{nodeId}/streams";
|
|
18934
19184
|
const getLogStreams = async () => {
|
|
18935
19185
|
const destinationAddress = getKosConnectionId();
|
|
18936
|
-
log$
|
|
19186
|
+
log$e.debug("sending GET for log-stream-container");
|
|
18937
19187
|
return await api$1.get(
|
|
18938
19188
|
SERVICE_PATH,
|
|
18939
19189
|
{
|
|
@@ -19505,11 +19755,14 @@ const { URL: URL$7 } = resolveServiceUrl();
|
|
|
19505
19755
|
const { getAll: getAll$4, postModel: postModel$1 } = ServiceFactory.build({
|
|
19506
19756
|
basePath: `${URL$7}/api/kos/troubles`
|
|
19507
19757
|
});
|
|
19508
|
-
const log$
|
|
19758
|
+
const log$d = KosLog.createLogger({
|
|
19759
|
+
group: LogGroup.service,
|
|
19760
|
+
name: "trouble-services"
|
|
19761
|
+
});
|
|
19509
19762
|
const getTroubles = async (servicePath) => {
|
|
19510
19763
|
const isKosTroubles = servicePath.includes("/kos/troubles");
|
|
19511
19764
|
const destinationAddress = getKosConnectionId();
|
|
19512
|
-
log$
|
|
19765
|
+
log$d.info(
|
|
19513
19766
|
`Fetching troubles from ${servicePath} with destination address: ${isKosTroubles ? destinationAddress : "N/A (not a kos troubles path)"}`
|
|
19514
19767
|
);
|
|
19515
19768
|
const response = await getAll$4({
|
|
@@ -19591,6 +19844,10 @@ const defaultTroubleRoleMapper = (trouble) => {
|
|
|
19591
19844
|
}
|
|
19592
19845
|
return "TECHNICIAN";
|
|
19593
19846
|
};
|
|
19847
|
+
const log$c = KosLog.createLogger({
|
|
19848
|
+
group: LogGroup.model,
|
|
19849
|
+
name: "trouble-data-extension"
|
|
19850
|
+
});
|
|
19594
19851
|
const EXTENSION_TROUBLE_DATA_MAPPER = "troubleDataMapper";
|
|
19595
19852
|
const troubleMappers$1 = /* @__PURE__ */ new Map();
|
|
19596
19853
|
registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
@@ -19614,7 +19871,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19614
19871
|
if (r.status === "fulfilled") {
|
|
19615
19872
|
acc = { ...acc, ...r.value };
|
|
19616
19873
|
} else {
|
|
19617
|
-
|
|
19874
|
+
log$c.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19618
19875
|
}
|
|
19619
19876
|
return acc;
|
|
19620
19877
|
},
|
|
@@ -19623,6 +19880,10 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19623
19880
|
return data;
|
|
19624
19881
|
}
|
|
19625
19882
|
});
|
|
19883
|
+
const log$b = KosLog.createLogger({
|
|
19884
|
+
group: LogGroup.model,
|
|
19885
|
+
name: "trouble-extension"
|
|
19886
|
+
});
|
|
19626
19887
|
const EXTENSION_TROUBLE_MAPPER = "troubleMapper";
|
|
19627
19888
|
const troubleMappers = /* @__PURE__ */ new Map();
|
|
19628
19889
|
registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
@@ -19643,7 +19904,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
|
19643
19904
|
if (r.status === "fulfilled") {
|
|
19644
19905
|
return r.value;
|
|
19645
19906
|
} else {
|
|
19646
|
-
|
|
19907
|
+
log$b.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19647
19908
|
return [];
|
|
19648
19909
|
}
|
|
19649
19910
|
}).flat();
|
|
@@ -20032,16 +20293,16 @@ const { URL: URL$6 } = resolveServiceUrl();
|
|
|
20032
20293
|
const { getAll: getAll$3 } = ServiceFactory.build({
|
|
20033
20294
|
basePath: `${URL$6}/api/kos/ota`
|
|
20034
20295
|
});
|
|
20035
|
-
const log$
|
|
20036
|
-
|
|
20037
|
-
|
|
20296
|
+
const log$a = KosLog.createLogger({
|
|
20297
|
+
group: LogGroup.service,
|
|
20298
|
+
name: "ota-service"
|
|
20038
20299
|
});
|
|
20039
20300
|
const getArtifacts = async () => {
|
|
20040
|
-
log$
|
|
20301
|
+
log$a.debug("sending GET request to /api/kos/ota/artifacts");
|
|
20041
20302
|
const response = await getAll$3({
|
|
20042
20303
|
urlOverride: `${URL$6}/api/kos/ota/artifacts`
|
|
20043
20304
|
});
|
|
20044
|
-
log$
|
|
20305
|
+
log$a.debug("getArtifacts - response:", response);
|
|
20045
20306
|
return response?.data;
|
|
20046
20307
|
};
|
|
20047
20308
|
var __defProp$a = Object.defineProperty;
|
|
@@ -20225,7 +20486,10 @@ const Ota = new SingletonKosModelRegistrationFactory({
|
|
|
20225
20486
|
class: OtaModelImpl,
|
|
20226
20487
|
type: MODEL_TYPE$c
|
|
20227
20488
|
});
|
|
20228
|
-
const log$
|
|
20489
|
+
const log$9 = KosLog.createLogger({
|
|
20490
|
+
group: LogGroup.model,
|
|
20491
|
+
name: "await-future-call"
|
|
20492
|
+
});
|
|
20229
20493
|
class FutureCallError extends Error {
|
|
20230
20494
|
endState;
|
|
20231
20495
|
reason;
|
|
@@ -20276,7 +20540,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20276
20540
|
const watchTracked = (future) => {
|
|
20277
20541
|
tracked = future;
|
|
20278
20542
|
if (cancelRequested) {
|
|
20279
|
-
future.cancelFuture().catch((e) => log$
|
|
20543
|
+
future.cancelFuture().catch((e) => log$9.error(e));
|
|
20280
20544
|
}
|
|
20281
20545
|
disposers.push(
|
|
20282
20546
|
mobx.reaction(
|
|
@@ -20293,7 +20557,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20293
20557
|
try {
|
|
20294
20558
|
cb(progress, status);
|
|
20295
20559
|
} catch (e) {
|
|
20296
|
-
log$
|
|
20560
|
+
log$9.warn("progress callback error", e);
|
|
20297
20561
|
}
|
|
20298
20562
|
});
|
|
20299
20563
|
},
|
|
@@ -20369,6 +20633,189 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20369
20633
|
};
|
|
20370
20634
|
return promise;
|
|
20371
20635
|
}
|
|
20636
|
+
function createCancellablePromise(promiseOrOptions, abortController, cancelFuture2, future) {
|
|
20637
|
+
const options = promiseOrOptions instanceof Promise ? { promise: promiseOrOptions, abortController, cancelFuture: cancelFuture2, future } : promiseOrOptions;
|
|
20638
|
+
const {
|
|
20639
|
+
promise,
|
|
20640
|
+
abortController: controller,
|
|
20641
|
+
cancelFuture: cancelFn,
|
|
20642
|
+
future: futureRef
|
|
20643
|
+
} = options;
|
|
20644
|
+
const cancellablePromise = promise;
|
|
20645
|
+
let currentProgress = 0;
|
|
20646
|
+
let currentStatus = "PENDING";
|
|
20647
|
+
let isRunning = true;
|
|
20648
|
+
const progressCallbacks = /* @__PURE__ */ new Set();
|
|
20649
|
+
let effectDisposer;
|
|
20650
|
+
if (futureRef && typeof futureRef === "object") {
|
|
20651
|
+
effectDisposer = mobx.autorun(() => {
|
|
20652
|
+
const newProgress = futureRef.progress || 0;
|
|
20653
|
+
const newStatus = futureRef.status || "PENDING";
|
|
20654
|
+
const newIsRunning = !futureRef.endState;
|
|
20655
|
+
if (newProgress !== currentProgress || newStatus !== currentStatus || newIsRunning !== isRunning) {
|
|
20656
|
+
currentProgress = newProgress;
|
|
20657
|
+
currentStatus = newStatus;
|
|
20658
|
+
isRunning = newIsRunning;
|
|
20659
|
+
progressCallbacks.forEach((callback) => {
|
|
20660
|
+
try {
|
|
20661
|
+
callback(currentProgress, currentStatus);
|
|
20662
|
+
} catch (error) {
|
|
20663
|
+
console.warn("Progress callback error:", error);
|
|
20664
|
+
}
|
|
20665
|
+
});
|
|
20666
|
+
}
|
|
20667
|
+
});
|
|
20668
|
+
}
|
|
20669
|
+
promise.finally(() => {
|
|
20670
|
+
isRunning = false;
|
|
20671
|
+
if (!controller?.signal.aborted) {
|
|
20672
|
+
currentStatus = "COMPLETED";
|
|
20673
|
+
progressCallbacks.forEach((callback) => {
|
|
20674
|
+
try {
|
|
20675
|
+
callback(currentProgress, currentStatus);
|
|
20676
|
+
} catch (error) {
|
|
20677
|
+
console.warn("Progress callback error:", error);
|
|
20678
|
+
}
|
|
20679
|
+
});
|
|
20680
|
+
}
|
|
20681
|
+
if (effectDisposer) {
|
|
20682
|
+
effectDisposer();
|
|
20683
|
+
}
|
|
20684
|
+
progressCallbacks.clear();
|
|
20685
|
+
});
|
|
20686
|
+
cancellablePromise.cancel = async () => {
|
|
20687
|
+
if (controller && !controller.signal.aborted) {
|
|
20688
|
+
controller.abort();
|
|
20689
|
+
}
|
|
20690
|
+
if (cancelFn) {
|
|
20691
|
+
await cancelFn();
|
|
20692
|
+
}
|
|
20693
|
+
isRunning = false;
|
|
20694
|
+
currentStatus = "CANCELLED";
|
|
20695
|
+
progressCallbacks.forEach((callback) => {
|
|
20696
|
+
try {
|
|
20697
|
+
callback(currentProgress, currentStatus);
|
|
20698
|
+
} catch (error) {
|
|
20699
|
+
console.warn("Progress callback error:", error);
|
|
20700
|
+
}
|
|
20701
|
+
});
|
|
20702
|
+
if (effectDisposer) {
|
|
20703
|
+
effectDisposer();
|
|
20704
|
+
}
|
|
20705
|
+
};
|
|
20706
|
+
cancellablePromise.getController = () => controller;
|
|
20707
|
+
cancellablePromise.isCancelled = () => controller?.signal.aborted ?? false;
|
|
20708
|
+
Object.defineProperty(cancellablePromise, "progress", {
|
|
20709
|
+
get: () => currentProgress,
|
|
20710
|
+
enumerable: true
|
|
20711
|
+
});
|
|
20712
|
+
Object.defineProperty(cancellablePromise, "status", {
|
|
20713
|
+
get: () => currentStatus,
|
|
20714
|
+
enumerable: true
|
|
20715
|
+
});
|
|
20716
|
+
Object.defineProperty(cancellablePromise, "isRunning", {
|
|
20717
|
+
get: () => isRunning,
|
|
20718
|
+
enumerable: true
|
|
20719
|
+
});
|
|
20720
|
+
cancellablePromise.onProgressUpdate = (callback) => {
|
|
20721
|
+
progressCallbacks.add(callback);
|
|
20722
|
+
callback(currentProgress, currentStatus);
|
|
20723
|
+
return () => progressCallbacks.delete(callback);
|
|
20724
|
+
};
|
|
20725
|
+
return cancellablePromise;
|
|
20726
|
+
}
|
|
20727
|
+
const log$8 = KosLog.createLogger({
|
|
20728
|
+
group: LogGroup.model,
|
|
20729
|
+
name: "cancellable-future-call"
|
|
20730
|
+
});
|
|
20731
|
+
function makeCancellable(model, methodCall) {
|
|
20732
|
+
const initialFuture = model.futureHandler.future;
|
|
20733
|
+
const promise = methodCall(model);
|
|
20734
|
+
let newFuture = null;
|
|
20735
|
+
setTimeout(() => {
|
|
20736
|
+
newFuture = model.futureHandler.future;
|
|
20737
|
+
if (newFuture === initialFuture) {
|
|
20738
|
+
newFuture = null;
|
|
20739
|
+
}
|
|
20740
|
+
}, 0);
|
|
20741
|
+
return createCancellablePromise({
|
|
20742
|
+
promise,
|
|
20743
|
+
abortController: void 0,
|
|
20744
|
+
// No direct AbortController access
|
|
20745
|
+
cancelFuture: async () => {
|
|
20746
|
+
if (newFuture) {
|
|
20747
|
+
await newFuture.cancelFuture();
|
|
20748
|
+
} else {
|
|
20749
|
+
const currentFuture = model.futureHandler.future;
|
|
20750
|
+
if (currentFuture) {
|
|
20751
|
+
await currentFuture.cancelFuture();
|
|
20752
|
+
}
|
|
20753
|
+
}
|
|
20754
|
+
},
|
|
20755
|
+
future: newFuture
|
|
20756
|
+
// Pass the future for progress tracking
|
|
20757
|
+
});
|
|
20758
|
+
}
|
|
20759
|
+
function withCancellation(model, methodName, ...args) {
|
|
20760
|
+
const method = model[methodName];
|
|
20761
|
+
if (typeof method !== "function") {
|
|
20762
|
+
throw new Error(`${String(methodName)} is not a method`);
|
|
20763
|
+
}
|
|
20764
|
+
const initialFuture = model.futureHandler.future;
|
|
20765
|
+
const promise = method.apply(model, args);
|
|
20766
|
+
let targetFuture = null;
|
|
20767
|
+
setTimeout(() => {
|
|
20768
|
+
const currentFuture = model.futureHandler.future;
|
|
20769
|
+
if (currentFuture && currentFuture !== initialFuture) {
|
|
20770
|
+
targetFuture = currentFuture;
|
|
20771
|
+
}
|
|
20772
|
+
}, 0);
|
|
20773
|
+
return createCancellablePromise({
|
|
20774
|
+
promise,
|
|
20775
|
+
abortController: void 0,
|
|
20776
|
+
cancelFuture: async () => {
|
|
20777
|
+
if (targetFuture) {
|
|
20778
|
+
await targetFuture.cancelFuture();
|
|
20779
|
+
} else {
|
|
20780
|
+
const fallbackFuture = model.futureHandler.future;
|
|
20781
|
+
if (fallbackFuture) {
|
|
20782
|
+
await fallbackFuture.cancelFuture();
|
|
20783
|
+
}
|
|
20784
|
+
}
|
|
20785
|
+
},
|
|
20786
|
+
future: targetFuture
|
|
20787
|
+
// Pass the future for progress tracking
|
|
20788
|
+
});
|
|
20789
|
+
}
|
|
20790
|
+
class CancellationBatch {
|
|
20791
|
+
operations = [];
|
|
20792
|
+
add(model, methodCall) {
|
|
20793
|
+
const cancellable = makeCancellable(model, methodCall);
|
|
20794
|
+
this.operations.push(cancellable);
|
|
20795
|
+
return cancellable;
|
|
20796
|
+
}
|
|
20797
|
+
async cancelAll() {
|
|
20798
|
+
await Promise.all(
|
|
20799
|
+
this.operations.map(
|
|
20800
|
+
(op) => op.cancel().catch(() => {
|
|
20801
|
+
log$8.warn("Cancellation failed for operation:", op);
|
|
20802
|
+
})
|
|
20803
|
+
)
|
|
20804
|
+
);
|
|
20805
|
+
}
|
|
20806
|
+
getAllControllers() {
|
|
20807
|
+
return this.operations.map((op) => op.getController());
|
|
20808
|
+
}
|
|
20809
|
+
getActiveCount() {
|
|
20810
|
+
return this.operations.filter((op) => !op.isCancelled()).length;
|
|
20811
|
+
}
|
|
20812
|
+
clear() {
|
|
20813
|
+
this.operations = [];
|
|
20814
|
+
}
|
|
20815
|
+
}
|
|
20816
|
+
function createCancellationBatch() {
|
|
20817
|
+
return new CancellationBatch();
|
|
20818
|
+
}
|
|
20372
20819
|
function createCancellableService(serviceFunction) {
|
|
20373
20820
|
let controller;
|
|
20374
20821
|
const wrappedFunction = async (...args) => {
|
|
@@ -22725,9 +23172,12 @@ const { URL: URL$5 } = resolveServiceUrl();
|
|
|
22725
23172
|
const { getOne: getOne$1 } = ServiceFactory.build({
|
|
22726
23173
|
basePath: `${URL$5}/api/device`
|
|
22727
23174
|
});
|
|
22728
|
-
const log$
|
|
23175
|
+
const log$7 = KosLog.createLogger({
|
|
23176
|
+
group: LogGroup.service,
|
|
23177
|
+
name: "device-service"
|
|
23178
|
+
});
|
|
22729
23179
|
const getSerialNumber = async () => {
|
|
22730
|
-
log$
|
|
23180
|
+
log$7.debug("sending GET for device serial number");
|
|
22731
23181
|
try {
|
|
22732
23182
|
const response = await getOne$1({
|
|
22733
23183
|
urlOverride: `${URL$5}/api/kos/device/serialNumber`
|
|
@@ -22735,14 +23185,14 @@ const getSerialNumber = async () => {
|
|
|
22735
23185
|
return [void 0, response?.data.serialNumber];
|
|
22736
23186
|
} catch (error) {
|
|
22737
23187
|
if (error instanceof FetchError) {
|
|
22738
|
-
log$
|
|
23188
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22739
23189
|
return [error.payload.error, void 0];
|
|
22740
23190
|
}
|
|
22741
23191
|
}
|
|
22742
23192
|
return ["unknownError", void 0];
|
|
22743
23193
|
};
|
|
22744
23194
|
const getDeviceDetails = async () => {
|
|
22745
|
-
log$
|
|
23195
|
+
log$7.debug("sending GET for device details");
|
|
22746
23196
|
try {
|
|
22747
23197
|
const response = await getOne$1({
|
|
22748
23198
|
urlOverride: `${URL$5}/api/kos/device`
|
|
@@ -22753,7 +23203,7 @@ const getDeviceDetails = async () => {
|
|
|
22753
23203
|
return [void 0, response.data];
|
|
22754
23204
|
} catch (error) {
|
|
22755
23205
|
if (error instanceof FetchError) {
|
|
22756
|
-
log$
|
|
23206
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22757
23207
|
return [error.payload.error, void 0];
|
|
22758
23208
|
}
|
|
22759
23209
|
}
|
|
@@ -22964,13 +23414,13 @@ const { URL: URL$4 } = resolveServiceUrl();
|
|
|
22964
23414
|
const { getAll: getAll$2 } = ServiceFactory.build({
|
|
22965
23415
|
basePath: `${URL$4}/api/kos/network/interfaces`
|
|
22966
23416
|
});
|
|
22967
|
-
const log$
|
|
22968
|
-
|
|
22969
|
-
|
|
23417
|
+
const log$6 = KosLog.createLogger({
|
|
23418
|
+
group: LogGroup.service,
|
|
23419
|
+
name: "network-interface-service"
|
|
22970
23420
|
});
|
|
22971
23421
|
const getNetworkInterfaces = async () => {
|
|
22972
23422
|
const destinationAddress = getKosConnectionId();
|
|
22973
|
-
log$
|
|
23423
|
+
log$6.debug("sending GET for copy-logs");
|
|
22974
23424
|
try {
|
|
22975
23425
|
const response = await getAll$2({
|
|
22976
23426
|
destinationAddress
|
|
@@ -22978,7 +23428,7 @@ const getNetworkInterfaces = async () => {
|
|
|
22978
23428
|
return [void 0, response?.data];
|
|
22979
23429
|
} catch (error) {
|
|
22980
23430
|
if (error instanceof FetchError) {
|
|
22981
|
-
log$
|
|
23431
|
+
log$6.error(`Error fetching log file size: ${error.payload.error}`);
|
|
22982
23432
|
return [error.payload.error, void 0];
|
|
22983
23433
|
}
|
|
22984
23434
|
}
|
|
@@ -23076,15 +23526,15 @@ const { URL: URL$3 } = resolveServiceUrl();
|
|
|
23076
23526
|
const { getAll: getAll$1 } = ServiceFactory.build({
|
|
23077
23527
|
basePath: `${URL$3}/api/kos/storage/devices`
|
|
23078
23528
|
});
|
|
23079
|
-
const log$
|
|
23080
|
-
|
|
23081
|
-
|
|
23529
|
+
const log$5 = KosLog.createLogger({
|
|
23530
|
+
group: LogGroup.service,
|
|
23531
|
+
name: "storage-device-service"
|
|
23082
23532
|
});
|
|
23083
23533
|
const getStorageDevices = async () => {
|
|
23084
|
-
log$
|
|
23534
|
+
log$5.debug("sending GET for storage-device");
|
|
23085
23535
|
const response = await getAll$1({});
|
|
23086
23536
|
if (!response?.data || response.status !== 200) {
|
|
23087
|
-
log$
|
|
23537
|
+
log$5.error("Failed to retrieve storage-device data", response);
|
|
23088
23538
|
return [];
|
|
23089
23539
|
}
|
|
23090
23540
|
return response.data;
|
|
@@ -23282,17 +23732,17 @@ const { URL: URL$2 } = resolveServiceUrl();
|
|
|
23282
23732
|
const { getAll, postModel } = ServiceFactory.build({
|
|
23283
23733
|
basePath: `${URL$2}/api/kos/update/available`
|
|
23284
23734
|
});
|
|
23285
|
-
const log$
|
|
23286
|
-
|
|
23287
|
-
|
|
23735
|
+
const log$4 = KosLog.createLogger({
|
|
23736
|
+
group: LogGroup.service,
|
|
23737
|
+
name: "usb-update-service"
|
|
23288
23738
|
});
|
|
23289
23739
|
const getAvailableUpdates = async () => {
|
|
23290
|
-
log$
|
|
23740
|
+
log$4.debug("sending GET for usb-update");
|
|
23291
23741
|
const response = await getAll({
|
|
23292
23742
|
urlOverride: `${URL$2}/api/kos/update/available`
|
|
23293
23743
|
});
|
|
23294
23744
|
if (!response?.data || response?.status !== 200) {
|
|
23295
|
-
log$
|
|
23745
|
+
log$4.error("Failed to retrieve usb-update data", response);
|
|
23296
23746
|
return [];
|
|
23297
23747
|
}
|
|
23298
23748
|
return response.data;
|
|
@@ -23533,9 +23983,9 @@ const { URL: URL$1 } = resolveServiceUrl();
|
|
|
23533
23983
|
const { getOne } = ServiceFactory.build({
|
|
23534
23984
|
basePath: `${URL$1}/api/translation`
|
|
23535
23985
|
});
|
|
23536
|
-
const log$
|
|
23537
|
-
|
|
23538
|
-
|
|
23986
|
+
const log$3 = KosLog.createLogger({
|
|
23987
|
+
group: LogGroup.service,
|
|
23988
|
+
name: "translation-service"
|
|
23539
23989
|
});
|
|
23540
23990
|
const getDefaultHost = () => {
|
|
23541
23991
|
const defaultHost = window.location.origin;
|
|
@@ -23545,23 +23995,23 @@ const getDefaultHost = () => {
|
|
|
23545
23995
|
return result;
|
|
23546
23996
|
};
|
|
23547
23997
|
const getTranslations = async (url, root) => {
|
|
23548
|
-
log$
|
|
23998
|
+
log$3.debug(`Loading translations from: ${url}`);
|
|
23549
23999
|
const rootUrl = root ?? getDefaultHost();
|
|
23550
24000
|
try {
|
|
23551
24001
|
const response = await fetch(`${rootUrl}${url}`);
|
|
23552
24002
|
if (response.status !== 200) {
|
|
23553
|
-
log$
|
|
24003
|
+
log$3.warn(`Failed to fetch translations at ${url}: ${response.status}`);
|
|
23554
24004
|
return {};
|
|
23555
24005
|
}
|
|
23556
24006
|
const json = await response.json();
|
|
23557
24007
|
return json;
|
|
23558
24008
|
} catch (error) {
|
|
23559
|
-
log$
|
|
24009
|
+
log$3.error("Error fetching translations", error);
|
|
23560
24010
|
throw error;
|
|
23561
24011
|
}
|
|
23562
24012
|
};
|
|
23563
24013
|
const getLocalizationDescriptor = async () => {
|
|
23564
|
-
log$
|
|
24014
|
+
log$3.debug("Getting system localization descriptor");
|
|
23565
24015
|
const response = await getOne({
|
|
23566
24016
|
urlOverride: `${URL$1}/api/system/kos/localization`
|
|
23567
24017
|
});
|
|
@@ -23573,7 +24023,7 @@ const getLocalizationDescriptor = async () => {
|
|
|
23573
24023
|
return response.data;
|
|
23574
24024
|
};
|
|
23575
24025
|
const getKosLocalizationDescriptor = (context) => async () => {
|
|
23576
|
-
log$
|
|
24026
|
+
log$3.debug(`Getting KOS localization descriptor for context: ${context}`);
|
|
23577
24027
|
const response = await getOne({
|
|
23578
24028
|
urlOverride: `${URL$1}/api/kos/localization/contexts`
|
|
23579
24029
|
});
|
|
@@ -24062,6 +24512,10 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
24062
24512
|
if (kind && result) __defProp(target, key, result);
|
|
24063
24513
|
return result;
|
|
24064
24514
|
};
|
|
24515
|
+
const log$2 = KosLog.createLogger({
|
|
24516
|
+
group: LogGroup.model,
|
|
24517
|
+
name: "ws-event-model"
|
|
24518
|
+
});
|
|
24065
24519
|
const stringify = ({ headers, body }) => {
|
|
24066
24520
|
const headText = Object.entries(headers).map(([key, value]) => `${key}:${value}`).join("\\n");
|
|
24067
24521
|
return headText + "\\n\\n" + body;
|
|
@@ -24085,7 +24539,7 @@ exports.WsEventModel = class WsEventModel {
|
|
|
24085
24539
|
this.processEvent(payload);
|
|
24086
24540
|
}
|
|
24087
24541
|
processEvent(data, isSend = false) {
|
|
24088
|
-
|
|
24542
|
+
log$2.debug("kos event received");
|
|
24089
24543
|
const { body, headers } = data.body;
|
|
24090
24544
|
const isUnique = headers["request-id"] || headers["response-id"];
|
|
24091
24545
|
const msgId = headers["request-id"] || headers["response-id"] || headers["topic"] || headers["type"];
|
|
@@ -24109,7 +24563,7 @@ exports.WsEventModel = class WsEventModel {
|
|
|
24109
24563
|
mocked: !!headers["mocked"]
|
|
24110
24564
|
};
|
|
24111
24565
|
this.events.set(rawKey, rawData);
|
|
24112
|
-
|
|
24566
|
+
log$2.debug(`logged ${this.events.size} events`);
|
|
24113
24567
|
}
|
|
24114
24568
|
}
|
|
24115
24569
|
};
|
|
@@ -24156,9 +24610,9 @@ const Registry = {
|
|
|
24156
24610
|
preloadModels: []
|
|
24157
24611
|
};
|
|
24158
24612
|
const PRELOAD = true;
|
|
24159
|
-
const registerCoreModels = (root) => () => {
|
|
24613
|
+
const registerCoreModels = (root) => ({ preloadLogManager = true } = {}) => {
|
|
24160
24614
|
const coreModels2 = CoreModels;
|
|
24161
|
-
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,
|
|
24615
|
+
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);
|
|
24162
24616
|
Object.keys(coreModels2).forEach((key) => {
|
|
24163
24617
|
const model = coreModels2[key];
|
|
24164
24618
|
registerLegacyModel(KosModelRegistry2)(key, model);
|
|
@@ -24182,7 +24636,10 @@ const KosModelRegistry2 = _KosModelRegistry;
|
|
|
24182
24636
|
const TIMER_EVENT = `/kos-timer-event`;
|
|
24183
24637
|
const TOPIC_TIMER_TICK_EVENT = `/kos-timer-event/tick`;
|
|
24184
24638
|
const TIMER_END = "defaultTimerEnd";
|
|
24185
|
-
const log$1 = KosLog.createLogger({
|
|
24639
|
+
const log$1 = KosLog.createLogger({
|
|
24640
|
+
group: LogGroup.model,
|
|
24641
|
+
name: "timer-manager"
|
|
24642
|
+
});
|
|
24186
24643
|
const isConfigProperty = (value) => value.updateProperty !== void 0;
|
|
24187
24644
|
class KosTimer {
|
|
24188
24645
|
name;
|
|
@@ -24209,7 +24666,7 @@ class KosTimer {
|
|
|
24209
24666
|
this.remainingTime = timeoutValue;
|
|
24210
24667
|
if (isConfigProperty(timeout)) {
|
|
24211
24668
|
kosAutoEffect(() => {
|
|
24212
|
-
|
|
24669
|
+
log$1.info(
|
|
24213
24670
|
`Updating config value timer ${name} with new timeout value ${timeout.value}`
|
|
24214
24671
|
);
|
|
24215
24672
|
const newValue = timeout.value || 60;
|
|
@@ -24447,8 +24904,8 @@ const TimerManager = {
|
|
|
24447
24904
|
}
|
|
24448
24905
|
};
|
|
24449
24906
|
const log = KosLog.createLogger({
|
|
24450
|
-
|
|
24451
|
-
|
|
24907
|
+
group: LogGroup.service,
|
|
24908
|
+
name: "software-info-service"
|
|
24452
24909
|
});
|
|
24453
24910
|
const getSoftwareInfos = async (signal) => {
|
|
24454
24911
|
const destinationAddress = getKosConnectionId();
|
|
@@ -24557,6 +25014,7 @@ exports.AuthState = AuthState;
|
|
|
24557
25014
|
exports.BrowserKosRouter = BrowserKosRouter;
|
|
24558
25015
|
exports.BrowserRouter = BrowserRouter;
|
|
24559
25016
|
exports.CancellableServiceManager = CancellableServiceManager;
|
|
25017
|
+
exports.CancellationBatch = CancellationBatch;
|
|
24560
25018
|
exports.CanvasDispatcher = CanvasDispatcher;
|
|
24561
25019
|
exports.CanvasRenderer = CanvasRenderer;
|
|
24562
25020
|
exports.ChildModels = ChildModels;
|
|
@@ -24651,10 +25109,11 @@ exports.LOGIN_HOST = LOGIN_HOST;
|
|
|
24651
25109
|
exports.LOGIN_URL = LOGIN_URL;
|
|
24652
25110
|
exports.LogBlock = LogBlock;
|
|
24653
25111
|
exports.LogBlockContainer = LogBlockContainer;
|
|
24654
|
-
exports.
|
|
25112
|
+
exports.LogGroup = LogGroup;
|
|
24655
25113
|
exports.LogStream = LogStream;
|
|
24656
25114
|
exports.LogStreamContainer = LogStreamContainer;
|
|
24657
25115
|
exports.LoggerSetup = LoggerSetup;
|
|
25116
|
+
exports.MESSAGE_LOGGER_NAME = MESSAGE_LOGGER_NAME;
|
|
24658
25117
|
exports.MODEL_DELETION_DELAY = MODEL_DELETION_DELAY;
|
|
24659
25118
|
exports.MixinModels = MixinModels;
|
|
24660
25119
|
exports.ModelEffects = ModelEffects;
|
|
@@ -24739,7 +25198,9 @@ exports.convert = convert;
|
|
|
24739
25198
|
exports.convertWithUnits = convertWithUnits;
|
|
24740
25199
|
exports.createBaseMessage = createBaseMessage;
|
|
24741
25200
|
exports.createBroadcastMessageResponse = createBroadcastMessageResponse;
|
|
25201
|
+
exports.createCancellablePromise = createCancellablePromise;
|
|
24742
25202
|
exports.createCancellableService = createCancellableService;
|
|
25203
|
+
exports.createCancellationBatch = createCancellationBatch;
|
|
24743
25204
|
exports.createClient = createClient;
|
|
24744
25205
|
exports.createFosBaseMessage = createFosBaseMessage;
|
|
24745
25206
|
exports.createHeaders = createHeaders;
|
|
@@ -24781,7 +25242,6 @@ exports.getKeyValue = getKeyValue;
|
|
|
24781
25242
|
exports.getKosCompanionModel = getKosCompanionModel;
|
|
24782
25243
|
exports.getKosConnectionId = getKosConnectionId;
|
|
24783
25244
|
exports.getKosLocalizationDescriptor = getKosLocalizationDescriptor;
|
|
24784
|
-
exports.getKosMessageLogging = getKosMessageLogging;
|
|
24785
25245
|
exports.getKosModel = getKosModel$1;
|
|
24786
25246
|
exports.getKosModelActivationState = getKosModelActivationState;
|
|
24787
25247
|
exports.getKosModelSync = getKosModelSync;
|
|
@@ -24790,7 +25250,6 @@ exports.getKosSessionKey = getKosSessionKey;
|
|
|
24790
25250
|
exports.getLocalizationDescriptor = getLocalizationDescriptor;
|
|
24791
25251
|
exports.getLogGroups = getLogGroups;
|
|
24792
25252
|
exports.getLogLevel = getLogLevel;
|
|
24793
|
-
exports.getLogMessageToStudio = getLogMessageToStudio;
|
|
24794
25253
|
exports.getLogOverrides = getLogOverrides;
|
|
24795
25254
|
exports.getLogStreamBlock = getLogStreamBlock;
|
|
24796
25255
|
exports.getLogStreamBlocks = getLogStreamBlocks;
|
|
@@ -24856,6 +25315,7 @@ exports.kosStateGuard = kosStateGuard;
|
|
|
24856
25315
|
exports.kosStateMachine = kosStateMachine;
|
|
24857
25316
|
exports.kosTopicHandler = kosTopicHandler;
|
|
24858
25317
|
exports.kosWhen = kosWhen;
|
|
25318
|
+
exports.makeCancellable = makeCancellable;
|
|
24859
25319
|
exports.mapConfigBeanModelToDto = mapConfigBeanModelToDto;
|
|
24860
25320
|
exports.mapDataToModel = mapDataToModel;
|
|
24861
25321
|
exports.mapDtoToConfigBeanModel = mapDtoToConfigBeanModel;
|
|
@@ -24894,6 +25354,7 @@ exports.resolveListDeltas = resolveListDeltas;
|
|
|
24894
25354
|
exports.resolveServiceRequestParameters = resolveServiceRequestParameters;
|
|
24895
25355
|
exports.resolveServiceUrl = resolveServiceUrl;
|
|
24896
25356
|
exports.resolveTrouble = resolveTrouble;
|
|
25357
|
+
exports.retryWithExponentialBackoff = retryWithExponentialBackoff;
|
|
24897
25358
|
exports.sendAsyncIntent = sendAsyncIntent;
|
|
24898
25359
|
exports.sendBroadcastMessage = sendBroadcastMessage;
|
|
24899
25360
|
exports.sendCanvasData = sendCanvasData;
|
|
@@ -24901,6 +25362,7 @@ exports.sendIntent = sendIntent;
|
|
|
24901
25362
|
exports.sendKosHttpMessageResponse = sendKosHttpMessageResponse;
|
|
24902
25363
|
exports.sendKosMessage = sendKosMessage;
|
|
24903
25364
|
exports.sendKosMessageResponse = sendKosMessageResponse;
|
|
25365
|
+
exports.sendRequest = sendRequest;
|
|
24904
25366
|
exports.sendStudioMessage = sendStudioMessage;
|
|
24905
25367
|
exports.sendStudioMessageRequest = sendStudioMessageRequest;
|
|
24906
25368
|
exports.service = service;
|
|
@@ -24909,6 +25371,7 @@ exports.setTime = setTime;
|
|
|
24909
25371
|
exports.setTimezone = setTimezone;
|
|
24910
25372
|
exports.subscribe = subscribe;
|
|
24911
25373
|
exports.subscribeToLogStream = subscribeToLogStream;
|
|
25374
|
+
exports.syncPublish = syncPublish;
|
|
24912
25375
|
exports.troubleByTypeReducer = troubleByTypeReducer;
|
|
24913
25376
|
exports.troubleDataFactory = troubleDataFactory;
|
|
24914
25377
|
exports.unloadKosModel = unloadKosModel;
|
|
@@ -24917,6 +25380,8 @@ exports.updateKeyValue = updateKeyValue;
|
|
|
24917
25380
|
exports.uuid = uuid;
|
|
24918
25381
|
exports.waitForAppToStart = waitForAppToStart;
|
|
24919
25382
|
exports.waitForAppsToStart = waitForAppsToStart;
|
|
25383
|
+
exports.waitForRequest = waitForRequest;
|
|
24920
25384
|
exports.whenReady = whenReady;
|
|
25385
|
+
exports.withCancellation = withCancellation;
|
|
24921
25386
|
exports.wrapWithFutureLifecycle = wrapWithFutureLifecycle;
|
|
24922
|
-
//# sourceMappingURL=software-info-registration-
|
|
25387
|
+
//# sourceMappingURL=software-info-registration-CA13_Qc_.cjs.map
|