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