@prajwalshete/telegram-plugin 0.0.0-stage → 0.1.1
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.
- package/CHANGELOG.md +91 -0
- package/LICENSE +21 -0
- package/README.md +109 -2
- package/dist/adapters/clock.d.ts +3 -0
- package/dist/adapters/clock.js +4 -0
- package/dist/adapters/console-log.d.ts +13 -0
- package/dist/adapters/console-log.js +41 -0
- package/dist/adapters/d1-db.d.ts +5 -0
- package/dist/adapters/d1-db.js +37 -0
- package/dist/adapters/ids.d.ts +5 -0
- package/dist/adapters/ids.js +25 -0
- package/dist/adapters/index.d.ts +7 -0
- package/dist/adapters/keyring.d.ts +50 -0
- package/dist/adapters/keyring.js +174 -0
- package/dist/adapters/metrics.d.ts +28 -0
- package/dist/adapters/metrics.js +48 -0
- package/dist/adapters/r2-files.d.ts +20 -0
- package/dist/adapters/r2-files.js +53 -0
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +45 -0
- package/dist/client/broadcasts.d.ts +35 -0
- package/dist/client/commands.d.ts +23 -0
- package/dist/client/endpoint.d.ts +34 -0
- package/dist/client/events.d.ts +33 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.js +3 -0
- package/dist/client/schedules.d.ts +42 -0
- package/dist/client/schema.d.ts +181 -0
- package/dist/client/send.d.ts +15 -0
- package/dist/client/templates.d.ts +47 -0
- package/dist/contracts/bots.d.ts +129 -0
- package/dist/contracts/bots.js +70 -0
- package/dist/contracts/broadcasts.d.ts +116 -0
- package/dist/contracts/broadcasts.js +63 -0
- package/dist/contracts/chats.d.ts +97 -0
- package/dist/contracts/chats.js +66 -0
- package/dist/contracts/commands.d.ts +52 -0
- package/dist/contracts/commands.js +53 -0
- package/dist/contracts/common.d.ts +38 -0
- package/dist/contracts/common.js +41 -0
- package/dist/contracts/deliveries.d.ts +103 -0
- package/dist/contracts/deliveries.js +74 -0
- package/dist/contracts/destinations.d.ts +24 -0
- package/dist/contracts/destinations.js +28 -0
- package/dist/contracts/events.d.ts +165 -0
- package/dist/contracts/events.js +98 -0
- package/dist/contracts/features.d.ts +20 -0
- package/dist/contracts/features.js +21 -0
- package/dist/contracts/health.d.ts +55 -0
- package/dist/contracts/health.js +58 -0
- package/dist/contracts/index.d.ts +22 -0
- package/dist/contracts/index.js +22 -0
- package/dist/contracts/labels.d.ts +38 -0
- package/dist/contracts/labels.js +52 -0
- package/dist/contracts/links.d.ts +51 -0
- package/dist/contracts/links.js +50 -0
- package/dist/contracts/meta.d.ts +132 -0
- package/dist/contracts/meta.js +85 -0
- package/dist/contracts/permissions.d.ts +24 -0
- package/dist/contracts/permissions.js +27 -0
- package/dist/contracts/problems.d.ts +106 -0
- package/dist/contracts/problems.js +101 -0
- package/dist/contracts/recipients.d.ts +36 -0
- package/dist/contracts/recipients.js +22 -0
- package/dist/contracts/schedules.d.ts +276 -0
- package/dist/contracts/schedules.js +143 -0
- package/dist/contracts/send.d.ts +126 -0
- package/dist/contracts/send.js +69 -0
- package/dist/contracts/subscriptions.d.ts +38 -0
- package/dist/contracts/subscriptions.js +31 -0
- package/dist/contracts/templates.d.ts +358 -0
- package/dist/contracts/templates.js +174 -0
- package/dist/contracts/users.d.ts +15 -0
- package/dist/contracts/users.js +19 -0
- package/dist/core/guards.d.ts +22 -0
- package/dist/core/guards.js +47 -0
- package/dist/core/html/escape.d.ts +2 -0
- package/dist/core/html/escape.js +36 -0
- package/dist/core/html/tokenize.js +65 -0
- package/dist/core/index.d.ts +18 -0
- package/dist/core/pacing.d.ts +1 -0
- package/dist/core/pacing.js +86 -0
- package/dist/core/random.d.ts +2 -0
- package/dist/core/random.js +38 -0
- package/dist/core/recipients.d.ts +1 -0
- package/dist/core/recipients.js +86 -0
- package/dist/core/schedule/describe.d.ts +3 -0
- package/dist/core/schedule/describe.js +74 -0
- package/dist/core/schedule/index.d.ts +4 -0
- package/dist/core/schedule/policy.d.ts +1 -0
- package/dist/core/schedule/policy.js +37 -0
- package/dist/core/schedule/rule.d.ts +25 -0
- package/dist/core/schedule/rule.js +142 -0
- package/dist/core/schedule/tz.d.ts +2 -0
- package/dist/core/schedule/tz.js +59 -0
- package/dist/core/split/plain.d.ts +2 -0
- package/dist/core/split/plain.js +23 -0
- package/dist/core/split/split.d.ts +15 -0
- package/dist/core/split/split.js +158 -0
- package/dist/core/template/ast.d.ts +58 -0
- package/dist/core/template/ast.js +5 -0
- package/dist/core/template/expr.js +108 -0
- package/dist/core/template/filters.d.ts +20 -0
- package/dist/core/template/filters.js +127 -0
- package/dist/core/template/format.d.ts +17 -0
- package/dist/core/template/format.js +88 -0
- package/dist/core/template/index.d.ts +20 -0
- package/dist/core/template/index.js +29 -0
- package/dist/core/template/parse.d.ts +8 -0
- package/dist/core/template/parse.js +369 -0
- package/dist/core/template/render.d.ts +17 -0
- package/dist/core/template/render.js +118 -0
- package/dist/core/template/shape.d.ts +28 -0
- package/dist/core/template/shape.js +151 -0
- package/dist/core/template/tags.js +105 -0
- package/dist/core/template/validate.d.ts +10 -0
- package/dist/core/template/validate.js +144 -0
- package/dist/core/template/variables.d.ts +15 -0
- package/dist/core/template/variables.js +41 -0
- package/dist/do/index.d.ts +3 -0
- package/dist/do/index.js +3 -0
- package/dist/do/telegram-bot-do.d.ts +45 -0
- package/dist/do/telegram-bot-do.js +219 -0
- package/dist/engine/actions/callback.js +256 -0
- package/dist/engine/actions/tokens.d.ts +2 -0
- package/dist/engine/actions/tokens.js +51 -0
- package/dist/engine/bot-api.js +20 -0
- package/dist/engine/bot-features.js +39 -0
- package/dist/engine/chat-state.js +66 -0
- package/dist/engine/content/audience.js +54 -0
- package/dist/engine/content/buttons.d.ts +1 -0
- package/dist/engine/content/buttons.js +113 -0
- package/dist/engine/content/fanout.js +284 -0
- package/dist/engine/content/intersect.d.ts +6 -0
- package/dist/engine/content/intersect.js +26 -0
- package/dist/engine/content/providers.d.ts +6 -0
- package/dist/engine/content/providers.js +142 -0
- package/dist/engine/content/recipients.js +128 -0
- package/dist/engine/content/render.js +138 -0
- package/dist/engine/content/reply.js +156 -0
- package/dist/engine/content/report-files.js +78 -0
- package/dist/engine/content/template-rows.js +74 -0
- package/dist/engine/dialogs/dialog.d.ts +2 -0
- package/dist/engine/dialogs/dialog.js +375 -0
- package/dist/engine/dispatch/builtins.js +198 -0
- package/dist/engine/dispatch/commands.js +194 -0
- package/dist/engine/dispatch/context.d.ts +2 -0
- package/dist/engine/dispatch/context.js +194 -0
- package/dist/engine/dispatch/dispatcher.js +66 -0
- package/dist/engine/dispatch/handlers.d.ts +1 -0
- package/dist/engine/dispatch/handlers.js +103 -0
- package/dist/engine/dispatch/lifecycle.js +85 -0
- package/dist/engine/dispatch/link-chat.js +31 -0
- package/dist/engine/dispatch/linking.js +273 -0
- package/dist/engine/errors.d.ts +60 -0
- package/dist/engine/errors.js +72 -0
- package/dist/engine/events/filters.d.ts +5 -0
- package/dist/engine/events/filters.js +82 -0
- package/dist/engine/events/kick.js +30 -0
- package/dist/engine/events/payload.d.ts +3 -0
- package/dist/engine/events/payload.js +16 -0
- package/dist/engine/events/tick.js +208 -0
- package/dist/engine/i18n.d.ts +12 -0
- package/dist/engine/i18n.js +55 -0
- package/dist/engine/inbound/files.js +121 -0
- package/dist/engine/inbound/handler.js +46 -0
- package/dist/engine/jobs.d.ts +32 -0
- package/dist/engine/jobs.js +85 -0
- package/dist/engine/link-codes.js +46 -0
- package/dist/engine/metrics.js +12 -0
- package/dist/engine/options.d.ts +369 -0
- package/dist/engine/options.js +81 -0
- package/dist/engine/outbox/dead-letter.js +78 -0
- package/dist/engine/outbox/do-registry.d.ts +10 -0
- package/dist/engine/outbox/do-registry.js +10 -0
- package/dist/engine/outbox/do-transport.d.ts +33 -0
- package/dist/engine/outbox/do-transport.js +73 -0
- package/dist/engine/outbox/drain.d.ts +13 -0
- package/dist/engine/outbox/drain.js +381 -0
- package/dist/engine/outbox/enqueue.d.ts +1 -0
- package/dist/engine/outbox/enqueue.js +63 -0
- package/dist/engine/outbox/select.js +24 -0
- package/dist/engine/outbox/send.js +362 -0
- package/dist/engine/outbox/transport.d.ts +35 -0
- package/dist/engine/outbox/transport.js +175 -0
- package/dist/engine/outbox/wake.js +28 -0
- package/dist/engine/registry.d.ts +502 -0
- package/dist/engine/registry.js +258 -0
- package/dist/engine/rows.d.ts +25 -0
- package/dist/engine/rows.js +131 -0
- package/dist/engine/runtime.d.ts +95 -0
- package/dist/engine/runtime.js +149 -0
- package/dist/engine/schedules/fire.js +208 -0
- package/dist/engine/schedules/resume.js +75 -0
- package/dist/engine/schedules/rows.js +69 -0
- package/dist/engine/schedules/tick.js +30 -0
- package/dist/engine/schedules/wake.js +50 -0
- package/dist/engine/state.d.ts +11 -0
- package/dist/engine/state.js +78 -0
- package/dist/locales/en.js +339 -0
- package/dist/locales/en.json +341 -0
- package/dist/locales/mr.js +339 -0
- package/dist/locales/mr.json +341 -0
- package/dist/ports/db.d.ts +22 -0
- package/dist/ports/index.d.ts +4 -0
- package/dist/ports/ports.d.ts +257 -0
- package/dist/ports/sql.d.ts +39 -0
- package/dist/ports/sql.js +76 -0
- package/dist/renderers/csv.d.ts +14 -0
- package/dist/renderers/csv.js +51 -0
- package/dist/renderers/html.d.ts +44 -0
- package/dist/renderers/html.js +81 -0
- package/dist/renderers/index.d.ts +5 -0
- package/dist/renderers/index.js +4 -0
- package/dist/renderers/table.d.ts +30 -0
- package/dist/renderers/table.js +114 -0
- package/dist/routes/admin.js +146 -0
- package/dist/routes/app.d.ts +3111 -0
- package/dist/routes/app.js +9 -0
- package/dist/routes/broadcasts.js +37 -0
- package/dist/routes/commands.js +35 -0
- package/dist/routes/content.js +12 -0
- package/dist/routes/events.js +36 -0
- package/dist/routes/http.d.ts +30 -0
- package/dist/routes/http.js +223 -0
- package/dist/routes/me.js +59 -0
- package/dist/routes/schedules.js +62 -0
- package/dist/routes/send.js +24 -0
- package/dist/routes/templates.js +70 -0
- package/dist/routes/webhook.js +147 -0
- package/dist/schema/columns.js +307 -0
- package/dist/schema/ddl.d.ts +7 -0
- package/dist/schema/ddl.js +45 -0
- package/dist/schema/index.d.ts +4255 -0
- package/dist/schema/index.js +44 -0
- package/dist/schema/reference.sql +359 -0
- package/dist/schema/tables.d.ts +4243 -0
- package/dist/schema/tables.js +327 -0
- package/dist/schema/version.d.ts +5 -0
- package/dist/schema/version.js +7 -0
- package/dist/server/index.d.ts +55 -0
- package/dist/server/index.js +46 -0
- package/dist/server/plugin.d.ts +81 -0
- package/dist/server/plugin.js +247 -0
- package/dist/server/version.d.ts +2 -0
- package/dist/server/version.js +4 -0
- package/dist/services/ai-tool.d.ts +26 -0
- package/dist/services/ai-tool.js +148 -0
- package/dist/services/bots.js +300 -0
- package/dist/services/broadcasts.js +390 -0
- package/dist/services/chats.js +83 -0
- package/dist/services/cleanup.js +83 -0
- package/dist/services/commands.js +140 -0
- package/dist/services/deliveries.js +53 -0
- package/dist/services/destinations.js +91 -0
- package/dist/services/event-rules.js +229 -0
- package/dist/services/events.js +20 -0
- package/dist/services/idempotency.js +64 -0
- package/dist/services/links.js +200 -0
- package/dist/services/menu.js +95 -0
- package/dist/services/ops.js +90 -0
- package/dist/services/rekey.js +63 -0
- package/dist/services/reports.js +87 -0
- package/dist/services/schedules.js +214 -0
- package/dist/services/send.d.ts +14 -0
- package/dist/services/send.js +421 -0
- package/dist/services/subscriptions.js +28 -0
- package/dist/services/templates.js +259 -0
- package/dist/telegram/classify.d.ts +30 -0
- package/dist/telegram/classify.js +164 -0
- package/dist/telegram/client.d.ts +73 -0
- package/dist/telegram/client.js +135 -0
- package/dist/telegram/errors.d.ts +37 -0
- package/dist/telegram/errors.js +62 -0
- package/dist/telegram/inbound.d.ts +40 -0
- package/dist/telegram/inbound.js +72 -0
- package/dist/telegram/index.d.ts +8 -0
- package/dist/telegram/multipart.d.ts +5 -0
- package/dist/telegram/multipart.js +47 -0
- package/dist/telegram/types.d.ts +271 -0
- package/dist/telegram/update.d.ts +833 -0
- package/dist/telegram/update.js +129 -0
- package/dist/testing/fake-html.d.ts +9 -0
- package/dist/testing/fake-html.js +83 -0
- package/dist/testing/fake-telegram.d.ts +206 -0
- package/dist/testing/fake-telegram.js +856 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/reference-sql.d.ts +4 -0
- package/dist/testing/reference-sql.js +8 -0
- package/dist/testing/test-plugin.d.ts +126 -0
- package/dist/testing/test-plugin.js +182 -0
- package/dist/testing/updates.d.ts +100 -0
- package/dist/testing/updates.js +212 -0
- package/package.json +113 -3
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Where a send goes. The AI may use only `ai_allowed` destinations. */
|
|
3
|
+
export declare const SendTarget: z.ZodUnion<readonly [z.ZodObject<{
|
|
4
|
+
destination: z.ZodString;
|
|
5
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
6
|
+
user: z.ZodString;
|
|
7
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
8
|
+
me: z.ZodLiteral<true>;
|
|
9
|
+
}, z.core.$strict>]>;
|
|
10
|
+
export type SendTarget = z.infer<typeof SendTarget>;
|
|
11
|
+
/** What is sent. */
|
|
12
|
+
export declare const SendWhat: z.ZodUnion<readonly [z.ZodObject<{
|
|
13
|
+
record: z.ZodObject<{
|
|
14
|
+
type: z.ZodString;
|
|
15
|
+
key: z.ZodString;
|
|
16
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
19
|
+
template: z.ZodString;
|
|
20
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
22
|
+
report: z.ZodString;
|
|
23
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
24
|
+
format: z.ZodEnum<{
|
|
25
|
+
pdf: "pdf";
|
|
26
|
+
csv: "csv";
|
|
27
|
+
}>;
|
|
28
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
29
|
+
file: z.ZodObject<{
|
|
30
|
+
source: z.ZodString;
|
|
31
|
+
ref: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
34
|
+
text: z.ZodString;
|
|
35
|
+
}, z.core.$strict>]>;
|
|
36
|
+
export type SendWhat = z.infer<typeof SendWhat>;
|
|
37
|
+
/** The one shape the AI layer, host code and the UI "Send to Telegram" button share. */
|
|
38
|
+
export declare const SendIntent: z.ZodObject<{
|
|
39
|
+
to: z.ZodUnion<readonly [z.ZodObject<{
|
|
40
|
+
destination: z.ZodString;
|
|
41
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
42
|
+
user: z.ZodString;
|
|
43
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
44
|
+
me: z.ZodLiteral<true>;
|
|
45
|
+
}, z.core.$strict>]>;
|
|
46
|
+
what: z.ZodUnion<readonly [z.ZodObject<{
|
|
47
|
+
record: z.ZodObject<{
|
|
48
|
+
type: z.ZodString;
|
|
49
|
+
key: z.ZodString;
|
|
50
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
53
|
+
template: z.ZodString;
|
|
54
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
55
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
56
|
+
report: z.ZodString;
|
|
57
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
58
|
+
format: z.ZodEnum<{
|
|
59
|
+
pdf: "pdf";
|
|
60
|
+
csv: "csv";
|
|
61
|
+
}>;
|
|
62
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
63
|
+
file: z.ZodObject<{
|
|
64
|
+
source: z.ZodString;
|
|
65
|
+
ref: z.ZodString;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
68
|
+
text: z.ZodString;
|
|
69
|
+
}, z.core.$strict>]>;
|
|
70
|
+
note: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export type SendIntent = z.infer<typeof SendIntent>;
|
|
73
|
+
/** `POST /admin/send/preview` (permission `telegram.send`): exactly what a send would deliver, nothing queued. */
|
|
74
|
+
export declare const SendPreview: z.ZodObject<{
|
|
75
|
+
to: z.ZodObject<{
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
kind: z.ZodEnum<{
|
|
78
|
+
private: "private";
|
|
79
|
+
group: "group";
|
|
80
|
+
supergroup: "supergroup";
|
|
81
|
+
channel: "channel";
|
|
82
|
+
}>;
|
|
83
|
+
botUsername: z.ZodString;
|
|
84
|
+
destination: z.ZodNullable<z.ZodString>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
audience: z.ZodString;
|
|
87
|
+
parts: z.ZodArray<z.ZodString>;
|
|
88
|
+
buttons: z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
89
|
+
text: z.ZodString;
|
|
90
|
+
kind: z.ZodEnum<{
|
|
91
|
+
action: "action";
|
|
92
|
+
url: "url";
|
|
93
|
+
}>;
|
|
94
|
+
url: z.ZodNullable<z.ZodString>;
|
|
95
|
+
style: z.ZodNullable<z.ZodEnum<{
|
|
96
|
+
success: "success";
|
|
97
|
+
primary: "primary";
|
|
98
|
+
danger: "danger";
|
|
99
|
+
}>>;
|
|
100
|
+
disabled: z.ZodBoolean;
|
|
101
|
+
}, z.core.$strip>>>>;
|
|
102
|
+
file: z.ZodNullable<z.ZodObject<{
|
|
103
|
+
name: z.ZodString;
|
|
104
|
+
mime: z.ZodString;
|
|
105
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
attachments: z.ZodArray<z.ZodObject<{
|
|
108
|
+
name: z.ZodString;
|
|
109
|
+
mime: z.ZodString;
|
|
110
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
consequence: z.ZodString;
|
|
113
|
+
chats: z.ZodNumber;
|
|
114
|
+
source: z.ZodEnum<{
|
|
115
|
+
ai: "ai";
|
|
116
|
+
api: "api";
|
|
117
|
+
}>;
|
|
118
|
+
warnings: z.ZodArray<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
export type SendPreview = z.infer<typeof SendPreview>;
|
|
121
|
+
/** `POST /admin/send`: rows queued (parts × chats; 0 when the same key was already sent). */
|
|
122
|
+
export declare const SendResult: z.ZodObject<{
|
|
123
|
+
queued: z.ZodNumber;
|
|
124
|
+
dedupeKey: z.ZodString;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
export type SendResult = z.infer<typeof SendResult>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { JsonObject, Key } from "./common.js";
|
|
2
|
+
import { Slug } from "./destinations.js";
|
|
3
|
+
import { PreviewButton, PreviewFile, ReportFormat } from "./templates.js";
|
|
4
|
+
import { FileRef } from "./broadcasts.js";
|
|
5
|
+
import { ChatKind } from "./chats.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
// src/contracts/send.ts
|
|
8
|
+
/** Where a send goes. The AI may use only `ai_allowed` destinations. */
|
|
9
|
+
const SendTarget = z.union([
|
|
10
|
+
z.strictObject({ destination: Slug }),
|
|
11
|
+
z.strictObject({ user: z.string().min(1) }),
|
|
12
|
+
z.strictObject({ me: z.literal(true) })
|
|
13
|
+
]);
|
|
14
|
+
/** What is sent. */
|
|
15
|
+
const SendWhat = z.union([
|
|
16
|
+
z.strictObject({ record: z.object({
|
|
17
|
+
type: Key,
|
|
18
|
+
key: z.string().min(1).max(128),
|
|
19
|
+
fields: z.array(z.string()).max(50).optional()
|
|
20
|
+
}) }),
|
|
21
|
+
z.strictObject({
|
|
22
|
+
template: Key,
|
|
23
|
+
params: JsonObject.optional()
|
|
24
|
+
}),
|
|
25
|
+
z.strictObject({
|
|
26
|
+
report: Key,
|
|
27
|
+
params: JsonObject.optional(),
|
|
28
|
+
format: ReportFormat
|
|
29
|
+
}),
|
|
30
|
+
z.strictObject({ file: FileRef }),
|
|
31
|
+
z.strictObject({ text: z.string().min(1).max(1e3) })
|
|
32
|
+
]);
|
|
33
|
+
/** The one shape the AI layer, host code and the UI "Send to Telegram" button share. */
|
|
34
|
+
const SendIntent = z.object({
|
|
35
|
+
to: SendTarget,
|
|
36
|
+
what: SendWhat,
|
|
37
|
+
/** Optional short text sent with it (the caption of a file send); AI-written notes pass the content checks. */
|
|
38
|
+
note: z.string().max(500).optional()
|
|
39
|
+
});
|
|
40
|
+
/** `POST /admin/send/preview` (permission `telegram.send`): exactly what a send would deliver, nothing queued. */
|
|
41
|
+
const SendPreview = z.object({
|
|
42
|
+
to: z.object({
|
|
43
|
+
name: z.string(),
|
|
44
|
+
kind: ChatKind,
|
|
45
|
+
botUsername: z.string(),
|
|
46
|
+
destination: Slug.nullable()
|
|
47
|
+
}),
|
|
48
|
+
/** Who will see it, in the caller's locale ("Only Asha will see it.", "Everyone in this group…"). */
|
|
49
|
+
audience: z.string(),
|
|
50
|
+
/** Telegram HTML, one entry per message part. */
|
|
51
|
+
parts: z.array(z.string()),
|
|
52
|
+
/** Inline keyboard rows, or null. */
|
|
53
|
+
buttons: z.array(z.array(PreviewButton)).nullable(),
|
|
54
|
+
file: PreviewFile.nullable(),
|
|
55
|
+
/** Every file the send carries (today at most one: `file`). */
|
|
56
|
+
attachments: z.array(PreviewFile),
|
|
57
|
+
/** One sentence for a confirm card, in the caller's locale: what goes where and who sees it. */
|
|
58
|
+
consequence: z.string(),
|
|
59
|
+
/** Number of chats the send reaches (`me` can mean one chat per bot). */
|
|
60
|
+
chats: z.number().int().positive(),
|
|
61
|
+
source: z.enum(["api", "ai"]),
|
|
62
|
+
warnings: z.array(z.string())
|
|
63
|
+
});
|
|
64
|
+
/** `POST /admin/send`: rows queued (parts × chats; 0 when the same key was already sent). */
|
|
65
|
+
const SendResult = z.object({
|
|
66
|
+
queued: z.number().int().nonnegative(),
|
|
67
|
+
dedupeKey: z.string()
|
|
68
|
+
});
|
|
69
|
+
export { SendIntent, SendPreview, SendResult, SendTarget, SendWhat };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Quiet hours window, local to `tz` (default: the chat's zone). `from` > `to` wraps past midnight. */
|
|
3
|
+
export declare const QuietHours: z.ZodObject<{
|
|
4
|
+
from: z.ZodString;
|
|
5
|
+
to: z.ZodString;
|
|
6
|
+
tz: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type QuietHours = z.infer<typeof QuietHours>;
|
|
9
|
+
/** `schedule:<id>`, `event:<key>`, `broadcast`, or `*` (all). */
|
|
10
|
+
export declare const SubscriptionTopic: z.ZodString;
|
|
11
|
+
export type SubscriptionTopic = z.infer<typeof SubscriptionTopic>;
|
|
12
|
+
/** One chat's preference for one topic. */
|
|
13
|
+
export declare const SubscriptionDto: z.ZodObject<{
|
|
14
|
+
chatRef: z.ZodString;
|
|
15
|
+
topic: z.ZodString;
|
|
16
|
+
muted: z.ZodBoolean;
|
|
17
|
+
quiet: z.ZodNullable<z.ZodObject<{
|
|
18
|
+
from: z.ZodString;
|
|
19
|
+
to: z.ZodString;
|
|
20
|
+
tz: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
updatedAt: z.ZodNumber;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type SubscriptionDto = z.infer<typeof SubscriptionDto>;
|
|
25
|
+
/** `PUT /me/subscriptions` and `PUT /admin/chats/:id/subscriptions`: replaces the chat's list. */
|
|
26
|
+
export declare const SubscriptionSave: z.ZodObject<{
|
|
27
|
+
chatRef: z.ZodString;
|
|
28
|
+
items: z.ZodArray<z.ZodObject<{
|
|
29
|
+
topic: z.ZodString;
|
|
30
|
+
muted: z.ZodBoolean;
|
|
31
|
+
quiet: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
32
|
+
from: z.ZodString;
|
|
33
|
+
to: z.ZodString;
|
|
34
|
+
tz: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>>>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type SubscriptionSave = z.infer<typeof SubscriptionSave>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ClockTime, EpochMs, Id, TimeZone } from "./common.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/contracts/subscriptions.ts
|
|
4
|
+
/** Quiet hours window, local to `tz` (default: the chat's zone). `from` > `to` wraps past midnight. */
|
|
5
|
+
const QuietHours = z.object({
|
|
6
|
+
from: ClockTime,
|
|
7
|
+
to: ClockTime,
|
|
8
|
+
tz: TimeZone.optional()
|
|
9
|
+
});
|
|
10
|
+
/** `schedule:<id>`, `event:<key>`, `broadcast`, or `*` (all). */
|
|
11
|
+
const SubscriptionTopic = z.string().regex(/^(\*|broadcast|schedule:[A-Za-z0-9_-]{1,64}|event:[a-z0-9._:-]{1,64})$/);
|
|
12
|
+
/** One chat's preference for one topic. */
|
|
13
|
+
const SubscriptionDto = z.object({
|
|
14
|
+
/** Plugin chat row id. */
|
|
15
|
+
chatRef: Id,
|
|
16
|
+
topic: SubscriptionTopic,
|
|
17
|
+
muted: z.boolean(),
|
|
18
|
+
/** Quiet hours (messages are held until they end), or null. */
|
|
19
|
+
quiet: QuietHours.nullable(),
|
|
20
|
+
updatedAt: EpochMs
|
|
21
|
+
});
|
|
22
|
+
/** `PUT /me/subscriptions` and `PUT /admin/chats/:id/subscriptions`: replaces the chat's list. */
|
|
23
|
+
const SubscriptionSave = z.object({
|
|
24
|
+
chatRef: Id,
|
|
25
|
+
items: z.array(z.object({
|
|
26
|
+
topic: SubscriptionTopic,
|
|
27
|
+
muted: z.boolean(),
|
|
28
|
+
quiet: QuietHours.nullable().default(null)
|
|
29
|
+
})).max(200)
|
|
30
|
+
});
|
|
31
|
+
export { QuietHours, SubscriptionDto, SubscriptionSave, SubscriptionTopic };
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** `message` renders chat text; `report` renders a file (PDF/CSV) with a caption. */
|
|
3
|
+
export declare const TEMPLATE_KINDS: readonly ["message", "report"];
|
|
4
|
+
/** Zod enum of {@link TEMPLATE_KINDS}. */
|
|
5
|
+
export declare const TemplateKind: z.ZodEnum<{
|
|
6
|
+
message: "message";
|
|
7
|
+
report: "report";
|
|
8
|
+
}>;
|
|
9
|
+
export type TemplateKind = z.infer<typeof TemplateKind>;
|
|
10
|
+
/** Body syntax: Telegram HTML subset, or plain text (escaped on send). */
|
|
11
|
+
export declare const TEMPLATE_FORMATS: readonly ["html", "text"];
|
|
12
|
+
/** Zod enum of {@link TEMPLATE_FORMATS}. */
|
|
13
|
+
export declare const TemplateFormat: z.ZodEnum<{
|
|
14
|
+
text: "text";
|
|
15
|
+
html: "html";
|
|
16
|
+
}>;
|
|
17
|
+
export type TemplateFormat = z.infer<typeof TemplateFormat>;
|
|
18
|
+
/** Report file formats with built-in renderers. */
|
|
19
|
+
export declare const REPORT_FORMATS: readonly ["pdf", "csv"];
|
|
20
|
+
/** Zod enum of {@link REPORT_FORMATS}. */
|
|
21
|
+
export declare const ReportFormat: z.ZodEnum<{
|
|
22
|
+
pdf: "pdf";
|
|
23
|
+
csv: "csv";
|
|
24
|
+
}>;
|
|
25
|
+
export type ReportFormat = z.infer<typeof ReportFormat>;
|
|
26
|
+
/** Optional inline button styles. */
|
|
27
|
+
export declare const BUTTON_STYLES: readonly ["primary", "success", "danger"];
|
|
28
|
+
/** Zod enum of {@link BUTTON_STYLES}. */
|
|
29
|
+
export declare const ButtonStyle: z.ZodEnum<{
|
|
30
|
+
success: "success";
|
|
31
|
+
primary: "primary";
|
|
32
|
+
danger: "danger";
|
|
33
|
+
}>;
|
|
34
|
+
export type ButtonStyle = z.infer<typeof ButtonStyle>;
|
|
35
|
+
/** One inline button in a template. Exactly one of `action` or `url`. Params may hold `{{variables}}`. */
|
|
36
|
+
export declare const ButtonSpec: z.ZodObject<{
|
|
37
|
+
text: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
38
|
+
action: z.ZodOptional<z.ZodString>;
|
|
39
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
40
|
+
url: z.ZodOptional<z.ZodString>;
|
|
41
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
success: "success";
|
|
43
|
+
primary: "primary";
|
|
44
|
+
danger: "danger";
|
|
45
|
+
}>>;
|
|
46
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type ButtonSpec = z.infer<typeof ButtonSpec>;
|
|
49
|
+
/** Rows of buttons (Telegram: ≤ 8 per row, ≤ 100 total). */
|
|
50
|
+
export declare const ButtonRows: z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
51
|
+
text: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
52
|
+
action: z.ZodOptional<z.ZodString>;
|
|
53
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
54
|
+
url: z.ZodOptional<z.ZodString>;
|
|
55
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
success: "success";
|
|
57
|
+
primary: "primary";
|
|
58
|
+
danger: "danger";
|
|
59
|
+
}>>;
|
|
60
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
}, z.core.$strip>>>;
|
|
62
|
+
export type ButtonRows = z.infer<typeof ButtonRows>;
|
|
63
|
+
/** How a `report` template renders its file. */
|
|
64
|
+
export declare const ReportSpec: z.ZodObject<{
|
|
65
|
+
renderer: z.ZodEnum<{
|
|
66
|
+
pdf: "pdf";
|
|
67
|
+
csv: "csv";
|
|
68
|
+
}>;
|
|
69
|
+
fileName: z.ZodString;
|
|
70
|
+
layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export type ReportSpec = z.infer<typeof ReportSpec>;
|
|
73
|
+
/** Bot API send options: `silent` = `disable_notification`, `protectContent`, `linkPreview` (default off). */
|
|
74
|
+
export declare const TemplateOptions: z.ZodObject<{
|
|
75
|
+
silent: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
protectContent: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
linkPreview: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export type TemplateOptions = z.infer<typeof TemplateOptions>;
|
|
80
|
+
/** A saved template (`/admin/templates`, permission `telegram.templates.manage`). */
|
|
81
|
+
export declare const TemplateDto: z.ZodObject<{
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
key: z.ZodString;
|
|
84
|
+
name: z.ZodString;
|
|
85
|
+
kind: z.ZodEnum<{
|
|
86
|
+
message: "message";
|
|
87
|
+
report: "report";
|
|
88
|
+
}>;
|
|
89
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
90
|
+
providerParams: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
91
|
+
body: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
92
|
+
format: z.ZodEnum<{
|
|
93
|
+
text: "text";
|
|
94
|
+
html: "html";
|
|
95
|
+
}>;
|
|
96
|
+
report: z.ZodNullable<z.ZodObject<{
|
|
97
|
+
renderer: z.ZodEnum<{
|
|
98
|
+
pdf: "pdf";
|
|
99
|
+
csv: "csv";
|
|
100
|
+
}>;
|
|
101
|
+
fileName: z.ZodString;
|
|
102
|
+
layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
buttons: z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
105
|
+
text: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
106
|
+
action: z.ZodOptional<z.ZodString>;
|
|
107
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
108
|
+
url: z.ZodOptional<z.ZodString>;
|
|
109
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
110
|
+
success: "success";
|
|
111
|
+
primary: "primary";
|
|
112
|
+
danger: "danger";
|
|
113
|
+
}>>;
|
|
114
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
+
}, z.core.$strip>>>>;
|
|
116
|
+
options: z.ZodObject<{
|
|
117
|
+
silent: z.ZodOptional<z.ZodBoolean>;
|
|
118
|
+
protectContent: z.ZodOptional<z.ZodBoolean>;
|
|
119
|
+
linkPreview: z.ZodOptional<z.ZodBoolean>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
version: z.ZodNumber;
|
|
122
|
+
updatedBy: z.ZodNullable<z.ZodString>;
|
|
123
|
+
updatedAt: z.ZodNumber;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
export type TemplateDto = z.infer<typeof TemplateDto>;
|
|
126
|
+
/** `POST`/`PUT /admin/templates` body (defaults: `message`, `html`, no provider, no buttons). Invalid source fails with `template_invalid`. */
|
|
127
|
+
export declare const TemplateSave: z.ZodObject<{
|
|
128
|
+
key: z.ZodString;
|
|
129
|
+
name: z.ZodString;
|
|
130
|
+
kind: z.ZodDefault<z.ZodEnum<{
|
|
131
|
+
message: "message";
|
|
132
|
+
report: "report";
|
|
133
|
+
}>>;
|
|
134
|
+
provider: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
135
|
+
providerParams: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
136
|
+
body: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
137
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
138
|
+
text: "text";
|
|
139
|
+
html: "html";
|
|
140
|
+
}>>;
|
|
141
|
+
report: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
142
|
+
renderer: z.ZodEnum<{
|
|
143
|
+
pdf: "pdf";
|
|
144
|
+
csv: "csv";
|
|
145
|
+
}>;
|
|
146
|
+
fileName: z.ZodString;
|
|
147
|
+
layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
148
|
+
}, z.core.$strip>>>;
|
|
149
|
+
buttons: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
150
|
+
text: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
151
|
+
action: z.ZodOptional<z.ZodString>;
|
|
152
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
153
|
+
url: z.ZodOptional<z.ZodString>;
|
|
154
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
155
|
+
success: "success";
|
|
156
|
+
primary: "primary";
|
|
157
|
+
danger: "danger";
|
|
158
|
+
}>>;
|
|
159
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
160
|
+
}, z.core.$strip>>>>>;
|
|
161
|
+
options: z.ZodDefault<z.ZodObject<{
|
|
162
|
+
silent: z.ZodOptional<z.ZodBoolean>;
|
|
163
|
+
protectContent: z.ZodOptional<z.ZodBoolean>;
|
|
164
|
+
linkPreview: z.ZodOptional<z.ZodBoolean>;
|
|
165
|
+
}, z.core.$strip>>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
export type TemplateSave = z.infer<typeof TemplateSave>;
|
|
168
|
+
/** One saved version (`GET /admin/templates/:id/versions`; restore with `POST …/restore/:version`). */
|
|
169
|
+
export declare const TemplateVersionDto: z.ZodObject<{
|
|
170
|
+
templateId: z.ZodString;
|
|
171
|
+
version: z.ZodNumber;
|
|
172
|
+
body: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
173
|
+
report: z.ZodNullable<z.ZodObject<{
|
|
174
|
+
renderer: z.ZodEnum<{
|
|
175
|
+
pdf: "pdf";
|
|
176
|
+
csv: "csv";
|
|
177
|
+
}>;
|
|
178
|
+
fileName: z.ZodString;
|
|
179
|
+
layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
180
|
+
}, z.core.$strip>>;
|
|
181
|
+
buttons: z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
182
|
+
text: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
183
|
+
action: z.ZodOptional<z.ZodString>;
|
|
184
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
185
|
+
url: z.ZodOptional<z.ZodString>;
|
|
186
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
187
|
+
success: "success";
|
|
188
|
+
primary: "primary";
|
|
189
|
+
danger: "danger";
|
|
190
|
+
}>>;
|
|
191
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
192
|
+
}, z.core.$strip>>>>;
|
|
193
|
+
savedBy: z.ZodNullable<z.ZodString>;
|
|
194
|
+
savedAt: z.ZodNumber;
|
|
195
|
+
}, z.core.$strip>;
|
|
196
|
+
export type TemplateVersionDto = z.infer<typeof TemplateVersionDto>;
|
|
197
|
+
/** Preview as a role or a user, so the admin sees exactly what that audience gets. */
|
|
198
|
+
export declare const PreviewAs: z.ZodUnion<readonly [z.ZodObject<{
|
|
199
|
+
role: z.ZodString;
|
|
200
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
201
|
+
userId: z.ZodString;
|
|
202
|
+
}, z.core.$strict>]>;
|
|
203
|
+
export type PreviewAs = z.infer<typeof PreviewAs>;
|
|
204
|
+
/** `POST /admin/templates/preview`: render a saved template (`templateId`) or unsaved `source`. */
|
|
205
|
+
export declare const TemplatePreviewRequest: z.ZodObject<{
|
|
206
|
+
templateId: z.ZodOptional<z.ZodString>;
|
|
207
|
+
source: z.ZodOptional<z.ZodString>;
|
|
208
|
+
buttons: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
209
|
+
text: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
210
|
+
action: z.ZodOptional<z.ZodString>;
|
|
211
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
212
|
+
url: z.ZodOptional<z.ZodString>;
|
|
213
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
214
|
+
success: "success";
|
|
215
|
+
primary: "primary";
|
|
216
|
+
danger: "danger";
|
|
217
|
+
}>>;
|
|
218
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
219
|
+
}, z.core.$strip>>>>;
|
|
220
|
+
format: z.ZodOptional<z.ZodEnum<{
|
|
221
|
+
text: "text";
|
|
222
|
+
html: "html";
|
|
223
|
+
}>>;
|
|
224
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
225
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
226
|
+
as: z.ZodUnion<readonly [z.ZodObject<{
|
|
227
|
+
role: z.ZodString;
|
|
228
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
229
|
+
userId: z.ZodString;
|
|
230
|
+
}, z.core.$strict>]>;
|
|
231
|
+
locale: z.ZodString;
|
|
232
|
+
sample: z.ZodOptional<z.ZodBoolean>;
|
|
233
|
+
}, z.core.$strip>;
|
|
234
|
+
export type TemplatePreviewRequest = z.infer<typeof TemplatePreviewRequest>;
|
|
235
|
+
/** A rendered inline button (callback data is not exposed in previews). */
|
|
236
|
+
export declare const PreviewButton: z.ZodObject<{
|
|
237
|
+
text: z.ZodString;
|
|
238
|
+
kind: z.ZodEnum<{
|
|
239
|
+
action: "action";
|
|
240
|
+
url: "url";
|
|
241
|
+
}>;
|
|
242
|
+
url: z.ZodNullable<z.ZodString>;
|
|
243
|
+
style: z.ZodNullable<z.ZodEnum<{
|
|
244
|
+
success: "success";
|
|
245
|
+
primary: "primary";
|
|
246
|
+
danger: "danger";
|
|
247
|
+
}>>;
|
|
248
|
+
disabled: z.ZodBoolean;
|
|
249
|
+
}, z.core.$strip>;
|
|
250
|
+
export type PreviewButton = z.infer<typeof PreviewButton>;
|
|
251
|
+
/** A file a preview would attach (`size` in bytes, null if unknown). */
|
|
252
|
+
export declare const PreviewFile: z.ZodObject<{
|
|
253
|
+
name: z.ZodString;
|
|
254
|
+
mime: z.ZodString;
|
|
255
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
256
|
+
}, z.core.$strip>;
|
|
257
|
+
export type PreviewFile = z.infer<typeof PreviewFile>;
|
|
258
|
+
/** Rendered preview; `warnings` are non-fatal template issues. */
|
|
259
|
+
export declare const TemplatePreviewResponse: z.ZodObject<{
|
|
260
|
+
parts: z.ZodArray<z.ZodString>;
|
|
261
|
+
buttons: z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
262
|
+
text: z.ZodString;
|
|
263
|
+
kind: z.ZodEnum<{
|
|
264
|
+
action: "action";
|
|
265
|
+
url: "url";
|
|
266
|
+
}>;
|
|
267
|
+
url: z.ZodNullable<z.ZodString>;
|
|
268
|
+
style: z.ZodNullable<z.ZodEnum<{
|
|
269
|
+
success: "success";
|
|
270
|
+
primary: "primary";
|
|
271
|
+
danger: "danger";
|
|
272
|
+
}>>;
|
|
273
|
+
disabled: z.ZodBoolean;
|
|
274
|
+
}, z.core.$strip>>>>;
|
|
275
|
+
file: z.ZodNullable<z.ZodObject<{
|
|
276
|
+
name: z.ZodString;
|
|
277
|
+
mime: z.ZodString;
|
|
278
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
279
|
+
}, z.core.$strip>>;
|
|
280
|
+
warnings: z.ZodArray<z.ZodObject<{
|
|
281
|
+
line: z.ZodNumber;
|
|
282
|
+
column: z.ZodNumber;
|
|
283
|
+
message: z.ZodString;
|
|
284
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
285
|
+
}, z.core.$strip>>;
|
|
286
|
+
}, z.core.$strip>;
|
|
287
|
+
export type TemplatePreviewResponse = z.infer<typeof TemplatePreviewResponse>;
|
|
288
|
+
/** Cell formats. `money` reads integer minor units; `date`/`datetime` read epoch ms (or ISO) in the report's zone. */
|
|
289
|
+
export declare const REPORT_COLUMN_FORMATS: readonly ["text", "number", "money", "date", "datetime", "yesno"];
|
|
290
|
+
/** Zod enum of {@link REPORT_COLUMN_FORMATS}. */
|
|
291
|
+
export declare const ReportColumnFormat: z.ZodEnum<{
|
|
292
|
+
number: "number";
|
|
293
|
+
date: "date";
|
|
294
|
+
datetime: "datetime";
|
|
295
|
+
text: "text";
|
|
296
|
+
money: "money";
|
|
297
|
+
yesno: "yesno";
|
|
298
|
+
}>;
|
|
299
|
+
export type ReportColumnFormat = z.infer<typeof ReportColumnFormat>;
|
|
300
|
+
/** One report column: a field of each row (dotted path), its header and how the value is written. */
|
|
301
|
+
export declare const ReportColumn: z.ZodObject<{
|
|
302
|
+
key: z.ZodString;
|
|
303
|
+
label: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodString>, z.ZodString]>;
|
|
304
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
305
|
+
number: "number";
|
|
306
|
+
date: "date";
|
|
307
|
+
datetime: "datetime";
|
|
308
|
+
text: "text";
|
|
309
|
+
money: "money";
|
|
310
|
+
yesno: "yesno";
|
|
311
|
+
}>>;
|
|
312
|
+
}, z.core.$strip>;
|
|
313
|
+
export type ReportColumn = z.infer<typeof ReportColumn>;
|
|
314
|
+
/**
|
|
315
|
+
* `report_json.layout` for the built-in renderers: `rows` names the provider variable holding the row array
|
|
316
|
+
* (default: the first array variable); `columns` picks and labels fields (default: every field of the first row).
|
|
317
|
+
*/
|
|
318
|
+
export declare const ReportLayout: z.ZodObject<{
|
|
319
|
+
rows: z.ZodOptional<z.ZodString>;
|
|
320
|
+
columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
321
|
+
key: z.ZodString;
|
|
322
|
+
label: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodString>, z.ZodString]>;
|
|
323
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
324
|
+
number: "number";
|
|
325
|
+
date: "date";
|
|
326
|
+
datetime: "datetime";
|
|
327
|
+
text: "text";
|
|
328
|
+
money: "money";
|
|
329
|
+
yesno: "yesno";
|
|
330
|
+
}>>;
|
|
331
|
+
}, z.core.$strip>>>;
|
|
332
|
+
title: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
333
|
+
}, z.core.$strip>;
|
|
334
|
+
export type ReportLayout = z.infer<typeof ReportLayout>;
|
|
335
|
+
/** Filters for `GET /admin/templates`. */
|
|
336
|
+
export declare const TemplateQuery: z.ZodObject<{
|
|
337
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
338
|
+
message: "message";
|
|
339
|
+
report: "report";
|
|
340
|
+
}>>;
|
|
341
|
+
}, z.core.$strip>;
|
|
342
|
+
export type TemplateQuery = z.infer<typeof TemplateQuery>;
|
|
343
|
+
/** `POST /admin/reports/render`: the same file the bot would send, as a download. */
|
|
344
|
+
export declare const ReportRenderRequest: z.ZodObject<{
|
|
345
|
+
template: z.ZodString;
|
|
346
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
347
|
+
as: z.ZodUnion<readonly [z.ZodObject<{
|
|
348
|
+
role: z.ZodString;
|
|
349
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
350
|
+
userId: z.ZodString;
|
|
351
|
+
}, z.core.$strict>]>;
|
|
352
|
+
format: z.ZodOptional<z.ZodEnum<{
|
|
353
|
+
pdf: "pdf";
|
|
354
|
+
csv: "csv";
|
|
355
|
+
}>>;
|
|
356
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
357
|
+
}, z.core.$strip>;
|
|
358
|
+
export type ReportRenderRequest = z.infer<typeof ReportRenderRequest>;
|