@zhin.js/adapter-line 1.1.20 → 1.1.22
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/CHANGELOG.md +62 -0
- package/adapters/line/index.js +10 -3
- package/adapters/line/index.ts +10 -3
- package/lib/endpoint.js +2 -0
- package/lib/protocol.d.ts +2 -5
- package/lib/self-profile.d.ts +9 -0
- package/lib/self-profile.js +13 -0
- package/package.json +19 -19
- package/plugin.js +1 -0
- package/schema.json +106 -1
- package/src/endpoint.ts +2 -0
- package/src/protocol.ts +2 -1
- package/src/self-profile.ts +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# @zhin.js/adapter-line
|
|
2
2
|
|
|
3
|
+
## 1.1.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 41ff1a5: ADR 0044 C5: every official adapter now declares a capability `profile` (its `segments` moved into `profile.default.messaging.segments`). icqq declares the complete profile (per conversation kind: scene, all 14 actions with real limits, events, feedback, delivery) and implements the seven new management ports (`pokeUser`, `unmuteGroupMember`, `muteAllGroupMembers`, `setGroupCard`, `setGroupTitle`, `setGroupEssence`, `inviteGroupMember`) with fresh bot-role reads. qq official declares its passive reply windows; undeclared capabilities stay unsupported.
|
|
8
|
+
- cbd3f14: ADR 0044 integration and C6 guard. `delivery.spool` now reproduces the pre-0044 media rule (icqq `false`, every other official adapter `true`). icqq narrows `actions.recall.others` unless the Bot is admin or owner, and declares recall for groups. Endpoint kind capabilities merge the Endpoint's `operations` (Discord reactions keep working; Discord declares reaction feedback). Adapters in the `@zhin.js/` scope are trusted: their custom prompt text is not labelled `external_content`. Core no longer keeps a telegram/discord interactive-policy table (adapters declare `segments.interactive`). New `pnpm check:no-platform-branches` blocks platform-name branches in runtime code.
|
|
9
|
+
- 4fe49b5: 支持配置按需生效:分离保存与有效版本,独立变更先应用,账号资料更新保留连接,模型按回合使用确定版本;Console 返回结构化应用结果。监听改为仅显式 --watch 启用,开发模板显式选择源码和配置监听。
|
|
10
|
+
|
|
11
|
+
自变更消费配置应用回执,避免已处理配置被二次重载;持久化本次写入修订和应用结果,未知结果或修订冲突时停止自动续作并保留现场,恢复不会覆盖未经本次变更确认的配置。
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [b249e5e]
|
|
14
|
+
- Updated dependencies [57661f6]
|
|
15
|
+
- Updated dependencies [cbd3f14]
|
|
16
|
+
- Updated dependencies [299863a]
|
|
17
|
+
- Updated dependencies [aaa93d7]
|
|
18
|
+
- Updated dependencies [bd524d1]
|
|
19
|
+
- Updated dependencies [126ae99]
|
|
20
|
+
- Updated dependencies [4fe49b5]
|
|
21
|
+
- Updated dependencies [cce07db]
|
|
22
|
+
- Updated dependencies [b652db3]
|
|
23
|
+
- Updated dependencies [0315ba0]
|
|
24
|
+
- Updated dependencies [00be764]
|
|
25
|
+
- @zhin.js/core@1.1.56
|
|
26
|
+
- @zhin.js/adapter@1.1.28
|
|
27
|
+
- @zhin.js/im-contract@1.1.11
|
|
28
|
+
- @zhin.js/tool@1.1.15
|
|
29
|
+
- @zhin.js/skill@1.1.13
|
|
30
|
+
- @zhin.js/host-http@1.1.14
|
|
31
|
+
- @zhin.js/feature-kit@1.1.12
|
|
32
|
+
- @zhin.js/client@1.1.24
|
|
33
|
+
- @zhin.js/page@1.1.14
|
|
34
|
+
- @zhin.js/agent-feature@1.1.13
|
|
35
|
+
|
|
36
|
+
## 1.1.21
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- af8f803: Use the current Endpoint's platform profile for Agent account identity, with per-field configured fallbacks and scoped, identity-approved profile tools. Keep SOUL first-person and independent of account names. Profile ports preserve the source Client, cancellation, truthful update outcomes and private image authority.
|
|
41
|
+
|
|
42
|
+
Adapter Feature API 2.1 and Tool Feature API 1.1 describe the additive profile requirements; new Core, official adapters and generated plugins declare the corresponding floors. Existing compatible API-2.0/API-1.0 plugins remain accepted by the newer providers. npm releases remain patch.
|
|
43
|
+
|
|
44
|
+
Private IM assets now bind to the full canonical conversation and principal. Existing IM asset records that contain only the earlier lossy hash remain on disk until their original expiry, but cannot be safely rebound; recapture them. No automatic file deletion, platform profile mutation or workspace SOUL rewrite occurs during upgrade.
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [b88e988]
|
|
47
|
+
- Updated dependencies [f78eb84]
|
|
48
|
+
- Updated dependencies [c15cef9]
|
|
49
|
+
- Updated dependencies [b0c02a2]
|
|
50
|
+
- Updated dependencies [af8f803]
|
|
51
|
+
- Updated dependencies [26fda97]
|
|
52
|
+
- Updated dependencies [976886c]
|
|
53
|
+
- Updated dependencies [032dc96]
|
|
54
|
+
- @zhin.js/adapter@1.1.27
|
|
55
|
+
- @zhin.js/client@1.1.23
|
|
56
|
+
- @zhin.js/im-contract@1.1.10
|
|
57
|
+
- @zhin.js/core@1.1.55
|
|
58
|
+
- @zhin.js/tool@1.1.14
|
|
59
|
+
- @zhin.js/page@1.1.13
|
|
60
|
+
- @zhin.js/host-http@1.1.13
|
|
61
|
+
- @zhin.js/agent-feature@1.1.12
|
|
62
|
+
- @zhin.js/feature-kit@1.1.11
|
|
63
|
+
- @zhin.js/skill@1.1.12
|
|
64
|
+
|
|
3
65
|
## 1.1.20
|
|
4
66
|
|
|
5
67
|
### Patch Changes
|
package/adapters/line/index.js
CHANGED
|
@@ -9,9 +9,16 @@ export { LineEndpoint } from "../../lib/endpoint.js";
|
|
|
9
9
|
export default defineAdapter({
|
|
10
10
|
capabilities: ['inbound', 'outbound'],
|
|
11
11
|
// LINE Messaging API 媒体消息仅消费远程 URL;无按钮交互面,交互段降级纯文本。
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
profile: {
|
|
13
|
+
default: {
|
|
14
|
+
messaging: {
|
|
15
|
+
segments: {
|
|
16
|
+
outboundMedia: ['url'],
|
|
17
|
+
interactive: 'text',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
delivery: { send: true, spool: true },
|
|
21
|
+
},
|
|
15
22
|
},
|
|
16
23
|
createAdapter: context => new LineAdapter(context),
|
|
17
24
|
});
|
package/adapters/line/index.ts
CHANGED
|
@@ -13,9 +13,16 @@ export type { LineEndpointOptions, LineFetch } from '../../src/endpoint.js';
|
|
|
13
13
|
export default defineAdapter<LineEndpointConfig>({
|
|
14
14
|
capabilities: ['inbound', 'outbound'],
|
|
15
15
|
// LINE Messaging API 媒体消息仅消费远程 URL;无按钮交互面,交互段降级纯文本。
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
profile: {
|
|
17
|
+
default: {
|
|
18
|
+
messaging: {
|
|
19
|
+
segments: {
|
|
20
|
+
outboundMedia: ['url'],
|
|
21
|
+
interactive: 'text',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
delivery: { send: true, spool: true },
|
|
25
|
+
},
|
|
19
26
|
},
|
|
20
27
|
createAdapter: context => new LineAdapter(context),
|
|
21
28
|
});
|
package/lib/endpoint.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createEndpointSpecification, endpointSpec } from 'zhin.js/adapter';
|
|
2
2
|
import { LineClient } from './client.js';
|
|
3
|
+
import { createLineSelfProfile } from './self-profile.js';
|
|
3
4
|
/** Actual protocol Client; framework lifecycle and admission stay in their symbol namespace. */
|
|
4
5
|
export class LineEndpoint extends LineClient {
|
|
5
6
|
[endpointSpec] = this.#createSpecification();
|
|
@@ -11,6 +12,7 @@ export class LineEndpoint extends LineClient {
|
|
|
11
12
|
send: (request) => this.sendPayload(request),
|
|
12
13
|
name: this.configName(),
|
|
13
14
|
management: this.endpointManagement,
|
|
15
|
+
profile: createLineSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
|
|
14
16
|
};
|
|
15
17
|
Object.defineProperty(hooks, 'transportState', { get: () => this.transportState });
|
|
16
18
|
return createEndpointSpecification(this, hooks);
|
package/lib/protocol.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
* LINE Messaging API protocol helpers — no legacy Adapter/Endpoint / segment-mapper.
|
|
3
|
-
* Canonicalization is owned by gateway/core before endpoint.send.
|
|
4
|
-
*/
|
|
1
|
+
import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
|
|
5
2
|
import type { IncomingMessage } from 'node:http';
|
|
6
3
|
import { type ConversationRef } from '@zhin.js/im-contract';
|
|
7
4
|
/** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
|
|
8
|
-
export interface LineEndpointConfig {
|
|
5
|
+
export interface LineEndpointConfig extends EndpointProfileConfiguration {
|
|
9
6
|
readonly id: string;
|
|
10
7
|
readonly channelSecret: string;
|
|
11
8
|
readonly channelAccessToken: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EndpointProfile } from 'zhin.js/adapter';
|
|
2
|
+
import type { LineApiClient } from './api-client.js';
|
|
3
|
+
interface LineSelfProfileOptions {
|
|
4
|
+
readonly client: Pick<LineApiClient, 'request'>;
|
|
5
|
+
readonly reportAccount: (id: string) => void;
|
|
6
|
+
}
|
|
7
|
+
/** Messaging API exposes bot info, but profile edits remain in LINE account administration. */
|
|
8
|
+
export declare function createLineSelfProfile({ client, reportAccount }: LineSelfProfileOptions): EndpointProfile;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Messaging API exposes bot info, but profile edits remain in LINE account administration. */
|
|
2
|
+
export function createLineSelfProfile({ client, reportAccount }) {
|
|
3
|
+
return Object.freeze({
|
|
4
|
+
writableFields: Object.freeze([]),
|
|
5
|
+
async read({ signal }) {
|
|
6
|
+
const self = await client.request('/v2/bot/info', { signal });
|
|
7
|
+
if (!self.userId || typeof self.displayName !== 'string')
|
|
8
|
+
throw new Error('LINE returned an incomplete bot profile');
|
|
9
|
+
reportAccount(self.userId);
|
|
10
|
+
return { nickname: self.displayName, ...(typeof self.pictureUrl === 'string' ? { avatar: self.pictureUrl } : {}) };
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-line",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"description": "Zhin.js LINE Messaging API adapter for Plugin Runtime (HTTP webhook)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -31,26 +31,26 @@
|
|
|
31
31
|
"directory": "plugins/adapters/line"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@zhin.js/adapter": "1.1.
|
|
35
|
-
"@zhin.js/agent-feature": "1.1.
|
|
36
|
-
"@zhin.js/client": "1.1.
|
|
34
|
+
"@zhin.js/adapter": "1.1.28",
|
|
35
|
+
"@zhin.js/agent-feature": "1.1.13",
|
|
36
|
+
"@zhin.js/client": "1.1.24",
|
|
37
37
|
"@zhin.js/console-contract": "1.1.3",
|
|
38
|
-
"@zhin.js/core": "1.1.
|
|
39
|
-
"@zhin.js/feature-kit": "1.1.
|
|
40
|
-
"@zhin.js/host-http": "1.1.
|
|
41
|
-
"@zhin.js/im-contract": "1.1.
|
|
38
|
+
"@zhin.js/core": "1.1.56",
|
|
39
|
+
"@zhin.js/feature-kit": "1.1.12",
|
|
40
|
+
"@zhin.js/host-http": "1.1.14",
|
|
41
|
+
"@zhin.js/im-contract": "1.1.11",
|
|
42
42
|
"@zhin.js/logger": "1.1.2",
|
|
43
|
-
"@zhin.js/page": "1.1.
|
|
44
|
-
"@zhin.js/skill": "1.1.
|
|
45
|
-
"@zhin.js/tool": "1.1.
|
|
43
|
+
"@zhin.js/page": "1.1.14",
|
|
44
|
+
"@zhin.js/skill": "1.1.13",
|
|
45
|
+
"@zhin.js/tool": "1.1.15"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"zod": "^4.0.0",
|
|
49
|
-
"@zhin.js/adapter": "^1.1.
|
|
50
|
-
"@zhin.js/command": "^1.1.
|
|
51
|
-
"@zhin.js/core": "^1.1.
|
|
52
|
-
"@zhin.js/host-http": "^1.1.
|
|
53
|
-
"zhin.js": "^1.1.
|
|
49
|
+
"@zhin.js/adapter": "^1.1.28",
|
|
50
|
+
"@zhin.js/command": "^1.1.14",
|
|
51
|
+
"@zhin.js/core": "^1.1.56",
|
|
52
|
+
"@zhin.js/host-http": "^1.1.14",
|
|
53
|
+
"zhin.js": "^1.1.21"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
56
56
|
"@zhin.js/command": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
69
|
"vitest": "^4.1.10",
|
|
70
70
|
"zod": "^4.4.3",
|
|
71
|
-
"zhin.js": "1.1.
|
|
71
|
+
"zhin.js": "1.1.21"
|
|
72
72
|
},
|
|
73
73
|
"files": [
|
|
74
74
|
"adapters",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"features": [
|
|
101
101
|
{
|
|
102
102
|
"package": "@zhin.js/adapter",
|
|
103
|
-
"api": "^2.
|
|
103
|
+
"api": "^2.1.0"
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
"package": "@zhin.js/command",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
"package": "@zhin.js/tool",
|
|
111
|
-
"api": "^1.
|
|
111
|
+
"api": "^1.1.0"
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
"package": "@zhin.js/skill",
|
package/plugin.js
CHANGED
|
@@ -3,6 +3,7 @@ import { definePlugin, pluginConsoleRpcToken } from 'zhin.js';
|
|
|
3
3
|
import { createLineConsoleRpc } from "./lib/console.js";
|
|
4
4
|
export default definePlugin({
|
|
5
5
|
name: 'line',
|
|
6
|
+
configUpdate: { featurePaths: [['nickname'], ['profile'], ['endpoints']] },
|
|
6
7
|
metadata: {
|
|
7
8
|
displayName: 'LINE Messaging API Adapter',
|
|
8
9
|
},
|
package/schema.json
CHANGED
|
@@ -95,6 +95,27 @@
|
|
|
95
95
|
"id": {
|
|
96
96
|
"type": "string",
|
|
97
97
|
"description": "LINE bot name"
|
|
98
|
+
},
|
|
99
|
+
"nickname": {
|
|
100
|
+
"type": [
|
|
101
|
+
"string",
|
|
102
|
+
"null"
|
|
103
|
+
],
|
|
104
|
+
"description": "账号昵称兜底",
|
|
105
|
+
"x-i18n": {
|
|
106
|
+
"en": {
|
|
107
|
+
"description": "Fallback account nickname"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"profile": {
|
|
112
|
+
"$ref": "#/$defs/selfProfileFallback",
|
|
113
|
+
"description": "账号资料兜底",
|
|
114
|
+
"x-i18n": {
|
|
115
|
+
"en": {
|
|
116
|
+
"description": "Fallback account profile"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
98
119
|
}
|
|
99
120
|
},
|
|
100
121
|
"required": [
|
|
@@ -118,9 +139,93 @@
|
|
|
118
139
|
"description": "Command prefix. The default empty string allows unprefixed commands; '/' requires a leading slash. Each endpoints[i] can override it."
|
|
119
140
|
}
|
|
120
141
|
}
|
|
142
|
+
},
|
|
143
|
+
"nickname": {
|
|
144
|
+
"type": [
|
|
145
|
+
"string",
|
|
146
|
+
"null"
|
|
147
|
+
],
|
|
148
|
+
"description": "账号昵称兜底",
|
|
149
|
+
"x-i18n": {
|
|
150
|
+
"en": {
|
|
151
|
+
"description": "Fallback account nickname"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"profile": {
|
|
156
|
+
"$ref": "#/$defs/selfProfileFallback",
|
|
157
|
+
"description": "账号资料兜底",
|
|
158
|
+
"x-i18n": {
|
|
159
|
+
"en": {
|
|
160
|
+
"description": "Fallback account profile"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
121
163
|
}
|
|
122
164
|
},
|
|
123
165
|
"required": [
|
|
124
166
|
"endpoints"
|
|
125
|
-
]
|
|
167
|
+
],
|
|
168
|
+
"$defs": {
|
|
169
|
+
"selfProfileFallback": {
|
|
170
|
+
"type": "object",
|
|
171
|
+
"additionalProperties": false,
|
|
172
|
+
"properties": {
|
|
173
|
+
"gender": {
|
|
174
|
+
"type": [
|
|
175
|
+
"string",
|
|
176
|
+
"null"
|
|
177
|
+
],
|
|
178
|
+
"enum": [
|
|
179
|
+
"male",
|
|
180
|
+
"female",
|
|
181
|
+
"other",
|
|
182
|
+
"unknown",
|
|
183
|
+
null
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
"age": {
|
|
187
|
+
"type": [
|
|
188
|
+
"integer",
|
|
189
|
+
"null"
|
|
190
|
+
],
|
|
191
|
+
"minimum": 0
|
|
192
|
+
},
|
|
193
|
+
"birthday": {
|
|
194
|
+
"type": [
|
|
195
|
+
"string",
|
|
196
|
+
"null"
|
|
197
|
+
],
|
|
198
|
+
"pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
|
|
199
|
+
},
|
|
200
|
+
"signature": {
|
|
201
|
+
"type": [
|
|
202
|
+
"string",
|
|
203
|
+
"null"
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
"avatar": {
|
|
207
|
+
"type": [
|
|
208
|
+
"string",
|
|
209
|
+
"null"
|
|
210
|
+
],
|
|
211
|
+
"pattern": "^(https?://[^\\s/?#]+(?:[/?#].*)?|)$"
|
|
212
|
+
},
|
|
213
|
+
"interests": {
|
|
214
|
+
"type": [
|
|
215
|
+
"array",
|
|
216
|
+
"null"
|
|
217
|
+
],
|
|
218
|
+
"items": {
|
|
219
|
+
"type": "string"
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"bio": {
|
|
223
|
+
"type": [
|
|
224
|
+
"string",
|
|
225
|
+
"null"
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
126
231
|
}
|
package/src/endpoint.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createEndpointSpecification, endpointSpec, type Endpoint } from 'zhin.js/adapter';
|
|
2
2
|
import { LineClient, type LineEndpointOptions } from './client.js';
|
|
3
|
+
import { createLineSelfProfile } from './self-profile.js';
|
|
3
4
|
export type { LineEndpointOptions } from './client.js';
|
|
4
5
|
export type { LineFetch } from './client.js';
|
|
5
6
|
|
|
@@ -14,6 +15,7 @@ export class LineEndpoint extends LineClient implements Endpoint {
|
|
|
14
15
|
send: (request: import('zhin.js/adapter').EndpointSendRequest) => this.sendPayload(request),
|
|
15
16
|
name: this.configName(),
|
|
16
17
|
management: this.endpointManagement,
|
|
18
|
+
profile: createLineSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
|
|
17
19
|
};
|
|
18
20
|
Object.defineProperty(hooks, 'transportState', { get: () => this.transportState });
|
|
19
21
|
return createEndpointSpecification(this, hooks);
|
package/src/protocol.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
|
|
1
2
|
/**
|
|
2
3
|
* LINE Messaging API protocol helpers — no legacy Adapter/Endpoint / segment-mapper.
|
|
3
4
|
* Canonicalization is owned by gateway/core before endpoint.send.
|
|
@@ -11,7 +12,7 @@ import { formatCompact, getLogger } from '@zhin.js/logger';
|
|
|
11
12
|
const logger = getLogger('line');
|
|
12
13
|
|
|
13
14
|
/** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
|
|
14
|
-
export interface LineEndpointConfig {
|
|
15
|
+
export interface LineEndpointConfig extends EndpointProfileConfiguration {
|
|
15
16
|
readonly id: string;
|
|
16
17
|
readonly channelSecret: string;
|
|
17
18
|
readonly channelAccessToken: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EndpointProfile } from 'zhin.js/adapter';
|
|
2
|
+
import type { LineApiClient } from './api-client.js';
|
|
3
|
+
|
|
4
|
+
interface LineSelfProfileOptions {
|
|
5
|
+
readonly client: Pick<LineApiClient, 'request'>;
|
|
6
|
+
readonly reportAccount: (id: string) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Messaging API exposes bot info, but profile edits remain in LINE account administration. */
|
|
10
|
+
export function createLineSelfProfile({ client, reportAccount }: LineSelfProfileOptions): EndpointProfile {
|
|
11
|
+
return Object.freeze<EndpointProfile>({
|
|
12
|
+
writableFields: Object.freeze([]),
|
|
13
|
+
async read({ signal }) {
|
|
14
|
+
const self = await client.request<{ userId: string; displayName: string; pictureUrl?: string }>('/v2/bot/info', { signal });
|
|
15
|
+
if (!self.userId || typeof self.displayName !== 'string') throw new Error('LINE returned an incomplete bot profile');
|
|
16
|
+
reportAccount(self.userId);
|
|
17
|
+
return { nickname: self.displayName, ...(typeof self.pictureUrl === 'string' ? { avatar: self.pictureUrl } : {}) };
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|