@hermeticacomms/sdk-node 0.0.0-stage → 0.4.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.
Files changed (73) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +12 -2
  3. package/dist/contracts/analytics.d.ts +405 -0
  4. package/dist/contracts/analytics.js +77 -0
  5. package/dist/contracts/auth.d.ts +363 -0
  6. package/dist/contracts/auth.js +130 -0
  7. package/dist/contracts/billing.d.ts +143 -0
  8. package/dist/contracts/billing.js +32 -0
  9. package/dist/contracts/campaigns.d.ts +915 -0
  10. package/dist/contracts/campaigns.js +276 -0
  11. package/dist/contracts/common.d.ts +57 -0
  12. package/dist/contracts/common.js +35 -0
  13. package/dist/contracts/connectors.d.ts +179 -0
  14. package/dist/contracts/connectors.js +46 -0
  15. package/dist/contracts/consent.d.ts +628 -0
  16. package/dist/contracts/consent.js +194 -0
  17. package/dist/contracts/content-blocks.d.ts +165 -0
  18. package/dist/contracts/content-blocks.js +62 -0
  19. package/dist/contracts/content-library.d.ts +347 -0
  20. package/dist/contracts/content-library.js +52 -0
  21. package/dist/contracts/content.d.ts +955 -0
  22. package/dist/contracts/content.js +194 -0
  23. package/dist/contracts/delivery.d.ts +602 -0
  24. package/dist/contracts/delivery.js +220 -0
  25. package/dist/contracts/events.d.ts +514 -0
  26. package/dist/contracts/events.js +180 -0
  27. package/dist/contracts/experiments.d.ts +378 -0
  28. package/dist/contracts/experiments.js +140 -0
  29. package/dist/contracts/identity.d.ts +761 -0
  30. package/dist/contracts/identity.js +226 -0
  31. package/dist/contracts/index.d.ts +15 -0
  32. package/dist/contracts/index.js +15 -0
  33. package/dist/contracts/integrations.d.ts +445 -0
  34. package/dist/contracts/integrations.js +139 -0
  35. package/dist/contracts/leads.d.ts +733 -0
  36. package/dist/contracts/leads.js +125 -0
  37. package/dist/contracts/metrics.d.ts +465 -0
  38. package/dist/contracts/metrics.js +96 -0
  39. package/dist/contracts/outbound.d.ts +15535 -0
  40. package/dist/contracts/outbound.js +432 -0
  41. package/dist/contracts/pickers.d.ts +12 -0
  42. package/dist/contracts/pickers.js +20 -0
  43. package/dist/contracts/platform-admin.d.ts +244 -0
  44. package/dist/contracts/platform-admin.js +98 -0
  45. package/dist/contracts/postcards.d.ts +79 -0
  46. package/dist/contracts/postcards.js +29 -0
  47. package/dist/contracts/push.d.ts +530 -0
  48. package/dist/contracts/push.js +102 -0
  49. package/dist/contracts/rcs.d.ts +39 -0
  50. package/dist/contracts/rcs.js +19 -0
  51. package/dist/contracts/segments.d.ts +3187 -0
  52. package/dist/contracts/segments.js +421 -0
  53. package/dist/contracts/workflow-nodes.d.ts +2130 -0
  54. package/dist/contracts/workflow-nodes.js +346 -0
  55. package/dist/contracts/workflows.d.ts +46811 -0
  56. package/dist/contracts/workflows.js +350 -0
  57. package/dist/contracts/x10-platform.d.ts +2603 -0
  58. package/dist/contracts/x10-platform.js +129 -0
  59. package/dist/http.d.ts +30 -0
  60. package/dist/http.js +65 -0
  61. package/dist/index.d.ts +11631 -0
  62. package/dist/index.js +63 -0
  63. package/dist/platform.d.ts +163 -0
  64. package/dist/platform.js +40 -0
  65. package/dist/resources.d.ts +1338 -0
  66. package/dist/resources.js +56 -0
  67. package/dist/signature.d.ts +5 -0
  68. package/dist/signature.js +19 -0
  69. package/dist/x10.d.ts +1608 -0
  70. package/dist/x10.js +66 -0
  71. package/dist/z10.d.ts +256 -0
  72. package/dist/z10.js +46 -0
  73. package/package.json +40 -4
@@ -0,0 +1,96 @@
1
+ import { z } from 'zod';
2
+ import { AppSlug, 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
+ /** Only events sent with this `app` (product). */
28
+ app: AppSlug.optional(),
29
+ });
30
+ export const EventExplorerPage = pageResult(EventRecord);
31
+ /** Matching events as CSV text (first 50,000). */
32
+ export const EventExportResult = z.object({ filename: z.string(), csv: z.string(), count: z.number().int(), truncated: z.boolean() });
33
+ // ---- metrics -----------------------------------------------------------------------------------------------------------
34
+ export const MetricSummary = z.object({
35
+ name: z.string(),
36
+ kind: z.enum(['event', 'custom']),
37
+ customMetricId: Id.nullable(),
38
+ category: z.enum(['standard', 'custom']),
39
+ goal: z.boolean(),
40
+ eventCount: z.number().int(),
41
+ lastEventAt: Timestamp.nullable(),
42
+ firstSeenAt: Timestamp.nullable(),
43
+ });
44
+ export const MetricList = z.object({ items: z.array(MetricSummary) });
45
+ export const ObservedProperty = z.object({ key: z.string(), types: z.array(z.string()), seen: z.number().int() });
46
+ export const MetricDetail = MetricSummary.extend({ schema: z.record(z.string(), z.string()).nullable(), properties: z.array(ObservedProperty) });
47
+ export const MetricParams = z.object({ name: z.string().min(1).max(128) });
48
+ export const AGGREGATE_MEASUREMENTS = ['count', 'unique', 'sum_value', 'avg_value', 'sum_property', 'avg_property'];
49
+ export const INTERVALS = ['hour', 'day', 'week', 'month'];
50
+ export const MetricAggregateQuery = z.object({
51
+ /** An event name, a custom metric id, or `mapped:<role>`. */
52
+ 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>'),
53
+ measurement: z.enum(AGGREGATE_MEASUREMENTS).default('count'),
54
+ /** Event property summed or averaged by `sum_property` / `avg_property`. */
55
+ measurementProperty: z.string().min(1).max(128).optional(),
56
+ interval: z.enum(INTERVALS).default('day'),
57
+ /** Breakdown: an event property key, or `$source` / `$currency`. */
58
+ by: z.string().min(1).max(128).optional(),
59
+ from: TimestampIn,
60
+ to: TimestampIn,
61
+ /** IANA zone the buckets follow; defaults to the workspace's zone. */
62
+ timezone: z.string().min(1).max(64).optional(),
63
+ filter: z.array(PropertyCondition).max(10).default([]),
64
+ /** Largest number of breakdown values returned (the rest are dropped). */
65
+ topN: z.number().int().min(1).max(25).default(10),
66
+ /** Only events sent with this `app` (product). */
67
+ app: AppSlug.optional(),
68
+ });
69
+ export const MetricListQuery = z.object({ app: AppSlug.optional() });
70
+ export const MetricAggregateResult = z.object({
71
+ metric: z.string(), measurement: z.string(), interval: z.string(), timezone: z.string(), by: z.string().nullable(),
72
+ /** Local bucket starts (ISO, no offset), oldest first; every series is aligned to them. */
73
+ buckets: z.array(z.string()),
74
+ series: z.array(z.object({ key: z.string(), values: z.array(z.number()), total: z.number() })),
75
+ total: z.number(),
76
+ });
77
+ // ---- custom + mapped metrics ---------------------------------------------------------------------------------------------
78
+ export const MetricSource = z.object({ event: z.string().min(1).max(128), conditions: z.array(PropertyCondition).max(10).default([]) });
79
+ export const CustomMetricDefinition = z.object({
80
+ sources: z.array(MetricSource).min(1).max(10),
81
+ /** Numeric event property used as the metric's value; defaults to the event's own value. */
82
+ valueProperty: z.string().min(1).max(128).nullable().default(null),
83
+ });
84
+ export const CreateCustomMetricBody = z.object({ name: z.string().trim().min(1).max(128), description: z.string().max(500).nullable().default(null), definition: CustomMetricDefinition });
85
+ export const UpdateCustomMetricBody = z.object({ name: z.string().trim().min(1).max(128).optional(), description: z.string().max(500).nullable().optional(), definition: CustomMetricDefinition.optional() });
86
+ export const CustomMetricDto = z.object({ id: Id, name: z.string(), description: z.string().nullable(), definition: CustomMetricDefinition, createdAt: Timestamp, updatedAt: Timestamp });
87
+ export const CustomMetricList = z.object({ items: z.array(CustomMetricDto) });
88
+ export const MAPPED_ROLES = ['placed_order', 'viewed_product', 'started_checkout', 'added_to_cart', 'submitted_form'];
89
+ export const MappedMetricRole = z.enum(MAPPED_ROLES);
90
+ export const MappedMetricDto = z.object({ role: MappedMetricRole, metricName: z.string(), configured: z.boolean() });
91
+ export const MappedMetricList = z.object({ items: z.array(MappedMetricDto) });
92
+ export const SetMappedMetricBody = z.object({ metricName: z.string().trim().min(1).max(128) });
93
+ // ---- used by -----------------------------------------------------------------------------------------------------------
94
+ 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() });
95
+ export const UsedByResult = z.object({ items: z.array(UsedByItem) });
96
+ export const UsedByParams = z.object({ kind: z.enum(['list', 'segment', 'template', 'metric', 'sender']), id: z.string().min(1).max(128) });