@qcobro/common 1.11.3 → 1.11.4
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/dist/config.d.ts +307 -0
- package/dist/config.d.ts.map +1 -0
- package/{src/config.ts → dist/config.js} +123 -154
- package/dist/config.js.map +1 -0
- package/dist/errors/ValidationError.d.ts +27 -0
- package/dist/errors/ValidationError.d.ts.map +1 -0
- package/dist/errors/ValidationError.js +52 -0
- package/dist/errors/ValidationError.js.map +1 -0
- package/{src/errors/index.ts → dist/errors/index.d.ts} +1 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +2 -5
- package/dist/index.js.map +1 -0
- package/dist/schemas/agentTemplates.d.ts +73 -0
- package/dist/schemas/agentTemplates.d.ts.map +1 -0
- package/dist/schemas/agentTemplates.js +90 -0
- package/dist/schemas/agentTemplates.js.map +1 -0
- package/dist/schemas/apiKeys.d.ts +17 -0
- package/dist/schemas/apiKeys.d.ts.map +1 -0
- package/{src/schemas/apiKeys.ts → dist/schemas/apiKeys.js} +11 -16
- package/dist/schemas/apiKeys.js.map +1 -0
- package/dist/schemas/auth.d.ts +74 -0
- package/dist/schemas/auth.d.ts.map +1 -0
- package/dist/schemas/auth.js +53 -0
- package/dist/schemas/auth.js.map +1 -0
- package/dist/schemas/campaigns.d.ts +61 -0
- package/dist/schemas/campaigns.d.ts.map +1 -0
- package/{src/schemas/campaigns.ts → dist/schemas/campaigns.js} +20 -32
- package/dist/schemas/campaigns.js.map +1 -0
- package/dist/schemas/contactLog.d.ts +121 -0
- package/dist/schemas/contactLog.d.ts.map +1 -0
- package/dist/schemas/contactLog.js +83 -0
- package/dist/schemas/contactLog.js.map +1 -0
- package/dist/schemas/dispatch.d.ts +51 -0
- package/dist/schemas/dispatch.d.ts.map +1 -0
- package/{src/schemas/dispatch.ts → dist/schemas/dispatch.js} +55 -61
- package/dist/schemas/dispatch.js.map +1 -0
- package/dist/schemas/email.d.ts +38 -0
- package/dist/schemas/email.d.ts.map +1 -0
- package/dist/schemas/email.js +34 -0
- package/dist/schemas/email.js.map +1 -0
- package/dist/schemas/index.d.ts +16 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/{src/schemas/index.ts → dist/schemas/index.js} +1 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/insight.d.ts +25 -0
- package/dist/schemas/insight.d.ts.map +1 -0
- package/{src/schemas/insight.ts → dist/schemas/insight.js} +6 -9
- package/dist/schemas/insight.js.map +1 -0
- package/dist/schemas/portfolios.d.ts +65 -0
- package/dist/schemas/portfolios.d.ts.map +1 -0
- package/dist/schemas/portfolios.js +40 -0
- package/dist/schemas/portfolios.js.map +1 -0
- package/dist/schemas/userSettings.d.ts +25 -0
- package/dist/schemas/userSettings.d.ts.map +1 -0
- package/{src/schemas/userSettings.ts → dist/schemas/userSettings.js} +4 -9
- package/dist/schemas/userSettings.js.map +1 -0
- package/dist/schemas/users.d.ts +7 -0
- package/dist/schemas/users.d.ts.map +1 -0
- package/dist/schemas/users.js +6 -0
- package/dist/schemas/users.js.map +1 -0
- package/dist/schemas/voiceEvent.d.ts +37 -0
- package/dist/schemas/voiceEvent.d.ts.map +1 -0
- package/dist/schemas/voiceEvent.js +35 -0
- package/dist/schemas/voiceEvent.js.map +1 -0
- package/dist/schemas/whatsApp.d.ts +76 -0
- package/dist/schemas/whatsApp.d.ts.map +1 -0
- package/dist/schemas/whatsApp.js +85 -0
- package/dist/schemas/whatsApp.js.map +1 -0
- package/dist/schemas/workspaceSettings.d.ts +27 -0
- package/dist/schemas/workspaceSettings.d.ts.map +1 -0
- package/{src/schemas/workspaceSettings.ts → dist/schemas/workspaceSettings.js} +6 -11
- package/dist/schemas/workspaceSettings.js.map +1 -0
- package/dist/schemas/workspaces.d.ts +50 -0
- package/dist/schemas/workspaces.d.ts.map +1 -0
- package/dist/schemas/workspaces.js +36 -0
- package/dist/schemas/workspaces.js.map +1 -0
- package/dist/types/agentTemplates.d.ts +119 -0
- package/dist/types/agentTemplates.d.ts.map +1 -0
- package/dist/types/agentTemplates.js +2 -0
- package/dist/types/agentTemplates.js.map +1 -0
- package/dist/types/campaigns.d.ts +257 -0
- package/dist/types/campaigns.d.ts.map +1 -0
- package/dist/types/campaigns.js +2 -0
- package/dist/types/campaigns.js.map +1 -0
- package/dist/types/dispatch.d.ts +168 -0
- package/dist/types/dispatch.d.ts.map +1 -0
- package/dist/types/dispatch.js +8 -0
- package/dist/types/dispatch.js.map +1 -0
- package/dist/types/email.d.ts +65 -0
- package/dist/types/email.d.ts.map +1 -0
- package/dist/types/email.js +7 -0
- package/dist/types/email.js.map +1 -0
- package/{src/types/engine.ts → dist/types/engine.d.ts} +23 -46
- package/dist/types/engine.d.ts.map +1 -0
- package/dist/types/engine.js +10 -0
- package/dist/types/engine.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/{src/types/index.ts → dist/types/index.js} +1 -0
- package/dist/types/index.js.map +1 -0
- package/{src/types/insight.ts → dist/types/insight.d.ts} +10 -8
- package/dist/types/insight.d.ts.map +1 -0
- package/dist/types/insight.js +2 -0
- package/dist/types/insight.js.map +1 -0
- package/dist/types/portfolios.d.ts +153 -0
- package/dist/types/portfolios.d.ts.map +1 -0
- package/dist/types/portfolios.js +2 -0
- package/dist/types/portfolios.js.map +1 -0
- package/dist/types/userSettings.d.ts +25 -0
- package/dist/types/userSettings.d.ts.map +1 -0
- package/dist/types/userSettings.js +2 -0
- package/dist/types/userSettings.js.map +1 -0
- package/dist/types/voiceApplication.d.ts +32 -0
- package/dist/types/voiceApplication.d.ts.map +1 -0
- package/dist/types/voiceApplication.js +7 -0
- package/dist/types/voiceApplication.js.map +1 -0
- package/dist/types/whatsApp.d.ts +97 -0
- package/dist/types/whatsApp.d.ts.map +1 -0
- package/dist/types/whatsApp.js +2 -0
- package/dist/types/whatsApp.js.map +1 -0
- package/dist/types/workspaceSettings.d.ts +26 -0
- package/dist/types/workspaceSettings.d.ts.map +1 -0
- package/dist/types/workspaceSettings.js +2 -0
- package/dist/types/workspaceSettings.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/{src/utils/outreach.ts → dist/utils/outreach.d.ts} +7 -32
- package/dist/utils/outreach.d.ts.map +1 -0
- package/dist/utils/outreach.js +49 -0
- package/dist/utils/outreach.js.map +1 -0
- package/dist/utils/time.d.ts +25 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +52 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/utils/withErrorHandlingAndValidation.d.ts +18 -0
- package/dist/utils/withErrorHandlingAndValidation.d.ts.map +1 -0
- package/{src/utils/withErrorHandlingAndValidation.ts → dist/utils/withErrorHandlingAndValidation.js} +9 -15
- package/dist/utils/withErrorHandlingAndValidation.js.map +1 -0
- package/package.json +4 -1
- package/CHANGELOG.md +0 -115
- package/src/config.test.ts +0 -19
- package/src/errors/ValidationError.test.ts +0 -38
- package/src/errors/ValidationError.ts +0 -68
- package/src/schemas/agentTemplates.ts +0 -100
- package/src/schemas/apiKeys.test.ts +0 -38
- package/src/schemas/auth.ts +0 -76
- package/src/schemas/contactLog.ts +0 -96
- package/src/schemas/email.ts +0 -37
- package/src/schemas/portfolios.ts +0 -49
- package/src/schemas/users.ts +0 -7
- package/src/schemas/voiceEvent.ts +0 -45
- package/src/schemas/whatsApp.ts +0 -101
- package/src/schemas/workspaces.ts +0 -53
- package/src/types/agentTemplates.ts +0 -104
- package/src/types/campaigns.ts +0 -210
- package/src/types/dispatch.ts +0 -160
- package/src/types/email.ts +0 -66
- package/src/types/portfolios.ts +0 -128
- package/src/types/userSettings.ts +0 -21
- package/src/types/voiceApplication.ts +0 -29
- package/src/types/whatsApp.ts +0 -82
- package/src/types/workspaceSettings.ts +0 -22
- package/src/utils/index.ts +0 -14
- package/src/utils/outreach.test.ts +0 -83
- package/src/utils/time.ts +0 -66
- package/src/utils/withErrorHandlingAndValidation.test.ts +0 -33
- package/tsconfig.json +0 -9
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* QCobro service configuration — the shape of `qcobro.json`.
|
|
5
4
|
*
|
|
@@ -12,27 +11,23 @@ import { z } from "zod";
|
|
|
12
11
|
* issuer, SMTP, …) lives with that service, not here.
|
|
13
12
|
*/
|
|
14
13
|
export const identityConfigSchema = z.object({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
/** host:port the apiserver uses to reach the external Identity gRPC service. */
|
|
15
|
+
endpoint: z.string().default("localhost:50051"),
|
|
16
|
+
/** Base URL of the Identity HTTP bridge (accepts invite tokens). */
|
|
17
|
+
httpBridgeUrl: z.string().default("http://localhost:9110")
|
|
19
18
|
});
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
20
|
* A selectable voice in the deployment's catalog. Voice agent templates pick a
|
|
23
21
|
* voice by `id` (the provider's voice identifier, e.g. an ElevenLabs voice id);
|
|
24
22
|
* the console renders the picker from this catalog rather than free text.
|
|
25
23
|
*/
|
|
26
24
|
export const voiceCatalogEntrySchema = z.object({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
id: z.string().min(1),
|
|
26
|
+
name: z.string().min(1),
|
|
27
|
+
language: z.string().min(1),
|
|
28
|
+
gender: z.enum(["female", "male"]),
|
|
29
|
+
provider: z.string().min(1).default("elevenlabs")
|
|
32
30
|
});
|
|
33
|
-
|
|
34
|
-
export type VoiceCatalogEntry = z.infer<typeof voiceCatalogEntrySchema>;
|
|
35
|
-
|
|
36
31
|
/**
|
|
37
32
|
* Fonoster connection + Autopilot defaults. VOICE_AI agent templates are synced to
|
|
38
33
|
* Fonoster as AUTOPILOT applications; the apiserver authenticates with a workspace
|
|
@@ -40,7 +35,7 @@ export type VoiceCatalogEntry = z.infer<typeof voiceCatalogEntrySchema>;
|
|
|
40
35
|
* and stay unsynced (the console offers a manual re-sync).
|
|
41
36
|
*/
|
|
42
37
|
export const fonosterConfigSchema = z
|
|
43
|
-
|
|
38
|
+
.object({
|
|
44
39
|
accessKeyId: z.string().min(1),
|
|
45
40
|
apiKey: z.string().min(1),
|
|
46
41
|
apiSecret: z.string().min(1),
|
|
@@ -50,7 +45,7 @@ export const fonosterConfigSchema = z
|
|
|
50
45
|
* TTS product is NOT set here — it is derived per voice (see `voices`) since
|
|
51
46
|
* both Voz IA and pre-recorded voice use it. */
|
|
52
47
|
autopilot: z
|
|
53
|
-
|
|
48
|
+
.object({
|
|
54
49
|
sttProductRef: z.string().default("stt.deepgram"),
|
|
55
50
|
sttModel: z.string().default("nova-3"),
|
|
56
51
|
llmProductRef: z.string().default("llm.google"),
|
|
@@ -58,8 +53,8 @@ export const fonosterConfigSchema = z
|
|
|
58
53
|
llmModel: z.string().default("gemini-2.0-flash"),
|
|
59
54
|
maxTokens: z.number().default(300),
|
|
60
55
|
temperature: z.number().default(0)
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
})
|
|
57
|
+
.default({
|
|
63
58
|
sttProductRef: "stt.deepgram",
|
|
64
59
|
sttModel: "nova-3",
|
|
65
60
|
llmProductRef: "llm.google",
|
|
@@ -67,7 +62,7 @@ export const fonosterConfigSchema = z
|
|
|
67
62
|
llmModel: "gemini-2.0-flash",
|
|
68
63
|
maxTokens: 300,
|
|
69
64
|
temperature: 0
|
|
70
|
-
|
|
65
|
+
}),
|
|
71
66
|
/**
|
|
72
67
|
* Selectable voice catalog for voice agent templates (Voz IA + pre-recorded).
|
|
73
68
|
* Voices are Fonoster-only, so they live here. Seeded with three Spanish
|
|
@@ -104,27 +99,23 @@ export const fonosterConfigSchema = z
|
|
|
104
99
|
* size and typical call duration. Reserve `0` to pause voice dispatch.
|
|
105
100
|
*/
|
|
106
101
|
maxCallsPerMinute: z.number().int().nonnegative().default(6)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
export type FonosterConfig = z.infer<typeof fonosterConfigSchema>;
|
|
111
|
-
|
|
102
|
+
})
|
|
103
|
+
.optional();
|
|
112
104
|
/**
|
|
113
105
|
* Derives the TTS product ref for a voice from its provider (e.g. an `elevenlabs`
|
|
114
106
|
* voice → `tts.elevenlabs`). Used by both Voz IA (Autopilot) and pre-recorded
|
|
115
107
|
* voice. Falls back to `tts.elevenlabs` when the voice isn't in the catalog.
|
|
116
108
|
*/
|
|
117
|
-
export function ttsProductRefForVoice(voiceId
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
export function ttsProductRefForVoice(voiceId, voices) {
|
|
110
|
+
const voice = voices.find((v) => v.id === voiceId);
|
|
111
|
+
return voice ? `tts.${voice.provider}` : "tts.elevenlabs";
|
|
120
112
|
}
|
|
121
|
-
|
|
122
113
|
/**
|
|
123
114
|
* Twilio connection for SMS dispatch. Optional — when absent, SMS dispatch fails
|
|
124
115
|
* with a clear error. `fromNumbers` (E.164) are rotated through per message.
|
|
125
116
|
*/
|
|
126
117
|
export const twilioConfigSchema = z
|
|
127
|
-
|
|
118
|
+
.object({
|
|
128
119
|
accountSid: z.string().min(1),
|
|
129
120
|
authToken: z.string().min(1),
|
|
130
121
|
fromNumbers: z.array(z.string().min(1)).default([]),
|
|
@@ -134,11 +125,8 @@ export const twilioConfigSchema = z
|
|
|
134
125
|
* Reserve `0` to pause SMS dispatch.
|
|
135
126
|
*/
|
|
136
127
|
maxSmsPerMinute: z.number().int().nonnegative().default(60)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
export type TwilioConfig = z.infer<typeof twilioConfigSchema>;
|
|
141
|
-
|
|
128
|
+
})
|
|
129
|
+
.optional();
|
|
142
130
|
/**
|
|
143
131
|
* Resend connection for the bidirectional EMAIL channel. Optional — when absent, EMAIL
|
|
144
132
|
* dispatch is inert (the engine reports EMAIL campaigns as not-configured) and the inbound
|
|
@@ -147,7 +135,7 @@ export type TwilioConfig = z.infer<typeof twilioConfigSchema>;
|
|
|
147
135
|
* `inboundSigningSecret`. The per-attempt reply cap defaults to `maxRepliesDefault`.
|
|
148
136
|
*/
|
|
149
137
|
export const resendConfigSchema = z
|
|
150
|
-
|
|
138
|
+
.object({
|
|
151
139
|
apiKey: z.string().min(1),
|
|
152
140
|
fromEmail: z.string().email(),
|
|
153
141
|
fromName: z.string().min(1).optional(),
|
|
@@ -166,11 +154,8 @@ export const resendConfigSchema = z
|
|
|
166
154
|
* keep the AI talking indefinitely.
|
|
167
155
|
*/
|
|
168
156
|
maxRepliesDefault: z.number().int().nonnegative().default(3)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
export type ResendConfig = z.infer<typeof resendConfigSchema>;
|
|
173
|
-
|
|
157
|
+
})
|
|
158
|
+
.optional();
|
|
174
159
|
/**
|
|
175
160
|
* AI-insight generation. Produces a gestión's structured analysis from its
|
|
176
161
|
* conversation transcript. Optional — when absent or `enabled:false`, no LLM is
|
|
@@ -182,18 +167,15 @@ export type ResendConfig = z.infer<typeof resendConfigSchema>;
|
|
|
182
167
|
* demos, and tests, with no key and no network/cost.
|
|
183
168
|
*/
|
|
184
169
|
export const aiProviderSchema = z.enum(["mock", "google", "openai", "anthropic"]);
|
|
185
|
-
export type AiProvider = z.infer<typeof aiProviderSchema>;
|
|
186
|
-
|
|
187
170
|
/** Valid models per provider; used to reject misconfiguration at load. */
|
|
188
|
-
export const AI_MODELS
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
171
|
+
export const AI_MODELS = {
|
|
172
|
+
mock: ["mock"],
|
|
173
|
+
google: ["gemini-2.5-flash", "gemini-2.5-flash-lite", "gemini-2.5-pro", "gemini-2.0-flash"],
|
|
174
|
+
openai: ["gpt-4o", "gpt-4o-mini", "gpt-4.1"],
|
|
175
|
+
anthropic: ["claude-3-5-sonnet-latest", "claude-3-5-haiku-latest"]
|
|
193
176
|
};
|
|
194
|
-
|
|
195
177
|
export const aiConfigSchema = z
|
|
196
|
-
|
|
178
|
+
.object({
|
|
197
179
|
enabled: z.boolean().default(false),
|
|
198
180
|
provider: aiProviderSchema.default("mock"),
|
|
199
181
|
apiKey: z.string().optional(),
|
|
@@ -203,23 +185,20 @@ export const aiConfigSchema = z
|
|
|
203
185
|
/** When the analysis is produced. `onDemand` = on first detail open (then
|
|
204
186
|
* cached); `onIngestion` = when the transcript is first stored. */
|
|
205
187
|
generation: z.enum(["onDemand", "onIngestion"]).default("onDemand")
|
|
206
|
-
|
|
207
|
-
|
|
188
|
+
})
|
|
189
|
+
.superRefine((cfg, ctx) => {
|
|
208
190
|
if (!AI_MODELS[cfg.provider].includes(cfg.model)) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
191
|
+
ctx.addIssue({
|
|
192
|
+
code: z.ZodIssueCode.custom,
|
|
193
|
+
path: ["model"],
|
|
194
|
+
message: `Invalid model "${cfg.model}" for provider "${cfg.provider}". Valid: ${AI_MODELS[cfg.provider].join(", ")}`
|
|
195
|
+
});
|
|
214
196
|
}
|
|
215
197
|
// apiKey is optional here: it may be omitted and supplied via an environment
|
|
216
198
|
// variable instead (the adapter resolves it and errors clearly if none is found
|
|
217
199
|
// at call time).
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
export type AiConfig = z.infer<typeof aiConfigSchema>;
|
|
222
|
-
|
|
200
|
+
})
|
|
201
|
+
.optional();
|
|
223
202
|
/**
|
|
224
203
|
* Text-to-speech for previewing pre-recorded agent scripts in the console (the
|
|
225
204
|
* Pre-grabada gestión detail plays the script as audio). Optional — when absent, the
|
|
@@ -227,15 +206,12 @@ export type AiConfig = z.infer<typeof aiConfigSchema>;
|
|
|
227
206
|
* unavailable. Voices come from `fonoster.voices`.
|
|
228
207
|
*/
|
|
229
208
|
export const ttsConfigSchema = z
|
|
230
|
-
|
|
209
|
+
.object({
|
|
231
210
|
provider: z.literal("elevenlabs").default("elevenlabs"),
|
|
232
211
|
apiKey: z.string().optional(),
|
|
233
212
|
model: z.string().default("eleven_multilingual_v2")
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
export type TtsConfig = z.infer<typeof ttsConfigSchema>;
|
|
238
|
-
|
|
213
|
+
})
|
|
214
|
+
.optional();
|
|
239
215
|
/**
|
|
240
216
|
* A piece of user-facing copy that may be localized. Either a single string
|
|
241
217
|
* (same text for every language) or a map of language code → string
|
|
@@ -243,11 +219,9 @@ export type TtsConfig = z.infer<typeof ttsConfigSchema>;
|
|
|
243
219
|
* resolves it against the active UI language, falling back to any available value.
|
|
244
220
|
*/
|
|
245
221
|
export const localizedStringSchema = z.union([
|
|
246
|
-
|
|
247
|
-
|
|
222
|
+
z.string().min(1),
|
|
223
|
+
z.record(z.string(), z.string().min(1))
|
|
248
224
|
]);
|
|
249
|
-
export type LocalizedString = z.infer<typeof localizedStringSchema>;
|
|
250
|
-
|
|
251
225
|
/**
|
|
252
226
|
* A deployment-wide announcement rendered as a dismissible banner across the
|
|
253
227
|
* console (and the workspace picker). Optional — when absent, no banner shows.
|
|
@@ -257,102 +231,97 @@ export type LocalizedString = z.infer<typeof localizedStringSchema>;
|
|
|
257
231
|
* `title` and `message` are localizable (see {@link localizedStringSchema}).
|
|
258
232
|
*/
|
|
259
233
|
export const announcementConfigSchema = z
|
|
260
|
-
|
|
234
|
+
.object({
|
|
261
235
|
enabled: z.boolean().default(true),
|
|
262
236
|
/** Color scheme: `announcement` (blue), `alert` (amber), `success` (green), `danger` (red). */
|
|
263
237
|
variant: z.enum(["announcement", "alert", "success", "danger"]).default("announcement"),
|
|
264
238
|
/** Leading icon from a curated set. */
|
|
265
239
|
icon: z
|
|
266
|
-
|
|
267
|
-
|
|
240
|
+
.enum(["megaphone", "info", "alert-triangle", "sparkles", "rocket", "bell"])
|
|
241
|
+
.default("megaphone"),
|
|
268
242
|
/** Whether the user can dismiss the banner. */
|
|
269
243
|
dismissible: z.boolean().default(true),
|
|
270
244
|
title: localizedStringSchema.optional(),
|
|
271
245
|
message: localizedStringSchema
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
export type AnnouncementConfig = z.infer<typeof announcementConfigSchema>;
|
|
276
|
-
|
|
246
|
+
})
|
|
247
|
+
.optional();
|
|
277
248
|
export const qcobroConfigSchema = z.object({
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
249
|
+
/** Application (apiserver) database. */
|
|
250
|
+
database: z.object({ url: z.string().min(1) }),
|
|
251
|
+
identity: identityConfigSchema,
|
|
252
|
+
apiserver: z
|
|
253
|
+
.object({
|
|
254
|
+
port: z.number().default(3000),
|
|
255
|
+
/**
|
|
256
|
+
* Port for the embedded Fonoster VoiceServer (external voice application).
|
|
257
|
+
* Pre-recorded voice agents are EXTERNAL Fonoster apps that call back into
|
|
258
|
+
* this server; it answers and plays the rendered script via the Say verb.
|
|
259
|
+
*/
|
|
260
|
+
voicePort: z.number().default(50061),
|
|
261
|
+
/** External contact-log ingress (`POST /api/contact-logs`) auth gate. */
|
|
262
|
+
contactLogAuth: z.object({ enabled: z.boolean().default(false) }).default({ enabled: false })
|
|
292
263
|
})
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
264
|
+
.default({
|
|
265
|
+
port: 3000,
|
|
266
|
+
voicePort: 50061,
|
|
267
|
+
contactLogAuth: { enabled: false }
|
|
297
268
|
}),
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
269
|
+
fonoster: fonosterConfigSchema,
|
|
270
|
+
twilio: twilioConfigSchema,
|
|
271
|
+
resend: resendConfigSchema,
|
|
272
|
+
ai: aiConfigSchema,
|
|
273
|
+
tts: ttsConfigSchema,
|
|
274
|
+
announcement: announcementConfigSchema,
|
|
275
|
+
/**
|
|
276
|
+
* Secret-at-rest. `cloakEncryptionKey` is a versioned AES-GCM-256 key
|
|
277
|
+
* (`k1.aesgcm256.<base64-32-byte>`) used by `prisma-field-encryption` (the Fonoster/Routr
|
|
278
|
+
* "cloak" pattern) to encrypt tenant-provided secrets — today the WhatsApp WABA access
|
|
279
|
+
* token. Optional: when absent, features that store tenant secrets (the Workspace
|
|
280
|
+
* Integrations area) are disabled rather than crashing boot. Only the *key* is global; the
|
|
281
|
+
* *secret* is per-workspace in the DB.
|
|
282
|
+
*/
|
|
283
|
+
security: z.object({ cloakEncryptionKey: z.string().min(1).optional() }).optional(),
|
|
284
|
+
/**
|
|
285
|
+
* WhatsApp (Meta Cloud API) connection defaults. Per-workspace credentials (WABA id +
|
|
286
|
+
* access token) live in the DB, not here — only the shared Graph API base/version are
|
|
287
|
+
* deployment config.
|
|
288
|
+
*/
|
|
289
|
+
whatsapp: z
|
|
290
|
+
.object({
|
|
291
|
+
apiBaseUrl: z.string().url().default("https://graph.facebook.com"),
|
|
292
|
+
apiVersion: z.string().default("v18.0"),
|
|
293
|
+
/** Engine pacing: max template messages the engine may dispatch per minute. */
|
|
294
|
+
maxMessagesPerMinute: z.number().int().positive().default(60),
|
|
295
|
+
/**
|
|
296
|
+
* Meta App Secret — used to verify the `X-Hub-Signature-256` on inbound webhook
|
|
297
|
+
* events. Optional: when absent, signature verification is skipped (not recommended
|
|
298
|
+
* in production).
|
|
299
|
+
*/
|
|
300
|
+
appSecret: z.string().min(1).optional(),
|
|
301
|
+
/**
|
|
302
|
+
* Default cap on autopilot replies per collection attempt (per gestión) when a
|
|
303
|
+
* WHATSAPP agent does not set its own `maxReplies`. Mirrors `resend.maxRepliesDefault`.
|
|
304
|
+
*/
|
|
305
|
+
maxRepliesDefault: z.number().int().nonnegative().default(3)
|
|
335
306
|
})
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
307
|
+
.default({
|
|
308
|
+
apiBaseUrl: "https://graph.facebook.com",
|
|
309
|
+
apiVersion: "v18.0",
|
|
310
|
+
maxMessagesPerMinute: 60,
|
|
311
|
+
maxRepliesDefault: 3
|
|
341
312
|
}),
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Campaigns engine. The autonomous in-process loop that originates campaign
|
|
315
|
+
* outreach. Disabled by default so it never auto-dials in local development;
|
|
316
|
+
* enable it in production. Per-channel pacing lives in the `fonoster`/`twilio`
|
|
317
|
+
* blocks (the provider pools they configure are deployment-wide).
|
|
318
|
+
*/
|
|
319
|
+
engine: z
|
|
320
|
+
.object({
|
|
321
|
+
enabled: z.boolean().default(false),
|
|
322
|
+
/** Seconds between engine ticks. */
|
|
323
|
+
tickSeconds: z.number().int().positive().default(60)
|
|
353
324
|
})
|
|
354
|
-
|
|
325
|
+
.default({ enabled: false, tickSeconds: 60 })
|
|
355
326
|
});
|
|
356
|
-
|
|
357
|
-
export type IdentityConfig = z.infer<typeof identityConfigSchema>;
|
|
358
|
-
export type QCobroConfig = z.infer<typeof qcobroConfigSchema>;
|
|
327
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,gFAAgF;IAChF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC;IAC/C,oEAAoE;IACpE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,uBAAuB,CAAC;CAC3D,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;CAClD,CAAC,CAAC;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,MAAM,CAAC;IACN,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,C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,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,4BAA4B,CAAC;QAClE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;QACvC,+EAA+E;QAC/E,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7D;;;;WAIG;QACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;QACvC;;;WAGG;QACH,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;KAC7D,CAAC;SACD,OAAO,CAAC;QACP,UAAU,EAAE,4BAA4B;QACxC,UAAU,EAAE,OAAO;QACnB,oBAAoB,EAAE,EAAE;QACxB,iBAAiB,EAAE,CAAC;KACrB,CAAC;IACJ;;;;;OAKG;IACH,MAAM,EAAE,CAAC;SACN,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;QACnC,oCAAoC;QACpC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KACrD,CAAC;SACD,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;CAChD,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
export interface FieldError {
|
|
3
|
+
field: string;
|
|
4
|
+
message: string;
|
|
5
|
+
code: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a Zod validation error with structured, field-level details suitable
|
|
9
|
+
* for API responses.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ValidationError extends Error {
|
|
12
|
+
readonly code = "VALIDATION_ERROR";
|
|
13
|
+
readonly fieldErrors: FieldError[];
|
|
14
|
+
readonly zodError: z.ZodError;
|
|
15
|
+
constructor(zodError: z.ZodError);
|
|
16
|
+
private static extractFieldErrors;
|
|
17
|
+
private static formatMessage;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a JSON-serializable representation for API responses.
|
|
20
|
+
*/
|
|
21
|
+
toJSON(): {
|
|
22
|
+
code: string;
|
|
23
|
+
message: string;
|
|
24
|
+
fieldErrors: FieldError[];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ValidationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationError.d.ts","sourceRoot":"","sources":["../../src/errors/ValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,sBAAsB;IAC1C,SAAgB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1C,SAAgB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;gBAEzB,QAAQ,EAAE,CAAC,CAAC,QAAQ;IAehC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAQjC,OAAO,CAAC,MAAM,CAAC,aAAa;IAiB5B;;OAEG;IACH,MAAM;;;;;CAOP"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a Zod validation error with structured, field-level details suitable
|
|
3
|
+
* for API responses.
|
|
4
|
+
*/
|
|
5
|
+
export class ValidationError extends Error {
|
|
6
|
+
code = "VALIDATION_ERROR";
|
|
7
|
+
fieldErrors;
|
|
8
|
+
zodError;
|
|
9
|
+
constructor(zodError) {
|
|
10
|
+
const fieldErrors = ValidationError.extractFieldErrors(zodError);
|
|
11
|
+
const message = ValidationError.formatMessage(fieldErrors);
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "ValidationError";
|
|
14
|
+
this.zodError = zodError;
|
|
15
|
+
this.fieldErrors = fieldErrors;
|
|
16
|
+
// Maintains proper stack trace for where the error was thrown (V8 engines).
|
|
17
|
+
if (Error.captureStackTrace) {
|
|
18
|
+
Error.captureStackTrace(this, ValidationError);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
static extractFieldErrors(zodError) {
|
|
22
|
+
return zodError.issues.map((issue) => ({
|
|
23
|
+
field: issue.path.join(".") || "root",
|
|
24
|
+
message: issue.message,
|
|
25
|
+
code: issue.code
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
static formatMessage(fieldErrors) {
|
|
29
|
+
if (fieldErrors.length === 0) {
|
|
30
|
+
return "Validation failed";
|
|
31
|
+
}
|
|
32
|
+
if (fieldErrors.length === 1) {
|
|
33
|
+
const { field, message } = fieldErrors[0];
|
|
34
|
+
return field === "root" ? message : `${field}: ${message}`;
|
|
35
|
+
}
|
|
36
|
+
const details = fieldErrors
|
|
37
|
+
.map(({ field, message }) => (field === "root" ? message : `${field}: ${message}`))
|
|
38
|
+
.join("; ");
|
|
39
|
+
return `Validation failed: ${details}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns a JSON-serializable representation for API responses.
|
|
43
|
+
*/
|
|
44
|
+
toJSON() {
|
|
45
|
+
return {
|
|
46
|
+
code: this.code,
|
|
47
|
+
message: this.message,
|
|
48
|
+
fieldErrors: this.fieldErrors
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=ValidationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationError.js","sourceRoot":"","sources":["../../src/err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AAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC;QAC7D,CAAC;QAED,MAAM,OAAO,GAAG,WAAW;aACxB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC,CAAC;aAClF,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,OAAO,sBAAsB,OAAO,EAAE,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAmB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export * from "./errors/index.js";
|
|
3
|
+
export * from "./utils/index.js";
|
|
4
|
+
export * from "./schemas/index.js";
|
|
5
|
+
export * from "./types/index.js";
|
|
6
|
+
export * from "./config.js";
|
|
7
|
+
/**
|
|
8
|
+
* Placeholder contract proving the shared-schema pattern.
|
|
9
|
+
*
|
|
10
|
+
* `common` is the single source of truth for domain types and Zod schemas,
|
|
11
|
+
* imported by both the apiserver (input validation) and the webapp (forms/types).
|
|
12
|
+
* Real domain schemas (portfolios, accounts, Objectives, ...) arrive in a later
|
|
13
|
+
* change; this entry exists so the contract pattern is wired end to end.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PingInput: z.ZodObject<{
|
|
16
|
+
message: z.ZodString;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
export type PingInput = z.infer<typeof PingInput>;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAE5B;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;iBAEpB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
2
|
export * from "./errors/index.js";
|
|
4
3
|
export * from "./utils/index.js";
|
|
5
4
|
export * from "./schemas/index.js";
|
|
6
5
|
export * from "./types/index.js";
|
|
7
6
|
export * from "./config.js";
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
8
|
* Placeholder contract proving the shared-schema pattern.
|
|
11
9
|
*
|
|
@@ -15,7 +13,6 @@ export * from "./config.js";
|
|
|
15
13
|
* change; this entry exists so the contract pattern is wired end to end.
|
|
16
14
|
*/
|
|
17
15
|
export const PingInput = z.object({
|
|
18
|
-
|
|
16
|
+
message: z.string().min(1).max(280)
|
|
19
17
|
});
|
|
20
|
-
|
|
21
|
-
export type PingInput = z.infer<typeof PingInput>;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACpC,CAAC,CAAC"}
|