@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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Id, PageQuery, Timestamp, pageResult } from './common.js';
|
|
3
|
+
import { NoteDto } from './identity.js';
|
|
4
|
+
import { LeadCriteria } from './leads.js';
|
|
5
|
+
import { ClientQuotaBody } from './platform-admin.js';
|
|
6
|
+
import { SequenceSettings } from './outbound.js';
|
|
7
|
+
// ---- agency client groups + bulk operations ---------------------------------------------------------------------
|
|
8
|
+
export const X10ClientGroupDto = z.object({ id: Id, name: z.string(), workspaceIds: z.array(Id), createdAt: Timestamp });
|
|
9
|
+
export const X10ClientGroupBody = z.object({ name: z.string().trim().min(1).max(120), workspaceIds: z.array(Id).max(500).default([]) });
|
|
10
|
+
export const X10ClientGroupPatch = z.object({ name: z.string().trim().min(1).max(120).optional(), workspaceIds: z.array(Id).max(500).optional() });
|
|
11
|
+
export const X10GroupParams = z.object({ groupId: Id });
|
|
12
|
+
export const X10GroupUnlinkBody = z.object({ workspaceIds: z.array(Id).min(1).max(500) });
|
|
13
|
+
export const X10BulkQuotaBody = ClientQuotaBody.extend({ workspaceIds: z.array(Id).max(500).optional(), groupId: Id.optional() });
|
|
14
|
+
export const X10BulkQuotaResult = z.object({ updated: z.number().int(), workspaceIds: z.array(Id) });
|
|
15
|
+
// ---- permission matrix --------------------------------------------------------------------------------------------
|
|
16
|
+
export const X10MatrixCell = z.object({ read: z.boolean(), write: z.boolean() });
|
|
17
|
+
export const X10Matrix = z.record(z.string(), X10MatrixCell);
|
|
18
|
+
export const X10MatrixBody = z.object({ matrix: X10Matrix });
|
|
19
|
+
export const X10MatrixDto = z.object({
|
|
20
|
+
modules: z.array(z.string()),
|
|
21
|
+
baseRoles: z.record(z.string(), X10Matrix),
|
|
22
|
+
roles: z.array(z.object({ id: Id, name: z.string(), baseRole: z.string(), matrix: X10Matrix })),
|
|
23
|
+
});
|
|
24
|
+
export const X10EmailParams = z.object({ email: z.string().min(3).max(320) });
|
|
25
|
+
export const X10MemberPermissions = z.object({ userId: Id, email: z.string(), name: z.string(), role: z.string(), modules: z.array(z.string()), matrix: X10Matrix });
|
|
26
|
+
// ---- generic job lookup -------------------------------------------------------------------------------------------
|
|
27
|
+
export const X10JobKind = z.enum(['bulk', 'export', 'import', 'catalog_bulk', 'lead', 'ai', 'account_export', 'estimate']);
|
|
28
|
+
export const X10JobDto = z.object({
|
|
29
|
+
id: Id, kind: X10JobKind, status: z.string(), total: z.number().int().nullable(), processed: z.number().int().nullable(), error: z.string().nullable(),
|
|
30
|
+
createdAt: Timestamp, detailPath: z.string(),
|
|
31
|
+
});
|
|
32
|
+
// ---- budgets ------------------------------------------------------------------------------------------------------
|
|
33
|
+
// Patch schemas are built from default-free fields: a zod default inside .partial() would silently reset omitted fields.
|
|
34
|
+
const BudgetFields = z.object({
|
|
35
|
+
name: z.string().trim().min(1).max(200), campaignRef: z.string().max(100).nullable().optional(), currency: z.string().length(3).toUpperCase(),
|
|
36
|
+
amountMinor: z.number().int().nonnegative(), startsOn: z.iso.date().nullable().optional(), endsOn: z.iso.date().nullable().optional(), notes: z.string().max(2000).nullable().optional(),
|
|
37
|
+
});
|
|
38
|
+
export const X10BudgetBody = BudgetFields.extend({ currency: BudgetFields.shape.currency.default('USD') });
|
|
39
|
+
export const X10BudgetPatch = BudgetFields.partial();
|
|
40
|
+
export const X10BudgetDto = z.object({
|
|
41
|
+
id: Id, name: z.string(), campaignRef: z.string().nullable(), currency: z.string(), amountMinor: z.number().int(), startsOn: z.string().nullable(), endsOn: z.string().nullable(),
|
|
42
|
+
notes: z.string().nullable(), spentMinor: z.number().int(), remainingMinor: z.number().int(), overBudget: z.boolean(), createdAt: Timestamp,
|
|
43
|
+
});
|
|
44
|
+
export const X10BudgetQuery = z.object({ campaignRef: z.string().max(100).optional() });
|
|
45
|
+
export const X10SpendBody = z.object({ amountMinor: z.number().int(), spentOn: z.iso.date(), description: z.string().max(500).nullable().optional(), idempotencyKey: z.string().min(1).max(200) });
|
|
46
|
+
export const X10SpendDto = z.object({ id: Id, budgetId: Id, amountMinor: z.number().int(), spentOn: z.string(), description: z.string().nullable(), createdAt: Timestamp });
|
|
47
|
+
export const X10SpendParams = z.object({ id: Id, spendId: Id });
|
|
48
|
+
// ---- company notes, lists, merge, sourcing -----------------------------------------------------------------------
|
|
49
|
+
export const X10NoteBody = z.object({ body: z.string().trim().min(1).max(5000) });
|
|
50
|
+
export const X10NoteDto = z.object({ id: Id, companyId: Id, body: z.string(), authorId: z.string(), createdAt: Timestamp });
|
|
51
|
+
/** `/v1/notes/:id`: a contact note or a company note, told apart by `resource`. */
|
|
52
|
+
export const NoteByIdDto = z.discriminatedUnion('resource', [NoteDto.extend({ resource: z.literal('contact') }), X10NoteDto.extend({ resource: z.literal('company') })]);
|
|
53
|
+
export const X10AllNotesQuery = z.object({ limit: z.coerce.number().int().min(1).max(100).default(50), before: Id.optional() });
|
|
54
|
+
export const X10AllNotesDto = z.object({ items: z.array(z.object({ id: Id, resource: z.enum(['contact', 'company']), resourceId: Id, body: z.string(), authorId: z.string(), at: Timestamp })), nextBefore: Id.nullable() });
|
|
55
|
+
export const X10NoteParams = z.object({ id: Id, noteId: Id });
|
|
56
|
+
export const X10CompanyListBody = z.object({ name: z.string().trim().min(1).max(200), description: z.string().max(1000).nullable().optional() });
|
|
57
|
+
export const X10CompanyListDto = z.object({ id: Id, name: z.string(), description: z.string().nullable(), companyCount: z.number().int(), createdAt: Timestamp });
|
|
58
|
+
export const X10CompanyIdsBody = z.object({ companyIds: z.array(Id).min(1).max(1000) });
|
|
59
|
+
export const X10MergeCompaniesBody = z.object({ mergeIds: z.array(Id).min(1).max(50) });
|
|
60
|
+
export const X10CompanyStageBody = z.object({
|
|
61
|
+
stage: z.enum(['new', 'engaged', 'opportunity', 'customer', 'not_a_fit', 'do_not_contact']).optional(), ownerUserId: Id.nullable().optional(),
|
|
62
|
+
});
|
|
63
|
+
export const X10SourceContactsBody = z.object({
|
|
64
|
+
providerId: Id, titles: z.array(z.string().max(100)).max(20).default([]), seniorities: z.array(z.string().max(50)).max(10).default([]), limit: z.number().int().min(1).max(50).default(10),
|
|
65
|
+
/** With no titles given, ask the AI assistant for the buyer titles of this account. */
|
|
66
|
+
offer: z.string().max(500).optional(),
|
|
67
|
+
});
|
|
68
|
+
export const X10UnifyResult = z.object({ linked: z.number().int(), created: z.number().int() });
|
|
69
|
+
export const X10SavedSearchPatch = z.object({
|
|
70
|
+
name: z.string().trim().min(1).max(200).optional(), criteria: LeadCriteria.optional(),
|
|
71
|
+
runEvery: z.enum(['daily', 'weekly']).nullable().optional(), autoEnrich: z.boolean().optional(), maxResults: z.number().int().min(1).max(100).optional(),
|
|
72
|
+
});
|
|
73
|
+
// ---- marketing events / webinars ----------------------------------------------------------------------------------
|
|
74
|
+
const EventKind = z.enum(['webinar', 'event', 'conference', 'workshop']);
|
|
75
|
+
const EventStatus = z.enum(['scheduled', 'live', 'completed', 'cancelled']);
|
|
76
|
+
const EventFields = z.object({
|
|
77
|
+
name: z.string().trim().min(1).max(200), kind: EventKind, startsAt: Timestamp.nullable().optional(), endsAt: Timestamp.nullable().optional(),
|
|
78
|
+
url: z.url().max(2000).nullable().optional(), organizer: z.string().max(200).nullable().optional(), capacity: z.number().int().positive().nullable().optional(),
|
|
79
|
+
status: EventStatus, externalRef: z.string().max(200).nullable().optional(),
|
|
80
|
+
});
|
|
81
|
+
export const X10EventBody = EventFields.extend({ kind: EventKind.default('webinar'), status: EventStatus.default('scheduled') });
|
|
82
|
+
export const X10EventPatch = EventFields.partial();
|
|
83
|
+
export const X10EventDto = z.object({
|
|
84
|
+
id: Id, name: z.string(), kind: EventKind, startsAt: Timestamp.nullable(), endsAt: Timestamp.nullable(), url: z.string().nullable(), organizer: z.string().nullable(),
|
|
85
|
+
capacity: z.number().int().nullable(), status: EventStatus, externalRef: z.string().nullable(), registered: z.number().int().default(0), attended: z.number().int().default(0), createdAt: Timestamp,
|
|
86
|
+
});
|
|
87
|
+
export const X10EventQuery = PageQuery.extend({ status: EventStatus.optional() });
|
|
88
|
+
export const X10EventPage = pageResult(X10EventDto);
|
|
89
|
+
export const X10RegisterBody = z.object({ emails: z.array(z.string().max(320)).min(1).max(1000) });
|
|
90
|
+
export const X10RegisterResult = z.object({ registered: z.number().int(), skipped: z.array(z.object({ email: z.string(), reason: z.string() })) });
|
|
91
|
+
export const X10AttendanceBody = z.object({ rows: z.array(z.object({ email: z.string().max(320), durationSec: z.number().int().nonnegative().optional() })).min(1).max(5000), markNoShows: z.boolean().default(false) });
|
|
92
|
+
export const X10AttendanceResult = z.object({ attended: z.number().int(), noShows: z.number().int() });
|
|
93
|
+
export const X10RegistrationDto = z.object({
|
|
94
|
+
id: Id, eventId: Id, email: z.string(), profileId: Id.nullable(), status: z.enum(['registered', 'attended', 'no_show', 'cancelled']), attendedAt: Timestamp.nullable(), durationSec: z.number().int().nullable(), createdAt: Timestamp,
|
|
95
|
+
});
|
|
96
|
+
export const X10RegistrationQuery = PageQuery.extend({ status: z.enum(['registered', 'attended', 'no_show', 'cancelled']).optional() });
|
|
97
|
+
export const X10RegistrationPage = pageResult(X10RegistrationDto);
|
|
98
|
+
export const X10CancelRegistrationBody = z.object({ email: z.string().max(320) });
|
|
99
|
+
// ---- AI: bulk jobs, sequence drafting, prompt templates ----------------------------------------------------------
|
|
100
|
+
const AiRow = z.object({
|
|
101
|
+
key: z.string().min(1).max(200),
|
|
102
|
+
prospect: z.object({ firstName: z.string().max(100).optional(), company: z.string().max(200).optional(), title: z.string().max(200).optional() }).default({}),
|
|
103
|
+
research: z.string().max(4000).default(''),
|
|
104
|
+
fields: z.record(z.string().max(100), z.string().max(1000)).optional(),
|
|
105
|
+
});
|
|
106
|
+
export const X10AiFirstLinesBody = z.object({ rows: z.array(AiRow).min(1).max(500), offer: z.string().max(500).optional() });
|
|
107
|
+
export const X10AiCustomBody = z.object({ rows: z.array(AiRow).min(1).max(500), prompt: z.string().trim().min(1).max(2000) });
|
|
108
|
+
export const X10AiJobDto = z.object({
|
|
109
|
+
id: Id, kind: z.enum(['first_line', 'custom']), status: z.enum(['queued', 'running', 'done', 'failed']), total: z.number().int(), processed: z.number().int(),
|
|
110
|
+
results: z.array(z.object({ key: z.string(), text: z.string().nullable(), error: z.string().optional() })), model: z.string().nullable(), error: z.string().nullable(), createdAt: Timestamp,
|
|
111
|
+
});
|
|
112
|
+
export const X10AiJobPage = pageResult(X10AiJobDto);
|
|
113
|
+
export const X10SequenceDraftBody = z.object({
|
|
114
|
+
brief: z.string().trim().min(1).max(3000), steps: z.number().int().min(1).max(8).default(4), audience: z.string().max(300).optional(), tone: z.string().max(60).optional(),
|
|
115
|
+
name: z.string().trim().min(1).max(200).optional(),
|
|
116
|
+
});
|
|
117
|
+
export const X10SequenceDraftResult = z.object({
|
|
118
|
+
name: z.string(), settings: SequenceSettings, templates: z.array(z.object({ id: Id, subject: z.string() })), draft: z.literal(true), model: z.string(),
|
|
119
|
+
});
|
|
120
|
+
export const X10PromptTemplateBody = z.object({ name: z.string().trim().min(1).max(200), prompt: z.string().trim().min(1).max(4000), resourceRef: z.string().max(100).nullable().optional() });
|
|
121
|
+
export const X10PromptTemplateDto = z.object({ id: Id, name: z.string(), prompt: z.string(), resourceRef: z.string().nullable(), createdAt: Timestamp });
|
|
122
|
+
export const X10PromptTemplateQuery = z.object({ resourceRef: z.string().max(100).optional() });
|
|
123
|
+
// ---- user groups, invitations, ownership --------------------------------------------------------------------------
|
|
124
|
+
export const X10UserGroupBody = z.object({ name: z.string().trim().min(1).max(120), customRoleId: Id, userIds: z.array(Id).max(1000).default([]) });
|
|
125
|
+
export const X10UserGroupPatch = z.object({ name: z.string().trim().min(1).max(120).optional(), customRoleId: Id.optional(), userIds: z.array(Id).max(1000).optional() });
|
|
126
|
+
export const X10UserGroupDto = z.object({ id: Id, name: z.string(), customRoleId: Id, userIds: z.array(Id), createdAt: Timestamp });
|
|
127
|
+
export const X10InvitationDto = z.object({ id: Id, email: z.string(), role: z.string(), expiresAt: Timestamp, createdAt: Timestamp });
|
|
128
|
+
export const X10TransferOwnerBody = z.object({ userId: Id });
|
|
129
|
+
export const X10SpendPatch = X10SpendBody.omit({ idempotencyKey: true }).partial();
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare class HermeticaError extends Error {
|
|
2
|
+
readonly status: number;
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly details?: Record<string, unknown>;
|
|
5
|
+
constructor(status: number, code: string, message: string, details?: Record<string, unknown>);
|
|
6
|
+
}
|
|
7
|
+
export interface ClientOptions {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
/** Secret API key (`hm_sk_...`). */
|
|
10
|
+
apiKey: string;
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
/** Retries after the first attempt, for 429/5xx. Default 3. */
|
|
13
|
+
maxRetries?: number;
|
|
14
|
+
/** Per-attempt timeout. Default 30 s. */
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
/** Injectable for tests. */
|
|
17
|
+
sleep?: (ms: number) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface RequestOptions {
|
|
20
|
+
/** Sent as `Idempotency-Key`. Also makes a POST safe to retry on 5xx. */
|
|
21
|
+
idempotencyKey?: string;
|
|
22
|
+
}
|
|
23
|
+
export type Query = Record<string, string | number | boolean | undefined>;
|
|
24
|
+
/** Retry-After as delta-seconds or HTTP date; null when absent/unparseable. */
|
|
25
|
+
export declare function retryAfterMs(h: string | null, now?: number): number | null;
|
|
26
|
+
export type Transport = <T>(method: string, path: string, init?: {
|
|
27
|
+
body?: unknown;
|
|
28
|
+
query?: Query;
|
|
29
|
+
} & RequestOptions) => Promise<T>;
|
|
30
|
+
export declare function createTransport(o: ClientOptions): Transport;
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export class HermeticaError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
code;
|
|
4
|
+
details;
|
|
5
|
+
constructor(status, code, message, details) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.code = code;
|
|
9
|
+
if (details !== undefined)
|
|
10
|
+
this.details = details;
|
|
11
|
+
this.name = 'HermeticaError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Retry-After as delta-seconds or HTTP date; null when absent/unparseable. */
|
|
15
|
+
export function retryAfterMs(h, now = Date.now()) {
|
|
16
|
+
if (!h)
|
|
17
|
+
return null;
|
|
18
|
+
const secs = Number(h);
|
|
19
|
+
if (Number.isFinite(secs))
|
|
20
|
+
return Math.max(0, secs * 1000);
|
|
21
|
+
const at = Date.parse(h);
|
|
22
|
+
return Number.isNaN(at) ? null : Math.max(0, at - now);
|
|
23
|
+
}
|
|
24
|
+
const backoff = (attempt) => Math.floor(Math.random() * Math.min(8_000, 250 * 2 ** attempt));
|
|
25
|
+
export function createTransport(o) {
|
|
26
|
+
const f = o.fetch ?? fetch;
|
|
27
|
+
const sleep = o.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
28
|
+
const maxRetries = o.maxRetries ?? 3;
|
|
29
|
+
const base = o.baseUrl.replace(/\/+$/, '');
|
|
30
|
+
return async (method, path, init = {}) => {
|
|
31
|
+
const qs = new URLSearchParams(Object.entries(init.query ?? {}).filter(([, v]) => v !== undefined).map(([k, v]) => [k, String(v)])).toString();
|
|
32
|
+
const headers = { authorization: `Bearer ${o.apiKey}`, accept: 'application/json' };
|
|
33
|
+
if (init.body !== undefined)
|
|
34
|
+
headers['content-type'] = 'application/json';
|
|
35
|
+
if (init.idempotencyKey)
|
|
36
|
+
headers['idempotency-key'] = init.idempotencyKey;
|
|
37
|
+
// 5xx may mean "processed, then crashed": only replay requests that are safe to repeat. 429 was never processed.
|
|
38
|
+
const replayable = method !== 'POST' || !!init.idempotencyKey;
|
|
39
|
+
for (let attempt = 0;; attempt++) {
|
|
40
|
+
let res = null;
|
|
41
|
+
try {
|
|
42
|
+
res = await f(`${base}${path}${qs ? `?${qs}` : ''}`, {
|
|
43
|
+
method, headers, signal: AbortSignal.timeout(o.timeoutMs ?? 30_000),
|
|
44
|
+
...(init.body !== undefined && { body: JSON.stringify(init.body) }),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
if (!replayable || attempt >= maxRetries)
|
|
49
|
+
throw e;
|
|
50
|
+
}
|
|
51
|
+
if (res?.ok)
|
|
52
|
+
return (res.status === 204 ? undefined : await res.json());
|
|
53
|
+
const retryable = res === null || res.status === 429 || (res.status >= 500 && replayable);
|
|
54
|
+
if (res && (!retryable || attempt >= maxRetries))
|
|
55
|
+
throw await toError(res);
|
|
56
|
+
if (res)
|
|
57
|
+
await res.body?.cancel();
|
|
58
|
+
await sleep(retryAfterMs(res?.headers.get('retry-after') ?? null) ?? backoff(attempt));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function toError(res) {
|
|
63
|
+
const j = (await res.json().catch(() => null));
|
|
64
|
+
return new HermeticaError(res.status, j?.error?.code ?? 'unknown', j?.error?.message ?? `HTTP ${res.status}`, j?.error?.details);
|
|
65
|
+
}
|