@satorijs/adapter-lark 3.1.6 → 3.2.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/lib/index.js CHANGED
@@ -67,7 +67,7 @@ __name(adaptSender, "adaptSender");
67
67
  function adaptMessage(bot, data, session) {
68
68
  var _a, _b;
69
69
  const json = JSON.parse(data.message.content);
70
- const assetEndpoint = (0, import_satori.trimSlash)((_a = bot.config.selfUrl) != null ? _a : bot.ctx.router.config.selfUrl) + bot.config.path + "/assets";
70
+ const assetEndpoint = (0, import_satori.trimSlash)((_a = bot.config.selfUrl) != null ? _a : bot.ctx.server.config.selfUrl) + bot.config.path + "/assets";
71
71
  const content = [];
72
72
  switch (data.message.message_type) {
73
73
  case "text": {
@@ -126,7 +126,7 @@ __name(adaptSession, "adaptSession");
126
126
  async function decodeMessage(bot, body) {
127
127
  var _a, _b;
128
128
  const json = JSON.parse(body.body.content);
129
- const assetEndpoint = (0, import_satori.trimSlash)((_a = bot.config.selfUrl) != null ? _a : bot.ctx.router.config.selfUrl) + bot.config.path + "/assets";
129
+ const assetEndpoint = (0, import_satori.trimSlash)((_a = bot.config.selfUrl) != null ? _a : bot.ctx.server.config.selfUrl) + bot.config.path + "/assets";
130
130
  const content = [];
131
131
  switch (body.msg_type) {
132
132
  case "text": {
@@ -248,7 +248,7 @@ var _HttpServer = class _HttpServer extends import_satori2.Adapter {
248
248
  }
249
249
  async connect(bot) {
250
250
  const { path } = bot.config;
251
- bot.ctx.router.post(path, (ctx) => {
251
+ bot.ctx.server.post(path, (ctx) => {
252
252
  var _a;
253
253
  this._refreshCipher();
254
254
  const signature = ctx.get("X-Lark-Signature");
@@ -291,7 +291,7 @@ var _HttpServer = class _HttpServer extends import_satori2.Adapter {
291
291
  this.dispatchSession(body);
292
292
  return ctx.status = 200;
293
293
  });
294
- bot.ctx.router.get(path + "/assets/:type/:message_id/:key", async (ctx) => {
294
+ bot.ctx.server.get(path + "/assets/:type/:message_id/:key", async (ctx) => {
295
295
  const type = ctx.params.type === "image" ? "image" : "file";
296
296
  const key = ctx.params.key;
297
297
  const messageId = ctx.params.message_id;
@@ -348,7 +348,7 @@ var _HttpServer = class _HttpServer extends import_satori2.Adapter {
348
348
  }
349
349
  };
350
350
  __name(_HttpServer, "HttpServer");
351
- __publicField(_HttpServer, "inject", ["router"]);
351
+ __publicField(_HttpServer, "inject", ["server"]);
352
352
  var HttpServer = _HttpServer;
353
353
  ((HttpServer2) => {
354
354
  HttpServer2.createConfig = /* @__PURE__ */ __name((path) => import_satori2.Schema.object({
@@ -649,7 +649,7 @@ var _LarkBot = class _LarkBot extends import_satori5.Bot {
649
649
  internal;
650
650
  constructor(ctx, config) {
651
651
  super(ctx, config, "lark");
652
- if (!config.selfUrl && !ctx.router.config.selfUrl) {
652
+ if (!config.selfUrl && !ctx.server.config.selfUrl) {
653
653
  this.logger.warn("selfUrl is not set, some features may not work");
654
654
  }
655
655
  this.selfId = config.appId;
@@ -731,7 +731,7 @@ var _LarkBot = class _LarkBot extends import_satori5.Bot {
731
731
  }
732
732
  };
733
733
  __name(_LarkBot, "LarkBot");
734
- __publicField(_LarkBot, "inject", ["router"]);
734
+ __publicField(_LarkBot, "inject", ["server"]);
735
735
  __publicField(_LarkBot, "MessageEncoder", LarkMessageEncoder);
736
736
  var LarkBot = _LarkBot;
737
737
  ((LarkBot2) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@satorijs/adapter-lark",
3
3
  "description": "Lark (飞书) Adapter for Satorijs",
4
- "version": "3.1.6",
4
+ "version": "3.2.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -33,10 +33,10 @@
33
33
  "chat"
34
34
  ],
35
35
  "devDependencies": {
36
- "@satorijs/router": "^1.1.2"
36
+ "@cordisjs/server": "^0.1.3"
37
37
  },
38
38
  "peerDependencies": {
39
- "@satorijs/satori": "^3.2.0"
39
+ "@satorijs/satori": "^3.3.0"
40
40
  },
41
41
  "dependencies": {
42
42
  "form-data": "^4.0.0"
package/src/bot.ts CHANGED
@@ -6,7 +6,7 @@ import { Internal } from './types'
6
6
  import * as Utils from './utils'
7
7
 
8
8
  export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config> {
9
- static inject = ['router']
9
+ static inject = ['server']
10
10
  static MessageEncoder = LarkMessageEncoder
11
11
 
12
12
  _token?: string
@@ -19,7 +19,7 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
19
19
  super(ctx, config, 'lark')
20
20
 
21
21
  // lark bot needs config.selfUrl to be set as it should be serve on a public url
22
- if (!config.selfUrl && !ctx.router.config.selfUrl) {
22
+ if (!config.selfUrl && !ctx.server.config.selfUrl) {
23
23
  this.logger.warn('selfUrl is not set, some features may not work')
24
24
  }
25
25
 
package/src/http.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import internal from 'stream'
2
2
  import { Adapter, Context, Logger, Schema } from '@satorijs/satori'
3
- import {} from '@satorijs/router'
3
+ import {} from '@cordisjs/server'
4
4
 
5
5
  import { FeishuBot } from './bot'
6
6
  import { AllEvents } from './types'
7
7
  import { adaptSession, Cipher } from './utils'
8
8
 
9
9
  export class HttpServer<C extends Context = Context> extends Adapter<C, FeishuBot<C>> {
10
- static inject = ['router']
10
+ static inject = ['server']
11
11
 
12
12
  private logger: Logger
13
13
  private ciphers: Record<string, Cipher> = {}
@@ -26,7 +26,7 @@ export class HttpServer<C extends Context = Context> extends Adapter<C, FeishuBo
26
26
 
27
27
  async connect(bot: FeishuBot) {
28
28
  const { path } = bot.config
29
- bot.ctx.router.post(path, (ctx) => {
29
+ bot.ctx.server.post(path, (ctx) => {
30
30
  this._refreshCipher()
31
31
 
32
32
  // compare signature if encryptKey is set
@@ -77,7 +77,7 @@ export class HttpServer<C extends Context = Context> extends Adapter<C, FeishuBo
77
77
  return ctx.status = 200
78
78
  })
79
79
 
80
- bot.ctx.router.get(path + '/assets/:type/:message_id/:key', async (ctx) => {
80
+ bot.ctx.server.get(path + '/assets/:type/:message_id/:key', async (ctx) => {
81
81
  const type = ctx.params.type === 'image' ? 'image' : 'file'
82
82
  const key = ctx.params.key
83
83
  const messageId = ctx.params.message_id
package/src/utils.ts CHANGED
@@ -25,7 +25,7 @@ export function adaptSender(sender: Sender, session: Session): Session {
25
25
 
26
26
  export function adaptMessage(bot: FeishuBot, data: Events['im.message.receive_v1']['event'], session: Session): Session {
27
27
  const json = JSON.parse(data.message.content) as MessageContentType<MessageType>
28
- const assetEndpoint = trimSlash(bot.config.selfUrl ?? bot.ctx.router.config.selfUrl) + bot.config.path + '/assets'
28
+ const assetEndpoint = trimSlash(bot.config.selfUrl ?? bot.ctx.server.config.selfUrl) + bot.config.path + '/assets'
29
29
  const content: (string | h)[] = []
30
30
  switch (data.message.message_type) {
31
31
  case 'text': {
@@ -88,7 +88,7 @@ export function adaptSession<C extends Context>(bot: FeishuBot<C>, body: AllEven
88
88
  // TODO: This function has many duplicated code with `adaptMessage`, should refactor them
89
89
  export async function decodeMessage(bot: LarkBot, body: LarkMessage): Promise<Message> {
90
90
  const json = JSON.parse(body.body.content) as MessageContentType<MessageType>
91
- const assetEndpoint = trimSlash(bot.config.selfUrl ?? bot.ctx.router.config.selfUrl) + bot.config.path + '/assets'
91
+ const assetEndpoint = trimSlash(bot.config.selfUrl ?? bot.ctx.server.config.selfUrl) + bot.config.path + '/assets'
92
92
  const content: h[] = []
93
93
  switch (body.msg_type) {
94
94
  case 'text': {