@zhin.js/command 1.1.4 → 1.1.5
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/command-index.js +5 -4
- package/package.json +4 -4
- package/src/command-index.ts +9 -8
package/lib/command-index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SegmentMatcher, TypeMatcherRegistry, } from 'segment-matcher';
|
|
2
|
-
import { operationClientAdapter } from '@zhin.js/feature-kit';
|
|
2
|
+
import { bindOperationInput, operationClientAdapter } from '@zhin.js/feature-kit';
|
|
3
3
|
import { permissionHostToken, toPermissionSubject, } from '@zhin.js/permission';
|
|
4
4
|
import { createCommandContext, resolveCommandSession, resolveDynamicParams, } from './definition.js';
|
|
5
5
|
const segmentFields = {
|
|
@@ -133,7 +133,6 @@ export class CommandIndex {
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
const interaction = interactionFactory?.(source);
|
|
137
136
|
const shortcut = this.#matchShortcut(input);
|
|
138
137
|
if (shortcut) {
|
|
139
138
|
if (!commandAdapterMatches(shortcut.record, source)) {
|
|
@@ -142,7 +141,8 @@ export class CommandIndex {
|
|
|
142
141
|
if (!(await this.#permitAllows(shortcut.record, source, operationSnapshot))) {
|
|
143
142
|
return Object.freeze({ matched: false });
|
|
144
143
|
}
|
|
145
|
-
const
|
|
144
|
+
const authorSource = bindOperationInput(source, shortcut.record.slot.owner, operationSnapshot);
|
|
145
|
+
const value = await shortcut.record.slot.definition.execute(createCommandContext(operationSnapshot, shortcut.record.slot.owner, Object.freeze([]), resolveDynamicParams(shortcut.params, authorSource), authorSource, Object.freeze([]), interactionFactory?.(authorSource), shortcut.record.slot.definition.adapter));
|
|
146
146
|
return Object.freeze({
|
|
147
147
|
matched: true,
|
|
148
148
|
command: shortcut.record.name,
|
|
@@ -160,7 +160,8 @@ export class CommandIndex {
|
|
|
160
160
|
return Object.freeze({ matched: false });
|
|
161
161
|
}
|
|
162
162
|
const args = textArgs(match.remaining);
|
|
163
|
-
const
|
|
163
|
+
const authorSource = bindOperationInput(source, match.command.slot.owner, operationSnapshot);
|
|
164
|
+
const value = await match.command.slot.definition.execute(createCommandContext(operationSnapshot, match.command.slot.owner, args, resolveDynamicParams(match.params, authorSource), authorSource, match.remaining, interactionFactory?.(authorSource), match.command.slot.definition.adapter));
|
|
164
165
|
return Object.freeze({
|
|
165
166
|
matched: true,
|
|
166
167
|
command: match.command.name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/command",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Convention-based Command Feature for Zhin Plugin Runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"segment-matcher": "^1.0.5",
|
|
21
|
-
"@zhin.js/feature-kit": "1.1.
|
|
21
|
+
"@zhin.js/feature-kit": "1.1.3",
|
|
22
22
|
"@zhin.js/interaction": "1.1.0",
|
|
23
|
-
"@zhin.js/permission": "1.1.
|
|
24
|
-
"@zhin.js/plugin-runtime": "1.1.
|
|
23
|
+
"@zhin.js/permission": "1.1.4",
|
|
24
|
+
"@zhin.js/plugin-runtime": "1.1.12"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^26.1.2",
|
package/src/command-index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
RuntimeSnapshot,
|
|
10
10
|
} from '@zhin.js/plugin-runtime';
|
|
11
11
|
import type { UserInteractionFactory } from '@zhin.js/interaction';
|
|
12
|
-
import { operationClientAdapter } from '@zhin.js/feature-kit';
|
|
12
|
+
import { bindOperationInput, operationClientAdapter } from '@zhin.js/feature-kit';
|
|
13
13
|
import {
|
|
14
14
|
permissionHostToken,
|
|
15
15
|
toPermissionSubject,
|
|
@@ -249,7 +249,6 @@ export class CommandIndex {
|
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
const interaction = interactionFactory?.(source);
|
|
253
252
|
const shortcut = this.#matchShortcut(input);
|
|
254
253
|
if (shortcut) {
|
|
255
254
|
if (!commandAdapterMatches(shortcut.record, source)) {
|
|
@@ -258,15 +257,16 @@ export class CommandIndex {
|
|
|
258
257
|
if (!(await this.#permitAllows(shortcut.record, source, operationSnapshot))) {
|
|
259
258
|
return Object.freeze({ matched: false });
|
|
260
259
|
}
|
|
260
|
+
const authorSource = bindOperationInput(source, shortcut.record.slot.owner, operationSnapshot);
|
|
261
261
|
const value = await shortcut.record.slot.definition.execute(
|
|
262
262
|
createCommandContext(
|
|
263
263
|
operationSnapshot,
|
|
264
264
|
shortcut.record.slot.owner,
|
|
265
265
|
Object.freeze([]),
|
|
266
|
-
resolveDynamicParams(shortcut.params,
|
|
267
|
-
|
|
266
|
+
resolveDynamicParams(shortcut.params, authorSource),
|
|
267
|
+
authorSource,
|
|
268
268
|
Object.freeze([]),
|
|
269
|
-
|
|
269
|
+
interactionFactory?.(authorSource),
|
|
270
270
|
shortcut.record.slot.definition.adapter,
|
|
271
271
|
),
|
|
272
272
|
);
|
|
@@ -287,15 +287,16 @@ export class CommandIndex {
|
|
|
287
287
|
return Object.freeze({ matched: false });
|
|
288
288
|
}
|
|
289
289
|
const args = textArgs(match.remaining);
|
|
290
|
+
const authorSource = bindOperationInput(source, match.command.slot.owner, operationSnapshot);
|
|
290
291
|
const value = await match.command.slot.definition.execute(
|
|
291
292
|
createCommandContext(
|
|
292
293
|
operationSnapshot,
|
|
293
294
|
match.command.slot.owner,
|
|
294
295
|
args,
|
|
295
|
-
resolveDynamicParams(match.params,
|
|
296
|
-
|
|
296
|
+
resolveDynamicParams(match.params, authorSource),
|
|
297
|
+
authorSource,
|
|
297
298
|
match.remaining,
|
|
298
|
-
|
|
299
|
+
interactionFactory?.(authorSource),
|
|
299
300
|
match.command.slot.definition.adapter,
|
|
300
301
|
),
|
|
301
302
|
);
|