@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,445 @@
1
+ import { z } from 'zod';
2
+ /** Exact topic (`profile.created`), prefix wildcard (`segment.*`) or everything (`*`). */
3
+ export declare const WebhookTopicPattern: z.ZodString;
4
+ /** A payload condition on `data` (dotted path). All filters of an endpoint must match for a delivery to be created. */
5
+ export declare const WebhookFilter: z.ZodObject<{
6
+ id: z.ZodOptional<z.ZodString>;
7
+ path: z.ZodString;
8
+ op: z.ZodEnum<{
9
+ contains: "contains";
10
+ eq: "eq";
11
+ exists: "exists";
12
+ gt: "gt";
13
+ in: "in";
14
+ lt: "lt";
15
+ neq: "neq";
16
+ }>;
17
+ value: z.ZodOptional<z.ZodUnknown>;
18
+ }, z.core.$strip>;
19
+ /** An extra header whose value is read from a named integration secret at send time. */
20
+ export declare const WebhookAuthHeader: z.ZodObject<{
21
+ header: z.ZodString;
22
+ secretName: z.ZodString;
23
+ prefix: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>;
25
+ /** A signing secret chosen by the caller (e.g. kept in a config file) instead of a generated one: unguessable, and never returned. */
26
+ export declare const WebhookSigningSecret: z.ZodString;
27
+ /** Watchtower's PagerDuty-compatible alert intake (hosted; a self-hosted Watchtower serves the same path on its edge). */
28
+ export declare const WATCHTOWER_ENQUEUE_URL = "https://edge.watchtowerops.net/v2/enqueue";
29
+ /** What a Watchtower endpoint is subscribed to unless you pick other topics: connection health (incl. pauses) and sending-domain verification. */
30
+ export declare const WATCHTOWER_TOPICS: string[];
31
+ /**
32
+ * A target preset. `watchtower`: each delivery is a Watchtower alert event (trigger on trouble, resolve on recovery) authenticated with the
33
+ * project's ingest key (scope `ingest:alerts`), which is kept sealed in place of a signing secret and never returned.
34
+ */
35
+ export declare const WebhookPresetInput: z.ZodObject<{
36
+ kind: z.ZodLiteral<"watchtower">;
37
+ ingestKey: z.ZodString;
38
+ environment: z.ZodString;
39
+ }, z.core.$strip>;
40
+ export declare const WebhookPreset: z.ZodObject<{
41
+ kind: z.ZodLiteral<"watchtower">;
42
+ environment: z.ZodString;
43
+ }, z.core.$strip>;
44
+ export declare const CreateWebhookEndpoint: z.ZodObject<{
45
+ preset: z.ZodOptional<z.ZodObject<{
46
+ kind: z.ZodLiteral<"watchtower">;
47
+ ingestKey: z.ZodString;
48
+ environment: z.ZodString;
49
+ }, z.core.$strip>>;
50
+ url: z.ZodURL;
51
+ topics: z.ZodArray<z.ZodString>;
52
+ secret: z.ZodOptional<z.ZodString>;
53
+ description: z.ZodOptional<z.ZodString>;
54
+ filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
55
+ id: z.ZodOptional<z.ZodString>;
56
+ path: z.ZodString;
57
+ op: z.ZodEnum<{
58
+ contains: "contains";
59
+ eq: "eq";
60
+ exists: "exists";
61
+ gt: "gt";
62
+ in: "in";
63
+ lt: "lt";
64
+ neq: "neq";
65
+ }>;
66
+ value: z.ZodOptional<z.ZodUnknown>;
67
+ }, z.core.$strip>>>;
68
+ listIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
+ sources: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
+ sequenceIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
71
+ bodyTemplate: z.ZodOptional<z.ZodString>;
72
+ authHeaders: z.ZodOptional<z.ZodArray<z.ZodObject<{
73
+ header: z.ZodString;
74
+ secretName: z.ZodString;
75
+ prefix: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$strip>>>;
77
+ throttleSeconds: z.ZodOptional<z.ZodNumber>;
78
+ throttleTopics: z.ZodOptional<z.ZodArray<z.ZodString>>;
79
+ autoDisableAfter: z.ZodOptional<z.ZodNumber>;
80
+ retryWindowHours: z.ZodOptional<z.ZodNumber>;
81
+ app: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ }, z.core.$strip>;
83
+ export declare const UpdateWebhookEndpoint: z.ZodObject<{
84
+ url: z.ZodOptional<z.ZodURL>;
85
+ topics: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
+ filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
87
+ id: z.ZodOptional<z.ZodString>;
88
+ path: z.ZodString;
89
+ op: z.ZodEnum<{
90
+ contains: "contains";
91
+ eq: "eq";
92
+ exists: "exists";
93
+ gt: "gt";
94
+ in: "in";
95
+ lt: "lt";
96
+ neq: "neq";
97
+ }>;
98
+ value: z.ZodOptional<z.ZodUnknown>;
99
+ }, z.core.$strip>>>;
100
+ listIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
101
+ sources: z.ZodOptional<z.ZodArray<z.ZodString>>;
102
+ sequenceIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
103
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
104
+ bodyTemplate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
+ authHeaders: z.ZodOptional<z.ZodArray<z.ZodObject<{
106
+ header: z.ZodString;
107
+ secretName: z.ZodString;
108
+ prefix: z.ZodOptional<z.ZodString>;
109
+ }, z.core.$strip>>>;
110
+ throttleSeconds: z.ZodOptional<z.ZodNumber>;
111
+ throttleTopics: z.ZodOptional<z.ZodArray<z.ZodString>>;
112
+ autoDisableAfter: z.ZodOptional<z.ZodNumber>;
113
+ retryWindowHours: z.ZodOptional<z.ZodNumber>;
114
+ status: z.ZodOptional<z.ZodEnum<{
115
+ active: "active";
116
+ disabled: "disabled";
117
+ }>>;
118
+ app: z.ZodOptional<z.ZodNullable<z.ZodString>>;
119
+ }, z.core.$strip>;
120
+ export declare const WebhookEndpointDto: z.ZodObject<{
121
+ id: z.ZodUUID;
122
+ url: z.ZodString;
123
+ topics: z.ZodArray<z.ZodString>;
124
+ description: z.ZodNullable<z.ZodString>;
125
+ filters: z.ZodArray<z.ZodObject<{
126
+ id: z.ZodOptional<z.ZodString>;
127
+ path: z.ZodString;
128
+ op: z.ZodEnum<{
129
+ contains: "contains";
130
+ eq: "eq";
131
+ exists: "exists";
132
+ gt: "gt";
133
+ in: "in";
134
+ lt: "lt";
135
+ neq: "neq";
136
+ }>;
137
+ value: z.ZodOptional<z.ZodUnknown>;
138
+ }, z.core.$strip>>;
139
+ listIds: z.ZodArray<z.ZodString>;
140
+ sources: z.ZodArray<z.ZodString>;
141
+ sequenceIds: z.ZodArray<z.ZodString>;
142
+ bodyTemplate: z.ZodNullable<z.ZodString>;
143
+ authHeaders: z.ZodArray<z.ZodObject<{
144
+ header: z.ZodString;
145
+ secretName: z.ZodString;
146
+ prefix: z.ZodOptional<z.ZodString>;
147
+ }, z.core.$strip>>;
148
+ throttleSeconds: z.ZodNumber;
149
+ throttleTopics: z.ZodArray<z.ZodString>;
150
+ autoDisableAfter: z.ZodDefault<z.ZodNumber>;
151
+ retryWindowHours: z.ZodDefault<z.ZodNumber>;
152
+ status: z.ZodEnum<{
153
+ active: "active";
154
+ disabled: "disabled";
155
+ }>;
156
+ app: z.ZodOptional<z.ZodNullable<z.ZodString>>;
157
+ preset: z.ZodOptional<z.ZodNullable<z.ZodObject<{
158
+ kind: z.ZodLiteral<"watchtower">;
159
+ environment: z.ZodString;
160
+ }, z.core.$strip>>>;
161
+ consecutiveFailures: z.ZodNumber;
162
+ createdAt: z.ZodISODateTime;
163
+ updatedAt: z.ZodISODateTime;
164
+ }, z.core.$strip>;
165
+ /** `secret` is shown exactly once (create / rotate); absent when the caller supplied its own. */
166
+ export declare const WebhookEndpointCreated: z.ZodObject<{
167
+ id: z.ZodUUID;
168
+ url: z.ZodString;
169
+ topics: z.ZodArray<z.ZodString>;
170
+ description: z.ZodNullable<z.ZodString>;
171
+ filters: z.ZodArray<z.ZodObject<{
172
+ id: z.ZodOptional<z.ZodString>;
173
+ path: z.ZodString;
174
+ op: z.ZodEnum<{
175
+ contains: "contains";
176
+ eq: "eq";
177
+ exists: "exists";
178
+ gt: "gt";
179
+ in: "in";
180
+ lt: "lt";
181
+ neq: "neq";
182
+ }>;
183
+ value: z.ZodOptional<z.ZodUnknown>;
184
+ }, z.core.$strip>>;
185
+ listIds: z.ZodArray<z.ZodString>;
186
+ sources: z.ZodArray<z.ZodString>;
187
+ sequenceIds: z.ZodArray<z.ZodString>;
188
+ bodyTemplate: z.ZodNullable<z.ZodString>;
189
+ authHeaders: z.ZodArray<z.ZodObject<{
190
+ header: z.ZodString;
191
+ secretName: z.ZodString;
192
+ prefix: z.ZodOptional<z.ZodString>;
193
+ }, z.core.$strip>>;
194
+ throttleSeconds: z.ZodNumber;
195
+ throttleTopics: z.ZodArray<z.ZodString>;
196
+ autoDisableAfter: z.ZodDefault<z.ZodNumber>;
197
+ retryWindowHours: z.ZodDefault<z.ZodNumber>;
198
+ status: z.ZodEnum<{
199
+ active: "active";
200
+ disabled: "disabled";
201
+ }>;
202
+ app: z.ZodOptional<z.ZodNullable<z.ZodString>>;
203
+ preset: z.ZodOptional<z.ZodNullable<z.ZodObject<{
204
+ kind: z.ZodLiteral<"watchtower">;
205
+ environment: z.ZodString;
206
+ }, z.core.$strip>>>;
207
+ consecutiveFailures: z.ZodNumber;
208
+ createdAt: z.ZodISODateTime;
209
+ updatedAt: z.ZodISODateTime;
210
+ secret: z.ZodOptional<z.ZodString>;
211
+ }, z.core.$strip>;
212
+ export declare const WebhookSecretResult: z.ZodObject<{
213
+ secret: z.ZodString;
214
+ previousSecretExpiresAt: z.ZodNullable<z.ZodISODateTime>;
215
+ }, z.core.$strip>;
216
+ /** `graceHours`: how long the old secret keeps signing next to the new one (default 24; `0` stops it at once, e.g. after a leak). */
217
+ export declare const RotateWebhookSecretQuery: z.ZodObject<{
218
+ graceHours: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
219
+ }, z.core.$strip>;
220
+ export declare const WebhookEndpointPage: z.ZodObject<{
221
+ items: z.ZodArray<z.ZodObject<{
222
+ id: z.ZodUUID;
223
+ url: z.ZodString;
224
+ topics: z.ZodArray<z.ZodString>;
225
+ description: z.ZodNullable<z.ZodString>;
226
+ filters: z.ZodArray<z.ZodObject<{
227
+ id: z.ZodOptional<z.ZodString>;
228
+ path: z.ZodString;
229
+ op: z.ZodEnum<{
230
+ contains: "contains";
231
+ eq: "eq";
232
+ exists: "exists";
233
+ gt: "gt";
234
+ in: "in";
235
+ lt: "lt";
236
+ neq: "neq";
237
+ }>;
238
+ value: z.ZodOptional<z.ZodUnknown>;
239
+ }, z.core.$strip>>;
240
+ listIds: z.ZodArray<z.ZodString>;
241
+ sources: z.ZodArray<z.ZodString>;
242
+ sequenceIds: z.ZodArray<z.ZodString>;
243
+ bodyTemplate: z.ZodNullable<z.ZodString>;
244
+ authHeaders: z.ZodArray<z.ZodObject<{
245
+ header: z.ZodString;
246
+ secretName: z.ZodString;
247
+ prefix: z.ZodOptional<z.ZodString>;
248
+ }, z.core.$strip>>;
249
+ throttleSeconds: z.ZodNumber;
250
+ throttleTopics: z.ZodArray<z.ZodString>;
251
+ autoDisableAfter: z.ZodDefault<z.ZodNumber>;
252
+ retryWindowHours: z.ZodDefault<z.ZodNumber>;
253
+ status: z.ZodEnum<{
254
+ active: "active";
255
+ disabled: "disabled";
256
+ }>;
257
+ app: z.ZodOptional<z.ZodNullable<z.ZodString>>;
258
+ preset: z.ZodOptional<z.ZodNullable<z.ZodObject<{
259
+ kind: z.ZodLiteral<"watchtower">;
260
+ environment: z.ZodString;
261
+ }, z.core.$strip>>>;
262
+ consecutiveFailures: z.ZodNumber;
263
+ createdAt: z.ZodISODateTime;
264
+ updatedAt: z.ZodISODateTime;
265
+ }, z.core.$strip>>;
266
+ nextCursor: z.ZodNullable<z.ZodUUID>;
267
+ }, z.core.$strip>;
268
+ /** `app` lists one product's endpoints (an app-bound key always gets its own). */
269
+ export declare const WebhookEndpointQuery: z.ZodObject<{
270
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
271
+ cursor: z.ZodOptional<z.ZodUUID>;
272
+ app: z.ZodOptional<z.ZodString>;
273
+ }, z.core.$strip>;
274
+ export declare const WebhookDeliveryStatus: z.ZodEnum<{
275
+ failed: "failed";
276
+ pending: "pending";
277
+ succeeded: "succeeded";
278
+ }>;
279
+ export declare const WebhookDeliveryDto: z.ZodObject<{
280
+ id: z.ZodUUID;
281
+ endpointId: z.ZodUUID;
282
+ outboxId: z.ZodNullable<z.ZodUUID>;
283
+ topic: z.ZodString;
284
+ attempt: z.ZodNumber;
285
+ status: z.ZodEnum<{
286
+ failed: "failed";
287
+ pending: "pending";
288
+ succeeded: "succeeded";
289
+ }>;
290
+ responseCode: z.ZodNullable<z.ZodNumber>;
291
+ latencyMs: z.ZodNullable<z.ZodNumber>;
292
+ error: z.ZodNullable<z.ZodString>;
293
+ nextAttemptAt: z.ZodNullable<z.ZodISODateTime>;
294
+ createdAt: z.ZodISODateTime;
295
+ }, z.core.$strip>;
296
+ export declare const WebhookDeliveryPage: z.ZodObject<{
297
+ items: z.ZodArray<z.ZodObject<{
298
+ id: z.ZodUUID;
299
+ endpointId: z.ZodUUID;
300
+ outboxId: z.ZodNullable<z.ZodUUID>;
301
+ topic: z.ZodString;
302
+ attempt: z.ZodNumber;
303
+ status: z.ZodEnum<{
304
+ failed: "failed";
305
+ pending: "pending";
306
+ succeeded: "succeeded";
307
+ }>;
308
+ responseCode: z.ZodNullable<z.ZodNumber>;
309
+ latencyMs: z.ZodNullable<z.ZodNumber>;
310
+ error: z.ZodNullable<z.ZodString>;
311
+ nextAttemptAt: z.ZodNullable<z.ZodISODateTime>;
312
+ createdAt: z.ZodISODateTime;
313
+ }, z.core.$strip>>;
314
+ nextCursor: z.ZodNullable<z.ZodUUID>;
315
+ }, z.core.$strip>;
316
+ export declare const WebhookDeliveriesQuery: z.ZodObject<{
317
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
318
+ cursor: z.ZodOptional<z.ZodUUID>;
319
+ status: z.ZodOptional<z.ZodEnum<{
320
+ failed: "failed";
321
+ pending: "pending";
322
+ succeeded: "succeeded";
323
+ }>>;
324
+ }, z.core.$strip>;
325
+ /** Pull journal entry: `offset` is the opaque, increasing position consumers resume from. */
326
+ export declare const WebhookJournalEntry: z.ZodObject<{
327
+ offset: z.ZodNumber;
328
+ id: z.ZodUUID;
329
+ topic: z.ZodString;
330
+ createdAt: z.ZodISODateTime;
331
+ data: z.ZodUnknown;
332
+ }, z.core.$strip>;
333
+ export declare const WebhookJournalQuery: z.ZodObject<{
334
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
335
+ after: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
336
+ endpointId: z.ZodOptional<z.ZodUUID>;
337
+ topic: z.ZodOptional<z.ZodString>;
338
+ }, z.core.$strip>;
339
+ export declare const WebhookJournalPage: z.ZodObject<{
340
+ items: z.ZodArray<z.ZodObject<{
341
+ offset: z.ZodNumber;
342
+ id: z.ZodUUID;
343
+ topic: z.ZodString;
344
+ createdAt: z.ZodISODateTime;
345
+ data: z.ZodUnknown;
346
+ }, z.core.$strip>>;
347
+ nextOffset: z.ZodNullable<z.ZodNumber>;
348
+ }, z.core.$strip>;
349
+ export declare const WebhookJournalBounds: z.ZodObject<{
350
+ earliest: z.ZodNullable<z.ZodNumber>;
351
+ latest: z.ZodNullable<z.ZodNumber>;
352
+ }, z.core.$strip>;
353
+ export declare const WebhookJournalBatchBody: z.ZodObject<{
354
+ offsets: z.ZodArray<z.ZodNumber>;
355
+ }, z.core.$strip>;
356
+ export declare const WebhookSummaryQuery: z.ZodObject<{
357
+ endpointId: z.ZodOptional<z.ZodUUID>;
358
+ since: z.ZodOptional<z.ZodISODateTime>;
359
+ until: z.ZodOptional<z.ZodISODateTime>;
360
+ }, z.core.$strip>;
361
+ export declare const WebhookSummary: z.ZodObject<{
362
+ total: z.ZodNumber;
363
+ succeeded: z.ZodNumber;
364
+ failed: z.ZodNumber;
365
+ pending: z.ZodNumber;
366
+ avgLatencyMs: z.ZodNullable<z.ZodNumber>;
367
+ }, z.core.$strip>;
368
+ export declare const WebhookSummaryByDate: z.ZodObject<{
369
+ items: z.ZodArray<z.ZodObject<{
370
+ total: z.ZodNumber;
371
+ succeeded: z.ZodNumber;
372
+ failed: z.ZodNumber;
373
+ pending: z.ZodNumber;
374
+ avgLatencyMs: z.ZodNullable<z.ZodNumber>;
375
+ date: z.ZodString;
376
+ }, z.core.$strip>>;
377
+ }, z.core.$strip>;
378
+ export declare const WebhookRetriggerResult: z.ZodObject<{
379
+ requeued: z.ZodNumber;
380
+ }, z.core.$strip>;
381
+ export declare const WebhookExportQuery: z.ZodObject<{
382
+ endpointId: z.ZodOptional<z.ZodUUID>;
383
+ status: z.ZodOptional<z.ZodEnum<{
384
+ failed: "failed";
385
+ pending: "pending";
386
+ succeeded: "succeeded";
387
+ }>>;
388
+ since: z.ZodOptional<z.ZodISODateTime>;
389
+ until: z.ZodOptional<z.ZodISODateTime>;
390
+ format: z.ZodDefault<z.ZodEnum<{
391
+ csv: "csv";
392
+ ndjson: "ndjson";
393
+ }>>;
394
+ }, z.core.$strip>;
395
+ export type CreateWebhookEndpoint = z.infer<typeof CreateWebhookEndpoint>;
396
+ export type UpdateWebhookEndpoint = z.infer<typeof UpdateWebhookEndpoint>;
397
+ export type WebhookEndpointDto = z.infer<typeof WebhookEndpointDto>;
398
+ export type WebhookEndpointCreated = z.infer<typeof WebhookEndpointCreated>;
399
+ export type WebhookDeliveryDto = z.infer<typeof WebhookDeliveryDto>;
400
+ export declare const IntegrationSecretName: z.ZodString;
401
+ export declare const PutIntegrationSecretBody: z.ZodObject<{
402
+ value: z.ZodString;
403
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
404
+ }, z.core.$strip>;
405
+ export declare const IntegrationSecretParams: z.ZodObject<{
406
+ name: z.ZodString;
407
+ }, z.core.$strip>;
408
+ /** Signs in with Google and saves the refreshable grant under `secretName` (journey Google Sheets steps reference it). */
409
+ export declare const GoogleSecretStartBody: z.ZodObject<{
410
+ secretName: z.ZodString;
411
+ }, z.core.$strip>;
412
+ /** Never carries the value. */
413
+ export declare const IntegrationSecretDto: z.ZodObject<{
414
+ id: z.ZodUUID;
415
+ name: z.ZodString;
416
+ description: z.ZodNullable<z.ZodString>;
417
+ createdAt: z.ZodISODateTime;
418
+ updatedAt: z.ZodISODateTime;
419
+ }, z.core.$strip>;
420
+ export declare const IntegrationSecretList: z.ZodObject<{
421
+ items: z.ZodArray<z.ZodObject<{
422
+ id: z.ZodUUID;
423
+ name: z.ZodString;
424
+ description: z.ZodNullable<z.ZodString>;
425
+ createdAt: z.ZodISODateTime;
426
+ updatedAt: z.ZodISODateTime;
427
+ }, z.core.$strip>>;
428
+ }, z.core.$strip>;
429
+ /** Async journal export job: same filters as the journal read; poll the job, then download the CSV. */
430
+ export declare const WebhookJournalExportBody: z.ZodObject<{
431
+ after: z.ZodOptional<z.ZodNumber>;
432
+ endpointId: z.ZodOptional<z.ZodUUID>;
433
+ topic: z.ZodOptional<z.ZodString>;
434
+ }, z.core.$strip>;
435
+ /** `hermetica webhooks listen`: a short-lived session that streams the workspace's events so a local receiver can be tested. */
436
+ export declare const CreateWebhookListen: z.ZodObject<{
437
+ topics: z.ZodDefault<z.ZodArray<z.ZodString>>;
438
+ }, z.core.$strip>;
439
+ /** `secret` signs the forwarded events (same `Hermetica-Signature` format as real deliveries); shown once, never stored. */
440
+ export declare const WebhookListenSession: z.ZodObject<{
441
+ id: z.ZodUUID;
442
+ topics: z.ZodArray<z.ZodString>;
443
+ secret: z.ZodString;
444
+ expiresAt: z.ZodISODateTime;
445
+ }, z.core.$strip>;
@@ -0,0 +1,139 @@
1
+ import { z } from 'zod';
2
+ import { AppSlug, Id, PageQuery, Timestamp, pageResult } from './common.js';
3
+ /** Exact topic (`profile.created`), prefix wildcard (`segment.*`) or everything (`*`). */
4
+ export const WebhookTopicPattern = z.string().regex(/^(\*|[a-z_]+(\.[a-z_]+)*(\.\*)?)$/, 'Use an exact topic, "prefix.*" or "*"').max(100);
5
+ const Url = z.url().max(2048);
6
+ const Topics = z.array(WebhookTopicPattern).min(1).max(50);
7
+ /** A payload condition on `data` (dotted path). All filters of an endpoint must match for a delivery to be created. */
8
+ export const WebhookFilter = z.object({
9
+ /** Stable id, assigned on save when absent (B5); older filters were addressed by position. */
10
+ id: z.string().min(1).max(40).optional(),
11
+ path: z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/).max(120),
12
+ op: z.enum(['eq', 'neq', 'in', 'contains', 'exists', 'gt', 'lt']),
13
+ value: z.unknown().optional(),
14
+ });
15
+ const Filters = z.array(WebhookFilter).max(20);
16
+ const Ids = z.array(z.string().min(1).max(128)).max(100);
17
+ const Scope = { filters: Filters, listIds: Ids, sources: Ids, sequenceIds: Ids };
18
+ const RESERVED_HEADERS = new Set(['content-type', 'content-length', 'host', 'user-agent', 'idempotency-key', 'transfer-encoding', 'connection']);
19
+ /** An extra header whose value is read from a named integration secret at send time. */
20
+ export const WebhookAuthHeader = z.object({
21
+ header: z.string().regex(/^[A-Za-z0-9-]{1,64}$/).refine((h) => !RESERVED_HEADERS.has(h.toLowerCase()) && !h.toLowerCase().startsWith('hermetica-'), 'Reserved header name'),
22
+ secretName: z.string().min(1).max(100),
23
+ prefix: z.string().max(40).optional(),
24
+ });
25
+ const Delivery = {
26
+ /** JSON text with `{{ path }}` placeholders over `{ id, topic, workspaceId, createdAt, data }`. */
27
+ bodyTemplate: z.string().max(8000),
28
+ authHeaders: z.array(WebhookAuthHeader).max(10),
29
+ throttleSeconds: z.number().int().min(0).max(86_400),
30
+ throttleTopics: z.array(WebhookTopicPattern).max(50),
31
+ /** Consecutive failed attempts before the endpoint is disabled (default 50). */
32
+ autoDisableAfter: z.number().int().min(1).max(1000),
33
+ /** Hours one event is retried (doubling backoff, at most 6 h apart) before it is given up (default 24). */
34
+ retryWindowHours: z.number().int().min(1).max(72),
35
+ };
36
+ /** A signing secret chosen by the caller (e.g. kept in a config file) instead of a generated one: unguessable, and never returned. */
37
+ export const WebhookSigningSecret = z.string().min(32).max(256).refine((s) => new Set(s).size >= 12, 'Use a random secret: at least 32 characters, at least 12 of them different');
38
+ /** Watchtower's PagerDuty-compatible alert intake (hosted; a self-hosted Watchtower serves the same path on its edge). */
39
+ export const WATCHTOWER_ENQUEUE_URL = 'https://edge.watchtowerops.net/v2/enqueue';
40
+ /** What a Watchtower endpoint is subscribed to unless you pick other topics: connection health (incl. pauses) and sending-domain verification. */
41
+ export const WATCHTOWER_TOPICS = ['connection.health_changed', 'domain.verification_failed', 'domain.verified'];
42
+ /**
43
+ * A target preset. `watchtower`: each delivery is a Watchtower alert event (trigger on trouble, resolve on recovery) authenticated with the
44
+ * project's ingest key (scope `ingest:alerts`), which is kept sealed in place of a signing secret and never returned.
45
+ */
46
+ export const WebhookPresetInput = z.object({ kind: z.literal('watchtower'), ingestKey: z.string().trim().min(8).max(256), environment: z.string().trim().min(1).max(64) });
47
+ export const WebhookPreset = WebhookPresetInput.omit({ ingestKey: true });
48
+ export const CreateWebhookEndpoint = z.object({ preset: WebhookPresetInput.optional(), url: Url, topics: Topics, secret: WebhookSigningSecret.optional(), description: z.string().max(500).optional(), filters: Scope.filters.optional(), listIds: Scope.listIds.optional(), sources: Scope.sources.optional(), sequenceIds: Scope.sequenceIds.optional(), bodyTemplate: Delivery.bodyTemplate.optional(), authHeaders: Delivery.authHeaders.optional(), throttleSeconds: Delivery.throttleSeconds.optional(), throttleTopics: Delivery.throttleTopics.optional(), autoDisableAfter: Delivery.autoDisableAfter.optional(), retryWindowHours: Delivery.retryWindowHours.optional(), /** Product this endpoint belongs to: it only gets events attributed to that app (or not attributed to any). An app-bound key sets it for you. */ app: AppSlug.nullish() });
49
+ export const UpdateWebhookEndpoint = z.object({
50
+ url: Url.optional(),
51
+ topics: Topics.optional(),
52
+ filters: Scope.filters.optional(), listIds: Scope.listIds.optional(), sources: Scope.sources.optional(), sequenceIds: Scope.sequenceIds.optional(),
53
+ description: z.string().max(500).nullable().optional(),
54
+ bodyTemplate: Delivery.bodyTemplate.nullable().optional(), authHeaders: Delivery.authHeaders.optional(), throttleSeconds: Delivery.throttleSeconds.optional(), throttleTopics: Delivery.throttleTopics.optional(),
55
+ autoDisableAfter: Delivery.autoDisableAfter.optional(), retryWindowHours: Delivery.retryWindowHours.optional(),
56
+ /** Re-enabling resets the failure counter. */
57
+ status: z.enum(['active', 'disabled']).optional(),
58
+ app: AppSlug.nullable().optional(),
59
+ });
60
+ export const WebhookEndpointDto = z.object({
61
+ id: Id,
62
+ url: z.string(),
63
+ topics: z.array(z.string()),
64
+ description: z.string().nullable(),
65
+ filters: Filters,
66
+ listIds: Ids,
67
+ sources: Ids,
68
+ sequenceIds: Ids,
69
+ bodyTemplate: z.string().nullable(), authHeaders: Delivery.authHeaders, throttleSeconds: z.number().int(), throttleTopics: z.array(z.string()),
70
+ autoDisableAfter: z.number().int().default(50), retryWindowHours: z.number().int().default(24),
71
+ status: z.enum(['active', 'disabled']),
72
+ app: z.string().nullable().optional(),
73
+ preset: WebhookPreset.nullable().optional(),
74
+ consecutiveFailures: z.number().int(),
75
+ createdAt: Timestamp,
76
+ updatedAt: Timestamp,
77
+ });
78
+ /** `secret` is shown exactly once (create / rotate); absent when the caller supplied its own. */
79
+ export const WebhookEndpointCreated = WebhookEndpointDto.extend({ secret: z.string().optional() });
80
+ export const WebhookSecretResult = z.object({
81
+ secret: z.string(),
82
+ /** Until then deliveries also carry the old secret's signature (a second `v1=`); null when it stopped at once. */
83
+ previousSecretExpiresAt: Timestamp.nullable(),
84
+ });
85
+ /** `graceHours`: how long the old secret keeps signing next to the new one (default 24; `0` stops it at once, e.g. after a leak). */
86
+ export const RotateWebhookSecretQuery = z.object({ graceHours: z.coerce.number().int().min(0).max(168).optional() });
87
+ export const WebhookEndpointPage = pageResult(WebhookEndpointDto);
88
+ /** `app` lists one product's endpoints (an app-bound key always gets its own). */
89
+ export const WebhookEndpointQuery = PageQuery.extend({ app: AppSlug.optional() });
90
+ export const WebhookDeliveryStatus = z.enum(['pending', 'succeeded', 'failed']);
91
+ export const WebhookDeliveryDto = z.object({
92
+ id: Id,
93
+ endpointId: Id,
94
+ outboxId: Id.nullable(),
95
+ topic: z.string(),
96
+ attempt: z.number().int(),
97
+ status: WebhookDeliveryStatus,
98
+ responseCode: z.number().int().nullable(),
99
+ latencyMs: z.number().int().nullable(),
100
+ error: z.string().nullable(),
101
+ nextAttemptAt: Timestamp.nullable(),
102
+ createdAt: Timestamp,
103
+ });
104
+ export const WebhookDeliveryPage = pageResult(WebhookDeliveryDto);
105
+ export const WebhookDeliveriesQuery = PageQuery.extend({ status: WebhookDeliveryStatus.optional() });
106
+ /** Pull journal entry: `offset` is the opaque, increasing position consumers resume from. */
107
+ export const WebhookJournalEntry = z.object({ offset: z.number().int(), id: Id, topic: z.string(), createdAt: Timestamp, data: z.unknown() });
108
+ export const WebhookJournalQuery = z.object({
109
+ limit: z.coerce.number().int().min(1).max(500).default(100),
110
+ /** Entries strictly after this offset (omit to start at the beginning). */
111
+ after: z.coerce.number().int().min(0).optional(),
112
+ /** Apply this endpoint's topics and filters to the stream. */
113
+ endpointId: Id.optional(),
114
+ topic: WebhookTopicPattern.optional(),
115
+ });
116
+ export const WebhookJournalPage = z.object({ items: z.array(WebhookJournalEntry), nextOffset: z.number().int().nullable() });
117
+ export const WebhookJournalBounds = z.object({ earliest: z.number().int().nullable(), latest: z.number().int().nullable() });
118
+ export const WebhookJournalBatchBody = z.object({ offsets: z.array(z.number().int().min(0)).min(1).max(500) });
119
+ export const WebhookSummaryQuery = z.object({ endpointId: Id.optional(), since: Timestamp.optional(), until: Timestamp.optional() });
120
+ export const WebhookSummary = z.object({ total: z.number().int(), succeeded: z.number().int(), failed: z.number().int(), pending: z.number().int(), avgLatencyMs: z.number().int().nullable() });
121
+ export const WebhookSummaryByDate = z.object({ items: z.array(WebhookSummary.extend({ date: z.string() })) });
122
+ export const WebhookRetriggerResult = z.object({ requeued: z.number().int() });
123
+ export const WebhookExportQuery = z.object({
124
+ endpointId: Id.optional(), status: WebhookDeliveryStatus.optional(), since: Timestamp.optional(), until: Timestamp.optional(), format: z.enum(['ndjson', 'csv']).default('ndjson'),
125
+ });
126
+ export const IntegrationSecretName = z.string().regex(/^[a-z0-9][a-z0-9_.-]{0,99}$/, 'Use lowercase letters, digits, ".", "-" and "_"');
127
+ export const PutIntegrationSecretBody = z.object({ value: z.string().min(1).max(4096), description: z.string().max(300).nullable().optional() });
128
+ export const IntegrationSecretParams = z.object({ name: IntegrationSecretName });
129
+ /** Signs in with Google and saves the refreshable grant under `secretName` (journey Google Sheets steps reference it). */
130
+ export const GoogleSecretStartBody = z.object({ secretName: IntegrationSecretName });
131
+ /** Never carries the value. */
132
+ export const IntegrationSecretDto = z.object({ id: Id, name: z.string(), description: z.string().nullable(), createdAt: Timestamp, updatedAt: Timestamp });
133
+ export const IntegrationSecretList = z.object({ items: z.array(IntegrationSecretDto) });
134
+ /** Async journal export job: same filters as the journal read; poll the job, then download the CSV. */
135
+ export const WebhookJournalExportBody = z.object({ after: z.number().int().min(0).optional(), endpointId: Id.optional(), topic: WebhookTopicPattern.optional() });
136
+ /** `hermetica webhooks listen`: a short-lived session that streams the workspace's events so a local receiver can be tested. */
137
+ export const CreateWebhookListen = z.object({ topics: Topics.default(['*']) });
138
+ /** `secret` signs the forwarded events (same `Hermetica-Signature` format as real deliveries); shown once, never stored. */
139
+ export const WebhookListenSession = z.object({ id: Id, topics: z.array(z.string()), secret: z.string(), expiresAt: Timestamp });