chatwoot-router 0.1.0

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.
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ export { ConfigError } from "../../../shared/config.ts";
3
+ export declare const configSchema: z.ZodObject<{
4
+ chatwoot: z.ZodObject<{
5
+ baseUrl: z.ZodURL;
6
+ }, z.core.$strict>;
7
+ reconcile: z.ZodPrefault<z.ZodObject<{
8
+ lookbackSeconds: z.ZodDefault<z.ZodNumber>;
9
+ maxCatchUpSeconds: z.ZodDefault<z.ZodNumber>;
10
+ }, z.core.$strict>>;
11
+ startAfterConversationId: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
12
+ subrequestBudget: z.ZodDefault<z.ZodNumber>;
13
+ routing: z.ZodObject<{
14
+ model: z.ZodDefault<z.ZodString>;
15
+ minConfidence: z.ZodDefault<z.ZodNumber>;
16
+ snoozeUnclear: z.ZodDefault<z.ZodBoolean>;
17
+ accounts: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
18
+ assignee: z.ZodNumber;
19
+ covers: z.ZodString;
20
+ }, z.core.$strict>>>;
21
+ topics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
22
+ kinds: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
23
+ covers: z.ZodString;
24
+ cannedResponse: z.ZodOptional<z.ZodString>;
25
+ status: z.ZodOptional<z.ZodEnum<{
26
+ resolved: "resolved";
27
+ snoozed: "snoozed";
28
+ }>>;
29
+ }, z.core.$strict>>>>;
30
+ }, z.core.$strict>;
31
+ }, z.core.$strict>;
32
+ export declare const secretsSchema: z.ZodObject<{
33
+ CHATWOOT_TOKEN: z.ZodString;
34
+ CHATWOOT_WEBHOOK_SECRETS: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<unknown, string>>, z.ZodRecord<z.ZodString, z.ZodString>>;
35
+ TYPESAFE_API_KEY: z.ZodString;
36
+ CHATWOOT_BOT_TOKENS: z.ZodDefault<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<unknown, string>>, z.ZodRecord<z.ZodString, z.ZodString>>>;
37
+ }, z.core.$strip>;
38
+ type Config = z.infer<typeof configSchema>;
39
+ type Secrets = z.infer<typeof secretsSchema>;
40
+ export interface Settings {
41
+ config: Config;
42
+ secrets: Secrets;
43
+ botToken(accountId: number): string | undefined;
44
+ }
45
+ export declare function parseSettings(rawConfig: unknown, rawSecrets: object): Settings;
46
+ export declare function buildSettings(config: Config, secrets: Secrets): Settings;
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import type { RoutingContext, RoutingStore } from "./routing.ts";
3
+ declare const effectSchema: z.ZodObject<{
4
+ inputId: z.ZodNumber;
5
+ kind: z.ZodNullable<z.ZodString>;
6
+ handled: z.ZodNumber;
7
+ }, z.core.$strip>;
8
+ export declare function actOnce(ctx: RoutingContext, key: string, effect: z.infer<typeof effectSchema>, record: "before" | "after", act: () => Promise<unknown>): Promise<void>;
9
+ export declare function readEffects(store: RoutingStore, accountId: number, conversationId: number): {
10
+ inputId: number;
11
+ kind: string | null;
12
+ handled: number;
13
+ }[];
14
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { ConfigEnv } from "../../../shared/settings.ts";
2
+ import type { Router } from "./router.ts";
3
+ export interface Env extends ConfigEnv {
4
+ ROUTER: DurableObjectNamespace<Router>;
5
+ CHATWOOT_TOKEN: string;
6
+ CHATWOOT_WEBHOOK_SECRETS: string;
7
+ TYPESAFE_API_KEY: string;
8
+ CHATWOOT_BOT_TOKENS?: string;
9
+ }
@@ -0,0 +1,7 @@
1
+ import type { Env } from "./env.ts";
2
+ declare const _default: {
3
+ fetch: (request: Request, env?: Env | {} | undefined, executionCtx?: import("hono").ExecutionContext) => Response | Promise<Response>;
4
+ scheduled(_controller: ScheduledController, env: Env, context: ExecutionContext<unknown>): Promise<void>;
5
+ };
6
+ export default _default;
7
+ export { Router } from "./router.ts";