@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.
Files changed (292) hide show
  1. package/LICENSE +21 -0
  2. package/cordis.patch.yml +11 -0
  3. package/lib/index.js +2765 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/types/api/alitrip.d.ts +397 -0
  6. package/lib/types/api/alitrip.d.ts.map +1 -0
  7. package/lib/types/api/alitrip.js +21 -0
  8. package/lib/types/api/alitrip.js.map +1 -0
  9. package/lib/types/api/attendance.d.ts +63 -0
  10. package/lib/types/api/attendance.d.ts.map +1 -0
  11. package/lib/types/api/attendance.js +8 -0
  12. package/lib/types/api/attendance.js.map +1 -0
  13. package/lib/types/api/badge.d.ts +233 -0
  14. package/lib/types/api/badge.d.ts.map +1 -0
  15. package/lib/types/api/badge.js +19 -0
  16. package/lib/types/api/badge.js.map +1 -0
  17. package/lib/types/api/blackboard.d.ts +17 -0
  18. package/lib/types/api/blackboard.d.ts.map +1 -0
  19. package/lib/types/api/blackboard.js +6 -0
  20. package/lib/types/api/blackboard.js.map +1 -0
  21. package/lib/types/api/calendar.d.ts +621 -0
  22. package/lib/types/api/calendar.d.ts.map +1 -0
  23. package/lib/types/api/calendar.js +57 -0
  24. package/lib/types/api/calendar.js.map +1 -0
  25. package/lib/types/api/card.d.ts +185 -0
  26. package/lib/types/api/card.d.ts.map +1 -0
  27. package/lib/types/api/card.js +13 -0
  28. package/lib/types/api/card.js.map +1 -0
  29. package/lib/types/api/conference.d.ts +404 -0
  30. package/lib/types/api/conference.d.ts.map +1 -0
  31. package/lib/types/api/conference.js +60 -0
  32. package/lib/types/api/conference.js.map +1 -0
  33. package/lib/types/api/connector.d.ts +79 -0
  34. package/lib/types/api/connector.d.ts.map +1 -0
  35. package/lib/types/api/connector.js +8 -0
  36. package/lib/types/api/connector.js.map +1 -0
  37. package/lib/types/api/contact.d.ts +40 -0
  38. package/lib/types/api/contact.d.ts.map +1 -0
  39. package/lib/types/api/contact.js +9 -0
  40. package/lib/types/api/contact.js.map +1 -0
  41. package/lib/types/api/convFile.d.ts +135 -0
  42. package/lib/types/api/convFile.d.ts.map +1 -0
  43. package/lib/types/api/convFile.js +9 -0
  44. package/lib/types/api/convFile.js.map +1 -0
  45. package/lib/types/api/crm.d.ts +662 -0
  46. package/lib/types/api/crm.d.ts.map +1 -0
  47. package/lib/types/api/crm.js +59 -0
  48. package/lib/types/api/crm.js.map +1 -0
  49. package/lib/types/api/customerService.d.ts +128 -0
  50. package/lib/types/api/customerService.d.ts.map +1 -0
  51. package/lib/types/api/customerService.js +13 -0
  52. package/lib/types/api/customerService.js.map +1 -0
  53. package/lib/types/api/datacenter.d.ts +506 -0
  54. package/lib/types/api/datacenter.d.ts.map +1 -0
  55. package/lib/types/api/datacenter.js +61 -0
  56. package/lib/types/api/datacenter.js.map +1 -0
  57. package/lib/types/api/devicemng.d.ts +161 -0
  58. package/lib/types/api/devicemng.d.ts.map +1 -0
  59. package/lib/types/api/devicemng.js +20 -0
  60. package/lib/types/api/devicemng.js.map +1 -0
  61. package/lib/types/api/diot.d.ts +13 -0
  62. package/lib/types/api/diot.d.ts.map +1 -0
  63. package/lib/types/api/diot.js +4 -0
  64. package/lib/types/api/diot.js.map +1 -0
  65. package/lib/types/api/doc.d.ts +141 -0
  66. package/lib/types/api/doc.d.ts.map +1 -0
  67. package/lib/types/api/doc.js +27 -0
  68. package/lib/types/api/doc.js.map +1 -0
  69. package/lib/types/api/drive.d.ts +88 -0
  70. package/lib/types/api/drive.d.ts.map +1 -0
  71. package/lib/types/api/drive.js +11 -0
  72. package/lib/types/api/drive.js.map +1 -0
  73. package/lib/types/api/edu.d.ts +23 -0
  74. package/lib/types/api/edu.d.ts.map +1 -0
  75. package/lib/types/api/edu.js +4 -0
  76. package/lib/types/api/edu.js.map +1 -0
  77. package/lib/types/api/esign.d.ts +34 -0
  78. package/lib/types/api/esign.d.ts.map +1 -0
  79. package/lib/types/api/esign.js +7 -0
  80. package/lib/types/api/esign.js.map +1 -0
  81. package/lib/types/api/exclusive.d.ts +304 -0
  82. package/lib/types/api/exclusive.d.ts.map +1 -0
  83. package/lib/types/api/exclusive.js +27 -0
  84. package/lib/types/api/exclusive.js.map +1 -0
  85. package/lib/types/api/h3yun.d.ts +438 -0
  86. package/lib/types/api/h3yun.d.ts.map +1 -0
  87. package/lib/types/api/h3yun.js +33 -0
  88. package/lib/types/api/h3yun.js.map +1 -0
  89. package/lib/types/api/hrm.d.ts +215 -0
  90. package/lib/types/api/hrm.d.ts.map +1 -0
  91. package/lib/types/api/hrm.js +20 -0
  92. package/lib/types/api/hrm.js.map +1 -0
  93. package/lib/types/api/im.d.ts +773 -0
  94. package/lib/types/api/im.d.ts.map +1 -0
  95. package/lib/types/api/im.js +72 -0
  96. package/lib/types/api/im.js.map +1 -0
  97. package/lib/types/api/industry.d.ts +118 -0
  98. package/lib/types/api/industry.d.ts.map +1 -0
  99. package/lib/types/api/industry.js +14 -0
  100. package/lib/types/api/industry.js.map +1 -0
  101. package/lib/types/api/jzcrm.d.ts +255 -0
  102. package/lib/types/api/jzcrm.d.ts.map +1 -0
  103. package/lib/types/api/jzcrm.js +18 -0
  104. package/lib/types/api/jzcrm.js.map +1 -0
  105. package/lib/types/api/link.d.ts +73 -0
  106. package/lib/types/api/link.d.ts.map +1 -0
  107. package/lib/types/api/link.js +9 -0
  108. package/lib/types/api/link.js.map +1 -0
  109. package/lib/types/api/live.d.ts +132 -0
  110. package/lib/types/api/live.d.ts.map +1 -0
  111. package/lib/types/api/live.js +13 -0
  112. package/lib/types/api/live.js.map +1 -0
  113. package/lib/types/api/microApp.d.ts +240 -0
  114. package/lib/types/api/microApp.d.ts.map +1 -0
  115. package/lib/types/api/microApp.js +29 -0
  116. package/lib/types/api/microApp.js.map +1 -0
  117. package/lib/types/api/oapi.d.ts +3362 -0
  118. package/lib/types/api/oapi.d.ts.map +1 -0
  119. package/lib/types/api/oapi.js +247 -0
  120. package/lib/types/api/oapi.js.map +1 -0
  121. package/lib/types/api/oauth2.d.ts +115 -0
  122. package/lib/types/api/oauth2.d.ts.map +1 -0
  123. package/lib/types/api/oauth2.js +12 -0
  124. package/lib/types/api/oauth2.js.map +1 -0
  125. package/lib/types/api/pedia.d.ts +186 -0
  126. package/lib/types/api/pedia.d.ts.map +1 -0
  127. package/lib/types/api/pedia.js +13 -0
  128. package/lib/types/api/pedia.js.map +1 -0
  129. package/lib/types/api/project.d.ts +1119 -0
  130. package/lib/types/api/project.d.ts.map +1 -0
  131. package/lib/types/api/project.js +135 -0
  132. package/lib/types/api/project.js.map +1 -0
  133. package/lib/types/api/resident.d.ts +107 -0
  134. package/lib/types/api/resident.d.ts.map +1 -0
  135. package/lib/types/api/resident.js +10 -0
  136. package/lib/types/api/resident.js.map +1 -0
  137. package/lib/types/api/robot.d.ts +256 -0
  138. package/lib/types/api/robot.d.ts.map +1 -0
  139. package/lib/types/api/robot.js +21 -0
  140. package/lib/types/api/robot.js.map +1 -0
  141. package/lib/types/api/rooms.d.ts +256 -0
  142. package/lib/types/api/rooms.d.ts.map +1 -0
  143. package/lib/types/api/rooms.js +23 -0
  144. package/lib/types/api/rooms.js.map +1 -0
  145. package/lib/types/api/serviceGroup.d.ts +176 -0
  146. package/lib/types/api/serviceGroup.d.ts.map +1 -0
  147. package/lib/types/api/serviceGroup.js +15 -0
  148. package/lib/types/api/serviceGroup.js.map +1 -0
  149. package/lib/types/api/storage.d.ts +1241 -0
  150. package/lib/types/api/storage.d.ts.map +1 -0
  151. package/lib/types/api/storage.js +128 -0
  152. package/lib/types/api/storage.js.map +1 -0
  153. package/lib/types/api/swform.d.ts +71 -0
  154. package/lib/types/api/swform.d.ts.map +1 -0
  155. package/lib/types/api/swform.js +8 -0
  156. package/lib/types/api/swform.js.map +1 -0
  157. package/lib/types/api/todo.d.ts +169 -0
  158. package/lib/types/api/todo.d.ts.map +1 -0
  159. package/lib/types/api/todo.js +16 -0
  160. package/lib/types/api/todo.js.map +1 -0
  161. package/lib/types/api/wiki.d.ts +195 -0
  162. package/lib/types/api/wiki.d.ts.map +1 -0
  163. package/lib/types/api/wiki.js +11 -0
  164. package/lib/types/api/wiki.js.map +1 -0
  165. package/lib/types/api/workbench.d.ts +46 -0
  166. package/lib/types/api/workbench.d.ts.map +1 -0
  167. package/lib/types/api/workbench.js +14 -0
  168. package/lib/types/api/workbench.js.map +1 -0
  169. package/lib/types/api/yida.d.ts +1838 -0
  170. package/lib/types/api/yida.d.ts.map +1 -0
  171. package/lib/types/api/yida.js +103 -0
  172. package/lib/types/api/yida.js.map +1 -0
  173. package/lib/types/bot.d.ts +62 -0
  174. package/lib/types/bot.d.ts.map +1 -0
  175. package/lib/types/bot.js +134 -0
  176. package/lib/types/bot.js.map +1 -0
  177. package/lib/types/config.d.ts +47 -0
  178. package/lib/types/config.d.ts.map +1 -0
  179. package/lib/types/config.js +53 -0
  180. package/lib/types/config.js.map +1 -0
  181. package/lib/types/decode.d.ts +36 -0
  182. package/lib/types/decode.d.ts.map +1 -0
  183. package/lib/types/decode.js +200 -0
  184. package/lib/types/decode.js.map +1 -0
  185. package/lib/types/errors.d.ts +77 -0
  186. package/lib/types/errors.d.ts.map +1 -0
  187. package/lib/types/errors.js +249 -0
  188. package/lib/types/errors.js.map +1 -0
  189. package/lib/types/index.d.ts +22 -0
  190. package/lib/types/index.d.ts.map +1 -0
  191. package/lib/types/index.js +22 -0
  192. package/lib/types/index.js.map +1 -0
  193. package/lib/types/internal.d.ts +15 -0
  194. package/lib/types/internal.d.ts.map +1 -0
  195. package/lib/types/internal.js +57 -0
  196. package/lib/types/internal.js.map +1 -0
  197. package/lib/types/media.d.ts +57 -0
  198. package/lib/types/media.d.ts.map +1 -0
  199. package/lib/types/media.js +99 -0
  200. package/lib/types/media.js.map +1 -0
  201. package/lib/types/modes/markdown.d.ts +12 -0
  202. package/lib/types/modes/markdown.d.ts.map +1 -0
  203. package/lib/types/modes/markdown.js +148 -0
  204. package/lib/types/modes/markdown.js.map +1 -0
  205. package/lib/types/modes/shared.d.ts +183 -0
  206. package/lib/types/modes/shared.d.ts.map +1 -0
  207. package/lib/types/modes/shared.js +358 -0
  208. package/lib/types/modes/shared.js.map +1 -0
  209. package/lib/types/request.d.ts +63 -0
  210. package/lib/types/request.d.ts.map +1 -0
  211. package/lib/types/request.js +182 -0
  212. package/lib/types/request.js.map +1 -0
  213. package/lib/types/send.d.ts +38 -0
  214. package/lib/types/send.d.ts.map +1 -0
  215. package/lib/types/send.js +128 -0
  216. package/lib/types/send.js.map +1 -0
  217. package/lib/types/token.d.ts +32 -0
  218. package/lib/types/token.d.ts.map +1 -0
  219. package/lib/types/token.js +62 -0
  220. package/lib/types/token.js.map +1 -0
  221. package/lib/types/transport/stream.d.ts +89 -0
  222. package/lib/types/transport/stream.d.ts.map +1 -0
  223. package/lib/types/transport/stream.js +345 -0
  224. package/lib/types/transport/stream.js.map +1 -0
  225. package/lib/types/transport/webhook.d.ts +54 -0
  226. package/lib/types/transport/webhook.d.ts.map +1 -0
  227. package/lib/types/transport/webhook.js +159 -0
  228. package/lib/types/transport/webhook.js.map +1 -0
  229. package/lib/types/types/index.d.ts +150 -0
  230. package/lib/types/types/index.d.ts.map +1 -0
  231. package/lib/types/types/index.js +43 -0
  232. package/lib/types/types/index.js.map +1 -0
  233. package/package.json +61 -3
  234. package/src/api/.eslintrc.yml +2 -0
  235. package/src/api/alitrip.ts +467 -0
  236. package/src/api/attendance.ts +81 -0
  237. package/src/api/badge.ts +285 -0
  238. package/src/api/blackboard.ts +28 -0
  239. package/src/api/calendar.ts +817 -0
  240. package/src/api/card.ts +215 -0
  241. package/src/api/conference.ts +561 -0
  242. package/src/api/connector.ts +97 -0
  243. package/src/api/contact.ts +56 -0
  244. package/src/api/convFile.ts +166 -0
  245. package/src/api/crm.ts +830 -0
  246. package/src/api/customerService.ts +156 -0
  247. package/src/api/datacenter.ts +672 -0
  248. package/src/api/devicemng.ts +202 -0
  249. package/src/api/diot.ts +19 -0
  250. package/src/api/doc.ts +232 -0
  251. package/src/api/drive.ts +109 -0
  252. package/src/api/edu.ts +30 -0
  253. package/src/api/esign.ts +44 -0
  254. package/src/api/exclusive.ts +372 -0
  255. package/src/api/h3yun.ts +537 -0
  256. package/src/api/hrm.ts +272 -0
  257. package/src/api/im.ts +978 -0
  258. package/src/api/industry.ts +153 -0
  259. package/src/api/jzcrm.ts +304 -0
  260. package/src/api/link.ts +94 -0
  261. package/src/api/live.ts +162 -0
  262. package/src/api/microApp.ts +309 -0
  263. package/src/api/oapi.ts +4083 -0
  264. package/src/api/oauth2.ts +146 -0
  265. package/src/api/pedia.ts +222 -0
  266. package/src/api/project.ts +1519 -0
  267. package/src/api/resident.ts +133 -0
  268. package/src/api/robot.ts +326 -0
  269. package/src/api/rooms.ts +334 -0
  270. package/src/api/serviceGroup.ts +216 -0
  271. package/src/api/storage.ts +1701 -0
  272. package/src/api/swform.ts +94 -0
  273. package/src/api/todo.ts +220 -0
  274. package/src/api/wiki.ts +231 -0
  275. package/src/api/workbench.ts +73 -0
  276. package/src/api/yida.ts +2165 -0
  277. package/src/bot.ts +211 -0
  278. package/src/config.ts +88 -0
  279. package/src/decode.ts +250 -0
  280. package/src/errors.ts +282 -0
  281. package/src/index.ts +82 -0
  282. package/src/internal.ts +60 -0
  283. package/src/media.ts +149 -0
  284. package/src/modes/markdown.ts +173 -0
  285. package/src/modes/shared.ts +473 -0
  286. package/src/request.ts +262 -0
  287. package/src/send.ts +195 -0
  288. package/src/token.ts +72 -0
  289. package/src/transport/stream.ts +436 -0
  290. package/src/transport/webhook.ts +198 -0
  291. package/src/types/index.ts +165 -0
  292. package/README.md +0 -3
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Inbound decoding: one bot-message callback body becomes an intake `Session`.
3
+ *
4
+ * DingTalk pushes six `msgtype`s to a robot (`text`, `richText`, `picture`, `file`, `audio`, `video`); all become one
5
+ * message event. Media elements name the bot's own `satori:` route rather than the platform's signed download URL, so a
6
+ * message read after the URL expired still resolves (the route exchanges the `downloadCode` per read).
7
+ */
8
+ import { h, normalize } from '@deepseek-ai/cordis-plugin-im-core';
9
+ import { mediaSource } from "./media.js";
10
+ /** The `errorCode` of a delivery failure body, which carries no message content. */
11
+ function errorCodeOf(body) {
12
+ return 'errorCode' in body ? body.errorCode : undefined;
13
+ }
14
+ /** The `errorMessage` of a delivery failure body. */
15
+ function errorMessageOf(body) {
16
+ return 'errorMessage' in body ? body.errorMessage : undefined;
17
+ }
18
+ /**
19
+ * Chat of one callback.
20
+ *
21
+ * A group message names its open conversation; a single chat has no conversation id on the send side, so the chat is
22
+ * the staff id the single-chat send endpoint addresses.
23
+ *
24
+ * @param body - the callback body.
25
+ * @param senderId - resolved sender id.
26
+ * @returns the chat reference.
27
+ */
28
+ function chatOf(body, senderId) {
29
+ if (body.conversationType === '1')
30
+ return { id: senderId, type: 'direct' };
31
+ return {
32
+ id: body.conversationId,
33
+ type: 'group',
34
+ ...(body.conversationTitle === undefined
35
+ ? {}
36
+ : { name: body.conversationTitle }),
37
+ };
38
+ }
39
+ /** The sender of one callback: `senderStaffId` exists only for an internal chat of a published robot. */
40
+ function senderOf(body) {
41
+ return {
42
+ id: body.senderStaffId || body.senderId,
43
+ ...(body.senderNick ? { name: body.senderNick } : {}),
44
+ isBot: false,
45
+ role: body.isAdmin === true ? 'admin' : 'member',
46
+ };
47
+ }
48
+ /** Mentions of one callback: a group message reaches a robot only when it mentions it. */
49
+ function mentionsOf(body, chat) {
50
+ const users = [];
51
+ for (const at of body.atUsers ?? []) {
52
+ const id = at.staffId || at.dingtalkId;
53
+ if (id)
54
+ users.push({ id });
55
+ }
56
+ // The platform pushes a group message only when the robot is mentioned, and a single chat never needs a mention.
57
+ return { self: chat.type === 'group', all: false, users };
58
+ }
59
+ /** The `createAt` timestamp, which the platform sends as a string in the documented sample and as a number in practice. */
60
+ function timeOf(body) {
61
+ const time = Number(body.createAt);
62
+ return Number.isFinite(time) ? time : Date.now();
63
+ }
64
+ /**
65
+ * One media element of a message, with the source the host reads it through.
66
+ *
67
+ * @param bot - the receiving adapter.
68
+ * @param body - the callback body the element comes from.
69
+ * @param code - the platform `downloadCode` of this media item.
70
+ * @param index - position of the media element in the message content.
71
+ * @returns the element; its `src` carries the code, so the host can resolve it without adapter state.
72
+ */
73
+ function mediaElement(bot, body, code, index) {
74
+ const src = mediaSource(bot, body.msgId, index, code);
75
+ switch (body.msgtype) {
76
+ case 'picture':
77
+ return h('img', { src });
78
+ case 'file':
79
+ return h('file', {
80
+ src,
81
+ ...(body.content.fileName ? { name: body.content.fileName } : {}),
82
+ });
83
+ case 'audio':
84
+ return h('audio', {
85
+ src,
86
+ ...(body.content.duration === undefined
87
+ ? {}
88
+ : { duration: body.content.duration }),
89
+ });
90
+ case 'video':
91
+ return h('video', {
92
+ src,
93
+ ...(body.content.duration === undefined
94
+ ? {}
95
+ : { duration: body.content.duration }),
96
+ });
97
+ default:
98
+ return h('img', { src });
99
+ }
100
+ }
101
+ /** The content tree of one callback, never empty. */
102
+ function decodeContent(bot, body) {
103
+ const nodes = [];
104
+ let index = 0;
105
+ switch (body.msgtype) {
106
+ case 'text':
107
+ nodes.push(h.text(body.text.content));
108
+ break;
109
+ case 'richText': {
110
+ for (const item of body.content.richText) {
111
+ // A rich-text item is either a text run or a picture; the picture may arrive under either field name.
112
+ if (item.text) {
113
+ nodes.push(h.text(item.text));
114
+ continue;
115
+ }
116
+ const code = item.downloadCode || item.pictureDownloadCode;
117
+ if (!code)
118
+ continue;
119
+ nodes.push(mediaElement(bot, body, code, index));
120
+ index += 1;
121
+ }
122
+ break;
123
+ }
124
+ case 'picture':
125
+ case 'file':
126
+ case 'audio':
127
+ case 'video': {
128
+ if (body.content.downloadCode) {
129
+ nodes.push(mediaElement(bot, body, body.content.downloadCode, 0));
130
+ }
131
+ // A voice message carries the platform's own transcription; dropping it would lose the message's content.
132
+ if (body.msgtype === 'audio' && body.content.recognition) {
133
+ nodes.push(h.text(body.content.recognition));
134
+ }
135
+ break;
136
+ }
137
+ default:
138
+ // An `msgtype` beyond the six is not decoded; `<raw>` keeps the body for diagnostics.
139
+ break;
140
+ }
141
+ if (nodes.length === 0) {
142
+ nodes.push(h('raw', { platform: 'dingtalk', type: body.msgtype, data: body }, h.text('')));
143
+ }
144
+ return normalize(nodes);
145
+ }
146
+ /**
147
+ * Decode one delivered callback body.
148
+ *
149
+ * A quota or delivery failure carries no message content (`errorCode: 20001` after the monthly allowance is spent), so
150
+ * it is logged instead of being decoded into an empty message.
151
+ *
152
+ * @param bot - the receiving adapter (its routes and identity are used by the decoded elements).
153
+ * @param body - the callback body of either transport.
154
+ * @returns the session to publish, or undefined for a body this adapter does not turn into a message.
155
+ */
156
+ export function decodeMessage(bot, body) {
157
+ if (typeof body !== 'object' || body === null)
158
+ return undefined;
159
+ const errorCode = errorCodeOf(body);
160
+ if (errorCode !== undefined) {
161
+ bot.ctx.logger.error('dingtalk quota or delivery error: %s %s', String(errorCode), String(errorMessageOf(body) ?? ''));
162
+ return undefined;
163
+ }
164
+ const sender = senderOf(body);
165
+ const chat = chatOf(body, sender.id);
166
+ const content = decodeContent(bot, body);
167
+ if (body.robotCode && body.robotCode !== bot.config.appkey) {
168
+ // An authorized third-party application has a robot code of its own; v1 supports internal applications only.
169
+ bot.ctx.logger.warn('dingtalk: the callback names robotCode %s, which differs from the configured appkey', body.robotCode);
170
+ }
171
+ const referrer = {
172
+ conversationId: body.conversationId,
173
+ conversationType: body.conversationType,
174
+ msgId: body.msgId,
175
+ chatbotUserId: body.chatbotUserId,
176
+ ...(body.sessionWebhook ? { sessionWebhook: body.sessionWebhook } : {}),
177
+ ...(body.sessionWebhookExpiredTime
178
+ ? { sessionWebhookExpiredTime: body.sessionWebhookExpiredTime }
179
+ : {}),
180
+ };
181
+ const message = {
182
+ id: body.msgId,
183
+ chat,
184
+ sender,
185
+ content,
186
+ mentions: mentionsOf(body, chat),
187
+ time: timeOf(body),
188
+ referrer,
189
+ raw: body,
190
+ };
191
+ return bot.session({
192
+ type: 'message',
193
+ id: body.msgId,
194
+ timestamp: message.time,
195
+ message,
196
+ referrer,
197
+ raw: body,
198
+ });
199
+ }
200
+ //# sourceMappingURL=decode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/decode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AASjE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAkBxC,oFAAoF;AACpF,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;AACzD,CAAC;AAED,qDAAqD;AACrD,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAA;AAC/D,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,MAAM,CAAC,IAAa,EAAE,QAAgB;IAC7C,IAAI,IAAI,CAAC,gBAAgB,KAAK,GAAG;QAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;IAC1E,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,cAAc;QACvB,IAAI,EAAE,OAAO;QACb,GAAG,CAAC,IAAI,CAAC,iBAAiB,KAAK,SAAS;YACtC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;KACtC,CAAA;AACH,CAAC;AAED,yGAAyG;AACzG,SAAS,QAAQ,CAAC,IAAa;IAC7B,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,QAAQ;QACvC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,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,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,GAAG,CAAC,IAAI,CAAC,yBAAyB;YAChC,CAAC,CAAC,EAAE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,EAAE;YAC/D,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;IACD,MAAM,OAAO,GAAmB;QAC9B,EAAE,EAAE,IAAI,CAAC,KAAK;QACd,IAAI;QACJ,MAAM;QACN,OAAO;QACP,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;QAClB,QAAQ;QACR,GAAG,EAAE,IAAI;KACV,CAAA;IACD,OAAO,GAAG,CAAC,OAAO,CAAC;QACjB,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,IAAI,CAAC,KAAK;QACd,SAAS,EAAE,OAAO,CAAC,IAAI;QACvB,OAAO;QACP,QAAQ;QACR,GAAG,EAAE,IAAI;KACV,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Platform failures of the DingTalk REST surface and their mapping onto the core taxonomy.
3
+ *
4
+ * DingTalk answers failures in three forms: an HTTP 4xx with `{ code, message, requestid }` (the `/v1.0/*` endpoints), an
5
+ * HTTP 200 with `{ errcode, errmsg }` (the legacy `oapi` endpoints, such as the media upload), and an HTML page from
6
+ * the IP-dimension rate limiter. Only an explicit platform refusal may be reported as `published: 'no'`.
7
+ */
8
+ import { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';
9
+ import type { PlatformErrorKind } from '@deepseek-ai/cordis-plugin-im-core';
10
+ /** Fields one failed DingTalk call carries for classification. */
11
+ export interface DingtalkApiErrorInit {
12
+ /** HTTP status of the answer, absent when the request never produced one. */
13
+ status?: number;
14
+ /** `code` of a `/v1.0/*` answer or `errcode` of an `oapi` one. */
15
+ code?: string | number;
16
+ /** `requestid` of a `/v1.0/*` answer, for a support ticket. */
17
+ requestid?: string;
18
+ /** The answer body, kept for diagnostics; long bodies are truncated. */
19
+ bodyText?: string;
20
+ /** The answer was not JSON (the HTML page of the IP-dimension rate limiter, a proxy error page). */
21
+ nonJson?: boolean;
22
+ cause?: unknown;
23
+ }
24
+ /** One failed DingTalk call, with the fields `classify` needs. */
25
+ export declare class DingtalkApiError extends Error {
26
+ readonly status: number | undefined;
27
+ readonly code: string | number | undefined;
28
+ readonly requestid: string | undefined;
29
+ readonly bodyText: string | undefined;
30
+ readonly nonJson: boolean;
31
+ constructor(message: string, init?: DingtalkApiErrorInit);
32
+ }
33
+ /** One classification of a platform code or status. */
34
+ interface Verdict {
35
+ kind: PlatformErrorKind;
36
+ published: 'no' | 'unknown';
37
+ }
38
+ /**
39
+ * Verdict of one platform code, if the tables cover it.
40
+ * @param code - `code` of a `/v1.0/*` answer or `errcode` of an `oapi` one.
41
+ * @returns its classification, or undefined for a code this adapter does not know.
42
+ */
43
+ export declare function verdictOfCode(code: string): Verdict | undefined;
44
+ /** Whether a failed call means the access token was refused, so the token is re-minted and the call retried once. */
45
+ export declare function isAuthFailure(error: unknown): boolean;
46
+ /**
47
+ * Whether a failed Stream registration names the configured credentials themselves.
48
+ *
49
+ * Such a refusal cannot be fixed by reconnecting: the loop stops and the bot reports the error until the profile is
50
+ * edited.
51
+ *
52
+ * @param error - the caught failure.
53
+ * @returns true for a credential code such as `invalidClientIdOrSecret`.
54
+ */
55
+ export declare function isCredentialRefusal(error: unknown): boolean;
56
+ /**
57
+ * Whether a failed Stream registration is an authentication or authorisation refusal.
58
+ *
59
+ * A refusal without a credential code may be transient (a gateway hiccup, a rate-limited gateway), so the loop keeps
60
+ * retrying; a run of them means the credentials are wrong.
61
+ *
62
+ * @param error - the caught failure.
63
+ * @returns true for a 401/403 answer or a credential code.
64
+ */
65
+ export declare function isAuthRefusal(error: unknown): boolean;
66
+ /**
67
+ * Map any failure onto the core platform taxonomy.
68
+ *
69
+ * A transport failure, a 5xx answer or a non-JSON answer leaves the outcome open: the request may have reached the
70
+ * platform. Only a documented refusal is reported as unpublished.
71
+ *
72
+ * @param error - the caught failure.
73
+ * @returns the classified platform error.
74
+ */
75
+ export declare function classifyDingtalkError(error: unknown): PlatformError;
76
+ export {};
77
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAE3E,kEAAkE;AAClE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oGAAoG;IACpG,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,kEAAkE;AAClE,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;gBAEb,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,oBAAyB;CAS7D;AAED,uDAAuD;AACvD,UAAU,OAAO;IACf,IAAI,EAAE,iBAAiB,CAAA;IACvB,SAAS,EAAE,IAAI,GAAG,SAAS,CAAA;CAC5B;AAkHD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAS/D;AASD,qHAAqH;AACrH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAIrD;AAUD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKrD;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAqBnE"}
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Platform failures of the DingTalk REST surface and their mapping onto the core taxonomy.
3
+ *
4
+ * DingTalk answers failures in three forms: an HTTP 4xx with `{ code, message, requestid }` (the `/v1.0/*` endpoints), an
5
+ * HTTP 200 with `{ errcode, errmsg }` (the legacy `oapi` endpoints, such as the media upload), and an HTML page from
6
+ * the IP-dimension rate limiter. Only an explicit platform refusal may be reported as `published: 'no'`.
7
+ */
8
+ import { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';
9
+ /** One failed DingTalk call, with the fields `classify` needs. */
10
+ export class DingtalkApiError extends Error {
11
+ status;
12
+ code;
13
+ requestid;
14
+ bodyText;
15
+ nonJson;
16
+ constructor(message, init = {}) {
17
+ super(message, init.cause === undefined ? undefined : { cause: init.cause });
18
+ this.name = 'DingtalkApiError';
19
+ this.status = init.status;
20
+ this.code = init.code;
21
+ this.requestid = init.requestid;
22
+ this.bodyText = init.bodyText;
23
+ this.nonJson = init.nonJson ?? false;
24
+ }
25
+ }
26
+ const RATE_LIMIT = { kind: 'rate-limit', published: 'no' };
27
+ const LIMIT = { kind: 'limit', published: 'no' };
28
+ const PERMISSION = { kind: 'permission', published: 'no' };
29
+ const NOT_FOUND = { kind: 'not-found', published: 'no' };
30
+ const INVALID = { kind: 'invalid', published: 'no' };
31
+ /** The platform reports an unknown send result: it may or may not have published, so the outcome stays open. */
32
+ const INVALID_UNKNOWN = { kind: 'invalid', published: 'unknown' };
33
+ const RETRYABLE = { kind: 'retryable', published: 'unknown' };
34
+ /**
35
+ * Codes of the documented error tables of `groupMessages/send`, `oToMessages/batchSend` and `groupMessages/recall`
36
+ * (three near-identical tables), plus the shared frequency-limit codes and the legacy `oapi` errcodes.
37
+ */
38
+ const CODE_VERDICTS = [
39
+ [
40
+ RATE_LIMIT,
41
+ [
42
+ 'send.too.fast',
43
+ 'send.byToken.tooFast',
44
+ 'too.many.group',
45
+ 'too.many.people',
46
+ '90018',
47
+ '90006',
48
+ '90002',
49
+ 'Forbidden.AccessDenied.QpsLimitForAppkeyAndApi',
50
+ ],
51
+ ],
52
+ [
53
+ LIMIT,
54
+ [
55
+ 'invalidParameter.msgParam.tooLong',
56
+ 'invalidParameter.userIds.overMax',
57
+ 'invalidParameter.processQueryKeys.overMax',
58
+ ],
59
+ ],
60
+ [
61
+ PERMISSION,
62
+ [
63
+ 'InvalidAuthentication',
64
+ 'invalidParameter.token.invalid',
65
+ 'Forbidden.AccessDenied.AccessTokenInvalid',
66
+ 'send.forbidden',
67
+ 'bot.forbidden.sendMessage',
68
+ 'unauthorized',
69
+ 'auth.error',
70
+ 'not.allowed.robotCode',
71
+ 'ip.not.match',
72
+ 'keywords.not.match',
73
+ 'sign.not.match',
74
+ 'only.groupAdmin.canAtAll',
75
+ 'conversation.org.notMatch',
76
+ ],
77
+ ],
78
+ [
79
+ NOT_FOUND,
80
+ [
81
+ 'invalidParameter.robotCode.empty',
82
+ 'invalidParameter.robotCode.missing',
83
+ 'invalidParameter.robotCode.invalid',
84
+ 'invalidParameter.robotCode.notExsit',
85
+ 'invalidParameter.robotCode.auth',
86
+ 'invalidParameter.robotCode.coolApp',
87
+ 'template.not.existed',
88
+ 'template.stopped',
89
+ 'bot.stopped',
90
+ 'resource.not.found',
91
+ 'resource.unavailable',
92
+ 'notFound.robotCode',
93
+ 'invalid.openConversationId',
94
+ 'miss.openConversationId',
95
+ 'group.disbanded',
96
+ 'staffId.notExisted',
97
+ 'robot.oto.notExist',
98
+ 'chatbotId.notAllow.sendOTO',
99
+ 'invalidParameter.processQueryKey.missing',
100
+ 'invalid.processQueryKey',
101
+ 'session.notExisted',
102
+ 'session.expired',
103
+ 'token.notExisted',
104
+ ],
105
+ ],
106
+ [
107
+ INVALID,
108
+ [
109
+ 'invalidParameter.msgKey.empty',
110
+ 'invalidParameter.msgKey.invalid',
111
+ 'invalidParameter.msg.unsupport',
112
+ 'invalidParameter.msgParam.invalid',
113
+ 'invalidParameter.msgBody.invalid',
114
+ 'invalidParameter.param.invalid',
115
+ 'contain.unsafe.url',
116
+ 'contain.notAllowed.text',
117
+ 'contain.notAllowed.picture',
118
+ 'contain.notAllowed.content',
119
+ ],
120
+ ],
121
+ [INVALID_UNKNOWN, ['unknown.send.result']],
122
+ [RETRYABLE, ['system.error', 'send.ding.exception']],
123
+ ];
124
+ /** Code prefixes whose whole family has one verdict (`miss.param.*`, `invalid.param.actionCard*`, `4xxxx` errcodes). */
125
+ const CODE_PREFIX_VERDICTS = [
126
+ [INVALID, 'miss.param.'],
127
+ [INVALID, 'invalid.param.actionCard'],
128
+ ];
129
+ const EXACT_CODES = new Map(CODE_VERDICTS.flatMap(([verdict, codes]) => codes.map((code) => [code, verdict])));
130
+ /**
131
+ * Verdict of one platform code, if the tables cover it.
132
+ * @param code - `code` of a `/v1.0/*` answer or `errcode` of an `oapi` one.
133
+ * @returns its classification, or undefined for a code this adapter does not know.
134
+ */
135
+ export function verdictOfCode(code) {
136
+ const exact = EXACT_CODES.get(code);
137
+ if (exact !== undefined)
138
+ return exact;
139
+ for (const [verdict, prefix] of CODE_PREFIX_VERDICTS) {
140
+ if (code.startsWith(prefix))
141
+ return verdict;
142
+ }
143
+ // The legacy media endpoints answer 400xx for a refused file; the exact codes are not cross-checked one by one.
144
+ if (/^400\d{2}$/.test(code))
145
+ return INVALID;
146
+ return undefined;
147
+ }
148
+ /** Codes that name the application credentials rather than a policy the caller can fix. */
149
+ const AUTH_CODES = new Set([
150
+ 'InvalidAuthentication',
151
+ 'invalidParameter.token.invalid',
152
+ 'Forbidden.AccessDenied.AccessTokenInvalid',
153
+ ]);
154
+ /** Whether a failed call means the access token was refused, so the token is re-minted and the call retried once. */
155
+ export function isAuthFailure(error) {
156
+ if (!(error instanceof DingtalkApiError))
157
+ return false;
158
+ if (error.status === 401)
159
+ return true;
160
+ return error.code !== undefined && AUTH_CODES.has(String(error.code));
161
+ }
162
+ const CREDENTIAL_CODES = new Set([
163
+ ...AUTH_CODES,
164
+ 'invalidClientIdOrSecret',
165
+ 'invalidClientId',
166
+ 'invalidClientSecret',
167
+ 'app.not.found',
168
+ ]);
169
+ /**
170
+ * Whether a failed Stream registration names the configured credentials themselves.
171
+ *
172
+ * Such a refusal cannot be fixed by reconnecting: the loop stops and the bot reports the error until the profile is
173
+ * edited.
174
+ *
175
+ * @param error - the caught failure.
176
+ * @returns true for a credential code such as `invalidClientIdOrSecret`.
177
+ */
178
+ export function isCredentialRefusal(error) {
179
+ return (error instanceof DingtalkApiError &&
180
+ error.code !== undefined &&
181
+ CREDENTIAL_CODES.has(String(error.code)));
182
+ }
183
+ /**
184
+ * Whether a failed Stream registration is an authentication or authorisation refusal.
185
+ *
186
+ * A refusal without a credential code may be transient (a gateway hiccup, a rate-limited gateway), so the loop keeps
187
+ * retrying; a run of them means the credentials are wrong.
188
+ *
189
+ * @param error - the caught failure.
190
+ * @returns true for a 401/403 answer or a credential code.
191
+ */
192
+ export function isAuthRefusal(error) {
193
+ return (error instanceof DingtalkApiError &&
194
+ (error.status === 401 || error.status === 403 || isCredentialRefusal(error)));
195
+ }
196
+ /** The verdict of a failed call: the code table first, then the HTTP status, then an assumed transient failure. */
197
+ function verdictOf(error) {
198
+ // A body that is not JSON came from something in front of the API (the IP-dimension rate limiter, a gateway), so the
199
+ // platform's own status cannot say whether the request was accepted.
200
+ if (error.nonJson)
201
+ return RETRYABLE;
202
+ if (error.code !== undefined) {
203
+ const verdict = verdictOfCode(String(error.code));
204
+ if (verdict !== undefined)
205
+ return verdict;
206
+ }
207
+ if (error.status === 429)
208
+ return RATE_LIMIT;
209
+ if (error.status === 401 || error.status === 403)
210
+ return PERMISSION;
211
+ if (error.status === 404)
212
+ return NOT_FOUND;
213
+ if (error.status !== undefined && error.status >= 400 && error.status < 500)
214
+ return INVALID;
215
+ return RETRYABLE;
216
+ }
217
+ /**
218
+ * Map any failure onto the core platform taxonomy.
219
+ *
220
+ * A transport failure, a 5xx answer or a non-JSON answer leaves the outcome open: the request may have reached the
221
+ * platform. Only a documented refusal is reported as unpublished.
222
+ *
223
+ * @param error - the caught failure.
224
+ * @returns the classified platform error.
225
+ */
226
+ export function classifyDingtalkError(error) {
227
+ if (error instanceof PlatformError)
228
+ return error;
229
+ if (error instanceof DingtalkApiError) {
230
+ const verdict = verdictOf(error);
231
+ return new PlatformError(verdict.kind, error.message, {
232
+ ...(error.code === undefined ? {} : { code: error.code }),
233
+ published: verdict.published,
234
+ cause: error,
235
+ });
236
+ }
237
+ if (error instanceof Error && error.name === 'AbortError') {
238
+ return new PlatformError('fatal', error.message, {
239
+ published: 'unknown',
240
+ cause: error,
241
+ });
242
+ }
243
+ const message = error instanceof Error ? error.message : String(error);
244
+ return new PlatformError('retryable', `dingtalk request failed: ${message}`, {
245
+ published: 'unknown',
246
+ cause: error,
247
+ });
248
+ }
249
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAkBlE,kEAAkE;AAClE,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,MAAM,CAAoB;IAC1B,IAAI,CAA6B;IACjC,SAAS,C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;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,IAAI,KAAK,YAAY,aAAa;QAAE,OAAO,KAAK,CAAA;IAChD,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QAChC,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE;YACpD,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACzD,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,KAAK,EAAE,KAAK;SACb,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC1D,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;YAC/C,SAAS,EAAE,SAAS;YACpB,KAAK,EAAE,KAAK;SACb,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACtE,OAAO,IAAI,aAAa,CAAC,WAAW,EAAE,4BAA4B,OAAO,EAAE,EAAE;QAC3E,SAAS,EAAE,SAAS;QACpB,KAAK,EAAE,KAAK;KACb,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `@im-more/dsh-dingtalk`: a DingTalk internal-application robot for the DeepSeek Harness IM subsystem.
3
+ *
4
+ * Mounting this plugin adds one `satori` bot (`dingtalk:<appkey>`) with a Stream Mode or HTTP-callback transport and the
5
+ * single `markdown` mode. See `docs/platforms/dingtalk.md` for the application setup and the platform's limits.
6
+ */
7
+ import * as Dingtalk from './types/index.ts';
8
+ export { Config, configError, routePath, type Config as DingtalkConfig, type DingtalkProtocol, } from './config.ts';
9
+ export { DingtalkBot, DingtalkBot as default, type DingtalkModes, } from './bot.ts';
10
+ export { decodeMessage, type DingtalkReferrer } from './decode.ts';
11
+ export { classifyDingtalkError, DingtalkApiError, isAuthFailure, isAuthRefusal, isCredentialRefusal, verdictOfCode, type DingtalkApiErrorInit, } from './errors.ts';
12
+ export { Internal } from './internal.ts';
13
+ export { downloadUrlOf, mediaSource, mediaTypeOf, uploadMedia, type DingtalkMediaUploadAnswer, } from './media.ts';
14
+ export { assembleDraft, checkDraft, DINGTALK_LIMITS, escape, fileTypeOf, mediaNode, serializeDraft, titleOf, unescape, ZERO_WIDTH, type DingtalkDraft, type DingtalkMedia, type DingtalkMediaKind, type DingtalkModeTypes, type DingtalkNode, type DingtalkPayload, } from './modes/shared.ts';
15
+ export { createMarkdownMode } from './modes/markdown.ts';
16
+ export { endpointOf, invoke, type DingtalkBase, type DingtalkRequestBody, } from './request.ts';
17
+ export { deletePart, sendPayload, type DingtalkSendDeps } from './send.ts';
18
+ export { AccessTokenCache, type DingtalkAccessToken } from './token.ts';
19
+ export { CALLBACK_TOPIC, CLIENT_USER_AGENT, DingtalkStream, type AckCode, type DingtalkAck, type DingtalkConnection, type DingtalkFrame, } from './transport/stream.ts';
20
+ export { DingtalkWebhook, matchesSign, signOf, TIMESTAMP_WINDOW_MS, } from './transport/webhook.ts';
21
+ export { Dingtalk };
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EACL,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,MAAM,IAAI,cAAc,EAC7B,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAA;AAC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AC/B,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `@im-more/dsh-dingtalk`: a DingTalk internal-application robot for the DeepSeek Harness IM subsystem.
3
+ *
4
+ * Mounting this plugin adds one `satori` bot (`dingtalk:<appkey>`) with a Stream Mode or HTTP-callback transport and the
5
+ * single `markdown` mode. See `docs/platforms/dingtalk.md` for the application setup and the platform's limits.
6
+ */
7
+ import * as Dingtalk from "./types/index.js";
8
+ export { Config, configError, routePath, } from "./config.js";
9
+ export { DingtalkBot, DingtalkBot as default, } from "./bot.js";
10
+ export { decodeMessage } from "./decode.js";
11
+ export { classifyDingtalkError, DingtalkApiError, isAuthFailure, isAuthRefusal, isCredentialRefusal, verdictOfCode, } from "./errors.js";
12
+ export { Internal } from "./internal.js";
13
+ export { downloadUrlOf, mediaSource, mediaTypeOf, uploadMedia, } from "./media.js";
14
+ export { assembleDraft, checkDraft, DINGTALK_LIMITS, escape, fileTypeOf, mediaNode, serializeDraft, titleOf, unescape, ZERO_WIDTH, } from "./modes/shared.js";
15
+ export { createMarkdownMode } from "./modes/markdown.js";
16
+ export { endpointOf, invoke, } from "./request.js";
17
+ export { deletePart, sendPayload } from "./send.js";
18
+ export { AccessTokenCache } from "./token.js";
19
+ export { CALLBACK_TOPIC, CLIENT_USER_AGENT, DingtalkStream, } from "./transport/stream.js";
20
+ export { DingtalkWebhook, matchesSign, signOf, TIMESTAMP_WINDOW_MS, } from "./transport/webhook.js";
21
+ export { Dingtalk };
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EACL,MAAM,EACN,WAAW,EACX,SAAS,GAGV,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,WAAW,EACX,WAAW,IAAI,OAAO,GAEvB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,aAAa,EAAyB,MAAM,aAAa,CAAA;AAClE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,aAAa,GAEd,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,EACX,WAAW,GAEZ,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,aAAa,EACb,UAAU,EACV,eAAe,EACf,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EACd,OAAO,EACP,QAAQ,EACR,UAAU,GAOX,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EACL,UAAU,EACV,MAAM,GAGP,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAyB,MAAM,WAAW,CAAA;AAC1E,OAAO,EAAE,gBAAgB,EAA4B,MAAM,YAAY,CAAA;AACvE,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,GAKf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,eAAe,EACf,WAAW,EACX,MAAM,EACN,mBAAmB,GACpB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { type Dict } from '@deepseek-ai/cordis-plugin-im-core';
2
+ import type { DingtalkBot } from './bot.ts';
3
+ /**
4
+ * Route table of the migrated REST layer: one entry per generated `Internal.define({...})` block.
5
+ *
6
+ * `isOldApi` selects the version-family transport: the new `api.dingtalk.com/v1.0` endpoints take a version query
7
+ * parameter and the access token in a header, the legacy `oapi.dingtalk.com` ones take `method` + `access_token` as
8
+ * query parameters.
9
+ */
10
+ export declare class Internal {
11
+ private bot;
12
+ constructor(bot: DingtalkBot);
13
+ static define(routes: Dict<Partial<Record<string, Record<string, boolean>>>>): void;
14
+ }
15
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG3C;;;;;;GAMG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,WAAW;IAEpC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CA4C7E"}