@satorijs/adapter-dingtalk 2.0.2 → 2.0.4
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/http.d.ts +4 -2
- package/lib/index.js +11 -8
- package/lib/index.js.map +1 -2
- package/package.json +8 -4
- package/src/api/.eslintrc.yml +2 -0
- package/src/api/alitrip.ts +467 -0
- package/src/api/attendance.ts +81 -0
- package/src/api/badge.ts +285 -0
- package/src/api/blackboard.ts +28 -0
- package/src/api/calendar.ts +817 -0
- package/src/api/card.ts +215 -0
- package/src/api/conference.ts +561 -0
- package/src/api/connector.ts +97 -0
- package/src/api/contact.ts +56 -0
- package/src/api/convFile.ts +166 -0
- package/src/api/crm.ts +830 -0
- package/src/api/customerService.ts +156 -0
- package/src/api/datacenter.ts +672 -0
- package/src/api/devicemng.ts +202 -0
- package/src/api/diot.ts +19 -0
- package/src/api/doc.ts +232 -0
- package/src/api/drive.ts +109 -0
- package/src/api/edu.ts +30 -0
- package/src/api/esign.ts +44 -0
- package/src/api/exclusive.ts +372 -0
- package/src/api/h3yun.ts +537 -0
- package/src/api/hrm.ts +272 -0
- package/src/api/im.ts +978 -0
- package/src/api/industry.ts +153 -0
- package/src/api/jzcrm.ts +304 -0
- package/src/api/link.ts +94 -0
- package/src/api/live.ts +162 -0
- package/src/api/microApp.ts +309 -0
- package/src/api/oapi.ts +4083 -0
- package/src/api/oauth2.ts +146 -0
- package/src/api/pedia.ts +222 -0
- package/src/api/project.ts +1519 -0
- package/src/api/resident.ts +133 -0
- package/src/api/robot.ts +326 -0
- package/src/api/rooms.ts +334 -0
- package/src/api/serviceGroup.ts +216 -0
- package/src/api/storage.ts +1701 -0
- package/src/api/swform.ts +94 -0
- package/src/api/todo.ts +220 -0
- package/src/api/wiki.ts +231 -0
- package/src/api/workbench.ts +73 -0
- package/src/api/yida.ts +2165 -0
- package/src/bot.ts +111 -0
- package/src/http.ts +44 -0
- package/src/index.ts +9 -0
- package/src/internal.ts +47 -0
- package/src/message.ts +141 -0
- package/src/types/index.ts +140 -0
- package/src/utils.ts +51 -0
- package/src/ws.ts +55 -0
package/lib/http.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Adapter, Context
|
|
1
|
+
import { Adapter, Context } from '@satorijs/satori';
|
|
2
2
|
import { DingtalkBot } from './bot';
|
|
3
3
|
export declare class HttpServer<C extends Context = Context> extends Adapter<C, DingtalkBot<C>> {
|
|
4
|
-
|
|
4
|
+
static inject: string[];
|
|
5
|
+
private logger;
|
|
6
|
+
constructor(ctx: C, bot: DingtalkBot<C>);
|
|
5
7
|
connect(bot: DingtalkBot<C>): Promise<void>;
|
|
6
8
|
}
|
package/lib/index.js
CHANGED
|
@@ -104,7 +104,11 @@ __name(decodeMessage, "decodeMessage");
|
|
|
104
104
|
|
|
105
105
|
// satori/adapters/dingtalk/src/http.ts
|
|
106
106
|
var _HttpServer = class _HttpServer extends import_satori2.Adapter {
|
|
107
|
-
logger
|
|
107
|
+
logger;
|
|
108
|
+
constructor(ctx, bot) {
|
|
109
|
+
super(ctx);
|
|
110
|
+
this.logger = ctx.logger("dingtalk");
|
|
111
|
+
}
|
|
108
112
|
async connect(bot) {
|
|
109
113
|
await bot.refreshToken();
|
|
110
114
|
await bot.getLogin();
|
|
@@ -130,6 +134,7 @@ var _HttpServer = class _HttpServer extends import_satori2.Adapter {
|
|
|
130
134
|
}
|
|
131
135
|
};
|
|
132
136
|
__name(_HttpServer, "HttpServer");
|
|
137
|
+
__publicField(_HttpServer, "inject", ["router"]);
|
|
133
138
|
var HttpServer = _HttpServer;
|
|
134
139
|
|
|
135
140
|
// satori/adapters/dingtalk/src/message.ts
|
|
@@ -278,7 +283,7 @@ var _WsClient = class _WsClient extends import_satori4.Adapter.WsClient {
|
|
|
278
283
|
this.bot.online();
|
|
279
284
|
this.socket.addEventListener("message", async ({ data }) => {
|
|
280
285
|
const parsed = JSON.parse(data.toString());
|
|
281
|
-
this.
|
|
286
|
+
this.bot.logger.debug(parsed);
|
|
282
287
|
if (parsed.type === "SYSTEM") {
|
|
283
288
|
if (parsed.headers.topic === "ping") {
|
|
284
289
|
this.socket.send(JSON.stringify({
|
|
@@ -289,11 +294,11 @@ var _WsClient = class _WsClient extends import_satori4.Adapter.WsClient {
|
|
|
289
294
|
}));
|
|
290
295
|
}
|
|
291
296
|
} else if (parsed.type === "CALLBACK") {
|
|
292
|
-
this.
|
|
297
|
+
this.bot.logger.debug(JSON.parse(parsed.data));
|
|
293
298
|
const session = await decodeMessage(this.bot, JSON.parse(parsed.data));
|
|
294
299
|
if (session)
|
|
295
300
|
this.bot.dispatch(session);
|
|
296
|
-
this.
|
|
301
|
+
this.bot.logger.debug(session);
|
|
297
302
|
}
|
|
298
303
|
});
|
|
299
304
|
}
|
|
@@ -359,15 +364,13 @@ __name(_Internal, "Internal");
|
|
|
359
364
|
var Internal = _Internal;
|
|
360
365
|
|
|
361
366
|
// satori/adapters/dingtalk/src/bot.ts
|
|
362
|
-
var logger = new import_satori6.Logger("dingtalk");
|
|
363
367
|
var _DingtalkBot = class _DingtalkBot extends import_satori6.Bot {
|
|
364
368
|
oldHttp;
|
|
365
369
|
http;
|
|
366
370
|
internal;
|
|
367
371
|
refreshTokenTimer;
|
|
368
372
|
constructor(ctx, config) {
|
|
369
|
-
super(ctx, config);
|
|
370
|
-
this.platform = "dingtalk";
|
|
373
|
+
super(ctx, config, "dingtalk");
|
|
371
374
|
this.selfId = config.appkey;
|
|
372
375
|
this.http = ctx.http.extend(config.api);
|
|
373
376
|
this.oldHttp = ctx.http.extend(config.oldApi);
|
|
@@ -395,7 +398,7 @@ var _DingtalkBot = class _DingtalkBot extends import_satori6.Bot {
|
|
|
395
398
|
appKey: this.config.appkey,
|
|
396
399
|
appSecret: this.config.secret
|
|
397
400
|
});
|
|
398
|
-
logger.debug("gettoken result: %o", data);
|
|
401
|
+
this.logger.debug("gettoken result: %o", data);
|
|
399
402
|
this.token = data.accessToken;
|
|
400
403
|
this.http = this.http.extend({
|
|
401
404
|
headers: {
|