@satorijs/adapter-dingtalk 1.0.0 → 1.0.2
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/api/contact.d.ts +1 -1
- package/lib/bot.d.ts +1 -1
- package/lib/index.js +25 -13
- package/lib/index.js.map +2 -2
- package/package.json +2 -2
- package/readme.md +5 -0
package/lib/api/contact.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface GetOrgAuthInfoResponse {
|
|
|
13
13
|
authLevel: number;
|
|
14
14
|
}
|
|
15
15
|
export interface BatchApproveUnionApplyParams {
|
|
16
|
-
/** 申请的合作伙伴组织CorpId,参考[基础概念-CorpId](https://open.dingtalk.com/document/org/basic-concepts)。 */
|
|
16
|
+
/** 申请的合作伙伴组织 CorpId,参考[基础概念-CorpId](https://open.dingtalk.com/document/org/basic-concepts)。 */
|
|
17
17
|
branchCorpId?: string;
|
|
18
18
|
/** 合作伙伴组织在上下游组织内的名称。 */
|
|
19
19
|
unionRootName?: string;
|
package/lib/bot.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export declare class DingtalkBot extends Bot<DingtalkBot.Config> {
|
|
|
7
7
|
static MessageEncoder: typeof DingtalkMessageEncoder;
|
|
8
8
|
oldHttp: Quester;
|
|
9
9
|
http: Quester;
|
|
10
|
-
refreshTokenTimer: NodeJS.Timeout;
|
|
11
10
|
internal: Internal;
|
|
11
|
+
refreshTokenTimer: NodeJS.Timeout;
|
|
12
12
|
constructor(ctx: Context, config: DingtalkBot.Config);
|
|
13
13
|
initialize(): Promise<void>;
|
|
14
14
|
stop(): Promise<void>;
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
@@ -26,6 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
27
|
mod
|
|
27
28
|
));
|
|
28
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => {
|
|
31
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
32
|
+
return value;
|
|
33
|
+
};
|
|
29
34
|
|
|
30
35
|
// satori/adapters/dingtalk/src/index.ts
|
|
31
36
|
var src_exports = {};
|
|
@@ -98,9 +103,9 @@ __name(decodeMessage, "decodeMessage");
|
|
|
98
103
|
|
|
99
104
|
// satori/adapters/dingtalk/src/http.ts
|
|
100
105
|
var _HttpServer = class _HttpServer extends import_satori2.Adapter.Server {
|
|
106
|
+
logger = new import_satori2.Logger("dingtalk");
|
|
101
107
|
constructor(ctx, bot) {
|
|
102
108
|
super();
|
|
103
|
-
this.logger = new import_satori2.Logger("dingtalk");
|
|
104
109
|
}
|
|
105
110
|
async start(bot) {
|
|
106
111
|
await bot.refreshToken();
|
|
@@ -136,15 +141,11 @@ var import_form_data = __toESM(require("form-data"));
|
|
|
136
141
|
var escape = /* @__PURE__ */ __name((val) => val.replace(/(?<!\u200b)[\*_~`]/g, "$&").replace(/([\\`*_{}[\]\-(#!>])/g, "\\$&").replace(/([\-\*]|\d\.) /g, "$&").replace(/^(\s{4})/gm, " "), "escape");
|
|
137
142
|
var unescape = /* @__PURE__ */ __name((val) => val.replace(/\u200b([\*_~`])/g, "$1"), "unescape");
|
|
138
143
|
var _DingtalkMessageEncoder = class _DingtalkMessageEncoder extends import_satori3.MessageEncoder {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*/
|
|
145
|
-
this.hasRichContent = true;
|
|
146
|
-
this.listType = null;
|
|
147
|
-
}
|
|
144
|
+
buffer = "";
|
|
145
|
+
/**
|
|
146
|
+
* Markdown: https://open.dingtalk.com/document/isvapp/robot-message-types-and-data-format
|
|
147
|
+
*/
|
|
148
|
+
hasRichContent = true;
|
|
148
149
|
async flush() {
|
|
149
150
|
if (this.buffer.length && !this.hasRichContent) {
|
|
150
151
|
await this.sendMessage("sampleText", {
|
|
@@ -198,6 +199,7 @@ var _DingtalkMessageEncoder = class _DingtalkMessageEncoder extends import_sator
|
|
|
198
199
|
});
|
|
199
200
|
return media_id;
|
|
200
201
|
}
|
|
202
|
+
listType = null;
|
|
201
203
|
async visit(element) {
|
|
202
204
|
const { type, attrs, children } = element;
|
|
203
205
|
if (type === "text") {
|
|
@@ -209,9 +211,14 @@ var _DingtalkMessageEncoder = class _DingtalkMessageEncoder extends import_sator
|
|
|
209
211
|
await this.render(children);
|
|
210
212
|
} else if (type === "at") {
|
|
211
213
|
this.buffer += `@${attrs.id}`;
|
|
212
|
-
} else if (type === "
|
|
214
|
+
} else if (type === "br") {
|
|
213
215
|
this.buffer += "\n";
|
|
216
|
+
} else if (type === "p") {
|
|
217
|
+
if (!this.buffer.endsWith("\n"))
|
|
218
|
+
this.buffer += "\n";
|
|
214
219
|
await this.render(children);
|
|
220
|
+
if (!this.buffer.endsWith("\n"))
|
|
221
|
+
this.buffer += "\n";
|
|
215
222
|
this.buffer += "\n";
|
|
216
223
|
} else if (type === "b" || type === "strong") {
|
|
217
224
|
this.buffer += ` **`;
|
|
@@ -357,8 +364,13 @@ var Internal = _Internal;
|
|
|
357
364
|
// satori/adapters/dingtalk/src/bot.ts
|
|
358
365
|
var logger = new import_satori6.Logger("dingtalk");
|
|
359
366
|
var _DingtalkBot = class _DingtalkBot extends import_satori6.Bot {
|
|
367
|
+
oldHttp;
|
|
368
|
+
http;
|
|
369
|
+
internal;
|
|
370
|
+
refreshTokenTimer;
|
|
360
371
|
constructor(ctx, config) {
|
|
361
372
|
super(ctx, config);
|
|
373
|
+
this.platform = "dingtalk";
|
|
362
374
|
this.http = ctx.http.extend(config.api);
|
|
363
375
|
this.oldHttp = ctx.http.extend(config.oldApi);
|
|
364
376
|
this.internal = new Internal(this);
|
|
@@ -378,6 +390,7 @@ var _DingtalkBot = class _DingtalkBot extends import_satori6.Bot {
|
|
|
378
390
|
stop() {
|
|
379
391
|
clearTimeout(this.refreshTokenTimer);
|
|
380
392
|
}
|
|
393
|
+
token;
|
|
381
394
|
async refreshToken() {
|
|
382
395
|
const data = await this.internal.getAccessToken({
|
|
383
396
|
appKey: this.config.appkey,
|
|
@@ -416,7 +429,7 @@ var _DingtalkBot = class _DingtalkBot extends import_satori6.Bot {
|
|
|
416
429
|
}
|
|
417
430
|
};
|
|
418
431
|
__name(_DingtalkBot, "DingtalkBot");
|
|
419
|
-
_DingtalkBot
|
|
432
|
+
__publicField(_DingtalkBot, "MessageEncoder", DingtalkMessageEncoder);
|
|
420
433
|
var DingtalkBot = _DingtalkBot;
|
|
421
434
|
((DingtalkBot2) => {
|
|
422
435
|
DingtalkBot2.Config = import_satori6.Schema.intersect([
|
|
@@ -433,7 +446,6 @@ var DingtalkBot = _DingtalkBot;
|
|
|
433
446
|
WsClient.Config
|
|
434
447
|
]);
|
|
435
448
|
})(DingtalkBot || (DingtalkBot = {}));
|
|
436
|
-
DingtalkBot.prototype.platform = "dingtalk";
|
|
437
449
|
|
|
438
450
|
// satori/adapters/dingtalk/src/api/oauth2.ts
|
|
439
451
|
Internal.define({
|