@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.
- 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 +363 -0
- package/dist/contracts/auth.js +130 -0
- package/dist/contracts/billing.d.ts +143 -0
- package/dist/contracts/billing.js +32 -0
- package/dist/contracts/campaigns.d.ts +915 -0
- package/dist/contracts/campaigns.js +276 -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 +628 -0
- package/dist/contracts/consent.js +194 -0
- package/dist/contracts/content-blocks.d.ts +165 -0
- package/dist/contracts/content-blocks.js +62 -0
- package/dist/contracts/content-library.d.ts +347 -0
- package/dist/contracts/content-library.js +52 -0
- package/dist/contracts/content.d.ts +955 -0
- package/dist/contracts/content.js +194 -0
- package/dist/contracts/delivery.d.ts +602 -0
- package/dist/contracts/delivery.js +220 -0
- package/dist/contracts/events.d.ts +514 -0
- package/dist/contracts/events.js +180 -0
- package/dist/contracts/experiments.d.ts +378 -0
- package/dist/contracts/experiments.js +140 -0
- package/dist/contracts/identity.d.ts +761 -0
- package/dist/contracts/identity.js +226 -0
- package/dist/contracts/index.d.ts +15 -0
- package/dist/contracts/index.js +15 -0
- package/dist/contracts/integrations.d.ts +445 -0
- package/dist/contracts/integrations.js +139 -0
- package/dist/contracts/leads.d.ts +733 -0
- package/dist/contracts/leads.js +125 -0
- package/dist/contracts/metrics.d.ts +465 -0
- package/dist/contracts/metrics.js +96 -0
- package/dist/contracts/outbound.d.ts +15535 -0
- package/dist/contracts/outbound.js +432 -0
- package/dist/contracts/pickers.d.ts +12 -0
- package/dist/contracts/pickers.js +20 -0
- package/dist/contracts/platform-admin.d.ts +244 -0
- package/dist/contracts/platform-admin.js +98 -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 +3187 -0
- package/dist/contracts/segments.js +421 -0
- package/dist/contracts/workflow-nodes.d.ts +2130 -0
- package/dist/contracts/workflow-nodes.js +346 -0
- package/dist/contracts/workflows.d.ts +46811 -0
- package/dist/contracts/workflows.js +350 -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 +11631 -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 +1338 -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 +1608 -0
- package/dist/x10.js +66 -0
- package/dist/z10.d.ts +256 -0
- package/dist/z10.js +46 -0
- package/package.json +40 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { resources } from './resources.js';
|
|
2
|
+
import { platformResources } from './platform.js';
|
|
3
|
+
import { x10Resources } from './x10.js';
|
|
4
|
+
import { z10Resources } from './z10.js';
|
|
5
|
+
import { createTransport } from './http.js';
|
|
6
|
+
export { HermeticaError } from './http.js';
|
|
7
|
+
export { verifyHermeticaSignature } from './signature.js';
|
|
8
|
+
export function createClient(options) {
|
|
9
|
+
const http = createTransport(options);
|
|
10
|
+
const enc = encodeURIComponent;
|
|
11
|
+
/** Follows `nextCursor` until exhausted. Works for every list route that returns `{ items, nextCursor }`. */
|
|
12
|
+
async function* paginate(path, query = {}) {
|
|
13
|
+
let cursor;
|
|
14
|
+
do {
|
|
15
|
+
const page = await http('GET', path, { query: { ...query, ...(cursor ? { cursor } : {}) } });
|
|
16
|
+
yield* page.items;
|
|
17
|
+
cursor = page.nextCursor ?? undefined;
|
|
18
|
+
} while (cursor);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
/** Typed escape hatch for any `/v1` route without a dedicated method. Retries and idempotency behave as for the typed ones. */
|
|
22
|
+
request: (method, path, o = {}) => http(method, path, o),
|
|
23
|
+
paginate,
|
|
24
|
+
...resources(http),
|
|
25
|
+
...platformResources(http),
|
|
26
|
+
...x10Resources(http),
|
|
27
|
+
...z10Resources(http),
|
|
28
|
+
profiles: {
|
|
29
|
+
list: (q = {}) => http('GET', '/v1/profiles', { query: q }),
|
|
30
|
+
get: (id) => http('GET', `/v1/profiles/${enc(id)}`),
|
|
31
|
+
upsert: (body, o) => http('POST', '/v1/profiles/upsert', { body, ...o }),
|
|
32
|
+
update: (id, body) => http('PATCH', `/v1/profiles/${enc(id)}`, { body }),
|
|
33
|
+
delete: (id) => http('DELETE', `/v1/profiles/${enc(id)}`),
|
|
34
|
+
},
|
|
35
|
+
events: {
|
|
36
|
+
ingest: (body, o) => http('POST', '/v1/events', { body, ...o }),
|
|
37
|
+
ingestBatch: (events, o) => http('POST', '/v1/events/batch', { body: { events }, ...o }),
|
|
38
|
+
identify: (body) => http('POST', '/v1/identify', { body }),
|
|
39
|
+
},
|
|
40
|
+
messages: {
|
|
41
|
+
/** `idempotencyKey` is required by the API and doubles as the `Idempotency-Key` header, so retries never double-send. */
|
|
42
|
+
send: (body) => http('POST', '/v1/messages/send', { body, idempotencyKey: body.idempotencyKey }),
|
|
43
|
+
},
|
|
44
|
+
segments: {
|
|
45
|
+
list: (q = {}) => http('GET', '/v1/segments', { query: q }),
|
|
46
|
+
get: (id) => http('GET', `/v1/segments/${enc(id)}`),
|
|
47
|
+
create: (body) => http('POST', '/v1/segments', { body }),
|
|
48
|
+
preview: (body) => http('POST', '/v1/segments/preview', { body }),
|
|
49
|
+
members: (id, q = {}) => http('GET', `/v1/segments/${enc(id)}/members`, { query: q }),
|
|
50
|
+
},
|
|
51
|
+
webhooks: {
|
|
52
|
+
list: (q = {}) => http('GET', '/v1/webhooks/endpoints', { query: q }),
|
|
53
|
+
create: (body) => http('POST', '/v1/webhooks/endpoints', { body }),
|
|
54
|
+
get: (id) => http('GET', `/v1/webhooks/endpoints/${enc(id)}`),
|
|
55
|
+
update: (id, body) => http('PATCH', `/v1/webhooks/endpoints/${enc(id)}`, { body }),
|
|
56
|
+
delete: (id) => http('DELETE', `/v1/webhooks/endpoints/${enc(id)}`),
|
|
57
|
+
rotateSecret: (id) => http('POST', `/v1/webhooks/endpoints/${enc(id)}/rotate-secret`),
|
|
58
|
+
test: (id) => http('POST', `/v1/webhooks/endpoints/${enc(id)}/test`),
|
|
59
|
+
deliveries: (id, q = {}) => http('GET', `/v1/webhooks/endpoints/${enc(id)}/deliveries`, { query: q }),
|
|
60
|
+
replay: (deliveryId) => http('POST', `/v1/webhooks/deliveries/${enc(deliveryId)}/replay`),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AccountExportDto, AuthorizedAppDto, ClientQuotaBody, InvoiceDto, OAuthClientBody, OAuthClientDto, UsagePeriodDto, WebhookTopicDto } from './contracts/index.ts';
|
|
3
|
+
import type { createTransport } from './http.ts';
|
|
4
|
+
type In<S extends z.ZodType> = z.input<S>;
|
|
5
|
+
type Out<S extends z.ZodType> = z.infer<S>;
|
|
6
|
+
/** Platform/admin resources: webhook topic catalog, billing history, account export, OAuth clients, authorized apps, agency client lifecycle. */
|
|
7
|
+
export declare function platformResources(http: ReturnType<typeof createTransport>): {
|
|
8
|
+
webhookTopics: {
|
|
9
|
+
list: () => Promise<{
|
|
10
|
+
items: Out<typeof WebhookTopicDto>[];
|
|
11
|
+
}>;
|
|
12
|
+
get: (topic: string) => Promise<{
|
|
13
|
+
topic: string;
|
|
14
|
+
category: string;
|
|
15
|
+
description: string;
|
|
16
|
+
schema: Record<string, unknown>;
|
|
17
|
+
example: Record<string, unknown>;
|
|
18
|
+
}>;
|
|
19
|
+
/** Sends the topic's example payload to one endpoint (signed, logged, never retried). */
|
|
20
|
+
testFire: (endpointId: string, topic: string) => Promise<{
|
|
21
|
+
id: string;
|
|
22
|
+
endpointId: string;
|
|
23
|
+
outboxId: string | null;
|
|
24
|
+
topic: string;
|
|
25
|
+
attempt: number;
|
|
26
|
+
status: "failed" | "pending" | "succeeded";
|
|
27
|
+
responseCode: number | null;
|
|
28
|
+
latencyMs: number | null;
|
|
29
|
+
error: string | null;
|
|
30
|
+
nextAttemptAt: string | null;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
billingHistory: {
|
|
35
|
+
usage: (months?: number) => Promise<{
|
|
36
|
+
items: Out<typeof UsagePeriodDto>[];
|
|
37
|
+
}>;
|
|
38
|
+
usageForPeriod: (period: string) => Promise<{
|
|
39
|
+
period: string;
|
|
40
|
+
sends_email: number;
|
|
41
|
+
sends_sms: number;
|
|
42
|
+
sends_whatsapp: number;
|
|
43
|
+
sends_push: number;
|
|
44
|
+
sends_postcard: number;
|
|
45
|
+
ai_tokens: number;
|
|
46
|
+
}>;
|
|
47
|
+
invoices: () => Promise<{
|
|
48
|
+
items: Out<typeof InvoiceDto>[];
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
accountExports: {
|
|
52
|
+
request: () => Promise<{
|
|
53
|
+
id: string;
|
|
54
|
+
status: "completed" | "failed" | "queued" | "running";
|
|
55
|
+
error: string | null;
|
|
56
|
+
sizeBytes: number | null;
|
|
57
|
+
datasets: Record<string, number>;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
finishedAt: string | null;
|
|
60
|
+
downloadPath: string | null;
|
|
61
|
+
options?: {
|
|
62
|
+
datasets?: string[] | undefined;
|
|
63
|
+
since?: string | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
list: () => Promise<{
|
|
67
|
+
items: Out<typeof AccountExportDto>[];
|
|
68
|
+
}>;
|
|
69
|
+
get: (id: string) => Promise<{
|
|
70
|
+
id: string;
|
|
71
|
+
status: "completed" | "failed" | "queued" | "running";
|
|
72
|
+
error: string | null;
|
|
73
|
+
sizeBytes: number | null;
|
|
74
|
+
datasets: Record<string, number>;
|
|
75
|
+
createdAt: string;
|
|
76
|
+
finishedAt: string | null;
|
|
77
|
+
downloadPath: string | null;
|
|
78
|
+
options?: {
|
|
79
|
+
datasets?: string[] | undefined;
|
|
80
|
+
since?: string | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
oauthClients: {
|
|
85
|
+
list: () => Promise<{
|
|
86
|
+
items: Out<typeof OAuthClientDto>[];
|
|
87
|
+
}>;
|
|
88
|
+
/** The client secret is returned once. */
|
|
89
|
+
create: (body: In<typeof OAuthClientBody>) => Promise<{
|
|
90
|
+
id: string;
|
|
91
|
+
clientId: string;
|
|
92
|
+
name: string;
|
|
93
|
+
redirectUris: string[];
|
|
94
|
+
scopes: string[];
|
|
95
|
+
isPublic: boolean;
|
|
96
|
+
revokedAt: string | null;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
clientSecret: string;
|
|
99
|
+
}>;
|
|
100
|
+
revoke: (id: string) => Promise<{
|
|
101
|
+
ok: true;
|
|
102
|
+
}>;
|
|
103
|
+
};
|
|
104
|
+
authorizedApps: {
|
|
105
|
+
list: () => Promise<{
|
|
106
|
+
items: Out<typeof AuthorizedAppDto>[];
|
|
107
|
+
}>;
|
|
108
|
+
get: (clientId: string) => Promise<{
|
|
109
|
+
clientId: string;
|
|
110
|
+
name: string;
|
|
111
|
+
scopes: string[];
|
|
112
|
+
grantedBy: string;
|
|
113
|
+
grantedAt: string;
|
|
114
|
+
lastUsedAt: string | null;
|
|
115
|
+
}>;
|
|
116
|
+
revoke: (clientId: string) => Promise<{
|
|
117
|
+
ok: true;
|
|
118
|
+
}>;
|
|
119
|
+
};
|
|
120
|
+
agencyClients: {
|
|
121
|
+
get: (workspaceId: string) => Promise<{
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
status: "active" | "paused" | "pending_deletion";
|
|
125
|
+
pausedAt: string | null;
|
|
126
|
+
pausedReason: string | null;
|
|
127
|
+
deleteAfter: string | null;
|
|
128
|
+
quota: {
|
|
129
|
+
sendsEmail: number | null;
|
|
130
|
+
sendsSms: number | null;
|
|
131
|
+
};
|
|
132
|
+
usage: {
|
|
133
|
+
period: string;
|
|
134
|
+
sends_email: number;
|
|
135
|
+
sends_sms: number;
|
|
136
|
+
sends_whatsapp: number;
|
|
137
|
+
sends_push: number;
|
|
138
|
+
sends_postcard: number;
|
|
139
|
+
ai_tokens: number;
|
|
140
|
+
};
|
|
141
|
+
reputation: {
|
|
142
|
+
sent30d: number;
|
|
143
|
+
bounceRate: number;
|
|
144
|
+
complaintRate: number;
|
|
145
|
+
rating: "good" | "poor" | "unknown" | "watch";
|
|
146
|
+
};
|
|
147
|
+
}>;
|
|
148
|
+
pause: (workspaceId: string, reason?: string) => Promise<{
|
|
149
|
+
ok: true;
|
|
150
|
+
}>;
|
|
151
|
+
resume: (workspaceId: string) => Promise<{
|
|
152
|
+
ok: true;
|
|
153
|
+
}>;
|
|
154
|
+
scheduleDeletion: (workspaceId: string, graceDays?: number) => Promise<{
|
|
155
|
+
deleteAfter: string;
|
|
156
|
+
}>;
|
|
157
|
+
setQuota: (workspaceId: string, body: In<typeof ClientQuotaBody>) => Promise<{
|
|
158
|
+
sendsEmail: number | null;
|
|
159
|
+
sendsSms: number | null;
|
|
160
|
+
}>;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
export {};
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const enc = encodeURIComponent;
|
|
2
|
+
/** Platform/admin resources: webhook topic catalog, billing history, account export, OAuth clients, authorized apps, agency client lifecycle. */
|
|
3
|
+
export function platformResources(http) {
|
|
4
|
+
return {
|
|
5
|
+
webhookTopics: {
|
|
6
|
+
list: () => http('GET', '/v1/webhooks/topics'),
|
|
7
|
+
get: (topic) => http('GET', `/v1/webhooks/topics/${enc(topic)}`),
|
|
8
|
+
/** Sends the topic's example payload to one endpoint (signed, logged, never retried). */
|
|
9
|
+
testFire: (endpointId, topic) => http('POST', `/v1/webhooks/endpoints/${enc(endpointId)}/test-topic`, { body: { topic } }),
|
|
10
|
+
},
|
|
11
|
+
billingHistory: {
|
|
12
|
+
usage: (months = 12) => http('GET', '/v1/billing/usage', { query: { months } }),
|
|
13
|
+
usageForPeriod: (period) => http('GET', `/v1/billing/usage/${enc(period)}`),
|
|
14
|
+
invoices: () => http('GET', '/v1/billing/invoices'),
|
|
15
|
+
},
|
|
16
|
+
accountExports: {
|
|
17
|
+
request: () => http('POST', '/v1/account-exports'),
|
|
18
|
+
list: () => http('GET', '/v1/account-exports'),
|
|
19
|
+
get: (id) => http('GET', `/v1/account-exports/${enc(id)}`),
|
|
20
|
+
},
|
|
21
|
+
oauthClients: {
|
|
22
|
+
list: () => http('GET', '/v1/oauth/clients'),
|
|
23
|
+
/** The client secret is returned once. */
|
|
24
|
+
create: (body) => http('POST', '/v1/oauth/clients', { body }),
|
|
25
|
+
revoke: (id) => http('DELETE', `/v1/oauth/clients/${enc(id)}`),
|
|
26
|
+
},
|
|
27
|
+
authorizedApps: {
|
|
28
|
+
list: () => http('GET', '/v1/authorized-apps'),
|
|
29
|
+
get: (clientId) => http('GET', `/v1/authorized-apps/${enc(clientId)}`),
|
|
30
|
+
revoke: (clientId) => http('DELETE', `/v1/authorized-apps/${enc(clientId)}`),
|
|
31
|
+
},
|
|
32
|
+
agencyClients: {
|
|
33
|
+
get: (workspaceId) => http('GET', `/v1/agency/clients/${enc(workspaceId)}`),
|
|
34
|
+
pause: (workspaceId, reason) => http('POST', `/v1/agency/clients/${enc(workspaceId)}/pause`, { body: { reason } }),
|
|
35
|
+
resume: (workspaceId) => http('POST', `/v1/agency/clients/${enc(workspaceId)}/resume`),
|
|
36
|
+
scheduleDeletion: (workspaceId, graceDays = 30) => http('POST', `/v1/agency/clients/${enc(workspaceId)}/delete`, { body: { graceDays } }),
|
|
37
|
+
setQuota: (workspaceId, body) => http('PUT', `/v1/agency/clients/${enc(workspaceId)}/quota`, { body }),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|