Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-1500-missing-declaration-chunks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eve": patch
---

Fix missing content-hashed declaration chunks in the published `eve` tarball. The chat and twilio vendor configs previously only co-copied `jsx-runtime-<hash>.d.ts` (chat) or no hashed chunks at all (twilio), so the upstream `messages-<hash>.d.ts` and `types-<hash>.d.ts` files were dropped from the published package — degrading ~120 chat exports to `any` and producing TS2307 errors with `skipLibCheck: false`. Extend `discoverExtraFiles` in `_shared.mjs` to fold the hashed siblings into the same declaration-rewrite pass as the named entry files, and add the chunk patterns (`messages-`, `types-`) to the chat and twilio configs. Also fixes a small set of `chat` and `@chat-adapter/twilio` type-surface leaks in eve sources and tests that were silently relying on the previous `any` fallback. Resolves #1500.
9 changes: 9 additions & 0 deletions packages/eve/scripts/vendor-compiled/@chat-adapter/twilio.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,14 @@ export default {
rewrites: {
chat: { kind: "vendored", compiledPath: "chat" },
},
discoverExtraFiles: (distEntries) =>
// The upstream bundler emits content-hashed sibling declaration
// chunks (`types-<hash>.d.ts`) that the entry .d.ts files import by
// relative path. Co-copy them verbatim so the specifier resolves
// inside the published tarball — the miss here produced TS2307 for
// `TwilioWebhookUrl` and `TwilioVerifiedRequest` under
// skipLibCheck:false (see #1500). Mirrors the @chat-adapter/slack
// pattern a few directories over.
distEntries.filter((name) => /^types-[^./]+\.d\.ts$/.test(name)),
}),
};
29 changes: 18 additions & 11 deletions packages/eve/scripts/vendor-compiled/_shared.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,21 @@ export function createDeclarationCopier({
? files
: [{ source: "index.d.ts", output: "index.d.ts" }];

// discoverExtraFiles names content-hashed sibling chunks (e.g.
// `messages-<hash>.d.ts`, `types-<hash>.d.ts`) that the upstream
// bundler emits next to the entry .d.ts. They must flow through the
// same rewrite pass as the named `files` — chat's `messages-<hash>`
// chunk imports `mdast`, and the published package cannot ship that
// bare specifier (no @types/mdast in scope; see #1500).
const extraFileNames =
typeof discoverExtraFiles === "function" ? discoverExtraFiles(distEntries) : [];
const allFiles = [
...declarationFiles,
...extraFileNames.map((name) => ({ source: name, output: name })),
];

const declarations = await Promise.all(
declarationFiles.map(async (file) => ({
allFiles.map(async (file) => ({
...file,
sourceText: await readFile(join(distDir, file.source), "utf8"),
})),
Expand Down Expand Up @@ -178,16 +191,10 @@ export function createDeclarationCopier({
}),
);

if (typeof discoverExtraFiles === "function") {
const extras = discoverExtraFiles(distEntries);
await Promise.all(
extras.map(async (file) => {
const outputPath = join(destinationRoot, file);
await mkdir(dirname(outputPath), { recursive: true });
await copyFile(join(distDir, file), outputPath);
}),
);
}
// NOTE: the previous tail block that re-copied each extra file verbatim
// (via copyFile) is removed — extras are folded into `declarations`
// above so they receive the same rewrite pass. Re-adding it would
// overwrite the rewritten output with the un-rewritten source.
};
}

Expand Down
10 changes: 9 additions & 1 deletion packages/eve/scripts/vendor-compiled/chat.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export default {
},
},
discoverExtraFiles: (distEntries) =>
distEntries.filter((name) => /^jsx-runtime-[^./]+\.d\.ts$/.test(name)),
// Co-copy the sibling content-hashed declaration chunks the upstream
// build emits that the entry .d.ts imports by relative path:
// `jsx-runtime-<hash>.d.ts` (pre-existing) and `messages-<hash>.d.ts`
// (previously missed — its absence with skipLibCheck:false produced
// TS2307 across ~120 chat exports, see #1500). The hash suffix is
// content-derived and drifts on every upstream build.
distEntries.filter((name) =>
/^(jsx-runtime|messages)-[^./]+\.d\.ts$/.test(name),
),
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export function chatSdkChannel<TAdapters extends ChatSdkAdapters>(
{ inputResponses: [response] },
{
auth: config.resolveInputAuth ? await config.resolveInputAuth(event) : null,
thread: event.thread,
thread: event.thread as Thread,
},
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { photonInboundContent } from "#public/channels/photon/inboundContent.js"
function message(text: string, attachments: Message["attachments"] = []): Message {
return new Message({
attachments,
author: { isBot: false, isMe: false, userId: "user", userName: "user" },
author: { fullName: "user", isBot: false, isMe: false, userId: "user", userName: "user" },
formatted: { type: "root", children: [] },
id: "message-id",
metadata: { dateSent: new Date(), edited: false },
raw: {},
text,
threadId: "thread-id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ describe("photonIMessageChannel", () => {
if (handler === undefined) throw new Error("Expected an inbound direct-message handler.");
const thread = { id: "thread-id" };
const message = new Message({
author: { isBot: false, isMe: false, userId: "user", userName: "user" },
attachments: [],
author: { fullName: "user", isBot: false, isMe: false, userId: "user", userName: "user" },
formatted: { type: "root", children: [] },
id: "message-id",
metadata: { dateSent: new Date(), edited: false },
raw: {},
text: "Steer this response",
threadId: thread.id,
Expand All @@ -65,8 +68,11 @@ describe("photonIMessageChannel", () => {
if (handler === undefined) throw new Error("Expected an inbound direct-message handler.");
const thread = { id: "thread-id" };
const message = new Message({
author: { isBot: false, isMe: false, userId: "user", userName: "user" },
attachments: [],
author: { fullName: "user", isBot: false, isMe: false, userId: "user", userName: "user" },
formatted: { type: "root", children: [] },
id: "message-id",
metadata: { dateSent: new Date(), edited: false },
raw: {},
text: " \n",
threadId: thread.id,
Expand All @@ -87,8 +93,11 @@ describe("photonIMessageChannel", () => {
}
const thread = { id: "group-thread-id" };
const message = new Message({
author: { isBot: false, isMe: false, userId: "user", userName: "user" },
attachments: [],
author: { fullName: "user", isBot: false, isMe: false, userId: "user", userName: "user" },
formatted: { type: "root", children: [] },
id: "message-id",
metadata: { dateSent: new Date(), edited: false },
raw: {},
text: "Hello group",
threadId: thread.id,
Expand Down
Loading