@hermeticacomms/sdk-node 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +12 -2
- package/dist/contracts/analytics.d.ts +405 -0
- package/dist/contracts/analytics.js +77 -0
- package/dist/contracts/auth.d.ts +359 -0
- package/dist/contracts/auth.js +121 -0
- package/dist/contracts/billing.d.ts +141 -0
- package/dist/contracts/billing.js +31 -0
- package/dist/contracts/campaigns.d.ts +918 -0
- package/dist/contracts/campaigns.js +269 -0
- package/dist/contracts/common.d.ts +57 -0
- package/dist/contracts/common.js +35 -0
- package/dist/contracts/connectors.d.ts +179 -0
- package/dist/contracts/connectors.js +46 -0
- package/dist/contracts/consent.d.ts +604 -0
- package/dist/contracts/consent.js +180 -0
- package/dist/contracts/content-blocks.d.ts +164 -0
- package/dist/contracts/content-blocks.js +60 -0
- package/dist/contracts/content-library.d.ts +339 -0
- package/dist/contracts/content-library.js +50 -0
- package/dist/contracts/content.d.ts +949 -0
- package/dist/contracts/content.js +192 -0
- package/dist/contracts/delivery.d.ts +599 -0
- package/dist/contracts/delivery.js +214 -0
- package/dist/contracts/events.d.ts +513 -0
- package/dist/contracts/events.js +178 -0
- package/dist/contracts/experiments.d.ts +376 -0
- package/dist/contracts/experiments.js +136 -0
- package/dist/contracts/identity.d.ts +756 -0
- package/dist/contracts/identity.js +225 -0
- package/dist/contracts/index.d.ts +15 -0
- package/dist/contracts/index.js +15 -0
- package/dist/contracts/integrations.d.ts +381 -0
- package/dist/contracts/integrations.js +112 -0
- package/dist/contracts/leads.d.ts +733 -0
- package/dist/contracts/leads.js +125 -0
- package/dist/contracts/metrics.d.ts +460 -0
- package/dist/contracts/metrics.js +90 -0
- package/dist/contracts/outbound.d.ts +15510 -0
- package/dist/contracts/outbound.js +423 -0
- package/dist/contracts/pickers.d.ts +12 -0
- package/dist/contracts/pickers.js +20 -0
- package/dist/contracts/platform-admin.d.ts +230 -0
- package/dist/contracts/platform-admin.js +91 -0
- package/dist/contracts/postcards.d.ts +79 -0
- package/dist/contracts/postcards.js +29 -0
- package/dist/contracts/push.d.ts +530 -0
- package/dist/contracts/push.js +102 -0
- package/dist/contracts/rcs.d.ts +39 -0
- package/dist/contracts/rcs.js +19 -0
- package/dist/contracts/segments.d.ts +3182 -0
- package/dist/contracts/segments.js +416 -0
- package/dist/contracts/workflow-nodes.d.ts +2118 -0
- package/dist/contracts/workflow-nodes.js +341 -0
- package/dist/contracts/workflows.d.ts +46413 -0
- package/dist/contracts/workflows.js +341 -0
- package/dist/contracts/x10-platform.d.ts +2603 -0
- package/dist/contracts/x10-platform.js +129 -0
- package/dist/http.d.ts +30 -0
- package/dist/http.js +65 -0
- package/dist/index.d.ts +11507 -0
- package/dist/index.js +63 -0
- package/dist/platform.d.ts +163 -0
- package/dist/platform.js +40 -0
- package/dist/resources.d.ts +1318 -0
- package/dist/resources.js +56 -0
- package/dist/signature.d.ts +5 -0
- package/dist/signature.js +19 -0
- package/dist/x10.d.ts +1607 -0
- package/dist/x10.js +66 -0
- package/dist/z10.d.ts +251 -0
- package/dist/z10.js +46 -0
- package/package.json +40 -4
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Id, PageQuery, Timestamp, pageResult } from './common.js';
|
|
3
|
+
import { EnrollProspectsResult, ProspectInput } from './outbound.js';
|
|
4
|
+
export const FinderKind = z.enum(['apollo', 'hunter', 'pdl', 'dropcontact', 'findymail']);
|
|
5
|
+
export const VerifierKind = z.enum(['zerobounce', 'neverbounce', 'kickbox', 'millionverifier', 'smtp']);
|
|
6
|
+
export const PhoneProviderKind = z.enum(['twilio_lookup', 'telnyx_lookup']);
|
|
7
|
+
export const LeadProviderKind = z.enum([...FinderKind.options, ...VerifierKind.options, ...PhoneProviderKind.options]);
|
|
8
|
+
export const ConnectLeadProviderBody = z.object({
|
|
9
|
+
kind: LeadProviderKind,
|
|
10
|
+
name: z.string().trim().min(1).max(100),
|
|
11
|
+
/** Not needed for the built-in `smtp` probe. */
|
|
12
|
+
apiKey: z.string().min(1).max(500).optional(),
|
|
13
|
+
priority: z.number().int().min(0).max(1000).default(100),
|
|
14
|
+
creditLimit: z.number().int().min(0).nullish(),
|
|
15
|
+
});
|
|
16
|
+
export const LeadProviderDto = z.object({
|
|
17
|
+
id: Id, kind: LeadProviderKind, role: z.enum(['finder', 'verifier', 'phone']), name: z.string(), priority: z.number().int(), enabled: z.boolean(),
|
|
18
|
+
creditsUsed: z.number().int(), creditLimit: z.number().int().nullable(), createdAt: Timestamp,
|
|
19
|
+
keyVerified: z.boolean().nullable().describe('true: the provider accepted the key at the last check (on connect or POST /v1/leads/providers/{id}/test). false: rejected, or not checked yet (keyCheckedAt null). null: no key (smtp)'),
|
|
20
|
+
keyCheckedAt: Timestamp.nullable().optional(), keyError: z.string().nullable().optional(),
|
|
21
|
+
});
|
|
22
|
+
export const UpdateLeadProviderBody = z.object({ enabled: z.boolean().optional(), priority: z.number().int().min(0).max(1000).optional(), creditLimit: z.number().int().min(0).nullable().optional() });
|
|
23
|
+
export const LeadCriteria = z.object({
|
|
24
|
+
titles: z.array(z.string().max(100)).max(20).default([]),
|
|
25
|
+
seniorities: z.array(z.string().max(50)).max(10).default([]),
|
|
26
|
+
industries: z.array(z.string().max(100)).max(20).default([]),
|
|
27
|
+
companySizes: z.array(z.string().max(30)).max(10).default([]),
|
|
28
|
+
locations: z.array(z.string().max(100)).max(20).default([]),
|
|
29
|
+
technologies: z.array(z.string().max(100)).max(20).default([]),
|
|
30
|
+
domains: z.array(z.string().max(253)).max(50).default([]),
|
|
31
|
+
});
|
|
32
|
+
export const LeadSearchBody = z.object({ providerId: Id, criteria: LeadCriteria, limit: z.number().int().min(1).max(100).default(25) });
|
|
33
|
+
export const SaveSearchBody = z.object({ name: z.string().trim().min(1).max(200), providerId: Id, criteria: LeadCriteria });
|
|
34
|
+
export const LeadSearchSchedule = z.enum(['daily', 'weekly']);
|
|
35
|
+
export const SavedSearchDto = z.object({
|
|
36
|
+
id: Id, name: z.string(), providerId: Id, criteria: LeadCriteria, createdAt: Timestamp,
|
|
37
|
+
runEvery: LeadSearchSchedule.nullable(), autoEnrich: z.boolean(), maxResults: z.number().int(),
|
|
38
|
+
lastRunAt: Timestamp.nullable(), lastRunCount: z.number().int().nullable(), lastError: z.string().nullable(),
|
|
39
|
+
});
|
|
40
|
+
export const LeadStatus = z.enum(['preview', 'revealed', 'pushed']);
|
|
41
|
+
export const EmailStatus = z.enum(['valid', 'invalid', 'risky', 'catch_all', 'unknown', 'disposable']);
|
|
42
|
+
export const LeadDto = z.object({
|
|
43
|
+
id: Id, providerKind: z.string(), firstName: z.string().nullable(), lastName: z.string().nullable(), title: z.string().nullable(), company: z.string().nullable(),
|
|
44
|
+
domain: z.string().nullable(), email: z.string().nullable(), phone: z.string().nullable(), linkedinUrl: z.string().nullable(), country: z.string().nullable(),
|
|
45
|
+
hasEmail: z.boolean(), emailStatus: EmailStatus.nullable(), status: LeadStatus, profileId: Id.nullable(),
|
|
46
|
+
provenance: z.record(z.string(), z.object({ provider: z.string(), confidence: z.number().nullable(), at: z.string() })),
|
|
47
|
+
createdAt: Timestamp,
|
|
48
|
+
});
|
|
49
|
+
export const LeadListQuery = PageQuery.extend({ status: LeadStatus.optional() });
|
|
50
|
+
export const LeadPage = pageResult(LeadDto);
|
|
51
|
+
export const LeadSearchResult = z.object({ items: z.array(LeadDto), cached: z.boolean() });
|
|
52
|
+
export const LeadIdsBody = z.object({ leadIds: z.array(Id).min(1).max(100) });
|
|
53
|
+
export const RevealResult = z.object({ items: z.array(LeadDto), creditsSpent: z.number().int(), errors: z.array(z.object({ leadId: Id, error: z.string() })) });
|
|
54
|
+
export const VerifyPolicy = z.object({
|
|
55
|
+
skipInvalid: z.boolean().default(true),
|
|
56
|
+
skipRisky: z.boolean().default(true),
|
|
57
|
+
skipCatchAll: z.boolean().default(true),
|
|
58
|
+
skipUnknown: z.boolean().default(false),
|
|
59
|
+
skipRole: z.boolean().default(false),
|
|
60
|
+
});
|
|
61
|
+
export const DEFAULT_VERIFY_POLICY = VerifyPolicy.parse({});
|
|
62
|
+
export const PushBody = z.object({
|
|
63
|
+
leadIds: z.array(Id).min(1).max(100),
|
|
64
|
+
sequenceId: Id.optional(),
|
|
65
|
+
policy: VerifyPolicy.default(DEFAULT_VERIFY_POLICY),
|
|
66
|
+
});
|
|
67
|
+
export const CsvLeadImportBody = z.object({
|
|
68
|
+
rows: z.array(ProspectInput).min(1).max(5000),
|
|
69
|
+
sequenceId: Id.optional(),
|
|
70
|
+
policy: VerifyPolicy.default(DEFAULT_VERIFY_POLICY),
|
|
71
|
+
});
|
|
72
|
+
export const PushResult = z.object({
|
|
73
|
+
imported: z.number().int(),
|
|
74
|
+
skipped: z.array(z.object({ ref: z.string(), reason: z.string() })),
|
|
75
|
+
enroll: EnrollProspectsResult.nullable(),
|
|
76
|
+
});
|
|
77
|
+
export const VerificationDto = z.object({
|
|
78
|
+
email: z.string(), status: EmailStatus, risk: z.number().int(), flags: z.array(z.string()), provider: z.string(), checkedAt: Timestamp,
|
|
79
|
+
});
|
|
80
|
+
export const VerifyBody = z.object({ email: z.string().max(320), force: z.boolean().default(false) });
|
|
81
|
+
export const LeadJobKind = z.enum(['clean', 'enrich']);
|
|
82
|
+
export const StartCleanBody = z.object({ emails: z.array(z.string().max(320)).min(1).max(10_000), maxBounceRate: z.number().min(0).max(1).default(0.05) });
|
|
83
|
+
export const StartEnrichBody = z.object({ leadIds: z.array(Id).min(1).max(500), waterfallId: Id.optional() });
|
|
84
|
+
export const CleanReportRow = z.object({ email: z.string(), status: EmailStatus, risk: z.number().int(), flags: z.array(z.string()) });
|
|
85
|
+
export const LeadJobDto = z.object({
|
|
86
|
+
id: Id, kind: LeadJobKind, status: z.enum(['queued', 'running', 'done', 'failed']), total: z.number().int(), processed: z.number().int(),
|
|
87
|
+
summary: z.record(z.string(), z.unknown()), error: z.string().nullable(), createdAt: Timestamp,
|
|
88
|
+
});
|
|
89
|
+
export const LeadJobReport = LeadJobDto.extend({ rows: z.array(CleanReportRow) });
|
|
90
|
+
export const LeadJobPage = pageResult(LeadJobDto);
|
|
91
|
+
export const CreditsDto = z.object({ providers: z.array(z.object({ id: Id, name: z.string(), kind: LeadProviderKind, used: z.number().int(), limit: z.number().int().nullable() })), totalUsed: z.number().int() });
|
|
92
|
+
export const DisposableBody = z.object({ domains: z.array(z.string().max(253)).min(1).max(100_000) });
|
|
93
|
+
export const DisposableResult = z.object({ added: z.number().int() });
|
|
94
|
+
// ---- companies (accounts) and phone line type
|
|
95
|
+
export const CompanyDto = z.object({
|
|
96
|
+
id: Id, domain: z.string(), name: z.string(), industry: z.string().nullable(), sizeBand: z.string().nullable(), country: z.string().nullable(),
|
|
97
|
+
suppressed: z.boolean(), suppressionReason: z.string().nullable(), leadCount: z.number().int(), contactCount: z.number().int(), createdAt: Timestamp,
|
|
98
|
+
stage: z.string().optional(), ownerUserId: Id.nullable().optional(),
|
|
99
|
+
customFields: z.record(z.string(), z.unknown()).optional(), score: z.number().int().optional(),
|
|
100
|
+
});
|
|
101
|
+
export const CompanyListQuery = PageQuery.extend({ q: z.string().max(100).optional(), suppressed: z.coerce.boolean().optional() });
|
|
102
|
+
export const CompanyPage = pageResult(CompanyDto);
|
|
103
|
+
export const CompanyLinkFields = z.object({ isPrimary: z.boolean(), jobTitle: z.string().nullable(), role: z.string().nullable() });
|
|
104
|
+
/** Every company the contact is linked to, primary first; `link` carries the link fields. */
|
|
105
|
+
export const M3ProfileCompanies = z.object({ items: z.array(CompanyDto.extend({ link: CompanyLinkFields.optional() })) });
|
|
106
|
+
export const CompanyDetail = CompanyDto.extend({ leads: z.array(LeadDto), profileIds: z.array(Id), contacts: z.array(CompanyLinkFields.extend({ profileId: Id })).optional() });
|
|
107
|
+
export const CreateCompanyBody = z.object({
|
|
108
|
+
domain: z.string().trim().min(3).max(253), name: z.string().trim().min(1).max(200).optional(), industry: z.string().max(100).optional(),
|
|
109
|
+
sizeBand: z.string().max(30).optional(), country: z.string().length(2).optional(),
|
|
110
|
+
/** Values for the workspace's company fields (`GET /v1/leads/company-fields`); validated against that registry. */
|
|
111
|
+
customFields: z.record(z.string().max(64), z.unknown()).optional(),
|
|
112
|
+
});
|
|
113
|
+
export const ImportCompaniesBody = z.object({ rows: z.array(CreateCompanyBody).min(1).max(1000) });
|
|
114
|
+
export const ImportCompaniesResult = z.object({ imported: z.number().int(), skipped: z.array(z.object({ row: z.number().int(), domain: z.string(), reason: z.string() })) });
|
|
115
|
+
export const UpdateCompanyBody = CreateCompanyBody.omit({ domain: true }).partial();
|
|
116
|
+
export const SuppressCompanyBody = z.object({ reason: z.string().trim().max(200).optional() });
|
|
117
|
+
export const LinkCompanyBody = z.object({
|
|
118
|
+
profileId: Id,
|
|
119
|
+
/** true: make this the contact's primary company; false: an extra link; omitted: primary only if the contact has none. */
|
|
120
|
+
primary: z.boolean().optional(),
|
|
121
|
+
jobTitle: z.string().trim().max(200).nullish(), role: z.string().trim().max(100).nullish(),
|
|
122
|
+
});
|
|
123
|
+
export const LineType = z.enum(['mobile', 'landline', 'voip', 'toll_free', 'other', 'unknown']);
|
|
124
|
+
export const PhoneLookupBody = z.object({ phone: z.string().max(40), country: z.string().length(2).optional(), force: z.boolean().default(false) });
|
|
125
|
+
export const PhoneLookupDto = z.object({ phone: z.string(), lineType: LineType, carrier: z.string().nullable(), landline: z.boolean(), provider: z.string(), checkedAt: Timestamp });
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CONDITION_OPS: readonly ['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'contains', 'not_contains', 'starts_with', 'ends_with', 'exists', 'not_exists', 'in', 'not_in', 'between'];
|
|
3
|
+
export declare const PropertyCondition: z.ZodObject<{
|
|
4
|
+
property: z.ZodString;
|
|
5
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
6
|
+
between: "between";
|
|
7
|
+
contains: "contains";
|
|
8
|
+
ends_with: "ends_with";
|
|
9
|
+
eq: "eq";
|
|
10
|
+
exists: "exists";
|
|
11
|
+
gt: "gt";
|
|
12
|
+
gte: "gte";
|
|
13
|
+
in: "in";
|
|
14
|
+
lt: "lt";
|
|
15
|
+
lte: "lte";
|
|
16
|
+
neq: "neq";
|
|
17
|
+
not_contains: "not_contains";
|
|
18
|
+
not_exists: "not_exists";
|
|
19
|
+
not_in: "not_in";
|
|
20
|
+
starts_with: "starts_with";
|
|
21
|
+
}>>;
|
|
22
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type PropertyCondition = z.infer<typeof PropertyCondition>;
|
|
25
|
+
export declare const EventExplorerQuery: z.ZodObject<{
|
|
26
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
27
|
+
cursor: z.ZodOptional<z.ZodUUID>;
|
|
28
|
+
name: z.ZodOptional<z.ZodString>;
|
|
29
|
+
profileId: z.ZodOptional<z.ZodUUID>;
|
|
30
|
+
from: z.ZodOptional<z.ZodISODateTime>;
|
|
31
|
+
to: z.ZodOptional<z.ZodISODateTime>;
|
|
32
|
+
filter: z.ZodOptional<z.ZodString>;
|
|
33
|
+
sort: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
"-datetime": "-datetime";
|
|
35
|
+
datetime: "datetime";
|
|
36
|
+
}>>;
|
|
37
|
+
include: z.ZodOptional<z.ZodString>;
|
|
38
|
+
journeyId: z.ZodOptional<z.ZodUUID>;
|
|
39
|
+
broadcastId: z.ZodOptional<z.ZodUUID>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
export declare const EventExplorerPage: z.ZodObject<{
|
|
42
|
+
items: z.ZodArray<z.ZodObject<{
|
|
43
|
+
id: z.ZodUUID;
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
profileId: z.ZodNullable<z.ZodUUID>;
|
|
46
|
+
anonymousId: z.ZodNullable<z.ZodString>;
|
|
47
|
+
occurredAt: z.ZodISODateTime;
|
|
48
|
+
source: z.ZodEnum<{
|
|
49
|
+
browser: "browser";
|
|
50
|
+
integration: "integration";
|
|
51
|
+
server: "server";
|
|
52
|
+
system: "system";
|
|
53
|
+
}>;
|
|
54
|
+
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
55
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
56
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
57
|
+
metric: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
category: z.ZodString;
|
|
60
|
+
goal: z.ZodBoolean;
|
|
61
|
+
}, z.core.$strip>>>;
|
|
62
|
+
profile: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
63
|
+
id: z.ZodUUID;
|
|
64
|
+
email: z.ZodNullable<z.ZodString>;
|
|
65
|
+
firstName: z.ZodNullable<z.ZodString>;
|
|
66
|
+
lastName: z.ZodNullable<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>>>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
nextCursor: z.ZodNullable<z.ZodUUID>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
/** Matching events as CSV text (first 50,000). */
|
|
72
|
+
export declare const EventExportResult: z.ZodObject<{
|
|
73
|
+
filename: z.ZodString;
|
|
74
|
+
csv: z.ZodString;
|
|
75
|
+
count: z.ZodNumber;
|
|
76
|
+
truncated: z.ZodBoolean;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
export declare const MetricSummary: z.ZodObject<{
|
|
79
|
+
name: z.ZodString;
|
|
80
|
+
kind: z.ZodEnum<{
|
|
81
|
+
custom: "custom";
|
|
82
|
+
event: "event";
|
|
83
|
+
}>;
|
|
84
|
+
customMetricId: z.ZodNullable<z.ZodUUID>;
|
|
85
|
+
category: z.ZodEnum<{
|
|
86
|
+
custom: "custom";
|
|
87
|
+
standard: "standard";
|
|
88
|
+
}>;
|
|
89
|
+
goal: z.ZodBoolean;
|
|
90
|
+
eventCount: z.ZodNumber;
|
|
91
|
+
lastEventAt: z.ZodNullable<z.ZodISODateTime>;
|
|
92
|
+
firstSeenAt: z.ZodNullable<z.ZodISODateTime>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
export declare const MetricList: z.ZodObject<{
|
|
95
|
+
items: z.ZodArray<z.ZodObject<{
|
|
96
|
+
name: z.ZodString;
|
|
97
|
+
kind: z.ZodEnum<{
|
|
98
|
+
custom: "custom";
|
|
99
|
+
event: "event";
|
|
100
|
+
}>;
|
|
101
|
+
customMetricId: z.ZodNullable<z.ZodUUID>;
|
|
102
|
+
category: z.ZodEnum<{
|
|
103
|
+
custom: "custom";
|
|
104
|
+
standard: "standard";
|
|
105
|
+
}>;
|
|
106
|
+
goal: z.ZodBoolean;
|
|
107
|
+
eventCount: z.ZodNumber;
|
|
108
|
+
lastEventAt: z.ZodNullable<z.ZodISODateTime>;
|
|
109
|
+
firstSeenAt: z.ZodNullable<z.ZodISODateTime>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
export declare const ObservedProperty: z.ZodObject<{
|
|
113
|
+
key: z.ZodString;
|
|
114
|
+
types: z.ZodArray<z.ZodString>;
|
|
115
|
+
seen: z.ZodNumber;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export declare const MetricDetail: z.ZodObject<{
|
|
118
|
+
name: z.ZodString;
|
|
119
|
+
kind: z.ZodEnum<{
|
|
120
|
+
custom: "custom";
|
|
121
|
+
event: "event";
|
|
122
|
+
}>;
|
|
123
|
+
customMetricId: z.ZodNullable<z.ZodUUID>;
|
|
124
|
+
category: z.ZodEnum<{
|
|
125
|
+
custom: "custom";
|
|
126
|
+
standard: "standard";
|
|
127
|
+
}>;
|
|
128
|
+
goal: z.ZodBoolean;
|
|
129
|
+
eventCount: z.ZodNumber;
|
|
130
|
+
lastEventAt: z.ZodNullable<z.ZodISODateTime>;
|
|
131
|
+
firstSeenAt: z.ZodNullable<z.ZodISODateTime>;
|
|
132
|
+
schema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
133
|
+
properties: z.ZodArray<z.ZodObject<{
|
|
134
|
+
key: z.ZodString;
|
|
135
|
+
types: z.ZodArray<z.ZodString>;
|
|
136
|
+
seen: z.ZodNumber;
|
|
137
|
+
}, z.core.$strip>>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
export declare const MetricParams: z.ZodObject<{
|
|
140
|
+
name: z.ZodString;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
export declare const AGGREGATE_MEASUREMENTS: readonly ['count', 'unique', 'sum_value', 'avg_value', 'sum_property', 'avg_property'];
|
|
143
|
+
export declare const INTERVALS: readonly ['hour', 'day', 'week', 'month'];
|
|
144
|
+
export declare const MetricAggregateQuery: z.ZodObject<{
|
|
145
|
+
metric: z.ZodString;
|
|
146
|
+
measurement: z.ZodDefault<z.ZodEnum<{
|
|
147
|
+
avg_property: "avg_property";
|
|
148
|
+
avg_value: "avg_value";
|
|
149
|
+
count: "count";
|
|
150
|
+
sum_property: "sum_property";
|
|
151
|
+
sum_value: "sum_value";
|
|
152
|
+
unique: "unique";
|
|
153
|
+
}>>;
|
|
154
|
+
measurementProperty: z.ZodOptional<z.ZodString>;
|
|
155
|
+
interval: z.ZodDefault<z.ZodEnum<{
|
|
156
|
+
day: "day";
|
|
157
|
+
hour: "hour";
|
|
158
|
+
month: "month";
|
|
159
|
+
week: "week";
|
|
160
|
+
}>>;
|
|
161
|
+
by: z.ZodOptional<z.ZodString>;
|
|
162
|
+
from: z.ZodCodec<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodString]>, z.ZodISODateTime>;
|
|
163
|
+
to: z.ZodCodec<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodString]>, z.ZodISODateTime>;
|
|
164
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
165
|
+
filter: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
166
|
+
property: z.ZodString;
|
|
167
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
168
|
+
between: "between";
|
|
169
|
+
contains: "contains";
|
|
170
|
+
ends_with: "ends_with";
|
|
171
|
+
eq: "eq";
|
|
172
|
+
exists: "exists";
|
|
173
|
+
gt: "gt";
|
|
174
|
+
gte: "gte";
|
|
175
|
+
in: "in";
|
|
176
|
+
lt: "lt";
|
|
177
|
+
lte: "lte";
|
|
178
|
+
neq: "neq";
|
|
179
|
+
not_contains: "not_contains";
|
|
180
|
+
not_exists: "not_exists";
|
|
181
|
+
not_in: "not_in";
|
|
182
|
+
starts_with: "starts_with";
|
|
183
|
+
}>>;
|
|
184
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
185
|
+
}, z.core.$strip>>>;
|
|
186
|
+
topN: z.ZodDefault<z.ZodNumber>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
export type MetricAggregateQuery = z.input<typeof MetricAggregateQuery>;
|
|
189
|
+
export declare const MetricAggregateResult: z.ZodObject<{
|
|
190
|
+
metric: z.ZodString;
|
|
191
|
+
measurement: z.ZodString;
|
|
192
|
+
interval: z.ZodString;
|
|
193
|
+
timezone: z.ZodString;
|
|
194
|
+
by: z.ZodNullable<z.ZodString>;
|
|
195
|
+
buckets: z.ZodArray<z.ZodString>;
|
|
196
|
+
series: z.ZodArray<z.ZodObject<{
|
|
197
|
+
key: z.ZodString;
|
|
198
|
+
values: z.ZodArray<z.ZodNumber>;
|
|
199
|
+
total: z.ZodNumber;
|
|
200
|
+
}, z.core.$strip>>;
|
|
201
|
+
total: z.ZodNumber;
|
|
202
|
+
}, z.core.$strip>;
|
|
203
|
+
export declare const MetricSource: z.ZodObject<{
|
|
204
|
+
event: z.ZodString;
|
|
205
|
+
conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
206
|
+
property: z.ZodString;
|
|
207
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
208
|
+
between: "between";
|
|
209
|
+
contains: "contains";
|
|
210
|
+
ends_with: "ends_with";
|
|
211
|
+
eq: "eq";
|
|
212
|
+
exists: "exists";
|
|
213
|
+
gt: "gt";
|
|
214
|
+
gte: "gte";
|
|
215
|
+
in: "in";
|
|
216
|
+
lt: "lt";
|
|
217
|
+
lte: "lte";
|
|
218
|
+
neq: "neq";
|
|
219
|
+
not_contains: "not_contains";
|
|
220
|
+
not_exists: "not_exists";
|
|
221
|
+
not_in: "not_in";
|
|
222
|
+
starts_with: "starts_with";
|
|
223
|
+
}>>;
|
|
224
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
225
|
+
}, z.core.$strip>>>;
|
|
226
|
+
}, z.core.$strip>;
|
|
227
|
+
export declare const CustomMetricDefinition: z.ZodObject<{
|
|
228
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
229
|
+
event: z.ZodString;
|
|
230
|
+
conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
231
|
+
property: z.ZodString;
|
|
232
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
233
|
+
between: "between";
|
|
234
|
+
contains: "contains";
|
|
235
|
+
ends_with: "ends_with";
|
|
236
|
+
eq: "eq";
|
|
237
|
+
exists: "exists";
|
|
238
|
+
gt: "gt";
|
|
239
|
+
gte: "gte";
|
|
240
|
+
in: "in";
|
|
241
|
+
lt: "lt";
|
|
242
|
+
lte: "lte";
|
|
243
|
+
neq: "neq";
|
|
244
|
+
not_contains: "not_contains";
|
|
245
|
+
not_exists: "not_exists";
|
|
246
|
+
not_in: "not_in";
|
|
247
|
+
starts_with: "starts_with";
|
|
248
|
+
}>>;
|
|
249
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
250
|
+
}, z.core.$strip>>>;
|
|
251
|
+
}, z.core.$strip>>;
|
|
252
|
+
valueProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
253
|
+
}, z.core.$strip>;
|
|
254
|
+
export declare const CreateCustomMetricBody: z.ZodObject<{
|
|
255
|
+
name: z.ZodString;
|
|
256
|
+
description: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
257
|
+
definition: z.ZodObject<{
|
|
258
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
259
|
+
event: z.ZodString;
|
|
260
|
+
conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
261
|
+
property: z.ZodString;
|
|
262
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
263
|
+
between: "between";
|
|
264
|
+
contains: "contains";
|
|
265
|
+
ends_with: "ends_with";
|
|
266
|
+
eq: "eq";
|
|
267
|
+
exists: "exists";
|
|
268
|
+
gt: "gt";
|
|
269
|
+
gte: "gte";
|
|
270
|
+
in: "in";
|
|
271
|
+
lt: "lt";
|
|
272
|
+
lte: "lte";
|
|
273
|
+
neq: "neq";
|
|
274
|
+
not_contains: "not_contains";
|
|
275
|
+
not_exists: "not_exists";
|
|
276
|
+
not_in: "not_in";
|
|
277
|
+
starts_with: "starts_with";
|
|
278
|
+
}>>;
|
|
279
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
280
|
+
}, z.core.$strip>>>;
|
|
281
|
+
}, z.core.$strip>>;
|
|
282
|
+
valueProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
283
|
+
}, z.core.$strip>;
|
|
284
|
+
}, z.core.$strip>;
|
|
285
|
+
export declare const UpdateCustomMetricBody: z.ZodObject<{
|
|
286
|
+
name: z.ZodOptional<z.ZodString>;
|
|
287
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
288
|
+
definition: z.ZodOptional<z.ZodObject<{
|
|
289
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
290
|
+
event: z.ZodString;
|
|
291
|
+
conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
292
|
+
property: z.ZodString;
|
|
293
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
294
|
+
between: "between";
|
|
295
|
+
contains: "contains";
|
|
296
|
+
ends_with: "ends_with";
|
|
297
|
+
eq: "eq";
|
|
298
|
+
exists: "exists";
|
|
299
|
+
gt: "gt";
|
|
300
|
+
gte: "gte";
|
|
301
|
+
in: "in";
|
|
302
|
+
lt: "lt";
|
|
303
|
+
lte: "lte";
|
|
304
|
+
neq: "neq";
|
|
305
|
+
not_contains: "not_contains";
|
|
306
|
+
not_exists: "not_exists";
|
|
307
|
+
not_in: "not_in";
|
|
308
|
+
starts_with: "starts_with";
|
|
309
|
+
}>>;
|
|
310
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
311
|
+
}, z.core.$strip>>>;
|
|
312
|
+
}, z.core.$strip>>;
|
|
313
|
+
valueProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
314
|
+
}, z.core.$strip>>;
|
|
315
|
+
}, z.core.$strip>;
|
|
316
|
+
export declare const CustomMetricDto: z.ZodObject<{
|
|
317
|
+
id: z.ZodUUID;
|
|
318
|
+
name: z.ZodString;
|
|
319
|
+
description: z.ZodNullable<z.ZodString>;
|
|
320
|
+
definition: z.ZodObject<{
|
|
321
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
322
|
+
event: z.ZodString;
|
|
323
|
+
conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
324
|
+
property: z.ZodString;
|
|
325
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
326
|
+
between: "between";
|
|
327
|
+
contains: "contains";
|
|
328
|
+
ends_with: "ends_with";
|
|
329
|
+
eq: "eq";
|
|
330
|
+
exists: "exists";
|
|
331
|
+
gt: "gt";
|
|
332
|
+
gte: "gte";
|
|
333
|
+
in: "in";
|
|
334
|
+
lt: "lt";
|
|
335
|
+
lte: "lte";
|
|
336
|
+
neq: "neq";
|
|
337
|
+
not_contains: "not_contains";
|
|
338
|
+
not_exists: "not_exists";
|
|
339
|
+
not_in: "not_in";
|
|
340
|
+
starts_with: "starts_with";
|
|
341
|
+
}>>;
|
|
342
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
343
|
+
}, z.core.$strip>>>;
|
|
344
|
+
}, z.core.$strip>>;
|
|
345
|
+
valueProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
346
|
+
}, z.core.$strip>;
|
|
347
|
+
createdAt: z.ZodISODateTime;
|
|
348
|
+
updatedAt: z.ZodISODateTime;
|
|
349
|
+
}, z.core.$strip>;
|
|
350
|
+
export declare const CustomMetricList: z.ZodObject<{
|
|
351
|
+
items: z.ZodArray<z.ZodObject<{
|
|
352
|
+
id: z.ZodUUID;
|
|
353
|
+
name: z.ZodString;
|
|
354
|
+
description: z.ZodNullable<z.ZodString>;
|
|
355
|
+
definition: z.ZodObject<{
|
|
356
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
357
|
+
event: z.ZodString;
|
|
358
|
+
conditions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
359
|
+
property: z.ZodString;
|
|
360
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
361
|
+
between: "between";
|
|
362
|
+
contains: "contains";
|
|
363
|
+
ends_with: "ends_with";
|
|
364
|
+
eq: "eq";
|
|
365
|
+
exists: "exists";
|
|
366
|
+
gt: "gt";
|
|
367
|
+
gte: "gte";
|
|
368
|
+
in: "in";
|
|
369
|
+
lt: "lt";
|
|
370
|
+
lte: "lte";
|
|
371
|
+
neq: "neq";
|
|
372
|
+
not_contains: "not_contains";
|
|
373
|
+
not_exists: "not_exists";
|
|
374
|
+
not_in: "not_in";
|
|
375
|
+
starts_with: "starts_with";
|
|
376
|
+
}>>;
|
|
377
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
378
|
+
}, z.core.$strip>>>;
|
|
379
|
+
}, z.core.$strip>>;
|
|
380
|
+
valueProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
381
|
+
}, z.core.$strip>;
|
|
382
|
+
createdAt: z.ZodISODateTime;
|
|
383
|
+
updatedAt: z.ZodISODateTime;
|
|
384
|
+
}, z.core.$strip>>;
|
|
385
|
+
}, z.core.$strip>;
|
|
386
|
+
export declare const MAPPED_ROLES: readonly ['placed_order', 'viewed_product', 'started_checkout', 'added_to_cart', 'submitted_form'];
|
|
387
|
+
export declare const MappedMetricRole: z.ZodEnum<{
|
|
388
|
+
added_to_cart: "added_to_cart";
|
|
389
|
+
placed_order: "placed_order";
|
|
390
|
+
started_checkout: "started_checkout";
|
|
391
|
+
submitted_form: "submitted_form";
|
|
392
|
+
viewed_product: "viewed_product";
|
|
393
|
+
}>;
|
|
394
|
+
export declare const MappedMetricDto: z.ZodObject<{
|
|
395
|
+
role: z.ZodEnum<{
|
|
396
|
+
added_to_cart: "added_to_cart";
|
|
397
|
+
placed_order: "placed_order";
|
|
398
|
+
started_checkout: "started_checkout";
|
|
399
|
+
submitted_form: "submitted_form";
|
|
400
|
+
viewed_product: "viewed_product";
|
|
401
|
+
}>;
|
|
402
|
+
metricName: z.ZodString;
|
|
403
|
+
configured: z.ZodBoolean;
|
|
404
|
+
}, z.core.$strip>;
|
|
405
|
+
export declare const MappedMetricList: z.ZodObject<{
|
|
406
|
+
items: z.ZodArray<z.ZodObject<{
|
|
407
|
+
role: z.ZodEnum<{
|
|
408
|
+
added_to_cart: "added_to_cart";
|
|
409
|
+
placed_order: "placed_order";
|
|
410
|
+
started_checkout: "started_checkout";
|
|
411
|
+
submitted_form: "submitted_form";
|
|
412
|
+
viewed_product: "viewed_product";
|
|
413
|
+
}>;
|
|
414
|
+
metricName: z.ZodString;
|
|
415
|
+
configured: z.ZodBoolean;
|
|
416
|
+
}, z.core.$strip>>;
|
|
417
|
+
}, z.core.$strip>;
|
|
418
|
+
export declare const SetMappedMetricBody: z.ZodObject<{
|
|
419
|
+
metricName: z.ZodString;
|
|
420
|
+
}, z.core.$strip>;
|
|
421
|
+
export declare const UsedByItem: z.ZodObject<{
|
|
422
|
+
kind: z.ZodEnum<{
|
|
423
|
+
campaign: "campaign";
|
|
424
|
+
custom_metric: "custom_metric";
|
|
425
|
+
form: "form";
|
|
426
|
+
segment: "segment";
|
|
427
|
+
sender_pool: "sender_pool";
|
|
428
|
+
workflow: "workflow";
|
|
429
|
+
}>;
|
|
430
|
+
id: z.ZodUUID;
|
|
431
|
+
name: z.ZodString;
|
|
432
|
+
status: z.ZodNullable<z.ZodString>;
|
|
433
|
+
via: z.ZodString;
|
|
434
|
+
}, z.core.$strip>;
|
|
435
|
+
export declare const UsedByResult: z.ZodObject<{
|
|
436
|
+
items: z.ZodArray<z.ZodObject<{
|
|
437
|
+
kind: z.ZodEnum<{
|
|
438
|
+
campaign: "campaign";
|
|
439
|
+
custom_metric: "custom_metric";
|
|
440
|
+
form: "form";
|
|
441
|
+
segment: "segment";
|
|
442
|
+
sender_pool: "sender_pool";
|
|
443
|
+
workflow: "workflow";
|
|
444
|
+
}>;
|
|
445
|
+
id: z.ZodUUID;
|
|
446
|
+
name: z.ZodString;
|
|
447
|
+
status: z.ZodNullable<z.ZodString>;
|
|
448
|
+
via: z.ZodString;
|
|
449
|
+
}, z.core.$strip>>;
|
|
450
|
+
}, z.core.$strip>;
|
|
451
|
+
export declare const UsedByParams: z.ZodObject<{
|
|
452
|
+
kind: z.ZodEnum<{
|
|
453
|
+
list: "list";
|
|
454
|
+
metric: "metric";
|
|
455
|
+
segment: "segment";
|
|
456
|
+
sender: "sender";
|
|
457
|
+
template: "template";
|
|
458
|
+
}>;
|
|
459
|
+
id: z.ZodString;
|
|
460
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Id, PageQuery, Timestamp, TimestampIn, pageResult } from './common.js';
|
|
3
|
+
import { EventRecord } from './events.js';
|
|
4
|
+
// ---- property conditions (shared by filters and custom metrics) --------------------------------------------------------
|
|
5
|
+
export const CONDITION_OPS = ['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'contains', 'not_contains', 'starts_with', 'ends_with', 'exists', 'not_exists', 'in', 'not_in', 'between'];
|
|
6
|
+
export const PropertyCondition = z.object({
|
|
7
|
+
property: z.string().min(1).max(128),
|
|
8
|
+
op: z.enum(CONDITION_OPS).default('eq'),
|
|
9
|
+
/** Arrays carry `in`/`not_in` members and the `[low, high]` of `between`. */
|
|
10
|
+
value: z.union([z.string().max(512), z.number(), z.boolean(), z.array(z.union([z.string().max(512), z.number()])).max(100)]).optional(),
|
|
11
|
+
});
|
|
12
|
+
// ---- event explorer ---------------------------------------------------------------------------------------------------
|
|
13
|
+
export const EventExplorerQuery = PageQuery.extend({
|
|
14
|
+
name: z.string().max(128).optional(),
|
|
15
|
+
profileId: Id.optional(),
|
|
16
|
+
from: Timestamp.optional(),
|
|
17
|
+
to: Timestamp.optional(),
|
|
18
|
+
/** JSON-encoded PropertyCondition[] (query strings carry no arrays). */
|
|
19
|
+
filter: z.string().max(4000).optional(),
|
|
20
|
+
/** By when it happened: `datetime` oldest first, `-datetime` newest first. Default: newest received first. */
|
|
21
|
+
sort: z.enum(['datetime', '-datetime']).optional(),
|
|
22
|
+
/** Comma separated: `metric` (the event's definition) and/or `profile` (who did it). */
|
|
23
|
+
include: z.string().max(40).regex(/^(metric|profile)(,(metric|profile))?$/, 'include takes metric and/or profile').optional(),
|
|
24
|
+
/** Only events from messages of this journey, or of this broadcast (campaign). */
|
|
25
|
+
journeyId: Id.optional(),
|
|
26
|
+
broadcastId: Id.optional(),
|
|
27
|
+
});
|
|
28
|
+
export const EventExplorerPage = pageResult(EventRecord);
|
|
29
|
+
/** Matching events as CSV text (first 50,000). */
|
|
30
|
+
export const EventExportResult = z.object({ filename: z.string(), csv: z.string(), count: z.number().int(), truncated: z.boolean() });
|
|
31
|
+
// ---- metrics -----------------------------------------------------------------------------------------------------------
|
|
32
|
+
export const MetricSummary = z.object({
|
|
33
|
+
name: z.string(),
|
|
34
|
+
kind: z.enum(['event', 'custom']),
|
|
35
|
+
customMetricId: Id.nullable(),
|
|
36
|
+
category: z.enum(['standard', 'custom']),
|
|
37
|
+
goal: z.boolean(),
|
|
38
|
+
eventCount: z.number().int(),
|
|
39
|
+
lastEventAt: Timestamp.nullable(),
|
|
40
|
+
firstSeenAt: Timestamp.nullable(),
|
|
41
|
+
});
|
|
42
|
+
export const MetricList = z.object({ items: z.array(MetricSummary) });
|
|
43
|
+
export const ObservedProperty = z.object({ key: z.string(), types: z.array(z.string()), seen: z.number().int() });
|
|
44
|
+
export const MetricDetail = MetricSummary.extend({ schema: z.record(z.string(), z.string()).nullable(), properties: z.array(ObservedProperty) });
|
|
45
|
+
export const MetricParams = z.object({ name: z.string().min(1).max(128) });
|
|
46
|
+
export const AGGREGATE_MEASUREMENTS = ['count', 'unique', 'sum_value', 'avg_value', 'sum_property', 'avg_property'];
|
|
47
|
+
export const INTERVALS = ['hour', 'day', 'week', 'month'];
|
|
48
|
+
export const MetricAggregateQuery = z.object({
|
|
49
|
+
/** An event name, a custom metric id, or `mapped:<role>`. */
|
|
50
|
+
metric: z.string().min(1).max(128).describe('An event name, a custom metric id (a name alone is read as an event name), or mapped:<role>'),
|
|
51
|
+
measurement: z.enum(AGGREGATE_MEASUREMENTS).default('count'),
|
|
52
|
+
/** Event property summed or averaged by `sum_property` / `avg_property`. */
|
|
53
|
+
measurementProperty: z.string().min(1).max(128).optional(),
|
|
54
|
+
interval: z.enum(INTERVALS).default('day'),
|
|
55
|
+
/** Breakdown: an event property key, or `$source` / `$currency`. */
|
|
56
|
+
by: z.string().min(1).max(128).optional(),
|
|
57
|
+
from: TimestampIn,
|
|
58
|
+
to: TimestampIn,
|
|
59
|
+
timezone: z.string().min(1).max(64).default('UTC'),
|
|
60
|
+
filter: z.array(PropertyCondition).max(10).default([]),
|
|
61
|
+
/** Largest number of breakdown values returned (the rest are dropped). */
|
|
62
|
+
topN: z.number().int().min(1).max(25).default(10),
|
|
63
|
+
});
|
|
64
|
+
export const MetricAggregateResult = z.object({
|
|
65
|
+
metric: z.string(), measurement: z.string(), interval: z.string(), timezone: z.string(), by: z.string().nullable(),
|
|
66
|
+
/** Local bucket starts (ISO, no offset), oldest first; every series is aligned to them. */
|
|
67
|
+
buckets: z.array(z.string()),
|
|
68
|
+
series: z.array(z.object({ key: z.string(), values: z.array(z.number()), total: z.number() })),
|
|
69
|
+
total: z.number(),
|
|
70
|
+
});
|
|
71
|
+
// ---- custom + mapped metrics ---------------------------------------------------------------------------------------------
|
|
72
|
+
export const MetricSource = z.object({ event: z.string().min(1).max(128), conditions: z.array(PropertyCondition).max(10).default([]) });
|
|
73
|
+
export const CustomMetricDefinition = z.object({
|
|
74
|
+
sources: z.array(MetricSource).min(1).max(10),
|
|
75
|
+
/** Numeric event property used as the metric's value; defaults to the event's own value. */
|
|
76
|
+
valueProperty: z.string().min(1).max(128).nullable().default(null),
|
|
77
|
+
});
|
|
78
|
+
export const CreateCustomMetricBody = z.object({ name: z.string().trim().min(1).max(128), description: z.string().max(500).nullable().default(null), definition: CustomMetricDefinition });
|
|
79
|
+
export const UpdateCustomMetricBody = z.object({ name: z.string().trim().min(1).max(128).optional(), description: z.string().max(500).nullable().optional(), definition: CustomMetricDefinition.optional() });
|
|
80
|
+
export const CustomMetricDto = z.object({ id: Id, name: z.string(), description: z.string().nullable(), definition: CustomMetricDefinition, createdAt: Timestamp, updatedAt: Timestamp });
|
|
81
|
+
export const CustomMetricList = z.object({ items: z.array(CustomMetricDto) });
|
|
82
|
+
export const MAPPED_ROLES = ['placed_order', 'viewed_product', 'started_checkout', 'added_to_cart', 'submitted_form'];
|
|
83
|
+
export const MappedMetricRole = z.enum(MAPPED_ROLES);
|
|
84
|
+
export const MappedMetricDto = z.object({ role: MappedMetricRole, metricName: z.string(), configured: z.boolean() });
|
|
85
|
+
export const MappedMetricList = z.object({ items: z.array(MappedMetricDto) });
|
|
86
|
+
export const SetMappedMetricBody = z.object({ metricName: z.string().trim().min(1).max(128) });
|
|
87
|
+
// ---- used by -----------------------------------------------------------------------------------------------------------
|
|
88
|
+
export const UsedByItem = z.object({ kind: z.enum(['workflow', 'campaign', 'segment', 'form', 'custom_metric', 'sender_pool']), id: Id, name: z.string(), status: z.string().nullable(), via: z.string() });
|
|
89
|
+
export const UsedByResult = z.object({ items: z.array(UsedByItem) });
|
|
90
|
+
export const UsedByParams = z.object({ kind: z.enum(['list', 'segment', 'template', 'metric', 'sender']), id: z.string().min(1).max(128) });
|