alemonjs 2.1.83-alpha.3 → 2.1.83-alpha.5
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/lib/application/index.d.ts +14 -1
- package/lib/application/index.js +24 -2
- package/lib/core/cbp/server/main.js +21 -3
- package/lib/core/process/ipc-bridge.js +10 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +15 -3
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ export * from '../types/index.js';
|
|
|
2
2
|
export { defineChildren } from './define-children.js';
|
|
3
3
|
export { defineResponse } from './define-response.js';
|
|
4
4
|
export { defineMiddleware } from './define-middleware.js';
|
|
5
|
-
export { defineRouter } from './define-router.js';
|
|
5
|
+
export { defineRouter, lazy, runHandler } from './define-router.js';
|
|
6
6
|
export * from './expose.js';
|
|
7
7
|
export * from './hooks/index.js';
|
|
8
8
|
export * from './schedule.js';
|
|
@@ -10,7 +10,20 @@ export * from './format/message-api.js';
|
|
|
10
10
|
export * from './format/message-format.js';
|
|
11
11
|
export * from './format/message-format-old.js';
|
|
12
12
|
export * from './router/main.js';
|
|
13
|
+
export { validateRouteArgsForCommand } from './router/validator.js';
|
|
13
14
|
export * from './runtime/event-response.js';
|
|
14
15
|
export * from './runtime/event-middleware.js';
|
|
15
16
|
export { createSelects, onSelects, onState, unChildren, unState, useState } from './runtime/event-utils.js';
|
|
16
17
|
export { onGroup } from './runtime/event-group.js';
|
|
18
|
+
export { Core, Response, ResponseMiddleware, MiddlewareTree, ResponseTree, ResponseRouter, MiddlewareRouter, Middleware, SubscribeList, StateSubscribe, State, ChildrenApp, registerRuntimeApp, updateRuntimeAppStatus, updateRuntimeAppCapabilities, setRuntimeAppKoaRouters, getRuntimeAppKoaRouters, clearRuntimeAppKoaRouters, listRuntimeAppKoaRouters, getRuntimeApp, toRuntimeAppSnapshot, listRuntimeApps, disposeRuntimeApp, disposeAllRuntimeApps, hasRuntimeAppCapability, bumpStoreVersion, getSubscribeList, getChildrenApp, listChildrenApps, ProcessorEventAutoClearMap, ProcessorEventUserAutoClearMap, core } from './runtime/store.js';
|
|
19
|
+
export type { RuntimeAppStatus, RuntimeAppCapability, RuntimeAppError, RuntimeAppRecord } from './runtime/store.js';
|
|
20
|
+
export { loadChildren, loadChildrenFile } from './runtime/load-modules/loadChild.js';
|
|
21
|
+
export { run, loadModels } from './runtime/load-modules/load.js';
|
|
22
|
+
export { onProcessor, OnProcessor } from './runtime/event-processor.js';
|
|
23
|
+
export { expendCycle } from './runtime/event-processor-cycle.js';
|
|
24
|
+
export { expendEvent } from './runtime/event-processor-event.js';
|
|
25
|
+
export { expendMiddleware } from './runtime/event-processor-middleware.js';
|
|
26
|
+
export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './runtime/event-processor-subscribe.js';
|
|
27
|
+
export { withEventContext, withProcessorTrace, getCurrentEvent, getCurrentNext, getCurrentAppName, getCurrentPhase, finishCurrentTrace, markEventSendAttempt, markEventSendSuccess, markEventSendFailure, recordEventSendResults } from './runtime/hook-event-context.js';
|
|
28
|
+
export { registerAppDir, unregisterAppDir, scheduleInterval, scheduleTimeout, scheduleCron, schedulePause, scheduleResume, scheduleCancel, scheduleCancelByApp, scheduleCancelAll, scheduleList } from './runtime/schedule-store.js';
|
|
29
|
+
export { cbpClient } from './runtime/cbp/index.js';
|
package/lib/application/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { ActionsEventEnum } from '../types/event/actions.js';
|
|
|
2
2
|
export { defineChildren } from './define-children.js';
|
|
3
3
|
export { defineResponse } from './define-response.js';
|
|
4
4
|
export { defineMiddleware } from './define-middleware.js';
|
|
5
|
-
export { defineRouter } from './define-router.js';
|
|
5
|
+
export { defineRouter, lazy, runHandler } from './define-router.js';
|
|
6
6
|
export { Expose, clearAllExpose, disposeExpose, registerExpose } from './expose.js';
|
|
7
7
|
export { useAnnounce } from './hooks/announce.js';
|
|
8
8
|
export { useChannel } from './hooks/channel.js';
|
|
@@ -29,8 +29,30 @@ export { Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Ma
|
|
|
29
29
|
export { Router } from './router/dsl.js';
|
|
30
30
|
export { checkFallbackHint } from './router/fallback.js';
|
|
31
31
|
export { normalizeRoutePath, parseMessageText } from './router/parser.js';
|
|
32
|
-
export { validateRouteArgs } from './router/validator.js';
|
|
32
|
+
export { validateRouteArgs, validateRouteArgsForCommand } from './router/validator.js';
|
|
33
33
|
export { OnResponse, onResponse } from './runtime/event-response.js';
|
|
34
34
|
export { OnMiddleware, onMiddleware } from './runtime/event-middleware.js';
|
|
35
35
|
export { createSelects, onSelects, onState, unChildren, unState, useState } from './runtime/event-utils.js';
|
|
36
36
|
export { onGroup } from './runtime/event-group.js';
|
|
37
|
+
export { ChildrenApp, Core, Middleware, MiddlewareRouter, MiddlewareTree, ProcessorEventAutoClearMap, ProcessorEventUserAutoClearMap, Response, ResponseMiddleware, ResponseRouter, ResponseTree, State, StateSubscribe, SubscribeList, bumpStoreVersion, clearRuntimeAppKoaRouters, core, disposeAllRuntimeApps, disposeRuntimeApp, getChildrenApp, getRuntimeApp, getRuntimeAppKoaRouters, getSubscribeList, hasRuntimeAppCapability, listChildrenApps, listRuntimeAppKoaRouters, listRuntimeApps, registerRuntimeApp, setRuntimeAppKoaRouters, toRuntimeAppSnapshot, updateRuntimeAppCapabilities, updateRuntimeAppStatus } from './runtime/store.js';
|
|
38
|
+
export { loadChildren, loadChildrenFile } from './runtime/load-modules/loadChild.js';
|
|
39
|
+
export { loadModels, run } from './runtime/load-modules/load.js';
|
|
40
|
+
export { OnProcessor, onProcessor } from './runtime/event-processor.js';
|
|
41
|
+
export { expendCycle } from './runtime/event-processor-cycle.js';
|
|
42
|
+
export { expendEvent } from './runtime/event-processor-event.js';
|
|
43
|
+
export { expendMiddleware } from './runtime/event-processor-middleware.js';
|
|
44
|
+
export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './runtime/event-processor-subscribe.js';
|
|
45
|
+
export { finishCurrentTrace, getCurrentAppName, getCurrentEvent, getCurrentNext, getCurrentPhase, markEventSendAttempt, markEventSendFailure, markEventSendSuccess, recordEventSendResults, withEventContext, withProcessorTrace } from './runtime/hook-event-context.js';
|
|
46
|
+
export { registerAppDir, scheduleCancel, scheduleCancelAll, scheduleCancelByApp, scheduleCron, scheduleInterval, scheduleList, schedulePause, scheduleResume, scheduleTimeout, unregisterAppDir } from './runtime/schedule-store.js';
|
|
47
|
+
export { cbpClient } from './runtime/cbp/connects/client.js';
|
|
48
|
+
import 'flatted';
|
|
49
|
+
import 'fs';
|
|
50
|
+
import 'path';
|
|
51
|
+
import 'yaml';
|
|
52
|
+
import '../common/logger.js';
|
|
53
|
+
import '../common/utils.js';
|
|
54
|
+
import 'net';
|
|
55
|
+
import 'v8';
|
|
56
|
+
import 'os';
|
|
57
|
+
import '../common/cbp/runtime.js';
|
|
58
|
+
import 'ws';
|
|
@@ -14,11 +14,29 @@ import 'v8';
|
|
|
14
14
|
import 'os';
|
|
15
15
|
import { USER_AGENT_HEADER, USER_AGENT_HEADER_VALUE_MAP, DEVICE_ID_HEADER, FULL_RECEIVE_HEADER } from '../../../common/cbp/constants.js';
|
|
16
16
|
import '../../../common/cbp/runtime.js';
|
|
17
|
-
import { normalizeInboundMessage, getNormalizedDeviceId, getNormalizedEventRouteId } from '../../../common/cbp/normalize.js';
|
|
17
|
+
import { normalizeInboundMessage, getNormalizedDeviceId, getNormalizedEventRouteId, isNormalizedActionRequest, toLegacyActionData, isNormalizedApiRequest, toLegacyApiData } from '../../../common/cbp/normalize.js';
|
|
18
18
|
import { platformClient, childrenClient, fullClient, childrenBind, clientBindCount, unbindClient, bindChannelToClient } from '../processor/config.js';
|
|
19
19
|
import { createTestOneController } from './testone.js';
|
|
20
20
|
import { getClientChild } from '../../process/ipc-bridge.js';
|
|
21
21
|
|
|
22
|
+
const stringifyForSocket = (payload) => {
|
|
23
|
+
return flattedJSON.stringify(payload);
|
|
24
|
+
};
|
|
25
|
+
const normalizeTestOneOutboundMessage = (message) => {
|
|
26
|
+
try {
|
|
27
|
+
const inbound = flattedJSON.parse(String(message));
|
|
28
|
+
const normalized = normalizeInboundMessage(inbound);
|
|
29
|
+
if (isNormalizedActionRequest(normalized)) {
|
|
30
|
+
return stringifyForSocket(toLegacyActionData(normalized));
|
|
31
|
+
}
|
|
32
|
+
if (isNormalizedApiRequest(normalized)) {
|
|
33
|
+
return stringifyForSocket(toLegacyApiData(normalized));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
}
|
|
38
|
+
return message.toString();
|
|
39
|
+
};
|
|
22
40
|
const routeNormalizedMessage = (message, input) => {
|
|
23
41
|
const normalized = normalizeInboundMessage(input);
|
|
24
42
|
if (!normalized) {
|
|
@@ -156,7 +174,7 @@ const setChildrenClient = (originId, ws) => {
|
|
|
156
174
|
ws.on('message', (message) => {
|
|
157
175
|
if (global.__sandbox) {
|
|
158
176
|
if (global.testoneClient?.readyState === WebSocket.OPEN) {
|
|
159
|
-
global.testoneClient.send(message.toString());
|
|
177
|
+
global.testoneClient.send(normalizeTestOneOutboundMessage(message.toString()));
|
|
160
178
|
}
|
|
161
179
|
return;
|
|
162
180
|
}
|
|
@@ -193,7 +211,7 @@ const setFullClient = (originId, ws) => {
|
|
|
193
211
|
ws.on('message', (message) => {
|
|
194
212
|
if (global.__sandbox) {
|
|
195
213
|
if (global.testoneClient?.readyState === WebSocket.OPEN) {
|
|
196
|
-
global.testoneClient.send(message.toString());
|
|
214
|
+
global.testoneClient.send(normalizeTestOneOutboundMessage(message.toString()));
|
|
197
215
|
}
|
|
198
216
|
return;
|
|
199
217
|
}
|
|
@@ -10,6 +10,7 @@ import 'net';
|
|
|
10
10
|
import 'v8';
|
|
11
11
|
import 'os';
|
|
12
12
|
import '../../common/cbp/runtime.js';
|
|
13
|
+
import { normalizeInboundMessage, isNormalizedActionRequest, toLegacyActionData, isNormalizedApiRequest, toLegacyApiData } from '../../common/cbp/normalize.js';
|
|
13
14
|
|
|
14
15
|
let platformChild = null;
|
|
15
16
|
let clientChild = null;
|
|
@@ -49,7 +50,15 @@ const forwardFromClient = (data) => {
|
|
|
49
50
|
}
|
|
50
51
|
if (global.__sandbox && global.testoneClient) {
|
|
51
52
|
try {
|
|
52
|
-
const
|
|
53
|
+
const normalized = normalizeInboundMessage(safeData);
|
|
54
|
+
let outbound = safeData;
|
|
55
|
+
if (isNormalizedActionRequest(normalized)) {
|
|
56
|
+
outbound = toLegacyActionData(normalized);
|
|
57
|
+
}
|
|
58
|
+
else if (isNormalizedApiRequest(normalized)) {
|
|
59
|
+
outbound = toLegacyApiData(normalized);
|
|
60
|
+
}
|
|
61
|
+
const messageStr = typeof outbound === 'string' ? outbound : flattedJSON.stringify(outbound);
|
|
53
62
|
if (global.testoneClient.readyState === WebSocket.OPEN) {
|
|
54
63
|
global.testoneClient.send(messageStr);
|
|
55
64
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export * from './common/index.js';
|
|
|
4
4
|
export * from './core/index.js';
|
|
5
5
|
export * from './platform/index.js';
|
|
6
6
|
export * from './application/index.js';
|
|
7
|
+
export { cbpServer } from './core/cbp/index.js';
|
|
8
|
+
export { Result } from './common/variable.js';
|
|
7
9
|
export { start } from './main.js';
|
|
8
10
|
export * from './main.js';
|
|
9
11
|
export * as common from './common/index.js';
|
package/lib/index.js
CHANGED
|
@@ -7,20 +7,24 @@ import * as index$3 from './platform/index.js';
|
|
|
7
7
|
export { index$3 as platform };
|
|
8
8
|
import * as index from './application/index.js';
|
|
9
9
|
export { index as application };
|
|
10
|
+
export { cbpServer } from './core/cbp/server/main.js';
|
|
11
|
+
export { EventMessageText, Fail, FailAuth, FailInternal, FailParams, Ok, Result, ResultCode, Warn, defaultLogin, defaultPlatformCommonPrefix, defaultPlatformPrefix, defaultPort, filePrefixCommon, fileSuffixMiddleware, fileSuffixResponse, processorMaxMapSize, processorRepeatedClearSize, processorRepeatedClearTimeMax, processorRepeatedClearTimeMin, processorRepeatedEventTime, processorRepeatedUserTime } from './common/variable.js';
|
|
10
12
|
export { start } from './core/start.js';
|
|
11
13
|
export { A, Body, Component, DOCTYPE, Div, H1, Head, Html, P, Style, Title, createElement, renderToString } from './common/react.js';
|
|
12
14
|
export { Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Markdown, MarkdownOriginal, Mention, Text, Video } from './application/format/message-format-old.js';
|
|
15
|
+
export { ChildrenApp, Core, Middleware, MiddlewareRouter, MiddlewareTree, ProcessorEventAutoClearMap, ProcessorEventUserAutoClearMap, Response, ResponseMiddleware, ResponseRouter, ResponseTree, State, StateSubscribe, SubscribeList, bumpStoreVersion, clearRuntimeAppKoaRouters, disposeAllRuntimeApps, disposeRuntimeApp, getChildrenApp, getRuntimeApp, getRuntimeAppKoaRouters, getSubscribeList, hasRuntimeAppCapability, listChildrenApps, listRuntimeAppKoaRouters, listRuntimeApps, registerRuntimeApp, setRuntimeAppKoaRouters, toRuntimeAppSnapshot, updateRuntimeAppCapabilities, updateRuntimeAppStatus } from './application/runtime/store.js';
|
|
13
16
|
export { DEVICE_ID_HEADER, FULL_RECEIVE_HEADER, HEARTBEAT_INTERVAL, USER_AGENT_HEADER, USER_AGENT_HEADER_VALUE_MAP, reconnectInterval, timeoutTime } from './common/cbp/constants.js';
|
|
14
|
-
export { EventMessageText, Fail, FailAuth, FailInternal, FailParams, Ok, ResultCode, Warn, defaultLogin, defaultPlatformCommonPrefix, defaultPlatformPrefix, defaultPort, filePrefixCommon, fileSuffixMiddleware, fileSuffixResponse, processorMaxMapSize, processorRepeatedClearSize, processorRepeatedClearTimeMax, processorRepeatedClearTimeMin, processorRepeatedEventTime, processorRepeatedUserTime } from './common/variable.js';
|
|
15
17
|
export { Expose, clearAllExpose, disposeExpose, registerExpose } from './application/expose.js';
|
|
16
18
|
export { Format, FormatButtonGroup, FormatMarkDown, FormatSelect } from './application/format/message-format.js';
|
|
17
19
|
export { FormatEvent, wrapEvent } from './platform/event-format.js';
|
|
18
20
|
export { Logger, logger } from './common/logger.js';
|
|
19
21
|
export { MessageDirect, createDataFormat, format, getMessageIntent, sendToChannel, sendToUser } from './application/format/message-api.js';
|
|
20
22
|
export { OnMiddleware, onMiddleware } from './application/runtime/event-middleware.js';
|
|
23
|
+
export { OnProcessor, onProcessor } from './application/runtime/event-processor.js';
|
|
21
24
|
export { OnResponse, onResponse } from './application/runtime/event-response.js';
|
|
22
25
|
export { Router } from './application/router/dsl.js';
|
|
23
26
|
export { SinglyLinkedList } from './common/SinglyLinkedList.js';
|
|
27
|
+
export { cbpClient } from './application/runtime/cbp/connects/client.js';
|
|
24
28
|
export { cbpPlatform } from './platform/cbp-platform.js';
|
|
25
29
|
export { checkFallbackHint } from './application/router/fallback.js';
|
|
26
30
|
export { clearInterval, clearTimeout, listSchedule, pauseSchedule, resumeSchedule, setCron, setInterval, setTimeout } from './application/schedule.js';
|
|
@@ -37,11 +41,19 @@ export { defineChildren } from './application/define-children.js';
|
|
|
37
41
|
export { defineMiddleware } from './application/define-middleware.js';
|
|
38
42
|
export { definePlatform } from './platform/define-platform.js';
|
|
39
43
|
export { defineResponse } from './application/define-response.js';
|
|
40
|
-
export { defineRouter } from './application/define-router.js';
|
|
44
|
+
export { defineRouter, lazy, runHandler } from './application/define-router.js';
|
|
41
45
|
export { deviceId, generateUniqueId } from './common/cbp/runtime.js';
|
|
46
|
+
export { expendCycle } from './application/runtime/event-processor-cycle.js';
|
|
47
|
+
export { expendEvent } from './application/runtime/event-processor-event.js';
|
|
48
|
+
export { expendMiddleware } from './application/runtime/event-processor-middleware.js';
|
|
49
|
+
export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './application/runtime/event-processor-subscribe.js';
|
|
50
|
+
export { finishCurrentTrace, getCurrentAppName, getCurrentEvent, getCurrentNext, getCurrentPhase, markEventSendAttempt, markEventSendFailure, markEventSendSuccess, recordEventSendResults, withEventContext, withProcessorTrace } from './application/runtime/hook-event-context.js';
|
|
42
51
|
export { getConfig, getConfigValue, onWatchConfigValue } from './common/config.js';
|
|
52
|
+
export { loadChildren, loadChildrenFile } from './application/runtime/load-modules/loadChild.js';
|
|
53
|
+
export { loadModels, run } from './application/runtime/load-modules/load.js';
|
|
43
54
|
export { normalizeRoutePath, parseMessageText } from './application/router/parser.js';
|
|
44
55
|
export { onGroup } from './application/runtime/event-group.js';
|
|
56
|
+
export { registerAppDir, scheduleCancel, scheduleCancelAll, scheduleCancelByApp, scheduleCron, scheduleInterval, scheduleList, schedulePause, scheduleResume, scheduleTimeout, unregisterAppDir } from './application/runtime/schedule-store.js';
|
|
45
57
|
export { useAnnounce } from './application/hooks/announce.js';
|
|
46
58
|
export { useChannel } from './application/hooks/channel.js';
|
|
47
59
|
export { useClient } from './application/hooks/client.js';
|
|
@@ -60,4 +72,4 @@ export { useRequest } from './application/hooks/request.js';
|
|
|
60
72
|
export { useRole } from './application/hooks/role.js';
|
|
61
73
|
export { useRoute } from './application/hooks/route.js';
|
|
62
74
|
export { useUser } from './application/hooks/user.js';
|
|
63
|
-
export { validateRouteArgs } from './application/router/validator.js';
|
|
75
|
+
export { validateRouteArgs, validateRouteArgsForCommand } from './application/router/validator.js';
|