@kosdev-code/kos-ui-sdk 3.0.28 → 3.0.30
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-reload-aware.d.ts +4 -0
- package/core/core/decorators/kos-reload-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 +1 -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/indexing/kos-container-index-aware.d.ts +4 -0
- package/core/core/indexing/kos-container-index-aware.d.ts.map +1 -1
- package/core/core/indexing/kos-index-aware.d.ts +6 -0
- package/core/core/indexing/kos-index-aware.d.ts.map +1 -1
- package/core/core/indexing/types.d.ts +30 -3
- package/core/core/indexing/types.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 +27 -0
- package/core/core/log/log-groups.d.ts.map +1 -0
- package/core/core/log/log-override-match.d.ts +24 -0
- package/core/core/log/log-override-match.d.ts.map +1 -0
- package/core/core/log/log.d.ts +15 -9
- package/core/core/log/log.d.ts.map +1 -1
- package/core/core/model/kos-logger-factory.d.ts +6 -4
- package/core/core/model/kos-logger-factory.d.ts.map +1 -1
- package/core/core/model/kos-model-component-factory.d.ts.map +1 -1
- package/core/core/model/model-hook-cache.d.ts +6 -1
- package/core/core/model/model-hook-cache.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/model-registration.d.ts +2 -0
- package/core/core/registration/model-registration.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/index.d.ts +2 -0
- package/core/core/transport/mock/index.d.ts.map +1 -1
- package/core/core/transport/mock/mock-boot.d.ts +39 -0
- package/core/core/transport/mock/mock-boot.d.ts.map +1 -0
- 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 +2 -0
- package/core/util/kos-model-utils.d.ts.map +1 -1
- package/core/util/kos-service-request.d.ts +11 -2
- 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 +109 -323
- package/index.cjs.map +1 -1
- package/index.js +363 -577
- 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/gpio-chip/services/gpio-chip-services.d.ts +1 -1
- package/models/models/key-value/services/key-value-services.d.ts.map +1 -1
- package/models/models/kos-expression-evaluator/expression-parse-cache.d.ts +2 -0
- package/models/models/kos-expression-evaluator/expression-parse-cache.d.ts.map +1 -1
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts +43 -24
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts.map +1 -1
- package/models/models/kos-log-manager/services/kos-log-manager-services.d.ts +20 -1
- package/models/models/kos-log-manager/services/kos-log-manager-services.d.ts.map +1 -1
- package/models/models/kos-log-manager/types/index.d.ts +75 -6
- package/models/models/log-stream/services/log-stream-services.d.ts.map +1 -1
- package/models/models/network-interface/services/network-interface-services.d.ts.map +1 -1
- package/models/models/ota/services/ota-services.d.ts.map +1 -1
- package/models/models/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/descriptor-merge.d.ts +9 -1
- package/models/models/translation/descriptor-merge.d.ts.map +1 -1
- package/models/models/translation/services/translation-services.d.ts.map +1 -1
- package/models/models/translation/translation-model.d.ts +4 -2
- package/models/models/translation/translation-model.d.ts.map +1 -1
- package/models/models/translation/types/index.d.ts +24 -6
- 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/types/cancellable-promise.d.ts +2 -0
- package/models/types/cancellable-promise.d.ts.map +1 -1
- package/models/utils/await-future-call.d.ts +8 -0
- package/models/utils/await-future-call.d.ts.map +1 -1
- package/models/utils/cancellable-future-call.d.ts.map +1 -1
- package/models/utils/client.d.ts +1 -1
- package/models/utils/core-registration-manager.d.ts +15 -2
- package/models/utils/core-registration-manager.d.ts.map +1 -1
- package/models/utils/get-kos-connection-id.d.ts.map +1 -1
- package/models/utils/service-accessor.d.ts +1 -1
- package/models/utils/service.d.ts +1 -1
- package/models/utils/services/kos/1.6.5/service.d.ts +1 -1
- package/models/utils/services/kos/1.8.1/service.d.ts +1 -1
- package/models/utils/services/kos/1.9.x/service.d.ts +1 -1
- package/models/utils/services/kos/daily/service.d.ts +1 -1
- package/models/utils/services/vfs/1.6.5/service.d.ts +1 -1
- package/models/utils/services/vfs/1.8.1/service.d.ts +1 -1
- package/models/utils/services/vfs/1.9.x/service.d.ts +1 -1
- package/models/utils/services/vfs/daily/service.d.ts +1 -1
- package/models/utils/timer-manager.d.ts.map +1 -1
- package/package.json +2 -2
- package/{software-info-registration-Le3V0a6v.cjs → software-info-registration-BPN4QLfN.cjs} +1299 -711
- package/software-info-registration-BPN4QLfN.cjs.map +1 -0
- package/{software-info-registration-kSGacOka.js → software-info-registration-BTHhITrs.js} +1610 -1022
- package/software-info-registration-BTHhITrs.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 +8 -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-kos-model.d.ts +1 -0
- package/ui/hooks/use-kos-model.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-Le3V0a6v.cjs.map +0 -1
- package/software-info-registration-kSGacOka.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const mobx = require("mobx");
|
|
3
|
-
const log$
|
|
3
|
+
const log$1h = require("loglevel");
|
|
4
4
|
const robot3 = require("robot3");
|
|
5
5
|
const dateFns = require("date-fns");
|
|
6
6
|
const HEADER_METHOD = `method`;
|
|
@@ -27,7 +27,140 @@ var KosWsEvents = /* @__PURE__ */ ((KosWsEvents2) => {
|
|
|
27
27
|
return KosWsEvents2;
|
|
28
28
|
})(KosWsEvents || {});
|
|
29
29
|
const EVENT_KOS_MODEL_READY = "/kos/model/ready/";
|
|
30
|
-
|
|
30
|
+
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
31
|
+
const [key, val] = pair.split("=");
|
|
32
|
+
return [key, decodeURIComponent(val || "")];
|
|
33
|
+
}).reduce((result, [key, val]) => {
|
|
34
|
+
result[key] = val;
|
|
35
|
+
return result;
|
|
36
|
+
}, {});
|
|
37
|
+
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
38
|
+
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
39
|
+
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
40
|
+
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
41
|
+
const PROFILE_LOG_INFO = "studio.log.info";
|
|
42
|
+
const defaultConfig = {
|
|
43
|
+
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
44
|
+
};
|
|
45
|
+
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
46
|
+
const configObj = JSON.parse(config);
|
|
47
|
+
const urlProfiles = () => {
|
|
48
|
+
if (typeof window === "undefined") {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const value = getQueryParams()?.["kosProfiles"];
|
|
52
|
+
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
53
|
+
};
|
|
54
|
+
configObj.profiles = [
|
|
55
|
+
...configObj.profiles ?? [],
|
|
56
|
+
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
57
|
+
];
|
|
58
|
+
globalThis.kosConfig = configObj;
|
|
59
|
+
const KosGlobalConfig = configObj;
|
|
60
|
+
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
61
|
+
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
62
|
+
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
63
|
+
const resolveLogLevelProfile = () => {
|
|
64
|
+
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
65
|
+
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
66
|
+
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
67
|
+
};
|
|
68
|
+
const getLogLevel = () => {
|
|
69
|
+
const params2 = getQueryParams();
|
|
70
|
+
const profileLogLevel = resolveLogLevelProfile();
|
|
71
|
+
const logLevelParam = params2["kosLogLevel"];
|
|
72
|
+
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
73
|
+
if (logLevel) {
|
|
74
|
+
return logLevel;
|
|
75
|
+
}
|
|
76
|
+
return "WARN";
|
|
77
|
+
};
|
|
78
|
+
const LogGroup = {
|
|
79
|
+
core: "core",
|
|
80
|
+
transport: "transport",
|
|
81
|
+
model: "model",
|
|
82
|
+
service: "service",
|
|
83
|
+
ui: "ui"
|
|
84
|
+
};
|
|
85
|
+
const UI_GROUP_OVERRIDE = "ui:group";
|
|
86
|
+
const UI_LOGGER_OVERRIDE = "ui:logger";
|
|
87
|
+
const LEVELS = ["trace", "debug", "info", "warn", "error"];
|
|
88
|
+
const getLoggerGroup = (loggerName) => {
|
|
89
|
+
const grouped = loggerName.indexOf(":::");
|
|
90
|
+
if (grouped >= 0) {
|
|
91
|
+
return loggerName.slice(0, grouped);
|
|
92
|
+
}
|
|
93
|
+
const ungrouped = loggerName.indexOf("::");
|
|
94
|
+
return ungrouped >= 0 ? loggerName.slice(0, ungrouped) : "";
|
|
95
|
+
};
|
|
96
|
+
const matchesPattern = (value, pattern) => {
|
|
97
|
+
const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
98
|
+
return new RegExp(`^${source}$`).test(value);
|
|
99
|
+
};
|
|
100
|
+
const matches = (loggerName, override) => {
|
|
101
|
+
const wildcard = override.name.includes("*");
|
|
102
|
+
if (override.type === UI_GROUP_OVERRIDE) {
|
|
103
|
+
const group = getLoggerGroup(loggerName);
|
|
104
|
+
return wildcard ? matchesPattern(group, override.name) : group === override.name;
|
|
105
|
+
}
|
|
106
|
+
if (override.type === UI_LOGGER_OVERRIDE) {
|
|
107
|
+
return wildcard ? matchesPattern(loggerName, override.name) : loggerName.startsWith(override.name);
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
};
|
|
111
|
+
const resolveOverrideLevel = (loggerName, overrides) => overrides.filter((override) => matches(loggerName, override)).map((override) => override.level.toLowerCase()).filter((level2) => LEVELS.includes(level2)).sort((a, b) => LEVELS.indexOf(a) - LEVELS.indexOf(b))[0];
|
|
112
|
+
const MESSAGE_LOGGER_NAME = "messages";
|
|
113
|
+
const MESSAGE_LOGGER = `${LogGroup.transport}:::${MESSAGE_LOGGER_NAME}`;
|
|
114
|
+
const originalFactory = log$1h.methodFactory;
|
|
115
|
+
log$1h.methodFactory = function(methodName, logLevel, loggerName) {
|
|
116
|
+
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
117
|
+
return function(...args) {
|
|
118
|
+
const _name = loggerName ? String(loggerName) : "";
|
|
119
|
+
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
120
|
+
const message = args.map(
|
|
121
|
+
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
122
|
+
).join(" ");
|
|
123
|
+
rawMethod(`${prefix}${message}`);
|
|
124
|
+
if (globalThis?.kosConfig?.logging && globalThis.kosLog && loggerName !== MESSAGE_LOGGER) {
|
|
125
|
+
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
let level = getLogLevel();
|
|
130
|
+
log$1h.setLevel(level);
|
|
131
|
+
window.setKosLogLevel = (_level) => {
|
|
132
|
+
level = _level;
|
|
133
|
+
log$1h.setLevel(_level);
|
|
134
|
+
};
|
|
135
|
+
const conditionallyLog = (level2) => (fn, logger = log$1h) => {
|
|
136
|
+
if (logger.getLevel() <= level2) {
|
|
137
|
+
fn();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const createLogger = ({ name, group }) => {
|
|
141
|
+
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
142
|
+
const _log = log$1h.getLogger(loggerName);
|
|
143
|
+
const _level = resolveOverrideLevel(
|
|
144
|
+
loggerName,
|
|
145
|
+
globalThis.kos?.logOverrides ?? []
|
|
146
|
+
);
|
|
147
|
+
if (_level) {
|
|
148
|
+
_log.setLevel(_level);
|
|
149
|
+
}
|
|
150
|
+
return _log;
|
|
151
|
+
};
|
|
152
|
+
const KosLog = {
|
|
153
|
+
...log$1h,
|
|
154
|
+
ifDebug: conditionallyLog(log$1h.levels.DEBUG),
|
|
155
|
+
ifInfo: conditionallyLog(log$1h.levels.INFO),
|
|
156
|
+
ifWarn: conditionallyLog(log$1h.levels.WARN),
|
|
157
|
+
ifError: conditionallyLog(log$1h.levels.ERROR),
|
|
158
|
+
getLogger: (name) => createLogger({ name }),
|
|
159
|
+
getLoggers: () => log$1h.getLoggers(),
|
|
160
|
+
createLogger
|
|
161
|
+
};
|
|
162
|
+
const log$1g = KosLog.createLogger({ group: LogGroup.core, name: "event-bus" });
|
|
163
|
+
log$1g.info("Initializing event bus");
|
|
31
164
|
globalThis.kos = globalThis.kos || {};
|
|
32
165
|
globalThis.kos.subscriptions = globalThis.kos.subscriptions || {};
|
|
33
166
|
const subscriptions = globalThis.kos.subscriptions;
|
|
@@ -38,15 +171,15 @@ function hasEventSubscriptions(eventType) {
|
|
|
38
171
|
function subscribe(eventType, callback) {
|
|
39
172
|
const id = getNextUniqueId();
|
|
40
173
|
if (!subscriptions[eventType]) {
|
|
41
|
-
log$
|
|
174
|
+
log$1g.debug(`Initializing subscription for ${eventType}`);
|
|
42
175
|
subscriptions[eventType] = {};
|
|
43
176
|
}
|
|
44
|
-
log$
|
|
177
|
+
log$1g.debug(`Subscribing to ${eventType} with id ${id.toString()}`);
|
|
45
178
|
subscriptions[eventType][id] = callback;
|
|
46
179
|
return {
|
|
47
180
|
count: subscriptions[eventType] ? Object.getOwnPropertySymbols(subscriptions[eventType]).length : 0,
|
|
48
181
|
unsubscribe: () => {
|
|
49
|
-
log$
|
|
182
|
+
log$1g.debug(`Unsubscribing from ${eventType} with id ${id.toString()}`);
|
|
50
183
|
if (subscriptions[eventType] && subscriptions[eventType][id]) {
|
|
51
184
|
delete subscriptions[eventType][id];
|
|
52
185
|
}
|
|
@@ -61,7 +194,7 @@ function subscribe(eventType, callback) {
|
|
|
61
194
|
}
|
|
62
195
|
function publish(eventType, msg, headers = {}) {
|
|
63
196
|
if (!subscriptions[eventType] || Object.getOwnPropertySymbols(subscriptions[eventType]).length === 0) {
|
|
64
|
-
log$
|
|
197
|
+
log$1g.debug(`No subscriptions for ${eventType}. Not publishing.`);
|
|
65
198
|
return {
|
|
66
199
|
eventType,
|
|
67
200
|
subscribers: 0
|
|
@@ -71,19 +204,19 @@ function publish(eventType, msg, headers = {}) {
|
|
|
71
204
|
Object.getOwnPropertySymbols(subscriptions[eventType]).forEach((id) => {
|
|
72
205
|
if (headers["sync"]) {
|
|
73
206
|
const responseId = headers["sync"];
|
|
74
|
-
log$
|
|
207
|
+
log$1g.debug(
|
|
75
208
|
`Performing sync publish for ${eventType} with sync id ${responseId}`
|
|
76
209
|
);
|
|
77
210
|
subscriptions[eventType][id]({ body: msg, headers }).then(
|
|
78
211
|
(response) => {
|
|
79
|
-
log$
|
|
212
|
+
log$1g.debug(
|
|
80
213
|
`Response recieved for ${responseId}, publishing back to source.`
|
|
81
214
|
);
|
|
82
215
|
publish(responseId, response);
|
|
83
216
|
}
|
|
84
217
|
);
|
|
85
218
|
} else {
|
|
86
|
-
log$
|
|
219
|
+
log$1g.debug(`Performing async publish for ${eventType}`);
|
|
87
220
|
subscriptions[eventType][id]({ body: msg, headers });
|
|
88
221
|
}
|
|
89
222
|
});
|
|
@@ -93,7 +226,7 @@ function publish(eventType, msg, headers = {}) {
|
|
|
93
226
|
};
|
|
94
227
|
}
|
|
95
228
|
function reset() {
|
|
96
|
-
log$
|
|
229
|
+
log$1g.warn("Resetting event bus");
|
|
97
230
|
Object.keys(subscriptions).forEach((key) => delete subscriptions[key]);
|
|
98
231
|
}
|
|
99
232
|
function once(eventType, callback) {
|
|
@@ -409,164 +542,11 @@ const eventBus_state = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defi
|
|
|
409
542
|
waitForAllWithState,
|
|
410
543
|
waitForOrGetState
|
|
411
544
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
412
|
-
const getQueryParams = (query = null) => (query || window.location.search.replace("?", "")).split("&").map((pair) => {
|
|
413
|
-
const [key, val] = pair.split("=");
|
|
414
|
-
return [key, decodeURIComponent(val || "")];
|
|
415
|
-
}).reduce((result, [key, val]) => {
|
|
416
|
-
result[key] = val;
|
|
417
|
-
return result;
|
|
418
|
-
}, {});
|
|
419
|
-
const PROFILE_ENABLE_RELEASES = "studio.enable.releases";
|
|
420
|
-
const PROFILE_TOOLS_PREVIEW = "studio.tools.preview";
|
|
421
|
-
const PROFILE_RELAX_STORE_VALIDATION = "studio.relax.store.validation";
|
|
422
|
-
const PROFILE_LOG_DEBUG = "studio.log.debug";
|
|
423
|
-
const PROFILE_LOG_INFO = "studio.log.info";
|
|
424
|
-
const defaultConfig = {
|
|
425
|
-
profiles: [PROFILE_TOOLS_PREVIEW]
|
|
426
|
-
};
|
|
427
|
-
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
428
|
-
const configObj = JSON.parse(config);
|
|
429
|
-
const urlProfiles = () => {
|
|
430
|
-
if (typeof window === "undefined") {
|
|
431
|
-
return [];
|
|
432
|
-
}
|
|
433
|
-
const value = getQueryParams()?.["kosProfiles"];
|
|
434
|
-
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
435
|
-
};
|
|
436
|
-
configObj.profiles = [
|
|
437
|
-
...configObj.profiles ?? [],
|
|
438
|
-
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
439
|
-
];
|
|
440
|
-
globalThis.kosConfig = configObj;
|
|
441
|
-
const KosGlobalConfig = configObj;
|
|
442
|
-
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
443
|
-
const hasKosProfile = (profile) => resolveKosProfiles().includes(profile);
|
|
444
|
-
const isKosLoggingEnabled = () => KosGlobalConfig.logging || false;
|
|
445
|
-
const resolveLogLevelProfile = () => {
|
|
446
|
-
const showDebugLogProfile = hasKosProfile(PROFILE_LOG_DEBUG);
|
|
447
|
-
const showInfoLogProfile = hasKosProfile(PROFILE_LOG_INFO);
|
|
448
|
-
return showDebugLogProfile ? "DEBUG" : showInfoLogProfile ? "INFO" : void 0;
|
|
449
|
-
};
|
|
450
|
-
const getLogLevel = () => {
|
|
451
|
-
const params2 = getQueryParams();
|
|
452
|
-
const profileLogLevel = resolveLogLevelProfile();
|
|
453
|
-
const logLevelParam = params2["kosLogLevel"];
|
|
454
|
-
const logLevel = logLevelParam ?? profileLogLevel ?? window.kosLogLevel ?? process.env.KOS_LOG_LEVEL;
|
|
455
|
-
if (logLevel) {
|
|
456
|
-
return logLevel;
|
|
457
|
-
}
|
|
458
|
-
return "WARN";
|
|
459
|
-
};
|
|
460
|
-
const getKosMessageLogging = () => {
|
|
461
|
-
const enableAll = window.kosMessageLogging || process.env.KOS_MESSAGE_LOGGING === "true";
|
|
462
|
-
return enableAll;
|
|
463
|
-
};
|
|
464
|
-
const getLogMessageToStudio = () => {
|
|
465
|
-
const enableAll = window.kosMessageStudioLogging || process.env.KOS_MESSAGE_STUDIO_LOGGING === "true";
|
|
466
|
-
return enableAll;
|
|
467
|
-
};
|
|
468
|
-
const WS_LOG = "ws-log";
|
|
469
|
-
const originalFactory = log$M.methodFactory;
|
|
470
|
-
const enableMessageLogging = getKosMessageLogging();
|
|
471
|
-
const enableStudioMessageLogging = getLogMessageToStudio();
|
|
472
|
-
log$M.methodFactory = function(methodName, logLevel, loggerName) {
|
|
473
|
-
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
474
|
-
return function(...args) {
|
|
475
|
-
const _name = loggerName ? String(loggerName) : "";
|
|
476
|
-
const prefix = _name ? `[${String(_name).substring(_name.lastIndexOf(":") + 1)}] | ` : "[root] | ";
|
|
477
|
-
const message = args.map(
|
|
478
|
-
(arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
|
|
479
|
-
).join(" ");
|
|
480
|
-
rawMethod(`${prefix}${message}`);
|
|
481
|
-
if (globalThis?.kosConfig?.logging && globalThis.kosLog && (loggerName !== WS_LOG || enableMessageLogging && enableStudioMessageLogging)) {
|
|
482
|
-
globalThis.kosLog(`UI: ${prefix}${message}`);
|
|
483
|
-
}
|
|
484
|
-
};
|
|
485
|
-
};
|
|
486
|
-
let level = getLogLevel();
|
|
487
|
-
log$M.setLevel(level);
|
|
488
|
-
window.setKosLogLevel = (_level) => {
|
|
489
|
-
level = _level;
|
|
490
|
-
log$M.setLevel(_level);
|
|
491
|
-
};
|
|
492
|
-
const wsLog = log$M.getLogger(WS_LOG);
|
|
493
|
-
window.enableKosMessageLog = () => {
|
|
494
|
-
wsLog.setLevel(log$M.levels.INFO);
|
|
495
|
-
};
|
|
496
|
-
window.disableKosMessageLog = () => {
|
|
497
|
-
wsLog.setLevel(log$M.levels.ERROR);
|
|
498
|
-
};
|
|
499
|
-
if (enableMessageLogging) {
|
|
500
|
-
window.enableKosMessageLog();
|
|
501
|
-
} else {
|
|
502
|
-
window.disableKosMessageLog();
|
|
503
|
-
}
|
|
504
|
-
const styles = [
|
|
505
|
-
"color: black",
|
|
506
|
-
"display: block",
|
|
507
|
-
"background-color: lightgreen",
|
|
508
|
-
"padding: 4px",
|
|
509
|
-
"margin: 0",
|
|
510
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
511
|
-
"box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset",
|
|
512
|
-
"font-weight: bold"
|
|
513
|
-
].join(";");
|
|
514
|
-
const received = [
|
|
515
|
-
"color: black",
|
|
516
|
-
"display: block",
|
|
517
|
-
"padding: 4px",
|
|
518
|
-
"background-color: yellow",
|
|
519
|
-
"margin: 0",
|
|
520
|
-
"text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)",
|
|
521
|
-
"box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset",
|
|
522
|
-
"font-weight: bold"
|
|
523
|
-
].join(";");
|
|
524
|
-
const conditionallyLog = (level2) => (fn) => {
|
|
525
|
-
if (log$M.getLevel() <= level2) {
|
|
526
|
-
fn();
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
const KosLog = {
|
|
530
|
-
...log$M,
|
|
531
|
-
ifDebug: conditionallyLog(log$M.levels.DEBUG),
|
|
532
|
-
ifInfo: conditionallyLog(log$M.levels.INFO),
|
|
533
|
-
ifWarn: conditionallyLog(log$M.levels.WARN),
|
|
534
|
-
ifError: conditionallyLog(log$M.levels.ERROR),
|
|
535
|
-
getLogger: (name) => log$M.getLogger(`kos::${name}`),
|
|
536
|
-
getLoggers: () => log$M.getLoggers(),
|
|
537
|
-
createLogger: ({ name, group }) => {
|
|
538
|
-
const loggerName = `${group ? `${group}:` : "kos"}::${name}`;
|
|
539
|
-
const _log = log$M.getLogger(loggerName);
|
|
540
|
-
let _level = globalThis.kos.logOverrides?.find(
|
|
541
|
-
(override) => override.name === loggerName
|
|
542
|
-
)?.level;
|
|
543
|
-
if (_level) {
|
|
544
|
-
_log.setLevel(_level);
|
|
545
|
-
} else {
|
|
546
|
-
_level = globalThis.kos.logOverrides?.find(
|
|
547
|
-
(override) => loggerName.startsWith(override.name)
|
|
548
|
-
)?.level;
|
|
549
|
-
if (_level) {
|
|
550
|
-
_log.setLevel(_level);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
return _log;
|
|
554
|
-
},
|
|
555
|
-
wsSend: (...msg) => {
|
|
556
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
557
|
-
wsLog.info(`%c⬆ ${str}`, styles);
|
|
558
|
-
},
|
|
559
|
-
wsReceive: (...msg) => {
|
|
560
|
-
const str = String(msg).replace(/\n/g, "\\n");
|
|
561
|
-
wsLog.info(`%c⬇ ${str}`, received);
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
545
|
const SubscriptionHandlers = /* @__PURE__ */ Symbol(`SubscriptionHandlers`);
|
|
565
546
|
const DependencyModels = /* @__PURE__ */ Symbol(`DependencyModels`);
|
|
566
547
|
const FutureService = /* @__PURE__ */ Symbol(`FutureService`);
|
|
567
548
|
const ChildModels = /* @__PURE__ */ Symbol(`ChildModels`);
|
|
568
549
|
const ParentModel = /* @__PURE__ */ Symbol(`ParentModel`);
|
|
569
|
-
const LogConfig = /* @__PURE__ */ Symbol(`LogConfig`);
|
|
570
550
|
const ReferenceConfig = /* @__PURE__ */ Symbol(`ReferenceConfig`);
|
|
571
551
|
const KosModelSymbol = /* @__PURE__ */ Symbol(`KosModelSymbol`);
|
|
572
552
|
const ModelEffects = /* @__PURE__ */ Symbol(`ModelEffects`);
|
|
@@ -588,7 +568,10 @@ const KosViewModelSymbol = /* @__PURE__ */ Symbol(`KosViewModelSymbol`);
|
|
|
588
568
|
const ViewModelConfig = /* @__PURE__ */ Symbol(`ViewModelConfig`);
|
|
589
569
|
const ReloadAwareSetup = /* @__PURE__ */ Symbol(`ReloadAwareSetup`);
|
|
590
570
|
const MixinModels = /* @__PURE__ */ Symbol(`MixinModels`);
|
|
591
|
-
const log$
|
|
571
|
+
const log$1f = KosLog.createLogger({
|
|
572
|
+
group: LogGroup.core,
|
|
573
|
+
name: "fsm-injection"
|
|
574
|
+
});
|
|
592
575
|
function injectStateMachineSupport(modelInstance) {
|
|
593
576
|
const fsmSetup = modelInstance[StateMachineSetup];
|
|
594
577
|
if (!fsmSetup) return;
|
|
@@ -632,7 +615,7 @@ function initializeFsmProperties(modelInstance, options) {
|
|
|
632
615
|
const config2 = modelInstance._fsmConfig;
|
|
633
616
|
const initialState = computeInitialState ? computeInitialState(modelInstance) : config2.initial;
|
|
634
617
|
if (computeInitialState && !config2.states[initialState]) {
|
|
635
|
-
log$
|
|
618
|
+
log$1f.warn(
|
|
636
619
|
`computeInitialState returned "${initialState}" which is not a valid state. Falling back to "${config2.initial}".`
|
|
637
620
|
);
|
|
638
621
|
modelInstance[stateProperty] = config2.initial;
|
|
@@ -762,7 +745,7 @@ function handleAsyncEntryResult(instance, state, stateProperty, result) {
|
|
|
762
745
|
if (stateConfig.onError && instance[stateProperty] === state) {
|
|
763
746
|
instance.transition(stateConfig.onError);
|
|
764
747
|
} else {
|
|
765
|
-
log$
|
|
748
|
+
log$1f.error(`Async entry handler for state "${state}" failed:`, err);
|
|
766
749
|
}
|
|
767
750
|
}
|
|
768
751
|
);
|
|
@@ -803,7 +786,7 @@ function initializeStateMachine(modelInstance, lifecycle) {
|
|
|
803
786
|
modelInstance._fsmInitialized = true;
|
|
804
787
|
trackInitialStateInHistory(modelInstance, config2.initial, options);
|
|
805
788
|
executeInitialStateEntryHandler(modelInstance, config2.initial);
|
|
806
|
-
log$
|
|
789
|
+
log$1f.debug(
|
|
807
790
|
`FSM initialized for model ${modelInstance.id} at lifecycle ${lifecycle} with initial state "${config2.initial}"`
|
|
808
791
|
);
|
|
809
792
|
}
|
|
@@ -927,9 +910,12 @@ function getHttpRouteHandlers(model) {
|
|
|
927
910
|
return model?.[HttpRouteHandlers] || [];
|
|
928
911
|
}
|
|
929
912
|
class KosLoggerFactory {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
913
|
+
/**
|
|
914
|
+
* The logger for a model type, `model:::{modelTypeName}`. Every instance of
|
|
915
|
+
* the type shares it; put the instance id in the message where it matters.
|
|
916
|
+
*/
|
|
917
|
+
static create({ modelTypeName }) {
|
|
918
|
+
return KosLog.createLogger({ group: LogGroup.model, name: modelTypeName });
|
|
933
919
|
}
|
|
934
920
|
}
|
|
935
921
|
function kosLoggerAware(options) {
|
|
@@ -947,8 +933,7 @@ function kosLoggerAware(options) {
|
|
|
947
933
|
if (!sharedLogger) {
|
|
948
934
|
const modelType = getModelType();
|
|
949
935
|
sharedLogger = KosLoggerFactory.create({
|
|
950
|
-
modelTypeName: loggerContext || modelType
|
|
951
|
-
component: "kos-model"
|
|
936
|
+
modelTypeName: loggerContext || modelType
|
|
952
937
|
});
|
|
953
938
|
}
|
|
954
939
|
return sharedLogger;
|
|
@@ -999,7 +984,10 @@ class ServiceRequestError extends Error {
|
|
|
999
984
|
this.responseHeaders = details.responseHeaders ?? {};
|
|
1000
985
|
}
|
|
1001
986
|
}
|
|
1002
|
-
const log$
|
|
987
|
+
const log$1e = KosLog.createLogger({
|
|
988
|
+
group: LogGroup.core,
|
|
989
|
+
name: "resolve-parameters"
|
|
990
|
+
});
|
|
1003
991
|
const resolveParameters = ({
|
|
1004
992
|
value,
|
|
1005
993
|
modelId,
|
|
@@ -1031,11 +1019,11 @@ const resolveParameters = ({
|
|
|
1031
1019
|
)) {
|
|
1032
1020
|
const prop = modelData[propName];
|
|
1033
1021
|
if (prop !== null && prop !== void 0) {
|
|
1034
|
-
log$
|
|
1022
|
+
log$1e.debug(`Resolved ${match} to ${prop}`);
|
|
1035
1023
|
return prop;
|
|
1036
1024
|
} else {
|
|
1037
1025
|
const logLevel2 = isOnlyPropKey ? "debug" : "warn";
|
|
1038
|
-
log$
|
|
1026
|
+
log$1e[logLevel2](
|
|
1039
1027
|
`Property ${propName} is null or undefined${isOnlyPropKey ? "" : " in composite string"}, marking for undefined return`
|
|
1040
1028
|
);
|
|
1041
1029
|
hasUnresolvedProp = true;
|
|
@@ -1043,7 +1031,7 @@ const resolveParameters = ({
|
|
|
1043
1031
|
}
|
|
1044
1032
|
}
|
|
1045
1033
|
const logLevel = isOnlyPropKey ? "debug" : "warn";
|
|
1046
|
-
log$
|
|
1034
|
+
log$1e[logLevel](
|
|
1047
1035
|
`Property ${propName} not found in modelData${isOnlyPropKey ? "" : " for composite string"}`
|
|
1048
1036
|
);
|
|
1049
1037
|
return match;
|
|
@@ -1058,7 +1046,10 @@ const resolveParameters = ({
|
|
|
1058
1046
|
}
|
|
1059
1047
|
return _value;
|
|
1060
1048
|
};
|
|
1061
|
-
const log$
|
|
1049
|
+
const log$1d = KosLog.createLogger({
|
|
1050
|
+
group: LogGroup.core,
|
|
1051
|
+
name: "ServiceRequestHelpers"
|
|
1052
|
+
});
|
|
1062
1053
|
function resolveServiceRequestParameters(metadata, modelInstance, args, runtimeOptions) {
|
|
1063
1054
|
const resolvedPath = resolveParameters({
|
|
1064
1055
|
value: metadata.path,
|
|
@@ -1127,7 +1118,7 @@ function handleServiceRequestError(error, response, errorHandler, modelInstance,
|
|
|
1127
1118
|
});
|
|
1128
1119
|
switch (errorHandler.strategy) {
|
|
1129
1120
|
case "log":
|
|
1130
|
-
log$
|
|
1121
|
+
log$1d.error(`Service request status ${richError.status} error: ${error}`);
|
|
1131
1122
|
if (errorHandler.onError) {
|
|
1132
1123
|
errorHandler.onError(richError, modelInstance);
|
|
1133
1124
|
}
|
|
@@ -1240,7 +1231,10 @@ var ReplayStrategy = /* @__PURE__ */ ((ReplayStrategy2) => {
|
|
|
1240
1231
|
ReplayStrategy2["NONE"] = "none";
|
|
1241
1232
|
return ReplayStrategy2;
|
|
1242
1233
|
})(ReplayStrategy || {});
|
|
1243
|
-
const log$
|
|
1234
|
+
const log$1c = KosLog.createLogger({
|
|
1235
|
+
group: LogGroup.core,
|
|
1236
|
+
name: "kos-state-machine"
|
|
1237
|
+
});
|
|
1244
1238
|
function kosStateMachine(config2, options) {
|
|
1245
1239
|
return (target) => {
|
|
1246
1240
|
target.prototype[StateMachineSetup] = {
|
|
@@ -1297,7 +1291,7 @@ function kosStateGuard(options) {
|
|
|
1297
1291
|
if (shouldThrow) {
|
|
1298
1292
|
throw new Error(message);
|
|
1299
1293
|
} else {
|
|
1300
|
-
log$
|
|
1294
|
+
log$1c.warn(message);
|
|
1301
1295
|
return void 0;
|
|
1302
1296
|
}
|
|
1303
1297
|
}
|
|
@@ -1323,6 +1317,10 @@ const kosDependency = ({
|
|
|
1323
1317
|
resolutionPolicy
|
|
1324
1318
|
};
|
|
1325
1319
|
};
|
|
1320
|
+
const log$1b = KosLog.createLogger({
|
|
1321
|
+
group: LogGroup.model,
|
|
1322
|
+
name: "future-aware"
|
|
1323
|
+
});
|
|
1326
1324
|
class MultipleFutureHandler {
|
|
1327
1325
|
futures;
|
|
1328
1326
|
defaultContext;
|
|
@@ -1413,7 +1411,7 @@ class FutureHandler {
|
|
|
1413
1411
|
try {
|
|
1414
1412
|
await this._future.cancelFuture();
|
|
1415
1413
|
} catch (e) {
|
|
1416
|
-
|
|
1414
|
+
log$1b.error(e);
|
|
1417
1415
|
throw e;
|
|
1418
1416
|
}
|
|
1419
1417
|
}
|
|
@@ -1538,6 +1536,10 @@ const ObservableData = (initialData) => {
|
|
|
1538
1536
|
const od = createObservableData(ObservableDataMap, initialData);
|
|
1539
1537
|
return new od(initialData);
|
|
1540
1538
|
};
|
|
1539
|
+
const log$1a = KosLog.createLogger({
|
|
1540
|
+
group: LogGroup.core,
|
|
1541
|
+
name: "extension-manager"
|
|
1542
|
+
});
|
|
1541
1543
|
const DEFAULT_EXTENSION_OPTIONS = {
|
|
1542
1544
|
failurePolicy: "throw"
|
|
1543
1545
|
};
|
|
@@ -1589,8 +1591,8 @@ const _ExtensionManager = {
|
|
|
1589
1591
|
return await loader(data);
|
|
1590
1592
|
} catch (e) {
|
|
1591
1593
|
if (options.failurePolicy === "continue") {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
+
log$1a.error(`Error executing data loader for id ${id}`);
|
|
1595
|
+
log$1a.error(e);
|
|
1594
1596
|
return void 0;
|
|
1595
1597
|
}
|
|
1596
1598
|
throw new ExtensionException(id, "dataLoader", e);
|
|
@@ -1615,8 +1617,8 @@ const _ExtensionManager = {
|
|
|
1615
1617
|
return mapper(data, context);
|
|
1616
1618
|
} catch (e) {
|
|
1617
1619
|
if (options.failurePolicy === "continue") {
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
+
log$1a.error(`Error executing property mapper for id ${id}`);
|
|
1621
|
+
log$1a.error(e);
|
|
1620
1622
|
return "";
|
|
1621
1623
|
}
|
|
1622
1624
|
throw new ExtensionException(id, "propertyMapper", e);
|
|
@@ -1644,8 +1646,8 @@ const _ExtensionManager = {
|
|
|
1644
1646
|
Object.assign(result, _interim);
|
|
1645
1647
|
} catch (e) {
|
|
1646
1648
|
if (options.failurePolicy === "continue") {
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
+
log$1a.error(`Error executing data mapper for id ${id}`);
|
|
1650
|
+
log$1a.error(e);
|
|
1649
1651
|
continue;
|
|
1650
1652
|
}
|
|
1651
1653
|
throw new ExtensionException(id, "dataMapper", e);
|
|
@@ -1657,7 +1659,7 @@ const _ExtensionManager = {
|
|
|
1657
1659
|
canvas: {
|
|
1658
1660
|
registerRenderer: (id, renderer) => {
|
|
1659
1661
|
if (!ExtensionManager[EXTENSION_CANVAS_RENDERER]) {
|
|
1660
|
-
|
|
1662
|
+
log$1a.warn(
|
|
1661
1663
|
`Canvas renderer extension point is not registered. Cannot register renderer "${id}".`
|
|
1662
1664
|
);
|
|
1663
1665
|
return;
|
|
@@ -1683,6 +1685,10 @@ const INDEX_COLLECTION_KEY = "@kosdev-code/kos-ui-sdk.collection";
|
|
|
1683
1685
|
function isIndexableItem(value) {
|
|
1684
1686
|
return typeof value === "object" && value !== null && INDEX_RECORD_SYMBOL in value;
|
|
1685
1687
|
}
|
|
1688
|
+
const log$19 = KosLog.createLogger({
|
|
1689
|
+
group: LogGroup.core,
|
|
1690
|
+
name: "kos-container-index"
|
|
1691
|
+
});
|
|
1686
1692
|
function isPromiseLike(value) {
|
|
1687
1693
|
return typeof value?.then === "function";
|
|
1688
1694
|
}
|
|
@@ -1734,7 +1740,7 @@ class KosContainerIndex {
|
|
|
1734
1740
|
const set = map.get(key) || /* @__PURE__ */ new Set();
|
|
1735
1741
|
this._map.set(key, set);
|
|
1736
1742
|
} else {
|
|
1737
|
-
|
|
1743
|
+
log$19.debug(`KosContainerIndex - Index ${key} is the same`);
|
|
1738
1744
|
}
|
|
1739
1745
|
});
|
|
1740
1746
|
}
|
|
@@ -1810,7 +1816,10 @@ function observeComputedProperties(model, callback, keys = []) {
|
|
|
1810
1816
|
);
|
|
1811
1817
|
return disposers;
|
|
1812
1818
|
}
|
|
1813
|
-
const log$
|
|
1819
|
+
const log$18 = KosLog.createLogger({
|
|
1820
|
+
group: LogGroup.core,
|
|
1821
|
+
name: "kos-container-model"
|
|
1822
|
+
});
|
|
1814
1823
|
class KosModelContainer {
|
|
1815
1824
|
_data;
|
|
1816
1825
|
_sortKey;
|
|
@@ -1932,14 +1941,14 @@ class KosModelContainer {
|
|
|
1932
1941
|
async removeAndDestroy(id) {
|
|
1933
1942
|
const model = this.getModel(id);
|
|
1934
1943
|
if (!model) {
|
|
1935
|
-
log$
|
|
1944
|
+
log$18.debug(`Model ${id} not found in container, skipping destroy`);
|
|
1936
1945
|
return;
|
|
1937
1946
|
}
|
|
1938
1947
|
this.removeModel(id);
|
|
1939
1948
|
try {
|
|
1940
1949
|
await destroyKosModel(model);
|
|
1941
1950
|
} catch (error) {
|
|
1942
|
-
log$
|
|
1951
|
+
log$18.error(`Failed to destroy model ${id}:`, error);
|
|
1943
1952
|
throw error;
|
|
1944
1953
|
}
|
|
1945
1954
|
}
|
|
@@ -1956,7 +1965,7 @@ class KosModelContainer {
|
|
|
1956
1965
|
async removeAndDestroyAll(ids) {
|
|
1957
1966
|
const models2 = ids.map((id) => this.getModel(id)).filter((model) => model !== void 0);
|
|
1958
1967
|
if (models2.length === 0) {
|
|
1959
|
-
log$
|
|
1968
|
+
log$18.debug("No models found to destroy");
|
|
1960
1969
|
return;
|
|
1961
1970
|
}
|
|
1962
1971
|
this.removeAll(ids);
|
|
@@ -1965,7 +1974,7 @@ class KosModelContainer {
|
|
|
1965
1974
|
);
|
|
1966
1975
|
results.forEach((result, index) => {
|
|
1967
1976
|
if (result.status === "rejected") {
|
|
1968
|
-
log$
|
|
1977
|
+
log$18.error(
|
|
1969
1978
|
`Failed to destroy model ${models2[index].id}:`,
|
|
1970
1979
|
result.reason
|
|
1971
1980
|
);
|
|
@@ -2138,7 +2147,7 @@ class KosModelContainer {
|
|
|
2138
2147
|
const idx = this.index.get(indexName);
|
|
2139
2148
|
return idx.keys ?? [];
|
|
2140
2149
|
} else {
|
|
2141
|
-
log$
|
|
2150
|
+
log$18.info(
|
|
2142
2151
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2143
2152
|
);
|
|
2144
2153
|
return [];
|
|
@@ -2150,7 +2159,7 @@ class KosModelContainer {
|
|
|
2150
2159
|
if (idx.index.has(indexKey)) {
|
|
2151
2160
|
return idx.getByKey(indexKey);
|
|
2152
2161
|
} else {
|
|
2153
|
-
log$
|
|
2162
|
+
log$18.info(
|
|
2154
2163
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
2155
2164
|
idx.index.keys()
|
|
2156
2165
|
)}`
|
|
@@ -2158,7 +2167,7 @@ class KosModelContainer {
|
|
|
2158
2167
|
return [];
|
|
2159
2168
|
}
|
|
2160
2169
|
} else {
|
|
2161
|
-
log$
|
|
2170
|
+
log$18.info(
|
|
2162
2171
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
2163
2172
|
);
|
|
2164
2173
|
return [];
|
|
@@ -2185,7 +2194,7 @@ class KosModelContainer {
|
|
|
2185
2194
|
* @private
|
|
2186
2195
|
*/
|
|
2187
2196
|
_logCapacityWarning(toEvict) {
|
|
2188
|
-
log$
|
|
2197
|
+
log$18.info(
|
|
2189
2198
|
`Container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${toEvict} models using ${this._evictionStrategy} strategy.`,
|
|
2190
2199
|
{ parentId: this._parentId }
|
|
2191
2200
|
);
|
|
@@ -2248,7 +2257,7 @@ class KosModelContainer {
|
|
|
2248
2257
|
const candidates = this._customEvictionFilter(this.data);
|
|
2249
2258
|
return candidates.slice(0, count);
|
|
2250
2259
|
}
|
|
2251
|
-
log$
|
|
2260
|
+
log$18.error(
|
|
2252
2261
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO.",
|
|
2253
2262
|
{ parentId: this._parentId }
|
|
2254
2263
|
);
|
|
@@ -2260,7 +2269,7 @@ class KosModelContainer {
|
|
|
2260
2269
|
*/
|
|
2261
2270
|
async _removeEvictedModels(models2) {
|
|
2262
2271
|
for (const model of models2) {
|
|
2263
|
-
log$
|
|
2272
|
+
log$18.info(
|
|
2264
2273
|
`Evicting model: ${model.id} (type: ${model.constructor.name})`,
|
|
2265
2274
|
{
|
|
2266
2275
|
modelId: model.id,
|
|
@@ -2270,7 +2279,7 @@ class KosModelContainer {
|
|
|
2270
2279
|
);
|
|
2271
2280
|
this.removeModel(model.id, true);
|
|
2272
2281
|
destroyKosModel(model).catch(
|
|
2273
|
-
(e) => log$
|
|
2282
|
+
(e) => log$18.error(`Failed to destroy evicted model ${model.id}:`, e)
|
|
2274
2283
|
);
|
|
2275
2284
|
}
|
|
2276
2285
|
}
|
|
@@ -2279,7 +2288,7 @@ class KosModelContainer {
|
|
|
2279
2288
|
* @private
|
|
2280
2289
|
*/
|
|
2281
2290
|
_logEvictionComplete(evictedCount) {
|
|
2282
|
-
log$
|
|
2291
|
+
log$18.info(
|
|
2283
2292
|
`Evicted ${evictedCount} models. Current size: ${this._data.size}/${this._maxCapacity}`,
|
|
2284
2293
|
{ parentId: this._parentId }
|
|
2285
2294
|
);
|
|
@@ -2288,9 +2297,9 @@ class KosModelContainer {
|
|
|
2288
2297
|
this._data.forEach((model) => {
|
|
2289
2298
|
const modelId = model.id;
|
|
2290
2299
|
destroyKosModel(model).then(() => {
|
|
2291
|
-
log$
|
|
2300
|
+
log$18.debug(`${modelId} destroyed, removing from map`);
|
|
2292
2301
|
this.removeModel(modelId, true);
|
|
2293
|
-
}).catch((e) => log$
|
|
2302
|
+
}).catch((e) => log$18.error(e));
|
|
2294
2303
|
});
|
|
2295
2304
|
this.increment();
|
|
2296
2305
|
}
|
|
@@ -2433,12 +2442,16 @@ const whenReady = async (dataModel) => {
|
|
|
2433
2442
|
}
|
|
2434
2443
|
return dataModel;
|
|
2435
2444
|
};
|
|
2445
|
+
const log$17 = KosLog.createLogger({
|
|
2446
|
+
group: LogGroup.core,
|
|
2447
|
+
name: "kos-model-utils"
|
|
2448
|
+
});
|
|
2436
2449
|
const destroyKosModel = async (model) => {
|
|
2437
2450
|
await KosCore.getInstance().whenReady();
|
|
2438
2451
|
await KosCore.getInstance().modelManager.initiateDestroyModel(model);
|
|
2439
2452
|
};
|
|
2440
2453
|
const unloadKosModel = async (dataModel) => {
|
|
2441
|
-
|
|
2454
|
+
log$17.warn(
|
|
2442
2455
|
`unloadKosModel(${dataModel?.id}) is deprecated and never resolves. Use destroyKosModel() to release a model, or reload() to refresh it.`
|
|
2443
2456
|
);
|
|
2444
2457
|
await KosCore.getInstance().whenReady();
|
|
@@ -2451,16 +2464,16 @@ const unloadKosModel = async (dataModel) => {
|
|
|
2451
2464
|
}
|
|
2452
2465
|
};
|
|
2453
2466
|
const resetKosModel = async (model) => {
|
|
2454
|
-
|
|
2467
|
+
log$17.warn(
|
|
2455
2468
|
`resetKosModel(${model?.id}) is deprecated: the reset route drops every topic handler registered at INIT or with no lifecycle. Implement reload() on the model and refetch and reconcile in place.`
|
|
2456
2469
|
);
|
|
2457
2470
|
await KosCore.getInstance().whenReady();
|
|
2458
2471
|
await KosCore.getInstance().modelManager.reloadModel(model);
|
|
2459
|
-
|
|
2472
|
+
log$17.debug(
|
|
2460
2473
|
`reload model initiated for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2461
2474
|
);
|
|
2462
2475
|
await whenReady(model);
|
|
2463
|
-
|
|
2476
|
+
log$17.debug(
|
|
2464
2477
|
`reload model complete for model ${model.id}, model ready: ${isKosModelReady(model)} - ${Date.now()} `
|
|
2465
2478
|
);
|
|
2466
2479
|
};
|
|
@@ -2536,7 +2549,7 @@ const getObservableCompanions = (modelId) => {
|
|
|
2536
2549
|
const resolveKosCompanion = (modelId, resolver) => {
|
|
2537
2550
|
const model = KosCore.getInstance().modelManager.getModelById(modelId);
|
|
2538
2551
|
if (!model) {
|
|
2539
|
-
|
|
2552
|
+
log$17.info(`Model not found for id ${modelId}`);
|
|
2540
2553
|
return void 0;
|
|
2541
2554
|
}
|
|
2542
2555
|
const companionModel = Array.from(model.companionModels.all()).find(
|
|
@@ -2575,7 +2588,10 @@ const getKosModelActivationState = (model) => {
|
|
|
2575
2588
|
}
|
|
2576
2589
|
};
|
|
2577
2590
|
};
|
|
2578
|
-
const log$
|
|
2591
|
+
const log$16 = KosLog.createLogger({
|
|
2592
|
+
group: LogGroup.core,
|
|
2593
|
+
name: "kos-model-factory"
|
|
2594
|
+
});
|
|
2579
2595
|
const KosModelFactory = {
|
|
2580
2596
|
byModelType: (modelType) => KosCore.getInstance().modelManager.getModelFactory(
|
|
2581
2597
|
modelType
|
|
@@ -2583,7 +2599,7 @@ const KosModelFactory = {
|
|
|
2583
2599
|
getModelInstance: (id, modelType, options) => {
|
|
2584
2600
|
const factory = KosModelFactory.byModelType(modelType);
|
|
2585
2601
|
if (!factory) {
|
|
2586
|
-
log$
|
|
2602
|
+
log$16.error(
|
|
2587
2603
|
`No registered factory found for model type ${modelType}. Please register a factory for this model type. `
|
|
2588
2604
|
);
|
|
2589
2605
|
throw Error(`No factory found for model type ${modelType}`);
|
|
@@ -2622,6 +2638,10 @@ const Kos = {
|
|
|
2622
2638
|
instance: (modelType) => (id) => KosModelFactory.getModelInstance(id, modelType)
|
|
2623
2639
|
}
|
|
2624
2640
|
};
|
|
2641
|
+
const log$15 = KosLog.createLogger({
|
|
2642
|
+
group: LogGroup.core,
|
|
2643
|
+
name: "registration-manager"
|
|
2644
|
+
});
|
|
2625
2645
|
window.KosRegistry = window.KosRegistry || {
|
|
2626
2646
|
coreModels: /* @__PURE__ */ new Map(),
|
|
2627
2647
|
preloadModels: [],
|
|
@@ -2666,7 +2686,7 @@ const RegistrationManager = {
|
|
|
2666
2686
|
}
|
|
2667
2687
|
if (KosCore.getInstance().isReady) {
|
|
2668
2688
|
if (!KosCore.getInstance().modelManager.registry.models[register.type]) {
|
|
2669
|
-
|
|
2689
|
+
log$15.info(
|
|
2670
2690
|
`Model with type ${register.type} doesn't exist. Adding new registration`
|
|
2671
2691
|
);
|
|
2672
2692
|
KosCore.getInstance().modelManager.registry.models[register.type] = register.registration[register.type];
|
|
@@ -2898,7 +2918,7 @@ class SingletonKosModelRegistrationFactory extends KosBaseModelRegistration {
|
|
|
2898
2918
|
};
|
|
2899
2919
|
}
|
|
2900
2920
|
}
|
|
2901
|
-
const log$
|
|
2921
|
+
const log$14 = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
2902
2922
|
const FUTURE_CANCEL_END_STATE = "CANCEL";
|
|
2903
2923
|
function resolveParentContext(TargetClass, modelId, modelData) {
|
|
2904
2924
|
const parentIdRaw = TargetClass[ParentModel]?.parentId;
|
|
@@ -3110,8 +3130,31 @@ function injectTroubleAwareSupport(modelInstance) {
|
|
|
3110
3130
|
configurable: true
|
|
3111
3131
|
});
|
|
3112
3132
|
}
|
|
3133
|
+
function registrationBuilders(model) {
|
|
3134
|
+
const registration = () => {
|
|
3135
|
+
const resolved = typeof model === "function" ? model() : model;
|
|
3136
|
+
if (!resolved) {
|
|
3137
|
+
throw new Error(
|
|
3138
|
+
"reconcile.model is undefined: the registration was not yet defined when @kosContainerAware ran. Pass model: () => Registration."
|
|
3139
|
+
);
|
|
3140
|
+
}
|
|
3141
|
+
return resolved;
|
|
3142
|
+
};
|
|
3143
|
+
return {
|
|
3144
|
+
create: (dto) => registration().instance(dto.id).options(dto).build(),
|
|
3145
|
+
update: (dto, existing) => {
|
|
3146
|
+
if (!isUpdateable(existing)) {
|
|
3147
|
+
throw new Error(
|
|
3148
|
+
`Model ${existing.id} is not updateable. reconcile.model needs the child to implement UpdateAware.`
|
|
3149
|
+
);
|
|
3150
|
+
}
|
|
3151
|
+
existing.updateModel(dto);
|
|
3152
|
+
}
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3113
3155
|
function createContainerReconcile(container, reconcile) {
|
|
3114
|
-
const {
|
|
3156
|
+
const { idMapper, filter, afterCreate } = reconcile;
|
|
3157
|
+
const { create, update } = "model" in reconcile && !reconcile.create ? registrationBuilders(reconcile.model) : reconcile;
|
|
3115
3158
|
const apply = resolveContainerDeltas({
|
|
3116
3159
|
container,
|
|
3117
3160
|
onAddItem: (dto) => {
|
|
@@ -3193,7 +3236,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3193
3236
|
const { mode, parentProperty, excludeProperties } = companionConfig;
|
|
3194
3237
|
const parentModel = initialData.companionParent;
|
|
3195
3238
|
if (!parentModel) {
|
|
3196
|
-
log$
|
|
3239
|
+
log$14.warn(
|
|
3197
3240
|
`Companion decorator configured but no parent model found in initialData.companionParent`
|
|
3198
3241
|
);
|
|
3199
3242
|
return;
|
|
@@ -3267,7 +3310,7 @@ function injectCompanionSupport(modelInstance, initialData) {
|
|
|
3267
3310
|
});
|
|
3268
3311
|
}
|
|
3269
3312
|
} catch (error) {
|
|
3270
|
-
log$
|
|
3313
|
+
log$14.debug(
|
|
3271
3314
|
`Skipping companion proxy for property ${propertyName}:`,
|
|
3272
3315
|
error
|
|
3273
3316
|
);
|
|
@@ -3304,7 +3347,7 @@ function makeSafeObservable(instance) {
|
|
|
3304
3347
|
try {
|
|
3305
3348
|
return mobx.makeAutoObservable(instance);
|
|
3306
3349
|
} catch (e) {
|
|
3307
|
-
log$
|
|
3350
|
+
log$14.error("Failed to make observable:", e);
|
|
3308
3351
|
return instance;
|
|
3309
3352
|
}
|
|
3310
3353
|
}
|
|
@@ -3314,9 +3357,8 @@ const modelConstructorProxy = {
|
|
|
3314
3357
|
const kosContext = KosContextManager.createContext(modelId);
|
|
3315
3358
|
resolveParentContext(TargetClass, modelId, initialData);
|
|
3316
3359
|
const hasLoggerAware = !!TargetClass.prototype[LoggerSetup];
|
|
3317
|
-
const logger = hasLoggerAware ? null :
|
|
3318
|
-
|
|
3319
|
-
group: TargetClass[LogConfig]?.group ?? "kos-model"
|
|
3360
|
+
const logger = hasLoggerAware ? null : KosLoggerFactory.create({
|
|
3361
|
+
modelTypeName: TargetClass.prototype.modelTypeId
|
|
3320
3362
|
});
|
|
3321
3363
|
const modelInstance = new TargetClass(modelId, initialData, {
|
|
3322
3364
|
logger,
|
|
@@ -3347,8 +3389,8 @@ function kosModel(config2) {
|
|
|
3347
3389
|
typedCtor.prototype[OptionsRequired] = true;
|
|
3348
3390
|
}
|
|
3349
3391
|
KosLog.ifDebug(() => {
|
|
3350
|
-
|
|
3351
|
-
});
|
|
3392
|
+
log$14.debug(`Registering model with id ${modelConfig.modelTypeId}`);
|
|
3393
|
+
}, log$14);
|
|
3352
3394
|
const proxiedCtor = new Proxy(typedCtor, modelConstructorProxy);
|
|
3353
3395
|
if (modelConfig.singleton !== void 0) {
|
|
3354
3396
|
let registration;
|
|
@@ -3644,7 +3686,10 @@ const KosDeletionManager = {
|
|
|
3644
3686
|
}
|
|
3645
3687
|
}
|
|
3646
3688
|
};
|
|
3647
|
-
const log$
|
|
3689
|
+
const log$13 = KosLog.createLogger({
|
|
3690
|
+
group: LogGroup.core,
|
|
3691
|
+
name: "kos-dependency-manager"
|
|
3692
|
+
});
|
|
3648
3693
|
class KosDependencyManager {
|
|
3649
3694
|
_usedByCache = /* @__PURE__ */ new Map();
|
|
3650
3695
|
_usesCache = /* @__PURE__ */ new Map();
|
|
@@ -3699,7 +3744,7 @@ class KosDependencyManager {
|
|
|
3699
3744
|
canDestroy(modelId) {
|
|
3700
3745
|
const usedBy = this._usedByCache.get(modelId);
|
|
3701
3746
|
if (usedBy?.length) {
|
|
3702
|
-
log$
|
|
3747
|
+
log$13.info(`Model ${modelId} is still used by: ${usedBy.join(", ")}`);
|
|
3703
3748
|
return false;
|
|
3704
3749
|
}
|
|
3705
3750
|
return true;
|
|
@@ -3709,7 +3754,10 @@ class KosDependencyManager {
|
|
|
3709
3754
|
this._usesCache.clear();
|
|
3710
3755
|
}
|
|
3711
3756
|
}
|
|
3712
|
-
const log$
|
|
3757
|
+
const log$12 = KosLog.createLogger({
|
|
3758
|
+
group: LogGroup.core,
|
|
3759
|
+
name: "kos-model-cache"
|
|
3760
|
+
});
|
|
3713
3761
|
class KosModelCache {
|
|
3714
3762
|
constructor(preloadKeys = []) {
|
|
3715
3763
|
this.preloadKeys = preloadKeys;
|
|
@@ -3760,11 +3808,11 @@ class KosModelCache {
|
|
|
3760
3808
|
}
|
|
3761
3809
|
preload(createFn) {
|
|
3762
3810
|
if (this._isPreloaded) {
|
|
3763
|
-
log$
|
|
3811
|
+
log$12.debug("Returning cached preloaded models");
|
|
3764
3812
|
return this._preloaded;
|
|
3765
3813
|
}
|
|
3766
3814
|
this._preloaded = this.preloadKeys.map((key) => {
|
|
3767
|
-
log$
|
|
3815
|
+
log$12.debug(
|
|
3768
3816
|
`Preloading model: ${typeof key === "string" ? key : key.modelType}`
|
|
3769
3817
|
);
|
|
3770
3818
|
return createFn(key);
|
|
@@ -3786,6 +3834,10 @@ const clearModelHookCacheEntry = (modelId) => {
|
|
|
3786
3834
|
cache.delete(modelId);
|
|
3787
3835
|
}
|
|
3788
3836
|
};
|
|
3837
|
+
const log$11 = KosLog.createLogger({
|
|
3838
|
+
group: LogGroup.core,
|
|
3839
|
+
name: "model-error-utils"
|
|
3840
|
+
});
|
|
3789
3841
|
class KosModelError extends Error {
|
|
3790
3842
|
context;
|
|
3791
3843
|
originalCause;
|
|
@@ -3847,10 +3899,10 @@ function enrichError(error, context) {
|
|
|
3847
3899
|
}
|
|
3848
3900
|
function logErrorCollection(errors, summary) {
|
|
3849
3901
|
if (errors.length === 0) return;
|
|
3850
|
-
|
|
3902
|
+
log$11.error(`${summary} - ${errors.length} error(s) occurred:`);
|
|
3851
3903
|
errors.forEach(({ error, context }, index) => {
|
|
3852
3904
|
const enriched = error instanceof KosModelError ? error : enrichError(error, context);
|
|
3853
|
-
|
|
3905
|
+
log$11.error(
|
|
3854
3906
|
` [${index + 1}/${errors.length}] ${enriched.toDetailedString()}`
|
|
3855
3907
|
);
|
|
3856
3908
|
});
|
|
@@ -3866,7 +3918,10 @@ function logModelInstantiationError(error, context) {
|
|
|
3866
3918
|
});
|
|
3867
3919
|
}
|
|
3868
3920
|
const isKosCompanionTypeFactory = (obj) => typeof obj === "function";
|
|
3869
|
-
const log$
|
|
3921
|
+
const log$10 = KosLog.createLogger({
|
|
3922
|
+
group: LogGroup.core,
|
|
3923
|
+
name: "kos-companion-instantiator"
|
|
3924
|
+
});
|
|
3870
3925
|
class KosCompanionInstantiator {
|
|
3871
3926
|
constructor(registry, cache2, createModel) {
|
|
3872
3927
|
this.registry = registry;
|
|
@@ -3888,7 +3943,7 @@ class KosCompanionInstantiator {
|
|
|
3888
3943
|
createCompanionModels(model, options, lifecycle) {
|
|
3889
3944
|
const companionDefs = this.getCompanionDefinitions(model.modelTypeName);
|
|
3890
3945
|
if (lifecycle !== void 0) {
|
|
3891
|
-
log$
|
|
3946
|
+
log$10.debug(
|
|
3892
3947
|
`Creating ${lifecycle} lifecycle companions for ${model.modelTypeName} [${model.modelId}]`
|
|
3893
3948
|
);
|
|
3894
3949
|
}
|
|
@@ -3940,7 +3995,7 @@ class KosCompanionInstantiator {
|
|
|
3940
3995
|
mobx.runInAction(() => {
|
|
3941
3996
|
model.modelData[property] = mixin.modelData;
|
|
3942
3997
|
});
|
|
3943
|
-
log$
|
|
3998
|
+
log$10.debug(
|
|
3944
3999
|
`Created mixin ${registration.type} for ${model.modelTypeName} [${model.modelId}]`
|
|
3945
4000
|
);
|
|
3946
4001
|
});
|
|
@@ -3972,7 +4027,7 @@ class KosCompanionInstantiator {
|
|
|
3972
4027
|
resolveFactoryCompanion(companionDef, model, options, requestedLifecycle) {
|
|
3973
4028
|
const companionType = companionDef.type(model.modelData, options);
|
|
3974
4029
|
if (!companionType) {
|
|
3975
|
-
log$
|
|
4030
|
+
log$10.debug(
|
|
3976
4031
|
`Companion factory returned undefined for ${model.modelTypeName} at ${requestedLifecycle || "INIT"} phase`
|
|
3977
4032
|
);
|
|
3978
4033
|
return null;
|
|
@@ -4031,7 +4086,7 @@ class KosCompanionInstantiator {
|
|
|
4031
4086
|
);
|
|
4032
4087
|
if (companion) {
|
|
4033
4088
|
this.attachCompanionToParent(companion, parentModel);
|
|
4034
|
-
log$
|
|
4089
|
+
log$10.debug(
|
|
4035
4090
|
`Created ${lifecycle || "INIT"} companion ${companionType} for ${parentModel.modelTypeName} [${parentModel.modelId}]`
|
|
4036
4091
|
);
|
|
4037
4092
|
}
|
|
@@ -4047,7 +4102,7 @@ class KosCompanionInstantiator {
|
|
|
4047
4102
|
*/
|
|
4048
4103
|
companionAlreadyExists(companionId, companionType, parentTypeName) {
|
|
4049
4104
|
if (this.cache.hasModel(companionId)) {
|
|
4050
|
-
log$
|
|
4105
|
+
log$10.debug(
|
|
4051
4106
|
`Companion ${companionType} already exists for ${parentTypeName}`
|
|
4052
4107
|
);
|
|
4053
4108
|
return true;
|
|
@@ -4132,6 +4187,10 @@ const TransitionMap = {
|
|
|
4132
4187
|
/* INIT */
|
|
4133
4188
|
]: transitionToInit
|
|
4134
4189
|
};
|
|
4190
|
+
const log$$ = KosLog.createLogger({
|
|
4191
|
+
group: LogGroup.core,
|
|
4192
|
+
name: "promise-utils"
|
|
4193
|
+
});
|
|
4135
4194
|
class ModelError extends Error {
|
|
4136
4195
|
model;
|
|
4137
4196
|
constructor(message, model) {
|
|
@@ -4143,7 +4202,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4143
4202
|
let timeoutId;
|
|
4144
4203
|
const promise = new Promise((_, reject) => {
|
|
4145
4204
|
timeoutId = setTimeout(() => {
|
|
4146
|
-
|
|
4205
|
+
log$$.error(
|
|
4147
4206
|
`Model ${model.modelId} - ${model.modelTypeName} - ${status} timed out after ${ms}ms`
|
|
4148
4207
|
);
|
|
4149
4208
|
reject(
|
|
@@ -4159,6 +4218,7 @@ const rejectAfterDelay$1 = (ms, model, status) => {
|
|
|
4159
4218
|
};
|
|
4160
4219
|
return { promise, cancel };
|
|
4161
4220
|
};
|
|
4221
|
+
const log$_ = KosLog.createLogger({ group: LogGroup.core, name: "model-utils" });
|
|
4162
4222
|
const createModelDependency = (model, dependency) => {
|
|
4163
4223
|
const _dataModelId = dependency.id || dependency.modelType;
|
|
4164
4224
|
const dataModelId = resolveParameters({
|
|
@@ -4167,7 +4227,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4167
4227
|
modelId: model.modelId
|
|
4168
4228
|
});
|
|
4169
4229
|
const resolutionPolicy = dependency.resolutionPolicy || DependencyResolutionPolicy.CREATE;
|
|
4170
|
-
|
|
4230
|
+
log$_.debug(
|
|
4171
4231
|
`Resolving dependent model ${dependency.modelType} with id ${dataModelId} (policy: ${resolutionPolicy})`
|
|
4172
4232
|
);
|
|
4173
4233
|
const options = Object.keys(dependency?.options || {}).reduce((acc, curr) => {
|
|
@@ -4183,7 +4243,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4183
4243
|
const modelRegistry = modelManager.registry.models[dependency.modelType];
|
|
4184
4244
|
if (!modelRegistry) {
|
|
4185
4245
|
const errorMessage = `No model registered for type ${dependency.modelType}`;
|
|
4186
|
-
|
|
4246
|
+
log$_.error(
|
|
4187
4247
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4188
4248
|
- Dependency Type: ${dependency.modelType}
|
|
4189
4249
|
- Dependency ID: ${dataModelId}
|
|
@@ -4193,7 +4253,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4193
4253
|
- Error: ${errorMessage}`
|
|
4194
4254
|
);
|
|
4195
4255
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4196
|
-
|
|
4256
|
+
log$_.warn(
|
|
4197
4257
|
`Model type not registered (policy: CONTINUE) - Model ${model.modelId} will continue without dependency ${dependency.modelType} [${dataModelId}]`
|
|
4198
4258
|
);
|
|
4199
4259
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4206,7 +4266,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4206
4266
|
if (existingModel) {
|
|
4207
4267
|
if (existingModel.modelTypeName !== dependency.modelType) {
|
|
4208
4268
|
const errorMessage = `Model type mismatch: expected ${dependency.modelType}, found ${existingModel.modelTypeName}`;
|
|
4209
|
-
|
|
4269
|
+
log$_.error(
|
|
4210
4270
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4211
4271
|
- Dependency Type: ${dependency.modelType}
|
|
4212
4272
|
- Dependency ID: ${dataModelId}
|
|
@@ -4217,7 +4277,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4217
4277
|
- Error: ${errorMessage}`
|
|
4218
4278
|
);
|
|
4219
4279
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4220
|
-
|
|
4280
|
+
log$_.warn(
|
|
4221
4281
|
`Model type mismatch (policy: CONTINUE) - Model ${model.modelId} will continue without dependency`
|
|
4222
4282
|
);
|
|
4223
4283
|
return { dependentModel: null, dataModelId, success: false };
|
|
@@ -4226,7 +4286,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4226
4286
|
`Dependency resolution failed - Model ${model.modelId} cannot resolve dependency ${dependency.modelType} [${dataModelId}]: ${errorMessage}`
|
|
4227
4287
|
);
|
|
4228
4288
|
}
|
|
4229
|
-
|
|
4289
|
+
log$_.debug(
|
|
4230
4290
|
`Found existing dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4231
4291
|
);
|
|
4232
4292
|
return {
|
|
@@ -4235,18 +4295,18 @@ const createModelDependency = (model, dependency) => {
|
|
|
4235
4295
|
success: true
|
|
4236
4296
|
};
|
|
4237
4297
|
}
|
|
4238
|
-
|
|
4298
|
+
log$_.debug(
|
|
4239
4299
|
`Model ${dependency.modelType} [${dataModelId}] does not exist. Applying resolution policy: ${resolutionPolicy}`
|
|
4240
4300
|
);
|
|
4241
4301
|
if (resolutionPolicy === DependencyResolutionPolicy.CONTINUE) {
|
|
4242
|
-
|
|
4302
|
+
log$_.warn(
|
|
4243
4303
|
`Model ${dependency.modelType} [${dataModelId}] not found (policy: CONTINUE) - Model ${model.modelId} will continue without this dependency`
|
|
4244
4304
|
);
|
|
4245
4305
|
return { dependentModel: null, dataModelId, success: false };
|
|
4246
4306
|
}
|
|
4247
4307
|
if (resolutionPolicy === DependencyResolutionPolicy.FAIL) {
|
|
4248
4308
|
const errorMessage = `No ${dependency.modelType} model with id ${dataModelId} exists`;
|
|
4249
|
-
|
|
4309
|
+
log$_.error(
|
|
4250
4310
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4251
4311
|
- Dependency Type: ${dependency.modelType}
|
|
4252
4312
|
- Dependency ID: ${dataModelId}
|
|
@@ -4264,7 +4324,7 @@ const createModelDependency = (model, dependency) => {
|
|
|
4264
4324
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
4265
4325
|
if (requiresOptions && !hasOptions) {
|
|
4266
4326
|
const errorMessage = `Model ${dependency.modelType} requires options but none were provided`;
|
|
4267
|
-
|
|
4327
|
+
log$_.error(
|
|
4268
4328
|
`Failed to resolve dependency for model ${model.modelId}:
|
|
4269
4329
|
- Dependency Type: ${dependency.modelType}
|
|
4270
4330
|
- Dependency ID: ${dataModelId}
|
|
@@ -4285,13 +4345,13 @@ const createModelDependency = (model, dependency) => {
|
|
|
4285
4345
|
dataModelId,
|
|
4286
4346
|
options
|
|
4287
4347
|
);
|
|
4288
|
-
|
|
4348
|
+
log$_.debug(
|
|
4289
4349
|
`Successfully created dependent model ${dependency.modelType} with id ${dataModelId}`
|
|
4290
4350
|
);
|
|
4291
4351
|
return { dependentModel, dataModelId, success: true };
|
|
4292
4352
|
} catch (error) {
|
|
4293
4353
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4294
|
-
|
|
4354
|
+
log$_.error(
|
|
4295
4355
|
`Failed to create dependency for model ${model.modelId}:
|
|
4296
4356
|
- Dependency Type: ${dependency.modelType}
|
|
4297
4357
|
- Dependency ID: ${dataModelId}
|
|
@@ -4307,14 +4367,14 @@ const createModelDependency = (model, dependency) => {
|
|
|
4307
4367
|
const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY) => {
|
|
4308
4368
|
const dependencies = model.modelData?.[DependencyModels] || {};
|
|
4309
4369
|
if (Object.keys(dependencies).length === 0) {
|
|
4310
|
-
|
|
4370
|
+
log$_.debug(`${model.modelId} has no dependencies. Returning`);
|
|
4311
4371
|
return [];
|
|
4312
4372
|
}
|
|
4313
4373
|
const dependenciesByLifecycle = Object.keys(dependencies).filter((key) => dependencies[key].lifecycle === lifecycle).map((key) => {
|
|
4314
4374
|
const dependency = dependencies[key];
|
|
4315
4375
|
const resolutionResult = createModelDependency(model, dependency);
|
|
4316
4376
|
if (!resolutionResult.success || !resolutionResult.dependentModel) {
|
|
4317
|
-
|
|
4377
|
+
log$_.debug(
|
|
4318
4378
|
`Skipping dependency ${dependency.modelType} with id ${resolutionResult.dataModelId} - resolution failed with CONTINUE policy`
|
|
4319
4379
|
);
|
|
4320
4380
|
model.modelData[key] = void 0;
|
|
@@ -4322,12 +4382,12 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4322
4382
|
}
|
|
4323
4383
|
const { dependentModel, dataModelId } = resolutionResult;
|
|
4324
4384
|
model.modelData[key] = dependentModel.data;
|
|
4325
|
-
|
|
4385
|
+
log$_.debug(
|
|
4326
4386
|
`waiting for dependent model ${dependency.modelType} with id ${dataModelId} - waiting for WHENREADY`
|
|
4327
4387
|
);
|
|
4328
4388
|
const readyFn = async (dependentModel2, modelType, id) => {
|
|
4329
4389
|
await dependentModel2.whenReady?.();
|
|
4330
|
-
|
|
4390
|
+
log$_.debug(`dependent model ${modelType} with id ${id} - READY`);
|
|
4331
4391
|
};
|
|
4332
4392
|
const { promise, cancel } = rejectAfterDelay$1(
|
|
4333
4393
|
MODEL_PROMISE_TIMEOUT_MS,
|
|
@@ -4348,7 +4408,7 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4348
4408
|
lifecycle,
|
|
4349
4409
|
operation: "dependency whenReady()"
|
|
4350
4410
|
});
|
|
4351
|
-
|
|
4411
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4352
4412
|
cancel();
|
|
4353
4413
|
throw enrichedError;
|
|
4354
4414
|
}),
|
|
@@ -4358,13 +4418,13 @@ const getDependenciesByLifecycle = (model, lifecycle = DependencyLifecycle.READY
|
|
|
4358
4418
|
return dependenciesByLifecycle;
|
|
4359
4419
|
};
|
|
4360
4420
|
const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycle) => {
|
|
4361
|
-
|
|
4421
|
+
log$_.debug(`Execute lifecycle with ${models2.length} models`);
|
|
4362
4422
|
if (models2.length === 0) {
|
|
4363
|
-
|
|
4423
|
+
log$_.debug(`${sourceModel.modelId} has no children. Returning`);
|
|
4364
4424
|
return;
|
|
4365
4425
|
}
|
|
4366
4426
|
if (!target) {
|
|
4367
|
-
|
|
4427
|
+
log$_.error(
|
|
4368
4428
|
`${sourceModel.modelId} is not transitioning with a valid target ${target}`
|
|
4369
4429
|
);
|
|
4370
4430
|
return;
|
|
@@ -4375,12 +4435,10 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4375
4435
|
p = TransitionMap[target](model);
|
|
4376
4436
|
} else {
|
|
4377
4437
|
if (!model) {
|
|
4378
|
-
|
|
4438
|
+
log$_.error("model is undefined. This shouldn't happen");
|
|
4379
4439
|
}
|
|
4380
4440
|
if (!TransitionMap[target]) {
|
|
4381
|
-
|
|
4382
|
-
`There is no promise in the Transition Map for ${target}`
|
|
4383
|
-
);
|
|
4441
|
+
log$_.error(`There is no promise in the Transition Map for ${target}`);
|
|
4384
4442
|
}
|
|
4385
4443
|
}
|
|
4386
4444
|
return {
|
|
@@ -4392,11 +4450,11 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4392
4450
|
};
|
|
4393
4451
|
}).filter((modelPromise) => {
|
|
4394
4452
|
if (!modelPromise.promise) {
|
|
4395
|
-
|
|
4453
|
+
log$_.error(`No promise found ${modelPromise.modelId}`);
|
|
4396
4454
|
return false;
|
|
4397
4455
|
}
|
|
4398
4456
|
if (!modelPromise.model) {
|
|
4399
|
-
|
|
4457
|
+
log$_.error(`No model found ${modelPromise.modelId}`);
|
|
4400
4458
|
return false;
|
|
4401
4459
|
}
|
|
4402
4460
|
return true;
|
|
@@ -4425,7 +4483,7 @@ const executeListLifecycle = async (sourceModel, models2, target, sourceLifecycl
|
|
|
4425
4483
|
lifecycle: sourceLifecycle,
|
|
4426
4484
|
operation: `transition to ${target}`
|
|
4427
4485
|
});
|
|
4428
|
-
|
|
4486
|
+
log$_.error(enrichedError.toDetailedString());
|
|
4429
4487
|
timeoutCancel();
|
|
4430
4488
|
throw enrichedError;
|
|
4431
4489
|
}),
|
|
@@ -4471,10 +4529,10 @@ const executeDependentModelLifecycle = async (model, lifecycle) => {
|
|
|
4471
4529
|
);
|
|
4472
4530
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
4473
4531
|
if (failed.length) {
|
|
4474
|
-
|
|
4532
|
+
log$_.error(
|
|
4475
4533
|
`There were ${failed.length} failed dependent models on ${lifecycle}`
|
|
4476
4534
|
);
|
|
4477
|
-
|
|
4535
|
+
log$_.error(failed);
|
|
4478
4536
|
}
|
|
4479
4537
|
};
|
|
4480
4538
|
function applyKosModelDevtoolsSupport(model) {
|
|
@@ -4738,7 +4796,10 @@ class KosEffectManager {
|
|
|
4738
4796
|
this.disposers = [];
|
|
4739
4797
|
}
|
|
4740
4798
|
}
|
|
4741
|
-
const log$
|
|
4799
|
+
const log$Z = KosLog.createLogger({
|
|
4800
|
+
group: LogGroup.core,
|
|
4801
|
+
name: "model-active-machine"
|
|
4802
|
+
});
|
|
4742
4803
|
const activeMachine = (model) => {
|
|
4743
4804
|
const machine2 = robot3.createMachine(KosModelState.INACTIVE, {
|
|
4744
4805
|
[KosModelState.FAILED]: robot3.state(
|
|
@@ -4793,11 +4854,14 @@ const activeMachine = (model) => {
|
|
|
4793
4854
|
});
|
|
4794
4855
|
const service2 = robot3.interpret(
|
|
4795
4856
|
machine2,
|
|
4796
|
-
(_service) => log$
|
|
4857
|
+
(_service) => log$Z.debug(_service.machine.current)
|
|
4797
4858
|
);
|
|
4798
4859
|
return { service: service2, machine: machine2 };
|
|
4799
4860
|
};
|
|
4800
|
-
const log$
|
|
4861
|
+
const log$Y = KosLog.createLogger({
|
|
4862
|
+
group: LogGroup.core,
|
|
4863
|
+
name: "model-online-machine"
|
|
4864
|
+
});
|
|
4801
4865
|
const onlineMachine = (model) => {
|
|
4802
4866
|
const machine2 = robot3.createMachine(KosModelState.OFFLINE, {
|
|
4803
4867
|
[KosModelState.ONLINE]: robot3.state(
|
|
@@ -4815,7 +4879,7 @@ const onlineMachine = (model) => {
|
|
|
4815
4879
|
KosModelEvents.GO_ONLINE,
|
|
4816
4880
|
KosModelState.ONLINE,
|
|
4817
4881
|
robot3.action(async () => {
|
|
4818
|
-
log$
|
|
4882
|
+
log$Y.debug(`Going online with model ${model.modelId}`);
|
|
4819
4883
|
await model.online();
|
|
4820
4884
|
model.onlineStatus = KosModelState.ONLINE;
|
|
4821
4885
|
await model.fsm.transitionTo(
|
|
@@ -4828,10 +4892,14 @@ const onlineMachine = (model) => {
|
|
|
4828
4892
|
});
|
|
4829
4893
|
const service2 = robot3.interpret(
|
|
4830
4894
|
machine2,
|
|
4831
|
-
(_service) => log$
|
|
4895
|
+
(_service) => log$Y.debug(_service.machine.current)
|
|
4832
4896
|
);
|
|
4833
4897
|
return { machine: machine2, service: service2 };
|
|
4834
4898
|
};
|
|
4899
|
+
const log$X = KosLog.createLogger({
|
|
4900
|
+
group: LogGroup.core,
|
|
4901
|
+
name: "model-machine"
|
|
4902
|
+
});
|
|
4835
4903
|
const machine = (model) => {
|
|
4836
4904
|
const active = activeMachine(model).service;
|
|
4837
4905
|
const online = onlineMachine(model).service;
|
|
@@ -4866,7 +4934,7 @@ const machine = (model) => {
|
|
|
4866
4934
|
`error`,
|
|
4867
4935
|
KosModelState.FAILED,
|
|
4868
4936
|
robot3.action(() => {
|
|
4869
|
-
|
|
4937
|
+
log$X.error(
|
|
4870
4938
|
`Model ${model.modelId} - ${model.modelTypeName} failed to initialize. Transitioning to FAILED state.`
|
|
4871
4939
|
);
|
|
4872
4940
|
model.status = KosModelState.FAILED;
|
|
@@ -4988,7 +5056,7 @@ const machine = (model) => {
|
|
|
4988
5056
|
`error`,
|
|
4989
5057
|
KosModelState.REATTACHING,
|
|
4990
5058
|
robot3.action((_ctx, event) => {
|
|
4991
|
-
|
|
5059
|
+
log$X.error(
|
|
4992
5060
|
`Model ${model.modelId} - ${model.modelTypeName} failed to reload; its data stays as it was. ${String(
|
|
4993
5061
|
event?.error
|
|
4994
5062
|
)}`
|
|
@@ -5025,11 +5093,14 @@ const machine = (model) => {
|
|
|
5025
5093
|
[KosModelState.FAILED]: robot3.state()
|
|
5026
5094
|
});
|
|
5027
5095
|
};
|
|
5028
|
-
const log$
|
|
5096
|
+
const log$W = KosLog.createLogger({
|
|
5097
|
+
group: LogGroup.core,
|
|
5098
|
+
name: "kos-model-lifecycle"
|
|
5099
|
+
});
|
|
5029
5100
|
const fsm = (model) => {
|
|
5030
5101
|
const service2 = robot3.interpret(
|
|
5031
5102
|
machine(model),
|
|
5032
|
-
(_service) => log$
|
|
5103
|
+
(_service) => log$W.debug(
|
|
5033
5104
|
`state machine for model ${model.modelId}: ${_service.machine.current});`
|
|
5034
5105
|
)
|
|
5035
5106
|
);
|
|
@@ -5631,6 +5702,10 @@ async function processRequestBody(body) {
|
|
|
5631
5702
|
}
|
|
5632
5703
|
throw new Error("Unsupported body type");
|
|
5633
5704
|
}
|
|
5705
|
+
const log$V = KosLog.createLogger({
|
|
5706
|
+
group: LogGroup.transport,
|
|
5707
|
+
name: "kos-message-utils"
|
|
5708
|
+
});
|
|
5634
5709
|
const createStudioMessage = ({
|
|
5635
5710
|
path,
|
|
5636
5711
|
requestId,
|
|
@@ -5844,10 +5919,10 @@ const sendKosMessage = (msg, options) => {
|
|
|
5844
5919
|
);
|
|
5845
5920
|
const socketTransport = KosCore.getInstance().transport.socket;
|
|
5846
5921
|
if (socketTransport) {
|
|
5847
|
-
|
|
5922
|
+
log$V.debug("Sending message", _msg);
|
|
5848
5923
|
socketTransport.socket.send(_msg);
|
|
5849
5924
|
} else {
|
|
5850
|
-
|
|
5925
|
+
log$V.error("socket transport is not initialized");
|
|
5851
5926
|
}
|
|
5852
5927
|
};
|
|
5853
5928
|
const createStudioMessageResponse = ({
|
|
@@ -5882,7 +5957,7 @@ const sendStudioMessageRequest = (msg, options) => {
|
|
|
5882
5957
|
if (socketTransport) {
|
|
5883
5958
|
socketTransport.socket.send(_msg);
|
|
5884
5959
|
} else {
|
|
5885
|
-
|
|
5960
|
+
log$V.error("socket transport is not initialized");
|
|
5886
5961
|
}
|
|
5887
5962
|
};
|
|
5888
5963
|
const sendStudioMessage = (msg, options) => {
|
|
@@ -5895,7 +5970,7 @@ const sendStudioMessage = (msg, options) => {
|
|
|
5895
5970
|
if (socketTransport) {
|
|
5896
5971
|
socketTransport.socket.send(_msg);
|
|
5897
5972
|
} else {
|
|
5898
|
-
|
|
5973
|
+
log$V.error("socket transport is not initialized");
|
|
5899
5974
|
}
|
|
5900
5975
|
};
|
|
5901
5976
|
const createBroadcastMessageResponse = ({
|
|
@@ -5965,7 +6040,7 @@ const sendBroadcastMessage = ({
|
|
|
5965
6040
|
if (socketTransport) {
|
|
5966
6041
|
socketTransport.socket.send(_msg);
|
|
5967
6042
|
} else {
|
|
5968
|
-
|
|
6043
|
+
log$V.error("socket transport is not initialized");
|
|
5969
6044
|
}
|
|
5970
6045
|
};
|
|
5971
6046
|
const sendKosMessageResponse = ({
|
|
@@ -5981,7 +6056,7 @@ const sendKosMessageResponse = ({
|
|
|
5981
6056
|
if (socketTransport) {
|
|
5982
6057
|
socketTransport.socket.send(_msg);
|
|
5983
6058
|
} else {
|
|
5984
|
-
|
|
6059
|
+
log$V.error("socket transport is not initialized");
|
|
5985
6060
|
}
|
|
5986
6061
|
};
|
|
5987
6062
|
const sendKosHttpMessageResponse = ({
|
|
@@ -5997,7 +6072,7 @@ const sendKosHttpMessageResponse = ({
|
|
|
5997
6072
|
if (socketTransport) {
|
|
5998
6073
|
socketTransport.socket.send(_msg);
|
|
5999
6074
|
} else {
|
|
6000
|
-
|
|
6075
|
+
log$V.error("socket transport is not initialized");
|
|
6001
6076
|
}
|
|
6002
6077
|
};
|
|
6003
6078
|
const getMessageBody = (payload, skipParse) => {
|
|
@@ -6029,7 +6104,10 @@ class TransportNotReadyError extends Error {
|
|
|
6029
6104
|
}
|
|
6030
6105
|
}
|
|
6031
6106
|
const isTransportNotReadyError = (error) => !!error && error.code === TRANSPORT_NOT_READY;
|
|
6032
|
-
const log$
|
|
6107
|
+
const log$U = KosLog.createLogger({
|
|
6108
|
+
group: LogGroup.transport,
|
|
6109
|
+
name: "kos-fetch"
|
|
6110
|
+
});
|
|
6033
6111
|
const DEFAULT_WS_TIMEOUT = 3e4;
|
|
6034
6112
|
const WS_TIMEOUT = (() => {
|
|
6035
6113
|
const configured = process.env.KOS_WS_TIMEOUT ? parseInt(process.env.KOS_WS_TIMEOUT) : DEFAULT_WS_TIMEOUT;
|
|
@@ -6094,7 +6172,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6094
6172
|
const requestId = uuid();
|
|
6095
6173
|
const urlObj = new URL(url);
|
|
6096
6174
|
const path = `${urlObj.pathname}${urlObj.search}`;
|
|
6097
|
-
log$
|
|
6175
|
+
log$U.debug(`path: ${path}`);
|
|
6098
6176
|
const budget = resolveTimeoutBudget(options?.timeout);
|
|
6099
6177
|
const messageFactory = fetchMessageFactory(options);
|
|
6100
6178
|
const signal = createRequestSignal(budget, options?.signal);
|
|
@@ -6102,12 +6180,12 @@ const kosFetchWs = async (url, options) => {
|
|
|
6102
6180
|
await transport.whenReady({ signal });
|
|
6103
6181
|
} catch (error) {
|
|
6104
6182
|
if (isTimeoutReason(error)) {
|
|
6105
|
-
log$
|
|
6183
|
+
log$U.error(
|
|
6106
6184
|
`Transport not ready${budget === void 0 ? "" : ` after ${budget}ms`} - request not sent - url: ${url}`
|
|
6107
6185
|
);
|
|
6108
6186
|
throw new TransportNotReadyError({ timeout: budget, url });
|
|
6109
6187
|
}
|
|
6110
|
-
log$
|
|
6188
|
+
log$U.debug(`Request aborted while waiting for transport - url: ${url}`);
|
|
6111
6189
|
throw error;
|
|
6112
6190
|
}
|
|
6113
6191
|
const processedBody = await processRequestBody(options?.body);
|
|
@@ -6136,9 +6214,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6136
6214
|
if (signal.aborted) {
|
|
6137
6215
|
const reason = signal.reason;
|
|
6138
6216
|
if (reason?.name === "TimeoutError") {
|
|
6139
|
-
log$
|
|
6217
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6140
6218
|
} else {
|
|
6141
|
-
log$
|
|
6219
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6142
6220
|
}
|
|
6143
6221
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6144
6222
|
return;
|
|
@@ -6147,9 +6225,9 @@ const kosFetchWs = async (url, options) => {
|
|
|
6147
6225
|
if (unsubscribe) unsubscribe();
|
|
6148
6226
|
const reason = signal.reason;
|
|
6149
6227
|
if (reason?.name === "TimeoutError") {
|
|
6150
|
-
log$
|
|
6228
|
+
log$U.error(`Timeout occurred - url: ${url}`);
|
|
6151
6229
|
} else {
|
|
6152
|
-
log$
|
|
6230
|
+
log$U.debug(`Request aborted - url: ${url}`);
|
|
6153
6231
|
}
|
|
6154
6232
|
reject(reason || new DOMException("Aborted", "AbortError"));
|
|
6155
6233
|
};
|
|
@@ -6165,7 +6243,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6165
6243
|
try {
|
|
6166
6244
|
bodyData = base64ToArrayBuffer(responseBody);
|
|
6167
6245
|
} catch (e) {
|
|
6168
|
-
log$
|
|
6246
|
+
log$U.error("Failed to decode base64 response", e);
|
|
6169
6247
|
}
|
|
6170
6248
|
}
|
|
6171
6249
|
const response = {
|
|
@@ -6219,7 +6297,7 @@ const kosFetchWs = async (url, options) => {
|
|
|
6219
6297
|
});
|
|
6220
6298
|
}
|
|
6221
6299
|
if (parsed.files) {
|
|
6222
|
-
log$
|
|
6300
|
+
log$U.warn(
|
|
6223
6301
|
"File reconstruction in FormData not fully implemented"
|
|
6224
6302
|
);
|
|
6225
6303
|
}
|
|
@@ -6270,7 +6348,10 @@ const resolveBaseUrl = () => {
|
|
|
6270
6348
|
const URL2 = exports.BASE_URL;
|
|
6271
6349
|
return { isMock: MOCK, URL: URL2 };
|
|
6272
6350
|
};
|
|
6273
|
-
const log$
|
|
6351
|
+
const log$T = KosLog.createLogger({
|
|
6352
|
+
group: LogGroup.transport,
|
|
6353
|
+
name: "kos-service-request"
|
|
6354
|
+
});
|
|
6274
6355
|
const ERROR_UNKNOWN = "errUnknown";
|
|
6275
6356
|
const ERROR_TRANSPORT_NOT_READY = "Transport not ready";
|
|
6276
6357
|
const MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
@@ -6296,7 +6377,7 @@ async function clientRequest(endpoint, method, options, params2, body) {
|
|
|
6296
6377
|
)}`
|
|
6297
6378
|
).join("&") : "";
|
|
6298
6379
|
const fullUrl = `${resolveBaseUrl().URL}${url}${query ? `?${query}` : ""}`;
|
|
6299
|
-
log$
|
|
6380
|
+
log$T.debug(`fullUrl: ${fullUrl}`);
|
|
6300
6381
|
const fetchOptions = {
|
|
6301
6382
|
method: String(method).toUpperCase(),
|
|
6302
6383
|
body: null,
|
|
@@ -6330,20 +6411,20 @@ async function executeFetch(fullUrl, fetchOptions) {
|
|
|
6330
6411
|
return [null, payload.data ?? payload, responseContext(response)];
|
|
6331
6412
|
} catch (error) {
|
|
6332
6413
|
if (isTransportNotReadyError(error)) {
|
|
6333
|
-
log$
|
|
6414
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6334
6415
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6335
6416
|
}
|
|
6336
6417
|
if (error instanceof DOMException) {
|
|
6337
6418
|
if (error.name === "TimeoutError") {
|
|
6338
|
-
log$
|
|
6419
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6339
6420
|
return ["Request timed out", null];
|
|
6340
6421
|
}
|
|
6341
6422
|
if (error.name === "AbortError") {
|
|
6342
|
-
log$
|
|
6423
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6343
6424
|
return ["Request aborted", null];
|
|
6344
6425
|
}
|
|
6345
6426
|
}
|
|
6346
|
-
log$
|
|
6427
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6347
6428
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6348
6429
|
}
|
|
6349
6430
|
}
|
|
@@ -6363,38 +6444,38 @@ async function executeFetchWithRetry(fullUrl, fetchOptions, config2) {
|
|
|
6363
6444
|
errorContext
|
|
6364
6445
|
];
|
|
6365
6446
|
if (config2.retryOn && !config2.retryOn(response)) {
|
|
6366
|
-
log$
|
|
6447
|
+
log$T.debug(
|
|
6367
6448
|
`Retry predicate returned false for ${fullUrl} (status ${response.status}), stopping`
|
|
6368
6449
|
);
|
|
6369
6450
|
return lastResult;
|
|
6370
6451
|
}
|
|
6371
6452
|
if (attempt < config2.maxAttempts) {
|
|
6372
6453
|
const delayMs = config2.baseDelayMs * Math.pow(config2.backoffFactor, attempt - 1);
|
|
6373
|
-
log$
|
|
6454
|
+
log$T.warn(
|
|
6374
6455
|
`Request to ${fullUrl} failed (status ${response.status}), retrying in ${delayMs}ms (attempt ${attempt}/${config2.maxAttempts})`
|
|
6375
6456
|
);
|
|
6376
6457
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
6377
6458
|
}
|
|
6378
6459
|
} catch (error) {
|
|
6379
6460
|
if (isTransportNotReadyError(error)) {
|
|
6380
|
-
log$
|
|
6461
|
+
log$T.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6381
6462
|
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6382
6463
|
}
|
|
6383
6464
|
if (error instanceof DOMException) {
|
|
6384
6465
|
if (error.name === "TimeoutError") {
|
|
6385
|
-
log$
|
|
6466
|
+
log$T.error(`Request timed out: ${fullUrl}`);
|
|
6386
6467
|
return ["Request timed out", null];
|
|
6387
6468
|
}
|
|
6388
6469
|
if (error.name === "AbortError") {
|
|
6389
|
-
log$
|
|
6470
|
+
log$T.debug(`Request aborted: ${fullUrl}`);
|
|
6390
6471
|
return ["Request aborted", null];
|
|
6391
6472
|
}
|
|
6392
6473
|
}
|
|
6393
|
-
log$
|
|
6474
|
+
log$T.error(`Unexpected error during fetch: ${error}`);
|
|
6394
6475
|
return [error instanceof Error ? error.message : ERROR_UNKNOWN, null];
|
|
6395
6476
|
}
|
|
6396
6477
|
}
|
|
6397
|
-
log$
|
|
6478
|
+
log$T.error(`All ${config2.maxAttempts} attempts failed for ${fullUrl}`);
|
|
6398
6479
|
return lastResult;
|
|
6399
6480
|
}
|
|
6400
6481
|
async function captureErrorResponseContext(response) {
|
|
@@ -6443,9 +6524,9 @@ const service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
6443
6524
|
default: api$1,
|
|
6444
6525
|
kosServiceRequest
|
|
6445
6526
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
6446
|
-
const log$
|
|
6447
|
-
|
|
6448
|
-
|
|
6527
|
+
const log$S = KosLog.createLogger({
|
|
6528
|
+
group: LogGroup.core,
|
|
6529
|
+
name: "kos-service-request-manager"
|
|
6449
6530
|
});
|
|
6450
6531
|
function shouldExecuteRequest(metadata, model) {
|
|
6451
6532
|
return !metadata.condition || metadata.condition(model);
|
|
@@ -6496,7 +6577,7 @@ function isValueMissing(value) {
|
|
|
6496
6577
|
}
|
|
6497
6578
|
function validateRequiredField(value, fieldName, path, isRequired) {
|
|
6498
6579
|
if (isRequired && isValueMissing(value)) {
|
|
6499
|
-
log$
|
|
6580
|
+
log$S.warn(
|
|
6500
6581
|
`Required field '${fieldName}' is missing in response for ${path}`
|
|
6501
6582
|
);
|
|
6502
6583
|
}
|
|
@@ -6531,7 +6612,7 @@ class ServiceRequestManager {
|
|
|
6531
6612
|
this.handlers.get(lifecycle).push(metadata);
|
|
6532
6613
|
});
|
|
6533
6614
|
if (Object.keys(handlerMetadata).length > 0) {
|
|
6534
|
-
log$
|
|
6615
|
+
log$S.debug(
|
|
6535
6616
|
`Discovered ${Object.keys(handlerMetadata).length} service request handlers for model ${this.model.id}`
|
|
6536
6617
|
);
|
|
6537
6618
|
}
|
|
@@ -6546,7 +6627,7 @@ class ServiceRequestManager {
|
|
|
6546
6627
|
if (!handlers || handlers.length === 0) {
|
|
6547
6628
|
return;
|
|
6548
6629
|
}
|
|
6549
|
-
log$
|
|
6630
|
+
log$S.debug(
|
|
6550
6631
|
`Executing ${handlers.length} service requests for lifecycle ${lifecycle}`
|
|
6551
6632
|
);
|
|
6552
6633
|
await Promise.all(handlers.map((handler) => this.executeHandler(handler)));
|
|
@@ -6581,7 +6662,7 @@ class ServiceRequestManager {
|
|
|
6581
6662
|
*/
|
|
6582
6663
|
shouldProcessRequest(metadata) {
|
|
6583
6664
|
if (!shouldExecuteRequest(metadata, this.model)) {
|
|
6584
|
-
log$
|
|
6665
|
+
log$S.debug(`Skipping request ${metadata.path} - condition returned false`);
|
|
6585
6666
|
return false;
|
|
6586
6667
|
}
|
|
6587
6668
|
return true;
|
|
@@ -6786,7 +6867,7 @@ class ServiceRequestManager {
|
|
|
6786
6867
|
case "json":
|
|
6787
6868
|
return typeof value === "string" ? JSON.parse(value) : value;
|
|
6788
6869
|
default:
|
|
6789
|
-
log$
|
|
6870
|
+
log$S.warn(`Unknown transformer: ${transform}`);
|
|
6790
6871
|
return value;
|
|
6791
6872
|
}
|
|
6792
6873
|
}
|
|
@@ -6797,7 +6878,7 @@ class ServiceRequestManager {
|
|
|
6797
6878
|
if (!metadata.iterateOver) return data;
|
|
6798
6879
|
const array = this.getNestedValue(data, metadata.iterateOver);
|
|
6799
6880
|
if (!Array.isArray(array)) {
|
|
6800
|
-
log$
|
|
6881
|
+
log$S.warn(
|
|
6801
6882
|
`iterateOver path '${metadata.iterateOver}' did not resolve to an array`
|
|
6802
6883
|
);
|
|
6803
6884
|
return [];
|
|
@@ -6840,7 +6921,7 @@ class ServiceRequestManager {
|
|
|
6840
6921
|
case "throw":
|
|
6841
6922
|
throw error;
|
|
6842
6923
|
case "log":
|
|
6843
|
-
log$
|
|
6924
|
+
log$S.error(
|
|
6844
6925
|
`Service request failed for ${metadata.path}:`,
|
|
6845
6926
|
error.message
|
|
6846
6927
|
);
|
|
@@ -6900,6 +6981,10 @@ class ServiceRequestManager {
|
|
|
6900
6981
|
}
|
|
6901
6982
|
}
|
|
6902
6983
|
}
|
|
6984
|
+
KosLog.createLogger({
|
|
6985
|
+
group: LogGroup.core,
|
|
6986
|
+
name: "async-event-bus"
|
|
6987
|
+
});
|
|
6903
6988
|
class AsyncEventIterator {
|
|
6904
6989
|
subscription;
|
|
6905
6990
|
unsubscribe;
|
|
@@ -7349,6 +7434,10 @@ function encodeFutureFrame(future) {
|
|
|
7349
7434
|
JSON.stringify(future)
|
|
7350
7435
|
);
|
|
7351
7436
|
}
|
|
7437
|
+
const log$R = KosLog.createLogger({
|
|
7438
|
+
group: LogGroup.transport,
|
|
7439
|
+
name: "future-simulator"
|
|
7440
|
+
});
|
|
7352
7441
|
const DEFAULT_DURATION_MS = 5e3;
|
|
7353
7442
|
const DEFAULT_INTERVAL_MS = 250;
|
|
7354
7443
|
class KosMockFutureHandle {
|
|
@@ -7459,7 +7548,7 @@ class KosMockFutureSimulator {
|
|
|
7459
7548
|
this.deps.ensureCancelRoutes();
|
|
7460
7549
|
}
|
|
7461
7550
|
if (!options.tracker) {
|
|
7462
|
-
|
|
7551
|
+
log$R.warn(
|
|
7463
7552
|
`KosMock future ${handle.id} has no tracker — models will not link it to their request; prefer futures.fromRequest`
|
|
7464
7553
|
);
|
|
7465
7554
|
}
|
|
@@ -7491,6 +7580,10 @@ class KosMockFutureSimulator {
|
|
|
7491
7580
|
this.futures.clear();
|
|
7492
7581
|
}
|
|
7493
7582
|
}
|
|
7583
|
+
const log$Q = KosLog.createLogger({
|
|
7584
|
+
group: LogGroup.transport,
|
|
7585
|
+
name: "mock-fixtures"
|
|
7586
|
+
});
|
|
7494
7587
|
const DEFAULT_FIXTURE_SERVER_URL = "http://localhost:5676";
|
|
7495
7588
|
const DB_NAME = "kos-mock-fixtures";
|
|
7496
7589
|
const STORE_NAME = "fixtures";
|
|
@@ -7643,7 +7736,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7643
7736
|
);
|
|
7644
7737
|
}
|
|
7645
7738
|
await target.save(name, named);
|
|
7646
|
-
|
|
7739
|
+
log$Q.info(`KosMock fixture "${name}" saved`);
|
|
7647
7740
|
return name;
|
|
7648
7741
|
},
|
|
7649
7742
|
saveRecording(name) {
|
|
@@ -7666,7 +7759,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7666
7759
|
(summary) => summaries.push({ ...summary, source: "server" })
|
|
7667
7760
|
);
|
|
7668
7761
|
} catch {
|
|
7669
|
-
|
|
7762
|
+
log$Q.warn(`KosMock fixture server unreachable at ${serverUrl}`);
|
|
7670
7763
|
}
|
|
7671
7764
|
}
|
|
7672
7765
|
try {
|
|
@@ -7687,7 +7780,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7687
7780
|
},
|
|
7688
7781
|
async import() {
|
|
7689
7782
|
if (typeof document === "undefined") {
|
|
7690
|
-
|
|
7783
|
+
log$Q.warn(`KosMock fixture import requires a browser environment`);
|
|
7691
7784
|
return void 0;
|
|
7692
7785
|
}
|
|
7693
7786
|
return new Promise((resolve) => {
|
|
@@ -7707,7 +7800,7 @@ function createFixtureStore(registry, deps = {}) {
|
|
|
7707
7800
|
});
|
|
7708
7801
|
resolve(name);
|
|
7709
7802
|
} catch (error) {
|
|
7710
|
-
|
|
7803
|
+
log$Q.error(`KosMock fixture import failed`, error?.message);
|
|
7711
7804
|
resolve(void 0);
|
|
7712
7805
|
}
|
|
7713
7806
|
};
|
|
@@ -7782,6 +7875,10 @@ function splitUrl(url) {
|
|
|
7782
7875
|
function methodMatches(routeMethod, requestMethod) {
|
|
7783
7876
|
return routeMethod === "*" || routeMethod.toUpperCase() === requestMethod.toUpperCase();
|
|
7784
7877
|
}
|
|
7878
|
+
const log$P = KosLog.createLogger({
|
|
7879
|
+
group: LogGroup.transport,
|
|
7880
|
+
name: "mock-playback"
|
|
7881
|
+
});
|
|
7785
7882
|
const rewriteTrackers = (raw, trackerMap) => {
|
|
7786
7883
|
let out = raw;
|
|
7787
7884
|
trackerMap.forEach((liveTracker, capturedTracker) => {
|
|
@@ -7943,7 +8040,7 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7943
8040
|
if ((options.pushes ?? "scheduled") === "scheduled") {
|
|
7944
8041
|
startPushes();
|
|
7945
8042
|
}
|
|
7946
|
-
|
|
8043
|
+
log$P.info(
|
|
7947
8044
|
`KosMock fixture${name ? ` "${name}"` : ""} loaded: ${groups.size} routes, ${fixture.pushes.length} pushes (${fixture.pushes.length - unanchored.length} anchored), consume: ${consume}`
|
|
7948
8045
|
);
|
|
7949
8046
|
return {
|
|
@@ -7957,6 +8054,10 @@ ${rewriteTrackers(push.body, trackerMap)}`
|
|
|
7957
8054
|
}
|
|
7958
8055
|
};
|
|
7959
8056
|
}
|
|
8057
|
+
const log$O = KosLog.createLogger({
|
|
8058
|
+
group: LogGroup.transport,
|
|
8059
|
+
name: "mock-recorder"
|
|
8060
|
+
});
|
|
7960
8061
|
class KosMockRecorder {
|
|
7961
8062
|
recording = false;
|
|
7962
8063
|
name;
|
|
@@ -7978,14 +8079,14 @@ class KosMockRecorder {
|
|
|
7978
8079
|
this.exchanges = [];
|
|
7979
8080
|
this.pushes = [];
|
|
7980
8081
|
this.sends = [];
|
|
7981
|
-
|
|
8082
|
+
log$O.info(
|
|
7982
8083
|
`KosMock recorder started${options.name ? ` (${options.name})` : ""}`
|
|
7983
8084
|
);
|
|
7984
8085
|
}
|
|
7985
8086
|
stop() {
|
|
7986
8087
|
const fixture = this.toFixture();
|
|
7987
8088
|
this.recording = false;
|
|
7988
|
-
|
|
8089
|
+
log$O.info(
|
|
7989
8090
|
`KosMock recorder stopped: ${fixture.exchanges.length} exchanges, ${fixture.pushes.length} pushes, ${fixture.sends?.length ?? 0} sends`
|
|
7990
8091
|
);
|
|
7991
8092
|
return fixture;
|
|
@@ -8002,7 +8103,7 @@ class KosMockRecorder {
|
|
|
8002
8103
|
}
|
|
8003
8104
|
download(filename) {
|
|
8004
8105
|
if (typeof document === "undefined") {
|
|
8005
|
-
|
|
8106
|
+
log$O.warn(`KosMock recorder download requires a browser environment`);
|
|
8006
8107
|
return;
|
|
8007
8108
|
}
|
|
8008
8109
|
const fixture = this.toFixture();
|
|
@@ -8117,6 +8218,10 @@ class KosMockRecorder {
|
|
|
8117
8218
|
}
|
|
8118
8219
|
}
|
|
8119
8220
|
}
|
|
8221
|
+
const log$N = KosLog.createLogger({
|
|
8222
|
+
group: LogGroup.transport,
|
|
8223
|
+
name: "mock-setups"
|
|
8224
|
+
});
|
|
8120
8225
|
const dynamicImport = (url) => import(
|
|
8121
8226
|
/* @vite-ignore */
|
|
8122
8227
|
/* webpackIgnore: true */
|
|
@@ -8149,7 +8254,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8149
8254
|
try {
|
|
8150
8255
|
entry.teardown?.();
|
|
8151
8256
|
} catch (error) {
|
|
8152
|
-
|
|
8257
|
+
log$N.error(`KosMock setup "${name}" teardown threw`, error?.message);
|
|
8153
8258
|
}
|
|
8154
8259
|
return true;
|
|
8155
8260
|
};
|
|
@@ -8176,7 +8281,7 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8176
8281
|
handle,
|
|
8177
8282
|
teardown: typeof result === "function" ? result : void 0
|
|
8178
8283
|
});
|
|
8179
|
-
|
|
8284
|
+
log$N.info(`KosMock setup "${name}" installed from ${url}`);
|
|
8180
8285
|
return handle;
|
|
8181
8286
|
},
|
|
8182
8287
|
async list() {
|
|
@@ -8199,6 +8304,10 @@ function createSetupStore(registry, deps = {}) {
|
|
|
8199
8304
|
};
|
|
8200
8305
|
return store;
|
|
8201
8306
|
}
|
|
8307
|
+
const log$M = KosLog.createLogger({
|
|
8308
|
+
group: LogGroup.transport,
|
|
8309
|
+
name: "mock-config"
|
|
8310
|
+
});
|
|
8202
8311
|
const asWireValue = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
8203
8312
|
const configTopic = (beanId) => `/kos/config/${beanId}`;
|
|
8204
8313
|
const changeEnvelope = (props, previousValues = {}) => {
|
|
@@ -8266,7 +8375,7 @@ function createConfigFacade(registry) {
|
|
|
8266
8375
|
return void 0;
|
|
8267
8376
|
}
|
|
8268
8377
|
if (injectedKeys.length < keys.length) {
|
|
8269
|
-
|
|
8378
|
+
log$M.warn(
|
|
8270
8379
|
`KosMock config.inject ${beanId}: mixed write passes through; injected props will be rejected by the backend: ${injectedKeys.join(
|
|
8271
8380
|
", "
|
|
8272
8381
|
)}`
|
|
@@ -8301,6 +8410,10 @@ function createConfigFacade(registry) {
|
|
|
8301
8410
|
};
|
|
8302
8411
|
return { update, inject };
|
|
8303
8412
|
}
|
|
8413
|
+
const log$L = KosLog.createLogger({
|
|
8414
|
+
group: LogGroup.transport,
|
|
8415
|
+
name: "mock-registry"
|
|
8416
|
+
});
|
|
8304
8417
|
const PENDING_REQUEST_CAP = 500;
|
|
8305
8418
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8306
8419
|
const asHandler = (handler) => typeof handler === "function" ? handler : () => handler;
|
|
@@ -8406,7 +8519,7 @@ class KosMockRegistry {
|
|
|
8406
8519
|
changed = true;
|
|
8407
8520
|
}
|
|
8408
8521
|
} catch (error) {
|
|
8409
|
-
|
|
8522
|
+
log$L.error(
|
|
8410
8523
|
`KosMock transformer for ${transformer.method} ${transformer.pattern} threw`,
|
|
8411
8524
|
error?.message
|
|
8412
8525
|
);
|
|
@@ -8522,7 +8635,7 @@ class KosMockRegistry {
|
|
|
8522
8635
|
try {
|
|
8523
8636
|
notify();
|
|
8524
8637
|
} catch (error) {
|
|
8525
|
-
|
|
8638
|
+
log$L.error(`KosMock observer threw`, error?.message);
|
|
8526
8639
|
}
|
|
8527
8640
|
}
|
|
8528
8641
|
loadFixture(fixture, options) {
|
|
@@ -8545,13 +8658,13 @@ class KosMockRegistry {
|
|
|
8545
8658
|
enable() {
|
|
8546
8659
|
if (!this.enabledFlag) {
|
|
8547
8660
|
this.enabledFlag = true;
|
|
8548
|
-
|
|
8661
|
+
log$L.info(`KosMock enabled`);
|
|
8549
8662
|
}
|
|
8550
8663
|
}
|
|
8551
8664
|
disable() {
|
|
8552
8665
|
if (this.enabledFlag) {
|
|
8553
8666
|
this.enabledFlag = false;
|
|
8554
|
-
|
|
8667
|
+
log$L.info(`KosMock disabled`);
|
|
8555
8668
|
}
|
|
8556
8669
|
}
|
|
8557
8670
|
get standalone() {
|
|
@@ -8627,7 +8740,7 @@ class KosMockRegistry {
|
|
|
8627
8740
|
}
|
|
8628
8741
|
publishFrame(rawFrame) {
|
|
8629
8742
|
if (this.injectors.size === 0) {
|
|
8630
|
-
|
|
8743
|
+
log$L.warn(
|
|
8631
8744
|
`KosMock.publishFrame: no active transport to deliver the frame`
|
|
8632
8745
|
);
|
|
8633
8746
|
return;
|
|
@@ -8670,7 +8783,7 @@ class KosMockRegistry {
|
|
|
8670
8783
|
if (teardown) {
|
|
8671
8784
|
this.scenarioTeardowns.set(id, teardown);
|
|
8672
8785
|
}
|
|
8673
|
-
|
|
8786
|
+
log$L.info(`KosMock scenario "${scenario.name}" installed`);
|
|
8674
8787
|
const remove = () => {
|
|
8675
8788
|
const dispose = this.scenarioTeardowns.get(id);
|
|
8676
8789
|
this.scenarioTeardowns.delete(id);
|
|
@@ -8774,7 +8887,7 @@ class KosMockRegistry {
|
|
|
8774
8887
|
return true;
|
|
8775
8888
|
}
|
|
8776
8889
|
if (policy === "warn") {
|
|
8777
|
-
|
|
8890
|
+
log$L.warn(`KosMock: unmatched ${frame.method} ${path}`);
|
|
8778
8891
|
}
|
|
8779
8892
|
return false;
|
|
8780
8893
|
}
|
|
@@ -8810,7 +8923,7 @@ class KosMockRegistry {
|
|
|
8810
8923
|
try {
|
|
8811
8924
|
accepted = route.when(scopedRequest);
|
|
8812
8925
|
} catch (error) {
|
|
8813
|
-
|
|
8926
|
+
log$L.error(
|
|
8814
8927
|
`KosMock \`when\` guard for ${route.method} ${route.pattern} threw`,
|
|
8815
8928
|
error?.message
|
|
8816
8929
|
);
|
|
@@ -8823,7 +8936,7 @@ class KosMockRegistry {
|
|
|
8823
8936
|
try {
|
|
8824
8937
|
response = await route.handler(scopedRequest, this.context());
|
|
8825
8938
|
} catch (error) {
|
|
8826
|
-
|
|
8939
|
+
log$L.error(
|
|
8827
8940
|
`KosMock handler for ${route.method} ${route.pattern} threw`,
|
|
8828
8941
|
error?.message
|
|
8829
8942
|
);
|
|
@@ -8856,7 +8969,7 @@ class KosMockRegistry {
|
|
|
8856
8969
|
return;
|
|
8857
8970
|
}
|
|
8858
8971
|
if (policy === "warn") {
|
|
8859
|
-
|
|
8972
|
+
log$L.warn(
|
|
8860
8973
|
`KosMock: all routes declined ${request.method} ${request.path}`
|
|
8861
8974
|
);
|
|
8862
8975
|
}
|
|
@@ -8971,7 +9084,7 @@ if (typeof window !== "undefined") {
|
|
|
8971
9084
|
if (fixture) {
|
|
8972
9085
|
bootLoads.push(
|
|
8973
9086
|
KosMock.fixtures.play(fixture).then(() => void 0).catch(
|
|
8974
|
-
(error) =>
|
|
9087
|
+
(error) => log$L.error(
|
|
8975
9088
|
`KosMock: boot fixture "${fixture}" failed to load`,
|
|
8976
9089
|
error?.message
|
|
8977
9090
|
)
|
|
@@ -8982,7 +9095,7 @@ if (typeof window !== "undefined") {
|
|
|
8982
9095
|
for (const name of setups.split(",").filter(Boolean)) {
|
|
8983
9096
|
bootLoads.push(
|
|
8984
9097
|
KosMock.setups.load(name).then(() => void 0).catch(
|
|
8985
|
-
(error) =>
|
|
9098
|
+
(error) => log$L.error(
|
|
8986
9099
|
`KosMock: boot setup "${name}" failed to load`,
|
|
8987
9100
|
error?.message
|
|
8988
9101
|
)
|
|
@@ -9092,6 +9205,14 @@ class WebSocketBridgeTransport extends WebSocket {
|
|
|
9092
9205
|
super(address);
|
|
9093
9206
|
}
|
|
9094
9207
|
}
|
|
9208
|
+
const log$K = KosLog.createLogger({
|
|
9209
|
+
group: LogGroup.transport,
|
|
9210
|
+
name: "base-message-transport"
|
|
9211
|
+
});
|
|
9212
|
+
const messageLog = KosLog.createLogger({
|
|
9213
|
+
group: LogGroup.transport,
|
|
9214
|
+
name: MESSAGE_LOGGER_NAME
|
|
9215
|
+
});
|
|
9095
9216
|
var WebSocketEvents = /* @__PURE__ */ ((WebSocketEvents2) => {
|
|
9096
9217
|
WebSocketEvents2["CONNECTED"] = `websocket.connected`;
|
|
9097
9218
|
WebSocketEvents2["DISCONNECTED"] = `websocket.disconnected`;
|
|
@@ -9188,9 +9309,9 @@ class BaseTransport {
|
|
|
9188
9309
|
}
|
|
9189
9310
|
onMessage(event) {
|
|
9190
9311
|
try {
|
|
9191
|
-
|
|
9312
|
+
log$K.debug("webSocketTransport: onMessage received");
|
|
9192
9313
|
const { headers, body } = this.processMessageEvent(event);
|
|
9193
|
-
|
|
9314
|
+
messageLog.debug("received", event.data);
|
|
9194
9315
|
const subscriptionTopic = headers["subscription"] || headers[this.RESPONSE_ID_HEADER] || headers["topic"] || headers["type"];
|
|
9195
9316
|
if (subscriptionTopic) {
|
|
9196
9317
|
let msgBody = body;
|
|
@@ -9206,11 +9327,11 @@ class BaseTransport {
|
|
|
9206
9327
|
publish(subscriptionTopic, msgBody, msgHeaders);
|
|
9207
9328
|
}
|
|
9208
9329
|
} catch (ex) {
|
|
9209
|
-
|
|
9330
|
+
log$K.error(`onMessage exception`, ex.message, ex.stack);
|
|
9210
9331
|
}
|
|
9211
9332
|
}
|
|
9212
9333
|
onOpen(event) {
|
|
9213
|
-
|
|
9334
|
+
log$K.info(`websocket connection opened`);
|
|
9214
9335
|
this.socket = event.currentTarget;
|
|
9215
9336
|
mobx.runInAction(() => {
|
|
9216
9337
|
this.connectionEstablished = true;
|
|
@@ -9220,11 +9341,9 @@ alias:${this.alias}
|
|
|
9220
9341
|
|
|
9221
9342
|
`);
|
|
9222
9343
|
}
|
|
9223
|
-
|
|
9224
|
-
`sending ${this.offlineMessages.length} offline FOS messages`
|
|
9225
|
-
);
|
|
9344
|
+
log$K.debug(`sending ${this.offlineMessages.length} offline FOS messages`);
|
|
9226
9345
|
this.offlineMessages.forEach((msg) => {
|
|
9227
|
-
|
|
9346
|
+
log$K.debug(`sending offline message ${msg.msg}`);
|
|
9228
9347
|
this.socket?.send(msg.msg);
|
|
9229
9348
|
});
|
|
9230
9349
|
this.offlineMessages = [];
|
|
@@ -9233,7 +9352,7 @@ alias:${this.alias}
|
|
|
9233
9352
|
}
|
|
9234
9353
|
onClose(event) {
|
|
9235
9354
|
const { code, reason, wasClean } = event;
|
|
9236
|
-
|
|
9355
|
+
log$K.warn(
|
|
9237
9356
|
`WebSocket closed: code=${code}, reason=${reason || "none"}, wasClean=${wasClean}`
|
|
9238
9357
|
);
|
|
9239
9358
|
mobx.runInAction(() => {
|
|
@@ -9243,13 +9362,13 @@ alias:${this.alias}
|
|
|
9243
9362
|
if (this.shouldAttemptReconnection(code)) {
|
|
9244
9363
|
this.onConnectionLost?.();
|
|
9245
9364
|
} else {
|
|
9246
|
-
|
|
9365
|
+
log$K.info(
|
|
9247
9366
|
`Not reconnecting due to close code ${code} (intentional close or configuration error)`
|
|
9248
9367
|
);
|
|
9249
9368
|
}
|
|
9250
9369
|
}
|
|
9251
9370
|
onError(ev) {
|
|
9252
|
-
|
|
9371
|
+
log$K.error(`websocket error: `, ev);
|
|
9253
9372
|
publish("websocket.error", { event: ev });
|
|
9254
9373
|
}
|
|
9255
9374
|
/**
|
|
@@ -9294,7 +9413,7 @@ alias:${this.alias}
|
|
|
9294
9413
|
}
|
|
9295
9414
|
}
|
|
9296
9415
|
send(data) {
|
|
9297
|
-
|
|
9416
|
+
messageLog.debug("sent", data);
|
|
9298
9417
|
if (window.kosLogEvents) {
|
|
9299
9418
|
const { headers, body } = processKosMessage(String(data));
|
|
9300
9419
|
publish(KosWsEvents.SEND, { headers, body });
|
|
@@ -9302,6 +9421,10 @@ alias:${this.alias}
|
|
|
9302
9421
|
this.oldSend.call(this.socket, data);
|
|
9303
9422
|
}
|
|
9304
9423
|
}
|
|
9424
|
+
const log$J = KosLog.createLogger({
|
|
9425
|
+
group: LogGroup.transport,
|
|
9426
|
+
name: "bridge-transport"
|
|
9427
|
+
});
|
|
9305
9428
|
class BridgeTransport {
|
|
9306
9429
|
addEventListener;
|
|
9307
9430
|
dispatchEvent;
|
|
@@ -9313,7 +9436,7 @@ class BridgeTransport {
|
|
|
9313
9436
|
messageQueue = [];
|
|
9314
9437
|
isSending = false;
|
|
9315
9438
|
constructor(addr) {
|
|
9316
|
-
log$
|
|
9439
|
+
log$J.debug(`called Bridge Transport with addr ${addr}`);
|
|
9317
9440
|
const that = this;
|
|
9318
9441
|
globalThis.kosWindowWebsocketRecv = (msg) => {
|
|
9319
9442
|
if (that.onmessage) {
|
|
@@ -9321,19 +9444,19 @@ class BridgeTransport {
|
|
|
9321
9444
|
that.onmessage(data);
|
|
9322
9445
|
}
|
|
9323
9446
|
};
|
|
9324
|
-
log$
|
|
9447
|
+
log$J.debug("Opening bridge transport");
|
|
9325
9448
|
globalThis.kosWindowWebsocketOpen();
|
|
9326
|
-
log$
|
|
9449
|
+
log$J.debug("Opened bridge transport");
|
|
9327
9450
|
this._onclose = null;
|
|
9328
9451
|
this._onerror = null;
|
|
9329
9452
|
this._onmessage = null;
|
|
9330
9453
|
this._onopen = null;
|
|
9331
|
-
this.addEventListener = () => log$
|
|
9332
|
-
this.dispatchEvent = () => log$
|
|
9333
|
-
this.removeEventListener = () => log$
|
|
9454
|
+
this.addEventListener = () => log$J.debug("not implemented");
|
|
9455
|
+
this.dispatchEvent = () => log$J.debug("not implemented");
|
|
9456
|
+
this.removeEventListener = () => log$J.debug("not implemented");
|
|
9334
9457
|
}
|
|
9335
9458
|
close() {
|
|
9336
|
-
log$
|
|
9459
|
+
log$J.debug("closing");
|
|
9337
9460
|
}
|
|
9338
9461
|
sendNextMessage() {
|
|
9339
9462
|
if (this.messageQueue.length > 0) {
|
|
@@ -9420,6 +9543,10 @@ class KosTransport extends BaseTransport {
|
|
|
9420
9543
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9421
9544
|
}
|
|
9422
9545
|
}
|
|
9546
|
+
const log$I = KosLog.createLogger({
|
|
9547
|
+
group: LogGroup.transport,
|
|
9548
|
+
name: "standalone-mock-socket"
|
|
9549
|
+
});
|
|
9423
9550
|
const LOGGED_IN_FRAME = `topic:/studioServer/auth/LOGGED_IN
|
|
9424
9551
|
type:kos.broker.topic
|
|
9425
9552
|
|
|
@@ -9430,7 +9557,7 @@ class StandaloneMockSocket {
|
|
|
9430
9557
|
onmessage = null;
|
|
9431
9558
|
onopen = null;
|
|
9432
9559
|
constructor(url) {
|
|
9433
|
-
|
|
9560
|
+
log$I.info(`KosMock standalone socket replacing ${url}`);
|
|
9434
9561
|
setTimeout(async () => {
|
|
9435
9562
|
await kosMockRegistry.bootGate;
|
|
9436
9563
|
this.onopen?.({ currentTarget: this });
|
|
@@ -9441,7 +9568,7 @@ class StandaloneMockSocket {
|
|
|
9441
9568
|
}
|
|
9442
9569
|
send(data) {
|
|
9443
9570
|
if (peekFrameType(data) === KOS_HTTP_REQUEST_TYPE) {
|
|
9444
|
-
|
|
9571
|
+
log$I.warn(
|
|
9445
9572
|
`KosMock standalone: unmatched request reached the loopback socket and will hang — add a route or use onUnmatched: "respond404"`,
|
|
9446
9573
|
String(data).split("\n", 2).join(" ")
|
|
9447
9574
|
);
|
|
@@ -9479,6 +9606,10 @@ class MockMessageTransport extends BaseTransport {
|
|
|
9479
9606
|
this.RESPONSE_ID_HEADER = `response-id`;
|
|
9480
9607
|
}
|
|
9481
9608
|
}
|
|
9609
|
+
const log$H = KosLog.createLogger({
|
|
9610
|
+
group: LogGroup.transport,
|
|
9611
|
+
name: "transport-factory"
|
|
9612
|
+
});
|
|
9482
9613
|
window.kosLogEvents = process.env.KOS_LOG_WS === "true";
|
|
9483
9614
|
class TransportFactory {
|
|
9484
9615
|
static build({
|
|
@@ -9490,13 +9621,13 @@ class TransportFactory {
|
|
|
9490
9621
|
onConnectionEstablished,
|
|
9491
9622
|
onConnectionLost
|
|
9492
9623
|
}) {
|
|
9493
|
-
|
|
9494
|
-
|
|
9624
|
+
log$H.debug(`initializing websocket connection`);
|
|
9625
|
+
log$H.warn(
|
|
9495
9626
|
`kosWindowWebsocketOpen: ${globalThis.kosWindowWebsocketOpen ? `true` : `false`}`
|
|
9496
9627
|
);
|
|
9497
|
-
|
|
9628
|
+
log$H.warn(`fos: ${fos ? `true` : `false`}`);
|
|
9498
9629
|
if (KosMock.standalone && !fos) {
|
|
9499
|
-
|
|
9630
|
+
log$H.warn(`Using KosMock standalone transport`);
|
|
9500
9631
|
return new MockMessageTransport({
|
|
9501
9632
|
host,
|
|
9502
9633
|
port,
|
|
@@ -9507,7 +9638,7 @@ class TransportFactory {
|
|
|
9507
9638
|
});
|
|
9508
9639
|
}
|
|
9509
9640
|
if (globalThis.kosWindowWebsocketOpen && !fos) {
|
|
9510
|
-
|
|
9641
|
+
log$H.warn(`Using bridged message transport`);
|
|
9511
9642
|
const transport = new BridgeMessageTransport({
|
|
9512
9643
|
host,
|
|
9513
9644
|
port,
|
|
@@ -9548,7 +9679,10 @@ if (params$1.fos) {
|
|
|
9548
9679
|
const fosPort = process.env.KOS_FOS_PORT;
|
|
9549
9680
|
window.kosUseFos = !!(window.kosUseFos || process.env.KOS_USE_FOS === "true");
|
|
9550
9681
|
window.kosFosPort = fosPort ? parseInt(fosPort) : 0;
|
|
9551
|
-
const log$
|
|
9682
|
+
const log$G = KosLog.createLogger({
|
|
9683
|
+
group: LogGroup.transport,
|
|
9684
|
+
name: "web-socket-transport"
|
|
9685
|
+
});
|
|
9552
9686
|
var KosWSTransportStatus = /* @__PURE__ */ ((KosWSTransportStatus2) => {
|
|
9553
9687
|
KosWSTransportStatus2["NOT_INITIALIZED"] = "not_initialized";
|
|
9554
9688
|
KosWSTransportStatus2["INITIALIZED"] = "initialized";
|
|
@@ -9605,7 +9739,7 @@ class WebSocketTransport {
|
|
|
9605
9739
|
() => this.connectionEstablished,
|
|
9606
9740
|
(connectionEstablished) => {
|
|
9607
9741
|
if (connectionEstablished) {
|
|
9608
|
-
log$
|
|
9742
|
+
log$G.warn("Connection Established");
|
|
9609
9743
|
this.reconnectAttempts = 0;
|
|
9610
9744
|
publish(WebSocketEvents.CONNECTED, {
|
|
9611
9745
|
reconnect: initialized
|
|
@@ -9637,7 +9771,7 @@ class WebSocketTransport {
|
|
|
9637
9771
|
return false;
|
|
9638
9772
|
}
|
|
9639
9773
|
init() {
|
|
9640
|
-
|
|
9774
|
+
log$G.warn(`Initializing WebSocketTransport on ${this.host}:${this.port}`);
|
|
9641
9775
|
if (this.useFosTransport) {
|
|
9642
9776
|
this.fosSocket = TransportFactory.build({
|
|
9643
9777
|
host: this.host,
|
|
@@ -9652,7 +9786,7 @@ class WebSocketTransport {
|
|
|
9652
9786
|
protocol: this.protocol,
|
|
9653
9787
|
alias: this.alias,
|
|
9654
9788
|
onConnectionLost: () => {
|
|
9655
|
-
log$
|
|
9789
|
+
log$G.error(`Connection Lost`);
|
|
9656
9790
|
this.scheduleReconnect();
|
|
9657
9791
|
}
|
|
9658
9792
|
});
|
|
@@ -9672,7 +9806,7 @@ class WebSocketTransport {
|
|
|
9672
9806
|
*/
|
|
9673
9807
|
scheduleReconnect() {
|
|
9674
9808
|
if (this.reconnectAttempts >= WebSocketTransport.MAX_RECONNECT_ATTEMPTS) {
|
|
9675
|
-
|
|
9809
|
+
log$G.error(
|
|
9676
9810
|
`Max reconnection attempts (${WebSocketTransport.MAX_RECONNECT_ATTEMPTS}) reached. Giving up.`
|
|
9677
9811
|
);
|
|
9678
9812
|
publish(WebSocketEvents.MAX_RETRIES_EXCEEDED, {
|
|
@@ -9681,7 +9815,7 @@ class WebSocketTransport {
|
|
|
9681
9815
|
return;
|
|
9682
9816
|
}
|
|
9683
9817
|
const delay2 = this.calculateBackoffDelay();
|
|
9684
|
-
|
|
9818
|
+
log$G.debug(
|
|
9685
9819
|
`Reconnecting in ${delay2}ms (attempt ${this.reconnectAttempts + 1}/${WebSocketTransport.MAX_RECONNECT_ATTEMPTS})`
|
|
9686
9820
|
);
|
|
9687
9821
|
setTimeout(() => {
|
|
@@ -9698,7 +9832,7 @@ class WebSocketTransport {
|
|
|
9698
9832
|
return Math.floor(exponentialDelay + jitter);
|
|
9699
9833
|
}
|
|
9700
9834
|
_sendSubscriptionMessage(topic, type, fos = false, bridge = false, connectionId, explicitDestination = false) {
|
|
9701
|
-
log$
|
|
9835
|
+
log$G.debug(`${type} to topic ${topic}`);
|
|
9702
9836
|
let connId;
|
|
9703
9837
|
if (explicitDestination) {
|
|
9704
9838
|
connId = connectionId;
|
|
@@ -9707,7 +9841,7 @@ class WebSocketTransport {
|
|
|
9707
9841
|
const connectionParam = params2?.connId;
|
|
9708
9842
|
connId = connectionId ?? connectionParam ?? window?.kosBridge?.("connId");
|
|
9709
9843
|
}
|
|
9710
|
-
log$
|
|
9844
|
+
log$G.debug(`subscribing with connId ${connId}`);
|
|
9711
9845
|
const dstAddr = connId ? `dst-addr:${connId}
|
|
9712
9846
|
` : "";
|
|
9713
9847
|
const msg = fos ? `subscribe:${topic}` : bridge ? `type:fos.broker
|
|
@@ -9721,7 +9855,7 @@ ${dstAddr}topics:${topic}
|
|
|
9721
9855
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9722
9856
|
socket?.socket?.send(msg);
|
|
9723
9857
|
} else {
|
|
9724
|
-
log$
|
|
9858
|
+
log$G.debug(`no connection adding to offline messages`);
|
|
9725
9859
|
const socket = fos ? this.fosSocket : this.socket;
|
|
9726
9860
|
socket?.addOfflineMessage(msg);
|
|
9727
9861
|
}
|
|
@@ -9735,7 +9869,7 @@ ${dstAddr}topics:${topic}
|
|
|
9735
9869
|
explicitDestination
|
|
9736
9870
|
}) {
|
|
9737
9871
|
const { unsubscribe, count } = subscribe(topic, callback);
|
|
9738
|
-
log$
|
|
9872
|
+
log$G.debug(`Topic ${topic} currently has ${count} subscribers`);
|
|
9739
9873
|
this._sendSubscriptionMessage(
|
|
9740
9874
|
topic,
|
|
9741
9875
|
"subscribe",
|
|
@@ -9746,7 +9880,7 @@ ${dstAddr}topics:${topic}
|
|
|
9746
9880
|
);
|
|
9747
9881
|
return () => {
|
|
9748
9882
|
const { count: count2 } = unsubscribe();
|
|
9749
|
-
log$
|
|
9883
|
+
log$G.debug(`Topic ${topic} currently has ${count2} subscribers`);
|
|
9750
9884
|
if (count2 === 0) {
|
|
9751
9885
|
this._sendSubscriptionMessage(
|
|
9752
9886
|
topic,
|
|
@@ -9786,7 +9920,7 @@ ${dstAddr}topics:${topic}
|
|
|
9786
9920
|
}
|
|
9787
9921
|
dropConnection() {
|
|
9788
9922
|
if (!this.connectionEstablished) {
|
|
9789
|
-
log$
|
|
9923
|
+
log$G.debug("dropConnection ignored: the connection is already closed");
|
|
9790
9924
|
return;
|
|
9791
9925
|
}
|
|
9792
9926
|
this.socket?.socket.close(1e3);
|
|
@@ -10572,21 +10706,17 @@ class ServiceResponseStore {
|
|
|
10572
10706
|
class KosModelComponentFactory {
|
|
10573
10707
|
static createAll(model) {
|
|
10574
10708
|
const { modelId, modelTypeName, modelData } = model;
|
|
10575
|
-
const log3 = KosLoggerFactory.create({
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
const fsm2 = new KosFSMManager(model, createTaggedLogger(log3, "fsm"));
|
|
10580
|
-
const offlineQueue = new KosOfflineQueue(
|
|
10581
|
-
createTaggedLogger(log3, "offline-queue")
|
|
10582
|
-
);
|
|
10709
|
+
const log3 = KosLoggerFactory.create({ modelTypeName });
|
|
10710
|
+
const tagged = (tag) => createTaggedLogger(log3, `${modelId}:${tag}`);
|
|
10711
|
+
const fsm2 = new KosFSMManager(model, tagged("fsm"));
|
|
10712
|
+
const offlineQueue = new KosOfflineQueue(tagged("offline-queue"));
|
|
10583
10713
|
const companionManager = new KosCompanionModelManager(model);
|
|
10584
10714
|
const childResolver = new KosChildResolver(model);
|
|
10585
10715
|
const serviceResponseStore = new ServiceResponseStore();
|
|
10586
10716
|
modelData.serviceResponses = serviceResponseStore;
|
|
10587
10717
|
const onlineLifecycleManager = new KosOnlineLifecycleManager(
|
|
10588
10718
|
model,
|
|
10589
|
-
|
|
10719
|
+
tagged("online")
|
|
10590
10720
|
);
|
|
10591
10721
|
const components = {
|
|
10592
10722
|
fsm: fsm2,
|
|
@@ -10601,11 +10731,11 @@ class KosModelComponentFactory {
|
|
|
10601
10731
|
modelTypeName,
|
|
10602
10732
|
modelId,
|
|
10603
10733
|
modelData,
|
|
10604
|
-
|
|
10734
|
+
tagged("effect")
|
|
10605
10735
|
);
|
|
10606
10736
|
}
|
|
10607
10737
|
if (hasSubscriptionHandlers(modelData)) {
|
|
10608
|
-
const subLogger =
|
|
10738
|
+
const subLogger = tagged("subscription");
|
|
10609
10739
|
components.subscriptionManager = new KosSubscriptionManager(
|
|
10610
10740
|
model,
|
|
10611
10741
|
modelData,
|
|
@@ -10617,7 +10747,7 @@ class KosModelComponentFactory {
|
|
|
10617
10747
|
if (hasHttpRouteHandlers(modelData)) {
|
|
10618
10748
|
components.httpRouteManager = new KosHttpRouteManager(
|
|
10619
10749
|
modelData,
|
|
10620
|
-
|
|
10750
|
+
tagged("http-routes")
|
|
10621
10751
|
);
|
|
10622
10752
|
}
|
|
10623
10753
|
if (hasServiceRequestHandlers(modelData)) {
|
|
@@ -10630,7 +10760,7 @@ class KosModelComponentFactory {
|
|
|
10630
10760
|
return components;
|
|
10631
10761
|
}
|
|
10632
10762
|
}
|
|
10633
|
-
const log$
|
|
10763
|
+
const log$F = KosLog.createLogger({ group: LogGroup.core, name: "kos-model" });
|
|
10634
10764
|
const MODEL_LOADER = "kos.extension.model.loader";
|
|
10635
10765
|
class KosModel {
|
|
10636
10766
|
_id;
|
|
@@ -10738,23 +10868,23 @@ class KosModel {
|
|
|
10738
10868
|
return this._status === KosModelState.READY;
|
|
10739
10869
|
}
|
|
10740
10870
|
async deactivate() {
|
|
10741
|
-
log$
|
|
10871
|
+
log$F.debug(
|
|
10742
10872
|
`deactivating model ${this.modelTypeName} with id ${this.modelId}`
|
|
10743
10873
|
);
|
|
10744
10874
|
try {
|
|
10745
10875
|
const context = KosContextManager.getContext(this.modelId);
|
|
10746
10876
|
await this.modelData?.deactivate?.(context);
|
|
10747
|
-
log$
|
|
10877
|
+
log$F.debug(
|
|
10748
10878
|
`Model ${this.modelTypeName} with id ${this.modelId} deactivated`
|
|
10749
10879
|
);
|
|
10750
10880
|
this.subscriptionManager?.deactivate();
|
|
10751
10881
|
} catch (e) {
|
|
10752
|
-
log$
|
|
10882
|
+
log$F.debug(`Model ${this.modelId} failed to deactivated`);
|
|
10753
10883
|
throw e;
|
|
10754
10884
|
}
|
|
10755
10885
|
}
|
|
10756
10886
|
async activate() {
|
|
10757
|
-
log$
|
|
10887
|
+
log$F.debug(`activating model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10758
10888
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ACTIVATE);
|
|
10759
10889
|
try {
|
|
10760
10890
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10763,16 +10893,16 @@ class KosModel {
|
|
|
10763
10893
|
const context = KosContextManager.getContext(this.modelId);
|
|
10764
10894
|
await this.modelData?.activate?.(context);
|
|
10765
10895
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.ACTIVATE);
|
|
10766
|
-
log$
|
|
10896
|
+
log$F.debug(
|
|
10767
10897
|
`Model ${this.modelTypeName} with id ${this.modelId} subscribing to all topics`
|
|
10768
10898
|
);
|
|
10769
10899
|
this.subscriptionManager?.registerAll(DependencyLifecycle.ACTIVATE);
|
|
10770
10900
|
this.createLifecycleCompanions(DependencyLifecycle.ACTIVATE);
|
|
10771
|
-
log$
|
|
10901
|
+
log$F.debug(
|
|
10772
10902
|
`Model ${this.modelTypeName} with id ${this.modelId} activated`
|
|
10773
10903
|
);
|
|
10774
10904
|
} catch (e) {
|
|
10775
|
-
log$
|
|
10905
|
+
log$F.debug(`Model ${this.modelId} failed to activate`);
|
|
10776
10906
|
throw e;
|
|
10777
10907
|
}
|
|
10778
10908
|
return;
|
|
@@ -10788,7 +10918,7 @@ class KosModel {
|
|
|
10788
10918
|
{
|
|
10789
10919
|
condition: () => this.loaded,
|
|
10790
10920
|
onMatch: () => {
|
|
10791
|
-
log$
|
|
10921
|
+
log$F.debug(`Model ${this.modelId} is loaded`);
|
|
10792
10922
|
}
|
|
10793
10923
|
}
|
|
10794
10924
|
]);
|
|
@@ -10804,7 +10934,7 @@ class KosModel {
|
|
|
10804
10934
|
{
|
|
10805
10935
|
condition: () => this.initialized,
|
|
10806
10936
|
onMatch: () => {
|
|
10807
|
-
log$
|
|
10937
|
+
log$F.debug(`Model ${this.modelId} is initialized`);
|
|
10808
10938
|
}
|
|
10809
10939
|
}
|
|
10810
10940
|
]);
|
|
@@ -10820,20 +10950,20 @@ class KosModel {
|
|
|
10820
10950
|
{
|
|
10821
10951
|
condition: () => this.status === KosModelState.READY,
|
|
10822
10952
|
onMatch: () => {
|
|
10823
|
-
log$
|
|
10953
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10824
10954
|
}
|
|
10825
10955
|
}
|
|
10826
10956
|
]);
|
|
10827
10957
|
}
|
|
10828
10958
|
async ready() {
|
|
10829
10959
|
if (this.fsm.current === KosModelState.READY) {
|
|
10830
|
-
log$
|
|
10960
|
+
log$F.debug(
|
|
10831
10961
|
`already readying model ${this.modelTypeName} with id ${this.modelId} returning`
|
|
10832
10962
|
);
|
|
10833
10963
|
return;
|
|
10834
10964
|
}
|
|
10835
10965
|
try {
|
|
10836
|
-
log$
|
|
10966
|
+
log$F.debug(`readying model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10837
10967
|
await executeDependentModelLifecycle(this, DependencyLifecycle.READY);
|
|
10838
10968
|
await executeChildrenModelLifecycle(
|
|
10839
10969
|
this,
|
|
@@ -10849,7 +10979,7 @@ class KosModel {
|
|
|
10849
10979
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.READY);
|
|
10850
10980
|
this.subscriptionManager?.registerAll(DependencyLifecycle.READY);
|
|
10851
10981
|
this.createLifecycleCompanions(DependencyLifecycle.READY);
|
|
10852
|
-
log$
|
|
10982
|
+
log$F.debug(`Model ${this.modelId} is ready`);
|
|
10853
10983
|
const payload = {
|
|
10854
10984
|
modelId: this.modelId,
|
|
10855
10985
|
modelType: this.modelTypeName
|
|
@@ -10860,7 +10990,7 @@ class KosModel {
|
|
|
10860
10990
|
);
|
|
10861
10991
|
publish(modelTypeEventTopicFactory(this.modelTypeName), payload);
|
|
10862
10992
|
} catch (e) {
|
|
10863
|
-
log$
|
|
10993
|
+
log$F.error(e);
|
|
10864
10994
|
throw Error(e);
|
|
10865
10995
|
}
|
|
10866
10996
|
}
|
|
@@ -10871,18 +11001,18 @@ class KosModel {
|
|
|
10871
11001
|
}
|
|
10872
11002
|
const { modelTypeName, modelId } = this;
|
|
10873
11003
|
if (this.fsm.current === KosModelState.LOADED) {
|
|
10874
|
-
log$
|
|
11004
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} already loaded`);
|
|
10875
11005
|
return;
|
|
10876
11006
|
}
|
|
10877
11007
|
if (this._isLoadExecuting) {
|
|
10878
|
-
log$
|
|
11008
|
+
log$F.debug(
|
|
10879
11009
|
`Model ${modelTypeName} with id ${modelId} is currently executing load`
|
|
10880
11010
|
);
|
|
10881
11011
|
return;
|
|
10882
11012
|
}
|
|
10883
11013
|
this._isLoadExecuting = true;
|
|
10884
11014
|
try {
|
|
10885
|
-
log$
|
|
11015
|
+
log$F.debug(`Loading model ${modelTypeName} with id ${modelId}`);
|
|
10886
11016
|
await executeDependentModelLifecycle(this, DependencyLifecycle.LOAD);
|
|
10887
11017
|
const context = KosContextManager.getContext(modelId);
|
|
10888
11018
|
const MODEL_LOADER_TYPE = `${MODEL_LOADER}.${modelTypeName}`;
|
|
@@ -10891,7 +11021,7 @@ class KosModel {
|
|
|
10891
11021
|
{}
|
|
10892
11022
|
);
|
|
10893
11023
|
if (loadedContext) {
|
|
10894
|
-
log$
|
|
11024
|
+
log$F.info(
|
|
10895
11025
|
`Setting loaded context for ${modelId}, type: ${modelTypeName}`
|
|
10896
11026
|
);
|
|
10897
11027
|
context?.set(MODEL_LOADER_TYPE, loadedContext);
|
|
@@ -10903,7 +11033,7 @@ class KosModel {
|
|
|
10903
11033
|
kosAction(() => {
|
|
10904
11034
|
this.loaded = true;
|
|
10905
11035
|
});
|
|
10906
|
-
log$
|
|
11036
|
+
log$F.debug(
|
|
10907
11037
|
`Model ${modelTypeName} with id ${modelId} successfully loaded`
|
|
10908
11038
|
);
|
|
10909
11039
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.LOAD);
|
|
@@ -10912,14 +11042,14 @@ class KosModel {
|
|
|
10912
11042
|
this.effectManager?.setup();
|
|
10913
11043
|
this.createLifecycleCompanions(DependencyLifecycle.LOAD);
|
|
10914
11044
|
} catch (e) {
|
|
10915
|
-
log$
|
|
11045
|
+
log$F.error(`Model ${modelId} failed to load`, e);
|
|
10916
11046
|
throw e;
|
|
10917
11047
|
} finally {
|
|
10918
11048
|
this._isLoadExecuting = false;
|
|
10919
11049
|
}
|
|
10920
11050
|
}
|
|
10921
11051
|
async unload() {
|
|
10922
|
-
log$
|
|
11052
|
+
log$F.debug(`unloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10923
11053
|
try {
|
|
10924
11054
|
const childrenUnload = this.getChildren().map((child) => child.unload?.()).filter((p) => !!p);
|
|
10925
11055
|
await Promise.allSettled(childrenUnload);
|
|
@@ -10938,12 +11068,12 @@ class KosModel {
|
|
|
10938
11068
|
modelData.stateHistory = [];
|
|
10939
11069
|
}
|
|
10940
11070
|
}
|
|
10941
|
-
log$
|
|
11071
|
+
log$F.debug(`Model ${this.modelTypeName} with id ${this.modelId} unloaded`);
|
|
10942
11072
|
this.effectManager?.disposeAll();
|
|
10943
11073
|
this.subscriptionManager?.disposeAll();
|
|
10944
11074
|
this.httpRouteManager?.dispose();
|
|
10945
11075
|
} catch (e) {
|
|
10946
|
-
log$
|
|
11076
|
+
log$F.debug(`Model ${this.modelId} failed to unload`);
|
|
10947
11077
|
throw e;
|
|
10948
11078
|
}
|
|
10949
11079
|
}
|
|
@@ -10954,7 +11084,7 @@ class KosModel {
|
|
|
10954
11084
|
}
|
|
10955
11085
|
const { modelId, modelTypeName } = this;
|
|
10956
11086
|
const context = KosContextManager.getContext(modelId);
|
|
10957
|
-
log$
|
|
11087
|
+
log$F.debug(`Initializing model ${modelTypeName} with id ${modelId}`);
|
|
10958
11088
|
await executeDependentModelLifecycle(this, DependencyLifecycle.INIT);
|
|
10959
11089
|
try {
|
|
10960
11090
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -10962,18 +11092,18 @@ class KosModel {
|
|
|
10962
11092
|
);
|
|
10963
11093
|
await this.modelData?.init?.(context);
|
|
10964
11094
|
this.initialized = true;
|
|
10965
|
-
log$
|
|
11095
|
+
log$F.debug(`Model ${modelTypeName} with id ${modelId} initialized`);
|
|
10966
11096
|
this.onlineLifecycleManager?.register();
|
|
10967
11097
|
this.initializeStateMachineForLifecycle(DependencyLifecycle.INIT);
|
|
10968
11098
|
this.registerSubscribers(DependencyLifecycle.INIT);
|
|
10969
11099
|
this.createLifecycleCompanions(DependencyLifecycle.INIT);
|
|
10970
11100
|
} catch (e) {
|
|
10971
|
-
log$
|
|
11101
|
+
log$F.error(`Model ${modelId} failed to initialize`, e);
|
|
10972
11102
|
throw e;
|
|
10973
11103
|
}
|
|
10974
11104
|
}
|
|
10975
11105
|
async registerSubscribers(lifecycle) {
|
|
10976
|
-
log$
|
|
11106
|
+
log$F.debug(
|
|
10977
11107
|
`registering subscribers in ${this.modelTypeName} with id ${this.modelId}`
|
|
10978
11108
|
);
|
|
10979
11109
|
this.subscriptionManager?.registerAll(lifecycle);
|
|
@@ -10990,7 +11120,7 @@ class KosModel {
|
|
|
10990
11120
|
}
|
|
10991
11121
|
/** @internal */
|
|
10992
11122
|
async reloadData() {
|
|
10993
|
-
log$
|
|
11123
|
+
log$F.info(`reloading model ${this.modelTypeName} with id ${this.modelId}`);
|
|
10994
11124
|
this.suspendForReload();
|
|
10995
11125
|
const data = this.modelData;
|
|
10996
11126
|
if (typeof data?.reload === "function" && !data[SelfManagedReload]) {
|
|
@@ -10999,7 +11129,7 @@ class KosModel {
|
|
|
10999
11129
|
}
|
|
11000
11130
|
/** @internal */
|
|
11001
11131
|
async reattach() {
|
|
11002
|
-
log$
|
|
11132
|
+
log$F.info(`reattaching model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11003
11133
|
kosAction(() => {
|
|
11004
11134
|
this.loaded = true;
|
|
11005
11135
|
});
|
|
@@ -11030,7 +11160,7 @@ class KosModel {
|
|
|
11030
11160
|
]);
|
|
11031
11161
|
reloaded.forEach((result, index) => {
|
|
11032
11162
|
if (result.status === "rejected") {
|
|
11033
|
-
log$
|
|
11163
|
+
log$F.error(
|
|
11034
11164
|
`reload of child ${ready[index].modelId} of ${this.modelId} failed`,
|
|
11035
11165
|
result.reason
|
|
11036
11166
|
);
|
|
@@ -11061,7 +11191,7 @@ class KosModel {
|
|
|
11061
11191
|
* each time. A state machine with `initializeAt: ONLINE` starts once.
|
|
11062
11192
|
*/
|
|
11063
11193
|
async online() {
|
|
11064
|
-
log$
|
|
11194
|
+
log$F.debug(`online model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11065
11195
|
this.registerSubscribers();
|
|
11066
11196
|
await executeDependentModelLifecycle(this, DependencyLifecycle.ONLINE);
|
|
11067
11197
|
await this.serviceRequestManager?.executeForLifecycle(
|
|
@@ -11073,7 +11203,7 @@ class KosModel {
|
|
|
11073
11203
|
this.createLifecycleCompanions(DependencyLifecycle.ONLINE);
|
|
11074
11204
|
}
|
|
11075
11205
|
async offline() {
|
|
11076
|
-
log$
|
|
11206
|
+
log$F.debug(`offline model ${this.modelTypeName} with id ${this.modelId}`);
|
|
11077
11207
|
this.subscriptionManager?.disposeAll();
|
|
11078
11208
|
const context = KosContextManager.getContext(this.modelId);
|
|
11079
11209
|
await this.modelData?.offline?.(context);
|
|
@@ -11091,7 +11221,10 @@ class KosModel {
|
|
|
11091
11221
|
this.companionManager.clear();
|
|
11092
11222
|
}
|
|
11093
11223
|
}
|
|
11094
|
-
const log$
|
|
11224
|
+
const log$E = KosLog.createLogger({
|
|
11225
|
+
group: LogGroup.core,
|
|
11226
|
+
name: "kos-model-instantiator"
|
|
11227
|
+
});
|
|
11095
11228
|
class KosModelInstantiator {
|
|
11096
11229
|
constructor(registry, cache2) {
|
|
11097
11230
|
this.registry = registry;
|
|
@@ -11109,7 +11242,7 @@ class KosModelInstantiator {
|
|
|
11109
11242
|
const modelRegistry = this.registry.models[typeId];
|
|
11110
11243
|
if (!modelRegistry) {
|
|
11111
11244
|
const errorMessage = `No model registered for type ${typeId}`;
|
|
11112
|
-
log$
|
|
11245
|
+
log$E.error(errorMessage, {
|
|
11113
11246
|
modelType: typeId,
|
|
11114
11247
|
requestedId: id,
|
|
11115
11248
|
providedOptions: options,
|
|
@@ -11128,7 +11261,7 @@ class KosModelInstantiator {
|
|
|
11128
11261
|
const modelId = modelRegistry.singleton ? typeId : id;
|
|
11129
11262
|
this.cache.restoreFromDeleteCache(modelId);
|
|
11130
11263
|
if (!this.cache.hasModel(modelId)) {
|
|
11131
|
-
log$
|
|
11264
|
+
log$E.debug(`Creating model instance: ${typeId} [${modelId}]`);
|
|
11132
11265
|
const hasOptions = options && Object.keys(options).length > 0;
|
|
11133
11266
|
const modelClass = modelRegistry.class || modelRegistry.create;
|
|
11134
11267
|
const requiresOptions = modelClass?.prototype?.[OptionsRequired] === true;
|
|
@@ -11174,7 +11307,7 @@ class KosModelInstantiator {
|
|
|
11174
11307
|
}
|
|
11175
11308
|
const activeModel = this.cache.getModelById(modelId);
|
|
11176
11309
|
if (!activeModel) {
|
|
11177
|
-
log$
|
|
11310
|
+
log$E.error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11178
11311
|
throw new Error(`Model ${typeId} [${modelId}] not found in cache`);
|
|
11179
11312
|
}
|
|
11180
11313
|
return { model: activeModel, data: activeModel.modelData };
|
|
@@ -11240,7 +11373,10 @@ let KosModelRegistry$1 = class KosModelRegistry {
|
|
|
11240
11373
|
}
|
|
11241
11374
|
};
|
|
11242
11375
|
const MODEL_DELETION_DELAY = 10;
|
|
11243
|
-
const log$
|
|
11376
|
+
const log$D = KosLog.createLogger({
|
|
11377
|
+
group: LogGroup.core,
|
|
11378
|
+
name: "kos-model-manager"
|
|
11379
|
+
});
|
|
11244
11380
|
class KosModelManager {
|
|
11245
11381
|
cache;
|
|
11246
11382
|
instantiator;
|
|
@@ -11283,7 +11419,7 @@ class KosModelManager {
|
|
|
11283
11419
|
}
|
|
11284
11420
|
static getInstance(reset2) {
|
|
11285
11421
|
if (!globalThis.kos?.modelManager || reset2) {
|
|
11286
|
-
log$
|
|
11422
|
+
log$D.debug("Creating new instance of KosModelManager");
|
|
11287
11423
|
new this();
|
|
11288
11424
|
}
|
|
11289
11425
|
return globalThis.kos?.modelManager;
|
|
@@ -11304,7 +11440,7 @@ class KosModelManager {
|
|
|
11304
11440
|
*/
|
|
11305
11441
|
get preloadedModels() {
|
|
11306
11442
|
return this.cache.preload((modelKey) => {
|
|
11307
|
-
log$
|
|
11443
|
+
log$D.debug(`preloading ${modelKey}`);
|
|
11308
11444
|
if (typeof modelKey === "string") {
|
|
11309
11445
|
return this.createModelInstance(modelKey).model;
|
|
11310
11446
|
} else {
|
|
@@ -11600,6 +11736,10 @@ class KosModelManager {
|
|
|
11600
11736
|
this._registry.registerModel(reg);
|
|
11601
11737
|
}
|
|
11602
11738
|
}
|
|
11739
|
+
const log$C = KosLog.createLogger({
|
|
11740
|
+
group: LogGroup.core,
|
|
11741
|
+
name: "kos-core-lifecycle"
|
|
11742
|
+
});
|
|
11603
11743
|
var KosCoreState = /* @__PURE__ */ ((KosCoreState2) => {
|
|
11604
11744
|
KosCoreState2["CREATING"] = `creating`;
|
|
11605
11745
|
KosCoreState2["CREATED"] = `created`;
|
|
@@ -11636,7 +11776,7 @@ const reportFailure = async (step, run) => {
|
|
|
11636
11776
|
return await run();
|
|
11637
11777
|
} catch (error) {
|
|
11638
11778
|
const detail = error instanceof Error ? error.stack ?? `${error.name}: ${error.message}` : String(error);
|
|
11639
|
-
log$
|
|
11779
|
+
log$C.error(`KOS Core lifecycle step "${step}" failed. ${detail}`);
|
|
11640
11780
|
throw error;
|
|
11641
11781
|
}
|
|
11642
11782
|
};
|
|
@@ -11675,7 +11815,7 @@ const coreFsm = (core) => {
|
|
|
11675
11815
|
});
|
|
11676
11816
|
const online = robot3.interpret(
|
|
11677
11817
|
onlineMachine2,
|
|
11678
|
-
(_service) => log$
|
|
11818
|
+
(_service) => log$C.debug(`KOS Core connection: ${_service.machine.current}`)
|
|
11679
11819
|
);
|
|
11680
11820
|
const syncOnline = () => online.send(
|
|
11681
11821
|
core.transport.connectionEstablished ? "go_online" : "go_offline"
|
|
@@ -11889,11 +12029,11 @@ const coreFsm = (core) => {
|
|
|
11889
12029
|
});
|
|
11890
12030
|
const service2 = robot3.interpret(
|
|
11891
12031
|
machine2,
|
|
11892
|
-
(_service) => log$
|
|
12032
|
+
(_service) => log$C.debug(`KOS Core state: ${_service.machine.current}`)
|
|
11893
12033
|
);
|
|
11894
12034
|
return { service: service2, online };
|
|
11895
12035
|
};
|
|
11896
|
-
const log$
|
|
12036
|
+
const log$B = KosLog.createLogger({ group: LogGroup.core, name: "kos-core" });
|
|
11897
12037
|
const getConnectionAlias = () => {
|
|
11898
12038
|
const params2 = getQueryParams();
|
|
11899
12039
|
const alias = params2?.alias;
|
|
@@ -11947,11 +12087,11 @@ const rejectAfterDelay = (ms, model) => {
|
|
|
11947
12087
|
const promise = new Promise((_, reject) => {
|
|
11948
12088
|
timeoutId = setTimeout(() => {
|
|
11949
12089
|
if (model) {
|
|
11950
|
-
|
|
12090
|
+
log$B.error(
|
|
11951
12091
|
`Model ${model.modelId} - ${model.modelTypeName} preloading - timed out after ${ms}ms`
|
|
11952
12092
|
);
|
|
11953
12093
|
} else {
|
|
11954
|
-
|
|
12094
|
+
log$B.error(`KOS Core preloading timed out after ${ms}ms`);
|
|
11955
12095
|
}
|
|
11956
12096
|
reject(
|
|
11957
12097
|
new Error(
|
|
@@ -12036,11 +12176,11 @@ class KosCore {
|
|
|
12036
12176
|
});
|
|
12037
12177
|
});
|
|
12038
12178
|
subscribe(WebSocketEvents.RELOAD, () => {
|
|
12039
|
-
log$
|
|
12179
|
+
log$B.warn("WebSocket requested reload");
|
|
12040
12180
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12041
12181
|
});
|
|
12042
12182
|
subscribe("/studio/project/reload", () => {
|
|
12043
|
-
log$
|
|
12183
|
+
log$B.warn("Project requested reload");
|
|
12044
12184
|
this.fsmService.service.send(KosCoreEvents.RELOAD);
|
|
12045
12185
|
});
|
|
12046
12186
|
const ws = WebSocketTransport.getInstance();
|
|
@@ -12069,7 +12209,7 @@ class KosCore {
|
|
|
12069
12209
|
applyConnectionAlias(connectionAlias) {
|
|
12070
12210
|
if (this._transport.alias) {
|
|
12071
12211
|
if (this.connectionAlias && this.connectionAlias !== connectionAlias) {
|
|
12072
|
-
log$
|
|
12212
|
+
log$B.warn(
|
|
12073
12213
|
`Connection alias ${connectionAlias} ignored; the connection already uses ${this._transport.alias}`
|
|
12074
12214
|
);
|
|
12075
12215
|
}
|
|
@@ -12107,13 +12247,13 @@ alias:${alias}
|
|
|
12107
12247
|
}
|
|
12108
12248
|
async reload() {
|
|
12109
12249
|
if (this._reloading) {
|
|
12110
|
-
log$
|
|
12250
|
+
log$B.info("reload already in progress");
|
|
12111
12251
|
return;
|
|
12112
12252
|
}
|
|
12113
12253
|
this._reloading = true;
|
|
12114
12254
|
try {
|
|
12115
|
-
log$
|
|
12116
|
-
log$
|
|
12255
|
+
log$B.warn("reloading KOS Core");
|
|
12256
|
+
log$B.warn("reloading preloaded models");
|
|
12117
12257
|
const modelManager = this.modelManager;
|
|
12118
12258
|
const preloaded = [...modelManager.preloadedModels];
|
|
12119
12259
|
const covered = /* @__PURE__ */ new Set();
|
|
@@ -12125,27 +12265,27 @@ alias:${alias}
|
|
|
12125
12265
|
for (const model of preloaded) {
|
|
12126
12266
|
if (isReloadable(model.modelData) && !covered.has(model)) {
|
|
12127
12267
|
if (isSelfManagedReload(model.modelData)) {
|
|
12128
|
-
log$
|
|
12268
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12129
12269
|
continue;
|
|
12130
12270
|
}
|
|
12131
|
-
log$
|
|
12271
|
+
log$B.info(`reloading model ${model.modelId}`);
|
|
12132
12272
|
await reloadRoot(model);
|
|
12133
|
-
log$
|
|
12273
|
+
log$B.info(`reloading model ${model.modelId} complete`);
|
|
12134
12274
|
}
|
|
12135
12275
|
}
|
|
12136
12276
|
for (const model of [...modelManager.models]) {
|
|
12137
12277
|
if (!preloaded.includes(model) && isReloadable(model.modelData) && !covered.has(model)) {
|
|
12138
12278
|
if (isSelfManagedReload(model.modelData)) {
|
|
12139
|
-
log$
|
|
12279
|
+
log$B.info(`skipping self-managed model ${model.modelId}`);
|
|
12140
12280
|
continue;
|
|
12141
12281
|
}
|
|
12142
|
-
log$
|
|
12282
|
+
log$B.warn(`reloading model ${model.modelId}`);
|
|
12143
12283
|
await reloadRoot(model);
|
|
12144
12284
|
}
|
|
12145
12285
|
}
|
|
12146
12286
|
} finally {
|
|
12147
12287
|
mobx.runInAction(() => {
|
|
12148
|
-
log$
|
|
12288
|
+
log$B.warn("reloading KOS Core complete");
|
|
12149
12289
|
this._reloading = false;
|
|
12150
12290
|
});
|
|
12151
12291
|
}
|
|
@@ -12155,13 +12295,13 @@ alias:${alias}
|
|
|
12155
12295
|
try {
|
|
12156
12296
|
await model.fsm.reload();
|
|
12157
12297
|
} catch (e) {
|
|
12158
|
-
log$
|
|
12298
|
+
log$B.error(`reload of ${model.modelId} failed`, e);
|
|
12159
12299
|
}
|
|
12160
12300
|
}
|
|
12161
12301
|
async online() {
|
|
12162
|
-
log$
|
|
12302
|
+
log$B.debug("KOS Core going online");
|
|
12163
12303
|
await this._transport.whenReady();
|
|
12164
|
-
log$
|
|
12304
|
+
log$B.debug("KOS Transport Ready. Calling online() for models");
|
|
12165
12305
|
this.modelManager.models.forEach(
|
|
12166
12306
|
(model) => model.onlineLifecycleManager?.register()
|
|
12167
12307
|
);
|
|
@@ -12169,14 +12309,14 @@ alias:${alias}
|
|
|
12169
12309
|
console.timeEnd("kosCore:startup");
|
|
12170
12310
|
}
|
|
12171
12311
|
async offline() {
|
|
12172
|
-
log$
|
|
12312
|
+
log$B.debug("KOS Core going offline");
|
|
12173
12313
|
publish("/kosCore/offline", "/kosCore/offline");
|
|
12174
12314
|
}
|
|
12175
12315
|
async unload() {
|
|
12176
|
-
log$
|
|
12316
|
+
log$B.debug("Unloading KOS Core");
|
|
12177
12317
|
const currentTime = Date.now();
|
|
12178
12318
|
this._unloading = true;
|
|
12179
|
-
log$
|
|
12319
|
+
log$B.debug("unloading KOS Core");
|
|
12180
12320
|
const modelManager = this.modelManager;
|
|
12181
12321
|
for (const model of modelManager.models) {
|
|
12182
12322
|
if (isUnloadable(model.modelData)) {
|
|
@@ -12194,9 +12334,9 @@ alias:${alias}
|
|
|
12194
12334
|
await mobx.when(() => this.status === KosCoreState.READY);
|
|
12195
12335
|
}
|
|
12196
12336
|
async ready() {
|
|
12197
|
-
log$
|
|
12337
|
+
log$B.debug("Readying KOS Core");
|
|
12198
12338
|
await this._transport.whenReady();
|
|
12199
|
-
log$
|
|
12339
|
+
log$B.debug("KOS Transport ready. Preloading models");
|
|
12200
12340
|
if (!this.modelManager) {
|
|
12201
12341
|
throw new Error(
|
|
12202
12342
|
"KOS Core reached ready() with no model manager. Its lifecycle was started without a registry."
|
|
@@ -12209,7 +12349,7 @@ alias:${alias}
|
|
|
12209
12349
|
promise: model.whenReady()
|
|
12210
12350
|
};
|
|
12211
12351
|
});
|
|
12212
|
-
log$
|
|
12352
|
+
log$B.debug(`Preloaded ${promises.length} models`);
|
|
12213
12353
|
const settled = await Promise.allSettled(
|
|
12214
12354
|
promises.map((promise) => {
|
|
12215
12355
|
const { promise: timeoutPromise, cancel: timeoutCancel } = rejectAfterDelay(5e3, promise.model);
|
|
@@ -12223,14 +12363,14 @@ alias:${alias}
|
|
|
12223
12363
|
);
|
|
12224
12364
|
const failed = settled.filter((p) => p.status === "rejected");
|
|
12225
12365
|
if (failed.length) {
|
|
12226
|
-
log$
|
|
12366
|
+
log$B.error(
|
|
12227
12367
|
`There were ${failed.length} failed models on model preloading`
|
|
12228
12368
|
);
|
|
12229
12369
|
throw Error(
|
|
12230
12370
|
`There were ${failed.length} failed models on model preloading`
|
|
12231
12371
|
);
|
|
12232
12372
|
}
|
|
12233
|
-
log$
|
|
12373
|
+
log$B.debug(`leaving kos-core ready() `);
|
|
12234
12374
|
}
|
|
12235
12375
|
get isReady() {
|
|
12236
12376
|
return this.status === KosCoreState.READY;
|
|
@@ -12248,19 +12388,19 @@ alias:${alias}
|
|
|
12248
12388
|
return this.loaded;
|
|
12249
12389
|
}
|
|
12250
12390
|
async init() {
|
|
12251
|
-
log$
|
|
12391
|
+
log$B.debug("entering kos-core init()");
|
|
12252
12392
|
console.time("kosCore:startup");
|
|
12253
12393
|
console.time("kosCore:init");
|
|
12254
12394
|
await this._transport.whenReady();
|
|
12255
12395
|
this.initialized = true;
|
|
12256
|
-
log$
|
|
12396
|
+
log$B.debug("initialized - leaving kos-core init()");
|
|
12257
12397
|
console.timeEnd("kosCore:init");
|
|
12258
12398
|
}
|
|
12259
12399
|
async load() {
|
|
12260
|
-
log$
|
|
12400
|
+
log$B.debug("entering kos-core load()");
|
|
12261
12401
|
console.time("kosCore:load");
|
|
12262
12402
|
this.loaded = true;
|
|
12263
|
-
log$
|
|
12403
|
+
log$B.debug("loaded - leaving kos-core load()");
|
|
12264
12404
|
console.timeEnd("kosCore:load");
|
|
12265
12405
|
}
|
|
12266
12406
|
static create(registry, reset2, connectionAlias) {
|
|
@@ -12350,9 +12490,9 @@ alias:${alias}
|
|
|
12350
12490
|
return this._instance;
|
|
12351
12491
|
}
|
|
12352
12492
|
}
|
|
12353
|
-
const log$
|
|
12354
|
-
|
|
12355
|
-
|
|
12493
|
+
const log$A = KosLog.createLogger({
|
|
12494
|
+
group: LogGroup.core,
|
|
12495
|
+
name: "kos-model-visitor"
|
|
12356
12496
|
});
|
|
12357
12497
|
class KosModelVisitor {
|
|
12358
12498
|
/**
|
|
@@ -12391,7 +12531,7 @@ class KosModelVisitor {
|
|
|
12391
12531
|
*/
|
|
12392
12532
|
visit(model) {
|
|
12393
12533
|
if (this.visitedModels.has(model.modelId)) {
|
|
12394
|
-
log$
|
|
12534
|
+
log$A.info(`model ${model.modelId} already visited`);
|
|
12395
12535
|
return;
|
|
12396
12536
|
}
|
|
12397
12537
|
const stopVisiting = !!this.visitModel(model.modelData, this);
|
|
@@ -12404,6 +12544,10 @@ class KosModelVisitor {
|
|
|
12404
12544
|
});
|
|
12405
12545
|
}
|
|
12406
12546
|
}
|
|
12547
|
+
const log$z = KosLog.createLogger({
|
|
12548
|
+
group: LogGroup.core,
|
|
12549
|
+
name: "feature-flags"
|
|
12550
|
+
});
|
|
12407
12551
|
const EXTENSION_FEATURE_FLAG_RESOLVER = "featureFlagResolver";
|
|
12408
12552
|
const flagResolvers = /* @__PURE__ */ new Map();
|
|
12409
12553
|
registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
@@ -12424,7 +12568,7 @@ registerExtensionPoint(EXTENSION_FEATURE_FLAG_RESOLVER, {
|
|
|
12424
12568
|
if (r.status === "fulfilled") {
|
|
12425
12569
|
return r.value;
|
|
12426
12570
|
} else {
|
|
12427
|
-
|
|
12571
|
+
log$z.info(`Feature flag resolver ${id} failed: ${r.reason}`);
|
|
12428
12572
|
return [];
|
|
12429
12573
|
}
|
|
12430
12574
|
}).flat();
|
|
@@ -12497,7 +12641,41 @@ const modelFactory = (typeId) => {
|
|
|
12497
12641
|
};
|
|
12498
12642
|
};
|
|
12499
12643
|
const pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);
|
|
12500
|
-
const log$
|
|
12644
|
+
const log$y = KosLog.createLogger({
|
|
12645
|
+
group: LogGroup.core,
|
|
12646
|
+
name: "retry-with-exponential-backoff"
|
|
12647
|
+
});
|
|
12648
|
+
const BASE_OPTIONS = {
|
|
12649
|
+
maxAttempts: 5,
|
|
12650
|
+
baseDelayMs: 100,
|
|
12651
|
+
backoffFactor: 1.5
|
|
12652
|
+
};
|
|
12653
|
+
async function retryWithExponentialBackoff(operation, options) {
|
|
12654
|
+
let attempt = 1;
|
|
12655
|
+
const _options = { ...BASE_OPTIONS, ...options };
|
|
12656
|
+
const { maxAttempts, baseDelayMs, backoffFactor } = _options;
|
|
12657
|
+
let delayMs = baseDelayMs;
|
|
12658
|
+
while (attempt <= maxAttempts) {
|
|
12659
|
+
try {
|
|
12660
|
+
const result = await operation();
|
|
12661
|
+
return result;
|
|
12662
|
+
} catch (error) {
|
|
12663
|
+
log$y.error(`Attempt ${attempt} failed: ${error}`);
|
|
12664
|
+
if (attempt < maxAttempts) {
|
|
12665
|
+
delayMs = baseDelayMs * Math.pow(backoffFactor, attempt);
|
|
12666
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
12667
|
+
attempt++;
|
|
12668
|
+
} else {
|
|
12669
|
+
throw error;
|
|
12670
|
+
}
|
|
12671
|
+
}
|
|
12672
|
+
}
|
|
12673
|
+
throw new Error("All attempts failed");
|
|
12674
|
+
}
|
|
12675
|
+
const log$x = KosLog.createLogger({
|
|
12676
|
+
group: LogGroup.transport,
|
|
12677
|
+
name: "kos-service-request"
|
|
12678
|
+
});
|
|
12501
12679
|
const resolveServiceUrl = (_service) => {
|
|
12502
12680
|
const MOCK = false;
|
|
12503
12681
|
const URL2 = exports.BASE_URL;
|
|
@@ -12669,7 +12847,7 @@ const getOne$7 = (destinationAddress, url, _fetch) => async ({
|
|
|
12669
12847
|
destinationAddress: destinationAddressOverride
|
|
12670
12848
|
});
|
|
12671
12849
|
const resolvedUrl = urlOverride || url;
|
|
12672
|
-
log$
|
|
12850
|
+
log$x.debug(`resolvedUrl: ${resolvedUrl}`);
|
|
12673
12851
|
try {
|
|
12674
12852
|
const response = await _fetch(resolvedUrl, options);
|
|
12675
12853
|
if (!response.ok) {
|
|
@@ -12988,6 +13166,62 @@ const ServiceFactory = {
|
|
|
12988
13166
|
const _sessionKey = uuid();
|
|
12989
13167
|
const getKosSessionKey = () => `kos-${_sessionKey}`;
|
|
12990
13168
|
const isLocalRefId = (id) => !!id && !id.includes("VM_SERVICE") && id.startsWith(getKosSessionKey());
|
|
13169
|
+
const log$w = KosLog.createLogger({
|
|
13170
|
+
group: LogGroup.transport,
|
|
13171
|
+
name: "wait-for-request"
|
|
13172
|
+
});
|
|
13173
|
+
const waitForRequest = async (requestId, timeout = 6e4) => new Promise((resolve, reject) => {
|
|
13174
|
+
const { unsubscribe } = subscribe(requestId, (op) => {
|
|
13175
|
+
log$w.debug(`recieved response for refId ${requestId}: ${op}`);
|
|
13176
|
+
unsubscribe();
|
|
13177
|
+
clearTimeout(cancel);
|
|
13178
|
+
try {
|
|
13179
|
+
const body = op?.body ? JSON.parse(op.body) : {};
|
|
13180
|
+
resolve(body);
|
|
13181
|
+
} catch {
|
|
13182
|
+
const body = op?.body || {};
|
|
13183
|
+
resolve(body);
|
|
13184
|
+
}
|
|
13185
|
+
});
|
|
13186
|
+
const cancel = setTimeout(() => {
|
|
13187
|
+
unsubscribe();
|
|
13188
|
+
reject(Error(`Request with ID ${requestId} timed out. Cancelling.`));
|
|
13189
|
+
}, timeout);
|
|
13190
|
+
});
|
|
13191
|
+
const sendRequest = async (requestPromise, params2, refId) => {
|
|
13192
|
+
const op = waitForRequest(refId);
|
|
13193
|
+
const result = await Promise.allSettled([requestPromise(params2), op]);
|
|
13194
|
+
if (result[0].status === "fulfilled") {
|
|
13195
|
+
if (result[1].status === "rejected") {
|
|
13196
|
+
throw Error(result[1].reason);
|
|
13197
|
+
} else {
|
|
13198
|
+
if (result[0].value) {
|
|
13199
|
+
if (result[1].value.error) {
|
|
13200
|
+
throw Error(result[1].value.error);
|
|
13201
|
+
}
|
|
13202
|
+
result[0].value.data = result[1].value;
|
|
13203
|
+
return result[0].value;
|
|
13204
|
+
}
|
|
13205
|
+
}
|
|
13206
|
+
} else {
|
|
13207
|
+
throw Error(result[0].reason);
|
|
13208
|
+
}
|
|
13209
|
+
return void 0;
|
|
13210
|
+
};
|
|
13211
|
+
const syncPublish = async ({
|
|
13212
|
+
topic,
|
|
13213
|
+
msg,
|
|
13214
|
+
requestId
|
|
13215
|
+
}) => {
|
|
13216
|
+
const _requestId = requestId ?? uuid();
|
|
13217
|
+
const responsePromise = waitForRequest(_requestId);
|
|
13218
|
+
publish(topic, msg, { sync: _requestId });
|
|
13219
|
+
const response = await responsePromise;
|
|
13220
|
+
if (response.error) {
|
|
13221
|
+
throw Error(response.error);
|
|
13222
|
+
}
|
|
13223
|
+
return response;
|
|
13224
|
+
};
|
|
12991
13225
|
const contextMap = /* @__PURE__ */ new Map();
|
|
12992
13226
|
class KosContextBean {
|
|
12993
13227
|
_context;
|
|
@@ -13084,7 +13318,10 @@ const KosContextManager = {
|
|
|
13084
13318
|
};
|
|
13085
13319
|
KosContextManager.createContext("root");
|
|
13086
13320
|
const resolveKosContext = (model) => KosContextManager.getContext(model.id);
|
|
13087
|
-
const log$
|
|
13321
|
+
const log$v = KosLog.createLogger({
|
|
13322
|
+
group: LogGroup.core,
|
|
13323
|
+
name: "kos-data-container"
|
|
13324
|
+
});
|
|
13088
13325
|
class KosDataContainer {
|
|
13089
13326
|
_data;
|
|
13090
13327
|
_sortKey;
|
|
@@ -13289,7 +13526,7 @@ class KosDataContainer {
|
|
|
13289
13526
|
const idx = this.index.get(indexName);
|
|
13290
13527
|
return idx.keys ?? [];
|
|
13291
13528
|
} else {
|
|
13292
|
-
log$
|
|
13529
|
+
log$v.info(
|
|
13293
13530
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13294
13531
|
);
|
|
13295
13532
|
return [];
|
|
@@ -13301,7 +13538,7 @@ class KosDataContainer {
|
|
|
13301
13538
|
if (idx.index.has(indexKey)) {
|
|
13302
13539
|
return idx.getByKey(indexKey);
|
|
13303
13540
|
} else {
|
|
13304
|
-
log$
|
|
13541
|
+
log$v.info(
|
|
13305
13542
|
`key ${indexKey} not found in ${indexName} index: ${Array.from(
|
|
13306
13543
|
idx.index.keys()
|
|
13307
13544
|
)}`
|
|
@@ -13309,7 +13546,7 @@ class KosDataContainer {
|
|
|
13309
13546
|
return [];
|
|
13310
13547
|
}
|
|
13311
13548
|
} else {
|
|
13312
|
-
log$
|
|
13549
|
+
log$v.info(
|
|
13313
13550
|
`index ${indexName} not found in ${Array.from(this.index.keys())}`
|
|
13314
13551
|
);
|
|
13315
13552
|
return [];
|
|
@@ -13336,7 +13573,7 @@ class KosDataContainer {
|
|
|
13336
13573
|
* @private
|
|
13337
13574
|
*/
|
|
13338
13575
|
_logDataCapacityWarning(toEvict) {
|
|
13339
|
-
log$
|
|
13576
|
+
log$v.info(
|
|
13340
13577
|
`Data container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${toEvict} items using ${this._evictionStrategy} strategy. This may indicate missing cleanup handlers or data inconsistency.`
|
|
13341
13578
|
);
|
|
13342
13579
|
}
|
|
@@ -13396,7 +13633,7 @@ class KosDataContainer {
|
|
|
13396
13633
|
const candidates = this._customEvictionFilter(this.data);
|
|
13397
13634
|
return candidates.slice(0, count).map((item) => item.id);
|
|
13398
13635
|
}
|
|
13399
|
-
log$
|
|
13636
|
+
log$v.error(
|
|
13400
13637
|
"Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO."
|
|
13401
13638
|
);
|
|
13402
13639
|
return this._selectFifoData(count);
|
|
@@ -13408,7 +13645,7 @@ class KosDataContainer {
|
|
|
13408
13645
|
_removeEvictedData(ids) {
|
|
13409
13646
|
ids.forEach((id) => {
|
|
13410
13647
|
const item = this._data.get(id);
|
|
13411
|
-
log$
|
|
13648
|
+
log$v.info(`Evicting data item: ${id}`, {
|
|
13412
13649
|
itemId: id,
|
|
13413
13650
|
itemType: item ? item.constructor?.name : "unknown",
|
|
13414
13651
|
strategy: this._evictionStrategy
|
|
@@ -13421,7 +13658,7 @@ class KosDataContainer {
|
|
|
13421
13658
|
* @private
|
|
13422
13659
|
*/
|
|
13423
13660
|
_logDataEvictionComplete(evictedCount) {
|
|
13424
|
-
log$
|
|
13661
|
+
log$v.info(
|
|
13425
13662
|
`Evicted ${evictedCount} data items. Current size: ${this._data.size}/${this._maxCapacity}`
|
|
13426
13663
|
);
|
|
13427
13664
|
}
|
|
@@ -13593,14 +13830,17 @@ class BrowserKosRouter {
|
|
|
13593
13830
|
}, {});
|
|
13594
13831
|
}
|
|
13595
13832
|
}
|
|
13596
|
-
const log$
|
|
13833
|
+
const log$u = KosLog.createLogger({
|
|
13834
|
+
group: LogGroup.core,
|
|
13835
|
+
name: "intent-service"
|
|
13836
|
+
});
|
|
13597
13837
|
const sendIntent = (intent) => {
|
|
13598
13838
|
if (hasEventSubscriptions(`/kos/intent/${intent.type}`)) {
|
|
13599
13839
|
publish(`/kos/intent/${intent.type}`, intent.options, {
|
|
13600
13840
|
"kos.intent.type": intent.type
|
|
13601
13841
|
});
|
|
13602
13842
|
} else {
|
|
13603
|
-
log$
|
|
13843
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13604
13844
|
}
|
|
13605
13845
|
};
|
|
13606
13846
|
const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
@@ -13630,11 +13870,14 @@ const sendAsyncIntent = async (intent) => new Promise((resolve) => {
|
|
|
13630
13870
|
sync: requestId
|
|
13631
13871
|
});
|
|
13632
13872
|
} else {
|
|
13633
|
-
log$
|
|
13873
|
+
log$u.info(`No subscribers for intent ${intent.type}. Intent not sent.`);
|
|
13634
13874
|
resolve([null, { body: void 0, payload: void 0 }]);
|
|
13635
13875
|
}
|
|
13636
13876
|
});
|
|
13637
|
-
const log$
|
|
13877
|
+
const log$t = KosLog.createLogger({
|
|
13878
|
+
group: LogGroup.core,
|
|
13879
|
+
name: "app-startup-service"
|
|
13880
|
+
});
|
|
13638
13881
|
async function waitForAppsToStart(appIds, options = {}) {
|
|
13639
13882
|
const {
|
|
13640
13883
|
timeout = 3e4,
|
|
@@ -13642,10 +13885,10 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13642
13885
|
requirePostStarted = false
|
|
13643
13886
|
} = options;
|
|
13644
13887
|
if (appIds.length === 0) {
|
|
13645
|
-
log$
|
|
13888
|
+
log$t.warn("No app IDs provided to waitForAppsToStart");
|
|
13646
13889
|
return true;
|
|
13647
13890
|
}
|
|
13648
|
-
log$
|
|
13891
|
+
log$t.debug(`Waiting for apps to start: ${appIds.join(", ")}`);
|
|
13649
13892
|
try {
|
|
13650
13893
|
const eventTopics = appIds.map((appId) => `/kos/app/started/${appId}`);
|
|
13651
13894
|
const startedApps = await waitForAllWithState(eventTopics, {
|
|
@@ -13654,12 +13897,12 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13654
13897
|
const { default: api2 } = await Promise.resolve().then(() => service);
|
|
13655
13898
|
const [error, data] = await api2.get("/api/kos/apps/started");
|
|
13656
13899
|
if (error) {
|
|
13657
|
-
log$
|
|
13900
|
+
log$t.error("Error fetching started apps:", error);
|
|
13658
13901
|
return [];
|
|
13659
13902
|
}
|
|
13660
13903
|
return data;
|
|
13661
13904
|
} catch (error) {
|
|
13662
|
-
log$
|
|
13905
|
+
log$t.error("Failed to fetch app startup status:", error);
|
|
13663
13906
|
}
|
|
13664
13907
|
return [];
|
|
13665
13908
|
},
|
|
@@ -13681,17 +13924,17 @@ async function waitForAppsToStart(appIds, options = {}) {
|
|
|
13681
13924
|
});
|
|
13682
13925
|
if (notStartedApps.length > 0) {
|
|
13683
13926
|
const message = `Apps not started: ${notStartedApps.join(", ")}`;
|
|
13684
|
-
log$
|
|
13927
|
+
log$t.error(message);
|
|
13685
13928
|
if (throwOnTimeout) {
|
|
13686
13929
|
throw new Error(`App startup timeout: ${message}`);
|
|
13687
13930
|
}
|
|
13688
13931
|
return false;
|
|
13689
13932
|
}
|
|
13690
|
-
log$
|
|
13933
|
+
log$t.info(`All apps started successfully: ${appIds.join(", ")}`);
|
|
13691
13934
|
return true;
|
|
13692
13935
|
} catch (error) {
|
|
13693
13936
|
const message = `Failed to wait for apps to start: ${appIds.join(", ")}`;
|
|
13694
|
-
log$
|
|
13937
|
+
log$t.error(message, error);
|
|
13695
13938
|
if (throwOnTimeout) {
|
|
13696
13939
|
throw new Error(
|
|
13697
13940
|
`${message} - ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -13718,7 +13961,7 @@ async function checkAppsStarted(appIds, requirePostStarted = false) {
|
|
|
13718
13961
|
result[appId] = app?.started === true && (!requirePostStarted || app?.postStarted === true);
|
|
13719
13962
|
});
|
|
13720
13963
|
} catch (error) {
|
|
13721
|
-
log$
|
|
13964
|
+
log$t.error("Failed to check app startup status:", error);
|
|
13722
13965
|
appIds.forEach((appId) => result[appId] = false);
|
|
13723
13966
|
}
|
|
13724
13967
|
return result;
|
|
@@ -13732,7 +13975,7 @@ async function getStartedApps() {
|
|
|
13732
13975
|
const result = await response.json();
|
|
13733
13976
|
return result?.data ?? [];
|
|
13734
13977
|
} catch (error) {
|
|
13735
|
-
log$
|
|
13978
|
+
log$t.error("Failed to fetch started apps:", error);
|
|
13736
13979
|
return [];
|
|
13737
13980
|
}
|
|
13738
13981
|
}
|
|
@@ -13759,9 +14002,9 @@ var Topics = /* @__PURE__ */ ((Topics2) => {
|
|
|
13759
14002
|
Topics2["TIMEZONE_CHANGE"] = "/kos/internal/time/timezone";
|
|
13760
14003
|
return Topics2;
|
|
13761
14004
|
})(Topics || {});
|
|
13762
|
-
const log$
|
|
13763
|
-
|
|
13764
|
-
|
|
14005
|
+
const log$s = KosLog.createLogger({
|
|
14006
|
+
group: LogGroup.service,
|
|
14007
|
+
name: "config-bean-service"
|
|
13765
14008
|
});
|
|
13766
14009
|
const URL$e = exports.BASE_URL;
|
|
13767
14010
|
const hasDecimals = (option) => option?.decimals !== void 0;
|
|
@@ -13770,7 +14013,7 @@ const { postModel: postModel$5, getOne: getOne$6 } = ServiceFactory.build({
|
|
|
13770
14013
|
basePath: `${URL$e}/kos/config/`
|
|
13771
14014
|
});
|
|
13772
14015
|
const modifyConfigBean = async (id, model, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13773
|
-
log$
|
|
14016
|
+
log$s.debug(`sending modify request for ConfigBean: ${id}`);
|
|
13774
14017
|
const response = postModel$5({
|
|
13775
14018
|
model,
|
|
13776
14019
|
urlOverride: `${URL$e}${path}/${id}`,
|
|
@@ -13779,7 +14022,7 @@ const modifyConfigBean = async (id, model, path = `/api/kos/config`, destination
|
|
|
13779
14022
|
return response;
|
|
13780
14023
|
};
|
|
13781
14024
|
const getConfigBean = async (id, path = `/api/kos/config`, destinationAddress = "") => {
|
|
13782
|
-
log$
|
|
14025
|
+
log$s.debug(`sending get request for ConfigBean: ${id}`);
|
|
13783
14026
|
const response = await getOne$6({
|
|
13784
14027
|
urlOverride: `${URL$e}${path}/details/${id}/15`,
|
|
13785
14028
|
destinationAddress
|
|
@@ -13892,7 +14135,10 @@ function matchValue(patterns, value) {
|
|
|
13892
14135
|
return void 0;
|
|
13893
14136
|
}
|
|
13894
14137
|
const CONFIG_BEAN_MODEL_TYPE = "config-bean-model";
|
|
13895
|
-
const log$
|
|
14138
|
+
const log$r = KosLog.createLogger({
|
|
14139
|
+
group: LogGroup.model,
|
|
14140
|
+
name: CONFIG_BEAN_MODEL_TYPE
|
|
14141
|
+
});
|
|
13896
14142
|
const PATH_PROP$3 = createPropKey("path");
|
|
13897
14143
|
const DESTINATION_PROP$2 = createPropKey("destinationAddress");
|
|
13898
14144
|
function configBeanModelId(path, destinationAddress) {
|
|
@@ -13965,8 +14211,8 @@ let ConfigBeanModelImpl = class {
|
|
|
13965
14211
|
* @internal
|
|
13966
14212
|
*/
|
|
13967
14213
|
async ready() {
|
|
13968
|
-
log$
|
|
13969
|
-
log$
|
|
14214
|
+
log$r.debug(`readying config bean ${this.path}`);
|
|
14215
|
+
log$r.debug(`complete readying config bean ${this.path}`);
|
|
13970
14216
|
}
|
|
13971
14217
|
/**
|
|
13972
14218
|
* @internal
|
|
@@ -13975,7 +14221,7 @@ let ConfigBeanModelImpl = class {
|
|
|
13975
14221
|
* Fetches the bean's values and schema.
|
|
13976
14222
|
*/
|
|
13977
14223
|
async load() {
|
|
13978
|
-
log$
|
|
14224
|
+
log$r.debug(`loading config bean ${this.path}`);
|
|
13979
14225
|
await this.fetchBean();
|
|
13980
14226
|
}
|
|
13981
14227
|
/**
|
|
@@ -13986,7 +14232,7 @@ let ConfigBeanModelImpl = class {
|
|
|
13986
14232
|
* KOS Core reload after a reconnect leaves the same instance current.
|
|
13987
14233
|
*/
|
|
13988
14234
|
async reload() {
|
|
13989
|
-
log$
|
|
14235
|
+
log$r.debug(`reloading config bean ${this.path}`);
|
|
13990
14236
|
await this.fetchBean();
|
|
13991
14237
|
}
|
|
13992
14238
|
async fetchBean() {
|
|
@@ -13998,7 +14244,7 @@ let ConfigBeanModelImpl = class {
|
|
|
13998
14244
|
if (response?.data) {
|
|
13999
14245
|
const data = response.data;
|
|
14000
14246
|
mapDtoToConfigBeanModel(data, this);
|
|
14001
|
-
log$
|
|
14247
|
+
log$r.debug(this.values);
|
|
14002
14248
|
const schemaResponse = response?.data.details[0].schema;
|
|
14003
14249
|
kosAction(() => {
|
|
14004
14250
|
if (schemaResponse) {
|
|
@@ -14243,7 +14489,10 @@ var __decorateClass$u = (decorators, target, key, kind) => {
|
|
|
14243
14489
|
return result;
|
|
14244
14490
|
};
|
|
14245
14491
|
const MODEL_TYPE$r = "region-info-model";
|
|
14246
|
-
const log$
|
|
14492
|
+
const log$q = KosLog.createLogger({
|
|
14493
|
+
group: LogGroup.model,
|
|
14494
|
+
name: "region-info-model"
|
|
14495
|
+
});
|
|
14247
14496
|
function servicePathMapper(regionInfoModel) {
|
|
14248
14497
|
const hasMapper = ExtensionManager.propertyMapper.hasMapper(
|
|
14249
14498
|
KosCoreModelPropertyMapper.RegionServicePath
|
|
@@ -14556,7 +14805,7 @@ let RegionInfoModelImpl = class {
|
|
|
14556
14805
|
}
|
|
14557
14806
|
toUnit = measureSystems[to.system]?.["default"];
|
|
14558
14807
|
if (!toUnit) {
|
|
14559
|
-
log$
|
|
14808
|
+
log$q.info("Could not find default unit for measure", to.measure);
|
|
14560
14809
|
}
|
|
14561
14810
|
}
|
|
14562
14811
|
if (!fromUnit && from.measure && from.system) {
|
|
@@ -14570,11 +14819,11 @@ let RegionInfoModelImpl = class {
|
|
|
14570
14819
|
}
|
|
14571
14820
|
fromUnit = measureSystems[from.system]?.["default"];
|
|
14572
14821
|
if (!fromUnit) {
|
|
14573
|
-
log$
|
|
14822
|
+
log$q.info("Could not find default unit for measure", from.measure);
|
|
14574
14823
|
}
|
|
14575
14824
|
}
|
|
14576
14825
|
if (!fromUnit || !toUnit) {
|
|
14577
|
-
log$
|
|
14826
|
+
log$q.warn("Could not find unit to convert to or from. Return value as is");
|
|
14578
14827
|
return String(value);
|
|
14579
14828
|
}
|
|
14580
14829
|
return this.convertByUnit(value, fromUnit, toUnit);
|
|
@@ -14584,13 +14833,13 @@ let RegionInfoModelImpl = class {
|
|
|
14584
14833
|
* @internal
|
|
14585
14834
|
*/
|
|
14586
14835
|
async init() {
|
|
14587
|
-
log$
|
|
14836
|
+
log$q.debug("initializing region info");
|
|
14588
14837
|
}
|
|
14589
14838
|
/**
|
|
14590
14839
|
* @internal
|
|
14591
14840
|
*/
|
|
14592
14841
|
async load() {
|
|
14593
|
-
log$
|
|
14842
|
+
log$q.debug("loading region info");
|
|
14594
14843
|
const regions = await getRegions(
|
|
14595
14844
|
this.serviceBasePath,
|
|
14596
14845
|
this.destinationAddress
|
|
@@ -14927,7 +15176,10 @@ function secondsToFormattedTime(secondsSinceMidnight, formatString) {
|
|
|
14927
15176
|
return dateFns.format(time, formatString);
|
|
14928
15177
|
}
|
|
14929
15178
|
const MODEL_TYPE$q = "config-bean-prop-model";
|
|
14930
|
-
const log$
|
|
15179
|
+
const log$p = KosLog.createLogger({
|
|
15180
|
+
group: LogGroup.model,
|
|
15181
|
+
name: "config-bean-prop-model"
|
|
15182
|
+
});
|
|
14931
15183
|
const PATH_PROP$2 = createPropKey("path");
|
|
14932
15184
|
const SERVICE_PATH_PROP = createPropKey("serviceBasePath");
|
|
14933
15185
|
const DESTINATION_PROP = createPropKey("destinationAddress");
|
|
@@ -15114,7 +15366,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15114
15366
|
return Number(result2);
|
|
15115
15367
|
}
|
|
15116
15368
|
} catch (e) {
|
|
15117
|
-
log$
|
|
15369
|
+
log$p.info(`error formatting value ${_val}`, e);
|
|
15118
15370
|
}
|
|
15119
15371
|
const result = Number(_val).toFixed(decimals);
|
|
15120
15372
|
return result;
|
|
@@ -15146,7 +15398,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15146
15398
|
* @internal
|
|
15147
15399
|
*/
|
|
15148
15400
|
async activate() {
|
|
15149
|
-
log$
|
|
15401
|
+
log$p.debug(`activating config bean ${this.id}`);
|
|
15150
15402
|
}
|
|
15151
15403
|
/**
|
|
15152
15404
|
* The value formatted with its unit for the active locale, such as `"72.5 °F"`.
|
|
@@ -15173,7 +15425,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15173
15425
|
return result;
|
|
15174
15426
|
}
|
|
15175
15427
|
} catch (e) {
|
|
15176
|
-
log$
|
|
15428
|
+
log$p.error(`error formatting value ${_val}`, e);
|
|
15177
15429
|
}
|
|
15178
15430
|
}
|
|
15179
15431
|
return String(_val);
|
|
@@ -15265,13 +15517,13 @@ let KosConfigPropertyImpl = class {
|
|
|
15265
15517
|
try {
|
|
15266
15518
|
formatter = new Intl.NumberFormat(locale, { ...formatOptions });
|
|
15267
15519
|
} catch (e) {
|
|
15268
|
-
log$
|
|
15520
|
+
log$p.error(
|
|
15269
15521
|
`error creating formatter ${formatOptions}. Returning the raw value`,
|
|
15270
15522
|
e
|
|
15271
15523
|
);
|
|
15272
15524
|
}
|
|
15273
15525
|
} else {
|
|
15274
|
-
log$
|
|
15526
|
+
log$p.debug(
|
|
15275
15527
|
`no formatter found for config bean prop ${this.id}. Returning the raw value`
|
|
15276
15528
|
);
|
|
15277
15529
|
}
|
|
@@ -15332,7 +15584,7 @@ let KosConfigPropertyImpl = class {
|
|
|
15332
15584
|
* @param value - The new value in display units
|
|
15333
15585
|
*/
|
|
15334
15586
|
async updateProperty(value) {
|
|
15335
|
-
log$
|
|
15587
|
+
log$p.debug(`updating property ${this.attribute} with value ${value}`);
|
|
15336
15588
|
let _value = value;
|
|
15337
15589
|
const converter = this.getConverter();
|
|
15338
15590
|
if (converter && !isNaN(_value)) {
|
|
@@ -15376,6 +15628,10 @@ const Registration = {
|
|
|
15376
15628
|
MODEL_TYPE$q
|
|
15377
15629
|
)
|
|
15378
15630
|
};
|
|
15631
|
+
const log$o = KosLog.createLogger({
|
|
15632
|
+
group: LogGroup.model,
|
|
15633
|
+
name: "future-model-builder"
|
|
15634
|
+
});
|
|
15379
15635
|
const mapDtoToFutureOptions = (dto) => {
|
|
15380
15636
|
const options = {
|
|
15381
15637
|
id: String(dto.id),
|
|
@@ -15391,10 +15647,10 @@ const mapDtoToFutureOptions = (dto) => {
|
|
|
15391
15647
|
return options;
|
|
15392
15648
|
};
|
|
15393
15649
|
const mapDtoToFutureModel = (dto, model) => {
|
|
15394
|
-
|
|
15395
|
-
|
|
15650
|
+
log$o.debug(`future dto ${dto.id} end state ${dto.endState}`);
|
|
15651
|
+
log$o.debug(`future model ${model.id} end state ${model.endState}`);
|
|
15396
15652
|
if (!model.endState) {
|
|
15397
|
-
|
|
15653
|
+
log$o.debug(`updating future model ${model.id}`);
|
|
15398
15654
|
mobx.runInAction(() => {
|
|
15399
15655
|
const options = mapDtoToFutureOptions(dto);
|
|
15400
15656
|
kosAction(() => {
|
|
@@ -15413,7 +15669,7 @@ const mapDtoToFutureModel = (dto, model) => {
|
|
|
15413
15669
|
});
|
|
15414
15670
|
});
|
|
15415
15671
|
} else {
|
|
15416
|
-
|
|
15672
|
+
log$o.debug(`future model ${model.id} is already complete`);
|
|
15417
15673
|
}
|
|
15418
15674
|
};
|
|
15419
15675
|
const buildFutureModel$1 = (factory) => (modelId) => (futureOptions) => {
|
|
@@ -15424,7 +15680,10 @@ const buildFuture = (factory) => (future) => pipe(
|
|
|
15424
15680
|
mapDtoToFutureOptions,
|
|
15425
15681
|
buildFutureModel$1(factory)(future.tracker || future.id)
|
|
15426
15682
|
)(future);
|
|
15427
|
-
const log$
|
|
15683
|
+
const log$n = KosLog.createLogger({
|
|
15684
|
+
group: LogGroup.service,
|
|
15685
|
+
name: "future-service"
|
|
15686
|
+
});
|
|
15428
15687
|
const { isMock, URL: URL$c } = resolveServiceUrl();
|
|
15429
15688
|
var FutureEndState = /* @__PURE__ */ ((FutureEndState2) => {
|
|
15430
15689
|
FutureEndState2["Success"] = "SUCCESS";
|
|
@@ -15443,7 +15702,7 @@ const getFutures = async () => {
|
|
|
15443
15702
|
return response;
|
|
15444
15703
|
};
|
|
15445
15704
|
const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
15446
|
-
log$
|
|
15705
|
+
log$n.info(`sending delete request for Future: ${id}`);
|
|
15447
15706
|
const response = await deleteModel$1({
|
|
15448
15707
|
id,
|
|
15449
15708
|
urlOverride: `${URL$c}${path}/${id}`
|
|
@@ -15451,7 +15710,7 @@ const deleteFuture = async (id, path = "/api/kos/future") => {
|
|
|
15451
15710
|
return response;
|
|
15452
15711
|
};
|
|
15453
15712
|
const addFuture = async (future, path = "/api/kos/future") => {
|
|
15454
|
-
log$
|
|
15713
|
+
log$n.info(`sending add request for Future`);
|
|
15455
15714
|
const response = await addModel({
|
|
15456
15715
|
model: future,
|
|
15457
15716
|
urlOverride: `${URL$c}${path}`
|
|
@@ -15459,7 +15718,7 @@ const addFuture = async (future, path = "/api/kos/future") => {
|
|
|
15459
15718
|
return response;
|
|
15460
15719
|
};
|
|
15461
15720
|
const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
15462
|
-
log$
|
|
15721
|
+
log$n.info(`sending modify request for Future: ${id}`);
|
|
15463
15722
|
const response = modifyModel({
|
|
15464
15723
|
model,
|
|
15465
15724
|
id,
|
|
@@ -15468,7 +15727,7 @@ const modifyFuture = async (id, model, path = "/api/kos/future") => {
|
|
|
15468
15727
|
return response;
|
|
15469
15728
|
};
|
|
15470
15729
|
const cancelFuture = async (id, path = "/api/kos/future") => {
|
|
15471
|
-
log$
|
|
15730
|
+
log$n.info(`sending cancel request for Future: ${id}`);
|
|
15472
15731
|
const response = postModel$4({
|
|
15473
15732
|
urlOverride: `${URL$c}${path}/${id}/cancel`,
|
|
15474
15733
|
ordered: true,
|
|
@@ -15508,6 +15767,10 @@ const FutureManager = {
|
|
|
15508
15767
|
initiateFuture,
|
|
15509
15768
|
getFuture
|
|
15510
15769
|
};
|
|
15770
|
+
const log$m = KosLog.createLogger({
|
|
15771
|
+
group: LogGroup.model,
|
|
15772
|
+
name: "future-service"
|
|
15773
|
+
});
|
|
15511
15774
|
const isFutureResponse = (response) => !response || !response.data;
|
|
15512
15775
|
const resolveFutureHandler = (model) => {
|
|
15513
15776
|
const handlerProperty = model?.[MultipleFutureContainerSetup]?.handlerProperty ?? model?.[FutureContainerSetup]?.handlerProperty ?? "futureHandler";
|
|
@@ -15522,9 +15785,7 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15522
15785
|
} = props;
|
|
15523
15786
|
return async function(...args) {
|
|
15524
15787
|
const tracker = uuid();
|
|
15525
|
-
|
|
15526
|
-
`Calling future service ${methodName} with tracker ${tracker}`
|
|
15527
|
-
);
|
|
15788
|
+
log$m.debug(`Calling future service ${methodName} with tracker ${tracker}`);
|
|
15528
15789
|
let abortControllerInstance;
|
|
15529
15790
|
let effectDisposer;
|
|
15530
15791
|
if (abortController) {
|
|
@@ -15537,17 +15798,17 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15537
15798
|
if (namespace) {
|
|
15538
15799
|
future.namespace = namespace;
|
|
15539
15800
|
}
|
|
15540
|
-
|
|
15801
|
+
log$m.debug(`waiting for future ${future.id} to be ready`);
|
|
15541
15802
|
await whenReady(future);
|
|
15542
|
-
|
|
15803
|
+
log$m.debug(`future ${future.id} is ready`);
|
|
15543
15804
|
kosAction(() => {
|
|
15544
|
-
|
|
15805
|
+
log$m.debug(`Adding future ${future.id} to futureHandler`);
|
|
15545
15806
|
resolveFutureHandler(this).addFuture(future, alias);
|
|
15546
15807
|
});
|
|
15547
15808
|
if (abortController && abortControllerInstance) {
|
|
15548
15809
|
effectDisposer = kosAutoEffect(() => {
|
|
15549
15810
|
if (future.status === "CANCELLED" || future.endState === FutureEndState.Canceled) {
|
|
15550
|
-
|
|
15811
|
+
log$m.debug(`Future ${future.id} cancelled, aborting request`);
|
|
15551
15812
|
abortControllerInstance?.abort();
|
|
15552
15813
|
}
|
|
15553
15814
|
});
|
|
@@ -15555,13 +15816,13 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15555
15816
|
"abort",
|
|
15556
15817
|
async () => {
|
|
15557
15818
|
if (future.status !== "CANCELLED" && future.endState !== FutureEndState.Canceled && !future.endState) {
|
|
15558
|
-
|
|
15819
|
+
log$m.debug(
|
|
15559
15820
|
`AbortController aborted, cancelling future ${future.id}`
|
|
15560
15821
|
);
|
|
15561
15822
|
try {
|
|
15562
15823
|
await future.cancelFuture();
|
|
15563
15824
|
} catch (error) {
|
|
15564
|
-
|
|
15825
|
+
log$m.error(`Failed to cancel future ${future.id}:`, error);
|
|
15565
15826
|
}
|
|
15566
15827
|
}
|
|
15567
15828
|
},
|
|
@@ -15602,15 +15863,15 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15602
15863
|
// eslint-disable-next-line no-invalid-this
|
|
15603
15864
|
await original.apply(this, enhancedArgs)
|
|
15604
15865
|
);
|
|
15605
|
-
|
|
15866
|
+
log$m.debug(`received future response for ${tracker}`, futureResponse);
|
|
15606
15867
|
const response = isFutureResponse(futureResponse) ? futureResponse : futureResponse?.data;
|
|
15607
15868
|
if (response) {
|
|
15608
15869
|
response.progress = 1;
|
|
15609
|
-
|
|
15870
|
+
log$m.debug(`mapping future response to future model`);
|
|
15610
15871
|
if (!future.endState) {
|
|
15611
15872
|
mapDtoToFutureModel(response, future);
|
|
15612
15873
|
} else {
|
|
15613
|
-
|
|
15874
|
+
log$m.debug(
|
|
15614
15875
|
`future ${future.id} has already completed. Not updating the model`
|
|
15615
15876
|
);
|
|
15616
15877
|
}
|
|
@@ -15623,10 +15884,10 @@ function wrapWithFutureLifecycle(original, methodName, props = {}) {
|
|
|
15623
15884
|
cleanup();
|
|
15624
15885
|
if (abortController && abortControllerInstance?.signal.aborted) {
|
|
15625
15886
|
const cancelledError = new Error("Operation cancelled");
|
|
15626
|
-
|
|
15887
|
+
log$m.debug(`Operation ${methodName} was cancelled`);
|
|
15627
15888
|
throw cancelledError;
|
|
15628
15889
|
}
|
|
15629
|
-
|
|
15890
|
+
log$m.error(e);
|
|
15630
15891
|
throw e;
|
|
15631
15892
|
}
|
|
15632
15893
|
};
|
|
@@ -15655,12 +15916,12 @@ const { URL: URL$b } = resolveServiceUrl();
|
|
|
15655
15916
|
const { getOne: getOne$4 } = ServiceFactory.build({
|
|
15656
15917
|
basePath: `${URL$b}/api/kos/state`
|
|
15657
15918
|
});
|
|
15658
|
-
const log$
|
|
15659
|
-
|
|
15660
|
-
|
|
15919
|
+
const log$l = KosLog.createLogger({
|
|
15920
|
+
group: LogGroup.service,
|
|
15921
|
+
name: "state-bean-service"
|
|
15661
15922
|
});
|
|
15662
15923
|
const getStateBeanData = async ({ path }) => {
|
|
15663
|
-
log$
|
|
15924
|
+
log$l.debug("sending GET for state-bean");
|
|
15664
15925
|
const response = await getOne$4({
|
|
15665
15926
|
urlOverride: `${URL$b}/api/kos/state/${path}`
|
|
15666
15927
|
});
|
|
@@ -15838,12 +16099,12 @@ const { URL: URL$a } = resolveServiceUrl();
|
|
|
15838
16099
|
const { getAll: getAll$5 } = ServiceFactory.build({
|
|
15839
16100
|
basePath: `${URL$a}/api/state-prop`
|
|
15840
16101
|
});
|
|
15841
|
-
const log$
|
|
15842
|
-
|
|
15843
|
-
|
|
16102
|
+
const log$k = KosLog.createLogger({
|
|
16103
|
+
group: LogGroup.service,
|
|
16104
|
+
name: "state-prop-service"
|
|
15844
16105
|
});
|
|
15845
16106
|
const getStateProps = async () => {
|
|
15846
|
-
log$
|
|
16107
|
+
log$k.debug("sending GET for state-prop");
|
|
15847
16108
|
const response = await getAll$5({});
|
|
15848
16109
|
return response;
|
|
15849
16110
|
};
|
|
@@ -15985,7 +16246,10 @@ var __decorateClass$p = (decorators, target, key, kind) => {
|
|
|
15985
16246
|
if (kind && result) __defProp$l(target, key, result);
|
|
15986
16247
|
return result;
|
|
15987
16248
|
};
|
|
15988
|
-
const log$
|
|
16249
|
+
const log$j = KosLog.createLogger({
|
|
16250
|
+
group: LogGroup.model,
|
|
16251
|
+
name: FutureFactory.type
|
|
16252
|
+
});
|
|
15989
16253
|
let FutureModel$1 = class FutureModel {
|
|
15990
16254
|
logger;
|
|
15991
16255
|
_cancelFuture;
|
|
@@ -16009,7 +16273,7 @@ let FutureModel$1 = class FutureModel {
|
|
|
16009
16273
|
kosWhen(
|
|
16010
16274
|
() => this.status === FutureEndState.Success || this.status === FutureEndState.Fail,
|
|
16011
16275
|
() => {
|
|
16012
|
-
log$
|
|
16276
|
+
log$j.info(`Future ${this.id} has completed with status ${this.status}`);
|
|
16013
16277
|
destroyKosModel(this);
|
|
16014
16278
|
}
|
|
16015
16279
|
);
|
|
@@ -16023,13 +16287,13 @@ let FutureModel$1 = class FutureModel {
|
|
|
16023
16287
|
* In future additional information about the workspace could be loaded
|
|
16024
16288
|
*/
|
|
16025
16289
|
async load() {
|
|
16026
|
-
log$
|
|
16290
|
+
log$j.debug(`loading Future ${this.id}`);
|
|
16027
16291
|
}
|
|
16028
16292
|
/**
|
|
16029
16293
|
* @internal
|
|
16030
16294
|
*/
|
|
16031
16295
|
unload() {
|
|
16032
|
-
log$
|
|
16296
|
+
log$j.info(`unloading Future ${this.id}`);
|
|
16033
16297
|
}
|
|
16034
16298
|
// -------------------ACTIONS----------------------------
|
|
16035
16299
|
/**
|
|
@@ -16048,7 +16312,7 @@ let FutureModel$1 = class FutureModel {
|
|
|
16048
16312
|
await kosWhen(() => this.futureId !== FUTURE_NOT_ASSIGNED);
|
|
16049
16313
|
const response = await this._cancelFuture(this.futureId, path);
|
|
16050
16314
|
if (response?.status !== 200) {
|
|
16051
|
-
log$
|
|
16315
|
+
log$j.error(
|
|
16052
16316
|
`Failed to cancel Future ${this.id}. Response: ${JSON.stringify(
|
|
16053
16317
|
response
|
|
16054
16318
|
)}`
|
|
@@ -16117,7 +16381,10 @@ var __decorateClass$o = (decorators, target, key, kind) => {
|
|
|
16117
16381
|
if (kind && result) __defProp$k(target, key, result);
|
|
16118
16382
|
return result;
|
|
16119
16383
|
};
|
|
16120
|
-
const log$
|
|
16384
|
+
const log$i = KosLog.createLogger({
|
|
16385
|
+
group: LogGroup.model,
|
|
16386
|
+
name: FutureContainerFactory.type
|
|
16387
|
+
});
|
|
16121
16388
|
let FutureContainerModel$1 = class FutureContainerModel {
|
|
16122
16389
|
id;
|
|
16123
16390
|
logger;
|
|
@@ -16232,8 +16499,8 @@ let FutureContainerModel$1 = class FutureContainerModel {
|
|
|
16232
16499
|
try {
|
|
16233
16500
|
await this._deleteFuture(id);
|
|
16234
16501
|
} catch (e) {
|
|
16235
|
-
log$
|
|
16236
|
-
log$
|
|
16502
|
+
log$i.error(`error deleting a Future`);
|
|
16503
|
+
log$i.error(e);
|
|
16237
16504
|
}
|
|
16238
16505
|
}
|
|
16239
16506
|
/**
|
|
@@ -16260,8 +16527,8 @@ let FutureContainerModel$1 = class FutureContainerModel {
|
|
|
16260
16527
|
return model2;
|
|
16261
16528
|
}
|
|
16262
16529
|
} catch (e) {
|
|
16263
|
-
log$
|
|
16264
|
-
log$
|
|
16530
|
+
log$i.error(`error creating a Future`);
|
|
16531
|
+
log$i.error(e);
|
|
16265
16532
|
throw e;
|
|
16266
16533
|
}
|
|
16267
16534
|
return void 0;
|
|
@@ -16290,9 +16557,9 @@ const { URL: URL$9 } = resolveServiceUrl();
|
|
|
16290
16557
|
const { getOne: getOne$3, postModel: postModel$3, deleteModel } = ServiceFactory.build({
|
|
16291
16558
|
basePath: `${URL$9}/api/keyVal`
|
|
16292
16559
|
});
|
|
16293
|
-
const log$
|
|
16294
|
-
|
|
16295
|
-
|
|
16560
|
+
const log$h = KosLog.createLogger({
|
|
16561
|
+
group: LogGroup.service,
|
|
16562
|
+
name: "key-value-service"
|
|
16296
16563
|
});
|
|
16297
16564
|
const deleteKeyValue = async (namespace, key) => {
|
|
16298
16565
|
await deleteModel({
|
|
@@ -16306,7 +16573,7 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16306
16573
|
model: value.toString()
|
|
16307
16574
|
});
|
|
16308
16575
|
if (response?.status !== 200) {
|
|
16309
|
-
log$
|
|
16576
|
+
log$h.error("Failed to update key-value data", response);
|
|
16310
16577
|
throw new Error(
|
|
16311
16578
|
`Failed to update key-value data for namespace ${namespace}`
|
|
16312
16579
|
);
|
|
@@ -16314,12 +16581,12 @@ const updateKeyValue = async (namespace, key, value) => {
|
|
|
16314
16581
|
return response.data;
|
|
16315
16582
|
};
|
|
16316
16583
|
const getKeyValue = async (namespace = "studio") => {
|
|
16317
|
-
log$
|
|
16584
|
+
log$h.debug(`Retrieving all key-value data for namespace: ${namespace}`);
|
|
16318
16585
|
const response = await getOne$3({
|
|
16319
16586
|
urlOverride: `${URL$9}/api/keyVal/${namespace}`
|
|
16320
16587
|
});
|
|
16321
16588
|
if (response?.status !== 200) {
|
|
16322
|
-
log$
|
|
16589
|
+
log$h.error("Failed to retrieve key-value data", response);
|
|
16323
16590
|
throw new Error(
|
|
16324
16591
|
`Failed to retrieve key-value data for namespace ${namespace}`
|
|
16325
16592
|
);
|
|
@@ -18395,14 +18662,46 @@ KosExpressionEvaluatorModelImpl = __decorateClass$m([
|
|
|
18395
18662
|
kosModel({ modelTypeId: MODEL_TYPE$l, singleton: false })
|
|
18396
18663
|
], KosExpressionEvaluatorModelImpl);
|
|
18397
18664
|
const KosExpressionEvaluator = KosExpressionEvaluatorModelImpl.Registration;
|
|
18398
|
-
const log$
|
|
18399
|
-
|
|
18400
|
-
|
|
18665
|
+
const log$g = KosLog.createLogger({
|
|
18666
|
+
group: LogGroup.transport,
|
|
18667
|
+
name: "get-kos-connection-id"
|
|
18668
|
+
});
|
|
18669
|
+
const getKosConnectionId = () => {
|
|
18670
|
+
const params2 = getQueryParams();
|
|
18671
|
+
const connId = params2?.connId;
|
|
18672
|
+
const result = connId || window?.kosBridge?.("connId");
|
|
18673
|
+
log$g.debug(`getKosConnectionId: ${result}`);
|
|
18674
|
+
return result;
|
|
18675
|
+
};
|
|
18676
|
+
const log$f = KosLog.createLogger({
|
|
18677
|
+
group: LogGroup.service,
|
|
18678
|
+
name: "kos-log-manager-service"
|
|
18401
18679
|
});
|
|
18402
18680
|
const SERVICE_PATH$1 = "/api/kos/logs/overrides";
|
|
18681
|
+
const GROUPS_PATH = "/api/kos/logs/groups";
|
|
18403
18682
|
const getLogOverrides = async () => {
|
|
18404
|
-
log$
|
|
18405
|
-
return await api$1.get(SERVICE_PATH$1
|
|
18683
|
+
log$f.debug("sending GET for kos-log-manager");
|
|
18684
|
+
return await api$1.get(SERVICE_PATH$1, void 0, {
|
|
18685
|
+
destinationAddress: getKosConnectionId()
|
|
18686
|
+
});
|
|
18687
|
+
};
|
|
18688
|
+
const getLogGroups = async () => {
|
|
18689
|
+
log$f.debug("sending GET for log groups");
|
|
18690
|
+
return await api$1.get(GROUPS_PATH, void 0, {
|
|
18691
|
+
destinationAddress: getKosConnectionId()
|
|
18692
|
+
});
|
|
18693
|
+
};
|
|
18694
|
+
const addLogOverride = async (override) => {
|
|
18695
|
+
log$f.debug(`sending POST for log override ${override.name}`);
|
|
18696
|
+
return await api$1.post(SERVICE_PATH$1, void 0, override, {
|
|
18697
|
+
destinationAddress: getKosConnectionId()
|
|
18698
|
+
});
|
|
18699
|
+
};
|
|
18700
|
+
const removeLogOverride = async (override) => {
|
|
18701
|
+
log$f.debug(`sending DELETE for log override ${override.name}`);
|
|
18702
|
+
return await api$1.delete(SERVICE_PATH$1, void 0, override, {
|
|
18703
|
+
destinationAddress: getKosConnectionId()
|
|
18704
|
+
});
|
|
18406
18705
|
};
|
|
18407
18706
|
var __defProp$h = Object.defineProperty;
|
|
18408
18707
|
var __getOwnPropDesc$l = Object.getOwnPropertyDescriptor;
|
|
@@ -18439,17 +18738,139 @@ const getLogLevelName = (level2) => {
|
|
|
18439
18738
|
}
|
|
18440
18739
|
return "info";
|
|
18441
18740
|
};
|
|
18741
|
+
const toDeviceOverride = (data) => {
|
|
18742
|
+
const nodeType = data.nodeType ?? "";
|
|
18743
|
+
const type = data.type ?? "";
|
|
18744
|
+
const name = data.name ?? "";
|
|
18745
|
+
return {
|
|
18746
|
+
id: `${nodeType}:${type}:${name}`,
|
|
18747
|
+
nodeType,
|
|
18748
|
+
type,
|
|
18749
|
+
name,
|
|
18750
|
+
level: data.level ?? "INFO"
|
|
18751
|
+
};
|
|
18752
|
+
};
|
|
18753
|
+
const isUiOverride = (override) => override.type === UI_GROUP_OVERRIDE || override.type === UI_LOGGER_OVERRIDE;
|
|
18754
|
+
const toUiLevel = (level2) => {
|
|
18755
|
+
const name = level2.toLowerCase();
|
|
18756
|
+
return name === "fatal" ? "error" : name;
|
|
18757
|
+
};
|
|
18758
|
+
const toUiOverride = (override) => {
|
|
18759
|
+
return {
|
|
18760
|
+
name: override.name ?? "",
|
|
18761
|
+
type: override.type ?? "",
|
|
18762
|
+
level: toUiLevel(override.level ?? "INFO"),
|
|
18763
|
+
id: `${override.type ?? ""}:${override.name ?? ""}`
|
|
18764
|
+
};
|
|
18765
|
+
};
|
|
18442
18766
|
let KosLogManagerModelImpl = class {
|
|
18443
18767
|
id;
|
|
18444
18768
|
logger;
|
|
18445
18769
|
_overrides;
|
|
18770
|
+
_deviceOverrides;
|
|
18771
|
+
_overriddenLoggers;
|
|
18772
|
+
groups;
|
|
18446
18773
|
constructor(modelId, options, context) {
|
|
18447
18774
|
this.id = modelId;
|
|
18448
18775
|
this.logger = context.logger;
|
|
18449
18776
|
this._overrides = new KosDataContainer();
|
|
18777
|
+
this._deviceOverrides = new KosDataContainer();
|
|
18778
|
+
this._overriddenLoggers = /* @__PURE__ */ new Set();
|
|
18779
|
+
this.groups = [];
|
|
18450
18780
|
}
|
|
18451
18781
|
updateModel(_options) {
|
|
18452
18782
|
}
|
|
18783
|
+
/**
|
|
18784
|
+
* Overrides stored on the device, for every node type.
|
|
18785
|
+
*/
|
|
18786
|
+
get deviceOverrides() {
|
|
18787
|
+
return this._deviceOverrides.data;
|
|
18788
|
+
}
|
|
18789
|
+
/**
|
|
18790
|
+
* Creates an override on the device, or changes the level of the override
|
|
18791
|
+
* with the same node type, type and name.
|
|
18792
|
+
*/
|
|
18793
|
+
async addOverride(override) {
|
|
18794
|
+
const [error] = await addLogOverride(override);
|
|
18795
|
+
if (error) {
|
|
18796
|
+
throw new Error(error);
|
|
18797
|
+
}
|
|
18798
|
+
await this.refreshOverrides();
|
|
18799
|
+
}
|
|
18800
|
+
/**
|
|
18801
|
+
* Removes the device override with the given id.
|
|
18802
|
+
*/
|
|
18803
|
+
async removeOverride(id) {
|
|
18804
|
+
const override = this._deviceOverrides.getModel(id);
|
|
18805
|
+
if (!override) {
|
|
18806
|
+
throw new Error(`Unable to delete: Override id "${id}" not found.`);
|
|
18807
|
+
}
|
|
18808
|
+
const { nodeType, type, name, level: level2 } = override;
|
|
18809
|
+
const [error] = await removeLogOverride({ nodeType, type, name, level: level2 });
|
|
18810
|
+
if (error) {
|
|
18811
|
+
throw new Error(error);
|
|
18812
|
+
}
|
|
18813
|
+
this._deviceOverrides.removeModel(id);
|
|
18814
|
+
this.applyUiOverrides();
|
|
18815
|
+
}
|
|
18816
|
+
/**
|
|
18817
|
+
* Reloads the device's overrides.
|
|
18818
|
+
*/
|
|
18819
|
+
async refreshOverrides() {
|
|
18820
|
+
const [error, overrides] = await getLogOverrides();
|
|
18821
|
+
if (error) {
|
|
18822
|
+
this.logger.error("Failed to load log overrides", error);
|
|
18823
|
+
return;
|
|
18824
|
+
}
|
|
18825
|
+
this.applyDeviceOverrides(overrides ?? []);
|
|
18826
|
+
}
|
|
18827
|
+
/**
|
|
18828
|
+
* Reloads the java log groups registered on the primary node. Groups appear
|
|
18829
|
+
* as the classes that join them load.
|
|
18830
|
+
*/
|
|
18831
|
+
async refreshGroups() {
|
|
18832
|
+
const [error, groups] = await getLogGroups();
|
|
18833
|
+
if (error) {
|
|
18834
|
+
this.logger.error("Failed to load log groups", error);
|
|
18835
|
+
return;
|
|
18836
|
+
}
|
|
18837
|
+
this.groups = [...groups ?? []].sort();
|
|
18838
|
+
}
|
|
18839
|
+
applyDeviceOverrides(overrides) {
|
|
18840
|
+
const next = overrides.map(toDeviceOverride);
|
|
18841
|
+
const ids = new Set(next.map((override) => override.id));
|
|
18842
|
+
this._deviceOverrides.data.filter((override) => !ids.has(override.id)).forEach((override) => this._deviceOverrides.removeModel(override.id));
|
|
18843
|
+
next.forEach((override) => {
|
|
18844
|
+
if (this._deviceOverrides.getModel(override.id)) {
|
|
18845
|
+
this._deviceOverrides.updateModel(override);
|
|
18846
|
+
} else {
|
|
18847
|
+
this._deviceOverrides.addModel(override);
|
|
18848
|
+
}
|
|
18849
|
+
});
|
|
18850
|
+
this.applyUiOverrides();
|
|
18851
|
+
}
|
|
18852
|
+
applyUiOverrides() {
|
|
18853
|
+
const next = this._deviceOverrides.data.filter(isUiOverride).map(toUiOverride);
|
|
18854
|
+
const ids = new Set(next.map((override) => override.id));
|
|
18855
|
+
this._overrides.data.filter((override) => !ids.has(override.id)).forEach((override) => this._overrides.removeModel(override.id));
|
|
18856
|
+
next.forEach((override) => {
|
|
18857
|
+
if (this._overrides.getModel(override.id)) {
|
|
18858
|
+
this._overrides.updateModel(override);
|
|
18859
|
+
} else {
|
|
18860
|
+
this._overrides.addModel(override);
|
|
18861
|
+
}
|
|
18862
|
+
});
|
|
18863
|
+
globalThis.kos.logOverrides = this._overrides.data;
|
|
18864
|
+
Object.entries(KosLog.getLoggers()).forEach(([name, logger]) => {
|
|
18865
|
+
const level2 = resolveOverrideLevel(name, next);
|
|
18866
|
+
if (level2) {
|
|
18867
|
+
logger.setLevel(level2);
|
|
18868
|
+
this._overriddenLoggers.add(name);
|
|
18869
|
+
} else if (this._overriddenLoggers.delete(name)) {
|
|
18870
|
+
logger.resetLevel();
|
|
18871
|
+
}
|
|
18872
|
+
});
|
|
18873
|
+
}
|
|
18453
18874
|
// -------------------LIFECYCLE----------------------------
|
|
18454
18875
|
/**
|
|
18455
18876
|
* Resolves all registered loggers and their current log levels.
|
|
@@ -18481,68 +18902,33 @@ let KosLogManagerModelImpl = class {
|
|
|
18481
18902
|
res?.send(loggers);
|
|
18482
18903
|
return loggers;
|
|
18483
18904
|
}
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
* whose names start with the override name.
|
|
18488
|
-
* @param override - The log override configuration to apply
|
|
18489
|
-
* @private
|
|
18490
|
-
*/
|
|
18491
|
-
setLogLevels(override) {
|
|
18492
|
-
const loggers = Object.values(this.resolveLoggers()).filter(
|
|
18493
|
-
(logger) => logger.name.startsWith(override.name)
|
|
18905
|
+
handleOverrideAdded(override, payload) {
|
|
18906
|
+
this.logger.debug(
|
|
18907
|
+
`Override received for node type ${payload.wildcardCapture?.nodeType ?? "unknown"}`
|
|
18494
18908
|
);
|
|
18495
|
-
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
this.logger.debug(`Logger ${logger.name} not found`);
|
|
18499
|
-
return;
|
|
18500
|
-
}
|
|
18501
|
-
_logger2.setLevel(override.level);
|
|
18909
|
+
const deviceOverride = toDeviceOverride({
|
|
18910
|
+
nodeType: payload.wildcardCapture?.nodeType,
|
|
18911
|
+
...override
|
|
18502
18912
|
});
|
|
18503
|
-
|
|
18504
|
-
|
|
18505
|
-
|
|
18506
|
-
|
|
18913
|
+
if (this._deviceOverrides.getModel(deviceOverride.id)) {
|
|
18914
|
+
this._deviceOverrides.updateModel(deviceOverride);
|
|
18915
|
+
} else {
|
|
18916
|
+
this._deviceOverrides.addModel(deviceOverride);
|
|
18507
18917
|
}
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
}
|
|
18511
|
-
/**
|
|
18512
|
-
* Resets log levels to their defaults for matching loggers.
|
|
18513
|
-
* Removes the override for the logger and all child loggers
|
|
18514
|
-
* whose names start with the override name.
|
|
18515
|
-
* @param override - The log override configuration to reset
|
|
18516
|
-
* @private
|
|
18517
|
-
*/
|
|
18518
|
-
resetLogLevels(override) {
|
|
18519
|
-
const loggers = Object.values(this.resolveLoggers()).filter(
|
|
18520
|
-
(logger) => logger.name.startsWith(override.name)
|
|
18521
|
-
);
|
|
18522
|
-
loggers.forEach((logger) => {
|
|
18523
|
-
const _logger2 = KosLog.getLoggers()[logger.name];
|
|
18524
|
-
if (!_logger2) {
|
|
18525
|
-
this.logger.debug(`Logger ${logger.name} not found`);
|
|
18526
|
-
}
|
|
18527
|
-
_logger2?.resetLevel();
|
|
18528
|
-
});
|
|
18529
|
-
const _logger = KosLog.getLoggers()[override.name];
|
|
18530
|
-
if (!_logger) {
|
|
18531
|
-
this.logger.debug(`Logger ${override.name} not found`);
|
|
18918
|
+
if (isUiOverride(override)) {
|
|
18919
|
+
this.applyUiOverrides();
|
|
18532
18920
|
}
|
|
18533
|
-
_logger?.resetLevel();
|
|
18534
|
-
globalThis.kos.logOverrides = this._overrides.data;
|
|
18535
18921
|
}
|
|
18536
|
-
|
|
18537
|
-
this.
|
|
18538
|
-
|
|
18922
|
+
handleOverrideRemoved(override, payload) {
|
|
18923
|
+
this._deviceOverrides.removeModel(
|
|
18924
|
+
toDeviceOverride({
|
|
18925
|
+
nodeType: payload.wildcardCapture?.nodeType,
|
|
18926
|
+
...override
|
|
18927
|
+
}).id
|
|
18539
18928
|
);
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18543
|
-
handleOverrideRemoved(override) {
|
|
18544
|
-
this._overrides.removeModel(override.name);
|
|
18545
|
-
this.resetLogLevels(override);
|
|
18929
|
+
if (isUiOverride(override)) {
|
|
18930
|
+
this.applyUiOverrides();
|
|
18931
|
+
}
|
|
18546
18932
|
}
|
|
18547
18933
|
/**
|
|
18548
18934
|
* Initializes the log manager model.
|
|
@@ -18553,30 +18939,15 @@ let KosLogManagerModelImpl = class {
|
|
|
18553
18939
|
this.logger.debug(`initializing kos-log-manager ${this.id}`);
|
|
18554
18940
|
}
|
|
18555
18941
|
/**
|
|
18556
|
-
* Loads
|
|
18557
|
-
*
|
|
18942
|
+
* Loads the java log groups and the device's overrides, and applies the
|
|
18943
|
+
* UI overrides to the current loggers.
|
|
18558
18944
|
* Called after model initialization.
|
|
18559
18945
|
* @internal
|
|
18560
18946
|
*/
|
|
18561
18947
|
async load() {
|
|
18562
18948
|
this.logger.debug(`loading kos-log-manager ${this.id}`);
|
|
18563
|
-
|
|
18564
|
-
|
|
18565
|
-
this.logger.error("Failed to load log overrides", error);
|
|
18566
|
-
return;
|
|
18567
|
-
}
|
|
18568
|
-
const uiOverrides = overrides?.filter((override) => override.type?.toUpperCase() === "UI").map((override) => {
|
|
18569
|
-
return {
|
|
18570
|
-
name: override.name ?? "",
|
|
18571
|
-
type: override.type ?? "",
|
|
18572
|
-
level: override.level ?? "info",
|
|
18573
|
-
id: override.name || ""
|
|
18574
|
-
};
|
|
18575
|
-
}) ?? [];
|
|
18576
|
-
this._overrides.addAll(uiOverrides);
|
|
18577
|
-
uiOverrides.forEach((override) => {
|
|
18578
|
-
this.setLogLevels(override);
|
|
18579
|
-
});
|
|
18949
|
+
await this.refreshGroups();
|
|
18950
|
+
await this.refreshOverrides();
|
|
18580
18951
|
}
|
|
18581
18952
|
};
|
|
18582
18953
|
__decorateClass$l([
|
|
@@ -18805,21 +19176,14 @@ __decorateClass$j([
|
|
|
18805
19176
|
LogBlockContainerModelImpl = __decorateClass$j([
|
|
18806
19177
|
kosModel(MODEL_TYPE$i)
|
|
18807
19178
|
], LogBlockContainerModelImpl);
|
|
18808
|
-
const
|
|
18809
|
-
|
|
18810
|
-
|
|
18811
|
-
const result = connId || window?.kosBridge?.("connId");
|
|
18812
|
-
KosLog.debug(`getKosConnectionId: ${result}`);
|
|
18813
|
-
return result;
|
|
18814
|
-
};
|
|
18815
|
-
const log$a = KosLog.createLogger({
|
|
18816
|
-
name: "log-stream-container-service",
|
|
18817
|
-
group: "Services"
|
|
19179
|
+
const log$e = KosLog.createLogger({
|
|
19180
|
+
group: LogGroup.service,
|
|
19181
|
+
name: "log-stream-container-service"
|
|
18818
19182
|
});
|
|
18819
19183
|
const SERVICE_PATH = "/api/kos/logs/node/{nodeId}/streams";
|
|
18820
19184
|
const getLogStreams = async () => {
|
|
18821
19185
|
const destinationAddress = getKosConnectionId();
|
|
18822
|
-
log$
|
|
19186
|
+
log$e.debug("sending GET for log-stream-container");
|
|
18823
19187
|
return await api$1.get(
|
|
18824
19188
|
SERVICE_PATH,
|
|
18825
19189
|
{
|
|
@@ -19391,11 +19755,14 @@ const { URL: URL$7 } = resolveServiceUrl();
|
|
|
19391
19755
|
const { getAll: getAll$4, postModel: postModel$1 } = ServiceFactory.build({
|
|
19392
19756
|
basePath: `${URL$7}/api/kos/troubles`
|
|
19393
19757
|
});
|
|
19394
|
-
const log$
|
|
19758
|
+
const log$d = KosLog.createLogger({
|
|
19759
|
+
group: LogGroup.service,
|
|
19760
|
+
name: "trouble-services"
|
|
19761
|
+
});
|
|
19395
19762
|
const getTroubles = async (servicePath) => {
|
|
19396
19763
|
const isKosTroubles = servicePath.includes("/kos/troubles");
|
|
19397
19764
|
const destinationAddress = getKosConnectionId();
|
|
19398
|
-
log$
|
|
19765
|
+
log$d.info(
|
|
19399
19766
|
`Fetching troubles from ${servicePath} with destination address: ${isKosTroubles ? destinationAddress : "N/A (not a kos troubles path)"}`
|
|
19400
19767
|
);
|
|
19401
19768
|
const response = await getAll$4({
|
|
@@ -19477,6 +19844,10 @@ const defaultTroubleRoleMapper = (trouble) => {
|
|
|
19477
19844
|
}
|
|
19478
19845
|
return "TECHNICIAN";
|
|
19479
19846
|
};
|
|
19847
|
+
const log$c = KosLog.createLogger({
|
|
19848
|
+
group: LogGroup.model,
|
|
19849
|
+
name: "trouble-data-extension"
|
|
19850
|
+
});
|
|
19480
19851
|
const EXTENSION_TROUBLE_DATA_MAPPER = "troubleDataMapper";
|
|
19481
19852
|
const troubleMappers$1 = /* @__PURE__ */ new Map();
|
|
19482
19853
|
registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
@@ -19500,7 +19871,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19500
19871
|
if (r.status === "fulfilled") {
|
|
19501
19872
|
acc = { ...acc, ...r.value };
|
|
19502
19873
|
} else {
|
|
19503
|
-
|
|
19874
|
+
log$c.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19504
19875
|
}
|
|
19505
19876
|
return acc;
|
|
19506
19877
|
},
|
|
@@ -19509,6 +19880,10 @@ registerExtensionPoint(EXTENSION_TROUBLE_DATA_MAPPER, {
|
|
|
19509
19880
|
return data;
|
|
19510
19881
|
}
|
|
19511
19882
|
});
|
|
19883
|
+
const log$b = KosLog.createLogger({
|
|
19884
|
+
group: LogGroup.model,
|
|
19885
|
+
name: "trouble-extension"
|
|
19886
|
+
});
|
|
19512
19887
|
const EXTENSION_TROUBLE_MAPPER = "troubleMapper";
|
|
19513
19888
|
const troubleMappers = /* @__PURE__ */ new Map();
|
|
19514
19889
|
registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
@@ -19529,7 +19904,7 @@ registerExtensionPoint(EXTENSION_TROUBLE_MAPPER, {
|
|
|
19529
19904
|
if (r.status === "fulfilled") {
|
|
19530
19905
|
return r.value;
|
|
19531
19906
|
} else {
|
|
19532
|
-
|
|
19907
|
+
log$b.info(`Trouble mapper ${id} failed: ${r.reason}`);
|
|
19533
19908
|
return [];
|
|
19534
19909
|
}
|
|
19535
19910
|
}).flat();
|
|
@@ -19918,16 +20293,16 @@ const { URL: URL$6 } = resolveServiceUrl();
|
|
|
19918
20293
|
const { getAll: getAll$3 } = ServiceFactory.build({
|
|
19919
20294
|
basePath: `${URL$6}/api/kos/ota`
|
|
19920
20295
|
});
|
|
19921
|
-
const log$
|
|
19922
|
-
|
|
19923
|
-
|
|
20296
|
+
const log$a = KosLog.createLogger({
|
|
20297
|
+
group: LogGroup.service,
|
|
20298
|
+
name: "ota-service"
|
|
19924
20299
|
});
|
|
19925
20300
|
const getArtifacts = async () => {
|
|
19926
|
-
log$
|
|
20301
|
+
log$a.debug("sending GET request to /api/kos/ota/artifacts");
|
|
19927
20302
|
const response = await getAll$3({
|
|
19928
20303
|
urlOverride: `${URL$6}/api/kos/ota/artifacts`
|
|
19929
20304
|
});
|
|
19930
|
-
log$
|
|
20305
|
+
log$a.debug("getArtifacts - response:", response);
|
|
19931
20306
|
return response?.data;
|
|
19932
20307
|
};
|
|
19933
20308
|
var __defProp$a = Object.defineProperty;
|
|
@@ -20111,7 +20486,10 @@ const Ota = new SingletonKosModelRegistrationFactory({
|
|
|
20111
20486
|
class: OtaModelImpl,
|
|
20112
20487
|
type: MODEL_TYPE$c
|
|
20113
20488
|
});
|
|
20114
|
-
const log$
|
|
20489
|
+
const log$9 = KosLog.createLogger({
|
|
20490
|
+
group: LogGroup.model,
|
|
20491
|
+
name: "await-future-call"
|
|
20492
|
+
});
|
|
20115
20493
|
class FutureCallError extends Error {
|
|
20116
20494
|
endState;
|
|
20117
20495
|
reason;
|
|
@@ -20162,7 +20540,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20162
20540
|
const watchTracked = (future) => {
|
|
20163
20541
|
tracked = future;
|
|
20164
20542
|
if (cancelRequested) {
|
|
20165
|
-
future.cancelFuture().catch((e) => log$
|
|
20543
|
+
future.cancelFuture().catch((e) => log$9.error(e));
|
|
20166
20544
|
}
|
|
20167
20545
|
disposers.push(
|
|
20168
20546
|
mobx.reaction(
|
|
@@ -20179,7 +20557,7 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20179
20557
|
try {
|
|
20180
20558
|
cb(progress, status);
|
|
20181
20559
|
} catch (e) {
|
|
20182
|
-
log$
|
|
20560
|
+
log$9.warn("progress callback error", e);
|
|
20183
20561
|
}
|
|
20184
20562
|
});
|
|
20185
20563
|
},
|
|
@@ -20255,6 +20633,189 @@ function awaitFutureCall(model, methodCall, options = {}) {
|
|
|
20255
20633
|
};
|
|
20256
20634
|
return promise;
|
|
20257
20635
|
}
|
|
20636
|
+
function createCancellablePromise(promiseOrOptions, abortController, cancelFuture2, future) {
|
|
20637
|
+
const options = promiseOrOptions instanceof Promise ? { promise: promiseOrOptions, abortController, cancelFuture: cancelFuture2, future } : promiseOrOptions;
|
|
20638
|
+
const {
|
|
20639
|
+
promise,
|
|
20640
|
+
abortController: controller,
|
|
20641
|
+
cancelFuture: cancelFn,
|
|
20642
|
+
future: futureRef
|
|
20643
|
+
} = options;
|
|
20644
|
+
const cancellablePromise = promise;
|
|
20645
|
+
let currentProgress = 0;
|
|
20646
|
+
let currentStatus = "PENDING";
|
|
20647
|
+
let isRunning = true;
|
|
20648
|
+
const progressCallbacks = /* @__PURE__ */ new Set();
|
|
20649
|
+
let effectDisposer;
|
|
20650
|
+
if (futureRef && typeof futureRef === "object") {
|
|
20651
|
+
effectDisposer = mobx.autorun(() => {
|
|
20652
|
+
const newProgress = futureRef.progress || 0;
|
|
20653
|
+
const newStatus = futureRef.status || "PENDING";
|
|
20654
|
+
const newIsRunning = !futureRef.endState;
|
|
20655
|
+
if (newProgress !== currentProgress || newStatus !== currentStatus || newIsRunning !== isRunning) {
|
|
20656
|
+
currentProgress = newProgress;
|
|
20657
|
+
currentStatus = newStatus;
|
|
20658
|
+
isRunning = newIsRunning;
|
|
20659
|
+
progressCallbacks.forEach((callback) => {
|
|
20660
|
+
try {
|
|
20661
|
+
callback(currentProgress, currentStatus);
|
|
20662
|
+
} catch (error) {
|
|
20663
|
+
console.warn("Progress callback error:", error);
|
|
20664
|
+
}
|
|
20665
|
+
});
|
|
20666
|
+
}
|
|
20667
|
+
});
|
|
20668
|
+
}
|
|
20669
|
+
promise.finally(() => {
|
|
20670
|
+
isRunning = false;
|
|
20671
|
+
if (!controller?.signal.aborted) {
|
|
20672
|
+
currentStatus = "COMPLETED";
|
|
20673
|
+
progressCallbacks.forEach((callback) => {
|
|
20674
|
+
try {
|
|
20675
|
+
callback(currentProgress, currentStatus);
|
|
20676
|
+
} catch (error) {
|
|
20677
|
+
console.warn("Progress callback error:", error);
|
|
20678
|
+
}
|
|
20679
|
+
});
|
|
20680
|
+
}
|
|
20681
|
+
if (effectDisposer) {
|
|
20682
|
+
effectDisposer();
|
|
20683
|
+
}
|
|
20684
|
+
progressCallbacks.clear();
|
|
20685
|
+
});
|
|
20686
|
+
cancellablePromise.cancel = async () => {
|
|
20687
|
+
if (controller && !controller.signal.aborted) {
|
|
20688
|
+
controller.abort();
|
|
20689
|
+
}
|
|
20690
|
+
if (cancelFn) {
|
|
20691
|
+
await cancelFn();
|
|
20692
|
+
}
|
|
20693
|
+
isRunning = false;
|
|
20694
|
+
currentStatus = "CANCELLED";
|
|
20695
|
+
progressCallbacks.forEach((callback) => {
|
|
20696
|
+
try {
|
|
20697
|
+
callback(currentProgress, currentStatus);
|
|
20698
|
+
} catch (error) {
|
|
20699
|
+
console.warn("Progress callback error:", error);
|
|
20700
|
+
}
|
|
20701
|
+
});
|
|
20702
|
+
if (effectDisposer) {
|
|
20703
|
+
effectDisposer();
|
|
20704
|
+
}
|
|
20705
|
+
};
|
|
20706
|
+
cancellablePromise.getController = () => controller;
|
|
20707
|
+
cancellablePromise.isCancelled = () => controller?.signal.aborted ?? false;
|
|
20708
|
+
Object.defineProperty(cancellablePromise, "progress", {
|
|
20709
|
+
get: () => currentProgress,
|
|
20710
|
+
enumerable: true
|
|
20711
|
+
});
|
|
20712
|
+
Object.defineProperty(cancellablePromise, "status", {
|
|
20713
|
+
get: () => currentStatus,
|
|
20714
|
+
enumerable: true
|
|
20715
|
+
});
|
|
20716
|
+
Object.defineProperty(cancellablePromise, "isRunning", {
|
|
20717
|
+
get: () => isRunning,
|
|
20718
|
+
enumerable: true
|
|
20719
|
+
});
|
|
20720
|
+
cancellablePromise.onProgressUpdate = (callback) => {
|
|
20721
|
+
progressCallbacks.add(callback);
|
|
20722
|
+
callback(currentProgress, currentStatus);
|
|
20723
|
+
return () => progressCallbacks.delete(callback);
|
|
20724
|
+
};
|
|
20725
|
+
return cancellablePromise;
|
|
20726
|
+
}
|
|
20727
|
+
const log$8 = KosLog.createLogger({
|
|
20728
|
+
group: LogGroup.model,
|
|
20729
|
+
name: "cancellable-future-call"
|
|
20730
|
+
});
|
|
20731
|
+
function makeCancellable(model, methodCall) {
|
|
20732
|
+
const initialFuture = model.futureHandler.future;
|
|
20733
|
+
const promise = methodCall(model);
|
|
20734
|
+
let newFuture = null;
|
|
20735
|
+
setTimeout(() => {
|
|
20736
|
+
newFuture = model.futureHandler.future;
|
|
20737
|
+
if (newFuture === initialFuture) {
|
|
20738
|
+
newFuture = null;
|
|
20739
|
+
}
|
|
20740
|
+
}, 0);
|
|
20741
|
+
return createCancellablePromise({
|
|
20742
|
+
promise,
|
|
20743
|
+
abortController: void 0,
|
|
20744
|
+
// No direct AbortController access
|
|
20745
|
+
cancelFuture: async () => {
|
|
20746
|
+
if (newFuture) {
|
|
20747
|
+
await newFuture.cancelFuture();
|
|
20748
|
+
} else {
|
|
20749
|
+
const currentFuture = model.futureHandler.future;
|
|
20750
|
+
if (currentFuture) {
|
|
20751
|
+
await currentFuture.cancelFuture();
|
|
20752
|
+
}
|
|
20753
|
+
}
|
|
20754
|
+
},
|
|
20755
|
+
future: newFuture
|
|
20756
|
+
// Pass the future for progress tracking
|
|
20757
|
+
});
|
|
20758
|
+
}
|
|
20759
|
+
function withCancellation(model, methodName, ...args) {
|
|
20760
|
+
const method = model[methodName];
|
|
20761
|
+
if (typeof method !== "function") {
|
|
20762
|
+
throw new Error(`${String(methodName)} is not a method`);
|
|
20763
|
+
}
|
|
20764
|
+
const initialFuture = model.futureHandler.future;
|
|
20765
|
+
const promise = method.apply(model, args);
|
|
20766
|
+
let targetFuture = null;
|
|
20767
|
+
setTimeout(() => {
|
|
20768
|
+
const currentFuture = model.futureHandler.future;
|
|
20769
|
+
if (currentFuture && currentFuture !== initialFuture) {
|
|
20770
|
+
targetFuture = currentFuture;
|
|
20771
|
+
}
|
|
20772
|
+
}, 0);
|
|
20773
|
+
return createCancellablePromise({
|
|
20774
|
+
promise,
|
|
20775
|
+
abortController: void 0,
|
|
20776
|
+
cancelFuture: async () => {
|
|
20777
|
+
if (targetFuture) {
|
|
20778
|
+
await targetFuture.cancelFuture();
|
|
20779
|
+
} else {
|
|
20780
|
+
const fallbackFuture = model.futureHandler.future;
|
|
20781
|
+
if (fallbackFuture) {
|
|
20782
|
+
await fallbackFuture.cancelFuture();
|
|
20783
|
+
}
|
|
20784
|
+
}
|
|
20785
|
+
},
|
|
20786
|
+
future: targetFuture
|
|
20787
|
+
// Pass the future for progress tracking
|
|
20788
|
+
});
|
|
20789
|
+
}
|
|
20790
|
+
class CancellationBatch {
|
|
20791
|
+
operations = [];
|
|
20792
|
+
add(model, methodCall) {
|
|
20793
|
+
const cancellable = makeCancellable(model, methodCall);
|
|
20794
|
+
this.operations.push(cancellable);
|
|
20795
|
+
return cancellable;
|
|
20796
|
+
}
|
|
20797
|
+
async cancelAll() {
|
|
20798
|
+
await Promise.all(
|
|
20799
|
+
this.operations.map(
|
|
20800
|
+
(op) => op.cancel().catch(() => {
|
|
20801
|
+
log$8.warn("Cancellation failed for operation:", op);
|
|
20802
|
+
})
|
|
20803
|
+
)
|
|
20804
|
+
);
|
|
20805
|
+
}
|
|
20806
|
+
getAllControllers() {
|
|
20807
|
+
return this.operations.map((op) => op.getController());
|
|
20808
|
+
}
|
|
20809
|
+
getActiveCount() {
|
|
20810
|
+
return this.operations.filter((op) => !op.isCancelled()).length;
|
|
20811
|
+
}
|
|
20812
|
+
clear() {
|
|
20813
|
+
this.operations = [];
|
|
20814
|
+
}
|
|
20815
|
+
}
|
|
20816
|
+
function createCancellationBatch() {
|
|
20817
|
+
return new CancellationBatch();
|
|
20818
|
+
}
|
|
20258
20819
|
function createCancellableService(serviceFunction) {
|
|
20259
20820
|
let controller;
|
|
20260
20821
|
const wrappedFunction = async (...args) => {
|
|
@@ -22611,9 +23172,12 @@ const { URL: URL$5 } = resolveServiceUrl();
|
|
|
22611
23172
|
const { getOne: getOne$1 } = ServiceFactory.build({
|
|
22612
23173
|
basePath: `${URL$5}/api/device`
|
|
22613
23174
|
});
|
|
22614
|
-
const log$
|
|
23175
|
+
const log$7 = KosLog.createLogger({
|
|
23176
|
+
group: LogGroup.service,
|
|
23177
|
+
name: "device-service"
|
|
23178
|
+
});
|
|
22615
23179
|
const getSerialNumber = async () => {
|
|
22616
|
-
log$
|
|
23180
|
+
log$7.debug("sending GET for device serial number");
|
|
22617
23181
|
try {
|
|
22618
23182
|
const response = await getOne$1({
|
|
22619
23183
|
urlOverride: `${URL$5}/api/kos/device/serialNumber`
|
|
@@ -22621,14 +23185,14 @@ const getSerialNumber = async () => {
|
|
|
22621
23185
|
return [void 0, response?.data.serialNumber];
|
|
22622
23186
|
} catch (error) {
|
|
22623
23187
|
if (error instanceof FetchError) {
|
|
22624
|
-
log$
|
|
23188
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22625
23189
|
return [error.payload.error, void 0];
|
|
22626
23190
|
}
|
|
22627
23191
|
}
|
|
22628
23192
|
return ["unknownError", void 0];
|
|
22629
23193
|
};
|
|
22630
23194
|
const getDeviceDetails = async () => {
|
|
22631
|
-
log$
|
|
23195
|
+
log$7.debug("sending GET for device details");
|
|
22632
23196
|
try {
|
|
22633
23197
|
const response = await getOne$1({
|
|
22634
23198
|
urlOverride: `${URL$5}/api/kos/device`
|
|
@@ -22639,7 +23203,7 @@ const getDeviceDetails = async () => {
|
|
|
22639
23203
|
return [void 0, response.data];
|
|
22640
23204
|
} catch (error) {
|
|
22641
23205
|
if (error instanceof FetchError) {
|
|
22642
|
-
log$
|
|
23206
|
+
log$7.error(`Error fetching device serial number: ${error.payload.error}`);
|
|
22643
23207
|
return [error.payload.error, void 0];
|
|
22644
23208
|
}
|
|
22645
23209
|
}
|
|
@@ -22850,13 +23414,13 @@ const { URL: URL$4 } = resolveServiceUrl();
|
|
|
22850
23414
|
const { getAll: getAll$2 } = ServiceFactory.build({
|
|
22851
23415
|
basePath: `${URL$4}/api/kos/network/interfaces`
|
|
22852
23416
|
});
|
|
22853
|
-
const log$
|
|
22854
|
-
|
|
22855
|
-
|
|
23417
|
+
const log$6 = KosLog.createLogger({
|
|
23418
|
+
group: LogGroup.service,
|
|
23419
|
+
name: "network-interface-service"
|
|
22856
23420
|
});
|
|
22857
23421
|
const getNetworkInterfaces = async () => {
|
|
22858
23422
|
const destinationAddress = getKosConnectionId();
|
|
22859
|
-
log$
|
|
23423
|
+
log$6.debug("sending GET for copy-logs");
|
|
22860
23424
|
try {
|
|
22861
23425
|
const response = await getAll$2({
|
|
22862
23426
|
destinationAddress
|
|
@@ -22864,7 +23428,7 @@ const getNetworkInterfaces = async () => {
|
|
|
22864
23428
|
return [void 0, response?.data];
|
|
22865
23429
|
} catch (error) {
|
|
22866
23430
|
if (error instanceof FetchError) {
|
|
22867
|
-
log$
|
|
23431
|
+
log$6.error(`Error fetching log file size: ${error.payload.error}`);
|
|
22868
23432
|
return [error.payload.error, void 0];
|
|
22869
23433
|
}
|
|
22870
23434
|
}
|
|
@@ -22962,15 +23526,15 @@ const { URL: URL$3 } = resolveServiceUrl();
|
|
|
22962
23526
|
const { getAll: getAll$1 } = ServiceFactory.build({
|
|
22963
23527
|
basePath: `${URL$3}/api/kos/storage/devices`
|
|
22964
23528
|
});
|
|
22965
|
-
const log$
|
|
22966
|
-
|
|
22967
|
-
|
|
23529
|
+
const log$5 = KosLog.createLogger({
|
|
23530
|
+
group: LogGroup.service,
|
|
23531
|
+
name: "storage-device-service"
|
|
22968
23532
|
});
|
|
22969
23533
|
const getStorageDevices = async () => {
|
|
22970
|
-
log$
|
|
23534
|
+
log$5.debug("sending GET for storage-device");
|
|
22971
23535
|
const response = await getAll$1({});
|
|
22972
23536
|
if (!response?.data || response.status !== 200) {
|
|
22973
|
-
log$
|
|
23537
|
+
log$5.error("Failed to retrieve storage-device data", response);
|
|
22974
23538
|
return [];
|
|
22975
23539
|
}
|
|
22976
23540
|
return response.data;
|
|
@@ -23168,17 +23732,17 @@ const { URL: URL$2 } = resolveServiceUrl();
|
|
|
23168
23732
|
const { getAll, postModel } = ServiceFactory.build({
|
|
23169
23733
|
basePath: `${URL$2}/api/kos/update/available`
|
|
23170
23734
|
});
|
|
23171
|
-
const log$
|
|
23172
|
-
|
|
23173
|
-
|
|
23735
|
+
const log$4 = KosLog.createLogger({
|
|
23736
|
+
group: LogGroup.service,
|
|
23737
|
+
name: "usb-update-service"
|
|
23174
23738
|
});
|
|
23175
23739
|
const getAvailableUpdates = async () => {
|
|
23176
|
-
log$
|
|
23740
|
+
log$4.debug("sending GET for usb-update");
|
|
23177
23741
|
const response = await getAll({
|
|
23178
23742
|
urlOverride: `${URL$2}/api/kos/update/available`
|
|
23179
23743
|
});
|
|
23180
23744
|
if (!response?.data || response?.status !== 200) {
|
|
23181
|
-
log$
|
|
23745
|
+
log$4.error("Failed to retrieve usb-update data", response);
|
|
23182
23746
|
return [];
|
|
23183
23747
|
}
|
|
23184
23748
|
return response.data;
|
|
@@ -23419,9 +23983,9 @@ const { URL: URL$1 } = resolveServiceUrl();
|
|
|
23419
23983
|
const { getOne } = ServiceFactory.build({
|
|
23420
23984
|
basePath: `${URL$1}/api/translation`
|
|
23421
23985
|
});
|
|
23422
|
-
const log$
|
|
23423
|
-
|
|
23424
|
-
|
|
23986
|
+
const log$3 = KosLog.createLogger({
|
|
23987
|
+
group: LogGroup.service,
|
|
23988
|
+
name: "translation-service"
|
|
23425
23989
|
});
|
|
23426
23990
|
const getDefaultHost = () => {
|
|
23427
23991
|
const defaultHost = window.location.origin;
|
|
@@ -23431,23 +23995,23 @@ const getDefaultHost = () => {
|
|
|
23431
23995
|
return result;
|
|
23432
23996
|
};
|
|
23433
23997
|
const getTranslations = async (url, root) => {
|
|
23434
|
-
log$
|
|
23998
|
+
log$3.debug(`Loading translations from: ${url}`);
|
|
23435
23999
|
const rootUrl = root ?? getDefaultHost();
|
|
23436
24000
|
try {
|
|
23437
24001
|
const response = await fetch(`${rootUrl}${url}`);
|
|
23438
24002
|
if (response.status !== 200) {
|
|
23439
|
-
log$
|
|
24003
|
+
log$3.warn(`Failed to fetch translations at ${url}: ${response.status}`);
|
|
23440
24004
|
return {};
|
|
23441
24005
|
}
|
|
23442
24006
|
const json = await response.json();
|
|
23443
24007
|
return json;
|
|
23444
24008
|
} catch (error) {
|
|
23445
|
-
log$
|
|
24009
|
+
log$3.error("Error fetching translations", error);
|
|
23446
24010
|
throw error;
|
|
23447
24011
|
}
|
|
23448
24012
|
};
|
|
23449
24013
|
const getLocalizationDescriptor = async () => {
|
|
23450
|
-
log$
|
|
24014
|
+
log$3.debug("Getting system localization descriptor");
|
|
23451
24015
|
const response = await getOne({
|
|
23452
24016
|
urlOverride: `${URL$1}/api/system/kos/localization`
|
|
23453
24017
|
});
|
|
@@ -23459,7 +24023,7 @@ const getLocalizationDescriptor = async () => {
|
|
|
23459
24023
|
return response.data;
|
|
23460
24024
|
};
|
|
23461
24025
|
const getKosLocalizationDescriptor = (context) => async () => {
|
|
23462
|
-
log$
|
|
24026
|
+
log$3.debug(`Getting KOS localization descriptor for context: ${context}`);
|
|
23463
24027
|
const response = await getOne({
|
|
23464
24028
|
urlOverride: `${URL$1}/api/kos/localization/contexts`
|
|
23465
24029
|
});
|
|
@@ -23565,6 +24129,7 @@ const splitKey = (currentNamespace, _key) => {
|
|
|
23565
24129
|
return { namespace: currentNamespace, key: _key };
|
|
23566
24130
|
}
|
|
23567
24131
|
};
|
|
24132
|
+
const isTranslationFallback = (bundle) => bundle?.fallback === true;
|
|
23568
24133
|
let TranslationModelImpl = class {
|
|
23569
24134
|
/** Unique identifier for the model instance */
|
|
23570
24135
|
id;
|
|
@@ -23624,23 +24189,28 @@ let TranslationModelImpl = class {
|
|
|
23624
24189
|
}
|
|
23625
24190
|
return langs;
|
|
23626
24191
|
}
|
|
24192
|
+
/** The namespace's translation file for `lang`, through `resolver`; empty when it has none. */
|
|
24193
|
+
loadFile(lang) {
|
|
24194
|
+
try {
|
|
24195
|
+
const translationsPath = this.resolver(this.namespace, lang);
|
|
24196
|
+
return getTranslations(translationsPath, this.rootUrl);
|
|
24197
|
+
} catch {
|
|
24198
|
+
return Promise.resolve({});
|
|
24199
|
+
}
|
|
24200
|
+
}
|
|
23627
24201
|
/**
|
|
23628
24202
|
* Loads and merges translations for all locales in the fallback chain.
|
|
23629
24203
|
* @private
|
|
23630
24204
|
*/
|
|
23631
24205
|
async loadTranslations() {
|
|
23632
24206
|
const reversed = this.getTranslationLocales(this.currentLocale).reverse();
|
|
23633
|
-
const allTranslations = reversed.map((lang) => {
|
|
24207
|
+
const allTranslations = reversed.map(async (lang) => {
|
|
23634
24208
|
if (this.bundleResolver) {
|
|
23635
24209
|
const context = KosContextManager.getContext(this.id);
|
|
23636
|
-
|
|
23637
|
-
|
|
23638
|
-
try {
|
|
23639
|
-
const translationsPath = this.resolver(this.namespace, lang);
|
|
23640
|
-
return getTranslations(translationsPath, this.rootUrl);
|
|
23641
|
-
} catch {
|
|
23642
|
-
return Promise.resolve({});
|
|
24210
|
+
const bundle = await this.bundleResolver(this.namespace, lang, context);
|
|
24211
|
+
return isTranslationFallback(bundle) ? this.loadFile(lang) : bundle;
|
|
23643
24212
|
}
|
|
24213
|
+
return this.loadFile(lang);
|
|
23644
24214
|
});
|
|
23645
24215
|
const results = await Promise.allSettled(allTranslations);
|
|
23646
24216
|
kosAction(() => {
|
|
@@ -23948,6 +24518,10 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
23948
24518
|
if (kind && result) __defProp(target, key, result);
|
|
23949
24519
|
return result;
|
|
23950
24520
|
};
|
|
24521
|
+
const log$2 = KosLog.createLogger({
|
|
24522
|
+
group: LogGroup.model,
|
|
24523
|
+
name: "ws-event-model"
|
|
24524
|
+
});
|
|
23951
24525
|
const stringify = ({ headers, body }) => {
|
|
23952
24526
|
const headText = Object.entries(headers).map(([key, value]) => `${key}:${value}`).join("\\n");
|
|
23953
24527
|
return headText + "\\n\\n" + body;
|
|
@@ -23971,7 +24545,7 @@ exports.WsEventModel = class WsEventModel {
|
|
|
23971
24545
|
this.processEvent(payload);
|
|
23972
24546
|
}
|
|
23973
24547
|
processEvent(data, isSend = false) {
|
|
23974
|
-
|
|
24548
|
+
log$2.debug("kos event received");
|
|
23975
24549
|
const { body, headers } = data.body;
|
|
23976
24550
|
const isUnique = headers["request-id"] || headers["response-id"];
|
|
23977
24551
|
const msgId = headers["request-id"] || headers["response-id"] || headers["topic"] || headers["type"];
|
|
@@ -23995,7 +24569,7 @@ exports.WsEventModel = class WsEventModel {
|
|
|
23995
24569
|
mocked: !!headers["mocked"]
|
|
23996
24570
|
};
|
|
23997
24571
|
this.events.set(rawKey, rawData);
|
|
23998
|
-
|
|
24572
|
+
log$2.debug(`logged ${this.events.size} events`);
|
|
23999
24573
|
}
|
|
24000
24574
|
}
|
|
24001
24575
|
};
|
|
@@ -24042,9 +24616,9 @@ const Registry = {
|
|
|
24042
24616
|
preloadModels: []
|
|
24043
24617
|
};
|
|
24044
24618
|
const PRELOAD = true;
|
|
24045
|
-
const registerCoreModels = (root) => () => {
|
|
24619
|
+
const registerCoreModels = (root) => ({ preloadLogManager = true } = {}) => {
|
|
24046
24620
|
const coreModels2 = CoreModels;
|
|
24047
|
-
registerKosModel(KosModelRegistry2)(Trouble).model(TroubleContainer).model(StorageDeviceContainer).model(UsbUpdateContainer).model(Device).model(Ota).model(ConfigBean).model(SoftwareInfo).model(KeyValue).model(NetworkInterfaceContainer).model(CanvasDispatcher).model(CanvasRenderer).model(KosExpressionEvaluator).model(BrowserRouter, PRELOAD).model(LogStreamContainer).model(KosLogManager);
|
|
24621
|
+
registerKosModel(KosModelRegistry2)(Trouble).model(TroubleContainer).model(StorageDeviceContainer).model(UsbUpdateContainer).model(Device).model(Ota).model(ConfigBean).model(SoftwareInfo).model(KeyValue).model(NetworkInterfaceContainer).model(CanvasDispatcher).model(CanvasRenderer).model(KosExpressionEvaluator).model(BrowserRouter, PRELOAD).model(LogStreamContainer).model(KosLogManager, preloadLogManager);
|
|
24048
24622
|
Object.keys(coreModels2).forEach((key) => {
|
|
24049
24623
|
const model = coreModels2[key];
|
|
24050
24624
|
registerLegacyModel(KosModelRegistry2)(key, model);
|
|
@@ -24068,7 +24642,10 @@ const KosModelRegistry2 = _KosModelRegistry;
|
|
|
24068
24642
|
const TIMER_EVENT = `/kos-timer-event`;
|
|
24069
24643
|
const TOPIC_TIMER_TICK_EVENT = `/kos-timer-event/tick`;
|
|
24070
24644
|
const TIMER_END = "defaultTimerEnd";
|
|
24071
|
-
const log$1 = KosLog.createLogger({
|
|
24645
|
+
const log$1 = KosLog.createLogger({
|
|
24646
|
+
group: LogGroup.model,
|
|
24647
|
+
name: "timer-manager"
|
|
24648
|
+
});
|
|
24072
24649
|
const isConfigProperty = (value) => value.updateProperty !== void 0;
|
|
24073
24650
|
class KosTimer {
|
|
24074
24651
|
name;
|
|
@@ -24095,7 +24672,7 @@ class KosTimer {
|
|
|
24095
24672
|
this.remainingTime = timeoutValue;
|
|
24096
24673
|
if (isConfigProperty(timeout)) {
|
|
24097
24674
|
kosAutoEffect(() => {
|
|
24098
|
-
|
|
24675
|
+
log$1.info(
|
|
24099
24676
|
`Updating config value timer ${name} with new timeout value ${timeout.value}`
|
|
24100
24677
|
);
|
|
24101
24678
|
const newValue = timeout.value || 60;
|
|
@@ -24333,8 +24910,8 @@ const TimerManager = {
|
|
|
24333
24910
|
}
|
|
24334
24911
|
};
|
|
24335
24912
|
const log = KosLog.createLogger({
|
|
24336
|
-
|
|
24337
|
-
|
|
24913
|
+
group: LogGroup.service,
|
|
24914
|
+
name: "software-info-service"
|
|
24338
24915
|
});
|
|
24339
24916
|
const getSoftwareInfos = async (signal) => {
|
|
24340
24917
|
const destinationAddress = getKosConnectionId();
|
|
@@ -24443,6 +25020,7 @@ exports.AuthState = AuthState;
|
|
|
24443
25020
|
exports.BrowserKosRouter = BrowserKosRouter;
|
|
24444
25021
|
exports.BrowserRouter = BrowserRouter;
|
|
24445
25022
|
exports.CancellableServiceManager = CancellableServiceManager;
|
|
25023
|
+
exports.CancellationBatch = CancellationBatch;
|
|
24446
25024
|
exports.CanvasDispatcher = CanvasDispatcher;
|
|
24447
25025
|
exports.CanvasRenderer = CanvasRenderer;
|
|
24448
25026
|
exports.ChildModels = ChildModels;
|
|
@@ -24537,10 +25115,11 @@ exports.LOGIN_HOST = LOGIN_HOST;
|
|
|
24537
25115
|
exports.LOGIN_URL = LOGIN_URL;
|
|
24538
25116
|
exports.LogBlock = LogBlock;
|
|
24539
25117
|
exports.LogBlockContainer = LogBlockContainer;
|
|
24540
|
-
exports.
|
|
25118
|
+
exports.LogGroup = LogGroup;
|
|
24541
25119
|
exports.LogStream = LogStream;
|
|
24542
25120
|
exports.LogStreamContainer = LogStreamContainer;
|
|
24543
25121
|
exports.LoggerSetup = LoggerSetup;
|
|
25122
|
+
exports.MESSAGE_LOGGER_NAME = MESSAGE_LOGGER_NAME;
|
|
24544
25123
|
exports.MODEL_DELETION_DELAY = MODEL_DELETION_DELAY;
|
|
24545
25124
|
exports.MixinModels = MixinModels;
|
|
24546
25125
|
exports.ModelEffects = ModelEffects;
|
|
@@ -24607,6 +25186,7 @@ exports.WebSocketEvents = WebSocketEvents;
|
|
|
24607
25186
|
exports.WebSocketTransport = WebSocketTransport;
|
|
24608
25187
|
exports.WsEventFactory = WsEventFactory;
|
|
24609
25188
|
exports.addFuture = addFuture;
|
|
25189
|
+
exports.addLogOverride = addLogOverride;
|
|
24610
25190
|
exports.api = api$1;
|
|
24611
25191
|
exports.api$1 = api;
|
|
24612
25192
|
exports.applyFunctionalEnhancements = applyFunctionalEnhancements;
|
|
@@ -24624,7 +25204,9 @@ exports.convert = convert;
|
|
|
24624
25204
|
exports.convertWithUnits = convertWithUnits;
|
|
24625
25205
|
exports.createBaseMessage = createBaseMessage;
|
|
24626
25206
|
exports.createBroadcastMessageResponse = createBroadcastMessageResponse;
|
|
25207
|
+
exports.createCancellablePromise = createCancellablePromise;
|
|
24627
25208
|
exports.createCancellableService = createCancellableService;
|
|
25209
|
+
exports.createCancellationBatch = createCancellationBatch;
|
|
24628
25210
|
exports.createClient = createClient;
|
|
24629
25211
|
exports.createFosBaseMessage = createFosBaseMessage;
|
|
24630
25212
|
exports.createHeaders = createHeaders;
|
|
@@ -24666,15 +25248,14 @@ exports.getKeyValue = getKeyValue;
|
|
|
24666
25248
|
exports.getKosCompanionModel = getKosCompanionModel;
|
|
24667
25249
|
exports.getKosConnectionId = getKosConnectionId;
|
|
24668
25250
|
exports.getKosLocalizationDescriptor = getKosLocalizationDescriptor;
|
|
24669
|
-
exports.getKosMessageLogging = getKosMessageLogging;
|
|
24670
25251
|
exports.getKosModel = getKosModel$1;
|
|
24671
25252
|
exports.getKosModelActivationState = getKosModelActivationState;
|
|
24672
25253
|
exports.getKosModelSync = getKosModelSync;
|
|
24673
25254
|
exports.getKosModelType = getKosModelType;
|
|
24674
25255
|
exports.getKosSessionKey = getKosSessionKey;
|
|
24675
25256
|
exports.getLocalizationDescriptor = getLocalizationDescriptor;
|
|
25257
|
+
exports.getLogGroups = getLogGroups;
|
|
24676
25258
|
exports.getLogLevel = getLogLevel;
|
|
24677
|
-
exports.getLogMessageToStudio = getLogMessageToStudio;
|
|
24678
25259
|
exports.getLogOverrides = getLogOverrides;
|
|
24679
25260
|
exports.getLogStreamBlock = getLogStreamBlock;
|
|
24680
25261
|
exports.getLogStreamBlocks = getLogStreamBlocks;
|
|
@@ -24740,6 +25321,7 @@ exports.kosStateGuard = kosStateGuard;
|
|
|
24740
25321
|
exports.kosStateMachine = kosStateMachine;
|
|
24741
25322
|
exports.kosTopicHandler = kosTopicHandler;
|
|
24742
25323
|
exports.kosWhen = kosWhen;
|
|
25324
|
+
exports.makeCancellable = makeCancellable;
|
|
24743
25325
|
exports.mapConfigBeanModelToDto = mapConfigBeanModelToDto;
|
|
24744
25326
|
exports.mapDataToModel = mapDataToModel;
|
|
24745
25327
|
exports.mapDtoToConfigBeanModel = mapDtoToConfigBeanModel;
|
|
@@ -24765,6 +25347,7 @@ exports.registerExtensionPoint = registerExtensionPoint;
|
|
|
24765
25347
|
exports.registerHttpRoutes = registerHttpRoutes;
|
|
24766
25348
|
exports.registerKosModel = registerKosModel;
|
|
24767
25349
|
exports.registerLegacyModel = registerLegacyModel;
|
|
25350
|
+
exports.removeLogOverride = removeLogOverride;
|
|
24768
25351
|
exports.resetKosModel = resetKosModel;
|
|
24769
25352
|
exports.resolveBaseUrl = resolveBaseUrl;
|
|
24770
25353
|
exports.resolveChild = resolveChild;
|
|
@@ -24777,6 +25360,7 @@ exports.resolveListDeltas = resolveListDeltas;
|
|
|
24777
25360
|
exports.resolveServiceRequestParameters = resolveServiceRequestParameters;
|
|
24778
25361
|
exports.resolveServiceUrl = resolveServiceUrl;
|
|
24779
25362
|
exports.resolveTrouble = resolveTrouble;
|
|
25363
|
+
exports.retryWithExponentialBackoff = retryWithExponentialBackoff;
|
|
24780
25364
|
exports.sendAsyncIntent = sendAsyncIntent;
|
|
24781
25365
|
exports.sendBroadcastMessage = sendBroadcastMessage;
|
|
24782
25366
|
exports.sendCanvasData = sendCanvasData;
|
|
@@ -24784,6 +25368,7 @@ exports.sendIntent = sendIntent;
|
|
|
24784
25368
|
exports.sendKosHttpMessageResponse = sendKosHttpMessageResponse;
|
|
24785
25369
|
exports.sendKosMessage = sendKosMessage;
|
|
24786
25370
|
exports.sendKosMessageResponse = sendKosMessageResponse;
|
|
25371
|
+
exports.sendRequest = sendRequest;
|
|
24787
25372
|
exports.sendStudioMessage = sendStudioMessage;
|
|
24788
25373
|
exports.sendStudioMessageRequest = sendStudioMessageRequest;
|
|
24789
25374
|
exports.service = service;
|
|
@@ -24792,6 +25377,7 @@ exports.setTime = setTime;
|
|
|
24792
25377
|
exports.setTimezone = setTimezone;
|
|
24793
25378
|
exports.subscribe = subscribe;
|
|
24794
25379
|
exports.subscribeToLogStream = subscribeToLogStream;
|
|
25380
|
+
exports.syncPublish = syncPublish;
|
|
24795
25381
|
exports.troubleByTypeReducer = troubleByTypeReducer;
|
|
24796
25382
|
exports.troubleDataFactory = troubleDataFactory;
|
|
24797
25383
|
exports.unloadKosModel = unloadKosModel;
|
|
@@ -24800,6 +25386,8 @@ exports.updateKeyValue = updateKeyValue;
|
|
|
24800
25386
|
exports.uuid = uuid;
|
|
24801
25387
|
exports.waitForAppToStart = waitForAppToStart;
|
|
24802
25388
|
exports.waitForAppsToStart = waitForAppsToStart;
|
|
25389
|
+
exports.waitForRequest = waitForRequest;
|
|
24803
25390
|
exports.whenReady = whenReady;
|
|
25391
|
+
exports.withCancellation = withCancellation;
|
|
24804
25392
|
exports.wrapWithFutureLifecycle = wrapWithFutureLifecycle;
|
|
24805
|
-
//# sourceMappingURL=software-info-registration-
|
|
25393
|
+
//# sourceMappingURL=software-info-registration-BPN4QLfN.cjs.map
|