Skip to content

Commit 982f9c2

Browse files
authored
Give MatrixInterfaceAdaptor all of its required callbacks. (#540)
* Update to @the-draupnir-project/[email protected]. The interface has been changed in `interface-manager` so that we can't forget them. Means that our little error renderer works again.
1 parent 8d1af84 commit 982f9c2

File tree

5 files changed

+27
-35
lines changed

5 files changed

+27
-35
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@sentry/node": "^7.17.2",
5757
"@sentry/tracing": "^7.17.2",
5858
"@sinclair/typebox": "0.32.34",
59-
"@the-draupnir-project/interface-manager": "1.1.1",
59+
"@the-draupnir-project/interface-manager": "2.0.0",
6060
"@the-draupnir-project/matrix-basic-types": "^0.1.1",
6161
"await-lock": "^2.2.2",
6262
"better-sqlite3": "^9.4.3",

src/appservice/bot/AppserviceBotCommandDispatcher.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,11 @@ import {
1919
} from "@the-draupnir-project/interface-manager";
2020
import {
2121
MPSCommandDispatcherCallbacks,
22+
MPSMatrixInterfaceAdaptorCallbacks,
2223
MatrixEventContext,
2324
invocationInformationFromMatrixEventcontext,
24-
matrixEventsFromDeadDocument,
25-
rendererFailedCB,
2625
} from "../../commands/interface-manager/MPSMatrixInterfaceAdaptor";
2726
import { AppserviceAdaptorContext } from "./AppserviceBotPrerequisite";
28-
import {
29-
promptDefault,
30-
promptSuggestions,
31-
} from "../../commands/interface-manager/MatrixPromptForAccept";
32-
import { matrixCommandRenderer } from "../../commands/interface-manager/MatrixHelpRenderer";
3327
import { userLocalpart } from "@the-draupnir-project/matrix-basic-types";
3428
import { AppserviceBotCommands } from "./AppserviceBotCommandTable";
3529
import { AppserviceBotHelpCommand } from "./AppserviceBotHelp";
@@ -43,11 +37,8 @@ export const AppserviceBotInterfaceAdaptor = new StandardMatrixInterfaceAdaptor<
4337
>(
4438
AppserviceAdaptorContextToCommandContextTranslator,
4539
invocationInformationFromMatrixEventcontext,
46-
promptDefault,
47-
promptSuggestions,
48-
matrixCommandRenderer,
49-
matrixEventsFromDeadDocument,
50-
rendererFailedCB
40+
MPSMatrixInterfaceAdaptorCallbacks,
41+
MPSCommandDispatcherCallbacks
5142
);
5243

5344
function makePrefixExtractor(

src/commands/DraupnirCommandPrerequisites.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,11 @@ import {
1313
} from "@the-draupnir-project/interface-manager";
1414
import { Draupnir } from "../Draupnir";
1515
import {
16+
MPSCommandDispatcherCallbacks,
17+
MPSMatrixInterfaceAdaptorCallbacks,
1618
MatrixEventContext,
1719
invocationInformationFromMatrixEventcontext,
18-
matrixEventsFromDeadDocument,
19-
rendererFailedCB,
2020
} from "./interface-manager/MPSMatrixInterfaceAdaptor";
21-
import { matrixCommandRenderer } from "./interface-manager/MatrixHelpRenderer";
22-
import {
23-
promptDefault,
24-
promptSuggestions,
25-
} from "./interface-manager/MatrixPromptForAccept";
2621

2722
export const DraupnirContextToCommandContextTranslator =
2823
new StandardAdaptorContextToCommandContextTranslator<Draupnir>();
@@ -32,9 +27,6 @@ export const DraupnirInterfaceAdaptor = new StandardMatrixInterfaceAdaptor<
3227
>(
3328
DraupnirContextToCommandContextTranslator,
3429
invocationInformationFromMatrixEventcontext,
35-
promptDefault,
36-
promptSuggestions,
37-
matrixCommandRenderer,
38-
matrixEventsFromDeadDocument,
39-
rendererFailedCB
30+
MPSMatrixInterfaceAdaptorCallbacks,
31+
MPSCommandDispatcherCallbacks
4032
);

src/commands/interface-manager/MPSMatrixInterfaceAdaptor.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
CommandDispatcherCallbacks,
3131
DocumentNode,
3232
InvocationInformationFromEventContext,
33+
MatrixInterfaceAdaptorCallbacks,
3334
MatrixInterfaceEventsFromDeadDocument,
3435
MatrixInterfaceRendererFailedCB,
3536
StandardAdaptorContextToCommandContextTranslator,
@@ -175,7 +176,7 @@ export const MPSCommandDispatcherCallbacks = {
175176
return new ActionException(
176177
ActionExceptionKind.Unknown,
177178
error,
178-
"An unexpected error occurred while processing the command."
179+
error.message
179180
);
180181
},
181182
} satisfies CommandDispatcherCallbacks<BasicInvocationInformation>;
@@ -190,6 +191,17 @@ export const rendererFailedCB: MatrixInterfaceRendererFailedCB<
190191
);
191192
};
192193

194+
export const MPSMatrixInterfaceAdaptorCallbacks = Object.freeze({
195+
promptDefault,
196+
promptSuggestions,
197+
defaultRenderer: matrixCommandRenderer,
198+
matrixEventsFromDeadDocument,
199+
rendererFailedCB,
200+
}) satisfies MatrixInterfaceAdaptorCallbacks<
201+
MatrixAdaptorContext,
202+
MatrixEventContext
203+
>;
204+
193205
export const invocationInformationFromMatrixEventcontext: InvocationInformationFromEventContext<MatrixEventContext> =
194206
function (eventContext) {
195207
return {
@@ -207,9 +219,6 @@ export const MPSMatrixInterfaceAdaptor = new StandardMatrixInterfaceAdaptor<
207219
>(
208220
MPSContextToCommandContextTranslator,
209221
invocationInformationFromMatrixEventcontext,
210-
promptDefault,
211-
promptSuggestions,
212-
matrixCommandRenderer,
213-
matrixEventsFromDeadDocument,
214-
rendererFailedCB
222+
MPSMatrixInterfaceAdaptorCallbacks,
223+
MPSCommandDispatcherCallbacks
215224
);

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@
256256
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e"
257257
integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==
258258

259-
"@the-draupnir-project/interface-manager@1.1.1":
260-
version "1.1.1"
261-
resolved "https://registry.yarnpkg.com/@the-draupnir-project/interface-manager/-/interface-manager-1.1.1.tgz#065201a1554cb6e2a4bdd20eb04da1feb413bc53"
262-
integrity sha512-83U5y9u77sAW2bLWmtDBzhAjX3Rbcle7xkQ86ee6sJKjevrjTf7FIqf2CAV1uic1JcQUCJDvfORPPpfNqEqjfw==
259+
"@the-draupnir-project/interface-manager@2.0.0":
260+
version "2.0.0"
261+
resolved "https://registry.yarnpkg.com/@the-draupnir-project/interface-manager/-/interface-manager-2.0.0.tgz#1386bb7d59257d867f963adf600cc506f3ec591d"
262+
integrity sha512-DD3D3cOx0LqPJ4oET1+ttpUlVZf+4u8RTqFwxL0Qh8KOWLS9oxBwiw+U0IPDbTa+07hbhzY/hRMRBiqheXS/LQ==
263263
dependencies:
264264
"@gnuxie/super-cool-stream" "^0.2.1"
265265
"@gnuxie/typescript-result" "^0.2.0"

0 commit comments

Comments
 (0)