@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,112 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { 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
|
+
export const CreateWebhookEndpoint = z.object({ url: Url, topics: Topics, 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() });
|
|
37
|
+
export const UpdateWebhookEndpoint = z.object({
|
|
38
|
+
url: Url.optional(),
|
|
39
|
+
topics: Topics.optional(),
|
|
40
|
+
filters: Scope.filters.optional(), listIds: Scope.listIds.optional(), sources: Scope.sources.optional(), sequenceIds: Scope.sequenceIds.optional(),
|
|
41
|
+
description: z.string().max(500).nullable().optional(),
|
|
42
|
+
bodyTemplate: Delivery.bodyTemplate.nullable().optional(), authHeaders: Delivery.authHeaders.optional(), throttleSeconds: Delivery.throttleSeconds.optional(), throttleTopics: Delivery.throttleTopics.optional(),
|
|
43
|
+
autoDisableAfter: Delivery.autoDisableAfter.optional(), retryWindowHours: Delivery.retryWindowHours.optional(),
|
|
44
|
+
/** Re-enabling resets the failure counter. */
|
|
45
|
+
status: z.enum(['active', 'disabled']).optional(),
|
|
46
|
+
});
|
|
47
|
+
export const WebhookEndpointDto = z.object({
|
|
48
|
+
id: Id,
|
|
49
|
+
url: z.string(),
|
|
50
|
+
topics: z.array(z.string()),
|
|
51
|
+
description: z.string().nullable(),
|
|
52
|
+
filters: Filters,
|
|
53
|
+
listIds: Ids,
|
|
54
|
+
sources: Ids,
|
|
55
|
+
sequenceIds: Ids,
|
|
56
|
+
bodyTemplate: z.string().nullable(), authHeaders: Delivery.authHeaders, throttleSeconds: z.number().int(), throttleTopics: z.array(z.string()),
|
|
57
|
+
autoDisableAfter: z.number().int().default(50), retryWindowHours: z.number().int().default(24),
|
|
58
|
+
status: z.enum(['active', 'disabled']),
|
|
59
|
+
consecutiveFailures: z.number().int(),
|
|
60
|
+
createdAt: Timestamp,
|
|
61
|
+
updatedAt: Timestamp,
|
|
62
|
+
});
|
|
63
|
+
/** `secret` is shown exactly once (create / rotate). */
|
|
64
|
+
export const WebhookEndpointCreated = WebhookEndpointDto.extend({ secret: z.string() });
|
|
65
|
+
export const WebhookSecretResult = z.object({ secret: z.string() });
|
|
66
|
+
export const WebhookEndpointPage = pageResult(WebhookEndpointDto);
|
|
67
|
+
export const WebhookDeliveryStatus = z.enum(['pending', 'succeeded', 'failed']);
|
|
68
|
+
export const WebhookDeliveryDto = z.object({
|
|
69
|
+
id: Id,
|
|
70
|
+
endpointId: Id,
|
|
71
|
+
outboxId: Id.nullable(),
|
|
72
|
+
topic: z.string(),
|
|
73
|
+
attempt: z.number().int(),
|
|
74
|
+
status: WebhookDeliveryStatus,
|
|
75
|
+
responseCode: z.number().int().nullable(),
|
|
76
|
+
latencyMs: z.number().int().nullable(),
|
|
77
|
+
error: z.string().nullable(),
|
|
78
|
+
nextAttemptAt: Timestamp.nullable(),
|
|
79
|
+
createdAt: Timestamp,
|
|
80
|
+
});
|
|
81
|
+
export const WebhookDeliveryPage = pageResult(WebhookDeliveryDto);
|
|
82
|
+
export const WebhookDeliveriesQuery = PageQuery.extend({ status: WebhookDeliveryStatus.optional() });
|
|
83
|
+
/** Pull journal entry: `offset` is the opaque, increasing position consumers resume from. */
|
|
84
|
+
export const WebhookJournalEntry = z.object({ offset: z.number().int(), id: Id, topic: z.string(), createdAt: Timestamp, data: z.unknown() });
|
|
85
|
+
export const WebhookJournalQuery = z.object({
|
|
86
|
+
limit: z.coerce.number().int().min(1).max(500).default(100),
|
|
87
|
+
/** Entries strictly after this offset (omit to start at the beginning). */
|
|
88
|
+
after: z.coerce.number().int().min(0).optional(),
|
|
89
|
+
/** Apply this endpoint's topics and filters to the stream. */
|
|
90
|
+
endpointId: Id.optional(),
|
|
91
|
+
topic: WebhookTopicPattern.optional(),
|
|
92
|
+
});
|
|
93
|
+
export const WebhookJournalPage = z.object({ items: z.array(WebhookJournalEntry), nextOffset: z.number().int().nullable() });
|
|
94
|
+
export const WebhookJournalBounds = z.object({ earliest: z.number().int().nullable(), latest: z.number().int().nullable() });
|
|
95
|
+
export const WebhookJournalBatchBody = z.object({ offsets: z.array(z.number().int().min(0)).min(1).max(500) });
|
|
96
|
+
export const WebhookSummaryQuery = z.object({ endpointId: Id.optional(), since: Timestamp.optional(), until: Timestamp.optional() });
|
|
97
|
+
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() });
|
|
98
|
+
export const WebhookSummaryByDate = z.object({ items: z.array(WebhookSummary.extend({ date: z.string() })) });
|
|
99
|
+
export const WebhookRetriggerResult = z.object({ requeued: z.number().int() });
|
|
100
|
+
export const WebhookExportQuery = z.object({
|
|
101
|
+
endpointId: Id.optional(), status: WebhookDeliveryStatus.optional(), since: Timestamp.optional(), until: Timestamp.optional(), format: z.enum(['ndjson', 'csv']).default('ndjson'),
|
|
102
|
+
});
|
|
103
|
+
export const IntegrationSecretName = z.string().regex(/^[a-z0-9][a-z0-9_.-]{0,99}$/, 'Use lowercase letters, digits, ".", "-" and "_"');
|
|
104
|
+
export const PutIntegrationSecretBody = z.object({ value: z.string().min(1).max(4096), description: z.string().max(300).nullable().optional() });
|
|
105
|
+
export const IntegrationSecretParams = z.object({ name: IntegrationSecretName });
|
|
106
|
+
/** Signs in with Google and saves the refreshable grant under `secretName` (journey Google Sheets steps reference it). */
|
|
107
|
+
export const GoogleSecretStartBody = z.object({ secretName: IntegrationSecretName });
|
|
108
|
+
/** Never carries the value. */
|
|
109
|
+
export const IntegrationSecretDto = z.object({ id: Id, name: z.string(), description: z.string().nullable(), createdAt: Timestamp, updatedAt: Timestamp });
|
|
110
|
+
export const IntegrationSecretList = z.object({ items: z.array(IntegrationSecretDto) });
|
|
111
|
+
/** Async journal export job: same filters as the journal read; poll the job, then download the CSV. */
|
|
112
|
+
export const WebhookJournalExportBody = z.object({ after: z.number().int().min(0).optional(), endpointId: Id.optional(), topic: WebhookTopicPattern.optional() });
|