@im-more/dsh-line 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 (97) hide show
  1. package/LICENSE +21 -0
  2. package/cordis.patch.yml +12 -0
  3. package/lib/index.js +1701 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/types/bot.d.ts +55 -0
  6. package/lib/types/bot.d.ts.map +1 -0
  7. package/lib/types/bot.js +169 -0
  8. package/lib/types/bot.js.map +1 -0
  9. package/lib/types/config.d.ts +47 -0
  10. package/lib/types/config.d.ts.map +1 -0
  11. package/lib/types/config.js +77 -0
  12. package/lib/types/config.js.map +1 -0
  13. package/lib/types/decode.d.ts +60 -0
  14. package/lib/types/decode.d.ts.map +1 -0
  15. package/lib/types/decode.js +321 -0
  16. package/lib/types/decode.js.map +1 -0
  17. package/lib/types/errors.d.ts +47 -0
  18. package/lib/types/errors.d.ts.map +1 -0
  19. package/lib/types/errors.js +112 -0
  20. package/lib/types/errors.js.map +1 -0
  21. package/lib/types/identity.d.ts +17 -0
  22. package/lib/types/identity.d.ts.map +1 -0
  23. package/lib/types/identity.js +24 -0
  24. package/lib/types/identity.js.map +1 -0
  25. package/lib/types/index.d.ts +17 -0
  26. package/lib/types/index.d.ts.map +1 -0
  27. package/lib/types/index.js +16 -0
  28. package/lib/types/index.js.map +1 -0
  29. package/lib/types/media.d.ts +19 -0
  30. package/lib/types/media.d.ts.map +1 -0
  31. package/lib/types/media.js +55 -0
  32. package/lib/types/media.js.map +1 -0
  33. package/lib/types/modes/shared.d.ts +126 -0
  34. package/lib/types/modes/shared.d.ts.map +1 -0
  35. package/lib/types/modes/shared.js +316 -0
  36. package/lib/types/modes/shared.js.map +1 -0
  37. package/lib/types/modes/text.d.ts +13 -0
  38. package/lib/types/modes/text.d.ts.map +1 -0
  39. package/lib/types/modes/text.js +143 -0
  40. package/lib/types/modes/text.js.map +1 -0
  41. package/lib/types/request.d.ts +49 -0
  42. package/lib/types/request.d.ts.map +1 -0
  43. package/lib/types/request.js +162 -0
  44. package/lib/types/request.js.map +1 -0
  45. package/lib/types/send.d.ts +43 -0
  46. package/lib/types/send.d.ts.map +1 -0
  47. package/lib/types/send.js +74 -0
  48. package/lib/types/send.js.map +1 -0
  49. package/lib/types/signature.d.ts +19 -0
  50. package/lib/types/signature.d.ts.map +1 -0
  51. package/lib/types/signature.js +30 -0
  52. package/lib/types/signature.js.map +1 -0
  53. package/lib/types/transport/media.d.ts +62 -0
  54. package/lib/types/transport/media.d.ts.map +1 -0
  55. package/lib/types/transport/media.js +104 -0
  56. package/lib/types/transport/media.js.map +1 -0
  57. package/lib/types/transport/webhook.d.ts +62 -0
  58. package/lib/types/transport/webhook.d.ts.map +1 -0
  59. package/lib/types/transport/webhook.js +208 -0
  60. package/lib/types/transport/webhook.js.map +1 -0
  61. package/lib/types/types/definition.d.ts +1006 -0
  62. package/lib/types/types/definition.d.ts.map +1 -0
  63. package/lib/types/types/definition.js +2 -0
  64. package/lib/types/types/definition.js.map +1 -0
  65. package/lib/types/types/index.d.ts +542 -0
  66. package/lib/types/types/index.d.ts.map +1 -0
  67. package/lib/types/types/index.js +4 -0
  68. package/lib/types/types/index.js.map +1 -0
  69. package/lib/types/types/internal.d.ts +8 -0
  70. package/lib/types/types/internal.d.ts.map +1 -0
  71. package/lib/types/types/internal.js +234 -0
  72. package/lib/types/types/internal.js.map +1 -0
  73. package/lib/types/types/request.d.ts +341 -0
  74. package/lib/types/types/request.d.ts.map +1 -0
  75. package/lib/types/types/request.js +2 -0
  76. package/lib/types/types/request.js.map +1 -0
  77. package/package.json +61 -3
  78. package/src/bot.ts +229 -0
  79. package/src/config.ts +113 -0
  80. package/src/decode.ts +418 -0
  81. package/src/errors.ts +138 -0
  82. package/src/identity.ts +28 -0
  83. package/src/index.ts +60 -0
  84. package/src/media.ts +66 -0
  85. package/src/modes/shared.ts +408 -0
  86. package/src/modes/text.ts +177 -0
  87. package/src/request.ts +215 -0
  88. package/src/send.ts +104 -0
  89. package/src/signature.ts +32 -0
  90. package/src/transport/media.ts +117 -0
  91. package/src/transport/webhook.ts +266 -0
  92. package/src/types/.eslintrc.yml +2 -0
  93. package/src/types/definition.ts +1008 -0
  94. package/src/types/index.ts +593 -0
  95. package/src/types/internal.ts +233 -0
  96. package/src/types/request.ts +341 -0
  97. package/README.md +0 -3
@@ -0,0 +1,17 @@
1
+ import type { BotInfoResponse } from './types/index.ts';
2
+ /** Failure to confirm the configured bot identity. */
3
+ export declare class LineIdentityError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ /**
7
+ * Verify a `getBotInfo` answer against the configured `selfId`.
8
+ *
9
+ * `bot.id` is fixed at construction, so the channel must be identified from configuration; this call proves the
10
+ * token belongs to that channel instead of discovering the id from it.
11
+ *
12
+ * @param selfId - the configured bot user id.
13
+ * @param info - the `GET /v2/bot/info` answer.
14
+ * @returns the platform user id, which is `selfId`.
15
+ */
16
+ export declare function verifyIdentity(selfId: string, info: BotInfoResponse): string;
17
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD,sDAAsD;AACtD,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,CAO5E"}
@@ -0,0 +1,24 @@
1
+ /** Failure to confirm the configured bot identity. */
2
+ export class LineIdentityError extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = 'LineIdentityError';
6
+ }
7
+ }
8
+ /**
9
+ * Verify a `getBotInfo` answer against the configured `selfId`.
10
+ *
11
+ * `bot.id` is fixed at construction, so the channel must be identified from configuration; this call proves the
12
+ * token belongs to that channel instead of discovering the id from it.
13
+ *
14
+ * @param selfId - the configured bot user id.
15
+ * @param info - the `GET /v2/bot/info` answer.
16
+ * @returns the platform user id, which is `selfId`.
17
+ */
18
+ export function verifyIdentity(selfId, info) {
19
+ if (info.userId !== selfId) {
20
+ throw new LineIdentityError(`line: selfId is ${selfId} but getBotInfo returned ${info.userId}`);
21
+ }
22
+ return info.userId;
23
+ }
24
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAEA,sDAAsD;AACtD,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,IAAqB;IAClE,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,iBAAiB,CACzB,mBAAmB,MAAM,4BAA4B,IAAI,CAAC,MAAM,EAAE,CACnE,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAA;AACpB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import * as Line from './types/index.ts';
2
+ export { LineBot, LineBot as default, type LineModes } from './bot.ts';
3
+ export { Config, configError, publicBase, routePath, type Config as LineConfig, } from './config.ts';
4
+ export { chatIdOf, chatRefOf, chatTargetOf, decodeEvent, parseChatId, type LineChatAddress, type LineChatKind, type LineReferrer, } from './decode.ts';
5
+ export { classifyLineError, LineApiError, type LineApiErrorInit, type LineErrorDetail, } from './errors.ts';
6
+ export { LineIdentityError, verifyIdentity } from './identity.ts';
7
+ export { serveMessageContent } from './media.ts';
8
+ export type { LineAction, LineBlock, LineDraft, LineModeTypes, LineNode, LinePayload, } from './modes/shared.ts';
9
+ export { LINE_LIMITS } from './modes/shared.ts';
10
+ export { downloadContent, invoke, LINE_API_ORIGIN, LINE_DATA_ORIGIN, type LineRequest, type LineRequestConfig, } from './request.ts';
11
+ export { members, sendPayload, type LineSendDeps } from './send.ts';
12
+ export { matchesSignature, signatureOf } from './signature.ts';
13
+ export { LineMediaRoute, MediaStaging, type StagedMedia, } from './transport/media.ts';
14
+ export { LineWebhook, type WebHandlerRoute, type WebResourceRoute, type WebServerLike, } from './transport/webhook.ts';
15
+ export { Internal } from './types/internal.ts';
16
+ export { Line };
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AAExC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AACtE,OAAO,EACL,MAAM,EACN,WAAW,EACX,UAAU,EACV,SAAS,EACT,KAAK,MAAM,IAAI,UAAU,GAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAChD,YAAY,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,QAAQ,EACR,WAAW,GACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EACL,eAAe,EACf,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EACL,cAAc,EACd,YAAY,EACZ,KAAK,WAAW,GACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,16 @@
1
+ import * as Line from "./types/index.js";
2
+ export { LineBot, LineBot as default } from "./bot.js";
3
+ export { Config, configError, publicBase, routePath, } from "./config.js";
4
+ export { chatIdOf, chatRefOf, chatTargetOf, decodeEvent, parseChatId, } from "./decode.js";
5
+ export { classifyLineError, LineApiError, } from "./errors.js";
6
+ export { LineIdentityError, verifyIdentity } from "./identity.js";
7
+ export { serveMessageContent } from "./media.js";
8
+ export { LINE_LIMITS } from "./modes/shared.js";
9
+ export { downloadContent, invoke, LINE_API_ORIGIN, LINE_DATA_ORIGIN, } from "./request.js";
10
+ export { members, sendPayload } from "./send.js";
11
+ export { matchesSignature, signatureOf } from "./signature.js";
12
+ export { LineMediaRoute, MediaStaging, } from "./transport/media.js";
13
+ export { LineWebhook, } from "./transport/webhook.js";
14
+ export { Internal } from "./types/internal.js";
15
+ export { Line };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AAExC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAkB,MAAM,UAAU,CAAA;AACtE,OAAO,EACL,MAAM,EACN,WAAW,EACX,UAAU,EACV,SAAS,GAEV,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,GAIZ,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iBAAiB,EACjB,YAAY,GAGb,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAShD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EACL,eAAe,EACf,MAAM,EACN,eAAe,EACf,gBAAgB,GAGjB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAqB,MAAM,WAAW,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EACL,cAAc,EACd,YAAY,GAEb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,WAAW,GAIZ,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Inbound media: the `satori:` route behind an image, video, audio or file element.
3
+ *
4
+ * LINE serves the bytes of a received message from its content API, with the channel's own credentials, and deletes
5
+ * them after a while. The route therefore downloads on demand instead of baking a URL into the stored message.
6
+ */
7
+ import type { LineBot } from './bot.ts';
8
+ /**
9
+ * Serve the bytes of one inbound message.
10
+ *
11
+ * The content API answers `202` while a large video or audio is still being transcoded, `404` for an unknown id and
12
+ * `410` for a message the user unsent; the host treats the first as "not available yet" and the second pair as "gone".
13
+ *
14
+ * @param bot - the receiving adapter.
15
+ * @param messageId - platform message id of the media.
16
+ * @returns the bytes, or the status the host reads as unavailable.
17
+ */
18
+ export declare function serveMessageContent(bot: LineBot, messageId: string): Promise<Response>;
19
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/media.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAQvC;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,QAAQ,CAAC,CAqCnB"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Inbound media: the `satori:` route behind an image, video, audio or file element.
3
+ *
4
+ * LINE serves the bytes of a received message from its content API, with the channel's own credentials, and deletes
5
+ * them after a while. The route therefore downloads on demand instead of baking a URL into the stored message.
6
+ */
7
+ import { downloadContent } from "./request.js";
8
+ /** Message of any caught value, for a log line. */
9
+ function messageOf(error) {
10
+ return error instanceof Error ? error.message : String(error);
11
+ }
12
+ /**
13
+ * Serve the bytes of one inbound message.
14
+ *
15
+ * The content API answers `202` while a large video or audio is still being transcoded, `404` for an unknown id and
16
+ * `410` for a message the user unsent; the host treats the first as "not available yet" and the second pair as "gone".
17
+ *
18
+ * @param bot - the receiving adapter.
19
+ * @param messageId - platform message id of the media.
20
+ * @returns the bytes, or the status the host reads as unavailable.
21
+ */
22
+ export async function serveMessageContent(bot, messageId) {
23
+ let response;
24
+ try {
25
+ response = await downloadContent(bot.request, messageId);
26
+ }
27
+ catch (error) {
28
+ bot.ctx.logger.warn('line: media %s could not be downloaded: %s', messageId, messageOf(error));
29
+ return new Response(null, { status: 502 });
30
+ }
31
+ switch (response.status) {
32
+ case 200: {
33
+ const headers = new Headers();
34
+ const mime = response.headers.get('content-type');
35
+ if (mime !== null)
36
+ headers.set('content-type', mime);
37
+ const cacheControl = response.headers.get('cache-control');
38
+ if (cacheControl !== null)
39
+ headers.set('cache-control', cacheControl);
40
+ return new Response(response.body, { status: 200, headers });
41
+ }
42
+ case 202:
43
+ // The transcoding is not finished; polling it would need a timer this adapter does not own.
44
+ bot.ctx.logger.warn('line: media %s is still being transcoded', messageId);
45
+ return new Response(null, { status: 503 });
46
+ case 404:
47
+ case 410:
48
+ // `410` means the user unsent the message; both are "these bytes no longer exist".
49
+ return new Response(null, { status: 404 });
50
+ default:
51
+ bot.ctx.logger.warn('line: media %s answered %s', messageId, String(response.status));
52
+ return new Response(null, { status: 502 });
53
+ }
54
+ }
55
+ //# sourceMappingURL=media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/media.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,mDAAmD;AACnD,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC/D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,GAAY,EACZ,SAAiB;IAEjB,IAAI,QAAkB,CAAA;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CACjB,4CAA4C,EAC5C,SAAS,EACT,SAAS,CAAC,KAAK,CAAC,CACjB,CAAA;QACD,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IAC5C,CAAC;IACD,QAAQ,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxB,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;YAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;YACjD,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;YACpD,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;YAC1D,IAAI,YAAY,KAAK,IAAI;gBAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,YAAY,CAAC,CAAA;YACrE,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;QAC9D,CAAC;QACD,KAAK,GAAG;YACN,4FAA4F;YAC5F,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,0CAA0C,EAAE,SAAS,CAAC,CAAA;YAC1E,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAC5C,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,mFAAmF;YACnF,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAC5C;YACE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CACjB,4BAA4B,EAC5B,SAAS,EACT,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CACxB,CAAA;YACD,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IAC9C,CAAC;AACH,CAAC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Shared types and the draft machinery of the single `text` mode.
3
+ *
4
+ * A LINE message object is the only outbound representation the platform programs against, and one request carries at
5
+ * most five of them. A draft is therefore one request: up to five message objects plus the quick reply items of the
6
+ * last one, because the platform shows only the last message object's quick reply.
7
+ */
8
+ import type { LimitViolation, ModeTypes, Prepared, RenderContext, ResourceRef, SerializeContext } from '@deepseek-ai/cordis-plugin-im-core';
9
+ import type { Element } from '@deepseek-ai/satori-element';
10
+ import type { Message } from '../types/index.ts';
11
+ /** One node a handler produces. */
12
+ export type LineNode = {
13
+ type: 'text';
14
+ text: string;
15
+ } | {
16
+ type: 'media';
17
+ block: LineBlock;
18
+ } | {
19
+ type: 'button';
20
+ action: LineAction;
21
+ };
22
+ /** One LINE message object of a draft, before resource resolution. */
23
+ export type LineBlock = {
24
+ type: 'text';
25
+ text: string;
26
+ } | {
27
+ type: 'image';
28
+ ref: ResourceRef<'image'>;
29
+ } | {
30
+ type: 'video';
31
+ ref: ResourceRef<'video'>;
32
+ poster: ResourceRef<'image'>;
33
+ } | {
34
+ type: 'audio';
35
+ ref: ResourceRef<'audio'>;
36
+ duration: number;
37
+ };
38
+ /** One quick reply action collected from `<button>`. */
39
+ export type LineAction = {
40
+ type: 'postback';
41
+ label: string;
42
+ data: string;
43
+ } | {
44
+ type: 'uri';
45
+ label: string;
46
+ uri: string;
47
+ } | {
48
+ type: 'message';
49
+ label: string;
50
+ text: string;
51
+ };
52
+ /** One request: up to five message objects and the quick reply items of the last one. */
53
+ export interface LineDraft {
54
+ blocks: LineBlock[];
55
+ actions: LineAction[];
56
+ }
57
+ /** Exact request body of one push. */
58
+ export interface LinePayload {
59
+ /** `userId` / `groupId` / `roomId`, translated from the `chat.id` prefix. */
60
+ to: string;
61
+ messages: Message[];
62
+ }
63
+ /** Mode types of the `text` mode. */
64
+ export interface LineModeTypes extends ModeTypes {
65
+ node: LineNode;
66
+ draft: LineDraft;
67
+ payload: LinePayload;
68
+ }
69
+ /** The platform's documented bounds. */
70
+ export declare const LINE_LIMITS: {
71
+ /** One text message object: 5,000 UTF-16 code units. */
72
+ readonly text: 5000;
73
+ /** Message objects one push accepts. */
74
+ readonly messages: 5;
75
+ /** Quick reply items one message accepts. */
76
+ readonly quickReplies: 13;
77
+ /** Request body size (`413 Payload Too Large`). */
78
+ readonly payloadBytes: number;
79
+ };
80
+ /**
81
+ * The text of a carrier message that exists only to show a quick reply.
82
+ *
83
+ * LINE has no message object without content, and a message of a zero-width word joiner renders as an empty bubble.
84
+ */
85
+ export declare const QUICK_REPLY_CARRIER = "\u2060";
86
+ /** Report inline media that moves out of its text run into a message object of its own. */
87
+ export declare function reportMovedMedia(el: Element, ctx: RenderContext<LineModeTypes>): void;
88
+ /**
89
+ * Cut text into chunks a text message object accepts.
90
+ *
91
+ * Point cuts prefer a paragraph break, then a line break, then a space, then a code-unit boundary that does not split a
92
+ * surrogate pair. The chunks concatenate back to the input.
93
+ *
94
+ * @param text - the text of one block.
95
+ * @param limit - the maximum chunk length in UTF-16 code units.
96
+ * @returns one or more chunks.
97
+ */
98
+ export declare function splitText(text: string, limit: number): string[];
99
+ /**
100
+ * Fold a node stream into requests.
101
+ *
102
+ * @param nodes - rendered nodes, in document order.
103
+ * @returns one draft per request, in send order; never empty.
104
+ */
105
+ export declare function assembleDraft(nodes: LineNode[]): LineDraft[];
106
+ /**
107
+ * Build the exact push body of one prepared draft.
108
+ *
109
+ * @param prepared - the draft with its resource keys resolved.
110
+ * @param ctx - the send context: target, part index and quoted message.
111
+ * @returns the request body.
112
+ * @throws PlatformError `invalid` when the target chat id carries no known prefix.
113
+ */
114
+ export declare function serializeDraft(prepared: Prepared<LineDraft>, ctx: SerializeContext): LinePayload;
115
+ /**
116
+ * Hard platform limits of one draft, checked before any request.
117
+ *
118
+ * Text splitting and per-request grouping already keep the draft inside the text, object-count and quick-reply bounds;
119
+ * the checks stay as a regression guard and as the only place a caller learns about a request body that outgrew the
120
+ * 2 MB limit (long media URLs).
121
+ *
122
+ * @param draft - the assembled draft.
123
+ * @returns every violation the platform would refuse.
124
+ */
125
+ export declare function checkDraft(draft: LineDraft): LimitViolation[];
126
+ //# sourceMappingURL=shared.d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;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,cAAc,EAAE,CAyC7D"}
@@ -0,0 +1,316 @@
1
+ /**
2
+ * Shared types and the draft machinery of the single `text` mode.
3
+ *
4
+ * A LINE message object is the only outbound representation the platform programs against, and one request carries at
5
+ * most five of them. A draft is therefore one request: up to five message objects plus the quick reply items of the
6
+ * last one, because the platform shows only the last message object's quick reply.
7
+ */
8
+ import { isPhrasingContainer } from '@deepseek-ai/satori-element';
9
+ import { chatTargetOf } from "../decode.js";
10
+ /** The platform's documented bounds. */
11
+ export const LINE_LIMITS = {
12
+ /** One text message object: 5,000 UTF-16 code units. */
13
+ text: 5_000,
14
+ /** Message objects one push accepts. */
15
+ messages: 5,
16
+ /** Quick reply items one message accepts. */
17
+ quickReplies: 13,
18
+ /** Request body size (`413 Payload Too Large`). */
19
+ payloadBytes: 2 * 1024 * 1024,
20
+ };
21
+ /**
22
+ * The length allowance of one media key that is not the source itself.
23
+ *
24
+ * A non-HTTPS source is staged and the request carries `<publicUrl><media.path>/<token>` instead of it, so measuring the
25
+ * source would refuse a `data:` URL of megabytes that actually spends a few dozen bytes of the request body.
26
+ */
27
+ const STAGED_URL_ALLOWANCE = 'https://line-media.invalid/0000000000000000000000';
28
+ /**
29
+ * The text of a carrier message that exists only to show a quick reply.
30
+ *
31
+ * LINE has no message object without content, and a message of a zero-width word joiner renders as an empty bubble.
32
+ */
33
+ export const QUICK_REPLY_CARRIER = '\u2060';
34
+ /** Report inline media that moves out of its text run into a message object of its own. */
35
+ export function reportMovedMedia(el, ctx) {
36
+ const parent = ctx.ancestors[ctx.ancestors.length - 1];
37
+ if (parent !== undefined && isPhrasingContainer(parent.type)) {
38
+ ctx.report.moved.push({
39
+ tag: el.type,
40
+ reason: 'line-media-split',
41
+ path: ctx.stableId(el),
42
+ });
43
+ }
44
+ }
45
+ /**
46
+ * The latest paragraph, line or space boundary at or before `limit`.
47
+ *
48
+ * The whitespace that ends the boundary stays in the chunk, so concatenating the chunks reproduces the input.
49
+ *
50
+ * @param text - the text to cut.
51
+ * @param limit - the maximum chunk length in UTF-16 code units.
52
+ * @returns the cut index including the boundary whitespace, or -1 for none.
53
+ */
54
+ function boundaryCut(text, limit) {
55
+ const window = text.slice(0, limit);
56
+ const paragraph = window.lastIndexOf('\n\n');
57
+ if (paragraph >= 0)
58
+ return paragraph + 2;
59
+ const line = window.lastIndexOf('\n');
60
+ if (line >= 0)
61
+ return line + 1;
62
+ const space = window.lastIndexOf(' ');
63
+ if (space >= 0)
64
+ return space + 1;
65
+ return -1;
66
+ }
67
+ /** Move a cut left by one unit when it would fall inside a surrogate pair. */
68
+ function avoidSplitPair(text, cut) {
69
+ if (cut <= 0 || cut >= text.length)
70
+ return cut;
71
+ const before = text.charCodeAt(cut - 1);
72
+ const after = text.charCodeAt(cut);
73
+ const high = before >= 0xd800 && before <= 0xdbff;
74
+ const low = after >= 0xdc00 && after <= 0xdfff;
75
+ return high && low ? cut - 1 : cut;
76
+ }
77
+ /**
78
+ * Cut text into chunks a text message object accepts.
79
+ *
80
+ * Point cuts prefer a paragraph break, then a line break, then a space, then a code-unit boundary that does not split a
81
+ * surrogate pair. The chunks concatenate back to the input.
82
+ *
83
+ * @param text - the text of one block.
84
+ * @param limit - the maximum chunk length in UTF-16 code units.
85
+ * @returns one or more chunks.
86
+ */
87
+ export function splitText(text, limit) {
88
+ if (text.length <= limit)
89
+ return [text];
90
+ const chunks = [];
91
+ let rest = text;
92
+ while (rest.length > limit) {
93
+ let cut = boundaryCut(rest, limit);
94
+ if (cut <= 0)
95
+ cut = Math.max(1, limit);
96
+ cut = Math.max(1, avoidSplitPair(rest, cut));
97
+ chunks.push(rest.slice(0, cut));
98
+ rest = rest.slice(cut);
99
+ }
100
+ if (rest !== '')
101
+ chunks.push(rest);
102
+ return chunks;
103
+ }
104
+ /** One message object of a draft, with resource keys resolved by the caller. */
105
+ function messageOf(block, keyOf) {
106
+ switch (block.type) {
107
+ case 'text':
108
+ return { type: 'text', text: block.text };
109
+ case 'image': {
110
+ const url = keyOf(block.ref);
111
+ // LINE documents the preview as a smaller image; the original is the one URL every client can show, and some
112
+ // clients use it for the preview anyway.
113
+ return { type: 'image', originalContentUrl: url, previewImageUrl: url };
114
+ }
115
+ case 'video':
116
+ return {
117
+ type: 'video',
118
+ originalContentUrl: keyOf(block.ref),
119
+ previewImageUrl: keyOf(block.poster),
120
+ };
121
+ case 'audio':
122
+ return {
123
+ type: 'audio',
124
+ originalContentUrl: keyOf(block.ref),
125
+ duration: block.duration,
126
+ };
127
+ }
128
+ }
129
+ /** One LINE action object of a quick reply item. */
130
+ function actionOf(action) {
131
+ switch (action.type) {
132
+ case 'postback':
133
+ return { type: 'postback', label: action.label, data: action.data };
134
+ case 'uri':
135
+ return { type: 'uri', label: action.label, uri: action.uri };
136
+ case 'message':
137
+ return { type: 'message', label: action.label, text: action.text };
138
+ }
139
+ }
140
+ /** Copy one message object with its quote token. */
141
+ function quoteMessage(message, quoteToken) {
142
+ return { ...message, quoteToken };
143
+ }
144
+ /** One quick reply item around a collected button. */
145
+ function quickReplyItemOf(action) {
146
+ return { type: 'action', action: actionOf(action) };
147
+ }
148
+ /**
149
+ * The message objects of one draft.
150
+ *
151
+ * A draft without blocks exists only to carry a quick reply (content that is nothing but buttons), so it gets a text
152
+ * message the quick reply can ride on.
153
+ */
154
+ function messagesOf(draft, keyOf) {
155
+ const blocks = draft.blocks.length > 0
156
+ ? draft.blocks
157
+ : [{ type: 'text', text: QUICK_REPLY_CARRIER }];
158
+ const messages = blocks.map((block) => messageOf(block, keyOf));
159
+ if (draft.actions.length > 0) {
160
+ const last = messages[messages.length - 1];
161
+ messages[messages.length - 1] = {
162
+ ...last,
163
+ quickReply: { items: draft.actions.map(quickReplyItemOf) },
164
+ };
165
+ }
166
+ return messages;
167
+ }
168
+ /**
169
+ * Fold a node stream into requests.
170
+ *
171
+ * @param nodes - rendered nodes, in document order.
172
+ * @returns one draft per request, in send order; never empty.
173
+ */
174
+ export function assembleDraft(nodes) {
175
+ const blocks = [];
176
+ const actions = [];
177
+ let buffer = '';
178
+ const flushText = () => {
179
+ const text = buffer.trim();
180
+ buffer = '';
181
+ if (text === '')
182
+ return;
183
+ for (const chunk of splitText(text, LINE_LIMITS.text)) {
184
+ blocks.push({ type: 'text', text: chunk });
185
+ }
186
+ };
187
+ for (const node of nodes) {
188
+ switch (node.type) {
189
+ case 'text':
190
+ buffer += node.text;
191
+ break;
192
+ case 'media':
193
+ flushText();
194
+ blocks.push(node.block);
195
+ break;
196
+ case 'button':
197
+ actions.push(node.action);
198
+ break;
199
+ }
200
+ }
201
+ flushText();
202
+ const drafts = [];
203
+ for (let index = 0; index < blocks.length; index += LINE_LIMITS.messages) {
204
+ drafts.push({
205
+ blocks: blocks.slice(index, index + LINE_LIMITS.messages),
206
+ actions: [],
207
+ });
208
+ }
209
+ if (drafts.length === 0)
210
+ drafts.push({ blocks: [], actions: [] });
211
+ // The platform shows only the last message object's quick reply, so every button rides the last request.
212
+ if (actions.length > 0) {
213
+ drafts[drafts.length - 1].actions = actions;
214
+ }
215
+ return drafts;
216
+ }
217
+ /** The referrer this adapter wrote, when the target still carries it. */
218
+ function isLineReferrer(value) {
219
+ return (typeof value === 'object' &&
220
+ value !== null &&
221
+ 'timestamp' in value &&
222
+ 'mode' in value);
223
+ }
224
+ /** One resolved resource key of a prepared draft. */
225
+ function resolvedKey(prepared, ref) {
226
+ const resolved = prepared.resolved.get(ref);
227
+ if (resolved === undefined) {
228
+ throw new Error('line: media was not prepared before serialize');
229
+ }
230
+ return resolved.key;
231
+ }
232
+ /** The quote token of this request, when the request answers the message the token belongs to. */
233
+ function quoteTokenOf(ctx) {
234
+ if (ctx.index !== 0 || ctx.quote === undefined)
235
+ return undefined;
236
+ const referrer = ctx.target.referrer;
237
+ if (!isLineReferrer(referrer))
238
+ return undefined;
239
+ if (referrer.messageId !== ctx.quote)
240
+ return undefined;
241
+ return referrer.quoteToken;
242
+ }
243
+ /**
244
+ * Build the exact push body of one prepared draft.
245
+ *
246
+ * @param prepared - the draft with its resource keys resolved.
247
+ * @param ctx - the send context: target, part index and quoted message.
248
+ * @returns the request body.
249
+ * @throws PlatformError `invalid` when the target chat id carries no known prefix.
250
+ */
251
+ export function serializeDraft(prepared, ctx) {
252
+ const messages = messagesOf(prepared.draft, (ref) => resolvedKey(prepared, ref));
253
+ const quoteToken = quoteTokenOf(ctx);
254
+ if (quoteToken !== undefined) {
255
+ const first = messages[0];
256
+ if (first.type === 'text' ||
257
+ first.type === 'image' ||
258
+ first.type === 'video' ||
259
+ first.type === 'sticker') {
260
+ messages[0] = quoteMessage(first, quoteToken);
261
+ }
262
+ else {
263
+ // Only the four types above accept a quote token; an audio object cannot be sent as a quote.
264
+ ctx.bot.ctx.logger.debug('line: the first message object is an %s, which cannot carry a quote token', first.type);
265
+ }
266
+ }
267
+ return { to: chatTargetOf(ctx.target.chat.id), messages };
268
+ }
269
+ /**
270
+ * Hard platform limits of one draft, checked before any request.
271
+ *
272
+ * Text splitting and per-request grouping already keep the draft inside the text, object-count and quick-reply bounds;
273
+ * the checks stay as a regression guard and as the only place a caller learns about a request body that outgrew the
274
+ * 2 MB limit (long media URLs).
275
+ *
276
+ * @param draft - the assembled draft.
277
+ * @returns every violation the platform would refuse.
278
+ */
279
+ export function checkDraft(draft) {
280
+ const violations = [];
281
+ for (const block of draft.blocks) {
282
+ if (block.type !== 'text')
283
+ continue;
284
+ const length = block.text.length;
285
+ if (length <= LINE_LIMITS.text)
286
+ continue;
287
+ violations.push({
288
+ kind: 'size',
289
+ key: 'limit.text.chars',
290
+ limit: LINE_LIMITS.text,
291
+ actual: length,
292
+ message: `LINE text accepts ${LINE_LIMITS.text} UTF-16 code units, got ${length}`,
293
+ });
294
+ }
295
+ if (draft.actions.length > LINE_LIMITS.quickReplies) {
296
+ violations.push({
297
+ kind: 'size',
298
+ key: 'limit.buttons.rows',
299
+ limit: LINE_LIMITS.quickReplies,
300
+ actual: draft.actions.length,
301
+ message: `LINE quick reply accepts ${LINE_LIMITS.quickReplies} items, got ${draft.actions.length}`,
302
+ });
303
+ }
304
+ const bytes = Buffer.byteLength(JSON.stringify(messagesOf(draft, (ref) => /^https:\/\//i.test(ref.src) ? ref.src : STAGED_URL_ALLOWANCE)), 'utf8');
305
+ if (bytes > LINE_LIMITS.payloadBytes) {
306
+ violations.push({
307
+ kind: 'size',
308
+ key: 'limit.payload.bytes',
309
+ limit: LINE_LIMITS.payloadBytes,
310
+ actual: bytes,
311
+ message: `LINE accepts a ${LINE_LIMITS.payloadBytes}-byte request body, got ${bytes}`,
312
+ });
313
+ }
314
+ return violations;
315
+ }
316
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/modes/shared.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AA2C3C,wCAAwC;AACxC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,wDAAwD;IACxD,IAAI,EAAE,KAAK;IACX,wCAAwC;IACxC,QAAQ,EAAE,CAAC;IACX,6CAA6C;IAC7C,YAAY,EAAE,EAAE;IAChB,mDAAmD;IACnD,YAAY,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;CACrB,CAAA;AAEV;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,mDAAmD,CAAA;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAA;AAE3C,2FAA2F;AAC3F,MAAM,UAAU,gBAAgB,CAC9B,EAAW,EACX,GAAiC;IAEjC,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACtD,IAAI,MAAM,KAAK,SAAS,IAAI,mBAAmB,CAAC,MAAM,CAAC,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