Skip to content

Commit e4796a8

Browse files
d-gubertCopilot
andcommitted
fix: deno-runtime import problems
Co-authored-by: Copilot <copilot@github.com>
1 parent d1390a6 commit e4796a8

6 files changed

Lines changed: 19 additions & 26 deletions

File tree

packages/apps/deno-runtime/deno.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"@msgpack/msgpack": "npm:@msgpack/msgpack@3.0.0-beta2",
44
"@rocket.chat/ui-kit": "npm:@rocket.chat/ui-kit@^0.31.22",
55
"@rocket.chat/apps-engine/": "../../../packages/apps-engine/",
6+
"@rocket.chat/apps/": "../",
67
"@std/cli": "jsr:@std/cli@^1.0.9",
78
"@std/io": "jsr:@std/io@^0.225.3",
89
"@std/streams": "jsr:@std/streams@^1.0.16",

packages/apps/deno-runtime/handlers/app/construct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Socket } from 'node:net';
22

3-
import type { IParseAppPackageResult } from '@rocket.chat/apps-engine/server/compiler/IParseAppPackageResult';
3+
import type { IParseAppPackageResult } from '@rocket.chat/apps/dist/server/compiler/IParseAppPackageResult';
44

55
import { AppObjectRegistry } from '../../AppObjectRegistry.ts';
66
import { require } from '../../lib/require.ts';

packages/apps/deno-runtime/handlers/slashcommand-handler.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms/IRoom';
22
import type { ISlashCommand } from '@rocket.chat/apps-engine/definition/slashcommands/ISlashCommand';
3-
import type { SlashCommandContext as _SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands/SlashCommandContext';
4-
import type { Room as _Room } from '@rocket.chat/apps-engine/server/rooms/Room';
3+
import { SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands/SlashCommandContext';
54
import { Defined, JsonRpcError } from 'jsonrpc-lite';
65

76
import { AppObjectRegistry } from '../AppObjectRegistry.ts';
87
import { AppAccessors, AppAccessorsInstance } from '../lib/accessors/mod.ts';
9-
import { require } from '../lib/require.ts';
108
import createRoom from '../lib/roomFactory.ts';
119
import { RequestContext } from '../lib/requestContext.ts';
1210
import { wrapComposedApp } from '../lib/wrapAppForRequest.ts';
1311

14-
// For some reason Deno couldn't understand the typecast to the original interfaces and said it wasn't a constructor type
15-
const { SlashCommandContext } = require('@rocket.chat/apps-engine/definition/slashcommands/SlashCommandContext.js') as {
16-
SlashCommandContext: typeof _SlashCommandContext;
17-
};
18-
1912
export default async function slashCommandHandler(request: RequestContext): Promise<JsonRpcError | Defined> {
2013
const { method: call, params } = request;
2114
const { logger } = request.context;
@@ -76,11 +69,11 @@ export function handleExecutor(deps: Deps, command: ISlashCommand, method: 'exec
7669
const { sender, room, params: args, threadId, triggerId } = params[0] as Record<string, unknown>;
7770

7871
const context = new SlashCommandContext(
79-
sender as _SlashCommandContext['sender'],
72+
sender as SlashCommandContext['sender'],
8073
createRoom(room as IRoom, deps.AppAccessorsInstance.getSenderFn()),
81-
args as _SlashCommandContext['params'],
82-
threadId as _SlashCommandContext['threadId'],
83-
triggerId as _SlashCommandContext['triggerId'],
74+
args as SlashCommandContext['params'],
75+
threadId as SlashCommandContext['threadId'],
76+
triggerId as SlashCommandContext['triggerId'],
8477
);
8578

8679
return executor.apply(wrapComposedApp(command, deps.request), [
@@ -109,11 +102,11 @@ export function handlePreviewItem(deps: Deps, command: ISlashCommand, params: un
109102
const [previewItem, { sender, room, params: args, threadId, triggerId }] = params as [Record<string, unknown>, Record<string, unknown>];
110103

111104
const context = new SlashCommandContext(
112-
sender as _SlashCommandContext['sender'],
105+
sender as SlashCommandContext['sender'],
113106
createRoom(room as IRoom, deps.AppAccessorsInstance.getSenderFn()),
114-
args as _SlashCommandContext['params'],
115-
threadId as _SlashCommandContext['threadId'],
116-
triggerId as _SlashCommandContext['triggerId'],
107+
args as SlashCommandContext['params'],
108+
threadId as SlashCommandContext['threadId'],
109+
triggerId as SlashCommandContext['triggerId'],
117110
);
118111

119112
return command.executePreviewItem.call(

packages/apps/deno-runtime/lib/accessors/modify/ModifyCreator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { randomBytes } from 'node:crypto';
2+
3+
import { UIHelper } from '@rocket.chat/apps/dist/server/misc/UIHelper';
14
import type { IModifyCreator } from '@rocket.chat/apps-engine/definition/accessors/IModifyCreator';
25
import type { IUploadCreator } from '@rocket.chat/apps-engine/definition/accessors/IUploadCreator';
36
import type { IEmailCreator } from '@rocket.chat/apps-engine/definition/accessors/IEmailCreator';
@@ -14,10 +17,8 @@ import type { IUserBuilder } from '@rocket.chat/apps-engine/definition/accessors
1417
import type { IVideoConferenceBuilder } from '@rocket.chat/apps-engine/definition/accessors/IVideoConferenceBuilder';
1518
import type { RoomType as _RoomType } from '@rocket.chat/apps-engine/definition/rooms/RoomType';
1619
import type { ILivechatMessageBuilder } from '@rocket.chat/apps-engine/definition/accessors/ILivechatMessageBuilder';
17-
import type { UIHelper as _UIHelper } from '@rocket.chat/apps-engine/server/misc/UIHelper';
1820

1921
import * as Messenger from '../../messenger.ts';
20-
import { randomBytes } from 'node:crypto';
2122

2223
import { BlockBuilder } from '../builders/BlockBuilder.ts';
2324
import { MessageBuilder } from '../builders/MessageBuilder.ts';
@@ -30,7 +31,6 @@ import { AppObjectRegistry } from '../../../AppObjectRegistry.ts';
3031
import { require } from '../../../lib/require.ts';
3132
import { formatErrorResponse } from '../formatResponseErrorHandler.ts';
3233

33-
const { UIHelper } = require('@rocket.chat/apps-engine/server/misc/UIHelper.js') as { UIHelper: typeof _UIHelper };
3434
const { RoomType } = require('@rocket.chat/apps-engine/definition/rooms/RoomType.js') as { RoomType: typeof _RoomType };
3535
const { UserType } = require('@rocket.chat/apps-engine/definition/users/UserType.js') as { UserType: typeof _UserType };
3636
const { RocketChatAssociationModel } = require('@rocket.chat/apps-engine/definition/metadata/RocketChatAssociations.js') as {
@@ -107,7 +107,7 @@ export class ModifyCreator implements IModifyCreator {
107107
throw formatErrorResponse(err);
108108
}),
109109
},
110-
);
110+
) as IEmailCreator;
111111
}
112112

113113
getContactCreator(): IContactCreator {
@@ -128,7 +128,7 @@ export class ModifyCreator implements IModifyCreator {
128128
throw formatErrorResponse(err);
129129
}),
130130
},
131-
);
131+
) as IContactCreator;
132132
}
133133

134134
getBlockBuilder() {

packages/apps/deno-runtime/lib/accessors/modify/ModifyUpdater.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { UIHelper } from '@rocket.chat/apps/dist/server/misc/UIHelper';
12
import type { IModifyUpdater } from '@rocket.chat/apps-engine/definition/accessors/IModifyUpdater';
23
import type { ILivechatUpdater } from '@rocket.chat/apps-engine/definition/accessors/ILivechatUpdater';
34
import type { IUserUpdater } from '@rocket.chat/apps-engine/definition/accessors/IUserUpdater';
@@ -8,7 +9,6 @@ import type { IUser } from '@rocket.chat/apps-engine/definition/users/IUser';
89
import type { IMessage } from '@rocket.chat/apps-engine/definition/messages/IMessage';
910
import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms/IRoom';
1011

11-
import type { UIHelper as _UIHelper } from '@rocket.chat/apps-engine/server/misc/UIHelper';
1212
import type { RoomType as _RoomType } from '@rocket.chat/apps-engine/definition/rooms/RoomType';
1313
import type { RocketChatAssociationModel as _RocketChatAssociationModel } from '@rocket.chat/apps-engine/definition/metadata/RocketChatAssociations';
1414

@@ -21,7 +21,6 @@ import { AppObjectRegistry } from '../../../AppObjectRegistry.ts';
2121
import { require } from '../../../lib/require.ts';
2222
import { formatErrorResponse } from '../formatResponseErrorHandler.ts';
2323

24-
const { UIHelper } = require('@rocket.chat/apps-engine/server/misc/UIHelper.js') as { UIHelper: typeof _UIHelper };
2524
const { RoomType } = require('@rocket.chat/apps-engine/definition/rooms/RoomType.js') as { RoomType: typeof _RoomType };
2625
const { RocketChatAssociationModel } = require('@rocket.chat/apps-engine/definition/metadata/RocketChatAssociations.js') as {
2726
RocketChatAssociationModel: typeof _RocketChatAssociationModel;

packages/apps/deno-runtime/lib/roomFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import type { AppManager } from '@rocket.chat/apps/dist/server/AppManager';
12
import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms/IRoom';
2-
import type { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
33

44
import { AppAccessors } from './accessors/mod.ts';
5-
import { Room } from './room.ts';
65
import { formatErrorResponse } from './accessors/formatResponseErrorHandler.ts';
6+
import { Room } from './room.ts';
77

88
const getMockAppManager = (senderFn: AppAccessors['senderFn']) => ({
99
getBridges: () => ({

0 commit comments

Comments
 (0)