mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Rebased onto dev after PR 1475 (cl/hexclave-pr1) was squash-merged. Squashes the original 46-commit branch (including PR1-duplicate commits that arrived via cherry-picks/merges) into a single commit containing only PR2's net delta over dev. Original PR 1481 head: 94872de407873a1cabd4085deb21b69afe8d7699 (kept locally at backup/cl-romantic-mendel-5a2c25-pre-rebase)
32 lines
844 B
TypeScript
32 lines
844 B
TypeScript
type TelegramErrorInfo = {
|
|
name?: string,
|
|
message: string,
|
|
stack?: string,
|
|
};
|
|
|
|
export type TelegramCompletionPayload = {
|
|
success: boolean,
|
|
distinctId?: string,
|
|
options: Record<string, unknown>,
|
|
args: string[],
|
|
isNonInteractive: boolean,
|
|
timestamp: string,
|
|
projectPath?: string,
|
|
error?: TelegramErrorInfo,
|
|
};
|
|
|
|
const API_BASE_ENV = "STACK_INIT_API_BASE_URL";
|
|
const DEFAULT_API_BASE_URL = "https://api.hexclave.com";
|
|
const CALLBACK_ENDPOINT = "/api/latest/internal/init-script-callback";
|
|
|
|
export async function invokeCallback(payload: TelegramCompletionPayload): Promise<void> {
|
|
const baseUrl = process.env[API_BASE_ENV] ?? DEFAULT_API_BASE_URL;
|
|
await fetch(`${baseUrl}${CALLBACK_ENDPOINT}`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify(payload),
|
|
});
|
|
}
|