alemonjs 2.1.83 → 2.1.85
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/{app → application}/define-children.js +2 -1
- package/lib/{app → application/format}/message-api.d.ts +2 -2
- package/lib/{app → application/format}/message-api.js +12 -4
- package/lib/{app → application/format}/message-format-old.d.ts +1 -1
- package/lib/{app → application/format}/message-format.d.ts +1 -2
- package/lib/{app → application/format}/message-format.js +0 -2
- package/lib/{app/hook-use → application/hooks}/announce.js +4 -3
- package/lib/{app/hook-use → application/hooks}/channel.js +4 -3
- package/lib/{app/hook-use → application/hooks}/client.d.ts +1 -1
- package/lib/{app/hook-use → application/hooks}/client.js +4 -11
- package/lib/{app/hook-use → application/hooks}/common.d.ts +7 -7
- package/lib/{app/hook-use → application/hooks}/common.js +9 -8
- package/lib/{app/hook-use → application/hooks}/event.js +1 -1
- package/lib/{app/hook-use → application/hooks}/guild.js +4 -3
- package/lib/{app/hook-use → application/hooks}/history.js +4 -3
- package/lib/{app/hook-use → application/hooks}/me.js +12 -7
- package/lib/{app/hook-use → application/hooks}/media.d.ts +3 -3
- package/lib/{app/hook-use → application/hooks}/media.js +4 -3
- package/lib/{app/hook-use → application/hooks}/member.js +4 -3
- package/lib/{app/hook-use → application/hooks}/mention.js +4 -3
- package/lib/{app/hook-use → application/hooks}/message.js +6 -5
- package/lib/{app/hook-use → application/hooks}/permission.js +4 -3
- package/lib/{app/hook-use → application/hooks}/reaction.js +4 -3
- package/lib/{app/hook-use → application/hooks}/request.js +12 -7
- package/lib/{app/hook-use → application/hooks}/role.js +4 -3
- package/lib/{app/hook-use → application/hooks}/subscribe.js +4 -4
- package/lib/{app/hook-use → application/hooks}/user.js +12 -7
- package/lib/application/index.d.ts +29 -0
- package/lib/application/index.js +58 -0
- package/lib/{app → application}/router/dsl.d.ts +1 -1
- package/lib/{app → application}/router/dsl.js +14 -10
- package/lib/{cbp → application/runtime/cbp}/connects/client.d.ts +1 -1
- package/lib/{cbp → application/runtime/cbp}/connects/client.js +43 -50
- package/lib/application/runtime/cbp/index.d.ts +3 -0
- package/lib/application/runtime/cbp/index.js +3 -0
- package/lib/application/runtime/cbp/processor/actions.d.ts +3 -0
- package/lib/application/runtime/cbp/processor/actions.js +58 -0
- package/lib/application/runtime/cbp/processor/api.d.ts +3 -0
- package/lib/application/runtime/cbp/processor/api.js +58 -0
- package/lib/application/runtime/cbp/processor/request-registry.d.ts +8 -0
- package/lib/application/runtime/cbp/processor/request-registry.js +6 -0
- package/lib/application/runtime/client-runtime.d.ts +1 -0
- package/lib/application/runtime/client-runtime.js +95 -0
- package/lib/{app → application/runtime}/event-error.d.ts +1 -1
- package/lib/{app → application/runtime}/event-error.js +1 -1
- package/lib/{app → application/runtime}/event-group.d.ts +1 -1
- package/lib/{app → application/runtime}/event-middleware.d.ts +1 -1
- package/lib/{app → application/runtime}/event-middleware.js +1 -1
- package/lib/{app → application/runtime}/event-processor-callHandler.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-callHandler.js +8 -1
- package/lib/{app → application/runtime}/event-processor-cycle.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-cycleFiles.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-cycleFiles.js +2 -2
- package/lib/{app → application/runtime}/event-processor-cycleRoute.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-cycleRoute.js +9 -2
- package/lib/{app → application/runtime}/event-processor-event.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-middleware.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-subscribe.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-subscribe.js +9 -2
- package/lib/{app → application/runtime}/event-processor.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor.js +4 -3
- package/lib/{app → application/runtime}/event-response.d.ts +1 -1
- package/lib/{app → application/runtime}/event-utils.d.ts +1 -1
- package/lib/{app → application/runtime}/event-utils.js +2 -2
- package/lib/{app → application/runtime}/hook-event-context.d.ts +2 -2
- package/lib/{app → application/runtime}/hook-event-context.js +2 -2
- package/lib/application/runtime/http/index.d.ts +4 -0
- package/lib/application/runtime/http/index.js +4 -0
- package/lib/application/runtime/http/routers/hello.html.d.ts +4 -0
- package/lib/application/runtime/http/routers/hello.html.js +363 -0
- package/lib/{server → application/runtime/http}/routers/router.js +265 -179
- package/lib/{server → application/runtime/http}/routers/utils.d.ts +1 -1
- package/lib/{server → application/runtime/http}/routers/utils.js +22 -8
- package/lib/{server/main.js → application/runtime/http-server.js} +2 -6
- package/lib/{app → application/runtime}/lifecycle-callbacks.d.ts +1 -1
- package/lib/{app → application/runtime}/lifecycle-callbacks.js +2 -7
- package/lib/{app/load_modules → application/runtime/load-modules}/load.js +2 -2
- package/lib/{app/load_modules → application/runtime/load-modules}/loadChild.js +14 -5
- package/lib/{app → application/runtime}/schedule-store.d.ts +1 -1
- package/lib/{app → application/runtime}/schedule-store.js +1 -1
- package/lib/{app → application/runtime}/store.d.ts +14 -19
- package/lib/{app → application/runtime}/store.js +8 -103
- package/lib/application/schedule.d.ts +17 -0
- package/lib/{app/api → application}/schedule.js +1 -1
- package/lib/client.d.ts +1 -1
- package/lib/client.js +1 -117
- package/lib/common/cbp/constants.d.ts +11 -0
- package/lib/common/cbp/constants.js +13 -0
- package/lib/{cbp/connects/connect.js → common/cbp/heartbeat.js} +3 -6
- package/lib/common/cbp/normalize.d.ts +16 -0
- package/lib/common/cbp/normalize.js +324 -0
- package/lib/common/cbp/runtime.d.ts +2 -0
- package/lib/common/cbp/runtime.js +10 -0
- package/lib/common/cbp/typings.d.ts +159 -0
- package/lib/{cbp/connects/base.js → common/cbp/ws-connector.js} +7 -9
- package/lib/{core → common}/config.d.ts +2 -2
- package/lib/{core → common}/config.js +5 -4
- package/lib/common/identity.d.ts +11 -0
- package/lib/common/identity.js +34 -0
- package/lib/common/index.d.ts +15 -0
- package/lib/common/index.js +14 -0
- package/lib/common/logger.d.ts +6 -0
- package/lib/common/logger.js +99 -0
- package/lib/{core → common}/react.js +22 -3
- package/lib/common/result.d.ts +7 -0
- package/lib/common/result.js +19 -0
- package/lib/{core → common}/utils.d.ts +3 -18
- package/lib/{core → common}/utils.js +6 -49
- package/lib/{core → common}/variable.js +1 -1
- package/lib/core/cbp/index.d.ts +1 -0
- package/lib/core/cbp/index.js +1 -0
- package/lib/core/cbp/processor/config.d.ts +8 -0
- package/lib/core/cbp/processor/config.js +29 -0
- package/lib/{cbp → core/cbp}/routers/hello.html.js +1 -1
- package/lib/{cbp → core/cbp}/server/main.js +57 -35
- package/lib/{cbp → core/cbp}/server/testone.d.ts +1 -1
- package/lib/{cbp → core/cbp}/server/testone.js +8 -2
- package/lib/core/index.d.ts +1 -3
- package/lib/core/index.js +1 -3
- package/lib/core/process/index.d.ts +3 -0
- package/lib/{process → core/process}/index.js +0 -1
- package/lib/{process → core/process}/ipc-bridge.js +16 -2
- package/lib/{process → core/process}/module.js +13 -4
- package/lib/{process → core/process}/platform.js +12 -3
- package/lib/core/start.d.ts +2 -0
- package/lib/core/start.js +76 -0
- package/lib/global.d.ts +4 -3
- package/lib/index.d.ts +10 -2
- package/lib/index.js +74 -54
- package/lib/main.d.ts +1 -2
- package/lib/main.js +1 -76
- package/lib/{cbp/connects/platform.d.ts → platform/cbp-platform.d.ts} +2 -2
- package/lib/{cbp/connects/platform.js → platform/cbp-platform.js} +52 -75
- package/lib/{app → platform}/define-platform.js +2 -0
- package/lib/platform/event-value.d.ts +7 -0
- package/lib/platform/event-value.js +5 -0
- package/lib/platform/index.d.ts +5 -0
- package/lib/platform/index.js +5 -0
- package/lib/types/actions.d.ts +20 -1
- package/lib/types/apis.d.ts +2 -1
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/cycle/index.d.ts +1 -1
- package/lib/types/event/index.d.ts +1 -1
- package/lib/types/subscribe/index.d.ts +1 -1
- package/package.json +22 -1
- package/lib/app/api/schedule.d.ts +0 -17
- package/lib/app/index.d.ts +0 -25
- package/lib/app/index.js +0 -47
- package/lib/cbp/index.d.ts +0 -3
- package/lib/cbp/index.js +0 -3
- package/lib/cbp/processor/actions.d.ts +0 -3
- package/lib/cbp/processor/actions.js +0 -48
- package/lib/cbp/processor/api.d.ts +0 -3
- package/lib/cbp/processor/api.js +0 -48
- package/lib/cbp/processor/config.d.ts +0 -29
- package/lib/cbp/processor/config.js +0 -52
- package/lib/cbp/typings.d.ts +0 -20
- package/lib/process/index.d.ts +0 -4
- package/lib/server/routers/hello.html.d.ts +0 -2
- package/lib/server/routers/hello.html.js +0 -31
- /package/lib/{app → application}/define-children.d.ts +0 -0
- /package/lib/{app → application}/define-middleware.d.ts +0 -0
- /package/lib/{app → application}/define-middleware.js +0 -0
- /package/lib/{app → application}/define-response.d.ts +0 -0
- /package/lib/{app → application}/define-response.js +0 -0
- /package/lib/{app → application}/define-router.d.ts +0 -0
- /package/lib/{app → application}/define-router.js +0 -0
- /package/lib/{app → application}/expose.d.ts +0 -0
- /package/lib/{app → application}/expose.js +0 -0
- /package/lib/{app → application/format}/message-format-old.js +0 -0
- /package/lib/{app/hook-use → application/hooks}/announce.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/channel.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/event.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/guild.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/history.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/index.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/index.js +0 -0
- /package/lib/{app/hook-use → application/hooks}/me.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/member.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/mention.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/message.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/permission.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/reaction.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/request.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/role.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/route.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/route.js +0 -0
- /package/lib/{app/hook-use → application/hooks}/subscribe.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/user.d.ts +0 -0
- /package/lib/{app → application}/router/fallback.d.ts +0 -0
- /package/lib/{app → application}/router/fallback.js +0 -0
- /package/lib/{app → application}/router/main.d.ts +0 -0
- /package/lib/{app → application}/router/main.js +0 -0
- /package/lib/{app → application}/router/parser.d.ts +0 -0
- /package/lib/{app → application}/router/parser.js +0 -0
- /package/lib/{app → application}/router/types.d.ts +0 -0
- /package/lib/{app → application}/router/types.js +0 -0
- /package/lib/{app → application}/router/validator.d.ts +0 -0
- /package/lib/{app → application}/router/validator.js +0 -0
- /package/lib/{cbp → application/runtime/cbp}/processor/transport.d.ts +0 -0
- /package/lib/{cbp → application/runtime/cbp}/processor/transport.js +0 -0
- /package/lib/{app → application/runtime}/event-group.js +0 -0
- /package/lib/{app → application/runtime}/event-processor-cycle.js +0 -0
- /package/lib/{app → application/runtime}/event-processor-event.js +0 -0
- /package/lib/{app → application/runtime}/event-processor-middleware.js +0 -0
- /package/lib/{app → application/runtime}/event-response.js +0 -0
- /package/lib/{server → application/runtime/http}/routers/middleware.d.ts +0 -0
- /package/lib/{server → application/runtime/http}/routers/middleware.js +0 -0
- /package/lib/{cbp → application/runtime/http}/routers/router.d.ts +0 -0
- /package/lib/{server/main.d.ts → application/runtime/http-server.d.ts} +0 -0
- /package/lib/{app/load_modules → application/runtime/load-modules}/index.d.ts +0 -0
- /package/lib/{app/load_modules → application/runtime/load-modules}/index.js +0 -0
- /package/lib/{app/load_modules → application/runtime/load-modules}/load.d.ts +0 -0
- /package/lib/{app/load_modules → application/runtime/load-modules}/loadChild.d.ts +0 -0
- /package/lib/{app/config.d.ts → application/runtime/subscribe-status.d.ts} +0 -0
- /package/lib/{app/config.js → application/runtime/subscribe-status.js} +0 -0
- /package/lib/{app → common}/SinglyLinkedList.d.ts +0 -0
- /package/lib/{app → common}/SinglyLinkedList.js +0 -0
- /package/lib/{cbp/connects/connect.d.ts → common/cbp/heartbeat.d.ts} +0 -0
- /package/lib/{cbp → common/cbp}/typings.js +0 -0
- /package/lib/{cbp/connects/base.d.ts → common/cbp/ws-connector.d.ts} +0 -0
- /package/lib/{process → common}/direct-channel.d.ts +0 -0
- /package/lib/{process → common}/direct-channel.js +0 -0
- /package/lib/{core → common}/react.d.ts +0 -0
- /package/lib/{core → common}/variable.d.ts +0 -0
- /package/lib/{cbp → core/cbp}/routers/hello.html.d.ts +0 -0
- /package/lib/{server → core/cbp}/routers/router.d.ts +0 -0
- /package/lib/{cbp → core/cbp}/routers/router.js +0 -0
- /package/lib/{cbp → core/cbp}/server/main.d.ts +0 -0
- /package/lib/{process → core/process}/ipc-bridge.d.ts +0 -0
- /package/lib/{process → core/process}/module.d.ts +0 -0
- /package/lib/{process → core/process}/platform.d.ts +0 -0
- /package/lib/{app → platform}/define-platform.d.ts +0 -0
- /package/lib/{app → platform}/event-format.d.ts +0 -0
- /package/lib/{app → platform}/event-format.js +0 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
const now = () => Date.now();
|
|
2
|
+
const asRecord = (value) => {
|
|
3
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
4
|
+
};
|
|
5
|
+
const asResults = (value) => {
|
|
6
|
+
return Array.isArray(value) ? value : [];
|
|
7
|
+
};
|
|
8
|
+
const inferEventRouteId = (event) => {
|
|
9
|
+
const channelId = event.ChannelId;
|
|
10
|
+
const guildId = event.GuildId;
|
|
11
|
+
const deviceId = event.DeviceId;
|
|
12
|
+
if (typeof channelId === 'string' && channelId) {
|
|
13
|
+
return channelId;
|
|
14
|
+
}
|
|
15
|
+
if (typeof guildId === 'string' && guildId) {
|
|
16
|
+
return guildId;
|
|
17
|
+
}
|
|
18
|
+
if (typeof deviceId === 'string' && deviceId) {
|
|
19
|
+
return deviceId;
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
23
|
+
const createRequestEnvelope = (type, id, deviceId, payload) => {
|
|
24
|
+
return {
|
|
25
|
+
protocol: 'cbp',
|
|
26
|
+
version: 1,
|
|
27
|
+
type,
|
|
28
|
+
id,
|
|
29
|
+
timestamp: now(),
|
|
30
|
+
source: {
|
|
31
|
+
role: 'app-client',
|
|
32
|
+
deviceId
|
|
33
|
+
},
|
|
34
|
+
payload
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const createResponseEnvelope = (type, replyTo, deviceId, payload, error) => {
|
|
38
|
+
return {
|
|
39
|
+
protocol: 'cbp',
|
|
40
|
+
version: 1,
|
|
41
|
+
type,
|
|
42
|
+
id: `${replyTo}:res`,
|
|
43
|
+
replyTo,
|
|
44
|
+
timestamp: now(),
|
|
45
|
+
source: {
|
|
46
|
+
role: 'platform',
|
|
47
|
+
deviceId
|
|
48
|
+
},
|
|
49
|
+
target: {
|
|
50
|
+
role: 'app-client',
|
|
51
|
+
deviceId
|
|
52
|
+
},
|
|
53
|
+
payload: {
|
|
54
|
+
results: payload
|
|
55
|
+
},
|
|
56
|
+
error
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const normalizeEnvelopeMessage = (input) => {
|
|
60
|
+
const payload = input.payload;
|
|
61
|
+
const meta = asRecord(input.meta);
|
|
62
|
+
const deviceId = input.source?.deviceId ?? input.target?.deviceId;
|
|
63
|
+
const sourceRole = input.source?.role;
|
|
64
|
+
const targetRole = input.target?.role;
|
|
65
|
+
switch (input.type) {
|
|
66
|
+
case 'event': {
|
|
67
|
+
const eventPayload = asRecord(payload);
|
|
68
|
+
const event = asRecord(eventPayload.event);
|
|
69
|
+
return {
|
|
70
|
+
kind: 'event',
|
|
71
|
+
id: input.id,
|
|
72
|
+
timestamp: input.timestamp,
|
|
73
|
+
deviceId,
|
|
74
|
+
sourceRole,
|
|
75
|
+
targetRole,
|
|
76
|
+
eventName: String(eventPayload.name ?? ''),
|
|
77
|
+
event,
|
|
78
|
+
raw: eventPayload.raw,
|
|
79
|
+
meta
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
case 'action.req': {
|
|
83
|
+
const actionPayload = asRecord(payload);
|
|
84
|
+
return {
|
|
85
|
+
kind: 'action.req',
|
|
86
|
+
id: input.id,
|
|
87
|
+
timestamp: input.timestamp,
|
|
88
|
+
deviceId,
|
|
89
|
+
sourceRole,
|
|
90
|
+
targetRole,
|
|
91
|
+
action: String(actionPayload.action ?? ''),
|
|
92
|
+
input: asRecord(actionPayload.input),
|
|
93
|
+
meta
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
case 'action.res':
|
|
97
|
+
return {
|
|
98
|
+
kind: 'action.res',
|
|
99
|
+
id: input.id,
|
|
100
|
+
replyTo: String(input.replyTo ?? ''),
|
|
101
|
+
timestamp: input.timestamp,
|
|
102
|
+
deviceId,
|
|
103
|
+
sourceRole,
|
|
104
|
+
targetRole,
|
|
105
|
+
results: asResults(asRecord(payload).results),
|
|
106
|
+
error: input.error,
|
|
107
|
+
meta
|
|
108
|
+
};
|
|
109
|
+
case 'api.req': {
|
|
110
|
+
const apiPayload = asRecord(payload);
|
|
111
|
+
return {
|
|
112
|
+
kind: 'api.req',
|
|
113
|
+
id: input.id,
|
|
114
|
+
timestamp: input.timestamp,
|
|
115
|
+
deviceId,
|
|
116
|
+
sourceRole,
|
|
117
|
+
targetRole,
|
|
118
|
+
api: String(apiPayload.api ?? ''),
|
|
119
|
+
input: asRecord(apiPayload.input),
|
|
120
|
+
meta
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
case 'api.res':
|
|
124
|
+
return {
|
|
125
|
+
kind: 'api.res',
|
|
126
|
+
id: input.id,
|
|
127
|
+
replyTo: String(input.replyTo ?? ''),
|
|
128
|
+
timestamp: input.timestamp,
|
|
129
|
+
deviceId,
|
|
130
|
+
sourceRole,
|
|
131
|
+
targetRole,
|
|
132
|
+
results: asResults(asRecord(payload).results),
|
|
133
|
+
error: input.error,
|
|
134
|
+
meta
|
|
135
|
+
};
|
|
136
|
+
case 'control': {
|
|
137
|
+
const controlPayload = asRecord(payload);
|
|
138
|
+
return {
|
|
139
|
+
kind: 'control',
|
|
140
|
+
id: input.id,
|
|
141
|
+
timestamp: input.timestamp,
|
|
142
|
+
deviceId,
|
|
143
|
+
sourceRole,
|
|
144
|
+
targetRole,
|
|
145
|
+
op: String(controlPayload.op ?? 'error'),
|
|
146
|
+
payload: controlPayload,
|
|
147
|
+
error: input.error,
|
|
148
|
+
meta
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
default:
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const normalizeLegacyMessage = (input) => {
|
|
156
|
+
if (input?.apiId) {
|
|
157
|
+
if (Array.isArray(input.payload)) {
|
|
158
|
+
return {
|
|
159
|
+
kind: 'api.res',
|
|
160
|
+
id: String(input.apiId),
|
|
161
|
+
replyTo: String(input.apiId),
|
|
162
|
+
timestamp: now(),
|
|
163
|
+
deviceId: typeof input.DeviceId === 'string' ? input.DeviceId : undefined,
|
|
164
|
+
results: input.payload,
|
|
165
|
+
meta: {}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
kind: 'api.req',
|
|
170
|
+
id: String(input.apiId),
|
|
171
|
+
timestamp: now(),
|
|
172
|
+
deviceId: typeof input.DeviceId === 'string' ? input.DeviceId : undefined,
|
|
173
|
+
api: typeof input.action === 'string' ? input.action : '',
|
|
174
|
+
input: asRecord(input.payload),
|
|
175
|
+
meta: {}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (input?.actionId) {
|
|
179
|
+
if (Array.isArray(input.payload)) {
|
|
180
|
+
return {
|
|
181
|
+
kind: 'action.res',
|
|
182
|
+
id: String(input.actionId),
|
|
183
|
+
replyTo: String(input.actionId),
|
|
184
|
+
timestamp: now(),
|
|
185
|
+
deviceId: typeof input.DeviceId === 'string' ? input.DeviceId : undefined,
|
|
186
|
+
results: input.payload,
|
|
187
|
+
meta: {}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
kind: 'action.req',
|
|
192
|
+
id: String(input.actionId),
|
|
193
|
+
timestamp: now(),
|
|
194
|
+
deviceId: typeof input.DeviceId === 'string' ? input.DeviceId : undefined,
|
|
195
|
+
action: typeof input.action === 'string' ? input.action : '',
|
|
196
|
+
input: asRecord(input.payload),
|
|
197
|
+
meta: {}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
if (input?.activeId && input?.active === 'sync') {
|
|
201
|
+
const payload = asRecord(input.payload);
|
|
202
|
+
return {
|
|
203
|
+
kind: 'control',
|
|
204
|
+
id: String(input.activeId),
|
|
205
|
+
timestamp: now(),
|
|
206
|
+
deviceId: typeof input.DeviceId === 'string' ? input.DeviceId : undefined,
|
|
207
|
+
op: 'sync',
|
|
208
|
+
payload,
|
|
209
|
+
meta: {}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (input?.name) {
|
|
213
|
+
const event = input;
|
|
214
|
+
return {
|
|
215
|
+
kind: 'event',
|
|
216
|
+
id: typeof input.MessageId === 'string' ? input.MessageId : typeof input.DeviceId === 'string' ? input.DeviceId : `${input.name}:${now()}`,
|
|
217
|
+
timestamp: typeof input.CreateAt === 'number' ? input.CreateAt : now(),
|
|
218
|
+
deviceId: typeof input.DeviceId === 'string' ? input.DeviceId : undefined,
|
|
219
|
+
eventName: input.name,
|
|
220
|
+
event,
|
|
221
|
+
raw: input.value,
|
|
222
|
+
meta: {}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
return null;
|
|
226
|
+
};
|
|
227
|
+
const isCBPEnvelope = (input) => {
|
|
228
|
+
if (!input || typeof input !== 'object') {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
const value = input;
|
|
232
|
+
return value.protocol === 'cbp' && value.version === 1 && typeof value.type === 'string' && typeof value.id === 'string';
|
|
233
|
+
};
|
|
234
|
+
const normalizeInboundMessage = (input) => {
|
|
235
|
+
if (!input || typeof input !== 'object') {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
if (isCBPEnvelope(input)) {
|
|
239
|
+
return normalizeEnvelopeMessage(input);
|
|
240
|
+
}
|
|
241
|
+
return normalizeLegacyMessage(input);
|
|
242
|
+
};
|
|
243
|
+
const toLegacyActionData = (message) => {
|
|
244
|
+
return {
|
|
245
|
+
action: message.action,
|
|
246
|
+
payload: message.input,
|
|
247
|
+
actionId: message.id,
|
|
248
|
+
DeviceId: message.deviceId
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
const toLegacyApiData = (message) => {
|
|
252
|
+
const input = message.input;
|
|
253
|
+
const key = typeof input.key === 'string' ? input.key : '';
|
|
254
|
+
const params = Array.isArray(input.params) ? input.params : [];
|
|
255
|
+
return {
|
|
256
|
+
action: message.api,
|
|
257
|
+
payload: {
|
|
258
|
+
event: input.event,
|
|
259
|
+
key,
|
|
260
|
+
params
|
|
261
|
+
},
|
|
262
|
+
apiId: message.id,
|
|
263
|
+
DeviceId: message.deviceId
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
const isNormalizedActionRequest = (message) => {
|
|
267
|
+
return message?.kind === 'action.req';
|
|
268
|
+
};
|
|
269
|
+
const isNormalizedApiRequest = (message) => {
|
|
270
|
+
return message?.kind === 'api.req';
|
|
271
|
+
};
|
|
272
|
+
const getNormalizedDeviceId = (message) => {
|
|
273
|
+
return message.deviceId;
|
|
274
|
+
};
|
|
275
|
+
const getNormalizedEventRouteId = (message) => {
|
|
276
|
+
if (message.kind !== 'event') {
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
return inferEventRouteId(message.event);
|
|
280
|
+
};
|
|
281
|
+
const createActionRequestEnvelope = (data) => {
|
|
282
|
+
return createRequestEnvelope('action.req', String(data.actionId ?? ''), data.DeviceId, {
|
|
283
|
+
action: data.action,
|
|
284
|
+
input: asRecord(data.payload)
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
const createApiRequestEnvelope = (data) => {
|
|
288
|
+
return createRequestEnvelope('api.req', String(data.apiId ?? ''), data.DeviceId, {
|
|
289
|
+
api: data.action,
|
|
290
|
+
input: asRecord(data.payload)
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
const createActionResponseEnvelope = (data, payload, error) => {
|
|
294
|
+
return createResponseEnvelope('action.res', String(data.actionId ?? ''), data.DeviceId, payload, error);
|
|
295
|
+
};
|
|
296
|
+
const createApiResponseEnvelope = (data, payload, error) => {
|
|
297
|
+
return createResponseEnvelope('api.res', String(data.apiId ?? ''), data.DeviceId, payload, error);
|
|
298
|
+
};
|
|
299
|
+
const createEventEnvelope = (data) => {
|
|
300
|
+
const deviceId = typeof data.DeviceId === 'string' ? data.DeviceId : undefined;
|
|
301
|
+
const eventName = typeof data.name === 'string' ? data.name : '';
|
|
302
|
+
const event = { ...data };
|
|
303
|
+
return {
|
|
304
|
+
protocol: 'cbp',
|
|
305
|
+
version: 1,
|
|
306
|
+
type: 'event',
|
|
307
|
+
id: typeof data.MessageId === 'string' ? data.MessageId : typeof deviceId === 'string' ? `${deviceId}:${now()}` : `${eventName}:${now()}`,
|
|
308
|
+
timestamp: typeof data.CreateAt === 'number' ? data.CreateAt : now(),
|
|
309
|
+
source: {
|
|
310
|
+
role: 'platform',
|
|
311
|
+
deviceId
|
|
312
|
+
},
|
|
313
|
+
payload: {
|
|
314
|
+
name: eventName,
|
|
315
|
+
event,
|
|
316
|
+
raw: data.value
|
|
317
|
+
},
|
|
318
|
+
meta: {
|
|
319
|
+
routeId: inferEventRouteId(event)
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export { createActionRequestEnvelope, createActionResponseEnvelope, createApiRequestEnvelope, createApiResponseEnvelope, createEventEnvelope, getNormalizedDeviceId, getNormalizedEventRouteId, isCBPEnvelope, isNormalizedActionRequest, isNormalizedApiRequest, normalizeInboundMessage, toLegacyActionData, toLegacyApiData };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
const deviceId = randomUUID();
|
|
4
|
+
let idCounter = 0;
|
|
5
|
+
const idPrefix = process.pid.toString(36) + Date.now().toString(36);
|
|
6
|
+
const generateUniqueId = () => {
|
|
7
|
+
return idPrefix + (++idCounter).toString(36);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { deviceId, generateUniqueId };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { EventKeys, Apis, Actions } from '../../types/index.js';
|
|
2
|
+
import type { Result } from '../index.js';
|
|
3
|
+
export type ParsedMessage = {
|
|
4
|
+
apiId?: string;
|
|
5
|
+
actionId?: string;
|
|
6
|
+
testID?: string;
|
|
7
|
+
ChannelId?: string;
|
|
8
|
+
GuildId?: string;
|
|
9
|
+
name?: EventKeys;
|
|
10
|
+
DeviceId?: string;
|
|
11
|
+
activeId?: string;
|
|
12
|
+
payload?: any;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
export type CBPProtocolRole = 'platform' | 'app-client' | 'server';
|
|
16
|
+
export type CBPMessageType = 'event' | 'action.req' | 'action.res' | 'api.req' | 'api.res' | 'control';
|
|
17
|
+
export type CBPEndpoint = {
|
|
18
|
+
role: CBPProtocolRole;
|
|
19
|
+
deviceId?: string;
|
|
20
|
+
appName?: string;
|
|
21
|
+
platform?: string;
|
|
22
|
+
};
|
|
23
|
+
export type CBPError = {
|
|
24
|
+
code: string;
|
|
25
|
+
message: string;
|
|
26
|
+
retryable?: boolean;
|
|
27
|
+
details?: unknown;
|
|
28
|
+
};
|
|
29
|
+
export type CBPResult = {
|
|
30
|
+
code: number;
|
|
31
|
+
message: string;
|
|
32
|
+
data?: unknown;
|
|
33
|
+
};
|
|
34
|
+
export type CBPCapability = 'event' | 'action' | 'api' | 'full-receive';
|
|
35
|
+
export type CBPControlPayload = {
|
|
36
|
+
op: 'hello';
|
|
37
|
+
capabilities?: CBPCapability[];
|
|
38
|
+
} | {
|
|
39
|
+
op: 'heartbeat';
|
|
40
|
+
} | {
|
|
41
|
+
op: 'goodbye';
|
|
42
|
+
reason?: string;
|
|
43
|
+
} | {
|
|
44
|
+
op: 'error';
|
|
45
|
+
code: string;
|
|
46
|
+
message: string;
|
|
47
|
+
} | {
|
|
48
|
+
op: 'sync';
|
|
49
|
+
env?: Record<string, string>;
|
|
50
|
+
};
|
|
51
|
+
export type CBPEventPayload = {
|
|
52
|
+
name: EventKeys | string;
|
|
53
|
+
event: Record<string, unknown>;
|
|
54
|
+
raw?: unknown;
|
|
55
|
+
};
|
|
56
|
+
export type CBPActionRequestPayload = {
|
|
57
|
+
action: string;
|
|
58
|
+
input: Record<string, unknown>;
|
|
59
|
+
};
|
|
60
|
+
export type CBPActionResponsePayload = {
|
|
61
|
+
results: CBPResult[] | Result[];
|
|
62
|
+
};
|
|
63
|
+
export type CBPApiRequestPayload = {
|
|
64
|
+
api: string;
|
|
65
|
+
input: Record<string, unknown>;
|
|
66
|
+
};
|
|
67
|
+
export type CBPApiResponsePayload = {
|
|
68
|
+
results: CBPResult[] | Result[];
|
|
69
|
+
};
|
|
70
|
+
export type CBPEnvelope = {
|
|
71
|
+
protocol: 'cbp';
|
|
72
|
+
version: 1;
|
|
73
|
+
type: CBPMessageType;
|
|
74
|
+
id: string;
|
|
75
|
+
replyTo?: string;
|
|
76
|
+
timestamp: number;
|
|
77
|
+
source: CBPEndpoint;
|
|
78
|
+
target?: CBPEndpoint;
|
|
79
|
+
payload?: CBPEventPayload | CBPActionRequestPayload | CBPActionResponsePayload | CBPApiRequestPayload | CBPApiResponsePayload | CBPControlPayload | unknown;
|
|
80
|
+
error?: CBPError;
|
|
81
|
+
meta?: Record<string, unknown>;
|
|
82
|
+
};
|
|
83
|
+
export type NormalizedEventMessage = {
|
|
84
|
+
kind: 'event';
|
|
85
|
+
id: string;
|
|
86
|
+
timestamp: number;
|
|
87
|
+
deviceId?: string;
|
|
88
|
+
sourceRole?: CBPProtocolRole;
|
|
89
|
+
targetRole?: CBPProtocolRole;
|
|
90
|
+
eventName: EventKeys | string;
|
|
91
|
+
event: Record<string, unknown>;
|
|
92
|
+
raw?: unknown;
|
|
93
|
+
meta?: Record<string, unknown>;
|
|
94
|
+
};
|
|
95
|
+
export type NormalizedActionRequestMessage = {
|
|
96
|
+
kind: 'action.req';
|
|
97
|
+
id: string;
|
|
98
|
+
timestamp: number;
|
|
99
|
+
deviceId?: string;
|
|
100
|
+
sourceRole?: CBPProtocolRole;
|
|
101
|
+
targetRole?: CBPProtocolRole;
|
|
102
|
+
action: string;
|
|
103
|
+
input: Record<string, unknown>;
|
|
104
|
+
meta?: Record<string, unknown>;
|
|
105
|
+
};
|
|
106
|
+
export type NormalizedActionResponseMessage = {
|
|
107
|
+
kind: 'action.res';
|
|
108
|
+
id: string;
|
|
109
|
+
replyTo: string;
|
|
110
|
+
timestamp: number;
|
|
111
|
+
deviceId?: string;
|
|
112
|
+
sourceRole?: CBPProtocolRole;
|
|
113
|
+
targetRole?: CBPProtocolRole;
|
|
114
|
+
results: Result[];
|
|
115
|
+
error?: CBPError;
|
|
116
|
+
meta?: Record<string, unknown>;
|
|
117
|
+
};
|
|
118
|
+
export type NormalizedApiRequestMessage = {
|
|
119
|
+
kind: 'api.req';
|
|
120
|
+
id: string;
|
|
121
|
+
timestamp: number;
|
|
122
|
+
deviceId?: string;
|
|
123
|
+
sourceRole?: CBPProtocolRole;
|
|
124
|
+
targetRole?: CBPProtocolRole;
|
|
125
|
+
api: string;
|
|
126
|
+
input: Record<string, unknown>;
|
|
127
|
+
meta?: Record<string, unknown>;
|
|
128
|
+
};
|
|
129
|
+
export type NormalizedApiResponseMessage = {
|
|
130
|
+
kind: 'api.res';
|
|
131
|
+
id: string;
|
|
132
|
+
replyTo: string;
|
|
133
|
+
timestamp: number;
|
|
134
|
+
deviceId?: string;
|
|
135
|
+
sourceRole?: CBPProtocolRole;
|
|
136
|
+
targetRole?: CBPProtocolRole;
|
|
137
|
+
results: Result[];
|
|
138
|
+
error?: CBPError;
|
|
139
|
+
meta?: Record<string, unknown>;
|
|
140
|
+
};
|
|
141
|
+
export type NormalizedControlMessage = {
|
|
142
|
+
kind: 'control';
|
|
143
|
+
id: string;
|
|
144
|
+
timestamp: number;
|
|
145
|
+
deviceId?: string;
|
|
146
|
+
sourceRole?: CBPProtocolRole;
|
|
147
|
+
targetRole?: CBPProtocolRole;
|
|
148
|
+
op: CBPControlPayload['op'];
|
|
149
|
+
payload?: Record<string, unknown>;
|
|
150
|
+
error?: CBPError;
|
|
151
|
+
meta?: Record<string, unknown>;
|
|
152
|
+
};
|
|
153
|
+
export type NormalizedCBPMessage = NormalizedEventMessage | NormalizedActionRequestMessage | NormalizedActionResponseMessage | NormalizedApiRequestMessage | NormalizedApiResponseMessage | NormalizedControlMessage;
|
|
154
|
+
export type CBPClientOptions = {
|
|
155
|
+
open?: () => void;
|
|
156
|
+
isFullReceive?: boolean;
|
|
157
|
+
};
|
|
158
|
+
export type ActionReplyFunc = (data: Actions, consume: (payload: Result[]) => void) => void;
|
|
159
|
+
export type ApiReplyFunc = (data: Apis, consume: (payload: Result[]) => void) => void;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { WebSocket } from 'ws';
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
7
|
-
import { deviceId, DEVICE_ID_HEADER, USER_AGENT_HEADER, reconnectInterval } from '../processor/config.js';
|
|
8
|
-
import { useHeartbeat } from './connect.js';
|
|
2
|
+
import { logger } from '../logger.js';
|
|
3
|
+
import { ResultCode } from '../variable.js';
|
|
4
|
+
import { DEVICE_ID_HEADER, USER_AGENT_HEADER, reconnectInterval } from './constants.js';
|
|
5
|
+
import { deviceId } from './runtime.js';
|
|
6
|
+
import { useHeartbeat } from './heartbeat.js';
|
|
9
7
|
|
|
10
8
|
const createWSConnector = (options) => {
|
|
11
9
|
const { url, role, onOpen, onMessage, extraHeaders = {}, globalKey } = options;
|
|
12
10
|
if (global[globalKey]) {
|
|
13
|
-
|
|
11
|
+
Reflect.deleteProperty(global, globalKey);
|
|
14
12
|
}
|
|
15
13
|
const [heartbeatControl] = useHeartbeat({
|
|
16
14
|
ping: () => {
|
|
@@ -57,7 +55,7 @@ const createWSConnector = (options) => {
|
|
|
57
55
|
message: `${role} 连接关闭,尝试重新连接...`,
|
|
58
56
|
data: code
|
|
59
57
|
});
|
|
60
|
-
|
|
58
|
+
Reflect.deleteProperty(global, globalKey);
|
|
61
59
|
setTimeout(() => {
|
|
62
60
|
start();
|
|
63
61
|
}, reconnectInterval);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Package } from '../types';
|
|
1
|
+
import type { Package } from '../types/index.js';
|
|
2
2
|
type ConfigValue = {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
apps?: string[] | {
|
|
@@ -55,4 +55,4 @@ declare class ConfigCore<T extends ConfigValue = ConfigValue> {
|
|
|
55
55
|
export declare const getConfig: <T extends ConfigValue = ConfigValue>() => ConfigCore<T>;
|
|
56
56
|
export declare const getConfigValue: <T extends ConfigValue = ConfigValue>() => T;
|
|
57
57
|
export declare const onWatchConfigValue: <T extends ConfigValue = ConfigValue>(callback: ConfigListener<T>) => (() => void);
|
|
58
|
-
export {};
|
|
58
|
+
export type { ConfigCore, ConfigListener, ConfigValue };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync, existsSync, watch, mkdirSync, writeFileSync } from 'fs';
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
3
|
import YAML from 'yaml';
|
|
4
|
+
import { logger } from './logger.js';
|
|
4
5
|
import { ResultCode } from './variable.js';
|
|
5
6
|
|
|
6
7
|
class ConfigCore {
|
|
@@ -13,6 +14,7 @@ class ConfigCore {
|
|
|
13
14
|
#argvProxy = null;
|
|
14
15
|
#resolvedDir = null;
|
|
15
16
|
#initValue = {};
|
|
17
|
+
#package = null;
|
|
16
18
|
constructor(dir) {
|
|
17
19
|
this.#resolvedDir = join(process.cwd(), dir);
|
|
18
20
|
}
|
|
@@ -142,7 +144,6 @@ class ConfigCore {
|
|
|
142
144
|
}
|
|
143
145
|
this.#listeners.clear();
|
|
144
146
|
}
|
|
145
|
-
#package = null;
|
|
146
147
|
get package() {
|
|
147
148
|
if (this.#package) {
|
|
148
149
|
return this.#package;
|
|
@@ -179,9 +180,9 @@ class ConfigCore {
|
|
|
179
180
|
if (typeof key === 'symbol') {
|
|
180
181
|
return undefined;
|
|
181
182
|
}
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
return process.argv[
|
|
183
|
+
const index0 = process.argv.indexOf(key);
|
|
184
|
+
if (index0 !== -1) {
|
|
185
|
+
return process.argv[index0 + 1];
|
|
185
186
|
}
|
|
186
187
|
const index = process.argv.indexOf(`--${key}`);
|
|
187
188
|
if (index !== -1) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const matchIn: (source: any, key: string) => boolean;
|
|
2
|
+
export declare const fastHash: (str: string) => string;
|
|
3
|
+
export declare const createUserHashKey: (event: {
|
|
4
|
+
UserId: string;
|
|
5
|
+
Platform: string;
|
|
6
|
+
}) => string;
|
|
7
|
+
export declare const useUserHashKey: (event: {
|
|
8
|
+
UserId: string;
|
|
9
|
+
Platform: string;
|
|
10
|
+
}) => string;
|
|
11
|
+
export declare const isMaster: (UserId: string, platform: string) => boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getConfigValue } from './config.js';
|
|
2
|
+
|
|
3
|
+
const matchIn = (source, key) => {
|
|
4
|
+
if (Array.isArray(source)) {
|
|
5
|
+
return source.includes(key);
|
|
6
|
+
}
|
|
7
|
+
if (source && typeof source === 'object') {
|
|
8
|
+
return Object.prototype.hasOwnProperty.call(source, key) && !!source[key];
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
};
|
|
12
|
+
const fastHash = (str) => {
|
|
13
|
+
let hash = 0x811c9dc5;
|
|
14
|
+
for (let i = 0; i < str.length; i++) {
|
|
15
|
+
hash ^= str.charCodeAt(i);
|
|
16
|
+
hash = Math.imul(hash, 0x01000193);
|
|
17
|
+
}
|
|
18
|
+
return (hash >>> 0).toString(36);
|
|
19
|
+
};
|
|
20
|
+
const createUserHashKey = (event) => {
|
|
21
|
+
return fastHash(`${event.Platform}:${event.UserId}`);
|
|
22
|
+
};
|
|
23
|
+
const useUserHashKey = createUserHashKey;
|
|
24
|
+
const isMaster = (UserId, platform) => {
|
|
25
|
+
const values = getConfigValue() || {};
|
|
26
|
+
const value = values[platform] && typeof values[platform] === 'object' ? values[platform] : {};
|
|
27
|
+
const UserKey = createUserHashKey({
|
|
28
|
+
Platform: platform,
|
|
29
|
+
UserId
|
|
30
|
+
});
|
|
31
|
+
return matchIn(values.master_key, UserKey) || matchIn(values.master_id, UserId) || matchIn(value.master_key, UserKey) || matchIn(value.master_id, UserId);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { createUserHashKey, fastHash, isMaster, matchIn, useUserHashKey };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './config.js';
|
|
2
|
+
export { processorRepeatedEventTime, processorRepeatedUserTime, processorRepeatedClearTimeMin, processorRepeatedClearTimeMax, processorRepeatedClearSize, processorMaxMapSize, fileSuffixMiddleware, fileSuffixResponse, filePrefixCommon, defaultPort, defaultLogin, defaultPlatformPrefix, defaultPlatformCommonPrefix, Ok, Warn, Fail, FailParams, FailAuth, FailInternal, EventMessageText, ResultCode } from './variable.js';
|
|
3
|
+
export * from './logger.js';
|
|
4
|
+
export * from './identity.js';
|
|
5
|
+
export * from './result.js';
|
|
6
|
+
export * from './SinglyLinkedList.js';
|
|
7
|
+
export * from './utils.js';
|
|
8
|
+
export * from './direct-channel.js';
|
|
9
|
+
export * from './react.js';
|
|
10
|
+
export * from './cbp/constants.js';
|
|
11
|
+
export * from './cbp/runtime.js';
|
|
12
|
+
export * from './cbp/heartbeat.js';
|
|
13
|
+
export * from './cbp/ws-connector.js';
|
|
14
|
+
export * from './cbp/normalize.js';
|
|
15
|
+
export * from './cbp/typings.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { getConfig, getConfigValue, onWatchConfigValue } from './config.js';
|
|
2
|
+
export { EventMessageText, Fail, FailAuth, FailInternal, FailParams, Ok, ResultCode, Warn, defaultLogin, defaultPlatformCommonPrefix, defaultPlatformPrefix, defaultPort, filePrefixCommon, fileSuffixMiddleware, fileSuffixResponse, processorMaxMapSize, processorRepeatedClearSize, processorRepeatedClearTimeMax, processorRepeatedClearTimeMin, processorRepeatedEventTime, processorRepeatedUserTime } from './variable.js';
|
|
3
|
+
export { Logger, logger } from './logger.js';
|
|
4
|
+
export { createUserHashKey, fastHash, isMaster, matchIn, useUserHashKey } from './identity.js';
|
|
5
|
+
export { createResult } from './result.js';
|
|
6
|
+
export { SinglyLinkedList } from './SinglyLinkedList.js';
|
|
7
|
+
export { createEventName, createHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, sanitizeForSerialization, showErrorModule, stringToNumber } from './utils.js';
|
|
8
|
+
export { createDirectClient, createDirectServer, generateSocketPath } from './direct-channel.js';
|
|
9
|
+
export { A, Body, Component, DOCTYPE, Div, H1, Head, Html, P, Style, Title, createElement, renderToString } from './react.js';
|
|
10
|
+
export { DEVICE_ID_HEADER, FULL_RECEIVE_HEADER, HEARTBEAT_INTERVAL, USER_AGENT_HEADER, USER_AGENT_HEADER_VALUE_MAP, reconnectInterval, timeoutTime } from './cbp/constants.js';
|
|
11
|
+
export { deviceId, generateUniqueId } from './cbp/runtime.js';
|
|
12
|
+
export { useHeartbeat } from './cbp/heartbeat.js';
|
|
13
|
+
export { createWSConnector } from './cbp/ws-connector.js';
|
|
14
|
+
export { createActionRequestEnvelope, createActionResponseEnvelope, createApiRequestEnvelope, createApiResponseEnvelope, createEventEnvelope, getNormalizedDeviceId, getNormalizedEventRouteId, isCBPEnvelope, isNormalizedActionRequest, isNormalizedApiRequest, normalizeInboundMessage, toLegacyActionData, toLegacyApiData } from './cbp/normalize.js';
|