@im-more/dsh-dingtalk 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/cordis.patch.yml +11 -0
- package/lib/index.js +2765 -0
- package/lib/index.js.map +1 -0
- package/lib/types/api/alitrip.d.ts +397 -0
- package/lib/types/api/alitrip.d.ts.map +1 -0
- package/lib/types/api/alitrip.js +21 -0
- package/lib/types/api/alitrip.js.map +1 -0
- package/lib/types/api/attendance.d.ts +63 -0
- package/lib/types/api/attendance.d.ts.map +1 -0
- package/lib/types/api/attendance.js +8 -0
- package/lib/types/api/attendance.js.map +1 -0
- package/lib/types/api/badge.d.ts +233 -0
- package/lib/types/api/badge.d.ts.map +1 -0
- package/lib/types/api/badge.js +19 -0
- package/lib/types/api/badge.js.map +1 -0
- package/lib/types/api/blackboard.d.ts +17 -0
- package/lib/types/api/blackboard.d.ts.map +1 -0
- package/lib/types/api/blackboard.js +6 -0
- package/lib/types/api/blackboard.js.map +1 -0
- package/lib/types/api/calendar.d.ts +621 -0
- package/lib/types/api/calendar.d.ts.map +1 -0
- package/lib/types/api/calendar.js +57 -0
- package/lib/types/api/calendar.js.map +1 -0
- package/lib/types/api/card.d.ts +185 -0
- package/lib/types/api/card.d.ts.map +1 -0
- package/lib/types/api/card.js +13 -0
- package/lib/types/api/card.js.map +1 -0
- package/lib/types/api/conference.d.ts +404 -0
- package/lib/types/api/conference.d.ts.map +1 -0
- package/lib/types/api/conference.js +60 -0
- package/lib/types/api/conference.js.map +1 -0
- package/lib/types/api/connector.d.ts +79 -0
- package/lib/types/api/connector.d.ts.map +1 -0
- package/lib/types/api/connector.js +8 -0
- package/lib/types/api/connector.js.map +1 -0
- package/lib/types/api/contact.d.ts +40 -0
- package/lib/types/api/contact.d.ts.map +1 -0
- package/lib/types/api/contact.js +9 -0
- package/lib/types/api/contact.js.map +1 -0
- package/lib/types/api/convFile.d.ts +135 -0
- package/lib/types/api/convFile.d.ts.map +1 -0
- package/lib/types/api/convFile.js +9 -0
- package/lib/types/api/convFile.js.map +1 -0
- package/lib/types/api/crm.d.ts +662 -0
- package/lib/types/api/crm.d.ts.map +1 -0
- package/lib/types/api/crm.js +59 -0
- package/lib/types/api/crm.js.map +1 -0
- package/lib/types/api/customerService.d.ts +128 -0
- package/lib/types/api/customerService.d.ts.map +1 -0
- package/lib/types/api/customerService.js +13 -0
- package/lib/types/api/customerService.js.map +1 -0
- package/lib/types/api/datacenter.d.ts +506 -0
- package/lib/types/api/datacenter.d.ts.map +1 -0
- package/lib/types/api/datacenter.js +61 -0
- package/lib/types/api/datacenter.js.map +1 -0
- package/lib/types/api/devicemng.d.ts +161 -0
- package/lib/types/api/devicemng.d.ts.map +1 -0
- package/lib/types/api/devicemng.js +20 -0
- package/lib/types/api/devicemng.js.map +1 -0
- package/lib/types/api/diot.d.ts +13 -0
- package/lib/types/api/diot.d.ts.map +1 -0
- package/lib/types/api/diot.js +4 -0
- package/lib/types/api/diot.js.map +1 -0
- package/lib/types/api/doc.d.ts +141 -0
- package/lib/types/api/doc.d.ts.map +1 -0
- package/lib/types/api/doc.js +27 -0
- package/lib/types/api/doc.js.map +1 -0
- package/lib/types/api/drive.d.ts +88 -0
- package/lib/types/api/drive.d.ts.map +1 -0
- package/lib/types/api/drive.js +11 -0
- package/lib/types/api/drive.js.map +1 -0
- package/lib/types/api/edu.d.ts +23 -0
- package/lib/types/api/edu.d.ts.map +1 -0
- package/lib/types/api/edu.js +4 -0
- package/lib/types/api/edu.js.map +1 -0
- package/lib/types/api/esign.d.ts +34 -0
- package/lib/types/api/esign.d.ts.map +1 -0
- package/lib/types/api/esign.js +7 -0
- package/lib/types/api/esign.js.map +1 -0
- package/lib/types/api/exclusive.d.ts +304 -0
- package/lib/types/api/exclusive.d.ts.map +1 -0
- package/lib/types/api/exclusive.js +27 -0
- package/lib/types/api/exclusive.js.map +1 -0
- package/lib/types/api/h3yun.d.ts +438 -0
- package/lib/types/api/h3yun.d.ts.map +1 -0
- package/lib/types/api/h3yun.js +33 -0
- package/lib/types/api/h3yun.js.map +1 -0
- package/lib/types/api/hrm.d.ts +215 -0
- package/lib/types/api/hrm.d.ts.map +1 -0
- package/lib/types/api/hrm.js +20 -0
- package/lib/types/api/hrm.js.map +1 -0
- package/lib/types/api/im.d.ts +773 -0
- package/lib/types/api/im.d.ts.map +1 -0
- package/lib/types/api/im.js +72 -0
- package/lib/types/api/im.js.map +1 -0
- package/lib/types/api/industry.d.ts +118 -0
- package/lib/types/api/industry.d.ts.map +1 -0
- package/lib/types/api/industry.js +14 -0
- package/lib/types/api/industry.js.map +1 -0
- package/lib/types/api/jzcrm.d.ts +255 -0
- package/lib/types/api/jzcrm.d.ts.map +1 -0
- package/lib/types/api/jzcrm.js +18 -0
- package/lib/types/api/jzcrm.js.map +1 -0
- package/lib/types/api/link.d.ts +73 -0
- package/lib/types/api/link.d.ts.map +1 -0
- package/lib/types/api/link.js +9 -0
- package/lib/types/api/link.js.map +1 -0
- package/lib/types/api/live.d.ts +132 -0
- package/lib/types/api/live.d.ts.map +1 -0
- package/lib/types/api/live.js +13 -0
- package/lib/types/api/live.js.map +1 -0
- package/lib/types/api/microApp.d.ts +240 -0
- package/lib/types/api/microApp.d.ts.map +1 -0
- package/lib/types/api/microApp.js +29 -0
- package/lib/types/api/microApp.js.map +1 -0
- package/lib/types/api/oapi.d.ts +3362 -0
- package/lib/types/api/oapi.d.ts.map +1 -0
- package/lib/types/api/oapi.js +247 -0
- package/lib/types/api/oapi.js.map +1 -0
- package/lib/types/api/oauth2.d.ts +115 -0
- package/lib/types/api/oauth2.d.ts.map +1 -0
- package/lib/types/api/oauth2.js +12 -0
- package/lib/types/api/oauth2.js.map +1 -0
- package/lib/types/api/pedia.d.ts +186 -0
- package/lib/types/api/pedia.d.ts.map +1 -0
- package/lib/types/api/pedia.js +13 -0
- package/lib/types/api/pedia.js.map +1 -0
- package/lib/types/api/project.d.ts +1119 -0
- package/lib/types/api/project.d.ts.map +1 -0
- package/lib/types/api/project.js +135 -0
- package/lib/types/api/project.js.map +1 -0
- package/lib/types/api/resident.d.ts +107 -0
- package/lib/types/api/resident.d.ts.map +1 -0
- package/lib/types/api/resident.js +10 -0
- package/lib/types/api/resident.js.map +1 -0
- package/lib/types/api/robot.d.ts +256 -0
- package/lib/types/api/robot.d.ts.map +1 -0
- package/lib/types/api/robot.js +21 -0
- package/lib/types/api/robot.js.map +1 -0
- package/lib/types/api/rooms.d.ts +256 -0
- package/lib/types/api/rooms.d.ts.map +1 -0
- package/lib/types/api/rooms.js +23 -0
- package/lib/types/api/rooms.js.map +1 -0
- package/lib/types/api/serviceGroup.d.ts +176 -0
- package/lib/types/api/serviceGroup.d.ts.map +1 -0
- package/lib/types/api/serviceGroup.js +15 -0
- package/lib/types/api/serviceGroup.js.map +1 -0
- package/lib/types/api/storage.d.ts +1241 -0
- package/lib/types/api/storage.d.ts.map +1 -0
- package/lib/types/api/storage.js +128 -0
- package/lib/types/api/storage.js.map +1 -0
- package/lib/types/api/swform.d.ts +71 -0
- package/lib/types/api/swform.d.ts.map +1 -0
- package/lib/types/api/swform.js +8 -0
- package/lib/types/api/swform.js.map +1 -0
- package/lib/types/api/todo.d.ts +169 -0
- package/lib/types/api/todo.d.ts.map +1 -0
- package/lib/types/api/todo.js +16 -0
- package/lib/types/api/todo.js.map +1 -0
- package/lib/types/api/wiki.d.ts +195 -0
- package/lib/types/api/wiki.d.ts.map +1 -0
- package/lib/types/api/wiki.js +11 -0
- package/lib/types/api/wiki.js.map +1 -0
- package/lib/types/api/workbench.d.ts +46 -0
- package/lib/types/api/workbench.d.ts.map +1 -0
- package/lib/types/api/workbench.js +14 -0
- package/lib/types/api/workbench.js.map +1 -0
- package/lib/types/api/yida.d.ts +1838 -0
- package/lib/types/api/yida.d.ts.map +1 -0
- package/lib/types/api/yida.js +103 -0
- package/lib/types/api/yida.js.map +1 -0
- package/lib/types/bot.d.ts +62 -0
- package/lib/types/bot.d.ts.map +1 -0
- package/lib/types/bot.js +134 -0
- package/lib/types/bot.js.map +1 -0
- package/lib/types/config.d.ts +47 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +53 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/decode.d.ts +36 -0
- package/lib/types/decode.d.ts.map +1 -0
- package/lib/types/decode.js +200 -0
- package/lib/types/decode.js.map +1 -0
- package/lib/types/errors.d.ts +77 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +249 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/index.d.ts +22 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +22 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/internal.d.ts +15 -0
- package/lib/types/internal.d.ts.map +1 -0
- package/lib/types/internal.js +57 -0
- package/lib/types/internal.js.map +1 -0
- package/lib/types/media.d.ts +57 -0
- package/lib/types/media.d.ts.map +1 -0
- package/lib/types/media.js +99 -0
- package/lib/types/media.js.map +1 -0
- package/lib/types/modes/markdown.d.ts +12 -0
- package/lib/types/modes/markdown.d.ts.map +1 -0
- package/lib/types/modes/markdown.js +148 -0
- package/lib/types/modes/markdown.js.map +1 -0
- package/lib/types/modes/shared.d.ts +183 -0
- package/lib/types/modes/shared.d.ts.map +1 -0
- package/lib/types/modes/shared.js +358 -0
- package/lib/types/modes/shared.js.map +1 -0
- package/lib/types/request.d.ts +63 -0
- package/lib/types/request.d.ts.map +1 -0
- package/lib/types/request.js +182 -0
- package/lib/types/request.js.map +1 -0
- package/lib/types/send.d.ts +38 -0
- package/lib/types/send.d.ts.map +1 -0
- package/lib/types/send.js +128 -0
- package/lib/types/send.js.map +1 -0
- package/lib/types/token.d.ts +32 -0
- package/lib/types/token.d.ts.map +1 -0
- package/lib/types/token.js +62 -0
- package/lib/types/token.js.map +1 -0
- package/lib/types/transport/stream.d.ts +89 -0
- package/lib/types/transport/stream.d.ts.map +1 -0
- package/lib/types/transport/stream.js +345 -0
- package/lib/types/transport/stream.js.map +1 -0
- package/lib/types/transport/webhook.d.ts +54 -0
- package/lib/types/transport/webhook.d.ts.map +1 -0
- package/lib/types/transport/webhook.js +159 -0
- package/lib/types/transport/webhook.js.map +1 -0
- package/lib/types/types/index.d.ts +150 -0
- package/lib/types/types/index.d.ts.map +1 -0
- package/lib/types/types/index.js +43 -0
- package/lib/types/types/index.js.map +1 -0
- package/package.json +61 -3
- 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 +211 -0
- package/src/config.ts +88 -0
- package/src/decode.ts +250 -0
- package/src/errors.ts +282 -0
- package/src/index.ts +82 -0
- package/src/internal.ts +60 -0
- package/src/media.ts +149 -0
- package/src/modes/markdown.ts +173 -0
- package/src/modes/shared.ts +473 -0
- package/src/request.ts +262 -0
- package/src/send.ts +195 -0
- package/src/token.ts +72 -0
- package/src/transport/stream.ts +436 -0
- package/src/transport/webhook.ts +198 -0
- package/src/types/index.ts +165 -0
- package/README.md +0 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound calls: one serialized payload becomes one platform message, and one published part becomes one recall.
|
|
3
|
+
*
|
|
4
|
+
* A group message posts to `groupMessages/send` with the open conversation id; a single chat posts to
|
|
5
|
+
* `oToMessages/batchSend` with the recipient's staff id. The response's `processQueryKey` is the only handle a recall
|
|
6
|
+
* accepts, so a send answer without one is reported as an unknown outcome rather than an unpublished one.
|
|
7
|
+
*/
|
|
8
|
+
import type { MessageHandle, SendContext, SentPart, Target } from '@deepseek-ai/cordis-plugin-im-core';
|
|
9
|
+
import type { Config } from './config.ts';
|
|
10
|
+
import type { DingtalkPayload } from './modes/shared.ts';
|
|
11
|
+
import type { Internal } from './internal.ts';
|
|
12
|
+
/** Everything `sendPayload` / `deletePart` need from the adapter. */
|
|
13
|
+
export interface DingtalkSendDeps {
|
|
14
|
+
readonly internal: Internal;
|
|
15
|
+
readonly config: Config;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Send one serialized payload.
|
|
19
|
+
*
|
|
20
|
+
* @param deps - adapter services.
|
|
21
|
+
* @param payload - the serialized draft.
|
|
22
|
+
* @param target - the chat the payload goes to.
|
|
23
|
+
* @param ctx - core send context (part index, cancellation, quote).
|
|
24
|
+
* @returns the published part.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sendPayload(deps: DingtalkSendDeps, payload: DingtalkPayload, target: Target, ctx: SendContext): Promise<SentPart>;
|
|
27
|
+
/**
|
|
28
|
+
* Recall one published message.
|
|
29
|
+
*
|
|
30
|
+
* The recall answers with the ids it accepted; an answer that does not list this part means the message was already
|
|
31
|
+
* recalled, expired past the window, or is not the robot's.
|
|
32
|
+
*
|
|
33
|
+
* @param deps - adapter services.
|
|
34
|
+
* @param part - the published part.
|
|
35
|
+
* @param handle - the message handle (carries the target chat).
|
|
36
|
+
*/
|
|
37
|
+
export declare function deletePart(deps: DingtalkSendDeps, part: SentPart, handle: MessageHandle): Promise<void>;
|
|
38
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/send.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,QAAQ,EACR,MAAM,EACP,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,qEAAqE;AACrE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAkED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,QAAQ,CAAC,CA+CnB;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound calls: one serialized payload becomes one platform message, and one published part becomes one recall.
|
|
3
|
+
*
|
|
4
|
+
* A group message posts to `groupMessages/send` with the open conversation id; a single chat posts to
|
|
5
|
+
* `oToMessages/batchSend` with the recipient's staff id. The response's `processQueryKey` is the only handle a recall
|
|
6
|
+
* accepts, so a send answer without one is reported as an unknown outcome rather than an unpublished one.
|
|
7
|
+
*/
|
|
8
|
+
import { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';
|
|
9
|
+
/** The platform message id of one payload, for the diagnostic record kept in `SentPart.raw`. */
|
|
10
|
+
function mediaIdOf(payload) {
|
|
11
|
+
switch (payload.kind) {
|
|
12
|
+
case 'text':
|
|
13
|
+
return undefined;
|
|
14
|
+
case 'image':
|
|
15
|
+
return payload.msgParam.photoURL;
|
|
16
|
+
case 'audio':
|
|
17
|
+
case 'file':
|
|
18
|
+
return payload.msgParam.mediaId;
|
|
19
|
+
case 'video':
|
|
20
|
+
return payload.msgParam.videoMediaId;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** The published part of one platform message. */
|
|
24
|
+
function partOf(payload, processQueryKey, referrer) {
|
|
25
|
+
// The request already reached the platform, so an answer without a processQueryKey is a published outcome, not a
|
|
26
|
+
// refusal: the message may be on the platform with no handle left to recall it by.
|
|
27
|
+
if (processQueryKey === undefined || processQueryKey === '') {
|
|
28
|
+
throw new PlatformError('invalid', 'dingtalk: the send answer carried no processQueryKey', { published: 'unknown' });
|
|
29
|
+
}
|
|
30
|
+
const mediaId = mediaIdOf(payload);
|
|
31
|
+
return {
|
|
32
|
+
id: processQueryKey,
|
|
33
|
+
kind: 'message',
|
|
34
|
+
time: Date.now(),
|
|
35
|
+
referrer,
|
|
36
|
+
raw: {
|
|
37
|
+
msgKey: payload.msgKey,
|
|
38
|
+
...(mediaId === undefined ? {} : { mediaId }),
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The adapter context one published part reports.
|
|
44
|
+
*
|
|
45
|
+
* The platform has no quoted reply, so the id of the quoted message is recorded for diagnostics only (never rendered).
|
|
46
|
+
*
|
|
47
|
+
* @param conversation - the conversation fields of the send answer.
|
|
48
|
+
* @param ctx - core send context: `quote` is present on every part, and only part 0 records it.
|
|
49
|
+
* @returns the referrer of the published part.
|
|
50
|
+
*/
|
|
51
|
+
function referrerOf(conversation, ctx) {
|
|
52
|
+
return {
|
|
53
|
+
...conversation,
|
|
54
|
+
...(ctx.index === 0 && ctx.quote !== undefined
|
|
55
|
+
? { quotedMessageId: ctx.quote }
|
|
56
|
+
: {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Send one serialized payload.
|
|
61
|
+
*
|
|
62
|
+
* @param deps - adapter services.
|
|
63
|
+
* @param payload - the serialized draft.
|
|
64
|
+
* @param target - the chat the payload goes to.
|
|
65
|
+
* @param ctx - core send context (part index, cancellation, quote).
|
|
66
|
+
* @returns the published part.
|
|
67
|
+
*/
|
|
68
|
+
export async function sendPayload(deps, payload, target, ctx) {
|
|
69
|
+
const msgParam = JSON.stringify(payload.msgParam);
|
|
70
|
+
const robotCode = deps.config.appkey;
|
|
71
|
+
if (target.chat.type === 'direct') {
|
|
72
|
+
const answer = await deps.internal.batchSendOTO({
|
|
73
|
+
robotCode,
|
|
74
|
+
userIds: [target.chat.id],
|
|
75
|
+
msgKey: payload.msgKey,
|
|
76
|
+
msgParam,
|
|
77
|
+
});
|
|
78
|
+
const invalid = answer.invalidStaffIdList ?? [];
|
|
79
|
+
if (invalid.length > 0) {
|
|
80
|
+
throw new PlatformError('invalid', `dingtalk: the recipient cannot receive a robot message (${invalid.join(', ')})`, { published: 'no', code: 'invalidStaffIdList' });
|
|
81
|
+
}
|
|
82
|
+
const flowControlled = answer.flowControlledStaffIdList ?? [];
|
|
83
|
+
if (flowControlled.length > 0) {
|
|
84
|
+
throw new PlatformError('rate-limit', `dingtalk: the recipient is flow-controlled (${flowControlled.join(', ')})`, { published: 'no', code: 'flowControlledStaffIdList' });
|
|
85
|
+
}
|
|
86
|
+
return partOf(payload, answer.processQueryKey, referrerOf({ conversationType: '1', userId: target.chat.id }, ctx));
|
|
87
|
+
}
|
|
88
|
+
// The platform has no topic concept; a `topic` chat is a group chat with a thread id nothing here produces.
|
|
89
|
+
const answer = await deps.internal.orgGroupSend({
|
|
90
|
+
robotCode,
|
|
91
|
+
openConversationId: target.chat.id,
|
|
92
|
+
msgKey: payload.msgKey,
|
|
93
|
+
msgParam,
|
|
94
|
+
});
|
|
95
|
+
return partOf(payload, answer.processQueryKey, referrerOf({ conversationType: '2', openConversationId: target.chat.id }, ctx));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Recall one published message.
|
|
99
|
+
*
|
|
100
|
+
* The recall answers with the ids it accepted; an answer that does not list this part means the message was already
|
|
101
|
+
* recalled, expired past the window, or is not the robot's.
|
|
102
|
+
*
|
|
103
|
+
* @param deps - adapter services.
|
|
104
|
+
* @param part - the published part.
|
|
105
|
+
* @param handle - the message handle (carries the target chat).
|
|
106
|
+
*/
|
|
107
|
+
export async function deletePart(deps, part, handle) {
|
|
108
|
+
const robotCode = deps.config.appkey;
|
|
109
|
+
if (handle.target.chat.type === 'direct') {
|
|
110
|
+
const answer = await deps.internal.batchRecallOTO({
|
|
111
|
+
robotCode,
|
|
112
|
+
processQueryKeys: [part.id],
|
|
113
|
+
});
|
|
114
|
+
if (!(answer.successResult ?? []).includes(part.id)) {
|
|
115
|
+
throw new PlatformError('not-found', `dingtalk: the recall did not accept ${part.id}`, { published: 'no' });
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const answer = await deps.internal.orgGroupRecall({
|
|
120
|
+
robotCode,
|
|
121
|
+
openConversationId: handle.target.chat.id,
|
|
122
|
+
processQueryKeys: [part.id],
|
|
123
|
+
});
|
|
124
|
+
if (!(answer.successResult ?? []).includes(part.id)) {
|
|
125
|
+
throw new PlatformError('not-found', `dingtalk: the recall did not accept ${part.id}`, { published: 'no' });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../src/send.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAiBlE,gGAAgG;AAChG,SAAS,SAAS,CAAC,OAAwB;IACzC,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,SAAS,CAAA;QAClB,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAA;QAClC,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAA;QACjC,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAA;IACxC,CAAC;AACH,CAAC;AAED,kDAAkD;AAClD,SAAS,MAAM,CACb,OAAwB,EACxB,eAAmC,EACnC,QAAgC;IAEhC,iHAAiH;IACjH,mFAAmF;IACnF,IAAI,eAAe,KAAK,SAAS,IAAI,eAAe,KAAK,EAAE,EAAE,CAAC;QAC5D,MAAM,IAAI,aAAa,CACrB,SAAS,EACT,sDAAsD,EACtD,EAAE,SAAS,EAAE,SAAS,EAAE,CACzB,CAAA;IACH,CAAC;IACD,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;IAClC,OAAO;QACL,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;QAChB,QAAQ;QACR,GAAG,EAAE;YACH,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,C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,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,aAAa,CACrB,WAAW,EACX,uCAAuC,IAAI,CAAC,EAAE,EAAE,EAChD,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAA;QACH,CAAC;QACD,OAAM;IACR,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QAChD,SAAS;QACT,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QACzC,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;KAC5B,CAAC,CAAA;IACF,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,aAAa,CACrB,WAAW,EACX,uCAAuC,IAAI,CAAC,EAAE,EAAE,EAChD,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The application `accessToken` every `/v1.0/*` request carries.
|
|
3
|
+
*
|
|
4
|
+
* The platform mints one token per application with a two-hour lifetime, and warns against requesting it often, so the
|
|
5
|
+
* cache is lazy (no background timer) and single-flight: concurrent callers share one request. A refusal classified as
|
|
6
|
+
* an authentication failure invalidates the cache and the caller asks again.
|
|
7
|
+
*/
|
|
8
|
+
/** One answer of `POST /v1.0/oauth2/accessToken`. */
|
|
9
|
+
export interface DingtalkAccessToken {
|
|
10
|
+
accessToken?: string;
|
|
11
|
+
expireIn?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class AccessTokenCache {
|
|
14
|
+
private readonly mint;
|
|
15
|
+
private readonly now;
|
|
16
|
+
private current;
|
|
17
|
+
private inflight;
|
|
18
|
+
/**
|
|
19
|
+
* @param mint - requests a new token from the platform.
|
|
20
|
+
* @param now - clock of the expiry check; tests replace it.
|
|
21
|
+
*/
|
|
22
|
+
constructor(mint: () => Promise<DingtalkAccessToken>, now?: () => number);
|
|
23
|
+
/** The cached token, requesting one when none is cached or the cached one is near its expiry. */
|
|
24
|
+
get(): Promise<string>;
|
|
25
|
+
/** Drop the cached token, so the next {@link get} asks the platform again. */
|
|
26
|
+
invalidate(): void;
|
|
27
|
+
/** The token in the cache, when one is cached; for diagnostics only. */
|
|
28
|
+
get cached(): string | undefined;
|
|
29
|
+
/** Whether a token request is in flight, so the transport can leave the minting request itself unauthenticated. */
|
|
30
|
+
get minting(): boolean;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAKD,qBAAa,gBAAgB;IASzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IATtB,OAAO,CAAC,OAAO,CAAkD;IACjE,OAAO,CAAC,QAAQ,CAA6B;IAE7C;;;OAGG;gBAEgB,IAAI,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,EACxC,GAAG,GAAE,MAAM,MAAiB;IAG/C,iGAAiG;IAC3F,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;IA0B5B,8EAA8E;IAC9E,UAAU,IAAI,IAAI;IAIlB,wEAAwE;IACxE,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,mHAAmH;IACnH,IAAI,OAAO,IAAI,OAAO,CAErB;CACF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The application `accessToken` every `/v1.0/*` request carries.
|
|
3
|
+
*
|
|
4
|
+
* The platform mints one token per application with a two-hour lifetime, and warns against requesting it often, so the
|
|
5
|
+
* cache is lazy (no background timer) and single-flight: concurrent callers share one request. A refusal classified as
|
|
6
|
+
* an authentication failure invalidates the cache and the caller asks again.
|
|
7
|
+
*/
|
|
8
|
+
/** Seconds shaved off the announced lifetime, so a request never races the expiry. */
|
|
9
|
+
const REFRESH_MARGIN_SECONDS = 300;
|
|
10
|
+
export class AccessTokenCache {
|
|
11
|
+
mint;
|
|
12
|
+
now;
|
|
13
|
+
current;
|
|
14
|
+
inflight;
|
|
15
|
+
/**
|
|
16
|
+
* @param mint - requests a new token from the platform.
|
|
17
|
+
* @param now - clock of the expiry check; tests replace it.
|
|
18
|
+
*/
|
|
19
|
+
constructor(mint, now = Date.now) {
|
|
20
|
+
this.mint = mint;
|
|
21
|
+
this.now = now;
|
|
22
|
+
}
|
|
23
|
+
/** The cached token, requesting one when none is cached or the cached one is near its expiry. */
|
|
24
|
+
async get() {
|
|
25
|
+
const current = this.current;
|
|
26
|
+
if (current !== undefined && this.now() < current.expiresAt)
|
|
27
|
+
return current.value;
|
|
28
|
+
this.inflight ??= this.mint()
|
|
29
|
+
.then((answer) => {
|
|
30
|
+
if (answer.accessToken === undefined || answer.accessToken === '') {
|
|
31
|
+
throw new Error('dingtalk: getAccessToken answered without a token');
|
|
32
|
+
}
|
|
33
|
+
const expireIn = answer.expireIn;
|
|
34
|
+
// Without a usable lifetime the token is still returned to this round of callers but not cached: a `NaN`
|
|
35
|
+
// deadline would silently re-request on every call.
|
|
36
|
+
if (typeof expireIn === 'number' && Number.isFinite(expireIn)) {
|
|
37
|
+
this.current = {
|
|
38
|
+
value: answer.accessToken,
|
|
39
|
+
expiresAt: this.now() + (expireIn - REFRESH_MARGIN_SECONDS) * 1_000,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return answer.accessToken;
|
|
43
|
+
})
|
|
44
|
+
.finally(() => {
|
|
45
|
+
this.inflight = undefined;
|
|
46
|
+
});
|
|
47
|
+
return await this.inflight;
|
|
48
|
+
}
|
|
49
|
+
/** Drop the cached token, so the next {@link get} asks the platform again. */
|
|
50
|
+
invalidate() {
|
|
51
|
+
this.current = undefined;
|
|
52
|
+
}
|
|
53
|
+
/** The token in the cache, when one is cached; for diagnostics only. */
|
|
54
|
+
get cached() {
|
|
55
|
+
return this.current?.value;
|
|
56
|
+
}
|
|
57
|
+
/** Whether a token request is in flight, so the transport can leave the minting request itself unauthenticated. */
|
|
58
|
+
get minting() {
|
|
59
|
+
return this.inflight !== undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,sFAAsF;AACtF,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAElC,MAAM,OAAO,gBAAgB;IASR;IACA;IATX,OAAO,CAAkD;IACzD,QAAQ,CAA6B;IAE7C;;;OAGG;IACH,YACmB,IAAwC,EACxC,MAAoB,IAAI,CAAC,GAAG;QAD5B,SAAI,GAAJ,IAAI,CAAoC;QACxC,QAAG,GAAH,GAAG,CAAyB;IAC5C,CAAC;IAEJ,iGAAiG;IACjG,KAAK,CAAC,GAAG;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC5B,IAAI,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,SAAS;YACzD,OAAO,OAAO,CAAC,KAAK,CAAA;QACtB,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,IAAI,EAAE;aAC1B,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,IAAI,MAAM,CAAC,WAAW,KAAK,EAAE,EAAE,CAAC;gBAClE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;YACtE,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;YAChC,yGAAyG;YACzG,oDAAoD;YACpD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9D,IAAI,CAAC,OAAO,GAAG;oBACb,KAAK,EAAE,MAAM,CAAC,WAAW;oBACzB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,GAAG,sBAAsB,CAAC,GAAG,KAAK;iBACpE,CAAA;YACH,CAAC;YACD,OAAO,MAAM,CAAC,WAAW,CAAA;QAC3B,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;QAC3B,CAAC,CAAC,CAAA;QACJ,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAA;IAC5B,CAAC;IAED,8EAA8E;IAC9E,UAAU;QACR,IAAI,CAAC,OAAO,GAAG,SAAS,CAAA;IAC1B,CAAC;IAED,wEAAwE;IACxE,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,KAAK,CAAA;IAC5B,CAAC;IAED,mHAAmH;IACnH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAA;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream Mode transport (`protocol: 'ws'`).
|
|
3
|
+
*
|
|
4
|
+
* The adapter registers a fresh connection before every dial: the platform's ticket is single-use and expires within 90
|
|
5
|
+
* seconds, so it can never be cached. The loop dials again forever — `ws.retryTimes` is a fast-retry budget, not a
|
|
6
|
+
* give-up count — and only a credential refusal stops it.
|
|
7
|
+
*
|
|
8
|
+
* A callback frame is acknowledged only after `bot.receive` accepted the message (`Bot.receive` waits for the intake
|
|
9
|
+
* listeners), so an acknowledgement always means the message is stored. Robot messages are fire-and-forget: the platform
|
|
10
|
+
* does not redeliver an acknowledged frame.
|
|
11
|
+
*/
|
|
12
|
+
import type { DingtalkBot } from '../bot.ts';
|
|
13
|
+
/** The one topic this adapter subscribes to. */
|
|
14
|
+
export declare const CALLBACK_TOPIC = "/v1.0/im/bot/messages/get";
|
|
15
|
+
/**
|
|
16
|
+
* The `ua` of the connection registration (`name-sdk-lang/version`). Keep the version in step with `package.json`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CLIENT_USER_AGENT = "dsh-im-more/dingtalk/0.1.0";
|
|
19
|
+
/** The code of a protocol acknowledgement. */
|
|
20
|
+
export type AckCode = 200 | 404 | 500;
|
|
21
|
+
/** The acknowledgement the protocol expects for one frame. */
|
|
22
|
+
export interface DingtalkAck {
|
|
23
|
+
code: AckCode;
|
|
24
|
+
headers: {
|
|
25
|
+
messageId?: string;
|
|
26
|
+
contentType: string;
|
|
27
|
+
};
|
|
28
|
+
message: string;
|
|
29
|
+
data?: string;
|
|
30
|
+
}
|
|
31
|
+
/** One frame the platform pushes. `data` is a JSON string, so a callback body is parsed a second time. */
|
|
32
|
+
export interface DingtalkFrame {
|
|
33
|
+
specVersion?: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
headers?: {
|
|
36
|
+
topic?: string;
|
|
37
|
+
messageId?: string;
|
|
38
|
+
contentType?: string;
|
|
39
|
+
time?: string;
|
|
40
|
+
};
|
|
41
|
+
data?: string;
|
|
42
|
+
}
|
|
43
|
+
/** The answer of the connection registration. */
|
|
44
|
+
export interface DingtalkConnection {
|
|
45
|
+
endpoint?: string;
|
|
46
|
+
ticket?: string;
|
|
47
|
+
}
|
|
48
|
+
/** The Stream Mode client of one bot. */
|
|
49
|
+
export declare class DingtalkStream {
|
|
50
|
+
private readonly bot;
|
|
51
|
+
private controller;
|
|
52
|
+
private running;
|
|
53
|
+
private socket;
|
|
54
|
+
/** Set by a `disconnect` frame: the redial follows at once instead of waiting out the retry interval. */
|
|
55
|
+
private redialImmediately;
|
|
56
|
+
constructor(bot: DingtalkBot);
|
|
57
|
+
/**
|
|
58
|
+
* Start the reconnect loop.
|
|
59
|
+
*
|
|
60
|
+
* Returning before the first dial is deliberate: `Bot.start` awaits `connect()`, and waiting here would hold plugin
|
|
61
|
+
* initialization for as long as the platform is unreachable.
|
|
62
|
+
*/
|
|
63
|
+
start(): Promise<void>;
|
|
64
|
+
/** Stop the loop and wait for it to unwind. */
|
|
65
|
+
stop(): Promise<void>;
|
|
66
|
+
private loop;
|
|
67
|
+
/** Delay before the next dial: the fast interval while the failure budget lasts, the lazy one after it. */
|
|
68
|
+
private intervalOf;
|
|
69
|
+
/** Register one connection and give back the socket URL its single-use ticket belongs to. */
|
|
70
|
+
private openUrl;
|
|
71
|
+
/** Dial the connection URL and resolve once the socket is open. */
|
|
72
|
+
private dial;
|
|
73
|
+
/** Serve one open connection until it closes. */
|
|
74
|
+
private accept;
|
|
75
|
+
/** Dispatch one received frame: a system notice, a callback, or a topic this adapter does not subscribe to. */
|
|
76
|
+
private handleFrame;
|
|
77
|
+
/**
|
|
78
|
+
* Hand one callback frame to intake, then acknowledge it.
|
|
79
|
+
*
|
|
80
|
+
* The acknowledgement goes out after `receive` resolved: the host stores a message before `receive` returns, so an
|
|
81
|
+
* acknowledged frame is a stored message. A failed intake is only logged, because no acknowledgement means the
|
|
82
|
+
* platform will not redeliver anyway (robot messages are fire-and-forget).
|
|
83
|
+
*/
|
|
84
|
+
private deliver;
|
|
85
|
+
/** Send one acknowledgement; a socket that already closed cannot carry it, which is only logged. */
|
|
86
|
+
private acknowledge;
|
|
87
|
+
private closeSocket;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/transport/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,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