@avenlabs/halal-trace-sdk 0.1.3 → 0.1.5

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 (3) hide show
  1. package/dist/client.js +97 -26
  2. package/package.json +2 -2
  3. package/src/client.ts +538 -147
package/dist/client.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ApiError, request, requestRaw } from "./http.js";
2
- const sdkVersion = "0.1.0";
1
+ import { ApiError, request, requestRaw, } from "./http.js";
2
+ const sdkVersion = "0.1.5";
3
3
  const withDefaults = (client, options = {}) => {
4
4
  return {
5
5
  ...options,
@@ -11,7 +11,9 @@ const withDefaults = (client, options = {}) => {
11
11
  sdkHeaders: {
12
12
  "x-sdk-name": "@avenlabs/halal-trace-sdk",
13
13
  "x-sdk-version": sdkVersion,
14
- ...(client.clientVersion ? { "x-client-version": client.clientVersion } : {}),
14
+ ...(client.clientVersion
15
+ ? { "x-client-version": client.clientVersion }
16
+ : {}),
15
17
  ...(client.userAgent ? { "User-Agent": client.userAgent } : {}),
16
18
  },
17
19
  hooks: client.hooks,
@@ -23,7 +25,10 @@ async function* listPaginated(client, path, query) {
23
25
  const limit = query?.limit ?? 50;
24
26
  let offset = 0;
25
27
  while (true) {
26
- const response = await client.request("GET", path, { query: { ...query, limit, offset }, canRetry: true });
28
+ const response = await client.request("GET", path, {
29
+ query: { ...query, limit, offset },
30
+ canRetry: true,
31
+ });
27
32
  const items = response.body.data ?? [];
28
33
  for (const item of items) {
29
34
  yield item;
@@ -35,7 +40,10 @@ async function* listPaginated(client, path, query) {
35
40
  }
36
41
  }
37
42
  async function* listSingle(client, path, query) {
38
- const response = await client.request("GET", path, { query, canRetry: true });
43
+ const response = await client.request("GET", path, {
44
+ query,
45
+ canRetry: true,
46
+ });
39
47
  const items = response.body.data ?? [];
40
48
  for (const item of items) {
41
49
  yield item;
@@ -45,7 +53,11 @@ async function* listRelayerJobsAll(client, orgId, query) {
45
53
  const limit = query?.limit ?? 100;
46
54
  let offset = 0;
47
55
  while (true) {
48
- const response = await client.orgs.listRelayerJobs(orgId, { ...query, limit, offset });
56
+ const response = await client.orgs.listRelayerJobs(orgId, {
57
+ ...query,
58
+ limit,
59
+ offset,
60
+ });
49
61
  const items = response.data ?? [];
50
62
  for (const item of items) {
51
63
  yield item;
@@ -101,13 +113,21 @@ export class ApiClient {
101
113
  };
102
114
  }
103
115
  health = {
104
- get: async () => unwrap((await this.request("GET", "/health", { canRetry: true })).body),
105
- live: async () => unwrap((await this.request("GET", "/live", { canRetry: true })).body),
106
- ready: async () => unwrap((await this.request("GET", "/ready", { canRetry: true })).body),
116
+ get: async () => unwrap((await this.request("GET", "/health", {
117
+ canRetry: true,
118
+ })).body),
119
+ live: async () => unwrap((await this.request("GET", "/live", { canRetry: true }))
120
+ .body),
121
+ ready: async () => unwrap((await this.request("GET", "/ready", {
122
+ canRetry: true,
123
+ })).body),
107
124
  };
108
125
  system = {
109
126
  docs: async () => {
110
- const response = await requestRaw(this.baseUrl, "/docs", "GET", { ...withDefaults(this, {}), canRetry: true });
127
+ const response = await requestRaw(this.baseUrl, "/docs", "GET", {
128
+ ...withDefaults(this, {}),
129
+ canRetry: true,
130
+ });
111
131
  return response.body;
112
132
  },
113
133
  openApi: async () => {
@@ -115,7 +135,10 @@ export class ApiClient {
115
135
  return response.body;
116
136
  },
117
137
  metrics: async () => {
118
- const response = await requestRaw(this.baseUrl, "/metrics", "GET", { ...withDefaults(this, {}), canRetry: true });
138
+ const response = await requestRaw(this.baseUrl, "/metrics", "GET", {
139
+ ...withDefaults(this, {}),
140
+ canRetry: true,
141
+ });
119
142
  return response.body;
120
143
  },
121
144
  inviteLanding: async (orgId, token) => {
@@ -134,7 +157,11 @@ export class ApiClient {
134
157
  body: payload,
135
158
  canRetry: false,
136
159
  });
137
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
160
+ return {
161
+ data: response.body,
162
+ token: response.headers.get("set-auth-token"),
163
+ requestId: response.requestId,
164
+ };
138
165
  },
139
166
  signInEmail: async (payload, options) => {
140
167
  const response = await requestRaw(this.baseUrl, "/api/auth/sign-in/email", "POST", {
@@ -142,7 +169,11 @@ export class ApiClient {
142
169
  body: payload,
143
170
  canRetry: false,
144
171
  });
145
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
172
+ return {
173
+ data: response.body,
174
+ token: response.headers.get("set-auth-token"),
175
+ requestId: response.requestId,
176
+ };
146
177
  },
147
178
  verifyEmail: async (token, callbackURL) => {
148
179
  const response = await requestRaw(this.baseUrl, "/api/auth/verify-email", "GET", {
@@ -150,7 +181,11 @@ export class ApiClient {
150
181
  query: { token, callbackURL },
151
182
  canRetry: true,
152
183
  });
153
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
184
+ return {
185
+ data: response.body,
186
+ token: response.headers.get("set-auth-token"),
187
+ requestId: response.requestId,
188
+ };
154
189
  },
155
190
  requestPasswordReset: async (payload) => {
156
191
  const response = await requestRaw(this.baseUrl, "/api/auth/request-password-reset", "POST", {
@@ -158,7 +193,11 @@ export class ApiClient {
158
193
  body: payload,
159
194
  canRetry: false,
160
195
  });
161
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
196
+ return {
197
+ data: response.body,
198
+ token: response.headers.get("set-auth-token"),
199
+ requestId: response.requestId,
200
+ };
162
201
  },
163
202
  resetPassword: async (payload) => {
164
203
  const response = await requestRaw(this.baseUrl, "/api/auth/reset-password", "POST", {
@@ -166,7 +205,11 @@ export class ApiClient {
166
205
  body: payload,
167
206
  canRetry: false,
168
207
  });
169
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
208
+ return {
209
+ data: response.body,
210
+ token: response.headers.get("set-auth-token"),
211
+ requestId: response.requestId,
212
+ };
170
213
  },
171
214
  };
172
215
  orgs = {
@@ -182,18 +225,31 @@ export class ApiClient {
182
225
  canRetry: true,
183
226
  idempotencyKey: options?.idempotencyKey,
184
227
  }).then((res) => res.body),
185
- updateMember: async (orgId, userId, payload) => await this.request("PATCH", `/orgs/${orgId}/members/${userId}`, { body: payload, canRetry: false }).then((res) => res.body),
186
- removeMember: async (orgId, userId) => await this.request("DELETE", `/orgs/${orgId}/members/${userId}`, { canRetry: false }).then((res) => res.body),
187
- listMembers: async (orgId) => await this.request("GET", `/orgs/${orgId}/members`, { canRetry: true }).then((res) => res.body),
228
+ updateMember: async (orgId, userId, payload) => await this.request("PATCH", `/orgs/${orgId}/members/${userId}`, {
229
+ body: payload,
230
+ canRetry: false,
231
+ }).then((res) => res.body),
232
+ removeMember: async (orgId, userId) => await this.request("DELETE", `/orgs/${orgId}/members/${userId}`, {
233
+ canRetry: false,
234
+ }).then((res) => res.body),
235
+ listMembers: async (orgId) => await this.request("GET", `/orgs/${orgId}/members`, {
236
+ canRetry: true,
237
+ }).then((res) => res.body),
188
238
  listMembersAll: (orgId) => listSingle(this, `/orgs/${orgId}/members`),
189
- listAuditLogs: async (orgId, query) => await this.request("GET", `/orgs/${orgId}/audit-logs`, { query, canRetry: true }).then((res) => res.body),
239
+ listAuditLogs: async (orgId, query) => await this.request("GET", `/orgs/${orgId}/audit-logs`, {
240
+ query,
241
+ canRetry: true,
242
+ }).then((res) => res.body),
190
243
  listAuditLogsAll: (orgId, query) => listPaginated(this, `/orgs/${orgId}/audit-logs`, query),
191
244
  listRelayerJobs: async (orgId, query) => await this.request("GET", `/orgs/${orgId}/relayer-jobs`, { query, canRetry: true }).then((res) => res.body),
192
245
  getRelayerJob: async (orgId, jobId) => await this.request("GET", `/orgs/${orgId}/relayer-jobs/${jobId}`, { canRetry: true }).then((res) => res.body),
193
246
  listDeadRelayerJobs: async (orgId) => await this.request("GET", `/orgs/${orgId}/relayer-jobs/dead`, { canRetry: true }).then((res) => res.body),
194
247
  retryRelayerJob: async (orgId, jobId) => await this.request("POST", `/orgs/${orgId}/relayer-jobs/${jobId}/retry`, { canRetry: false }).then((res) => res.body),
195
248
  backfillOrg: async (orgId) => await this.request("POST", `/orgs/${orgId}/relayer-jobs/backfill`, { canRetry: false }).then((res) => res.body),
196
- listInvites: async (orgId, query) => await this.request("GET", `/orgs/${orgId}/invites`, { query, canRetry: true }).then((res) => res.body),
249
+ listInvites: async (orgId, query) => await this.request("GET", `/orgs/${orgId}/invites`, {
250
+ query,
251
+ canRetry: true,
252
+ }).then((res) => res.body),
197
253
  listInvitesAll: (orgId, query) => listSingle(this, `/orgs/${orgId}/invites`, query),
198
254
  inviteMember: async (orgId, payload, options) => await this.request("POST", `/orgs/${orgId}/invites`, {
199
255
  ...options,
@@ -202,9 +258,17 @@ export class ApiClient {
202
258
  idempotencyKey: options?.idempotencyKey,
203
259
  }).then((res) => res.body),
204
260
  acceptInvite: async (orgId, token) => await this.request("POST", `/orgs/${orgId}/invites/${token}/accept`, { canRetry: false }).then((res) => res.body),
205
- lookupUserByEmail: async (orgId, email) => await this.request("GET", `/orgs/${orgId}/users`, { query: { email }, canRetry: true }).then((res) => res.body),
206
- listPermissions: async (orgId) => await this.request("GET", `/orgs/${orgId}/permissions`, { canRetry: true }).then((res) => res.body),
207
- addPermission: async (orgId, payload) => await this.request("POST", `/orgs/${orgId}/permissions`, { body: payload, canRetry: false }).then((res) => res.body),
261
+ lookupUserByEmail: async (orgId, email) => await this.request("GET", `/orgs/${orgId}/users`, {
262
+ query: { email },
263
+ canRetry: true,
264
+ }).then((res) => res.body),
265
+ listPermissions: async (orgId) => await this.request("GET", `/orgs/${orgId}/permissions`, {
266
+ canRetry: true,
267
+ }).then((res) => res.body),
268
+ addPermission: async (orgId, payload) => await this.request("POST", `/orgs/${orgId}/permissions`, {
269
+ body: payload,
270
+ canRetry: false,
271
+ }).then((res) => res.body),
208
272
  removePermission: async (orgId, payload) => await this.request("DELETE", `/orgs/${orgId}/permissions`, {
209
273
  body: payload,
210
274
  canRetry: false,
@@ -220,7 +284,10 @@ export class ApiClient {
220
284
  const start = Date.now();
221
285
  while (Date.now() - start < timeoutMs) {
222
286
  const job = await this.relayerJobs.get(orgId, jobId);
223
- if (job && (job.status === "completed" || job.status === "dead" || job.status === "failed")) {
287
+ if (job &&
288
+ (job.status === "completed" ||
289
+ job.status === "dead" ||
290
+ job.status === "failed")) {
224
291
  return job;
225
292
  }
226
293
  await new Promise((resolve) => setTimeout(resolve, intervalMs));
@@ -232,7 +299,11 @@ export class ApiClient {
232
299
  const intervalMs = options?.intervalMs ?? 2000;
233
300
  const start = Date.now();
234
301
  while (Date.now() - start < timeoutMs) {
235
- const jobs = await this.orgs.listRelayerJobs(orgId, { requestId, limit: 10, offset: 0 });
302
+ const jobs = await this.orgs.listRelayerJobs(orgId, {
303
+ requestId,
304
+ limit: 10,
305
+ offset: 0,
306
+ });
236
307
  const job = jobs.data?.[0];
237
308
  if (job) {
238
309
  return job;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avenlabs/halal-trace-sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,4 +18,4 @@
18
18
  "typescript": "^5.5.4",
19
19
  "vitest": "^2.0.4"
20
20
  }
21
- }
21
+ }
package/src/client.ts CHANGED
@@ -24,7 +24,15 @@ import type {
24
24
  SignatureRecord,
25
25
  TraceEvent,
26
26
  } from "./types.js";
27
- import { ApiError, request, requestRaw, type AuthOptions, type ClientHooks, type RequestOptions, type RetryOptions } from "./http.js";
27
+ import {
28
+ ApiError,
29
+ request,
30
+ requestRaw,
31
+ type AuthOptions,
32
+ type ClientHooks,
33
+ type RequestOptions,
34
+ type RetryOptions,
35
+ } from "./http.js";
28
36
 
29
37
  type BaseClientOptions = {
30
38
  baseUrl: string;
@@ -40,7 +48,10 @@ type BaseClientOptions = {
40
48
  signingHook?: RequestOptions["signingHook"];
41
49
  };
42
50
 
43
- type RequestConfig = Omit<RequestOptions, "sdkHeaders" | "hooks" | "signingHook"> & {
51
+ type RequestConfig = Omit<
52
+ RequestOptions,
53
+ "sdkHeaders" | "hooks" | "signingHook"
54
+ > & {
44
55
  auth?: AuthOptions;
45
56
  timeoutMs?: number;
46
57
  retry?: RetryOptions;
@@ -48,9 +59,12 @@ type RequestConfig = Omit<RequestOptions, "sdkHeaders" | "hooks" | "signingHook"
48
59
  onAuthError?: (error: ApiError) => void | Promise<void>;
49
60
  };
50
61
 
51
- const sdkVersion = "0.1.0";
62
+ const sdkVersion = "0.1.5";
52
63
 
53
- const withDefaults = (client: ApiClient, options: RequestConfig = {}): RequestOptions => {
64
+ const withDefaults = (
65
+ client: ApiClient,
66
+ options: RequestConfig = {},
67
+ ): RequestOptions => {
54
68
  return {
55
69
  ...options,
56
70
  timeoutMs: options.timeoutMs ?? client.timeoutMs,
@@ -61,7 +75,9 @@ const withDefaults = (client: ApiClient, options: RequestConfig = {}): RequestOp
61
75
  sdkHeaders: {
62
76
  "x-sdk-name": "@avenlabs/halal-trace-sdk",
63
77
  "x-sdk-version": sdkVersion,
64
- ...(client.clientVersion ? { "x-client-version": client.clientVersion } : {}),
78
+ ...(client.clientVersion
79
+ ? { "x-client-version": client.clientVersion }
80
+ : {}),
65
81
  ...(client.userAgent ? { "User-Agent": client.userAgent } : {}),
66
82
  },
67
83
  hooks: client.hooks,
@@ -69,15 +85,25 @@ const withDefaults = (client: ApiClient, options: RequestConfig = {}): RequestOp
69
85
  };
70
86
  };
71
87
 
72
- const unwrap = <T>(response: ApiResponse<T>): T => response.data ?? (undefined as T);
88
+ const unwrap = <T>(response: ApiResponse<T>): T =>
89
+ response.data ?? (undefined as T);
73
90
 
74
- type PaginatedQuery = Record<string, string | number | boolean | undefined> & { limit?: number };
91
+ type PaginatedQuery = Record<string, string | number | boolean | undefined> & {
92
+ limit?: number;
93
+ };
75
94
 
76
- async function* listPaginated<T>(client: ApiClient, path: string, query?: PaginatedQuery) {
95
+ async function* listPaginated<T>(
96
+ client: ApiClient,
97
+ path: string,
98
+ query?: PaginatedQuery,
99
+ ) {
77
100
  const limit = query?.limit ?? 50;
78
101
  let offset = 0;
79
102
  while (true) {
80
- const response = await client.request<T[]>("GET", path, { query: { ...query, limit, offset }, canRetry: true });
103
+ const response = await client.request<T[]>("GET", path, {
104
+ query: { ...query, limit, offset },
105
+ canRetry: true,
106
+ });
81
107
  const items = response.body.data ?? [];
82
108
  for (const item of items) {
83
109
  yield item;
@@ -89,8 +115,15 @@ async function* listPaginated<T>(client: ApiClient, path: string, query?: Pagina
89
115
  }
90
116
  }
91
117
 
92
- async function* listSingle<T>(client: ApiClient, path: string, query?: Record<string, string | number | boolean | undefined>) {
93
- const response = await client.request<T[]>("GET", path, { query, canRetry: true });
118
+ async function* listSingle<T>(
119
+ client: ApiClient,
120
+ path: string,
121
+ query?: Record<string, string | number | boolean | undefined>,
122
+ ) {
123
+ const response = await client.request<T[]>("GET", path, {
124
+ query,
125
+ canRetry: true,
126
+ });
94
127
  const items = response.body.data ?? [];
95
128
  for (const item of items) {
96
129
  yield item;
@@ -100,12 +133,22 @@ async function* listSingle<T>(client: ApiClient, path: string, query?: Record<st
100
133
  async function* listRelayerJobsAll(
101
134
  client: ApiClient,
102
135
  orgId: string,
103
- query?: { status?: string; jobType?: string; batchId?: string; requestId?: string; limit?: number },
136
+ query?: {
137
+ status?: string;
138
+ jobType?: string;
139
+ batchId?: string;
140
+ requestId?: string;
141
+ limit?: number;
142
+ },
104
143
  ) {
105
144
  const limit = query?.limit ?? 100;
106
145
  let offset = 0;
107
146
  while (true) {
108
- const response = await client.orgs.listRelayerJobs(orgId, { ...query, limit, offset });
147
+ const response = await client.orgs.listRelayerJobs(orgId, {
148
+ ...query,
149
+ limit,
150
+ offset,
151
+ });
109
152
  const items = response.data ?? [];
110
153
  for (const item of items) {
111
154
  yield item;
@@ -165,119 +208,283 @@ export class ApiClient {
165
208
  }
166
209
 
167
210
  health = {
168
- get: async () => unwrap((await this.request<HealthResponse>("GET", "/health", { canRetry: true })).body),
169
- live: async () => unwrap((await this.request<HealthResponse>("GET", "/live", { canRetry: true })).body),
170
- ready: async () => unwrap((await this.request<HealthResponse>("GET", "/ready", { canRetry: true })).body),
211
+ get: async () =>
212
+ unwrap(
213
+ (
214
+ await this.request<HealthResponse>("GET", "/health", {
215
+ canRetry: true,
216
+ })
217
+ ).body,
218
+ ),
219
+ live: async () =>
220
+ unwrap(
221
+ (await this.request<HealthResponse>("GET", "/live", { canRetry: true }))
222
+ .body,
223
+ ),
224
+ ready: async () =>
225
+ unwrap(
226
+ (
227
+ await this.request<HealthResponse>("GET", "/ready", {
228
+ canRetry: true,
229
+ })
230
+ ).body,
231
+ ),
171
232
  };
172
233
 
173
234
  system = {
174
235
  docs: async () => {
175
- const response = await requestRaw(this.baseUrl, "/docs", "GET", { ...withDefaults(this, {}), canRetry: true });
236
+ const response = await requestRaw(this.baseUrl, "/docs", "GET", {
237
+ ...withDefaults(this, {}),
238
+ canRetry: true,
239
+ });
176
240
  return response.body as string;
177
241
  },
178
242
  openApi: async () => {
179
- const response = await requestRaw(this.baseUrl, "/docs/openapi.json", "GET", { ...withDefaults(this, {}), canRetry: true });
243
+ const response = await requestRaw(
244
+ this.baseUrl,
245
+ "/docs/openapi.json",
246
+ "GET",
247
+ { ...withDefaults(this, {}), canRetry: true },
248
+ );
180
249
  return response.body as unknown;
181
250
  },
182
251
  metrics: async () => {
183
- const response = await requestRaw(this.baseUrl, "/metrics", "GET", { ...withDefaults(this, {}), canRetry: true });
184
- return response.body as string;
185
- },
186
- inviteLanding: async (orgId: string, token: string) => {
187
- const response = await requestRaw(this.baseUrl, "/invites/accept", "GET", {
252
+ const response = await requestRaw(this.baseUrl, "/metrics", "GET", {
188
253
  ...withDefaults(this, {}),
189
- query: { orgId, token },
190
254
  canRetry: true,
191
255
  });
192
256
  return response.body as string;
193
257
  },
258
+ inviteLanding: async (orgId: string, token: string) => {
259
+ const response = await requestRaw(
260
+ this.baseUrl,
261
+ "/invites/accept",
262
+ "GET",
263
+ {
264
+ ...withDefaults(this, {}),
265
+ query: { orgId, token },
266
+ canRetry: true,
267
+ },
268
+ );
269
+ return response.body as string;
270
+ },
194
271
  };
195
272
 
196
273
  auth = {
197
- signUpEmail: async (payload: { name: string; email: string; password: string; callbackURL?: string }, options?: RequestConfig): Promise<AuthResult> => {
198
- const response = await requestRaw(this.baseUrl, "/api/auth/sign-up/email", "POST", {
199
- ...withDefaults(this, options ?? {}),
200
- body: payload,
201
- canRetry: false,
202
- });
203
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
274
+ signUpEmail: async (
275
+ payload: {
276
+ name: string;
277
+ email: string;
278
+ password: string;
279
+ callbackURL?: string;
280
+ },
281
+ options?: RequestConfig,
282
+ ): Promise<AuthResult> => {
283
+ const response = await requestRaw(
284
+ this.baseUrl,
285
+ "/api/auth/sign-up/email",
286
+ "POST",
287
+ {
288
+ ...withDefaults(this, options ?? {}),
289
+ body: payload,
290
+ canRetry: false,
291
+ },
292
+ );
293
+ return {
294
+ data: response.body,
295
+ token: response.headers.get("set-auth-token"),
296
+ requestId: response.requestId,
297
+ };
204
298
  },
205
- signInEmail: async (payload: { email: string; password: string }, options?: RequestConfig): Promise<AuthResult> => {
206
- const response = await requestRaw(this.baseUrl, "/api/auth/sign-in/email", "POST", {
207
- ...withDefaults(this, options ?? {}),
208
- body: payload,
209
- canRetry: false,
210
- });
211
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
299
+ signInEmail: async (
300
+ payload: { email: string; password: string },
301
+ options?: RequestConfig,
302
+ ): Promise<AuthResult> => {
303
+ const response = await requestRaw(
304
+ this.baseUrl,
305
+ "/api/auth/sign-in/email",
306
+ "POST",
307
+ {
308
+ ...withDefaults(this, options ?? {}),
309
+ body: payload,
310
+ canRetry: false,
311
+ },
312
+ );
313
+ return {
314
+ data: response.body,
315
+ token: response.headers.get("set-auth-token"),
316
+ requestId: response.requestId,
317
+ };
212
318
  },
213
- verifyEmail: async (token: string, callbackURL?: string): Promise<AuthResult> => {
214
- const response = await requestRaw(this.baseUrl, "/api/auth/verify-email", "GET", {
215
- ...withDefaults(this, {}),
216
- query: { token, callbackURL },
217
- canRetry: true,
218
- });
219
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
319
+ verifyEmail: async (
320
+ token: string,
321
+ callbackURL?: string,
322
+ ): Promise<AuthResult> => {
323
+ const response = await requestRaw(
324
+ this.baseUrl,
325
+ "/api/auth/verify-email",
326
+ "GET",
327
+ {
328
+ ...withDefaults(this, {}),
329
+ query: { token, callbackURL },
330
+ canRetry: true,
331
+ },
332
+ );
333
+ return {
334
+ data: response.body,
335
+ token: response.headers.get("set-auth-token"),
336
+ requestId: response.requestId,
337
+ };
220
338
  },
221
- requestPasswordReset: async (payload: { email: string }): Promise<AuthResult> => {
222
- const response = await requestRaw(this.baseUrl, "/api/auth/request-password-reset", "POST", {
223
- ...withDefaults(this, {}),
224
- body: payload,
225
- canRetry: false,
226
- });
227
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
339
+ requestPasswordReset: async (payload: {
340
+ email: string;
341
+ }): Promise<AuthResult> => {
342
+ const response = await requestRaw(
343
+ this.baseUrl,
344
+ "/api/auth/request-password-reset",
345
+ "POST",
346
+ {
347
+ ...withDefaults(this, {}),
348
+ body: payload,
349
+ canRetry: false,
350
+ },
351
+ );
352
+ return {
353
+ data: response.body,
354
+ token: response.headers.get("set-auth-token"),
355
+ requestId: response.requestId,
356
+ };
228
357
  },
229
- resetPassword: async (payload: { token: string; newPassword: string }): Promise<AuthResult> => {
230
- const response = await requestRaw(this.baseUrl, "/api/auth/reset-password", "POST", {
231
- ...withDefaults(this, {}),
232
- body: payload,
233
- canRetry: false,
234
- });
235
- return { data: response.body, token: response.headers.get("set-auth-token"), requestId: response.requestId };
358
+ resetPassword: async (payload: {
359
+ token: string;
360
+ newPassword: string;
361
+ }): Promise<AuthResult> => {
362
+ const response = await requestRaw(
363
+ this.baseUrl,
364
+ "/api/auth/reset-password",
365
+ "POST",
366
+ {
367
+ ...withDefaults(this, {}),
368
+ body: payload,
369
+ canRetry: false,
370
+ },
371
+ );
372
+ return {
373
+ data: response.body,
374
+ token: response.headers.get("set-auth-token"),
375
+ requestId: response.requestId,
376
+ };
236
377
  },
237
378
  };
238
379
 
239
380
  orgs = {
240
- create: async (payload: { orgId: string; name?: string }, options?: RequestConfig) =>
381
+ create: async (
382
+ payload: { orgId: string; name?: string },
383
+ options?: RequestConfig,
384
+ ) =>
241
385
  await this.request<Org>("POST", "/orgs", {
242
386
  ...options,
243
387
  body: payload,
244
388
  canRetry: true,
245
389
  idempotencyKey: options?.idempotencyKey,
246
390
  }).then((res) => res.body),
247
- addMember: async (orgId: string, payload: { userId: string; role: string; department?: string }, options?: RequestConfig) =>
391
+ addMember: async (
392
+ orgId: string,
393
+ payload: { userId: string; role: string; department?: string },
394
+ options?: RequestConfig,
395
+ ) =>
248
396
  await this.request<Member>("POST", `/orgs/${orgId}/members`, {
249
397
  ...options,
250
398
  body: payload,
251
399
  canRetry: true,
252
400
  idempotencyKey: options?.idempotencyKey,
253
401
  }).then((res) => res.body),
254
- updateMember: async (orgId: string, userId: string, payload: { role?: string; department?: string }) =>
255
- await this.request<Member>("PATCH", `/orgs/${orgId}/members/${userId}`, { body: payload, canRetry: false }).then((res) => res.body),
402
+ updateMember: async (
403
+ orgId: string,
404
+ userId: string,
405
+ payload: { role?: string; department?: string },
406
+ ) =>
407
+ await this.request<Member>("PATCH", `/orgs/${orgId}/members/${userId}`, {
408
+ body: payload,
409
+ canRetry: false,
410
+ }).then((res) => res.body),
256
411
  removeMember: async (orgId: string, userId: string) =>
257
- await this.request<Member>("DELETE", `/orgs/${orgId}/members/${userId}`, { canRetry: false }).then((res) => res.body),
412
+ await this.request<Member>("DELETE", `/orgs/${orgId}/members/${userId}`, {
413
+ canRetry: false,
414
+ }).then((res) => res.body),
258
415
  listMembers: async (orgId: string) =>
259
- await this.request<Member[]>("GET", `/orgs/${orgId}/members`, { canRetry: true }).then((res) => res.body),
260
- listMembersAll: (orgId: string) => listSingle<Member>(this, `/orgs/${orgId}/members`),
261
- listAuditLogs: async (orgId: string, query?: { limit?: number; offset?: number }) =>
262
- await this.request<AuditLog[]>("GET", `/orgs/${orgId}/audit-logs`, { query, canRetry: true }).then((res) => res.body),
263
- listAuditLogsAll: (orgId: string, query?: { limit?: number }) => listPaginated<AuditLog>(this, `/orgs/${orgId}/audit-logs`, query),
416
+ await this.request<Member[]>("GET", `/orgs/${orgId}/members`, {
417
+ canRetry: true,
418
+ }).then((res) => res.body),
419
+ listMembersAll: (orgId: string) =>
420
+ listSingle<Member>(this, `/orgs/${orgId}/members`),
421
+ listAuditLogs: async (
422
+ orgId: string,
423
+ query?: { limit?: number; offset?: number },
424
+ ) =>
425
+ await this.request<AuditLog[]>("GET", `/orgs/${orgId}/audit-logs`, {
426
+ query,
427
+ canRetry: true,
428
+ }).then((res) => res.body),
429
+ listAuditLogsAll: (orgId: string, query?: { limit?: number }) =>
430
+ listPaginated<AuditLog>(this, `/orgs/${orgId}/audit-logs`, query),
264
431
  listRelayerJobs: async (
265
432
  orgId: string,
266
- query?: { status?: string; jobType?: string; batchId?: string; requestId?: string; limit?: number; offset?: number },
433
+ query?: {
434
+ status?: string;
435
+ jobType?: string;
436
+ batchId?: string;
437
+ requestId?: string;
438
+ limit?: number;
439
+ offset?: number;
440
+ },
267
441
  ) =>
268
- await this.request<RelayerJobSummary[]>("GET", `/orgs/${orgId}/relayer-jobs`, { query, canRetry: true }).then((res) => res.body),
442
+ await this.request<RelayerJobSummary[]>(
443
+ "GET",
444
+ `/orgs/${orgId}/relayer-jobs`,
445
+ { query, canRetry: true },
446
+ ).then((res) => res.body),
269
447
  getRelayerJob: async (orgId: string, jobId: number) =>
270
- await this.request<RelayerJobSummary>("GET", `/orgs/${orgId}/relayer-jobs/${jobId}`, { canRetry: true }).then((res) => res.body),
448
+ await this.request<RelayerJobSummary>(
449
+ "GET",
450
+ `/orgs/${orgId}/relayer-jobs/${jobId}`,
451
+ { canRetry: true },
452
+ ).then((res) => res.body),
271
453
  listDeadRelayerJobs: async (orgId: string) =>
272
- await this.request<RelayerJobSummary[]>("GET", `/orgs/${orgId}/relayer-jobs/dead`, { canRetry: true }).then((res) => res.body),
454
+ await this.request<RelayerJobSummary[]>(
455
+ "GET",
456
+ `/orgs/${orgId}/relayer-jobs/dead`,
457
+ { canRetry: true },
458
+ ).then((res) => res.body),
273
459
  retryRelayerJob: async (orgId: string, jobId: number) =>
274
- await this.request<RelayerJobSummary>("POST", `/orgs/${orgId}/relayer-jobs/${jobId}/retry`, { canRetry: false }).then((res) => res.body),
460
+ await this.request<RelayerJobSummary>(
461
+ "POST",
462
+ `/orgs/${orgId}/relayer-jobs/${jobId}/retry`,
463
+ { canRetry: false },
464
+ ).then((res) => res.body),
275
465
  backfillOrg: async (orgId: string) =>
276
- await this.request<RelayerJobSummary>("POST", `/orgs/${orgId}/relayer-jobs/backfill`, { canRetry: false }).then((res) => res.body),
466
+ await this.request<RelayerJobSummary>(
467
+ "POST",
468
+ `/orgs/${orgId}/relayer-jobs/backfill`,
469
+ { canRetry: false },
470
+ ).then((res) => res.body),
277
471
  listInvites: async (orgId: string, query?: { status?: string }) =>
278
- await this.request<Invite[]>("GET", `/orgs/${orgId}/invites`, { query, canRetry: true }).then((res) => res.body),
279
- listInvitesAll: (orgId: string, query?: { status?: string }) => listSingle<Invite>(this, `/orgs/${orgId}/invites`, query),
280
- inviteMember: async (orgId: string, payload: { email: string; role: string; department?: string; inviteUrl?: string }, options?: RequestConfig) =>
472
+ await this.request<Invite[]>("GET", `/orgs/${orgId}/invites`, {
473
+ query,
474
+ canRetry: true,
475
+ }).then((res) => res.body),
476
+ listInvitesAll: (orgId: string, query?: { status?: string }) =>
477
+ listSingle<Invite>(this, `/orgs/${orgId}/invites`, query),
478
+ inviteMember: async (
479
+ orgId: string,
480
+ payload: {
481
+ email: string;
482
+ role: string;
483
+ department?: string;
484
+ inviteUrl?: string;
485
+ },
486
+ options?: RequestConfig,
487
+ ) =>
281
488
  await this.request<OrgInviteResult>("POST", `/orgs/${orgId}/invites`, {
282
489
  ...options,
283
490
  body: payload,
@@ -285,45 +492,99 @@ export class ApiClient {
285
492
  idempotencyKey: options?.idempotencyKey,
286
493
  }).then((res) => res.body),
287
494
  acceptInvite: async (orgId: string, token: string) =>
288
- await this.request<{ invite: Invite; member: Member }>("POST", `/orgs/${orgId}/invites/${token}/accept`, { canRetry: false }).then((res) => res.body),
495
+ await this.request<{ invite: Invite; member: Member }>(
496
+ "POST",
497
+ `/orgs/${orgId}/invites/${token}/accept`,
498
+ { canRetry: false },
499
+ ).then((res) => res.body),
289
500
  lookupUserByEmail: async (orgId: string, email: string) =>
290
- await this.request<OrgUserLookup>("GET", `/orgs/${orgId}/users`, { query: { email }, canRetry: true }).then((res) => res.body),
501
+ await this.request<OrgUserLookup>("GET", `/orgs/${orgId}/users`, {
502
+ query: { email },
503
+ canRetry: true,
504
+ }).then((res) => res.body),
291
505
  listPermissions: async (orgId: string) =>
292
- await this.request<Permission[]>("GET", `/orgs/${orgId}/permissions`, { canRetry: true }).then((res) => res.body),
293
- addPermission: async (orgId: string, payload: { action: string; role: string }) =>
294
- await this.request<Permission>("POST", `/orgs/${orgId}/permissions`, { body: payload, canRetry: false }).then((res) => res.body),
295
- removePermission: async (orgId: string, payload: { action: string; role: string }) =>
296
- await this.request<{ orgId: string; action: string; role: string }>("DELETE", `/orgs/${orgId}/permissions`, {
506
+ await this.request<Permission[]>("GET", `/orgs/${orgId}/permissions`, {
507
+ canRetry: true,
508
+ }).then((res) => res.body),
509
+ addPermission: async (
510
+ orgId: string,
511
+ payload: { action: string; role: string },
512
+ ) =>
513
+ await this.request<Permission>("POST", `/orgs/${orgId}/permissions`, {
297
514
  body: payload,
298
515
  canRetry: false,
299
516
  }).then((res) => res.body),
300
- setEventDepartment: async (orgId: string, payload: { eventType: string; department: string }) =>
301
- await this.request<EventDepartment>("POST", `/orgs/${orgId}/event-departments`, { body: payload, canRetry: false }).then((res) => res.body),
517
+ removePermission: async (
518
+ orgId: string,
519
+ payload: { action: string; role: string },
520
+ ) =>
521
+ await this.request<{ orgId: string; action: string; role: string }>(
522
+ "DELETE",
523
+ `/orgs/${orgId}/permissions`,
524
+ {
525
+ body: payload,
526
+ canRetry: false,
527
+ },
528
+ ).then((res) => res.body),
529
+ setEventDepartment: async (
530
+ orgId: string,
531
+ payload: { eventType: string; department: string },
532
+ ) =>
533
+ await this.request<EventDepartment>(
534
+ "POST",
535
+ `/orgs/${orgId}/event-departments`,
536
+ { body: payload, canRetry: false },
537
+ ).then((res) => res.body),
302
538
  };
303
539
 
304
540
  relayerJobs = {
305
- listAll: (orgId: string, query?: { status?: string; jobType?: string; batchId?: string; limit?: number }) =>
306
- listRelayerJobsAll(this, orgId, query),
307
- get: async (orgId: string, jobId: number) => this.orgs.getRelayerJob(orgId, jobId).then((res) => res.data),
308
- waitFor: async (orgId: string, jobId: number, options?: { timeoutMs?: number; intervalMs?: number }) => {
541
+ listAll: (
542
+ orgId: string,
543
+ query?: {
544
+ status?: string;
545
+ jobType?: string;
546
+ batchId?: string;
547
+ limit?: number;
548
+ },
549
+ ) => listRelayerJobsAll(this, orgId, query),
550
+ get: async (orgId: string, jobId: number) =>
551
+ this.orgs.getRelayerJob(orgId, jobId).then((res) => res.data),
552
+ waitFor: async (
553
+ orgId: string,
554
+ jobId: number,
555
+ options?: { timeoutMs?: number; intervalMs?: number },
556
+ ) => {
309
557
  const timeoutMs = options?.timeoutMs ?? 60000;
310
558
  const intervalMs = options?.intervalMs ?? 2000;
311
559
  const start = Date.now();
312
560
  while (Date.now() - start < timeoutMs) {
313
561
  const job = await this.relayerJobs.get(orgId, jobId);
314
- if (job && (job.status === "completed" || job.status === "dead" || job.status === "failed")) {
562
+ if (
563
+ job &&
564
+ (job.status === "completed" ||
565
+ job.status === "dead" ||
566
+ job.status === "failed")
567
+ ) {
315
568
  return job;
316
569
  }
317
570
  await new Promise((resolve) => setTimeout(resolve, intervalMs));
318
571
  }
319
572
  throw new ApiError("Timeout waiting for relayer job");
320
573
  },
321
- waitForRequest: async (orgId: string, requestId: string, options?: { timeoutMs?: number; intervalMs?: number }) => {
574
+ waitForRequest: async (
575
+ orgId: string,
576
+ requestId: string,
577
+ options?: { timeoutMs?: number; intervalMs?: number },
578
+ ) => {
322
579
  const timeoutMs = options?.timeoutMs ?? 60000;
323
580
  const intervalMs = options?.intervalMs ?? 2000;
324
581
  const start = Date.now();
325
582
  while (Date.now() - start < timeoutMs) {
326
- const jobs = await this.orgs.listRelayerJobs(orgId, { requestId, limit: 10, offset: 0 });
583
+ const jobs = await this.orgs.listRelayerJobs(orgId, {
584
+ requestId,
585
+ limit: 10,
586
+ offset: 0,
587
+ });
327
588
  const job = jobs.data?.[0];
328
589
  if (job) {
329
590
  return job;
@@ -335,23 +596,44 @@ export class ApiClient {
335
596
  };
336
597
 
337
598
  batches = {
338
- create: async (payload: { batchId: string; orgId: string; productId: string; facilityId?: string }, options?: RequestConfig) =>
599
+ create: async (
600
+ payload: {
601
+ batchId: string;
602
+ orgId: string;
603
+ productId: string;
604
+ facilityId?: string;
605
+ },
606
+ options?: RequestConfig,
607
+ ) =>
339
608
  await this.request<Batch>("POST", "/batches", {
340
609
  ...options,
341
610
  body: payload,
342
611
  canRetry: true,
343
612
  idempotencyKey: options?.idempotencyKey,
344
613
  }).then((res) => res.body),
345
- addPublicAttribute: async (batchId: string, payload: { key: string; value: string }, options?: RequestConfig) =>
346
- await this.request<PublicAttribute>("POST", `/batches/${batchId}/public-attributes`, {
347
- ...options,
348
- body: payload,
349
- canRetry: true,
350
- idempotencyKey: options?.idempotencyKey,
351
- }).then((res) => res.body),
614
+ addPublicAttribute: async (
615
+ batchId: string,
616
+ payload: { key: string; value: string },
617
+ options?: RequestConfig,
618
+ ) =>
619
+ await this.request<PublicAttribute>(
620
+ "POST",
621
+ `/batches/${batchId}/public-attributes`,
622
+ {
623
+ ...options,
624
+ body: payload,
625
+ canRetry: true,
626
+ idempotencyKey: options?.idempotencyKey,
627
+ },
628
+ ).then((res) => res.body),
352
629
  addEvent: async (
353
630
  batchId: string,
354
- payload: { eventType: string; metadataHash: string; actorRole: string; deviceId?: string },
631
+ payload: {
632
+ eventType: string;
633
+ metadataHash: string;
634
+ actorRole: string;
635
+ deviceId?: string;
636
+ },
355
637
  options?: RequestConfig,
356
638
  ) =>
357
639
  await this.request<TraceEvent>("POST", `/batches/${batchId}/events`, {
@@ -360,57 +642,129 @@ export class ApiClient {
360
642
  canRetry: Boolean(options?.idempotencyKey),
361
643
  idempotencyKey: options?.idempotencyKey,
362
644
  }).then((res) => res.body),
363
- addDocument: async (batchId: string, payload: { docHash: string; docType: string; uri: string }, options?: RequestConfig) =>
364
- await this.request<DocumentAnchor>("POST", `/batches/${batchId}/documents`, {
365
- ...options,
366
- body: payload,
367
- canRetry: true,
368
- idempotencyKey: options?.idempotencyKey,
369
- }).then((res) => res.body),
370
- addSignature: async (batchId: string, payload: { signatureHash: string; signerRole: string; signerIdHash: string }, options?: RequestConfig) =>
371
- await this.request<SignatureRecord>("POST", `/batches/${batchId}/signatures`, {
372
- ...options,
373
- body: payload,
374
- canRetry: Boolean(options?.idempotencyKey),
375
- idempotencyKey: options?.idempotencyKey,
376
- }).then((res) => res.body),
645
+ addDocument: async (
646
+ batchId: string,
647
+ payload: { docHash: string; docType: string; uri: string },
648
+ options?: RequestConfig,
649
+ ) =>
650
+ await this.request<DocumentAnchor>(
651
+ "POST",
652
+ `/batches/${batchId}/documents`,
653
+ {
654
+ ...options,
655
+ body: payload,
656
+ canRetry: true,
657
+ idempotencyKey: options?.idempotencyKey,
658
+ },
659
+ ).then((res) => res.body),
660
+ addSignature: async (
661
+ batchId: string,
662
+ payload: {
663
+ signatureHash: string;
664
+ signerRole: string;
665
+ signerIdHash: string;
666
+ },
667
+ options?: RequestConfig,
668
+ ) =>
669
+ await this.request<SignatureRecord>(
670
+ "POST",
671
+ `/batches/${batchId}/signatures`,
672
+ {
673
+ ...options,
674
+ body: payload,
675
+ canRetry: Boolean(options?.idempotencyKey),
676
+ idempotencyKey: options?.idempotencyKey,
677
+ },
678
+ ).then((res) => res.body),
377
679
  addCertification: async (
378
680
  batchId: string,
379
- payload: { status: "pending" | "approved" | "rejected"; decisionHash: string; reviewerRole: string; reviewerIdHash: string },
681
+ payload: {
682
+ status: "pending" | "approved" | "rejected";
683
+ decisionHash: string;
684
+ reviewerRole: string;
685
+ reviewerIdHash: string;
686
+ },
380
687
  options?: RequestConfig,
381
688
  ) =>
382
- await this.request<CertificationRecord>("POST", `/batches/${batchId}/certifications`, {
383
- ...options,
384
- body: payload,
385
- canRetry: Boolean(options?.idempotencyKey),
386
- idempotencyKey: options?.idempotencyKey,
387
- }).then((res) => res.body),
689
+ await this.request<CertificationRecord>(
690
+ "POST",
691
+ `/batches/${batchId}/certifications`,
692
+ {
693
+ ...options,
694
+ body: payload,
695
+ canRetry: Boolean(options?.idempotencyKey),
696
+ idempotencyKey: options?.idempotencyKey,
697
+ },
698
+ ).then((res) => res.body),
388
699
  getAuditPackManifest: async (batchId: string) =>
389
- await this.request<AuditPackManifest>("GET", `/batches/${batchId}/audit-pack/manifest`, { canRetry: true }).then((res) => res.body),
390
- listRelayerJobs: async (batchId: string, query?: { status?: string; jobType?: string; limit?: number; offset?: number }) =>
391
- await this.request<RelayerJobSummary[]>("GET", `/batches/${batchId}/relayer-jobs`, { query, canRetry: true }).then((res) => res.body),
392
- listRelayerJobsAll: (batchId: string, query?: { status?: string; jobType?: string; limit?: number }) =>
393
- listPaginated<RelayerJobSummary>(this, `/batches/${batchId}/relayer-jobs`, query),
700
+ await this.request<AuditPackManifest>(
701
+ "GET",
702
+ `/batches/${batchId}/audit-pack/manifest`,
703
+ { canRetry: true },
704
+ ).then((res) => res.body),
705
+ listRelayerJobs: async (
706
+ batchId: string,
707
+ query?: {
708
+ status?: string;
709
+ jobType?: string;
710
+ limit?: number;
711
+ offset?: number;
712
+ },
713
+ ) =>
714
+ await this.request<RelayerJobSummary[]>(
715
+ "GET",
716
+ `/batches/${batchId}/relayer-jobs`,
717
+ { query, canRetry: true },
718
+ ).then((res) => res.body),
719
+ listRelayerJobsAll: (
720
+ batchId: string,
721
+ query?: { status?: string; jobType?: string; limit?: number },
722
+ ) =>
723
+ listPaginated<RelayerJobSummary>(
724
+ this,
725
+ `/batches/${batchId}/relayer-jobs`,
726
+ query,
727
+ ),
394
728
  backfillBatch: async (batchId: string) =>
395
- await this.request<RelayerJobSummary>("POST", `/batches/${batchId}/relayer-jobs/backfill`, { canRetry: false }).then((res) => res.body),
729
+ await this.request<RelayerJobSummary>(
730
+ "POST",
731
+ `/batches/${batchId}/relayer-jobs/backfill`,
732
+ { canRetry: false },
733
+ ).then((res) => res.body),
396
734
  };
397
735
 
398
736
  devices = {
399
- register: async (payload: { deviceId: string; orgId: string; deviceType: string; label: string }, options?: RequestConfig) =>
737
+ register: async (
738
+ payload: {
739
+ deviceId: string;
740
+ orgId: string;
741
+ deviceType: string;
742
+ label: string;
743
+ },
744
+ options?: RequestConfig,
745
+ ) =>
400
746
  await this.request<Device>("POST", "/devices", {
401
747
  ...options,
402
748
  body: payload,
403
749
  canRetry: true,
404
750
  idempotencyKey: options?.idempotencyKey,
405
751
  }).then((res) => res.body),
406
- update: async (deviceId: string, payload: { deviceType: string; label: string }, options?: RequestConfig) =>
752
+ update: async (
753
+ deviceId: string,
754
+ payload: { deviceType: string; label: string },
755
+ options?: RequestConfig,
756
+ ) =>
407
757
  await this.request<Device>("PATCH", `/devices/${deviceId}`, {
408
758
  ...options,
409
759
  body: payload,
410
760
  canRetry: Boolean(options?.idempotencyKey),
411
761
  idempotencyKey: options?.idempotencyKey,
412
762
  }).then((res) => res.body),
413
- setStatus: async (deviceId: string, payload: { active: boolean }, options?: RequestConfig) =>
763
+ setStatus: async (
764
+ deviceId: string,
765
+ payload: { active: boolean },
766
+ options?: RequestConfig,
767
+ ) =>
414
768
  await this.request<Device>("PATCH", `/devices/${deviceId}/status`, {
415
769
  ...options,
416
770
  body: payload,
@@ -421,7 +775,15 @@ export class ApiClient {
421
775
 
422
776
  anchors = {
423
777
  create: async (
424
- payload: { orgId: string; merkleRoot: string; metadataHash: string; periodStart: number; periodEnd: number; anchorChainId: number; anchorTxHash: string },
778
+ payload: {
779
+ orgId: string;
780
+ merkleRoot: string;
781
+ metadataHash: string;
782
+ periodStart: number;
783
+ periodEnd: number;
784
+ anchorChainId: number;
785
+ anchorTxHash: string;
786
+ },
425
787
  options?: RequestConfig,
426
788
  ) =>
427
789
  await this.request<Anchor>("POST", "/anchors", {
@@ -434,7 +796,14 @@ export class ApiClient {
434
796
 
435
797
  auditPacks = {
436
798
  create: async (
437
- payload: { batchId: string; pdfHash: string; jsonHash?: string; packVersion: string; pdfUri: string; jsonUri?: string },
799
+ payload: {
800
+ batchId: string;
801
+ pdfHash: string;
802
+ jsonHash?: string;
803
+ packVersion: string;
804
+ pdfUri: string;
805
+ jsonUri?: string;
806
+ },
438
807
  options?: RequestConfig,
439
808
  ) =>
440
809
  await this.request<AuditPack>("POST", "/audit-packs", {
@@ -446,14 +815,20 @@ export class ApiClient {
446
815
  downloadPdf: async (pdfUri: string) => {
447
816
  const response = await fetch(pdfUri);
448
817
  if (!response.ok) {
449
- throw new ApiError(`Failed to download PDF: ${response.status}`, response.status);
818
+ throw new ApiError(
819
+ `Failed to download PDF: ${response.status}`,
820
+ response.status,
821
+ );
450
822
  }
451
823
  return response.arrayBuffer();
452
824
  },
453
825
  downloadJson: async (jsonUri: string) => {
454
826
  const response = await fetch(jsonUri);
455
827
  if (!response.ok) {
456
- throw new ApiError(`Failed to download JSON: ${response.status}`, response.status);
828
+ throw new ApiError(
829
+ `Failed to download JSON: ${response.status}`,
830
+ response.status,
831
+ );
457
832
  }
458
833
  return response.text();
459
834
  },
@@ -461,7 +836,13 @@ export class ApiClient {
461
836
 
462
837
  holograms = {
463
838
  issue: async (
464
- payload: { batchId: string; hologramId: string; metadataHash: string; uri: string; publicCode?: string },
839
+ payload: {
840
+ batchId: string;
841
+ hologramId: string;
842
+ metadataHash: string;
843
+ uri: string;
844
+ publicCode?: string;
845
+ },
465
846
  options?: RequestConfig,
466
847
  ) =>
467
848
  await this.request<Hologram>("POST", "/holograms", {
@@ -470,22 +851,32 @@ export class ApiClient {
470
851
  canRetry: true,
471
852
  idempotencyKey: options?.idempotencyKey,
472
853
  }).then((res) => res.body),
473
- revoke: async (payload: { hologramId: string; reasonHash: string }, options?: RequestConfig) =>
474
- await this.request<{ hologramId: string; active: boolean }>("POST", "/holograms/revoke", {
475
- ...options,
476
- body: payload,
477
- canRetry: true,
478
- idempotencyKey: options?.idempotencyKey,
479
- }).then((res) => res.body),
854
+ revoke: async (
855
+ payload: { hologramId: string; reasonHash: string },
856
+ options?: RequestConfig,
857
+ ) =>
858
+ await this.request<{ hologramId: string; active: boolean }>(
859
+ "POST",
860
+ "/holograms/revoke",
861
+ {
862
+ ...options,
863
+ body: payload,
864
+ canRetry: true,
865
+ idempotencyKey: options?.idempotencyKey,
866
+ },
867
+ ).then((res) => res.body),
480
868
  verify: async (publicCode: string) => {
481
- const response = await this.request<HologramVerification>("GET", `/verify/holograms/${publicCode}`, { canRetry: true });
869
+ const response = await this.request<HologramVerification>(
870
+ "GET",
871
+ `/verify/holograms/${publicCode}`,
872
+ { canRetry: true },
873
+ );
482
874
  if (response.body.status !== "ok") {
483
875
  return null;
484
876
  }
485
877
  return response.body.data ?? null;
486
878
  },
487
879
  };
488
-
489
880
  }
490
881
 
491
882
  export type { BaseClientOptions, RequestConfig };