@blocklet/sdk 1.16.33-beta-20241014-122831-e6000fb8 → 1.16.33-beta-20241015-065257-56072e40
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/config.js +10 -1
- package/lib/service/notification.js +5 -2
- package/package.json +8 -7
package/lib/config.js
CHANGED
|
@@ -10,18 +10,20 @@ const path_1 = __importDefault(require("path"));
|
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
11
|
const ufo_1 = require("ufo");
|
|
12
12
|
const events_1 = require("events");
|
|
13
|
+
const axios_1 = __importDefault(require("axios"));
|
|
14
|
+
const debug_1 = __importDefault(require("debug"));
|
|
13
15
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
14
16
|
const throttle_1 = __importDefault(require("lodash/throttle"));
|
|
15
17
|
const env_1 = __importDefault(require("@blocklet/env"));
|
|
16
18
|
const constant_1 = require("@blocklet/constant");
|
|
17
19
|
const util_1 = require("@blocklet/env/lib/util");
|
|
18
20
|
const util_2 = require("@blocklet/meta/lib/util");
|
|
19
|
-
const axios_1 = __importDefault(require("axios"));
|
|
20
21
|
const security_1 = require("./security");
|
|
21
22
|
const version_1 = require("./version");
|
|
22
23
|
const notification_1 = __importDefault(require("./service/notification"));
|
|
23
24
|
const server_version_1 = __importDefault(require("./util/server-version"));
|
|
24
25
|
const parse_env_file_1 = require("./util/parse-env-file");
|
|
26
|
+
const debug = (0, debug_1.default)('@blocklet/sdk:config');
|
|
25
27
|
const events = new events_1.EventEmitter();
|
|
26
28
|
exports.events = events;
|
|
27
29
|
const Events = {
|
|
@@ -152,11 +154,13 @@ const _setUpdatedComponents = (components) => {
|
|
|
152
154
|
};
|
|
153
155
|
const _handleComponentStarted = (data) => {
|
|
154
156
|
const list = _setComponentStatus(data.components, constant_1.BlockletStatus.running);
|
|
157
|
+
debug('handle component started', data, list);
|
|
155
158
|
events.emit(Events.componentStarted, list);
|
|
156
159
|
};
|
|
157
160
|
exports._handleComponentStarted = _handleComponentStarted;
|
|
158
161
|
const _handleComponentStopped = (data) => {
|
|
159
162
|
const list = _setComponentStatus(data.components, constant_1.BlockletStatus.stopped);
|
|
163
|
+
debug('handle component stopped', data, list);
|
|
160
164
|
events.emit(Events.componentStopped, list);
|
|
161
165
|
};
|
|
162
166
|
exports._handleComponentStopped = _handleComponentStopped;
|
|
@@ -164,16 +168,19 @@ const _handleComponentRemoved = (data) => {
|
|
|
164
168
|
const list = componentStore.filter((x) => data.components.find((y) => y.did !== x.did));
|
|
165
169
|
componentStore.splice(0, componentStore.length);
|
|
166
170
|
componentStore.push(...list);
|
|
171
|
+
debug('handle component removed', data, list);
|
|
167
172
|
events.emit(Events.componentRemoved, data.components);
|
|
168
173
|
};
|
|
169
174
|
exports._handleComponentRemoved = _handleComponentRemoved;
|
|
170
175
|
const _handleComponentUpdated = (data) => {
|
|
171
176
|
const list = _setUpdatedComponents(data.components);
|
|
177
|
+
debug('handle component updated', data, list);
|
|
172
178
|
events.emit(Events.componentUpdated, list);
|
|
173
179
|
};
|
|
174
180
|
exports._handleComponentUpdated = _handleComponentUpdated;
|
|
175
181
|
const _handleComponentInstalled = (data) => {
|
|
176
182
|
const list = _setUpdatedComponents(data.components);
|
|
183
|
+
debug('handle component installed', data, list);
|
|
177
184
|
events.emit(Events.componentAdded, list);
|
|
178
185
|
};
|
|
179
186
|
exports._handleComponentInstalled = _handleComponentInstalled;
|
|
@@ -199,6 +206,7 @@ const _handleConfigUpdate = (data) => {
|
|
|
199
206
|
return acc;
|
|
200
207
|
}, {})));
|
|
201
208
|
Object.assign(env, updates);
|
|
209
|
+
debug('handle app config update', data, updates);
|
|
202
210
|
events.emit(Events.envUpdate, updates);
|
|
203
211
|
};
|
|
204
212
|
exports._handleConfigUpdate = _handleConfigUpdate;
|
|
@@ -219,6 +227,7 @@ const _handleComponentConfigUpdate = (data) => {
|
|
|
219
227
|
}, {}));
|
|
220
228
|
env.preferences = env.preferences || {};
|
|
221
229
|
Object.assign(env.preferences, preferenceUpdates);
|
|
230
|
+
debug('handle component config update', data, decrypted, { ...updates, preferences: preferenceUpdates });
|
|
222
231
|
events.emit(Events.envUpdate, {
|
|
223
232
|
...updates,
|
|
224
233
|
preferences: preferenceUpdates,
|
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.broadcast = exports.sendToRelay = exports.sendToMail = exports.sendToUser = exports._message = exports.off = exports.on = void 0;
|
|
30
30
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
31
31
|
const Jwt = __importStar(require("@arcblock/jwt"));
|
|
32
|
+
const debug_1 = __importDefault(require("debug"));
|
|
32
33
|
const node_events_1 = require("node:events");
|
|
33
34
|
const ws_1 = require("@arcblock/ws");
|
|
34
35
|
const channel_1 = require("@blocklet/meta/lib/channel");
|
|
@@ -38,6 +39,7 @@ const send_notification_1 = require("../util/send-notification");
|
|
|
38
39
|
const constants_1 = require("../util/constants");
|
|
39
40
|
const wallet_1 = __importStar(require("../wallet"));
|
|
40
41
|
const notification_1 = require("../validators/notification");
|
|
42
|
+
const debug = (0, debug_1.default)('@blocklet/sdk:notification');
|
|
41
43
|
const getSender = () => {
|
|
42
44
|
const wallet = (0, wallet_1.default)();
|
|
43
45
|
return {
|
|
@@ -144,6 +146,7 @@ const initClient = () => {
|
|
|
144
146
|
.receive('error', joinChannelErrorHandler('app component channel', 'error'))
|
|
145
147
|
.receive('timeout', joinChannelErrorHandler('app component channel', 'timeout'));
|
|
146
148
|
messageChannel.on('message', ({ status, response } = {}) => {
|
|
149
|
+
debug('messageChannel.on', { status, response });
|
|
147
150
|
if (status === 'ok') {
|
|
148
151
|
messageEmitter.emit(response.type, response);
|
|
149
152
|
if (response.type === notification_1.NOTIFICATION_TYPES.HI) {
|
|
@@ -161,10 +164,9 @@ const initClient = () => {
|
|
|
161
164
|
[...Object.keys(constant_1.BlockletInternalEvents), ...Object.keys(constant_1.TeamEvents)].forEach((key) => {
|
|
162
165
|
const event = constant_1.BlockletInternalEvents[key] || constant_1.TeamEvents[key];
|
|
163
166
|
componentChannel.on(event, ({ status, response } = {}) => {
|
|
167
|
+
debug('componentChannel.on', { event, status, response });
|
|
164
168
|
if (status === 'ok') {
|
|
165
169
|
const { data, sender, time } = response;
|
|
166
|
-
// eslint-disable-next-line no-console
|
|
167
|
-
console.info(`Received event from component channel: ${event}. time: ${time}`);
|
|
168
170
|
if (!time || new Date(time).getTime() < new Date(process.env.BLOCKLET_START_AT).getTime()) {
|
|
169
171
|
return;
|
|
170
172
|
}
|
|
@@ -185,6 +187,7 @@ const initClient = () => {
|
|
|
185
187
|
});
|
|
186
188
|
});
|
|
187
189
|
appPublicChannel.on(notification_1.NOTIFICATION_TYPES.HI, ({ status, response } = {}) => {
|
|
190
|
+
debug('appPublicChannel.on', { event: notification_1.NOTIFICATION_TYPES.HI, status, response });
|
|
188
191
|
if (status === 'ok') {
|
|
189
192
|
emitter.emit(notification_1.NOTIFICATION_TYPES.HI, response);
|
|
190
193
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.33-beta-
|
|
6
|
+
"version": "1.16.33-beta-20241015-065257-56072e40",
|
|
7
7
|
"description": "graphql client to read/write data on abt node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"typings": "lib/index.d.ts",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abtnode/client": "1.16.33-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.33-beta-
|
|
30
|
+
"@abtnode/client": "1.16.33-beta-20241015-065257-56072e40",
|
|
31
|
+
"@abtnode/constant": "1.16.33-beta-20241015-065257-56072e40",
|
|
32
32
|
"@arcblock/did": "1.18.135",
|
|
33
33
|
"@arcblock/did-auth": "1.18.135",
|
|
34
34
|
"@arcblock/jwt": "1.18.135",
|
|
35
35
|
"@arcblock/ws": "1.18.135",
|
|
36
|
-
"@blocklet/constant": "1.16.33-beta-
|
|
37
|
-
"@blocklet/env": "1.16.33-beta-
|
|
38
|
-
"@blocklet/meta": "1.16.33-beta-
|
|
36
|
+
"@blocklet/constant": "1.16.33-beta-20241015-065257-56072e40",
|
|
37
|
+
"@blocklet/env": "1.16.33-beta-20241015-065257-56072e40",
|
|
38
|
+
"@blocklet/meta": "1.16.33-beta-20241015-065257-56072e40",
|
|
39
39
|
"@did-connect/authenticator": "^2.2.4",
|
|
40
40
|
"@did-connect/handler": "^2.2.4",
|
|
41
41
|
"@nedb/core": "^2.1.5",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@ocap/wallet": "1.18.135",
|
|
44
44
|
"axios": "^1.7.5",
|
|
45
45
|
"cheerio": "1.0.0-rc.12",
|
|
46
|
+
"debug": "^4.3.7",
|
|
46
47
|
"fs-extra": "^11.2.0",
|
|
47
48
|
"joi": "17.12.2",
|
|
48
49
|
"json-stable-stringify": "^1.0.1",
|
|
@@ -76,5 +77,5 @@
|
|
|
76
77
|
"ts-node": "^10.9.1",
|
|
77
78
|
"typescript": "^5.6.3"
|
|
78
79
|
},
|
|
79
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "38bdd3a115d74c6f92b884844af0ff37a8926d80"
|
|
80
81
|
}
|