@otterlabs/blocx 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/dist/index.js ADDED
@@ -0,0 +1,2229 @@
1
+ // src/generated/core/bodySerializer.gen.ts
2
+ var jsonBodySerializer = {
3
+ bodySerializer: (body) => JSON.stringify(
4
+ body,
5
+ (_key, value) => typeof value === "bigint" ? value.toString() : value
6
+ )
7
+ };
8
+
9
+ // src/generated/core/serverSentEvents.gen.ts
10
+ var createSseClient = ({
11
+ onRequest,
12
+ onSseError,
13
+ onSseEvent,
14
+ responseTransformer,
15
+ responseValidator,
16
+ sseDefaultRetryDelay,
17
+ sseMaxRetryAttempts,
18
+ sseMaxRetryDelay,
19
+ sseSleepFn,
20
+ url,
21
+ ...options
22
+ }) => {
23
+ let lastEventId;
24
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
25
+ const createStream = async function* () {
26
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
27
+ let attempt = 0;
28
+ const signal = options.signal ?? new AbortController().signal;
29
+ while (true) {
30
+ if (signal.aborted) break;
31
+ attempt++;
32
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
33
+ if (lastEventId !== void 0) {
34
+ headers.set("Last-Event-ID", lastEventId);
35
+ }
36
+ try {
37
+ const requestInit = {
38
+ redirect: "follow",
39
+ ...options,
40
+ body: options.serializedBody,
41
+ headers,
42
+ signal
43
+ };
44
+ let request = new Request(url, requestInit);
45
+ if (onRequest) {
46
+ request = await onRequest(url, requestInit);
47
+ }
48
+ const _fetch = options.fetch ?? globalThis.fetch;
49
+ const response = await _fetch(request);
50
+ if (!response.ok)
51
+ throw new Error(
52
+ `SSE failed: ${response.status} ${response.statusText}`
53
+ );
54
+ if (!response.body) throw new Error("No body in SSE response");
55
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
56
+ let buffer = "";
57
+ const abortHandler = () => {
58
+ try {
59
+ reader.cancel();
60
+ } catch {
61
+ }
62
+ };
63
+ signal.addEventListener("abort", abortHandler);
64
+ try {
65
+ while (true) {
66
+ const { done, value } = await reader.read();
67
+ if (done) break;
68
+ buffer += value;
69
+ const chunks = buffer.split("\n\n");
70
+ buffer = chunks.pop() ?? "";
71
+ for (const chunk of chunks) {
72
+ const lines = chunk.split("\n");
73
+ const dataLines = [];
74
+ let eventName;
75
+ for (const line of lines) {
76
+ if (line.startsWith("data:")) {
77
+ dataLines.push(line.replace(/^data:\s*/, ""));
78
+ } else if (line.startsWith("event:")) {
79
+ eventName = line.replace(/^event:\s*/, "");
80
+ } else if (line.startsWith("id:")) {
81
+ lastEventId = line.replace(/^id:\s*/, "");
82
+ } else if (line.startsWith("retry:")) {
83
+ const parsed = Number.parseInt(
84
+ line.replace(/^retry:\s*/, ""),
85
+ 10
86
+ );
87
+ if (!Number.isNaN(parsed)) {
88
+ retryDelay = parsed;
89
+ }
90
+ }
91
+ }
92
+ let data;
93
+ let parsedJson = false;
94
+ if (dataLines.length) {
95
+ const rawData = dataLines.join("\n");
96
+ try {
97
+ data = JSON.parse(rawData);
98
+ parsedJson = true;
99
+ } catch {
100
+ data = rawData;
101
+ }
102
+ }
103
+ if (parsedJson) {
104
+ if (responseValidator) {
105
+ await responseValidator(data);
106
+ }
107
+ if (responseTransformer) {
108
+ data = await responseTransformer(data);
109
+ }
110
+ }
111
+ onSseEvent?.({
112
+ data,
113
+ event: eventName,
114
+ id: lastEventId,
115
+ retry: retryDelay
116
+ });
117
+ if (dataLines.length) {
118
+ yield data;
119
+ }
120
+ }
121
+ }
122
+ } finally {
123
+ signal.removeEventListener("abort", abortHandler);
124
+ reader.releaseLock();
125
+ }
126
+ break;
127
+ } catch (error) {
128
+ onSseError?.(error);
129
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
130
+ break;
131
+ }
132
+ const backoff = Math.min(
133
+ retryDelay * 2 ** (attempt - 1),
134
+ sseMaxRetryDelay ?? 3e4
135
+ );
136
+ await sleep(backoff);
137
+ }
138
+ }
139
+ };
140
+ const stream = createStream();
141
+ return { stream };
142
+ };
143
+
144
+ // src/generated/core/pathSerializer.gen.ts
145
+ var separatorArrayExplode = (style) => {
146
+ switch (style) {
147
+ case "label":
148
+ return ".";
149
+ case "matrix":
150
+ return ";";
151
+ case "simple":
152
+ return ",";
153
+ default:
154
+ return "&";
155
+ }
156
+ };
157
+ var separatorArrayNoExplode = (style) => {
158
+ switch (style) {
159
+ case "form":
160
+ return ",";
161
+ case "pipeDelimited":
162
+ return "|";
163
+ case "spaceDelimited":
164
+ return "%20";
165
+ default:
166
+ return ",";
167
+ }
168
+ };
169
+ var separatorObjectExplode = (style) => {
170
+ switch (style) {
171
+ case "label":
172
+ return ".";
173
+ case "matrix":
174
+ return ";";
175
+ case "simple":
176
+ return ",";
177
+ default:
178
+ return "&";
179
+ }
180
+ };
181
+ var serializeArrayParam = ({
182
+ allowReserved,
183
+ explode,
184
+ name,
185
+ style,
186
+ value
187
+ }) => {
188
+ if (!explode) {
189
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
190
+ switch (style) {
191
+ case "label":
192
+ return `.${joinedValues2}`;
193
+ case "matrix":
194
+ return `;${name}=${joinedValues2}`;
195
+ case "simple":
196
+ return joinedValues2;
197
+ default:
198
+ return `${name}=${joinedValues2}`;
199
+ }
200
+ }
201
+ const separator = separatorArrayExplode(style);
202
+ const joinedValues = value.map((v) => {
203
+ if (style === "label" || style === "simple") {
204
+ return allowReserved ? v : encodeURIComponent(v);
205
+ }
206
+ return serializePrimitiveParam({
207
+ allowReserved,
208
+ name,
209
+ value: v
210
+ });
211
+ }).join(separator);
212
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
213
+ };
214
+ var serializePrimitiveParam = ({
215
+ allowReserved,
216
+ name,
217
+ value
218
+ }) => {
219
+ if (value === void 0 || value === null) {
220
+ return "";
221
+ }
222
+ if (typeof value === "object") {
223
+ throw new Error(
224
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
225
+ );
226
+ }
227
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
228
+ };
229
+ var serializeObjectParam = ({
230
+ allowReserved,
231
+ explode,
232
+ name,
233
+ style,
234
+ value,
235
+ valueOnly
236
+ }) => {
237
+ if (value instanceof Date) {
238
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
239
+ }
240
+ if (style !== "deepObject" && !explode) {
241
+ let values = [];
242
+ Object.entries(value).forEach(([key, v]) => {
243
+ values = [
244
+ ...values,
245
+ key,
246
+ allowReserved ? v : encodeURIComponent(v)
247
+ ];
248
+ });
249
+ const joinedValues2 = values.join(",");
250
+ switch (style) {
251
+ case "form":
252
+ return `${name}=${joinedValues2}`;
253
+ case "label":
254
+ return `.${joinedValues2}`;
255
+ case "matrix":
256
+ return `;${name}=${joinedValues2}`;
257
+ default:
258
+ return joinedValues2;
259
+ }
260
+ }
261
+ const separator = separatorObjectExplode(style);
262
+ const joinedValues = Object.entries(value).map(
263
+ ([key, v]) => serializePrimitiveParam({
264
+ allowReserved,
265
+ name: style === "deepObject" ? `${name}[${key}]` : key,
266
+ value: v
267
+ })
268
+ ).join(separator);
269
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
270
+ };
271
+
272
+ // src/generated/core/utils.gen.ts
273
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
274
+ var defaultPathSerializer = ({ path, url: _url }) => {
275
+ let url = _url;
276
+ const matches = _url.match(PATH_PARAM_RE);
277
+ if (matches) {
278
+ for (const match of matches) {
279
+ let explode = false;
280
+ let name = match.substring(1, match.length - 1);
281
+ let style = "simple";
282
+ if (name.endsWith("*")) {
283
+ explode = true;
284
+ name = name.substring(0, name.length - 1);
285
+ }
286
+ if (name.startsWith(".")) {
287
+ name = name.substring(1);
288
+ style = "label";
289
+ } else if (name.startsWith(";")) {
290
+ name = name.substring(1);
291
+ style = "matrix";
292
+ }
293
+ const value = path[name];
294
+ if (value === void 0 || value === null) {
295
+ continue;
296
+ }
297
+ if (Array.isArray(value)) {
298
+ url = url.replace(
299
+ match,
300
+ serializeArrayParam({ explode, name, style, value })
301
+ );
302
+ continue;
303
+ }
304
+ if (typeof value === "object") {
305
+ url = url.replace(
306
+ match,
307
+ serializeObjectParam({
308
+ explode,
309
+ name,
310
+ style,
311
+ value,
312
+ valueOnly: true
313
+ })
314
+ );
315
+ continue;
316
+ }
317
+ if (style === "matrix") {
318
+ url = url.replace(
319
+ match,
320
+ `;${serializePrimitiveParam({
321
+ name,
322
+ value
323
+ })}`
324
+ );
325
+ continue;
326
+ }
327
+ const replaceValue = encodeURIComponent(
328
+ style === "label" ? `.${value}` : value
329
+ );
330
+ url = url.replace(match, replaceValue);
331
+ }
332
+ }
333
+ return url;
334
+ };
335
+ var getUrl = ({
336
+ baseUrl,
337
+ path,
338
+ query,
339
+ querySerializer,
340
+ url: _url
341
+ }) => {
342
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
343
+ let url = (baseUrl ?? "") + pathUrl;
344
+ if (path) {
345
+ url = defaultPathSerializer({ path, url });
346
+ }
347
+ let search = query ? querySerializer(query) : "";
348
+ if (search.startsWith("?")) {
349
+ search = search.substring(1);
350
+ }
351
+ if (search) {
352
+ url += `?${search}`;
353
+ }
354
+ return url;
355
+ };
356
+ function getValidRequestBody(options) {
357
+ const hasBody = options.body !== void 0;
358
+ const isSerializedBody = hasBody && options.bodySerializer;
359
+ if (isSerializedBody) {
360
+ if ("serializedBody" in options) {
361
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
362
+ return hasSerializedBody ? options.serializedBody : null;
363
+ }
364
+ return options.body !== "" ? options.body : null;
365
+ }
366
+ if (hasBody) {
367
+ return options.body;
368
+ }
369
+ return void 0;
370
+ }
371
+
372
+ // src/generated/core/auth.gen.ts
373
+ var getAuthToken = async (auth, callback) => {
374
+ const token = typeof callback === "function" ? await callback(auth) : callback;
375
+ if (!token) {
376
+ return;
377
+ }
378
+ if (auth.scheme === "bearer") {
379
+ return `Bearer ${token}`;
380
+ }
381
+ if (auth.scheme === "basic") {
382
+ return `Basic ${btoa(token)}`;
383
+ }
384
+ return token;
385
+ };
386
+
387
+ // src/generated/client/utils.gen.ts
388
+ var createQuerySerializer = ({
389
+ allowReserved,
390
+ array,
391
+ object
392
+ } = {}) => {
393
+ const querySerializer = (queryParams) => {
394
+ const search = [];
395
+ if (queryParams && typeof queryParams === "object") {
396
+ for (const name in queryParams) {
397
+ const value = queryParams[name];
398
+ if (value === void 0 || value === null) {
399
+ continue;
400
+ }
401
+ if (Array.isArray(value)) {
402
+ const serializedArray = serializeArrayParam({
403
+ allowReserved,
404
+ explode: true,
405
+ name,
406
+ style: "form",
407
+ value,
408
+ ...array
409
+ });
410
+ if (serializedArray) search.push(serializedArray);
411
+ } else if (typeof value === "object") {
412
+ const serializedObject = serializeObjectParam({
413
+ allowReserved,
414
+ explode: true,
415
+ name,
416
+ style: "deepObject",
417
+ value,
418
+ ...object
419
+ });
420
+ if (serializedObject) search.push(serializedObject);
421
+ } else {
422
+ const serializedPrimitive = serializePrimitiveParam({
423
+ allowReserved,
424
+ name,
425
+ value
426
+ });
427
+ if (serializedPrimitive) search.push(serializedPrimitive);
428
+ }
429
+ }
430
+ }
431
+ return search.join("&");
432
+ };
433
+ return querySerializer;
434
+ };
435
+ var getParseAs = (contentType) => {
436
+ if (!contentType) {
437
+ return "stream";
438
+ }
439
+ const cleanContent = contentType.split(";")[0]?.trim();
440
+ if (!cleanContent) {
441
+ return;
442
+ }
443
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
444
+ return "json";
445
+ }
446
+ if (cleanContent === "multipart/form-data") {
447
+ return "formData";
448
+ }
449
+ if (["application/", "audio/", "image/", "video/"].some(
450
+ (type) => cleanContent.startsWith(type)
451
+ )) {
452
+ return "blob";
453
+ }
454
+ if (cleanContent.startsWith("text/")) {
455
+ return "text";
456
+ }
457
+ return;
458
+ };
459
+ var checkForExistence = (options, name) => {
460
+ if (!name) {
461
+ return false;
462
+ }
463
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
464
+ return true;
465
+ }
466
+ return false;
467
+ };
468
+ var setAuthParams = async ({
469
+ security,
470
+ ...options
471
+ }) => {
472
+ for (const auth of security) {
473
+ if (checkForExistence(options, auth.name)) {
474
+ continue;
475
+ }
476
+ const token = await getAuthToken(auth, options.auth);
477
+ if (!token) {
478
+ continue;
479
+ }
480
+ const name = auth.name ?? "Authorization";
481
+ switch (auth.in) {
482
+ case "query":
483
+ if (!options.query) {
484
+ options.query = {};
485
+ }
486
+ options.query[name] = token;
487
+ break;
488
+ case "cookie":
489
+ options.headers.append("Cookie", `${name}=${token}`);
490
+ break;
491
+ case "header":
492
+ default:
493
+ options.headers.set(name, token);
494
+ break;
495
+ }
496
+ }
497
+ };
498
+ var buildUrl = (options) => getUrl({
499
+ baseUrl: options.baseUrl,
500
+ path: options.path,
501
+ query: options.query,
502
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
503
+ url: options.url
504
+ });
505
+ var mergeConfigs = (a, b) => {
506
+ const config = { ...a, ...b };
507
+ if (config.baseUrl?.endsWith("/")) {
508
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
509
+ }
510
+ config.headers = mergeHeaders(a.headers, b.headers);
511
+ return config;
512
+ };
513
+ var headersEntries = (headers) => {
514
+ const entries = [];
515
+ headers.forEach((value, key) => {
516
+ entries.push([key, value]);
517
+ });
518
+ return entries;
519
+ };
520
+ var mergeHeaders = (...headers) => {
521
+ const mergedHeaders = new Headers();
522
+ for (const header of headers) {
523
+ if (!header) {
524
+ continue;
525
+ }
526
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
527
+ for (const [key, value] of iterator) {
528
+ if (value === null) {
529
+ mergedHeaders.delete(key);
530
+ } else if (Array.isArray(value)) {
531
+ for (const v of value) {
532
+ mergedHeaders.append(key, v);
533
+ }
534
+ } else if (value !== void 0) {
535
+ mergedHeaders.set(
536
+ key,
537
+ typeof value === "object" ? JSON.stringify(value) : value
538
+ );
539
+ }
540
+ }
541
+ }
542
+ return mergedHeaders;
543
+ };
544
+ var Interceptors = class {
545
+ fns = [];
546
+ clear() {
547
+ this.fns = [];
548
+ }
549
+ eject(id) {
550
+ const index = this.getInterceptorIndex(id);
551
+ if (this.fns[index]) {
552
+ this.fns[index] = null;
553
+ }
554
+ }
555
+ exists(id) {
556
+ const index = this.getInterceptorIndex(id);
557
+ return Boolean(this.fns[index]);
558
+ }
559
+ getInterceptorIndex(id) {
560
+ if (typeof id === "number") {
561
+ return this.fns[id] ? id : -1;
562
+ }
563
+ return this.fns.indexOf(id);
564
+ }
565
+ update(id, fn) {
566
+ const index = this.getInterceptorIndex(id);
567
+ if (this.fns[index]) {
568
+ this.fns[index] = fn;
569
+ return id;
570
+ }
571
+ return false;
572
+ }
573
+ use(fn) {
574
+ this.fns.push(fn);
575
+ return this.fns.length - 1;
576
+ }
577
+ };
578
+ var createInterceptors = () => ({
579
+ error: new Interceptors(),
580
+ request: new Interceptors(),
581
+ response: new Interceptors()
582
+ });
583
+ var defaultQuerySerializer = createQuerySerializer({
584
+ allowReserved: false,
585
+ array: {
586
+ explode: true,
587
+ style: "form"
588
+ },
589
+ object: {
590
+ explode: true,
591
+ style: "deepObject"
592
+ }
593
+ });
594
+ var defaultHeaders = {
595
+ "Content-Type": "application/json"
596
+ };
597
+ var createConfig = (override = {}) => ({
598
+ ...jsonBodySerializer,
599
+ headers: defaultHeaders,
600
+ parseAs: "auto",
601
+ querySerializer: defaultQuerySerializer,
602
+ ...override
603
+ });
604
+
605
+ // src/generated/client/client.gen.ts
606
+ var createClient = (config = {}) => {
607
+ let _config = mergeConfigs(createConfig(), config);
608
+ const getConfig = () => ({ ..._config });
609
+ const setConfig = (config2) => {
610
+ _config = mergeConfigs(_config, config2);
611
+ return getConfig();
612
+ };
613
+ const interceptors = createInterceptors();
614
+ const beforeRequest = async (options) => {
615
+ const opts = {
616
+ ..._config,
617
+ ...options,
618
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
619
+ headers: mergeHeaders(_config.headers, options.headers),
620
+ serializedBody: void 0
621
+ };
622
+ if (opts.security) {
623
+ await setAuthParams({
624
+ ...opts,
625
+ security: opts.security
626
+ });
627
+ }
628
+ if (opts.requestValidator) {
629
+ await opts.requestValidator(opts);
630
+ }
631
+ if (opts.body !== void 0 && opts.bodySerializer) {
632
+ opts.serializedBody = opts.bodySerializer(opts.body);
633
+ }
634
+ if (opts.body === void 0 || opts.serializedBody === "") {
635
+ opts.headers.delete("Content-Type");
636
+ }
637
+ const url = buildUrl(opts);
638
+ return { opts, url };
639
+ };
640
+ const request = async (options) => {
641
+ const { opts, url } = await beforeRequest(options);
642
+ const requestInit = {
643
+ redirect: "follow",
644
+ ...opts,
645
+ body: getValidRequestBody(opts)
646
+ };
647
+ let request2 = new Request(url, requestInit);
648
+ for (const fn of interceptors.request.fns) {
649
+ if (fn) {
650
+ request2 = await fn(request2, opts);
651
+ }
652
+ }
653
+ const _fetch = opts.fetch;
654
+ let response = await _fetch(request2);
655
+ for (const fn of interceptors.response.fns) {
656
+ if (fn) {
657
+ response = await fn(response, request2, opts);
658
+ }
659
+ }
660
+ const result = {
661
+ request: request2,
662
+ response
663
+ };
664
+ if (response.ok) {
665
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
666
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
667
+ let emptyData;
668
+ switch (parseAs) {
669
+ case "arrayBuffer":
670
+ case "blob":
671
+ case "text":
672
+ emptyData = await response[parseAs]();
673
+ break;
674
+ case "formData":
675
+ emptyData = new FormData();
676
+ break;
677
+ case "stream":
678
+ emptyData = response.body;
679
+ break;
680
+ case "json":
681
+ default:
682
+ emptyData = {};
683
+ break;
684
+ }
685
+ return opts.responseStyle === "data" ? emptyData : {
686
+ data: emptyData,
687
+ ...result
688
+ };
689
+ }
690
+ let data;
691
+ switch (parseAs) {
692
+ case "arrayBuffer":
693
+ case "blob":
694
+ case "formData":
695
+ case "json":
696
+ case "text":
697
+ data = await response[parseAs]();
698
+ break;
699
+ case "stream":
700
+ return opts.responseStyle === "data" ? response.body : {
701
+ data: response.body,
702
+ ...result
703
+ };
704
+ }
705
+ if (parseAs === "json") {
706
+ if (opts.responseValidator) {
707
+ await opts.responseValidator(data);
708
+ }
709
+ if (opts.responseTransformer) {
710
+ data = await opts.responseTransformer(data);
711
+ }
712
+ }
713
+ return opts.responseStyle === "data" ? data : {
714
+ data,
715
+ ...result
716
+ };
717
+ }
718
+ const textError = await response.text();
719
+ let jsonError;
720
+ try {
721
+ jsonError = JSON.parse(textError);
722
+ } catch {
723
+ }
724
+ const error = jsonError ?? textError;
725
+ let finalError = error;
726
+ for (const fn of interceptors.error.fns) {
727
+ if (fn) {
728
+ finalError = await fn(error, response, request2, opts);
729
+ }
730
+ }
731
+ finalError = finalError || {};
732
+ if (opts.throwOnError) {
733
+ throw finalError;
734
+ }
735
+ return opts.responseStyle === "data" ? void 0 : {
736
+ error: finalError,
737
+ ...result
738
+ };
739
+ };
740
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
741
+ const makeSseFn = (method) => async (options) => {
742
+ const { opts, url } = await beforeRequest(options);
743
+ return createSseClient({
744
+ ...opts,
745
+ body: opts.body,
746
+ headers: opts.headers,
747
+ method,
748
+ onRequest: async (url2, init) => {
749
+ let request2 = new Request(url2, init);
750
+ for (const fn of interceptors.request.fns) {
751
+ if (fn) {
752
+ request2 = await fn(request2, opts);
753
+ }
754
+ }
755
+ return request2;
756
+ },
757
+ url
758
+ });
759
+ };
760
+ return {
761
+ buildUrl,
762
+ connect: makeMethodFn("CONNECT"),
763
+ delete: makeMethodFn("DELETE"),
764
+ get: makeMethodFn("GET"),
765
+ getConfig,
766
+ head: makeMethodFn("HEAD"),
767
+ interceptors,
768
+ options: makeMethodFn("OPTIONS"),
769
+ patch: makeMethodFn("PATCH"),
770
+ post: makeMethodFn("POST"),
771
+ put: makeMethodFn("PUT"),
772
+ request,
773
+ setConfig,
774
+ sse: {
775
+ connect: makeSseFn("CONNECT"),
776
+ delete: makeSseFn("DELETE"),
777
+ get: makeSseFn("GET"),
778
+ head: makeSseFn("HEAD"),
779
+ options: makeSseFn("OPTIONS"),
780
+ patch: makeSseFn("PATCH"),
781
+ post: makeSseFn("POST"),
782
+ put: makeSseFn("PUT"),
783
+ trace: makeSseFn("TRACE")
784
+ },
785
+ trace: makeMethodFn("TRACE")
786
+ };
787
+ };
788
+
789
+ // src/generated/client.gen.ts
790
+ var client = createClient(createConfig());
791
+
792
+ // src/generated/sdk.gen.ts
793
+ var Brands = class {
794
+ /**
795
+ * List brands
796
+ *
797
+ * List all registered 10DLC brands.
798
+ *
799
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
800
+ */
801
+ static listBrands(options) {
802
+ return (options?.client ?? client).get({
803
+ security: [
804
+ {
805
+ name: "x-access-key-id",
806
+ type: "apiKey"
807
+ },
808
+ {
809
+ name: "x-secret-access-key",
810
+ type: "apiKey"
811
+ }
812
+ ],
813
+ url: "/brands",
814
+ ...options
815
+ });
816
+ }
817
+ /**
818
+ * Register brand
819
+ *
820
+ * Register a 10DLC brand. Created as `PENDING_REGISTRATION`, processed async. $4.50 fee charged on completion.
821
+ *
822
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
823
+ */
824
+ static createBrand(options) {
825
+ return (options?.client ?? client).post({
826
+ security: [
827
+ {
828
+ name: "x-access-key-id",
829
+ type: "apiKey"
830
+ },
831
+ {
832
+ name: "x-secret-access-key",
833
+ type: "apiKey"
834
+ }
835
+ ],
836
+ url: "/brands",
837
+ ...options,
838
+ headers: {
839
+ "Content-Type": "application/json",
840
+ ...options?.headers
841
+ }
842
+ });
843
+ }
844
+ /**
845
+ * Get brand
846
+ *
847
+ * Get brand details including campaigns.
848
+ *
849
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
850
+ */
851
+ static getBrand(options) {
852
+ return (options?.client ?? client).get({
853
+ security: [
854
+ {
855
+ name: "x-access-key-id",
856
+ type: "apiKey"
857
+ },
858
+ {
859
+ name: "x-secret-access-key",
860
+ type: "apiKey"
861
+ }
862
+ ],
863
+ url: "/brands/{id}",
864
+ ...options
865
+ });
866
+ }
867
+ /**
868
+ * Get brand feedback
869
+ *
870
+ * Get TCR identity feedback (reasons for UNVERIFIED).
871
+ *
872
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
873
+ */
874
+ static getBrandFeedback(options) {
875
+ return (options?.client ?? client).get({
876
+ security: [
877
+ {
878
+ name: "x-access-key-id",
879
+ type: "apiKey"
880
+ },
881
+ {
882
+ name: "x-secret-access-key",
883
+ type: "apiKey"
884
+ }
885
+ ],
886
+ url: "/brands/{id}/feedback",
887
+ ...options
888
+ });
889
+ }
890
+ };
891
+ var Campaigns = class {
892
+ /**
893
+ * List campaigns
894
+ *
895
+ * List all 10DLC campaigns.
896
+ *
897
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
898
+ */
899
+ static listCampaigns(options) {
900
+ return (options?.client ?? client).get({
901
+ security: [
902
+ {
903
+ name: "x-access-key-id",
904
+ type: "apiKey"
905
+ },
906
+ {
907
+ name: "x-secret-access-key",
908
+ type: "apiKey"
909
+ }
910
+ ],
911
+ url: "/campaigns",
912
+ ...options
913
+ });
914
+ }
915
+ /**
916
+ * Create campaign
917
+ *
918
+ * Register a 10DLC campaign. Created as `PENDING_REGISTRATION`, processed async. Fee varies by use case.
919
+ *
920
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
921
+ */
922
+ static createCampaign(options) {
923
+ return (options?.client ?? client).post({
924
+ security: [
925
+ {
926
+ name: "x-access-key-id",
927
+ type: "apiKey"
928
+ },
929
+ {
930
+ name: "x-secret-access-key",
931
+ type: "apiKey"
932
+ }
933
+ ],
934
+ url: "/campaigns",
935
+ ...options,
936
+ headers: {
937
+ "Content-Type": "application/json",
938
+ ...options?.headers
939
+ }
940
+ });
941
+ }
942
+ /**
943
+ * Get campaign
944
+ *
945
+ * Get campaign details.
946
+ *
947
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
948
+ */
949
+ static getCampaign(options) {
950
+ return (options?.client ?? client).get({
951
+ security: [
952
+ {
953
+ name: "x-access-key-id",
954
+ type: "apiKey"
955
+ },
956
+ {
957
+ name: "x-secret-access-key",
958
+ type: "apiKey"
959
+ }
960
+ ],
961
+ url: "/campaigns/{id}",
962
+ ...options
963
+ });
964
+ }
965
+ /**
966
+ * Get qualified use cases
967
+ *
968
+ * Get use cases a brand qualifies for.
969
+ *
970
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
971
+ */
972
+ static getQualifiedUseCases(options) {
973
+ return (options?.client ?? client).get({
974
+ security: [
975
+ {
976
+ name: "x-access-key-id",
977
+ type: "apiKey"
978
+ },
979
+ {
980
+ name: "x-secret-access-key",
981
+ type: "apiKey"
982
+ }
983
+ ],
984
+ url: "/campaigns/usecases/{brandId}",
985
+ ...options
986
+ });
987
+ }
988
+ /**
989
+ * Share campaign
990
+ *
991
+ * Share with upstream CNP/DCA.
992
+ *
993
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
994
+ */
995
+ static shareCampaign(options) {
996
+ return (options?.client ?? client).post({
997
+ security: [
998
+ {
999
+ name: "x-access-key-id",
1000
+ type: "apiKey"
1001
+ },
1002
+ {
1003
+ name: "x-secret-access-key",
1004
+ type: "apiKey"
1005
+ }
1006
+ ],
1007
+ url: "/campaigns/{id}/share",
1008
+ ...options,
1009
+ headers: {
1010
+ "Content-Type": "application/json",
1011
+ ...options?.headers
1012
+ }
1013
+ });
1014
+ }
1015
+ /**
1016
+ * Get sharing status
1017
+ *
1018
+ * Get campaign sharing status with upstream CNPs.
1019
+ *
1020
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1021
+ */
1022
+ static getCampaignSharing(options) {
1023
+ return (options?.client ?? client).get({
1024
+ security: [
1025
+ {
1026
+ name: "x-access-key-id",
1027
+ type: "apiKey"
1028
+ },
1029
+ {
1030
+ name: "x-secret-access-key",
1031
+ type: "apiKey"
1032
+ }
1033
+ ],
1034
+ url: "/campaigns/{id}/sharing",
1035
+ ...options
1036
+ });
1037
+ }
1038
+ /**
1039
+ * Get MNO status
1040
+ *
1041
+ * Get per-carrier approval status.
1042
+ *
1043
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1044
+ */
1045
+ static getCampaignMnoStatus(options) {
1046
+ return (options?.client ?? client).get({
1047
+ security: [
1048
+ {
1049
+ name: "x-access-key-id",
1050
+ type: "apiKey"
1051
+ },
1052
+ {
1053
+ name: "x-secret-access-key",
1054
+ type: "apiKey"
1055
+ }
1056
+ ],
1057
+ url: "/campaigns/{id}/operation-status",
1058
+ ...options
1059
+ });
1060
+ }
1061
+ };
1062
+ var Compliance = class {
1063
+ /**
1064
+ * List compliance events
1065
+ *
1066
+ * List compliance events. Created automatically on brand/campaign status changes.
1067
+ *
1068
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1069
+ */
1070
+ static listComplianceEvents(options) {
1071
+ return (options?.client ?? client).get({
1072
+ security: [
1073
+ {
1074
+ name: "x-access-key-id",
1075
+ type: "apiKey"
1076
+ },
1077
+ {
1078
+ name: "x-secret-access-key",
1079
+ type: "apiKey"
1080
+ }
1081
+ ],
1082
+ url: "/compliance",
1083
+ ...options
1084
+ });
1085
+ }
1086
+ /**
1087
+ * Get compliance event
1088
+ *
1089
+ * Get event with messages and comments. Auto-marks as read.
1090
+ *
1091
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1092
+ */
1093
+ static getComplianceEvent(options) {
1094
+ return (options?.client ?? client).get({
1095
+ security: [
1096
+ {
1097
+ name: "x-access-key-id",
1098
+ type: "apiKey"
1099
+ },
1100
+ {
1101
+ name: "x-secret-access-key",
1102
+ type: "apiKey"
1103
+ }
1104
+ ],
1105
+ url: "/compliance/{id}",
1106
+ ...options
1107
+ });
1108
+ }
1109
+ };
1110
+ var Email = class {
1111
+ /**
1112
+ * Get email status
1113
+ *
1114
+ * Check if email is enabled.
1115
+ */
1116
+ static getEmailStatus(options) {
1117
+ return (options?.client ?? client).get({
1118
+ security: [
1119
+ {
1120
+ name: "x-access-key-id",
1121
+ type: "apiKey"
1122
+ },
1123
+ {
1124
+ name: "x-secret-access-key",
1125
+ type: "apiKey"
1126
+ }
1127
+ ],
1128
+ url: "/email/status",
1129
+ ...options
1130
+ });
1131
+ }
1132
+ /**
1133
+ * Enable email
1134
+ *
1135
+ * Enable email sending. Async — poll `GET /email/status` until `enabled` is `true`.
1136
+ */
1137
+ static enableEmail(options) {
1138
+ return (options?.client ?? client).post({
1139
+ security: [
1140
+ {
1141
+ name: "x-access-key-id",
1142
+ type: "apiKey"
1143
+ },
1144
+ {
1145
+ name: "x-secret-access-key",
1146
+ type: "apiKey"
1147
+ }
1148
+ ],
1149
+ url: "/email/enable",
1150
+ ...options
1151
+ });
1152
+ }
1153
+ /**
1154
+ * List identities
1155
+ *
1156
+ * List email domain identities.
1157
+ */
1158
+ static listEmailIdentities(options) {
1159
+ return (options?.client ?? client).get({
1160
+ security: [
1161
+ {
1162
+ name: "x-access-key-id",
1163
+ type: "apiKey"
1164
+ },
1165
+ {
1166
+ name: "x-secret-access-key",
1167
+ type: "apiKey"
1168
+ }
1169
+ ],
1170
+ url: "/email/identities",
1171
+ ...options
1172
+ });
1173
+ }
1174
+ /**
1175
+ * Add domain
1176
+ *
1177
+ * Add a sending domain. DNS records appear once processing completes.
1178
+ *
1179
+ * **Plan**: Adding a second (or further) verified domain requires the `multiple_email_domains` capability — included in the **Email** and **All Services** plans.
1180
+ */
1181
+ static createEmailIdentity(options) {
1182
+ return (options?.client ?? client).post({
1183
+ security: [
1184
+ {
1185
+ name: "x-access-key-id",
1186
+ type: "apiKey"
1187
+ },
1188
+ {
1189
+ name: "x-secret-access-key",
1190
+ type: "apiKey"
1191
+ }
1192
+ ],
1193
+ url: "/email/identities",
1194
+ ...options,
1195
+ headers: {
1196
+ "Content-Type": "application/json",
1197
+ ...options?.headers
1198
+ }
1199
+ });
1200
+ }
1201
+ /**
1202
+ * Delete identity
1203
+ *
1204
+ * Remove a domain identity.
1205
+ */
1206
+ static deleteEmailIdentity(options) {
1207
+ return (options?.client ?? client).delete({
1208
+ security: [
1209
+ {
1210
+ name: "x-access-key-id",
1211
+ type: "apiKey"
1212
+ },
1213
+ {
1214
+ name: "x-secret-access-key",
1215
+ type: "apiKey"
1216
+ }
1217
+ ],
1218
+ url: "/email/identities/{id}",
1219
+ ...options
1220
+ });
1221
+ }
1222
+ /**
1223
+ * Get identity
1224
+ *
1225
+ * Get identity with DNS records.
1226
+ */
1227
+ static getEmailIdentity(options) {
1228
+ return (options?.client ?? client).get({
1229
+ security: [
1230
+ {
1231
+ name: "x-access-key-id",
1232
+ type: "apiKey"
1233
+ },
1234
+ {
1235
+ name: "x-secret-access-key",
1236
+ type: "apiKey"
1237
+ }
1238
+ ],
1239
+ url: "/email/identities/{id}",
1240
+ ...options
1241
+ });
1242
+ }
1243
+ /**
1244
+ * Verify DNS
1245
+ *
1246
+ * Trigger DNS verification check.
1247
+ */
1248
+ static verifyEmailIdentityDns(options) {
1249
+ return (options?.client ?? client).post({
1250
+ security: [
1251
+ {
1252
+ name: "x-access-key-id",
1253
+ type: "apiKey"
1254
+ },
1255
+ {
1256
+ name: "x-secret-access-key",
1257
+ type: "apiKey"
1258
+ }
1259
+ ],
1260
+ url: "/email/identities/{id}/check-dns",
1261
+ ...options
1262
+ });
1263
+ }
1264
+ /**
1265
+ * Send test email
1266
+ *
1267
+ * Send a test email from a verified domain.
1268
+ */
1269
+ static sendEmailIdentityTest(options) {
1270
+ return (options?.client ?? client).post({
1271
+ security: [
1272
+ {
1273
+ name: "x-access-key-id",
1274
+ type: "apiKey"
1275
+ },
1276
+ {
1277
+ name: "x-secret-access-key",
1278
+ type: "apiKey"
1279
+ }
1280
+ ],
1281
+ url: "/email/identities/{id}/send-test",
1282
+ ...options,
1283
+ headers: {
1284
+ "Content-Type": "application/json",
1285
+ ...options?.headers
1286
+ }
1287
+ });
1288
+ }
1289
+ /**
1290
+ * Get sent emails
1291
+ *
1292
+ * Sent email history, newest first. Cursor-paginated.
1293
+ */
1294
+ static getEmailHistory(options) {
1295
+ return (options?.client ?? client).get({
1296
+ security: [
1297
+ {
1298
+ name: "x-access-key-id",
1299
+ type: "apiKey"
1300
+ },
1301
+ {
1302
+ name: "x-secret-access-key",
1303
+ type: "apiKey"
1304
+ }
1305
+ ],
1306
+ url: "/email/history",
1307
+ ...options
1308
+ });
1309
+ }
1310
+ /**
1311
+ * Send email
1312
+ *
1313
+ * Send an email. The `from` domain must be verified. Rate limit headers are included: `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`.
1314
+ */
1315
+ static sendEmail(options) {
1316
+ return (options?.client ?? client).post({
1317
+ security: [
1318
+ {
1319
+ name: "x-access-key-id",
1320
+ type: "apiKey"
1321
+ },
1322
+ {
1323
+ name: "x-secret-access-key",
1324
+ type: "apiKey"
1325
+ }
1326
+ ],
1327
+ url: "/email/send",
1328
+ ...options,
1329
+ headers: {
1330
+ "Content-Type": "application/json",
1331
+ ...options?.headers
1332
+ }
1333
+ });
1334
+ }
1335
+ };
1336
+ var Balance = class {
1337
+ /**
1338
+ * Get balance
1339
+ *
1340
+ * Current balance in microdollars (1 dollar = 1,000,000).
1341
+ */
1342
+ static getBalance(options) {
1343
+ return (options?.client ?? client).get({
1344
+ security: [
1345
+ {
1346
+ name: "x-access-key-id",
1347
+ type: "apiKey"
1348
+ },
1349
+ {
1350
+ name: "x-secret-access-key",
1351
+ type: "apiKey"
1352
+ }
1353
+ ],
1354
+ url: "/balance",
1355
+ ...options
1356
+ });
1357
+ }
1358
+ /**
1359
+ * Get history
1360
+ *
1361
+ * Paginated transaction history.
1362
+ */
1363
+ static getBalanceHistory(options) {
1364
+ return (options?.client ?? client).get({
1365
+ security: [
1366
+ {
1367
+ name: "x-access-key-id",
1368
+ type: "apiKey"
1369
+ },
1370
+ {
1371
+ name: "x-secret-access-key",
1372
+ type: "apiKey"
1373
+ }
1374
+ ],
1375
+ url: "/balance/history",
1376
+ ...options
1377
+ });
1378
+ }
1379
+ /**
1380
+ * Get usage
1381
+ *
1382
+ * Current month debit summary.
1383
+ */
1384
+ static getBalanceUsage(options) {
1385
+ return (options?.client ?? client).get({
1386
+ security: [
1387
+ {
1388
+ name: "x-access-key-id",
1389
+ type: "apiKey"
1390
+ },
1391
+ {
1392
+ name: "x-secret-access-key",
1393
+ type: "apiKey"
1394
+ }
1395
+ ],
1396
+ url: "/balance/usage",
1397
+ ...options
1398
+ });
1399
+ }
1400
+ };
1401
+ var Messaging = class {
1402
+ /**
1403
+ * Send message
1404
+ *
1405
+ * Send an SMS or MMS. Rate limit headers are included: `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`.
1406
+ *
1407
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1408
+ */
1409
+ static sendMessage(options) {
1410
+ return (options?.client ?? client).post({
1411
+ security: [
1412
+ {
1413
+ name: "x-access-key-id",
1414
+ type: "apiKey"
1415
+ },
1416
+ {
1417
+ name: "x-secret-access-key",
1418
+ type: "apiKey"
1419
+ }
1420
+ ],
1421
+ url: "/messaging/send",
1422
+ ...options,
1423
+ headers: {
1424
+ "Content-Type": "application/json",
1425
+ ...options?.headers
1426
+ }
1427
+ });
1428
+ }
1429
+ };
1430
+ var FaVerifications = class {
1431
+ /**
1432
+ * Send verification code
1433
+ *
1434
+ * Send a 6-digit verification code via email or SMS. Rate limit headers are included: `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`.
1435
+ *
1436
+ * Requires permission: `twofa.create`.
1437
+ *
1438
+ * **Plan**: Requires the `twofa` capability — included in the **All Services** plan.
1439
+ *
1440
+ * **Rate limits**: 60/min per account, 1/min per recipient, 5/hour per tenant+recipient.
1441
+ *
1442
+ * **Note**: This endpoint is served by the 2FA service, not the main API. Base URL differs in production.
1443
+ */
1444
+ static createVerification(options) {
1445
+ return (options?.client ?? client).post({
1446
+ security: [
1447
+ {
1448
+ name: "x-access-key-id",
1449
+ type: "apiKey"
1450
+ },
1451
+ {
1452
+ name: "x-secret-access-key",
1453
+ type: "apiKey"
1454
+ }
1455
+ ],
1456
+ url: "/twofa/verifications",
1457
+ ...options,
1458
+ headers: {
1459
+ "Content-Type": "application/json",
1460
+ ...options?.headers
1461
+ }
1462
+ });
1463
+ }
1464
+ /**
1465
+ * Check verification code
1466
+ *
1467
+ * Verify a submitted code. Returns the verification status.
1468
+ *
1469
+ * Requires permission: `twofa.check`.
1470
+ *
1471
+ * **Plan**: Requires the `twofa` capability — included in the **All Services** plan.
1472
+ *
1473
+ * After 5 wrong attempts the verification is permanently `failed`. Codes expire after 10 minutes.
1474
+ *
1475
+ * **Terminal statuses** (`approved`, `failed`, `expired`) reject further checks.
1476
+ */
1477
+ static checkVerification(options) {
1478
+ return (options.client ?? client).post({
1479
+ security: [
1480
+ {
1481
+ name: "x-access-key-id",
1482
+ type: "apiKey"
1483
+ },
1484
+ {
1485
+ name: "x-secret-access-key",
1486
+ type: "apiKey"
1487
+ }
1488
+ ],
1489
+ url: "/twofa/verifications/{id}/check",
1490
+ ...options,
1491
+ headers: {
1492
+ "Content-Type": "application/json",
1493
+ ...options.headers
1494
+ }
1495
+ });
1496
+ }
1497
+ };
1498
+ var FaTemplates = class {
1499
+ /**
1500
+ * List templates
1501
+ *
1502
+ * List all 2FA templates (email and SMS) for the account.
1503
+ *
1504
+ * Requires permission: `twofa_templates.read`.
1505
+ *
1506
+ * **Plan**: Requires the `twofa` capability — included in the **All Services** plan.
1507
+ */
1508
+ static listTwofaTemplates(options) {
1509
+ return (options?.client ?? client).get({
1510
+ security: [
1511
+ {
1512
+ name: "x-access-key-id",
1513
+ type: "apiKey"
1514
+ },
1515
+ {
1516
+ name: "x-secret-access-key",
1517
+ type: "apiKey"
1518
+ }
1519
+ ],
1520
+ url: "/twofa/templates",
1521
+ ...options
1522
+ });
1523
+ }
1524
+ /**
1525
+ * Create template
1526
+ *
1527
+ * Create a new 2FA template. Set `channel` to `EMAIL` (with `subject` + `bodyType`) or `SMS` (body-only). Starts in `DRAFT` status. Body must contain the `{{code}}` placeholder.
1528
+ *
1529
+ * Requires permission: `twofa_templates.write`.
1530
+ *
1531
+ * **Plan**: Requires the `twofa` capability — included in the **All Services** plan.
1532
+ */
1533
+ static createTwofaTemplate(options) {
1534
+ return (options?.client ?? client).post({
1535
+ security: [
1536
+ {
1537
+ name: "x-access-key-id",
1538
+ type: "apiKey"
1539
+ },
1540
+ {
1541
+ name: "x-secret-access-key",
1542
+ type: "apiKey"
1543
+ }
1544
+ ],
1545
+ url: "/twofa/templates",
1546
+ ...options,
1547
+ headers: {
1548
+ "Content-Type": "application/json",
1549
+ ...options?.headers
1550
+ }
1551
+ });
1552
+ }
1553
+ /**
1554
+ * Delete template
1555
+ *
1556
+ * Delete a template. Cannot delete while in `PENDING_REVIEW` status.
1557
+ *
1558
+ * Requires permission: `twofa_templates.write`.
1559
+ *
1560
+ * **Plan**: Requires the `twofa` capability — included in the **All Services** plan.
1561
+ */
1562
+ static deleteTwofaTemplate(options) {
1563
+ return (options.client ?? client).delete({
1564
+ security: [
1565
+ {
1566
+ name: "x-access-key-id",
1567
+ type: "apiKey"
1568
+ },
1569
+ {
1570
+ name: "x-secret-access-key",
1571
+ type: "apiKey"
1572
+ }
1573
+ ],
1574
+ url: "/twofa/templates/{id}",
1575
+ ...options
1576
+ });
1577
+ }
1578
+ /**
1579
+ * Get template
1580
+ *
1581
+ * Get a single template by ID.
1582
+ *
1583
+ * Requires permission: `twofa_templates.read`.
1584
+ *
1585
+ * **Plan**: Requires the `twofa` capability — included in the **All Services** plan.
1586
+ */
1587
+ static getTwofaTemplate(options) {
1588
+ return (options.client ?? client).get({
1589
+ security: [
1590
+ {
1591
+ name: "x-access-key-id",
1592
+ type: "apiKey"
1593
+ },
1594
+ {
1595
+ name: "x-secret-access-key",
1596
+ type: "apiKey"
1597
+ }
1598
+ ],
1599
+ url: "/twofa/templates/{id}",
1600
+ ...options
1601
+ });
1602
+ }
1603
+ /**
1604
+ * Update template
1605
+ *
1606
+ * Update a template. The `channel` field must match the existing template — channel cannot be changed. Only editable in `DRAFT` or `REJECTED` status. Editing resets status to `DRAFT`.
1607
+ *
1608
+ * Requires permission: `twofa_templates.write`.
1609
+ *
1610
+ * **Plan**: Requires the `twofa` capability — included in the **All Services** plan.
1611
+ */
1612
+ static updateTwofaTemplate(options) {
1613
+ return (options.client ?? client).patch({
1614
+ security: [
1615
+ {
1616
+ name: "x-access-key-id",
1617
+ type: "apiKey"
1618
+ },
1619
+ {
1620
+ name: "x-secret-access-key",
1621
+ type: "apiKey"
1622
+ }
1623
+ ],
1624
+ url: "/twofa/templates/{id}",
1625
+ ...options,
1626
+ headers: {
1627
+ "Content-Type": "application/json",
1628
+ ...options.headers
1629
+ }
1630
+ });
1631
+ }
1632
+ /**
1633
+ * Submit for review
1634
+ *
1635
+ * Submit a `DRAFT` or `REJECTED` template for admin review. Once submitted, edits are locked until the template is approved or rejected.
1636
+ *
1637
+ * Requires permission: `twofa_templates.write`.
1638
+ *
1639
+ * **Plan**: Requires the `twofa` capability — included in the **All Services** plan.
1640
+ *
1641
+ * **Approval flow**: `DRAFT` → `PENDING_REVIEW` → `APPROVED` or `REJECTED`. Only `APPROVED` templates can be used in verification API calls.
1642
+ */
1643
+ static submitTwofaTemplate(options) {
1644
+ return (options.client ?? client).post({
1645
+ security: [
1646
+ {
1647
+ name: "x-access-key-id",
1648
+ type: "apiKey"
1649
+ },
1650
+ {
1651
+ name: "x-secret-access-key",
1652
+ type: "apiKey"
1653
+ }
1654
+ ],
1655
+ url: "/twofa/templates/{id}/submit",
1656
+ ...options
1657
+ });
1658
+ }
1659
+ };
1660
+ var Quotas = class {
1661
+ /**
1662
+ * List account quotas
1663
+ *
1664
+ * Get all rate limits and quotas for the account. Shows both defaults and any admin-set overrides.
1665
+ *
1666
+ * Requires permission: `quotas.read`.
1667
+ */
1668
+ static listQuotas(options) {
1669
+ return (options?.client ?? client).get({
1670
+ security: [
1671
+ {
1672
+ name: "x-access-key-id",
1673
+ type: "apiKey"
1674
+ },
1675
+ {
1676
+ name: "x-secret-access-key",
1677
+ type: "apiKey"
1678
+ }
1679
+ ],
1680
+ url: "/quotas",
1681
+ ...options
1682
+ });
1683
+ }
1684
+ /**
1685
+ * List increase requests
1686
+ *
1687
+ * List all quota increase requests for the account.
1688
+ *
1689
+ * Requires permission: `quotas.read`.
1690
+ */
1691
+ static listQuotaIncreaseRequests(options) {
1692
+ return (options?.client ?? client).get({
1693
+ security: [
1694
+ {
1695
+ name: "x-access-key-id",
1696
+ type: "apiKey"
1697
+ },
1698
+ {
1699
+ name: "x-secret-access-key",
1700
+ type: "apiKey"
1701
+ }
1702
+ ],
1703
+ url: "/quotas/increase-requests",
1704
+ ...options
1705
+ });
1706
+ }
1707
+ /**
1708
+ * Request quota increase
1709
+ *
1710
+ * Submit a request to increase a specific quota. Only one pending request per resource/action/window is allowed. The requested limit must exceed the current limit.
1711
+ *
1712
+ * Requires permission: `quotas.request_increase`.
1713
+ *
1714
+ * Admin will review and either approve (automatically applies the new limit) or reject (with a note).
1715
+ */
1716
+ static createQuotaIncreaseRequest(options) {
1717
+ return (options?.client ?? client).post({
1718
+ security: [
1719
+ {
1720
+ name: "x-access-key-id",
1721
+ type: "apiKey"
1722
+ },
1723
+ {
1724
+ name: "x-secret-access-key",
1725
+ type: "apiKey"
1726
+ }
1727
+ ],
1728
+ url: "/quotas/increase-requests",
1729
+ ...options,
1730
+ headers: {
1731
+ "Content-Type": "application/json",
1732
+ ...options?.headers
1733
+ }
1734
+ });
1735
+ }
1736
+ /**
1737
+ * Get increase request
1738
+ *
1739
+ * Get a single quota increase request by ID.
1740
+ *
1741
+ * Requires permission: `quotas.read`.
1742
+ */
1743
+ static getQuotaIncreaseRequest(options) {
1744
+ return (options?.client ?? client).get({
1745
+ security: [
1746
+ {
1747
+ name: "x-access-key-id",
1748
+ type: "apiKey"
1749
+ },
1750
+ {
1751
+ name: "x-secret-access-key",
1752
+ type: "apiKey"
1753
+ }
1754
+ ],
1755
+ url: "/quotas/increase-requests/{id}",
1756
+ ...options
1757
+ });
1758
+ }
1759
+ };
1760
+ var MessagingProfiles = class {
1761
+ /**
1762
+ * List messaging profiles
1763
+ *
1764
+ * List all messaging profiles for the account. Supports pagination and search.
1765
+ *
1766
+ * Requires permission: `messaging_profiles.read`.
1767
+ *
1768
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1769
+ */
1770
+ static listMessagingProfiles(options) {
1771
+ return (options?.client ?? client).get({
1772
+ security: [
1773
+ {
1774
+ name: "x-access-key-id",
1775
+ type: "apiKey"
1776
+ },
1777
+ {
1778
+ name: "x-secret-access-key",
1779
+ type: "apiKey"
1780
+ }
1781
+ ],
1782
+ url: "/messaging-profiles",
1783
+ ...options
1784
+ });
1785
+ }
1786
+ /**
1787
+ * Create messaging profile
1788
+ *
1789
+ * Create a new messaging profile. Default allowed destination is US.
1790
+ *
1791
+ * Requires permission: `messaging_profiles.write`.
1792
+ *
1793
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1794
+ */
1795
+ static createMessagingProfile(options) {
1796
+ return (options?.client ?? client).post({
1797
+ security: [
1798
+ {
1799
+ name: "x-access-key-id",
1800
+ type: "apiKey"
1801
+ },
1802
+ {
1803
+ name: "x-secret-access-key",
1804
+ type: "apiKey"
1805
+ }
1806
+ ],
1807
+ url: "/messaging-profiles",
1808
+ ...options,
1809
+ headers: {
1810
+ "Content-Type": "application/json",
1811
+ ...options?.headers
1812
+ }
1813
+ });
1814
+ }
1815
+ /**
1816
+ * Delete messaging profile
1817
+ *
1818
+ * Delete a messaging profile. All phone numbers must be unassigned first — deletion is blocked while numbers are still associated.
1819
+ *
1820
+ * Requires permission: `messaging_profiles.write`.
1821
+ *
1822
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1823
+ */
1824
+ static deleteMessagingProfile(options) {
1825
+ return (options?.client ?? client).delete({
1826
+ security: [
1827
+ {
1828
+ name: "x-access-key-id",
1829
+ type: "apiKey"
1830
+ },
1831
+ {
1832
+ name: "x-secret-access-key",
1833
+ type: "apiKey"
1834
+ }
1835
+ ],
1836
+ url: "/messaging-profiles/{id}",
1837
+ ...options
1838
+ });
1839
+ }
1840
+ /**
1841
+ * Get messaging profile
1842
+ *
1843
+ * Get a messaging profile by ID with full configuration.
1844
+ *
1845
+ * Requires permission: `messaging_profiles.read`.
1846
+ *
1847
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1848
+ */
1849
+ static getMessagingProfile(options) {
1850
+ return (options?.client ?? client).get({
1851
+ security: [
1852
+ {
1853
+ name: "x-access-key-id",
1854
+ type: "apiKey"
1855
+ },
1856
+ {
1857
+ name: "x-secret-access-key",
1858
+ type: "apiKey"
1859
+ }
1860
+ ],
1861
+ url: "/messaging-profiles/{id}",
1862
+ ...options
1863
+ });
1864
+ }
1865
+ /**
1866
+ * Update messaging profile
1867
+ *
1868
+ * Update a messaging profile. Changes to auto-response keywords are applied automatically.
1869
+ *
1870
+ * Requires permission: `messaging_profiles.write`.
1871
+ *
1872
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1873
+ */
1874
+ static updateMessagingProfile(options) {
1875
+ return (options?.client ?? client).put({
1876
+ security: [
1877
+ {
1878
+ name: "x-access-key-id",
1879
+ type: "apiKey"
1880
+ },
1881
+ {
1882
+ name: "x-secret-access-key",
1883
+ type: "apiKey"
1884
+ }
1885
+ ],
1886
+ url: "/messaging-profiles/{id}",
1887
+ ...options,
1888
+ headers: {
1889
+ "Content-Type": "application/json",
1890
+ ...options?.headers
1891
+ }
1892
+ });
1893
+ }
1894
+ /**
1895
+ * Assign numbers to profile
1896
+ *
1897
+ * Assign phone numbers to a messaging profile. Numbers that fail to assign are skipped and reported in the response.
1898
+ *
1899
+ * Requires permission: `messaging_profiles.write`.
1900
+ *
1901
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1902
+ */
1903
+ static assignMessagingProfileNumbers(options) {
1904
+ return (options?.client ?? client).post({
1905
+ security: [
1906
+ {
1907
+ name: "x-access-key-id",
1908
+ type: "apiKey"
1909
+ },
1910
+ {
1911
+ name: "x-secret-access-key",
1912
+ type: "apiKey"
1913
+ }
1914
+ ],
1915
+ url: "/messaging-profiles/{id}/assign",
1916
+ ...options,
1917
+ headers: {
1918
+ "Content-Type": "application/json",
1919
+ ...options?.headers
1920
+ }
1921
+ });
1922
+ }
1923
+ /**
1924
+ * Unassign numbers from profile
1925
+ *
1926
+ * Unassign phone numbers from a messaging profile. Numbers revert to `UNASSIGNED` status.
1927
+ *
1928
+ * Requires permission: `messaging_profiles.write`.
1929
+ *
1930
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1931
+ */
1932
+ static unassignMessagingProfileNumbers(options) {
1933
+ return (options?.client ?? client).post({
1934
+ security: [
1935
+ {
1936
+ name: "x-access-key-id",
1937
+ type: "apiKey"
1938
+ },
1939
+ {
1940
+ name: "x-secret-access-key",
1941
+ type: "apiKey"
1942
+ }
1943
+ ],
1944
+ url: "/messaging-profiles/{id}/unassign",
1945
+ ...options,
1946
+ headers: {
1947
+ "Content-Type": "application/json",
1948
+ ...options?.headers
1949
+ }
1950
+ });
1951
+ }
1952
+ };
1953
+ var PhoneNumbers = class {
1954
+ /**
1955
+ * Search available numbers
1956
+ *
1957
+ * Search for available phone numbers to purchase. Rate limit headers are included: `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`.
1958
+ *
1959
+ * Requires permission: `numbers.search`.
1960
+ *
1961
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1962
+ *
1963
+ * **Rate limit**: 30 searches/min per account.
1964
+ */
1965
+ static searchPhoneNumbers(options) {
1966
+ return (options?.client ?? client).get({
1967
+ security: [
1968
+ {
1969
+ name: "x-access-key-id",
1970
+ type: "apiKey"
1971
+ },
1972
+ {
1973
+ name: "x-secret-access-key",
1974
+ type: "apiKey"
1975
+ }
1976
+ ],
1977
+ url: "/phone-numbers/search",
1978
+ ...options
1979
+ });
1980
+ }
1981
+ /**
1982
+ * List phone numbers
1983
+ *
1984
+ * List all phone numbers for the account. Supports filtering by status, capabilities, messaging profile, tags, and country.
1985
+ *
1986
+ * Requires permission: `numbers.read`.
1987
+ *
1988
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
1989
+ */
1990
+ static listPhoneNumbers(options) {
1991
+ return (options?.client ?? client).get({
1992
+ security: [
1993
+ {
1994
+ name: "x-access-key-id",
1995
+ type: "apiKey"
1996
+ },
1997
+ {
1998
+ name: "x-secret-access-key",
1999
+ type: "apiKey"
2000
+ }
2001
+ ],
2002
+ url: "/phone-numbers",
2003
+ ...options
2004
+ });
2005
+ }
2006
+ /**
2007
+ * Get phone number
2008
+ *
2009
+ * Get a single phone number by ID.
2010
+ *
2011
+ * Requires permission: `numbers.read`.
2012
+ *
2013
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
2014
+ */
2015
+ static getPhoneNumber(options) {
2016
+ return (options?.client ?? client).get({
2017
+ security: [
2018
+ {
2019
+ name: "x-access-key-id",
2020
+ type: "apiKey"
2021
+ },
2022
+ {
2023
+ name: "x-secret-access-key",
2024
+ type: "apiKey"
2025
+ }
2026
+ ],
2027
+ url: "/phone-numbers/{id}",
2028
+ ...options
2029
+ });
2030
+ }
2031
+ /**
2032
+ * Update phone number
2033
+ *
2034
+ * Update a phone number (messaging profile assignment, tags). If a messaging profile assignment fails, the update is rejected.
2035
+ *
2036
+ * Requires permission: `numbers.write`.
2037
+ *
2038
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
2039
+ */
2040
+ static updatePhoneNumber(options) {
2041
+ return (options?.client ?? client).put({
2042
+ security: [
2043
+ {
2044
+ name: "x-access-key-id",
2045
+ type: "apiKey"
2046
+ },
2047
+ {
2048
+ name: "x-secret-access-key",
2049
+ type: "apiKey"
2050
+ }
2051
+ ],
2052
+ url: "/phone-numbers/{id}",
2053
+ ...options,
2054
+ headers: {
2055
+ "Content-Type": "application/json",
2056
+ ...options?.headers
2057
+ }
2058
+ });
2059
+ }
2060
+ /**
2061
+ * Bulk assign to profile
2062
+ *
2063
+ * Assign multiple phone numbers to a messaging profile. Numbers that fail to assign are skipped and reported in the response.
2064
+ *
2065
+ * Requires permission: `numbers.write`.
2066
+ *
2067
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
2068
+ */
2069
+ static bulkAssignPhoneNumbers(options) {
2070
+ return (options?.client ?? client).post({
2071
+ security: [
2072
+ {
2073
+ name: "x-access-key-id",
2074
+ type: "apiKey"
2075
+ },
2076
+ {
2077
+ name: "x-secret-access-key",
2078
+ type: "apiKey"
2079
+ }
2080
+ ],
2081
+ url: "/phone-numbers/bulk-assign",
2082
+ ...options,
2083
+ headers: {
2084
+ "Content-Type": "application/json",
2085
+ ...options?.headers
2086
+ }
2087
+ });
2088
+ }
2089
+ /**
2090
+ * Bulk unassign from profile
2091
+ *
2092
+ * Unassign multiple phone numbers from their messaging profiles. Numbers revert to `UNASSIGNED` status.
2093
+ *
2094
+ * Requires permission: `numbers.write`.
2095
+ *
2096
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
2097
+ */
2098
+ static bulkUnassignPhoneNumbers(options) {
2099
+ return (options?.client ?? client).post({
2100
+ security: [
2101
+ {
2102
+ name: "x-access-key-id",
2103
+ type: "apiKey"
2104
+ },
2105
+ {
2106
+ name: "x-secret-access-key",
2107
+ type: "apiKey"
2108
+ }
2109
+ ],
2110
+ url: "/phone-numbers/bulk-unassign",
2111
+ ...options,
2112
+ headers: {
2113
+ "Content-Type": "application/json",
2114
+ ...options?.headers
2115
+ }
2116
+ });
2117
+ }
2118
+ };
2119
+ var PhoneOrders = class {
2120
+ /**
2121
+ * List phone orders
2122
+ *
2123
+ * List all phone number orders. Supports pagination and filtering by status.
2124
+ *
2125
+ * Requires permission: `numbers.read`.
2126
+ *
2127
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
2128
+ */
2129
+ static listPhoneOrders(options) {
2130
+ return (options?.client ?? client).get({
2131
+ security: [
2132
+ {
2133
+ name: "x-access-key-id",
2134
+ type: "apiKey"
2135
+ },
2136
+ {
2137
+ name: "x-secret-access-key",
2138
+ type: "apiKey"
2139
+ }
2140
+ ],
2141
+ url: "/phone-orders",
2142
+ ...options
2143
+ });
2144
+ }
2145
+ /**
2146
+ * Place phone number order
2147
+ *
2148
+ * Purchase phone numbers. Creates a PhoneOrder with items, provisions the numbers, charges the account balance, and optionally assigns to a messaging profile.
2149
+ *
2150
+ * Requires permission: `numbers.buy`.
2151
+ *
2152
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
2153
+ */
2154
+ static createPhoneOrder(options) {
2155
+ return (options?.client ?? client).post({
2156
+ security: [
2157
+ {
2158
+ name: "x-access-key-id",
2159
+ type: "apiKey"
2160
+ },
2161
+ {
2162
+ name: "x-secret-access-key",
2163
+ type: "apiKey"
2164
+ }
2165
+ ],
2166
+ url: "/phone-orders",
2167
+ ...options,
2168
+ headers: {
2169
+ "Content-Type": "application/json",
2170
+ ...options?.headers
2171
+ }
2172
+ });
2173
+ }
2174
+ /**
2175
+ * Get phone order
2176
+ *
2177
+ * Get a single phone order with items.
2178
+ *
2179
+ * Requires permission: `numbers.read`.
2180
+ *
2181
+ * **Plan**: Requires the `sms` capability — included in the **All Services** plan.
2182
+ */
2183
+ static getPhoneOrder(options) {
2184
+ return (options?.client ?? client).get({
2185
+ security: [
2186
+ {
2187
+ name: "x-access-key-id",
2188
+ type: "apiKey"
2189
+ },
2190
+ {
2191
+ name: "x-secret-access-key",
2192
+ type: "apiKey"
2193
+ }
2194
+ ],
2195
+ url: "/phone-orders/{id}",
2196
+ ...options
2197
+ });
2198
+ }
2199
+ };
2200
+
2201
+ // src/index.ts
2202
+ function buildConfig(options) {
2203
+ const { accessKeyId, secretAccessKey, baseUrl, fetch, headers } = options;
2204
+ const config = {
2205
+ baseUrl: baseUrl ?? "https://api.blocx.com",
2206
+ headers: {
2207
+ "x-access-key-id": accessKeyId,
2208
+ "x-secret-access-key": secretAccessKey,
2209
+ ...headers
2210
+ }
2211
+ };
2212
+ if (fetch) config.fetch = fetch;
2213
+ return config;
2214
+ }
2215
+ function createBlocxClient(options) {
2216
+ const config = buildConfig(options);
2217
+ const instance = createClient(config);
2218
+ return {
2219
+ client: instance,
2220
+ setDefault() {
2221
+ client.setConfig(config);
2222
+ return instance;
2223
+ }
2224
+ };
2225
+ }
2226
+
2227
+ export { Balance, Brands, Campaigns, Compliance, Email, FaTemplates, FaVerifications, Messaging, MessagingProfiles, PhoneNumbers, PhoneOrders, Quotas, createBlocxClient };
2228
+ //# sourceMappingURL=index.js.map
2229
+ //# sourceMappingURL=index.js.map