@seamapi/http 0.10.2 → 0.11.1

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
@@ -65,6 +65,12 @@ var getApiKeyFromEnv = (options) => {
65
65
  if ("clientSessionToken" in options && options.clientSessionToken != null) {
66
66
  return null;
67
67
  }
68
+ if ("consoleSessionToken" in options && options.consoleSessionToken != null) {
69
+ return null;
70
+ }
71
+ if ("personalAccessToken" in options && options.personalAccessToken != null) {
72
+ return null;
73
+ }
68
74
  return globalThis.process?.env?.SEAM_API_KEY;
69
75
  };
70
76
  var getEndpointFromEnv = () => {
@@ -515,6 +521,78 @@ var getRequestId = (err) => {
515
521
  return requestId;
516
522
  };
517
523
 
524
+ // src/lib/params-serializer.ts
525
+ var paramsSerializer = (params) => {
526
+ const searchParams = new URLSearchParams();
527
+ for (const [name, value] of Object.entries(params)) {
528
+ if (value == null)
529
+ continue;
530
+ if (Array.isArray(value)) {
531
+ if (value.length === 0)
532
+ searchParams.set(name, "");
533
+ if (value.length === 1 && value[0] === "") {
534
+ throw new UnserializableParamError(
535
+ name,
536
+ `is a single element array containing the empty string which is unsupported because it serializes to the empty array`
537
+ );
538
+ }
539
+ for (const v of value) {
540
+ searchParams.append(name, serialize(name, v));
541
+ }
542
+ continue;
543
+ }
544
+ searchParams.set(name, serialize(name, value));
545
+ }
546
+ searchParams.sort();
547
+ return searchParams.toString();
548
+ };
549
+ var serialize = (k, v) => {
550
+ if (typeof v === "string")
551
+ return v.toString();
552
+ if (typeof v === "number")
553
+ return v.toString();
554
+ if (typeof v === "bigint")
555
+ return v.toString();
556
+ if (typeof v === "boolean")
557
+ return v.toString();
558
+ throw new UnserializableParamError(k, `is a ${typeof v}`);
559
+ };
560
+ var UnserializableParamError = class extends Error {
561
+ constructor(name, message) {
562
+ super(`Could not serialize parameter: '${name}' ${message}`);
563
+ this.name = this.constructor.name;
564
+ Error.captureStackTrace(this, this.constructor);
565
+ }
566
+ };
567
+
568
+ // src/lib/seam/connect/client.ts
569
+ var createClient = (options) => {
570
+ const client = axios__default.default.create({
571
+ paramsSerializer,
572
+ ...options.axiosOptions
573
+ });
574
+ axiosBetterStacktrace__default.default(axios__default.default);
575
+ axiosRetry__default.default(client, {
576
+ retries: 2,
577
+ retryDelay: axiosRetry.exponentialDelay,
578
+ ...options.axiosRetryOptions
579
+ });
580
+ client.interceptors.response.use(void 0, errorInterceptor);
581
+ return client;
582
+ };
583
+
584
+ // src/lib/seam/connect/openapi.ts
585
+ var getOpenapiSchema = async (endpoint = defaultEndpoint) => {
586
+ const client = createClient({
587
+ axiosOptions: {
588
+ baseURL: endpoint,
589
+ headers: sdkHeaders
590
+ }
591
+ });
592
+ const { data } = await client.get("/openapi.json");
593
+ return data;
594
+ };
595
+
518
596
  // src/lib/seam/connect/resolve-action-attempt.ts
519
597
  var resolveActionAttempt = async (actionAttempt, actionAttempts, { timeout = 5e3, pollingInterval = 500 }) => {
520
598
  let timeoutRef;
@@ -590,66 +668,6 @@ var SeamActionAttemptTimeoutError = class extends SeamActionAttemptError {
590
668
  var isSuccessfulActionAttempt = (actionAttempt) => actionAttempt.status === "success";
591
669
  var isFailedActionAttempt = (actionAttempt) => actionAttempt.status === "error";
592
670
 
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
671
  // src/lib/seam/connect/routes/client-sessions.ts
654
672
  var SeamHttpClientSessions = class _SeamHttpClientSessions {
655
673
  constructor(apiKeyOrOptions = {}) {
@@ -3333,6 +3351,7 @@ exports.SeamHttpWebhooks = SeamHttpWebhooks;
3333
3351
  exports.SeamHttpWorkspaces = SeamHttpWorkspaces;
3334
3352
  exports.UnserializableParamError = UnserializableParamError;
3335
3353
  exports.errorInterceptor = errorInterceptor;
3354
+ exports.getOpenapiSchema = getOpenapiSchema;
3336
3355
  exports.isSeamActionAttemptError = isSeamActionAttemptError;
3337
3356
  exports.isSeamActionAttemptFailedError = isSeamActionAttemptFailedError;
3338
3357
  exports.isSeamActionAttemptTimeoutError = isSeamActionAttemptTimeoutError;