@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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const agentTypeSchema: z.ZodEnum<{
|
|
3
|
+
VOICE_AI: "VOICE_AI";
|
|
4
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
5
|
+
SMS: "SMS";
|
|
6
|
+
EMAIL: "EMAIL";
|
|
7
|
+
WHATSAPP: "WHATSAPP";
|
|
8
|
+
}>;
|
|
9
|
+
export type AgentType = z.infer<typeof agentTypeSchema>;
|
|
10
|
+
/**
|
|
11
|
+
* Creating an agent template is a discriminated union on `type`: each channel
|
|
12
|
+
* carries its own config fields, never mixed across types. `fonosterAppName` is
|
|
13
|
+
* optional on voice types — the create function defaults it to the template name.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createAgentTemplateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
16
|
+
type: z.ZodLiteral<"VOICE_AI">;
|
|
17
|
+
voice: z.ZodString;
|
|
18
|
+
systemPrompt: z.ZodString;
|
|
19
|
+
firstMessage: z.ZodOptional<z.ZodString>;
|
|
20
|
+
language: z.ZodString;
|
|
21
|
+
fonosterAppName: z.ZodOptional<z.ZodString>;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"VOICE_PRERECORDED">;
|
|
25
|
+
voice: z.ZodString;
|
|
26
|
+
script: z.ZodString;
|
|
27
|
+
language: z.ZodString;
|
|
28
|
+
fonosterAppName: z.ZodOptional<z.ZodString>;
|
|
29
|
+
name: z.ZodString;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<"SMS">;
|
|
32
|
+
messageBody: z.ZodString;
|
|
33
|
+
senderId: z.ZodOptional<z.ZodString>;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
36
|
+
type: z.ZodLiteral<"EMAIL">;
|
|
37
|
+
subject: z.ZodString;
|
|
38
|
+
messageBody: z.ZodString;
|
|
39
|
+
systemPrompt: z.ZodString;
|
|
40
|
+
maxReplies: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<"WHATSAPP">;
|
|
44
|
+
templateId: z.ZodString;
|
|
45
|
+
templateName: z.ZodString;
|
|
46
|
+
messageBody: z.ZodString;
|
|
47
|
+
systemPrompt: z.ZodString;
|
|
48
|
+
maxReplies: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
name: z.ZodString;
|
|
50
|
+
}, z.core.$strip>], "type">;
|
|
51
|
+
export type CreateAgentTemplateInput = z.infer<typeof createAgentTemplateSchema>;
|
|
52
|
+
/**
|
|
53
|
+
* Updating an agent template: mutable base fields plus a loose `config` bag of
|
|
54
|
+
* type-specific fields applied to the stored child table. `type` is immutable —
|
|
55
|
+
* `.strict()` rejects any attempt to pass it (or other unknown keys).
|
|
56
|
+
*/
|
|
57
|
+
export declare const updateAgentTemplateSchema: z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
archived: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
export type UpdateAgentTemplateInput = z.infer<typeof updateAgentTemplateSchema>;
|
|
64
|
+
export declare const deleteAgentTemplateSchema: z.ZodObject<{
|
|
65
|
+
id: z.ZodString;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type DeleteAgentTemplateInput = z.infer<typeof deleteAgentTemplateSchema>;
|
|
68
|
+
/** Manually re-attempt the Fonoster sync for a voice template. */
|
|
69
|
+
export declare const syncAgentTemplateSchema: z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export type SyncAgentTemplateInput = z.infer<typeof syncAgentTemplateSchema>;
|
|
73
|
+
//# sourceMappingURL=agentTemplates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentTemplates.d.ts","sourceRoot":"","sources":["../../src/schemas/agentTemplates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAMxD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAkDpC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB;;;;;kBAS3B,CAAC;AACZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEjF,eAAO,MAAM,yBAAyB;;iBAEpC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEjF,kEAAkE;AAClE,eAAO,MAAM,uBAAuB;;iBAElC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const agentTypeSchema = z.enum([
|
|
3
|
+
"SMS",
|
|
4
|
+
"VOICE_PRERECORDED",
|
|
5
|
+
"VOICE_AI",
|
|
6
|
+
"EMAIL",
|
|
7
|
+
"WHATSAPP"
|
|
8
|
+
]);
|
|
9
|
+
const baseFields = {
|
|
10
|
+
name: z.string().min(1).max(120)
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creating an agent template is a discriminated union on `type`: each channel
|
|
14
|
+
* carries its own config fields, never mixed across types. `fonosterAppName` is
|
|
15
|
+
* optional on voice types — the create function defaults it to the template name.
|
|
16
|
+
*/
|
|
17
|
+
export const createAgentTemplateSchema = z.discriminatedUnion("type", [
|
|
18
|
+
z.object({
|
|
19
|
+
...baseFields,
|
|
20
|
+
type: z.literal("VOICE_AI"),
|
|
21
|
+
voice: z.string().min(1),
|
|
22
|
+
systemPrompt: z.string().min(1),
|
|
23
|
+
// Optional: a VOICE_AI agent may rely on its system prompt with no scripted opening line.
|
|
24
|
+
firstMessage: z.string().optional(),
|
|
25
|
+
language: z.string().min(1),
|
|
26
|
+
fonosterAppName: z.string().min(1).optional()
|
|
27
|
+
}),
|
|
28
|
+
z.object({
|
|
29
|
+
...baseFields,
|
|
30
|
+
type: z.literal("VOICE_PRERECORDED"),
|
|
31
|
+
voice: z.string().min(1),
|
|
32
|
+
script: z.string().min(1),
|
|
33
|
+
language: z.string().min(1),
|
|
34
|
+
fonosterAppName: z.string().min(1).optional()
|
|
35
|
+
}),
|
|
36
|
+
z.object({
|
|
37
|
+
...baseFields,
|
|
38
|
+
type: z.literal("SMS"),
|
|
39
|
+
messageBody: z.string().min(1),
|
|
40
|
+
senderId: z.string().min(1).optional()
|
|
41
|
+
}),
|
|
42
|
+
z.object({
|
|
43
|
+
...baseFields,
|
|
44
|
+
type: z.literal("EMAIL"),
|
|
45
|
+
subject: z.string().min(1),
|
|
46
|
+
messageBody: z.string().min(1),
|
|
47
|
+
/** Autopilot decision brain: governs reply/ignore/resolve/escalate on each inbound reply. */
|
|
48
|
+
systemPrompt: z.string().min(1),
|
|
49
|
+
/** Per-agent cap on autopilot replies per collection attempt; falls back to the
|
|
50
|
+
* `resend.maxRepliesDefault` deployment default when omitted. */
|
|
51
|
+
maxReplies: z.number().int().nonnegative().optional()
|
|
52
|
+
}),
|
|
53
|
+
z.object({
|
|
54
|
+
...baseFields,
|
|
55
|
+
type: z.literal("WHATSAPP"),
|
|
56
|
+
/** Meta template id the operator enters; QCobro resolves + previews the template from the WABA. */
|
|
57
|
+
templateId: z.string().min(1),
|
|
58
|
+
/** Resolved from `templateId` (read-only in the UI); the approved Meta template name to send. */
|
|
59
|
+
templateName: z.string().min(1),
|
|
60
|
+
/** Fetched template body (read-only preview); its `{{vars}}` are sent as named parameters. */
|
|
61
|
+
messageBody: z.string().min(1),
|
|
62
|
+
/** Smart-agent decision brain for replies after the customer responds (mirrors EMAIL). */
|
|
63
|
+
systemPrompt: z.string().min(1),
|
|
64
|
+
/** Per-agent cap on automated replies per gestión; falls back to the deployment default when omitted. */
|
|
65
|
+
maxReplies: z.number().int().nonnegative().optional()
|
|
66
|
+
})
|
|
67
|
+
]);
|
|
68
|
+
/**
|
|
69
|
+
* Updating an agent template: mutable base fields plus a loose `config` bag of
|
|
70
|
+
* type-specific fields applied to the stored child table. `type` is immutable —
|
|
71
|
+
* `.strict()` rejects any attempt to pass it (or other unknown keys).
|
|
72
|
+
*/
|
|
73
|
+
export const updateAgentTemplateSchema = z
|
|
74
|
+
.object({
|
|
75
|
+
id: z.string().min(1),
|
|
76
|
+
name: z.string().min(1).max(120).optional(),
|
|
77
|
+
// `archived` toggles the template's archived state: true sets `archivedAt` to
|
|
78
|
+
// now, false clears it (restore). Templates have no status concept.
|
|
79
|
+
archived: z.boolean().optional(),
|
|
80
|
+
config: z.record(z.string(), z.unknown()).optional()
|
|
81
|
+
})
|
|
82
|
+
.strict();
|
|
83
|
+
export const deleteAgentTemplateSchema = z.object({
|
|
84
|
+
id: z.string().min(1)
|
|
85
|
+
});
|
|
86
|
+
/** Manually re-attempt the Fonoster sync for a voice template. */
|
|
87
|
+
export const syncAgentTemplateSchema = z.object({
|
|
88
|
+
id: z.string().min(1)
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=agentTemplates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentTemplates.js","sourceRoot":"","sources":["../../src/schemas/agentTemplates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC,KAAK;IACL,mBAAmB;IACnB,UAAU;IACV,OAAO;IACP,UAAU;CACX,CAAC,CAAC;AAGH,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACjC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACpE,CAAC,CAAC,MAAM,CAAC;QACP,GAAG,UAAU;QACb,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;QAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACxB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/B,0FAA0F;QAC1F,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACnC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3B,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;KAC9C,CAAC;IACF,CAAC,CAAC,MAAM,CAAC;QACP,GAAG,UAAU;QACb,IAAI,EAAE,CAAC,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C,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const apiKeyRoleEnum: z.ZodEnum<{
|
|
3
|
+
WORKSPACE_ADMIN: "WORKSPACE_ADMIN";
|
|
4
|
+
}>;
|
|
5
|
+
export type ApiKeyRole = z.infer<typeof apiKeyRoleEnum>;
|
|
6
|
+
export declare const createApiKeySchema: z.ZodObject<{
|
|
7
|
+
role: z.ZodDefault<z.ZodEnum<{
|
|
8
|
+
WORKSPACE_ADMIN: "WORKSPACE_ADMIN";
|
|
9
|
+
}>>;
|
|
10
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type CreateApiKeyInput = z.infer<typeof createApiKeySchema>;
|
|
13
|
+
export declare const apiKeyRefSchema: z.ZodObject<{
|
|
14
|
+
ref: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type ApiKeyRefInput = z.infer<typeof apiKeyRefSchema>;
|
|
17
|
+
//# sourceMappingURL=apiKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiKeys.d.ts","sourceRoot":"","sources":["../../src/schemas/apiKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,cAAc;;EAA8B,CAAC;AAC1D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAExD,eAAO,MAAM,kBAAkB;;;;;iBAU7B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAGnE,eAAO,MAAM,eAAe;;iBAE1B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
2
|
// API keys are workspace-scoped credentials for unattended, server-to-server
|
|
4
3
|
// integrations (e.g. @qcobro/sdk's loginWithApiKey). Unlike member invites,
|
|
5
4
|
// Fonoster Identity only permits WORKSPACE_ADMIN for an API key (its
|
|
6
5
|
// createApiKeyRequestSchema is `z.enum([WORKSPACE_ADMIN])`), so there is no role
|
|
7
6
|
// choice — every key is an admin-scoped key.
|
|
8
7
|
export const apiKeyRoleEnum = z.enum(["WORKSPACE_ADMIN"]);
|
|
9
|
-
export type ApiKeyRole = z.infer<typeof apiKeyRoleEnum>;
|
|
10
|
-
|
|
11
8
|
export const createApiKeySchema = z.object({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
role: apiKeyRoleEnum.default("WORKSPACE_ADMIN"),
|
|
10
|
+
// Optional expiry as epoch milliseconds; must be in the future when present.
|
|
11
|
+
// Identity stores no expiry when this is omitted (the key never expires).
|
|
12
|
+
expiresAt: z
|
|
13
|
+
.number()
|
|
14
|
+
.int()
|
|
15
|
+
.positive()
|
|
16
|
+
.refine((ms) => ms > Date.now(), { message: "expiresAt must be in the future" })
|
|
17
|
+
.optional()
|
|
21
18
|
});
|
|
22
|
-
export type CreateApiKeyInput = z.infer<typeof createApiKeySchema>;
|
|
23
|
-
|
|
24
19
|
// Identifies a single key for regenerate/delete.
|
|
25
20
|
export const apiKeyRefSchema = z.object({
|
|
26
|
-
|
|
21
|
+
ref: z.string().min(1)
|
|
27
22
|
});
|
|
28
|
-
|
|
23
|
+
//# sourceMappingURL=apiKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiKeys.js","sourceRoot":"","sources":["../../src/schemas/apiKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,6EAA6E;AAC7E,4EAA4E;AAC5E,qEAAqE;AACrE,iFAAiF;AACjF,6CAA6C;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAG1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,iBAAiB,CAAC;IAC/C,6EAA6E;IAC7E,0EAA0E;IAC1E,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC;SAC/E,QAAQ,EAAE;CACd,CAAC,CAAC;AAGH,iDAAiD;AACjD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const signUpSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
email: z.ZodEmail;
|
|
5
|
+
password: z.ZodString;
|
|
6
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
7
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type SignUpInput = z.infer<typeof signUpSchema>;
|
|
10
|
+
export declare const loginSchema: z.ZodObject<{
|
|
11
|
+
email: z.ZodEmail;
|
|
12
|
+
password: z.ZodString;
|
|
13
|
+
twoFactorCode: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type LoginInput = z.infer<typeof loginSchema>;
|
|
16
|
+
export declare const refreshTokenSchema: z.ZodObject<{
|
|
17
|
+
refreshToken: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type RefreshTokenInput = z.infer<typeof refreshTokenSchema>;
|
|
20
|
+
export declare const apiKeyLoginSchema: z.ZodObject<{
|
|
21
|
+
accessKeyId: z.ZodString;
|
|
22
|
+
accessKeySecret: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type ApiKeyLoginInput = z.infer<typeof apiKeyLoginSchema>;
|
|
25
|
+
export declare const sendResetPasswordCodeSchema: z.ZodObject<{
|
|
26
|
+
username: z.ZodEmail;
|
|
27
|
+
resetPasswordUrl: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type SendResetPasswordCodeInput = z.infer<typeof sendResetPasswordCodeSchema>;
|
|
30
|
+
export declare const resetPasswordSchema: z.ZodObject<{
|
|
31
|
+
username: z.ZodEmail;
|
|
32
|
+
password: z.ZodString;
|
|
33
|
+
verificationCode: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type ResetPasswordInput = z.infer<typeof resetPasswordSchema>;
|
|
36
|
+
export declare const contactTypeEnum: z.ZodEnum<{
|
|
37
|
+
EMAIL: "EMAIL";
|
|
38
|
+
PHONE: "PHONE";
|
|
39
|
+
}>;
|
|
40
|
+
export type ContactType = z.infer<typeof contactTypeEnum>;
|
|
41
|
+
export declare const sendVerificationCodeSchema: z.ZodObject<{
|
|
42
|
+
contactType: z.ZodEnum<{
|
|
43
|
+
EMAIL: "EMAIL";
|
|
44
|
+
PHONE: "PHONE";
|
|
45
|
+
}>;
|
|
46
|
+
value: z.ZodString;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type SendVerificationCodeInput = z.infer<typeof sendVerificationCodeSchema>;
|
|
49
|
+
export declare const verifyCodeSchema: z.ZodObject<{
|
|
50
|
+
username: z.ZodEmail;
|
|
51
|
+
contactType: z.ZodEnum<{
|
|
52
|
+
EMAIL: "EMAIL";
|
|
53
|
+
PHONE: "PHONE";
|
|
54
|
+
}>;
|
|
55
|
+
value: z.ZodString;
|
|
56
|
+
verificationCode: z.ZodString;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
export type VerifyCodeInput = z.infer<typeof verifyCodeSchema>;
|
|
59
|
+
export declare const oauthProviderEnum: z.ZodEnum<{
|
|
60
|
+
GITHUB: "GITHUB";
|
|
61
|
+
}>;
|
|
62
|
+
export type OauthProvider = z.infer<typeof oauthProviderEnum>;
|
|
63
|
+
export declare const oauthSignInSchema: z.ZodObject<{
|
|
64
|
+
provider: z.ZodEnum<{
|
|
65
|
+
GITHUB: "GITHUB";
|
|
66
|
+
}>;
|
|
67
|
+
code: z.ZodString;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export type OauthSignInInput = z.infer<typeof oauthSignInSchema>;
|
|
70
|
+
export declare const oauthSignUpSchema: z.ZodObject<{
|
|
71
|
+
code: z.ZodString;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export type OauthSignUpInput = z.infer<typeof oauthSignUpSchema>;
|
|
74
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/schemas/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,YAAY;;;;;;iBAMvB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,eAAO,MAAM,WAAW;;;;iBAItB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAErD,eAAO,MAAM,kBAAkB;;iBAE7B,CAAC;AACH,MAAM,MAAM,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
1
|
+
import { z } from "zod";
|
|
2
|
+
export const signUpSchema = z.object({
|
|
3
|
+
name: z.string().min(1).max(60),
|
|
4
|
+
email: z.email(),
|
|
5
|
+
password: z.string().min(8).max(128),
|
|
6
|
+
phone: z.string().max(20).optional(),
|
|
7
|
+
avatar: z.string().max(255).optional()
|
|
8
|
+
});
|
|
9
|
+
export const loginSchema = z.object({
|
|
10
|
+
email: z.email(),
|
|
11
|
+
password: z.string().min(1),
|
|
12
|
+
twoFactorCode: z.string().optional()
|
|
13
|
+
});
|
|
14
|
+
export const refreshTokenSchema = z.object({
|
|
15
|
+
refreshToken: z.string().min(1)
|
|
16
|
+
});
|
|
17
|
+
// Exchange a workspace API key (accessKeyId + accessKeySecret) for tokens.
|
|
18
|
+
// Used by unattended, server-to-server integrations (e.g. the SDK's
|
|
19
|
+
// loginWithApiKey) that cannot perform an interactive credentials login.
|
|
20
|
+
export const apiKeyLoginSchema = z.object({
|
|
21
|
+
accessKeyId: z.string().min(1),
|
|
22
|
+
accessKeySecret: z.string().min(1)
|
|
23
|
+
});
|
|
24
|
+
export const sendResetPasswordCodeSchema = z.object({
|
|
25
|
+
username: z.email(),
|
|
26
|
+
resetPasswordUrl: z.string().url()
|
|
27
|
+
});
|
|
28
|
+
export const resetPasswordSchema = z.object({
|
|
29
|
+
username: z.email(),
|
|
30
|
+
password: z.string().min(8).max(128),
|
|
31
|
+
verificationCode: z.string().min(1)
|
|
32
|
+
});
|
|
33
|
+
export const contactTypeEnum = z.enum(["EMAIL", "PHONE"]);
|
|
34
|
+
export const sendVerificationCodeSchema = z.object({
|
|
35
|
+
contactType: contactTypeEnum,
|
|
36
|
+
value: z.string().min(1)
|
|
37
|
+
});
|
|
38
|
+
export const verifyCodeSchema = z.object({
|
|
39
|
+
username: z.email(),
|
|
40
|
+
contactType: contactTypeEnum,
|
|
41
|
+
value: z.string().min(1),
|
|
42
|
+
verificationCode: z.string().min(1)
|
|
43
|
+
});
|
|
44
|
+
// Identity currently supports a single OAuth2 provider.
|
|
45
|
+
export const oauthProviderEnum = z.enum(["GITHUB"]);
|
|
46
|
+
export const oauthSignInSchema = z.object({
|
|
47
|
+
provider: oauthProviderEnum,
|
|
48
|
+
code: z.string().min(1)
|
|
49
|
+
});
|
|
50
|
+
export const oauthSignUpSchema = z.object({
|
|
51
|
+
code: z.string().min(1)
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/schemas/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAC/B,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE;IAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE;IAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,C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AAK,EAAE;IACnB,WAAW,EAAE,eAAe;IAC5B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACpC,CAAC,CAAC;AAGH,wDAAwD;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAGpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,iBAAiB;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const campaignStatusSchema: z.ZodEnum<{
|
|
3
|
+
PAUSED: "PAUSED";
|
|
4
|
+
ACTIVE: "ACTIVE";
|
|
5
|
+
COMPLETED: "COMPLETED";
|
|
6
|
+
ARCHIVED: "ARCHIVED";
|
|
7
|
+
}>;
|
|
8
|
+
export type CampaignStatus = z.infer<typeof campaignStatusSchema>;
|
|
9
|
+
/**
|
|
10
|
+
* Valid status transitions. A new campaign starts ACTIVE (dispatching immediately).
|
|
11
|
+
* COMPLETED is read-only. An ARCHIVED campaign can be restored to PAUSED — it never
|
|
12
|
+
* resumes dispatch without an explicit later activation. The UI offers only the
|
|
13
|
+
* transitions valid for the current status; the API enforces the same map.
|
|
14
|
+
*/
|
|
15
|
+
export declare const campaignStatusTransitions: Record<CampaignStatus, CampaignStatus[]>;
|
|
16
|
+
export declare const createCampaignSchema: z.ZodObject<{
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
agentTemplateId: z.ZodString;
|
|
19
|
+
portfolioIds: z.ZodArray<z.ZodString>;
|
|
20
|
+
whatsAppSenderNumberId: z.ZodOptional<z.ZodString>;
|
|
21
|
+
startDate: z.ZodString;
|
|
22
|
+
endDate: z.ZodOptional<z.ZodString>;
|
|
23
|
+
daysOfWeek: z.ZodArray<z.ZodNumber>;
|
|
24
|
+
startTime: z.ZodString;
|
|
25
|
+
endTime: z.ZodString;
|
|
26
|
+
maxAttemptsPerAccount: z.ZodNumber;
|
|
27
|
+
maxAttemptsPerDay: z.ZodNumber;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type CreateCampaignInput = z.infer<typeof createCampaignSchema>;
|
|
30
|
+
/**
|
|
31
|
+
* Updating a campaign: mutable configuration only. `agentTemplateId` is immutable and
|
|
32
|
+
* `status` is changed through {@link updateCampaignStatusSchema} (guarded transitions),
|
|
33
|
+
* so `.strict()` rejects either being passed here, along with any unknown keys.
|
|
34
|
+
*/
|
|
35
|
+
export declare const updateCampaignSchema: z.ZodObject<{
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
name: z.ZodOptional<z.ZodString>;
|
|
38
|
+
startDate: z.ZodOptional<z.ZodString>;
|
|
39
|
+
endDate: z.ZodOptional<z.ZodString>;
|
|
40
|
+
daysOfWeek: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
41
|
+
startTime: z.ZodOptional<z.ZodString>;
|
|
42
|
+
endTime: z.ZodOptional<z.ZodString>;
|
|
43
|
+
maxAttemptsPerAccount: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
maxAttemptsPerDay: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
export type UpdateCampaignInput = z.infer<typeof updateCampaignSchema>;
|
|
47
|
+
export declare const updateCampaignStatusSchema: z.ZodObject<{
|
|
48
|
+
id: z.ZodString;
|
|
49
|
+
status: z.ZodEnum<{
|
|
50
|
+
PAUSED: "PAUSED";
|
|
51
|
+
ACTIVE: "ACTIVE";
|
|
52
|
+
COMPLETED: "COMPLETED";
|
|
53
|
+
ARCHIVED: "ARCHIVED";
|
|
54
|
+
}>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export type UpdateCampaignStatusInput = z.infer<typeof updateCampaignStatusSchema>;
|
|
57
|
+
export declare const deleteCampaignSchema: z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export type DeleteCampaignInput = z.infer<typeof deleteCampaignSchema>;
|
|
61
|
+
//# sourceMappingURL=campaigns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaigns.d.ts","sourceRoot":"","sources":["../../src/schemas/campaigns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB;;;;;EAAwD,CAAC;AAC1F,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,cAAc,EAAE,cAAc,EAAE,CAK9E,CAAC;AAeF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;iBAwB7B,CAAC;AACL,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEvE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;kBAYtB,CAAC;AACZ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEvE,eAAO,MAAM,0BAA0B;;;;;;;;iBAGrC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEnF,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
2
|
export const campaignStatusSchema = z.enum(["PAUSED", "ACTIVE", "COMPLETED", "ARCHIVED"]);
|
|
4
|
-
export type CampaignStatus = z.infer<typeof campaignStatusSchema>;
|
|
5
|
-
|
|
6
3
|
/**
|
|
7
4
|
* Valid status transitions. A new campaign starts ACTIVE (dispatching immediately).
|
|
8
5
|
* COMPLETED is read-only. An ARCHIVED campaign can be restored to PAUSED — it never
|
|
9
6
|
* resumes dispatch without an explicit later activation. The UI offers only the
|
|
10
7
|
* transitions valid for the current status; the API enforces the same map.
|
|
11
8
|
*/
|
|
12
|
-
export const campaignStatusTransitions
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
export const campaignStatusTransitions = {
|
|
10
|
+
PAUSED: ["ACTIVE", "ARCHIVED"],
|
|
11
|
+
ACTIVE: ["PAUSED", "COMPLETED", "ARCHIVED"],
|
|
12
|
+
COMPLETED: ["ARCHIVED"],
|
|
13
|
+
ARCHIVED: ["PAUSED"]
|
|
17
14
|
};
|
|
18
|
-
|
|
19
15
|
const timeOfDay = z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "must be HH:MM 24h time");
|
|
20
|
-
|
|
21
16
|
/**
|
|
22
17
|
* Days of the week the campaign runs, as ISO weekday numbers (1 = Monday … 7 = Sunday).
|
|
23
18
|
* Any non-empty combination is allowed (e.g. Monday + Friday only).
|
|
24
19
|
*/
|
|
25
20
|
const daysOfWeek = z
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
.array(z.number().int().min(1, "weekday must be 1–7").max(7, "weekday must be 1–7"))
|
|
22
|
+
.min(1, "select at least one day")
|
|
23
|
+
.refine((days) => new Set(days).size === days.length, {
|
|
29
24
|
message: "days of week must be unique"
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
});
|
|
32
26
|
export const createCampaignSchema = z
|
|
33
|
-
|
|
27
|
+
.object({
|
|
34
28
|
name: z.string().min(1).max(120),
|
|
35
29
|
agentTemplateId: z.string().min(1),
|
|
36
30
|
portfolioIds: z.array(z.string().min(1)).min(1),
|
|
@@ -49,20 +43,18 @@ export const createCampaignSchema = z
|
|
|
49
43
|
endTime: timeOfDay,
|
|
50
44
|
maxAttemptsPerAccount: z.number().int().positive(),
|
|
51
45
|
maxAttemptsPerDay: z.number().int().positive()
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
})
|
|
47
|
+
.refine((c) => !c.endDate || new Date(c.endDate) > new Date(c.startDate), {
|
|
54
48
|
message: "endDate must be after startDate",
|
|
55
49
|
path: ["endDate"]
|
|
56
|
-
|
|
57
|
-
export type CreateCampaignInput = z.infer<typeof createCampaignSchema>;
|
|
58
|
-
|
|
50
|
+
});
|
|
59
51
|
/**
|
|
60
52
|
* Updating a campaign: mutable configuration only. `agentTemplateId` is immutable and
|
|
61
53
|
* `status` is changed through {@link updateCampaignStatusSchema} (guarded transitions),
|
|
62
54
|
* so `.strict()` rejects either being passed here, along with any unknown keys.
|
|
63
55
|
*/
|
|
64
56
|
export const updateCampaignSchema = z
|
|
65
|
-
|
|
57
|
+
.object({
|
|
66
58
|
id: z.string().min(1),
|
|
67
59
|
name: z.string().min(1).max(120).optional(),
|
|
68
60
|
startDate: z.string().min(1).optional(),
|
|
@@ -72,17 +64,13 @@ export const updateCampaignSchema = z
|
|
|
72
64
|
endTime: timeOfDay.optional(),
|
|
73
65
|
maxAttemptsPerAccount: z.number().int().positive().optional(),
|
|
74
66
|
maxAttemptsPerDay: z.number().int().positive().optional()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export type UpdateCampaignInput = z.infer<typeof updateCampaignSchema>;
|
|
78
|
-
|
|
67
|
+
})
|
|
68
|
+
.strict();
|
|
79
69
|
export const updateCampaignStatusSchema = z.object({
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
id: z.string().min(1),
|
|
71
|
+
status: campaignStatusSchema
|
|
82
72
|
});
|
|
83
|
-
export type UpdateCampaignStatusInput = z.infer<typeof updateCampaignStatusSchema>;
|
|
84
|
-
|
|
85
73
|
export const deleteCampaignSchema = z.object({
|
|
86
|
-
|
|
74
|
+
id: z.string().min(1)
|
|
87
75
|
});
|
|
88
|
-
|
|
76
|
+
//# sourceMappingURL=campaigns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaigns.js","sourceRoot":"","sources":["../../src/schemas/campaigns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;AAG1F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAA6C;IACjF,MAAM,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,MAAM,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAC;IAC3C,SAAS,EAAE,CAAC,UAAU,CAAC;IACvB,QAAQ,EAAE,CAAC,QAAQ,CAAC;CACrB,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,2BAA2B,EAAE,wBAAwB,CAAC,CAAC;AAE1F;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC;KACjB,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;KACnF,GAAG,CAAC,CAAC,EAAE,yBAAyB,CAAC;KACjC,MAAM,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