@seamapi/http 0.10.2 → 0.11.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/connect.cjs CHANGED
@@ -515,6 +515,78 @@ var getRequestId = (err) => {
515
515
  return requestId;
516
516
  };
517
517
 
518
+ // src/lib/params-serializer.ts
519
+ var paramsSerializer = (params) => {
520
+ const searchParams = new URLSearchParams();
521
+ for (const [name, value] of Object.entries(params)) {
522
+ if (value == null)
523
+ continue;
524
+ if (Array.isArray(value)) {
525
+ if (value.length === 0)
526
+ searchParams.set(name, "");
527
+ if (value.length === 1 && value[0] === "") {
528
+ throw new UnserializableParamError(
529
+ name,
530
+ `is a single element array containing the empty string which is unsupported because it serializes to the empty array`
531
+ );
532
+ }
533
+ for (const v of value) {
534
+ searchParams.append(name, serialize(name, v));
535
+ }
536
+ continue;
537
+ }
538
+ searchParams.set(name, serialize(name, value));
539
+ }
540
+ searchParams.sort();
541
+ return searchParams.toString();
542
+ };
543
+ var serialize = (k, v) => {
544
+ if (typeof v === "string")
545
+ return v.toString();
546
+ if (typeof v === "number")
547
+ return v.toString();
548
+ if (typeof v === "bigint")
549
+ return v.toString();
550
+ if (typeof v === "boolean")
551
+ return v.toString();
552
+ throw new UnserializableParamError(k, `is a ${typeof v}`);
553
+ };
554
+ var UnserializableParamError = class extends Error {
555
+ constructor(name, message) {
556
+ super(`Could not serialize parameter: '${name}' ${message}`);
557
+ this.name = this.constructor.name;
558
+ Error.captureStackTrace(this, this.constructor);
559
+ }
560
+ };
561
+
562
+ // src/lib/seam/connect/client.ts
563
+ var createClient = (options) => {
564
+ const client = axios__default.default.create({
565
+ paramsSerializer,
566
+ ...options.axiosOptions
567
+ });
568
+ axiosBetterStacktrace__default.default(axios__default.default);
569
+ axiosRetry__default.default(client, {
570
+ retries: 2,
571
+ retryDelay: axiosRetry.exponentialDelay,
572
+ ...options.axiosRetryOptions
573
+ });
574
+ client.interceptors.response.use(void 0, errorInterceptor);
575
+ return client;
576
+ };
577
+
578
+ // src/lib/seam/connect/openapi.ts
579
+ var getOpenapiSchema = async (endpoint = defaultEndpoint) => {
580
+ const client = createClient({
581
+ axiosOptions: {
582
+ baseURL: endpoint,
583
+ headers: sdkHeaders
584
+ }
585
+ });
586
+ const { data } = await client.get("/openapi.json");
587
+ return data;
588
+ };
589
+
518
590
  // src/lib/seam/connect/resolve-action-attempt.ts
519
591
  var resolveActionAttempt = async (actionAttempt, actionAttempts, { timeout = 5e3, pollingInterval = 500 }) => {
520
592
  let timeoutRef;
@@ -590,66 +662,6 @@ var SeamActionAttemptTimeoutError = class extends SeamActionAttemptError {
590
662
  var isSuccessfulActionAttempt = (actionAttempt) => actionAttempt.status === "success";
591
663
  var isFailedActionAttempt = (actionAttempt) => actionAttempt.status === "error";
592
664
 
593
- // src/lib/params-serializer.ts
594
- var paramsSerializer = (params) => {
595
- const searchParams = new URLSearchParams();
596
- for (const [name, value] of Object.entries(params)) {
597
- if (value == null)
598
- continue;
599
- if (Array.isArray(value)) {
600
- if (value.length === 0)
601
- searchParams.set(name, "");
602
- if (value.length === 1 && value[0] === "") {
603
- throw new UnserializableParamError(
604
- name,
605
- `is a single element array containing the empty string which is unsupported because it serializes to the empty array`
606
- );
607
- }
608
- for (const v of value) {
609
- searchParams.append(name, serialize(name, v));
610
- }
611
- continue;
612
- }
613
- searchParams.set(name, serialize(name, value));
614
- }
615
- searchParams.sort();
616
- return searchParams.toString();
617
- };
618
- var serialize = (k, v) => {
619
- if (typeof v === "string")
620
- return v.toString();
621
- if (typeof v === "number")
622
- return v.toString();
623
- if (typeof v === "bigint")
624
- return v.toString();
625
- if (typeof v === "boolean")
626
- return v.toString();
627
- throw new UnserializableParamError(k, `is a ${typeof v}`);
628
- };
629
- var UnserializableParamError = class extends Error {
630
- constructor(name, message) {
631
- super(`Could not serialize parameter: '${name}' ${message}`);
632
- this.name = this.constructor.name;
633
- Error.captureStackTrace(this, this.constructor);
634
- }
635
- };
636
-
637
- // src/lib/seam/connect/client.ts
638
- var createClient = (options) => {
639
- const client = axios__default.default.create({
640
- paramsSerializer,
641
- ...options.axiosOptions
642
- });
643
- axiosBetterStacktrace__default.default(axios__default.default);
644
- axiosRetry__default.default(client, {
645
- retries: 2,
646
- retryDelay: axiosRetry.exponentialDelay,
647
- ...options.axiosRetryOptions
648
- });
649
- client.interceptors.response.use(void 0, errorInterceptor);
650
- return client;
651
- };
652
-
653
665
  // src/lib/seam/connect/routes/client-sessions.ts
654
666
  var SeamHttpClientSessions = class _SeamHttpClientSessions {
655
667
  constructor(apiKeyOrOptions = {}) {
@@ -3333,6 +3345,7 @@ exports.SeamHttpWebhooks = SeamHttpWebhooks;
3333
3345
  exports.SeamHttpWorkspaces = SeamHttpWorkspaces;
3334
3346
  exports.UnserializableParamError = UnserializableParamError;
3335
3347
  exports.errorInterceptor = errorInterceptor;
3348
+ exports.getOpenapiSchema = getOpenapiSchema;
3336
3349
  exports.isSeamActionAttemptError = isSeamActionAttemptError;
3337
3350
  exports.isSeamActionAttemptFailedError = isSeamActionAttemptFailedError;
3338
3351
  exports.isSeamActionAttemptTimeoutError = isSeamActionAttemptTimeoutError;