@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,5 +1,5 @@
|
|
|
1
1
|
import { makeAutoObservable, observable, makeObservable, action, createAtom, autorun, runInAction, observe, isComputedProp, reaction, ObservableMap, when, computed, isObservable } from "mobx";
|
|
2
|
-
import log$
|
|
2
|
+
import log$1h from "loglevel";
|
|
3
3
|
import { createMachine, invoke, transition, action as action$1, state, interpret, immediate } from "robot3";
|
|
4
4
|
import { format } from "date-fns";
|
|
5
5
|
const HEADER_METHOD = `method`;
|
|
@@ -26,7 +26,140 @@ var KosWsEvents = /* @__PURE__ */ ((KosWsEvents2) => {
|
|
|
26
26
|
return KosWsEvents2;
|
|
27
27
|
})(KosWsEvents || {});
|
|
28
28
|
const EVENT_KOS_MODEL_READY = "/kos/model/ready/";
|
|
29
|
-
|
|
29
|
+
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
30
|
+
const [key, val] = pair.split("=");
|
|
31
|
+
return [key, decodeURIComponent(val || "")];
|
|
32
|
+
}).reduce((result, [key, val]) => {
|
|
33
|
+
result[key] = val;
|
|
34
|
+
return result;
|
|
35
|
+
}, {});
|
|
36
|
+
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
37
|
+
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
38
|
+
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
39
|
+
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
40
|
+
const PROFILE_LOG_INFO = "studio.log.info";
|
|
41
|
+
const defaultConfig = {
|
|
42
|
+
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
43
|
+
};
|
|
44
|
+
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
45
|
+
const configObj = JSON.parse(config);
|
|
46
|
+
const urlProfiles = () => {
|
|
47
|
+
if (typeof window === "undefined") {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const value = getQueryParams()?.["kosProfiles"];
|
|
51
|
+
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
52
|
+
};
|
|
53
|
+
configObj.profiles = [
|
|
54
|
+
...configObj.profiles ?? [],
|
|
55
|
+
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
56
|
+
];
|
|
57
|
+
globalThis.kosConfig = configObj;
|
|
58
|
+
const KosGlobalConfig = configObj;
|
|
59
|
+
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
60
|
+
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
61
|
+
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
62
|
+
const resolveLogLevelProfile = () => {
|
|
63
|
+
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
64
|
+
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
65
|
+
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
66
|
+
};
|
|
67
|
+
const getLogLevel = () => {
|
|
68
|
+
const params2 = getQueryParams();
|
|
69
|
+
const profileLogLevel = resolveLogLevelProfile();
|
|
70
|
+
const logLevelParam = params2["kosLogLevel"];
|
|
71
|
+
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
72
|
+
if (logLevel) {
|
|
73
|
+
return logLevel;
|
|
74
|
+
}
|
|
75
|
+
return "WARN";
|
|
76
|
+
};
|
|
77
|
+
const LogGroup = {
|
|
78
|
+
core: "core",
|
|
79
|
+
transport: "transport",
|
|
80
|
+
model: "model",
|
|
81
|
+
service: "service",
|
|
82
|
+
ui: "ui"
|
|
83
|
+
};
|
|
84
|
+
const UI_GROUP_OVERRIDE = "ui:group";
|
|
85
|
+
const UI_LOGGER_OVERRIDE = "ui:logger";
|
|
86
|
+
const LEVELS = ["trace", "debug", "info", "warn", "error"];
|
|
87
|
+
const getLoggerGroup = (loggerName) => {
|
|
88
|
+
const grouped = loggerName.indexOf(":::");
|
|
89
|
+
if (grouped >= 0) {
|
|
90
|
+
return loggerName.slice(0, grouped);
|
|
91
|
+
}
|
|
92
|
+
const ungrouped = loggerName.indexOf("::");
|
|
93
|
+
return ungrouped >= 0 ? loggerName.slice(0, ungrouped) : "";
|
|
94
|
+
};
|
|
95
|
+
const matchesPattern = (value, pattern) => {
|
|
96
|
+
const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
97
|
+
return new RegExp(`^${source}$`).test(value);
|
|
98
|
+
};
|
|
99
|
+
const matches = (loggerName, override) => {
|
|
100
|
+
const wildcard = override.name.includes("*");
|
|
101
|
+
if (override.type === UI_GROUP_OVERRIDE) {
|
|
102
|
+
const group = getLoggerGroup(loggerName);
|
|
103
|
+
return wildcard ? matchesPattern(group, override.name) : group === override.name;
|
|
104
|
+
}
|
|
105
|
+
if (override.type === UI_LOGGER_OVERRIDE) {
|
|
106
|
+
return wildcard ? matchesPattern(loggerName, override.name) : loggerName.startsWith(override.name);
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
};
|
|
110
|
+
const resolveOverrideLevel = (loggerName, overrides) => overrides.filter((override) => matches(loggerName, override)).map((override) => override.level.toLowerCase()).filter((level2) => LEVELS.includes(level2)).sort((a, b) => LEVELS.indexOf(a) - LEVELS.indexOf(b))[0];
|
|
111
|
+
const MESSAGE_LOGGER_NAME = "messages";
|
|
112
|
+
const MESSAGE_LOGGER = `${LogGroup.transport}:::${MESSAGE_LOGGER_NAME}`;
|
|
113
|
+
const originalFactory = log$1h.methodFactory;
|
|
114
|
+
log$1h.methodFactory = function(methodName, logLevel, loggerName) {
|
|
115
|
+
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
116
|
+
return function(...args) {
|
|
117
|
+
const _name = loggerName ? String(loggerName) : "";
|
|
118
|
+
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
119
|
+
const message = args.map(
|
|
120
|
+
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
121
|
+
).join(" ");
|
|
122
|
+
rawMethod(`${prefix}${message}`);
|
|
123
|
+
if (globalThis?.kosConfig?.logging && globalThis.kosLog && loggerName !== MESSAGE_LOGGER) {
|
|
124
|
+
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
let level = getLogLevel();
|
|
129
|
+
log$1h.setLevel(level);
|
|
130
|
+
window.setKosLogLevel = (_level) => {
|
|
131
|
+
level = _level;
|
|
132
|
+
log$1h.setLevel(_level);
|
|
133
|
+
};
|
|
134
|
+
const conditionallyLog = (level2) => (fn, logger = log$1h) => {
|
|
135
|
+
if (logger.getLevel() <= level2) {
|
|
136
|
+
fn();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const createLogger = ({ name, group }) => {
|
|
140
|
+
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
141
|
+
const _log = log$1h.getLogger(loggerName);
|
|
142
|
+
const _level = resolveOverrideLevel(
|
|
143
|
+
loggerName,
|
|
144
|
+
globalThis.kos?.logOverrides ?? []
|
|
145
|
+
);
|
|
146
|
+
if (_level) {
|
|
147
|
+
_log.setLevel(_level);
|
|
148
|
+
}
|
|
149
|
+
return _log;
|
|
150
|
+
};
|
|
151
|
+
const KosLog = {
|
|
152
|
+
...log$1h,
|
|
153
|
+
ifDebug: conditionallyLog(log$1h.levels.DEBUG),
|
|
154
|
+
ifInfo: conditionallyLog(log$1h.levels.INFO),
|
|
155
|
+
ifWarn: conditionallyLog(log$1h.levels.WARN),
|
|
156
|
+
ifError: conditionallyLog(log$1h.levels.ERROR),
|
|
157
|
+
getLogger: (name) => createLogger({ name }),
|
|
158
|
+
getLoggers: () => log$1h.getLoggers(),
|
|
159
|
+
createLogger
|
|
160
|
+
};
|
|
161
|
+
const log$1g = KosLog.createLogger({ group: LogGroup.core, name: "event-bus" });
|
|
162
|
+
log$1g.info("Initializing event bus");
|
|
30
163
|
globalThis.kos = globalThis.kos || {};
|
|
31
164
|
globalThis.kos.subscriptions = globalThis.kos.subscriptions || {};
|
|
32
165
|
const subscriptions = globalThis.kos.subscriptions;
|
|
@@ -37,15 +170,15 @@ function hasEventSubscriptions(eventType) {
|
|
|
37
170
|
function subscribe(eventType, callback) {
|
|
38
171
|
const id = getNextUniqueId();
|
|
39
172
|
if (!subscriptions[eventType]) {
|
|
40
|
-
log$
|
|
173
|
+
log$1g.debug(`Initializing subscription for ${eventType}`);
|
|
41
174
|
subscriptions[eventType] = {};
|
|
42
175
|
}
|
|
43
|
-
log$
|
|
176
|
+
log$1g.debug(`Subscribing to ${eventType} with id ${id.toString()}`);
|
|
44
177
|
subscriptions[eventType][id] = callback;
|
|
45
178
|
return {
|
|
46
179
|
count: subscriptions[eventType] ? Object.getOwnPropertySymbols(subscriptions[eventType]).length : 0,
|
|
47
180
|
unsubscribe: () => {
|
|
48
|
-
log$
|
|
181
|
+
log$1g.debug(`Unsubscribing from ${eventType} with id ${id.toString()}`);
|
|
49
182
|
if (subscriptions[eventType] && subscriptions[eventType][id]) {
|
|
50
183
|
delete subscriptions[eventType][id];
|
|
51
184
|
}
|
|
@@ -60,7 +193,7 @@ function subscribe(eventType, callback) {
|
|
|
60
193
|
}
|
|
61
194
|
function publish(eventType, msg, headers = {}) {
|
|
62
195
|
if (!subscriptions[eventType] || Object.getOwnPropertySymbols(subscriptions[eventType]).length === 0) {
|
|
63
|
-
log$
|
|
196
|
+
log$1g.debug(`No subscriptions for ${eventType}. Not publishing.`);
|
|
64
197
|
return {
|
|
65
198
|
eventType,
|
|
66
199
|
subscribers: 0
|
|
@@ -70,19 +203,19 @@ function publish(eventType, msg, headers = {}) {
|
|
|
70
203
|
Object.getOwnPropertySymbols(subscriptions[eventType]).forEach((id) => {
|
|
71
204
|
if (headers["sync"]) {
|
|
72
205
|
const responseId = headers["sync"];
|
|
73
|
-
log$
|
|
206
|
+
log$1g.debug(
|
|
74
207
|
`Performing sync publish for ${eventType} with sync id ${responseId}`
|
|
75
208
|
);
|
|
76
209
|
subscriptions[eventType][id]({ body: msg, headers }).then(
|
|
77
210
|
(response) => {
|
|
78
|
-
log$
|
|
211
|
+
log$1g.debug(
|
|
79
212
|
`Response recieved for ${responseId}, publishing back to source.`
|
|
80
213
|
);
|
|
81
214
|
publish(responseId, response);
|
|
82
215
|
}
|
|
83
216
|
);
|
|
84
217
|
} else {
|
|
85
|
-
log$
|
|
218
|
+
log$1g.debug(`Performing async publish for ${eventType}`);
|
|
86
219
|
subscriptions[eventType][id]({ body: msg, headers });
|
|
87
220
|
}
|
|
88
221
|
});
|
|
@@ -92,7 +225,7 @@ function publish(eventType, msg, headers = {}) {
|
|
|
92
225
|
};
|
|
93
226
|
}
|
|
94
227
|
function reset() {
|
|
95
|
-
log$
|
|
228
|
+
log$1g.warn("Resetting event bus");
|
|
96
229
|
Object.keys(subscriptions).forEach((key) => delete subscriptions[key]);
|
|
97
230
|
}
|
|
98
231
|
function once(eventType, callback) {
|
|
@@ -408,185 +541,11 @@ const eventBus_state = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defi
|
|
|
408
541
|
waitForAllWithState,
|
|
409
542
|
waitForOrGetState
|
|
410
543
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
411
|
-
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
412
|
-
const [key, val] = pair.split("=");
|
|
413
|
-
return [key, decodeURIComponent(val || "")];
|
|
414
|
-
}).reduce((result, [key, val]) => {
|
|
415
|
-
result[key] = val;
|
|
416
|
-
return result;
|
|
417
|
-
}, {});
|
|
418
|
-
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
419
|
-
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
420
|
-
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
421
|
-
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
422
|
-
const PROFILE_LOG_INFO = "studio.log.info";
|
|
423
|
-
const defaultConfig = {
|
|
424
|
-
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
425
|
-
};
|
|
426
|
-
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
427
|
-
const configObj = JSON.parse(config);
|
|
428
|
-
const urlProfiles = () => {
|
|
429
|
-
if (typeof window === "undefined") {
|
|
430
|
-
return [];
|
|
431
|
-
}
|
|
432
|
-
const value = getQueryParams()?.["kosProfiles"];
|
|
433
|
-
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
434
|
-
};
|
|
435
|
-
configObj.profiles = [
|
|
436
|
-
...configObj.profiles ?? [],
|
|
437
|
-
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
438
|
-
];
|
|
439
|
-
globalThis.kosConfig = configObj;
|
|
440
|
-
const KosGlobalConfig = configObj;
|
|
441
|
-
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
442
|
-
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
443
|
-
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
444
|
-
const resolveLogLevelProfile = () => {
|
|
445
|
-
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
446
|
-
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
447
|
-
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
448
|
-
};
|
|
449
|
-
const getLogLevel = () => {
|
|
450
|
-
const params2 = getQueryParams();
|
|
451
|
-
const profileLogLevel = resolveLogLevelProfile();
|
|
452
|
-
const logLevelParam = params2["kosLogLevel"];
|
|
453
|
-
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
454
|
-
if (logLevel) {
|
|
455
|
-
return logLevel;
|
|
456
|
-
}
|
|
457
|
-
return "WARN";
|
|
458
|
-
};
|
|
459
|
-
const getKosMessageLogging = () => {
|
|
460
|
-
const enableAll = window.kosMessageLogging || process.env.KOS_MESSAGE_LOGGING === "true";
|
|
461
|
-
return enableAll;
|
|
462
|
-
};
|
|
463
|
-
const getLogMessageToStudio = () => {
|
|
464
|
-
const enableAll = window.kosMessageStudioLogging || process.env.KOS_MESSAGE_STUDIO_LOGGING === "true";
|
|
465
|
-
return enableAll;
|
|
466
|
-
};
|
|
467
|
-
const UI_GROUP_OVERRIDE = "ui:group";
|
|
468
|
-
const UI_LOGGER_OVERRIDE = "ui:logger";
|
|
469
|
-
const LEVELS = ["trace", "debug", "info", "warn", "error"];
|
|
470
|
-
const getLoggerGroup = (loggerName) => {
|
|
471
|
-
const grouped = loggerName.indexOf(":::");
|
|
472
|
-
if (grouped >= 0) {
|
|
473
|
-
return loggerName.slice(0, grouped);
|
|
474
|
-
}
|
|
475
|
-
const ungrouped = loggerName.indexOf("::");
|
|
476
|
-
return ungrouped >= 0 ? loggerName.slice(0, ungrouped) : "";
|
|
477
|
-
};
|
|
478
|
-
const matchesPattern = (value, pattern) => {
|
|
479
|
-
const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
480
|
-
return new RegExp(`^${source}$`).test(value);
|
|
481
|
-
};
|
|
482
|
-
const matches = (loggerName, override) => {
|
|
483
|
-
const wildcard = override.name.includes("*");
|
|
484
|
-
if (override.type === UI_GROUP_OVERRIDE) {
|
|
485
|
-
const group = getLoggerGroup(loggerName);
|
|
486
|
-
return wildcard ? matchesPattern(group, override.name) : group === override.name;
|
|
487
|
-
}
|
|
488
|
-
if (override.type === UI_LOGGER_OVERRIDE) {
|
|
489
|
-
return wildcard ? matchesPattern(loggerName, override.name) : loggerName.startsWith(override.name);
|
|
490
|
-
}
|
|
491
|
-
return false;
|
|
492
|
-
};
|
|
493
|
-
const resolveOverrideLevel = (loggerName, overrides) => overrides.filter((override) => matches(loggerName, override)).map((override) => override.level.toLowerCase()).filter((level2) => LEVELS.includes(level2)).sort((a, b) => LEVELS.indexOf(a) - LEVELS.indexOf(b))[0];
|
|
494
|
-
const WS_LOG = "ws-log";
|
|
495
|
-
const originalFactory = log$M.methodFactory;
|
|
496
|
-
const enableMessageLogging = getKosMessageLogging();
|
|
497
|
-
const enableStudioMessageLogging = getLogMessageToStudio();
|
|
498
|
-
log$M.methodFactory = function(methodName, logLevel, loggerName) {
|
|
499
|
-
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
500
|
-
return function(...args) {
|
|
501
|
-
const _name = loggerName ? String(loggerName) : "";
|
|
502
|
-
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
503
|
-
const message = args.map(
|
|
504
|
-
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
505
|
-
).join(" ");
|
|
506
|
-
rawMethod(`${prefix}${message}`);
|
|
507
|
-
if (globalThis?.kosConfig?.logging && globalThis.kosLog && (loggerName !== WS_LOG || enableMessageLogging && enableStudioMessageLogging)) {
|
|
508
|
-
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
};
|
|
512
|
-
let level = getLogLevel();
|
|
513
|
-
log$M.setLevel(level);
|
|
514
|
-
window.setKosLogLevel = (_level) => {
|
|
515
|
-
level = _level;
|
|
516
|
-
log$M.setLevel(_level);
|
|
517
|
-
};
|
|
518
|
-
const wsLog = log$M.getLogger(WS_LOG);
|
|
519
|
-
window.enableKosMessageLog = () => {
|
|
520
|
-
wsLog.setLevel(log$M.levels.INFO);
|
|
521
|
-
};
|
|
522
|
-
window.disableKosMessageLog = () => {
|
|
523
|
-
wsLog.setLevel(log$M.levels.ERROR);
|
|
524
|
-
};
|
|
525
|
-
if (enableMessageLogging) {
|
|
526
|
-
window.enableKosMessageLog();
|
|
527
|
-
} else {
|
|
528
|
-
window.disableKosMessageLog();
|
|
529
|
-
}
|
|
530
|
-
const styles = [
|
|
531
|
-
"color: black",
|
|
532
|
-
"display: block",
|
|
533
|
-
"background-color: lightgreen",
|
|
534
|
-
"padding: 4px",
|
|
535
|
-
"margin: 0",
|
|
536
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
537
|
-
"box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset",
|
|
538
|
-
"font-weight: bold"
|
|
539
|
-
].join(";");
|
|
540
|
-
const received = [
|
|
541
|
-
"color: black",
|
|
542
|
-
"display: block",
|
|
543
|
-
"padding: 4px",
|
|
544
|
-
"background-color: yellow",
|
|
545
|
-
"margin: 0",
|
|
546
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
547
|
-
"box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset",
|
|
548
|
-
"font-weight: bold"
|
|
549
|
-
].join(";");
|
|
550
|
-
const conditionallyLog = (level2) => (fn) => {
|
|
551
|
-
if (log$M.getLevel() <= level2) {
|
|
552
|
-
fn();
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
const KosLog = {
|
|
556
|
-
...log$M,
|
|
557
|
-
ifDebug: conditionallyLog(log$M.levels.DEBUG),
|
|
558
|
-
ifInfo: conditionallyLog(log$M.levels.INFO),
|
|
559
|
-
ifWarn: conditionallyLog(log$M.levels.WARN),
|
|
560
|
-
ifError: conditionallyLog(log$M.levels.ERROR),
|
|
561
|
-
getLogger: (name) => log$M.getLogger(`kos::${name}`),
|
|
562
|
-
getLoggers: () => log$M.getLoggers(),
|
|
563
|
-
createLogger: ({ name, group }) => {
|
|
564
|
-
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
565
|
-
const _log = log$M.getLogger(loggerName);
|
|
566
|
-
const _level = resolveOverrideLevel(
|
|
567
|
-
loggerName,
|
|
568
|
-
globalThis.kos?.logOverrides ?? []
|
|
569
|
-
);
|
|
570
|
-
if (_level) {
|
|
571
|
-
_log.setLevel(_level);
|
|
572
|
-
}
|
|
573
|
-
return _log;
|
|
574
|
-
},
|
|
575
|
-
wsSend: (...msg) => {
|
|
576
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
577
|
-
wsLog.info(`%c⬆ ${str}`, styles);
|
|
578
|
-
},
|
|
579
|
-
wsReceive: (...msg) => {
|
|
580
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
581
|
-
wsLog.info(`%c⬇ ${str}`, received);
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
544
|
const SubscriptionHandlers = /* @__PURE__ */ Symbol(`SubscriptionHandlers`);
|
|
585
545
|
const DependencyModels = /* @__PURE__ */ Symbol(`DependencyModels`);
|
|
586
546
|
const FutureService = /* @__PURE__ */ Symbol(`FutureService`);
|
|
587
547
|
const ChildModels = /* @__PURE__ */ Symbol(`ChildModels`);
|
|
588
548
|
const ParentModel = /* @__PURE__ */ Symbol(`ParentModel`);
|
|
589
|
-
const LogConfig = /* @__PURE__ */ Symbol(`LogConfig`);
|
|
590
549
|
const ReferenceConfig = /* @__PURE__ */ Symbol(`ReferenceConfig`);
|
|
591
550
|
const KosModelSymbol = /* @__PURE__ */ Symbol(`KosModelSymbol`);
|
|
592
551
|
const ModelEffects = /* @__PURE__ */ Symbol(`ModelEffects`);
|
|
@@ -608,7 +567,10 @@ const KosViewModelSymbol = /* @__PURE__ */ Symbol(`KosViewModelSymbol`);
|
|
|
608
567
|
const ViewModelConfig = /* @__PURE__ */ Symbol(`ViewModelConfig`);
|
|
609
568
|
const ReloadAwareSetup = /* @__PURE__ */ Symbol(`ReloadAwareSetup`);
|
|
610
569
|
const MixinModels = /* @__PURE__ */ Symbol(`MixinModels`);
|
|
611
|
-
const log$
|
|
570
|
+
const log$1f = KosLog.createLogger({
|
|
571
|
+
group: LogGroup.core,
|
|
572
|
+
name: "fsm-injection"
|
|
573
|
+
});
|
|
612
574
|
function injectStateMachineSupport(modelInstance) {
|
|
613
575
|
const fsmSetup = modelInstance[StateMachineSetup];
|
|
614
576
|
if (!fsmSetup) return;
|
|
@@ -652,7 +614,7 @@ function initializeFsmProperties(modelInstance, options) {
|
|
|
652
614
|
const config2 = modelInstance._fsmConfig;
|
|
653
615
|
const initialState = computeInitialState ? computeInitialState(modelInstance) : config2.initial;
|
|
654
616
|
if (computeInitialState && !config2.states[initialState]) {
|
|
655
|
-
log$
|
|
617
|
+
log$1f.warn(
|
|
656
618
|
`computeInitialState returned "${initialState}" which is not a valid state. Falling back to "${config2.initial}".`
|
|
657
619
|
);
|
|
658
620
|
modelInstance[stateProperty] = config2.initial;
|
|
@@ -782,7 +744,7 @@ function handleAsyncEntryResult(instance, state2, stateProperty, result) {
|
|
|
782
744
|
if (stateConfig.onError && instance[stateProperty] === state2) {
|
|
783
745
|
instance.transition(stateConfig.onError);
|
|
784
746
|
} else {
|
|
785
|
-
log$
|
|
747
|
+
log$1f.error(`Async entry handler for state "${state2}" failed:`, err);
|
|
786
748
|
}
|
|
787
749
|
}
|
|
788
750
|
);
|
|
@@ -823,7 +785,7 @@ function initializeStateMachine(modelInstance, lifecycle) {
|
|
|
823
785
|
modelInstance._fsmInitialized = true;
|
|
824
786
|
trackInitialStateInHistory(modelInstance, config2.initial, options);
|
|
825
787
|
executeInitialStateEntryHandler(modelInstance, config2.initial);
|
|
826
|
-
log$
|
|
788
|
+
log$1f.debug(
|
|
827
789
|
`FSM initialized for model ${modelInstance.id} at lifecycle ${lifecycle} with initial state "${config2.initial}"`
|
|
828
790
|
);
|
|
829
791
|
}
|
|
@@ -947,9 +909,12 @@ function getHttpRouteHandlers(model) {
|
|
|
947
909
|
return model?.[HttpRouteHandlers] || [];
|
|
948
910
|
}
|
|
949
911
|
class KosLoggerFactory {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
912
|
+
/**
|
|
913
|
+
* The logger for a model type, `model:::{modelTypeName}`. Every instance of
|
|
914
|
+
* the type shares it; put the instance id in the message where it matters.
|
|
915
|
+
*/
|
|
916
|
+
static create({ modelTypeName }) {
|
|
917
|
+
return KosLog.createLogger({ group: LogGroup.model, name: modelTypeName });
|
|
953
918
|
}
|
|
954
919
|
}
|
|
955
920
|
function kosLoggerAware(options) {
|
|
@@ -967,8 +932,7 @@ function kosLoggerAware(options) {
|
|
|
967
932
|
if (!sharedLogger) {
|
|
968
933
|
const modelType = getModelType();
|
|
969
934
|
sharedLogger = KosLoggerFactory.create({
|
|
970
|
-
modelTypeName: loggerContext || modelType
|
|
971
|
-
component: "kos-model"
|
|
935
|
+
modelTypeName: loggerContext || modelType
|
|
972
936
|
});
|
|
973
937
|
}
|
|
974
938
|
return sharedLogger;
|
|
@@ -1019,7 +983,10 @@ class ServiceRequestError extends Error {
|
|
|
1019
983
|
this.responseHeaders = details.responseHeaders ?? {};
|
|
1020
984
|
}
|
|
1021
985
|
}
|
|
1022
|
-
const log$
|
|
986
|
+
const log$1e = KosLog.createLogger({
|
|
987
|
+
group: LogGroup.core,
|
|
988
|
+
name: "resolve-parameters"
|
|
989
|
+
});
|
|
1023
990
|
const resolveParameters = ({
|
|
1024
991
|
value,
|
|
1025
992
|
modelId,
|
|
@@ -1051,11 +1018,11 @@ const resolveParameters = ({
|
|
|
1051
1018
|
)) {
|
|
1052
1019
|
const prop = modelData[propName];
|
|
1053
1020
|
if (prop !== null && prop !== void 0) {
|
|
1054
|
-
log$
|
|
1021
|
+
log$1e.debug(`Resolved ${match} to ${prop}`);
|
|
1055
1022
|
return prop;
|
|
1056
1023
|
} else {
|
|
1057
1024
|
const logLevel2 = isOnlyPropKey ? "debug" : "warn";
|
|
1058
|
-
log$
|
|
1025
|
+
log$1e[logLevel2](
|
|
1059
1026
|
`Property ${propName} is null or undefined${isOnlyPropKey ? "" : " in composite string"}, marking for undefined return`
|
|
1060
1027
|
);
|
|
1061
1028
|
hasUnresolvedProp = true;
|
|
@@ -1063,7 +1030,7 @@ const resolveParameters = ({
|
|
|
1063
1030
|
}
|
|
1064
1031
|
}
|
|
1065
1032
|
const logLevel = isOnlyPropKey ? "debug" : "warn";
|
|
1066
|
-
log$
|
|
1033
|
+
log$1e[logLevel](
|
|
1067
1034
|
`Property ${propName} not found in modelData${isOnlyPropKey ? "" : " for composite string"}`
|
|
1068
1035
|
);
|
|
1069
1036
|
return match;
|
|
@@ -1078,7 +1045,10 @@ const resolveParameters = ({
|
|
|
1078
1045
|
}
|
|
1079
1046
|
return _value;
|
|
1080
1047
|
};
|
|
1081
|
-
const log$
|
|
1048
|
+
const log$1d = KosLog.createLogger({
|
|
1049
|
+
group: LogGroup.core,
|
|
1050
|
+
name: "ServiceRequestHelpers"
|
|
1051
|
+
});
|
|
1082
1052
|
function resolveServiceRequestParameters(metadata, modelInstance, args, runtimeOptions) {
|
|
1083
1053
|
const resolvedPath = resolveParameters({
|
|
1084
1054
|
value: metadata.path,
|
|
@@ -1147,7 +1117,7 @@ function handleServiceRequestError(error, response, errorHandler, modelInstance,
|
|
|
1147
1117
|
});
|
|
1148
1118
|
switch (errorHandler.strategy) {
|
|
1149
1119
|
case "log":
|
|
1150
|
-
log$
|
|
1120
|
+
log$1d.error(`Service request status ${richError.status} error: ${error}`);
|
|
1151
1121
|
if (errorHandler.onError) {
|
|
1152
1122
|
errorHandler.onError(richError, modelInstance);
|
|
1153
1123
|
}
|
|
@@ -1260,7 +1230,10 @@ var ReplayStrategy = /* @__PURE__ */ ((ReplayStrategy2) => {
|
|
|
1260
1230
|
ReplayStrategy2["NONE"] = "none";
|
|
1261
1231
|
return ReplayStrategy2;
|
|
1262
1232
|
})(ReplayStrategy || {});
|
|
1263
|
-
const log$
|
|
1233
|
+
const log$1c = KosLog.createLogger({
|
|
1234
|
+
group: LogGroup.core,
|
|
1235
|
+
name: "kos-state-machine"
|
|
1236
|
+
});
|
|
1264
1237
|
function kosStateMachine(config2, options) {
|
|
1265
1238
|
return (target) => {
|
|
1266
1239
|
target.prototype[StateMachineSetup] = {
|
|
@@ -1317,7 +1290,7 @@ function kosStateGuard(options) {
|
|
|
1317
1290
|
if (shouldThrow) {
|
|
1318
1291
|
throw new Error(message);
|
|
1319
1292
|
} else {
|
|
1320
|
-
log$
|
|
1293
|
+
log$1c.warn(message);
|
|
1321
1294
|
return void 0;
|
|
1322
1295
|
}
|
|
1323
1296
|
}
|
|
@@ -1343,6 +1316,10 @@ const kosDependency = ({
|
|
|
1343
1316
|
resolutionPolicy
|
|
1344
1317
|
};
|
|
1345
1318
|
};
|
|
1319
|
+
const log$1b = KosLog.createLogger({
|
|
1320
|
+
group: LogGroup.model,
|
|
1321
|
+
name: "future-aware"
|
|
1322
|
+
});
|
|
1346
1323
|
class MultipleFutureHandler {
|
|
1347
1324
|
futures;
|
|
1348
1325
|
defaultContext;
|
|
@@ -1433,7 +1410,7 @@ class FutureHandler {
|
|
|
1433
1410
|
try {
|
|
1434
1411
|
await this._future.cancelFuture();
|
|
1435
1412
|
} catch (e) {
|
|
1436
|
-
|
|
1413
|
+
log$1b.error(e);
|
|
1437
1414
|
throw e;
|
|
1438
1415
|
}
|
|
1439
1416
|
}
|
|
@@ -1558,6 +1535,10 @@ const ObservableData = (initialData) => {
|
|
|
1558
1535
|
const od = createObservableData(ObservableDataMap, initialData);
|
|
1559
1536
|
return new od(initialData);
|
|
1560
1537
|
};
|
|
1538
|
+
const log$1a = KosLog.createLogger({
|
|
1539
|
+
group: LogGroup.core,
|
|
1540
|
+
name: "extension-manager"
|
|
1541
|
+
});
|
|
1561
1542
|
const DEFAULT_EXTENSION_OPTIONS = {
|
|
1562
1543
|
failurePolicy: "throw"
|
|
1563
1544
|
};
|
|
@@ -1609,8 +1590,8 @@ const _ExtensionManager = {
|
|
|
1609
1590
|
return await loader(data);
|
|
1610
1591
|
} catch (e) {
|
|
1611
1592
|
if (options.failurePolicy === "continue") {
|
|
1612
|
-
|
|
1613
|
-
|
|
1593
|
+
log$1a.error(`Error executing data loader for id ${id}`);
|
|
1594
|
+
log$1a.error(e);
|
|
1614
1595
|
return void 0;
|
|
1615
1596
|
}
|
|
1616
1597
|
throw new ExtensionException(id, "dataLoader", e);
|
|
@@ -1635,8 +1616,8 @@ const _ExtensionManager = {
|
|
|
1635
1616
|
return mapper(data, context);
|
|
1636
1617
|
} catch (e) {
|
|
1637
1618
|
if (options.failurePolicy === "continue") {
|
|
1638
|
-
|
|
1639
|
-
|
|
1619
|
+
log$1a.error(`Error executing property mapper for id ${id}`);
|
|
1620
|
+
log$1a.error(e);
|
|
1640
1621
|
return "";
|
|
1641
1622
|
}
|
|
1642
1623
|
throw new ExtensionException(id, "propertyMapper", e);
|
|
@@ -1664,8 +1645,8 @@ const _ExtensionManager = {
|
|
|
1664
1645
|
Object.assign(result, _interim);
|
|
1665
1646
|
} catch (e) {
|
|
1666
1647
|
if (options.failurePolicy === "continue") {
|
|
1667
|
-
|
|
1668
|
-
|
|
1648
|
+
log$1a.error(`Error executing data mapper for id ${id}`);
|
|
1649
|
+
log$1a.error(e);
|
|
1669
1650
|
continue;
|
|
1670
1651
|
}
|
|
1671
1652
|
throw new ExtensionException(id, "dataMapper", e);
|
|
@@ -1677,7 +1658,7 @@ const _ExtensionManager = {
|
|
|
1677
1658
|
canvas: {
|
|
1678
1659
|
registerRenderer: (id, renderer) => {
|
|
1679
1660
|
if (!ExtensionManager[EXTENSION_CANVAS_RENDERER]) {
|
|
1680
|
-
|
|
1661
|
+
log$1a.warn(
|
|
1681
1662
|
`Canvas renderer extension point is not registered. Cannot register renderer "${id}".`
|
|
1682
1663
|
);
|
|
1683
1664
|
return;
|
|
@@ -1703,6 +1684,10 @@ const INDEX_COLLECTION_KEY = "@kosdev-code/kos-ui-sdk.collection";
|
|
|
1703
1684
|
function isIndexableItem(value) {
|
|
1704
1685
|
return typeof value === "object" && value !== null && INDEX_RECORD_SYMBOL in value;
|
|
1705
1686
|
}
|
|
1687
|
+
const log$19 = KosLog.createLogger({
|
|
1688
|
+
group: LogGroup.core,
|
|
1689
|
+
name: "kos-container-index"
|
|
1690
|
+
});
|
|
1706
1691
|
function isPromiseLike(value) {
|
|
1707
1692
|
return typeof value?.then === "function";
|
|
1708
1693
|
}
|
|
@@ -1754,7 +1739,7 @@ class KosContainerIndex {
|
|
|
1754
1739
|
const set = map.get(key) || /* @__PURE__ */ new Set();
|
|
1755
1740
|
this._map.set(key, set);
|
|
1756
1741
|
} else {
|
|
1757
|
-
|
|
1742
|
+
log$19.debug(`KosContainerIndex - Index ${key} is the same`);
|
|
1758
1743
|
}
|
|
1759
1744
|
});
|
|
1760
1745
|
}
|
|
@@ -1830,7 +1815,10 @@ function observeComputedProperties(model, callback, keys = []) {
|
|
|
1830
1815
|
);
|
|
1831
1816
|
return disposers;
|
|
1832
1817
|
}
|
|
1833
|
-
const log$
|
|
1818
|
+
const log$18 = KosLog.createLogger({
|
|
1819
|
+
group: LogGroup.core,
|
|
1820
|
+
name: "kos-container-model"
|
|
1821
|
+
});
|
|
1834
1822
|
class KosModelContainer {
|
|
1835
1823
|
_data;
|
|
1836
1824
|
_sortKey;
|
|
@@ -1952,14 +1940,14 @@ class KosModelContainer {
|
|
|
1952
1940
|
async removeAndDestroy(id) {
|
|
1953
1941
|
const model = this.getModel(id);
|
|
1954
1942
|
if (!model) {
|
|
1955
|
-
log$
|
|
1943
|
+
log$18.debug(`Model ${id} not found in container, skipping destroy`);
|
|
1956
1944
|
return;
|
|
1957
1945
|
}
|
|
1958
1946
|
this.removeModel(id);
|
|
1959
1947
|
try {
|
|
1960
1948
|
await destroyKosModel(model);
|
|
1961
1949
|
} catch (error) {
|
|
1962
|
-
log$
|
|
1950
|
+
log$18.error(`Failed to destroy model ${id}:`, error);
|
|
1963
1951
|
throw error;
|
|
1964
1952
|
}
|
|
1965
1953
|
}
|
|
@@ -1976,7 +1964,7 @@ class KosModelContainer {
|
|
|
1976
1964
|
async removeAndDestroyAll(ids) {
|
|
1977
1965
|
const models2 = ids.map((id) => this.getModel(id)).filter((model) => model !== void 0);
|
|
1978
1966
|
if (models2.length === 0) {
|
|
1979
|
-
log$
|
|
1967
|
+
log$18.debug("No models found to destroy");
|
|
1980
1968
|
return;
|
|
1981
1969
|
}
|
|
1982
1970
|
this.removeAll(ids);
|
|
@@ -1985,7 +1973,7 @@ class KosModelContainer {
|
|
|
1985
1973
|
);
|
|
1986
1974
|
results.forEach((result, index) => {
|
|
1987
1975
|
if (result.status === "rejected") {
|
|
1988
|
-
log$
|
|
1976
|
+
log$18.error(
|
|
1989
1977
|
`Failed to destroy model ${models2[index].id}:`,
|
|
1990
1978
|
result.reason
|
|
1991
1979
|
);
|
|
@@ -2158,7 +2146,7 @@ class KosModelContainer {
|
|
|
2158
2146
|
const idx = this.index.get(indexName);
|
|
2159
2147
|
return idx.keys ?? [];
|
|
2160
2148
|
} else {
|
|
2161
|
-
log$
|
|
2149
|
+
log$18.info(
|
|
2162
2150
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2163
2151
|
);
|
|
2164
2152
|
return [];
|
|
@@ -2170,7 +2158,7 @@ class KosModelContainer {
|
|
|
2170
2158
|
if (idx.index.has(indexKey)) {
|
|
2171
2159
|
return idx.getByKey(indexKey);
|
|
2172
2160
|
} else {
|
|
2173
|
-
log$
|
|
2161
|
+
log$18.info(
|
|
2174
2162
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
2175
2163
|
idx.index.keys()
|
|
2176
2164
|
)}`
|
|
@@ -2178,7 +2166,7 @@ class KosModelContainer {
|
|
|
2178
2166
|
return [];
|
|
2179
2167
|
}
|
|
2180
2168
|
} else {
|
|
2181
|
-
log$
|
|
2169
|
+
log$18.info(
|
|
2182
2170
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2183
2171
|
);
|
|
2184
2172
|
return [];
|
|
@@ -2205,7 +2193,7 @@ class KosModelContainer {
|
|
|
2205
2193
|
* @private
|
|
2206
2194
|
*/
|
|
2207
2195
|
_logCapacityWarning(toEvict) {
|
|
2208
|
-
log$
|
|
2196
|
+
log$18.info(
|
|
2209
2197
|
`Container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${toEvict} models using ${this._evictionStrategy} strategy.`,
|
|
2210
2198
|
{ parentId: this._parentId }
|
|
2211
2199
|
);
|
|
@@ -2268,7 +2256,7 @@ class KosModelContainer {
|
|
|
2268
2256
|
const candidates = this._customEvictionFilter(this.data);
|
|
2269
2257
|
return candidates.slice(0, count);
|
|
2270
2258
|
}
|
|
2271
|
-
log$
|
|
2259
|
+
log$18.error(
|
|
2272
2260
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO.",
|
|
2273
2261
|
{ parentId: this._parentId }
|
|
2274
2262
|
);
|
|
@@ -2280,7 +2268,7 @@ class KosModelContainer {
|
|
|
2280
2268
|
*/
|
|
2281
2269
|
async _removeEvictedModels(models2) {
|
|
2282
2270
|
for (const model of models2) {
|
|
2283
|
-
log$
|
|
2271
|
+
log$18.info(
|
|
2284
2272
|
`Evicting model: ${model.id} (type: ${model.constructor.name})`,
|
|
2285
2273
|
{
|
|
2286
2274
|
modelId: model.id,
|
|
@@ -2290,7 +2278,7 @@ class KosModelContainer {
|
|
|
2290
2278
|
);
|
|
2291
2279
|
this.removeModel(model.id, true);
|
|
2292
2280
|
destroyKosModel(model).catch(
|
|
2293
|
-
(e) => log$
|
|
2281
|
+
(e) => log$18.error(`Failed to destroy evicted model ${model.id}:`, e)
|
|
2294
2282
|
);
|
|
2295
2283
|
}
|
|
2296
2284
|
}
|
|
@@ -2299,7 +2287,7 @@ class KosModelContainer {
|
|
|
2299
2287
|
* @private
|
|
2300
2288
|
*/
|
|
2301
2289
|
_logEvictionComplete(evictedCount) {
|
|
2302
|
-
log$
|
|
2290
|
+
log$18.info(
|
|
2303
2291
|
`Evicted ${evictedCount} models. Current size: ${this._data.size}/${this._maxCapacity}`,
|
|
2304
2292
|
{ parentId: this._parentId }
|
|
2305
2293
|
);
|
|
@@ -2308,9 +2296,9 @@ class KosModelContainer {
|
|
|
2308
2296
|
this._data.forEach((model) => {
|
|
2309
2297
|
const modelId = model.id;
|
|
2310
2298
|
destroyKosModel(model).then(() => {
|
|
2311
|
-
log$
|
|
2299
|
+
log$18.debug(`${modelId} destroyed, removing from map`);
|
|
2312
2300
|
this.removeModel(modelId, true);
|
|
2313
|
-
}).catch((e) => log$
|
|
2301
|
+
}).catch((e) => log$18.error(e));
|
|
2314
2302
|
});
|
|
2315
2303
|
this.increment();
|
|
2316
2304
|
}
|
|
@@ -2453,12 +2441,16 @@ const whenReady = async (dataModel) => {
|
|
|
2453
2441
|
}
|
|
2454
2442
|
return dataModel;
|
|
2455
2443
|
};
|
|
2444
|
+
const log$17 = KosLog.createLogger({
|
|
2445
|
+
group: LogGroup.core,
|
|
2446
|
+
name: "kos-model-utils"
|
|
2447
|
+
});
|
|
2456
2448
|
const destroyKosModel = async (model) => {
|
|
2457
2449
|
await KosCore.getInstance().whenReady();
|
|
2458
2450
|
await KosCore.getInstance().modelManager.initiateDestroyModel(model);
|
|
2459
2451
|
};
|
|
2460
2452
|
const unloadKosModel = async (dataModel) => {
|
|
2461
|
-
|
|
2453
|
+
log$17.warn(
|
|
2462
2454
|
`unloadKosModel(${dataModel?.id}) is deprecated and never resolves. Use destroyKosModel() to release a model, or reload() to refresh it.`
|
|
2463
2455
|
);
|
|
2464
2456
|
await KosCore.getInstance().whenReady();
|
|
@@ -2471,16 +2463,16 @@ const unloadKosModel = async (dataModel) => {
|
|
|
2471
2463
|
}
|
|
2472
2464
|
};
|
|
2473
2465
|
const resetKosModel = async (model) => {
|
|
2474
|
-
|
|
2466
|
+
log$17.warn(
|
|
2475
2467
|
`resetKosModel(${model?.id}) is deprecated: the reset route drops every topic handler registered at INIT or with no lifecycle. Implement reload() on the model and refetch and reconcile in place.`
|
|
2476
2468
|
);
|
|
2477
2469
|
await KosCore.getInstance().whenReady();
|
|
2478
2470
|
await KosCore.getInstance().modelManager.reloadModel(model);
|
|
2479
|
-
|
|
2471
|
+
log$17.debug(
|
|
2480
2472
|
`reload model initiated for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2481
2473
|
);
|
|
2482
2474
|
await whenReady(model);
|
|
2483
|
-
|
|
2475
|
+
log$17.debug(
|
|
2484
2476
|
`reload model complete for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2485
2477
|
);
|
|
2486
2478
|
};
|
|
@@ -2556,7 +2548,7 @@ const getObservableCompanions = (modelId) => {
|
|
|
2556
2548
|
const resolveKosCompanion = (modelId, resolver) => {
|
|
2557
2549
|
const model = KosCore.getInstance().modelManager.getModelById(modelId);
|
|
2558
2550
|
if (!model) {
|
|
2559
|
-
|
|
2551
|
+
log$17.info(`Model not found for id ${modelId}`);
|
|
2560
2552
|
return void 0;
|
|
2561
2553
|
}
|
|
2562
2554
|
const companionModel = Array.from(model.companionModels.all()).find(
|
|
@@ -2595,7 +2587,10 @@ const getKosModelActivationState = (model) => {
|
|
|
2595
2587
|
}
|
|
2596
2588
|
};
|
|
2597
2589
|
};
|
|
2598
|
-
const log$
|
|
2590
|
+
const log$16 = KosLog.createLogger({
|
|
2591
|
+
group: LogGroup.core,
|
|
2592
|
+
name: "kos-model-factory"
|
|
2593
|
+
});
|
|
2599
2594
|
const KosModelFactory = {
|
|
2600
2595
|
byModelType: (modelType) => KosCore.getInstance().modelManager.getModelFactory(
|
|
2601
2596
|
modelType
|
|
@@ -2603,7 +2598,7 @@ const KosModelFactory = {
|
|
|
2603
2598
|
getModelInstance: (id, modelType, options) => {
|
|
2604
2599
|
const factory = KosModelFactory.byModelType(modelType);
|
|
2605
2600
|
if (!factory) {
|
|
2606
|
-
log$
|
|
2601
|
+
log$16.error(
|
|
2607
2602
|
`No registered factory found for model type ${modelType}. Please register a factory for this model type. `
|
|
2608
2603
|
);
|
|
2609
2604
|
throw Error(`No factory found for model type ${modelType}`);
|
|
@@ -2642,6 +2637,10 @@ const Kos = {
|
|
|
2642
2637
|
instance: (modelType) => (id) => KosModelFactory.getModelInstance(id, modelType)
|
|
2643
2638
|
}
|
|
2644
2639
|
};
|
|
2640
|
+
const log$15 = KosLog.createLogger({
|
|
2641
|
+
group: LogGroup.core,
|
|
2642
|
+
name: "registration-manager"
|
|
2643
|
+
});
|
|
2645
2644
|
window.KosRegistry = window.KosRegistry || {
|
|
2646
2645
|
coreModels: /* @__PURE__ */ new Map(),
|
|
2647
2646
|
preloadModels: [],
|
|
@@ -2686,7 +2685,7 @@ const RegistrationManager = {
|
|
|
2686
2685
|
}
|
|
2687
2686
|
if (KosCore.getInstance().isReady) {
|
|
2688
2687
|
if (!KosCore.getInstance().modelManager.registry.models[register.type]) {
|
|
2689
|
-
|
|
2688
|
+
log$15.info(
|
|
2690
2689
|
`Model with type ${register.type} doesn't exist. Adding new registration`
|
|
2691
2690
|
);
|
|
2692
2691
|
KosCore.getInstance().modelManager.registry.models[register.type] = register.registration[register.type];
|
|
@@ -2918,7 +2917,7 @@ class SingletonKosModelRegistrationFactory extends KosBaseModelRegistration {
|
|
|
2918
2917
|
};
|
|
2919
2918
|
}
|
|
2920
2919
|
}
|
|
2921
|
-
const log$
|
|
2920
|
+
const log$14 = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
2922
2921
|
const FUTURE_CANCEL_END_STATE = "CANCEL";
|
|
2923
2922
|
function resolveParentContext(TargetClass, modelId, modelData) {
|
|
2924
2923
|
const parentIdRaw = TargetClass[ParentModel]?.parentId;
|
|
@@ -3130,8 +3129,31 @@ function injectTroubleAwareSupport(modelInstance) {
|
|
|
3130
3129
|
configurable: true
|
|
3131
3130
|
});
|
|
3132
3131
|
}
|
|
3132
|
+
function registrationBuilders(model) {
|
|
3133
|
+
const registration = () => {
|
|
3134
|
+
const resolved = typeof model === "function" ? model() : model;
|
|
3135
|
+
if (!resolved) {
|
|
3136
|
+
throw new Error(
|
|
3137
|
+
"reconcile.model is undefined: the registration was not yet defined when @kosContainerAware ran. Pass model: () => Registration."
|
|
3138
|
+
);
|
|
3139
|
+
}
|
|
3140
|
+
return resolved;
|
|
3141
|
+
};
|
|
3142
|
+
return {
|
|
3143
|
+
create: (dto) => registration().instance(dto.id).options(dto).build(),
|
|
3144
|
+
update: (dto, existing) => {
|
|
3145
|
+
if (!isUpdateable(existing)) {
|
|
3146
|
+
throw new Error(
|
|
3147
|
+
`Model ${existing.id} is not updateable. reconcile.model needs the child to implement UpdateAware.`
|
|
3148
|
+
);
|
|
3149
|
+
}
|
|
3150
|
+
existing.updateModel(dto);
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3153
|
+
}
|
|
3133
3154
|
function createContainerReconcile(container, reconcile) {
|
|
3134
|
-
const {
|
|
3155
|
+
const { idMapper, filter, afterCreate } = reconcile;
|
|
3156
|
+
const { create, update } = "model" in reconcile && !reconcile.create ? registrationBuilders(reconcile.model) : reconcile;
|
|
3135
3157
|
const apply = resolveContainerDeltas({
|
|
3136
3158
|
container,
|
|
3137
3159
|
onAddItem: (dto) => {
|
|
@@ -3213,7 +3235,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3213
3235
|
const { mode, parentProperty, excludeProperties } = companionConfig;
|
|
3214
3236
|
const parentModel = initialData.companionParent;
|
|
3215
3237
|
if (!parentModel) {
|
|
3216
|
-
log$
|
|
3238
|
+
log$14.warn(
|
|
3217
3239
|
`Companion decorator configured but no parent model found in initialData.companionParent`
|
|
3218
3240
|
);
|
|
3219
3241
|
return;
|
|
@@ -3287,7 +3309,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3287
3309
|
});
|
|
3288
3310
|
}
|
|
3289
3311
|
} catch (error) {
|
|
3290
|
-
log$
|
|
3312
|
+
log$14.debug(
|
|
3291
3313
|
`Skipping companion proxy for property ${propertyName}:`,
|
|
3292
3314
|
error
|
|
3293
3315
|
);
|
|
@@ -3324,7 +3346,7 @@ function makeSafeObservable(instance) {
|
|
|
3324
3346
|
try {
|
|
3325
3347
|
return makeAutoObservable(instance);
|
|
3326
3348
|
} catch (e) {
|
|
3327
|
-
log$
|
|
3349
|
+
log$14.error("Failed to make observable:", e);
|
|
3328
3350
|
return instance;
|
|
3329
3351
|
}
|
|
3330
3352
|
}
|
|
@@ -3334,9 +3356,8 @@ const modelConstructorProxy = {
|
|
|
3334
3356
|
const kosContext = KosContextManager.createContext(modelId);
|
|
3335
3357
|
resolveParentContext(TargetClass, modelId, initialData);
|
|
3336
3358
|
const hasLoggerAware = !!TargetClass.prototype[LoggerSetup];
|
|
3337
|
-
const logger = hasLoggerAware ? null :
|
|
3338
|
-
|
|
3339
|
-
group: TargetClass[LogConfig]?.group ?? "kos-model"
|
|
3359
|
+
const logger = hasLoggerAware ? null : KosLoggerFactory.create({
|
|
3360
|
+
modelTypeName: TargetClass.prototype.modelTypeId
|
|
3340
3361
|
});
|
|
3341
3362
|
const modelInstance = new TargetClass(modelId, initialData, {
|
|
3342
3363
|
logger,
|
|
@@ -3367,8 +3388,8 @@ function kosModel(config2) {
|
|
|
3367
3388
|
typedCtor.prototype[OptionsRequired] = true;
|
|
3368
3389
|
}
|
|
3369
3390
|
KosLog.ifDebug(() => {
|
|
3370
|
-
|
|
3371
|
-
});
|
|
3391
|
+
log$14.debug(`Registering model with id ${modelConfig.modelTypeId}`);
|
|
3392
|
+
}, log$14);
|
|
3372
3393
|
const proxiedCtor = new Proxy(typedCtor, modelConstructorProxy);
|
|
3373
3394
|
if (modelConfig.singleton !== void 0) {
|
|
3374
3395
|
let registration;
|
|
@@ -3664,7 +3685,10 @@ const KosDeletionManager = {
|
|
|
3664
3685
|
}
|
|
3665
3686
|
}
|
|
3666
3687
|
};
|
|
3667
|
-
const log$
|
|
3688
|
+
const log$13 = KosLog.createLogger({
|
|
3689
|
+
group: LogGroup.core,
|
|
3690
|
+
name: "kos-dependency-manager"
|
|
3691
|
+
});
|
|
3668
3692
|
class KosDependencyManager {
|
|
3669
3693
|
_usedByCache = /* @__PURE__ */ new Map();
|
|
3670
3694
|
_usesCache = /* @__PURE__ */ new Map();
|
|
@@ -3719,7 +3743,7 @@ class KosDependencyManager {
|
|
|
3719
3743
|
canDestroy(modelId) {
|
|
3720
3744
|
const usedBy = this._usedByCache.get(modelId);
|
|
3721
3745
|
if (usedBy?.length) {
|
|
3722
|
-
log$
|
|
3746
|
+
log$13.info(`Model ${modelId} is still used by: ${usedBy.join(", ")}`);
|
|
3723
3747
|
return false;
|
|
3724
3748
|
}
|
|
3725
3749
|
return true;
|
|
@@ -3729,7 +3753,10 @@ class KosDependencyManager {
|
|
|
3729
3753
|
this._usesCache.clear();
|
|
3730
3754
|
}
|
|
3731
3755
|
}
|
|
3732
|
-
const log$
|
|
3756
|
+
const log$12 = KosLog.createLogger({
|
|
3757
|
+
group: LogGroup.core,
|
|
3758
|
+
name: "kos-model-cache"
|
|
3759
|
+
});
|
|
3733
3760
|
class KosModelCache {
|
|
3734
3761
|
constructor(preloadKeys = []) {
|
|
3735
3762
|
this.preloadKeys = preloadKeys;
|
|
@@ -3780,11 +3807,11 @@ class KosModelCache {
|
|
|
3780
3807
|
}
|
|
3781
3808
|
preload(createFn) {
|
|
3782
3809
|
if (this._isPreloaded) {
|
|
3783
|
-
log$
|
|
3810
|
+
log$12.debug("Returning cached preloaded models");
|
|
3784
3811
|
return this._preloaded;
|
|
3785
3812
|
}
|
|
3786
3813
|
this._preloaded = this.preloadKeys.map((key) => {
|
|
3787
|
-
log$
|
|
3814
|
+
log$12.debug(
|
|
3788
3815
|
`Preloading model: ${typeof key === "string" ? key : key.modelType}`
|
|
3789
3816
|
);
|
|
3790
3817
|
return createFn(key);
|
|
@@ -3806,6 +3833,10 @@ const clearModelHookCacheEntry = (modelId) => {
|
|
|
3806
3833
|
cache.delete(modelId);
|
|
3807
3834
|
}
|
|
3808
3835
|
};
|
|
3836
|
+
const log$11 = KosLog.createLogger({
|
|
3837
|
+
group: LogGroup.core,
|
|
3838
|
+
name: "model-error-utils"
|
|
3839
|
+
});
|
|
3809
3840
|
class KosModelError extends Error {
|
|
3810
3841
|
context;
|
|
3811
3842
|
originalCause;
|
|
@@ -3867,10 +3898,10 @@ function enrichError(error, context) {
|
|
|
3867
3898
|
}
|
|
3868
3899
|
function logErrorCollection(errors, summary) {
|
|
3869
3900
|
if (errors.length === 0) return;
|
|
3870
|
-
|
|
3901
|
+
log$11.error(`${summary} - ${errors.length} error(s) occurred:`);
|
|
3871
3902
|
errors.forEach(({ error, context }, index) => {
|
|
3872
3903
|
const enriched = error instanceof KosModelError ? error : enrichError(error, context);
|
|
3873
|
-
|
|
3904
|
+
log$11.error(
|
|
3874
3905
|
` [${index + 1}/${errors.length}] ${enriched.toDetailedString()}`
|
|
3875
3906
|
);
|
|
3876
3907
|
});
|
|
@@ -3886,7 +3917,10 @@ function logModelInstantiationError(error, context) {
|
|
|
3886
3917
|
});
|
|
3887
3918
|
}
|
|
3888
3919
|
const isKosCompanionTypeFactory = (obj) => typeof obj === "function";
|
|
3889
|
-
const log$
|
|
3920
|
+
const log$10 = KosLog.createLogger({
|
|
3921
|
+
group: LogGroup.core,
|
|
3922
|
+
name: "kos-companion-instantiator"
|
|
3923
|
+
});
|
|
3890
3924
|
class KosCompanionInstantiator {
|
|
3891
3925
|
constructor(registry, cache2, createModel) {
|
|
3892
3926
|
this.registry = registry;
|
|
@@ -3908,7 +3942,7 @@ class KosCompanionInstantiator {
|
|
|
3908
3942
|
createCompanionModels(model, options, lifecycle) {
|
|
3909
3943
|
const companionDefs = this.getCompanionDefinitions(model.modelTypeName);
|
|
3910
3944
|
if (lifecycle !== void 0) {
|
|
3911
|
-
log$
|
|
3945
|
+
log$10.debug(
|
|
3912
3946
|
`Creating ${lifecycle} lifecycle companions for ${model.modelTypeName} [${model.modelId}]`
|
|
3913
3947
|
);
|
|
3914
3948
|
}
|
|
@@ -3960,7 +3994,7 @@ class KosCompanionInstantiator {
|
|
|
3960
3994
|
runInAction(() => {
|
|
3961
3995
|
model.modelData[property] = mixin.modelData;
|
|
3962
3996
|
});
|
|
3963
|
-
log$
|
|
3997
|
+
log$10.debug(
|
|
3964
3998
|
`Created mixin ${registration.type} for ${model.modelTypeName} [${model.modelId}]`
|
|
3965
3999
|
);
|
|
3966
4000
|
});
|
|
@@ -3992,7 +4026,7 @@ class KosCompanionInstantiator {
|
|
|
3992
4026
|
resolveFactoryCompanion(companionDef, model, options, requestedLifecycle) {
|
|
3993
4027
|
const companionType = companionDef.type(model.modelData, options);
|
|
3994
4028
|
if (!companionType) {
|
|
3995
|
-
log$
|
|
4029
|
+
log$10.debug(
|
|
3996
4030
|
`Companion factory returned undefined for ${model.modelTypeName} at ${requestedLifecycle || "INIT"} phase`
|
|
3997
4031
|
);
|
|
3998
4032
|
return null;
|
|
@@ -4051,7 +4085,7 @@ class KosCompanionInstantiator {
|
|
|
4051
4085
|
);
|
|
4052
4086
|
if (companion) {
|
|
4053
4087
|
this.attachCompanionToParent(companion, parentModel);
|
|
4054
|
-
log$
|
|
4088
|
+
log$10.debug(
|
|
4055
4089
|
`Created ${lifecycle || "INIT"} companion ${companionType} for ${parentModel.modelTypeName} [${parentModel.modelId}]`
|
|
4056
4090
|
);
|
|
4057
4091
|
}
|
|
@@ -4067,7 +4101,7 @@ class KosCompanionInstantiator {
|
|
|
4067
4101
|
*/
|
|
4068
4102
|
companionAlreadyExists(companionId, companionType, parentTypeName) {
|
|
4069
4103
|
if (this.cache.hasModel(companionId)) {
|
|
4070
|
-
log$
|
|
4104
|
+
log$10.debug(
|
|
4071
4105
|
`Companion ${companionType} already exists for ${parentTypeName}`
|
|
4072
4106
|
);
|
|
4073
4107
|
return true;
|
|
@@ -4152,6 +4186,10 @@ const TransitionMap = {
|
|
|
4152
4186
|
/* INIT */
|
|
4153
4187
|
]: transitionToInit
|
|
4154
4188
|
};
|
|
4189
|
+
const log$$ = KosLog.createLogger({
|
|
4190
|
+
group: LogGroup.core,
|
|
4191
|
+
name: "promise-utils"
|
|
4192
|
+
});
|
|
4155
4193
|
class ModelError extends Error {
|
|
4156
4194
|
model;
|
|
4157
4195
|
constructor(message, model) {
|
|
@@ -4163,7 +4201,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4163
4201
|
let timeoutId;
|
|
4164
4202
|
const promise = new Promise((_, reject) => {
|
|
4165
4203
|
timeoutId = setTimeout(() => {
|
|
4166
|
-
|
|
4204
|
+
log$$.error(
|
|
4167
4205
|
`Model ${model.modelId} - ${model.modelTypeName} - ${status} timed out after ${ms}ms`
|
|
4168
4206
|
);
|
|
4169
4207
|
reject(
|
|
@@ -4179,6 +4217,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4179
4217
|
};
|
|
4180
4218
|
return { promise, cancel };
|
|
4181
4219
|
};
|
|
4220
|
+
const log$_ = KosLog.createLogger({ group: LogGroup.core, name: "model-utils" });
|
|
4182
4221
|
const createModelDependency = (model, dependency) => {
|
|
4183
4222
|
const _dataModelId = dependency.id || dependency.modelType;
|
|
4184
4223
|
const dataModelId = resolveParameters({
|
|
@@ -4187,7 +4226,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4187
4226
|
modelId: model.modelId
|
|
4188
4227
|
});
|
|
4189
4228
|
const resolutionPolicy = dependency.resolutionPolicy || DependencyResolutionPolicy.CREATE;
|
|
4190
|
-
|
|
4229
|
+
log$_.debug(
|
|
4191
4230
|
`Resolving dependent model ${dependency.modelType} with id ${dataModelId} (policy: ${resolutionPolicy})`
|
|
4192
4231
|
);
|
|
4193
4232
|
const options = Object.keys(dependency?.options || {}).reduce((acc, curr) => {
|
|
@@ -4203,7 +4242,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4203
4242
|
const modelRegistry = modelManager.registry.models[dependency.modelType];
|
|
4204
4243
|
if (!modelRegistry) {
|
|
4205
4244
|
const errorMessage = `No model registered for type ${dependency.modelType}`;
|
|
4206
|
-
|
|
4245
|
+
log$_.error(
|
|
4207
4246
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4208
4247
|
- Dependency Type: ${dependency.modelType}
|
|
4209
4248
|
- Dependency ID: ${dataModelId}
|
|
@@ -4213,7 +4252,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4213
4252
|
- Error: ${errorMessage}`
|
|
4214
4253
|
);
|
|
4215
4254
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4216
|
-
|
|
4255
|
+
log$_.warn(
|
|
4217
4256
|
`Model type not registered (policy: CONTINUE) - Model ${model.modelId} will continue without dependency ${dependency.modelType} [${dataModelId}]`
|
|
4218
4257
|
);
|
|
4219
4258
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4226,7 +4265,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4226
4265
|
if (existingModel) {
|
|
4227
4266
|
if (existingModel.modelTypeName !== dependency.modelType) {
|
|
4228
4267
|
const errorMessage = `Model type mismatch: expected ${dependency.modelType}, found ${existingModel.modelTypeName}`;
|
|
4229
|
-
|
|
4268
|
+
log$_.error(
|
|
4230
4269
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4231
4270
|
- Dependency Type: ${dependency.modelType}
|
|
4232
4271
|
- Dependency ID: ${dataModelId}
|
|
@@ -4237,7 +4276,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4237
4276
|
- Error: ${errorMessage}`
|
|
4238
4277
|
);
|
|
4239
4278
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4240
|
-
|
|
4279
|
+
log$_.warn(
|
|
4241
4280
|
`Model type mismatch (policy: CONTINUE) - Model ${model.modelId} will continue without dependency`
|
|
4242
4281
|
);
|
|
4243
4282
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4246,7 +4285,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4246
4285
|
`Dependency resolution failed - Model ${model.modelId} cannot resolve dependency ${dependency.modelType} [${dataModelId}]: ${errorMessage}`
|
|
4247
4286
|
);
|
|
4248
4287
|
}
|
|
4249
|
-
|
|
4288
|
+
log$_.debug(
|
|
4250
4289
|
`Found existing dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4251
4290
|
);
|
|
4252
4291
|
return {
|
|
@@ -4255,18 +4294,18 @@ const createModelDependency = (model, dependency) => {
|
|
|
4255
4294
|
success: true
|
|
4256
4295
|
};
|
|
4257
4296
|
}
|
|
4258
|
-
|
|
4297
|
+
log$_.debug(
|
|
4259
4298
|
`Model ${dependency.modelType} [${dataModelId}] does not exist. Applying resolution policy: ${resolutionPolicy}`
|
|
4260
4299
|
);
|
|
4261
4300
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4262
|
-
|
|
4301
|
+
log$_.warn(
|
|
4263
4302
|
`Model ${dependency.modelType} [${dataModelId}] not found (policy: CONTINUE) - Model ${model.modelId} will continue without this dependency`
|
|
4264
4303
|
);
|
|
4265
4304
|
return { dependentModel: null, dataModelId, success: false };
|
|
4266
4305
|
}
|
|
4267
4306
|
if (resolutionPolicy === DependencyResolutionPolicy.FAIL) {
|
|
4268
4307
|
const errorMessage = `No ${dependency.modelType} model with id ${dataModelId} exists`;
|
|
4269
|
-
|
|
4308
|
+
log$_.error(
|
|
4270
4309
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4271
4310
|
- Dependency Type: ${dependency.modelType}
|
|
4272
4311
|
- Dependency ID: ${dataModelId}
|
|
@@ -4284,7 +4323,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4284
4323
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
4285
4324
|
if (requiresOptions && !hasOptions) {
|
|
4286
4325
|
const errorMessage = `Model ${dependency.modelType} requires options but none were provided`;
|
|
4287
|
-
|
|
4326
|
+
log$_.error(
|
|
4288
4327
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4289
4328
|
- Dependency Type: ${dependency.modelType}
|
|
4290
4329
|
- Dependency ID: ${dataModelId}
|
|
@@ -4305,13 +4344,13 @@ const createModelDependency = (model, dependency) => {
|
|
|
4305
4344
|
dataModelId,
|
|
4306
4345
|
options
|
|
4307
4346
|
);
|
|
4308
|
-
|
|
4347
|
+
log$_.debug(
|
|
4309
4348
|
`Successfully created dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4310
4349
|
);
|
|
4311
4350
|
return { dependentModel, dataModelId, success: true };
|
|
4312
4351
|
} catch (error) {
|
|
4313
4352
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4314
|
-
|
|
4353
|
+
log$_.error(
|
|
4315
4354
|
`Failed to create dependency for model ${model.modelId}:
|
|
4316
4355
|
- Dependency Type: ${dependency.modelType}
|
|
4317
4356
|
- Dependency ID: ${dataModelId}
|
|
@@ -4327,14 +4366,14 @@ const createModelDependency = (model, dependency) => {
|
|
|
4327
4366
|
const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY) => {
|
|
4328
4367
|
const dependencies = model.modelData?.[DependencyModels] || {};
|
|
4329
4368
|
if (Object.keys(dependencies).length === 0) {
|
|
4330
|
-
|
|
4369
|
+
log$_.debug(`${model.modelId} has no dependencies. Returning`);
|
|
4331
4370
|
return [];
|
|
4332
4371
|
}
|
|
4333
4372
|
const dependenciesByLifecycle = Object.keys(dependencies).filter((key) => dependencies[key].lifecycle === lifecycle).map((key) => {
|
|
4334
4373
|
const dependency = dependencies[key];
|
|
4335
4374
|
const resolutionResult = createModelDependency(model, dependency);
|
|
4336
4375
|
if (!resolutionResult.success || !resolutionResult.dependentModel) {
|
|
4337
|
-
|
|
4376
|
+
log$_.debug(
|
|
4338
4377
|
`Skipping dependency ${dependency.modelType} with id ${resolutionResult.dataModelId} - resolution failed with CONTINUE policy`
|
|
4339
4378
|
);
|
|
4340
4379
|
model.modelData[key] = void 0;
|
|
@@ -4342,12 +4381,12 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4342
4381
|
}
|
|
4343
4382
|
const { dependentModel, dataModelId } = resolutionResult;
|
|
4344
4383
|
model.modelData[key] = dependentModel.data;
|
|
4345
|
-
|
|
4384
|
+
log$_.debug(
|
|
4346
4385
|
`waiting for dependent model ${dependency.modelType} with id ${dataModelId} - waiting for WHENREADY`
|
|
4347
4386
|
);
|
|
4348
4387
|
const readyFn = async (dependentModel2, modelType, id) => {
|
|
4349
4388
|
await dependentModel2.whenReady?.();
|
|
4350
|
-
|
|
4389
|
+
log$_.debug(`dependent model ${modelType} with id ${id} - READY`);
|
|
4351
4390
|
};
|
|
4352
4391
|
const { promise, cancel } = rejectAfterDelay$1(
|
|
4353
4392
|
MODEL_PROMISE_TIMEOUT_MS,
|
|
@@ -4368,7 +4407,7 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4368
4407
|
lifecycle,
|
|
4369
4408
|
operation: "dependency whenReady()"
|
|
4370
4409
|
});
|
|
4371
|
-
|
|
4410
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4372
4411
|
cancel();
|
|
4373
4412
|
throw enrichedError;
|
|
4374
4413
|
}),
|
|
@@ -4378,13 +4417,13 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4378
4417
|
return dependenciesByLifecycle;
|
|
4379
4418
|
};
|
|
4380
4419
|
const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycle) => {
|
|
4381
|
-
|
|
4420
|
+
log$_.debug(`Execute lifecycle with ${models2.length} models`);
|
|
4382
4421
|
if (models2.length === 0) {
|
|
4383
|
-
|
|
4422
|
+
log$_.debug(`${sourceModel.modelId} has no children. Returning`);
|
|
4384
4423
|
return;
|
|
4385
4424
|
}
|
|
4386
4425
|
if (!target) {
|
|
4387
|
-
|
|
4426
|
+
log$_.error(
|
|
4388
4427
|
`${sourceModel.modelId} is not transitioning with a valid target ${target}`
|
|
4389
4428
|
);
|
|
4390
4429
|
return;
|
|
@@ -4395,12 +4434,10 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4395
4434
|
p = TransitionMap[target](model);
|
|
4396
4435
|
} else {
|
|
4397
4436
|
if (!model) {
|
|
4398
|
-
|
|
4437
|
+
log$_.error("model is undefined. This shouldn't happen");
|
|
4399
4438
|
}
|
|
4400
4439
|
if (!TransitionMap[target]) {
|
|
4401
|
-
|
|
4402
|
-
`There is no promise in the Transition Map for ${target}`
|
|
4403
|
-
);
|
|
4440
|
+
log$_.error(`There is no promise in the Transition Map for ${target}`);
|
|
4404
4441
|
}
|
|
4405
4442
|
}
|
|
4406
4443
|
return {
|
|
@@ -4412,11 +4449,11 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4412
4449
|
};
|
|
4413
4450
|
}).filter((modelPromise) => {
|
|
4414
4451
|
if (!modelPromise.promise) {
|
|
4415
|
-
|
|
4452
|
+
log$_.error(`No promise found ${modelPromise.modelId}`);
|
|
4416
4453
|
return false;
|
|
4417
4454
|
}
|
|
4418
4455
|
if (!modelPromise.model) {
|
|
4419
|
-
|
|
4456
|
+
log$_.error(`No model found ${modelPromise.modelId}`);
|
|
4420
4457
|
return false;
|
|
4421
4458
|
}
|
|
4422
4459
|
return true;
|
|
@@ -4445,7 +4482,7 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4445
4482
|
lifecycle: sourceLifecycle,
|
|
4446
4483
|
operation: `transition to ${target}`
|
|
4447
4484
|
});
|
|
4448
|
-
|
|
4485
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4449
4486
|
timeoutCancel();
|
|
4450
4487
|
throw enrichedError;
|
|
4451
4488
|
}),
|
|
@@ -4491,10 +4528,10 @@ const executeDependentModelLifecycle = async (model, lifecycle) => {
|
|
|
4491
4528
|
);
|
|
4492
4529
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
4493
4530
|
if (failed.length) {
|
|
4494
|
-
|
|
4531
|
+
log$_.error(
|
|
4495
4532
|
`There were ${failed.length} failed dependent models on ${lifecycle}`
|
|
4496
4533
|
);
|
|
4497
|
-
|
|
4534
|
+
log$_.error(failed);
|
|
4498
4535
|
}
|
|
4499
4536
|
};
|
|
4500
4537
|
function applyKosModelDevtoolsSupport(model) {
|
|
@@ -4758,7 +4795,10 @@ class KosEffectManager {
|
|
|
4758
4795
|
this.disposers = [];
|
|
4759
4796
|
}
|
|
4760
4797
|
}
|
|
4761
|
-
const log$
|
|
4798
|
+
const log$Z = KosLog.createLogger({
|
|
4799
|
+
group: LogGroup.core,
|
|
4800
|
+
name: "model-active-machine"
|
|
4801
|
+
});
|
|
4762
4802
|
const activeMachine = (model) => {
|
|
4763
4803
|
const machine2 = createMachine(KosModelState.INACTIVE, {
|
|
4764
4804
|
[KosModelState.FAILED]: state(
|
|
@@ -4813,11 +4853,14 @@ const activeMachine = (model) => {
|
|
|
4813
4853
|
});
|
|
4814
4854
|
const service2 = interpret(
|
|
4815
4855
|
machine2,
|
|
4816
|
-
(_service) => log$
|
|
4856
|
+
(_service) => log$Z.debug(_service.machine.current)
|
|
4817
4857
|
);
|
|
4818
4858
|
return { service: service2, machine: machine2 };
|
|
4819
4859
|
};
|
|
4820
|
-
const log$
|
|
4860
|
+
const log$Y = KosLog.createLogger({
|
|
4861
|
+
group: LogGroup.core,
|
|
4862
|
+
name: "model-online-machine"
|
|
4863
|
+
});
|
|
4821
4864
|
const onlineMachine = (model) => {
|
|
4822
4865
|
const machine2 = createMachine(KosModelState.OFFLINE, {
|
|
4823
4866
|
[KosModelState.ONLINE]: state(
|
|
@@ -4835,7 +4878,7 @@ const onlineMachine = (model) => {
|
|
|
4835
4878
|
KosModelEvents.GO_ONLINE,
|
|
4836
4879
|
KosModelState.ONLINE,
|
|
4837
4880
|
action$1(async () => {
|
|
4838
|
-
log$
|
|
4881
|
+
log$Y.debug(`Going online with model ${model.modelId}`);
|
|
4839
4882
|
await model.online();
|
|
4840
4883
|
model.onlineStatus = KosModelState.ONLINE;
|
|
4841
4884
|
await model.fsm.transitionTo(
|
|
@@ -4848,10 +4891,14 @@ const onlineMachine = (model) => {
|
|
|
4848
4891
|
});
|
|
4849
4892
|
const service2 = interpret(
|
|
4850
4893
|
machine2,
|
|
4851
|
-
(_service) => log$
|
|
4894
|
+
(_service) => log$Y.debug(_service.machine.current)
|
|
4852
4895
|
);
|
|
4853
4896
|
return { machine: machine2, service: service2 };
|
|
4854
4897
|
};
|
|
4898
|
+
const log$X = KosLog.createLogger({
|
|
4899
|
+
group: LogGroup.core,
|
|
4900
|
+
name: "model-machine"
|
|
4901
|
+
});
|
|
4855
4902
|
const machine = (model) => {
|
|
4856
4903
|
const active = activeMachine(model).service;
|
|
4857
4904
|
const online = onlineMachine(model).service;
|
|
@@ -4886,7 +4933,7 @@ const machine = (model) => {
|
|
|
4886
4933
|
`error`,
|
|
4887
4934
|
KosModelState.FAILED,
|
|
4888
4935
|
action$1(() => {
|
|
4889
|
-
|
|
4936
|
+
log$X.error(
|
|
4890
4937
|
`Model ${model.modelId} - ${model.modelTypeName} failed to initialize. Transitioning to FAILED state.`
|
|
4891
4938
|
);
|
|
4892
4939
|
model.status = KosModelState.FAILED;
|
|
@@ -5008,7 +5055,7 @@ const machine = (model) => {
|
|
|
5008
5055
|
`error`,
|
|
5009
5056
|
KosModelState.REATTACHING,
|
|
5010
5057
|
action$1((_ctx, event) => {
|
|
5011
|
-
|
|
5058
|
+
log$X.error(
|
|
5012
5059
|
`Model ${model.modelId} - ${model.modelTypeName} failed to reload; its data stays as it was. ${String(
|
|
5013
5060
|
event?.error
|
|
5014
5061
|
)}`
|
|
@@ -5045,11 +5092,14 @@ const machine = (model) => {
|
|
|
5045
5092
|
[KosModelState.FAILED]: state()
|
|
5046
5093
|
});
|
|
5047
5094
|
};
|
|
5048
|
-
const log$
|
|
5095
|
+
const log$W = KosLog.createLogger({
|
|
5096
|
+
group: LogGroup.core,
|
|
5097
|
+
name: "kos-model-lifecycle"
|
|
5098
|
+
});
|
|
5049
5099
|
const fsm = (model) => {
|
|
5050
5100
|
const service2 = interpret(
|
|
5051
5101
|
machine(model),
|
|
5052
|
-
(_service) => log$
|
|
5102
|
+
(_service) => log$W.debug(
|
|
5053
5103
|
`state machine for model ${model.modelId}: ${_service.machine.current});`
|
|
5054
5104
|
)
|
|
5055
5105
|
);
|
|
@@ -5651,6 +5701,10 @@ async function processRequestBody(body) {
|
|
|
5651
5701
|
}
|
|
5652
5702
|
throw new Error("Unsupported body type");
|
|
5653
5703
|
}
|
|
5704
|
+
const log$V = KosLog.createLogger({
|
|
5705
|
+
group: LogGroup.transport,
|
|
5706
|
+
name: "kos-message-utils"
|
|
5707
|
+
});
|
|
5654
5708
|
const createStudioMessage = ({
|
|
5655
5709
|
path,
|
|
5656
5710
|
requestId,
|
|
@@ -5864,10 +5918,10 @@ const sendKosMessage = (msg, options) => {
|
|
|
5864
5918
|
);
|
|
5865
5919
|
const socketTransport = KosCore.getInstance().transport.socket;
|
|
5866
5920
|
if (socketTransport) {
|
|
5867
|
-
|
|
5921
|
+
log$V.debug("Sending message", _msg);
|
|
5868
5922
|
socketTransport.socket.send(_msg);
|
|
5869
5923
|
} else {
|
|
5870
|
-
|
|
5924
|
+
log$V.error("socket transport is not initialized");
|
|
5871
5925
|
}
|
|
5872
5926
|
};
|
|
5873
5927
|
const createStudioMessageResponse = ({
|
|
@@ -5902,7 +5956,7 @@ const sendStudioMessageRequest = (msg, options) => {
|
|
|
5902
5956
|
if (socketTransport) {
|
|
5903
5957
|
socketTransport.socket.send(_msg);
|
|
5904
5958
|
} else {
|
|
5905
|
-
|
|
5959
|
+
log$V.error("socket transport is not initialized");
|
|
5906
5960
|
}
|
|
5907
5961
|
};
|
|
5908
5962
|
const sendStudioMessage = (msg, options) => {
|
|
@@ -5915,7 +5969,7 @@ const sendStudioMessage = (msg, options) => {
|
|
|
5915
5969
|
if (socketTransport) {
|
|
5916
5970
|
socketTransport.socket.send(_msg);
|
|
5917
5971
|
} else {
|
|
5918
|
-
|
|
5972
|
+
log$V.error("socket transport is not initialized");
|
|
5919
5973
|
}
|
|
5920
5974
|
};
|
|
5921
5975
|
const createBroadcastMessageResponse = ({
|
|
@@ -5985,7 +6039,7 @@ const sendBroadcastMessage = ({
|
|
|
5985
6039
|
if (socketTransport) {
|
|
5986
6040
|
socketTransport.socket.send(_msg);
|
|
5987
6041
|
} else {
|
|
5988
|
-
|
|
6042
|
+
log$V.error("socket transport is not initialized");
|
|
5989
6043
|
}
|
|
5990
6044
|
};
|
|
5991
6045
|
const sendKosMessageResponse = ({
|
|
@@ -6001,7 +6055,7 @@ const sendKosMessageResponse = ({
|
|
|
6001
6055
|
if (socketTransport) {
|
|
6002
6056
|
socketTransport.socket.send(_msg);
|
|
6003
6057
|
} else {
|
|
6004
|
-
|
|
6058
|
+
log$V.error("socket transport is not initialized");
|
|
6005
6059
|
}
|
|
6006
6060
|
};
|
|
6007
6061
|
const sendKosHttpMessageResponse = ({
|
|
@@ -6017,7 +6071,7 @@ const sendKosHttpMessageResponse = ({
|
|
|
6017
6071
|
if (socketTransport) {
|
|
6018
6072
|
socketTransport.socket.send(_msg);
|
|
6019
6073
|
} else {
|
|
6020
|
-
|
|
6074
|
+
log$V.error("socket transport is not initialized");
|
|
6021
6075
|
}
|
|
6022
6076
|
};
|
|
6023
6077
|
const getMessageBody = (payload, skipParse) => {
|
|
@@ -6049,7 +6103,10 @@ class TransportNotReadyError extends Error {
|
|
|
6049
6103
|
}
|
|
6050
6104
|
}
|
|
6051
6105
|
const isTransportNotReadyError = (error) => !!error && error.code === TRANSPORT_NOT_READY;
|
|
6052
|
-
const log$
|
|
6106
|
+
const log$U = KosLog.createLogger({
|
|
6107
|
+
group: LogGroup.transport,
|
|
6108
|
+
name: "kos-fetch"
|
|
6109
|
+
});
|
|
6053
6110
|
const DEFAULT_WS_TIMEOUT = 3e4;
|
|
6054
6111
|
const WS_TIMEOUT = (() => {
|
|
6055
6112
|
const configured = process.env.KOS_WS_TIMEOUT ? parseInt(process.env.KOS_WS_TIMEOUT) : DEFAULT_WS_TIMEOUT;
|
|
@@ -6114,7 +6171,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6114
6171
|
const requestId = uuid();
|
|
6115
6172
|
const urlObj = new URL(url);
|
|
6116
6173
|
const path = `${urlObj.pathname}${urlObj.search}`;
|
|
6117
|
-
log$
|
|
6174
|
+
log$U.debug(`path: ${path}`);
|
|
6118
6175
|
const budget = resolveTimeoutBudget(options?.timeout);
|
|
6119
6176
|
const messageFactory = fetchMessageFactory(options);
|
|
6120
6177
|
const signal = createRequestSignal(budget, options?.signal);
|
|
@@ -6122,12 +6179,12 @@ const kosFetchWs = async (url, options) => {
|
|
|
6122
6179
|
await transport.whenReady({ signal });
|
|
6123
6180
|
} catch (error) {
|
|
6124
6181
|
if (isTimeoutReason(error)) {
|
|
6125
|
-
log$
|
|
6182
|
+
log$U.error(
|
|
6126
6183
|
`Transport not ready${budget === void 0 ? "" : ` after ${budget}ms`} - request not sent - url: ${url}`
|
|
6127
6184
|
);
|
|
6128
6185
|
throw new TransportNotReadyError({ timeout: budget, url });
|
|
6129
6186
|
}
|
|
6130
|
-
log$
|
|
6187
|
+
log$U.debug(`Request aborted while waiting for transport - url: ${url}`);
|
|
6131
6188
|
throw error;
|
|
6132
6189
|
}
|
|
6133
6190
|
const processedBody = await processRequestBody(options?.body);
|
|
@@ -6156,9 +6213,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6156
6213
|
if (signal.aborted) {
|
|
6157
6214
|
const reason = signal.reason;
|
|
6158
6215
|
if (reason?.name === "TimeoutError") {
|
|
6159
|
-
log$
|
|
6216
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6160
6217
|
} else {
|
|
6161
|
-
log$
|
|
6218
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6162
6219
|
}
|
|
6163
6220
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6164
6221
|
return;
|
|
@@ -6167,9 +6224,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6167
6224
|
if (unsubscribe) unsubscribe();
|
|
6168
6225
|
const reason = signal.reason;
|
|
6169
6226
|
if (reason?.name === "TimeoutError") {
|
|
6170
|
-
log$
|
|
6227
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6171
6228
|
} else {
|
|
6172
|
-
log$
|
|
6229
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6173
6230
|
}
|
|
6174
6231
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6175
6232
|
};
|
|
@@ -6185,7 +6242,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6185
6242
|
try {
|
|
6186
6243
|
bodyData = base64ToArrayBuffer(responseBody);
|
|
6187
6244
|
} catch (e) {
|
|
6188
|
-
log$
|
|
6245
|
+
log$U.error("Failed to decode base64 response", e);
|
|
6189
6246
|
}
|
|
6190
6247
|
}
|
|
6191
6248
|
const response = {
|
|
@@ -6239,7 +6296,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6239
6296
|
});
|
|
6240
6297
|
}
|
|
6241
6298
|
if (parsed.files) {
|
|
6242
|
-
log$
|
|
6299
|
+
log$U.warn(
|
|
6243
6300
|
"File reconstruction in FormData not fully implemented"
|
|
6244
6301
|
);
|
|
6245
6302
|
}
|
|
@@ -6290,7 +6347,10 @@ const resolveBaseUrl = () => {
|
|
|
6290
6347
|
const URL2 = BASE_URL;
|
|
6291
6348
|
return { isMock: MOCK, URL: URL2 };
|
|
6292
6349
|
};
|
|
6293
|
-
const log$
|
|
6350
|
+
const log$T = KosLog.createLogger({
|
|
6351
|
+
group: LogGroup.transport,
|
|
6352
|
+
name: "kos-service-request"
|
|
6353
|
+
});
|
|
6294
6354
|
const ERROR_UNKNOWN = "errUnknown";
|
|
6295
6355
|
const ERROR_TRANSPORT_NOT_READY = "Transport not ready";
|
|
6296
6356
|
const MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
@@ -6316,7 +6376,7 @@ async function clientRequest(endpoint, method, options, params2, body) {
|
|
|
6316
6376
|
)}`
|
|
6317
6377
|
).join("&") : "";
|
|
6318
6378
|
const fullUrl = `${resolveBaseUrl().URL}${url}${query ? `?${query}` : ""}`;
|
|
6319
|
-
log$
|
|
6379
|
+
log$T.debug(`fullUrl: ${fullUrl}`);
|
|
6320
6380
|
const fetchOptions = {
|
|
6321
6381
|
method: String(method).toUpperCase(),
|
|
6322
6382
|
body: null,
|
|
@@ -6350,20 +6410,20 @@ async function executeFetch(fullUrl, fetchOptions) {
|
|
|
6350
6410
|
return [null, payload.data ?? payload, responseContext(response)];
|
|
6351
6411
|
} catch (error) {
|
|
6352
6412
|
if (isTransportNotReadyError(error)) {
|
|
6353
|
-
log$
|
|
6413
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6354
6414
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6355
6415
|
}
|
|
6356
6416
|
if (error instanceof DOMException) {
|
|
6357
6417
|
if (error.name === "TimeoutError") {
|
|
6358
|
-
log$
|
|
6418
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6359
6419
|
return ["Request timed out", null];
|
|
6360
6420
|
}
|
|
6361
6421
|
if (error.name === "AbortError") {
|
|
6362
|
-
log$
|
|
6422
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6363
6423
|
return ["Request aborted", null];
|
|
6364
6424
|
}
|
|
6365
6425
|
}
|
|
6366
|
-
log$
|
|
6426
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6367
6427
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6368
6428
|
}
|
|
6369
6429
|
}
|
|
@@ -6383,38 +6443,38 @@ async function executeFetchWithRetry(fullUrl, fetchOptions, config2) {
|
|
|
6383
6443
|
errorContext
|
|
6384
6444
|
];
|
|
6385
6445
|
if (config2.retryOn && !config2.retryOn(response)) {
|
|
6386
|
-
log$
|
|
6446
|
+
log$T.debug(
|
|
6387
6447
|
`Retry predicate returned false for ${fullUrl} (status ${response.status}), stopping`
|
|
6388
6448
|
);
|
|
6389
6449
|
return lastResult;
|
|
6390
6450
|
}
|
|
6391
6451
|
if (attempt < config2.maxAttempts) {
|
|
6392
6452
|
const delayMs = config2.baseDelayMs * Math.pow(config2.backoffFactor, attempt - 1);
|
|
6393
|
-
log$
|
|
6453
|
+
log$T.warn(
|
|
6394
6454
|
`Request to ${fullUrl} failed (status ${response.status}), retrying in ${delayMs}ms (attempt ${attempt}/${config2.maxAttempts})`
|
|
6395
6455
|
);
|
|
6396
6456
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
6397
6457
|
}
|
|
6398
6458
|
} catch (error) {
|
|
6399
6459
|
if (isTransportNotReadyError(error)) {
|
|
6400
|
-
log$
|
|
6460
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6401
6461
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6402
6462
|
}
|
|
6403
6463
|
if (error instanceof DOMException) {
|
|
6404
6464
|
if (error.name === "TimeoutError") {
|
|
6405
|
-
log$
|
|
6465
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6406
6466
|
return ["Request timed out", null];
|
|
6407
6467
|
}
|
|
6408
6468
|
if (error.name === "AbortError") {
|
|
6409
|
-
log$
|
|
6469
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6410
6470
|
return ["Request aborted", null];
|
|
6411
6471
|
}
|
|
6412
6472
|
}
|
|
6413
|
-
log$
|
|
6473
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6414
6474
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6415
6475
|
}
|
|
6416
6476
|
}
|
|
6417
|
-
log$
|
|
6477
|
+
log$T.error(`All ${config2.maxAttempts} attempts failed for ${fullUrl}`);
|
|
6418
6478
|
return lastResult;
|
|
6419
6479
|
}
|
|
6420
6480
|
async function captureErrorResponseContext(response) {
|
|
@@ -6463,9 +6523,9 @@ const service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
6463
6523
|
default: api$1,
|
|
6464
6524
|
kosServiceRequest
|
|
6465
6525
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
6466
|
-
const log$
|
|
6467
|
-
|
|
6468
|
-
|
|
6526
|
+
const log$S = KosLog.createLogger({
|
|
6527
|
+
group: LogGroup.core,
|
|
6528
|
+
name: "kos-service-request-manager"
|
|
6469
6529
|
});
|
|
6470
6530
|
function shouldExecuteRequest(metadata, model) {
|
|
6471
6531
|
return !metadata.condition || metadata.condition(model);
|
|
@@ -6516,7 +6576,7 @@ function isValueMissing(value) {
|
|
|
6516
6576
|
}
|
|
6517
6577
|
function validateRequiredField(value, fieldName, path, isRequired) {
|
|
6518
6578
|
if (isRequired && isValueMissing(value)) {
|
|
6519
|
-
log$
|
|
6579
|
+
log$S.warn(
|
|
6520
6580
|
`Required field '${fieldName}' is missing in response for ${path}`
|
|
6521
6581
|
);
|
|
6522
6582
|
}
|
|
@@ -6551,7 +6611,7 @@ class ServiceRequestManager {
|
|
|
6551
6611
|
this.handlers.get(lifecycle).push(metadata);
|
|
6552
6612
|
});
|
|
6553
6613
|
if (Object.keys(handlerMetadata).length > 0) {
|
|
6554
|
-
log$
|
|
6614
|
+
log$S.debug(
|
|
6555
6615
|
`Discovered ${Object.keys(handlerMetadata).length} service request handlers for model ${this.model.id}`
|
|
6556
6616
|
);
|
|
6557
6617
|
}
|
|
@@ -6566,7 +6626,7 @@ class ServiceRequestManager {
|
|
|
6566
6626
|
if (!handlers || handlers.length === 0) {
|
|
6567
6627
|
return;
|
|
6568
6628
|
}
|
|
6569
|
-
log$
|
|
6629
|
+
log$S.debug(
|
|
6570
6630
|
`Executing ${handlers.length} service requests for lifecycle ${lifecycle}`
|
|
6571
6631
|
);
|
|
6572
6632
|
await Promise.all(handlers.map((handler) => this.executeHandler(handler)));
|
|
@@ -6601,7 +6661,7 @@ class ServiceRequestManager {
|
|
|
6601
6661
|
*/
|
|
6602
6662
|
shouldProcessRequest(metadata) {
|
|
6603
6663
|
if (!shouldExecuteRequest(metadata, this.model)) {
|
|
6604
|
-
log$
|
|
6664
|
+
log$S.debug(`Skipping request ${metadata.path} - condition returned false`);
|
|
6605
6665
|
return false;
|
|
6606
6666
|
}
|
|
6607
6667
|
return true;
|
|
@@ -6806,7 +6866,7 @@ class ServiceRequestManager {
|
|
|
6806
6866
|
case "json":
|
|
6807
6867
|
return typeof value === "string" ? JSON.parse(value) : value;
|
|
6808
6868
|
default:
|
|
6809
|
-
log$
|
|
6869
|
+
log$S.warn(`Unknown transformer: ${transform}`);
|
|
6810
6870
|
return value;
|
|
6811
6871
|
}
|
|
6812
6872
|
}
|
|
@@ -6817,7 +6877,7 @@ class ServiceRequestManager {
|
|
|
6817
6877
|
if (!metadata.iterateOver) return data;
|
|
6818
6878
|
const array = this.getNestedValue(data, metadata.iterateOver);
|
|
6819
6879
|
if (!Array.isArray(array)) {
|
|
6820
|
-
log$
|
|
6880
|
+
log$S.warn(
|
|
6821
6881
|
`iterateOver path '${metadata.iterateOver}' did not resolve to an array`
|
|
6822
6882
|
);
|
|
6823
6883
|
return [];
|
|
@@ -6860,7 +6920,7 @@ class ServiceRequestManager {
|
|
|
6860
6920
|
case "throw":
|
|
6861
6921
|
throw error;
|
|
6862
6922
|
case "log":
|
|
6863
|
-
log$
|
|
6923
|
+
log$S.error(
|
|
6864
6924
|
`Service request failed for ${metadata.path}:`,
|
|
6865
6925
|
error.message
|
|
6866
6926
|
);
|
|
@@ -6920,6 +6980,10 @@ class ServiceRequestManager {
|
|
|
6920
6980
|
}
|
|
6921
6981
|
}
|
|
6922
6982
|
}
|
|
6983
|
+
KosLog.createLogger({
|
|
6984
|
+
group: LogGroup.core,
|
|
6985
|
+
name: "async-event-bus"
|
|
6986
|
+
});
|
|
6923
6987
|
class AsyncEventIterator {
|
|
6924
6988
|
subscription;
|
|
6925
6989
|
unsubscribe;
|
|
@@ -7369,6 +7433,10 @@ function encodeFutureFrame(future) {
|
|
|
7369
7433
|
JSON.stringify(future)
|
|
7370
7434
|
);
|
|
7371
7435
|
}
|
|
7436
|
+
const log$R = KosLog.createLogger({
|
|
7437
|
+
group: LogGroup.transport,
|
|
7438
|
+
name: "future-simulator"
|
|
7439
|
+
});
|
|
7372
7440
|
const DEFAULT_DURATION_MS = 5e3;
|
|
7373
7441
|
const DEFAULT_INTERVAL_MS = 250;
|
|
7374
7442
|
class KosMockFutureHandle {
|
|
@@ -7479,7 +7547,7 @@ class KosMockFutureSimulator {
|
|
|
7479
7547
|
this.deps.ensureCancelRoutes();
|
|
7480
7548
|
}
|
|
7481
7549
|
if (!options.tracker) {
|
|
7482
|
-
|
|
7550
|
+
log$R.warn(
|
|
7483
7551
|
`KosMock future ${handle.id} has no tracker — models will not link it to their request; prefer futures.fromRequest`
|
|
7484
7552
|
);
|
|
7485
7553
|
}
|
|
@@ -7511,6 +7579,10 @@ class KosMockFutureSimulator {
|
|
|
7511
7579
|
this.futures.clear();
|
|
7512
7580
|
}
|
|
7513
7581
|
}
|
|
7582
|
+
const log$Q = KosLog.createLogger({
|
|
7583
|
+
group: LogGroup.transport,
|
|
7584
|
+
name: "mock-fixtures"
|
|
7585
|
+
});
|
|
7514
7586
|
const DEFAULT_FIXTURE_SERVER_URL = "http://localhost:5676";
|
|
7515
7587
|
const DB_NAME = "kos-mock-fixtures";
|
|
7516
7588
|
const STORE_NAME = "fixtures";
|
|
@@ -7663,7 +7735,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7663
7735
|
);
|
|
7664
7736
|
}
|
|
7665
7737
|
await target.save(name, named);
|
|
7666
|
-
|
|
7738
|
+
log$Q.info(`KosMock fixture "${name}" saved`);
|
|
7667
7739
|
return name;
|
|
7668
7740
|
},
|
|
7669
7741
|
saveRecording(name) {
|
|
@@ -7686,7 +7758,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7686
7758
|
(summary) => summaries.push({ ...summary, source: "server" })
|
|
7687
7759
|
);
|
|
7688
7760
|
} catch {
|
|
7689
|
-
|
|
7761
|
+
log$Q.warn(`KosMock fixture server unreachable at ${serverUrl}`);
|
|
7690
7762
|
}
|
|
7691
7763
|
}
|
|
7692
7764
|
try {
|
|
@@ -7707,7 +7779,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7707
7779
|
},
|
|
7708
7780
|
async import() {
|
|
7709
7781
|
if (typeof document === "undefined") {
|
|
7710
|
-
|
|
7782
|
+
log$Q.warn(`KosMock fixture import requires a browser environment`);
|
|
7711
7783
|
return void 0;
|
|
7712
7784
|
}
|
|
7713
7785
|
return new Promise((resolve) => {
|
|
@@ -7727,7 +7799,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7727
7799
|
});
|
|
7728
7800
|
resolve(name);
|
|
7729
7801
|
} catch (error) {
|
|
7730
|
-
|
|
7802
|
+
log$Q.error(`KosMock fixture import failed`, error?.message);
|
|
7731
7803
|
resolve(void 0);
|
|
7732
7804
|
}
|
|
7733
7805
|
};
|
|
@@ -7802,6 +7874,10 @@ function splitUrl(url) {
|
|
|
7802
7874
|
function methodMatches(routeMethod, requestMethod) {
|
|
7803
7875
|
return routeMethod === "*" || routeMethod.toUpperCase() === requestMethod.toUpperCase();
|
|
7804
7876
|
}
|
|
7877
|
+
const log$P = KosLog.createLogger({
|
|
7878
|
+
group: LogGroup.transport,
|
|
7879
|
+
name: "mock-playback"
|
|
7880
|
+
});
|
|
7805
7881
|
const rewriteTrackers = (raw, trackerMap) => {
|
|
7806
7882
|
let out = raw;
|
|
7807
7883
|
trackerMap.forEach((liveTracker, capturedTracker) => {
|
|
@@ -7963,7 +8039,7 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7963
8039
|
if ((options.pushes ?? "scheduled") === "scheduled") {
|
|
7964
8040
|
startPushes();
|
|
7965
8041
|
}
|
|
7966
|
-
|
|
8042
|
+
log$P.info(
|
|
7967
8043
|
`KosMock fixture${name ? ` "${name}"` : ""} loaded: ${groups.size} routes, ${fixture.pushes.length} pushes (${fixture.pushes.length - unanchored.length} anchored), consume: ${consume}`
|
|
7968
8044
|
);
|
|
7969
8045
|
return {
|
|
@@ -7977,6 +8053,10 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7977
8053
|
}
|
|
7978
8054
|
};
|
|
7979
8055
|
}
|
|
8056
|
+
const log$O = KosLog.createLogger({
|
|
8057
|
+
group: LogGroup.transport,
|
|
8058
|
+
name: "mock-recorder"
|
|
8059
|
+
});
|
|
7980
8060
|
class KosMockRecorder {
|
|
7981
8061
|
recording = false;
|
|
7982
8062
|
name;
|
|
@@ -7998,14 +8078,14 @@ class KosMockRecorder {
|
|
|
7998
8078
|
this.exchanges = [];
|
|
7999
8079
|
this.pushes = [];
|
|
8000
8080
|
this.sends = [];
|
|
8001
|
-
|
|
8081
|
+
log$O.info(
|
|
8002
8082
|
`KosMock recorder started${options.name ? ` (${options.name})` : ""}`
|
|
8003
8083
|
);
|
|
8004
8084
|
}
|
|
8005
8085
|
stop() {
|
|
8006
8086
|
const fixture = this.toFixture();
|
|
8007
8087
|
this.recording = false;
|
|
8008
|
-
|
|
8088
|
+
log$O.info(
|
|
8009
8089
|
`KosMock recorder stopped: ${fixture.exchanges.length} exchanges, ${fixture.pushes.length} pushes, ${fixture.sends?.length ?? 0} sends`
|
|
8010
8090
|
);
|
|
8011
8091
|
return fixture;
|
|
@@ -8022,7 +8102,7 @@ class KosMockRecorder {
|
|
|
8022
8102
|
}
|
|
8023
8103
|
download(filename) {
|
|
8024
8104
|
if (typeof document === "undefined") {
|
|
8025
|
-
|
|
8105
|
+
log$O.warn(`KosMock recorder download requires a browser environment`);
|
|
8026
8106
|
return;
|
|
8027
8107
|
}
|
|
8028
8108
|
const fixture = this.toFixture();
|
|
@@ -8137,6 +8217,10 @@ class KosMockRecorder {
|
|
|
8137
8217
|
}
|
|
8138
8218
|
}
|
|
8139
8219
|
}
|
|
8220
|
+
const log$N = KosLog.createLogger({
|
|
8221
|
+
group: LogGroup.transport,
|
|
8222
|
+
name: "mock-setups"
|
|
8223
|
+
});
|
|
8140
8224
|
const dynamicImport = (url) => import(
|
|
8141
8225
|
/* @vite-ignore */
|
|
8142
8226
|
/* webpackIgnore: true */
|
|
@@ -8169,7 +8253,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8169
8253
|
try {
|
|
8170
8254
|
entry.teardown?.();
|
|
8171
8255
|
} catch (error) {
|
|
8172
|
-
|
|
8256
|
+
log$N.error(`KosMock setup "${name}" teardown threw`, error?.message);
|
|
8173
8257
|
}
|
|
8174
8258
|
return true;
|
|
8175
8259
|
};
|
|
@@ -8196,7 +8280,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8196
8280
|
handle,
|
|
8197
8281
|
teardown: typeof result === "function" ? result : void 0
|
|
8198
8282
|
});
|
|
8199
|
-
|
|
8283
|
+
log$N.info(`KosMock setup "${name}" installed from ${url}`);
|
|
8200
8284
|
return handle;
|
|
8201
8285
|
},
|
|
8202
8286
|
async list() {
|
|
@@ -8219,6 +8303,10 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8219
8303
|
};
|
|
8220
8304
|
return store;
|
|
8221
8305
|
}
|
|
8306
|
+
const log$M = KosLog.createLogger({
|
|
8307
|
+
group: LogGroup.transport,
|
|
8308
|
+
name: "mock-config"
|
|
8309
|
+
});
|
|
8222
8310
|
const asWireValue = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
8223
8311
|
const configTopic = (beanId) => `/kos/config/${beanId}`;
|
|
8224
8312
|
const changeEnvelope = (props, previousValues = {}) => {
|
|
@@ -8286,7 +8374,7 @@ function createConfigFacade(registry) {
|
|
|
8286
8374
|
return void 0;
|
|
8287
8375
|
}
|
|
8288
8376
|
if (injectedKeys.length < keys.length) {
|
|
8289
|
-
|
|
8377
|
+
log$M.warn(
|
|
8290
8378
|
`KosMock config.inject ${beanId}: mixed write passes through; injected props will be rejected by the backend: ${injectedKeys.join(
|
|
8291
8379
|
", "
|
|
8292
8380
|
)}`
|
|
@@ -8321,6 +8409,10 @@ function createConfigFacade(registry) {
|
|
|
8321
8409
|
};
|
|
8322
8410
|
return { update, inject };
|
|
8323
8411
|
}
|
|
8412
|
+
const log$L = KosLog.createLogger({
|
|
8413
|
+
group: LogGroup.transport,
|
|
8414
|
+
name: "mock-registry"
|
|
8415
|
+
});
|
|
8324
8416
|
const PENDING_REQUEST_CAP = 500;
|
|
8325
8417
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8326
8418
|
const asHandler = (handler) => typeof handler === "function" ? handler : () => handler;
|
|
@@ -8426,7 +8518,7 @@ class KosMockRegistry {
|
|
|
8426
8518
|
changed = true;
|
|
8427
8519
|
}
|
|
8428
8520
|
} catch (error) {
|
|
8429
|
-
|
|
8521
|
+
log$L.error(
|
|
8430
8522
|
`KosMock transformer for ${transformer.method} ${transformer.pattern} threw`,
|
|
8431
8523
|
error?.message
|
|
8432
8524
|
);
|
|
@@ -8542,7 +8634,7 @@ class KosMockRegistry {
|
|
|
8542
8634
|
try {
|
|
8543
8635
|
notify();
|
|
8544
8636
|
} catch (error) {
|
|
8545
|
-
|
|
8637
|
+
log$L.error(`KosMock observer threw`, error?.message);
|
|
8546
8638
|
}
|
|
8547
8639
|
}
|
|
8548
8640
|
loadFixture(fixture, options) {
|
|
@@ -8565,13 +8657,13 @@ class KosMockRegistry {
|
|
|
8565
8657
|
enable() {
|
|
8566
8658
|
if (!this.enabledFlag) {
|
|
8567
8659
|
this.enabledFlag = true;
|
|
8568
|
-
|
|
8660
|
+
log$L.info(`KosMock enabled`);
|
|
8569
8661
|
}
|
|
8570
8662
|
}
|
|
8571
8663
|
disable() {
|
|
8572
8664
|
if (this.enabledFlag) {
|
|
8573
8665
|
this.enabledFlag = false;
|
|
8574
|
-
|
|
8666
|
+
log$L.info(`KosMock disabled`);
|
|
8575
8667
|
}
|
|
8576
8668
|
}
|
|
8577
8669
|
get standalone() {
|
|
@@ -8647,7 +8739,7 @@ class KosMockRegistry {
|
|
|
8647
8739
|
}
|
|
8648
8740
|
publishFrame(rawFrame) {
|
|
8649
8741
|
if (this.injectors.size === 0) {
|
|
8650
|
-
|
|
8742
|
+
log$L.warn(
|
|
8651
8743
|
`KosMock.publishFrame: no active transport to deliver the frame`
|
|
8652
8744
|
);
|
|
8653
8745
|
return;
|
|
@@ -8690,7 +8782,7 @@ class KosMockRegistry {
|
|
|
8690
8782
|
if (teardown) {
|
|
8691
8783
|
this.scenarioTeardowns.set(id, teardown);
|
|
8692
8784
|
}
|
|
8693
|
-
|
|
8785
|
+
log$L.info(`KosMock scenario "${scenario.name}" installed`);
|
|
8694
8786
|
const remove = () => {
|
|
8695
8787
|
const dispose = this.scenarioTeardowns.get(id);
|
|
8696
8788
|
this.scenarioTeardowns.delete(id);
|
|
@@ -8794,7 +8886,7 @@ class KosMockRegistry {
|
|
|
8794
8886
|
return true;
|
|
8795
8887
|
}
|
|
8796
8888
|
if (policy === "warn") {
|
|
8797
|
-
|
|
8889
|
+
log$L.warn(`KosMock: unmatched ${frame.method} ${path}`);
|
|
8798
8890
|
}
|
|
8799
8891
|
return false;
|
|
8800
8892
|
}
|
|
@@ -8830,7 +8922,7 @@ class KosMockRegistry {
|
|
|
8830
8922
|
try {
|
|
8831
8923
|
accepted = route.when(scopedRequest);
|
|
8832
8924
|
} catch (error) {
|
|
8833
|
-
|
|
8925
|
+
log$L.error(
|
|
8834
8926
|
`KosMock \`when\` guard for ${route.method} ${route.pattern} threw`,
|
|
8835
8927
|
error?.message
|
|
8836
8928
|
);
|
|
@@ -8843,7 +8935,7 @@ class KosMockRegistry {
|
|
|
8843
8935
|
try {
|
|
8844
8936
|
response = await route.handler(scopedRequest, this.context());
|
|
8845
8937
|
} catch (error) {
|
|
8846
|
-
|
|
8938
|
+
log$L.error(
|
|
8847
8939
|
`KosMock handler for ${route.method} ${route.pattern} threw`,
|
|
8848
8940
|
error?.message
|
|
8849
8941
|
);
|
|
@@ -8876,7 +8968,7 @@ class KosMockRegistry {
|
|
|
8876
8968
|
return;
|
|
8877
8969
|
}
|
|
8878
8970
|
if (policy === "warn") {
|
|
8879
|
-
|
|
8971
|
+
log$L.warn(
|
|
8880
8972
|
`KosMock: all routes declined ${request.method} ${request.path}`
|
|
8881
8973
|
);
|
|
8882
8974
|
}
|
|
@@ -8991,7 +9083,7 @@ if (typeof window !== "undefined") {
|
|
|
8991
9083
|
if (fixture) {
|
|
8992
9084
|
bootLoads.push(
|
|
8993
9085
|
KosMock.fixtures.play(fixture).then(() => void 0).catch(
|
|
8994
|
-
(error) =>
|
|
9086
|
+
(error) => log$L.error(
|
|
8995
9087
|
`KosMock: boot fixture "${fixture}" failed to load`,
|
|
8996
9088
|
error?.message
|
|
8997
9089
|
)
|
|
@@ -9002,7 +9094,7 @@ if (typeof window !== "undefined") {
|
|
|
9002
9094
|
for (const name of setups.split(",").filter(Boolean)) {
|
|
9003
9095
|
bootLoads.push(
|
|
9004
9096
|
KosMock.setups.load(name).then(() => void 0).catch(
|
|
9005
|
-
(error) =>
|
|
9097
|
+
(error) => log$L.error(
|
|
9006
9098
|
`KosMock: boot setup "${name}" failed to load`,
|
|
9007
9099
|
error?.message
|
|
9008
9100
|
)
|
|
@@ -9112,6 +9204,14 @@ class WebSocketBridgeTransport extends WebSocket {
|
|
|
9112
9204
|
super(address);
|
|
9113
9205
|
}
|
|
9114
9206
|
}
|
|
9207
|
+
const log$K = KosLog.createLogger({
|
|
9208
|
+
group: LogGroup.transport,
|
|
9209
|
+
name: "base-message-transport"
|
|
9210
|
+
});
|
|
9211
|
+
const messageLog = KosLog.createLogger({
|
|
9212
|
+
group: LogGroup.transport,
|
|
9213
|
+
name: MESSAGE_LOGGER_NAME
|
|
9214
|
+
});
|
|
9115
9215
|
var WebSocketEvents = /* @__PURE__ */ ((WebSocketEvents2) => {
|
|
9116
9216
|
WebSocketEvents2["CONNECTED"] = `websocket.connected`;
|
|
9117
9217
|
WebSocketEvents2["DISCONNECTED"] = `websocket.disconnected`;
|
|
@@ -9208,9 +9308,9 @@ class BaseTransport {
|
|
|
9208
9308
|
}
|
|
9209
9309
|
onMessage(event) {
|
|
9210
9310
|
try {
|
|
9211
|
-
|
|
9311
|
+
log$K.debug("webSocketTransport: onMessage received");
|
|
9212
9312
|
const { headers, body } = this.processMessageEvent(event);
|
|
9213
|
-
|
|
9313
|
+
messageLog.debug("received", event.data);
|
|
9214
9314
|
const subscriptionTopic = headers["subscription"] || headers[this.RESPONSE_ID_HEADER] || headers["topic"] || headers["type"];
|
|
9215
9315
|
if (subscriptionTopic) {
|
|
9216
9316
|
let msgBody = body;
|
|
@@ -9226,11 +9326,11 @@ class BaseTransport {
|
|
|
9226
9326
|
publish(subscriptionTopic, msgBody, msgHeaders);
|
|
9227
9327
|
}
|
|
9228
9328
|
} catch (ex) {
|
|
9229
|
-
|
|
9329
|
+
log$K.error(`onMessage exception`, ex.message, ex.stack);
|
|
9230
9330
|
}
|
|
9231
9331
|
}
|
|
9232
9332
|
onOpen(event) {
|
|
9233
|
-
|
|
9333
|
+
log$K.info(`websocket connection opened`);
|
|
9234
9334
|
this.socket = event.currentTarget;
|
|
9235
9335
|
runInAction(() => {
|
|
9236
9336
|
this.connectionEstablished = true;
|
|
@@ -9240,11 +9340,9 @@ alias:${this.alias}
|
|
|
9240
9340
|
|
|
9241
9341
|
`);
|
|
9242
9342
|
}
|
|
9243
|
-
|
|
9244
|
-
`sending ${this.offlineMessages.length} offline FOS messages`
|
|
9245
|
-
);
|
|
9343
|
+
log$K.debug(`sending ${this.offlineMessages.length} offline FOS messages`);
|
|
9246
9344
|
this.offlineMessages.forEach((msg) => {
|
|
9247
|
-
|
|
9345
|
+
log$K.debug(`sending offline message ${msg.msg}`);
|
|
9248
9346
|
this.socket?.send(msg.msg);
|
|
9249
9347
|
});
|
|
9250
9348
|
this.offlineMessages = [];
|
|
@@ -9253,7 +9351,7 @@ alias:${this.alias}
|
|
|
9253
9351
|
}
|
|
9254
9352
|
onClose(event) {
|
|
9255
9353
|
const { code, reason, wasClean } = event;
|
|
9256
|
-
|
|
9354
|
+
log$K.warn(
|
|
9257
9355
|
`WebSocket closed: code=${code}, reason=${reason || "none"}, wasClean=${wasClean}`
|
|
9258
9356
|
);
|
|
9259
9357
|
runInAction(() => {
|
|
@@ -9263,13 +9361,13 @@ alias:${this.alias}
|
|
|
9263
9361
|
if (this.shouldAttemptReconnection(code)) {
|
|
9264
9362
|
this.onConnectionLost?.();
|
|
9265
9363
|
} else {
|
|
9266
|
-
|
|
9364
|
+
log$K.info(
|
|
9267
9365
|
`Not reconnecting due to close code ${code} (intentional close or configuration error)`
|
|
9268
9366
|
);
|
|
9269
9367
|
}
|
|
9270
9368
|
}
|
|
9271
9369
|
onError(ev) {
|
|
9272
|
-
|
|
9370
|
+
log$K.error(`websocket error: `, ev);
|
|
9273
9371
|
publish("websocket.error", { event: ev });
|
|
9274
9372
|
}
|
|
9275
9373
|
/**
|
|
@@ -9314,7 +9412,7 @@ alias:${this.alias}
|
|
|
9314
9412
|
}
|
|
9315
9413
|
}
|
|
9316
9414
|
send(data) {
|
|
9317
|
-
|
|
9415
|
+
messageLog.debug("sent", data);
|
|
9318
9416
|
if (window.kosLogEvents) {
|
|
9319
9417
|
const { headers, body } = processKosMessage(String(data));
|
|
9320
9418
|
publish(KosWsEvents.SEND, { headers, body });
|
|
@@ -9322,6 +9420,10 @@ alias:${this.alias}
|
|
|
9322
9420
|
this.oldSend.call(this.socket, data);
|
|
9323
9421
|
}
|
|
9324
9422
|
}
|
|
9423
|
+
const log$J = KosLog.createLogger({
|
|
9424
|
+
group: LogGroup.transport,
|
|
9425
|
+
name: "bridge-transport"
|
|
9426
|
+
});
|
|
9325
9427
|
class BridgeTransport {
|
|
9326
9428
|
addEventListener;
|
|
9327
9429
|
dispatchEvent;
|
|
@@ -9333,7 +9435,7 @@ class BridgeTransport {
|
|
|
9333
9435
|
messageQueue = [];
|
|
9334
9436
|
isSending = false;
|
|
9335
9437
|
constructor(addr) {
|
|
9336
|
-
log$
|
|
9438
|
+
log$J.debug(`called Bridge Transport with addr ${addr}`);
|
|
9337
9439
|
const that = this;
|
|
9338
9440
|
globalThis.kosWindowWebsocketRecv = (msg) => {
|
|
9339
9441
|
if (that.onmessage) {
|
|
@@ -9341,19 +9443,19 @@ class BridgeTransport {
|
|
|
9341
9443
|
that.onmessage(data);
|
|
9342
9444
|
}
|
|
9343
9445
|
};
|
|
9344
|
-
log$
|
|
9446
|
+
log$J.debug("Opening bridge transport");
|
|
9345
9447
|
globalThis.kosWindowWebsocketOpen();
|
|
9346
|
-
log$
|
|
9448
|
+
log$J.debug("Opened bridge transport");
|
|
9347
9449
|
this._onclose = null;
|
|
9348
9450
|
this._onerror = null;
|
|
9349
9451
|
this._onmessage = null;
|
|
9350
9452
|
this._onopen = null;
|
|
9351
|
-
this.addEventListener = () => log$
|
|
9352
|
-
this.dispatchEvent = () => log$
|
|
9353
|
-
this.removeEventListener = () => log$
|
|
9453
|
+
this.addEventListener = () => log$J.debug("not implemented");
|
|
9454
|
+
this.dispatchEvent = () => log$J.debug("not implemented");
|
|
9455
|
+
this.removeEventListener = () => log$J.debug("not implemented");
|
|
9354
9456
|
}
|
|
9355
9457
|
close() {
|
|
9356
|
-
log$
|
|
9458
|
+
log$J.debug("closing");
|
|
9357
9459
|
}
|
|
9358
9460
|
sendNextMessage() {
|
|
9359
9461
|
if (this.messageQueue.length > 0) {
|
|
@@ -9440,6 +9542,10 @@ class KosTransport extends BaseTransport {
|
|
|
9440
9542
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9441
9543
|
}
|
|
9442
9544
|
}
|
|
9545
|
+
const log$I = KosLog.createLogger({
|
|
9546
|
+
group: LogGroup.transport,
|
|
9547
|
+
name: "standalone-mock-socket"
|
|
9548
|
+
});
|
|
9443
9549
|
const LOGGED_IN_FRAME = `topic:/studioServer/auth/LOGGED_IN
|
|
9444
9550
|
type:kos.broker.topic
|
|
9445
9551
|
|
|
@@ -9450,7 +9556,7 @@ class StandaloneMockSocket {
|
|
|
9450
9556
|
onmessage = null;
|
|
9451
9557
|
onopen = null;
|
|
9452
9558
|
constructor(url) {
|
|
9453
|
-
|
|
9559
|
+
log$I.info(`KosMock standalone socket replacing ${url}`);
|
|
9454
9560
|
setTimeout(async () => {
|
|
9455
9561
|
await kosMockRegistry.bootGate;
|
|
9456
9562
|
this.onopen?.({ currentTarget: this });
|
|
@@ -9461,7 +9567,7 @@ class StandaloneMockSocket {
|
|
|
9461
9567
|
}
|
|
9462
9568
|
send(data) {
|
|
9463
9569
|
if (peekFrameType(data) === KOS_HTTP_REQUEST_TYPE) {
|
|
9464
|
-
|
|
9570
|
+
log$I.warn(
|
|
9465
9571
|
`KosMock standalone: unmatched request reached the loopback socket and will hang — add a route or use onUnmatched: "respond404"`,
|
|
9466
9572
|
String(data).split("\n", 2).join(" ")
|
|
9467
9573
|
);
|
|
@@ -9499,6 +9605,10 @@ class MockMessageTransport extends BaseTransport {
|
|
|
9499
9605
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9500
9606
|
}
|
|
9501
9607
|
}
|
|
9608
|
+
const log$H = KosLog.createLogger({
|
|
9609
|
+
group: LogGroup.transport,
|
|
9610
|
+
name: "transport-factory"
|
|
9611
|
+
});
|
|
9502
9612
|
window.kosLogEvents = process.env.KOS_LOG_WS === "true";
|
|
9503
9613
|
class TransportFactory {
|
|
9504
9614
|
static build({
|
|
@@ -9510,13 +9620,13 @@ class TransportFactory {
|
|
|
9510
9620
|
onConnectionEstablished,
|
|
9511
9621
|
onConnectionLost
|
|
9512
9622
|
}) {
|
|
9513
|
-
|
|
9514
|
-
|
|
9623
|
+
log$H.debug(`initializing websocket connection`);
|
|
9624
|
+
log$H.warn(
|
|
9515
9625
|
`kosWindowWebsocketOpen: ${globalThis.kosWindowWebsocketOpen ? `true` : `false`}`
|
|
9516
9626
|
);
|
|
9517
|
-
|
|
9627
|
+
log$H.warn(`fos: ${fos ? `true` : `false`}`);
|
|
9518
9628
|
if (KosMock.standalone && !fos) {
|
|
9519
|
-
|
|
9629
|
+
log$H.warn(`Using KosMock standalone transport`);
|
|
9520
9630
|
return new MockMessageTransport({
|
|
9521
9631
|
host,
|
|
9522
9632
|
port,
|
|
@@ -9527,7 +9637,7 @@ class TransportFactory {
|
|
|
9527
9637
|
});
|
|
9528
9638
|
}
|
|
9529
9639
|
if (globalThis.kosWindowWebsocketOpen && !fos) {
|
|
9530
|
-
|
|
9640
|
+
log$H.warn(`Using bridged message transport`);
|
|
9531
9641
|
const transport = new BridgeMessageTransport({
|
|
9532
9642
|
host,
|
|
9533
9643
|
port,
|
|
@@ -9568,7 +9678,10 @@ if (params$1.fos) {
|
|
|
9568
9678
|
const fosPort = process.env.KOS_FOS_PORT;
|
|
9569
9679
|
window.kosUseFos = !!(window.kosUseFos || process.env.KOS_USE_FOS === "true");
|
|
9570
9680
|
window.kosFosPort = fosPort ? parseInt(fosPort) : 0;
|
|
9571
|
-
const log$
|
|
9681
|
+
const log$G = KosLog.createLogger({
|
|
9682
|
+
group: LogGroup.transport,
|
|
9683
|
+
name: "web-socket-transport"
|
|
9684
|
+
});
|
|
9572
9685
|
var KosWSTransportStatus = /* @__PURE__ */ ((KosWSTransportStatus2) => {
|
|
9573
9686
|
KosWSTransportStatus2["NOT_INITIALIZED"] = "not_initialized";
|
|
9574
9687
|
KosWSTransportStatus2["INITIALIZED"] = "initialized";
|
|
@@ -9625,7 +9738,7 @@ class WebSocketTransport {
|
|
|
9625
9738
|
() => this.connectionEstablished,
|
|
9626
9739
|
(connectionEstablished) => {
|
|
9627
9740
|
if (connectionEstablished) {
|
|
9628
|
-
log$
|
|
9741
|
+
log$G.warn("Connection Established");
|
|
9629
9742
|
this.reconnectAttempts = 0;
|
|
9630
9743
|
publish(WebSocketEvents.CONNECTED, {
|
|
9631
9744
|
reconnect: initialized
|
|
@@ -9657,7 +9770,7 @@ class WebSocketTransport {
|
|
|
9657
9770
|
return false;
|
|
9658
9771
|
}
|
|
9659
9772
|
init() {
|
|
9660
|
-
|
|
9773
|
+
log$G.warn(`Initializing WebSocketTransport on ${this.host}:${this.port}`);
|
|
9661
9774
|
if (this.useFosTransport) {
|
|
9662
9775
|
this.fosSocket = TransportFactory.build({
|
|
9663
9776
|
host: this.host,
|
|
@@ -9672,7 +9785,7 @@ class WebSocketTransport {
|
|
|
9672
9785
|
protocol: this.protocol,
|
|
9673
9786
|
alias: this.alias,
|
|
9674
9787
|
onConnectionLost: () => {
|
|
9675
|
-
log$
|
|
9788
|
+
log$G.error(`Connection Lost`);
|
|
9676
9789
|
this.scheduleReconnect();
|
|
9677
9790
|
}
|
|
9678
9791
|
});
|
|
@@ -9692,7 +9805,7 @@ class WebSocketTransport {
|
|
|
9692
9805
|
*/
|
|
9693
9806
|
scheduleReconnect() {
|
|
9694
9807
|
if (this.reconnectAttempts >= WebSocketTransport.MAX_RECONNECT_ATTEMPTS) {
|
|
9695
|
-
|
|
9808
|
+
log$G.error(
|
|
9696
9809
|
`Max reconnection attempts (${WebSocketTransport.MAX_RECONNECT_ATTEMPTS}) reached. Giving up.`
|
|
9697
9810
|
);
|
|
9698
9811
|
publish(WebSocketEvents.MAX_RETRIES_EXCEEDED, {
|
|
@@ -9701,7 +9814,7 @@ class WebSocketTransport {
|
|
|
9701
9814
|
return;
|
|
9702
9815
|
}
|
|
9703
9816
|
const delay2 = this.calculateBackoffDelay();
|
|
9704
|
-
|
|
9817
|
+
log$G.debug(
|
|
9705
9818
|
`Reconnecting in ${delay2}ms (attempt ${this.reconnectAttempts + 1}/${WebSocketTransport.MAX_RECONNECT_ATTEMPTS})`
|
|
9706
9819
|
);
|
|
9707
9820
|
setTimeout(() => {
|
|
@@ -9718,7 +9831,7 @@ class WebSocketTransport {
|
|
|
9718
9831
|
return Math.floor(exponentialDelay + jitter);
|
|
9719
9832
|
}
|
|
9720
9833
|
_sendSubscriptionMessage(topic, type, fos = false, bridge = false, connectionId, explicitDestination = false) {
|
|
9721
|
-
log$
|
|
9834
|
+
log$G.debug(`${type} to topic ${topic}`);
|
|
9722
9835
|
let connId;
|
|
9723
9836
|
if (explicitDestination) {
|
|
9724
9837
|
connId = connectionId;
|
|
@@ -9727,7 +9840,7 @@ class WebSocketTransport {
|
|
|
9727
9840
|
const connectionParam = params2?.connId;
|
|
9728
9841
|
connId = connectionId ?? connectionParam ?? window?.kosBridge?.("connId");
|
|
9729
9842
|
}
|
|
9730
|
-
log$
|
|
9843
|
+
log$G.debug(`subscribing with connId ${connId}`);
|
|
9731
9844
|
const dstAddr = connId ? `dst-addr:${connId}
|
|
9732
9845
|
` : "";
|
|
9733
9846
|
const msg = fos ? `subscribe:${topic}` : bridge ? `type:fos.broker
|
|
@@ -9741,7 +9854,7 @@ ${dstAddr}topics:${topic}
|
|
|
9741
9854
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9742
9855
|
socket?.socket?.send(msg);
|
|
9743
9856
|
} else {
|
|
9744
|
-
log$
|
|
9857
|
+
log$G.debug(`no connection adding to offline messages`);
|
|
9745
9858
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9746
9859
|
socket?.addOfflineMessage(msg);
|
|
9747
9860
|
}
|
|
@@ -9755,7 +9868,7 @@ ${dstAddr}topics:${topic}
|
|
|
9755
9868
|
explicitDestination
|
|
9756
9869
|
}) {
|
|
9757
9870
|
const { unsubscribe, count } = subscribe(topic, callback);
|
|
9758
|
-
log$
|
|
9871
|
+
log$G.debug(`Topic ${topic} currently has ${count} subscribers`);
|
|
9759
9872
|
this._sendSubscriptionMessage(
|
|
9760
9873
|
topic,
|
|
9761
9874
|
"subscribe",
|
|
@@ -9766,7 +9879,7 @@ ${dstAddr}topics:${topic}
|
|
|
9766
9879
|
);
|
|
9767
9880
|
return () => {
|
|
9768
9881
|
const { count: count2 } = unsubscribe();
|
|
9769
|
-
log$
|
|
9882
|
+
log$G.debug(`Topic ${topic} currently has ${count2} subscribers`);
|
|
9770
9883
|
if (count2 === 0) {
|
|
9771
9884
|
this._sendSubscriptionMessage(
|
|
9772
9885
|
topic,
|
|
@@ -9806,7 +9919,7 @@ ${dstAddr}topics:${topic}
|
|
|
9806
9919
|
}
|
|
9807
9920
|
dropConnection() {
|
|
9808
9921
|
if (!this.connectionEstablished) {
|
|
9809
|
-
log$
|
|
9922
|
+
log$G.debug("dropConnection ignored: the connection is already closed");
|
|
9810
9923
|
return;
|
|
9811
9924
|
}
|
|
9812
9925
|
this.socket?.socket.close(1e3);
|
|
@@ -10592,21 +10705,17 @@ class ServiceResponseStore {
|
|
|
10592
10705
|
class KosModelComponentFactory {
|
|
10593
10706
|
static createAll(model) {
|
|
10594
10707
|
const { modelId, modelTypeName, modelData } = model;
|
|
10595
|
-
const log3 = KosLoggerFactory.create({
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
const fsm2 = new KosFSMManager(model, createTaggedLogger(log3, "fsm"));
|
|
10600
|
-
const offlineQueue = new KosOfflineQueue(
|
|
10601
|
-
createTaggedLogger(log3, "offline-queue")
|
|
10602
|
-
);
|
|
10708
|
+
const log3 = KosLoggerFactory.create({ modelTypeName });
|
|
10709
|
+
const tagged = (tag) => createTaggedLogger(log3, `${modelId}:${tag}`);
|
|
10710
|
+
const fsm2 = new KosFSMManager(model, tagged("fsm"));
|
|
10711
|
+
const offlineQueue = new KosOfflineQueue(tagged("offline-queue"));
|
|
10603
10712
|
const companionManager = new KosCompanionModelManager(model);
|
|
10604
10713
|
const childResolver = new KosChildResolver(model);
|
|
10605
10714
|
const serviceResponseStore = new ServiceResponseStore();
|
|
10606
10715
|
modelData.serviceResponses = serviceResponseStore;
|
|
10607
10716
|
const onlineLifecycleManager = new KosOnlineLifecycleManager(
|
|
10608
10717
|
model,
|
|
10609
|
-
|
|
10718
|
+
tagged("online")
|
|
10610
10719
|
);
|
|
10611
10720
|
const components = {
|
|
10612
10721
|
fsm: fsm2,
|
|
@@ -10621,11 +10730,11 @@ class KosModelComponentFactory {
|
|
|
10621
10730
|
modelTypeName,
|
|
10622
10731
|
modelId,
|
|
10623
10732
|
modelData,
|
|
10624
|
-
|
|
10733
|
+
tagged("effect")
|
|
10625
10734
|
);
|
|
10626
10735
|
}
|
|
10627
10736
|
if (hasSubscriptionHandlers(modelData)) {
|
|
10628
|
-
const subLogger =
|
|
10737
|
+
const subLogger = tagged("subscription");
|
|
10629
10738
|
components.subscriptionManager = new KosSubscriptionManager(
|
|
10630
10739
|
model,
|
|
10631
10740
|
modelData,
|
|
@@ -10637,7 +10746,7 @@ class KosModelComponentFactory {
|
|
|
10637
10746
|
if (hasHttpRouteHandlers(modelData)) {
|
|
10638
10747
|
components.httpRouteManager = new KosHttpRouteManager(
|
|
10639
10748
|
modelData,
|
|
10640
|
-
|
|
10749
|
+
tagged("http-routes")
|
|
10641
10750
|
);
|
|
10642
10751
|
}
|
|
10643
10752
|
if (hasServiceRequestHandlers(modelData)) {
|
|
@@ -10650,7 +10759,7 @@ class KosModelComponentFactory {
|
|
|
10650
10759
|
return components;
|
|
10651
10760
|
}
|
|
10652
10761
|
}
|
|
10653
|
-
const log$
|
|
10762
|
+
const log$F = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
10654
10763
|
const MODEL_LOADER = "kos.extension.model.loader";
|
|
10655
10764
|
class KosModel {
|
|
10656
10765
|
_id;
|
|
@@ -10758,23 +10867,23 @@ class KosModel {
|
|
|
10758
10867
|
return this._status === KosModelState.READY;
|
|
10759
10868
|
}
|
|
10760
10869
|
async deactivate() {
|
|
10761
|
-
log$
|
|
10870
|
+
log$F.debug(
|
|
10762
10871
|
`deactivating model ${this.modelTypeName} with id ${this.modelId}`
|
|
10763
10872
|
);
|
|
10764
10873
|
try {
|
|
10765
10874
|
const context = KosContextManager.getContext(this.modelId);
|
|
10766
10875
|
await this.modelData?.deactivate?.(context);
|
|
10767
|
-
log$
|
|
10876
|
+
log$F.debug(
|
|
10768
10877
|
`Model ${this.modelTypeName} with id ${this.modelId} deactivated`
|
|
10769
10878
|
);
|
|
10770
10879
|
this.subscriptionManager?.deactivate();
|
|
10771
10880
|
} catch (e) {
|
|
10772
|
-
log$
|
|
10881
|
+
log$F.debug(`Model ${this.modelId} failed to deactivated`);
|
|
10773
10882
|
throw e;
|
|
10774
10883
|
}
|
|
10775
10884
|
}
|
|
10776
10885
|
async activate() {
|
|
10777
|
-
log$
|
|
10886
|
+
log$F.debug(`activating model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10778
10887
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ACTIVATE);
|
|
10779
10888
|
try {
|
|
10780
10889
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10783,16 +10892,16 @@ class KosModel {
|
|
|
10783
10892
|
const context = KosContextManager.getContext(this.modelId);
|
|
10784
10893
|
await this.modelData?.activate?.(context);
|
|
10785
10894
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.ACTIVATE);
|
|
10786
|
-
log$
|
|
10895
|
+
log$F.debug(
|
|
10787
10896
|
`Model ${this.modelTypeName} with id ${this.modelId} subscribing to all topics`
|
|
10788
10897
|
);
|
|
10789
10898
|
this.subscriptionManager?.registerAll(DependencyLifecycle.ACTIVATE);
|
|
10790
10899
|
this.createLifecycleCompanions(DependencyLifecycle.ACTIVATE);
|
|
10791
|
-
log$
|
|
10900
|
+
log$F.debug(
|
|
10792
10901
|
`Model ${this.modelTypeName} with id ${this.modelId} activated`
|
|
10793
10902
|
);
|
|
10794
10903
|
} catch (e) {
|
|
10795
|
-
log$
|
|
10904
|
+
log$F.debug(`Model ${this.modelId} failed to activate`);
|
|
10796
10905
|
throw e;
|
|
10797
10906
|
}
|
|
10798
10907
|
return;
|
|
@@ -10808,7 +10917,7 @@ class KosModel {
|
|
|
10808
10917
|
{
|
|
10809
10918
|
condition: () => this.loaded,
|
|
10810
10919
|
onMatch: () => {
|
|
10811
|
-
log$
|
|
10920
|
+
log$F.debug(`Model ${this.modelId} is loaded`);
|
|
10812
10921
|
}
|
|
10813
10922
|
}
|
|
10814
10923
|
]);
|
|
@@ -10824,7 +10933,7 @@ class KosModel {
|
|
|
10824
10933
|
{
|
|
10825
10934
|
condition: () => this.initialized,
|
|
10826
10935
|
onMatch: () => {
|
|
10827
|
-
log$
|
|
10936
|
+
log$F.debug(`Model ${this.modelId} is initialized`);
|
|
10828
10937
|
}
|
|
10829
10938
|
}
|
|
10830
10939
|
]);
|
|
@@ -10840,20 +10949,20 @@ class KosModel {
|
|
|
10840
10949
|
{
|
|
10841
10950
|
condition: () => this.status === KosModelState.READY,
|
|
10842
10951
|
onMatch: () => {
|
|
10843
|
-
log$
|
|
10952
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10844
10953
|
}
|
|
10845
10954
|
}
|
|
10846
10955
|
]);
|
|
10847
10956
|
}
|
|
10848
10957
|
async ready() {
|
|
10849
10958
|
if (this.fsm.current === KosModelState.READY) {
|
|
10850
|
-
log$
|
|
10959
|
+
log$F.debug(
|
|
10851
10960
|
`already readying model ${this.modelTypeName} with id ${this.modelId} returning`
|
|
10852
10961
|
);
|
|
10853
10962
|
return;
|
|
10854
10963
|
}
|
|
10855
10964
|
try {
|
|
10856
|
-
log$
|
|
10965
|
+
log$F.debug(`readying model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10857
10966
|
await executeDependentModelLifecycle(this, DependencyLifecycle.READY);
|
|
10858
10967
|
await executeChildrenModelLifecycle(
|
|
10859
10968
|
this,
|
|
@@ -10869,7 +10978,7 @@ class KosModel {
|
|
|
10869
10978
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.READY);
|
|
10870
10979
|
this.subscriptionManager?.registerAll(DependencyLifecycle.READY);
|
|
10871
10980
|
this.createLifecycleCompanions(DependencyLifecycle.READY);
|
|
10872
|
-
log$
|
|
10981
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10873
10982
|
const payload = {
|
|
10874
10983
|
modelId: this.modelId,
|
|
10875
10984
|
modelType: this.modelTypeName
|
|
@@ -10880,7 +10989,7 @@ class KosModel {
|
|
|
10880
10989
|
);
|
|
10881
10990
|
publish(modelTypeEventTopicFactory(this.modelTypeName), payload);
|
|
10882
10991
|
} catch (e) {
|
|
10883
|
-
log$
|
|
10992
|
+
log$F.error(e);
|
|
10884
10993
|
throw Error(e);
|
|
10885
10994
|
}
|
|
10886
10995
|
}
|
|
@@ -10891,18 +11000,18 @@ class KosModel {
|
|
|
10891
11000
|
}
|
|
10892
11001
|
const { modelTypeName, modelId } = this;
|
|
10893
11002
|
if (this.fsm.current === KosModelState.LOADED) {
|
|
10894
|
-
log$
|
|
11003
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} already loaded`);
|
|
10895
11004
|
return;
|
|
10896
11005
|
}
|
|
10897
11006
|
if (this._isLoadExecuting) {
|
|
10898
|
-
log$
|
|
11007
|
+
log$F.debug(
|
|
10899
11008
|
`Model ${modelTypeName} with id ${modelId} is currently executing load`
|
|
10900
11009
|
);
|
|
10901
11010
|
return;
|
|
10902
11011
|
}
|
|
10903
11012
|
this._isLoadExecuting = true;
|
|
10904
11013
|
try {
|
|
10905
|
-
log$
|
|
11014
|
+
log$F.debug(`Loading model ${modelTypeName} with id ${modelId}`);
|
|
10906
11015
|
await executeDependentModelLifecycle(this, DependencyLifecycle.LOAD);
|
|
10907
11016
|
const context = KosContextManager.getContext(modelId);
|
|
10908
11017
|
const MODEL_LOADER_TYPE = `${MODEL_LOADER}.${modelTypeName}`;
|
|
@@ -10911,7 +11020,7 @@ class KosModel {
|
|
|
10911
11020
|
{}
|
|
10912
11021
|
);
|
|
10913
11022
|
if (loadedContext) {
|
|
10914
|
-
log$
|
|
11023
|
+
log$F.info(
|
|
10915
11024
|
`Setting loaded context for ${modelId}, type: ${modelTypeName}`
|
|
10916
11025
|
);
|
|
10917
11026
|
context?.set(MODEL_LOADER_TYPE, loadedContext);
|
|
@@ -10923,7 +11032,7 @@ class KosModel {
|
|
|
10923
11032
|
kosAction(() => {
|
|
10924
11033
|
this.loaded = true;
|
|
10925
11034
|
});
|
|
10926
|
-
log$
|
|
11035
|
+
log$F.debug(
|
|
10927
11036
|
`Model ${modelTypeName} with id ${modelId} successfully loaded`
|
|
10928
11037
|
);
|
|
10929
11038
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.LOAD);
|
|
@@ -10932,14 +11041,14 @@ class KosModel {
|
|
|
10932
11041
|
this.effectManager?.setup();
|
|
10933
11042
|
this.createLifecycleCompanions(DependencyLifecycle.LOAD);
|
|
10934
11043
|
} catch (e) {
|
|
10935
|
-
log$
|
|
11044
|
+
log$F.error(`Model ${modelId} failed to load`, e);
|
|
10936
11045
|
throw e;
|
|
10937
11046
|
} finally {
|
|
10938
11047
|
this._isLoadExecuting = false;
|
|
10939
11048
|
}
|
|
10940
11049
|
}
|
|
10941
11050
|
async unload() {
|
|
10942
|
-
log$
|
|
11051
|
+
log$F.debug(`unloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10943
11052
|
try {
|
|
10944
11053
|
const childrenUnload = this.getChildren().map((child) => child.unload?.()).filter((p) => !!p);
|
|
10945
11054
|
await Promise.allSettled(childrenUnload);
|
|
@@ -10958,12 +11067,12 @@ class KosModel {
|
|
|
10958
11067
|
modelData.stateHistory = [];
|
|
10959
11068
|
}
|
|
10960
11069
|
}
|
|
10961
|
-
log$
|
|
11070
|
+
log$F.debug(`Model ${this.modelTypeName} with id ${this.modelId} unloaded`);
|
|
10962
11071
|
this.effectManager?.disposeAll();
|
|
10963
11072
|
this.subscriptionManager?.disposeAll();
|
|
10964
11073
|
this.httpRouteManager?.dispose();
|
|
10965
11074
|
} catch (e) {
|
|
10966
|
-
log$
|
|
11075
|
+
log$F.debug(`Model ${this.modelId} failed to unload`);
|
|
10967
11076
|
throw e;
|
|
10968
11077
|
}
|
|
10969
11078
|
}
|
|
@@ -10974,7 +11083,7 @@ class KosModel {
|
|
|
10974
11083
|
}
|
|
10975
11084
|
const { modelId, modelTypeName } = this;
|
|
10976
11085
|
const context = KosContextManager.getContext(modelId);
|
|
10977
|
-
log$
|
|
11086
|
+
log$F.debug(`Initializing model ${modelTypeName} with id ${modelId}`);
|
|
10978
11087
|
await executeDependentModelLifecycle(this, DependencyLifecycle.INIT);
|
|
10979
11088
|
try {
|
|
10980
11089
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10982,18 +11091,18 @@ class KosModel {
|
|
|
10982
11091
|
);
|
|
10983
11092
|
await this.modelData?.init?.(context);
|
|
10984
11093
|
this.initialized = true;
|
|
10985
|
-
log$
|
|
11094
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} initialized`);
|
|
10986
11095
|
this.onlineLifecycleManager?.register();
|
|
10987
11096
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.INIT);
|
|
10988
11097
|
this.registerSubscribers(DependencyLifecycle.INIT);
|
|
10989
11098
|
this.createLifecycleCompanions(DependencyLifecycle.INIT);
|
|
10990
11099
|
} catch (e) {
|
|
10991
|
-
log$
|
|
11100
|
+
log$F.error(`Model ${modelId} failed to initialize`, e);
|
|
10992
11101
|
throw e;
|
|
10993
11102
|
}
|
|
10994
11103
|
}
|
|
10995
11104
|
async registerSubscribers(lifecycle) {
|
|
10996
|
-
log$
|
|
11105
|
+
log$F.debug(
|
|
10997
11106
|
`registering subscribers in ${this.modelTypeName} with id ${this.modelId}`
|
|
10998
11107
|
);
|
|
10999
11108
|
this.subscriptionManager?.registerAll(lifecycle);
|
|
@@ -11010,7 +11119,7 @@ class KosModel {
|
|
|
11010
11119
|
}
|
|
11011
11120
|
/** @internal */
|
|
11012
11121
|
async reloadData() {
|
|
11013
|
-
log$
|
|
11122
|
+
log$F.info(`reloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11014
11123
|
this.suspendForReload();
|
|
11015
11124
|
const data = this.modelData;
|
|
11016
11125
|
if (typeof data?.reload === "function" && !data[SelfManagedReload]) {
|
|
@@ -11019,7 +11128,7 @@ class KosModel {
|
|
|
11019
11128
|
}
|
|
11020
11129
|
/** @internal */
|
|
11021
11130
|
async reattach() {
|
|
11022
|
-
log$
|
|
11131
|
+
log$F.info(`reattaching model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11023
11132
|
kosAction(() => {
|
|
11024
11133
|
this.loaded = true;
|
|
11025
11134
|
});
|
|
@@ -11050,7 +11159,7 @@ class KosModel {
|
|
|
11050
11159
|
]);
|
|
11051
11160
|
reloaded.forEach((result, index) => {
|
|
11052
11161
|
if (result.status === "rejected") {
|
|
11053
|
-
log$
|
|
11162
|
+
log$F.error(
|
|
11054
11163
|
`reload of child ${ready[index].modelId} of ${this.modelId} failed`,
|
|
11055
11164
|
result.reason
|
|
11056
11165
|
);
|
|
@@ -11081,7 +11190,7 @@ class KosModel {
|
|
|
11081
11190
|
* each time. A state machine with `initializeAt: ONLINE` starts once.
|
|
11082
11191
|
*/
|
|
11083
11192
|
async online() {
|
|
11084
|
-
log$
|
|
11193
|
+
log$F.debug(`online model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11085
11194
|
this.registerSubscribers();
|
|
11086
11195
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ONLINE);
|
|
11087
11196
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -11093,7 +11202,7 @@ class KosModel {
|
|
|
11093
11202
|
this.createLifecycleCompanions(DependencyLifecycle.ONLINE);
|
|
11094
11203
|
}
|
|
11095
11204
|
async offline() {
|
|
11096
|
-
log$
|
|
11205
|
+
log$F.debug(`offline model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11097
11206
|
this.subscriptionManager?.disposeAll();
|
|
11098
11207
|
const context = KosContextManager.getContext(this.modelId);
|
|
11099
11208
|
await this.modelData?.offline?.(context);
|
|
@@ -11111,7 +11220,10 @@ class KosModel {
|
|
|
11111
11220
|
this.companionManager.clear();
|
|
11112
11221
|
}
|
|
11113
11222
|
}
|
|
11114
|
-
const log$
|
|
11223
|
+
const log$E = KosLog.createLogger({
|
|
11224
|
+
group: LogGroup.core,
|
|
11225
|
+
name: "kos-model-instantiator"
|
|
11226
|
+
});
|
|
11115
11227
|
class KosModelInstantiator {
|
|
11116
11228
|
constructor(registry, cache2) {
|
|
11117
11229
|
this.registry = registry;
|
|
@@ -11129,7 +11241,7 @@ class KosModelInstantiator {
|
|
|
11129
11241
|
const modelRegistry = this.registry.models[typeId];
|
|
11130
11242
|
if (!modelRegistry) {
|
|
11131
11243
|
const errorMessage = `No model registered for type ${typeId}`;
|
|
11132
|
-
log$
|
|
11244
|
+
log$E.error(errorMessage, {
|
|
11133
11245
|
modelType: typeId,
|
|
11134
11246
|
requestedId: id,
|
|
11135
11247
|
providedOptions: options,
|
|
@@ -11148,7 +11260,7 @@ class KosModelInstantiator {
|
|
|
11148
11260
|
const modelId = modelRegistry.singleton ? typeId : id;
|
|
11149
11261
|
this.cache.restoreFromDeleteCache(modelId);
|
|
11150
11262
|
if (!this.cache.hasModel(modelId)) {
|
|
11151
|
-
log$
|
|
11263
|
+
log$E.debug(`Creating model instance: ${typeId} [${modelId}]`);
|
|
11152
11264
|
const hasOptions = options && Object.keys(options).length > 0;
|
|
11153
11265
|
const modelClass = modelRegistry.class || modelRegistry.create;
|
|
11154
11266
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
@@ -11194,7 +11306,7 @@ class KosModelInstantiator {
|
|
|
11194
11306
|
}
|
|
11195
11307
|
const activeModel = this.cache.getModelById(modelId);
|
|
11196
11308
|
if (!activeModel) {
|
|
11197
|
-
log$
|
|
11309
|
+
log$E.error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11198
11310
|
throw new Error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11199
11311
|
}
|
|
11200
11312
|
return { model: activeModel, data: activeModel.modelData };
|
|
@@ -11260,7 +11372,10 @@ let KosModelRegistry$1 = class KosModelRegistry {
|
|
|
11260
11372
|
}
|
|
11261
11373
|
};
|
|
11262
11374
|
const MODEL_DELETION_DELAY = 10;
|
|
11263
|
-
const log$
|
|
11375
|
+
const log$D = KosLog.createLogger({
|
|
11376
|
+
group: LogGroup.core,
|
|
11377
|
+
name: "kos-model-manager"
|
|
11378
|
+
});
|
|
11264
11379
|
class KosModelManager {
|
|
11265
11380
|
cache;
|
|
11266
11381
|
instantiator;
|
|
@@ -11303,7 +11418,7 @@ class KosModelManager {
|
|
|
11303
11418
|
}
|
|
11304
11419
|
static getInstance(reset2) {
|
|
11305
11420
|
if (!globalThis.kos?.modelManager || reset2) {
|
|
11306
|
-
log$
|
|
11421
|
+
log$D.debug("Creating new instance of KosModelManager");
|
|
11307
11422
|
new this();
|
|
11308
11423
|
}
|
|
11309
11424
|
return globalThis.kos?.modelManager;
|
|
@@ -11324,7 +11439,7 @@ class KosModelManager {
|
|
|
11324
11439
|
*/
|
|
11325
11440
|
get preloadedModels() {
|
|
11326
11441
|
return this.cache.preload((modelKey) => {
|
|
11327
|
-
log$
|
|
11442
|
+
log$D.debug(`preloading ${modelKey}`);
|
|
11328
11443
|
if (typeof modelKey === "string") {
|
|
11329
11444
|
return this.createModelInstance(modelKey).model;
|
|
11330
11445
|
} else {
|
|
@@ -11620,6 +11735,10 @@ class KosModelManager {
|
|
|
11620
11735
|
this._registry.registerModel(reg);
|
|
11621
11736
|
}
|
|
11622
11737
|
}
|
|
11738
|
+
const log$C = KosLog.createLogger({
|
|
11739
|
+
group: LogGroup.core,
|
|
11740
|
+
name: "kos-core-lifecycle"
|
|
11741
|
+
});
|
|
11623
11742
|
var KosCoreState = /* @__PURE__ */ ((KosCoreState2) => {
|
|
11624
11743
|
KosCoreState2["CREATING"] = `creating`;
|
|
11625
11744
|
KosCoreState2["CREATED"] = `created`;
|
|
@@ -11656,7 +11775,7 @@ const reportFailure = async (step, run) => {
|
|
|
11656
11775
|
return await run();
|
|
11657
11776
|
} catch (error) {
|
|
11658
11777
|
const detail = error instanceof Error ? error.stack ?? `${error.name}: ${error.message}` : String(error);
|
|
11659
|
-
log$
|
|
11778
|
+
log$C.error(`KOS Core lifecycle step "${step}" failed. ${detail}`);
|
|
11660
11779
|
throw error;
|
|
11661
11780
|
}
|
|
11662
11781
|
};
|
|
@@ -11695,7 +11814,7 @@ const coreFsm = (core) => {
|
|
|
11695
11814
|
});
|
|
11696
11815
|
const online = interpret(
|
|
11697
11816
|
onlineMachine2,
|
|
11698
|
-
(_service) => log$
|
|
11817
|
+
(_service) => log$C.debug(`KOS Core connection: ${_service.machine.current}`)
|
|
11699
11818
|
);
|
|
11700
11819
|
const syncOnline = () => online.send(
|
|
11701
11820
|
core.transport.connectionEstablished ? "go_online" : "go_offline"
|
|
@@ -11909,11 +12028,11 @@ const coreFsm = (core) => {
|
|
|
11909
12028
|
});
|
|
11910
12029
|
const service2 = interpret(
|
|
11911
12030
|
machine2,
|
|
11912
|
-
(_service) => log$
|
|
12031
|
+
(_service) => log$C.debug(`KOS Core state: ${_service.machine.current}`)
|
|
11913
12032
|
);
|
|
11914
12033
|
return { service: service2, online };
|
|
11915
12034
|
};
|
|
11916
|
-
const log$
|
|
12035
|
+
const log$B = KosLog.createLogger({ group: LogGroup.core, name: "kos-core" });
|
|
11917
12036
|
const getConnectionAlias = () => {
|
|
11918
12037
|
const params2 = getQueryParams();
|
|
11919
12038
|
const alias = params2?.alias;
|
|
@@ -11967,11 +12086,11 @@ const rejectAfterDelay = (ms, model) => {
|
|
|
11967
12086
|
const promise = new Promise((_, reject) => {
|
|
11968
12087
|
timeoutId = setTimeout(() => {
|
|
11969
12088
|
if (model) {
|
|
11970
|
-
|
|
12089
|
+
log$B.error(
|
|
11971
12090
|
`Model ${model.modelId} - ${model.modelTypeName} preloading - timed out after ${ms}ms`
|
|
11972
12091
|
);
|
|
11973
12092
|
} else {
|
|
11974
|
-
|
|
12093
|
+
log$B.error(`KOS Core preloading timed out after ${ms}ms`);
|
|
11975
12094
|
}
|
|
11976
12095
|
reject(
|
|
11977
12096
|
new Error(
|
|
@@ -12056,11 +12175,11 @@ class KosCore {
|
|
|
12056
12175
|
});
|
|
12057
12176
|
});
|
|
12058
12177
|
subscribe(WebSocketEvents.RELOAD, () => {
|
|
12059
|
-
log$
|
|
12178
|
+
log$B.warn("WebSocket requested reload");
|
|
12060
12179
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12061
12180
|
});
|
|
12062
12181
|
subscribe("/studio/project/reload", () => {
|
|
12063
|
-
log$
|
|
12182
|
+
log$B.warn("Project requested reload");
|
|
12064
12183
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12065
12184
|
});
|
|
12066
12185
|
const ws = WebSocketTransport.getInstance();
|
|
@@ -12089,7 +12208,7 @@ class KosCore {
|
|
|
12089
12208
|
applyConnectionAlias(connectionAlias) {
|
|
12090
12209
|
if (this._transport.alias) {
|
|
12091
12210
|
if (this.connectionAlias && this.connectionAlias !== connectionAlias) {
|
|
12092
|
-
log$
|
|
12211
|
+
log$B.warn(
|
|
12093
12212
|
`Connection alias ${connectionAlias} ignored; the connection already uses ${this._transport.alias}`
|
|
12094
12213
|
);
|
|
12095
12214
|
}
|
|
@@ -12127,13 +12246,13 @@ alias:${alias}
|
|
|
12127
12246
|
}
|
|
12128
12247
|
async reload() {
|
|
12129
12248
|
if (this._reloading) {
|
|
12130
|
-
log$
|
|
12249
|
+
log$B.info("reload already in progress");
|
|
12131
12250
|
return;
|
|
12132
12251
|
}
|
|
12133
12252
|
this._reloading = true;
|
|
12134
12253
|
try {
|
|
12135
|
-
log$
|
|
12136
|
-
log$
|
|
12254
|
+
log$B.warn("reloading KOS Core");
|
|
12255
|
+
log$B.warn("reloading preloaded models");
|
|
12137
12256
|
const modelManager = this.modelManager;
|
|
12138
12257
|
const preloaded = [...modelManager.preloadedModels];
|
|
12139
12258
|
const covered = /* @__PURE__ */ new Set();
|
|
@@ -12145,27 +12264,27 @@ alias:${alias}
|
|
|
12145
12264
|
for (const model of preloaded) {
|
|
12146
12265
|
if (isReloadable(model.modelData) && !covered.has(model)) {
|
|
12147
12266
|
if (isSelfManagedReload(model.modelData)) {
|
|
12148
|
-
log$
|
|
12267
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12149
12268
|
continue;
|
|
12150
12269
|
}
|
|
12151
|
-
log$
|
|
12270
|
+
log$B.info(`reloading model ${model.modelId}`);
|
|
12152
12271
|
await reloadRoot(model);
|
|
12153
|
-
log$
|
|
12272
|
+
log$B.info(`reloading model ${model.modelId} complete`);
|
|
12154
12273
|
}
|
|
12155
12274
|
}
|
|
12156
12275
|
for (const model of [...modelManager.models]) {
|
|
12157
12276
|
if (!preloaded.includes(model) && isReloadable(model.modelData) && !covered.has(model)) {
|
|
12158
12277
|
if (isSelfManagedReload(model.modelData)) {
|
|
12159
|
-
log$
|
|
12278
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12160
12279
|
continue;
|
|
12161
12280
|
}
|
|
12162
|
-
log$
|
|
12281
|
+
log$B.warn(`reloading model ${model.modelId}`);
|
|
12163
12282
|
await reloadRoot(model);
|
|
12164
12283
|
}
|
|
12165
12284
|
}
|
|
12166
12285
|
} finally {
|
|
12167
12286
|
runInAction(() => {
|
|
12168
|
-
log$
|
|
12287
|
+
log$B.warn("reloading KOS Core complete");
|
|
12169
12288
|
this._reloading = false;
|
|
12170
12289
|
});
|
|
12171
12290
|
}
|
|
@@ -12175,13 +12294,13 @@ alias:${alias}
|
|
|
12175
12294
|
try {
|
|
12176
12295
|
await model.fsm.reload();
|
|
12177
12296
|
} catch (e) {
|
|
12178
|
-
log$
|
|
12297
|
+
log$B.error(`reload of ${model.modelId} failed`, e);
|
|
12179
12298
|
}
|
|
12180
12299
|
}
|
|
12181
12300
|
async online() {
|
|
12182
|
-
log$
|
|
12301
|
+
log$B.debug("KOS Core going online");
|
|
12183
12302
|
await this._transport.whenReady();
|
|
12184
|
-
log$
|
|
12303
|
+
log$B.debug("KOS Transport Ready. Calling online() for models");
|
|
12185
12304
|
this.modelManager.models.forEach(
|
|
12186
12305
|
(model) => model.onlineLifecycleManager?.register()
|
|
12187
12306
|
);
|
|
@@ -12189,14 +12308,14 @@ alias:${alias}
|
|
|
12189
12308
|
console.timeEnd("kosCore:startup");
|
|
12190
12309
|
}
|
|
12191
12310
|
async offline() {
|
|
12192
|
-
log$
|
|
12311
|
+
log$B.debug("KOS Core going offline");
|
|
12193
12312
|
publish("/kosCore/offline", "/kosCore/offline");
|
|
12194
12313
|
}
|
|
12195
12314
|
async unload() {
|
|
12196
|
-
log$
|
|
12315
|
+
log$B.debug("Unloading KOS Core");
|
|
12197
12316
|
const currentTime = Date.now();
|
|
12198
12317
|
this._unloading = true;
|
|
12199
|
-
log$
|
|
12318
|
+
log$B.debug("unloading KOS Core");
|
|
12200
12319
|
const modelManager = this.modelManager;
|
|
12201
12320
|
for (const model of modelManager.models) {
|
|
12202
12321
|
if (isUnloadable(model.modelData)) {
|
|
@@ -12214,9 +12333,9 @@ alias:${alias}
|
|
|
12214
12333
|
await when(() => this.status === KosCoreState.READY);
|
|
12215
12334
|
}
|
|
12216
12335
|
async ready() {
|
|
12217
|
-
log$
|
|
12336
|
+
log$B.debug("Readying KOS Core");
|
|
12218
12337
|
await this._transport.whenReady();
|
|
12219
|
-
log$
|
|
12338
|
+
log$B.debug("KOS Transport ready. Preloading models");
|
|
12220
12339
|
if (!this.modelManager) {
|
|
12221
12340
|
throw new Error(
|
|
12222
12341
|
"KOS Core reached ready() with no model manager. Its lifecycle was started without a registry."
|
|
@@ -12229,7 +12348,7 @@ alias:${alias}
|
|
|
12229
12348
|
promise: model.whenReady()
|
|
12230
12349
|
};
|
|
12231
12350
|
});
|
|
12232
|
-
log$
|
|
12351
|
+
log$B.debug(`Preloaded ${promises.length} models`);
|
|
12233
12352
|
const settled = await Promise.allSettled(
|
|
12234
12353
|
promises.map((promise) => {
|
|
12235
12354
|
const { promise: timeoutPromise, cancel: timeoutCancel } = rejectAfterDelay(5e3, promise.model);
|
|
@@ -12243,14 +12362,14 @@ alias:${alias}
|
|
|
12243
12362
|
);
|
|
12244
12363
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
12245
12364
|
if (failed.length) {
|
|
12246
|
-
log$
|
|
12365
|
+
log$B.error(
|
|
12247
12366
|
`There were ${failed.length} failed models on model preloading`
|
|
12248
12367
|
);
|
|
12249
12368
|
throw Error(
|
|
12250
12369
|
`There were ${failed.length} failed models on model preloading`
|
|
12251
12370
|
);
|
|
12252
12371
|
}
|
|
12253
|
-
log$
|
|
12372
|
+
log$B.debug(`leaving kos-core ready() `);
|
|
12254
12373
|
}
|
|
12255
12374
|
get isReady() {
|
|
12256
12375
|
return this.status === KosCoreState.READY;
|
|
@@ -12268,19 +12387,19 @@ alias:${alias}
|
|
|
12268
12387
|
return this.loaded;
|
|
12269
12388
|
}
|
|
12270
12389
|
async init() {
|
|
12271
|
-
log$
|
|
12390
|
+
log$B.debug("entering kos-core init()");
|
|
12272
12391
|
console.time("kosCore:startup");
|
|
12273
12392
|
console.time("kosCore:init");
|
|
12274
12393
|
await this._transport.whenReady();
|
|
12275
12394
|
this.initialized = true;
|
|
12276
|
-
log$
|
|
12395
|
+
log$B.debug("initialized - leaving kos-core init()");
|
|
12277
12396
|
console.timeEnd("kosCore:init");
|
|
12278
12397
|
}
|
|
12279
12398
|
async load() {
|
|
12280
|
-
log$
|
|
12399
|
+
log$B.debug("entering kos-core load()");
|
|
12281
12400
|
console.time("kosCore:load");
|
|
12282
12401
|
this.loaded = true;
|
|
12283
|
-
log$
|
|
12402
|
+
log$B.debug("loaded - leaving kos-core load()");
|
|
12284
12403
|
console.timeEnd("kosCore:load");
|
|
12285
12404
|
}
|
|
12286
12405
|
static create(registry, reset2, connectionAlias) {
|
|
@@ -12370,9 +12489,9 @@ alias:${alias}
|
|
|
12370
12489
|
return this._instance;
|
|
12371
12490
|
}
|
|
12372
12491
|
}
|
|
12373
|
-
const log$
|
|
12374
|
-
|
|
12375
|
-
|
|
12492
|
+
const log$A = KosLog.createLogger({
|
|
12493
|
+
group: LogGroup.core,
|
|
12494
|
+
name: "kos-model-visitor"
|
|
12376
12495
|
});
|
|
12377
12496
|
class KosModelVisitor {
|
|
12378
12497
|
/**
|
|
@@ -12411,7 +12530,7 @@ class KosModelVisitor {
|
|
|
12411
12530
|
*/
|
|
12412
12531
|
visit(model) {
|
|
12413
12532
|
if (this.visitedModels.has(model.modelId)) {
|
|
12414
|
-
log$
|
|
12533
|
+
log$A.info(`model ${model.modelId} already visited`);
|
|
12415
12534
|
return;
|
|
12416
12535
|
}
|
|
12417
12536
|
const stopVisiting = !!this.visitModel(model.modelData, this);
|
|
@@ -12424,6 +12543,10 @@ class KosModelVisitor {
|
|
|
12424
12543
|
});
|
|
12425
12544
|
}
|
|
12426
12545
|
}
|
|
12546
|
+
const log$z = KosLog.createLogger({
|
|
12547
|
+
group: LogGroup.core,
|
|
12548
|
+
name: "feature-flags"
|
|
12549
|
+
});
|
|
12427
12550
|
const EXTENSION_FEATURE_FLAG_RESOLVER = "featureFlagResolver";
|
|
12428
12551
|
const flagResolvers = /* @__PURE__ */ new Map();
|
|
12429
12552
|
registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
@@ -12444,7 +12567,7 @@ registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
|
12444
12567
|
if (r.status === "fulfilled") {
|
|
12445
12568
|
return r.value;
|
|
12446
12569
|
} else {
|
|
12447
|
-
|
|
12570
|
+
log$z.info(`Feature flag resolver ${id} failed: ${r.reason}`);
|
|
12448
12571
|
return [];
|
|
12449
12572
|
}
|
|
12450
12573
|
}).flat();
|
|
@@ -12517,7 +12640,41 @@ const modelFactory = (typeId) => {
|
|
|
12517
12640
|
};
|
|
12518
12641
|
};
|
|
12519
12642
|
const pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);
|
|
12520
|
-
const log$
|
|
12643
|
+
const log$y = KosLog.createLogger({
|
|
12644
|
+
group: LogGroup.core,
|
|
12645
|
+
name: "retry-with-exponential-backoff"
|
|
12646
|
+
});
|
|
12647
|
+
const BASE_OPTIONS = {
|
|
12648
|
+
maxAttempts: 5,
|
|
12649
|
+
baseDelayMs: 100,
|
|
12650
|
+
backoffFactor: 1.5
|
|
12651
|
+
};
|
|
12652
|
+
async function retryWithExponentialBackoff(operation, options) {
|
|
12653
|
+
let attempt = 1;
|
|
12654
|
+
const _options = { ...BASE_OPTIONS, ...options };
|
|
12655
|
+
const { maxAttempts, baseDelayMs, backoffFactor } = _options;
|
|
12656
|
+
let delayMs = baseDelayMs;
|
|
12657
|
+
while (attempt <= maxAttempts) {
|
|
12658
|
+
try {
|
|
12659
|
+
const result = await operation();
|
|
12660
|
+
return result;
|
|
12661
|
+
} catch (error) {
|
|
12662
|
+
log$y.error(`Attempt ${attempt} failed: ${error}`);
|
|
12663
|
+
if (attempt < maxAttempts) {
|
|
12664
|
+
delayMs = baseDelayMs * Math.pow(backoffFactor, attempt);
|
|
12665
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
12666
|
+
attempt++;
|
|
12667
|
+
} else {
|
|
12668
|
+
throw error;
|
|
12669
|
+
}
|
|
12670
|
+
}
|
|
12671
|
+
}
|
|
12672
|
+
throw new Error("All attempts failed");
|
|
12673
|
+
}
|
|
12674
|
+
const log$x = KosLog.createLogger({
|
|
12675
|
+
group: LogGroup.transport,
|
|
12676
|
+
name: "kos-service-request"
|
|
12677
|
+
});
|
|
12521
12678
|
const resolveServiceUrl = (_service) => {
|
|
12522
12679
|
const MOCK = false;
|
|
12523
12680
|
const URL2 = BASE_URL;
|
|
@@ -12689,7 +12846,7 @@ const getOne$7 = (destinationAddress, url, _fetch) => async ({
|
|
|
12689
12846
|
destinationAddress: destinationAddressOverride
|
|
12690
12847
|
});
|
|
12691
12848
|
const resolvedUrl = urlOverride || url;
|
|
12692
|
-
log$
|
|
12849
|
+
log$x.debug(`resolvedUrl: ${resolvedUrl}`);
|
|
12693
12850
|
try {
|
|
12694
12851
|
const response = await _fetch(resolvedUrl, options);
|
|
12695
12852
|
if (!response.ok) {
|
|
@@ -13008,6 +13165,62 @@ const ServiceFactory = {
|
|
|
13008
13165
|
const _sessionKey = uuid();
|
|
13009
13166
|
const getKosSessionKey = () => `kos-${_sessionKey}`;
|
|
13010
13167
|
const isLocalRefId = (id) => !!id && !id.includes("VM_SERVICE") && id.startsWith(getKosSessionKey());
|
|
13168
|
+
const log$w = KosLog.createLogger({
|
|
13169
|
+
group: LogGroup.transport,
|
|
13170
|
+
name: "wait-for-request"
|
|
13171
|
+
});
|
|
13172
|
+
const waitForRequest = async (requestId, timeout = 6e4) => new Promise((resolve, reject) => {
|
|
13173
|
+
const { unsubscribe } = subscribe(requestId, (op) => {
|
|
13174
|
+
log$w.debug(`recieved response for refId ${requestId}: ${op}`);
|
|
13175
|
+
unsubscribe();
|
|
13176
|
+
clearTimeout(cancel);
|
|
13177
|
+
try {
|
|
13178
|
+
const body = op?.body ? JSON.parse(op.body) : {};
|
|
13179
|
+
resolve(body);
|
|
13180
|
+
} catch {
|
|
13181
|
+
const body = op?.body || {};
|
|
13182
|
+
resolve(body);
|
|
13183
|
+
}
|
|
13184
|
+
});
|
|
13185
|
+
const cancel = setTimeout(() => {
|
|
13186
|
+
unsubscribe();
|
|
13187
|
+
reject(Error(`Request with ID ${requestId} timed out. Cancelling.`));
|
|
13188
|
+
}, timeout);
|
|
13189
|
+
});
|
|
13190
|
+
const sendRequest = async (requestPromise, params2, refId) => {
|
|
13191
|
+
const op = waitForRequest(refId);
|
|
13192
|
+
const result = await Promise.allSettled([requestPromise(params2), op]);
|
|
13193
|
+
if (result[0].status === "fulfilled") {
|
|
13194
|
+
if (result[1].status === "rejected") {
|
|
13195
|
+
throw Error(result[1].reason);
|
|
13196
|
+
} else {
|
|
13197
|
+
if (result[0].value) {
|
|
13198
|
+
if (result[1].value.error) {
|
|
13199
|
+
throw Error(result[1].value.error);
|
|
13200
|
+
}
|
|
13201
|
+
result[0].value.data = result[1].value;
|
|
13202
|
+
return result[0].value;
|
|
13203
|
+
}
|
|
13204
|
+
}
|
|
13205
|
+
} else {
|
|
13206
|
+
throw Error(result[0].reason);
|
|
13207
|
+
}
|
|
13208
|
+
return void 0;
|
|
13209
|
+
};
|
|
13210
|
+
const syncPublish = async ({
|
|
13211
|
+
topic,
|
|
13212
|
+
msg,
|
|
13213
|
+
requestId
|
|
13214
|
+
}) => {
|
|
13215
|
+
const _requestId = requestId ?? uuid();
|
|
13216
|
+
const responsePromise = waitForRequest(_requestId);
|
|
13217
|
+
publish(topic, msg, { sync: _requestId });
|
|
13218
|
+
const response = await responsePromise;
|
|
13219
|
+
if (response.error) {
|
|
13220
|
+
throw Error(response.error);
|
|
13221
|
+
}
|
|
13222
|
+
return response;
|
|
13223
|
+
};
|
|
13011
13224
|
const contextMap = /* @__PURE__ */ new Map();
|
|
13012
13225
|
class KosContextBean {
|
|
13013
13226
|
_context;
|
|
@@ -13104,7 +13317,10 @@ const KosContextManager = {
|
|
|
13104
13317
|
};
|
|
13105
13318
|
KosContextManager.createContext("root");
|
|
13106
13319
|
const resolveKosContext = (model) => KosContextManager.getContext(model.id);
|
|
13107
|
-
const log$
|
|
13320
|
+
const log$v = KosLog.createLogger({
|
|
13321
|
+
group: LogGroup.core,
|
|
13322
|
+
name: "kos-data-container"
|
|
13323
|
+
});
|
|
13108
13324
|
class KosDataContainer {
|
|
13109
13325
|
_data;
|
|
13110
13326
|
_sortKey;
|
|
@@ -13309,7 +13525,7 @@ class KosDataContainer {
|
|
|
13309
13525
|
const idx = this.index.get(indexName);
|
|
13310
13526
|
return idx.keys ?? [];
|
|
13311
13527
|
} else {
|
|
13312
|
-
log$
|
|
13528
|
+
log$v.info(
|
|
13313
13529
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13314
13530
|
);
|
|
13315
13531
|
return [];
|
|
@@ -13321,7 +13537,7 @@ class KosDataContainer {
|
|
|
13321
13537
|
if (idx.index.has(indexKey)) {
|
|
13322
13538
|
return idx.getByKey(indexKey);
|
|
13323
13539
|
} else {
|
|
13324
|
-
log$
|
|
13540
|
+
log$v.info(
|
|
13325
13541
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
13326
13542
|
idx.index.keys()
|
|
13327
13543
|
)}`
|
|
@@ -13329,7 +13545,7 @@ class KosDataContainer {
|
|
|
13329
13545
|
return [];
|
|
13330
13546
|
}
|
|
13331
13547
|
} else {
|
|
13332
|
-
log$
|
|
13548
|
+
log$v.info(
|
|
13333
13549
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13334
13550
|
);
|
|
13335
13551
|
return [];
|
|
@@ -13356,7 +13572,7 @@ class KosDataContainer {
|
|
|
13356
13572
|
* @private
|
|
13357
13573
|
*/
|
|
13358
13574
|
_logDataCapacityWarning(toEvict) {
|
|
13359
|
-
log$
|
|
13575
|
+
log$v.info(
|
|
13360
13576
|
`Data container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${toEvict} items using ${this._evictionStrategy} strategy. This may indicate missing cleanup handlers or data inconsistency.`
|
|
13361
13577
|
);
|
|
13362
13578
|
}
|
|
@@ -13416,7 +13632,7 @@ class KosDataContainer {
|
|
|
13416
13632
|
const candidates = this._customEvictionFilter(this.data);
|
|
13417
13633
|
return candidates.slice(0, count).map((item) => item.id);
|
|
13418
13634
|
}
|
|
13419
|
-
log$
|
|
13635
|
+
log$v.error(
|
|
13420
13636
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO."
|
|
13421
13637
|
);
|
|
13422
13638
|
return this._selectFifoData(count);
|
|
@@ -13428,7 +13644,7 @@ class KosDataContainer {
|
|
|
13428
13644
|
_removeEvictedData(ids) {
|
|
13429
13645
|
ids.forEach((id) => {
|
|
13430
13646
|
const item = this._data.get(id);
|
|
13431
|
-
log$
|
|
13647
|
+
log$v.info(`Evicting data item: ${id}`, {
|
|
13432
13648
|
itemId: id,
|
|
13433
13649
|
itemType: item ? item.constructor?.name : "unknown",
|
|
13434
13650
|
strategy: this._evictionStrategy
|
|
@@ -13441,7 +13657,7 @@ class KosDataContainer {
|
|
|
13441
13657
|
* @private
|
|
13442
13658
|
*/
|
|
13443
13659
|
_logDataEvictionComplete(evictedCount) {
|
|
13444
|
-
log$
|
|
13660
|
+
log$v.info(
|
|
13445
13661
|
`Evicted ${evictedCount} data items. Current size: ${this._data.size}/${this._maxCapacity}`
|
|
13446
13662
|
);
|
|
13447
13663
|
}
|
|
@@ -13613,14 +13829,17 @@ class BrowserKosRouter {
|
|
|
13613
13829
|
}, {});
|
|
13614
13830
|
}
|
|
13615
13831
|
}
|
|
13616
|
-
const log$
|
|
13832
|
+
const log$u = KosLog.createLogger({
|
|
13833
|
+
group: LogGroup.core,
|
|
13834
|
+
name: "intent-service"
|
|
13835
|
+
});
|
|
13617
13836
|
const sendIntent = (intent) => {
|
|
13618
13837
|
if (hasEventSubscriptions(`/kos/intent/${intent.type}`)) {
|
|
13619
13838
|
publish(`/kos/intent/${intent.type}`, intent.options, {
|
|
13620
13839
|
"kos.intent.type": intent.type
|
|
13621
13840
|
});
|
|
13622
13841
|
} else {
|
|
13623
|
-
log$
|
|
13842
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13624
13843
|
}
|
|
13625
13844
|
};
|
|
13626
13845
|
const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
@@ -13650,11 +13869,14 @@ const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
|
13650
13869
|
sync: requestId
|
|
13651
13870
|
});
|
|
13652
13871
|
} else {
|
|
13653
|
-
log$
|
|
13872
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13654
13873
|
resolve([null, { body: void 0, payload: void 0 }]);
|
|
13655
13874
|
}
|
|
13656
13875
|
});
|
|
13657
|
-
const log$
|
|
13876
|
+
const log$t = KosLog.createLogger({
|
|
13877
|
+
group: LogGroup.core,
|
|
13878
|
+
name: "app-startup-service"
|
|
13879
|
+
});
|
|
13658
13880
|
async function waitForAppsToStart(appIds, options = {}) {
|
|
13659
13881
|
const {
|
|
13660
13882
|
timeout = 3e4,
|
|
@@ -13662,10 +13884,10 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13662
13884
|
requirePostStarted = false
|
|
13663
13885
|
} = options;
|
|
13664
13886
|
if (appIds.length === 0) {
|
|
13665
|
-
log$
|
|
13887
|
+
log$t.warn("No app IDs provided to waitForAppsToStart");
|
|
13666
13888
|
return true;
|
|
13667
13889
|
}
|
|
13668
|
-
log$
|
|
13890
|
+
log$t.debug(`Waiting for apps to start: ${appIds.join(", ")}`);
|
|
13669
13891
|
try {
|
|
13670
13892
|
const eventTopics = appIds.map((appId) => `/kos/app/started/${appId}`);
|
|
13671
13893
|
const startedApps = await waitForAllWithState(eventTopics, {
|
|
@@ -13674,12 +13896,12 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13674
13896
|
const { default: api2 } = await Promise.resolve().then(() => service);
|
|
13675
13897
|
const [error, data] = await api2.get("/api/kos/apps/started");
|
|
13676
13898
|
if (error) {
|
|
13677
|
-
log$
|
|
13899
|
+
log$t.error("Error fetching started apps:", error);
|
|
13678
13900
|
return [];
|
|
13679
13901
|
}
|
|
13680
13902
|
return data;
|
|
13681
13903
|
} catch (error) {
|
|
13682
|
-
log$
|
|
13904
|
+
log$t.error("Failed to fetch app startup status:", error);
|
|
13683
13905
|
}
|
|
13684
13906
|
return [];
|
|
13685
13907
|
},
|
|
@@ -13701,17 +13923,17 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13701
13923
|
});
|
|
13702
13924
|
if (notStartedApps.length > 0) {
|
|
13703
13925
|
const message = `Apps not started: ${notStartedApps.join(", ")}`;
|
|
13704
|
-
log$
|
|
13926
|
+
log$t.error(message);
|
|
13705
13927
|
if (throwOnTimeout) {
|
|
13706
13928
|
throw new Error(`App startup timeout: ${message}`);
|
|
13707
13929
|
}
|
|
13708
13930
|
return false;
|
|
13709
13931
|
}
|
|
13710
|
-
log$
|
|
13932
|
+
log$t.info(`All apps started successfully: ${appIds.join(", ")}`);
|
|
13711
13933
|
return true;
|
|
13712
13934
|
} catch (error) {
|
|
13713
13935
|
const message = `Failed to wait for apps to start: ${appIds.join(", ")}`;
|
|
13714
|
-
log$
|
|
13936
|
+
log$t.error(message, error);
|
|
13715
13937
|
if (throwOnTimeout) {
|
|
13716
13938
|
throw new Error(
|
|
13717
13939
|
`${message} - ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -13738,7 +13960,7 @@ async function checkAppsStarted(appIds, requirePostStarted = false) {
|
|
|
13738
13960
|
result[appId] = app?.started === true && (!requirePostStarted || app?.postStarted === true);
|
|
13739
13961
|
});
|
|
13740
13962
|
} catch (error) {
|
|
13741
|
-
log$
|
|
13963
|
+
log$t.error("Failed to check app startup status:", error);
|
|
13742
13964
|
appIds.forEach((appId) => result[appId] = false);
|
|
13743
13965
|
}
|
|
13744
13966
|
return result;
|
|
@@ -13752,7 +13974,7 @@ async function getStartedApps() {
|
|
|
13752
13974
|
const result = await response.json();
|
|
13753
13975
|
return result?.data ?? [];
|
|
13754
13976
|
} catch (error) {
|
|
13755
|
-
log$
|
|
13977
|
+
log$t.error("Failed to fetch started apps:", error);
|
|
13756
13978
|
return [];
|
|
13757
13979
|
}
|
|
13758
13980
|
}
|
|
@@ -13779,9 +14001,9 @@ var Topics = /* @__PURE__ */ ((Topics2) => {
|
|
|
13779
14001
|
Topics2["TIMEZONE_CHANGE"] = "/kos/internal/time/timezone";
|
|
13780
14002
|
return Topics2;
|
|
13781
14003
|
})(Topics || {});
|
|
13782
|
-
const log$
|
|
13783
|
-
|
|
13784
|
-
|
|
14004
|
+
const log$s = KosLog.createLogger({
|
|
14005
|
+
group: LogGroup.service,
|
|
14006
|
+
name: "config-bean-service"
|
|
13785
14007
|
});
|
|
13786
14008
|
const URL$e = BASE_URL;
|
|
13787
14009
|
const hasDecimals = (option) => option?.decimals !== void 0;
|
|
@@ -13790,7 +14012,7 @@ const { postModel: postModel$5, getOne: getOne$6 } = ServiceFactory.build({
|
|
|
13790
14012
|
basePath: `${URL$e}/kos/config/`
|
|
13791
14013
|
});
|
|
13792
14014
|
const modifyConfigBean = async (id, model, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13793
|
-
log$
|
|
14015
|
+
log$s.debug(`sending modify request for ConfigBean: ${id}`);
|
|
13794
14016
|
const response = postModel$5({
|
|
13795
14017
|
model,
|
|
13796
14018
|
urlOverride: `${URL$e}${path}/${id}`,
|
|
@@ -13799,7 +14021,7 @@ const modifyConfigBean = async (id, model, path = `/api/kos/config`, destination
|
|
|
13799
14021
|
return response;
|
|
13800
14022
|
};
|
|
13801
14023
|
const getConfigBean = async (id, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13802
|
-
log$
|
|
14024
|
+
log$s.debug(`sending get request for ConfigBean: ${id}`);
|
|
13803
14025
|
const response = await getOne$6({
|
|
13804
14026
|
urlOverride: `${URL$e}${path}/details/${id}/15`,
|
|
13805
14027
|
destinationAddress
|
|
@@ -13912,7 +14134,10 @@ function matchValue(patterns, value) {
|
|
|
13912
14134
|
return void 0;
|
|
13913
14135
|
}
|
|
13914
14136
|
const CONFIG_BEAN_MODEL_TYPE = "config-bean-model";
|
|
13915
|
-
const log$
|
|
14137
|
+
const log$r = KosLog.createLogger({
|
|
14138
|
+
group: LogGroup.model,
|
|
14139
|
+
name: CONFIG_BEAN_MODEL_TYPE
|
|
14140
|
+
});
|
|
13916
14141
|
const PATH_PROP$3 = createPropKey("path");
|
|
13917
14142
|
const DESTINATION_PROP$2 = createPropKey("destinationAddress");
|
|
13918
14143
|
function configBeanModelId(path, destinationAddress) {
|
|
@@ -13985,8 +14210,8 @@ let ConfigBeanModelImpl = class {
|
|
|
13985
14210
|
* @internal
|
|
13986
14211
|
*/
|
|
13987
14212
|
async ready() {
|
|
13988
|
-
log$
|
|
13989
|
-
log$
|
|
14213
|
+
log$r.debug(`readying config bean ${this.path}`);
|
|
14214
|
+
log$r.debug(`complete readying config bean ${this.path}`);
|
|
13990
14215
|
}
|
|
13991
14216
|
/**
|
|
13992
14217
|
* @internal
|
|
@@ -13995,7 +14220,7 @@ let ConfigBeanModelImpl = class {
|
|
|
13995
14220
|
* Fetches the bean's values and schema.
|
|
13996
14221
|
*/
|
|
13997
14222
|
async load() {
|
|
13998
|
-
log$
|
|
14223
|
+
log$r.debug(`loading config bean ${this.path}`);
|
|
13999
14224
|
await this.fetchBean();
|
|
14000
14225
|
}
|
|
14001
14226
|
/**
|
|
@@ -14006,7 +14231,7 @@ let ConfigBeanModelImpl = class {
|
|
|
14006
14231
|
* KOS Core reload after a reconnect leaves the same instance current.
|
|
14007
14232
|
*/
|
|
14008
14233
|
async reload() {
|
|
14009
|
-
log$
|
|
14234
|
+
log$r.debug(`reloading config bean ${this.path}`);
|
|
14010
14235
|
await this.fetchBean();
|
|
14011
14236
|
}
|
|
14012
14237
|
async fetchBean() {
|
|
@@ -14018,7 +14243,7 @@ let ConfigBeanModelImpl = class {
|
|
|
14018
14243
|
if (response?.data) {
|
|
14019
14244
|
const data = response.data;
|
|
14020
14245
|
mapDtoToConfigBeanModel(data, this);
|
|
14021
|
-
log$
|
|
14246
|
+
log$r.debug(this.values);
|
|
14022
14247
|
const schemaResponse = response?.data.details[0].schema;
|
|
14023
14248
|
kosAction(() => {
|
|
14024
14249
|
if (schemaResponse) {
|
|
@@ -14263,7 +14488,10 @@ var __decorateClass$u = (decorators, target, key, kind) => {
|
|
|
14263
14488
|
return result;
|
|
14264
14489
|
};
|
|
14265
14490
|
const MODEL_TYPE$r = "region-info-model";
|
|
14266
|
-
const log$
|
|
14491
|
+
const log$q = KosLog.createLogger({
|
|
14492
|
+
group: LogGroup.model,
|
|
14493
|
+
name: "region-info-model"
|
|
14494
|
+
});
|
|
14267
14495
|
function servicePathMapper(regionInfoModel) {
|
|
14268
14496
|
const hasMapper = ExtensionManager.propertyMapper.hasMapper(
|
|
14269
14497
|
KosCoreModelPropertyMapper.RegionServicePath
|
|
@@ -14576,7 +14804,7 @@ let RegionInfoModelImpl = class {
|
|
|
14576
14804
|
}
|
|
14577
14805
|
toUnit = measureSystems[to.system]?.["default"];
|
|
14578
14806
|
if (!toUnit) {
|
|
14579
|
-
log$
|
|
14807
|
+
log$q.info("Could not find default unit for measure", to.measure);
|
|
14580
14808
|
}
|
|
14581
14809
|
}
|
|
14582
14810
|
if (!fromUnit && from.measure && from.system) {
|
|
@@ -14590,11 +14818,11 @@ let RegionInfoModelImpl = class {
|
|
|
14590
14818
|
}
|
|
14591
14819
|
fromUnit = measureSystems[from.system]?.["default"];
|
|
14592
14820
|
if (!fromUnit) {
|
|
14593
|
-
log$
|
|
14821
|
+
log$q.info("Could not find default unit for measure", from.measure);
|
|
14594
14822
|
}
|
|
14595
14823
|
}
|
|
14596
14824
|
if (!fromUnit || !toUnit) {
|
|
14597
|
-
log$
|
|
14825
|
+
log$q.warn("Could not find unit to convert to or from. Return value as is");
|
|
14598
14826
|
return String(value);
|
|
14599
14827
|
}
|
|
14600
14828
|
return this.convertByUnit(value, fromUnit, toUnit);
|
|
@@ -14604,13 +14832,13 @@ let RegionInfoModelImpl = class {
|
|
|
14604
14832
|
* @internal
|
|
14605
14833
|
*/
|
|
14606
14834
|
async init() {
|
|
14607
|
-
log$
|
|
14835
|
+
log$q.debug("initializing region info");
|
|
14608
14836
|
}
|
|
14609
14837
|
/**
|
|
14610
14838
|
* @internal
|
|
14611
14839
|
*/
|
|
14612
14840
|
async load() {
|
|
14613
|
-
log$
|
|
14841
|
+
log$q.debug("loading region info");
|
|
14614
14842
|
const regions = await getRegions(
|
|
14615
14843
|
this.serviceBasePath,
|
|
14616
14844
|
this.destinationAddress
|
|
@@ -14947,7 +15175,10 @@ function secondsToFormattedTime(secondsSinceMidnight, formatString) {
|
|
|
14947
15175
|
return format(time, formatString);
|
|
14948
15176
|
}
|
|
14949
15177
|
const MODEL_TYPE$q = "config-bean-prop-model";
|
|
14950
|
-
const log$
|
|
15178
|
+
const log$p = KosLog.createLogger({
|
|
15179
|
+
group: LogGroup.model,
|
|
15180
|
+
name: "config-bean-prop-model"
|
|
15181
|
+
});
|
|
14951
15182
|
const PATH_PROP$2 = createPropKey("path");
|
|
14952
15183
|
const SERVICE_PATH_PROP = createPropKey("serviceBasePath");
|
|
14953
15184
|
const DESTINATION_PROP = createPropKey("destinationAddress");
|
|
@@ -15134,7 +15365,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15134
15365
|
return Number(result2);
|
|
15135
15366
|
}
|
|
15136
15367
|
} catch (e) {
|
|
15137
|
-
log$
|
|
15368
|
+
log$p.info(`error formatting value ${_val}`, e);
|
|
15138
15369
|
}
|
|
15139
15370
|
const result = Number(_val).toFixed(decimals);
|
|
15140
15371
|
return result;
|
|
@@ -15166,7 +15397,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15166
15397
|
* @internal
|
|
15167
15398
|
*/
|
|
15168
15399
|
async activate() {
|
|
15169
|
-
log$
|
|
15400
|
+
log$p.debug(`activating config bean ${this.id}`);
|
|
15170
15401
|
}
|
|
15171
15402
|
/**
|
|
15172
15403
|
* The value formatted with its unit for the active locale, such as `"72.5 °F"`.
|
|
@@ -15193,7 +15424,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15193
15424
|
return result;
|
|
15194
15425
|
}
|
|
15195
15426
|
} catch (e) {
|
|
15196
|
-
log$
|
|
15427
|
+
log$p.error(`error formatting value ${_val}`, e);
|
|
15197
15428
|
}
|
|
15198
15429
|
}
|
|
15199
15430
|
return String(_val);
|
|
@@ -15285,13 +15516,13 @@ let KosConfigPropertyImpl = class {
|
|
|
15285
15516
|
try {
|
|
15286
15517
|
formatter = new Intl.NumberFormat(locale, { ...formatOptions });
|
|
15287
15518
|
} catch (e) {
|
|
15288
|
-
log$
|
|
15519
|
+
log$p.error(
|
|
15289
15520
|
`error creating formatter ${formatOptions}. Returning the raw value`,
|
|
15290
15521
|
e
|
|
15291
15522
|
);
|
|
15292
15523
|
}
|
|
15293
15524
|
} else {
|
|
15294
|
-
log$
|
|
15525
|
+
log$p.debug(
|
|
15295
15526
|
`no formatter found for config bean prop ${this.id}. Returning the raw value`
|
|
15296
15527
|
);
|
|
15297
15528
|
}
|
|
@@ -15352,7 +15583,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15352
15583
|
* @param value - The new value in display units
|
|
15353
15584
|
*/
|
|
15354
15585
|
async updateProperty(value) {
|
|
15355
|
-
log$
|
|
15586
|
+
log$p.debug(`updating property ${this.attribute} with value ${value}`);
|
|
15356
15587
|
let _value = value;
|
|
15357
15588
|
const converter = this.getConverter();
|
|
15358
15589
|
if (converter && !isNaN(_value)) {
|
|
@@ -15396,6 +15627,10 @@ const Registration = {
|
|
|
15396
15627
|
MODEL_TYPE$q
|
|
15397
15628
|
)
|
|
15398
15629
|
};
|
|
15630
|
+
const log$o = KosLog.createLogger({
|
|
15631
|
+
group: LogGroup.model,
|
|
15632
|
+
name: "future-model-builder"
|
|
15633
|
+
});
|
|
15399
15634
|
const mapDtoToFutureOptions = (dto) => {
|
|
15400
15635
|
const options = {
|
|
15401
15636
|
id: String(dto.id),
|
|
@@ -15411,10 +15646,10 @@ const mapDtoToFutureOptions = (dto) => {
|
|
|
15411
15646
|
return options;
|
|
15412
15647
|
};
|
|
15413
15648
|
const mapDtoToFutureModel = (dto, model) => {
|
|
15414
|
-
|
|
15415
|
-
|
|
15649
|
+
log$o.debug(`future dto ${dto.id} end state ${dto.endState}`);
|
|
15650
|
+
log$o.debug(`future model ${model.id} end state ${model.endState}`);
|
|
15416
15651
|
if (!model.endState) {
|
|
15417
|
-
|
|
15652
|
+
log$o.debug(`updating future model ${model.id}`);
|
|
15418
15653
|
runInAction(() => {
|
|
15419
15654
|
const options = mapDtoToFutureOptions(dto);
|
|
15420
15655
|
kosAction(() => {
|
|
@@ -15433,7 +15668,7 @@ const mapDtoToFutureModel = (dto, model) => {
|
|
|
15433
15668
|
});
|
|
15434
15669
|
});
|
|
15435
15670
|
} else {
|
|
15436
|
-
|
|
15671
|
+
log$o.debug(`future model ${model.id} is already complete`);
|
|
15437
15672
|
}
|
|
15438
15673
|
};
|
|
15439
15674
|
const buildFutureModel$1 = (factory) => (modelId) => (futureOptions) => {
|
|
@@ -15444,7 +15679,10 @@ const buildFuture = (factory) => (future) => pipe(
|
|
|
15444
15679
|
mapDtoToFutureOptions,
|
|
15445
15680
|
buildFutureModel$1(factory)(future.tracker || future.id)
|
|
15446
15681
|
)(future);
|
|
15447
|
-
const log$
|
|
15682
|
+
const log$n = KosLog.createLogger({
|
|
15683
|
+
group: LogGroup.service,
|
|
15684
|
+
name: "future-service"
|
|
15685
|
+
});
|
|
15448
15686
|
const { isMock, URL: URL$c } = resolveServiceUrl();
|
|
15449
15687
|
var FutureEndState = /* @__PURE__ */ ((FutureEndState2) => {
|
|
15450
15688
|
FutureEndState2["Success"] = "SUCCESS";
|
|
@@ -15463,7 +15701,7 @@ const getFutures = async () => {
|
|
|
15463
15701
|
return response;
|
|
15464
15702
|
};
|
|
15465
15703
|
const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
15466
|
-
log$
|
|
15704
|
+
log$n.info(`sending delete request for Future: ${id}`);
|
|
15467
15705
|
const response = await deleteModel$1({
|
|
15468
15706
|
id,
|
|
15469
15707
|
urlOverride: `${URL$c}${path}/${id}`
|
|
@@ -15471,7 +15709,7 @@ const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
|
15471
15709
|
return response;
|
|
15472
15710
|
};
|
|
15473
15711
|
const addFuture = async (future, path = "/api/kos/future") => {
|
|
15474
|
-
log$
|
|
15712
|
+
log$n.info(`sending add request for Future`);
|
|
15475
15713
|
const response = await addModel({
|
|
15476
15714
|
model: future,
|
|
15477
15715
|
urlOverride: `${URL$c}${path}`
|
|
@@ -15479,7 +15717,7 @@ const addFuture = async (future, path = "/api/kos/future") => {
|
|
|
15479
15717
|
return response;
|
|
15480
15718
|
};
|
|
15481
15719
|
const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
15482
|
-
log$
|
|
15720
|
+
log$n.info(`sending modify request for Future: ${id}`);
|
|
15483
15721
|
const response = modifyModel({
|
|
15484
15722
|
model,
|
|
15485
15723
|
id,
|
|
@@ -15488,7 +15726,7 @@ const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
|
15488
15726
|
return response;
|
|
15489
15727
|
};
|
|
15490
15728
|
const cancelFuture = async (id, path = "/api/kos/future") => {
|
|
15491
|
-
log$
|
|
15729
|
+
log$n.info(`sending cancel request for Future: ${id}`);
|
|
15492
15730
|
const response = postModel$4({
|
|
15493
15731
|
urlOverride: `${URL$c}${path}/${id}/cancel`,
|
|
15494
15732
|
ordered: true,
|
|
@@ -15528,6 +15766,10 @@ const FutureManager = {
|
|
|
15528
15766
|
initiateFuture,
|
|
15529
15767
|
getFuture
|
|
15530
15768
|
};
|
|
15769
|
+
const log$m = KosLog.createLogger({
|
|
15770
|
+
group: LogGroup.model,
|
|
15771
|
+
name: "future-service"
|
|
15772
|
+
});
|
|
15531
15773
|
const isFutureResponse = (response) => !response || !response.data;
|
|
15532
15774
|
const resolveFutureHandler = (model) => {
|
|
15533
15775
|
const handlerProperty = model?.[MultipleFutureContainerSetup]?.handlerProperty ?? model?.[FutureContainerSetup]?.handlerProperty ?? "futureHandler";
|
|
@@ -15542,9 +15784,7 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15542
15784
|
} = props;
|
|
15543
15785
|
return async function(...args) {
|
|
15544
15786
|
const tracker = uuid();
|
|
15545
|
-
|
|
15546
|
-
`Calling future service ${methodName} with tracker ${tracker}`
|
|
15547
|
-
);
|
|
15787
|
+
log$m.debug(`Calling future service ${methodName} with tracker ${tracker}`);
|
|
15548
15788
|
let abortControllerInstance;
|
|
15549
15789
|
let effectDisposer;
|
|
15550
15790
|
if (abortController) {
|
|
@@ -15557,17 +15797,17 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15557
15797
|
if (namespace) {
|
|
15558
15798
|
future.namespace = namespace;
|
|
15559
15799
|
}
|
|
15560
|
-
|
|
15800
|
+
log$m.debug(`waiting for future ${future.id} to be ready`);
|
|
15561
15801
|
await whenReady(future);
|
|
15562
|
-
|
|
15802
|
+
log$m.debug(`future ${future.id} is ready`);
|
|
15563
15803
|
kosAction(() => {
|
|
15564
|
-
|
|
15804
|
+
log$m.debug(`Adding future ${future.id} to futureHandler`);
|
|
15565
15805
|
resolveFutureHandler(this).addFuture(future, alias);
|
|
15566
15806
|
});
|
|
15567
15807
|
if (abortController && abortControllerInstance) {
|
|
15568
15808
|
effectDisposer = kosAutoEffect(() => {
|
|
15569
15809
|
if (future.status === "CANCELLED" || future.endState === FutureEndState.Canceled) {
|
|
15570
|
-
|
|
15810
|
+
log$m.debug(`Future ${future.id} cancelled, aborting request`);
|
|
15571
15811
|
abortControllerInstance?.abort();
|
|
15572
15812
|
}
|
|
15573
15813
|
});
|
|
@@ -15575,13 +15815,13 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15575
15815
|
"abort",
|
|
15576
15816
|
async () => {
|
|
15577
15817
|
if (future.status !== "CANCELLED" && future.endState !== FutureEndState.Canceled && !future.endState) {
|
|
15578
|
-
|
|
15818
|
+
log$m.debug(
|
|
15579
15819
|
`AbortController aborted, cancelling future ${future.id}`
|
|
15580
15820
|
);
|
|
15581
15821
|
try {
|
|
15582
15822
|
await future.cancelFuture();
|
|
15583
15823
|
} catch (error) {
|
|
15584
|
-
|
|
15824
|
+
log$m.error(`Failed to cancel future ${future.id}:`, error);
|
|
15585
15825
|
}
|
|
15586
15826
|
}
|
|
15587
15827
|
},
|
|
@@ -15622,15 +15862,15 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15622
15862
|
// eslint-disable-next-line no-invalid-this
|
|
15623
15863
|
await original.apply(this, enhancedArgs)
|
|
15624
15864
|
);
|
|
15625
|
-
|
|
15865
|
+
log$m.debug(`received future response for ${tracker}`, futureResponse);
|
|
15626
15866
|
const response = isFutureResponse(futureResponse) ? futureResponse : futureResponse?.data;
|
|
15627
15867
|
if (response) {
|
|
15628
15868
|
response.progress = 1;
|
|
15629
|
-
|
|
15869
|
+
log$m.debug(`mapping future response to future model`);
|
|
15630
15870
|
if (!future.endState) {
|
|
15631
15871
|
mapDtoToFutureModel(response, future);
|
|
15632
15872
|
} else {
|
|
15633
|
-
|
|
15873
|
+
log$m.debug(
|
|
15634
15874
|
`future ${future.id} has already completed. Not updating the model`
|
|
15635
15875
|
);
|
|
15636
15876
|
}
|
|
@@ -15643,10 +15883,10 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15643
15883
|
cleanup();
|
|
15644
15884
|
if (abortController && abortControllerInstance?.signal.aborted) {
|
|
15645
15885
|
const cancelledError = new Error("Operation cancelled");
|
|
15646
|
-
|
|
15886
|
+
log$m.debug(`Operation ${methodName} was cancelled`);
|
|
15647
15887
|
throw cancelledError;
|
|
15648
15888
|
}
|
|
15649
|
-
|
|
15889
|
+
log$m.error(e);
|
|
15650
15890
|
throw e;
|
|
15651
15891
|
}
|
|
15652
15892
|
};
|
|
@@ -15675,12 +15915,12 @@ const { URL: URL$b } = resolveServiceUrl();
|
|
|
15675
15915
|
const { getOne: getOne$4 } = ServiceFactory.build({
|
|
15676
15916
|
basePath: `${URL$b}/api/kos/state`
|
|
15677
15917
|
});
|
|
15678
|
-
const log$
|
|
15679
|
-
|
|
15680
|
-
|
|
15918
|
+
const log$l = KosLog.createLogger({
|
|
15919
|
+
group: LogGroup.service,
|
|
15920
|
+
name: "state-bean-service"
|
|
15681
15921
|
});
|
|
15682
15922
|
const getStateBeanData = async ({ path }) => {
|
|
15683
|
-
log$
|
|
15923
|
+
log$l.debug("sending GET for state-bean");
|
|
15684
15924
|
const response = await getOne$4({
|
|
15685
15925
|
urlOverride: `${URL$b}/api/kos/state/${path}`
|
|
15686
15926
|
});
|
|
@@ -15858,12 +16098,12 @@ const { URL: URL$a } = resolveServiceUrl();
|
|
|
15858
16098
|
const { getAll: getAll$5 } = ServiceFactory.build({
|
|
15859
16099
|
basePath: `${URL$a}/api/state-prop`
|
|
15860
16100
|
});
|
|
15861
|
-
const log$
|
|
15862
|
-
|
|
15863
|
-
|
|
16101
|
+
const log$k = KosLog.createLogger({
|
|
16102
|
+
group: LogGroup.service,
|
|
16103
|
+
name: "state-prop-service"
|
|
15864
16104
|
});
|
|
15865
16105
|
const getStateProps = async () => {
|
|
15866
|
-
log$
|
|
16106
|
+
log$k.debug("sending GET for state-prop");
|
|
15867
16107
|
const response = await getAll$5({});
|
|
15868
16108
|
return response;
|
|
15869
16109
|
};
|
|
@@ -16005,7 +16245,10 @@ var __decorateClass$p = (decorators, target, key, kind) => {
|
|
|
16005
16245
|
if (kind && result) __defProp$l(target, key, result);
|
|
16006
16246
|
return result;
|
|
16007
16247
|
};
|
|
16008
|
-
const log$
|
|
16248
|
+
const log$j = KosLog.createLogger({
|
|
16249
|
+
group: LogGroup.model,
|
|
16250
|
+
name: FutureFactory.type
|
|
16251
|
+
});
|
|
16009
16252
|
let FutureModel = class {
|
|
16010
16253
|
logger;
|
|
16011
16254
|
_cancelFuture;
|
|
@@ -16029,7 +16272,7 @@ let FutureModel = class {
|
|
|
16029
16272
|
kosWhen(
|
|
16030
16273
|
() => this.status === FutureEndState.Success || this.status === FutureEndState.Fail,
|
|
16031
16274
|
() => {
|
|
16032
|
-
log$
|
|
16275
|
+
log$j.info(`Future ${this.id} has completed with status ${this.status}`);
|
|
16033
16276
|
destroyKosModel(this);
|
|
16034
16277
|
}
|
|
16035
16278
|
);
|
|
@@ -16043,13 +16286,13 @@ let FutureModel = class {
|
|
|
16043
16286
|
* In future additional information about the workspace could be loaded
|
|
16044
16287
|
*/
|
|
16045
16288
|
async load() {
|
|
16046
|
-
log$
|
|
16289
|
+
log$j.debug(`loading Future ${this.id}`);
|
|
16047
16290
|
}
|
|
16048
16291
|
/**
|
|
16049
16292
|
* @internal
|
|
16050
16293
|
*/
|
|
16051
16294
|
unload() {
|
|
16052
|
-
log$
|
|
16295
|
+
log$j.info(`unloading Future ${this.id}`);
|
|
16053
16296
|
}
|
|
16054
16297
|
// -------------------ACTIONS----------------------------
|
|
16055
16298
|
/**
|
|
@@ -16068,7 +16311,7 @@ let FutureModel = class {
|
|
|
16068
16311
|
await kosWhen(() => this.futureId !== FUTURE_NOT_ASSIGNED);
|
|
16069
16312
|
const response = await this._cancelFuture(this.futureId, path);
|
|
16070
16313
|
if (response?.status !== 200) {
|
|
16071
|
-
log$
|
|
16314
|
+
log$j.error(
|
|
16072
16315
|
`Failed to cancel Future ${this.id}. Response: ${JSON.stringify(
|
|
16073
16316
|
response
|
|
16074
16317
|
)}`
|
|
@@ -16137,7 +16380,10 @@ var __decorateClass$o = (decorators, target, key, kind) => {
|
|
|
16137
16380
|
if (kind && result) __defProp$k(target, key, result);
|
|
16138
16381
|
return result;
|
|
16139
16382
|
};
|
|
16140
|
-
const log$
|
|
16383
|
+
const log$i = KosLog.createLogger({
|
|
16384
|
+
group: LogGroup.model,
|
|
16385
|
+
name: FutureContainerFactory.type
|
|
16386
|
+
});
|
|
16141
16387
|
let FutureContainerModel = class {
|
|
16142
16388
|
id;
|
|
16143
16389
|
logger;
|
|
@@ -16252,8 +16498,8 @@ let FutureContainerModel = class {
|
|
|
16252
16498
|
try {
|
|
16253
16499
|
await this._deleteFuture(id);
|
|
16254
16500
|
} catch (e) {
|
|
16255
|
-
log$
|
|
16256
|
-
log$
|
|
16501
|
+
log$i.error(`error deleting a Future`);
|
|
16502
|
+
log$i.error(e);
|
|
16257
16503
|
}
|
|
16258
16504
|
}
|
|
16259
16505
|
/**
|
|
@@ -16280,8 +16526,8 @@ let FutureContainerModel = class {
|
|
|
16280
16526
|
return model2;
|
|
16281
16527
|
}
|
|
16282
16528
|
} catch (e) {
|
|
16283
|
-
log$
|
|
16284
|
-
log$
|
|
16529
|
+
log$i.error(`error creating a Future`);
|
|
16530
|
+
log$i.error(e);
|
|
16285
16531
|
throw e;
|
|
16286
16532
|
}
|
|
16287
16533
|
return void 0;
|
|
@@ -16310,9 +16556,9 @@ const { URL: URL$9 } = resolveServiceUrl();
|
|
|
16310
16556
|
const { getOne: getOne$3, postModel: postModel$3, deleteModel } = ServiceFactory.build({
|
|
16311
16557
|
basePath: `${URL$9}/api/keyVal`
|
|
16312
16558
|
});
|
|
16313
|
-
const log$
|
|
16314
|
-
|
|
16315
|
-
|
|
16559
|
+
const log$h = KosLog.createLogger({
|
|
16560
|
+
group: LogGroup.service,
|
|
16561
|
+
name: "key-value-service"
|
|
16316
16562
|
});
|
|
16317
16563
|
const deleteKeyValue = async (namespace, key) => {
|
|
16318
16564
|
await deleteModel({
|
|
@@ -16326,7 +16572,7 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16326
16572
|
model: value.toString()
|
|
16327
16573
|
});
|
|
16328
16574
|
if (response?.status !== 200) {
|
|
16329
|
-
log$
|
|
16575
|
+
log$h.error("Failed to update key-value data", response);
|
|
16330
16576
|
throw new Error(
|
|
16331
16577
|
`Failed to update key-value data for namespace ${namespace}`
|
|
16332
16578
|
);
|
|
@@ -16334,12 +16580,12 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16334
16580
|
return response.data;
|
|
16335
16581
|
};
|
|
16336
16582
|
const getKeyValue = async (namespace = "studio") => {
|
|
16337
|
-
log$
|
|
16583
|
+
log$h.debug(`Retrieving all key-value data for namespace: ${namespace}`);
|
|
16338
16584
|
const response = await getOne$3({
|
|
16339
16585
|
urlOverride: `${URL$9}/api/keyVal/${namespace}`
|
|
16340
16586
|
});
|
|
16341
16587
|
if (response?.status !== 200) {
|
|
16342
|
-
log$
|
|
16588
|
+
log$h.error("Failed to retrieve key-value data", response);
|
|
16343
16589
|
throw new Error(
|
|
16344
16590
|
`Failed to retrieve key-value data for namespace ${namespace}`
|
|
16345
16591
|
);
|
|
@@ -18415,39 +18661,43 @@ KosExpressionEvaluatorModelImpl = __decorateClass$m([
|
|
|
18415
18661
|
kosModel({ modelTypeId: MODEL_TYPE$l, singleton: false })
|
|
18416
18662
|
], KosExpressionEvaluatorModelImpl);
|
|
18417
18663
|
const KosExpressionEvaluator = KosExpressionEvaluatorModelImpl.Registration;
|
|
18664
|
+
const log$g = KosLog.createLogger({
|
|
18665
|
+
group: LogGroup.transport,
|
|
18666
|
+
name: "get-kos-connection-id"
|
|
18667
|
+
});
|
|
18418
18668
|
const getKosConnectionId = () => {
|
|
18419
18669
|
const params2 = getQueryParams();
|
|
18420
18670
|
const connId = params2?.connId;
|
|
18421
18671
|
const result = connId || window?.kosBridge?.("connId");
|
|
18422
|
-
|
|
18672
|
+
log$g.debug(`getKosConnectionId: ${result}`);
|
|
18423
18673
|
return result;
|
|
18424
18674
|
};
|
|
18425
|
-
const log$
|
|
18426
|
-
|
|
18427
|
-
|
|
18675
|
+
const log$f = KosLog.createLogger({
|
|
18676
|
+
group: LogGroup.service,
|
|
18677
|
+
name: "kos-log-manager-service"
|
|
18428
18678
|
});
|
|
18429
18679
|
const SERVICE_PATH$1 = "/api/kos/logs/overrides";
|
|
18430
18680
|
const GROUPS_PATH = "/api/kos/logs/groups";
|
|
18431
18681
|
const getLogOverrides = async () => {
|
|
18432
|
-
log$
|
|
18682
|
+
log$f.debug("sending GET for kos-log-manager");
|
|
18433
18683
|
return await api$1.get(SERVICE_PATH$1, void 0, {
|
|
18434
18684
|
destinationAddress: getKosConnectionId()
|
|
18435
18685
|
});
|
|
18436
18686
|
};
|
|
18437
18687
|
const getLogGroups = async () => {
|
|
18438
|
-
log$
|
|
18688
|
+
log$f.debug("sending GET for log groups");
|
|
18439
18689
|
return await api$1.get(GROUPS_PATH, void 0, {
|
|
18440
18690
|
destinationAddress: getKosConnectionId()
|
|
18441
18691
|
});
|
|
18442
18692
|
};
|
|
18443
18693
|
const addLogOverride = async (override) => {
|
|
18444
|
-
log$
|
|
18694
|
+
log$f.debug(`sending POST for log override ${override.name}`);
|
|
18445
18695
|
return await api$1.post(SERVICE_PATH$1, void 0, override, {
|
|
18446
18696
|
destinationAddress: getKosConnectionId()
|
|
18447
18697
|
});
|
|
18448
18698
|
};
|
|
18449
18699
|
const removeLogOverride = async (override) => {
|
|
18450
|
-
log$
|
|
18700
|
+
log$f.debug(`sending DELETE for log override ${override.name}`);
|
|
18451
18701
|
return await api$1.delete(SERVICE_PATH$1, void 0, override, {
|
|
18452
18702
|
destinationAddress: getKosConnectionId()
|
|
18453
18703
|
});
|
|
@@ -18925,14 +19175,14 @@ __decorateClass$j([
|
|
|
18925
19175
|
LogBlockContainerModelImpl = __decorateClass$j([
|
|
18926
19176
|
kosModel(MODEL_TYPE$i)
|
|
18927
19177
|
], LogBlockContainerModelImpl);
|
|
18928
|
-
const log$
|
|
18929
|
-
|
|
18930
|
-
|
|
19178
|
+
const log$e = KosLog.createLogger({
|
|
19179
|
+
group: LogGroup.service,
|
|
19180
|
+
name: "log-stream-container-service"
|
|
18931
19181
|
});
|
|
18932
19182
|
const SERVICE_PATH = "/api/kos/logs/node/{nodeId}/streams";
|
|
18933
19183
|
const getLogStreams = async () => {
|
|
18934
19184
|
const destinationAddress = getKosConnectionId();
|
|
18935
|
-
log$
|
|
19185
|
+
log$e.debug("sending GET for log-stream-container");
|
|
18936
19186
|
return await api$1.get(
|
|
18937
19187
|
SERVICE_PATH,
|
|
18938
19188
|
{
|
|
@@ -19504,11 +19754,14 @@ const { URL: URL$7 } = resolveServiceUrl();
|
|
|
19504
19754
|
const { getAll: getAll$4, postModel: postModel$1 } = ServiceFactory.build({
|
|
19505
19755
|
basePath: `${URL$7}/api/kos/troubles`
|
|
19506
19756
|
});
|
|
19507
|
-
const log$
|
|
19757
|
+
const log$d = KosLog.createLogger({
|
|
19758
|
+
group: LogGroup.service,
|
|
19759
|
+
name: "trouble-services"
|
|
19760
|
+
});
|
|
19508
19761
|
const getTroubles = async (servicePath) => {
|
|
19509
19762
|
const isKosTroubles = servicePath.includes("/kos/troubles");
|
|
19510
19763
|
const destinationAddress = getKosConnectionId();
|
|
19511
|
-
log$
|
|
19764
|
+
log$d.info(
|
|
19512
19765
|
`Fetching troubles from ${servicePath} with destination address: ${isKosTroubles ? destinationAddress : "N/A (not a kos troubles path)"}`
|
|
19513
19766
|
);
|
|
19514
19767
|
const response = await getAll$4({
|
|
@@ -19590,6 +19843,10 @@ const defaultTroubleRoleMapper = (trouble) => {
|
|
|
19590
19843
|
}
|
|
19591
19844
|
return "TECHNICIAN";
|
|
19592
19845
|
};
|
|
19846
|
+
const log$c = KosLog.createLogger({
|
|
19847
|
+
group: LogGroup.model,
|
|
19848
|
+
name: "trouble-data-extension"
|
|
19849
|
+
});
|
|
19593
19850
|
const EXTENSION_TROUBLE_DATA_MAPPER = "troubleDataMapper";
|
|
19594
19851
|
const troubleMappers$1 = /* @__PURE__ */ new Map();
|
|
19595
19852
|
registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
@@ -19613,7 +19870,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19613
19870
|
if (r.status === "fulfilled") {
|
|
19614
19871
|
acc = { ...acc, ...r.value };
|
|
19615
19872
|
} else {
|
|
19616
|
-
|
|
19873
|
+
log$c.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19617
19874
|
}
|
|
19618
19875
|
return acc;
|
|
19619
19876
|
},
|
|
@@ -19622,6 +19879,10 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19622
19879
|
return data;
|
|
19623
19880
|
}
|
|
19624
19881
|
});
|
|
19882
|
+
const log$b = KosLog.createLogger({
|
|
19883
|
+
group: LogGroup.model,
|
|
19884
|
+
name: "trouble-extension"
|
|
19885
|
+
});
|
|
19625
19886
|
const EXTENSION_TROUBLE_MAPPER = "troubleMapper";
|
|
19626
19887
|
const troubleMappers = /* @__PURE__ */ new Map();
|
|
19627
19888
|
registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
@@ -19642,7 +19903,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
|
19642
19903
|
if (r.status === "fulfilled") {
|
|
19643
19904
|
return r.value;
|
|
19644
19905
|
} else {
|
|
19645
|
-
|
|
19906
|
+
log$b.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19646
19907
|
return [];
|
|
19647
19908
|
}
|
|
19648
19909
|
}).flat();
|
|
@@ -20031,16 +20292,16 @@ const { URL: URL$6 } = resolveServiceUrl();
|
|
|
20031
20292
|
const { getAll: getAll$3 } = ServiceFactory.build({
|
|
20032
20293
|
basePath: `${URL$6}/api/kos/ota`
|
|
20033
20294
|
});
|
|
20034
|
-
const log$
|
|
20035
|
-
|
|
20036
|
-
|
|
20295
|
+
const log$a = KosLog.createLogger({
|
|
20296
|
+
group: LogGroup.service,
|
|
20297
|
+
name: "ota-service"
|
|
20037
20298
|
});
|
|
20038
20299
|
const getArtifacts = async () => {
|
|
20039
|
-
log$
|
|
20300
|
+
log$a.debug("sending GET request to /api/kos/ota/artifacts");
|
|
20040
20301
|
const response = await getAll$3({
|
|
20041
20302
|
urlOverride: `${URL$6}/api/kos/ota/artifacts`
|
|
20042
20303
|
});
|
|
20043
|
-
log$
|
|
20304
|
+
log$a.debug("getArtifacts - response:", response);
|
|
20044
20305
|
return response?.data;
|
|
20045
20306
|
};
|
|
20046
20307
|
var __defProp$a = Object.defineProperty;
|
|
@@ -20224,7 +20485,10 @@ const Ota = new SingletonKosModelRegistrationFactory({
|
|
|
20224
20485
|
class: OtaModelImpl,
|
|
20225
20486
|
type: MODEL_TYPE$c
|
|
20226
20487
|
});
|
|
20227
|
-
const log$
|
|
20488
|
+
const log$9 = KosLog.createLogger({
|
|
20489
|
+
group: LogGroup.model,
|
|
20490
|
+
name: "await-future-call"
|
|
20491
|
+
});
|
|
20228
20492
|
class FutureCallError extends Error {
|
|
20229
20493
|
endState;
|
|
20230
20494
|
reason;
|
|
@@ -20275,7 +20539,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20275
20539
|
const watchTracked = (future) => {
|
|
20276
20540
|
tracked = future;
|
|
20277
20541
|
if (cancelRequested) {
|
|
20278
|
-
future.cancelFuture().catch((e) => log$
|
|
20542
|
+
future.cancelFuture().catch((e) => log$9.error(e));
|
|
20279
20543
|
}
|
|
20280
20544
|
disposers.push(
|
|
20281
20545
|
reaction(
|
|
@@ -20292,7 +20556,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20292
20556
|
try {
|
|
20293
20557
|
cb(progress, status);
|
|
20294
20558
|
} catch (e) {
|
|
20295
|
-
log$
|
|
20559
|
+
log$9.warn("progress callback error", e);
|
|
20296
20560
|
}
|
|
20297
20561
|
});
|
|
20298
20562
|
},
|
|
@@ -20368,6 +20632,189 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20368
20632
|
};
|
|
20369
20633
|
return promise;
|
|
20370
20634
|
}
|
|
20635
|
+
function createCancellablePromise(promiseOrOptions, abortController, cancelFuture2, future) {
|
|
20636
|
+
const options = promiseOrOptions instanceof Promise ? { promise: promiseOrOptions, abortController, cancelFuture: cancelFuture2, future } : promiseOrOptions;
|
|
20637
|
+
const {
|
|
20638
|
+
promise,
|
|
20639
|
+
abortController: controller,
|
|
20640
|
+
cancelFuture: cancelFn,
|
|
20641
|
+
future: futureRef
|
|
20642
|
+
} = options;
|
|
20643
|
+
const cancellablePromise = promise;
|
|
20644
|
+
let currentProgress = 0;
|
|
20645
|
+
let currentStatus = "PENDING";
|
|
20646
|
+
let isRunning = true;
|
|
20647
|
+
const progressCallbacks = /* @__PURE__ */ new Set();
|
|
20648
|
+
let effectDisposer;
|
|
20649
|
+
if (futureRef && typeof futureRef === "object") {
|
|
20650
|
+
effectDisposer = autorun(() => {
|
|
20651
|
+
const newProgress = futureRef.progress || 0;
|
|
20652
|
+
const newStatus = futureRef.status || "PENDING";
|
|
20653
|
+
const newIsRunning = !futureRef.endState;
|
|
20654
|
+
if (newProgress !== currentProgress || newStatus !== currentStatus || newIsRunning !== isRunning) {
|
|
20655
|
+
currentProgress = newProgress;
|
|
20656
|
+
currentStatus = newStatus;
|
|
20657
|
+
isRunning = newIsRunning;
|
|
20658
|
+
progressCallbacks.forEach((callback) => {
|
|
20659
|
+
try {
|
|
20660
|
+
callback(currentProgress, currentStatus);
|
|
20661
|
+
} catch (error) {
|
|
20662
|
+
console.warn("Progress callback error:", error);
|
|
20663
|
+
}
|
|
20664
|
+
});
|
|
20665
|
+
}
|
|
20666
|
+
});
|
|
20667
|
+
}
|
|
20668
|
+
promise.finally(() => {
|
|
20669
|
+
isRunning = false;
|
|
20670
|
+
if (!controller?.signal.aborted) {
|
|
20671
|
+
currentStatus = "COMPLETED";
|
|
20672
|
+
progressCallbacks.forEach((callback) => {
|
|
20673
|
+
try {
|
|
20674
|
+
callback(currentProgress, currentStatus);
|
|
20675
|
+
} catch (error) {
|
|
20676
|
+
console.warn("Progress callback error:", error);
|
|
20677
|
+
}
|
|
20678
|
+
});
|
|
20679
|
+
}
|
|
20680
|
+
if (effectDisposer) {
|
|
20681
|
+
effectDisposer();
|
|
20682
|
+
}
|
|
20683
|
+
progressCallbacks.clear();
|
|
20684
|
+
});
|
|
20685
|
+
cancellablePromise.cancel = async () => {
|
|
20686
|
+
if (controller && !controller.signal.aborted) {
|
|
20687
|
+
controller.abort();
|
|
20688
|
+
}
|
|
20689
|
+
if (cancelFn) {
|
|
20690
|
+
await cancelFn();
|
|
20691
|
+
}
|
|
20692
|
+
isRunning = false;
|
|
20693
|
+
currentStatus = "CANCELLED";
|
|
20694
|
+
progressCallbacks.forEach((callback) => {
|
|
20695
|
+
try {
|
|
20696
|
+
callback(currentProgress, currentStatus);
|
|
20697
|
+
} catch (error) {
|
|
20698
|
+
console.warn("Progress callback error:", error);
|
|
20699
|
+
}
|
|
20700
|
+
});
|
|
20701
|
+
if (effectDisposer) {
|
|
20702
|
+
effectDisposer();
|
|
20703
|
+
}
|
|
20704
|
+
};
|
|
20705
|
+
cancellablePromise.getController = () => controller;
|
|
20706
|
+
cancellablePromise.isCancelled = () => controller?.signal.aborted ?? false;
|
|
20707
|
+
Object.defineProperty(cancellablePromise, "progress", {
|
|
20708
|
+
get: () => currentProgress,
|
|
20709
|
+
enumerable: true
|
|
20710
|
+
});
|
|
20711
|
+
Object.defineProperty(cancellablePromise, "status", {
|
|
20712
|
+
get: () => currentStatus,
|
|
20713
|
+
enumerable: true
|
|
20714
|
+
});
|
|
20715
|
+
Object.defineProperty(cancellablePromise, "isRunning", {
|
|
20716
|
+
get: () => isRunning,
|
|
20717
|
+
enumerable: true
|
|
20718
|
+
});
|
|
20719
|
+
cancellablePromise.onProgressUpdate = (callback) => {
|
|
20720
|
+
progressCallbacks.add(callback);
|
|
20721
|
+
callback(currentProgress, currentStatus);
|
|
20722
|
+
return () => progressCallbacks.delete(callback);
|
|
20723
|
+
};
|
|
20724
|
+
return cancellablePromise;
|
|
20725
|
+
}
|
|
20726
|
+
const log$8 = KosLog.createLogger({
|
|
20727
|
+
group: LogGroup.model,
|
|
20728
|
+
name: "cancellable-future-call"
|
|
20729
|
+
});
|
|
20730
|
+
function makeCancellable(model, methodCall) {
|
|
20731
|
+
const initialFuture = model.futureHandler.future;
|
|
20732
|
+
const promise = methodCall(model);
|
|
20733
|
+
let newFuture = null;
|
|
20734
|
+
setTimeout(() => {
|
|
20735
|
+
newFuture = model.futureHandler.future;
|
|
20736
|
+
if (newFuture === initialFuture) {
|
|
20737
|
+
newFuture = null;
|
|
20738
|
+
}
|
|
20739
|
+
}, 0);
|
|
20740
|
+
return createCancellablePromise({
|
|
20741
|
+
promise,
|
|
20742
|
+
abortController: void 0,
|
|
20743
|
+
// No direct AbortController access
|
|
20744
|
+
cancelFuture: async () => {
|
|
20745
|
+
if (newFuture) {
|
|
20746
|
+
await newFuture.cancelFuture();
|
|
20747
|
+
} else {
|
|
20748
|
+
const currentFuture = model.futureHandler.future;
|
|
20749
|
+
if (currentFuture) {
|
|
20750
|
+
await currentFuture.cancelFuture();
|
|
20751
|
+
}
|
|
20752
|
+
}
|
|
20753
|
+
},
|
|
20754
|
+
future: newFuture
|
|
20755
|
+
// Pass the future for progress tracking
|
|
20756
|
+
});
|
|
20757
|
+
}
|
|
20758
|
+
function withCancellation(model, methodName, ...args) {
|
|
20759
|
+
const method = model[methodName];
|
|
20760
|
+
if (typeof method !== "function") {
|
|
20761
|
+
throw new Error(`${String(methodName)} is not a method`);
|
|
20762
|
+
}
|
|
20763
|
+
const initialFuture = model.futureHandler.future;
|
|
20764
|
+
const promise = method.apply(model, args);
|
|
20765
|
+
let targetFuture = null;
|
|
20766
|
+
setTimeout(() => {
|
|
20767
|
+
const currentFuture = model.futureHandler.future;
|
|
20768
|
+
if (currentFuture && currentFuture !== initialFuture) {
|
|
20769
|
+
targetFuture = currentFuture;
|
|
20770
|
+
}
|
|
20771
|
+
}, 0);
|
|
20772
|
+
return createCancellablePromise({
|
|
20773
|
+
promise,
|
|
20774
|
+
abortController: void 0,
|
|
20775
|
+
cancelFuture: async () => {
|
|
20776
|
+
if (targetFuture) {
|
|
20777
|
+
await targetFuture.cancelFuture();
|
|
20778
|
+
} else {
|
|
20779
|
+
const fallbackFuture = model.futureHandler.future;
|
|
20780
|
+
if (fallbackFuture) {
|
|
20781
|
+
await fallbackFuture.cancelFuture();
|
|
20782
|
+
}
|
|
20783
|
+
}
|
|
20784
|
+
},
|
|
20785
|
+
future: targetFuture
|
|
20786
|
+
// Pass the future for progress tracking
|
|
20787
|
+
});
|
|
20788
|
+
}
|
|
20789
|
+
class CancellationBatch {
|
|
20790
|
+
operations = [];
|
|
20791
|
+
add(model, methodCall) {
|
|
20792
|
+
const cancellable = makeCancellable(model, methodCall);
|
|
20793
|
+
this.operations.push(cancellable);
|
|
20794
|
+
return cancellable;
|
|
20795
|
+
}
|
|
20796
|
+
async cancelAll() {
|
|
20797
|
+
await Promise.all(
|
|
20798
|
+
this.operations.map(
|
|
20799
|
+
(op) => op.cancel().catch(() => {
|
|
20800
|
+
log$8.warn("Cancellation failed for operation:", op);
|
|
20801
|
+
})
|
|
20802
|
+
)
|
|
20803
|
+
);
|
|
20804
|
+
}
|
|
20805
|
+
getAllControllers() {
|
|
20806
|
+
return this.operations.map((op) => op.getController());
|
|
20807
|
+
}
|
|
20808
|
+
getActiveCount() {
|
|
20809
|
+
return this.operations.filter((op) => !op.isCancelled()).length;
|
|
20810
|
+
}
|
|
20811
|
+
clear() {
|
|
20812
|
+
this.operations = [];
|
|
20813
|
+
}
|
|
20814
|
+
}
|
|
20815
|
+
function createCancellationBatch() {
|
|
20816
|
+
return new CancellationBatch();
|
|
20817
|
+
}
|
|
20371
20818
|
function createCancellableService(serviceFunction) {
|
|
20372
20819
|
let controller;
|
|
20373
20820
|
const wrappedFunction = async (...args) => {
|
|
@@ -22724,9 +23171,12 @@ const { URL: URL$5 } = resolveServiceUrl();
|
|
|
22724
23171
|
const { getOne: getOne$1 } = ServiceFactory.build({
|
|
22725
23172
|
basePath: `${URL$5}/api/device`
|
|
22726
23173
|
});
|
|
22727
|
-
const log$
|
|
23174
|
+
const log$7 = KosLog.createLogger({
|
|
23175
|
+
group: LogGroup.service,
|
|
23176
|
+
name: "device-service"
|
|
23177
|
+
});
|
|
22728
23178
|
const getSerialNumber = async () => {
|
|
22729
|
-
log$
|
|
23179
|
+
log$7.debug("sending GET for device serial number");
|
|
22730
23180
|
try {
|
|
22731
23181
|
const response = await getOne$1({
|
|
22732
23182
|
urlOverride: `${URL$5}/api/kos/device/serialNumber`
|
|
@@ -22734,14 +23184,14 @@ const getSerialNumber = async () => {
|
|
|
22734
23184
|
return [void 0, response?.data.serialNumber];
|
|
22735
23185
|
} catch (error) {
|
|
22736
23186
|
if (error instanceof FetchError) {
|
|
22737
|
-
log$
|
|
23187
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22738
23188
|
return [error.payload.error, void 0];
|
|
22739
23189
|
}
|
|
22740
23190
|
}
|
|
22741
23191
|
return ["unknownError", void 0];
|
|
22742
23192
|
};
|
|
22743
23193
|
const getDeviceDetails = async () => {
|
|
22744
|
-
log$
|
|
23194
|
+
log$7.debug("sending GET for device details");
|
|
22745
23195
|
try {
|
|
22746
23196
|
const response = await getOne$1({
|
|
22747
23197
|
urlOverride: `${URL$5}/api/kos/device`
|
|
@@ -22752,7 +23202,7 @@ const getDeviceDetails = async () => {
|
|
|
22752
23202
|
return [void 0, response.data];
|
|
22753
23203
|
} catch (error) {
|
|
22754
23204
|
if (error instanceof FetchError) {
|
|
22755
|
-
log$
|
|
23205
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22756
23206
|
return [error.payload.error, void 0];
|
|
22757
23207
|
}
|
|
22758
23208
|
}
|
|
@@ -22963,13 +23413,13 @@ const { URL: URL$4 } = resolveServiceUrl();
|
|
|
22963
23413
|
const { getAll: getAll$2 } = ServiceFactory.build({
|
|
22964
23414
|
basePath: `${URL$4}/api/kos/network/interfaces`
|
|
22965
23415
|
});
|
|
22966
|
-
const log$
|
|
22967
|
-
|
|
22968
|
-
|
|
23416
|
+
const log$6 = KosLog.createLogger({
|
|
23417
|
+
group: LogGroup.service,
|
|
23418
|
+
name: "network-interface-service"
|
|
22969
23419
|
});
|
|
22970
23420
|
const getNetworkInterfaces = async () => {
|
|
22971
23421
|
const destinationAddress = getKosConnectionId();
|
|
22972
|
-
log$
|
|
23422
|
+
log$6.debug("sending GET for copy-logs");
|
|
22973
23423
|
try {
|
|
22974
23424
|
const response = await getAll$2({
|
|
22975
23425
|
destinationAddress
|
|
@@ -22977,7 +23427,7 @@ const getNetworkInterfaces = async () => {
|
|
|
22977
23427
|
return [void 0, response?.data];
|
|
22978
23428
|
} catch (error) {
|
|
22979
23429
|
if (error instanceof FetchError) {
|
|
22980
|
-
log$
|
|
23430
|
+
log$6.error(`Error fetching log file size: ${error.payload.error}`);
|
|
22981
23431
|
return [error.payload.error, void 0];
|
|
22982
23432
|
}
|
|
22983
23433
|
}
|
|
@@ -23075,15 +23525,15 @@ const { URL: URL$3 } = resolveServiceUrl();
|
|
|
23075
23525
|
const { getAll: getAll$1 } = ServiceFactory.build({
|
|
23076
23526
|
basePath: `${URL$3}/api/kos/storage/devices`
|
|
23077
23527
|
});
|
|
23078
|
-
const log$
|
|
23079
|
-
|
|
23080
|
-
|
|
23528
|
+
const log$5 = KosLog.createLogger({
|
|
23529
|
+
group: LogGroup.service,
|
|
23530
|
+
name: "storage-device-service"
|
|
23081
23531
|
});
|
|
23082
23532
|
const getStorageDevices = async () => {
|
|
23083
|
-
log$
|
|
23533
|
+
log$5.debug("sending GET for storage-device");
|
|
23084
23534
|
const response = await getAll$1({});
|
|
23085
23535
|
if (!response?.data || response.status !== 200) {
|
|
23086
|
-
log$
|
|
23536
|
+
log$5.error("Failed to retrieve storage-device data", response);
|
|
23087
23537
|
return [];
|
|
23088
23538
|
}
|
|
23089
23539
|
return response.data;
|
|
@@ -23281,17 +23731,17 @@ const { URL: URL$2 } = resolveServiceUrl();
|
|
|
23281
23731
|
const { getAll, postModel } = ServiceFactory.build({
|
|
23282
23732
|
basePath: `${URL$2}/api/kos/update/available`
|
|
23283
23733
|
});
|
|
23284
|
-
const log$
|
|
23285
|
-
|
|
23286
|
-
|
|
23734
|
+
const log$4 = KosLog.createLogger({
|
|
23735
|
+
group: LogGroup.service,
|
|
23736
|
+
name: "usb-update-service"
|
|
23287
23737
|
});
|
|
23288
23738
|
const getAvailableUpdates = async () => {
|
|
23289
|
-
log$
|
|
23739
|
+
log$4.debug("sending GET for usb-update");
|
|
23290
23740
|
const response = await getAll({
|
|
23291
23741
|
urlOverride: `${URL$2}/api/kos/update/available`
|
|
23292
23742
|
});
|
|
23293
23743
|
if (!response?.data || response?.status !== 200) {
|
|
23294
|
-
log$
|
|
23744
|
+
log$4.error("Failed to retrieve usb-update data", response);
|
|
23295
23745
|
return [];
|
|
23296
23746
|
}
|
|
23297
23747
|
return response.data;
|
|
@@ -23532,9 +23982,9 @@ const { URL: URL$1 } = resolveServiceUrl();
|
|
|
23532
23982
|
const { getOne } = ServiceFactory.build({
|
|
23533
23983
|
basePath: `${URL$1}/api/translation`
|
|
23534
23984
|
});
|
|
23535
|
-
const log$
|
|
23536
|
-
|
|
23537
|
-
|
|
23985
|
+
const log$3 = KosLog.createLogger({
|
|
23986
|
+
group: LogGroup.service,
|
|
23987
|
+
name: "translation-service"
|
|
23538
23988
|
});
|
|
23539
23989
|
const getDefaultHost = () => {
|
|
23540
23990
|
const defaultHost = window.location.origin;
|
|
@@ -23544,23 +23994,23 @@ const getDefaultHost = () => {
|
|
|
23544
23994
|
return result;
|
|
23545
23995
|
};
|
|
23546
23996
|
const getTranslations = async (url, root) => {
|
|
23547
|
-
log$
|
|
23997
|
+
log$3.debug(`Loading translations from: ${url}`);
|
|
23548
23998
|
const rootUrl = root ?? getDefaultHost();
|
|
23549
23999
|
try {
|
|
23550
24000
|
const response = await fetch(`${rootUrl}${url}`);
|
|
23551
24001
|
if (response.status !== 200) {
|
|
23552
|
-
log$
|
|
24002
|
+
log$3.warn(`Failed to fetch translations at ${url}: ${response.status}`);
|
|
23553
24003
|
return {};
|
|
23554
24004
|
}
|
|
23555
24005
|
const json = await response.json();
|
|
23556
24006
|
return json;
|
|
23557
24007
|
} catch (error) {
|
|
23558
|
-
log$
|
|
24008
|
+
log$3.error("Error fetching translations", error);
|
|
23559
24009
|
throw error;
|
|
23560
24010
|
}
|
|
23561
24011
|
};
|
|
23562
24012
|
const getLocalizationDescriptor = async () => {
|
|
23563
|
-
log$
|
|
24013
|
+
log$3.debug("Getting system localization descriptor");
|
|
23564
24014
|
const response = await getOne({
|
|
23565
24015
|
urlOverride: `${URL$1}/api/system/kos/localization`
|
|
23566
24016
|
});
|
|
@@ -23572,7 +24022,7 @@ const getLocalizationDescriptor = async () => {
|
|
|
23572
24022
|
return response.data;
|
|
23573
24023
|
};
|
|
23574
24024
|
const getKosLocalizationDescriptor = (context) => async () => {
|
|
23575
|
-
log$
|
|
24025
|
+
log$3.debug(`Getting KOS localization descriptor for context: ${context}`);
|
|
23576
24026
|
const response = await getOne({
|
|
23577
24027
|
urlOverride: `${URL$1}/api/kos/localization/contexts`
|
|
23578
24028
|
});
|
|
@@ -24061,6 +24511,10 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
24061
24511
|
if (kind && result) __defProp(target, key, result);
|
|
24062
24512
|
return result;
|
|
24063
24513
|
};
|
|
24514
|
+
const log$2 = KosLog.createLogger({
|
|
24515
|
+
group: LogGroup.model,
|
|
24516
|
+
name: "ws-event-model"
|
|
24517
|
+
});
|
|
24064
24518
|
const stringify = ({ headers, body }) => {
|
|
24065
24519
|
const headText = Object.entries(headers).map(([key, value]) => `${key}:${value}`).join("\\n");
|
|
24066
24520
|
return headText + "\\n\\n" + body;
|
|
@@ -24084,7 +24538,7 @@ let WsEventModel = class {
|
|
|
24084
24538
|
this.processEvent(payload);
|
|
24085
24539
|
}
|
|
24086
24540
|
processEvent(data, isSend = false) {
|
|
24087
|
-
|
|
24541
|
+
log$2.debug("kos event received");
|
|
24088
24542
|
const { body, headers } = data.body;
|
|
24089
24543
|
const isUnique = headers["request-id"] || headers["response-id"];
|
|
24090
24544
|
const msgId = headers["request-id"] || headers["response-id"] || headers["topic"] || headers["type"];
|
|
@@ -24108,7 +24562,7 @@ let WsEventModel = class {
|
|
|
24108
24562
|
mocked: !!headers["mocked"]
|
|
24109
24563
|
};
|
|
24110
24564
|
this.events.set(rawKey, rawData);
|
|
24111
|
-
|
|
24565
|
+
log$2.debug(`logged ${this.events.size} events`);
|
|
24112
24566
|
}
|
|
24113
24567
|
}
|
|
24114
24568
|
};
|
|
@@ -24155,9 +24609,9 @@ const Registry = {
|
|
|
24155
24609
|
preloadModels: []
|
|
24156
24610
|
};
|
|
24157
24611
|
const PRELOAD = true;
|
|
24158
|
-
const registerCoreModels = (root) => () => {
|
|
24612
|
+
const registerCoreModels = (root) => ({ preloadLogManager = true } = {}) => {
|
|
24159
24613
|
const coreModels2 = CoreModels;
|
|
24160
|
-
registerKosModel(KosModelRegistry2)(Trouble).model(TroubleContainer).model(StorageDeviceContainer).model(UsbUpdateContainer).model(Device).model(Ota).model(ConfigBean).model(SoftwareInfo).model(KeyValue).model(NetworkInterfaceContainer).model(CanvasDispatcher).model(CanvasRenderer).model(KosExpressionEvaluator).model(BrowserRouter, PRELOAD).model(LogStreamContainer).model(KosLogManager,
|
|
24614
|
+
registerKosModel(KosModelRegistry2)(Trouble).model(TroubleContainer).model(StorageDeviceContainer).model(UsbUpdateContainer).model(Device).model(Ota).model(ConfigBean).model(SoftwareInfo).model(KeyValue).model(NetworkInterfaceContainer).model(CanvasDispatcher).model(CanvasRenderer).model(KosExpressionEvaluator).model(BrowserRouter, PRELOAD).model(LogStreamContainer).model(KosLogManager, preloadLogManager);
|
|
24161
24615
|
Object.keys(coreModels2).forEach((key) => {
|
|
24162
24616
|
const model = coreModels2[key];
|
|
24163
24617
|
registerLegacyModel(KosModelRegistry2)(key, model);
|
|
@@ -24181,7 +24635,10 @@ const KosModelRegistry2 = _KosModelRegistry;
|
|
|
24181
24635
|
const TIMER_EVENT = `/kos-timer-event`;
|
|
24182
24636
|
const TOPIC_TIMER_TICK_EVENT = `/kos-timer-event/tick`;
|
|
24183
24637
|
const TIMER_END = "defaultTimerEnd";
|
|
24184
|
-
const log$1 = KosLog.createLogger({
|
|
24638
|
+
const log$1 = KosLog.createLogger({
|
|
24639
|
+
group: LogGroup.model,
|
|
24640
|
+
name: "timer-manager"
|
|
24641
|
+
});
|
|
24185
24642
|
const isConfigProperty = (value) => value.updateProperty !== void 0;
|
|
24186
24643
|
class KosTimer {
|
|
24187
24644
|
name;
|
|
@@ -24208,7 +24665,7 @@ class KosTimer {
|
|
|
24208
24665
|
this.remainingTime = timeoutValue;
|
|
24209
24666
|
if (isConfigProperty(timeout)) {
|
|
24210
24667
|
kosAutoEffect(() => {
|
|
24211
|
-
|
|
24668
|
+
log$1.info(
|
|
24212
24669
|
`Updating config value timer ${name} with new timeout value ${timeout.value}`
|
|
24213
24670
|
);
|
|
24214
24671
|
const newValue = timeout.value || 60;
|
|
@@ -24446,8 +24903,8 @@ const TimerManager = {
|
|
|
24446
24903
|
}
|
|
24447
24904
|
};
|
|
24448
24905
|
const log = KosLog.createLogger({
|
|
24449
|
-
|
|
24450
|
-
|
|
24906
|
+
group: LogGroup.service,
|
|
24907
|
+
name: "software-info-service"
|
|
24451
24908
|
});
|
|
24452
24909
|
const getSoftwareInfos = async (signal) => {
|
|
24453
24910
|
const destinationAddress = getKosConnectionId();
|
|
@@ -24553,99 +25010,99 @@ const SoftwareInfo = {
|
|
|
24553
25010
|
)
|
|
24554
25011
|
};
|
|
24555
25012
|
export {
|
|
24556
|
-
|
|
24557
|
-
|
|
24558
|
-
|
|
25013
|
+
subscribeToLogStream as $,
|
|
25014
|
+
StateProp as A,
|
|
25015
|
+
deleteKeyValue as B,
|
|
24559
25016
|
CompanionParentModel as C,
|
|
24560
25017
|
DependencyModels as D,
|
|
24561
25018
|
ExtensionManager as E,
|
|
24562
|
-
|
|
24563
|
-
|
|
24564
|
-
|
|
25019
|
+
deleteKeyValueNamespace as F,
|
|
25020
|
+
getKeyValue as G,
|
|
25021
|
+
updateKeyValue as H,
|
|
24565
25022
|
INDEX_RECORD_SYMBOL as I,
|
|
24566
|
-
|
|
25023
|
+
addLogOverride as J,
|
|
24567
25024
|
KosContextManager as K,
|
|
24568
|
-
|
|
25025
|
+
getLogGroups as L,
|
|
24569
25026
|
MultipleFutureContainerSetup as M,
|
|
24570
|
-
|
|
24571
|
-
|
|
24572
|
-
|
|
24573
|
-
|
|
25027
|
+
getLogOverrides as N,
|
|
25028
|
+
removeLogOverride as O,
|
|
25029
|
+
getTimezone as P,
|
|
25030
|
+
setDate as Q,
|
|
24574
25031
|
ReferenceConfig as R,
|
|
24575
25032
|
SubscriptionHandlers as S,
|
|
24576
25033
|
TroubleAwareSetup as T,
|
|
24577
|
-
|
|
25034
|
+
setTime as U,
|
|
24578
25035
|
ViewModelConfig as V,
|
|
24579
|
-
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
25036
|
+
setTimezone as W,
|
|
25037
|
+
createOverride as X,
|
|
25038
|
+
getLogStreamBlock as Y,
|
|
25039
|
+
getLogStreamBlocks as Z,
|
|
25040
|
+
getLogStreams as _,
|
|
24584
25041
|
MixinModels as a,
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
24597
|
-
|
|
24598
|
-
|
|
24599
|
-
|
|
24600
|
-
|
|
24601
|
-
|
|
24602
|
-
|
|
24603
|
-
|
|
24604
|
-
|
|
24605
|
-
|
|
24606
|
-
|
|
24607
|
-
|
|
24608
|
-
|
|
24609
|
-
|
|
24610
|
-
|
|
24611
|
-
|
|
24612
|
-
|
|
24613
|
-
|
|
24614
|
-
|
|
24615
|
-
|
|
24616
|
-
|
|
24617
|
-
|
|
24618
|
-
|
|
24619
|
-
|
|
24620
|
-
|
|
24621
|
-
|
|
24622
|
-
|
|
24623
|
-
|
|
24624
|
-
|
|
24625
|
-
|
|
24626
|
-
|
|
24627
|
-
|
|
24628
|
-
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
|
|
24637
|
-
|
|
24638
|
-
|
|
24639
|
-
|
|
24640
|
-
|
|
24641
|
-
|
|
24642
|
-
|
|
24643
|
-
|
|
24644
|
-
|
|
24645
|
-
|
|
24646
|
-
|
|
24647
|
-
|
|
24648
|
-
|
|
25042
|
+
CancellationBatch as a$,
|
|
25043
|
+
unsubscribeFromLogStream as a0,
|
|
25044
|
+
bulkResolveTroubles as a1,
|
|
25045
|
+
getTroubles as a2,
|
|
25046
|
+
resolveTrouble as a3,
|
|
25047
|
+
sendCanvasData as a4,
|
|
25048
|
+
getDeviceDetails as a5,
|
|
25049
|
+
getSerialNumber as a6,
|
|
25050
|
+
getNetworkInterfaces as a7,
|
|
25051
|
+
getStorageDevices as a8,
|
|
25052
|
+
getAvailableUpdates as a9,
|
|
25053
|
+
WebSocketEvents as aA,
|
|
25054
|
+
modelHookCache as aB,
|
|
25055
|
+
isUpdateable as aC,
|
|
25056
|
+
KosModelState as aD,
|
|
25057
|
+
KosModelEvents as aE,
|
|
25058
|
+
clearModelHookCacheEntry as aF,
|
|
25059
|
+
KosTime as aG,
|
|
25060
|
+
SoftwareInfo as aH,
|
|
25061
|
+
getQueryParams as aI,
|
|
25062
|
+
getKosLocalizationDescriptor as aJ,
|
|
25063
|
+
Device as aK,
|
|
25064
|
+
NetworkInterfaceContainer as aL,
|
|
25065
|
+
Ota as aM,
|
|
25066
|
+
StorageDeviceContainer as aN,
|
|
25067
|
+
TimerManager as aO,
|
|
25068
|
+
TIMER_END as aP,
|
|
25069
|
+
TIMER_EVENT as aQ,
|
|
25070
|
+
TOPIC_TIMER_TICK_EVENT as aR,
|
|
25071
|
+
getKosModel$1 as aS,
|
|
25072
|
+
Trouble as aT,
|
|
25073
|
+
TroubleContainer as aU,
|
|
25074
|
+
UsbUpdateContainer as aV,
|
|
25075
|
+
Registration$1 as aW,
|
|
25076
|
+
AuthState as aX,
|
|
25077
|
+
BrowserKosRouter as aY,
|
|
25078
|
+
BrowserRouter as aZ,
|
|
25079
|
+
CancellableServiceManager as a_,
|
|
25080
|
+
installUpdate as aa,
|
|
25081
|
+
TranslationContainer as ab,
|
|
25082
|
+
whenReady as ac,
|
|
25083
|
+
KosCoreModelPropertyMapper as ad,
|
|
25084
|
+
CanvasDispatcher as ae,
|
|
25085
|
+
KeyValue as af,
|
|
25086
|
+
destroyKosModel as ag,
|
|
25087
|
+
createClient as ah,
|
|
25088
|
+
kosServiceRequest$1 as ai,
|
|
25089
|
+
getSoftwareInfos as aj,
|
|
25090
|
+
getSoftwareInfosWithCancel as ak,
|
|
25091
|
+
KosLog as al,
|
|
25092
|
+
LogGroup as am,
|
|
25093
|
+
BASE_URL as an,
|
|
25094
|
+
kosFetch as ao,
|
|
25095
|
+
kosModel as ap,
|
|
25096
|
+
kosLoggerAware as aq,
|
|
25097
|
+
kosContainerAware as ar,
|
|
25098
|
+
kosChild as as,
|
|
25099
|
+
api$1 as at,
|
|
25100
|
+
ObservableData as au,
|
|
25101
|
+
WebSocketTransport as av,
|
|
25102
|
+
kosComputed as aw,
|
|
25103
|
+
KosModelRegistrationFactory as ax,
|
|
25104
|
+
getKosModelSync as ay,
|
|
25105
|
+
kosAutoEffect as az,
|
|
24649
25106
|
KosViewModelSymbol as b,
|
|
24650
25107
|
KosModelManager as b$,
|
|
24651
25108
|
CanvasRenderer as b0,
|
|
@@ -24712,7 +25169,7 @@ export {
|
|
|
24712
25169
|
HEADER_CONTENT_TYPE as by,
|
|
24713
25170
|
HEADER_DESTINATION_ADDR as bz,
|
|
24714
25171
|
StateMachineSetup as c,
|
|
24715
|
-
|
|
25172
|
+
checkWildcardPattern as c$,
|
|
24716
25173
|
KosModelRegistry2 as c0,
|
|
24717
25174
|
KosModelSymbol as c1,
|
|
24718
25175
|
KosObservableData as c2,
|
|
@@ -24723,204 +25180,212 @@ export {
|
|
|
24723
25180
|
LOGIN_HOST as c7,
|
|
24724
25181
|
LOGIN_URL as c8,
|
|
24725
25182
|
LogBlock as c9,
|
|
24726
|
-
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
|
|
24732
|
-
|
|
24733
|
-
|
|
24734
|
-
|
|
24735
|
-
|
|
24736
|
-
|
|
24737
|
-
|
|
24738
|
-
|
|
24739
|
-
|
|
24740
|
-
|
|
24741
|
-
|
|
24742
|
-
|
|
24743
|
-
|
|
24744
|
-
|
|
24745
|
-
|
|
24746
|
-
|
|
24747
|
-
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
|
|
24751
|
-
|
|
24752
|
-
|
|
25183
|
+
ServiceRequestHandlers as cA,
|
|
25184
|
+
SingletonKosModelRegistrationFactory as cB,
|
|
25185
|
+
StateActionHandlers as cC,
|
|
25186
|
+
StateEntryHandlers as cD,
|
|
25187
|
+
StateExitHandlers as cE,
|
|
25188
|
+
StorageDevice as cF,
|
|
25189
|
+
TRANSPORT_NOT_READY as cG,
|
|
25190
|
+
Topics as cH,
|
|
25191
|
+
TransitionMap as cI,
|
|
25192
|
+
Transitions as cJ,
|
|
25193
|
+
Translation as cK,
|
|
25194
|
+
TransportFactory as cL,
|
|
25195
|
+
TransportNotReadyError as cM,
|
|
25196
|
+
Troubles as cN,
|
|
25197
|
+
UsbUpdate as cO,
|
|
25198
|
+
WS_EVENT_TYPE as cP,
|
|
25199
|
+
WsEventFactory as cQ,
|
|
25200
|
+
WsEventModel as cR,
|
|
25201
|
+
addFuture as cS,
|
|
25202
|
+
api as cT,
|
|
25203
|
+
applyFunctionalEnhancements as cU,
|
|
25204
|
+
awaitFutureCall as cV,
|
|
25205
|
+
buildConfigBeanModel as cW,
|
|
25206
|
+
buildFuture as cX,
|
|
25207
|
+
buildFutureModel$1 as cY,
|
|
25208
|
+
cancelFuture as cZ,
|
|
25209
|
+
checkAppsStarted as c_,
|
|
24753
25210
|
LogBlockContainer as ca,
|
|
24754
25211
|
LogStream as cb,
|
|
24755
25212
|
LogStreamContainer as cc,
|
|
24756
25213
|
LoggerSetup as cd,
|
|
24757
|
-
|
|
24758
|
-
|
|
24759
|
-
|
|
24760
|
-
|
|
24761
|
-
|
|
24762
|
-
|
|
24763
|
-
|
|
24764
|
-
|
|
24765
|
-
|
|
24766
|
-
|
|
24767
|
-
|
|
24768
|
-
|
|
24769
|
-
|
|
24770
|
-
|
|
24771
|
-
|
|
24772
|
-
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
24778
|
-
|
|
25214
|
+
MESSAGE_LOGGER_NAME as ce,
|
|
25215
|
+
MODEL_DELETION_DELAY as cf,
|
|
25216
|
+
ModelError as cg,
|
|
25217
|
+
MultipleFutureHandler as ch,
|
|
25218
|
+
NetworkInterface as ci,
|
|
25219
|
+
OptionsRequired as cj,
|
|
25220
|
+
PORT as ck,
|
|
25221
|
+
PROFILE_ENABLE_RELEASES as cl,
|
|
25222
|
+
PROFILE_LOG_DEBUG as cm,
|
|
25223
|
+
PROFILE_LOG_INFO as cn,
|
|
25224
|
+
PROFILE_RELAX_STORE_VALIDATION as co,
|
|
25225
|
+
PROFILE_TOOLS_PREVIEW as cp,
|
|
25226
|
+
ParentModel as cq,
|
|
25227
|
+
RegistrationManager as cr,
|
|
25228
|
+
Registry as cs,
|
|
25229
|
+
ReloadAwareSetup as ct,
|
|
25230
|
+
ReplayStrategy as cu,
|
|
25231
|
+
ResponseRetention as cv,
|
|
25232
|
+
STATUS as cw,
|
|
25233
|
+
SelfManagedReload as cx,
|
|
25234
|
+
ServiceFactory as cy,
|
|
25235
|
+
ServiceRequestError as cz,
|
|
24779
25236
|
DependencyLifecycle as d,
|
|
24780
|
-
|
|
24781
|
-
|
|
24782
|
-
|
|
24783
|
-
|
|
24784
|
-
|
|
24785
|
-
|
|
24786
|
-
|
|
24787
|
-
|
|
24788
|
-
|
|
24789
|
-
|
|
24790
|
-
|
|
24791
|
-
|
|
24792
|
-
|
|
24793
|
-
|
|
24794
|
-
|
|
24795
|
-
|
|
24796
|
-
|
|
24797
|
-
|
|
24798
|
-
|
|
24799
|
-
|
|
24800
|
-
|
|
24801
|
-
|
|
24802
|
-
|
|
24803
|
-
|
|
24804
|
-
|
|
24805
|
-
|
|
24806
|
-
|
|
24807
|
-
|
|
24808
|
-
|
|
24809
|
-
|
|
24810
|
-
|
|
24811
|
-
|
|
24812
|
-
|
|
24813
|
-
|
|
24814
|
-
|
|
24815
|
-
|
|
24816
|
-
|
|
24817
|
-
|
|
24818
|
-
|
|
24819
|
-
|
|
24820
|
-
|
|
24821
|
-
|
|
24822
|
-
|
|
24823
|
-
|
|
24824
|
-
|
|
24825
|
-
|
|
24826
|
-
|
|
24827
|
-
|
|
24828
|
-
|
|
24829
|
-
|
|
24830
|
-
|
|
24831
|
-
|
|
24832
|
-
|
|
24833
|
-
|
|
24834
|
-
|
|
24835
|
-
|
|
24836
|
-
|
|
24837
|
-
|
|
24838
|
-
|
|
24839
|
-
|
|
24840
|
-
|
|
24841
|
-
|
|
24842
|
-
|
|
25237
|
+
kosAction as d$,
|
|
25238
|
+
convert as d0,
|
|
25239
|
+
convertWithUnits as d1,
|
|
25240
|
+
createBaseMessage as d2,
|
|
25241
|
+
createBroadcastMessageResponse as d3,
|
|
25242
|
+
createCancellablePromise as d4,
|
|
25243
|
+
createCancellableService as d5,
|
|
25244
|
+
createCancellationBatch as d6,
|
|
25245
|
+
createFosBaseMessage as d7,
|
|
25246
|
+
createHeaders as d8,
|
|
25247
|
+
createKosHtpMessageResponse as d9,
|
|
25248
|
+
getKosCompanionModel as dA,
|
|
25249
|
+
getKosConnectionId as dB,
|
|
25250
|
+
getKosModelActivationState as dC,
|
|
25251
|
+
getKosModelType as dD,
|
|
25252
|
+
getKosSessionKey as dE,
|
|
25253
|
+
getLocalizationDescriptor as dF,
|
|
25254
|
+
getLogLevel as dG,
|
|
25255
|
+
getMessageBody as dH,
|
|
25256
|
+
getObservableCompanions as dI,
|
|
25257
|
+
getStartedApps as dJ,
|
|
25258
|
+
getTranslations as dK,
|
|
25259
|
+
handleServiceRequestError as dL,
|
|
25260
|
+
hasDecimals as dM,
|
|
25261
|
+
hasHttpRouteHandlers$1 as dN,
|
|
25262
|
+
hasKosProfile as dO,
|
|
25263
|
+
httpDelete as dP,
|
|
25264
|
+
isBoolean as dQ,
|
|
25265
|
+
isKosCompanionTypeFactory as dR,
|
|
25266
|
+
isKosDataModel as dS,
|
|
25267
|
+
isKosExecutionContext as dT,
|
|
25268
|
+
isKosLoggingEnabled as dU,
|
|
25269
|
+
isKosModelContainer as dV,
|
|
25270
|
+
isKosModelReady as dW,
|
|
25271
|
+
isLocalRefId as dX,
|
|
25272
|
+
isNumber as dY,
|
|
25273
|
+
isPrintable as dZ,
|
|
25274
|
+
isTransportNotReadyError as d_,
|
|
25275
|
+
createKosMessage as da,
|
|
25276
|
+
createKosMessageResponse as db,
|
|
25277
|
+
createMessageBody as dc,
|
|
25278
|
+
createModelDependency as dd,
|
|
25279
|
+
createOptionKey as de,
|
|
25280
|
+
createPropKey as df,
|
|
25281
|
+
createReadableStream as dg,
|
|
25282
|
+
createStudioMessage as dh,
|
|
25283
|
+
createStudioMessageRequest as di,
|
|
25284
|
+
createStudioMessageResponse as dj,
|
|
25285
|
+
del as dk,
|
|
25286
|
+
deleteFuture as dl,
|
|
25287
|
+
evaluateScopes as dm,
|
|
25288
|
+
executeApiMethod as dn,
|
|
25289
|
+
executeChildrenModelLifecycle as dp,
|
|
25290
|
+
executeDependentModelLifecycle as dq,
|
|
25291
|
+
executeListLifecycle as dr,
|
|
25292
|
+
findModel as ds,
|
|
25293
|
+
findModels as dt,
|
|
25294
|
+
get as du,
|
|
25295
|
+
getAllKosCompanionModels as dv,
|
|
25296
|
+
getConfigBean as dw,
|
|
25297
|
+
getDependenciesByLifecycle as dx,
|
|
25298
|
+
getFutures as dy,
|
|
25299
|
+
getHttpRouteHandlers as dz,
|
|
24843
25300
|
initializeStateMachine as e,
|
|
24844
|
-
|
|
24845
|
-
|
|
24846
|
-
|
|
24847
|
-
|
|
24848
|
-
|
|
24849
|
-
|
|
24850
|
-
|
|
24851
|
-
|
|
24852
|
-
|
|
24853
|
-
|
|
24854
|
-
|
|
24855
|
-
|
|
24856
|
-
|
|
24857
|
-
|
|
24858
|
-
|
|
24859
|
-
|
|
24860
|
-
|
|
24861
|
-
|
|
24862
|
-
|
|
24863
|
-
|
|
24864
|
-
|
|
24865
|
-
|
|
24866
|
-
|
|
24867
|
-
|
|
24868
|
-
|
|
24869
|
-
|
|
24870
|
-
|
|
24871
|
-
|
|
24872
|
-
|
|
24873
|
-
|
|
24874
|
-
|
|
24875
|
-
|
|
24876
|
-
|
|
24877
|
-
|
|
24878
|
-
|
|
24879
|
-
|
|
24880
|
-
|
|
24881
|
-
|
|
24882
|
-
|
|
24883
|
-
|
|
24884
|
-
|
|
24885
|
-
|
|
24886
|
-
|
|
24887
|
-
|
|
24888
|
-
|
|
24889
|
-
|
|
24890
|
-
|
|
24891
|
-
|
|
24892
|
-
|
|
24893
|
-
|
|
24894
|
-
|
|
24895
|
-
|
|
24896
|
-
|
|
24897
|
-
|
|
24898
|
-
|
|
24899
|
-
|
|
24900
|
-
|
|
24901
|
-
|
|
24902
|
-
|
|
24903
|
-
|
|
25301
|
+
waitForAppsToStart as e$,
|
|
25302
|
+
kosDependency as e0,
|
|
25303
|
+
kosEffect as e1,
|
|
25304
|
+
kosFuture as e2,
|
|
25305
|
+
kosFutureAware as e3,
|
|
25306
|
+
kosModelEffect as e4,
|
|
25307
|
+
kosObservable as e5,
|
|
25308
|
+
kosReloadAware as e6,
|
|
25309
|
+
kosStateEntry as e7,
|
|
25310
|
+
kosStateExit as e8,
|
|
25311
|
+
kosStateGuard as e9,
|
|
25312
|
+
registerLegacyModel as eA,
|
|
25313
|
+
resetKosModel as eB,
|
|
25314
|
+
resolveBaseUrl as eC,
|
|
25315
|
+
resolveChild as eD,
|
|
25316
|
+
resolveContainerDeltas as eE,
|
|
25317
|
+
resolveItemListDeltas as eF,
|
|
25318
|
+
resolveKosCompanion as eG,
|
|
25319
|
+
resolveKosContext as eH,
|
|
25320
|
+
resolveKosProfiles as eI,
|
|
25321
|
+
resolveListDeltas as eJ,
|
|
25322
|
+
resolveServiceRequestParameters as eK,
|
|
25323
|
+
resolveServiceUrl as eL,
|
|
25324
|
+
retryWithExponentialBackoff as eM,
|
|
25325
|
+
sendAsyncIntent as eN,
|
|
25326
|
+
sendBroadcastMessage as eO,
|
|
25327
|
+
sendIntent as eP,
|
|
25328
|
+
sendKosHttpMessageResponse as eQ,
|
|
25329
|
+
sendKosMessage as eR,
|
|
25330
|
+
sendRequest as eS,
|
|
25331
|
+
sendStudioMessage as eT,
|
|
25332
|
+
sendStudioMessageRequest as eU,
|
|
25333
|
+
syncPublish as eV,
|
|
25334
|
+
troubleByTypeReducer as eW,
|
|
25335
|
+
troubleDataFactory as eX,
|
|
25336
|
+
unloadKosModel as eY,
|
|
25337
|
+
uuid as eZ,
|
|
25338
|
+
waitForAppToStart as e_,
|
|
25339
|
+
kosStateMachine as ea,
|
|
25340
|
+
kosTopicHandler as eb,
|
|
25341
|
+
kosWhen as ec,
|
|
25342
|
+
makeCancellable as ed,
|
|
25343
|
+
mapConfigBeanModelToDto as ee,
|
|
25344
|
+
mapDataToModel as ef,
|
|
25345
|
+
mapDtoToConfigBeanModel as eg,
|
|
25346
|
+
mapDtoToFutureModel as eh,
|
|
25347
|
+
mapDtoToFutureOptions as ei,
|
|
25348
|
+
mapUpdateDtoToConfigBeanModel as ej,
|
|
25349
|
+
modelEventTopicFactory as ek,
|
|
25350
|
+
modelFactory as el,
|
|
25351
|
+
modelTypeEventTopicFactory as em,
|
|
25352
|
+
modifyConfigBean as en,
|
|
25353
|
+
modifyFuture as eo,
|
|
25354
|
+
parseWildcardSegment as ep,
|
|
25355
|
+
pipe as eq,
|
|
25356
|
+
post as er,
|
|
25357
|
+
preloadKosModel as es,
|
|
25358
|
+
processId as et,
|
|
25359
|
+
put as eu,
|
|
25360
|
+
registerCompanionModel as ev,
|
|
25361
|
+
registerCoreModels as ew,
|
|
25362
|
+
registerExtensionPoint as ex,
|
|
25363
|
+
registerHttpRoutes as ey,
|
|
25364
|
+
registerKosModel as ez,
|
|
24904
25365
|
ModelEffects as f,
|
|
25366
|
+
waitForRequest as f0,
|
|
25367
|
+
withCancellation as f1,
|
|
25368
|
+
wrapWithFutureLifecycle as f2,
|
|
25369
|
+
service as f3,
|
|
24905
25370
|
KosModelVisitor as g,
|
|
24906
25371
|
KosCore as h,
|
|
24907
25372
|
injectStateMachineSupport as i,
|
|
24908
25373
|
sendKosMessageResponse as j,
|
|
24909
25374
|
kosParentAware as k,
|
|
24910
|
-
|
|
24911
|
-
|
|
24912
|
-
|
|
24913
|
-
|
|
25375
|
+
INDEX_COLLECTION_KEY as l,
|
|
25376
|
+
KosContainerIndexEvents as m,
|
|
25377
|
+
isIndexableItem as n,
|
|
25378
|
+
Kos as o,
|
|
24914
25379
|
publish as p,
|
|
24915
|
-
|
|
24916
|
-
|
|
25380
|
+
isKosModel as q,
|
|
25381
|
+
ConfigBean as r,
|
|
24917
25382
|
subscribe as s,
|
|
24918
|
-
|
|
24919
|
-
|
|
24920
|
-
|
|
24921
|
-
|
|
24922
|
-
|
|
24923
|
-
|
|
24924
|
-
|
|
24925
|
-
};
|
|
24926
|
-
//# sourceMappingURL=software-info-registration-
|
|
25383
|
+
configBeanModelId as t,
|
|
25384
|
+
getRegionInfo as u,
|
|
25385
|
+
getRegions as v,
|
|
25386
|
+
Registration as w,
|
|
25387
|
+
getStateBeanData as x,
|
|
25388
|
+
StateBean as y,
|
|
25389
|
+
getStateProps as z
|
|
25390
|
+
};
|
|
25391
|
+
//# sourceMappingURL=software-info-registration-CKRUzp_3.js.map
|